Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

getopt.c File Reference

#include <stdio.h>

Include dependency graph for getopt.c:

Include dependency graph

Go to the source code of this file.

Defines

#define EPR   fprintf(stderr,
#define ERR(str, chr)   if(opterr){EPR "%s%c\n", str, chr);}

Functions

int getopt (int argc, char *const argv[], const char *opts)
char * strchr ()

Variables

char * optarg
int opterr = 1
int optind = 1
int optopt


Define Documentation

#define EPR   fprintf(stderr,
 

Definition at line 2 of file getopt.c.

#define ERR str,
chr   )     if(opterr){EPR "%s%c\n", str, chr);}
 

Definition at line 3 of file getopt.c.

Referenced by getopt().


Function Documentation

int getopt int  argc,
char *const   argv[],
const char *  opts
 

Definition at line 11 of file getopt.c.

References argc, argv, c, cp, ERR, optarg, optind, optopt, strchr(), and strcmp().

00012 {
00013     static int sp = 1;
00014     int c;
00015     char *cp;
00016 
00017     if (sp == 1)
00018         if (optind >= argc ||
00019            argv[optind][0] != '-' || argv[optind][1] == '\0')
00020             return -1;
00021         else if (strcmp(argv[optind], "--") == 0) {
00022             optind++;
00023             return -1;
00024         }
00025     optopt = c = argv[optind][sp];
00026     if (c == ':' || (cp=strchr(opts, c)) == 0) {
00027         ERR (": illegal option -- ", c);
00028         if (argv[optind][++sp] == '\0') {
00029             optind++;
00030             sp = 1;
00031         }
00032         return '?';
00033     }
00034     if (*++cp == ':') {
00035         if (argv[optind][sp+1] != '\0')
00036             optarg = &argv[optind++][sp+1];
00037         else if (++optind >= argc) {
00038             ERR (": option requires an argument -- ", c);
00039             sp = 1;
00040             return '?';
00041         } else
00042             optarg = argv[optind++];
00043         sp = 1;
00044     } else {
00045         if (argv[optind][++sp] == '\0') {
00046             sp = 1;
00047             optind++;
00048         }
00049         optarg = 0;
00050     }
00051     return c;
00052 }

Here is the call graph for this function:

char* strchr  ) 
 

Referenced by ASE_KeyGEOMOBJECT(), ASE_KeyMAP_DIFFUSE(), BotAI(), callsys(), CG_NewClientInfo(), CL_NextDownload(), CL_ServerStatusResponse(), Cmd_CallTeamVote_f(), Cmd_CallVote_f(), compose(), Cvar_ValidateString(), doop(), G_ProcessIPBans(), getopt(), GetPackFileList(), GetPackTextureDirs(), Info_RemoveKey(), Info_RemoveKey_Big(), Info_SetValueForKey(), Info_SetValueForKey_Big(), Info_Validate(), Item_Text_Wrapped_Paint(), main(), main_init(), OpenPakFile(), PakLoadFile(), path2list(), PrintMsg(), R_LoadEntities(), replace(), CMainFrame::ShowMenuItemKeyBindings(), suffix(), trace_init(), UI_GetServerStatusInfo(), UI_RegisterClientModelname(), and yylex().


Variable Documentation

char* optarg
 

Definition at line 7 of file getopt.c.

Referenced by getopt(), and setup().

int opterr = 1
 

Definition at line 4 of file getopt.c.

int optind = 1
 

Definition at line 5 of file getopt.c.

Referenced by getopt(), and setup().

int optopt
 

Definition at line 6 of file getopt.c.

Referenced by getopt().


Generated on Thu Aug 25 15:47:33 2005 for Quake III Arena by  doxygen 1.3.9.1