1 /* gEDA - GPL Electronic Design Automation
2 * gattrib -- gEDA component and net attribute manipulation using spreadsheet.
3 * Copyright (C) 2003-2010 Stuart D. Brorson.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * \brief Functions to parse the command line.
23 * Functions to parse the command line and to provide usage
40 #endif /* Checking for getopt */
42 #if !defined(HAVE_GETOPT_LONG) || !defined(HAVE_GETOPT_H)
43 /*! \brief Command line option string for getopt.
45 * Command line option string for getopt. Defines "q" for quiet,
46 * "v" for verbose and "h" for help.
49 #ifndef OPTARG_IN_UNISTD
53 #endif /* Checking for getopt_long */
56 /*------------------------------------------------------------------
57 * Gattrib specific includes
58 *------------------------------------------------------------------*/
59 #include <libgeda/libgeda.h> /* geda library fcns */
60 #include "../include/struct.h" /* typdef and struct declarations */
61 #include "../include/prototype.h" /* function prototypes */
62 #include "../include/globals.h"
63 #include "../include/gettext.h"
66 * \brief Print usage message
68 * Prints gattrib usage information to stdout.
69 * \param cmd Unused parameter.
77 "Gattrib: The gEDA project\'s attribute editor.\n"
78 "Presents schematic attributes in easy-to-edit spreadsheet format.\n"
80 "Usage: %s [OPTIONS] filename1 ... filenameN\n"
81 " -q, --quiet Quiet mode\n"
82 " -v, --verbose Verbose mode on\n"
83 " -h, --help This help menu\n"
86 " * What do the colors of the cell text mean?\n"
87 " The cell colors indicate the visibility of the attribute.\n"
88 " Black = Visible attribute, value displayed only.\n"
89 " Grey = Invisible attribute.\n"
90 " Red = Visible attribute, name displayed only.\n"
91 " Blue = Visible attribute, both name and value displayed.\n"
93 " * What does the period (\".\") at the end of some component refdeses mean?\n"
94 " The period is placed after the refdeses of slotted components.\n"
95 " If slots are present on the component, then the different slots appear\n"
96 " in different rows with the slot number after the period. Example: C101.2.\n"
98 "Copyright (C) 2003 -- 2006 Stuart D. Brorson. E-mail: sdb (AT) cloud9 (DOT) net.\n"
104 * \brief Parse command line switches.
106 * Parse command line switches at startup. There are only 3 command
111 * \param argc Number of command line arguments
112 * \param argv Command line arguments (array of strings)
113 * \returns I don't know what - looks uninitialised in some circumstances.
116 int parse_commandline(int argc
, char *argv
[])
120 #if defined(HAVE_GETOPT_LONG) && defined(HAVE_GETOPT_H)
121 /* Use getopt_long if it is available */
122 int option_index
= 0;
123 static struct option long_options
[] = {
125 {"quiet", 0, 0, 'q'},
126 {"verbose", 0, 0, 'v'},
131 ch
= getopt_long(argc
, argv
, "hqv", long_options
, &option_index
);
135 /* Otherwise just use regular getopt */
136 while ((ch
= getopt(argc
, argv
, OPTIONS
)) != -1) {
161 verbose_mode
= FALSE
;