Commits (6)
......@@ -564,13 +564,20 @@ bool sbbs_t::guru_page(void)
errormsg(WHERE,ERR_OPEN,path,O_RDONLY);
return(false);
}
if((gurubuf=(char *)malloc((size_t)filelength(file)+1))==NULL) {
errormsg(WHERE,ERR_ALLOC,path,(size_t)filelength(file)+1);
long length = (long)filelength(file);
if(length < 0) {
errormsg(WHERE ,ERR_CHK, path, length);
close(file);
return false;
}
if((gurubuf=(char *)malloc(length + 1))==NULL) {
errormsg(WHERE, ERR_ALLOC, path, length + 1);
close(file);
return(false);
}
(void)read(file,gurubuf,(size_t)filelength(file));
gurubuf[filelength(file)]=0;
if(read(file,gurubuf,length) != length)
errormsg(WHERE, ERR_READ, path, length);
gurubuf[length]=0;
close(file);
localguru(gurubuf,i);
free(gurubuf);
......
......@@ -75,7 +75,7 @@ int sbbs_t::loadmsg(smbmsg_t *msg, ulong number)
}
/* Synchronized with atcode()! */
void sbbs_t::show_msgattr(smbmsg_t* msg)
void sbbs_t::show_msgattr(const smbmsg_t* msg)
{
uint16_t attr = msg->hdr.attr;
uint16_t poll = attr&MSG_POLL_VOTE_MASK;
......@@ -163,7 +163,7 @@ const char* sbbs_t::msghdr_field(const smbmsg_t* msg, const char* str, char* buf
/****************************************************************************/
/* Displays a message header to the screen */
/****************************************************************************/
void sbbs_t::show_msghdr(smb_t* smb, smbmsg_t* msg, const char* subject, const char* from, const char* to)
void sbbs_t::show_msghdr(smb_t* smb, const smbmsg_t* msg, const char* subject, const char* from, const char* to)
{
char str[MAX_PATH+1];
char age[64];
......
......@@ -3948,7 +3948,7 @@ js_change_msg_attr(JSContext *cx, uintN argc, jsval *arglist)
return JS_TRUE;
rc=JS_SUSPENDREQUEST(cx);
int32 attr = sbbs->chmsgattr(*msg);
int32 attr = sbbs->chmsgattr(msg);
JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(attr));
......
......@@ -503,7 +503,7 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode)
done=1;
break;
case 'C': /* Change attributes of last piece */
i=chmsgattr(msg);
i=chmsgattr(&msg);
if(msg.hdr.attr==i)
break;
if(msg.total_hfields)
......
......@@ -1214,7 +1214,7 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
: matchuser(&cfg,msg.from,FALSE));
break;
case 'C': /* Change message attributes */
i=chmsgattr(msg);
i=chmsgattr(&msg);
if(msg.hdr.attr==i)
break;
if(msg.total_hfields)
......
......@@ -614,7 +614,7 @@ public:
csi_t main_csi; /* Main Command Shell Image */
smbmsg_t* current_msg; /* For message header @-codes */
const smbmsg_t* current_msg; /* For message header @-codes */
const char* current_msg_subj;
const char* current_msg_from;
const char* current_msg_to;
......@@ -745,7 +745,7 @@ public:
void removeline(char *str, char *str2, char num, char skip);
ulong msgeditor(char *buf, const char *top, char *title);
bool editfile(char *path, bool msg=false);
ushort chmsgattr(smbmsg_t);
ushort chmsgattr(const smbmsg_t*);
bool quotemsg(smb_t*, smbmsg_t*, bool tails = false);
bool editmsg(smb_t*, smbmsg_t*);
void editor_inf(int xeditnum, const char *to, const char* from, const char *subj, long mode
......@@ -767,8 +767,8 @@ public:
/* getmsg.cpp */
int loadmsg(smbmsg_t *msg, ulong number);
void show_msgattr(smbmsg_t*);
void show_msghdr(smb_t*, smbmsg_t*, const char *subj = NULL, const char* from = NULL, const char* to = NULL);
void show_msgattr(const smbmsg_t*);
void show_msghdr(smb_t*, const smbmsg_t*, const char *subj = NULL, const char* from = NULL, const char* to = NULL);
bool show_msg(smb_t*, smbmsg_t*, long p_mode = 0, post_t* post = NULL);
bool msgtotxt(smb_t*, smbmsg_t*, const char *fname, bool header = true, ulong gettxt_mode = GETMSGTXT_ALL);
const char* msghdr_text(const smbmsg_t*, uint index);
......
......@@ -1196,16 +1196,26 @@ void packmsgs(ulong packable)
continue;
}
off_t offset;
if(!(smb.status.attr&SMB_HYPERALLOC)) {
msg.hdr.offset = (uint32_t)smb_fallocdat(&smb,(uint32_t)m,1);
datoffset[datoffsets].new = msg.hdr.offset;
offset = smb_fallocdat(&smb,(uint32_t)m,1);
if(offset < 0) {
fprintf(errfp,"\n%s!Data allocation failure: %ld\n", beep, (long)offset);
continue;
}
datoffset[datoffsets].new = (uint32_t)offset;
datoffsets++;
fseek(tmp_sdt,msg.hdr.offset,SEEK_SET);
fseeko(tmp_sdt, offset, SEEK_SET);
}
else {
fseek(tmp_sdt,0L,SEEK_END);
msg.hdr.offset=ftell(tmp_sdt);
offset = ftello(tmp_sdt);
if(offset < 0) {
fprintf(errfp,"\n%s!ftell() ERROR %d\n", beep, errno);
continue;
}
}
msg.hdr.offset = (uint32_t)offset;
/* Actually copy the data */
......@@ -1225,28 +1235,34 @@ void packmsgs(ulong packable)
/* Write the new index entry */
length=smb_getmsghdrlen(&msg);
off_t offset;
if(smb.status.attr&SMB_HYPERALLOC)
msg.idx.offset=ftell(tmp_shd);
offset = ftello(tmp_shd);
else
msg.idx.offset=(uint32_t)smb_fallochdr(&smb,(ulong)length)+smb.status.header_offset;
smb_init_idx(&smb, &msg);
fseek(tmp_sid, l * idxreclen, SEEK_SET);
fwrite(&msg.idx, 1, sizeof(msg.idx), tmp_sid);
/* Write the new header entry */
fseek(tmp_shd,msg.idx.offset,SEEK_SET);
fwrite(&msg.hdr,1,sizeof(msghdr_t),tmp_shd);
for(n=0;n<msg.hdr.total_dfields;n++)
fwrite(&msg.dfield[n],1,sizeof(dfield_t),tmp_shd);
for(n=0;n<msg.total_hfields;n++) {
fwrite(&msg.hfield[n],1,sizeof(hfield_t),tmp_shd);
fwrite(msg.hfield_dat[n],1,msg.hfield[n].length,tmp_shd);
}
while(length%SHD_BLOCK_LEN) { /* pad with NULLs */
fputc(0,tmp_shd);
length++;
offset = smb_fallochdr(&smb,(ulong)length)+smb.status.header_offset;
if(offset < 0) {
fprintf(errfp,"\n%s!header allocation ERROR %ld\n", beep, (long)offset);
} else {
msg.idx.offset = (uint32_t)offset;
smb_init_idx(&smb, &msg);
fseek(tmp_sid, l * idxreclen, SEEK_SET);
fwrite(&msg.idx, 1, sizeof(msg.idx), tmp_sid);
/* Write the new header entry */
fseek(tmp_shd,msg.idx.offset,SEEK_SET);
fwrite(&msg.hdr,1,sizeof(msghdr_t),tmp_shd);
for(n=0;n<msg.hdr.total_dfields;n++)
fwrite(&msg.dfield[n],1,sizeof(dfield_t),tmp_shd);
for(n=0;n<msg.total_hfields;n++) {
fwrite(&msg.hfield[n],1,sizeof(hfield_t),tmp_shd);
fwrite(msg.hfield_dat[n],1,msg.hfield[n].length,tmp_shd);
}
while(length%SHD_BLOCK_LEN) { /* pad with NULLs */
fputc(0,tmp_shd);
length++;
}
total++;
}
total++;
smb_freemsgmem(&msg);
}
......
......@@ -1093,8 +1093,8 @@ const char * const text_defaults[TOTAL_TEXT]={
,"\x01\x6e\x01\x79\x01\x68\x25\x73\x01\x6e\x01\x63\x20\x73\x65\x6e\x74\x20\x79\x6f\x75\x20\x61\x20\x66\x69\x6c\x65\x2e\x0d\x0a" // 649 UserSentYouFile
,"\x01\x6e\x01\x79\x01\x68\x25\x73\x01\x6e\x01\x63\x20\x72\x65\x61\x64\x20\x79\x6f\x75\x72\x20\x45\x2d\x6d\x61\x69\x6c\x20\x6f\x6e"
"\x20\x25\x73\x2e\x0d\x0a" // 650 UserReadYourMail
,"\x07\x01\x5f\x01\x77\x01\x68\x4e\x6f\x64\x65\x20\x25\x32\x64\x3a\x20\x01\x67\x25\x73\x01\x6e\x01\x67\x20\x72\x65\x61\x64\x20\x79"
"\x6f\x75\x72\x20\x45\x2d\x6d\x61\x69\x6c\x2e\x0d\x0a" // 651 UserReadYourMailNodeMsg
,"\x01\x5f\x01\x77\x01\x68\x4e\x6f\x64\x65\x20\x25\x32\x64\x3a\x20\x01\x67\x25\x73\x01\x6e\x01\x67\x20\x72\x65\x61\x64\x20\x79\x6f"
"\x75\x72\x20\x45\x2d\x6d\x61\x69\x6c\x2e\x0d\x0a" // 651 UserReadYourMailNodeMsg
,"\x0d\x0a\x57\x68\x69\x63\x68\x2c\x20\x7e\x51\x75\x69\x74\x2c\x20\x6f\x72\x20\x5b\x25\x75\x5d\x3a\x20" // 652 JoinWhichGrp
,"\x0d\x0a\x57\x68\x69\x63\x68\x2c\x20\x7e\x51\x75\x69\x74\x2c\x20\x6f\x72\x20\x5b\x25\x75\x5d\x3a\x20" // 653 JoinWhichSub
,"\x0d\x0a\x57\x68\x69\x63\x68\x2c\x20\x7e\x51\x75\x69\x74\x2c\x20\x6f\x72\x20\x5b\x25\x75\x5d\x3a\x20" // 654 JoinWhichLib
......
......@@ -852,7 +852,7 @@ void sbbs_t::removeline(char *str, char *str2, char num, char skip)
{
char* buf;
size_t slen;
int i,file;
int i,file;
long l=0,flen;
FILE *stream;
......@@ -861,6 +861,11 @@ void sbbs_t::removeline(char *str, char *str2, char num, char skip)
return;
}
flen=(long)filelength(file);
if(flen < 0) {
close(file);
errormsg(WHERE, ERR_CHK, str, flen);
return;
}
slen=strlen(str2);
if((buf=(char *)malloc(flen))==NULL) {
close(file);
......@@ -1840,57 +1845,58 @@ bool sbbs_t::movemsg(smbmsg_t* msg, uint subnum)
return(true);
}
ushort sbbs_t::chmsgattr(smbmsg_t msg)
ushort sbbs_t::chmsgattr(const smbmsg_t* msg)
{
int ch;
uint16_t attr = msg->hdr.attr;
while(online && !(sys_status&SS_ABORT)) {
CRLF;
show_msgattr(&msg);
show_msgattr(msg);
menu("msgattr");
ch=getkey(K_UPPER);
if(ch)
bprintf("%c\r\n",ch);
switch(ch) {
case 'P':
msg.hdr.attr^=MSG_PRIVATE;
attr^=MSG_PRIVATE;
break;
case 'S':
msg.hdr.attr^=MSG_SPAM;
attr^=MSG_SPAM;
break;
case 'R':
msg.hdr.attr^=MSG_READ;
attr^=MSG_READ;
break;
case 'K':
msg.hdr.attr^=MSG_KILLREAD;
attr^=MSG_KILLREAD;
break;
case 'A':
msg.hdr.attr^=MSG_ANONYMOUS;
attr^=MSG_ANONYMOUS;
break;
case 'N': /* Non-purgeable */
msg.hdr.attr^=MSG_PERMANENT;
attr^=MSG_PERMANENT;
break;
case 'M':
msg.hdr.attr^=MSG_MODERATED;
attr^=MSG_MODERATED;
break;
case 'V':
msg.hdr.attr^=MSG_VALIDATED;
attr^=MSG_VALIDATED;
break;
case 'D':
msg.hdr.attr^=MSG_DELETE;
attr^=MSG_DELETE;
break;
case 'L':
msg.hdr.attr^=MSG_LOCKED;
attr^=MSG_LOCKED;
break;
case 'C':
msg.hdr.attr^=MSG_NOREPLY;
attr^=MSG_NOREPLY;
break;
case 'E':
msg.hdr.attr^=MSG_REPLIED;
attr^=MSG_REPLIED;
break;
default:
return(msg.hdr.attr);
return(attr);
}
}
return(msg.hdr.attr);
return(attr);
}
......@@ -243,8 +243,8 @@ SMBEXPORT char* smb_hfieldtype(uint16_t type);
SMBEXPORT uint16_t smb_hfieldtypelookup(const char*);
SMBEXPORT char* smb_dfieldtype(uint16_t type);
SMBEXPORT char* smb_faddrtoa(fidoaddr_t* addr, char* outstr);
SMBEXPORT char* smb_netaddr(net_t* net);
SMBEXPORT char* smb_netaddrstr(net_t* net, char* fidoaddr_buf);
SMBEXPORT char* smb_netaddr(const net_t* net);
SMBEXPORT char* smb_netaddrstr(const net_t* net, char* fidoaddr_buf);
SMBEXPORT char* smb_nettype(enum smb_net_type);
SMBEXPORT char* smb_zonestr(int16_t zone, char* outstr);
SMBEXPORT char* smb_msgattrstr(int16_t attr, char* outstr, size_t maxlen);
......
......@@ -309,7 +309,7 @@ fidoaddr_t smb_atofaddr(const fidoaddr_t* sys_addr, const char *str)
/* Returns ASCIIZ representation of network address (net_t) */
/* NOT THREAD-SAFE! */
/****************************************************************************/
char* smb_netaddr(net_t* net)
char* smb_netaddr(const net_t* net)
{
return(smb_netaddrstr(net, NULL));
}
......@@ -317,7 +317,7 @@ char* smb_netaddr(net_t* net)
/****************************************************************************/
/* Copies ASCIIZ representation of network address (net_t) into buf */
/****************************************************************************/
char* smb_netaddrstr(net_t* net, char* fidoaddr_buf)
char* smb_netaddrstr(const net_t* net, char* fidoaddr_buf)
{
if(net->type==NET_FIDO)
return(smb_faddrtoa((fidoaddr_t*)net->addr,fidoaddr_buf));
......