summaryrefslogtreecommitdiff
path: root/strfuncs.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2005-05-01 10:19:59 +0000
committerJames Bursa <james@netsurf-browser.org>2005-05-01 10:19:59 +0000
commit18781a787eb8aca7dc19d53189a7ef65856bb746 (patch)
treeb10695345b705315da7945cd79a32e606bf26fc2 /strfuncs.c
parenta13b4fc11cdeee628d92fd6d734ed0f5ffa497fc (diff)
downloadlibrufl-18781a787eb8aca7dc19d53189a7ef65856bb746.tar.gz
librufl-18781a787eb8aca7dc19d53189a7ef65856bb746.tar.bz2
[project @ 2005-05-01 10:19:59 by bursa]
Add Python module. Add support for compiling with Norcroft (mainly required for the Python module). svn path=/import/rufl/; revision=2463
Diffstat (limited to 'strfuncs.c')
-rw-r--r--strfuncs.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/strfuncs.c b/strfuncs.c
new file mode 100644
index 0000000..e6c6347
--- /dev/null
+++ b/strfuncs.c
@@ -0,0 +1,35 @@
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+char *strdup(const char *s)
+{
+ size_t len = strlen(s);
+ char *new = malloc(len + 1);
+ if (!new)
+ return 0;
+ memcpy(new, s, len);
+ new[len] = '\0';
+ return new;
+}
+
+char *strndup(const char *s, size_t n)
+{
+ size_t len = strlen(s);
+ if (n < len)
+ len = n;
+ char *new = malloc(len + 1);
+ if (!new)
+ return 0;
+ memcpy(new, s, len);
+ new[len] = '\0';
+ return new;
+}
+
+int strcasecmp(const char *s1, const char *s2)
+{
+ int i;
+ while ((i = tolower(*s1)) && i == tolower(*s2))
+ s1++, s2++;
+ return ((unsigned char) tolower(*s1) - (unsigned char) tolower(*s2));
+}