Lines Matching refs:argv
11 and argv are the argument count and array as passed to the main() function
18 The external variable optind is the index of the next array element of argv
49 argv-elements.
65 expect options and other argv-elements in any order and that care about the
66 ordering of the two. We describe each non-option argv-element as if it were
112 /* reverse_argv_elements: reverses num elements starting at argv */
114 reverse_argv_elements (char **argv, int num)
121 tmp = argv[i];
122 argv[i] = argv[num - i - 1];
123 argv[num - i - 1] = tmp;
127 /* permute: swap two blocks of argv-elements given their lengths */
129 permute (char **argv, int len1, int len2)
131 reverse_argv_elements (argv, len1);
132 reverse_argv_elements (argv, len1 + len2);
133 reverse_argv_elements (argv, len2);
136 /* is_option: is this argv-element an option or the end of the option list? */
146 getopt_internal (int argc, char **argv, char *shortopts,
162 if (argc == 0 || argv == NULL || (shortopts == NULL && longopts == NULL))
164 if (optind >= argc || argv[optind] == NULL)
166 if (strcmp (argv[optind], "--") == 0)
195 while (!is_option (argv[optind], only))
200 if (argv[optind] == NULL)
206 else if (strcmp (argv[optind], "--") == 0)
209 permute (argv + permute_from, num_nonopts, 1);
215 if (!is_option (argv[optind], only))
217 optarg = argv[optind++];
222 if (!is_option (argv[optind], only))
231 && (memcmp (argv[optind], "--", 2) == 0
232 || (only && argv[optind][0] == '+')) && optwhere == 1)
235 if (memcmp (argv[optind], "--", 2) == 0)
238 possible_arg = strchr (argv[optind] + optwhere, '=');
241 /* no =, so next argv might be arg */
242 match_chars = strlen (argv[optind]);
243 possible_arg = argv[optind] + match_chars;
247 match_chars = (possible_arg - argv[optind]) - optwhere;
250 if (memcmp (argv[optind] + optwhere,
270 argv[0],
271 argv[optind],
285 cp = strchr (shortopts, argv[optind][optwhere]);
292 argv[0], argv[optind][optwhere]);
294 if (argv[optind][optwhere] == '\0')
303 possible_arg = argv[optind] + optwhere + 1;
333 fprintf (stderr, "%s: argument required for option `", argv[0]);
344 optarg = argv[optind + 1];
353 if (argv[optind][optwhere] == '\0')
365 permute (argv + permute_from, num_nonopts, 1 + arg_next);
390 getopt (int argc, char **argv, char *optstring)
392 return getopt_internal (argc, argv, optstring, NULL, NULL, 0);
397 getopt_long (int argc, char **argv, const char *shortopts,
400 return getopt_internal (argc, argv, (char*)shortopts, (GETOPT_LONG_OPTION_T*)longopts, longind, 0);
404 getopt_long_only (int argc, char **argv, const char *shortopts,
407 return getopt_internal (argc, argv, (char*)shortopts, (GETOPT_LONG_OPTION_T*)longopts, longind, 1);