annotate src/getopt1.c @ 12785:beda858e88fa

[gaim-migrate @ 15132] Whitespace and a note about something that may or may not want to be looked at in the future. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Mon, 09 Jan 2006 07:49:05 +0000
parents 840a7d176754
children
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.
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 991
diff changeset
2 Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 991
diff changeset
3 to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 991
diff changeset
4 source distribution.
991
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 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
7 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
8 Free Software Foundation; either version 2, or (at your option) any
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 later version.
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 This program is distributed in the hope that it will be useful,
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 GNU General Public License for more details.
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 along with this program; if not, write to the Free Software
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
12371
840a7d176754 [gaim-migrate @ 14675]
Richard Laager <rlaager@wiktel.com>
parents: 8046
diff changeset
19
991
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 #ifdef HAVE_CONFIG_H
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 #include "config.h"
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 #endif
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #include "getopt.h"
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #if !__STDC__ && !defined(const) && IN_GCC
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #define const
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #endif
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <stdio.h>
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 /* 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
33 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
34 Library, but also included in many other GNU distributions. Compiling
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 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
36 (especially if it is a shared library). Rather than having every GNU
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 program understand `configure --with-gnu-libc' and omit the object files,
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 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
39
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #if defined (_LIBC) || !defined (__GNU_LIBRARY__)
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
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 /* This needs to come after some library #include
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 to get __GNU_LIBRARY__ defined. */
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #ifdef __GNU_LIBRARY__
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #include <stdlib.h>
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #else
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 char *getenv ();
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #endif
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 #ifndef NULL
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 #define NULL 0
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 #endif
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 int
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 getopt_long (argc, argv, options, long_options, opt_index)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 int argc;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 char *const *argv;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 const char *options;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 const struct option *long_options;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 int *opt_index;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
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
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 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
68 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
69 instead. */
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 int
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 getopt_long_only (argc, argv, options, long_options, opt_index)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 int argc;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 char *const *argv;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 const char *options;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 const struct option *long_options;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 int *opt_index;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
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
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 #endif /* _LIBC or not __GNU_LIBRARY__. */
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 #ifdef TEST
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 #include <stdio.h>
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 int
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 main (argc, argv)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 int argc;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 char **argv;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 int c;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 int digit_optind = 0;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 while (1)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 int this_option_optind = optind ? optind : 1;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 int option_index = 0;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 static struct option long_options[] =
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 {"add", 1, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 {"append", 0, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 {"delete", 1, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 {"verbose", 0, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 {"create", 0, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 {"file", 1, 0, 0},
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 {0, 0, 0, 0}
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
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 c = getopt_long (argc, argv, "abc:d:0123456789",
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 long_options, &option_index);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 if (c == EOF)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 switch (c)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 case 0:
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 printf ("option %s", long_options[option_index].name);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 if (optarg)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 printf (" with arg %s", optarg);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 printf ("\n");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 case '0':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 case '1':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 case '2':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 case '3':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 case '4':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 case '5':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 case '6':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 case '7':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 case '8':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 case '9':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 if (digit_optind != 0 && digit_optind != this_option_optind)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 printf ("digits occur in two different argv-elements.\n");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 digit_optind = this_option_optind;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 printf ("option %c\n", c);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 case 'a':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 printf ("option a\n");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 case 'b':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 printf ("option b\n");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 case 'c':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 printf ("option c with value `%s'\n", optarg);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 case 'd':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 printf ("option d with value `%s'\n", optarg);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 case '?':
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 break;
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 default:
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 printf ("?? getopt returned character code 0%o ??\n", c);
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
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 if (optind < argc)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 {
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 printf ("non-option ARGV-elements: ");
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 while (optind < argc)
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 printf ("%s ", argv[optind++]);
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 printf ("\n");
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
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 exit (0);
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
3dbc2cd326e2 [gaim-migrate @ 1001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 #endif /* TEST */