#ifndef _GETOPT_H_
#define _GETOPT_H_
-#include <sys/cdefs.h>
-
/*
* GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions
*/
#define required_argument 1
#define optional_argument 2
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct option {
/* name of long option */
const char *name;
int val;
};
-__BEGIN_DECLS
int getopt_long(int, char * const *, const char *,
const struct option *, int *);
int getopt_long_only(int, char * const *, const char *,
extern int optreset;
extern char *suboptarg; /* getsubopt(3) external variable */
#endif
-__END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
#endif /* !_GETOPT_H_ */
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <err.h>
#include <errno.h>
#include <getopt.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
else {
/* ambiguous abbreviation */
if (PRINT_ERROR)
- warnx(ambig, (int)current_argv_len,
+ fprintf(stderr, ambig, (int)current_argv_len,
current_argv);
optopt = 0;
return (BADCH);
if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
- warnx(noarg, (int)current_argv_len,
+ fprintf(stderr, noarg, (int)current_argv_len,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
* should be generated.
*/
if (PRINT_ERROR)
- warnx(recargstring,
+ fprintf(stderr, recargstring,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
return (-1);
}
if (PRINT_ERROR)
- warnx(illoptstring, current_argv);
+ fprintf(stderr, illoptstring, current_argv);
optopt = 0;
return (BADCH);
}
if (!*place)
++optind;
if (PRINT_ERROR)
- warnx(illoptchar, optchar);
+ fprintf(stderr, illoptchar, optchar);
optopt = optchar;
return (BADCH);
}
else if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
- warnx(recargchar, optchar);
+ fprintf(stderr, recargchar, optchar);
optopt = optchar;
return (BADARG);
} else /* white space */
if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
- warnx(recargchar, optchar);
+ fprintf(stderr, recargchar, optchar);
optopt = optchar;
return (BADARG);
} else