Annotation of mstools/samples/sdktools/mc/mc.c, revision 1.1

1.1     ! root        1: /*++
        !             2: 
        !             3: Copyright (c) 1991  Microsoft Corporation
        !             4: 
        !             5: Module Name:
        !             6: 
        !             7:     mc.c
        !             8: 
        !             9: Abstract:
        !            10: 
        !            11:     This is the main source file for the Win32 Message Compiler (MC)
        !            12: 
        !            13: --*/
        !            14: 
        !            15: #include "mc.h"
        !            16: 
        !            17: #include "windows.h"
        !            18: 
        !            19: 
        !            20: void
        !            21: ConvertAppToOem( unsigned argc, char* argv[] )
        !            22: /*++
        !            23: 
        !            24: Routine Description:
        !            25: 
        !            26:     Converts the command line from ANSI to OEM, and force the app
        !            27:     to use OEM APIs
        !            28: 
        !            29: Arguments:
        !            30: 
        !            31:     argc - Standard C argument count.
        !            32: 
        !            33:     argv - Standard C argument strings.
        !            34: 
        !            35: Return Value:
        !            36: 
        !            37:     None.
        !            38: 
        !            39: --*/
        !            40: 
        !            41: {
        !            42:     unsigned i;
        !            43: 
        !            44:     for( i=0; i<argc; i++ ) {
        !            45:        CharToOem( argv[i], argv[i] );
        !            46:     }
        !            47:     SetFileApisToOEM();
        !            48: }
        !            49: 
        !            50: 
        !            51: 
        !            52: 
        !            53: void
        !            54: McPrintUsage( void )
        !            55: {
        !            56:     fprintf( stderr, "usage: MC [-?vws] [-h dirspec] [-r dirspec] filename.mc\n" );
        !            57:     fprintf( stderr, "       -? - displays this message\n" );
        !            58:     fprintf( stderr, "       -v - gives verbose output.\n" );
        !            59:     fprintf( stderr, "       -c - sets the Customer bit in all the message Ids.\n" );
        !            60:     fprintf( stderr, "       -d - numeric values in header file in decimal.\n" );
        !            61:     fprintf( stderr, "       -w - warns if message text contains non-OS/2 compatible inserts.\n" );
        !            62:     fprintf( stderr, "       -s - insert symbolic name as first line of each message.\n" );
        !            63:     fprintf( stderr, "       -h pathspec - gives the path of where to create the C include file\n" );
        !            64:     fprintf( stderr, "                     Default is .\\\n" );
        !            65:     fprintf( stderr, "       -r pathspec - gives the path of where to create the RC include file\n" );
        !            66:     fprintf( stderr, "                     and the binary message resource files it includes.\n" );
        !            67:     fprintf( stderr, "                     Default is .\\\n" );
        !            68:     fprintf( stderr, "       filename.mc - gives the names of a message text file\n" );
        !            69:     fprintf( stderr, "                     to compile.\n" );
        !            70: }
        !            71: 
        !            72: 
        !            73: int
        !            74: _CRTAPI1 main(
        !            75:     int argc,
        !            76:     char *argv[]
        !            77:     )
        !            78: {
        !            79:     char c, *s, *s1;
        !            80:     int ShowUsage;
        !            81: 
        !            82: 
        !            83:     ConvertAppToOem( argc, argv );
        !            84:     FacilityNames = NULL;
        !            85:     SeverityNames = NULL;
        !            86:     LanguageNames = NULL;
        !            87: 
        !            88:     MessageIdTypeName = NULL;
        !            89: 
        !            90:     CurrentFacilityName =
        !            91:     McAddName( &FacilityNames, "Application",  0x0, NULL );
        !            92:     CurrentSeverityName =
        !            93:     McAddName( &SeverityNames, "Success",       0x0, NULL );
        !            94: 
        !            95:     McAddName( &SeverityNames, "Informational", 0x1, NULL );
        !            96:     McAddName( &SeverityNames, "Warning",       0x2, NULL );
        !            97:     McAddName( &SeverityNames, "Error",         0x3, NULL );
        !            98: 
        !            99:     McAddName( &LanguageNames,
        !           100:                "English",
        !           101:                MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
        !           102:                "MSG00001"
        !           103:              );
        !           104: 
        !           105:     strcpy( HeaderFileName, ".\\" );
        !           106:     strcpy( RcInclFileName, ".\\" );
        !           107:     strcpy( BinaryMessageFileName, ".\\" );
        !           108:     MessageFileName[ 0 ] = '\0';
        !           109: 
        !           110:     McInitLexer();
        !           111: 
        !           112:     VerboseOutput = FALSE;
        !           113:     WarnOs2Compatible = FALSE;
        !           114:     GenerateDecimalValues = FALSE;
        !           115:     ShowUsage = FALSE;
        !           116:     while (--argc) {
        !           117:         s = *++argv;
        !           118:         if (*s == '-' || *s == '/') {
        !           119:             while (c = *++s) {
        !           120:                 switch( c ) {
        !           121:                 case '?':
        !           122:                     McPrintUsage();
        !           123:                     exit( 0 );
        !           124:                     break;
        !           125: 
        !           126:                 case 'c':
        !           127:                     CustomerMsgIdBit = 0x1 << 29;
        !           128:                     break;
        !           129: 
        !           130:                 case 'v':
        !           131:                     VerboseOutput = TRUE;
        !           132:                     break;
        !           133: 
        !           134:                 case 'd':
        !           135:                     GenerateDecimalValues = TRUE;
        !           136:                     break;
        !           137: 
        !           138:                 case 'w':
        !           139:                     WarnOs2Compatible = TRUE;
        !           140:                     break;
        !           141: 
        !           142:                 case 's':
        !           143:                     InsertSymbolicName = TRUE;
        !           144:                     break;
        !           145: 
        !           146:                 case 'h':
        !           147:                     if (--argc) {
        !           148:                         strcpy( s1 = HeaderFileName, *++argv );
        !           149:                         s1 += strlen( s1 ) - 1;
        !           150:                         if (*s1 != '\\' && *s1 != '/') {
        !           151:                             *++s1 = '\\';
        !           152:                             *++s1 = '\0';
        !           153:                             }
        !           154:                         }
        !           155:                     else {
        !           156:                         argc++;
        !           157:                         fprintf( stderr, "MC: missing argument for -%c switch\n", (USHORT)c );
        !           158:                         ShowUsage = TRUE;
        !           159:                         }
        !           160:                     break;
        !           161: 
        !           162:                 case 'r':
        !           163:                     if (--argc) {
        !           164:                         strcpy( s1 = RcInclFileName, *++argv );
        !           165:                         s1 += strlen( s1 ) - 1;
        !           166:                         if (*s1 != '\\' && *s1 != '/') {
        !           167:                             *++s1 = '\\';
        !           168:                             *++s1 = '\0';
        !           169:                             }
        !           170: 
        !           171:                         strcpy( BinaryMessageFileName, RcInclFileName );
        !           172:                         }
        !           173:                     else {
        !           174:                         argc++;
        !           175:                         fprintf( stderr, "MC: missing argument for -%c switch\n", (USHORT)c );
        !           176:                         ShowUsage = TRUE;
        !           177:                         }
        !           178:                     break;
        !           179: 
        !           180:                 default:
        !           181:                     fprintf( stderr, "MC: Invalid switch: %c\n", (USHORT)c );
        !           182:                     ShowUsage = TRUE;
        !           183:                     break;
        !           184:                     }
        !           185:                 }
        !           186:             }
        !           187:         else
        !           188:         if (strlen( MessageFileName )) {
        !           189:             fprintf( stderr, "MC: may only specify one message file to compile.\n" );
        !           190:             ShowUsage = TRUE;
        !           191:             }
        !           192:         else {
        !           193:             strcpy( MessageFileName, s );
        !           194:             }
        !           195:         }
        !           196: 
        !           197:     if (ShowUsage) {
        !           198:         McPrintUsage();
        !           199:         exit( 1 );
        !           200:         }
        !           201: 
        !           202:     ResultCode = 1;
        !           203:     if (McParseFile() && McBlockMessages() && McWriteBinaryFiles()) {
        !           204:         ResultCode = 0;
        !           205:         }
        !           206:     else {
        !           207:         McCloseInputFile();
        !           208:         McCloseOutputFiles();
        !           209:         }
        !           210: 
        !           211:     return( ResultCode );
        !           212: }
        !           213: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.