PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ pgis_getopt()

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

Definition at line 44 of file getopt.c.

References ERR, pgis_optarg, pgis_optind, and pgis_optopt.

Referenced by main().

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