]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/xpm/misc.c
Commented out palette code for wxGTK
[wxWidgets.git] / src / mac / xpm / misc.c
... / ...
CommitLineData
1/*
2 * Copyright (C) 1989-95 GROUPE BULL
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 *
21 * Except as contained in this notice, the name of GROUPE BULL shall not be
22 * used in advertising or otherwise to promote the sale, use or other dealings
23 * in this Software without prior written authorization from GROUPE BULL.
24 */
25
26/*****************************************************************************\
27* misc.c: *
28* *
29* XPM library *
30* Miscellaneous utilities *
31* *
32* Developed by Arnaud Le Hors *
33\*****************************************************************************/
34
35#include "XpmI.h"
36
37#ifdef NEED_STRDUP
38/*
39 * in case strdup is not provided by the system here is one
40 * which does the trick
41 */
42char *
43xpmstrdup(s1)
44 char *s1;
45{
46 char *s2;
47 int l = strlen(s1) + 1;
48
49 if (s2 = (char *) XpmMalloc(l))
50 strcpy(s2, s1);
51 return s2;
52}
53
54#endif
55
56unsigned int
57xpmatoui(p, l, ui_return)
58 register char *p;
59 unsigned int l;
60 unsigned int *ui_return;
61{
62 register unsigned int n, i;
63
64 n = 0;
65 for (i = 0; i < l; i++)
66 if (*p >= '0' && *p <= '9')
67 n = n * 10 + *p++ - '0';
68 else
69 break;
70
71 if (i != 0 && i == l) {
72 *ui_return = n;
73 return 1;
74 } else
75 return 0;
76}
77
78/*
79 * Function returning a character string related to an error code.
80 */
81char *
82XpmGetErrorString(errcode)
83 int errcode;
84{
85 switch (errcode) {
86 case XpmColorError:
87 return ("XpmColorError");
88 case XpmSuccess:
89 return ("XpmSuccess");
90 case XpmOpenFailed:
91 return ("XpmOpenFailed");
92 case XpmFileInvalid:
93 return ("XpmFileInvalid");
94 case XpmNoMemory:
95 return ("XpmNoMemory");
96 case XpmColorFailed:
97 return ("XpmColorFailed");
98 default:
99 return ("Invalid XpmError");
100 }
101}
102
103/*
104 * The following function provides a way to figure out if the linked library is
105 * newer or older than the one with which a program has been first compiled.
106 */
107int
108XpmLibraryVersion()
109{
110 return XpmIncludeVersion;
111}
112
113
114/* The following should help people wanting to use their own functions */
115#ifdef XpmFree
116#undef XpmFree
117#endif
118
119void
120XpmFree(ptr)
121 void *ptr;
122{
123 free(ptr);
124}