int main( int argc, char *argv[] ) { int i; int argbase = 1; char *defines[64]; // max of 64 defines int numdefines = 0; if ( !Q_stricmp( argv[argbase],"-o" ) ) { func_filename = argv[argbase + 1]; func_filedesc = argv[argbase + 2]; argbase = 4; } if ( !Q_stricmp( argv[argbase],"-d" ) ) { i = 1; while ( Q_stricmp( argv[argbase + i],"-f" ) ) { defines[numdefines] = malloc( strlen( argv[argbase + i] ) + 1 ); strncpy( defines[numdefines], argv[argbase + i], strlen( argv[argbase + i] ) ); numdefines++; i++; } argbase += i + 1; } for ( i = argbase; i < argc; i++ ) { printf( "%d: %s\n", i, argv[i] ); GetFunctionNamesFromFile( argv[i], defines, numdefines ); } DumpReplaceFunctions(); }
void main( int argc, char *argv[] ) { WIN32_FIND_DATA filedata; HWND handle; int done; //, i; char *defines[64]; // max of 64 defines int numdefines = 0; if ( argc > 2 ) { int argi = 2; while ( argi != argc ) { if ( !Q_stricmp( argv[argi], "-d" ) ) { argi++; if ( argi == argc ) { Usage(); } defines[numdefines] = malloc( strlen( argv[argi] ) + 1 ); strncpy( defines[numdefines], argv[argi], strlen( argv[argi] ) ); defines[numdefines++][strlen( argv[argi++] )] = '\0'; } else if ( !Q_stricmp( argv[argi], "-o" ) ) { argi++; if ( argi + 2 > argc ) { Usage(); } func_filename = argv[argi++]; func_filedesc = argv[argi++]; } else { Usage(); } } } handle = FindFirstFile( argv[1], &filedata ); done = ( handle == INVALID_HANDLE_VALUE ); while ( !done ) { if ( !( filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) { // GetFunctionNamesFromFile( filedata.cFileName, defines, numdefines ); } //end if //find the next file done = !FindNextFile( handle, &filedata ); } //end while DumpReplaceFunctions(); while ( numdefines > 0 ) { numdefines--; free( defines[numdefines] ); } } //end of the function main
/* *nix version, let the shell do the pattern matching (that's what shells are for :-)) */ int main (int argc, char *argv[]) { int i, firstParm; int argbase = 1; char typeName[128]; qboolean typeExtract = false; qboolean firstParmSet = false; /* if ( argc < 2 ) Usage(); if ( !Q_stricmp(argv[1],"-o") ) { if ( argc < 5 ) { Usage (); } func_listfile = argv[2]; func_decsfile = argv[3]; argbase = 4; } */ // Knightmare- check for command line switches for (i=0; i<argc; i++) { if (!firstParmSet && argv[i][0] == '-') { firstParm = i; firstParmSet = true; } if ( !Q_stricmp(argv[i], "-t") && (i < argc-1) && (argv[i+1][0] != '-') ) { char buf[_MAX_PATH]; Com_sprintf (typeName, sizeof(typeName), argv[i+1]); printf("Data type to extract: %s\n", typeName); Com_sprintf (buf, sizeof(buf), "g_%s_list.h", typeName); func_listfile = strdup(buf); Com_sprintf (buf, sizeof(buf), "g_%s_decs.h", typeName); func_decsfile = strdup(buf); typeExtract = true; } else if ( !Q_stricmp(argv[i], "-o") && (i < argc-1) && (argv[i+1][0] != '-') ) { func_listfile = argv[i+1]; printf("Pointer table list file: %s\n", func_listfile); if ( (i < argc-2) && (argv[i+2][0] != '-') ) { func_decsfile = argv[i+2]; printf("Pointer list decs file: %s\n", func_decsfile); } } else if (!Q_stricmp(argv[i], "-d")) { printf("Define option not yet implemented.\n"); } } if (argc < 2 || (firstParmSet && firstParm < 1)) Usage (); // end Knightmare // for ( i = argbase; i < argc; i++ ) for ( i = argbase; i < firstParm; i++ ) { printf( "%d: %s\n", i, argv[i] ); if (typeExtract) GetTypeNamesFromFile (argv[i], typeName); else GetFunctionNamesFromFile (argv[i]); } if (typeExtract) DumpReplaceFunctions (typeName); else DumpReplaceFunctions (NULL); return 0; }
void main (int argc, char *argv[]) { WIN32_FIND_DATA filedata; HWND handle; int i, firstParm, done; char typeName[128]; qboolean typeExtract = false; qboolean firstParmSet = false; // if ( argc < 2 ) // Usage (); // Knightmare- check for command line switches for (i=0; i<argc; i++) { if (!firstParmSet && argv[i][0] == '-') { firstParm = i; firstParmSet = true; } if ( !Q_stricmp(argv[i], "-t") && (i < argc-1) && (argv[i+1][0] != '-') ) { char buf[_MAX_PATH]; Com_sprintf (typeName, sizeof(typeName), argv[i+1]); printf("Data type to extract: %s\n", typeName); Com_sprintf (buf, sizeof(buf), "g_%s_list.h", typeName); func_listfile = strdup(buf); Com_sprintf (buf, sizeof(buf), "g_%s_decs.h", typeName); func_decsfile = strdup(buf); typeExtract = true; } else if ( !Q_stricmp(argv[i], "-o") && (i < argc-1) && (argv[i+1][0] != '-') ) { func_listfile = argv[i+1]; printf("Pointer table list file: %s\n", func_listfile); if ( (i < argc-2) && (argv[i+2][0] != '-') ) { func_decsfile = argv[i+2]; printf("Pointer list decs file: %s\n", func_decsfile); } } else if (!Q_stricmp(argv[i], "-d")) { printf("Define option not yet implemented.\n"); } } if (argc < 2 || (firstParmSet && firstParm < 1)) Usage (); // end Knightmare handle = FindFirstFile (argv[1], &filedata); done = (handle == INVALID_HANDLE_VALUE); while (!done) { if ( !(filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) { if (typeExtract) GetTypeNamesFromFile (filedata.cFileName, typeName); else GetFunctionNamesFromFile (filedata.cFileName); } //find the next file done = !FindNextFile (handle, &filedata); } if (typeExtract) DumpReplaceFunctions (typeName); else DumpReplaceFunctions (NULL); return 0; }