missing NULL terminator in set_config_x
[geda-gaf.git] / utils / gschlas / parsecmd.c
blob90729942986c172497e5cea10047b2d2d36fb4d7
1 /* gEDA - GPL Electronic Design Automation
2 * gschlas - gEDA Load and Save
3 * Copyright (C) 2002-2010 Ales Hvezda
4 * Copyright (C) 2002-2020 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <config.h>
23 #include <stdio.h>
24 #ifdef HAVE_STRING_H
25 #include <string.h>
26 #endif
27 #ifdef HAVE_UNISTD_H
28 #include <unistd.h>
29 #endif
31 #include <libgeda/libgeda.h>
33 #include "../include/globals.h"
34 #include "../include/prototype.h"
36 #define OPTIONS "hqveu"
38 #ifndef OPTARG_IN_UNISTD
39 extern char *optarg;
40 extern int optind;
41 #endif
43 #ifdef HAVE_GETOPT_H
44 #include <getopt.h>
45 #endif
47 #ifdef HAVE_GETOPT_LONG
48 struct option long_options[] =
50 {"embed", 0, 0, 'e'},
51 {"unembed", 0, 0, 'u'},
52 {"quiet", 0, 0, 'q'},
53 {"verbose", 0, 0, 'v'},
54 {"help", 0, 0, 'h'}
56 #endif
58 void usage(char *cmd)
60 printf("Usage: %s [OPTIONS] filename1 ... filenameN\n\n", cmd);
61 printf(" -e, --embed Embed all components/pictures\n");
62 printf(" -u, --unembed Unembed all components/pictures\n");
63 printf(" -q, --quiet Quiet mode\n");
64 printf(" -v, --verbose Verbose mode on\n");
65 printf(" -h, --help This message\n");
66 printf("\n");
67 exit(0);
70 int parse_commandline(int argc, char *argv[])
72 int ch;
74 #ifdef HAVE_GETOPT_LONG
75 while ((ch = getopt_long (argc, argv, OPTIONS, long_options, NULL)) != -1) {
76 #else
77 while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
78 #endif
79 switch (ch) {
81 case 'v':
82 verbose_mode = TRUE;
83 break;
85 case 'q':
86 quiet_mode = TRUE;
87 break;
89 case 'e':
90 embed_mode = TRUE;
91 break;
93 case 'u':
94 unembed_mode = TRUE;
95 break;
97 case 'h':
98 usage(argv[0]);
99 break;
101 case '?':
102 default:
103 usage(argv[0]);
104 break;
108 if (quiet_mode) {
109 verbose_mode = FALSE;
112 if (embed_mode && unembed_mode) {
113 fprintf(stderr,
114 "Cannot specify both -e and -u at the same time (ignoring both flags)\n");
115 embed_mode = FALSE;
116 unembed_mode = FALSE;
119 return (optind);