Prevented declarations conflict of reactos functions with <string.h>
authorshort <>
Wed, 5 Feb 2003 12:39:52 +0000 (12:39 +0000)
committershort <>
Wed, 5 Feb 2003 12:39:52 +0000 (12:39 +0000)
src/libcaptive/include/reactos/compat.h
src/libcaptive/rtl/Makefile.am
src/libcaptive/rtl/memcpy.c [new file with mode: 0644]
src/libcaptive/rtl/memmove.c [new file with mode: 0644]
src/libcaptive/rtl/memset.c [new file with mode: 0644]
src/libcaptive/rtl/string.c [new file with mode: 0644]

index 6a157d0..bc76d04 100644 (file)
 #undef CDECL
 #endif
 
+/* Get the system declarations as their original names.
+ * reactos will use the redefined ones below.
+ * If we would include <string.h> later the system declarations would have captive_reactos_*
+ * names and system vs. reactos declarations would conflict again - just named captive_reactos_*.
+ * FIXME: Unfortunately we cannot include <string.h> twice.
+ * If we do "reactos/*.h" include from libcaptive (not reactos)
+ * we already lost the possibility to use the optimized
+ * system macros as they are #define-d and we #undef them here.
+ * Fortunately there should also be a system declarations with the same
+ * name and we are satisfied with their non-inlined (=non-#define-d) versions.
+ */
+#include <string.h>
+
 #ifdef REACTOS_COMPAT
 #define wcscpy captive_reactos_wcscpy
 #else
 #undef _wcsicmp
 #endif
 
+#ifdef REACTOS_COMPAT
+#undef memchr
+#define memchr captive_reactos_memchr
+#else
+#undef memchr
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef memcpy
+#define memcpy captive_reactos_memcpy
+#else
+#undef memcpy
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef memmove
+#define memmove captive_reactos_memmove
+#else
+#undef memmove
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef memset
+#define memset captive_reactos_memset
+#else
+#undef memset
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strcat
+#define strcat captive_reactos_strcat
+#else
+#undef strcat
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strchr
+#define strchr captive_reactos_strchr
+#else
+#undef strchr
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strcmp
+#define strcmp captive_reactos_strcmp
+#else
+#undef strcmp
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strcpy
+#define strcpy captive_reactos_strcpy
+#else
+#undef strcpy
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strlen
+#define strlen captive_reactos_strlen
+#else
+#undef strlen
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strncat
+#define strncat captive_reactos_strncat
+#else
+#undef strncat
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strncmp
+#define strncmp captive_reactos_strncmp
+#else
+#undef strncmp
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strncpy
+#define strncpy captive_reactos_strncpy
+#else
+#undef strncpy
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strrchr
+#define strrchr captive_reactos_strrchr
+#else
+#undef strrchr
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strspn
+#define strspn captive_reactos_strspn
+#else
+#undef strspn
+#endif
+
+#ifdef REACTOS_COMPAT
+#undef strstr
+#define strstr captive_reactos_strstr
+#else
+#undef strstr
+#endif
+
 /* int iswdigit(wint_t wc); should be safe */
 /* int iswlower(wint_t wc); should be safe */
 /* int iswxdigit(wint_t wc); should be safe */
index ae50e29..2e385f0 100644 (file)
@@ -24,5 +24,9 @@ librtl_la_SOURCES= \
                error.c \
                file.c \
                generictable.c \
+               memcpy.c \
+               memmove.c \
+               memset.c \
+               string.c \
                unicode.c \
                unicode_reactos.c
diff --git a/src/libcaptive/rtl/memcpy.c b/src/libcaptive/rtl/memcpy.c
new file mode 100644 (file)
index 0000000..c7ca67f
--- /dev/null
@@ -0,0 +1,51 @@
+/* $Id$
+ * captive_reactos_memcpy() for reactos wrapper of libcaptive
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include "reactos/ddk/rtl.h"   /* self */
+#include <glib/gmessages.h>
+#include <string.h>
+
+
+/**
+ * captive_reactos_memcpy:
+ * @to: Target memory area.
+ * %NULL value is forbidden.
+ * @from: Source memory area.
+ * %NULL value is forbidden.
+ * @count: Length of the area.
+ * Value %0 is permitted (NOP in such case).
+ *
+ * Simple wrapper around system memcpy() to prevent possible declaration conflicts.
+ *
+ * Returns: The same pointer @to as received.
+ */
+void *captive_reactos_memcpy(void *to,const void *from, size_t count)
+{
+void *r;
+
+       g_return_val_if_fail(to!=NULL,NULL);
+       g_return_val_if_fail(from!=NULL,NULL);
+
+       r=memcpy(to,from,count);
+       g_assert(r==to);
+
+       return r;
+}
diff --git a/src/libcaptive/rtl/memmove.c b/src/libcaptive/rtl/memmove.c
new file mode 100644 (file)
index 0000000..f16a0f2
--- /dev/null
@@ -0,0 +1,51 @@
+/* $Id$
+ * captive_reactos_memmove() for reactos wrapper of libcaptive
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include "reactos/ddk/rtl.h"   /* self */
+#include <glib/gmessages.h>
+#include <string.h>
+
+
+/**
+ * captive_reactos_memmove:
+ * @dest: Target memory area.
+ * %NULL value is forbidden.
+ * @src: Source memory area.
+ * %NULL value is forbidden.
+ * @count: Length of the area.
+ * Value %0 is permitted (NOP in such case).
+ *
+ * Simple wrapper around system memmove() to prevent possible declaration conflicts.
+ *
+ * Returns: The same pointer @dest as received.
+ */
+void *captive_reactos_memmove(void *dest,const void *src, size_t count)
+{
+void *r;
+
+       g_return_val_if_fail(dest!=NULL,NULL);
+       g_return_val_if_fail(src!=NULL,NULL);
+
+       r=memmove(dest,src,count);
+       g_assert(r==dest);
+
+       return r;
+}
diff --git a/src/libcaptive/rtl/memset.c b/src/libcaptive/rtl/memset.c
new file mode 100644 (file)
index 0000000..cd64322
--- /dev/null
@@ -0,0 +1,49 @@
+/* $Id$
+ * captive_reactos_memset() for reactos wrapper of libcaptive
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include "reactos/ddk/rtl.h"   /* self */
+#include <glib/gmessages.h>
+#include <string.h>
+
+
+/**
+ * captive_reactos_memset:
+ * @src: Memory area to fill.
+ * %NULL value is forbidden.
+ * @val: #guint8 byte value to fill the area by.
+ * @count: Length of the area.
+ * Value %0 is permitted (NOP in such case).
+ *
+ * Simple wrapper around system memset() to prevent possible declaration conflicts.
+ *
+ * Returns: The same pointer @src as received.
+ */
+void *captive_reactos_memset(void *src, int val, size_t count)
+{
+void *r;
+
+       g_return_val_if_fail(src!=NULL,NULL);
+
+       r=memset(src,val,count);
+       g_assert(r==src);
+
+       return r;
+}
diff --git a/src/libcaptive/rtl/string.c b/src/libcaptive/rtl/string.c
new file mode 100644 (file)
index 0000000..dff6cb2
--- /dev/null
@@ -0,0 +1,106 @@
+/* $Id$
+ * captive_reactos_str*() for reactos wrappers of libcaptive
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include "reactos/ddk/rtl.h"   /* self */
+#include <glib/gmessages.h>
+#include <string.h>
+
+
+/**
+ * captive_reactos_strchr:
+ * @s: 0-terminated string to search @c in.
+ * %NULL value is forbidden.
+ * @c: #guint8 byte to search for in @s.
+ *
+ * Simple wrapper around system strchr() to prevent possible declaration conflicts.
+ *
+ * Returns: Pointer to the found @c in @s or %NULL if not found.
+ */
+char *captive_reactos_strchr(const char *s, int c)
+{
+       g_return_val_if_fail(s!=NULL,NULL);
+
+       return strchr(s,c);
+}
+
+
+/**
+ * captive_reactos_strcmp:
+ * @s1: 0-terminated first string to compare.
+ * %NULL value is forbidden.
+ * @s2: 0-terminated second string to compare.
+ * %NULL value is forbidden.
+ *
+ * Simple wrapper around system strcmp() to prevent possible declaration conflicts.
+ *
+ * Returns: integer less than, equal to, or greater than zero if @s1 (or the
+ * first n bytes thereof) is found, respectively, to be less than, to match, or
+ * be greater than @s2.
+ */
+int captive_reactos_strcmp(const char *s1, const char *s2)
+{
+       g_return_val_if_fail(s1!=NULL,0);
+       g_return_val_if_fail(s2!=NULL,0);
+
+       return strcmp(s1,s2);
+}
+
+
+/**
+ * captive_reactos_strcpy:
+ * @to: Target memory to copy @from to.
+ * %NULL value is forbidden.
+ * @s2: 0-terminated string to copy to @to.
+ * %NULL value is forbidden.
+ *
+ * Simple wrapper around system strcpy() to prevent possible declaration conflicts.
+ *
+ * Returns: The same pointer @to as received.
+ */
+char *captive_reactos_strcpy(char *to, const char *from)
+{
+char *r;
+
+       g_return_val_if_fail(to!=NULL,NULL);
+       g_return_val_if_fail(from!=NULL,NULL);
+
+       r=strcpy(to,from);
+       g_assert(r==to);
+
+       return r;
+}
+
+
+/**
+ * captive_reactos_strlen:
+ * @str: 0-terminated string to measure its length.
+ * %NULL value is forbidden.
+ *
+ * Simple wrapper around system strlen() to prevent possible declaration conflicts.
+ *
+ * Returns: Number of characters in @str.
+ */
+size_t captive_reactos_strlen(const char *str)
+{
+       g_return_val_if_fail(str!=NULL,0);
+
+       return strlen(str);
+}