From 0b96d16e62d14f634651af0edbcef0ac0a415007 Mon Sep 17 00:00:00 2001 From: ellson Date: Wed, 1 Oct 2008 13:59:48 +0000 Subject: [PATCH] add inkpot to the builds, although not yet used by dot --- lib/inkpot/inkpot.c | 107 +++++++++++++++++++++++++++++++++++++ lib/inkpot/inkpot_scheme.c | 4 +- 2 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 lib/inkpot/inkpot.c diff --git a/lib/inkpot/inkpot.c b/lib/inkpot/inkpot.c new file mode 100644 index 000000000..7da858a4e --- /dev/null +++ b/lib/inkpot/inkpot.c @@ -0,0 +1,107 @@ +/* $Id$ $Revision$ */ +/* vim:set shiftwidth=4 ts=8: */ + +/*********************************************************** + * This software is part of the graphviz package * + * http://www.graphviz.org/ * + * * + * Copyright (c) 1994-2008 AT&T Corp. * + * and is licensed under the * + * Common Public License, Version 1.0 * + * by AT&T Corp. * + * * + * Information and Software Systems Research * + * AT&T Research, Florham Park NJ * + **********************************************************/ + +#include +#include + +#include "inkpot.h" + +int main (int argc, char *argv[]) +{ + inkpot_t *inkpot; + inkpot_status_t rc; + char *color; + double rgba[4], hsva[4], cmyk[4]; + + inkpot = inkpot_init(); + if (!inkpot) { + fprintf(stderr, "failure to initialize inkpot\n"); + return 0; + } + + /* requested color */ + if (argc < 2) + color = NULL; + else + color = argv[1]; + + /* requested schemes (comma-separated) */ + if (argc < 3) { + rc = inkpot_schemes(inkpot, "x11"); + assert(rc == INKPOT_SUCCESS); + } + else { + rc = inkpot_schemes(inkpot, argv[2]); + if (rc == INKPOT_SCHEME_UNKNOWN) + inkpot_debug_error(inkpot); + else + assert(rc == INKPOT_SUCCESS); + } + + /* target scheme */ + if (argc < 4) { + rc = inkpot_translate(inkpot, "x11"); + assert(rc == INKPOT_SUCCESS); + } + else { + rc = inkpot_translate(inkpot, argv[3]); + if (rc == INKPOT_SCHEME_UNKNOWN) + inkpot_debug_error(inkpot); + else + assert(rc == INKPOT_SUCCESS); + } + + inkpot_debug_schemes(inkpot); + +#if 0 + inkpot_debug_names(inkpot); + + inkpot_debug_out_names(inkpot); + + inkpot_debug_values(inkpot); +#endif + + fprintf(stdout, "%s ", color); /* ' ' after %s so it doesn't crash on NULL */ + rc = inkpot_set(inkpot, color); + if (rc == INKPOT_COLOR_UNKNOWN) + fprintf(stdout, "(unknown)"); + fprintf(stdout, "\n text: "); + + rc = inkpot_write(inkpot); + if (rc == INKPOT_COLOR_NONAME || rc == INKPOT_NOPALETTE) { + fprintf(stdout, "#"); + rc = inkpot_write_rgba8(inkpot); + } + assert (rc == INKPOT_SUCCESS); + + rc = inkpot_get_rgba(inkpot, rgba); + assert (rc == INKPOT_SUCCESS); + fprintf(stdout, "\n rgba: %.3f,%.3f,%.3f,%.3f\n", + rgba[0], rgba[1], rgba[2], rgba[3]); + + rc = inkpot_get_hsva(inkpot, hsva); + assert (rc == INKPOT_SUCCESS); + fprintf(stdout, " hsva: %.3f,%.3f,%.3f,%.3f\n", + hsva[0], hsva[1], hsva[2], hsva[3]); + + rc = inkpot_get_cmyk(inkpot, cmyk); + assert (rc == INKPOT_SUCCESS); + fprintf(stdout, " cmyk: %.3f,%.3f,%.3f,%.3f\n", + cmyk[0], cmyk[1], cmyk[2], cmyk[3]); + + inkpot_destroy(inkpot); + return 0; +} diff --git a/lib/inkpot/inkpot_scheme.c b/lib/inkpot/inkpot_scheme.c index 5b398ae8a..ae05414bb 100644 --- a/lib/inkpot/inkpot_scheme.c +++ b/lib/inkpot/inkpot_scheme.c @@ -140,7 +140,7 @@ static inkpot_status_t inkpot_scheme ( inkpot_t *inkpot, const char *scheme ) inkpot_status_t inkpot_schemes ( inkpot_t *inkpot, const char *schemes ) { - inkpot_status_t rc; + inkpot_status_t rc = INKPOT_SUCCESS; const char *q; char *p, *s, c; int len; @@ -923,7 +923,7 @@ inkpot_status_t inkpot_debug_values( inkpot_t *inkpot ) inkpot_status_t inkpot_debug_error ( inkpot_t *inkpot ) { - const char *m; + const char *m = "\nINKPOT_FAIL\n"; assert(inkpot); switch (inkpot->status) { -- 2.40.0