gattrib

parsecmd.c

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * gattrib -- gEDA component and net attribute manipulation using spreadsheet.
00003  * Copyright (C) 2003-2010 Stuart D. Brorson.
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00018  */
00027 #include <config.h>
00028 
00029 #include <stdio.h>
00030 #ifdef HAVE_STRING_H
00031 #include <string.h>
00032 #endif
00033 #ifdef HAVE_UNISTD_H
00034 #include <unistd.h>
00035 #endif
00036 
00037 
00038 #ifdef HAVE_GETOPT_H
00039 #include <getopt.h>
00040 #endif  /* Checking for getopt  */
00041 
00042 #if !defined(HAVE_GETOPT_LONG) || !defined(HAVE_GETOPT_H)
00043 
00048 #define OPTIONS "qvh"
00049 #ifndef OPTARG_IN_UNISTD
00050 extern char *optarg;
00051 extern int optind;
00052 #endif
00053 #endif   /* Checking for getopt_long  */
00054 
00055 
00056 #ifdef HAVE_LIBDMALLOC
00057 #include <dmalloc.h>
00058 #endif
00059 
00060 
00061 /*------------------------------------------------------------------
00062  * Gattrib specific includes
00063  *------------------------------------------------------------------*/
00064 #include <libgeda/libgeda.h>       /* geda library fcns  */
00065 #include "../include/struct.h"     /* typdef and struct declarations */
00066 #include "../include/prototype.h"  /* function prototypes */
00067 #include "../include/globals.h"
00068 
00077 void usage(char *cmd)
00078 {
00079     printf("\n");
00080     printf("Gattrib:  The gEDA project\'s attribute editor.\n");
00081     printf("Presents schematic attributes in easy-to-edit spreadsheet format.\n");
00082     printf("\n");
00083     printf("Usage: %s [OPTIONS] filename1 ... filenameN\n", cmd);
00084     printf("  -q, --quiet            Quiet mode\n");
00085     printf("  -v, --verbose          Verbose mode on\n");
00086     printf("  -h, --help             This help menu\n");
00087     printf("\n");
00088     printf("  FAQ:\n");
00089     printf("  *  What do the colors of the cell text mean?\n");
00090     printf("     The cell colors indicate the visibility of the attribute.\n");
00091     printf("     Black = Visible attribute, value displayed only.\n");
00092     printf("     Grey  = Invisible attribute.\n");
00093     printf("     Red   = Visible attribute, name displayed only.\n");
00094     printf("     Blue  = Visible attribute, both name and value displayed.\n");
00095     printf("\n");
00096     printf("  *  What does the period (\".\") at the end of some component refdeses mean?\n");
00097     printf("     The period is placed after the refdeses of slotted components.\n");
00098     printf("     If slots are present on the component, then the different slots appear\n");
00099     printf("     in different rows with the slot number after the period.  Example:  C101.2.\n");
00100     printf("\n");
00101     printf("Copyright (C) 2003 -- 2006 Stuart D. Brorson.  E-mail: sdb (AT) cloud9 (DOT) net.\n");
00102     printf("\n");
00103     exit(0);
00104 }
00105 
00119 int parse_commandline(int argc, char *argv[])
00120 {
00121     int ch;
00122 
00123 #if defined(HAVE_GETOPT_LONG) && defined(HAVE_GETOPT_H)
00124     /* Use getopt_long if it is available */
00125     int option_index = 0;
00126     static struct option long_options[] = {
00127       {"help", 0, 0, 'h'},
00128       {"quiet", 0, 0, 'q'},
00129       {"verbose", 0, 0, 'v'},
00130       {0, 0, 0, 0}
00131     };
00132 
00133     while (1) {
00134       ch = getopt_long(argc, argv, "hqv", long_options, &option_index);
00135       if (ch == -1)
00136     break;
00137 #else
00138     /* Otherwise just use regular getopt */
00139     while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
00140 #endif
00141 
00142       switch (ch) {
00143     
00144       case 'v':
00145     verbose_mode = TRUE;
00146     break;
00147     
00148       case 'q':
00149     quiet_mode = TRUE;
00150     break;
00151     
00152       case 'h':
00153     usage(argv[0]);
00154     break;
00155     
00156       case '?':
00157       default:
00158     usage(argv[0]);
00159     break;
00160       }
00161     }
00162     
00163     if (quiet_mode) {
00164     verbose_mode = FALSE;
00165     }
00166 
00167     return (optind);
00168 }
00169 
00170 
00171 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines