Commit dfa39195 authored by rswindell's avatar rswindell
Browse files

Changed putnmsg() to a DLL-exported C function (allowing it to be called from

outside the sbbs_t class).
parent 51de8b33
......@@ -247,7 +247,7 @@ int sbbs_t::bulkmailhdr(uint usernum, smbmsg_t *msg, ushort msgattr, ulong offse
if(node.useron==usernum && !(node.misc&NODE_POFF)
&& (node.status==NODE_INUSE || node.status==NODE_QUIET)) {
sprintf(str,text[EmailNodeMsg],cfg.node_num,useron.alias);
putnmsg(i,str);
putnmsg(&cfg,i,str);
break; } }
if(i>cfg.sys_nodes) { /* User wasn't online, so leave short msg */
sprintf(str,text[UserSentYouMail],useron.alias);
......
......@@ -332,7 +332,7 @@ void sbbs_t::multinodechat(int channel)
strcat(buf,crlf);
if(useron.chat&CHAT_ECHO)
bputs(buf);
putnmsg(j,buf);
putnmsg(&cfg,j,buf);
break;
case 'Q': /* quit */
done=1;
......@@ -454,7 +454,7 @@ void sbbs_t::multinodechat(int channel)
? text[UNKNOWN_USER] : useron.alias
,"you");
strcat(buf,crlf);
putnmsg(usr[j],buf); }
putnmsg(&cfg,usr[j],buf); }
/* Display to all other users */
......@@ -468,10 +468,10 @@ void sbbs_t::multinodechat(int channel)
if(i==j)
continue;
getnodedat(usr[i],&node,0);
putnmsg(usr[i],buf); }
putnmsg(&cfg,usr[i],buf); }
for(i=0;i<qusrs;i++) {
getnodedat(qusr[i],&node,0);
putnmsg(qusr[i],buf); }
putnmsg(&cfg,qusr[i],buf); }
continue; } }
sprintf(buf,text[ChatLineFmt]
......@@ -483,10 +483,10 @@ void sbbs_t::multinodechat(int channel)
bputs(buf);
for(i=0;i<usrs;i++) {
getnodedat(usr[i],&node,0);
putnmsg(usr[i],buf); }
putnmsg(&cfg,usr[i],buf); }
for(i=0;i<qusrs;i++) {
getnodedat(qusr[i],&node,0);
putnmsg(qusr[i],buf); }
putnmsg(&cfg,qusr[i],buf); }
if(!usrs && channel && gurubuf
&& cfg.chan[channel-1]->misc&CHAN_GURU)
guruchat(pgraph,gurubuf,cfg.chan[channel-1]->guru);
......@@ -742,7 +742,7 @@ void sbbs_t::privchat(bool local)
sprintf(str,text[NodePChatPageMsg]
,cfg.node_num,thisnode.misc&NODE_ANON
? text[UNKNOWN_USER] : useron.alias);
putnmsg(n,str);
putnmsg(&cfg,n,str);
sprintf(str,"%s paged %s on node %d to private chat"
,useron.alias,username(&cfg,node.useron,tmp),n);
logline("C",str); }
......@@ -1316,7 +1316,7 @@ void sbbs_t::nodemsg()
sprintf(buf,text[NodeMsgFmt],cfg.node_num
,thisnode.misc&NODE_ANON
? text[UNKNOWN_USER] : useron.alias,line);
putnmsg(i,buf);
putnmsg(&cfg,i,buf);
if(!(node.misc&NODE_ANON))
bprintf(text[MsgSentToUser],"Message"
,username(&cfg,usernumber,tmp),usernumber);
......@@ -1338,7 +1338,7 @@ void sbbs_t::nodemsg()
if((node.status==NODE_INUSE
|| (SYSOP && node.status==NODE_QUIET))
&& (SYSOP || !(node.misc&NODE_POFF)))
putnmsg(i,buf); }
putnmsg(&cfg,i,buf); }
sprintf(str,"%s sent message to all nodes",useron.alias);
logline("C",str);
logline(nulstr,line);
......
......@@ -307,7 +307,7 @@ bool sbbs_t::email(int usernumber, char *top, char *subj, long mode)
if(node.useron==usernumber && !(node.misc&NODE_POFF)
&& (node.status==NODE_INUSE || node.status==NODE_QUIET)) {
sprintf(str,text[EmailNodeMsg],cfg.node_num,useron.alias);
putnmsg(i,str);
putnmsg(&cfg,i,str);
break; } }
if(i>cfg.sys_nodes) { /* User wasn't online, so leave short msg */
sprintf(str,text[UserSentYouMail],useron.alias);
......
......@@ -1968,7 +1968,7 @@ js_put_node_message(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
if((msg=JS_GetStringBytes(js_msg))==NULL)
return(JS_FALSE);
sbbs->putnmsg(node,msg);
putnmsg(&sbbs->cfg,node,msg);
*rval = JSVAL_VOID;
return(JS_TRUE);
......
......@@ -524,7 +524,7 @@ bool sbbs_t::logon()
,cfg.node_num
,thisnode.misc&NODE_ANON ? text[UNKNOWN_USER] : useron.alias
,connection);
putnmsg(i,str);
putnmsg(&cfg,i,str);
}
}
......
......@@ -82,7 +82,7 @@ void sbbs_t::logout()
sprintf(str,text[NodeLoggedOff],cfg.node_num
,thisnode.misc&NODE_ANON
? text[UNKNOWN_USER] : useron.alias);
putnmsg(i,str); } }
putnmsg(&cfg,i,str); } }
if(!online) { /* NOT re-login */
......
......@@ -214,7 +214,7 @@ void sbbs_t::telluser(smbmsg_t* msg)
sprintf(str
,text[UserReadYourMailNodeMsg]
,cfg.node_num,useron.alias);
putnmsg(n,str);
putnmsg(&cfg,n,str);
break; } }
if(n>cfg.sys_nodes) {
now=time(NULL);
......
......@@ -112,39 +112,6 @@ int sbbs_t::putnodedat(uint number, node_t* node)
return(0);
}
/****************************************************************************/
/* Creates a short message for node 'num' than contains 'strin' */
/****************************************************************************/
int sbbs_t::putnmsg(int num, char *strin)
{
char str[256];
int file,i;
node_t node;
sprintf(str,"%smsgs/n%3.3u.msg",cfg.data_dir,num);
if((file=nopen(str,O_WRONLY|O_CREAT))==-1) {
errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_CREAT);
return(errno);
}
lseek(file,0L,SEEK_END); // Instead of opening with O_APPEND
i=strlen(strin);
if(write(file,strin,i)!=i) {
close(file);
errormsg(WHERE,ERR_WRITE,str,i);
return(errno);
}
close(file);
getnodedat(num,&node,0);
if((node.status==NODE_INUSE || node.status==NODE_QUIET)
&& !(node.misc&NODE_NMSG)) {
getnodedat(num,&node,1);
node.misc|=NODE_NMSG;
putnodedat(num,&node);
}
return(0);
}
int sbbs_t::putnodeext(uint number, char *ext)
{
char str[MAX_PATH+1];
......
......@@ -508,7 +508,6 @@ public:
/* putnode.cpp */
int putnodedat(uint number, node_t * node);
int putnodeext(uint number, char * str);
int putnmsg(int num, char *strin);
/* logonoff.cpp */
bool answer();
......
......@@ -235,7 +235,7 @@ bool sbbs_t::unpack_rep(char* repfile)
|| node.status==NODE_QUIET)) {
sprintf(str,text[EmailNodeMsg]
,cfg.node_num,tmp);
putnmsg(k,str);
putnmsg(&cfg,k,str);
break; } }
if(k>cfg.sys_nodes) {
sprintf(str,text[UserSentYouMail],tmp);
......
......@@ -477,7 +477,7 @@ bool sbbs_t::upload(uint dirnum)
if(node.useron==destuser[j] && !(node.misc&NODE_POFF)
&& (node.status==NODE_INUSE || node.status==NODE_QUIET)) {
sprintf(str,text[UserToUserXferNodeMsg],cfg.node_num,useron.alias);
putnmsg(i,str);
putnmsg(&cfg,i,str);
break; } }
if(i>cfg.sys_nodes) { /* User not online */
sprintf(str,text[UserSentYouFile],useron.alias);
......
......@@ -967,7 +967,7 @@ uint DLLCALL userdatdupe(scfg_t* cfg, uint usernumber, uint offset, uint datlen,
}
/****************************************************************************/
/* Creates a short message for 'usernumber' than contains 'strin' */
/* Creates a short message for 'usernumber' that contains 'strin' */
/****************************************************************************/
int DLLCALL putsmsg(scfg_t* cfg, int usernumber, char *strin)
{
......@@ -998,6 +998,36 @@ int DLLCALL putsmsg(scfg_t* cfg, int usernumber, char *strin)
return(0);
}
/****************************************************************************/
/* Creates a short message for node 'num' that contains 'strin' */
/****************************************************************************/
int DLLCALL putnmsg(scfg_t* cfg, int num, char *strin)
{
char str[256];
int file,i;
node_t node;
sprintf(str,"%smsgs/n%3.3u.msg",cfg->data_dir,num);
if((file=nopen(str,O_WRONLY|O_CREAT))==-1)
return(errno);
lseek(file,0L,SEEK_END); // Instead of opening with O_APPEND
i=strlen(strin);
if(write(file,strin,i)!=i) {
close(file);
return(errno);
}
close(file);
getnodedat(cfg,num,&node,NULL);
if((node.status==NODE_INUSE || node.status==NODE_QUIET)
&& !(node.misc&NODE_NMSG)) {
getnodedat(cfg,num,&node,&file);
node.misc|=NODE_NMSG;
putnodedat(cfg,num,&node,file);
}
return(0);
}
static BOOL ar_exp(scfg_t* cfg, uchar **ptrptr, user_t* user)
{
BOOL result,not,or,equal;
......
......@@ -88,6 +88,8 @@ DLLEXPORT void DLLCALL packchatpass(char *pass, node_t* node);
DLLEXPORT char* DLLCALL unpackchatpass(char *pass, node_t* node);
DLLEXPORT int DLLCALL putsmsg(scfg_t* cfg, int usernumber, char *strin);
DLLEXPORT int DLLCALL putnmsg(scfg_t* cfg, int num, char *strin);
DLLEXPORT uint DLLCALL userdatdupe(scfg_t* cfg, uint usernumber, uint offset, uint datlen, char *dat
,BOOL del);
......
......@@ -964,7 +964,7 @@ void sbbs_t::forwardmail(smbmsg_t *msg, int usernumber)
if(node.useron==usernumber && !(node.misc&NODE_POFF)
&& (node.status==NODE_INUSE || node.status==NODE_QUIET)) {
sprintf(str,text[EmailNodeMsg],cfg.node_num,useron.alias);
putnmsg(i,str);
putnmsg(&cfg,i,str);
break; } }
if(i>cfg.sys_nodes) { /* User wasn't online, so leave short msg */
sprintf(str,text[UserSentYouMail],useron.alias);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment