Commit c5e716b0 authored by deuce's avatar deuce

Fix new GNU C++ warning: deprecated conversion from string constant to 'char*'

by properly const-ifying the appropriate functions and variables.

Not yet tested on Win32
parent 3670cb20
......@@ -73,7 +73,7 @@ uint16_t crc16tbl[] = {
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
uint16_t crc16(char* data, unsigned long len)
uint16_t crc16(const char* data, unsigned long len)
{
uint16_t crc = 0;
unsigned long l;
......
......@@ -46,7 +46,7 @@ extern "C" {
extern uint16_t crc16tbl[];
uint16_t crc16(char* data, unsigned long len);
uint16_t crc16(const char* data, unsigned long len);
#ifdef __cplusplus
}
......
......@@ -78,7 +78,7 @@ int32_t crc32tbl[]={ /* CRC polynomial 0xedb88320 */
/* Pass len of 0 to auto-determine ASCIIZ string length */
/* or non-zero for arbitrary binary data */
/****************************************************************************/
uint32_t crc32i(uint32_t crc, char *buf, unsigned long len)
uint32_t crc32i(uint32_t crc, const char *buf, unsigned long len)
{
unsigned long l;
......
......@@ -47,7 +47,7 @@ extern "C" {
extern int32_t crc32tbl[];
uint32_t crc32i(uint32_t crc, char* buf, unsigned long len);
uint32_t crc32i(uint32_t crc, const char* buf, unsigned long len);
uint32_t fcrc32(FILE* fp, unsigned long len);
#ifdef __cplusplus
......
......@@ -66,7 +66,7 @@ char lib[LEN_GSNAME+1];
/****************************************************************************/
/* This is needed by load_cfg.c */
/****************************************************************************/
int lprintf(int level, char *fmat, ...)
int lprintf(int level, const char *fmat, ...)
{
va_list argptr;
char sbuf[512];
......
......@@ -44,7 +44,7 @@
/* high intensity colors, or background/forground cobinations don't work. */
/* A call to attr is more appropriate, being it is intelligent */
/****************************************************************************/
char *sbbs_t::ansi(int atr)
const char *sbbs_t::ansi(int atr)
{
switch(atr) {
......
......@@ -48,13 +48,14 @@
/****************************************************************************/
/* Returns 0 if invalid @ code. Returns length of @ code if valid. */
/****************************************************************************/
int sbbs_t::show_atcode(char *instr)
int sbbs_t::show_atcode(const char *instr)
{
char str[128],str2[128],*p,*tp,*sp;
char str[128],str2[128],*tp,*sp,*p;
int len;
int disp_len;
bool padded_left=false;
bool padded_right=false;
const char *cp;
sprintf(str,"%.80s",instr);
tp=strchr(str+1,'@');
......@@ -78,21 +79,21 @@ int sbbs_t::show_atcode(char *instr)
*p=0;
}
p=atcode(sp,str2,sizeof(str2));
if(p==NULL)
cp=atcode(sp,str2,sizeof(str2));
if(cp==NULL)
return(0);
if(padded_left)
rprintf("%-*.*s",disp_len,disp_len,p);
rprintf("%-*.*s",disp_len,disp_len,cp);
else if(padded_right)
rprintf("%*.*s",disp_len,disp_len,p);
rprintf("%*.*s",disp_len,disp_len,cp);
else
rputs(p);
rputs(cp);
return(len);
}
char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
{
char* tp;
uint i;
......
......@@ -37,7 +37,7 @@
#include "sbbs.h"
bool sbbs_t::ar_exp(uchar **ptrptr, user_t* user)
bool sbbs_t::ar_exp(const uchar **ptrptr, user_t* user)
{
bool result,_not,_or,equal;
uint i,n,artype,age;
......@@ -582,9 +582,9 @@ bool sbbs_t::ar_exp(uchar **ptrptr, user_t* user)
return(result);
}
bool sbbs_t::chk_ar(uchar *ar, user_t* user)
bool sbbs_t::chk_ar(const uchar *ar, user_t* user)
{
uchar *p;
const uchar *p;
if(ar==NULL)
return(true);
......
......@@ -49,7 +49,7 @@ typedef struct {
WORD port; /* TCP port number */
time_t time; /* connect time */
const char* protocol; /* protocol description */
char* user; /* user name */
const char* user; /* user name */
char pad[32]; /* padding for future expansion */
} client_t;
......
......@@ -69,7 +69,7 @@ void sbbs_t::redrwstr(char *strin, int i, int l, long mode)
}
int sbbs_t::uselect(int add, uint n, char *title, char *item, uchar *ar)
int sbbs_t::uselect(int add, uint n, const char *title, const char *item, const uchar *ar)
{
char str[128];
int i;
......
......@@ -71,7 +71,7 @@ char* DLLCALL ascii_str(uchar* str)
/* Outputs a NULL terminated string locally and remotely (if applicable) */
/* Handles ctrl-a characters */
/****************************************************************************/
int sbbs_t::bputs(char *str)
int sbbs_t::bputs(const char *str)
{
int i;
ulong l=0;
......@@ -115,7 +115,7 @@ int sbbs_t::bputs(char *str)
/* Does not expand ctrl-a characters (raw) */
/* Max length of str is 64 kbytes */
/****************************************************************************/
int sbbs_t::rputs(char *str)
int sbbs_t::rputs(const char *str)
{
ulong l=0;
......@@ -130,7 +130,7 @@ int sbbs_t::rputs(char *str)
/****************************************************************************/
/* Performs printf() using bbs bputs function */
/****************************************************************************/
int sbbs_t::bprintf(char *fmt, ...)
int sbbs_t::bprintf(const char *fmt, ...)
{
va_list argptr;
char sbuf[4096];
......@@ -147,7 +147,7 @@ int sbbs_t::bprintf(char *fmt, ...)
/****************************************************************************/
/* Performs printf() using bbs rputs function */
/****************************************************************************/
int sbbs_t::rprintf(char *fmt, ...)
int sbbs_t::rprintf(const char *fmt, ...)
{
va_list argptr;
char sbuf[4096];
......
......@@ -254,7 +254,7 @@ static void client_on(void* p, BOOL on, int sock, client_t* client, BOOL update)
ReleaseMutex(ClientForm->ListMutex);
}
static int bbs_lputs(void* p, int level, char *str)
static int bbs_lputs(void* p, int level, const char *str)
{
static HANDLE mutex;
......@@ -272,7 +272,7 @@ static int bbs_lputs(void* p, int level, char *str)
return(Line.Length());
}
static void bbs_status(void* p, char *str)
static void bbs_status(void* p, const char *str)
{
static HANDLE mutex;
......@@ -341,7 +341,7 @@ static void bbs_start(void)
Application->ProcessMessages();
}
static int event_lputs(int level, char *str)
static int event_lputs(int level, const char *str)
{
static HANDLE mutex;
......@@ -359,7 +359,7 @@ static int event_lputs(int level, char *str)
return(Line.Length());
}
static int service_lputs(void* p, int level, char *str)
static int service_lputs(void* p, int level, const char *str)
{
static HANDLE mutex;
......@@ -377,7 +377,7 @@ static int service_lputs(void* p, int level, char *str)
return(Line.Length());
}
static void services_status(void* p, char *str)
static void services_status(void* p, const char *str)
{
static HANDLE mutex;
......@@ -411,7 +411,7 @@ static void services_clients(void* p, int clients)
{
}
static int mail_lputs(void* p, int level, char *str)
static int mail_lputs(void* p, int level, const char *str)
{
static HANDLE mutex;
static FILE* LogStream;
......@@ -463,7 +463,7 @@ static int mail_lputs(void* p, int level, char *str)
return(Line.Length());
}
static void mail_status(void* p, char *str)
static void mail_status(void* p, const char *str)
{
static HANDLE mutex;
......@@ -527,7 +527,7 @@ static void mail_start(void)
Application->ProcessMessages();
}
static int ftp_lputs(void* p, int level, char *str)
static int ftp_lputs(void* p, int level, const char *str)
{
static HANDLE mutex;
static FILE* LogStream;
......@@ -580,7 +580,7 @@ static int ftp_lputs(void* p, int level, char *str)
return(Line.Length());
}
static void ftp_status(void* p, char *str)
static void ftp_status(void* p, const char *str)
{
static HANDLE mutex;
......@@ -644,7 +644,7 @@ static void ftp_start(void)
Application->ProcessMessages();
}
//---------------------------------------------------------------------------
static int web_lputs(void* p, int level, char *str)
static int web_lputs(void* p, int level, const char *str)
{
static HANDLE mutex;
static FILE* LogStream;
......@@ -697,7 +697,7 @@ static int web_lputs(void* p, int level, char *str)
return(Line.Length());
}
static void web_status(void* p, char *str)
static void web_status(void* p, const char *str)
{
static HANDLE mutex;
......
......@@ -41,7 +41,7 @@
/* Places into 'strout' CR or ETX terminated string starting at */
/* 'start' and ending at 'start'+'length' or terminator from 'strin' */
/****************************************************************************/
void DLLCALL getrec(char *strin,int start,int length,char *strout)
void DLLCALL getrec(const char *strin,int start,int length,char *strout)
{
int i=0,stop;
......
......@@ -65,7 +65,7 @@
extern "C" {
#endif
DLLEXPORT void DLLCALL getrec(char *instr,int start,int length,char *outstr); /* Retrieve a record from a string */
DLLEXPORT void DLLCALL getrec(const char *instr,int start,int length,char *outstr); /* Retrieve a record from a string */
DLLEXPORT void DLLCALL putrec(char *outstr,int start,int length,char *instr); /* Place a record into a string */
#ifdef __cplusplus
......
......@@ -73,7 +73,7 @@ long lputs(char *str)
/* Performs printf() through local assembly routines */
/* Called from everywhere */
/****************************************************************************/
int lprintf(char *fmat, ...)
int lprintf(const char *fmat, ...)
{
va_list argptr;
char sbuf[256];
......
......@@ -171,7 +171,7 @@ void sbbs_t::notdownloaded(ulong size, time_t start, time_t end)
}
}
char* sbbs_t::protcmdline(prot_t* prot, enum XFER_TYPE type)
const char* sbbs_t::protcmdline(prot_t* prot, enum XFER_TYPE type)
{
switch(type) {
case XFER_UPLOAD:
......
......@@ -31,7 +31,7 @@ return(fputs(tmp,stderr));
/* Performs printf() through local assembly routines */
/* Called from everywhere */
/****************************************************************************/
int lprintf(char *fmat, ...)
int lprintf(const char *fmat, ...)
{
va_list argptr;
char sbuf[256];
......
......@@ -43,7 +43,7 @@
/* of message. */
/* Called from functions main_sec, newuser, readmail and scanposts */
/****************************************************************************/
bool sbbs_t::email(int usernumber, char *top, char *subj, long mode)
bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
{
char str[256],str2[256],msgpath[256],title[LEN_TITLE+1],ch
,buf[SDT_BLOCK_LEN];
......
......@@ -450,7 +450,7 @@ int sbbs_t::exec_net(csi_t* csi)
}
/* FTP Command/Response function */
bool sbbs_t::ftp_cmd(csi_t* csi, SOCKET sock, char* cmdsrc, char* rsp)
bool sbbs_t::ftp_cmd(csi_t* csi, SOCKET sock, const char* cmdsrc, char* rsp)
{
char cmd[512];
int len;
......
......@@ -96,7 +96,7 @@ bool sbbs_t::lookup_netuser(char *into)
/****************************************************************************/
/* Send FidoNet/QWK/Internet NetMail from BBS */
/****************************************************************************/
bool sbbs_t::netmail(char *into, char *title, long mode)
bool sbbs_t::netmail(const char *into, const char *title, long mode)
{
char str[256],subj[128],to[256],fname[128],*buf,*p,ch;
char tmp[512];
......
......@@ -239,7 +239,7 @@ char * sbbs_t::getfilespec(char *str)
/****************************************************************************/
/* Checks to see if filename matches filespec. Returns 1 if yes, 0 if no */
/****************************************************************************/
extern "C" BOOL filematch(char *filename, char *filespec)
extern "C" BOOL filematch(const char *filename, const char *filespec)
{
char c;
......
......@@ -531,7 +531,7 @@ BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename)
/****************************************************************************/
/* Turns FILE.EXT into FILE .EXT */
/****************************************************************************/
char* DLLCALL padfname(char *filename, char *str)
char* DLLCALL padfname(const char *filename, char *str)
{
int c,d;
......@@ -558,7 +558,7 @@ char* DLLCALL padfname(char *filename, char *str)
/****************************************************************************/
/* Turns FILE .EXT into FILE.EXT */
/****************************************************************************/
char* DLLCALL unpadfname(char *filename, char *str)
char* DLLCALL unpadfname(const char *filename, char *str)
{
int c,d;
......
......@@ -49,7 +49,7 @@ char *crlf="\r\n";
/****************************************************************************/
/****************************************************************************/
int lprintf(int level, char *fmat, ...)
int lprintf(int level, const char *fmat, ...)
{
va_list argptr;
char sbuf[256];
......
......@@ -126,7 +126,7 @@ BOOL dir_op(scfg_t* cfg, user_t* user, uint dirnum)
|| (cfg->dir[dirnum]->op_ar[0] && chk_ar(cfg,cfg->dir[dirnum]->op_ar,user)));
}
static int lprintf(int level, char *fmt, ...)
static int lprintf(int level, const char *fmt, ...)
{
int result;
va_list argptr;
......
......@@ -57,8 +57,8 @@ typedef struct {
void* cbdata; /* Private data passed to callbacks */
/* Callbacks (NULL if unused) */
int (*lputs)(void*, int, char*);
void (*status)(void*, char*);
int (*lputs)(void*, int, const char*);
void (*status)(void*, const char*);
void (*started)(void*);
void (*recycle)(void*);
void (*terminated)(void*, int code);
......
......@@ -299,7 +299,7 @@ char sbbs_t::getkey(long mode)
/****************************************************************************/
/* Outputs a string highlighting characters preceeded by a tilde */
/****************************************************************************/
void sbbs_t::mnemonics(char *str)
void sbbs_t::mnemonics(const char *str)
{
char *ctrl_a_codes;
long l;
......@@ -351,7 +351,7 @@ void sbbs_t::mnemonics(char *str)
/* Returns 1 for Y or 0 for N */
/* Called from quite a few places */
/****************************************************************************/
bool sbbs_t::yesno(char *str)
bool sbbs_t::yesno(const char *str)
{
char ch;
......@@ -389,7 +389,7 @@ bool sbbs_t::yesno(char *str)
/* Returns 1 for N or 0 for Y */
/* Called from quite a few places */
/****************************************************************************/
bool sbbs_t::noyes(char *str)
bool sbbs_t::noyes(const char *str)
{
char ch;
......@@ -428,7 +428,7 @@ bool sbbs_t::noyes(char *str)
/* it is echoed (upper case) and is the return value. */
/* Called from quite a few functions */
/****************************************************************************/
long sbbs_t::getkeys(char *keys, ulong max)
long sbbs_t::getkeys(const char *keys, ulong max)
{
char str[81];
uchar ch,n=0,c=0;
......
......@@ -246,8 +246,8 @@ enum {
static JSBool js_bbs_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
char* p=NULL;
char* nulstr="";
const char* p=NULL;
const char* nulstr="";
ulong val=0;
jsint tiny;
sbbs_t* sbbs;
......@@ -1263,6 +1263,7 @@ js_atcode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
int disp_len;
bool padded_left=false;
bool padded_right=false;
const char *cp;
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
......@@ -1285,17 +1286,17 @@ js_atcode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
if(disp_len >= sizeof(str))
disp_len=sizeof(str)-1;
p=sbbs->atcode(instr,str2,sizeof(str2));
cp=sbbs->atcode(instr,str2,sizeof(str2));
free(instr);
if(p==NULL)
if(cp==NULL)
*rval = JSVAL_NULL;
else {
if(padded_left)
sprintf(str,"%-*.*s",disp_len,disp_len,p);
sprintf(str,"%-*.*s",disp_len,disp_len,cp);
else if(padded_right)
sprintf(str,"%*.*s",disp_len,disp_len,p);
sprintf(str,"%*.*s",disp_len,disp_len,cp);
else
SAFECOPY(str,p);
SAFECOPY(str,cp);
JSString* js_str = JS_NewStringCopyZ(cx, str);
if(js_str==NULL)
......@@ -1931,8 +1932,8 @@ js_email(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
int32 usernumber=1;
long mode=WM_EMAIL;
char* top="";
char* subj="";
const char* top="";
const char* subj="";
JSString* js_top=NULL;
JSString* js_subj=NULL;
sbbs_t* sbbs;
......@@ -1963,7 +1964,7 @@ static JSBool
js_netmail(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
long mode=0;
char* subj="";
const char* subj="";
JSString* js_to;
JSString* js_subj=NULL;
sbbs_t* sbbs;
......@@ -2259,8 +2260,8 @@ static JSBool
js_cmdstr(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
char* p;
char* fpath="";
char* fspec="";
const char* fpath="";
const char* fspec="";
JSString* js_str;
sbbs_t* sbbs;
......@@ -2318,7 +2319,7 @@ static JSBool
js_listfiles(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
long mode=0;
char* fspec=ALLFILES;
const char* fspec=ALLFILES;
char buf[MAX_PATH+1];
uint dirnum;
JSString* js_str;
......@@ -2355,7 +2356,7 @@ static JSBool
js_listfileinfo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
long mode=FI_INFO;
char* fspec=ALLFILES;
const char* fspec=ALLFILES;
char buf[MAX_PATH+1];
uint dirnum;
JSString* js_str;
......@@ -2526,7 +2527,7 @@ js_scandirs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool
js_scanposts(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
char* find="";
const char* find="";
long mode=0;
uint subnum;
sbbs_t* sbbs;
......@@ -2558,7 +2559,7 @@ js_scanposts(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool
js_listmsgs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
char* find="";
const char* find="";
long mode=0;
long start=0;
uint subnum;
......
......@@ -70,7 +70,7 @@ static JSBool js_client_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
static JSBool js_client_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
char* p=NULL;
const char* p=NULL;
ulong val=0;
jsint tiny;
JSString* js_str;
......
......@@ -159,7 +159,7 @@ int mfprintf(FILE* fp, char *fmt, ...)
}
/* Log printf */
int lprintf(int level, char *fmt, ...)
int lprintf(int level, const char *fmt, ...)
{
va_list argptr;
char sbuf[1024];
......
......@@ -48,7 +48,7 @@ int extdesclines(char *str);
/* list the directory header. */
/* Returns -1 if the listing was aborted, otherwise total files listed */
/*****************************************************************************/
int sbbs_t::listfiles(uint dirnum, char *filespec, int tofile, long mode)
int sbbs_t::listfiles(uint dirnum, const char *filespec, int tofile, long mode)
{
char str[256],hdr[256],c,d,letter='A',*p,*datbuf,ext[513];
char tmp[512];
......@@ -372,8 +372,8 @@ int sbbs_t::listfiles(uint dirnum, char *filespec, int tofile, long mode)
/* Prints one file's information on a single line */
/* Return 1 if displayed, 0 otherwise */
/****************************************************************************/
bool sbbs_t::listfile(char *fname, char *buf, uint dirnum
, char *search, char letter, ulong datoffset)
bool sbbs_t::listfile(const char *fname, const char *buf, uint dirnum
, const char *search, const char letter, ulong datoffset)
{
char str[256],ext[513]="",*ptr,*cr,*lf,exist=1;
char path[MAX_PATH+1];
......@@ -390,7 +390,7 @@ bool sbbs_t::listfile(char *fname, char *buf, uint dirnum
attr(cfg.color[clr_filename]);
bputs(fname);
getrec((char *)buf,F_ALTPATH,2,str);
getrec(buf,F_ALTPATH,2,str);
alt=(uchar)ahtoul(str);
sprintf(path,"%s%s",alt>0 && alt<=cfg.altpaths ? cfg.altpath[alt-1]:cfg.dir[dirnum]->path
,unpadfname(fname,tmp));
......@@ -410,7 +410,7 @@ bool sbbs_t::listfile(char *fname, char *buf, uint dirnum
attr(cfg.color[clr_err]); }
else
attr(cfg.color[clr_filecdt]);
getrec((char *)buf,F_CDT,LEN_FCDT,str);
getrec(buf,F_CDT,LEN_FCDT,str);
cdt=atol(str);
if(useron.misc&BATCHFLAG) {
if(!cdt) {
......@@ -435,7 +435,7 @@ bool sbbs_t::listfile(char *fname, char *buf, uint dirnum
outchar(' ');
else
outchar('-');
getrec((char *)buf,F_DESC,LEN_FDESC,str);
getrec(buf,F_DESC,LEN_FDESC,str);
attr(cfg.color[clr_filedesc]);
#ifdef _WIN32
......
......@@ -42,7 +42,7 @@ static void prep_cfg(scfg_t* cfg);
static void free_attr_cfg(scfg_t* cfg);
char * readtext(long *line, FILE *stream);
int lprintf(int level, char *fmt, ...); /* log output */
int lprintf(int level, const char *fmt, ...); /* log output */
/****************************************************************************/