Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | #include "includes.h" | - |
54 | | - |
55 | #if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET) | - |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | | - |
61 | | - |
62 | #define warnx logit | - |
63 | | - |
64 | #if 0 | - |
65 | #include <err.h> | - |
66 | #include <getopt.h> | - |
67 | #endif | - |
68 | #include <errno.h> | - |
69 | #include <stdlib.h> | - |
70 | #include <string.h> | - |
71 | #include <stdarg.h> | - |
72 | | - |
73 | #include "log.h" | - |
74 | | - |
75 | int opterr = 1; | - |
76 | int optind = 1; | - |
77 | int optopt = '?'; | - |
78 | int optreset; | - |
79 | char *optarg; | - |
80 | | - |
81 | #define PRINT_ERROR ((opterr) && (*options != ':')) | - |
82 | | - |
83 | #define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ | - |
84 | #define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ | - |
85 | #define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ | - |
86 | | - |
87 | | - |
88 | #define BADCH (int)'?' | - |
89 | #define BADARG ((*options == ':') ? (int)':' : (int)'?') | - |
90 | #define INORDER (int)1 | - |
91 | | - |
92 | #define EMSG "" | - |
93 | | - |
94 | static int getopt_internal(int, char * const *, const char *, | - |
95 | const struct option *, int *, int); | - |
96 | static int parse_long_options(char * const *, const char *, | - |
97 | const struct option *, int *, int); | - |
98 | static int gcd(int, int); | - |
99 | static void permute_args(int, int, int, char * const *); | - |
100 | | - |
101 | static char *place = EMSG; | - |
102 | | - |
103 | | - |
104 | static int nonopt_start = -1; | - |
105 | static int nonopt_end = -1; | - |
106 | | - |
107 | | - |
108 | static const char recargchar[] = "option requires an argument -- %c"; | - |
109 | static const char recargstring[] = "option requires an argument -- %s"; | - |
110 | static const char ambig[] = "ambiguous option -- %.*s"; | - |
111 | static const char noarg[] = "option doesn't take an argument -- %.*s"; | - |
112 | static const char illoptchar[] = "unknown option -- %c"; | - |
113 | static const char illoptstring[] = "unknown option -- %s"; | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | static int | - |
119 | gcd(int a, int b) | - |
120 | { | - |
121 | int c; | - |
122 | | - |
123 | c = a % b; | - |
124 | while (c != 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
125 | a = b; | - |
126 | b = c; | - |
127 | c = a % b; | - |
128 | } never executed: end of block | 0 |
129 | | - |
130 | return (b); never executed: return (b); | 0 |
131 | } | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | static void | - |
139 | permute_args(int panonopt_start, int panonopt_end, int opt_end, | - |
140 | char * const *nargv) | - |
141 | { | - |
142 | int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; | - |
143 | char *swap; | - |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
148 | nnonopts = panonopt_end - panonopt_start; | - |
149 | nopts = opt_end - panonopt_end; | - |
150 | ncycle = gcd(nnonopts, nopts); | - |
151 | cyclelen = (opt_end - panonopt_start) / ncycle; | - |
152 | | - |
153 | for (i = 0; i < ncycle; i++) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
154 | cstart = panonopt_end+i; | - |
155 | pos = cstart; | - |
156 | for (j = 0; j < cyclelen; j++) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
157 | if (pos >= panonopt_end)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
158 | pos -= nnonopts; never executed: pos -= nnonopts; | 0 |
159 | else | - |
160 | pos += nopts; never executed: pos += nopts; | 0 |
161 | swap = nargv[pos]; | - |
162 | | - |
163 | ((char **) nargv)[pos] = nargv[cstart]; | - |
164 | | - |
165 | ((char **)nargv)[cstart] = swap; | - |
166 | } never executed: end of block | 0 |
167 | } never executed: end of block | 0 |
168 | } never executed: end of block | 0 |
169 | | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | static int | - |
176 | parse_long_options(char * const *nargv, const char *options, | - |
177 | const struct option *long_options, int *idx, int short_too) | - |
178 | { | - |
179 | char *current_argv, *has_equal; | - |
180 | size_t current_argv_len; | - |
181 | int i, match; | - |
182 | | - |
183 | current_argv = place; | - |
184 | match = -1; | - |
185 | | - |
186 | optind++; | - |
187 | | - |
188 | if ((has_equal = strchr(current_argv, '=')) != NULL) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
189 | | - |
190 | current_argv_len = has_equal - current_argv; | - |
191 | has_equal++; | - |
192 | } else never executed: end of block | 0 |
193 | current_argv_len = strlen(current_argv); never executed: current_argv_len = strlen(current_argv); | 0 |
194 | | - |
195 | for (i = 0; long_options[i].name; i++) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
196 | | - |
197 | if (strncmp(current_argv, long_options[i].name, never executed: __result = (((const unsigned char *) (const char *) ( current_argv ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( long_options[i].name ))[3] - __s2[3]); never executed: end of block never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
198 | current_argv_len)) | - |
199 | continue; never executed: continue; | 0 |
200 | | - |
201 | if (strlen(long_options[i].name) == current_argv_len) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
202 | | - |
203 | match = i; | - |
204 | break; never executed: break; | 0 |
205 | } | - |
206 | | - |
207 | | - |
208 | | - |
209 | | - |
210 | if (short_too && current_argv_len == 1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
211 | continue; never executed: continue; | 0 |
212 | | - |
213 | if (match == -1) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
214 | match = i; never executed: match = i; | 0 |
215 | else { | - |
216 | | - |
217 | if (PRINT_ERROR)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
218 | warnx(ambig, (int)current_argv_len, never executed: logit(ambig, (int)current_argv_len, current_argv); | 0 |
219 | current_argv); never executed: logit(ambig, (int)current_argv_len, current_argv); | 0 |
220 | optopt = 0; | - |
221 | return (BADCH); never executed: return ((int)'?'); | 0 |
222 | } | - |
223 | } | - |
224 | if (match != -1) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
225 | if (long_options[match].has_arg == no_argumentTRUE | never evaluated | FALSE | never evaluated |
| 0 |
226 | && has_equal) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
227 | if (PRINT_ERROR)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
228 | warnx(noarg, (int)current_argv_len, never executed: logit(noarg, (int)current_argv_len, current_argv); | 0 |
229 | current_argv); never executed: logit(noarg, (int)current_argv_len, current_argv); | 0 |
230 | | - |
231 | | - |
232 | | - |
233 | if (long_options[match].flag == NULL)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
234 | optopt = long_options[match].val; never executed: BSDoptopt = long_options[match].val; | 0 |
235 | else | - |
236 | optopt = 0; never executed: BSDoptopt = 0; | 0 |
237 | return (BADARG); never executed: return (((*options == ':') ? (int)':' : (int)'?')); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
238 | } | - |
239 | if (long_options[match].has_arg == required_argument ||TRUE | never evaluated | FALSE | never evaluated |
| 0 |
240 | long_options[match].has_arg == optional_argument) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
241 | if (has_equal)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
242 | optarg = has_equal; never executed: BSDoptarg = has_equal; | 0 |
243 | else if (long_options[match].has_arg ==TRUE | never evaluated | FALSE | never evaluated |
| 0 |
244 | required_argument) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
245 | | - |
246 | | - |
247 | | - |
248 | optarg = nargv[optind++]; | - |
249 | } never executed: end of block | 0 |
250 | } never executed: end of block | 0 |
251 | if ((long_options[match].has_arg == required_argument)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
252 | && (optarg == NULL)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
253 | | - |
254 | | - |
255 | | - |
256 | | - |
257 | if (PRINT_ERROR)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
258 | warnx(recargstring, never executed: logit(recargstring, current_argv); | 0 |
259 | current_argv); never executed: logit(recargstring, current_argv); | 0 |
260 | | - |
261 | | - |
262 | | - |
263 | if (long_options[match].flag == NULL)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
264 | optopt = long_options[match].val; never executed: BSDoptopt = long_options[match].val; | 0 |
265 | else | - |
266 | optopt = 0; never executed: BSDoptopt = 0; | 0 |
267 | --optind; | - |
268 | return (BADARG); never executed: return (((*options == ':') ? (int)':' : (int)'?')); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
269 | } | - |
270 | } else { never executed: end of block | 0 |
271 | if (short_too) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
272 | --optind; | - |
273 | return (-1); never executed: return (-1); | 0 |
274 | } | - |
275 | if (PRINT_ERROR)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
276 | warnx(illoptstring, current_argv); never executed: logit(illoptstring, current_argv); | 0 |
277 | optopt = 0; | - |
278 | return (BADCH); never executed: return ((int)'?'); | 0 |
279 | } | - |
280 | if (idx)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
281 | *idx = match; never executed: *idx = match; | 0 |
282 | if (long_options[match].flag) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
283 | *long_options[match].flag = long_options[match].val; | - |
284 | return (0); never executed: return (0); | 0 |
285 | } else | - |
286 | return (long_options[match].val); never executed: return (long_options[match].val); | 0 |
287 | } | - |
288 | | - |
289 | | - |
290 | | - |
291 | | - |
292 | | - |
293 | static int | - |
294 | getopt_internal(int nargc, char * const *nargv, const char *options, | - |
295 | const struct option *long_options, int *idx, int flags) | - |
296 | { | - |
297 | char *oli; | - |
298 | int optchar, short_too; | - |
299 | static int posixly_correct = -1; | - |
300 | | - |
301 | if (options == NULL)TRUE | never evaluated | FALSE | evaluated 117 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-117 |
302 | return (-1); never executed: return (-1); | 0 |
303 | | - |
304 | | - |
305 | | - |
306 | | - |
307 | | - |
308 | if (optind == 0)TRUE | never evaluated | FALSE | evaluated 117 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-117 |
309 | optind = optreset = 1; never executed: BSDoptind = BSDoptreset = 1; | 0 |
310 | | - |
311 | | - |
312 | | - |
313 | | - |
314 | | - |
315 | if (posixly_correct == -1 || optreset)TRUE | evaluated 38 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
| FALSE | evaluated 79 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
TRUE | never evaluated | FALSE | evaluated 79 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
| 0-79 |
316 | posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);executed 38 times by 10 tests: posixly_correct = (getenv("POSIXLY_CORRECT") != ((void *)0) ); Executed by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
| 38 |
317 | if (*options == '-')TRUE | never evaluated | FALSE | evaluated 117 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-117 |
318 | flags |= FLAG_ALLARGS; never executed: flags |= 0x02; | 0 |
319 | else if (posixly_correct || *options == '+')TRUE | never evaluated | FALSE | evaluated 117 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
TRUE | never evaluated | FALSE | evaluated 117 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-117 |
320 | flags &= ~FLAG_PERMUTE; never executed: flags &= ~0x01; | 0 |
321 | if (*options == '+' || *options == '-')TRUE | never evaluated | FALSE | evaluated 117 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
TRUE | never evaluated | FALSE | evaluated 117 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-117 |
322 | options++; never executed: options++; | 0 |
323 | | - |
324 | optarg = NULL; | - |
325 | if (optreset)TRUE | never evaluated | FALSE | evaluated 117 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-117 |
326 | nonopt_start = nonopt_end = -1; never executed: nonopt_start = nonopt_end = -1; | 0 |
327 | start:code before this statement executed 117 times by 10 tests: start: Executed by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
| 117 |
328 | if (optreset || !*place) { TRUE | never evaluated | FALSE | evaluated 117 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
TRUE | evaluated 96 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
| FALSE | evaluated 21 times by 1 test |
| 0-117 |
329 | optreset = 0; | - |
330 | if (optind >= nargc) { TRUE | evaluated 38 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
| FALSE | evaluated 58 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
| 38-58 |
331 | place = EMSG; | - |
332 | if (nonopt_end != -1) {TRUE | never evaluated | FALSE | evaluated 38 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-38 |
333 | | - |
334 | permute_args(nonopt_start, nonopt_end, | - |
335 | optind, nargv); | - |
336 | optind -= nonopt_end - nonopt_start; | - |
337 | } never executed: end of block | 0 |
338 | else if (nonopt_start != -1) {TRUE | never evaluated | FALSE | evaluated 38 times by 10 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-38 |
339 | | - |
340 | | - |
341 | | - |
342 | | - |
343 | optind = nonopt_start; | - |
344 | } never executed: end of block | 0 |
345 | nonopt_start = nonopt_end = -1; | - |
346 | return (-1);executed 38 times by 10 tests: return (-1); Executed by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
| 38 |
347 | } | - |
348 | if (*(place = nargv[optind]) != '-' ||TRUE | never evaluated | FALSE | evaluated 58 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
| 0-58 |
349 | (place[1] == '\0' && strchr(options, '-') == NULL)) {TRUE | never evaluated | FALSE | evaluated 58 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-58 |
350 | place = EMSG; | - |
351 | if (flags & FLAG_ALLARGS) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
352 | | - |
353 | | - |
354 | | - |
355 | | - |
356 | optarg = nargv[optind++]; | - |
357 | return (INORDER); never executed: return ((int)1); | 0 |
358 | } | - |
359 | if (!(flags & FLAG_PERMUTE)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
360 | | - |
361 | | - |
362 | | - |
363 | | - |
364 | return (-1); never executed: return (-1); | 0 |
365 | } | - |
366 | | - |
367 | if (nonopt_start == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
368 | nonopt_start = optind; never executed: nonopt_start = BSDoptind; | 0 |
369 | else if (nonopt_end != -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
370 | permute_args(nonopt_start, nonopt_end, | - |
371 | optind, nargv); | - |
372 | nonopt_start = optind - | - |
373 | (nonopt_end - nonopt_start); | - |
374 | nonopt_end = -1; | - |
375 | } never executed: end of block | 0 |
376 | optind++; | - |
377 | | - |
378 | goto start; never executed: goto start; | 0 |
379 | } | - |
380 | if (nonopt_start != -1 && nonopt_end == -1)TRUE | never evaluated | FALSE | evaluated 58 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
TRUE | never evaluated | FALSE | never evaluated |
| 0-58 |
381 | nonopt_end = optind; never executed: nonopt_end = BSDoptind; | 0 |
382 | | - |
383 | | - |
384 | | - |
385 | | - |
386 | if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {TRUE | evaluated 58 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
| FALSE | never evaluated |
TRUE | never evaluated | FALSE | evaluated 58 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
TRUE | never evaluated | FALSE | never evaluated |
| 0-58 |
387 | optind++; | - |
388 | place = EMSG; | - |
389 | | - |
390 | | - |
391 | | - |
392 | | - |
393 | if (nonopt_end != -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
394 | permute_args(nonopt_start, nonopt_end, | - |
395 | optind, nargv); | - |
396 | optind -= nonopt_end - nonopt_start; | - |
397 | } never executed: end of block | 0 |
398 | nonopt_start = nonopt_end = -1; | - |
399 | return (-1); never executed: return (-1); | 0 |
400 | } | - |
401 | }executed 58 times by 4 tests: end of block Executed by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
| 58 |
402 | | - |
403 | | - |
404 | | - |
405 | | - |
406 | | - |
407 | | - |
408 | | - |
409 | if (long_options != NULL && place != nargv[optind] &&TRUE | never evaluated | FALSE | evaluated 79 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
TRUE | never evaluated | FALSE | never evaluated |
| 0-79 |
410 | (*place == '-' || (flags & FLAG_LONGONLY))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
411 | short_too = 0; | - |
412 | if (*place == '-')TRUE | never evaluated | FALSE | never evaluated |
| 0 |
413 | place++; never executed: place++; | 0 |
414 | else if (*place != ':' && strchr(options, *place) != NULL)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
415 | short_too = 1; never executed: short_too = 1; | 0 |
416 | | - |
417 | optchar = parse_long_options(nargv, options, long_options, | - |
418 | idx, short_too); | - |
419 | if (optchar != -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
420 | place = EMSG; | - |
421 | return (optchar); never executed: return (optchar); | 0 |
422 | } | - |
423 | } never executed: end of block | 0 |
424 | | - |
425 | if ((optchar = (int)*place++) == (int)':' ||TRUE | never evaluated | FALSE | evaluated 79 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
| 0-79 |
426 | (optchar == (int)'-' && *place != '\0') ||TRUE | never evaluated | FALSE | evaluated 79 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
TRUE | never evaluated | FALSE | never evaluated |
| 0-79 |
427 | (oli = strchr(options, optchar)) == NULL) {TRUE | never evaluated | FALSE | evaluated 79 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
TRUE | never evaluated | FALSE | evaluated 79 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-79 |
428 | | - |
429 | | - |
430 | | - |
431 | | - |
432 | | - |
433 | if (optchar == (int)'-' && *place == '\0')TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
434 | return (-1); never executed: return (-1); | 0 |
435 | if (!*place)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
436 | ++optind; never executed: ++BSDoptind; | 0 |
437 | if (PRINT_ERROR)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
438 | warnx(illoptchar, optchar); never executed: logit(illoptchar, optchar); | 0 |
439 | optopt = optchar; | - |
440 | return (BADCH); never executed: return ((int)'?'); | 0 |
441 | } | - |
442 | if (long_options != NULL && optchar == 'W' && oli[1] == ';') {TRUE | never evaluated | FALSE | evaluated 79 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-79 |
443 | | - |
444 | if (*place) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
445 | ; never executed: ; | 0 |
446 | else if (++optind >= nargc) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
447 | place = EMSG; | - |
448 | if (PRINT_ERROR)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
449 | warnx(recargchar, optchar); never executed: logit(recargchar, optchar); | 0 |
450 | optopt = optchar; | - |
451 | return (BADARG); never executed: return (((*options == ':') ? (int)':' : (int)'?')); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
452 | } else | - |
453 | place = nargv[optind]; never executed: place = nargv[BSDoptind]; | 0 |
454 | optchar = parse_long_options(nargv, options, long_options, | - |
455 | idx, 0); | - |
456 | place = EMSG; | - |
457 | return (optchar); never executed: return (optchar); | 0 |
458 | } | - |
459 | if (*++oli != ':') { TRUE | evaluated 30 times by 2 tests | FALSE | evaluated 49 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
| 30-49 |
460 | if (!*place)TRUE | evaluated 9 times by 2 tests | FALSE | evaluated 21 times by 1 test |
| 9-21 |
461 | ++optind;executed 9 times by 2 tests: ++BSDoptind; | 9 |
462 | } else { executed 30 times by 2 tests: end of block | 30 |
463 | optarg = NULL; | - |
464 | if (*place) TRUE | never evaluated | FALSE | evaluated 49 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
| 0-49 |
465 | optarg = place; never executed: BSDoptarg = place; | 0 |
466 | else if (oli[1] != ':') { TRUE | evaluated 49 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
| FALSE | never evaluated |
| 0-49 |
467 | if (++optind >= nargc) { TRUE | never evaluated | FALSE | evaluated 49 times by 4 testsEvaluated by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
|
| 0-49 |
468 | place = EMSG; | - |
469 | if (PRINT_ERROR)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
470 | warnx(recargchar, optchar); never executed: logit(recargchar, optchar); | 0 |
471 | optopt = optchar; | - |
472 | return (BADARG); never executed: return (((*options == ':') ? (int)':' : (int)'?')); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
473 | } else | - |
474 | optarg = nargv[optind];executed 49 times by 4 tests: BSDoptarg = nargv[BSDoptind]; Executed by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
| 49 |
475 | } | - |
476 | place = EMSG; | - |
477 | ++optind; | - |
478 | }executed 49 times by 4 tests: end of block Executed by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
| 49 |
479 | | - |
480 | return (optchar);executed 79 times by 4 tests: return (optchar); Executed by:- ssh-keygen
- sshd
- test_hostkeys
- test_sshkey
| 79 |
481 | } | - |
482 | | - |
483 | | - |
484 | | - |
485 | | - |
486 | | - |
487 | | - |
488 | | - |
489 | int | - |
490 | getopt(int nargc, char * const *nargv, const char *options) | - |
491 | { | - |
492 | | - |
493 | | - |
494 | | - |
495 | | - |
496 | | - |
497 | | - |
498 | | - |
499 | | - |
500 | | - |
501 | return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));executed 117 times by 10 tests: return (getopt_internal(nargc, nargv, options, ((void *)0) , ((void *)0) , 0)); Executed by:- ssh-keygen
- sshd
- test_bitmap
- test_conversion
- test_hostkeys
- test_kex
- test_match
- test_sshbuf
- test_sshkey
- test_utf8
| 117 |
502 | } | - |
503 | | - |
504 | #if 0 | - |
505 | | - |
506 | | - |
507 | | - |
508 | | - |
509 | int | - |
510 | getopt_long(int nargc, char * const *nargv, const char *options, | - |
511 | const struct option *long_options, int *idx) | - |
512 | { | - |
513 | | - |
514 | return (getopt_internal(nargc, nargv, options, long_options, idx, | - |
515 | FLAG_PERMUTE)); | - |
516 | } | - |
517 | | - |
518 | | - |
519 | | - |
520 | | - |
521 | | - |
522 | int | - |
523 | getopt_long_only(int nargc, char * const *nargv, const char *options, | - |
524 | const struct option *long_options, int *idx) | - |
525 | { | - |
526 | | - |
527 | return (getopt_internal(nargc, nargv, options, long_options, idx, | - |
528 | FLAG_PERMUTE|FLAG_LONGONLY)); | - |
529 | } | - |
530 | #endif | - |
531 | | - |
532 | #endif /* !defined(HAVE_GETOPT) || !defined(HAVE_OPTRESET) */ | - |
| | |