aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/ChangeLog10
-rw-r--r--common/Makefile.am16
-rw-r--r--common/fseeko.c41
-rw-r--r--common/ftello.c46
-rw-r--r--common/mkdtemp.c97
-rw-r--r--common/putc_unlocked.c31
-rw-r--r--common/strsep.c76
-rw-r--r--common/ttyname.c32
-rw-r--r--common/util.h40
-rw-r--r--common/xasprintf.c2
10 files changed, 38 insertions, 353 deletions
diff --git a/common/ChangeLog b/common/ChangeLog
index abb3c6427..fccc71d49 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,13 @@
+2005-06-01 Werner Koch <[email protected]>
+
+ * Makefile.am (AM_CPPFLAGS): Added.
+
+ * util.h: Add some includes for gnulib.
+ (ttyname, isascii): Define them inline.
+ * fseeko.c, ftello.c: Removed.
+ * strsep.c, mkdtemp.c: Removed.
+ * ttyname.c, isascii.c: Removed.
+
2005-05-31 Werner Koch <[email protected]>
* dynload.h: s/__inline__/inline/.
diff --git a/common/Makefile.am b/common/Makefile.am
index a039be184..0f9b4324d 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -21,7 +21,9 @@
noinst_LIBRARIES = libcommon.a libsimple-pwquery.a
-AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS) $(PTH_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/gl
+
+AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS) $(PTH_CFLAGS)
libcommon_a_SOURCES = \
util.h i18n.h \
@@ -49,18 +51,6 @@ libcommon_a_SOURCES = \
estream.c estream.h
-libcommon_a_LIBADD = @LIBOBJS@
-
libsimple_pwquery_a_SOURCES = \
simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h
-libsimple_pwquery_a_LIBADD = @LIBOBJS@
-
-
-
-
-
-
-
-
-
diff --git a/common/fseeko.c b/common/fseeko.c
deleted file mode 100644
index 06838e4c4..000000000
--- a/common/fseeko.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* fseeko.c - libc replacement function
- * Copyright (C) 2001 Free Software Foundation, Inc.
- *
- * This file is part of GnuPG.
- *
- * GnuPG 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 of the License, or
- * (at your option) any later version.
- *
- * GnuPG 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
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <sys/types.h> /* Defines off_t under W32. */
-
-int
-fseeko (FILE *stream, off_t off, int whence)
-{
- return fseek (stream, off, whence);
-}
-
-
-
-
-
-
-
-
-
-
diff --git a/common/ftello.c b/common/ftello.c
deleted file mode 100644
index 6837be959..000000000
--- a/common/ftello.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ftello.c - libc replacement function
- * Copyright (C) 2001 Free Software Foundation, Inc.
- *
- * This file is part of GnuPG.
- *
- * GnuPG 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 of the License, or
- * (at your option) any later version.
- *
- * GnuPG 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
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <sys/types.h> /* Defines off_t under W32. */
-
-off_t
-ftello (FILE *stream)
-{
- long int off;
-
- off = ftell (stream);
- if (off == -1)
- return (off_t)-1;
- return off;
-}
-
-
-
-
-
-
-
-
-
-
diff --git a/common/mkdtemp.c b/common/mkdtemp.c
deleted file mode 100644
index a85b89eb4..000000000
--- a/common/mkdtemp.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* mkdtemp.c - libc replacement function
- * Copyright (C) 2001 Free Software Foundation, Inc.
- *
- * This file is part of GnuPG.
- *
- * GnuPG 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 of the License, or
- * (at your option) any later version.
- *
- * GnuPG 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
- */
-
-/* This is a replacement function for mkdtemp in case the platform
- we're building on (like mine!) doesn't have it. */
-
-#include <config.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <gcrypt.h>
-
-#ifdef MKDIR_TAKES_ONE_ARG
-# undef mkdir
-# define mkdir(a,b) mkdir(a)
-#endif
-
-char *
-mkdtemp (char *template)
-{
- int attempts,idx,count=0;
- unsigned char *ch;
-
- idx=strlen(template);
-
- /* Walk backwards to count all the Xes */
- while(idx>0 && template[idx-1]=='X')
- {
- count++;
- idx--;
- }
-
- if(count==0)
- {
- errno=EINVAL;
- return NULL;
- }
-
- ch=&template[idx];
-
- /* Try 4 times to make the temp directory */
- for(attempts=0;attempts<4;attempts++)
- {
- int remaining=count;
- char *marker=ch;
- unsigned char *randombits;
-
- idx=0;
-
- randombits = gcry_xmalloc (4*remaining);
- gcry_create_nonce (randombits, 4*remaining);
-
- while(remaining>1)
- {
- sprintf(marker,"%02X",randombits[idx++]);
- marker+=2;
- remaining-=2;
- }
-
- /* Any leftover Xes? get_random_bits rounds up to full bytes,
- so this is safe. */
- if(remaining>0)
- sprintf(marker,"%X",randombits[idx]&0xF);
-
- gcry_free (randombits);
-
- if(mkdir(template,0700)==0)
- break;
- }
-
- if(attempts==4)
- return NULL; /* keeps the errno from mkdir, whatever it is */
-
- return template;
-}
-
-
diff --git a/common/putc_unlocked.c b/common/putc_unlocked.c
deleted file mode 100644
index 02c646130..000000000
--- a/common/putc_unlocked.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* putc_unlocked.c - Replacement for putc_unlocked.
- * Copyright (C) 2002 Free Software Foundation, Inc.
- *
- * This file is part of GnuPG.
- *
- * GnuPG 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 of the License, or
- * (at your option) any later version.
- *
- * GnuPG 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
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-
-int
-putc_unlocked (int c, FILE *stream)
-{
- return putc (c, stream);
-}
diff --git a/common/strsep.c b/common/strsep.c
deleted file mode 100644
index dd01a826f..000000000
--- a/common/strsep.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* strsep.c - Replacement for strsep().
- * Copyright (C) 1992, 1993, 1996, 1997, 1998, 1999,
- * 2004 Free Software Foundation, Inc.
- *
- * This file is part of the GNU C Library.
- *
- * The GNU C Library 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 of the License, or (at your option) any later version.
- *
- * The GNU C Library 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 the GNU C Library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307 USA.
- */
-
-/* Code taken from glibc-2.3.2/sysdeps/generic/strsep.c and slightly
- modified for use with GnuPG. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <string.h>
-
-char *
-strsep (char **stringp, const char *delim)
-{
- char *begin, *end;
-
- begin = *stringp;
- if (begin == NULL)
- return NULL;
-
- /* A frequent case is when the delimiter string contains only one
- character. Here we don't need to call the expensive `strpbrk'
- function and instead work using `strchr'. */
- if (delim[0] == '\0' || delim[1] == '\0')
- {
- char ch = delim[0];
-
- if (ch == '\0')
- end = NULL;
- else
- {
- if (*begin == ch)
- end = begin;
- else if (*begin == '\0')
- end = NULL;
- else
- end = strchr (begin + 1, ch);
- }
- }
- else
- /* Find the end of the token. */
- end = strpbrk (begin, delim);
-
- if (end)
- {
- /* Terminate the token and set *STRINGP past NUL character. */
- *end++ = '\0';
- *stringp = end;
- }
- else
- /* No more delimiters; this is the last token. */
- *stringp = NULL;
-
- return begin;
-}
-
diff --git a/common/ttyname.c b/common/ttyname.c
deleted file mode 100644
index 822beef99..000000000
--- a/common/ttyname.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ttyname.c - Replacement for ttyname.
- * Copyright (C) 2004 Free Software Foundation, Inc.
- *
- * This file is part of GnuPG.
- *
- * GnuPG 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 of the License, or
- * (at your option) any later version.
- *
- * GnuPG 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
- */
-
-/* This one is a simple dummy and suitable for Dosish systems. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-
-char *
-ttyname (int fd)
-{
- return NULL;
-}
diff --git a/common/util.h b/common/util.h
index 6a9b54ef5..d233dbf5e 100644
--- a/common/util.h
+++ b/common/util.h
@@ -25,7 +25,13 @@
#include <time.h> /* We need time_t. */
#include <gpg-error.h> /* we need gpg-error_t. */
-/* to pass hash functions to libksba we need to cast it */
+/* Common GNUlib includes (-I ../gl/). */
+#include "strpbrk.h"
+#include "strsep.h"
+#include "vasprintf.h"
+
+
+/* Hash function used with libksba. */
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)
/* get all the stuff from jnlib */
@@ -152,24 +158,26 @@ char *make_printable_string (const byte *p, size_t n, int delim);
int is_file_compressed (const char *s, int *ret_rc);
-/*-- replacement functions from funcname.c --*/
-#if !HAVE_VASPRINTF
-#include <stdarg.h>
-int vasprintf (char **result, const char *format, va_list args);
-int asprintf (char **result, const char *format, ...) JNLIB_GCC_A_PRINTF(2,3);
-#endif
-#ifndef HAVE_STRSEP
-char *strsep (char **stringp, const char *delim);
-#endif
+
+/*-- Simple replacement functions. */
#ifndef HAVE_TTYNAME
-char *ttyname (int fd);
-#endif
-#ifndef HAVE_MKDTEMP
-char *mkdtemp (char *template);
-#endif
+/* Systems without ttyname (W32) will merely return NULL. */
+static inline char *
+ttyname (int fd)
+{
+ return NULL
+};
+#endif /* !HAVE_TTYNAME */
+#ifndef HAVE_ISASCII
+static inline int
+isascii (int c)
+{
+ return (((c) & ~0x7f) == 0);
+}
+#endif /* !HAVE_ISASCII */
-/*-- some macros to replace ctype ones and avoid locale problems --*/
+/*-- Macros to replace ctype ones to avoid locale problems. --*/
#define spacep(p) (*(p) == ' ' || *(p) == '\t')
#define digitp(p) (*(p) >= '0' && *(p) <= '9')
#define hexdigitp(a) (digitp (a) \
diff --git a/common/xasprintf.c b/common/xasprintf.c
index a3b5e27ac..46740a2e6 100644
--- a/common/xasprintf.c
+++ b/common/xasprintf.c
@@ -43,7 +43,7 @@ xasprintf (const char *fmt, ...)
return p;
}
-/* Same as above bit return NULL on memory failure. */
+/* Same as above but return NULL on memory failure. */
char *
xtryasprintf (const char *fmt, ...)
{