1 /* -*- buffer-read-only: t -*- vi: set ro:
2    THIS FILE IS GENERATED AUTOMATICALLY.  PLEASE DO NOT EDIT.
3 */
4 #line 1 "eclatcl.m4"
5 /* This file is part of Eclat.
6    Copyright (C) 2012-2018 Sergey Poznyakoff.
7 
8    Eclat is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3, or (at your option)
11    any later version.
12 
13    Eclat is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with Eclat.  If not, see <http://www.gnu.org/licenses/>. */
20 
21 #line 23
22 
23 
24 
25 
26 #line 35
27 
28 
29 #line 1 "ispeek-cl.opt"
30 /* This file is part of Eclat.
31    Copyright (C) 2012-2018 Sergey Poznyakoff.
32 
33    Eclat is free software; you can redistribute it and/or modify
34    it under the terms of the GNU General Public License as published by
35    the Free Software Foundation; either version 3, or (at your option)
36    any later version.
37 
38    Eclat is distributed in the hope that it will be useful,
39    but WITHOUT ANY WARRANTY; without even the implied warranty of
40    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
41    GNU General Public License for more details.
42 
43    You should have received a copy of the GNU General Public License
44    along with Eclat.  If not, see <http://www.gnu.org/licenses/>. */
45 
46 #ifdef HAVE_GETOPT_H
47 # include <getopt.h>
48 #endif
49 
50 #line 81 "ispeek-cl.opt"
51 
52 #line 81
53 
54 #line 81
55 #ifdef HAVE_CONFIG_H
56 #line 81
57 # include <config.h>
58 #line 81
59 #endif
60 #line 81
61 #ifdef HAVE_GETOPT_H
62 #line 81
63 # include <getopt.h>
64 #line 81
65 #endif
66 #line 81
67 #include <unistd.h>
68 #line 81
69 
70 #line 81
71 #include <grecs.h>
72 #line 81
73 #include <grecs/opt.h>
74 #line 81
75 /* Option codes */
76 #line 81
77 enum {
78 #line 81
79 	_OPTION_INIT=255,
80 #line 81
81 	#line 81 "ispeek-cl.opt"
82 
83 #line 81
84 	OPTION_USAGE,
85 
86 #line 81 "ispeek-cl.opt"
87 	MAX_OPTION
88 #line 81
89 };
90 #line 81
91 #ifdef HAVE_GETOPT_LONG
92 #line 81
93 static struct option long_options[] = {
94 #line 81
95 	#line 28 "ispeek-cl.opt"
96 
97 #line 28
98 	{ "base", required_argument, 0, 'b' },
99 #line 34 "ispeek-cl.opt"
100 
101 #line 34
102 	{ "port", required_argument, 0, 'p' },
103 #line 45 "ispeek-cl.opt"
104 
105 #line 45
106 	{ "recursive", no_argument, 0, 'r' },
107 #line 51 "ispeek-cl.opt"
108 
109 #line 51
110 	{ "names", no_argument, 0, 'N' },
111 #line 57 "ispeek-cl.opt"
112 
113 #line 57
114 	{ "quote", no_argument, 0, 'Q' },
115 #line 63 "ispeek-cl.opt"
116 
117 #line 63
118 	{ "type", no_argument, 0, 'T' },
119 #line 69 "ispeek-cl.opt"
120 
121 #line 69
122 	{ "delimiter", required_argument, 0, 'D' },
123 #line 75 "ispeek-cl.opt"
124 
125 #line 75
126 	{ "debug", no_argument, 0, 'd' },
127 #line 81 "ispeek-cl.opt"
128 
129 #line 81
130 	{ "help", no_argument, 0, 'h' },
131 #line 81 "ispeek-cl.opt"
132 
133 #line 81
134 	{ "usage", no_argument, 0, OPTION_USAGE },
135 #line 81 "ispeek-cl.opt"
136 
137 #line 81
138 	{ "version", no_argument, 0, 'V' },
139 
140 #line 81 "ispeek-cl.opt"
141 	{0, 0, 0, 0}
142 #line 81
143 };
144 #line 81
145 #endif
146 #line 81
147 static struct grecs_opthelp opthelp[] = {
148 #line 81
149 	#line 30 "ispeek-cl.opt"
150 
151 #line 30
152 	{
153 #line 30
154 #ifdef HAVE_GETOPT_LONG
155 #line 30
156 	  "-b, --base",
157 #line 30
158 #else
159 #line 30
160 	  "-b",
161 #line 30
162 #endif
163 #line 30
164 				   N_("URL"), 0, N_("base URL") },
165 #line 36 "ispeek-cl.opt"
166 
167 #line 36
168 	{
169 #line 36
170 #ifdef HAVE_GETOPT_LONG
171 #line 36
172 	  "-p, --port",
173 #line 36
174 #else
175 #line 36
176 	  "-p",
177 #line 36
178 #endif
179 #line 36
180 				   N_("NUMBER"), 0, N_("set remote port number") },
181 #line 47 "ispeek-cl.opt"
182 
183 #line 47
184 	{
185 #line 47
186 #ifdef HAVE_GETOPT_LONG
187 #line 47
188 	  "-r, --recursive",
189 #line 47
190 #else
191 #line 47
192 	  "-r",
193 #line 47
194 #endif
195 #line 47
196 				   NULL, 0, N_("list recursively") },
197 #line 53 "ispeek-cl.opt"
198 
199 #line 53
200 	{
201 #line 53
202 #ifdef HAVE_GETOPT_LONG
203 #line 53
204 	  "-N, --names",
205 #line 53
206 #else
207 #line 53
208 	  "-N",
209 #line 53
210 #endif
211 #line 53
212 				   NULL, 0, N_("print key names") },
213 #line 59 "ispeek-cl.opt"
214 
215 #line 59
216 	{
217 #line 59
218 #ifdef HAVE_GETOPT_LONG
219 #line 59
220 	  "-Q, --quote",
221 #line 59
222 #else
223 #line 59
224 	  "-Q",
225 #line 59
226 #endif
227 #line 59
228 				   NULL, 0, N_("quote strings") },
229 #line 65 "ispeek-cl.opt"
230 
231 #line 65
232 	{
233 #line 65
234 #ifdef HAVE_GETOPT_LONG
235 #line 65
236 	  "-T, --type",
237 #line 65
238 #else
239 #line 65
240 	  "-T",
241 #line 65
242 #endif
243 #line 65
244 				   NULL, 0, N_("print value types") },
245 #line 71 "ispeek-cl.opt"
246 
247 #line 71
248 	{
249 #line 71
250 #ifdef HAVE_GETOPT_LONG
251 #line 71
252 	  "-D, --delimiter",
253 #line 71
254 #else
255 #line 71
256 	  "-D",
257 #line 71
258 #endif
259 #line 71
260 				   N_("STRING"), 0, N_("use STRING as a delimiter, instead of colon") },
261 #line 77 "ispeek-cl.opt"
262 
263 #line 77
264 	{
265 #line 77
266 #ifdef HAVE_GETOPT_LONG
267 #line 77
268 	  "-d, --debug",
269 #line 77
270 #else
271 #line 77
272 	  "-d",
273 #line 77
274 #endif
275 #line 77
276 				   NULL, 0, N_("increase debugging level") },
277 #line 81 "ispeek-cl.opt"
278 
279 #line 81
280 	{ NULL, NULL, 0, N_("Other options") },
281 #line 81 "ispeek-cl.opt"
282 
283 #line 81
284 	{
285 #line 81
286 #ifdef HAVE_GETOPT_LONG
287 #line 81
288 	  "-h, --help",
289 #line 81
290 #else
291 #line 81
292 	  "-h",
293 #line 81
294 #endif
295 #line 81
296 				   NULL, 0, N_("Give this help list") },
297 #line 81 "ispeek-cl.opt"
298 
299 #line 81
300 	{
301 #line 81
302 #ifdef HAVE_GETOPT_LONG
303 #line 81
304 	  "--usage",
305 #line 81
306 #else
307 #line 81
308 	  "",
309 #line 81
310 #endif
311 #line 81
312 				   NULL, 0, N_("Give a short usage message") },
313 #line 81 "ispeek-cl.opt"
314 
315 #line 81
316 	{
317 #line 81
318 #ifdef HAVE_GETOPT_LONG
319 #line 81
320 	  "-V, --version",
321 #line 81
322 #else
323 #line 81
324 	  "-V",
325 #line 81
326 #endif
327 #line 81
328 				   NULL, 0, N_("Print program version") },
329 
330 #line 81 "ispeek-cl.opt"
331 };
332 #line 21 "ispeek-cl.opt"
333 
334 #line 21
335 
336 #line 21
337 static struct grecs_proginfo proginfo = {
338 #line 21
339 	"ispeek", /* progname */
340 #line 21
341 	NULL, /* subcommands */
342 #line 21
343 	N_("EC2 instance store lister"), /* docstring */
344 #line 21
345 	N_("PATH [KEY...]"), /* args_doc */
346 #line 21
347 	opthelp, /* opthelp */
348 #line 21
349 	sizeof(opthelp)/sizeof(opthelp[0]), /* optcount */
350 #line 21
351 	NULL, /* print_help_hook */
352 #line 21
353 	NULL, /* print_version_hook */
354 #line 21
355 	PACKAGE_NAME,    /* package */
356 #line 21
357 	PACKAGE_VERSION, /* version */
358 #line 21
359 	NULL, /* license */
360 #line 21
361 	"2012-2018",/* copyright_year */
362 #line 21
363 	"Sergey Poznyakoff", /* copyright_holder */
364 #line 21
365 	NULL, /* *authors */
366 #line 21
367 	"<" PACKAGE_BUGREPORT ">", /* bug_address */
368 #line 21
369 	PACKAGE_URL, /* url */
370 #line 21
371 	NULL  /* epilogue */
372 #line 21
373 };
374 #line 21
375 static struct grecs_node *cmdline_tree;
376 #line 21
377 
378 #line 21
379 
380 #line 81 "ispeek-cl.opt"
381 
382 #line 81
383 
384 
385 static void
parse_options(int * pargc,char ** pargv[])386 parse_options(int *pargc, char **pargv[])
387 {
388 	int argc = *pargc;
389 	char **argv = *pargv;
390 	int index;
391 
392 
393 #line 90
394  {
395 #line 90
396   int c;
397 #line 90
398 
399 #line 90
400   optind = 0;
401 #line 90
402 #ifdef HAVE_GETOPT_LONG
403 #line 90
404   while ((c = getopt_long(argc, argv, "b:p:rNQTD:dhV",
405 #line 90
406 			  long_options, NULL)) != EOF)
407 #line 90
408 #else
409 #line 90
410   while ((c = getopt(argc, argv, "b:p:rNQTD:dhV")) != EOF)
411 #line 90
412 #endif
413 #line 90
414     {
415 #line 90
416       switch (c)
417 #line 90
418 	{
419 #line 90
420 	default:
421 #line 90
422 	   	   exit(EX_USAGE);
423 #line 90
424 	#line 30 "ispeek-cl.opt"
425 	 case 'b':
426 #line 30
427 	  {
428 #line 30
429 
430         base_url = optarg;
431 
432 #line 32
433 	     break;
434 #line 32
435 	  }
436 #line 36 "ispeek-cl.opt"
437 	 case 'p':
438 #line 36
439 	  {
440 #line 36
441 
442 	char *p;
443 
444 	errno = 0;
445 	port = strtol(optarg, &p, 10);
446 	if (port <= 0 || port > USHRT_MAX || errno || *p)
447 		die(EX_USAGE, "invalid port number");
448 
449 #line 43
450 	     break;
451 #line 43
452 	  }
453 #line 47 "ispeek-cl.opt"
454 	 case 'r':
455 #line 47
456 	  {
457 #line 47
458 
459 	recursive = 1;
460 
461 #line 49
462 	     break;
463 #line 49
464 	  }
465 #line 53 "ispeek-cl.opt"
466 	 case 'N':
467 #line 53
468 	  {
469 #line 53
470 
471 	print_options |= PRINT_NAME;
472 
473 #line 55
474 	     break;
475 #line 55
476 	  }
477 #line 59 "ispeek-cl.opt"
478 	 case 'Q':
479 #line 59
480 	  {
481 #line 59
482 
483 	print_options |= PRINT_QUOTE;
484 
485 #line 61
486 	     break;
487 #line 61
488 	  }
489 #line 65 "ispeek-cl.opt"
490 	 case 'T':
491 #line 65
492 	  {
493 #line 65
494 
495 	print_options |= PRINT_TYPE;
496 
497 #line 67
498 	     break;
499 #line 67
500 	  }
501 #line 71 "ispeek-cl.opt"
502 	 case 'D':
503 #line 71
504 	  {
505 #line 71
506 
507 	delim = optarg;
508 
509 #line 73
510 	     break;
511 #line 73
512 	  }
513 #line 77 "ispeek-cl.opt"
514 	 case 'd':
515 #line 77
516 	  {
517 #line 77
518 
519 	debug_category[0].level++;
520 
521 #line 79
522 	     break;
523 #line 79
524 	  }
525 #line 81 "ispeek-cl.opt"
526 	 case 'h':
527 #line 81
528 	  {
529 #line 81
530 
531 #line 81
532 		grecs_print_help(&proginfo);
533 #line 81
534 		exit(0);
535 #line 81
536 
537 #line 81
538 	     break;
539 #line 81
540 	  }
541 #line 81 "ispeek-cl.opt"
542 	 case OPTION_USAGE:
543 #line 81
544 	  {
545 #line 81
546 
547 #line 81
548 		grecs_print_usage(&proginfo);
549 #line 81
550 		exit(0);
551 #line 81
552 
553 #line 81
554 	     break;
555 #line 81
556 	  }
557 #line 81 "ispeek-cl.opt"
558 	 case 'V':
559 #line 81
560 	  {
561 #line 81
562 
563 #line 81
564 		/* Give version */
565 #line 81
566 		grecs_print_version(&proginfo, stdout);
567 #line 81
568 		exit(0);
569 #line 81
570 
571 #line 81
572 	     break;
573 #line 81
574 	  }
575 
576 #line 90 "ispeek-cl.opt"
577 	}
578 #line 90
579     }
580 #line 90
581 
582 #line 90
583   index = optind;
584 #line 90
585   if (cmdline_tree)
586 #line 90
587     {
588 #line 90
589       struct grecs_node *rn = grecs_node_create(grecs_node_root, NULL);
590 #line 90
591       rn->down = cmdline_tree;
592 #line 90
593       cmdline_tree = rn;
594 #line 90
595     }
596 #line 90
597  }
598 #line 90
599 
600 	*pargc -= index;
601 	*pargv += index;
602 }
603 
604