Changeset 4402 for trunk/tools/impdef/ImpDef.cpp
- Timestamp:
- Oct 3, 2000, 7:42:41 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/impdef/ImpDef.cpp
r867 r4402 1 /* $Id: ImpDef.cpp,v 1. 3 1999-09-08 07:30:09bird Exp $ */1 /* $Id: ImpDef.cpp,v 1.4 2000-10-03 05:42:41 bird Exp $ */ 2 2 /* 3 3 * ImpDef - Create export file which use internal names and ordinals. … … 15 15 #include <stdlib.h> 16 16 #include "ImpDef.h" 17 #include "kFile.h" 17 18 #include "kFileFormatBase.h" 18 19 #include "kFileDef.h" … … 75 76 options.ulOrdStartInternalFunctions = atol(&argv[argi][3]); 76 77 if (options.ulOrdStartInternalFunctions == 0) 77 fprintf(stderr,"warning: internal functions starts at ordinal 0!\n");78 kFile::StdErr.printf("warning: internal functions starts at ordinal 0!\n"); 78 79 } 79 80 else 80 81 { 81 fprintf(stderr,"incorrect parameter -I:<ord>. (argi=%d, argv[argi]=%s)\n", argi, argv[argi]);82 kFile::StdErr.printf("incorrect parameter -I:<ord>. (argi=%d, argv[argi]=%s)\n", argi, argv[argi]); 82 83 fFatal = TRUE; 83 84 } … … 96 97 97 98 default: 98 fprintf(stderr,"incorrect parameter. (argi=%d, argv[argi]=%s)\n", argi, argv[argi]);99 kFile::StdErr.printf("incorrect parameter. (argi=%d, argv[argi]=%s)\n", argi, argv[argi]); 99 100 fFatal = TRUE; 100 101 break; … … 109 110 else 110 111 { 111 fprintf(stderr,"To many files are specified!\n");112 kFile::StdErr.printf("To many files are specified!\n"); 112 113 fFatal = TRUE; 113 114 } … … 119 120 { 120 121 fFatal = TRUE; 121 fprintf(stderr,"Missing input file.\n");122 kFile::StdErr.printf("Missing input file.\n"); 122 123 } 123 124 else if (pszOutput == NULL) 124 125 { 125 126 fFatal = TRUE; 126 fprintf(stderr,"Missing output file.\n");127 kFile::StdErr.printf("Missing output file.\n"); 127 128 } 128 129 … … 141 142 static void syntax(void) 142 143 { 143 printf("\n" 144 "ImpDef - Creates internal import definition file\n" 145 "------------------------------------------------\n" 146 "syntax: ImpDef.exe [-h|-?] [-S] <infile> <outfile>\n" 147 " -h or -? Syntax help. (this)\n" 148 " -F<[+]|-> Fix! Export int.name for int.functions. default: F+\n" 149 " -I:<ord> Start of internal function. default: I:%d\n" 150 " -O<[+]|-> Remove OS2 prefix on APIs. default: O-\n" 151 " -S<[+]|-> Similar to exported name. default: S+\n" 152 " infile Name of input file\n" 153 " outfile Name of output file\n" 154 "\n" 155 "Notes:\n" 156 " -S+ only works on stdcall functions (having '@' in the internal name).\n" 157 " -S+ takes the '_' and the '@..' parts from the internal name and adds it\n" 158 " to the exported name. This way the OS2 prefix is removed.\n" 159 " -O+ has no effect on stdcall functions when -S+ is set. -S+ has higher\n" 160 " precedence than -O+.\n" 161 " -O+ only removes the OS2 prefix from internal names.\n", 162 ORD_START_INTERNAL_FUNCTIONS 163 ); 144 kFile::StdOut.printf( 145 "\n" 146 "ImpDef - Creates internal import definition file\n" 147 "------------------------------------------------\n" 148 "syntax: ImpDef.exe [-h|-?] [-S] <infile> <outfile>\n" 149 " -h or -? Syntax help. (this)\n" 150 " -F<[+]|-> Fix! Export int.name for int.functions. default: F+\n" 151 " -I:<ord> Start of internal function. default: I:%d\n" 152 " -O<[+]|-> Remove OS2 prefix on APIs. default: O-\n" 153 " -S<[+]|-> Similar to exported name. default: S+\n" 154 " infile Name of input file\n" 155 " outfile Name of output file\n" 156 "\n" 157 "Notes:\n" 158 " -S+ only works on stdcall functions (having '@' in the internal name).\n" 159 " -S+ takes the '_' and the '@..' parts from the internal name and adds it\n" 160 " to the exported name. This way the OS2 prefix is removed.\n" 161 " -O+ has no effect on stdcall functions when -S+ is set. -S+ has higher\n" 162 " precedence than -O+.\n" 163 " -O+ only removes the OS2 prefix from internal names.\n", 164 ORD_START_INTERNAL_FUNCTIONS 165 ); 164 166 } 165 167 … … 179 181 static long processFile(const char *pszInput, const char *pszOutput, const POPTIONS pOptions) 180 182 { 181 FILE *phInput;182 FILE *phOutput;183 183 long lRc = 0; 184 184 185 phInput = fopen(pszInput, "rb");186 if (phInput != NULL)187 {185 try 186 { 187 kFile Input(pszInput); 188 188 try 189 189 { 190 kFileDef DefFile(phInput); 191 phOutput = fopen(pszOutput, "w"); 192 if (phOutput != NULL) 190 kFileDef DefFile(&Input); 191 try 193 192 { 194 193 EXPORTENTRY export; 194 kFile Output(pszOutput, FALSE); 195 195 196 196 /* generate LIBRARY line */ 197 fputs(";Internal export definition file - autogenerated by ImpDef.", phOutput); 198 fputc('\n', phOutput); 199 fputs(DefFile.queryType(), phOutput); 200 fputc('\n', phOutput); 197 Output.printf( 198 ";Internal export definition file - autogenerated by ImpDef.\n" 199 "%s\n", 200 DefFile.queryType()); 201 202 /* Description line */ 201 203 if (DefFile.queryDescription()) 202 { 203 fputs(DefFile.queryDescription(), phOutput); 204 fputc('\n', phOutput); 205 } 204 Output.printf("DESCRIPTION %s\n", DefFile.queryDescription()); 205 206 /* Exports */ 206 207 if (DefFile.findFirstExport(&export)) 207 208 { 208 fputs("EXPORTS\n", phOutput);209 Output.printf("EXPORTS\n"); 209 210 do 210 211 { … … 215 216 if (export.achName[0] == '\0') 216 217 { 217 fprintf(stderr, "Warning export name is missing.\n"); 218 fprintf(stderr, "info:\texport.achIntName=%s\n\texport.achName=%s\n\texport.ulOrdinal=%ld\n", export.achIntName, export.achName, export.ulOrdinal); 218 kFile::StdErr.printf( 219 "Warning export name is missing.\n" 220 "info:\texport.achIntName=%s\n\texport.achName=%s\n\texport.ulOrdinal=%ld\n", 221 export.achIntName, export.achName, export.ulOrdinal); 219 222 continue; 220 223 } 221 224 if (export.ulOrdinal == ~0UL) 222 225 { 223 fprintf(stderr, "warning: export is missing ordinal value. Export is ignored\n"); 224 fprintf(stderr, "info:\texport.achIntName=%s\n\texport.achName=%s\n\texport.ulOrdinal=%ld\n", export.achIntName, export.achName, export.ulOrdinal); 226 kFile::StdErr.printf( 227 "warning: export is missing ordinal value. Export is ignored\n" 228 "info:\texport.achIntName=%s\n\texport.achName=%s\n\texport.ulOrdinal=%ld\n", 229 export.achIntName, export.achName, export.ulOrdinal); 225 230 continue; 226 231 } … … 229 234 pszName = generateExportName(&export, &szName[0], pOptions); 230 235 231 fprintf(phOutput," %-*s @%ld\n", 40, pszName, export.ulOrdinal);236 Output.printf(" %-*s @%ld\n", 40, pszName, export.ulOrdinal); 232 237 } while (DefFile.findNextExport(&export)); 233 238 } 234 fclose(phOutput); 235 } 236 else 237 { 238 fprintf(stderr, "error creating output file, '%s'\n", pszOutput); 239 } 240 catch (int errorcode) 241 { 242 kFile::StdErr.printf("error creating output file, '%s', errorcode 0x%x\n", pszOutput, errorcode); 239 243 lRc = -4; 240 244 } … … 242 246 catch (int errorcode) 243 247 { 244 fprintf(stderr,"%s is not a valid def file, errorcode 0x%x\n", pszInput, errorcode);248 kFile::StdErr.printf("%s is not a valid def file, errorcode 0x%x\n", pszInput, errorcode); 245 249 lRc = -3; 246 250 } 247 fclose(phInput); 248 } 249 else 250 { 251 fprintf(stderr, "error openining inputfile, '%s'\n", pszInput); 251 } 252 catch (int errorcode) 253 { 254 kFile::StdErr.printf( "error openining inputfile, '%s', errorcode 0x%x\n", pszInput, errorcode); 252 255 lRc = -2; 253 256 }
Note:
See TracChangeset
for help on using the changeset viewer.