annotate src/getopt1.c @ 6070:8469f83b6cae

[gaim-migrate @ 6520] Well, they're alphabetized. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 09 Jul 2003 04:32:53 +0000
parents 3dbc2cd326e2
children fa6395637e2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
991
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* getopt_long and getopt_long_only entry points for GNU getopt.
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 Free Software Foundation, Inc.
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify it
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 under the terms of the GNU General Public License as published by the
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 Free Software Foundation; either version 2, or (at your option) any
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 later version.
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 GNU General Public License for more details.
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 along with this program; if not, write to the Free Software
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 #ifdef HAVE_CONFIG_H
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 #include "config.h"
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 #endif
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 #include "getopt.h"
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #if !__STDC__ && !defined(const) && IN_GCC
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #define const
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #endif
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <stdio.h>
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 /* Comment out all this code if we are using the GNU C Library, and are not
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 actually compiling the library itself. This code is part of the GNU C
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 Library, but also included in many other GNU distributions. Compiling
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 and linking in this code is a waste when using the GNU C library
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 (especially if it is a shared library). Rather than having every GNU
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 program understand `configure --with-gnu-libc' and omit the object files,
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 it is simpler to just do this in the source for each such file. */
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #if defined (_LIBC) || !defined (__GNU_LIBRARY__)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 /* This needs to come after some library #include
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 to get __GNU_LIBRARY__ defined. */
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #ifdef __GNU_LIBRARY__
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #include <stdlib.h>
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #else
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 char *getenv ();
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #endif
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 #ifndef NULL
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 #define NULL 0
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 #endif
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 int
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 getopt_long (argc, argv, options, long_options, opt_index)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 int argc;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 char *const *argv;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 const char *options;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 const struct option *long_options;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 int *opt_index;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 }
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 If an option that starts with '-' (not '--') doesn't match a long option,
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 but does match a short option, it is parsed as a short option
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 instead. */
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 int
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 getopt_long_only (argc, argv, options, long_options, opt_index)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 int argc;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 char *const *argv;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 const char *options;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 const struct option *long_options;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 int *opt_index;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 }
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 #endif /* _LIBC or not __GNU_LIBRARY__. */
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 #ifdef TEST
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 #include <stdio.h>
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 int
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 main (argc, argv)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 int argc;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 char **argv;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 int c;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 int digit_optind = 0;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 while (1)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 int this_option_optind = optind ? optind : 1;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 int option_index = 0;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 static struct option long_options[] =
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 {"add", 1, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 {"append", 0, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 {"delete", 1, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 {"verbose", 0, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 {"create", 0, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 {"file", 1, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 {0, 0, 0, 0}
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 };
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 c = getopt_long (argc, argv, "abc:d:0123456789",
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 long_options, &option_index);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 if (c == EOF)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 switch (c)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 case 0:
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 printf ("option %s", long_options[option_index].name);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 if (optarg)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 printf (" with arg %s", optarg);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 printf ("\n");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 case '0':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 case '1':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 case '2':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 case '3':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 case '4':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 case '5':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 case '6':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 case '7':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 case '8':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 case '9':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 if (digit_optind != 0 && digit_optind != this_option_optind)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 printf ("digits occur in two different argv-elements.\n");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 digit_optind = this_option_optind;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 printf ("option %c\n", c);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 case 'a':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 printf ("option a\n");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 case 'b':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 printf ("option b\n");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 case 'c':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 printf ("option c with value `%s'\n", optarg);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 case 'd':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 printf ("option d with value `%s'\n", optarg);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 case '?':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 default:
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 printf ("?? getopt returned character code 0%o ??\n", c);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 }
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 }
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 if (optind < argc)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 printf ("non-option ARGV-elements: ");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 while (optind < argc)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 printf ("%s ", argv[optind++]);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 printf ("\n");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 }
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 exit (0);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 }
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 #endif /* TEST */