$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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
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;
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];
#include "sysdep.h"
#include <limits.h>
#include "sysconfig.h"
+#include "typesize.h"
#include "ipcdef.h"
#ifdef __cplusplus
#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 */
* 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
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)*/
};
/* $Id$ */
-extern char fullname[32];
+extern char fullname[USERNAME_SIZE];
extern unsigned room_flags;
extern char room_name[ROOMNAMELEN];
extern struct CtdlServInfo serv_info;
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;
* 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;
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;
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);
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);
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__
char filename[SIZ];
char pathname[SIZ];
struct usersupp usbuf;
- char which_user[32];
+ char which_user[USERNAME_SIZE];
int which_floor;
int a;
#ifndef MD5_H
#define MD5_H
+#include "sysdep.h"
#include "typesize.h"
struct MD5Context {
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;
*/
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];
scr_printf("%s\n", cmd);
} else {
save_buffer(attachment,
- extract_long(cmd, 0),
+ extract_unsigned_long(cmd, 0),
save_to);
}
if (attachment) free(attachment);
int a, b, c;
int real = 0;
int old = 0;
- CIT_UBYTE ch;
+ cit_uint8_t ch;
char aaa[140];
char buffer[SIZ];
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));
) {
int i, k;
char buf[1024];
- CIT_UBYTE ch;
+ cit_uint8_t ch;
char allkeys[SIZ];
char display_name[SIZ];
char *mptr;
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);
}
-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;
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;
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");
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;
}
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"); */
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);
* 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;
#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","");
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);
*/
-int room_prompt(int qrflags)
+int room_prompt(unsigned int qrflags)
{ /* return proper room prompt character */
int a;
a = '>';
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);
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);
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]; /* */
/*
* 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;
/* 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, "");
/*
* 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;
if (strlen(source)==0) {
return;
- }
+ }
for (i=0; i<strlen(source); ++i) {
if (source[i]==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;
if (strlen(source)==0) {
return;
- }
+ }
for (i=0; i<strlen(source); ++i) {
if ( (start < 0) && (curr_parm == parmnum) ) {
/*
* 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];
/*
* 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];
}
+/*
+ * 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
* 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;
* 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;
/* $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);
/* $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
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 */
int getuser(struct usersupp *usbuf, char name[])
{
- char lowercase_name[32];
+ char lowercase_name[USERNAME_SIZE];
int a;
struct cdbdata *cdbus;
*/
void putuser(struct usersupp *usbuf)
{
- char lowercase_name[32];
+ char lowercase_name[USERNAME_SIZE];
int a;
for (a = 0; a <= strlen(usbuf->fullname); ++a) {
{
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;