]> git.saurik.com Git - wxWidgets.git/commitdiff
modified macintosh ifdef compilations to also test for __APPLE__
authorGilles Depeyrot <gilles_depeyrot@mac.com>
Sat, 27 Jan 2001 21:18:36 +0000 (21:18 +0000)
committerGilles Depeyrot <gilles_depeyrot@mac.com>
Sat, 27 Jan 2001 21:18:36 +0000 (21:18 +0000)
__APPLE__ is defined by the C/C++ compiler under Mac OS X

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9191 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/xpm/Imagexpm.c [new file with mode: 0644]
src/mac/xpm/XpmI.h
src/mac/xpm/create.c
src/mac/xpm/data.c
src/mac/xpm/dataxpm.c [new file with mode: 0644]
src/mac/xpm/parse.c
src/mac/xpm/simx.c
src/mac/xpm/simx.h
src/mac/xpm/xpm.h

diff --git a/src/mac/xpm/Imagexpm.c b/src/mac/xpm/Imagexpm.c
new file mode 100644 (file)
index 0000000..0753622
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 1989-95 GROUPE BULL
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of GROUPE BULL shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from GROUPE BULL.
+ */
+
+/*****************************************************************************\
+*  Image.c:                                                                   *
+*                                                                             *
+*  XPM library                                                                *
+*  Functions to init and free the XpmImage structure.                         *
+*                                                                             *
+*  Developed by Arnaud Le Hors                                                *
+\*****************************************************************************/
+
+#include "XpmI.h"
+
+/*
+ * Init returned data to free safely later on
+ */
+void
+xpmInitXpmImage(image)
+    XpmImage *image;
+{
+    image->ncolors = 0;
+    image->colorTable = NULL;
+    image->data = NULL;
+}
+
+/*
+ * Free the XpmImage data which have been allocated
+ */
+void
+XpmFreeXpmImage(image)
+    XpmImage *image;
+{
+    if (image->colorTable)
+       xpmFreeColorTable(image->colorTable, image->ncolors);
+    if (image->data)
+       XpmFree(image->data);
+    image->data = NULL;
+}
index b50e38af938e3d947288b6799cb8a706c4abec2e..74271d3b534b8e3b452fa6ab1e53745f383778a1 100644 (file)
@@ -62,7 +62,7 @@
 extern FILE *popen();
 #endif
 
-#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32) || defined( macintosh )
+#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32) || defined(macintosh) || defined(__APPLE__)
 #include <string.h>
 
 #ifndef index
@@ -79,7 +79,7 @@ extern FILE *popen();
 
 
 
-#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32) || defined( macintosh )
+#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32) || defined(macintosh) || defined(__APPLE__)
 #ifndef bcopy
 #define bcopy(source, dest, count) memcpy(dest, source, count)
 #endif
index 5495b9692a95db1924544a6aa637d67c317e39fb..fdb8a797245346776172320f014eb54f3a3873de 100644 (file)
@@ -412,7 +412,7 @@ CreateColors(display, attributes, colors, ncolors, image_pixels, mask_pixels,
            } 
            else
            {
-               #ifdef macintosh
+               #if defined(macintosh) || defined(__APPLE__)
                        SET_WHITE_PIXEL( *mask_pixels ) ; // is this correct CS ????
                        #else
                        *mask_pixels = 1; // is this correct CS ????
@@ -677,7 +677,7 @@ PlatformPutImagePixels(dc, image, width, height, pixelindex, pixels)
        }
     }
     SelectObject(*dc, obm);
-#elif macintosh
+#elif defined(macintosh) || defined(__APPLE__)
        GrafPtr         origPort ;
        GDHandle        origDevice ;
        
@@ -1036,7 +1036,7 @@ ParseAndPutPixels(
            }
            obm = SelectObject(*dc, image->bitmap);
 
-               #elif macintosh
+               #elif defined(macintosh) || defined(__APPLE__)
                GrafPtr         origPort ;
                GDHandle        origDevice ;
                
@@ -1065,7 +1065,7 @@ ParseAndPutPixels(
                                        {
                                            SetPixel(shapedc, x, y, shape_pixels[colidx[c] - 1]);
                                        }
-                                       #elif macintosh
+                                       #elif defined(macintosh) || defined(__APPLE__)
                                        SetCPixel( x, y, &image_pixels[colidx[c] - 1]);
                                        if (shapeimage) 
                                        {
@@ -1086,7 +1086,7 @@ ParseAndPutPixels(
                        DeleteDC(shapedc);
            }
            SelectObject(*dc, obm);
-               #elif macintosh
+               #elif defined(macintosh) || defined(__APPLE__)
        SetGWorld( origPort , origDevice ) ;
                #endif
        }
@@ -1103,7 +1103,7 @@ if (cidx[f]) XpmFree(cidx[f]);}
            /* array of pointers malloced by need */
            unsigned short *cidx[256];
            int char1;
-               #ifdef macintosh
+               #if defined(macintosh) || defined(__APPLE__)
                GrafPtr         origPort ;
                GDHandle        origDevice ;
                GetGWorld( &origPort , &origDevice ) ;
@@ -1116,7 +1116,7 @@ if (cidx[f]) XpmFree(cidx[f]);}
                    cidx[char1] = (unsigned short *)
                        XpmCalloc(256, sizeof(unsigned short));
                    if (cidx[char1] == NULL) { /* new block failed */
-                       #ifdef macintosh
+                       #if defined(macintosh) || defined(__APPLE__)
                SetGWorld( origPort , origDevice ) ;
                        #endif
                        FREE_CIDX;
@@ -1145,19 +1145,19 @@ if (cidx[f]) XpmFree(cidx[f]);}
                            SetPixel(*dc, x, y,
                                     shape_pixels[cidx[cc1][cc2] - 1]);
                        }
-                       #elif macintosh
+                       #elif defined(macintosh) || defined(__APPLE__)
                        SetCPixel( x, y, &image_pixels[cidx[cc1][cc2] - 1]);  
                        #endif
                        } else 
                        {
-                               #ifdef macintosh
+                               #if defined(macintosh) || defined(__APPLE__)
                        SetGWorld( origPort , origDevice ) ;
                                #endif
                            FREE_CIDX;
                            return (XpmFileInvalid);
                        }
                    } else {
-                               #ifdef macintosh
+                               #if defined(macintosh) || defined(__APPLE__)
                        SetGWorld( origPort , origDevice ) ;
                                #endif
                        FREE_CIDX;
@@ -1165,7 +1165,7 @@ if (cidx[f]) XpmFree(cidx[f]);}
                    }
                }
            }
-               #ifdef macintosh
+               #if defined(macintosh) || defined(__APPLE__)
                SetGWorld( origPort , origDevice ) ;
                #endif
            FREE_CIDX;
@@ -1177,7 +1177,7 @@ if (cidx[f]) XpmFree(cidx[f]);}
        {
            char *s;
            char buf[BUFSIZ];
-               #ifdef macintosh
+               #if defined(macintosh) || defined(__APPLE__)
                GrafPtr         origPort ;
                GDHandle        origDevice ;
                GetGWorld( &origPort , &origDevice ) ;
@@ -1196,7 +1196,7 @@ if (cidx[f]) XpmFree(cidx[f]);}
                        slot = xpmHashSlot(hashtable, buf);
                        if (!*slot)     /* no color matches */
                        {
-                               #ifdef macintosh
+                               #if defined(macintosh) || defined(__APPLE__)
                        SetGWorld( origPort , origDevice ) ;
                                #endif
                            return (XpmFileInvalid);
@@ -1212,7 +1212,7 @@ if (cidx[f]) XpmFree(cidx[f]);}
                            SetPixel(*dc, x, y,
                                     shape_pixels[HashColorIndex(slot)]);
                        }
-                       #elif macintosh
+                       #elif defined(macintosh) || defined(__APPLE__)
                        SetCPixel( x, y, &image_pixels[HashColorIndex(slot)]); 
                        #endif
                    }
@@ -1228,7 +1228,7 @@ if (cidx[f]) XpmFree(cidx[f]);}
                                break;
                        if (a == ncolors)       /* no color matches */
                        {
-                               #ifdef macintosh
+                               #if defined(macintosh) || defined(__APPLE__)
                        SetGWorld( origPort , origDevice ) ;
                                #endif
                            return (XpmFileInvalid);
@@ -1241,13 +1241,13 @@ if (cidx[f]) XpmFree(cidx[f]);}
                            SelectObject(*dc, shapeimage->bitmap);
                            SetPixel(*dc, x, y, shape_pixels[a]);
                        }
-                       #elif macintosh
+                       #elif defined(macintosh) || defined(__APPLE__)
                SetCPixel( x, y, &image_pixels[a]); // data is [x+y*width] 
                        #endif
                    }
                }
            }
-               #ifdef macintosh
+               #if defined(macintosh) || defined(__APPLE__)
        SetGWorld( origPort , origDevice ) ;
                #endif
 
index 2a9d2ece2ec2cba8a7938b0ec76d9baab7003cb2..3c374fd3914b0457dde4538950d4deb54301c32f 100644 (file)
@@ -423,7 +423,7 @@ xpmParseHeader(data)
            if (!l)
                return (XpmFileInvalid);
            buf[l] = '\0';
-           #ifdef macintosh
+           #if defined(macintosh) ||Êdefined(__APPLE__)
            ptr = strrchr(buf, '_');
            #else
            ptr = rindex(buf, '_');
diff --git a/src/mac/xpm/dataxpm.c b/src/mac/xpm/dataxpm.c
new file mode 100644 (file)
index 0000000..cba3063
--- /dev/null
@@ -0,0 +1,487 @@
+/*
+ * Copyright (C) 1989-95 GROUPE BULL
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of GROUPE BULL shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from GROUPE BULL.
+ */
+
+/*****************************************************************************\
+* data.c:                                                                     *
+*                                                                             *
+*  XPM library                                                                *
+*  IO utilities                                                               *
+*                                                                             *
+*  Developed by Arnaud Le Hors                                                *
+\*****************************************************************************/
+
+#ifndef CXPMPROG
+/* Official version number */
+static char *RCS_Version = "$XpmVersion: 3.4k $";
+
+/* Internal version number */
+static char *RCS_Id = "$Id$";
+
+#include "XpmI.h"
+#endif
+#include <ctype.h>
+
+#ifndef CXPMPROG
+#define Getc(data, file) getc(file)
+#define Ungetc(data, c, file) ungetc(c, file)
+#endif
+
+static int
+ParseComment(data)
+    xpmData *data;
+{
+    if (data->type == XPMBUFFER) {
+       register char c;
+       register unsigned int n = 0;
+       unsigned int notend;
+       char *s, *s2;
+
+       s = data->Comment;
+       *s = data->Bcmt[0];
+
+       /* skip the string beginning comment */
+       s2 = data->Bcmt;
+       do {
+           c = *data->cptr++;
+           *++s = c;
+           n++;
+           s2++;
+       } while (c == *s2 && *s2 != '\0' && c);
+
+       if (*s2 != '\0') {
+           /* this wasn't the beginning of a comment */
+           data->cptr -= n;
+           return 0;
+       }
+       /* store comment */
+       data->Comment[0] = *s;
+       s = data->Comment;
+       notend = 1;
+       n = 0;
+       while (notend) {
+           s2 = data->Ecmt;
+           while (*s != *s2 && c) {
+               c = *data->cptr++;
+               if (n == XPMMAXCMTLEN - 1)  { /* forget it */
+                   s = data->Comment;
+                   n = 0;
+               }
+               *++s = c;
+               n++;
+           }
+           data->CommentLength = n;
+           do {
+               c = *data->cptr++;
+               if (n == XPMMAXCMTLEN - 1)  { /* forget it */
+                   s = data->Comment;
+                   n = 0;
+               }
+               *++s = c;
+               n++;
+               s2++;
+           } while (c == *s2 && *s2 != '\0' && c);
+           if (*s2 == '\0') {
+               /* this is the end of the comment */
+               notend = 0;
+               data->cptr--;
+           }
+       }
+       return 0;
+    } else {
+       FILE *file = data->stream.file;
+       register int c;
+       register unsigned int n = 0, a;
+       unsigned int notend;
+       char *s, *s2;
+
+       s = data->Comment;
+       *s = data->Bcmt[0];
+
+       /* skip the string beginning comment */
+       s2 = data->Bcmt;
+       do {
+           c = Getc(data, file);
+           *++s = c;
+           n++;
+           s2++;
+       } while (c == *s2 && *s2 != '\0' && c != EOF);
+
+       if (*s2 != '\0') {
+           /* this wasn't the beginning of a comment */
+           /* put characters back in the order that we got them */
+           for (a = n; a > 0; a--, s--)
+               Ungetc(data, *s, file);
+           return 0;
+       }
+       /* store comment */
+       data->Comment[0] = *s;
+       s = data->Comment;
+       notend = 1;
+       n = 0;
+       while (notend) {
+           s2 = data->Ecmt;
+           while (*s != *s2 && c != EOF) {
+               c = Getc(data, file);
+               if (n == XPMMAXCMTLEN - 1)  { /* forget it */
+                   s = data->Comment;
+                   n = 0;
+               }
+               *++s = c;
+               n++;
+           }
+           data->CommentLength = n;
+           do {
+               c = Getc(data, file);
+               if (n == XPMMAXCMTLEN - 1)  { /* forget it */
+                   s = data->Comment;
+                   n = 0;
+               }
+               *++s = c;
+               n++;
+               s2++;
+           } while (c == *s2 && *s2 != '\0' && c != EOF);
+           if (*s2 == '\0') {
+               /* this is the end of the comment */
+               notend = 0;
+               Ungetc(data, *s, file);
+           }
+       }
+       return 0;
+    }
+}
+
+/*
+ * skip to the end of the current string and the beginning of the next one
+ */
+int
+xpmNextString(data)
+    xpmData *data;
+{
+    if (!data->type)
+       data->cptr = (data->stream.data)[++data->line];
+    else if (data->type == XPMBUFFER) {
+       register char c;
+
+       /* get to the end of the current string */
+       if (data->Eos)
+           while ((c = *data->cptr++)!=NULL && c != data->Eos)
+           {}
+
+       /*
+        * then get to the beginning of the next string looking for possible
+        * comment
+        */
+       if (data->Bos) {
+           while ((c = *data->cptr++)!=NULL  && c != data->Bos)
+               if (data->Bcmt && c == data->Bcmt[0])
+                   ParseComment(data);
+       } else if (data->Bcmt) {        /* XPM2 natural */
+           while ((c = *data->cptr++) == data->Bcmt[0])
+               ParseComment(data);
+           data->cptr--;
+       }
+    } else {
+       register int c;
+       FILE *file = data->stream.file;
+
+       /* get to the end of the current string */
+       if (data->Eos)
+           while ((c = Getc(data, file))!=NULL  != data->Eos && c != EOF)
+           {}
+
+       /*
+        * then get to the beginning of the next string looking for possible
+        * comment
+        */
+       if (data->Bos) {
+           while ((c = Getc(data, file)) != data->Bos && c != EOF)
+               if (data->Bcmt && c == data->Bcmt[0])
+                   ParseComment(data);
+
+       } else if (data->Bcmt) {        /* XPM2 natural */
+           while ((c = Getc(data, file)) == data->Bcmt[0])
+               ParseComment(data);
+           Ungetc(data, c, file);
+       }
+    }
+    return 0;
+}
+
+
+/*
+ * skip whitespace and return the following word
+ */
+unsigned int
+xpmNextWord(data, buf, buflen)
+    xpmData *data;
+    char *buf;
+    unsigned int buflen;
+{
+    register unsigned int n = 0;
+    int c;
+
+    if (!data->type || data->type == XPMBUFFER) {
+       while (isspace(c = *data->cptr) && c != data->Eos)
+           data->cptr++;
+       do {
+           c = *data->cptr++;
+           *buf++ = c;
+           n++;
+       } while (!isspace(c) && c != data->Eos && n < buflen);
+       n--;
+       data->cptr--;
+    } else {
+       FILE *file = data->stream.file;
+
+       while ((c = Getc(data, file)) != EOF && isspace(c) && c != data->Eos)
+       {
+       }
+       while (!isspace(c) && c != data->Eos && c != EOF && n < buflen) {
+           *buf++ = c;
+           n++;
+           c = Getc(data, file);
+       }
+       Ungetc(data, c, file);
+    }
+    return (n);
+}
+
+/*
+ * skip whitespace and compute the following unsigned int,
+ * returns 1 if one is found and 0 if not
+ */
+int
+xpmNextUI(data, ui_return)
+    xpmData *data;
+    unsigned int *ui_return;
+{
+    char buf[BUFSIZ];
+    int l;
+
+    l = xpmNextWord(data, buf, BUFSIZ);
+    return xpmatoui(buf, l, ui_return);
+}
+
+/*
+ * return end of string - WARNING: malloc!
+ */
+int
+xpmGetString(data, sptr, l)
+    xpmData *data;
+    char **sptr;
+    unsigned int *l;
+{
+    unsigned int i, n = 0;
+    int c;
+    char *p = NULL, *q, buf[BUFSIZ];
+
+    if (!data->type || data->type == XPMBUFFER) {
+       if (data->cptr) {
+           char *start = data->cptr;
+           while ((c = *data->cptr)!=NULL  && c != data->Eos)
+               data->cptr++;
+           n = data->cptr - start + 1;
+           p = (char *) XpmMalloc(n);
+           if (!p)
+               return (XpmNoMemory);
+           strncpy(p, start, n);
+           if (data->type)             /* XPMBUFFER */
+               p[n - 1] = '\0';
+       }
+    } else {
+       FILE *file = data->stream.file;
+
+       if ((c = Getc(data, file)) == EOF)
+           return (XpmFileInvalid);
+
+       i = 0;
+       q = buf;
+       p = (char *) XpmMalloc(1);
+       while (c != data->Eos && c != EOF) {
+           if (i == BUFSIZ) {
+               /* get to the end of the buffer */
+               /* malloc needed memory */
+               q = (char *) XpmRealloc(p, n + i);
+               if (!q) {
+                   XpmFree(p);
+                   return (XpmNoMemory);
+               }
+               p = q;
+               q += n;
+               /* and copy what we already have */
+               strncpy(q, buf, i);
+               n += i;
+               i = 0;
+               q = buf;
+           }
+           *q++ = c;
+           i++;
+           c = Getc(data, file);
+       }
+       if (c == EOF) {
+           XpmFree(p);
+           return (XpmFileInvalid);
+       }
+       if (n + i != 0) {
+           /* malloc needed memory */
+           q = (char *) XpmRealloc(p, n + i + 1);
+           if (!q) {
+               XpmFree(p);
+               return (XpmNoMemory);
+           }
+           p = q;
+           q += n;
+           /* and copy the buffer */
+           strncpy(q, buf, i);
+           n += i;
+           p[n++] = '\0';
+       } else {
+           *p = '\0';
+           n = 1;
+       }
+       Ungetc(data, c, file);
+    }
+    *sptr = p;
+    *l = n;
+    return (XpmSuccess);
+}
+
+/*
+ * get the current comment line
+ */
+int
+xpmGetCmt(data, cmt)
+    xpmData *data;
+    char **cmt;
+{
+    if (!data->type)
+       *cmt = NULL;
+    else if (data->CommentLength) {
+       *cmt = (char *) XpmMalloc(data->CommentLength + 1);
+       strncpy(*cmt, data->Comment, data->CommentLength);
+       (*cmt)[data->CommentLength] = '\0';
+       data->CommentLength = 0;
+    } else
+       *cmt = NULL;
+    return 0;
+}
+
+xpmDataType xpmDataTypes[] =
+{
+    "", "!", "\n", '\0', '\n', "", "", "", "", /* Natural type */
+    "C", "/*", "*/", '"', '"', ",\n", "static char *", "[] = {\n", "};\n",
+    "Lisp", ";", "\n", '"', '"', "\n", "(setq ", " '(\n", "))\n",
+#ifdef VMS
+    NULL
+#else
+    NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL
+#endif
+};
+
+/*
+ * parse xpm header
+ */
+int
+xpmParseHeader(data)
+    xpmData *data;
+{
+    char buf[BUFSIZ];
+    int l, n = 0;
+
+    if (data->type) {
+       data->Bos = '\0';
+       data->Eos = '\n';
+       data->Bcmt = data->Ecmt = NULL;
+       l = xpmNextWord(data, buf, BUFSIZ);
+       if (l == 7 && !strncmp("#define", buf, 7)) {
+           /* this maybe an XPM 1 file */
+           char *ptr;
+
+           l = xpmNextWord(data, buf, BUFSIZ);
+           if (!l)
+               return (XpmFileInvalid);
+           buf[l] = '\0';
+           #if defined(macintosh) || defined(__APPLE__)
+           ptr = strrchr(buf, '_');
+           #else
+           ptr = rindex(buf, '_');
+           #endif
+           if (!ptr || strncmp("_format", ptr, l - (ptr - buf)))
+               return XpmFileInvalid;
+           /* this is definitely an XPM 1 file */
+           data->format = 1;
+           n = 1;                      /* handle XPM1 as mainly XPM2 C */
+       } else {
+
+           /*
+            * skip the first word, get the second one, and see if this is
+            * XPM 2 or 3
+            */
+           l = xpmNextWord(data, buf, BUFSIZ);
+           if ((l == 3 && !strncmp("XPM", buf, 3)) ||
+               (l == 4 && !strncmp("XPM2", buf, 4))) {
+               if (l == 3)
+                   n = 1;              /* handle XPM as XPM2 C */
+               else {
+                   /* get the type key word */
+                   l = xpmNextWord(data, buf, BUFSIZ);
+
+                   /*
+                    * get infos about this type
+                    */
+                   while (xpmDataTypes[n].type
+                          && strncmp(xpmDataTypes[n].type, buf, l))
+                       n++;
+               }
+               data->format = 0;
+           } else
+               /* nope this is not an XPM file */
+               return XpmFileInvalid;
+       }
+       if (xpmDataTypes[n].type) {
+           if (n == 0) {               /* natural type */
+               data->Bcmt = xpmDataTypes[n].Bcmt;
+               data->Ecmt = xpmDataTypes[n].Ecmt;
+               xpmNextString(data);    /* skip the end of the headerline */
+               data->Bos = xpmDataTypes[n].Bos;
+               data->Eos = xpmDataTypes[n].Eos;
+           } else {
+               data->Bcmt = xpmDataTypes[n].Bcmt;
+               data->Ecmt = xpmDataTypes[n].Ecmt;
+               if (!data->format) {    /* XPM 2 or 3 */
+                   data->Bos = xpmDataTypes[n].Bos;
+                   data->Eos = '\0';
+                   /* get to the beginning of the first string */
+                   xpmNextString(data);
+                   data->Eos = xpmDataTypes[n].Eos;
+               } else                  /* XPM 1 skip end of line */
+                   xpmNextString(data);
+           }
+       } else
+           /* we don't know about that type of XPM file... */
+           return XpmFileInvalid;
+    }
+    return XpmSuccess;
+}
index 905666777ff928eb41cefd3e37b66a8d0aa2b21a..fdf19f342060c21761e2dabe1f6b7abb21bc76a1 100644 (file)
@@ -111,7 +111,8 @@ xpmParseValues(data, width, height, ncolors, cpp,
            ptr = buf;
            got_one = False;
            while (!got_one) {
-           #ifdef macintosh // we have a strange parameter problem here
+           #if defined(macintosh) || defined(__APPLE__)
+           // we have a strange parameter problem here
                ptr = strchr(ptr, '_'); // index
            #else
                ptr = index(ptr, '_'); 
index 48dc21b0374c13986ae6b1af3b0e698ca1c320e4..7b6638fb2eb243a13c96e4599beb5cb206f0ecfd 100644 (file)
@@ -173,7 +173,7 @@ rgbFromHex(char *hex, int *r, int *g, int *b)
                *r = hexCharToInt(hex[1]);
                *g = hexCharToInt(hex[2]);
                *b = hexCharToInt(hex[3]);
-               #ifdef macintosh
+               #if defined(macintosh) || defined(__APPLE__)
                *r <<= 12 ;
                *g <<= 12 ;
                *b <<= 12 ;
@@ -183,7 +183,7 @@ rgbFromHex(char *hex, int *r, int *g, int *b)
                *r = hexCharToInt(hex[1]) * 16 + hexCharToInt(hex[2]);
                *g = hexCharToInt(hex[3]) * 16 + hexCharToInt(hex[4]);
                *b = hexCharToInt(hex[5]) * 16 + hexCharToInt(hex[6]);
-               #ifdef macintosh
+               #if defined(macintosh) || defined(__APPLE__)
                *r <<= 8 ;
                *g <<= 8 ;
                *b <<= 8 ;
@@ -191,7 +191,7 @@ rgbFromHex(char *hex, int *r, int *g, int *b)
     } else if (len == 12 + 1) 
     {
                /* it's like c #32329999CCCC */
-               #ifdef macintosh
+               #if defined(macintosh) || defined(__APPLE__)
                *r = hexCharToInt(hex[1]) * 0x1000 + hexCharToInt(hex[2]) *0x0100 + hexCharToInt(hex[3]) *0x0010 + hexCharToInt(hex[4]) ;
                *g = hexCharToInt(hex[5]) * 0x1000 + hexCharToInt(hex[6]) *0x0100 + hexCharToInt(hex[7]) *0x0010 + hexCharToInt(hex[8]);
                *b =hexCharToInt(hex[9]) * 0x1000 + hexCharToInt(hex[10]) *0x0100 + hexCharToInt(hex[11]) *0x0010 + hexCharToInt(hex[12]);
@@ -232,7 +232,7 @@ XParseColor(Display *d, Colormap *cmap, char *name, XColor *color)
                        color->red = (BYTE) r;
                        color->green = (BYTE) g;
                        color->blue = (BYTE) b;
-       #elif macintosh
+       #elif defined(macintosh) || defined(__APPLE__)
                color->pixel.red = r ;
                color->pixel.green = g ;
                color->pixel.blue = b ;
@@ -273,7 +273,7 @@ XQueryColors(Display *display, Colormap *colormap,
 }
 int 
 XFreeColors(Display *d, Colormap cmap,
-           unsigned long pixels[], int npixels, unsigned long planes)
+           Pixel *pixels, int npixels, unsigned long planes)
 {
     /* no colormap yet */
     return (0);                                /* correct ??? */
@@ -302,7 +302,7 @@ XCreateImage(Display *d, Visual *v,
            img->bitmap = CreateBitmap(width, height, 1 /* plane */ ,
                                       depth /* bits per pixel */ , NULL);
                }
-       #elif macintosh
+       #elif defined(macintosh) || defined(__APPLE__)
                Rect rect ;
                
                rect.left= rect.top = 0 ;
@@ -346,7 +346,7 @@ XDestroyImage(XImage *img)
     if (img) {
     #if FOR_MSW
        DeleteObject(img->bitmap);      /* check return ??? */
-       #elif macintosh
+       #elif defined(macintosh) || defined(__APPLE__)
        if ( img->gworldptr )
        {
                UnlockPixels( GetGWorldPixMap( img->gworldptr ) ) ;
index 4922f1f58ac978046cd7b37fb318729d06706d28..90324a50963788cb06df100a9adeb42bf8f3cb93 100644 (file)
@@ -89,8 +89,10 @@ typedef struct {
     unsigned int depth;
 }      XImage;
 
-#elif macintosh
-#ifndef __MWERKS__
+#elif defined(macintosh) || defined(__APPLE__)
+#if defined(__APPLE__)
+#include <Carbon/Carbon.h>
+#elif !defined(__MWERKS__)
 #include <wx/wxprec.h>
 #endif
 /* define Mac types for X window types */
@@ -138,7 +140,7 @@ extern "C" {
     FUNC(XQueryColors, void, (Display *display, Colormap *colormap,
                              XColor *xcolors, int ncolors));
     FUNC(XFreeColors, int, (Display *d, Colormap cmap,
-                           unsigned long pixels[],
+                           Pixel *pixels,
                            int npixels, unsigned long planes));
 /* XImage */
     FUNC(XCreateImage, XImage *, (Display *, Visual *, int depth, int format,
@@ -163,7 +165,7 @@ extern "C" {
 #ifndef Bool
 #ifdef FOR_MSW
 typedef BOOL Bool;             /* take MSW bool */
-#elif macintosh
+#elif defined(macintosh) || defined(__APPLE__)
 typedef Boolean Bool;          /* take MSW bool */
 #endif
 #endif
index 1680f6363ac2fa2a673760a760858d0107042725..c64a22776c2dcf092cfee654f984b9868606064e 100644 (file)
@@ -79,7 +79,7 @@
 #define SET_ZERO_PIXEL(a) { (a)  = 0 }
 #define SET_WHITE_PIXEL(a) { (a)  = 0 }
 #  include "amigax.h"
-#elif macintosh
+#elif defined(macintosh) || defined(__APPLE__)
 #define IS_EQUAL_PIXEL( a , b ) ( (a).red == (b).red && (a).green == (b).green && (a).blue == (b).blue )
 #define IS_ZERO_PIXEL(a) (!(a).red && !(a).green && !(a).blue )
 #define SET_ZERO_PIXEL(a) { (a).red = 0 ; (a).green = 0 ;(a).blue = 0 ;}