Commit 1e700f5c 1e700f5c5c378762384c2178f98158b399a44b92 by Alain Magloire

GNU md5.c is GPL, so we should use a non GPL version for libmailbox

1 parent 53047de9
......@@ -81,7 +81,8 @@ AC_FUNC_FNMATCH
if test "$ac_cv_func_fnmatch_works" = "no"; then
: LIBOBJS="$LIBOBJS fnmatch.o"
fi
AC_REPLACE_FUNCS(setenv snprintf strtok_r strncasecmp strcasecmp vasprintf)
AC_REPLACE_FUNCS(setenv snprintf strtok_r strncasecmp strcasecmp strsignal \
vasprintf)
AC_CHECK_FUNCS(mkstemp sigaction sysconf)
dnl Check for libraries
......
......@@ -2,10 +2,10 @@ AUTOMAKE_OPTIONS = ansi2knr
noinst_LIBRARIES = libmailutils.a
libmailutils_a_SOURCES = basename.c getopt.c getopt1.c md5.c getline.c \
xstrdup.c xmalloc.c argcv.c signame.c
xstrdup.c xmalloc.c argcv.c
EXTRA_DIST = alloca.c fnmatch.c setenv.c snprintf.c strchrnul.c strndup.c \
strnlen.c strtok_r.c xstrtol.c vasprintf.c
strnlen.c strtok_r.c strsignal.c xstrtol.c vasprintf.c
noinst_HEADERS = argcv.h error.h fnmatch.h getline.h getopt.h md5.h \
snprintf.h xalloc.h xstrtol.h
......
......@@ -15,21 +15,39 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <signal.h>
#include <unistd.h>
#include <signal.h>
#ifndef SYS_SIGLIST_DECLARED
/* For snprintf (). */
#include <stdio.h>
#endif
/* Some systems do not define NSIG in <signal.h>. */
#ifndef NSIG
# ifdef _NSIG
# define NSIG _NSIG
# else
# define NSIG 32
# endif
#endif
/* FIXME: Should probably go in a .h somewhere. */
char *strsignal __P ((int));
char *
mu_signame (int signo)
strsignal (int signo)
{
#ifdef SYS_SIGLIST_DECLARED
return sys_siglist[signo];
/* Let's try to protect ourself a little. */
if (signo > 0 || signo < NSIG)
return (char *)sys_siglist[signo];
return (char *)"";
#else
static char buf[64];
snprintf (buf, sizeof buf, "%d", signo);
snprintf (buf, sizeof buf, "Signal %d", signo);
return buf;
#endif
}
......
......@@ -9,7 +9,7 @@ SUBDIRS = include
lib_LTLIBRARIES = libmailbox.la
EXTRA_DIST = mbx_mboxscan.c
EXTRA_DIST = mbx_mboxscan.c md5-rsa.h
libmailbox_la_SOURCES = \
address.c \
......@@ -39,6 +39,7 @@ mbx_file.c \
mbx_imap.c \
mbx_mbox.c \
mbx_pop.c \
md5-rsa.c \
message.c \
memory_stream.c \
mime.c \
......
/* MD5.H - header file for MD5C.C
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
/* GLOBAL.H - RSAREF types and constants
*/
/* PROTOTYPES should be set to one if and only if the compiler supports
function argument prototyping.
The following makes PROTOTYPES default to 0 if it has not already
been defined with C compiler flags.
*/
#ifndef PROTOTYPES
#define PROTOTYPES 0
#endif
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT2 defines a two byte word */
typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */
typedef unsigned long int UINT4;
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
returns an empty list.
*/
#if __STDC__
#define PROTO_LIST(list) list
#else
#define PROTO_LIST(list) ()
#endif
/* MD5 context. */
typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
void MD5Init PROTO_LIST ((MD5_CTX *));
void MD5Update PROTO_LIST ((MD5_CTX *, unsigned char *, unsigned int));
void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
......@@ -28,7 +28,7 @@
#include <string.h>
#include <ctype.h>
#include "md5.h"
#include "md5-rsa.h"
#include <message0.h>
#include <mailutils/address.h>
......@@ -527,7 +527,7 @@ message_get_uidl (message_t msg, char *buffer, size_t buflen, size_t *pwriten)
else
{
size_t uid = 0;
struct md5_ctx md5context;
MD5_CTX md5context;
stream_t stream = NULL;
char buf[1024];
off_t offset = 0;
......@@ -536,14 +536,14 @@ message_get_uidl (message_t msg, char *buffer, size_t buflen, size_t *pwriten)
n = 0;
message_get_uid (msg, &uid);
message_get_stream (msg, &stream);
md5_init_ctx (&md5context);
MD5Init (&md5context);
while (stream_read (stream, buf, sizeof (buf), offset, &n) == 0
&& n > 0)
{
md5_process_bytes (buf, n, &md5context);
MD5Update (&md5context, buf, n);
offset += n;
}
md5_finish_ctx (&md5context, md5digest);
MD5Final (md5digest, &md5context);
tmp = buf;
for (n = 0; n < 16; n++, tmp += 2)
sprintf (tmp, "%02x", md5digest[n]);
......
......@@ -38,9 +38,9 @@ pop3d_sigchld (int signo)
RETSIGTYPE
pop3d_signal (int signo)
{
extern char *mu_signame __P((int signo));
syslog (LOG_CRIT, "got signal %s", mu_signame(signo));
/* extern char *mu_signame __P((int)); */
syslog (LOG_CRIT, "got signal %s", strsignal(signo));
/* Master process. */
if (!ofile)
{
......