home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MAKEMB.ZIP / MAKEMB.C next >
C/C++ Source or Header  |  1990-09-08  |  1KB  |  46 lines

  1. /*  Builds the alc.mb file from alcmsg.txt.  Actually, redirection of standard
  2.     input and output is used so any other combination of input and output can
  3.     be handled. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <ctype.h>
  8. #include <string.h>
  9.  
  10. char
  11.     line[150],
  12.     prefix[4],
  13.     pattern[11];
  14.  
  15.  
  16. void main(int argc, char *argv[])
  17. {
  18.     int
  19.         i,
  20.         c;
  21.     if (argc < 3)
  22.     {
  23.         fprintf(stderr,"Usage:    makemb outfile.exe infile.msg <msgtxt.src >msgbind.inp");
  24.         exit(1);
  25.     }
  26.     prefix[0] = 0;
  27.     while (gets(line) != NULL && prefix[0] == 0)
  28.     {
  29.         if (strlen(line) == 3)
  30.             if (isalpha(line[0]) && isalpha(line[1]) && isalpha(line[2]))
  31.                 strcpy(prefix,line);
  32.     }
  33.     strcpy(pattern,prefix);
  34.     strcat(pattern,"%4d%c:");
  35.     putchar('>');
  36.     puts(argv[1]);
  37.     putchar('<');
  38.     puts(argv[2]);
  39.     while(gets(line) != NULL)
  40.     {
  41.         if (sscanf(line, pattern, &i, &c) == 2)
  42.             if (line[8] == ':')
  43.                 printf("%s%04d\n",prefix,i);
  44.     }
  45. }
  46.