]> granicus.if.org Git - graphviz/commitdiff
put rbtree sources in their own directory, build as a convenience library
authorellson <devnull@localhost>
Sun, 5 Oct 2008 03:22:07 +0000 (03:22 +0000)
committerellson <devnull@localhost>
Sun, 5 Oct 2008 03:22:07 +0000 (03:22 +0000)
lib/inkpot/inkpot.c
lib/rbtree/.cvsignore [new file with mode: 0644]
lib/rbtree/CHANGES [new file with mode: 0644]
lib/rbtree/LICENSE [new file with mode: 0644]

index 86ceb63f57a8b43a523076fd5050fe0dbfc22723..ffea6c86722292e03ab3b586475713d4ce8a1675 100644 (file)
  **********************************************************/
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
 #include <assert.h>
 
 #include "inkpot.h"
 
+char *Info[] = {
+    "inkpot",                   /* Program */
+    "1","2008"
+#if 0
+    VERSION,                    /* Version */
+    BUILDDATE                   /* Build Date */
+#endif
+};
+
+static const char *usage =
+    ": inkpot [<color>]\n\
+    -f <schemes> - input color scheme, or ',' separated list of schemes\n\
+    -t <scheme>  - output solor scheme\n\
+    -V           - print version info\n\
+    -?           - print usage info\n\
+    If no color is specified, a stdin is processed for color tokens.\n";
+
+static void scanArgs(inkpot_t *inkpot, int argc, char **argv)
+{
+    int c;
+
+    while ((c = getopt(argc, argv, ":?Vf:t:o:")) != -1) {
+       switch (c) {
+       case 'f':
+           inkpot_schemes_put(inkpot, optarg);
+           break;
+       case 't':
+           inkpot_scheme_get(inkpot, optarg);
+           break;
+       case 'V':
+           fprintf(stderr, "%s version %s (%s)\n",
+                   Info[0], Info[1], Info[2]);
+           exit(0);
+           break;
+       case '?':
+           fprintf(stderr,"%s\n", usage);
+           exit(0);
+           break;
+       case ':':
+           fprintf (stderr, "missing argument for option -%c\n", optopt);
+           break;
+       default:
+           fprintf(stderr,"option -%c unrecognized\n", optopt);
+       }
+    }
+}
+
+
 int main (int argc, char *argv[])
 {
     inkpot_t *inkpot;
@@ -32,38 +83,17 @@ int main (int argc, char *argv[])
        return 0;
     }
  
+    inkpot_schemes_put(inkpot, "x11");
+    inkpot_scheme_get(inkpot, "x11");
+
+    scanArgs(inkpot, argc, argv);
+
     /* requested color */
     if (argc < 2)
         color = NULL;
     else
         color = argv[1];
 
-    /* requested schemes (comma-separated) */
-    if (argc < 3) {
-        rc = inkpot_schemes_put(inkpot, "x11");
-        assert(rc == INKPOT_SUCCESS);
-    }
-    else {
-        rc = inkpot_schemes_put(inkpot, argv[2]);
-        if (rc == INKPOT_SCHEME_UNKNOWN)
-           fprintf(stderr, "unknown in scheme(s)\n");
-        else
-            assert(rc == INKPOT_SUCCESS);
-    }
-
-    /* target scheme */
-    if (argc < 4) {
-        rc = inkpot_scheme_get(inkpot, "x11");
-        assert(rc == INKPOT_SUCCESS);
-    }
-    else {
-        rc = inkpot_scheme_get(inkpot, argv[3]);
-        if (rc == INKPOT_SCHEME_UNKNOWN)
-           fprintf(stderr, "unknown out scheme\n");
-        else
-            assert(rc == INKPOT_SUCCESS);
-    }
-
     inkpot_debug_schemes(inkpot);
     
 #if 0
diff --git a/lib/rbtree/.cvsignore b/lib/rbtree/.cvsignore
new file mode 100644 (file)
index 0000000..dcdebf2
--- /dev/null
@@ -0,0 +1,9 @@
+*.la
+*.lo
+*.pc
+.deps
+.libs
+Makefile
+Makefile.in
+*.pdf
+CMakeFiles CMakeTmp CMakeFiles CMakeCache.txt cmake_install.cmake
diff --git a/lib/rbtree/CHANGES b/lib/rbtree/CHANGES
new file mode 100644 (file)
index 0000000..dd9eb7c
--- /dev/null
@@ -0,0 +1,10 @@
+
+Sun Jan 09, 2005: I fixed a bug that caused the test_rb program to
+                  go into an infinite loop if the user entered an
+                  invalid key.  Thanks to Amores Perros for pointing
+                  out this problem.
+
+Wed Sep 19, 2001: I fixed some bugs and memory leaks pointed out
+                  by Brett Donahue and added some rudimentary
+                  memory checking tests to the makefile.
+
diff --git a/lib/rbtree/LICENSE b/lib/rbtree/LICENSE
new file mode 100644 (file)
index 0000000..db40928
--- /dev/null
@@ -0,0 +1,18 @@
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that neither the name of Emin
+Martinian nor the names of any contributors are be used to endorse or
+promote products derived from this software without specific prior
+written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.