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
1 2001-04-16 Alain Magloire
2
3 To get things to compile on Solaris, change configure to check
4 for -lpthread since in libc the thread functions are defined
5 but all return ENOSYS, you need to explicitely link with -lphtread.
6 the ctype functions is*() arguments should be explicitely cast
7 since Solaris use them as indexes. __REENTRANT as to be define
8 if compile with support for threads. Never realize this but
9 setenv() is a BSD/GNU thing, so took a variant from libiberty
10 to cope.
11
12 * configure.in: Check for setenv. First check if -lphtread is ok.
13 * lib/setenv.c: New functions.
14 * lib/Makefile.am: add setenv.c in EXTRA_DIST.
15 * imap4d/imap4d.h: Include <alloca.h>
16 * mailbox/attachment.c: Include <alloca.h>
17 * (_header_get_param): isspace() cast argument.
18 * mail/mail.h: check if <paths.h> is available if not
19 define _PATH_SENDMAIL=/usr/lib/sendmail.
20 * mailbox/folder_imap.c: if pthread available, define _REENTRANT.
21 Include <alloca.h>.
22 (imap_bodystructure0): isdigit() cast argument.
23 * mailbox/mbx_mbox.c: if pthread available, define _REENTRANT.
24 Include <alloca.h>.
25 * mailbox/parse822.c: isdigit() cast argument unsigned.
26
1 2001-04-15 Alain Magloire 27 2001-04-15 Alain Magloire
2 28
3 The FILE* stream "stdout" is not an lvalue so it is an error to 29 The FILE* stream "stdout" is not an lvalue so it is an error to
......
...@@ -68,7 +68,7 @@ AC_FUNC_ALLOCA ...@@ -68,7 +68,7 @@ AC_FUNC_ALLOCA
68 AC_FUNC_MMAP 68 AC_FUNC_MMAP
69 # FIXME: Provide the GNU one for loosing platforms 69 # FIXME: Provide the GNU one for loosing platforms
70 AC_FUNC_FNMATCH 70 AC_FUNC_FNMATCH
71 AC_REPLACE_FUNCS(snprintf strtok_r vasprintf strncasecmp strcasecmp) 71 AC_REPLACE_FUNCS(setenv snprintf strtok_r strncasecmp strcasecmp vasprintf)
72 AC_CHECK_FUNCS(mkstemp) 72 AC_CHECK_FUNCS(mkstemp)
73 73
74 dnl Check for libraries 74 dnl Check for libraries
...@@ -104,9 +104,13 @@ AC_SUBST(AUTHLIBS) ...@@ -104,9 +104,13 @@ AC_SUBST(AUTHLIBS)
104 104
105 dnl Check threading support 105 dnl Check threading support
106 if test x"$usepthread" = x"yes"; then 106 if test x"$usepthread" = x"yes"; then
107 AC_CHECK_LIB(pthread, pthread_cancel, [AC_CHECK_HEADERS(pthread.h,
108 AC_DEFINE(WITH_PTHREAD))
109 LIBS="$LIBS -lpthread"
110 AC_CHECK_FUNCS(pthread_rwlock_init)],
107 AC_SEARCH_LIBS(pthread_cancel, pthread, 111 AC_SEARCH_LIBS(pthread_cancel, pthread,
108 [AC_CHECK_FUNCS(pthread_rwlock_init) 112 [AC_CHECK_FUNCS(pthread_rwlock_init)
109 AC_CHECK_HEADERS(pthread.h, AC_DEFINE(WITH_PTHREAD))]) 113 AC_CHECK_HEADERS(pthread.h, AC_DEFINE(WITH_PTHREAD))]))
110 fi 114 fi
111 115
112 dnl Do we need extra libs for networking? 116 dnl Do we need extra libs for networking?
......
...@@ -47,6 +47,11 @@ ...@@ -47,6 +47,11 @@
47 #include <stdarg.h> 47 #include <stdarg.h>
48 #include <sys/time.h> 48 #include <sys/time.h>
49 #include <sys/stat.h> 49 #include <sys/stat.h>
50
51 #ifdef HAVE_ALLOCA_H
52 # include <alloca.h>
53 #endif
54
50 #ifdef HAVE_STRINGS_H 55 #ifdef HAVE_STRINGS_H
51 # include <strings.h> 56 # include <strings.h>
52 #endif 57 #endif
......
...@@ -4,8 +4,8 @@ noinst_LIBRARIES = libmailutils.a ...@@ -4,8 +4,8 @@ noinst_LIBRARIES = libmailutils.a
4 libmailutils_a_SOURCES = basename.c getopt.c getopt1.c md5.c getline.c \ 4 libmailutils_a_SOURCES = basename.c getopt.c getopt1.c md5.c getline.c \
5 xstrdup.c xmalloc.c argcv.c 5 xstrdup.c xmalloc.c argcv.c
6 6
7 EXTRA_DIST = alloca.c snprintf.c strchrnul.c strndup.c strnlen.c strtok_r.c \ 7 EXTRA_DIST = alloca.c setenv.c snprintf.c strchrnul.c strndup.c strnlen.c \
8 xstrtol.c vasprintf.c 8 strtok_r.c xstrtol.c vasprintf.c
9 9
10 noinst_HEADERS = getopt.h md5.h getline.h snprintf.h xstrtol.h xalloc.h \ 10 noinst_HEADERS = getopt.h md5.h getline.h snprintf.h xstrtol.h xalloc.h \
11 argcv.h error.h 11 argcv.h error.h
......
1 /* Copyright (C) 1992, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
2 This file based on setenv.c in the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19 #if HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22
23 #include <errno.h>
24
25 #if HAVE_STDLIB_H
26 # include <stdlib.h>
27 #else
28 #include <sys/types.h> /* For `size_t' */
29 #include <stdio.h> /* For `NULL' */
30 #endif
31 #if HAVE_STRING_H
32 # include <string.h>
33 #endif
34 #if HAVE_UNISTD_H
35 # include <unistd.h>
36 #endif
37
38 #define __environ environ
39 extern char **environ;
40
41 /* LOCK and UNLOCK are defined as no-ops. This makes the libiberty
42 * implementation MT-Unsafe. */
43 #define LOCK
44 #define UNLOCK
45
46 /* Below this point, it's verbatim code from the glibc-2.0 implementation */
47
48 /* If this variable is not a null pointer we allocated the current
49 environment. */
50 static char **last_environ;
51
52
53 int
54 setenv (name, value, replace)
55 const char *name;
56 const char *value;
57 int replace;
58 {
59 register char **ep;
60 register size_t size;
61 const size_t namelen = strlen (name);
62 const size_t vallen = strlen (value) + 1;
63
64 LOCK;
65
66 size = 0;
67 if (__environ != NULL)
68 for (ep = __environ; *ep != NULL; ++ep)
69 if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
70 break;
71 else
72 ++size;
73
74 if (__environ == NULL || *ep == NULL)
75 {
76 char **new_environ;
77 if (__environ == last_environ && __environ != NULL)
78 /* We allocated this space; we can extend it. */
79 new_environ = (char **) realloc (last_environ,
80 (size + 2) * sizeof (char *));
81 else
82 new_environ = (char **) malloc ((size + 2) * sizeof (char *));
83
84 if (new_environ == NULL)
85 {
86 UNLOCK;
87 return -1;
88 }
89
90 new_environ[size] = malloc (namelen + 1 + vallen);
91 if (new_environ[size] == NULL)
92 {
93 free ((char *) new_environ);
94 errno = ENOMEM;
95 UNLOCK;
96 return -1;
97 }
98
99 if (__environ != last_environ)
100 memcpy ((char *) new_environ, (char *) __environ,
101 size * sizeof (char *));
102
103 memcpy (new_environ[size], name, namelen);
104 new_environ[size][namelen] = '=';
105 memcpy (&new_environ[size][namelen + 1], value, vallen);
106
107 new_environ[size + 1] = NULL;
108
109 last_environ = __environ = new_environ;
110 }
111 else if (replace)
112 {
113 size_t len = strlen (*ep);
114 if (len + 1 < namelen + 1 + vallen)
115 {
116 /* The existing string is too short; malloc a new one. */
117 char *new = malloc (namelen + 1 + vallen);
118 if (new == NULL)
119 {
120 UNLOCK;
121 return -1;
122 }
123 *ep = new;
124 }
125 memcpy (*ep, name, namelen);
126 (*ep)[namelen] = '=';
127 memcpy (&(*ep)[namelen + 1], value, vallen);
128 }
129
130 UNLOCK;
131
132 return 0;
133 }
134
135 void
136 unsetenv (name)
137 const char *name;
138 {
139 const size_t len = strlen (name);
140 char **ep;
141
142 LOCK;
143
144 for (ep = __environ; *ep; ++ep)
145 if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
146 {
147 /* Found it. Remove this pointer by moving later ones back. */
148 char **dp = ep;
149 do
150 dp[0] = dp[1];
151 while (*dp++);
152 /* Continue the loop in case NAME appears again. */
153 }
154
155 UNLOCK;
156 }
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
32 #include <stdarg.h> 32 #include <stdarg.h>
33 #include <signal.h> 33 #include <signal.h>
34 #include <ctype.h> 34 #include <ctype.h>
35 #ifdef HAVE_PATHS_H
36 #include <paths.h>
37 #endif
35 38
36 #include <argp.h> 39 #include <argp.h>
37 40
...@@ -146,6 +149,10 @@ struct mail_env_entry *util_find_env __P((char *var)); ...@@ -146,6 +149,10 @@ struct mail_env_entry *util_find_env __P((char *var));
146 int util_printenv __P((int set)); 149 int util_printenv __P((int set));
147 int util_isdeleted __P((int message)); 150 int util_isdeleted __P((int message));
148 151
152 #ifndef _PATH_SENDMAIL
153 #define _PATH_SENDMAIL "/usr/lib/sendmail"
154 #endif
155
149 #ifdef __cplusplus 156 #ifdef __cplusplus
150 } 157 }
151 #endif 158 #endif
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
26 #include <unistd.h> 26 #include <unistd.h>
27 #include <ctype.h> 27 #include <ctype.h>
28 28
29 #ifdef HAVE_ALLOCA_H
30 # include <alloca.h>
31 #endif
32
29 #ifdef HAVE_LIBGEN_H 33 #ifdef HAVE_LIBGEN_H
30 # include <libgen.h> 34 # include <libgen.h>
31 #endif 35 #endif
...@@ -165,13 +169,13 @@ static char *_header_get_param(char *field_body, const char *param, size_t *len) ...@@ -165,13 +169,13 @@ static char *_header_get_param(char *field_body, const char *param, size_t *len)
165 p = strchr(str, ';' ); 169 p = strchr(str, ';' );
166 while ( p ) { 170 while ( p ) {
167 p++; 171 p++;
168 while( isspace(*p) ) /* walk upto start of param */ 172 while( isspace((unsigned)*p) ) /* walk upto start of param */
169 p++; 173 p++;
170 if ( ( v = strchr(p, '=' ) ) == NULL ) 174 if ( ( v = strchr(p, '=' ) ) == NULL )
171 break; 175 break;
172 *len = 0; 176 *len = 0;
173 v = e = v + 1; 177 v = e = v + 1;
174 while ( *e && (quoted || ( !_ISSPECIAL(*e) && !isspace(*e) ) ) ) { /* skip pass value and calc len */ 178 while ( *e && (quoted || ( !_ISSPECIAL(*e) && !isspace((unsigned)*e) ) ) ) { /* skip pass value and calc len */
175 if ( *e == '\"' ) 179 if ( *e == '\"' )
176 quoted = ~quoted, was_quoted = 1; 180 quoted = ~quoted, was_quoted = 1;
177 else 181 else
......
...@@ -23,13 +23,9 @@ ...@@ -23,13 +23,9 @@
23 23
24 #include <stdlib.h> 24 #include <stdlib.h>
25 #include <errno.h> 25 #include <errno.h>
26 #ifdef HAVE_PTHREAD_H
27 # define _XOPEN_SOURCE 500
28 # include <pthread.h>
29 #endif
30 26
31 #include <filter0.h>
32 #include <mailutils/property.h> 27 #include <mailutils/property.h>
28 #include <filter0.h>
33 29
34 static int rfc822_property __P ((property_t, const char *, const char *)); 30 static int rfc822_property __P ((property_t, const char *, const char *));
35 static int rfc822_init __P ((filter_t)); 31 static int rfc822_init __P ((filter_t));
......
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
19 # include <config.h> 19 # include <config.h>
20 #endif 20 #endif
21 21
22 #ifdef WITH_PTHREAD
23 # define _REENTRANT
24 #endif
25
22 #include <stdlib.h> 26 #include <stdlib.h>
23 #include <ctype.h> 27 #include <ctype.h>
24 #include <stdarg.h> 28 #include <stdarg.h>
...@@ -27,6 +31,10 @@ ...@@ -27,6 +31,10 @@
27 #include <assert.h> 31 #include <assert.h>
28 #include <fnmatch.h> 32 #include <fnmatch.h>
29 33
34 #ifdef HAVE_ALLOCA_H
35 # include <alloca.h>
36 #endif
37
30 #ifdef HAVE_STRINGS_H 38 #ifdef HAVE_STRINGS_H
31 # include <strings.h> 39 # include <strings.h>
32 #endif 40 #endif
...@@ -1109,7 +1117,7 @@ imap_bodystructure0 (msg_imap_t msg_imap, char **ptr) ...@@ -1109,7 +1117,7 @@ imap_bodystructure0 (msg_imap_t msg_imap, char **ptr)
1109 no_arg = 0; 1117 no_arg = 0;
1110 } 1118 }
1111 1119
1112 if (isdigit (**ptr)) 1120 if (isdigit ((unsigned)**ptr))
1113 { 1121 {
1114 char *start = *ptr; 1122 char *start = *ptr;
1115 size_t size = strtoul (*ptr, ptr, 10); 1123 size_t size = strtoul (*ptr, ptr, 10);
......
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
21 # include <config.h> 21 # include <config.h>
22 #endif 22 #endif
23 23
24 #ifdef WITH_PTHREAD
25 # define _REENTRANT
26 # ifdef HAVE_PTHREAD_H
27 # define _XOPEN_SOURCE 500
28 # include <pthread.h>
29 # endif
30 #endif
24 #include <stdlib.h> 31 #include <stdlib.h>
25 #include <stdio.h> 32 #include <stdio.h>
26 #include <time.h> 33 #include <time.h>
...@@ -33,10 +40,11 @@ ...@@ -33,10 +40,11 @@
33 #include <ctype.h> 40 #include <ctype.h>
34 #include <limits.h> 41 #include <limits.h>
35 #include <errno.h> 42 #include <errno.h>
36 #ifdef HAVE_PTHREAD_H 43
37 # define _XOPEN_SOURCE 500 44 #ifdef HAVE_ALLOCA_H
38 # include <pthread.h> 45 # include <alloca.h>
39 #endif 46 #endif
47
40 #ifdef HAVE_STRINGS_H 48 #ifdef HAVE_STRINGS_H
41 # include <strings.h> 49 # include <strings.h>
42 #endif 50 #endif
......
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
27 #include <unistd.h> 27 #include <unistd.h>
28 #include <fcntl.h> 28 #include <fcntl.h>
29 #include <stdarg.h> 29 #include <stdarg.h>
30
31 #ifdef HAVE_ALLOCA_H
32 # include <alloca.h>
33 #endif
34
30 #ifdef HAVE_STRINGS_H 35 #ifdef HAVE_STRINGS_H
31 # include <strings.h> 36 # include <strings.h>
32 #endif 37 #endif
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Library Public License as published by 5 it under the terms of the GNU General Library Public License as published by
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
25 #endif 25 #endif
26 26
27 #ifdef WITH_PTHREAD 27 #ifdef WITH_PTHREAD
28 # define _REENTRANT
28 # ifdef HAVE_PTHREAD_H 29 # ifdef HAVE_PTHREAD_H
29 # include <pthread.h> 30 # include <pthread.h>
30 # endif 31 # endif
......
...@@ -162,11 +162,11 @@ int parse822_is_digit(char c) ...@@ -162,11 +162,11 @@ int parse822_is_digit(char c)
162 { 162 {
163 /* digit = <any ASCII decimal digit> */ 163 /* digit = <any ASCII decimal digit> */
164 164
165 return isdigit(c); 165 return isdigit((unsigned)c);
166 } 166 }
167 int parse822_is_ctl(char c) 167 int parse822_is_ctl(char c)
168 { 168 {
169 return iscntrl(c) || c == 127 /* DEL */; 169 return iscntrl((unsigned)c) || c == 127 /* DEL */;
170 } 170 }
171 int parse822_is_space(char c) 171 int parse822_is_space(char c)
172 { 172 {
......