]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Update.
authorSimon Josefsson <simon@josefsson.org>
Mon, 12 Jun 2006 15:39:09 +0000 (15:39 +0000)
committerSimon Josefsson <simon@josefsson.org>
Mon, 12 Jun 2006 15:39:09 +0000 (15:39 +0000)
gl/Makefile.am
gl/gc-gnulib.c
gl/m4/gnulib-cache.m4
gl/m4/gnulib-comp.m4
gl/m4/read-file.m4 [new file with mode: 0644]
gl/read-file.c [new file with mode: 0644]
gl/read-file.h [new file with mode: 0644]

index bc4979889064e13260886c4abe12bede1663d405..f37e27fa9047953dda82569f977ad83fd4ca3d0e 100644 (file)
@@ -8,7 +8,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --lgpl --libtool --macro-prefix=gl gc gc-arcfour gc-arctwo gc-des gc-hmac-md5 gc-md2 gc-md4 gc-md5 gc-pbkdf2-sha1 gc-random gc-rijndael gc-sha1 getaddrinfo getline getpass gettext inet_ntop maintainer-makefile memmem memmove minmax readline snprintf socklen stdint
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --lgpl --libtool --macro-prefix=gl gc gc-arcfour gc-arctwo gc-des gc-hmac-md5 gc-md2 gc-md4 gc-md5 gc-pbkdf2-sha1 gc-random gc-rijndael gc-sha1 getaddrinfo getline getpass gettext inet_ntop maintainer-makefile memmem memmove minmax read-file readline snprintf socklen stdint
 
 AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
 
index ca0ee95299861f930537180d16d19a78e7a8a17f..4829730d45c1b79ddbf531fa9108637593a0f203 100644 (file)
@@ -858,9 +858,3 @@ gc_hmac_sha1 (const void *key, size_t keylen,
   return GC_OK;
 }
 #endif
-
-void
-gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, const char *key)
-{
-  return;
-}
index 9f1876452cd2a0ee0d99463c3e741518ce32f166..de62ba2b3ac55d7298de1ce0e59e11bcda0a3235 100644 (file)
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --lgpl --libtool --macro-prefix=gl gc gc-arcfour gc-arctwo gc-des gc-hmac-md5 gc-md2 gc-md4 gc-md5 gc-pbkdf2-sha1 gc-random gc-rijndael gc-sha1 getaddrinfo getline getpass gettext inet_ntop maintainer-makefile memmem memmove minmax readline snprintf socklen stdint
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --lgpl --libtool --macro-prefix=gl gc gc-arcfour gc-arctwo gc-des gc-hmac-md5 gc-md2 gc-md4 gc-md5 gc-pbkdf2-sha1 gc-random gc-rijndael gc-sha1 getaddrinfo getline getpass gettext inet_ntop maintainer-makefile memmem memmove minmax read-file readline snprintf socklen stdint
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
-gl_MODULES([gc gc-arcfour gc-arctwo gc-des gc-hmac-md5 gc-md2 gc-md4 gc-md5 gc-pbkdf2-sha1 gc-random gc-rijndael gc-sha1 getaddrinfo getline getpass gettext inet_ntop maintainer-makefile memmem memmove minmax readline snprintf socklen stdint])
+gl_MODULES([gc gc-arcfour gc-arctwo gc-des gc-hmac-md5 gc-md2 gc-md4 gc-md5 gc-pbkdf2-sha1 gc-random gc-rijndael gc-sha1 getaddrinfo getline getpass gettext inet_ntop maintainer-makefile memmem memmove minmax read-file readline snprintf socklen stdint])
 gl_AVOID([])
 gl_SOURCE_BASE([gl])
 gl_M4_BASE([gl/m4])
index f39eb2c1f781faf3956627b78a9a463733072a1b..062e59426ca3598c83dd430bfb568bcc166d4353 100644 (file)
@@ -53,6 +53,7 @@ AC_DEFUN([gl_INIT],
   gl_FUNC_MEMMEM
   gl_FUNC_MEMMOVE
   gl_MINMAX
+  gl_FUNC_READ_FILE
   gl_FUNC_READLINE
   gl_C_RESTRICT
   gl_SIZE_MAX
@@ -116,6 +117,8 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/printf-args.h
   lib/printf-parse.c
   lib/printf-parse.h
+  lib/read-file.c
+  lib/read-file.h
   lib/readline.c
   lib/readline.h
   lib/rijndael-alg-fst.c
@@ -190,6 +193,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/po.m4
   m4/printf-posix.m4
   m4/progtest.m4
+  m4/read-file.m4
   m4/readline.m4
   m4/restrict.m4
   m4/rijndael.m4
diff --git a/gl/m4/read-file.m4 b/gl/m4/read-file.m4
new file mode 100644 (file)
index 0000000..15bcad9
--- /dev/null
@@ -0,0 +1,15 @@
+# read-file.m4 serial 1
+dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_READ_FILE],
+[
+  AC_LIBSOURCES([read-file.c, read-file.h])
+  AC_LIBOBJ([read-file])
+  gl_PREREQ_READ_FILE
+])
+
+# Prerequisites of lib/read-file.c.
+AC_DEFUN([gl_PREREQ_READ_FILE], [:])
diff --git a/gl/read-file.c b/gl/read-file.c
new file mode 100644 (file)
index 0000000..12b2f17
--- /dev/null
@@ -0,0 +1,143 @@
+/* read-file.c -- read file contents into a string
+   Copyright (C) 2006 Free Software Foundation, Inc.
+   Written by Simon Josefsson and Bruno Haible.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser 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.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "read-file.h"
+
+/* Get realloc, free. */
+#include <stdlib.h>
+
+/* Get errno. */
+#include <errno.h>
+
+/* Read a STREAM and return a newly allocated string with the content,
+   and set *LENGTH to the length of the string.  The string is
+   zero-terminated, but the terminating zero byte is not counted in
+   *LENGTH.  On errors, *LENGTH is undefined, errno preserves the
+   values set by system functions (if any), and NULL is returned. */
+char *
+fread_file (FILE * stream, size_t * length)
+{
+  char *buf = NULL;
+  size_t alloc = 0;
+  size_t size = 0;
+
+  while (!feof (stream))
+    {
+      size_t count;
+
+      if (size + BUFSIZ + 1 > alloc)
+       {
+         char *new_buf;
+
+         alloc += alloc / 2;
+         if (alloc < size + BUFSIZ + 1)
+           alloc = size + BUFSIZ + 1;
+
+         new_buf = realloc (buf, alloc);
+         if (!new_buf)
+           {
+             int save_errno = errno;
+             free (buf);
+             errno = save_errno;
+             return NULL;
+           }
+
+         buf = new_buf;
+       }
+
+      count = fread (buf + size, 1, alloc - size - 1, stream);
+      size += count;
+
+      if (ferror (stream))
+       {
+         int save_errno = errno;
+         free (buf);
+         errno = save_errno;
+         return NULL;
+       }
+    }
+
+  if (buf)
+    buf[size] = '\0';
+
+  *length = size;
+
+  return buf;
+}
+
+static char *
+internal_read_file (const char *filename, size_t * length, const char *mode)
+{
+  FILE *stream = fopen (filename, mode);
+  char *out;
+  int rc;
+
+  if (!stream)
+    return NULL;
+
+  out = fread_file (stream, length);
+
+  if (out)
+    rc = fclose (stream);
+  else
+    {
+      /* On failure, preserve the original errno value. */
+      int save_errno = errno;
+      rc = fclose (stream);
+      errno = save_errno;
+    }
+
+  if (rc != 0)
+    {
+      int save_errno = errno;
+      free (out);
+      errno = save_errno;
+      return NULL;
+    }
+
+  return out;
+}
+
+/* Open and read the contents of FILENAME, and return a newly
+   allocated string with the content, and set *LENGTH to the length of
+   the string.  The string is zero-terminated, but the terminating
+   zero byte is not counted in *LENGTH.  On errors, *LENGTH is
+   undefined, errno preserves the values set by system functions (if
+   any), and NULL is returned.  */
+char *
+read_file (const char *filename, size_t * length)
+{
+  return internal_read_file (filename, length, "r");
+}
+
+/* Open (on non-POSIX systems, in binary mode) and read the contents
+   of FILENAME, and return a newly allocated string with the content,
+   and set LENGTH to the length of the string.  The string is
+   zero-terminated, but the terminating zero byte is not counted in
+   the LENGTH variable.  On errors, *LENGTH is undefined, errno
+   preserves the values set by system functions (if any), and NULL is
+   returned.  */
+char *
+read_binary_file (const char *filename, size_t * length)
+{
+  return internal_read_file (filename, length, "rb");
+}
diff --git a/gl/read-file.h b/gl/read-file.h
new file mode 100644 (file)
index 0000000..798d841
--- /dev/null
@@ -0,0 +1,34 @@
+/* read-file.h -- read file contents into a string
+   Copyright (C) 2006 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser 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.  */
+
+#ifndef READ_FILE_H
+#define READ_FILE_H
+
+/* Get size_t.  */
+#include <stddef.h>
+
+/* Get FILE.  */
+#include <stdio.h>
+
+extern char *fread_file (FILE * stream, size_t * length);
+
+extern char *read_file (const char *filename, size_t * length);
+
+extern char *read_binary_file (const char *filename, size_t * length);
+
+#endif /* READ_FILE_H */