Mercurial > hg > dmlib
comparison tools/data2inc.c @ 958:985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 27 Feb 2015 03:58:25 +0200 |
parents | 49fc8d8a0b9c |
children | 69c0d8ad2672 |
comparison
equal
deleted
inserted
replaced
957:b66653c9acb3 | 958:985225a93aeb |
---|---|
117 case 10: | 117 case 10: |
118 optExtraData = TRUE; | 118 optExtraData = TRUE; |
119 break; | 119 break; |
120 | 120 |
121 default: | 121 default: |
122 dmError("Unknown option '%s'.\n", currArg); | 122 dmErrorMsg("Unknown option '%s'.\n", currArg); |
123 return FALSE; | 123 return FALSE; |
124 } | 124 } |
125 | 125 |
126 return TRUE; | 126 return TRUE; |
127 } | 127 } |
133 optInFilename = currArg; | 133 optInFilename = currArg; |
134 else | 134 else |
135 if (!optOutFilename) | 135 if (!optOutFilename) |
136 optOutFilename = currArg; | 136 optOutFilename = currArg; |
137 else | 137 else |
138 dmError("Source and destination filenames already specified, extraneous argument '%s'.\n", currArg); | 138 dmErrorMsg("Source and destination filenames already specified, extraneous argument '%s'.\n", currArg); |
139 | 139 |
140 return TRUE; | 140 return TRUE; |
141 } | 141 } |
142 | 142 |
143 | 143 |
283 { | 283 { |
284 char *dext; | 284 char *dext; |
285 | 285 |
286 if (optOutFilename == NULL) | 286 if (optOutFilename == NULL) |
287 { | 287 { |
288 dmError("Output format not specified and no output filename given (try --help)\n"); | 288 dmErrorMsg("Output format not specified and no output filename given (try --help)\n"); |
289 exit(1); | 289 exit(1); |
290 } | 290 } |
291 | 291 |
292 /* Check filename extension */ | 292 /* Check filename extension */ |
293 dext = strrchr(optOutFilename, '.'); | 293 dext = strrchr(optOutFilename, '.'); |
327 writeFooter = writeFooter_C; | 327 writeFooter = writeFooter_C; |
328 break; | 328 break; |
329 | 329 |
330 case FMT_AUTO: | 330 case FMT_AUTO: |
331 default: | 331 default: |
332 dmError("Internal error, FMT_AUTO at output function init.\n"); | 332 dmErrorMsg("Internal error, FMT_AUTO at output function init.\n"); |
333 exit(2); | 333 exit(2); |
334 } | 334 } |
335 | 335 |
336 /* Open the files */ | 336 /* Open the files */ |
337 if (optInFilename == NULL) | 337 if (optInFilename == NULL) |
338 sfile = stdin; | 338 sfile = stdin; |
339 else | 339 else |
340 if ((sfile = fopen(optInFilename, "rb")) == NULL) | 340 if ((sfile = fopen(optInFilename, "rb")) == NULL) |
341 { | 341 { |
342 tmpRes = errno; | 342 tmpRes = errno; |
343 dmError("Error opening input file '%s'. (%s)\n", | 343 dmErrorMsg("Error opening input file '%s'. (%s)\n", |
344 optInFilename, strerror(tmpRes)); | 344 optInFilename, strerror(tmpRes)); |
345 exit(3); | 345 exit(3); |
346 } | 346 } |
347 | 347 |
348 if (optOutFilename == NULL) | 348 if (optOutFilename == NULL) |
349 dfile = stdout; | 349 dfile = stdout; |
350 else | 350 else |
351 if ((dfile = fopen(optOutFilename, "wa")) == NULL) | 351 if ((dfile = fopen(optOutFilename, "wa")) == NULL) |
352 { | 352 { |
353 tmpRes = errno; | 353 tmpRes = errno; |
354 dmError("Error creating output file '%s'. (%s)\n", | 354 dmErrorMsg("Error creating output file '%s'. (%s)\n", |
355 optOutFilename, strerror(tmpRes)); | 355 optOutFilename, strerror(tmpRes)); |
356 exit(4); | 356 exit(4); |
357 } | 357 } |
358 | 358 |
359 /* Get sourcefile size */ | 359 /* Get sourcefile size */ |