Commit c8df06a7 c8df06a75ca9559630d761a6745032c22d9beb58 by 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.
1 parent 9221152b
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
......
......@@ -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?
......
......@@ -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
......
......@@ -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
......
/* 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;
}
......@@ -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
......
......@@ -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
......
......@@ -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));
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
/* 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
......
......@@ -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;
}
......