gsch2pcb: Make --m4-file and -m4-pcbdir arguments work again.
[geda-gaf/peter-b.git] / utils / gschlas / parsecmd.c
blobf65730e627b9dd16e1e7bccd4f6cbf53887e20a5
1 /* gEDA - GPL Electronic Design Automation
2 * gschlas - gEDA Load and Save
3 * Copyright (C) 2002-2010 Ales Hvezda
4 * Copyright (C) 2002-2010 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 #ifdef HAVE_LIBDMALLOC
37 #include <dmalloc.h>
38 #endif
40 #define OPTIONS "hqveu"
42 #ifndef OPTARG_IN_UNISTD
43 extern char *optarg;
44 extern int optind;
45 #endif
48 void usage(char *cmd)
50 printf("Usage: %s [OPTIONS] filename1 ... filenameN\n", cmd);
51 printf(" -e Embed all components/pictures\n");
52 printf(" -u Unembed all components/pictures\n");
53 printf(" -q Quiet mode\n");
54 printf(" -v Verbose mode on\n");
55 printf(" -h This message\n");
56 printf("\n");
57 exit(0);
60 int parse_commandline(int argc, char *argv[])
62 int ch;
64 while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
65 switch (ch) {
67 case 'v':
68 verbose_mode = TRUE;
69 break;
71 case 'q':
72 quiet_mode = TRUE;
73 break;
75 case 'e':
76 embed_mode = TRUE;
77 break;
79 case 'u':
80 unembed_mode = TRUE;
81 break;
83 case 'h':
84 usage(argv[0]);
85 break;
87 case '?':
88 default:
89 usage(argv[0]);
90 break;
94 if (quiet_mode) {
95 verbose_mode = FALSE;
98 if (embed_mode && unembed_mode) {
99 fprintf(stderr,
100 "Cannot specify both -e and -u at the same time (ignoring both flags)\n");
101 embed_mode = FALSE;
102 unembed_mode = FALSE;
105 return (optind);