Works with letters, added trimmed Lovecraft
[name-generation.git] / element-lists / names-2.0.1 / src / getopt.h
1 #ifndef GETOPT_H
2 #define GETOPT_H
3
4 /* implements UNIX-style getopt
5
6 The example below shows typical usage. The third argument is a string of
7 option letters. If an option letter is followed by ':' it takes an
8 argument. Getopt returns the option letter if it finds one; if the option
9 specified is illegal, it prints an error message and returns '?'. When
10 no more options are found, it returns -1. Optind always points to the
11 next argument in the option list. For options which take an argument,
12 optarg points to the argument (see -c in the example).
13
14 An option of "-" (single dash) signifies the end of the option list, and
15 causes getopt to return -1. This is useful for specifying filenames
16 which start with a dash.
17
18 This version of getopt recognizes options which begin with '-', but also
19 recognizes '/' as an option switch (per NT usage). Options which don't
20 require an argument may be stacked on the command line. Valid options
21 using the example below:
22
23 myprogram -a -b
24 myprogram -ab
25 myprogram -c file1 -ac file2
26 myprogram -c:file
27
28 As shown in the example, this version of getopt allows a ':' to be placed
29 between the option letter and its argument.
30
31 EXAMPLE:
32
33 #include <stdio.h>
34 #include "getopt.h"
35 main(int argc, char **argv)
36 {
37 int c;
38 while ((c=getopt(argc, argv, "abc:")) != -1) {
39 switch (c) {
40 case 'a': printf("got -a\n"); break;
41 case 'b': printf("got -b\n"); break;
42 case 'c': printf("got -c = %s\n", optarg); break;
43 case '?': printf(); exit(1);
44 }
45 }
46 for ( ; optind < argc; optind++)
47 process_file(argv[optind]);
48 }
49
50 */
51
52 int getopt(int argc, char ** argv, char *opt);
53
54 extern int optind; /* current argc index into arglist */
55 extern char *optarg; /* argument string for options that take an argument */
56 extern int opterr; /* set to 1 if error condition, 0 otherwise; */
57 /* useful for using '?' as an option */
58
59 #endif