annotate audacious/getopt1.c @ 517:55dc40ff1aff trunk

[svn] Add tell_audio(AFormat *, gint *, gint *), for retrieving audio format information from an output plugin. Right now, we need this inside the core to do effects processing. Rationale: - If tell_audio() is unavailable, do not do processing. - If tell_audio() is available and there is a format mismatch, do not do processing yet -- we need to reinitialize the output port before we can do anything useful. Disk Writer and Crossfade are too fragile to make these changes to, so they do not support tell_audio yet.
author nenolod
date Thu, 26 Jan 2006 11:37:48 -0800
parents cb178e5ad177
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* getopt_long and getopt_long_only entry points for GNU getopt.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 This file is part of the GNU C Library. Its master source is NOT part of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 the C library, however. The master source lives in /gd/gnu/lib.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 The GNU C Library is free software; you can redistribute it and/or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 modify it under the terms of the GNU Library General Public License as
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 published by the Free Software Foundation; either version 2 of the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 License, or (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 The GNU C Library is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 Library General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 You should have received a copy of the GNU Library General Public
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 License along with the GNU C Library; see the file COPYING.LIB. If not,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 #include <config.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include "getopt.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #if !defined (__STDC__) || !__STDC__
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 /* This is a separate conditional since some stdc systems
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 reject `defined (const)'. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #ifndef const
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 #define const
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 #include <stdio.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 /* Comment out all this code if we are using the GNU C Library, and are not
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 actually compiling the library itself. This code is part of the GNU C
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 Library, but also included in many other GNU distributions. Compiling
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 and linking in this code is a waste when using the GNU C library
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 (especially if it is a shared library). Rather than having every GNU
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 program understand `configure --with-gnu-libc' and omit the object files,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 it is simpler to just do this in the source for each such file. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 #define GETOPT_INTERFACE_VERSION 2
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 #include <gnu-versions.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 #define ELIDE_CODE
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 #ifndef ELIDE_CODE
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 /* This needs to come after some library #include
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 to get __GNU_LIBRARY__ defined. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 #ifdef __GNU_LIBRARY__
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 #include <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 #ifndef NULL
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 #define NULL 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 int
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 getopt_long(argc, argv, options, long_options, opt_index)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 int argc;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 char *const *argv;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 const char *options;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 const struct option *long_options;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 int *opt_index;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 return _getopt_internal(argc, argv, options, long_options, opt_index, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 If an option that starts with '-' (not '--') doesn't match a long option,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 but does match a short option, it is parsed as a short option
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 instead. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 int
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 getopt_long_only(argc, argv, options, long_options, opt_index)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 int argc;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 char *const *argv;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 const char *options;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 const struct option *long_options;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 int *opt_index;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 return _getopt_internal(argc, argv, options, long_options, opt_index, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 #endif /* Not ELIDE_CODE. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 #ifdef TEST
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 #include <stdio.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 int
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 main(argc, argv)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 int argc;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 char **argv;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 int c;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 int digit_optind = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 while (1) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 int this_option_optind = optind ? optind : 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 int option_index = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 static struct option long_options[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 {"add", 1, 0, 0},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 {"append", 0, 0, 0},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 {"delete", 1, 0, 0},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 {"verbose", 0, 0, 0},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 {"create", 0, 0, 0},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 {"file", 1, 0, 0},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 {0, 0, 0, 0}
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 c = getopt_long(argc, argv, "abc:d:0123456789",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 long_options, &option_index);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 if (c == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 switch (c) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 case 0:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 printf("option %s", long_options[option_index].name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 if (optarg)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 printf(" with arg %s", optarg);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 printf("\n");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 case '0':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 case '1':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 case '2':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 case '3':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 case '4':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 case '5':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 case '6':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 case '7':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 case '8':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 case '9':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 if (digit_optind != 0 && digit_optind != this_option_optind)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 printf("digits occur in two different argv-elements.\n");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 digit_optind = this_option_optind;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 printf("option %c\n", c);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 case 'a':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 printf("option a\n");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 case 'b':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 printf("option b\n");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 case 'c':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 printf("option c with value `%s'\n", optarg);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 case 'd':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 printf("option d with value `%s'\n", optarg);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 case '?':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 default:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 printf("?? getopt returned character code 0%o ??\n", c);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 if (optind < argc) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 printf("non-option ARGV-elements: ");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 while (optind < argc)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 printf("%s ", argv[optind++]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 printf("\n");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 exit(0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 #endif /* TEST */