|
|
@ -54,42 +54,39 @@ static const char rcsid[]="$Id: getopt_long.c,v 1.1 2009/10/16 19:50:28 rodney E |
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
|
|
|
#include <err.h> |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#include <errno.h> |
|
|
|
#include <errno.h> |
|
|
|
#include <getopt.h> |
|
|
|
#include <getopt.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
|
|
|
|
|
|
/* Windows needs warnx(). We change the definition though:
|
|
|
|
/* Windows needs warnx(). We change the definition though:
|
|
|
|
* 1. (another) global is defined, opterrmsg, which holds the error message |
|
|
|
* 1. (another) global is defined, opterrmsg, which holds the error message |
|
|
|
* 2. errors are always printed out on stderr w/o the program name |
|
|
|
* 2. errors are always printed out on stderr w/o the program name |
|
|
|
* Note that opterrmsg always gets set no matter what opterr is set to. The |
|
|
|
* Note that opterrmsg always gets set no matter what opterr is set to. The |
|
|
|
* error message will not be printed if opterr is 0 as usual. |
|
|
|
* error message will not be printed if opterr is 0 as usual. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdarg.h> |
|
|
|
#include <stdarg.h> |
|
|
|
#include <stdarg.h> |
|
|
|
#include <stdarg.h> |
|
|
|
|
|
|
|
|
|
|
|
char opterrmsg[128]; /* last error message is stored here */ |
|
|
|
char opterrmsg[128]; /* last error message is stored here */ |
|
|
|
|
|
|
|
|
|
|
|
static void warnx(const char *fmt, ...) |
|
|
|
static void warnx(const char *fmt, ...) |
|
|
|
{ |
|
|
|
{ |
|
|
|
va_list ap; |
|
|
|
va_list ap; |
|
|
|
va_start(ap, fmt); |
|
|
|
va_start(ap, fmt); |
|
|
|
if (fmt != NULL) |
|
|
|
if (fmt != NULL) |
|
|
|
_vsnprintf(opterrmsg, 128, fmt, ap); |
|
|
|
_vsnprintf(opterrmsg, 128, fmt, ap); |
|
|
|
else |
|
|
|
else |
|
|
|
opterrmsg[0]='\0'; |
|
|
|
opterrmsg[0]='\0'; |
|
|
|
va_end(ap); |
|
|
|
va_end(ap); |
|
|
|
fprintf(stderr, opterrmsg); |
|
|
|
fprintf(stderr, opterrmsg); |
|
|
|
fprintf(stderr, "\n"); |
|
|
|
fprintf(stderr, "\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif /*_WIN32*/ |
|
|
|
#endif /*_WIN32*/ |
|
|
|
|
|
|
|
|
|
|
|
#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */ |
|
|
|
#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */ |
|
|
|