]> granicus.if.org Git - graphviz/commitdiff
add inkpot_print_names_out() for listing names in the out scheme
authorellson <devnull@localhost>
Thu, 25 Sep 2008 16:29:32 +0000 (16:29 +0000)
committerellson <devnull@localhost>
Thu, 25 Sep 2008 16:29:32 +0000 (16:29 +0000)
lib/inkpot/inkpot.h
lib/inkpot/inkpot_scheme.c
lib/inkpot/test.c

index 8d9e275add933b0bd42c7038ecfd94e1538ba11b..ac36544019a0579d439ae4e016c7e144ff554fb1 100644 (file)
@@ -32,26 +32,27 @@ typedef enum {
 
 typedef struct inkpot_s inkpot_t;
 
-extern inkpot_status_t inkpot_init         ( inkpot_t **inkpot );
-extern inkpot_status_t inkpot_clear        ( inkpot_t *inkpot );
-extern inkpot_status_t inkpot_activate     ( inkpot_t *inkpot, const char *scheme );
-extern inkpot_status_t inkpot_translate            ( inkpot_t *inkpot, const char *scheme );
-
-extern inkpot_status_t inkpot_set          ( inkpot_t *inkpot, const char *color );
-extern inkpot_status_t inkpot_set_default   ( inkpot_t *inkpot );
-extern inkpot_status_t inkpot_set_rgba     ( inkpot_t *inkpot, unsigned char rgba[4] );
-
-extern inkpot_status_t inkpot_get          ( inkpot_t *inkpot, const char **color );
-extern inkpot_status_t inkpot_get_rgba     ( inkpot_t *inkpot, unsigned char *rgba );
-extern inkpot_status_t inkpot_get_hsva     ( inkpot_t *inkpot, unsigned char *hsva );
-extern inkpot_status_t inkpot_get_cmyk     ( inkpot_t *inkpot, unsigned char *cmyk );
-extern inkpot_status_t inkpot_get_RGBA     ( inkpot_t *inkpot, double *RGBA );
-extern inkpot_status_t inkpot_get_HSVA     ( inkpot_t *inkpot, double *HSVA );
-extern inkpot_status_t inkpot_get_index            ( inkpot_t *inkpot, unsigned int *index );
-
-extern inkpot_status_t inkpot_print_schemes ( inkpot_t *inkpot, FILE *out );
-extern inkpot_status_t inkpot_print_names   ( inkpot_t *inkpot, FILE *out );
-extern inkpot_status_t inkpot_print_values  ( inkpot_t *inkpot, FILE *out );
+extern inkpot_status_t inkpot_init           ( inkpot_t **inkpot );
+extern inkpot_status_t inkpot_clear          ( inkpot_t *inkpot );
+extern inkpot_status_t inkpot_activate       ( inkpot_t *inkpot, const char *scheme );
+extern inkpot_status_t inkpot_translate              ( inkpot_t *inkpot, const char *scheme );
+
+extern inkpot_status_t inkpot_set            ( inkpot_t *inkpot, const char *color );
+extern inkpot_status_t inkpot_set_default     ( inkpot_t *inkpot );
+extern inkpot_status_t inkpot_set_rgba       ( inkpot_t *inkpot, unsigned char rgba[4] );
+
+extern inkpot_status_t inkpot_get            ( inkpot_t *inkpot, const char **color );
+extern inkpot_status_t inkpot_get_rgba       ( inkpot_t *inkpot, unsigned char *rgba );
+extern inkpot_status_t inkpot_get_hsva       ( inkpot_t *inkpot, unsigned char *hsva );
+extern inkpot_status_t inkpot_get_cmyk       ( inkpot_t *inkpot, unsigned char *cmyk );
+extern inkpot_status_t inkpot_get_RGBA       ( inkpot_t *inkpot, double *RGBA );
+extern inkpot_status_t inkpot_get_HSVA       ( inkpot_t *inkpot, double *HSVA );
+extern inkpot_status_t inkpot_get_index              ( inkpot_t *inkpot, unsigned int *index );
+
+extern inkpot_status_t inkpot_print_schemes   ( inkpot_t *inkpot, FILE *out );
+extern inkpot_status_t inkpot_print_names     ( inkpot_t *inkpot, FILE *out );
+extern inkpot_status_t inkpot_print_names_out ( inkpot_t *inkpot, FILE *out );
+extern inkpot_status_t inkpot_print_values    ( inkpot_t *inkpot, FILE *out );
 
 #ifdef __cplusplus
 }
index 38e7d15e7c9540b525edf0d114db32613b8bfb48..15b931c7c257ee2309e811cff84a46de551cd749 100644 (file)
@@ -166,7 +166,7 @@ static inkpot_status_t inkpot_set_name ( inkpot_t *inkpot, const char *color )
     const char *last_color;
     IDX_NAME_ALTS i;
     IDX_NAMES base, top, name_idx = 0;
-    int found;
+    int found=0;
 
     if (inkpot == NULL || ! inkpot->scheme_bits)
         return INKPOT_SCHEME_UNKNOWN;
@@ -522,23 +522,18 @@ static inkpot_status_t inkpot_print_rgba( unsigned char *rgba, FILE *out )
     return INKPOT_SUCCESS;
 }
 
-inkpot_status_t inkpot_print_names( inkpot_t *inkpot, FILE *out )
+static inkpot_status_t inkpot_print_names_schemes( inkpot_t *inkpot, FILE *out, BIT_SCHEMES_NAME scheme_bits, inkpot_scheme_index_t *scheme_index )
 {
     inkpot_name_t *name;
-    inkpot_scheme_index_t *scheme_index;
     IDX_NAMES i;
     IDX_SCHEMES_INDEX j;
-    BIT_SCHEMES_NAME inkpot_scheme_bits, scheme_bits;
     IDX_IXVALUES k, first, last;
     IDX_VALUES v;
 
-    fprintf(out, "names (in):\n");
-    inkpot_scheme_bits = inkpot->scheme_bits;
-    if (inkpot_scheme_bits) {
+    if (scheme_bits) {
         for (i = 0; i < SZT_NAMES; i++) {
             name = &TAB_NAMES[i];
-           scheme_bits = name->scheme_bits & inkpot_scheme_bits;
-            if (scheme_bits) {
+            if (scheme_bits & name->scheme_bits) {
                 fprintf(out, "%s", &TAB_STRINGS[TAB_NAMES[i].string_idx]);
                inkpot_print_scheme_names(inkpot, scheme_bits, out);
                fprintf(out, " ");
@@ -549,9 +544,7 @@ inkpot_status_t inkpot_print_names( inkpot_t *inkpot, FILE *out )
             }
         }
     }
-    scheme_index = inkpot->scheme_index;
     if (scheme_index) {
-
        first = scheme_index->first_value_idx;
        j = scheme_index - TAB_SCHEMES_INDEX;
        if (++j >= SZT_SCHEMES_INDEX)
@@ -574,8 +567,28 @@ inkpot_status_t inkpot_print_names( inkpot_t *inkpot, FILE *out )
     return INKPOT_SUCCESS;
 }
 
-/* Print all values that are members of the currently activated name schemes, with the names in those schemes */
-/*    Does not print the indexes in index schemes that a value may be a member of. */
+inkpot_status_t inkpot_print_names( inkpot_t *inkpot, FILE *out )
+{
+    BIT_SCHEMES_NAME scheme_bits = inkpot->scheme_bits;
+    inkpot_scheme_index_t *scheme_index = inkpot->scheme_index;
+
+    fprintf(out, "names (in):\n");
+    return inkpot_print_names_schemes(inkpot, out, scheme_bits, scheme_index);
+}
+
+inkpot_status_t inkpot_print_names_out( inkpot_t *inkpot, FILE *out )
+{
+    BIT_SCHEMES_NAME scheme_bits = inkpot->out_scheme_bit;
+    inkpot_scheme_index_t *scheme_index = inkpot->out_scheme_index;
+
+    fprintf(out, "names (out):\n");
+    return inkpot_print_names_schemes(inkpot, out, scheme_bits, scheme_index);
+}
+
+/* Print all values that are members of the currently activated
+ * name schemes, with the names in those schemes.
+ * Does not print the indexes in index schemes that a value may
+ * be a member of. */
 inkpot_status_t inkpot_print_values( inkpot_t *inkpot, FILE *out )
 {
     inkpot_value_t *value;
index 91c22acf9e2b4e3da4d55f86dcd1cca0d578bd0f..0a919ab255f3704f3e09e4d8aa280bd952fd0949 100644 (file)
@@ -53,6 +53,8 @@ int main (int argc, char *argv[])
     
     inkpot_print_names(inkpot, stderr);
 
+    inkpot_print_names_out(inkpot, stderr);
+
     inkpot_print_values(inkpot, stderr);