5151
5252#include <sys/cdefs.h>
5353
54- #include <err.h>
5554#include <errno.h>
5655#include "getopt.h"
5756#include <stdlib.h>
5857#include <string.h>
5958
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+
6071#define GNU_COMPATIBLE /* Be more compatible, configure's use us! */
6172
6273
@@ -245,7 +256,7 @@ parse_long_options(char * const *nargv, const char *options,
245256if (!exact_match && second_partial_match ) {
246257/* ambiguous abbreviation */
247258if (PRINT_ERROR )
248- warnx ( ambig ,
259+ elog ( WARNING , ambig ,
249260#ifdef GNU_COMPATIBLE
250261current_dash ,
251262#endif
@@ -258,7 +269,7 @@ parse_long_options(char * const *nargv, const char *options,
258269if (long_options [match ].has_arg == no_argument
259270&& has_equal ) {
260271if (PRINT_ERROR )
261- warnx ( noarg ,
272+ elog ( WARNING , noarg ,
262273#ifdef GNU_COMPATIBLE
263274current_dash ,
264275#endif
@@ -296,7 +307,7 @@ parse_long_options(char * const *nargv, const char *options,
296307 * should be generated.
297308 */
298309if (PRINT_ERROR )
299- warnx ( recargstring ,
310+ elog ( WARNING , recargstring ,
300311#ifdef GNU_COMPATIBLE
301312current_dash ,
302313#endif
@@ -317,7 +328,7 @@ parse_long_options(char * const *nargv, const char *options,
317328return (-1 );
318329}
319330if (PRINT_ERROR )
320- warnx ( illoptstring ,
331+ elog ( WARNING , illoptstring ,
321332#ifdef GNU_COMPATIBLE
322333current_dash ,
323334#endif
@@ -494,11 +505,11 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
494505++ optind ;
495506#ifdef GNU_COMPATIBLE
496507if (PRINT_ERROR )
497- warnx ( posixly_correct ?illoptchar :gnuoptchar ,
508+ elog ( WARNING , posixly_correct ?illoptchar :gnuoptchar ,
498509optchar );
499510#else
500511if (PRINT_ERROR )
501- warnx ( illoptchar ,optchar );
512+ elog ( WARNING , illoptchar ,optchar );
502513#endif
503514optopt = optchar ;
504515return (BADCH );
@@ -510,7 +521,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
510521else if (++ optind >=nargc ) {/* no arg */
511522place = EMSG ;
512523if (PRINT_ERROR )
513- warnx ( recargchar ,optchar );
524+ elog ( WARNING , recargchar ,optchar );
514525optopt = optchar ;
515526return (BADARG );
516527}else /* white space */
@@ -534,7 +545,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
534545if (++ optind >=nargc ) {/* no arg */
535546place = EMSG ;
536547if (PRINT_ERROR )
537- warnx ( recargchar ,optchar );
548+ elog ( WARNING , recargchar ,optchar );
538549optopt = optchar ;
539550return (BADARG );
540551}else