/trunk/HuntnGather/Gather/getopt.c |
@@ -1,5 +1,5 @@ |
/**************************************************************************** |
* getopt(): Return the next user option on each iteration. |
* getopt(): Return the next user option on each iteration. |
* This is a clone of the usual UNIX getopt() function. |
* If you have never used a getopt() before, you'll have to |
* read about it on any UNIX machine or other C system that |
@@ -64,6 +64,10 @@ |
* |
****************************************************************************/ |
|
#if defined MWDEBUG |
#include "memwatch.h" |
#endif |
|
#ifndef __STDIO_H /* If we haven't already included stdio.h, do it. */ |
# include <stdio.h> /* Maybe someday I'll eliminate this. */ |
#endif |
@@ -104,7 +108,7 @@ |
* Global variables. You must declare these externs in your program |
* if you want to see their values! |
************************************************************************/ |
|
|
char *optarg = NULL; /* This will point to a required argument, if any. */ |
int optind = 1; /* The index of the next argument in argv. */ |
int opterr = 1; /* 1 == print internal error messages. 0 else. */ |
@@ -127,11 +131,11 @@ |
* If we have a DASH followed immediately by another DASH, this is the |
* special "--" option that means "no more options follow." Return EOF. |
* Otherwise, we have an actual option or list of options. Process it. */ |
|
|
static int NextOption(char *argv[], char *optString) |
{ |
static int optsSkipped = 0; /* In a single argv[i]. */ |
|
|
if ((argv[optind][0] == DASH) |
&& ((optopt = argv[optind][1+optsSkipped]) != '\0')) |
{ |
@@ -158,7 +162,7 @@ |
* If the option requires no argument, just return the option letter. |
* If the option requires an argument, call HandleArgument and return |
* the option letter. */ |
|
|
static int RealOption(char *argv[], char *optString, int *optsSkipped, |
int *optind, int optopt) |
{ |