#include <stdio.h>
#include <string.h>

void barf (char *msg)
{
  fprintf (stderr,"fatal error: %s",msg);
  abort ();
}


int main (int argc,char *argv[])
{
  int c;
  unsigned long i;
  char *s,buf[2048];
  if (fread (buf,1,2048,stdin) != 2048) barf ("no header");
  if (fwrite (buf,1,2048,stdout) != 2048) barf ("can't write header");
  while ((c = getchar ()) != EOF) {
    s = buf;
    *s++ = c;
    while ((s < (buf + 64)) && ((c = getchar ()) != EOF) && (c != '\n'))
      *s++ = c;
    if (c != '\n') barf ("bad message header line");
    *s++ = c;
    *s = '\0';
    if ((s = strchr (buf,',')) && (i = strtoul (s+1,&s,10)) && (*s == ';'))
      s += 9;
    else barf ("no size count");
    if (*s == '8') *s = '0';
    if (fputs (buf,stdout) == EOF) barf ("can't write msg header");
    while (i--) {
      if ((c = getchar ()) == EOF) barf ("bad msg");
      if ((putchar (c)) == EOF) barf ("can't write msg text");
    }
  }
  exit (0);
}
