51
51
52
52
#include <sys/cdefs.h>
53
53
54
- #include <err.h>
55
54
#include <errno.h>
56
55
#include "getopt.h"
57
56
#include <stdlib.h>
58
57
#include <string.h>
59
58
59
+ #define LOG (-4)
60
+ #define INFO (-3)
61
+ #define NOTICE (-2)
62
+ #define WARNING (-1)
63
+ #define ERROR 1
64
+ #define FATAL 2
65
+ #define PANIC 3
66
+
67
+ extern void
68
+ elog (int elevel , const char * fmt , ...)
69
+ __attribute__((format (printf , 2 , 3 )));
70
+
60
71
#define GNU_COMPATIBLE /* Be more compatible, configure's use us! */
61
72
62
73
@@ -245,7 +256,7 @@ parse_long_options(char * const *nargv, const char *options,
245
256
if (!exact_match && second_partial_match ) {
246
257
/* ambiguous abbreviation */
247
258
if (PRINT_ERROR )
248
- warnx ( ambig ,
259
+ elog ( WARNING , ambig ,
249
260
#ifdef GNU_COMPATIBLE
250
261
current_dash ,
251
262
#endif
@@ -258,7 +269,7 @@ parse_long_options(char * const *nargv, const char *options,
258
269
if (long_options [match ].has_arg == no_argument
259
270
&& has_equal ) {
260
271
if (PRINT_ERROR )
261
- warnx ( noarg ,
272
+ elog ( WARNING , noarg ,
262
273
#ifdef GNU_COMPATIBLE
263
274
current_dash ,
264
275
#endif
@@ -296,7 +307,7 @@ parse_long_options(char * const *nargv, const char *options,
296
307
* should be generated.
297
308
*/
298
309
if (PRINT_ERROR )
299
- warnx ( recargstring ,
310
+ elog ( WARNING , recargstring ,
300
311
#ifdef GNU_COMPATIBLE
301
312
current_dash ,
302
313
#endif
@@ -317,7 +328,7 @@ parse_long_options(char * const *nargv, const char *options,
317
328
return (-1 );
318
329
}
319
330
if (PRINT_ERROR )
320
- warnx ( illoptstring ,
331
+ elog ( WARNING , illoptstring ,
321
332
#ifdef GNU_COMPATIBLE
322
333
current_dash ,
323
334
#endif
@@ -494,11 +505,11 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
494
505
++ optind ;
495
506
#ifdef GNU_COMPATIBLE
496
507
if (PRINT_ERROR )
497
- warnx ( posixly_correct ? illoptchar : gnuoptchar ,
508
+ elog ( WARNING , posixly_correct ? illoptchar : gnuoptchar ,
498
509
optchar );
499
510
#else
500
511
if (PRINT_ERROR )
501
- warnx ( illoptchar , optchar );
512
+ elog ( WARNING , illoptchar , optchar );
502
513
#endif
503
514
optopt = optchar ;
504
515
return (BADCH );
@@ -510,7 +521,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
510
521
else if (++ optind >= nargc ) { /* no arg */
511
522
place = EMSG ;
512
523
if (PRINT_ERROR )
513
- warnx ( recargchar , optchar );
524
+ elog ( WARNING , recargchar , optchar );
514
525
optopt = optchar ;
515
526
return (BADARG );
516
527
} else /* white space */
@@ -534,7 +545,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
534
545
if (++ optind >= nargc ) { /* no arg */
535
546
place = EMSG ;
536
547
if (PRINT_ERROR )
537
- warnx ( recargchar , optchar );
548
+ elog ( WARNING , recargchar , optchar );
538
549
optopt = optchar ;
539
550
return (BADARG );
540
551
} else
0 commit comments