aboutsummaryrefslogtreecommitdiff
path: root/backends/PalmOS/Src/missing/ext_string.c
diff options
context:
space:
mode:
authorChris Apers2006-02-25 20:34:13 +0000
committerChris Apers2006-02-25 20:34:13 +0000
commit1d09fb169b45671e47586e9d0ed811212dd9ba74 (patch)
treea55584aaf2deaf2634927921e96aa31198e9df30 /backends/PalmOS/Src/missing/ext_string.c
parent544438b01e0827bb223f22276edc9fe1344735a7 (diff)
downloadscummvm-rg350-1d09fb169b45671e47586e9d0ed811212dd9ba74.tar.gz
scummvm-rg350-1d09fb169b45671e47586e9d0ed811212dd9ba74.tar.bz2
scummvm-rg350-1d09fb169b45671e47586e9d0ed811212dd9ba74.zip
Rename those files so that:
- fucntions can also be used in C projects - functions really replace same functions from MSL instead of having multiple definitions for C and C++ svn-id: r20887
Diffstat (limited to 'backends/PalmOS/Src/missing/ext_string.c')
-rw-r--r--backends/PalmOS/Src/missing/ext_string.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/backends/PalmOS/Src/missing/ext_string.c b/backends/PalmOS/Src/missing/ext_string.c
new file mode 100644
index 0000000000..a02c360ceb
--- /dev/null
+++ b/backends/PalmOS/Src/missing/ext_string.c
@@ -0,0 +1,121 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include <string.h>
+
+void *memchr(const void *s, int c, UInt32 n) {
+ UInt32 chr;
+ for(chr = 0; chr < n;chr++,((UInt8 *)s)++)
+ if ( *((UInt8 *)s) == c)
+ return (void *)s;
+
+ return NULL;
+}
+
+UInt32 strspn(const char *s1, const char *s2) {
+ UInt32 chr = 0;
+
+ while ( chr < strlen(s1) &&
+ strchr(s2, s1[chr]) )
+ chr++;
+
+ return chr;
+}
+
+static Char *StrTokNext = NULL;
+
+Char *strtok(Char *str, const Char *sep) {
+ Char *position = NULL,
+ *found,
+ *end;
+
+ UInt16 loop = 0,
+ chars= StrLen(sep);
+
+ str = (str)?(str):(StrTokNext);
+ StrTokNext = NULL;
+
+ if (!str)
+ return NULL;
+
+ end = str+StrLen(str);
+
+ while (loop<chars)
+ {
+ found = StrChr(str,sep[loop]);
+ loop++;
+
+ if (found == str)
+ {
+ str++;
+ loop = 0;
+ }
+ else if (position == NULL || position > found)
+ position = found;
+ }
+
+ if (position == NULL)
+ if (str==end)
+ return NULL;
+ else
+ return str;
+
+ position[0] = 0;
+ StrTokNext = position+1;
+
+ return str;
+}
+
+Char *strpbrk(const Char *s1, const Char *s2) {
+ Char *found;
+ UInt32 n;
+
+ for (n=0; n <= StrLen(s2); n++) {
+ found = StrChr(s1, s2[n]);
+ if (found)
+ return found;
+ }
+
+ return NULL;
+}
+
+Char *strrchr(const Char *s, int c) {
+ UInt32 chr;
+ UInt32 n = StrLen(s);
+
+ for(chr = n; chr >= 0; chr--)
+ if ( *((UInt8 *)s+chr) == c)
+ return (Char *)(s+chr);
+
+ return NULL;
+}
+
+Char *strdup(const Char *s1) {
+ Char* buf = (Char *)MemPtrNew(StrLen(s1)+1);
+
+ if(buf)
+ StrCopy(buf, s1);
+
+ return buf;
+} \ No newline at end of file