#include <stdio.h>
#include "fegetopt.h"
Go to the source code of this file.
|
char * | getenv () |
|
static size_t | my_strlen (const char *str) |
|
static const char * | my_index (const char *str, int chr) |
|
static void | exchange (char **argv) |
|
int | _fe_getopt_internal (int argc, char *const *argv, const char *optstring, const struct fe_option *longopts, int *longind, int long_only) |
|
int | fe_getopt (int argc, char *const *argv, const char *optstring) |
|
int | fe_getopt_long (int argc, char *const *argv, const char *options, const struct fe_option *long_options, int *opt_index) |
|
int | fe_getopt_long_only (int argc, char *const *argv, const char *options, const struct fe_option *long_options, int *opt_index) |
|
◆ _NO_PROTO
◆ BAD_OPTION
◆ const
◆ anonymous enum
Enumerator |
---|
REQUIRE_ORDER | |
PERMUTE | |
RETURN_IN_ORDER | |
Definition at line 161 of file fegetopt.c.
◆ _fe_getopt_internal()
int _fe_getopt_internal |
( |
int |
argc, |
|
|
char *const * |
argv, |
|
|
const char * |
optstring, |
|
|
const struct fe_option * |
longopts, |
|
|
int * |
longind, |
|
|
int |
long_only |
|
) |
| |
Definition at line 325 of file fegetopt.c.
350 if (optstring[0] ==
'-')
355 else if (optstring[0] ==
'+')
447 && (argv[
fe_optind][1] ==
'-' || long_only))
460 while (*
s && *
s !=
'=')
464 for (
p = longopts, option_index = 0;
p->name;
472 indfound = option_index;
476 else if (pfound ==
NULL)
480 indfound = option_index;
490 fprintf (stderr,
"%s: option `%s' is ambiguous\n",
499 option_index = indfound;
514 "%s: option `--%s' doesn't allow an argument\n",
515 argv[0], pfound->
name);
519 "%s: option `%c%s' doesn't allow an argument\n",
533 fprintf (stderr,
"%s: option `%s' requires an argument\n",
536 return optstring[0] ==
':' ?
':' :
BAD_OPTION;
541 *longind = option_index;
548 if (!long_only || argv[
fe_optind][1] ==
'-'
558 fprintf (stderr,
"%s: unrecognized option `--%s'\n",
562 fprintf (stderr,
"%s: unrecognized option `%c%s'\n",
575 const char *temp =
my_index (optstring, c);
581 if (temp ==
NULL || c ==
':')
586 if (c < 040 || c >= 0177)
587 fprintf (stderr,
"%s: unrecognized option, character code 0%o\n",
590 fprintf (stderr,
"%s: unrecognized option `-%c'\n", argv[0], c);
593 fprintf (stderr,
"%s: illegal option -- %c\n", argv[0], c);
628 fprintf (stderr,
"%s: option `-%c' requires an argument\n",
632 fprintf (stderr,
"%s: option requires an argument -- %c\n",
637 if (optstring[0] ==
':')
const CanonicalForm int s
static void exchange(char **argv)
static size_t my_strlen(const char *str)
static const char * my_index(const char *str, int chr)
◆ exchange()
static void exchange |
( |
char ** |
argv | ) |
|
|
static |
Definition at line 243 of file fegetopt.c.
245 char *temp, **first, **
last;
250 while (first <
last) {
251 temp = *first; *first = *
last; *
last = temp; first++;
last--;
257 while (first <
last) {
258 temp = *first; *first = *
last; *
last = temp; first++;
last--;
265 while (first <
last) {
266 temp = *first; *first = *
last; *
last = temp; first++;
last--;
◆ fe_getopt()
int fe_getopt |
( |
int |
argc, |
|
|
char *const * |
argv, |
|
|
const char * |
optstring |
|
) |
| |
Definition at line 653 of file fegetopt.c.
int _fe_getopt_internal(int argc, char *const *argv, const char *optstring, const struct fe_option *longopts, int *longind, int long_only)
◆ fe_getopt_long()
int fe_getopt_long |
( |
int |
argc, |
|
|
char *const * |
argv, |
|
|
const char * |
options, |
|
|
const struct fe_option * |
long_options, |
|
|
int * |
opt_index |
|
) |
| |
◆ fe_getopt_long_only()
int fe_getopt_long_only |
( |
int |
argc, |
|
|
char *const * |
argv, |
|
|
const char * |
options, |
|
|
const struct fe_option * |
long_options, |
|
|
int * |
opt_index |
|
) |
| |
◆ getenv()
◆ my_index()
static const char* my_index |
( |
const char * |
str, |
|
|
int |
chr |
|
) |
| |
|
static |
◆ my_strlen()
static size_t my_strlen |
( |
const char * |
str | ) |
|
|
static |
◆ fe_optarg
◆ fe_opterr
◆ fe_optind
◆ fe_optopt
◆ first_nonopt
◆ last_nonopt
◆ nextchar