comparison tools/data2inc.c @ 2586:9807ae37ad69

Require stdbool.h, we require C11 now.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 08 Dec 2022 15:59:22 +0200
parents 3feca4682680
children
comparison
equal deleted inserted replaced
2585:ef6c826c5b7a 2586:9807ae37ad69
46 *optAddLine = NULL; 46 *optAddLine = NULL;
47 47
48 const DMOutputFormat *setFormat = NULL; 48 const DMOutputFormat *setFormat = NULL;
49 int optIndentation = -1, 49 int optIndentation = -1,
50 optLineLen = SET_DEF_LINELEN; 50 optLineLen = SET_DEF_LINELEN;
51 BOOL optHexMode = FALSE, 51 bool optHexMode = false,
52 optQuiet = FALSE, 52 optQuiet = false,
53 optExtraData = FALSE, 53 optExtraData = false,
54 optFormatting = TRUE; 54 optFormatting = true;
55 55
56 56
57 static const DMOptArg optList[] = 57 static const DMOptArg optList[] =
58 { 58 {
59 { 0, '?', "help" , "Show this help", OPT_NONE }, 59 { 0, '?', "help" , "Show this help", OPT_NONE },
357 "\n" 357 "\n"
358 ); 358 );
359 } 359 }
360 360
361 361
362 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) 362 bool argHandleOpt(const int optN, char *optArg, char *currArg)
363 { 363 {
364 switch (optN) 364 switch (optN)
365 { 365 {
366 case 0: 366 case 0:
367 argShowHelp(); 367 argShowHelp();
386 { 386 {
387 const DMOutputFormat *fmt = &dmFormatList[i]; 387 const DMOutputFormat *fmt = &dmFormatList[i];
388 if (strcasecmp(fmt->name, optArg) == 0) 388 if (strcasecmp(fmt->name, optArg) == 0)
389 { 389 {
390 setFormat = fmt; 390 setFormat = fmt;
391 return TRUE; 391 return true;
392 } 392 }
393 } 393 }
394 dmErrorMsg("Invalid format name '%s'.\n", 394 dmErrorMsg("Invalid format name '%s'.\n",
395 optArg); 395 optArg);
396 return FALSE; 396 return false;
397 397
398 case 16: 398 case 16:
399 optAddLine = optArg; 399 optAddLine = optArg;
400 break; 400 break;
401 401
403 optLineLen = atoi(optArg); 403 optLineLen = atoi(optArg);
404 if (optLineLen < 1) 404 if (optLineLen < 1)
405 { 405 {
406 dmErrorMsg("Invalid line length / number of items per line '%s'.\n", 406 dmErrorMsg("Invalid line length / number of items per line '%s'.\n",
407 optArg); 407 optArg);
408 return FALSE; 408 return false;
409 } 409 }
410 break; 410 break;
411 411
412 case 20: 412 case 20:
413 optHexMode = TRUE; 413 optHexMode = true;
414 break; 414 break;
415 415
416 case 22: 416 case 22:
417 optQuiet = TRUE; 417 optQuiet = true;
418 break; 418 break;
419 419
420 case 24: 420 case 24:
421 optFormatting = FALSE; 421 optFormatting = false;
422 break; 422 break;
423 423
424 case 26: 424 case 26:
425 optIndentation = atoi(optArg); 425 optIndentation = atoi(optArg);
426 break; 426 break;
427 427
428 case 28: 428 case 28:
429 optExtraData = TRUE; 429 optExtraData = true;
430 break; 430 break;
431 431
432 default: 432 default:
433 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg); 433 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg);
434 return FALSE; 434 return false;
435 } 435 }
436 436
437 return TRUE; 437 return true;
438 } 438 }
439 439
440 440
441 BOOL argHandleFile(char * currArg) 441 bool argHandleFile(char * currArg)
442 { 442 {
443 if (optInFilename == NULL) 443 if (optInFilename == NULL)
444 optInFilename = currArg; 444 optInFilename = currArg;
445 else 445 else
446 if (optOutFilename == NULL) 446 if (optOutFilename == NULL)
447 optOutFilename = currArg; 447 optOutFilename = currArg;
448 else 448 else
449 dmErrorMsg("Source and destination filenames already specified, extraneous argument '%s'.\n", currArg); 449 dmErrorMsg("Source and destination filenames already specified, extraneous argument '%s'.\n", currArg);
450 450
451 return TRUE; 451 return true;
452 } 452 }
453 453
454 454
455 const DMOutputFormat *dmGuessFormatFromName(const char *filename) 455 const DMOutputFormat *dmGuessFormatFromName(const char *filename)
456 { 456 {