* Bug fixes: Fix numerous char array size mismatches, signed/unsigned
authorMichael Hampton <io_error@uncensored.citadel.org>
Thu, 17 Oct 2002 12:56:44 +0000 (12:56 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Thu, 17 Oct 2002 12:56:44 +0000 (12:56 +0000)
  mismatches, and const correctness problems (though not nearly all)

21 files changed:
citadel/ChangeLog
citadel/citadel.c
citadel/citadel.h
citadel/citadel_decls.h
citadel/commands.c
citadel/commands.h
citadel/file_ops.c
citadel/md5.h
citadel/messages.c
citadel/msgbase.c
citadel/rooms.c
citadel/routines.c
citadel/routines.h
citadel/routines2.c
citadel/routines2.h
citadel/serv_upgrade.c
citadel/serv_upgrade.h
citadel/tools.c
citadel/tools.h
citadel/typesize.h
citadel/user_ops.c

index 8fad209e24b0b893c2ef66083823c6fa2097a644..2aae852e295daf767bd720653cb29d38fc7fd987 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 601.33  2002/10/17 12:56:44  error
+ * Bug fixes:  Fix numerous char array size mismatches, signed/unsigned
+   mismatches, and const correctness problems (though not nearly all)
+
  Revision 601.32  2002/10/17 11:13:27  error
  * Convert room listings and some aide functions to new IPC code
 
@@ -4093,3 +4097,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 8e68bd10a680841bca5afe22b01eb99a86e053d7..2c92308011abc4feb71a9fc4e807a23f790ac2f3 100644 (file)
@@ -68,7 +68,7 @@ char tempdir[PATH_MAX];               /* Name of general temp dir */
 char editor_path[SIZ];         /* path to external editor */
 char printcmd[SIZ];            /* print command */
 int editor_pid = (-1);
-char fullname[32];
+char fullname[USERNAME_SIZE];
 jmp_buf nextbuf;
 struct CtdlServInfo serv_info; /* Info on the server connected */
 int screenwidth;
@@ -91,7 +91,7 @@ long highest_msg_read;                /* used for <A>bandon room cmd */
 long maxmsgnum;                        /* used for <G>oto */
 char sigcaught = 0;
 char have_xterm = 0;           /* are we running on an xterm? */
-char rc_username[32];
+char rc_username[USERNAME_SIZE];
 char rc_password[32];
 char hostbuf[SIZ];
 char portbuf[SIZ];
index a9f09d724c3746a076ac1e4f8363b54cb92e4024..693d1cf472a8415435dd86fee2d1c39814711e8f 100644 (file)
@@ -13,6 +13,7 @@
 #include "sysdep.h"
 #include <limits.h>
 #include "sysconfig.h"
+#include "typesize.h"
 #include "ipcdef.h"
 
 #ifdef __cplusplus
@@ -48,15 +49,6 @@ extern "C" {
 #define tolower(x)     ( ((x>='A')&&(x<='Z')) ? (x+'a'-'A') : x )
 #define NEW_CONFIG
 
-/* 
- * The only typedef we do is an 8-bit unsigned, for screen dimensions.
- * All other defs are done using standard C types.  The code assumes that
- * 'int' 'unsigned' and 'short' are at least 16 bits, and that 'long' is at
- * least 32 bits.  There are no endian dependencies in any of the Citadel
- * programs.
- */
-typedef unsigned char CIT_UBYTE;
-
 /* Various length constants */
 
 #define UGLISTLEN   100   /* you get a ungoto list of this size */
@@ -66,7 +58,7 @@ typedef unsigned char CIT_UBYTE;
                                         * in the nonce, as per the APOP RFC.
                                         */
                                         
-#define USERNAME_SIZE  32              /* The size of a username string */
+#define USERNAME_SIZE  64              /* The size of a username string */
 
 /*
  * Message expiration policy stuff
@@ -156,13 +148,13 @@ struct usersupp {                 /* User record                      */
        unsigned flags;                 /* See US_ flags below              */
        long timescalled;               /* Total number of logins           */
        long posted;                    /* Number of messages posted (ever) */
-       CIT_UBYTE axlevel;              /* Access level                     */
+       cit_uint8_t axlevel;            /* Access level                     */
        long usernum;                   /* User number (never recycled)     */
        time_t lastcall;                /* Last time the user called        */
        int USuserpurge;                /* Purge time (in days) for user    */
        char fullname[64];              /* Name for Citadel messages & mail */
-       CIT_UBYTE USscreenwidth;        /* Screen width (for textmode users)*/
-       CIT_UBYTE USscreenheight;       /* Screen height(for textmode users)*/
+       cit_uint8_t USscreenwidth;      /* Screen width (for textmode users)*/
+       cit_uint8_t USscreenheight;     /* Screen height(for textmode users)*/
 };
 
 
index 371aa5de60ef98c2951458ae1c5f4be35c0a59c5..dc36d75096ae7a4f9408abf9b3dbd872a5b554fb 100644 (file)
@@ -1,5 +1,5 @@
 /* $Id$ */
-extern char fullname[32];
+extern char fullname[USERNAME_SIZE];
 extern unsigned room_flags;
 extern char room_name[ROOMNAMELEN];
 extern struct CtdlServInfo serv_info;
@@ -10,7 +10,7 @@ extern char sigcaught;
 extern char editor_path[SIZ];
 extern char printcmd[SIZ];
 extern char have_xterm;
-extern char rc_username[32];
+extern char rc_username[USERNAME_SIZE];
 extern char rc_password[32];
 extern char rc_floor_mode;
 extern time_t rc_idle_threshold;
index 49c0710c4c7ba06c2c68ba35c1e08c84bfbc85b2..4ae380c9433b67f7b8380affb7f0fc50f80d25e2 100644 (file)
@@ -142,7 +142,7 @@ char was_a_key_pressed(void) {
  * we are probably in the middle of a server operation and the NOOP command
  * would confuse everything.
  */
-int checkpagin(int lp, int pagin, int height)
+int checkpagin(int lp, unsigned int pagin, unsigned int height)
 {
        int thekey;
 
@@ -1192,8 +1192,8 @@ void sttybbs(int cmd)
                live.c_oflag = OPOST | ONLCR;
                live.c_lflag = ISIG | NOFLSH;
 
-               live.c_cc[VINTR] = (-1);
-               live.c_cc[VQUIT] = (-1);
+               live.c_cc[VINTR] = 0;
+               live.c_cc[VQUIT] = 0;
 
 #ifdef hpux
                live.c_cc[VMIN] = 0;
@@ -1269,7 +1269,7 @@ int fmout(
        char pagin,     /* nonzero if we should use the paginator */
        int height,     /* screen height to use */
        int starting_lp,/* starting value for lines_printed, -1 for global */
-       char subst)     /* nonzero if we should use hypertext mode */
+       int subst)      /* nonzero if we should use hypertext mode */
 {
        int a, b, c, old;
        int real = (-1);
index 6b15ddab94de9e602c1857a4c9cb65e5c8f40716..8a4180b841b893c66ec7468d407d49cfe6a8268f 100644 (file)
@@ -38,7 +38,7 @@ void strprompt(char *prompt, char *str, int len);
 int boolprompt(char *prompt, int prev_val);
 int intprompt(char *prompt, int ival, int imin, int imax);
 int fmout(int width, FILE *fpin, char *text, FILE *fpout, char pagin,
-               int height, int starting_lp, char subst);
+               int height, int starting_lp, int subst);
 int getcmd(CtdlIPC *ipc, char *argbuf);
 void display_help(CtdlIPC *ipc, char *name);
 void color(int colornum);
@@ -54,7 +54,7 @@ void keyopt(char *);
 char keymenu(char *menuprompt, char *menustring);
 void async_ka_start(void);
 void async_ka_end(void);
-int checkpagin(int lp, int pagin, int height);
+int checkpagin(int lp, unsigned int pagin, unsigned int height);
 char was_a_key_pressed(void);
 
 #ifdef __GNUC__
index a9de64ae65819f172536ede4bfde557d42c52a13..b016cba47131fecb7c79fa4c098ec702237ea89b 100644 (file)
@@ -393,7 +393,7 @@ void cmd_oimg(char *cmdbuf)
        char filename[SIZ];
        char pathname[SIZ];
        struct usersupp usbuf;
-       char which_user[32];
+       char which_user[USERNAME_SIZE];
        int which_floor;
        int a;
 
index 553196c77c0583c7320cfd691cc5c94c9a38e30d..f77e141b76876e9205903dc330836706d12402ae 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MD5_H
 #define MD5_H
 
+#include "sysdep.h"
 #include "typesize.h"
 
 struct MD5Context {
index b9655d3d3ad123a714d3bed30672062f89526d9b..34751004490381f12d99f35cf16475700e061e26 100644 (file)
@@ -60,9 +60,9 @@ int haschar(const char *st, int ch);
 void getline(char *string, int lim);
 int file_checksum(char *filename);
 void do_edit(char *desc, char *read_cmd, char *check_cmd, char *write_cmd);
-void progress(long int curr, long int cmax);
+void progress(unsigned long curr, unsigned long cmax);
 
-long *msg_arr = NULL;
+unsigned long *msg_arr = NULL;
 int msg_arr_size = 0;
 int num_msgs;
 char rc_alt_semantics;
@@ -352,7 +352,7 @@ void citedit(CtdlIPC *ipc, FILE * fp)
  */
 int read_message(CtdlIPC *ipc,
        long num,   /* message number */
-       char pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */
+       int pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */
        FILE *dest) /* Destination file, NULL for screen */
 {
        char buf[SIZ];
@@ -1550,7 +1550,7 @@ RMSGREAD: scr_flush();
                                scr_printf("%s\n", cmd);
                        } else {
                                save_buffer(attachment,
-                                               extract_long(cmd, 0),
+                                               extract_unsigned_long(cmd, 0),
                                                save_to);
                        }
                        if (attachment) free(attachment);
index afa4d455435832b874ad2b35d6552484eca09ede..98563d64e66b6d3ac47bf49354a74b17aa59e42c 100644 (file)
@@ -624,7 +624,7 @@ void memfmout(
        int a, b, c;
        int real = 0;
        int old = 0;
-       CIT_UBYTE ch;
+       cit_uint8_t ch;
        char aaa[140];
        char buffer[SIZ];
 
@@ -770,8 +770,8 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum)
        struct cdbdata *dmsgtext;
        struct CtdlMessage *ret = NULL;
        char *mptr;
-       CIT_UBYTE ch;
-       CIT_UBYTE field_header;
+       cit_uint8_t ch;
+       cit_uint8_t field_header;
        size_t field_length;
 
        dmsgtext = cdb_fetch(CDB_MSGMAIN, &msgnum, sizeof(long));
@@ -1089,7 +1089,7 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
 ) {
        int i, k;
        char buf[1024];
-       CIT_UBYTE ch;
+       cit_uint8_t ch;
        char allkeys[SIZ];
        char display_name[SIZ];
        char *mptr;
index 51613ab378dc9928235272126e6b5dd84d5f6aad..84a4ee23e1401f2a19f9ff70264236d7b445970a 100644 (file)
@@ -37,7 +37,7 @@
 void sttybbs(int cmd);
 void hit_any_key(void);
 void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto);
-void progress(long int curr, long int cmax);
+void progress(unsigned long curr, unsigned long cmax);
 int pattern(char *search, char *patn);
 int file_checksum(char *filename);
 int nukedir(char *dirname);
@@ -305,7 +305,7 @@ void listzrooms(CtdlIPC *ipc)
 }
 
 
-int set_room_attr(CtdlIPC *ipc, int ibuf, char *prompt, unsigned int sbit)
+int set_room_attr(CtdlIPC *ipc, unsigned int ibuf, char *prompt, unsigned int sbit)
 {
        int a;
 
@@ -377,7 +377,7 @@ int select_floor(CtdlIPC *ipc, int rfloor)
 void editthisroom(CtdlIPC *ipc)
 {
        int rbump = 0;
-       char raide[32];
+       char raide[USERNAME_SIZE];
        char buf[SIZ];
        struct quickroom *attr = NULL;
        struct ExpirePolicy *eptr = NULL;
@@ -635,7 +635,7 @@ void download(CtdlIPC *ipc, int proto)
        int broken = 0;
        int r;
        void *file = NULL;      /* The downloaded file */
-       long filelen = 0L;      /* The downloaded file length */
+       size_t filelen = 0L;    /* The downloaded file length */
 
        if ((room_flags & QR_DOWNLOAD) == 0) {
                scr_printf("*** You cannot download from this room.\n");
@@ -652,7 +652,7 @@ void download(CtdlIPC *ipc, int proto)
                        scr_printf("%s\n", buf);
                        return;
                }
-               save_buffer(file, extract_long(buf, 0), tempname);
+               save_buffer(file, (size_t)extract_long(buf, 0), tempname);
                free(file);
                return;
        }
@@ -662,7 +662,7 @@ void download(CtdlIPC *ipc, int proto)
                scr_printf("%s\n", buf);
                return;
        }
-       filelen = extract_long(buf, 0);
+       filelen = extract_unsigned_long(buf, 0);
 
        /* Meta-download for public clients */
        /* scr_printf("Fetching file from Citadel server...\n"); */
@@ -670,6 +670,7 @@ void download(CtdlIPC *ipc, int proto)
        snprintf(tempname, sizeof tempname, "%s/%s", tempdir, filename);
        tpipe = fopen(tempname, "wb");
        if (fwrite(file, filelen, 1, tpipe) < filelen) {
+               /* FIXME: restart syscall on EINTR */
                broken = 1;
        }
        fclose(tpipe);
index 89de17cbd20357a8544122698d6059793507cb08..15f954d36802391e3849b52df54459c80a4e171d 100644 (file)
@@ -159,7 +159,7 @@ void edituser(CtdlIPC *ipc)
  * yes or no.  Yes=1 and No=0, unless 'backwards' is set to a nonzero value
  * in which case No=1 and Yes=0.
  */
-int set_attr(CtdlIPC *ipc, int sval, char *prompt, unsigned int sbit, int backwards)
+int set_attr(CtdlIPC *ipc, unsigned int sval, char *prompt, unsigned int sbit, int backwards)
 {
        int a;
        int temp;
@@ -388,13 +388,13 @@ char *strerror(int e)
 #endif
 
 
-void progress(long int curr, long int cmax)
+void progress(unsigned long curr, unsigned long cmax)
 {
        static char dots[] =
                "**************************************************";
        char dots_printed[51];
        char fmt[42];
-       long a;
+       unsigned long a;
 
        if (curr >= cmax) {
                sln_printf("\r%79s\r","");
index 10b49f412d208dc85e0f1ec0d94efccfa27d6975..986d928cd64aaa4d0ef5c50b8ae67a510fc735b1 100644 (file)
@@ -10,4 +10,4 @@ int nukedir(char *dirname);
 int num_parms(char *source);
 void strproc(char *string);
 void back(int spaces);
-void progress(long int curr, long int cmax);
+void progress(unsigned long curr, unsigned long cmax);
index f851e3df450c6c9e491f3188dd139cbf734eace2..d8076dc21a30a75ae33a54608aa5dc61d264efba 100644 (file)
@@ -69,7 +69,7 @@ int eopen(char *name, int mode)
 */
 
 
-int room_prompt(int qrflags)
+int room_prompt(unsigned int qrflags)
 {                              /* return proper room prompt character */
        int a;
        a = '>';
index adc217a6b0b9ae217d9d751c085f2cc3d57e28b2..12204a526ec18930ac7d904b25f6265a80e4e852 100644 (file)
@@ -11,7 +11,7 @@ void cli_upload(CtdlIPC *ipc);
 void validate(CtdlIPC *ipc);
 void read_bio(CtdlIPC *ipc);
 void cli_image_upload(CtdlIPC *ipc, char *keyname);
-int room_prompt(int qrflags);
+int room_prompt(unsigned int qrflags);
 void do_internet_configuration(CtdlIPC *ipc);
 void do_ignet_configuration(CtdlIPC *ipc);
 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment);
index 01e0e53f5058722eb587dabbe1c3e47ffde675fe..0f2686da319796281565920e51b82f2a872d963a 100644 (file)
@@ -83,13 +83,13 @@ void do_pre555_usersupp_upgrade(void) {
                newus.flags = usbuf.flags;
                newus.timescalled = (long) usbuf.timescalled;
                newus.posted = (long) usbuf.posted;
-               newus.axlevel = (CIT_UBYTE) usbuf.axlevel;
+               newus.axlevel = (cit_uint8_t) usbuf.axlevel;
                newus.usernum = (long) usbuf.usernum;
                newus.lastcall = (long) usbuf.lastcall;
                newus.USuserpurge = (int) usbuf.USuserpurge;
                strcpy(newus.fullname, usbuf.fullname);
-               newus.USscreenwidth = (CIT_UBYTE) usbuf.USscreenwidth;
-               newus.USscreenheight = (CIT_UBYTE) usbuf.USscreenheight;
+               newus.USscreenwidth = (cit_uint8_t) usbuf.USscreenwidth;
+               newus.USscreenheight = (cit_uint8_t) usbuf.USscreenheight;
 
                putuser(&newus);
 
index 2895dbf7390183e54641ab4dfd34050480609d76..ebac97e4e5d096bd942adfa9b539b91b9c2473a3 100644 (file)
@@ -14,8 +14,8 @@ struct pre555usersupp {                       /* User record                      */
        int posted;                     /* Number of messages posted (ever) */
        char fullname[26];              /* Name for Citadel messages & mail */
        char axlevel;                   /* Access level                     */
-       CIT_UBYTE USscreenwidth;        /* Screen width (for textmode users)*/
-       CIT_UBYTE USscreenheight;       /* Screen height(for textmode users)*/
+       cit_uint8_t USscreenwidth;      /* Screen width (for textmode users)*/
+       cit_uint8_t USscreenheight;     /* Screen height(for textmode users)*/
        long usernum;                   /* User number (never recycled)     */
        time_t lastcall;                /* Last time the user called        */
        char USname[30];                /*                                  */
index 64e790c881a76aca24d709149367efbdc83a13d3..c4a3ca4307c4015b16f442f6d54622e3594cb521 100644 (file)
@@ -74,7 +74,7 @@ int strncasecmp(char *lstr, char *rstr, int len)
 /*
  * num_tokens()  -  discover number of parameters/tokens in a string
  */
-int num_tokens(char *source, char tok) {
+int num_tokens(const char *source, char tok) {
        int a;
        int count = 1;
 
@@ -87,9 +87,10 @@ int num_tokens(char *source, char tok) {
 
 
 /* extract_token_fast() - a smarter string tokenizer */
-void extract_token(char *dest, char *source, int parmnum, char separator)
+void extract_token(char *dest, const char *source, unsigned long parmnum, char separator)
 {
-       char *d, *s;            /* dest, source */
+       char *d;                /* dest */
+       const char *s;          /* source */
        int count = 0;
 
        strcpy(dest, "");
@@ -119,7 +120,7 @@ void extract_token(char *dest, char *source, int parmnum, char separator)
 /*
  * extract_token()  -  a smarter string tokenizer
  */
-void extract_token_old(char *dest, char *source, int parmnum, char separator) 
+void extract_token_old(char *dest, const char *source, unsigned long parmnum, char separator) 
 {
        int i;
        int len;
@@ -131,7 +132,7 @@ void extract_token_old(char *dest, char *source, int parmnum, char separator)
 
        if (strlen(source)==0) {
                return;
-               }
+       }
 
        for (i=0; i<strlen(source); ++i) {
                if (source[i]==separator) {
@@ -147,7 +148,7 @@ void extract_token_old(char *dest, char *source, int parmnum, char separator)
 
 
 /* remove_token_fast() - a tokenizer that kills, maims, and destroys fast */
-void remove_token(char *source, int parmnum, char separator)
+void remove_token(char *source, unsigned long parmnum, char separator)
 {
        char *d, *s;            /* dest, source */
        int count = 0;
@@ -206,7 +207,7 @@ void remove_token_old(char *source, int parmnum, char separator)
 
        if (strlen(source)==0) {
                return;
-               }
+       }
 
        for (i=0; i<strlen(source); ++i) {
                if ( (start < 0) && (curr_parm == parmnum) ) {
@@ -232,7 +233,7 @@ void remove_token_old(char *source, int parmnum, char separator)
 /*
  * extract_int()  -  extract an int parm w/o supplying a buffer
  */
-int extract_int(char *source, int parmnum)
+int extract_int(const char *source, unsigned long parmnum)
 {
        char buf[SIZ];
        
@@ -243,7 +244,7 @@ int extract_int(char *source, int parmnum)
 /*
  * extract_long()  -  extract an long parm w/o supplying a buffer
  */
-long extract_long(char *source, long int parmnum)
+long extract_long(const char *source, unsigned long parmnum)
 {
        char buf[SIZ];
        
@@ -252,6 +253,17 @@ long extract_long(char *source, long int parmnum)
 }
 
 
+/*
+ * extract_unsigned_long() - extract an unsigned long parm
+ */
+unsigned long extract_unsigned_long(const char *source, unsigned long parmnum)
+{
+       char buf[SIZ];
+
+       extract_token(buf, source, parmnum, '|');
+       return strtoul(buf, NULL, 10);
+}
+
 
 /*
  * CtdlDecodeBase64() and CtdlEncodeBase64() are adaptations of code by
@@ -260,7 +272,7 @@ long extract_long(char *source, long int parmnum)
  * the separate executables, and using the ones in our code exclusively.
  */
 
-void CtdlEncodeBase64(char *dest, char *source, int sourcelen)
+void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen)
 {
     int i, hiteof = FALSE;
     int spos = 0;
@@ -320,7 +332,7 @@ void CtdlEncodeBase64(char *dest, char *source, int sourcelen)
  * Convert base64-encoded to binary.  Returns the length of the decoded data.
  * It will stop after reading 'length' bytes.
  */
-int CtdlDecodeBase64(char *dest, char *source, size_t length)
+int CtdlDecodeBase64(char *dest, const char *source, size_t length)
 {
     int i, c;
     int dpos = 0;
index 7e199a191f6d8650b7ee88b7ccb860b87cd6acbc..1c6320a73e679db3aa61632c82f433ae4d98d87c 100644 (file)
@@ -1,15 +1,16 @@
 /* $Id$ */
 char *safestrncpy(char *dest, const char *src, size_t n);
-int num_tokens (char *source, char tok);
-void extract_token(char *dest, char *source, int parmnum, char separator);
-int extract_int (char *source, int parmnum);
-long int extract_long (char *source, long int parmnum);
-void CtdlEncodeBase64(char *dest, char *source, int sourcelen);
-int CtdlDecodeBase64(char *dest, char *source, size_t length);
+int num_tokens (const char *source, char tok);
+void extract_token(char *dest, const char *source, unsigned long parmnum, char separator);
+int extract_int (const char *source, unsigned long parmnum);
+long extract_long (const char *source, unsigned long parmnum);
+unsigned long extract_unsigned_long(const char *source, unsigned long parmnum);
+void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen);
+int CtdlDecodeBase64(char *dest, const char *source, size_t length);
 void striplt(char *);
 int haschar(const char *st, int ch);
 int collapsed_strcmp(char *s1, char *s2);
-void remove_token(char *source, int parmnum, char separator);
+void remove_token(char *source, unsigned long parmnum, char separator);
 void fmt_date(char *buf, size_t n, time_t thetime, int seconds);
 int is_msg_in_mset(char *mset, long msgnum);
 char *memreadline(char *start, char *buf, int maxlen);
index 00b4987c62c21f6ce9a4db4580668a3a2661a905..4298082f47d07217058a266ad891cc1cb5eff4c1 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$ */
 
 /*
-   This file defines macros for 8, 16, and 32 bit integers.  The macros are:
+   This file defines typedefs for 8, 16, and 32 bit integers.  They are:
    cit_int8_t  default 8-bit int
    cit_int16_t default 16-bit int
    cit_int32_t default 32-bit int
@@ -17,8 +17,8 @@
 
    The sizes are determined during the configure process; see the 
    AC_CHECK_SIZEOF macros in configure.in.  In no way do we assume that any
-   given datatype is any particular width, e.g. we don't assume char is one
-   byte; we check for it specifically.
+   given datatype is any particular width, e.g. we don't assume short is two
+   bytes; we check for it specifically.
 
    This might seem excessively paranoid, but I've seen some WEIRD systems
    and some bizarre compilers (Domain/OS for instance) in my time.
 # include "sysdep.h"
 #endif
 
-/* 8-bit */
+/* 8-bit - If this fails, your compiler is broken */
 #if SIZEOF_CHAR == 1
-# define cit_int8_t    char
-#elif SIZEOF_SHORT == 1
-# define cit_int8_t    short
+typedef char cit_int8_t;
+typedef signed char cit_sint8_t;
+typedef unsigned char cit_uint8_t;
 #else
 # error Unable to find an 8-bit integer datatype
 #endif
 
-/* 16-bit */
+/* 16-bit - If this fails, your compiler is broken */
 #if SIZEOF_SHORT == 2
-# define cit_int16_t   short
+typedef short cit_int16_t;
+typedef signed short cit_sint16_t;
+typedef unsigned short cit_uint16_t;
 #elif SIZEOF_INT == 2
-# define cit_int16_t   int
-#elif SIZEOF_CHAR == 2
-# define cit_int16_t   char
+typedef int cit_int16_t;
+typedef signed int cit_sint16_t;
+typedef unsigned int cit_uint16_t;
 #else
 # error Unable to find a 16-bit integer datatype
 #endif
 
-/* 32-bit */
+/* 32-bit - If this fails, your compiler is broken */
 #if SIZEOF_INT == 4
-# define cit_int32_t   int
-#elif SIZEOF_SHORT == 4
-# define cit_int32_t   short
+typedef int cit_int32_t;
+typedef signed int cit_sint32_t;
+typedef unsigned int cit_uint32_t;
 #elif SIZEOF_LONG == 4
-# define cit_int32_t   long
+typedef long cit_int32_t;
+typedef signed long cit_sint32_t;
+typedef unsigned long cit_uint32_t;
 #else
 # error Unable to find a 32-bit integer datatype
 #endif
 
-/* signed */
-#define cit_sint8_t    signed cit_int8_t
-#define cit_sint16_t   signed cit_int16_t
-#define cit_sint32_t   signed cit_int32_t
-
-/* unsigned */
-#define cit_uint8_t    unsigned cit_int8_t
-#define cit_uint16_t   unsigned cit_int16_t
-#define cit_uint32_t   unsigned cit_int32_t
-
 #endif /* _CITADEL_UX_TYPESIZE_H */
index 9b809fdf664a07728c3b8cac5ba7c0e65ade9b74..4e0146df8a809673c59c151e89daa9abce3473f7 100644 (file)
@@ -61,7 +61,7 @@
 int getuser(struct usersupp *usbuf, char name[])
 {
 
-       char lowercase_name[32];
+       char lowercase_name[USERNAME_SIZE];
        int a;
        struct cdbdata *cdbus;
 
@@ -105,7 +105,7 @@ int lgetuser(struct usersupp *usbuf, char *name)
  */
 void putuser(struct usersupp *usbuf)
 {
-       char lowercase_name[32];
+       char lowercase_name[USERNAME_SIZE];
        int a;
 
        for (a = 0; a <= strlen(usbuf->fullname); ++a) {
@@ -621,7 +621,7 @@ int purge_user(char pname[])
 {
        char filename[64];
        struct usersupp usbuf;
-       char lowercase_name[32];
+       char lowercase_name[USERNAME_SIZE];
        int a;
        struct CitContext *ccptr;
        int user_is_logged_in = 0;