Changeset 20 for trunk/src/sh_getopt.c
- Timestamp:
- Feb 13, 2006, 11:54:42 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_getopt.c
r1 r20 40 40 #endif 41 41 42 extern int sh_calls_set_bind_addr (c har *);42 extern int sh_calls_set_bind_addr (const char *); 43 43 44 44 #undef FIL__ … … 56 56 char * usage; 57 57 int hasArg; 58 int (*func)(c har * opt);58 int (*func)(const char * opt); 59 59 } opttable_t; 60 60 61 61 /*@noreturn@*/ 62 static int sh_getopt_usage (c har * dummy);62 static int sh_getopt_usage (const char * dummy); 63 63 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 64 static int sh_getopt_forever (c har * dummy);65 #endif 66 static int sh_getopt_copyright (c har * dummy);64 static int sh_getopt_forever (const char * dummy); 65 #endif 66 static int sh_getopt_copyright (const char * dummy); 67 67 68 68 static opttable_t op_table[] = { … … 258 258 HAS_ARG_NO, 259 259 sh_getopt_usage }, 260 #if defined(HAVE_LIBPRELUDE) && defined(HAVE_LIBPRELUDE_9) 261 /* need to skip over these */ 262 { N_("prelude"), 263 '-', 264 N_("Prelude generic options"), 265 HAS_ARG_NO, 266 NULL }, 267 { N_("profile"), 268 '-', 269 N_("Profile to use for this analyzer"), 270 HAS_ARG_YES, 271 NULL }, 272 { N_("heartbeat-interval"), 273 '-', 274 N_("Number of seconds between two heartbeats"), 275 HAS_ARG_YES, 276 NULL }, 277 { N_("server-addr"), 278 '-', 279 N_("Address where this sensor should report to"), 280 HAS_ARG_YES, 281 NULL }, 282 { N_("analyzer-name"), 283 '-', 284 N_("Name for this analyzer"), 285 HAS_ARG_YES, 286 NULL }, 287 #endif 260 288 /* last entry -- required !! -- */ 261 289 { NULL, … … 266 294 }; 267 295 268 static int sh_getopt_copyright (c har * dummy)296 static int sh_getopt_copyright (const char * dummy) 269 297 { 270 298 fprintf (stdout, … … 331 359 332 360 /*@noreturn@*/ 333 static int sh_getopt_usage (c har * dummy)361 static int sh_getopt_usage (const char * dummy) 334 362 { 335 363 int i; … … 413 441 414 442 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 415 static int sh_getopt_forever (c har * dummy)443 static int sh_getopt_forever (const char * dummy) 416 444 { 417 445 dummy = (void *) dummy; … … 489 517 /* call function with argument */ 490 518 --argc; ++argv; 491 if (0 != (* op_table[i].func )(argv[1])) 519 if (NULL != op_table[i].func && 520 0 != (* op_table[i].func )(argv[1])) 492 521 fprintf (stderr, 493 522 _("Error processing option -%c"), … … 498 527 else 499 528 { 500 if (0 != (* op_table[i].func )(NULL)) 529 if (NULL != op_table[i].func && 530 0 != (* op_table[i].func )(NULL)) 501 531 fprintf (stderr, 502 532 _("Error processing option -%c"), … … 540 570 if ( (theequal = strchr(argv[1], '=')) == NULL) 541 571 { 542 fprintf (stderr, _("Error: missing argument\n")); 543 /* argument required, but no avail */ 544 (void) sh_getopt_usage(_("fail")); 572 if (argc < 3) 573 { 574 /* argument required, but no avail 575 */ 576 fprintf (stderr, _("Error: missing argument\n")); 577 (void) sh_getopt_usage(_("fail")); 578 } 579 else 580 { 581 /* call function with argument */ 582 --argc; ++argv; 583 if (NULL != op_table[i].func && 584 0 != (* op_table[i].func )(argv[1])) 585 fprintf (stderr, 586 _("Error processing option -%s"), 587 op_table[i].longopt); 588 break; 589 } 545 590 } 546 591 else … … 550 595 ++theequal; 551 596 /* call function with argument */ 552 if (0 != (* op_table[i].func )(theequal)) 597 if (NULL != op_table[i].func && 598 0 != (* op_table[i].func )(theequal)) 553 599 fprintf (stderr, 554 600 _("Error processing option -%s"), … … 566 612 else 567 613 { 568 if (0 != (* op_table[i].func )(NULL)) 614 if (NULL != op_table[i].func && 615 0 != (* op_table[i].func )(NULL)) 569 616 fprintf (stderr, 570 617 _("Error processing option -%s"),
Note:
See TracChangeset
for help on using the changeset viewer.