On 25 May 2000, Marcus Sundberg wrote:

> [EMAIL PROTECTED] (Christoph Egger) writes:
> 
> > Hi!
> > 
> > I've just cleaned up the libggi-code a bit. I created and attached a
> > patch.
> > Anyone here to commit it?
> 
> Nice work, 

TNX!

> I'd like to request some minor changes though:
> 
> > diff -uNr degas/lib/libggi/display/monotext/visual.c 
>20000521-devel/degas/lib/libggi/display/monotext/visual.c
> > --- degas/lib/libggi/display/monotext/visual.c      Tue Apr 25 07:07:11 2000
> > +++ 20000521-devel/degas/lib/libggi/display/monotext/visual.c       Wed May 24 
>19:15:55 2000
> > @@ -34,16 +34,18 @@
> >  #include <ggi/display/monotext.h>
> >  
> >  
> > -static gg_option options[] =
> > +static gg_option monotext_options[] =
> 
> As these are all static variables I'd actually be most grateful if you
> would change all files to simply use 'options' instead of '<name>_options'.

Done.
 
> > diff -uNr degas/lib/libggi/display/palemu/visual.c 
>20000521-devel/degas/lib/libggi/display/palemu/visual.c
> > --- degas/lib/libggi/display/palemu/visual.c        Tue Apr 25 07:07:12 2000
> > +++ 20000521-devel/degas/lib/libggi/display/palemu/visual.c Wed May 24 18:31:39 
>2000
> 
> [snip]
> 
> > @@ -78,8 +82,12 @@
> >     }
> >     
> >     if (args) {
> > +#if 0      /* Why 3 options? */
> >             args = ggParseOptions((char *) args, palemu_options, 3);
> > -                   
> > +#endif
> 
> Looks like a copy-n-paste error, just remove the old code.

Done.

I've attached the same patch with the above changes.


Christoph Egger
E-Mail: [EMAIL PROTECTED]
diff -uNr degas-old/lib/libggi/display/file/visual.c 
degas/lib/libggi/display/file/visual.c
--- degas-old/lib/libggi/display/file/visual.c  Tue Apr 25 07:07:06 2000
+++ degas/lib/libggi/display/file/visual.c      Thu May 25 20:13:00 2000
@@ -34,7 +34,7 @@
 #include <ggi/internal/ggi-dl.h>
 #include <ggi/display/file.h>
 
-static gg_option file_options[] =
+static gg_option options[] =
 {
        { "flushcmd", "" },
        { "flushframe",  "0" },
@@ -45,7 +45,7 @@
 #define OPT_FLUSHFRAME 1
 #define OPT_FLUSHTIME  2
 
-#define NUM_OPTS       (sizeof(file_options)/sizeof(gg_option))
+#define NUM_OPTS       (sizeof(options)/sizeof(gg_option))
 
 
 static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh,
@@ -72,7 +72,7 @@
        /* Handle arguments */
        if (getenv("GGI_FILE_OPTIONS") != NULL) {
                if (ggParseOptions(getenv("GGI_FILE_OPTIONS"),
-                       file_options, NUM_OPTS) == NULL) {
+                       options, NUM_OPTS) == NULL) {
                        
                        fprintf(stderr, "display-file: error in "
                                "$GGI_FILE_OPTIONS.\n");
@@ -81,7 +81,7 @@
                }
        }
 
-       args = ggParseOptions((char *) args, file_options, NUM_OPTS);
+       args = ggParseOptions((char *) args, options, NUM_OPTS);
 
        if (args == NULL) {
                fprintf(stderr, "display-file: error in "
@@ -91,10 +91,10 @@
        }
 
        ff->filename   = strdup(args);
-       ff->flushcmd   = file_options[OPT_FLUSHCMD].result[0]
-               ? strdup(file_options[OPT_FLUSHCMD].result) : NULL;
-       ff->flushevery = atoi(file_options[OPT_FLUSHFRAME].result);
-       fltime         = atof(file_options[OPT_FLUSHTIME].result);
+       ff->flushcmd   = options[OPT_FLUSHCMD].result[0]
+               ? strdup(options[OPT_FLUSHCMD].result) : NULL;
+       ff->flushevery = atoi(options[OPT_FLUSHFRAME].result);
+       fltime         = atof(options[OPT_FLUSHTIME].result);
        ff->flushcnt   = 0;
        ff->flushtotal = 0;
        gettimeofday(&ff->flushlast,NULL);
diff -uNr degas-old/lib/libggi/display/memory/visual.c 
degas/lib/libggi/display/memory/visual.c
--- degas-old/lib/libggi/display/memory/visual.c        Tue Apr 25 07:07:10 2000
+++ degas/lib/libggi/display/memory/visual.c    Thu May 25 20:07:59 2000
@@ -32,11 +32,15 @@
 
 #include <ggi/display/memory.h>
 
-static gg_option memory_options[1] =
+static gg_option options[] =
 {
        { "input", "" }
 };
 
+#define OPT_INPUT      0
+
+#define NUM_OPTS       (sizeof(options)/sizeof(gg_option))
+
 ggi_event_mask GII_memory_poll(gii_input_t inp, void *arg)
 {
        struct memhooks *hook=inp->priv;
@@ -96,7 +100,7 @@
        MEMLIB_PRIV(vis)->inputoffset=0;        /* Setup offset. */
 
        if (args) {
-               args = ggParseOptions((char *) args, memory_options, 1);
+               args = ggParseOptions((char *) args, options, NUM_OPTS);
                if (args == NULL) {
                        fprintf(stderr, "display-memory: error in "
                                "arguments.\n");
@@ -118,7 +122,7 @@
                        if (MEMLIB_PRIV(vis)->memptr!=(void *)-1) 
                        {
                                MEMLIB_PRIV(vis)->memtype=MT_SHMID;
-                               if (memory_options[0].result[0])
+                               if (options[OPT_INPUT].result[0])
                                {
                                        
MEMLIB_PRIV(vis)->inputbuffer=MEMLIB_PRIV(vis)->memptr;
                                        MEMLIB_PRIV(vis)->memptr=(char 
*)MEMLIB_PRIV(vis)->memptr+INPBUFSIZE;
@@ -147,7 +151,7 @@
                        if (MEMLIB_PRIV(vis)->memptr!=(void *)-1) 
                        {
                                MEMLIB_PRIV(vis)->memtype=MT_SHMID;
-                               if (memory_options[0].result[0])
+                               if (options[OPT_INPUT].result[0])
                                {
                                        
MEMLIB_PRIV(vis)->inputbuffer=MEMLIB_PRIV(vis)->memptr;
                                        MEMLIB_PRIV(vis)->memptr=(char 
*)MEMLIB_PRIV(vis)->memptr+INPBUFSIZE;
diff -uNr degas-old/lib/libggi/display/monotext/visual.c 
degas/lib/libggi/display/monotext/visual.c
--- degas-old/lib/libggi/display/monotext/visual.c      Tue Apr 25 07:07:11 2000
+++ degas/lib/libggi/display/monotext/visual.c  Thu May 25 20:09:20 2000
@@ -40,10 +40,12 @@
        { "x",  "2" },
        { "y",  "4" }
 };
+
 #define OPT_A          0
 #define OPT_X          1
 #define OPT_Y          2
-#define NUM_OPTIONS    (sizeof(options)/sizeof(gg_option))
+
+#define NUM_OPTS       (sizeof(options)/sizeof(gg_option))
 
 
 static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh,
@@ -57,7 +59,7 @@
        GGIDPRINT("display-monotext: GGIdlinit start.\n");
 
        if (args) {
-               args = ggParseOptions(args, options, NUM_OPTIONS);
+               args = ggParseOptions(args, options, NUM_OPTS);
                if (args == NULL) {
                        fprintf(stderr,
                                "display-monotext: error in arguments\n");
diff -uNr degas-old/lib/libggi/display/palemu/visual.c 
degas/lib/libggi/display/palemu/visual.c
--- degas-old/lib/libggi/display/palemu/visual.c        Tue Apr 25 07:07:12 2000
+++ degas/lib/libggi/display/palemu/visual.c    Thu May 25 20:10:30 2000
@@ -34,11 +34,15 @@
 #include <ggi/display/palemu.h>
 
 
-static gg_option palemu_options[1] =
+static gg_option options[] =
 {
        { "parent", "[]" }
 };
 
+#define OPT_PARENT     0
+
+#define NUM_OPTS       (sizeof(options)/sizeof(gg_option))
+
 
 static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh,
                        const char *args, void *argptr, uint32 *dlret)
@@ -68,7 +72,7 @@
 
        if (getenv("GGI_PALEMU_OPTIONS") != NULL) {
                if (ggParseOptions(getenv("GGI_PALEMU_OPTIONS"),
-                       palemu_options, 1) == NULL) {
+                       options, NUM_OPTS) == NULL) {
                        
                        fprintf(stderr, "display-palemu: error in "
                                "$GGI_PALEMU_OPTIONS.\n");
@@ -78,8 +82,8 @@
        }
        
        if (args) {
-               args = ggParseOptions((char *) args, palemu_options, 3);
-                       
+               args = ggParseOptions((char *) args, options, NUM_OPTS);
+
                if (args == NULL) {
                        fprintf(stderr, "display-palemu: error in "
                                "arguments.\n");
@@ -89,9 +93,9 @@
        }
 
        GGIDPRINT("display-palemu: parent mode is '%s'\n",
-               palemu_options[0].result);
+               options[OPT_PARENT].result);
 
-       ggiParseMode(palemu_options[0].result, &ph->mode);
+       ggiParseMode(options[OPT_PARENT].result, &ph->mode);
        
        /* Setup mansync */
        err = _ggiAddDL(vis, "helper-mansync", NULL, ph->opmansync, 0);
diff -uNr degas-old/lib/libggi/display/trueemu/visual.c 
degas/lib/libggi/display/trueemu/visual.c
--- degas-old/lib/libggi/display/trueemu/visual.c       Tue Apr 25 07:07:17 2000
+++ degas/lib/libggi/display/trueemu/visual.c   Thu May 25 20:10:53 2000
@@ -34,13 +34,20 @@
 #include <ggi/display/trueemu.h>
 
 
-static gg_option trueemu_options[3] =
+static gg_option options[] =
 {
        { "parent", ""    },
        { "dither", "4"   },
        { "model",  "rgb" }
 };
 
+#define OPT_PARENT     0
+#define OPT_DITHER     1
+#define OPT_MODEL      2
+
+#define NUM_OPTS       (sizeof(options)/sizeof(gg_option))
+
+
 static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh,
                   const char *args, void *argptr, uint32 *dlret)
 {
@@ -67,7 +74,7 @@
        /* handle arguments */
        if (getenv("GGI_TRUEEMU_OPTIONS") != NULL) {
                if (ggParseOptions(getenv("GGI_TRUEEMU_OPTIONS"),
-                       trueemu_options, 3) == NULL) {
+                       options, NUM_OPTS) == NULL) {
                        
                        fprintf(stderr, "display-trueemu: error in "
                                "$GGI_TRUEEMU_OPTIONS.\n");
@@ -77,7 +84,7 @@
        }
 
        if (args) {
-               args = ggParseOptions((char *) args, trueemu_options, 3);
+               args = ggParseOptions((char *) args, options, NUM_OPTS);
 
                if (args == NULL) {
                        fprintf(stderr, "display-trueemu: error in "
@@ -88,30 +95,30 @@
        }
 
        /* parse the results */
-       GGIDPRINT("trueemu: parent is '%s'.\n", trueemu_options[0].result);
-       GGIDPRINT("trueemu: dither is '%s'.\n", trueemu_options[1].result);
-       GGIDPRINT("trueemu: model  is '%s'.\n", trueemu_options[2].result);
+       GGIDPRINT("trueemu: parent is '%s'.\n", options[OPT_PARENT].result);
+       GGIDPRINT("trueemu: dither is '%s'.\n", options[OPT_DITHER].result);
+       GGIDPRINT("trueemu: model  is '%s'.\n", options[OPT_MODEL].result);
 
-       ggiParseMode(trueemu_options[0].result, &priv->mode);
+       ggiParseMode(options[OPT_PARENT].result, &priv->mode);
 
-       switch (trueemu_options[1].result[0]) {
+       switch (options[OPT_DITHER].result[0]) {
                case '0': priv->flags |= TRUEEMU_F_DITHER_0; break;
                case '2': priv->flags |= TRUEEMU_F_DITHER_2; break;
                case '4': priv->flags |= TRUEEMU_F_DITHER_4; break;
 
                default:
                        fprintf(stderr, "display-trueemu: Unknown dither "
-                               "'%s'.\n", trueemu_options[1].result);
+                               "'%s'.\n", options[OPT_DITHER].result);
        }
 
-       switch (trueemu_options[2].result[0]) {
+       switch (options[OPT_MODEL].result[0]) {
                case 'r': priv->flags |= TRUEEMU_F_RGB;    break;
                case 'c': priv->flags |= TRUEEMU_F_CUBE;   break;
                case 'p': priv->flags |= TRUEEMU_F_PASTEL; break;
 
                default:
                        fprintf(stderr, "display-trueemu: Unknown model "
-                               "'%s'.\n", trueemu_options[2].result);
+                               "'%s'.\n", options[OPT_MODEL].result);
        }
 
        /* setup mansync */
diff -uNr degas-old/lib/libggi/display/vcsa/visual.c 
degas/lib/libggi/display/vcsa/visual.c
--- degas-old/lib/libggi/display/vcsa/visual.c  Tue Apr 25 07:07:18 2000
+++ degas/lib/libggi/display/vcsa/visual.c      Thu May 25 20:11:26 2000
@@ -43,9 +43,7 @@
 #include <ggi/display/vcsa.h>
 
 
-#define VCSA_OPTIONS  5
-
-static gg_option vcsa_options[VCSA_OPTIONS] =
+static gg_option options[] =
 {
        { "noinput", "no" },
        { "nokbd",   "no" },
@@ -54,6 +52,15 @@
        { "shade",   "no" }
 };
 
+#define OPT_NOINPUT    0
+#define OPT_NOKBD      1
+#define OPT_NOMOUSE    2
+#define OPT_ASCII      3
+#define OPT_SHADE      4
+
+#define NUM_OPTS       (sizeof(options)/sizeof(gg_option))
+
+
 static int which_console(void)
 {
        int fd; 
@@ -92,7 +99,7 @@
 
        if (getenv("GGI_VCSA_OPTIONS") != 0) {
                if (ggParseOptions(getenv("GGI_VCSA_OPTIONS"),
-                       vcsa_options, VCSA_OPTIONS) == NULL) {
+                       options, NUM_OPTS) == NULL) {
                        fprintf(stderr, "display-vcsa: error in "
                                "$GGI_VCSA_OPTIONS.\n");
                        return GGI_EARGINVAL;
@@ -100,8 +107,8 @@
        }
 
        if (args) {
-               args = ggParseOptions((char *)args, vcsa_options,
-                               VCSA_OPTIONS);
+               args = ggParseOptions((char *)args, options,
+                               NUM_OPTS);
                if (args == NULL) {
                        fprintf(stderr, "display-vcsa: error in "
                                "arguments.\n");
@@ -160,20 +167,20 @@
        priv->inputs = VCSA_INP_KBD | VCSA_INP_MOUSE;
        priv->flags = 0;
 
-       if (toupper(vcsa_options[0].result[0]) != 'N') {
+       if (toupper(options[OPT_NOINPUT].result[0]) != 'N') {
                priv->inputs = 0;
        }
-       if (toupper(vcsa_options[1].result[0]) != 'N') {
+       if (toupper(options[OPT_NOKBD].result[0]) != 'N') {
                priv->inputs &= ~VCSA_INP_KBD;
        }
-       if (toupper(vcsa_options[2].result[0]) != 'N') {
+       if (toupper(options[OPT_NOMOUSE].result[0]) != 'N') {
                priv->inputs &= ~VCSA_INP_MOUSE;
        }
        
-       if (toupper(vcsa_options[3].result[0]) != 'N') {
+       if (toupper(options[OPT_ASCII].result[0]) != 'N') {
                priv->flags |= VCSA_FLAG_ASCII;
        }
-       if (toupper(vcsa_options[4].result[0]) != 'N') {
+       if (toupper(options[OPT_SHADE].result[0]) != 'N') {
                priv->flags |= VCSA_FLAG_SHADE;
        }
 
diff -uNr degas-old/lib/libggi/include/ggi/types.h 
degas/lib/libggi/include/ggi/types.h
--- degas-old/lib/libggi/include/ggi/types.h    Mon Feb 22 07:11:41 1999
+++ degas/lib/libggi/include/ggi/types.h        Thu May 25 20:23:19 2000
@@ -62,6 +62,7 @@
 typedef struct { uint16        size; ggi_color *data; }                ggi_clut;
 
 #define        GGI_COLOR_PRECISION 16  /* 16 bit per R,G, B value      */
+#define        GGI_COLOR_MAX_VAL   0xFFFF      /* portability ...      */
 
 /*
  * Graphtypes

Reply via email to