[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: parsecmd.c
User: sdb
Date: 06/08/12 18:03:06
Modified: . parsecmd.c
Log:
Implemented getopt_long for systems which have it.
Revision Changes Path
1.3 +78 -33 eda/geda/gaf/gattrib/src/parsecmd.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: parsecmd.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gattrib/src/parsecmd.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- parsecmd.c 5 Feb 2005 16:03:53 -0000 1.2
+++ parsecmd.c 12 Aug 2006 22:03:06 -0000 1.3
@@ -27,32 +27,59 @@
#include <unistd.h>
#endif
-/*------------------------------------------------------------------
- * Gattrib specific includes
- *------------------------------------------------------------------*/
-#include <libgeda/libgeda.h> /* geda library fcns */
-#include "../include/struct.h" /* typdef and struct declarations */
-#include "../include/prototype.h" /* function prototypes */
-#include "../include/globals.h"
-
-#ifdef HAVE_LIBDMALLOC
-#include <dmalloc.h>
-#endif
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif /* Checking for getopt */
+#if !defined(HAVE_GETOPT_LONG) || !defined(HAVE_GETOPT_H)
#define OPTIONS "qvh"
-
#ifndef OPTARG_IN_UNISTD
extern char *optarg;
extern int optind;
#endif
+#endif /* Checking for getopt_long */
+
+
+#ifdef HAVE_LIBDMALLOC
+#include <dmalloc.h>
+#endif
+
+
+/*------------------------------------------------------------------
+ * Gattrib specific includes
+ *------------------------------------------------------------------*/
+#include <libgeda/libgeda.h> /* geda library fcns */
+#include "../include/struct.h" /* typdef and struct declarations */
+#include "../include/prototype.h" /* function prototypes */
+#include "../include/globals.h"
void usage(char *cmd)
{
+ printf("\n");
+ printf("Gattrib: The gEDA project\'s attribute editor.\n");
+ printf("Presents schematic attributes in easy-to-edit spreadsheet format.\n");
+ printf("\n");
printf("Usage: %s [OPTIONS] filename1 ... filenameN\n", cmd);
- printf(" -q Quiet mode\n");
- printf(" -v Verbose mode on\n");
+ printf(" -q, --quiet Quiet mode\n");
+ printf(" -v, --verbose Verbose mode on\n");
+ printf(" -h, --help This help menu\n");
+ printf("\n");
+ printf(" FAQ:\n");
+ printf(" * What do the colors of the cell text mean?\n");
+ printf(" The cell colors indicate the visibility of the attribute.\n");
+ printf(" Black = Visible attribute, value displayed only.\n");
+ printf(" Grey = Invisible attribute.\n");
+ printf(" Red = Visible attribute, name displayed only.\n");
+ printf(" Blue = Visible attribute, both name and value displayed.\n");
+ printf("\n");
+ printf(" * What does the period (\".\") at the end of some component refdeses mean?\n");
+ printf(" The period is placed after the refdeses of slotted components.\n");
+ printf(" If slots are present on the component, then the different slots appear\n");
+ printf(" in different rows with the slot number after the period. Example: C101.2.\n");
+ printf("\n");
+ printf("Copyright (C) 2003 -- 2006 Stuart D. Brorson. E-mail: sdb (AT) cloud9 (DOT) net.\n");
printf("\n");
exit(0);
}
@@ -62,7 +89,25 @@
{
int ch;
+#if defined(HAVE_GETOPT_LONG) && defined(HAVE_GETOPT_H)
+ /* Use getopt_long if it is available */
+ int option_index = 0;
+ static struct option long_options[] = {
+ {"help", 0, 0, 'h'},
+ {"quiet", 0, 0, 'q'},
+ {"verbose", 0, 0, 'v'},
+ {0, 0, 0, 0}
+ };
+
+ while (1) {
+ ch = getopt_long(argc, argv, "hqv", long_options, &option_index);
+ if (ch == -1)
+ break;
+#else
+ /* Otherwise just use regular getopt */
while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
+#endif
+
switch (ch) {
case 'v':
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs