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 #ifdef HAVE_LIBDMALLOC
61 /*------------------------------------------------------------------
62 * Gattrib specific includes
63 *------------------------------------------------------------------*/
64 #include <libgeda/libgeda.h> /* geda library fcns */
65 #include "../include/struct.h" /* typdef and struct declarations */
66 #include "../include/prototype.h" /* function prototypes */
67 #include "../include/globals.h"
70 * \brief Print usage message
72 * Prints gattrib usage information to stdout.
73 * \param cmd Unused parameter.
80 printf("Gattrib: The gEDA project\'s attribute editor.\n");
81 printf("Presents schematic attributes in easy-to-edit spreadsheet format.\n");
83 printf("Usage: %s [OPTIONS] filename1 ... filenameN\n", cmd
);
84 printf(" -q, --quiet Quiet mode\n");
85 printf(" -v, --verbose Verbose mode on\n");
86 printf(" -h, --help This help menu\n");
89 printf(" * What do the colors of the cell text mean?\n");
90 printf(" The cell colors indicate the visibility of the attribute.\n");
91 printf(" Black = Visible attribute, value displayed only.\n");
92 printf(" Grey = Invisible attribute.\n");
93 printf(" Red = Visible attribute, name displayed only.\n");
94 printf(" Blue = Visible attribute, both name and value displayed.\n");
96 printf(" * What does the period (\".\") at the end of some component refdeses mean?\n");
97 printf(" The period is placed after the refdeses of slotted components.\n");
98 printf(" If slots are present on the component, then the different slots appear\n");
99 printf(" in different rows with the slot number after the period. Example: C101.2.\n");
101 printf("Copyright (C) 2003 -- 2006 Stuart D. Brorson. E-mail: sdb (AT) cloud9 (DOT) net.\n");
107 * \brief Parse command line switches.
109 * Parse command line switches at startup. There are only 3 command
114 * \param argc Number of command line arguments
115 * \param argv Command line arguments (array of strings)
116 * \returns I don't know what - looks uninitialised in some circumstances.
119 int parse_commandline(int argc
, char *argv
[])
123 #if defined(HAVE_GETOPT_LONG) && defined(HAVE_GETOPT_H)
124 /* Use getopt_long if it is available */
125 int option_index
= 0;
126 static struct option long_options
[] = {
128 {"quiet", 0, 0, 'q'},
129 {"verbose", 0, 0, 'v'},
134 ch
= getopt_long(argc
, argv
, "hqv", long_options
, &option_index
);
138 /* Otherwise just use regular getopt */
139 while ((ch
= getopt(argc
, argv
, OPTIONS
)) != -1) {
164 verbose_mode
= FALSE
;