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

attgetopt.c File Reference

#include <stdio.h>
#include <string.h>
#include "gw-config.h"

Include dependency graph for attgetopt.c:

Include dependency graph

Go to the source code of this file.

Defines

#define ERR(s, c)

Functions

int getopt (int argc, char **argv, char *opts)

Variables

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


Define Documentation

#define ERR s,
 ) 
 

Value:

if (opterr) \
            (void) fprintf(stderr, "%s: %s\n", argv[0], s)

Definition at line 75 of file attgetopt.c.

Referenced by getopt().


Function Documentation

int getopt int  argc,
char **  argv,
char *  opts
 

Definition at line 84 of file attgetopt.c.

References ERR, optarg, optind, and optopt.

Referenced by main(), and parse_options().

00085 {
00086         static int sp = 1;
00087         register int c;
00088         register char *cp;
00089 
00090         if(sp == 1) {
00091                 if(optind >= argc ||
00092                    argv[optind][0] != '-' || argv[optind][1] == '\0')
00093                         return(EOF);
00094                 else if(strcmp(argv[optind], "--") == 0) {
00095                         optind++;
00096                         return(EOF);
00097                 }
00098     }
00099         optopt = c = argv[optind][sp];
00100         if(c == ':' || (cp=strchr(opts, c)) == NULL) {
00101                 ERR(": illegal option -- ", c);
00102                 if(argv[optind][++sp] == '\0') {
00103                         optind++;
00104                         sp = 1;
00105                 }
00106                 return('?');
00107         }
00108         if(*++cp == ':') {
00109                 if(argv[optind][sp+1] != '\0')
00110                         optarg = &argv[optind++][sp+1];
00111                 else if(++optind >= argc) {
00112                         ERR(": option requires an argument -- ", c);
00113                         sp = 1;
00114                         return('?');
00115                 } else
00116                         optarg = argv[optind++];
00117                 sp = 1;
00118         } else {
00119                 if(argv[optind][++sp] == '\0') {
00120                         sp = 1;
00121                         optind++;
00122                 }
00123                 optarg = NULL;
00124         }
00125         return(c);
00126 }


Variable Documentation

char* optarg
 

Definition at line 82 of file attgetopt.c.

Referenced by getopt(), main(), and parse_options().

int opterr = 1
 

Definition at line 79 of file attgetopt.c.

int optind = 1
 

Definition at line 80 of file attgetopt.c.

Referenced by getopt(), and main().

int optopt
 

Definition at line 81 of file attgetopt.c.

Referenced by getopt().

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.