From 688a3026b832099213fb47051e7b8d0403fd0b87 Mon Sep 17 00:00:00 2001 From: ellson Date: Sun, 5 Oct 2008 03:22:07 +0000 Subject: [PATCH] put rbtree sources in their own directory, build as a convenience library --- lib/inkpot/inkpot.c | 82 +++++++++++++++++++++++++++++-------------- lib/rbtree/.cvsignore | 9 +++++ lib/rbtree/CHANGES | 10 ++++++ lib/rbtree/LICENSE | 18 ++++++++++ 4 files changed, 93 insertions(+), 26 deletions(-) create mode 100644 lib/rbtree/.cvsignore create mode 100644 lib/rbtree/CHANGES create mode 100644 lib/rbtree/LICENSE diff --git a/lib/inkpot/inkpot.c b/lib/inkpot/inkpot.c index 86ceb63f5..ffea6c867 100644 --- a/lib/inkpot/inkpot.c +++ b/lib/inkpot/inkpot.c @@ -15,10 +15,61 @@ **********************************************************/ #include +#include +#include +#include #include #include "inkpot.h" +char *Info[] = { + "inkpot", /* Program */ + "1","2008" +#if 0 + VERSION, /* Version */ + BUILDDATE /* Build Date */ +#endif +}; + +static const char *usage = + ": inkpot []\n\ + -f - input color scheme, or ',' separated list of schemes\n\ + -t - 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 index 000000000..dcdebf23e --- /dev/null +++ b/lib/rbtree/.cvsignore @@ -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 index 000000000..dd9eb7c60 --- /dev/null +++ b/lib/rbtree/CHANGES @@ -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 index 000000000..db4092863 --- /dev/null +++ b/lib/rbtree/LICENSE @@ -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. -- 2.40.0