On UN*X, __progname is a BSD-specific variable, so don't rely on it
being defined by the system.
On Windows, don't hardwire "windump" as the program name.
char * const *nargv;
const char *ostr;
{
-#ifdef _WIN32
- char *__progname="windump";
-#else
- extern char *__progname;
-#endif
+ char *cp;
+ static char *__progname;
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
+ if (__progname == NULL) {
+ if ((cp = strrchr(nargv[0], '/')) != NULL)
+ __progname = cp + 1;
+ else
+ __progname = nargv[0];
+ }
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {