...
 
Commits (5)
......@@ -587,7 +587,7 @@ static int sockgetrsp_opt(SOCKET socket, const char* prot, CRYPT_SESSION sess, c
lprintf(LOG_DEBUG,"%04d %s RX: %s",socket, prot, buf);
continue;
}
if(rsp!=NULL && strnicmp(buf,rsp,strlen(rsp))) {
if(strnicmp(buf,rsp,strlen(rsp))) {
lprintf(LOG_WARNING,"%04d %s !INVALID RESPONSE: '%s' Expected: '%s'", socket, prot, buf, rsp);
free(mopt);
return(-1);
......
......@@ -4068,8 +4068,6 @@ void sbbs_t::spymsg(const char* msg)
#endif
}
#define MV_BUFLEN 4096
/****************************************************************************/
/* Moves or copies a file from one dir to another */
/* both 'src' and 'dest' must contain full path and filename */
......@@ -4077,13 +4075,6 @@ void sbbs_t::spymsg(const char* msg)
/****************************************************************************/
int sbbs_t::mv(char *src, char *dest, char copy)
{
char *buf,atr=curatr;
int ind,outd;
uint chunk=MV_BUFLEN;
ulong length,l;
time_t ftime;
FILE *inp,*outp;
if(!stricmp(src,dest)) /* source and destination are the same! */
return(0);
if(!fexistcase(src)) {
......@@ -4107,67 +4098,10 @@ int sbbs_t::mv(char *src, char *dest, char copy)
return(0);
}
#endif
attr(WHITE);
if((ind=nopen(src,O_RDONLY))==-1) {
errormsg(WHERE,ERR_OPEN,src,O_RDONLY);
return(-1);
}
if((inp=fdopen(ind,"rb"))==NULL) {
close(ind);
errormsg(WHERE,ERR_FDOPEN,src,O_RDONLY);
return(-1);
}
setvbuf(inp,NULL,_IOFBF,32*1024);
if((outd=nopen(dest,O_WRONLY|O_CREAT|O_TRUNC))==-1) {
fclose(inp);
errormsg(WHERE,ERR_OPEN,dest,O_WRONLY|O_CREAT|O_TRUNC);
return(-1);
}
if((outp=fdopen(outd,"wb"))==NULL) {
close(outd);
fclose(inp);
errormsg(WHERE,ERR_FDOPEN,dest,O_WRONLY|O_CREAT|O_TRUNC);
return(-1);
}
setvbuf(outp,NULL,_IOFBF,8*1024);
ftime=filetime(ind);
length=(long)filelength(ind);
if(length) { /* Something to copy */
if((buf=(char *)malloc(MV_BUFLEN))==NULL) {
fclose(inp);
fclose(outp);
errormsg(WHERE,ERR_ALLOC,nulstr,MV_BUFLEN);
return(-1);
}
l=0L;
while(l<length) {
bprintf("%2lu%%",l ? (long)(100.0/((float)length/l)) : 0L);
if(l+chunk>length)
chunk=length-l;
if(fread(buf,1,chunk,inp)!=chunk) {
free(buf);
fclose(inp);
fclose(outp);
errormsg(WHERE,ERR_READ,src,chunk);
return(-1);
}
if(fwrite(buf,1,chunk,outp)!=chunk) {
free(buf);
fclose(inp);
fclose(outp);
errormsg(WHERE,ERR_WRITE,dest,chunk);
return(-1);
}
l+=chunk;
bputs("\b\b\b");
}
bputs(" \b\b\b"); /* erase it */
attr(atr);
free(buf);
if(!CopyFile(src, dest, /* fail if exists: */true)) {
errormsg(WHERE, "CopyFile", src, 0, dest);
return -1;
}
fclose(inp);
fclose(outp);
setfdate(dest,ftime); /* Would be nice if we could use futime() instead */
if(!copy && remove(src)) {
errormsg(WHERE,ERR_REMOVE,src,0);
return(-1);
......
......@@ -68,7 +68,8 @@ char *readtext(long *line,FILE *stream,long dflt)
continue;
break;
}
*(p)=0;
if(p != NULL)
*p = '\0';
k=strlen(buf);
for(i=1,j=0;i<k && j<sizeof(str)-1;j++) {
if(buf[i]=='\\') { /* escape */
......
......@@ -354,10 +354,10 @@ void status_client_on(enum sbbs_status_service svc, BOOL on, SOCKET sock, client
pthread_mutex_lock(&status_mutex[svc]);
if(on) {
prot = client->protocol;
if (client == NULL || prot == NULL)
if (prot == NULL)
prot = "<null>";
user = client->user;
if (client == NULL || user == NULL)
if (user == NULL)
user = "<null>";
if(update) {
list_node_t* node;
......
......@@ -4371,13 +4371,14 @@ int pkt_to_msg(FILE* fidomsg, fmsghdr_t* hdr, const char* info, const char* inbo
/**************************************/
/* Send netmail, returns 0 on success */
/**************************************/
int import_netmail(const char* path, fmsghdr_t hdr, FILE* fp, const char* inbound)
int import_netmail(const char* path, const fmsghdr_t* inhdr, FILE* fp, const char* inbound)
{
char info[512],str[256],tmp[256],subj[256]
,*fmsgbuf=NULL,*p,*tp,*sp;
int i,match,usernumber = 0;
ulong length;
fidoaddr_t addr;
fmsghdr_t hdr = *inhdr;
hdr.destzone=sys_faddr.zone;
hdr.destpoint=hdr.origpoint=0;
......@@ -5882,7 +5883,7 @@ void import_packets(const char* inbound, nodecfg_t* inbox, bool secure)
if(strncmp(fmsgbuf, "AREA:", 5) != 0) { /* Netmail */
(void)fseeko(fidomsg, msg_offset, SEEK_SET);
import_netmail("", hdr, fidomsg, inbound);
import_netmail("", &hdr, fidomsg, inbound);
(void)fseeko(fidomsg, next_msg, SEEK_SET);
printf("\n");
continue;
......@@ -6654,7 +6655,7 @@ int main(int argc, char **argv)
lprintf(LOG_ERR,"ERROR line %d reading fido msghdr from %s",__LINE__,path);
continue;
}
i=import_netmail(path,hdr,fidomsg,cfg.inbound);
i=import_netmail(path, &hdr, fidomsg, cfg.inbound);
/**************************************/
/* Delete source netmail if specified */
/**************************************/
......