# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close error fdl gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile progname readline select setsockopt shutdown socket version-etc-fsf
+# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close error fdl gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile minmax progname read-file readline select setsockopt shutdown socket version-etc-fsf
AUTOMAKE_OPTIONS = 1.5 gnits
## end gnulib module maintainer-makefile
+## begin gnulib module minmax
+
+libgnu_la_SOURCES += minmax.h
+
+## end gnulib module minmax
+
## begin gnulib module netdb
BUILT_SOURCES += $(NETDB_H)
## end gnulib module progname
+## begin gnulib module read-file
+
+
+EXTRA_DIST += read-file.c read-file.h
+
+EXTRA_libgnu_la_SOURCES += read-file.c
+
+## end gnulib module read-file
+
## begin gnulib module readline
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close error fdl gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile progname readline select setsockopt shutdown socket version-etc-fsf
+# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close error fdl gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile minmax progname read-file readline select setsockopt shutdown socket version-etc-fsf
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([gl/override])
lgpl-2.1
listen
maintainer-makefile
+ minmax
progname
+ read-file
readline
select
setsockopt
gl_SYS_SOCKET_MODULE_INDICATOR([listen])
gl_FUNC_LSEEK
gl_UNISTD_MODULE_INDICATOR([lseek])
+ gl_MINMAX
gl_HEADER_NETDB
gl_HEADER_NETINET_IN
AC_PROG_MKDIR_P
+ gl_FUNC_READ_FILE
gl_FUNC_READLINE
gl_FUNC_REALLOC_POSIX
gl_STDLIB_MODULE_INDICATOR([realloc-posix])
lib/intprops.h
lib/listen.c
lib/lseek.c
+ lib/minmax.h
lib/netdb.in.h
lib/netinet_in.in.h
lib/printf-args.c
lib/printf-parse.h
lib/progname.c
lib/progname.h
+ lib/read-file.c
+ lib/read-file.h
lib/readline.c
lib/readline.h
lib/realloc.c
m4/longlong.m4
m4/lseek.m4
m4/malloc.m4
+ m4/minmax.m4
m4/netdb_h.m4
m4/netinet_in_h.m4
m4/perror.m4
m4/printf.m4
+ m4/read-file.m4
m4/readline.m4
m4/realloc.m4
m4/size_max.m4
tests/test-netinet_in.c
tests/test-perror.c
tests/test-perror.sh
+ tests/test-read-file.c
tests/test-select.c
tests/test-snprintf.c
tests/test-sockets.c
--- /dev/null
+# minmax.m4 serial 2
+dnl Copyright (C) 2005 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_PREREQ(2.52)
+
+AC_DEFUN([gl_MINMAX],
+[
+ AC_REQUIRE([gl_PREREQ_MINMAX])
+])
+
+# Prerequisites of lib/minmax.h.
+AC_DEFUN([gl_PREREQ_MINMAX],
+[
+ gl_MINMAX_IN_HEADER([limits.h])
+ gl_MINMAX_IN_HEADER([sys/param.h])
+])
+
+dnl gl_MINMAX_IN_HEADER(HEADER)
+dnl The parameter has to be a literal header name; it cannot be macro,
+dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
+dnl invocations with a literal macro name.)
+AC_DEFUN([gl_MINMAX_IN_HEADER],
+[
+ m4_pushdef([header], AS_TR_SH([$1]))
+ m4_pushdef([HEADER], AS_TR_CPP([$1]))
+ AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
+ [gl_cv_minmax_in_]header,
+ [AC_TRY_COMPILE([#include <$1>
+int x = MIN (42, 17);], [],
+ [gl_cv_minmax_in_]header[=yes],
+ [gl_cv_minmax_in_]header[=no])])
+ if test $gl_cv_minmax_in_[]header = yes; then
+ AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
+ [Define to 1 if <$1> defines the MIN and MAX macros.])
+ fi
+ m4_popdef([HEADER])
+ m4_popdef([header])
+])
--- /dev/null
+# read-file.m4 serial 2
+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_LIBOBJ([read-file])
+ gl_PREREQ_READ_FILE
+])
+
+# Prerequisites of lib/read-file.c.
+AC_DEFUN([gl_PREREQ_READ_FILE], [:])
--- /dev/null
+/* MIN, MAX macros.
+ Copyright (C) 1995, 1998, 2001, 2003, 2005 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 3, 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. */
+
+#ifndef _MINMAX_H
+#define _MINMAX_H
+
+/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
+ (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
+ MIN, MAX macro redefinitions on some systems; the workaround is to
+ #include this file as the last one among the #include list. */
+
+/* Before we define the following symbols we get the <limits.h> file
+ since otherwise we get redefinitions on some systems if <limits.h> is
+ included after this file. Likewise for <sys/param.h>.
+ If more than one of these system headers define MIN and MAX, pick just
+ one of the headers (because the definitions most likely are the same). */
+#if HAVE_MINMAX_IN_LIMITS_H
+# include <limits.h>
+#elif HAVE_MINMAX_IN_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+/* Note: MIN and MAX should be used with two arguments of the
+ same type. They might not return the minimum and maximum of their two
+ arguments, if the arguments have different types or have unusual
+ floating-point values. For example, on a typical host with 32-bit 'int',
+ 64-bit 'long long', and 64-bit IEEE 754 'double' types:
+
+ MAX (-1, 2147483648) returns 4294967295.
+ MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
+ MAX (NaN, 0.0) returns 0.0.
+ MAX (+0.0, -0.0) returns -0.0.
+
+ and in each case the answer is in some sense bogus. */
+
+/* MAX(a,b) returns the maximum of A and B. */
+#ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+/* MIN(a,b) returns the minimum of A and B. */
+#ifndef MIN
+# define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#endif /* _MINMAX_H */
--- /dev/null
+/* 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 General Public License as published by
+ the Free Software Foundation; either version 3, 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 "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;
+ int save_errno;
+
+ for (;;)
+ {
+ size_t count;
+ size_t requested;
+
+ 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)
+ {
+ save_errno = errno;
+ break;
+ }
+
+ buf = new_buf;
+ }
+
+ requested = alloc - size - 1;
+ count = fread (buf + size, 1, requested, stream);
+ size += count;
+
+ if (count != requested)
+ {
+ save_errno = errno;
+ if (ferror (stream))
+ break;
+ buf[size] = '\0';
+ *length = size;
+ return buf;
+ }
+ }
+
+ free (buf);
+ errno = save_errno;
+ return NULL;
+}
+
+static char *
+internal_read_file (const char *filename, size_t * length, const char *mode)
+{
+ FILE *stream = fopen (filename, mode);
+ char *out;
+ int save_errno;
+
+ if (!stream)
+ return NULL;
+
+ out = fread_file (stream, length);
+
+ save_errno = errno;
+
+ if (fclose (stream) != 0)
+ {
+ if (out)
+ {
+ 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");
+}
--- /dev/null
+/* 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 General Public License as published by
+ the Free Software Foundation; either version 3, 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. */
+
+#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 */
## end gnulib module perror-tests
+## begin gnulib module read-file-tests
+
+TESTS += test-read-file
+check_PROGRAMS += test-read-file
+EXTRA_DIST += test-read-file.c
+
+## end gnulib module read-file-tests
+
## begin gnulib module select-tests
TESTS += test-select
--- /dev/null
+/*
+ * Copyright (C) 2006-2007 Free Software Foundation
+ * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "read-file.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+#define FILE1 "/etc/resolv.conf"
+#define FILE2 "/dev/null"
+
+int
+main (void)
+{
+ struct stat statbuf;
+ int err = 0;
+
+ /* We can perform the test only if the file exists and is readable.
+ Test whether it exists, then assume it is world-readable. */
+ if (stat (FILE1, &statbuf) >= 0)
+ {
+ size_t len;
+ char *out = read_file (FILE1, &len);
+
+ if (!out)
+ {
+ perror ("Could not read file");
+ err = 1;
+ }
+ else
+ {
+ if (out[len] != '\0')
+ {
+ perror ("BAD: out[len] not zero");
+ err = 1;
+ }
+
+ /* Assume FILE1 is a regular file or a symlink to a regular file. */
+ if (len != statbuf.st_size)
+ {
+ fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE1);
+ err = 1;
+ }
+ free (out);
+ }
+ }
+
+ /* We can perform the test only if the file exists and is readable.
+ Test whether it exists, then assume it is world-readable. */
+ if (stat (FILE2, &statbuf) >= 0)
+ {
+ size_t len;
+ char *out = read_file (FILE2, &len);
+
+ if (!out)
+ {
+ perror ("Could not read file");
+ err = 1;
+ }
+ else
+ {
+ if (out[len] != '\0')
+ {
+ perror ("BAD: out[len] not zero");
+ err = 1;
+ }
+
+ /* /dev/null should always be empty. Ignore statbuf.st_size, since it
+ is not a regular file. */
+ if (len != 0)
+ {
+ fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE2);
+ err = 1;
+ }
+ free (out);
+ }
+ }
+
+ return err;
+}
SUBDIRS = cfg
AM_CPPFLAGS = \
- -I$(srcdir)/../lib/gl \
- -I$(builddir)/../lib/gl \
-I$(srcdir)/../gl \
-I$(builddir)/../gl \
-I$(builddir)/../lib/includes \
endif
gnutls_serv_SOURCES = serv.gaa serv-gaa.h serv-gaa.c list.h serv.c \
- common.h common.c select.c certtool-common.h
+ common.h common.c certtool-common.h
gnutls_serv_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la \
../gl/libgnu.la
psktool_LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lib/gl/liblgnu.la
gnutls_cli_SOURCES = cli.gaa cli-gaa.h cli-gaa.c cli.c common.h \
- common.c select.c
+ common.c
gnutls_cli_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la \
../gl/libgnu.la
#include "common.h"
#include "cli-gaa.h"
-#if defined _WIN32 || defined __WIN32__
-int _win_select (int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
- const struct timeval *tv);
-#define select _win_select
-#endif
-
#define SA struct sockaddr
#define ERR(err,s) do { if (err==-1) {perror(s);return(1);} } while (0)
#define MAX_BUF 4096
#include <gnutls/extra.h>
#include <gnutls/openpgp.h>
#include <sys/time.h>
+#include <sys/select.h>
#include <fcntl.h>
#include <list.h>
#include <netdb.h>
+#include <error.h>
-#if defined _WIN32 || defined __WIN32__
-int _win_select (int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
- const struct timeval *tv);
-#define select _win_select
-#endif
-
-#include "error.h"
#include "progname.h"
#include "version-etc.h"
#include "read-file.h"