[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9567 - GNUnet/src/util/boot
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9567 - GNUnet/src/util/boot |
Date: |
Mon, 16 Nov 2009 11:53:52 -0700 |
Author: grothoff
Date: 2009-11-16 11:53:52 -0700 (Mon, 16 Nov 2009)
New Revision: 9567
Added:
GNUnet/src/util/boot/lib_mempcpy.c
GNUnet/src/util/boot/lib_strndup.c
GNUnet/src/util/boot/lib_strnlen.c
Modified:
GNUnet/src/util/boot/Makefile.am
GNUnet/src/util/boot/lib_argz.c
GNUnet/src/util/boot/startup.c
Log:
adding missing functions:
Modified: GNUnet/src/util/boot/Makefile.am
===================================================================
--- GNUnet/src/util/boot/Makefile.am 2009-11-16 14:55:04 UTC (rev 9566)
+++ GNUnet/src/util/boot/Makefile.am 2009-11-16 18:53:52 UTC (rev 9567)
@@ -12,5 +12,5 @@
libboot_la_SOURCES = \
startup.c
-EXTRA_DIST = lib_argz.c
+EXTRA_DIST = lib_argz.c lib_mempcpy.c lib_strnlen.c lib_strndup.c
Modified: GNUnet/src/util/boot/lib_argz.c
===================================================================
--- GNUnet/src/util/boot/lib_argz.c 2009-11-16 14:55:04 UTC (rev 9566)
+++ GNUnet/src/util/boot/lib_argz.c 2009-11-16 18:53:52 UTC (rev 9567)
@@ -16,9 +16,6 @@
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-#include <config.h>
-
-#include <argz.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@@ -297,7 +294,7 @@
/* Append BUF, of length BUF_LEN to *TO, of length *TO_LEN, reallocating and
updating *TO & *TO_LEN appropriately. If an allocation error occurs,
*TO's old value is freed, and *TO is set to 0. */
-void
+static void
str_append (char **to, size_t *to_len, const char *buf, const size_t buf_len)
{
size_t new_len = *to_len + buf_len;
Added: GNUnet/src/util/boot/lib_mempcpy.c
===================================================================
--- GNUnet/src/util/boot/lib_mempcpy.c (rev 0)
+++ GNUnet/src/util/boot/lib_mempcpy.c 2009-11-16 18:53:52 UTC (rev 9567)
@@ -0,0 +1,27 @@
+/* Copy memory area and return pointer after last written byte.
+ Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+
+ 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, 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. */
+
+/* Specification. */
+#include <string.h>
+
+/* Copy N bytes of SRC to DEST, return pointer to bytes after the
+ last written byte. */
+void *
+mempcpy (void *dest, const void *src, size_t n)
+{
+ return (char *) memcpy (dest, src, n) + n;
+}
Added: GNUnet/src/util/boot/lib_strndup.c
===================================================================
--- GNUnet/src/util/boot/lib_strndup.c (rev 0)
+++ GNUnet/src/util/boot/lib_strndup.c 2009-11-16 18:53:52 UTC (rev 9567)
@@ -0,0 +1,35 @@
+/* A replacement function, for systems that lack strndup.
+
+ Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006, 2007
+ Free Software Foundation, Inc.
+
+ 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, 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. */
+
+#include <string.h>
+
+#include <stdlib.h>
+
+char *
+strndup (char const *s, size_t n)
+{
+ size_t len = strnlen (s, n);
+ char *new = malloc (len + 1);
+
+ if (new == NULL)
+ return NULL;
+
+ new[len] = '\0';
+ return memcpy (new, s, len);
+}
Added: GNUnet/src/util/boot/lib_strnlen.c
===================================================================
--- GNUnet/src/util/boot/lib_strnlen.c (rev 0)
+++ GNUnet/src/util/boot/lib_strnlen.c 2009-11-16 18:53:52 UTC (rev 9567)
@@ -0,0 +1,29 @@
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+ Written by Simon Josefsson.
+
+ 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, 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. */
+
+#include <string.h>
+
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ If no '\0' terminator is found in that many characters, return MAXLEN. */
+
+size_t
+strnlen (const char *string, size_t maxlen)
+{
+ const char *end = memchr (string, '\0', maxlen);
+ return end ? (size_t) (end - string) : maxlen;
+}
Modified: GNUnet/src/util/boot/startup.c
===================================================================
--- GNUnet/src/util/boot/startup.c 2009-11-16 14:55:04 UTC (rev 9566)
+++ GNUnet/src/util/boot/startup.c 2009-11-16 18:53:52 UTC (rev 9567)
@@ -186,6 +186,9 @@
#if HAVE_ARGZ_H
#include <argz.h>
#else
+#include "lib_strnlen.c"
+#include "lib_strndup.c"
+#include "lib_mempcpy.c"
#include "lib_argz.c"
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9567 - GNUnet/src/util/boot,
gnunet <=