Commit 9b47f0be authored by Thomas Roessler's avatar Thomas Roessler

Portability patches for SunOS 4.1. From Lars Hecking.

parent 8d759499
......@@ -120,6 +120,9 @@
/* Does your system have the fchdir() call? */
#undef HAVE_FCHDIR
/* getopt() is available, but not declared in any header */
#undef HAVE_GETOPT_DECL
/* Define if your locale.h file contains LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
......@@ -144,3 +147,6 @@
/* Where are the character set definitions located? */
#undef CHARMAPS_DIR
/* Define to `int' if <signal.h> doesn't define. */
#undef sig_atomic_t
......@@ -202,10 +202,15 @@ main ()
AC_HEADER_STDC
AC_CHECK_HEADERS(stdarg.h sys/ioctl.h sysexits.h getopt.h)
AC_CHECK_HEADERS(stdarg.h sys/ioctl.h sysexits.h)
AC_TYPE_SIGNAL
AC_MSG_CHECKING(for sig_atomic_t in signal.h)
AC_EGREP_HEADER(sig_atomic_t,signal.h,dnl
[ ac_cv_type_sig_atomic_t=yes; AC_MSG_RESULT(yes) ],dnl
AC_MSG_RESULT(no); AC_CHECK_TYPE(sig_atomic_t, int))
AC_DECL_SYS_SIGLIST
dnl need this for DEC alpha
......@@ -213,10 +218,27 @@ AC_CHECK_SIZEOF(long)
AC_TYPE_PID_T
AC_CHECK_FUNCS(setegid srand48 strerror)
AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror)
AC_REPLACE_FUNCS(strcasecmp)
AC_CHECK_FUNC(getopt)
if test $ac_cv_func_getopt = yes; then
AC_CHECK_HEADERS(getopt.h)
if test $ac_cv_header_getopt_h = no; then
AC_MSG_CHECKING(for getopt declaration in stdio.h)
AC_EGREP_HEADER(getopt,stdio.h,dnl
[ AC_DEFINE(HAVE_GETOPT_DECL)
AC_MSG_RESULT(yes) ],dnl
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for getopt declaration in stdlib.h)
AC_EGREP_HEADER(getopt,stdlib.h,dnl
[ AC_DEFINE(HAVE_GETOPT_DECL)
AC_MSG_RESULT(yes) ],dnl
AC_MSG_RESULT(no)))
fi
fi
mutt_cv_snprintf=no
SNPRINTFOBJS=""
AC_CHECK_FUNC(snprintf, [AC_DEFINE(HAVE_SNPRINTF)], [mutt_cv_snprintf=yes])
......
......@@ -44,12 +44,25 @@
#include <time.h>
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#else
# ifndef HAVE_GETOPT_DECL
extern char *optarg;
extern int optind;
# endif
#endif
#include "sha.h"
#include "lib.h"
#include "pgplib.h"
#ifdef HAVE_FGETPOS
#define FGETPOS(fp,pos) fgetpos((fp),&(pos))
#define FSETPOS(fp,pos) fsetpos((fp),&(pos))
#else
#define FGETPOS(fp,pos) pos=ftell((fp));
#define FSETPOS(fp,pos) fseek((fp),(pos),SEEK_SET)
#endif
#define CHUNKSIZE 1024
static unsigned char *pbuf = NULL;
......@@ -731,15 +744,19 @@ static pgp_key_t *pgp_parse_keyblock (FILE * fp)
size_t l;
short err = 0;
#ifdef HAVE_FGETPOS
fpos_t pos;
#else
long pos;
#endif
pgp_key_t *root = NULL;
pgp_key_t **last = &root;
pgp_key_t *p = NULL;
pgp_uid_t *uid = NULL;
pgp_uid_t **addr = NULL;
fgetpos (fp, &pos);
FGETPOS(fp,pos);
while (!err && (buff = pgp_read_packet (fp, &l)) != NULL)
{
......@@ -750,7 +767,7 @@ static pgp_key_t *pgp_parse_keyblock (FILE * fp)
if ((pt == PT_SECKEY || pt == PT_PUBKEY) && root)
{
fsetpos (fp, &pos);
FSETPOS(fp, pos);
return root;
}
......@@ -841,7 +858,7 @@ static pgp_key_t *pgp_parse_keyblock (FILE * fp)
}
}
fgetpos (fp, &pos);
FGETPOS(fp,pos);
}
if (err)
......@@ -874,7 +891,11 @@ static int pgpring_string_matches_hint (const char *s, const char *hints[], int
static void pgpring_find_candidates (char *ringfile, const char *hints[], int nhints)
{
FILE *rfp;
#ifdef HAVE_FGETPOS
fpos_t pos, keypos;
#else
long pos, keypos;
#endif
unsigned char *buff = NULL;
unsigned char pt = 0;
......@@ -888,8 +909,8 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], int nh
return;
}
fgetpos (rfp, &pos);
fgetpos (rfp, &keypos);
FGETPOS(rfp,pos);
FGETPOS(rfp,keypos);
while (!err && (buff = pgp_read_packet (rfp, &l)) != NULL)
{
......@@ -915,7 +936,7 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], int nh
{
pgp_key_t *p;
fsetpos (rfp, &keypos);
FSETPOS(rfp, keypos);
/* Not bailing out here would lead us into an endless loop. */
......@@ -929,7 +950,7 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], int nh
safe_free ((void **) &tmp);
}
fgetpos (rfp, &pos);
FGETPOS(rfp,pos);
}
fclose (rfp);
......
......@@ -341,6 +341,10 @@ extern char *sys_errlist[];
#define strerror(x) ((x) > 0 && (x) < sys_nerr) ? sys_errlist[(x)] : 0
#endif /* !HAVE_STRERROR */
#ifndef HAVE_MEMMOVE
#define memmove(d,s,n) bcopy((s),(d),(n))
#endif
/* AIX doesn't define these in any headers (sigh) */
int strcasecmp (const char *, const char *);
int strncasecmp (const char *, const char *, size_t);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment