**********************************************************/
#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;
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
--- /dev/null
+
+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.