INKPOT_COLOR_UNKNOWN,
INKPOT_COLOR_NONAME,
INKPOT_COLOR_NOPALETTE,
- INKPOT_SCHEME_UNKNOWN
+ INKPOT_SCHEME_UNKNOWN,
+ INKPOT_NOSUCH_INDEX
} inkpot_status_t;
typedef struct inkpot_s inkpot_t;
**********************************************************/
typedef unsigned int IDX_STRINGS;
+#define SZT_STRINGS 79
+#define SZL_STRINGS 6
+
typedef unsigned short MSK_SCHEMES_NAME;
typedef unsigned char IDX_SCHEMES_NAME;
-typedef unsigned char IDX_SCHEMES_INDEX;
-typedef unsigned int IDX_NAMES;
-typedef unsigned char IDX_NAME_ALTS;
-
-typedef unsigned int IDX_MRU_CACHE;
-#define SZT_MRU_CACHE 4
+#define SZT_SCHEMES_NAME 3
+typedef unsigned char IDX_SCHEMES_INDEX;
#define SZT_SCHEMES_INDEX 2
-#define SZL_STRINGS 6
-
-#define SZT_STRINGS 79
-#define SZT_SCHEMES_NAME 3
+typedef unsigned int IDX_NAMES;
#define SZT_NAMES 11
-#define SZT_NAME_ALTS 2
+typedef unsigned char IDX_NAME_ALTS;
+#define SZT_NAME_ALTS 2
-/* for values */
+typedef unsigned int IDX_MRU_CACHE;
+#define SZT_MRU_CACHE 4
-typedef unsigned int IDX_VALUES;
typedef unsigned int IDX_IXVALUES;
+#define SZT_IXVALUES 7
+typedef unsigned int IDX_TONAMES;
+#define SZT_TONAMES 7
+
typedef unsigned long VALUE;
#define SZB_RED 16
#define MSK_RED 65535
#define MAX_RED 65535
+typedef unsigned int IDX_VALUES;
#define SZT_VALUES 7
#define SZT_NONAME_VALUES 4
-#define SZT_IXVALUES 7
-
-
IDX_NAMES TAB_NAME_ALTS[SZT_NAME_ALTS] = {
0, 10,
};
+
+IDX_TONAMES TAB_TONAMES[SZT_TONAMES] = {
+ 0, /* black */
+ 1, /* bleu, blue */
+ 3, /* green, vert */
+ 5, /* red, rouge */
+ 7, /* yellow (svg) */
+ 8, /* yellow (x11), jaune */
+ 10, /* white */
+};
+
+IDX_VALUES TAB_IXVALUES[SZT_IXVALUES] = {
+ 7, 8, 9, 10, 1, /* xxx */
+ 0, 6, /* yyy */
+};
+
+
inkpot = malloc(sizeof(inkpot_t));
if (inkpot) {
- inkpot->values = inkpot_values_init ();
- if (! inkpot->values) {
- free(inkpot);
- return NULL;
- }
+ inkpot->values.no_palette_value = 0;
+ inkpot->values.no_palette_vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes);
+
+ inkpot->value.index = 0;
+ inkpot->value.value = 0;
+ inkpot->value.vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes);
inkpot->canon = NULL;
inkpot->canon_alloc = 0;
void inkpot_destroy ( inkpot_t *inkpot )
{
- inkpot_values_destroy ( inkpot->values );
free(inkpot->canon);
free(inkpot);
}
}
value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes;
- rc = inkpot_value_set ( inkpot->values, &value );
+ rc = inkpot_value_set ( &inkpot->values, &value );
if (rc == INKPOT_SUCCESS)
inkpot->value = value;
return (inkpot->status = rc);
value.value = (((((((VALUE)r) << SZB_RED) | (VALUE)g) << SZB_RED) | (VALUE)b) << SZB_RED) | (VALUE)a;
value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes;
- rc = inkpot_value_set ( inkpot->values, &value );
+ rc = inkpot_value_set ( &inkpot->values, &value );
if (rc == INKPOT_SUCCESS)
inkpot->value = value;
inkpot->status = rc;
if (inkpot->out_scheme_bit) {
value_idx = inkpot->value.index;
if (value_idx < SZT_VALUES) {
- for (t = TAB_VALUES[value_idx].toname_idx; t < SZT_NAMES; t++) {
+ for (t = TAB_TONAMES[value_idx]; t < SZT_NAMES; t++) {
out_name = &TAB_NAMES[TAB_NAMES[t].toname_idx];
if (out_name->value_idx != value_idx)
break;
int i;
value = inkpot->value;
- rc = inkpot->status = inkpot_value_get( inkpot->values, &value );
+ rc = inkpot->status = inkpot_value_get( &inkpot->values, &value );
if (rc == INKPOT_SUCCESS) {
for (i = 3; i >= 0; i--) {
rgba[i] = (value.value & MSK_RED);
int i;
value = inkpot->value;
- rc = inkpot->status = inkpot_value_get( inkpot->values, &value );
+ rc = inkpot->status = inkpot_value_get( &inkpot->values, &value );
if (rc == INKPOT_SUCCESS) {
for (i = 3; i >= 0; i--) {
rgba[i] = (value.value & MSK_RED) / (double)MAX_RED;
return ((inkpot->status = INKPOT_SUCCESS));
}
+#if 0
static inkpot_status_t inkpot_debug_scheme_names( inkpot_t *inkpot, int scheme_bits )
{
IDX_SCHEMES_NAME i;
sprintf(buf, "#%04x%04x%04x%04x", rgba[0], rgba[1], rgba[2], rgba[3]);
errputs(inkpot, buf);
}
+#endif
+#if 0
static inkpot_status_t inkpot_debug_names_schemes( inkpot_t *inkpot, MSK_SCHEMES_NAME scheme_bits, IDX_SCHEMES_INDEX active, IDX_SCHEMES_NAME *scheme_index )
{
inkpot_name_t *name;
errputs(inkpot, "names (out):\n");
return inkpot_debug_names_schemes(inkpot, inkpot->out_scheme_bit, 1, inkpot->out_scheme_list);
}
+#endif
#if 0
/* Print all values that are members of the currently listed
* be a member of. */
inkpot_status_t inkpot_debug_values( inkpot_t *inkpot )
{
+ inkpot_status_t rc;
inkpot_value_t *value;
inkpot_name_t *name;
IDX_VALUES i;
int found;
errputs(inkpot, "values:\n");
- for (i = 0; i < SZT_VALUES; i++) {
- value = &TAB_VALUES[i];
+ for (rc = inkpot_value_get_first(inkpot, &value);
+ rc == INKPOT_SUCCESS
+ rc = inkpot_value_get_next(inkpot, &value)) {
+
found = 0;
for (t = value->toname_idx; t < SZT_NAMES; t++) {
name = &TAB_NAMES[TAB_NAMES[t].toname_idx];
m = "\nINKPOT_COLOR_PALETTE\n"; break;
case INKPOT_SCHEME_UNKNOWN:
m = "\nINKPOT_SCHEME_UNKNOWN\n"; break;
+ case INKPOT_NOSUCH_INDEX:
+ m = "\nINKPOT_NOSUCH_INDEX\n"; break;
}
inkpot->disc.err_writer(inkpot->err_closure, m, strlen(m));
char *canon; /* malloc'ed, reused storage for canonicalizing color request strings */
int canon_alloc;
- inkpot_values_t *values;/* The values store */
+ inkpot_values_t values; /* The values store */
inkpot_value_t value; /* The current value of the inkpot */
inkpot_cache_element_t
#include "inkpot_value.h"
#include "inkpot_value_table.h"
-struct inkpot_values_s {
- VALUE
- no_palette_value;
- BIT_VTYPE
- no_palette_vtype;
-};
-
-inkpot_values_t* inkpot_values_init ( void )
-{
- inkpot_values_t *values;
-
- values = (inkpot_values_t*)malloc(sizeof(inkpot_values_t));
- if (values) {
-
- }
- return values;
-}
-
-void inkpot_values_destroy ( inkpot_values_t *values )
-{
- free(values);
-}
-
inkpot_status_t inkpot_value_set ( inkpot_values_t *values, inkpot_value_t *value )
{
values->no_palette_value = value->value;
index = value->index;
if (index < SZT_VALUES) {
- value->value = TAB_VALUES[index].value;
+ value->value = TAB_VALUES[index];
value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes;
}
else if (index - SZT_VALUES < SZT_NONAME_VALUES) {
- value->value = TAB_NONAME_VALUES[index - SZT_VALUES].value;
+ value->value = TAB_NONAME_VALUES[index - SZT_VALUES];
value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes;
}
else if (index == SZT_VALUES + SZT_NONAME_VALUES) {
value->vtype = values->no_palette_vtype;
}
else
- assert(0);
+ return INKPOT_NOSUCH_INDEX;
return INKPOT_SUCCESS;
}
+
+inkpot_status_t inkpot_value_get_first ( inkpot_values_t *values, inkpot_value_t *value )
+{
+ value->index = 0;
+ return inkpot_value_get ( values, value );
+}
+
+inkpot_status_t inkpot_value_get_next ( inkpot_values_t *values, inkpot_value_t *value )
+{
+ value->index++;
+ return inkpot_value_get ( values, value );
+}
extern "C" {
#endif
-#if 1
-/* FIXME - this stuff needs to go */
-
-typedef struct inkpot_oldvalue_s { /* Numeric color values used by the set
- * of inkpot_name_t and indexes from
- * indexed color schemes ( total presumed
- * to be less than all possible color values).
- * inkpot_value_t instances are unique and
- * are numerically sorted by rgb value
- * in TAB_VALUES[] */
-
- VALUE value;
-
- IDX_NAMES /* FIXME - searate this in to a separate table */
- toname_idx; /* An index into TAB_NAMES to the toname
- * which indexes the first inkpot_name_t
- * in TAB_NAMES that maps to this color,
- * followed in TAB_NAMES by the toname indexes
- * of other inkpot_name_t that also map to
- * this inkpot_value_t, until a toname index
- * in TAB_NAMES indexes a inkpot_name_t
- * that doesn't map to this inkpot_value_t,
- * or until the end of TAB_NAMES is reached.
- * (Phew!) */
-} inkpot_oldvalue_t;
-
-typedef struct inkpot_noname_value_s { /* Numeric color values used by the remainder
- * of indexes from indexed color schemes
- * inkpot_noname_value_t instances are unique and
- * are numerically sorted by rgba value
- * in TAB_NONAME_VALUES[] */
- VALUE value;
-
-} inkpot_noname_value_t;
-
-extern inkpot_oldvalue_t TAB_VALUES[];
-extern inkpot_noname_value_t TAB_NONAME_VALUES[];
-#endif
-extern IDX_VALUES TAB_IXVALUES[];
-
-/* proper api starts here */
-
-typedef struct inkpot_values_s inkpot_values_t;
-
typedef int BIT_VTYPE;
#define MSK_VTYPE_size 0x01
-#define BIT_VTYPE_size_8 0x00
-#define BIT_VTYPE_size_16 0x01
+#define BIT_VTYPE_size_16 0x00
+#define BIT_VTYPE_size_8 0x01
#define MSK_VTYPE_code 0x0e
#define BIT_VTYPE_code_VALUE 0x00
#define BIT_VTYPE_code_cmyk 0x06
#define MSK_VTYPE_alpha 0x10
-#define BIT_VTYPE_alpha_no 0x00
-#define BIT_VTYPE_alpha_yes 0x10
+#define BIT_VTYPE_alpha_yes 0x00
+#define BIT_VTYPE_alpha_no 0x10
+
+typedef struct inkpot_values_s {
+ VALUE no_palette_value;
+ BIT_VTYPE no_palette_vtype;
+} inkpot_values_t;
typedef struct inkpot_value_s {
- IDX_VALUES index; /* write by set, read by get, write by first/next */
- BIT_VTYPE vtype; /* read by set, write by get, read by first/next */
- VALUE value; /* read by set, write by get, write by first/next */
+ IDX_VALUES index; /* write by set, read by get, write by first, read/write by next */
+ BIT_VTYPE vtype; /* read by set, write by get, read by first, read by next */
+ VALUE value; /* read by set, write by get, write by first, write by next */
} inkpot_value_t;
-extern inkpot_values_t* inkpot_values_init ();
-extern void inkpot_values_destroy ( inkpot_values_t *values );
-
extern inkpot_status_t inkpot_value_set ( inkpot_values_t *values, inkpot_value_t *value );
extern inkpot_status_t inkpot_value_get ( inkpot_values_t *values, inkpot_value_t *value );
* AT&T Research, Florham Park NJ *
**********************************************************/
-inkpot_oldvalue_t TAB_VALUES[SZT_VALUES] = { /* Must be sort'ed */
- { 0x000000000000ffff, 0 }, /* black */
- { 0x00000000ffffffff, 1 }, /* bleu, blue */
- { 0x0000ffff0000ffff, 3 }, /* green, vert */
- { 0xffff00000000ffff, 5 }, /* red, rouge */
- { 0xffffcf000000ffff, 7 }, /* yellow (svg) */
- { 0xffffffff0000ffff, 8 }, /* yellow (x11), jaune */
- { 0xffffffffffffffff, 10}, /* white */
+VALUE TAB_VALUES[SZT_VALUES] = {
+ 0x000000000000ffff, /* black */
+ 0x00000000ffffffff, /* bleu, blue */
+ 0x0000ffff0000ffff, /* green, vert */
+ 0xffff00000000ffff, /* red, rouge */
+ 0xffffcf000000ffff, /* yellow (svg) */
+ 0xffffffff0000ffff, /* yellow (x11), jaune */
+ 0xffffffffffffffff, /* white */
};
-inkpot_noname_value_t TAB_NONAME_VALUES[SZT_NONAME_VALUES] = { /* Must be sort'ed */
- { 0x000000008000ffff, },
- { 0x00000000a400ffff, },
- { 0x00000000c800ffff, },
- { 0x00000000ea00ffff, },
+VALUE TAB_NONAME_VALUES[SZT_NONAME_VALUES] = {
+ 0x000000008000ffff,
+ 0x00000000a400ffff,
+ 0x00000000c800ffff,
+ 0x00000000ea00ffff,
};
-
-IDX_VALUES TAB_IXVALUES[SZT_IXVALUES] = {
- 7, 8, 9, 10, 1, /* xxx */
- 0, 6, /* yyy */
-};