PostGIS  2.1.10dev-r@@SVN_REVISION@@
int pgis_getopt ( int  argc,
char **  argv,
char *  opts 
)

Definition at line 48 of file getopt.c.

References ERR, pgis_optarg, pgis_optind, and pgis_optopt.

Referenced by main().

49 {
50  static int sp = 1;
51  register int c;
52  register char *cp;
53 
54  if (sp == 1)
55  {
56  if (pgis_optind >= argc ||
57  argv[pgis_optind][0] != '-' /* && argv[pgis_optind][0] != '/' */ ||
58  argv[pgis_optind][1] == '\0')
59  {
60  return(EOF);
61  }
62  else if (strcmp(argv[pgis_optind], "--") == 0)
63  {
64  pgis_optind++;
65  return(EOF);
66  }
67  }
68  pgis_optopt = c = argv[pgis_optind][sp];
69  if (c == ':' || (cp=strchr(opts, c)) == 0)
70  {
71  ERR(": illegal option -- ", c);
72  if (argv[pgis_optind][++sp] == '\0')
73  {
74  pgis_optind++;
75  sp = 1;
76  }
77  return('?');
78  }
79  if (*++cp == ':')
80  {
81  if (argv[pgis_optind][sp+1] != '\0')
82  pgis_optarg = &argv[pgis_optind++][sp+1];
83  else if (++pgis_optind >= argc)
84  {
85  ERR(": option requires an argument -- ", c);
86  sp = 1;
87  return('?');
88  }
89  else
90  pgis_optarg = argv[pgis_optind++];
91  sp = 1;
92  }
93  else
94  {
95  if (argv[pgis_optind][++sp] == '\0')
96  {
97  sp = 1;
98  pgis_optind++;
99  }
100  pgis_optarg = NULL;
101  }
102  return(c);
103 }
int pgis_optopt
Definition: getopt.c:44
int pgis_optind
Definition: getopt.c:43
char * pgis_optarg
Definition: getopt.c:45
#define ERR(s, c)
Definition: getopt.c:33

Here is the caller graph for this function: