diff options
author | Alain Magloire <alainm@gnu.org> | 2001-04-16 21:05:51 +0000 |
---|---|---|
committer | Alain Magloire <alainm@gnu.org> | 2001-04-16 21:05:51 +0000 |
commit | c8df06a75ca9559630d761a6745032c22d9beb58 (patch) | |
tree | bb937da99a1c040fb7f6422a82b3eca4cade36ae | |
parent | 9221152b3ac3aef5728923837a4ade51ac78b47c (diff) | |
download | mailutils-c8df06a75ca9559630d761a6745032c22d9beb58.tar.gz mailutils-c8df06a75ca9559630d761a6745032c22d9beb58.tar.bz2 |
To get things to compile on Solaris, change configure to check
for -lpthread since in libc the thread functions are defined
but all return ENOSYS, you need to explicitely link with -lphtread.
the ctype functions is*() arguments should be explicitely cast
since Solaris use them as indexes. __REENTRANT as to be define
if compile with support for threads. Never realize this but
setenv() is a BSD/GNU thing, so took a variant from libiberty
to cope.
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | configure.in | 12 | ||||
-rw-r--r-- | imap4d/imap4d.h | 5 | ||||
-rw-r--r-- | lib/Makefile.am | 4 | ||||
-rw-r--r-- | lib/setenv.c | 156 | ||||
-rw-r--r-- | mail/mail.h | 7 | ||||
-rw-r--r-- | mailbox/attachment.c | 8 | ||||
-rw-r--r-- | mailbox/filter_rfc822.c | 6 | ||||
-rw-r--r-- | mailbox/folder_imap.c | 10 | ||||
-rw-r--r-- | mailbox/mbx_mbox.c | 14 | ||||
-rw-r--r-- | mailbox/mbx_pop.c | 5 | ||||
-rw-r--r-- | mailbox/monitor.c | 3 | ||||
-rw-r--r-- | mailbox/parse822.c | 6 |
13 files changed, 241 insertions, 21 deletions
@@ -1,3 +1,29 @@ +2001-04-16 Alain Magloire + + To get things to compile on Solaris, change configure to check + for -lpthread since in libc the thread functions are defined + but all return ENOSYS, you need to explicitely link with -lphtread. + the ctype functions is*() arguments should be explicitely cast + since Solaris use them as indexes. __REENTRANT as to be define + if compile with support for threads. Never realize this but + setenv() is a BSD/GNU thing, so took a variant from libiberty + to cope. + + * configure.in: Check for setenv. First check if -lphtread is ok. + * lib/setenv.c: New functions. + * lib/Makefile.am: add setenv.c in EXTRA_DIST. + * imap4d/imap4d.h: Include <alloca.h> + * mailbox/attachment.c: Include <alloca.h> + * (_header_get_param): isspace() cast argument. + * mail/mail.h: check if <paths.h> is available if not + define _PATH_SENDMAIL=/usr/lib/sendmail. + * mailbox/folder_imap.c: if pthread available, define _REENTRANT. + Include <alloca.h>. + (imap_bodystructure0): isdigit() cast argument. + * mailbox/mbx_mbox.c: if pthread available, define _REENTRANT. + Include <alloca.h>. + * mailbox/parse822.c: isdigit() cast argument unsigned. + 2001-04-15 Alain Magloire The FILE* stream "stdout" is not an lvalue so it is an error to diff --git a/configure.in b/configure.in index cf472a36a..b5ebb8e9d 100644 --- a/configure.in +++ b/configure.in @@ -68,7 +68,7 @@ AC_FUNC_ALLOCA AC_FUNC_MMAP # FIXME: Provide the GNU one for loosing platforms AC_FUNC_FNMATCH -AC_REPLACE_FUNCS(snprintf strtok_r vasprintf strncasecmp strcasecmp) +AC_REPLACE_FUNCS(setenv snprintf strtok_r strncasecmp strcasecmp vasprintf) AC_CHECK_FUNCS(mkstemp) dnl Check for libraries @@ -104,9 +104,13 @@ AC_SUBST(AUTHLIBS) dnl Check threading support if test x"$usepthread" = x"yes"; then - AC_SEARCH_LIBS(pthread_cancel, pthread, - [AC_CHECK_FUNCS(pthread_rwlock_init) - AC_CHECK_HEADERS(pthread.h, AC_DEFINE(WITH_PTHREAD))]) + AC_CHECK_LIB(pthread, pthread_cancel, [AC_CHECK_HEADERS(pthread.h, + AC_DEFINE(WITH_PTHREAD)) + LIBS="$LIBS -lpthread" + AC_CHECK_FUNCS(pthread_rwlock_init)], + AC_SEARCH_LIBS(pthread_cancel, pthread, + [AC_CHECK_FUNCS(pthread_rwlock_init) + AC_CHECK_HEADERS(pthread.h, AC_DEFINE(WITH_PTHREAD))])) fi dnl Do we need extra libs for networking? diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h index 5f1e6c6a1..3c240ac29 100644 --- a/imap4d/imap4d.h +++ b/imap4d/imap4d.h @@ -47,6 +47,11 @@ #include <stdarg.h> #include <sys/time.h> #include <sys/stat.h> + +#ifdef HAVE_ALLOCA_H +# include <alloca.h> +#endif + #ifdef HAVE_STRINGS_H # include <strings.h> #endif diff --git a/lib/Makefile.am b/lib/Makefile.am index fafcb5b26..6b584b0cb 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -4,8 +4,8 @@ noinst_LIBRARIES = libmailutils.a libmailutils_a_SOURCES = basename.c getopt.c getopt1.c md5.c getline.c \ xstrdup.c xmalloc.c argcv.c -EXTRA_DIST = alloca.c snprintf.c strchrnul.c strndup.c strnlen.c strtok_r.c \ - xstrtol.c vasprintf.c +EXTRA_DIST = alloca.c setenv.c snprintf.c strchrnul.c strndup.c strnlen.c \ + strtok_r.c xstrtol.c vasprintf.c noinst_HEADERS = getopt.h md5.h getline.h snprintf.h xstrtol.h xalloc.h \ argcv.h error.h diff --git a/lib/setenv.c b/lib/setenv.c new file mode 100644 index 000000000..ba965faaa --- /dev/null +++ b/lib/setenv.c @@ -0,0 +1,156 @@ +/* Copyright (C) 1992, 1995, 1996, 1997, 2001 Free Software Foundation, Inc. + This file based on setenv.c in 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <errno.h> + +#if HAVE_STDLIB_H +# include <stdlib.h> +#else +#include <sys/types.h> /* For `size_t' */ +#include <stdio.h> /* For `NULL' */ +#endif +#if HAVE_STRING_H +# include <string.h> +#endif +#if HAVE_UNISTD_H +# include <unistd.h> +#endif + +#define __environ environ +extern char **environ; + +/* LOCK and UNLOCK are defined as no-ops. This makes the libiberty + * implementation MT-Unsafe. */ +#define LOCK +#define UNLOCK + +/* Below this point, it's verbatim code from the glibc-2.0 implementation */ + +/* If this variable is not a null pointer we allocated the current + environment. */ +static char **last_environ; + + +int +setenv (name, value, replace) + const char *name; + const char *value; + int replace; +{ + register char **ep; + register size_t size; + const size_t namelen = strlen (name); + const size_t vallen = strlen (value) + 1; + + LOCK; + + size = 0; + if (__environ != NULL) + for (ep = __environ; *ep != NULL; ++ep) + if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') + break; + else + ++size; + + if (__environ == NULL || *ep == NULL) + { + char **new_environ; + if (__environ == last_environ && __environ != NULL) + /* We allocated this space; we can extend it. */ + new_environ = (char **) realloc (last_environ, + (size + 2) * sizeof (char *)); + else + new_environ = (char **) malloc ((size + 2) * sizeof (char *)); + + if (new_environ == NULL) + { + UNLOCK; + return -1; + } + + new_environ[size] = malloc (namelen + 1 + vallen); + if (new_environ[size] == NULL) + { + free ((char *) new_environ); + errno = ENOMEM; + UNLOCK; + return -1; + } + + if (__environ != last_environ) + memcpy ((char *) new_environ, (char *) __environ, + size * sizeof (char *)); + + memcpy (new_environ[size], name, namelen); + new_environ[size][namelen] = '='; + memcpy (&new_environ[size][namelen + 1], value, vallen); + + new_environ[size + 1] = NULL; + + last_environ = __environ = new_environ; + } + else if (replace) + { + size_t len = strlen (*ep); + if (len + 1 < namelen + 1 + vallen) + { + /* The existing string is too short; malloc a new one. */ + char *new = malloc (namelen + 1 + vallen); + if (new == NULL) + { + UNLOCK; + return -1; + } + *ep = new; + } + memcpy (*ep, name, namelen); + (*ep)[namelen] = '='; + memcpy (&(*ep)[namelen + 1], value, vallen); + } + + UNLOCK; + + return 0; +} + +void +unsetenv (name) + const char *name; +{ + const size_t len = strlen (name); + char **ep; + + LOCK; + + for (ep = __environ; *ep; ++ep) + if (!strncmp (*ep, name, len) && (*ep)[len] == '=') + { + /* Found it. Remove this pointer by moving later ones back. */ + char **dp = ep; + do + dp[0] = dp[1]; + while (*dp++); + /* Continue the loop in case NAME appears again. */ + } + + UNLOCK; +} diff --git a/mail/mail.h b/mail/mail.h index 83caf9c83..c682bd7a6 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -32,6 +32,9 @@ #include <stdarg.h> #include <signal.h> #include <ctype.h> +#ifdef HAVE_PATHS_H +#include <paths.h> +#endif #include <argp.h> @@ -146,6 +149,10 @@ struct mail_env_entry *util_find_env __P((char *var)); int util_printenv __P((int set)); int util_isdeleted __P((int message)); +#ifndef _PATH_SENDMAIL +#define _PATH_SENDMAIL "/usr/lib/sendmail" +#endif + #ifdef __cplusplus } #endif diff --git a/mailbox/attachment.c b/mailbox/attachment.c index 3cfb0aa31..0bc5a78d6 100644 --- a/mailbox/attachment.c +++ b/mailbox/attachment.c @@ -26,6 +26,10 @@ #include <unistd.h> #include <ctype.h> +#ifdef HAVE_ALLOCA_H +# include <alloca.h> +#endif + #ifdef HAVE_LIBGEN_H # include <libgen.h> #endif @@ -165,13 +169,13 @@ static char *_header_get_param(char *field_body, const char *param, size_t *len) p = strchr(str, ';' ); while ( p ) { p++; - while( isspace(*p) ) /* walk upto start of param */ + while( isspace((unsigned)*p) ) /* walk upto start of param */ p++; if ( ( v = strchr(p, '=' ) ) == NULL ) break; *len = 0; v = e = v + 1; - while ( *e && (quoted || ( !_ISSPECIAL(*e) && !isspace(*e) ) ) ) { /* skip pass value and calc len */ + while ( *e && (quoted || ( !_ISSPECIAL(*e) && !isspace((unsigned)*e) ) ) ) { /* skip pass value and calc len */ if ( *e == '\"' ) quoted = ~quoted, was_quoted = 1; else diff --git a/mailbox/filter_rfc822.c b/mailbox/filter_rfc822.c index e33076812..fdd8c5da0 100644 --- a/mailbox/filter_rfc822.c +++ b/mailbox/filter_rfc822.c @@ -23,13 +23,9 @@ #include <stdlib.h> #include <errno.h> -#ifdef HAVE_PTHREAD_H -# define _XOPEN_SOURCE 500 -# include <pthread.h> -#endif -#include <filter0.h> #include <mailutils/property.h> +#include <filter0.h> static int rfc822_property __P ((property_t, const char *, const char *)); static int rfc822_init __P ((filter_t)); diff --git a/mailbox/folder_imap.c b/mailbox/folder_imap.c index a5d97102e..4d846ed89 100644 --- a/mailbox/folder_imap.c +++ b/mailbox/folder_imap.c @@ -19,6 +19,10 @@ # include <config.h> #endif +#ifdef WITH_PTHREAD +# define _REENTRANT +#endif + #include <stdlib.h> #include <ctype.h> #include <stdarg.h> @@ -27,6 +31,10 @@ #include <assert.h> #include <fnmatch.h> +#ifdef HAVE_ALLOCA_H +# include <alloca.h> +#endif + #ifdef HAVE_STRINGS_H # include <strings.h> #endif @@ -1109,7 +1117,7 @@ imap_bodystructure0 (msg_imap_t msg_imap, char **ptr) no_arg = 0; } - if (isdigit (**ptr)) + if (isdigit ((unsigned)**ptr)) { char *start = *ptr; size_t size = strtoul (*ptr, ptr, 10); diff --git a/mailbox/mbx_mbox.c b/mailbox/mbx_mbox.c index 6aed91130..ace9badc1 100644 --- a/mailbox/mbx_mbox.c +++ b/mailbox/mbx_mbox.c @@ -21,6 +21,13 @@ # include <config.h> #endif +#ifdef WITH_PTHREAD +# define _REENTRANT +# ifdef HAVE_PTHREAD_H +# define _XOPEN_SOURCE 500 +# include <pthread.h> +# endif +#endif #include <stdlib.h> #include <stdio.h> #include <time.h> @@ -33,10 +40,11 @@ #include <ctype.h> #include <limits.h> #include <errno.h> -#ifdef HAVE_PTHREAD_H -# define _XOPEN_SOURCE 500 -# include <pthread.h> + +#ifdef HAVE_ALLOCA_H +# include <alloca.h> #endif + #ifdef HAVE_STRINGS_H # include <strings.h> #endif diff --git a/mailbox/mbx_pop.c b/mailbox/mbx_pop.c index c23afe5a0..eceb38d76 100644 --- a/mailbox/mbx_pop.c +++ b/mailbox/mbx_pop.c @@ -27,6 +27,11 @@ #include <unistd.h> #include <fcntl.h> #include <stdarg.h> + +#ifdef HAVE_ALLOCA_H +# include <alloca.h> +#endif + #ifdef HAVE_STRINGS_H # include <strings.h> #endif diff --git a/mailbox/monitor.c b/mailbox/monitor.c index e4a727f26..87116f231 100644 --- a/mailbox/monitor.c +++ b/mailbox/monitor.c @@ -1,5 +1,5 @@ /* GNU mailutils - a suite of utilities for electronic mail - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Library Public License as published by @@ -25,6 +25,7 @@ #endif #ifdef WITH_PTHREAD +# define _REENTRANT # ifdef HAVE_PTHREAD_H # include <pthread.h> # endif diff --git a/mailbox/parse822.c b/mailbox/parse822.c index 2674778a9..66c7f739c 100644 --- a/mailbox/parse822.c +++ b/mailbox/parse822.c @@ -162,11 +162,11 @@ int parse822_is_digit(char c) { /* digit = <any ASCII decimal digit> */ - return isdigit(c); + return isdigit((unsigned)c); } int parse822_is_ctl(char c) { - return iscntrl(c) || c == 127 /* DEL */; + return iscntrl((unsigned)c) || c == 127 /* DEL */; } int parse822_is_space(char c) { @@ -1209,7 +1209,7 @@ int parse822_quote_local_part(char** quoted, const char* raw) */ const char* s = 0; - + if(!raw || !quoted || *quoted) { return EINVAL; } |