INKPOT_MALLOC_FAIL,
INKPOT_COLOR_UNKNOWN,
INKPOT_COLOR_NONAME,
- INKPOT_SCHEME_UNKNOWN,
- INKPOT_FAIL
+ INKPOT_SCHEME_UNKNOWN
} inkpot_status_t;
typedef struct inkpot_s inkpot_t;
extern inkpot_status_t inkpot_disciplines ( inkpot_t *inkpot, inkpot_disc_t disc, void *out_closure, void *err_closure );
-extern inkpot_status_t inkpot_schemes ( inkpot_t *inkpot, const char *scheme, ... );
+extern inkpot_status_t inkpot_schemes ( inkpot_t *inkpot, const char *schemes );
extern inkpot_status_t inkpot_translate ( inkpot_t *inkpot, const char *scheme );
extern inkpot_status_t inkpot_set ( inkpot_t *inkpot, const char *color );
**********************************************************/
#include <stdio.h>
-#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
inkpot->default_scheme_name_idx = idx; /* first scheme is default */
inkpot->default_value_idx = TAB_NAMES[inkpot_scheme_name->default_name_idx].value_idx;
}
- if (! (inkpot->scheme_bits & (1 << idx))) {
- inkpot->scheme_bits |= 1 << idx;
-// inkpot->name = NULL; /* clear cached name */ /* FIXME */
- }
+ inkpot->scheme_bits |= 1 << idx;
return ((inkpot->status = INKPOT_SUCCESS));
}
* named schemes are currently active */
inkpot->default_value_idx = TAB_IXVALUES[inkpot_scheme_index->first_value_idx];
}
-// inkpot->name = NULL; /* clear cached name */ /* FIXME */
}
return ((inkpot->status = INKPOT_SUCCESS));
}
-inkpot_status_t inkpot_schemes ( inkpot_t *inkpot, const char *scheme, ... )
+inkpot_status_t inkpot_schemes ( inkpot_t *inkpot, const char *schemes )
{
inkpot_status_t rc;
- va_list argp;
- const char *s;
+ static char *schemelist;
+ static int schemelist_alloc;
+ const char *q;
+ char *p, *s, c;
+ int len;
- if (scheme == NULL)
+ if (schemes == NULL)
return ((inkpot->status = INKPOT_SCHEME_UNKNOWN));
- rc = inkpot_clear(inkpot);
- if (rc != INKPOT_SUCCESS)
- return rc;
+ len = strlen(schemes);
+ if (len >= schemelist_alloc) {
+ schemelist_alloc = len + 1 + 10;
+ schemelist = realloc(schemelist, schemelist_alloc);
+ if (! schemelist)
+ return ((inkpot->status = INKPOT_MALLOC_FAIL));
+ }
- va_start(argp, scheme);
- for (s = scheme; s; s = va_arg(argp, const char*)) {
- rc = inkpot_scheme(inkpot, s);
+ q = schemes;
+ p = schemelist;
+ rc = inkpot_clear(inkpot);
+ for (c = *q; c;) {
if (rc != INKPOT_SUCCESS)
- break;
+ return rc;
+ s = p;
+ while ((c = *q++) && c != ' ' && c != '\t' && c != ',') {*p++ = c;}
+ *p++ = '\0';
+ if (*s)
+ rc = inkpot_scheme(inkpot, s);
}
- va_end(argp);
return rc;
}
}
*color = NULL;
- return ((inkpot->status = INKPOT_FAIL));
+ return ((inkpot->status = INKPOT_COLOR_NONAME));
}
static inkpot_status_t inkpot_get_RGBA ( inkpot_t *inkpot, RGBA *rgba )
return rc;
}
+#if 0
+/* FIXME - requires palette collection and transformation */
inkpot_status_t inkpot_get_index ( inkpot_t *inkpot, unsigned int *index )
{
/* FIXME */
return ((inkpot->status = INKPOT_FAIL));
}
+#endif
static void errputs(inkpot_t *inkpot, const char *s)
{
m = "INKPOT_COLOR_NONAME\n"; break;
case INKPOT_SCHEME_UNKNOWN:
m = "INKPOT_SCHEME_UNKNOWN\n"; break;
- case INKPOT_FAIL:
- m = "INKPOT_FAIL\n"; break;
}
inkpot->disc.err_writer(inkpot->err_closure, m, strlen(m));