[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9561 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9561 - gnunet/src/util |
Date: |
Mon, 16 Nov 2009 07:10:10 -0700 |
Author: grothoff
Date: 2009-11-16 07:10:10 -0700 (Mon, 16 Nov 2009)
New Revision: 9561
Added:
gnunet/src/util/program_lib_mempcpy.c
gnunet/src/util/program_lib_strndup.c
gnunet/src/util/program_lib_strnlen.c
Modified:
gnunet/src/util/Makefile.am
gnunet/src/util/program.c
Log:
more
Modified: gnunet/src/util/Makefile.am
===================================================================
--- gnunet/src/util/Makefile.am 2009-11-16 14:03:01 UTC (rev 9560)
+++ gnunet/src/util/Makefile.am 2009-11-16 14:10:10 UTC (rev 9561)
@@ -363,6 +363,9 @@
EXTRA_DIST = \
program_lib_argz.c \
+ program_lib_strndup.c \
+ program_lib_strnlen.c \
+ program_lib_mempcpy.c \
test_configuration_data.conf \
test_container_meta_data_image.jpg \
test_program_data.conf \
Modified: gnunet/src/util/program.c
===================================================================
--- gnunet/src/util/program.c 2009-11-16 14:03:01 UTC (rev 9560)
+++ gnunet/src/util/program.c 2009-11-16 14:10:10 UTC (rev 9561)
@@ -38,6 +38,9 @@
#if HAVE_ARGZ_H
#include <argz.h>
#else
+#include "program_lib_strndup.c"
+#include "program_lib_strnlen.c"
+#include "program_lib_mempcpy.c"
#include "program_lib_argz.c"
#endif
Added: gnunet/src/util/program_lib_mempcpy.c
===================================================================
--- gnunet/src/util/program_lib_mempcpy.c (rev 0)
+++ gnunet/src/util/program_lib_mempcpy.c 2009-11-16 14:10:10 UTC (rev
9561)
@@ -0,0 +1,29 @@
+/* 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. */
+
+#include <config.h>
+
+/* 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/program_lib_strndup.c
===================================================================
--- gnunet/src/util/program_lib_strndup.c (rev 0)
+++ gnunet/src/util/program_lib_strndup.c 2009-11-16 14:10:10 UTC (rev
9561)
@@ -0,0 +1,37 @@
+/* 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 <config.h>
+
+#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/program_lib_strnlen.c
===================================================================
--- gnunet/src/util/program_lib_strnlen.c (rev 0)
+++ gnunet/src/util/program_lib_strnlen.c 2009-11-16 14:10:10 UTC (rev
9561)
@@ -0,0 +1,31 @@
+/* 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 <config.h>
+
+#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;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9561 - gnunet/src/util,
gnunet <=