warning fixes and cleanups for 64-bit machines
authorNathan Bryant <loanshark@uncensored.citadel.org>
Wed, 17 Oct 2001 19:40:39 +0000 (19:40 +0000)
committerNathan Bryant <loanshark@uncensored.citadel.org>
Wed, 17 Oct 2001 19:40:39 +0000 (19:40 +0000)
18 files changed:
citadel/ChangeLog
citadel/aidepost.c
citadel/citserver.c
citadel/configure.ac
citadel/control.c
citadel/domain.c
citadel/file_ops.c
citadel/imap_fetch.c
citadel/imap_tools.c
citadel/internet_addressing.c
citadel/md5.c
citadel/md5.h
citadel/msgbase.c
citadel/serv_chat.c
citadel/serv_network.c
citadel/serv_smtp.c
citadel/snprintf.h
citadel/sysdep.c

index 2e8c5e733c5ac658a36343520874ee13ca6e0a6d..f50f3c0f452008307c9fad7ea536f41bdaf94368 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 580.64  2001/10/17 19:40:38  nbryant
+ warning fixes and cleanups for 64-bit machines
+
  Revision 580.63  2001/10/16 20:47:37  nbryant
  - backed out -export-dynamic, it doesn't do anything and i've found the real
  problem
@@ -2821,3 +2824,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index 1d38d92ef712dc58cc56459d219c77652a33e39f..37d1a295e92e8b1d4844bd61967d11070a92f646 100644 (file)
 #include "citadel.h"
 #include "config.h"
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
+
 static void make_message(FILE *fp, char *target_room, char *author)
 {
        int a;
index 57fe8e98bb4b8bb9dc962dfea5f1fb83de028d4f..3d83bfe8c4544254731704879c318f865137aab2 100644 (file)
 #include "control.h"
 #include "tools.h"
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
 struct CitContext *ContextList = NULL;
 char *unique_session_numbers;
 int ScheduledShutdown = 0;
index cc8f0e3e95230579cb0aa99bb923944679198075..776c40d1ec483440f5f76ae8bd23b352b71183c7 100644 (file)
@@ -92,11 +92,11 @@ AC_PROG_CC
 dnl Set up system-dependent compiler flags.
 if test "$GCC" = yes; then
        case "$host" in
-               *-*-solaris*)
-                       CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
+               *-*-solaris*|alpha*-dec-osf*)
+                       CFLAGS="$CFLAGS -Wall -Wcast-align -Wno-char-subscripts"
                ;;
                *)
-                       CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
+                       CFLAGS="$CFLAGS -Wall -Wcast-align -Wstrict-prototypes"
                ;;
        esac
 fi
index fd44e0905c6d3aaa0bcd9a6e30931d19cf6e8816..c1a34fbc46dcd34e8e342f2300ec62f5111a940e 100644 (file)
 #include "tools.h"
 #include "room_ops.h"
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
 struct CitControl CitControl;
 struct config config;
 FILE *control_fp = NULL;
index ccf62f7c795753d9d09e65f2b7eb035b903eb11d..69376cbb0b5d16a541c47479917a3b1725704f10 100644 (file)
@@ -93,13 +93,15 @@ void sort_mxrecs(struct mx *mxrecs, int num_mxrecs) {
  *
  */
 int getmx(char *mxbuf, char *dest) {
-       char answer[1024];
+       union {
+                       u_char bytes[1024];
+                       HEADER header;
+    } answer;
        int ret;
        unsigned char *startptr, *endptr, *ptr;
        char expanded_buf[1024];
        unsigned short pref, type;
        int n = 0;
-       HEADER *hp;
        int qdcount;
 
        struct mx *mxrecs = NULL;
@@ -116,7 +118,7 @@ int getmx(char *mxbuf, char *dest) {
         */
        ret = res_query(
                dest,
-               C_IN, T_MX, (unsigned char *)answer, sizeof(answer)  );
+               C_IN, T_MX, (unsigned char *)answer.bytes, sizeof(answer)  );
 
        if (ret < 0) {
                mxrecs = mallok(sizeof(struct mx));
@@ -130,12 +132,11 @@ int getmx(char *mxbuf, char *dest) {
                if (ret > sizeof(answer))
                        ret = sizeof(answer);
        
-               hp = (HEADER *)&answer[0];
-               startptr = &answer[0];          /* start and end of buffer */
-               endptr = &answer[ret];
+               startptr = &answer.bytes[0];            /* start and end of buffer */
+               endptr = &answer.bytes[ret];
                ptr = startptr + HFIXEDSZ;      /* advance past header */
        
-               for (qdcount = ntohs(hp->qdcount); qdcount--; ptr += ret + QFIXEDSZ) {
+               for (qdcount = ntohs(answer.header.qdcount); qdcount--; ptr += ret + QFIXEDSZ) {
                        if ((ret = dn_skipname(ptr, endptr)) < 0) {
                                lprintf(9, "dn_skipname error\n");
                                return(0);
index a04dc32c9b38ab312e02ba1ef8bb34ba0eb9827c..61ad702d23d7f98b72e2f2a87e3ef762fa387b7f 100644 (file)
@@ -44,6 +44,9 @@
 #include "tools.h"
 #include "citserver.h"
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
 
 /*
  * network_talking_to()  --  concurrency checker
index 0143a7b1f634b0841b9296c77c78107f12ad654b..2fc7ffe81277d76d65f93f7bc81ffba09f497046 100644 (file)
@@ -218,7 +218,7 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp,
                        }
                        fprintf(imfp->output_fp, "\r\n");
                }
-               fprintf(imfp->output_fp, "Content-Length: %d\r\n", length);
+               fprintf(imfp->output_fp, "Content-Length: %ld\r\n", (long)length);
                fprintf(imfp->output_fp, "\r\n");
        }
                        
index 58aabd897da843ac79c3b2e8fa8c070419c79e8e..c205dbd35bbfc07909e159e2c2a32c36a68cfa37 100644 (file)
 #include "imap_tools.h"
 
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
 /*
  * Output a string to the IMAP client, either as a literal or quoted.
  * (We do a literal if it has any double-quotes or backslashes.)
index ca0530d968bc2dde41f9fe48219bfbff0279a17f..678189bb1b4b1ad7e947ea6d3100de21bcdbfbbb 100644 (file)
 #include "parsedate.h"
 
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
+
 struct trynamebuf {
        char buffer1[SIZ];
        char buffer2[SIZ];
index 1488a1a4e9e1a814e9a3d582196ba921efcfc2e7..c0ba96afad0341f1e0c24828565888616f076b53 100644 (file)
@@ -89,7 +89,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
        }
        memcpy(p, buf, t);
        byteReverse(ctx->in, 16);
-       MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in);
+       MD5Transform(ctx->buf, ctx->in);
        buf += t;
        len -= t;
     }
@@ -98,7 +98,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
     while (len >= 64) {
        memcpy(ctx->in, buf, 64);
        byteReverse(ctx->in, 16);
-       MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in);
+       MD5Transform(ctx->buf, ctx->in);
        buf += 64;
        len -= 64;
     }
@@ -122,7 +122,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
 
     /* Set the first char of padding to 0x80.  This is safe since there is
        always at least one byte free */
-    p = ctx->in + count;
+    p = ((unsigned char*)ctx->in) + count;
     *p++ = 0x80;
 
     /* Bytes of padding needed to make 64 bytes */
@@ -133,7 +133,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
        /* Two lots of padding:  Pad the first block to 64 bytes */
        memset(p, 0, count);
        byteReverse(ctx->in, 16);
-       MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in);
+       MD5Transform(ctx->buf, ctx->in);
 
        /* Now fill the next block with 56 bytes */
        memset(ctx->in, 0, 56);
@@ -336,7 +336,7 @@ void MD5Transform(cit_uint32_t buf[4], cit_uint32_t const in[16])
  * md5 string
  */
 
-char *make_apop_string(char *realpass, char *nonce, u_char *buffer)
+char *make_apop_string(char *realpass, char *nonce, char *buffer)
 {
    struct MD5Context ctx;
    u_char rawdigest[MD5_DIGEST_LEN];
@@ -344,9 +344,9 @@ char *make_apop_string(char *realpass, char *nonce, u_char *buffer)
    
    MD5Init(&ctx);
 //   printf("MD5@@: Adding nonce: %s\n", nonce);
-   MD5Update(&ctx, nonce, strlen(nonce));
+   MD5Update(&ctx, (u_char*)nonce, strlen(nonce));
 //   printf("MD5@@: Adding password %s\n", realpass);
-   MD5Update(&ctx, realpass, strlen(realpass));
+   MD5Update(&ctx, (u_char*)realpass, strlen(realpass));
    MD5Final(rawdigest, &ctx);
    for (i=0; i<MD5_DIGEST_LEN; i++)
    {
index f81237108d8f47d5ec7ca0c6f806e19eb8c4c2f4..64beb61881ae93ceb69e267fc7adb0871aef7c88 100644 (file)
@@ -6,7 +6,7 @@
 struct MD5Context {
        cit_uint32_t buf[4];
        cit_uint32_t bits[2];
-       unsigned char in[64];
+       cit_uint32_t in[16];
 };
 
 void MD5Init(struct MD5Context *context);
@@ -14,7 +14,7 @@ void MD5Update(struct MD5Context *context, unsigned char const *buf,
               unsigned len);
 void MD5Final(unsigned char digest[16], struct MD5Context *context);
 void MD5Transform(cit_uint32_t buf[4], cit_uint32_t const in[16]);
-char *make_apop_string(char *realpass, char *nonce, u_char *buffer);
+char *make_apop_string(char *realpass, char *nonce, char *buffer);
 
 /*
  * This is needed to make RSAREF happy on some MS-DOS compilers.
index fc7ecf00832c26744a6ec682ce1bf50d9f73bfd7..e5c1bcac02e760bf4d21ce666ad7492387a07016 100644 (file)
@@ -1709,7 +1709,7 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */
         */
        if (msg->cm_fields['T'] == NULL) {
                lprintf(9, "Generating timestamp\n");
-               sprintf(aaa, "%ld", time(NULL));
+               sprintf(aaa, "%ld", (long)time(NULL));
                msg->cm_fields['T'] = strdoop(aaa);
        }
 
@@ -1919,7 +1919,7 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */
                        "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
                        "bounceto|%s@%s\n"
                        "remote|%s|0||\n",
-                       SPOOLMIME, newmsgid, time(NULL),
+                       SPOOLMIME, newmsgid, (long)time(NULL),
                        msg->cm_fields['A'], msg->cm_fields['N'],
                        recipient );
 
@@ -2091,7 +2091,7 @@ static struct CtdlMessage *make_message(
        sprintf(buf, "cit%ld", author->usernum);                /* Path */
        msg->cm_fields['P'] = strdoop(buf);
 
-       sprintf(buf, "%ld", time(NULL));                        /* timestamp */
+       sprintf(buf, "%ld", (long)time(NULL));                  /* timestamp */
        msg->cm_fields['T'] = strdoop(buf);
 
        if (fake_name[0])                                       /* author */
@@ -2365,21 +2365,21 @@ void cmd_ent3(char *entargs)
 
        cprintf("%d %ld\n", SEND_BINARY, msglen);
 
-       client_read(&ch, 1);                            /* 0xFF magic number */
+       client_read((char*)&ch, 1);                             /* 0xFF magic number */
        msg->cm_magic = CTDLMESSAGE_MAGIC;
-       client_read(&ch, 1);                            /* anon type */
+       client_read((char*)&ch, 1);                             /* anon type */
        msg->cm_anon_type = ch;
-       client_read(&ch, 1);                            /* format type */
+       client_read((char*)&ch, 1);                             /* format type */
        msg->cm_format_type = ch;
        msglen = msglen - 3;
 
        while (msglen > 0) {
-               client_read(&which_field, 1);
+               client_read((char*)&which_field, 1);
                if (!isalpha(which_field)) valid_msg = 0;
                --msglen;
                tempbuf[0] = 0;
                do {
-                       client_read(&ch, 1);
+                       client_read((char*)&ch, 1);
                        --msglen;
                        a = strlen(tempbuf);
                        tempbuf[a+1] = 0;
index afe54a979099c22e2206c67a8146dd72a5b7033e..4ac4ce50f6b533917e221d7a96f27687dc9d8294 100644 (file)
 #include "user_ops.h"
 #include "room_ops.h"
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
 struct ChatLine *ChatQueue = NULL;
 int ChatLastMsg = 0;
 
index 2dd370bc3bfb4e62f78966f55b7886bb51578b61..37feb4079c198d6be6a93217795252b6c3df80cf 100644 (file)
 #include "clientsocket.h"
 #include "file_ops.h"
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
 
 /*
  * When we do network processing, it's accomplished in two passes; one to
@@ -167,7 +171,7 @@ int network_usetable(int operation, struct CtdlMessage *msg) {
                                        sprintf(&serialized_table[strlen(
                                          serialized_table)], "%s|%ld\n",
                                            ut->message_id,
-                                           ut->timestamp);
+                                           (long)ut->timestamp);
                                }
 
                                /* Now free the memory */
@@ -233,7 +237,7 @@ void write_network_map(void) {
                                sprintf(&serialized_map[strlen(serialized_map)],
                                        "%s|%ld|%s\n",
                                        nmptr->nodename,
-                                       nmptr->lastcontact,
+                                       (long)nmptr->lastcontact,
                                        nmptr->nexthop);
                        }
                }
@@ -442,7 +446,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                sprintf(instr,
                        "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
                        "bounceto|postmaster@%s\n" ,
-                       SPOOLMIME, msgnum, time(NULL), config.c_fqdn );
+                       SPOOLMIME, msgnum, (long)time(NULL), config.c_fqdn );
        
                /* Generate delivery instructions for each recipient */
                for (nptr = sc->listrecps; nptr != NULL; nptr = nptr->next) {
@@ -731,7 +735,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
                phree(msg->cm_fields['I']);
        }
        sprintf(buf, "%ld.%04x.%04x@%s",
-               time(NULL), getpid(), ++serialnum, config.c_fqdn);
+               (long)time(NULL), getpid(), ++serialnum, config.c_fqdn);
        msg->cm_fields['I'] = strdoop(buf);
 
        /*
index b79d4403023b9f522f9dbbe33418dd00f7128a92..2d3ef0ceb15cd629fba46c21ec2a5caab73b3803 100644 (file)
 #include "clientsocket.h"
 
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
 struct citsmtp {               /* Information about the current session */
        int command_state;
        char helo_node[SIZ];
index aa082b4451c9350eb0c45733f912ffad1528f78b..1a27cdf138c8977bd18d934d717fb72b0f640e8a 100644 (file)
@@ -1,3 +1,5 @@
 /* $Id$ */
+#ifndef __DECC
 int snprintf (char *buf, size_t max, const char *fmt, ...);
 int vsnprintf (char *buf, size_t max, const char *fmt, va_list argp);
+#endif
index f1c933f8e5dc6987dc605b177e3a1597a19d8c7e..86534cf078d9b916d07e4b99f689996f825ce8a6 100644 (file)
@@ -123,7 +123,7 @@ void lprintf(int loglevel, const char *format, ...) {
                fprintf(stderr, "%04d/%02d/%02d %2d:%02d:%02d.%03ld %s",
                        tim->tm_year + 1900, tim->tm_mon + 1, tim->tm_mday,
                        tim->tm_hour, tim->tm_min, tim->tm_sec,
-                       tv.tv_usec / 1000, buf);
+                       (long)tv.tv_usec / 1000, buf);
                fflush(stderr);
        }