HuntnGather – Diff between revs 1 and 28
?pathlinks?
Rev 1 | Rev 28 | |||
---|---|---|---|---|
1 | /************************************************************************* |
1 | /************************************************************************* |
|
2 | * getopt.h: Header file for using getopt(). |
2 | * getopt.h: Header file for using getopt(). |
|
3 | * Author: Daniel J. Barrett, barrett@cs.umass.edu |
3 | * Author: Daniel J. Barrett, barrett@cs.umass.edu |
|
4 | * Status: Public domain. |
4 | * Status: Public domain. |
|
5 | *************************************************************************/ |
5 | *************************************************************************/ |
|
6 | |
6 | |
|
7 | |
7 | |
|
8 | #ifndef _GETOPT_H /* Insure we #include me only once. */ |
8 | #ifndef _GETOPT_H /* Insure we #include me only once. */ |
|
9 | #define _GETOPT_H 1 |
9 | #define _GETOPT_H 1 |
|
10 | |
10 | |
|
11 | |
11 | |
|
12 | /************************************************************************* |
12 | /************************************************************************* |
|
13 | * optarg |
13 | * optarg |
|
14 | * This variable is READ-ONLY! Do not set its value yourself! |
14 | * This variable is READ-ONLY! Do not set its value yourself! |
|
15 | * |
15 | * |
|
16 | * If an option must be followed by a string, then optarg is a pointer |
16 | * If an option must be followed by a string, then optarg is a pointer |
|
17 | * to that string. |
17 | * to that string. |
|
18 | * |
18 | * |
|
19 | * If an option should NOT be followed by an string, then optarg is |
19 | * If an option should NOT be followed by an string, then optarg is |
|
20 | * NOT DEFINED. It is an error to reference optarg if no argument is |
20 | * NOT DEFINED. It is an error to reference optarg if no argument is |
|
21 | * expected. |
21 | * expected. |
|
22 | *************************************************************************/ |
22 | *************************************************************************/ |
|
23 | |
23 | |
|
24 | extern char *optarg; |
24 | extern char *optarg; |
|
25 | |
25 | |
|
26 | /************************************************************************* |
26 | /************************************************************************* |
|
27 | * optind |
27 | * optind |
|
28 | * This variable is READ-ONLY! Do not set its value yourself! |
28 | * This variable is READ-ONLY! Do not set its value yourself! |
|
29 | * |
29 | * |
|
30 | * After getopt() returns EOF, this variable contains the index of the |
30 | * After getopt() returns EOF, this variable contains the index of the |
|
31 | * next unprocessed command-line argument. |
31 | * next unprocessed command-line argument. |
|
32 | * |
32 | * |
|
33 | * That is, argv[optind] is the first argument AFTER the options. |
33 | * That is, argv[optind] is the first argument AFTER the options. |
|
34 | * |
34 | * |
|
35 | * If optind == argc-1, then there are no arguments after the options. |
35 | * If optind == argc-1, then there are no arguments after the options. |
|
36 | *************************************************************************/ |
36 | *************************************************************************/ |
|
37 | |
37 | |
|
38 | extern int optind; |
38 | extern int optind; |
|
39 | |
39 | |
|
40 | /************************************************************************* |
40 | /************************************************************************* |
|
41 | * optopt |
41 | * optopt |
|
42 | * This variable is READ-ONLY! Do not set its value yourself! |
42 | * This variable is READ-ONLY! Do not set its value yourself! |
|
43 | * |
43 | * |
|
44 | * After each call of getopt(), this variable contains the option character |
44 | * After each call of getopt(), this variable contains the option character |
|
45 | * which was found on this call. |
45 | * which was found on this call. |
|
46 | * |
46 | * |
|
47 | * Normally, you do not need to examine this variable because getopt() |
47 | * Normally, you do not need to examine this variable because getopt() |
|
48 | * returns the value of the character it read. |
48 | * returns the value of the character it read. |
|
49 | * However, when getopt() discovers an illegal option, it returns the |
49 | * However, when getopt() discovers an illegal option, it returns the |
|
50 | * character '?'. You now examine optopt to find the actual character |
50 | * character '?'. You now examine optopt to find the actual character |
|
51 | * which getopt() read. |
51 | * which getopt() read. |
|
52 | *************************************************************************/ |
52 | *************************************************************************/ |
|
53 | |
53 | |
|
54 | extern int optopt; |
54 | extern int optopt; |
|
55 | |
55 | |
|
56 | /************************************************************************* |
56 | /************************************************************************* |
|
57 | * opterr |
57 | * opterr |
|
58 | * This variable is READ/WRITE. You may set its value yourself. |
58 | * This variable is READ/WRITE. You may set its value yourself. |
|
59 | * |
59 | * |
|
60 | * If opterr != 0, then getopt() will print its own error messages |
60 | * If opterr != 0, then getopt() will print its own error messages |
|
61 | * on standard error (stderr). Error messages are of the form: |
61 | * on standard error (stderr). Error messages are of the form: |
|
62 | * |
62 | * |
|
63 | * -x: Illegal option. |
63 | * -x: Illegal option. |
|
64 | * -x: An argument is required, but missing. |
64 | * -x: An argument is required, but missing. |
|
65 | * |
65 | * |
|
66 | * assuming that the illegal option "-x" was read by getopt(). |
66 | * assuming that the illegal option "-x" was read by getopt(). |
|
67 | * |
67 | * |
|
68 | * If opterr == 0, these error messages are suppressed. |
68 | * If opterr == 0, these error messages are suppressed. |
|
69 | * |
69 | * |
|
70 | * By default, opterr == 1, meaning that error messages are printed. |
70 | * By default, opterr == 1, meaning that error messages are printed. |
|
71 | *************************************************************************/ |
71 | *************************************************************************/ |
|
72 | |
72 | |
|
73 | extern int opterr; |
73 | extern int opterr; |
|
74 | |
74 | |
|
75 | /************************************************************************* |
75 | /************************************************************************* |
|
76 | * getopt() |
76 | * getopt() |
|
77 | * The function prototype. |
77 | * The function prototype. |
|
78 | *************************************************************************/ |
78 | *************************************************************************/ |
|
79 | |
79 | |
|
80 | |
80 | |
|
81 | #ifdef __STDC__ |
81 | #ifdef __STDC__ |
|
82 | int getopt(int argc, char *argv[], char *optionString); |
82 | int getopt(int argc, char *argv[], char *optionString); |
|
83 | #else |
83 | #else |
|
84 | int getopt(); |
84 | int getopt(); |
|
85 | #endif /* __STDC__ */ |
85 | #endif /* __STDC__ */ |
|
86 | |
86 | |
|
87 | |
- | ||
88 | #endif /* _GETOPT_H */ |
87 | |
|
- | 88 | #endif /* _GETOPT_H */ |
||
89 | |
89 | |
|
90 |
|
- | ||
91 | |
- | ||
92 | |
- | ||
93 | |
- |