home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / makemb / makemb.c < prev    next >
C/C++ Source or Header  |  1992-04-14  |  2KB  |  83 lines

  1. /*== Set tab spacing to 4 ======================================================
  2.  
  3.     MAKEMB
  4.  
  5.     Builds a message bind directive file from a message source file. 
  6.  
  7.     If you plan on using the msgbind utility to bind a set of messages to
  8.     an executable file then you have to supply a message bind directive
  9.     file.  This program helps you by automating the construction of the
  10.     directive file.
  11.  
  12.     Two parameters are required.  The first is the name of the executable
  13.     file to which the message segment will be bound.  The second is the
  14.     name of the message file which was constructed by the mkmsgf utility.
  15.     Standard input should come from the message source file, i.e. the
  16.     one used as input to mkmsgf, and standard output should be sent to
  17.     the bind directive file.
  18.  
  19.     Example:
  20.  
  21.     You have a brilliant program, brill.exe to which you want to bind
  22.     a message segment.  The source for the messages is in message.src
  23.     and you used that as input to mkmsgf to build a binary message file
  24.     message.bin.
  25.  
  26.         makemb brill.exe message.bin <message.src >message.mb
  27.  
  28.     takes as input the same message source used by mkmsgf and generates
  29.     message.mb for input to msgbind.
  30.  
  31.     This makes the maintenance of message files a whole lot easier: you
  32.     can change the message source file and construct the bind directive
  33.     file automagically; otherwise every message numbering change would
  34.     have to be manually duplicated in the bind directive file.
  35.  
  36.  
  37.     Jon Saxton
  38.     February 1990
  39.  
  40. ==============================================================================*/
  41.  
  42. #include <stdio.h>
  43. #include <stdlib.h>
  44. #include <ctype.h>
  45. #include <string.h>
  46.  
  47. char
  48.     line[150],
  49.     prefix[4],
  50.     pattern[11];
  51.  
  52.  
  53. void main(int argc, char *argv[])
  54. {
  55.     int
  56.         i,
  57.         c;
  58.     if (argc < 3)
  59.     {
  60.         fprintf(stderr,"Usage:    makemb outfile.exe infile.msg <msgtxt.src >msgbind.inp");
  61.         exit(1);
  62.     }
  63.     prefix[0] = 0;
  64.     while (gets(line) != NULL && prefix[0] == 0)
  65.     {
  66.         if (strlen(line) == 3)
  67.             if (isalpha(line[0]) && isalpha(line[1]) && isalpha(line[2]))
  68.                 strcpy(prefix,line);
  69.     }
  70.     strcpy(pattern,prefix);
  71.     strcat(pattern,"%4d%c:");
  72.     putchar('>');
  73.     puts(argv[1]);
  74.     putchar('<');
  75.     puts(argv[2]);
  76.     while(gets(line) != NULL)
  77.     {
  78.         if (sscanf(line, pattern, &i, &c) == 2)
  79.             if (line[8] == ':')
  80.                 printf("%s%04d\n",prefix,i);
  81.     }
  82. }
  83.