Skip to content
Snippets Groups Projects
Commit 41a5418e authored by rswindell's avatar rswindell
Browse files

Fix bcc32 compile errors and warnings.

Update indentation/brace style.
Display CVS revision in version banner, no copyright.
parent bac24478
No related branches found
No related tags found
No related merge requests found
/* QWKNODES.C */ /* $Id$ */
/* Synchronet QWKnet node list or route.dat file generator */ /* Synchronet QWKnet node list or route.dat file generator */
/* $Id$ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html * * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License * * modify it under the terms of the GNU General Public License *
...@@ -35,13 +33,11 @@ ...@@ -35,13 +33,11 @@
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
#include "gen_defs.h"
#include "genwrap.h"
#include "dirwrap.h"
#include "sbbs.h" #include "sbbs.h"
#include "nopen.h" #include "nopen.h"
#include "crc16.h" #include "crc16.h"
#include "crc32.h" #include "crc32.h"
#include "conwrap.h" /* kbhit */
unsigned _stklen=10000; unsigned _stklen=10000;
smb_t smb; smb_t smb;
...@@ -56,12 +52,12 @@ for(i=j=0;str[i];i++) { ...@@ -56,12 +52,12 @@ for(i=j=0;str[i];i++) {
if(str[i]==CTRL_A && str[i+1]!=0) if(str[i]==CTRL_A && str[i+1]!=0)
i++; i++;
else else
out[j++]=str[i]; } out[j++]=str[i];
}
out[j]=0; out[j]=0;
strcpy(str,out); strcpy(str,out);
} }
int lputs(char* str) int lputs(char* str)
{ {
char tmp[256]; char tmp[256];
...@@ -117,7 +113,8 @@ for(i=0;i<msg.hdr.total_dfields;i++) { ...@@ -117,7 +113,8 @@ for(i=0;i<msg.hdr.total_dfields;i++) {
if((buf=REALLOC(buf,l+msg.dfield[i].length+1))==NULL) if((buf=REALLOC(buf,l+msg.dfield[i].length+1))==NULL)
return(buf); return(buf);
l+=fread(buf+l,1,length,smb.sdt_fp); l+=fread(buf+l,1,length,smb.sdt_fp);
buf[l]=0; } buf[l]=0;
}
return(buf); return(buf);
} }
...@@ -154,7 +151,7 @@ FREE(buf); ...@@ -154,7 +151,7 @@ FREE(buf);
#define NODES (1<<2) #define NODES (1<<2)
#define USERS (1<<3) #define USERS (1<<3)
char *usage="\nusage: qwknodes [/opts] cmds" char *usage="\nusage: qwknodes [-opts] cmds"
"\n" "\n"
"\n cmds: r = create route.dat" "\n cmds: r = create route.dat"
"\n u = create users.dat" "\n u = create users.dat"
...@@ -177,10 +174,12 @@ int main(int argc, char **argv) ...@@ -177,10 +174,12 @@ int main(int argc, char **argv)
time_t now; time_t now;
smbmsg_t msg; smbmsg_t msg;
char *ctrl_dir; char *ctrl_dir;
char revision[16];
fprintf(stderr,"\nSynchronet QWKnet Node/Route/User List v1.20 " sscanf("$Revision$", "%*s %s", revision);
"Copyright 2000 Rob Swindell\n");
fprintf(stderr,"\nSynchronet QWKnet Node/Route/User List Generator v%s-%s\n"
,revision, PLATFORM_DESC);
for(i=1;i<argc;i++) for(i=1;i<argc;i++)
for(j=0;argv[i][j];j++) for(j=0;argv[i][j];j++)
...@@ -208,7 +207,8 @@ for(i=1;i<argc;i++) ...@@ -208,7 +207,8 @@ for(i=1;i<argc;i++)
break; break;
default: default:
printf(usage); printf(usage);
return(1); } return(1);
}
j--; j--;
break; break;
case 'R': case 'R':
...@@ -222,11 +222,13 @@ for(i=1;i<argc;i++) ...@@ -222,11 +222,13 @@ for(i=1;i<argc;i++)
break; break;
default: default:
printf(usage); printf(usage);
return(1); } return(1);
}
if(!cmd) { if(!cmd) {
printf(usage); printf(usage);
return(1); } return(1);
}
if(mode&APPEND) if(mode&APPEND)
o_mode=O_WRONLY|O_CREAT|O_APPEND; o_mode=O_WRONLY|O_CREAT|O_APPEND;
...@@ -236,17 +238,20 @@ else ...@@ -236,17 +238,20 @@ else
if(cmd&NODES) if(cmd&NODES)
if((nodes=fnopen(&i,"nodes.dat",o_mode))==NULL) { if((nodes=fnopen(&i,"nodes.dat",o_mode))==NULL) {
printf("\7\nError opening nodes.dat\n"); printf("\7\nError opening nodes.dat\n");
return(1); } return(1);
}
if(cmd&USERS) if(cmd&USERS)
if((users=fnopen(&i,"users.dat",o_mode))==NULL) { if((users=fnopen(&i,"users.dat",o_mode))==NULL) {
printf("\7\nError opening users.dat\n"); printf("\7\nError opening users.dat\n");
return(1); } return(1);
}
if(cmd&ROUTE) if(cmd&ROUTE)
if((route=fnopen(&i,"route.dat",o_mode))==NULL) { if((route=fnopen(&i,"route.dat",o_mode))==NULL) {
printf("\7\nError opening route.dat\n"); printf("\7\nError opening route.dat\n");
return(1); } return(1);
}
cfg.size=sizeof(cfg); cfg.size=sizeof(cfg);
ctrl_dir=getenv("SBBSCTRL"); ctrl_dir=getenv("SBBSCTRL");
...@@ -261,35 +266,6 @@ if(!load_cfg(&cfg, NULL, TRUE, str)) { ...@@ -261,35 +266,6 @@ if(!load_cfg(&cfg, NULL, TRUE, str)) {
printf("\7\n%s\n",str); printf("\7\n%s\n",str);
} }
#if 0
if(!cfg.node_dir[0]) {
p=getenv("SBBSNODE");
if(p==NULL) {
printf("\7\nSBBSNODE environment variable not set.\n");
return(1); }
strcpy(cfg.node_dir,p); }
if(cfg.node_dir[strlen(cfg.node_dir)-1]!='\\')
strcat(cfg.node_dir,"\\");
read_node_cfg(&cfg,txt);
if(ctrl_dir[0]=='.') { /* Relative path */
strcpy(str,ctrl_dir);
sprintf(ctrl_dir,"%s%s",cfg.node_dir,str);
if(FULLPATH(str,ctrl_dir,40))
strcpy(ctrl_dir,str); }
backslash(ctrl_dir);
read_main_cfg(&cfg,txt);
if(data_dir[0]=='.') { /* Relative path */
strcpy(str,data_dir);
sprintf(data_dir,"%s%s",cfg.node_dir,str);
if(FULLPATH(str,data_dir,40))
strcpy(data_dir,str); }
backslash(data_dir);
read_msgs_cfg(txt);
#endif
now=time(NULL); now=time(NULL);
smm=crc16("smm",0); smm=crc16("smm",0);
sbl=crc16("sbl",0); sbl=crc16("sbl",0);
...@@ -304,21 +280,25 @@ for(i=0;i<cfg.total_subs;i++) { ...@@ -304,21 +280,25 @@ for(i=0;i<cfg.total_subs;i++) {
smb.subnum=i; smb.subnum=i;
if((j=smb_open(&smb))!=0) { if((j=smb_open(&smb))!=0) {
printf("smb_open returned %d\n",j); printf("smb_open returned %d\n",j);
continue; } continue;
}
if((j=smb_locksmbhdr(&smb))!=0) { if((j=smb_locksmbhdr(&smb))!=0) {
printf("smb_locksmbhdr returned %d\n",j); printf("smb_locksmbhdr returned %d\n",j);
smb_close(&smb); smb_close(&smb);
continue; } continue;
}
if((j=smb_getstatus(&smb))!=0) { if((j=smb_getstatus(&smb))!=0) {
printf("smb_getstatus returned %d\n",j); printf("smb_getstatus returned %d\n",j);
smb_close(&smb); smb_close(&smb);
continue; } continue;
}
smb_unlocksmbhdr(&smb); smb_unlocksmbhdr(&smb);
msg.offset=smb.status.total_msgs; msg.offset=smb.status.total_msgs;
if(!msg.offset) { if(!msg.offset) {
smb_close(&smb); smb_close(&smb);
printf("Empty.\n"); printf("Empty.\n");
continue; } continue;
}
while(!kbhit() && !ferror(smb.sid_fp) && msg.offset) { while(!kbhit() && !ferror(smb.sid_fp) && msg.offset) {
msg.offset--; msg.offset--;
fseek(smb.sid_fp,msg.offset*sizeof(idxrec_t),SEEK_SET); fseek(smb.sid_fp,msg.offset*sizeof(idxrec_t),SEEK_SET);
...@@ -331,10 +311,12 @@ for(i=0;i<cfg.total_subs;i++) { ...@@ -331,10 +311,12 @@ for(i=0;i<cfg.total_subs;i++) {
continue; continue;
if((j=smb_lockmsghdr(&smb,&msg))!=0) { if((j=smb_lockmsghdr(&smb,&msg))!=0) {
printf("smb_lockmsghdr returned %d\n",j); printf("smb_lockmsghdr returned %d\n",j);
break; } break;
}
if((j=smb_getmsghdr(&smb,&msg))!=0) { if((j=smb_getmsghdr(&smb,&msg))!=0) {
printf("smb_getmsghdr returned %d\n",j); printf("smb_getmsghdr returned %d\n",j);
break; } break;
}
smb_unlockmsghdr(&smb,&msg); smb_unlockmsghdr(&smb,&msg);
if((mode&LOCAL && msg.from_net.type==NET_NONE) if((mode&LOCAL && msg.from_net.type==NET_NONE)
|| msg.from_net.type==NET_QWK) { || msg.from_net.type==NET_QWK) {
...@@ -342,7 +324,8 @@ for(i=0;i<cfg.total_subs;i++) { ...@@ -342,7 +324,8 @@ for(i=0;i<cfg.total_subs;i++) {
msg.from_net.addr=""; msg.from_net.addr="";
if(cmd&USERS) { if(cmd&USERS) {
sprintf(str,"%s%s",msg.from_net.addr,msg.from); sprintf(str,"%s%s",msg.from_net.addr,msg.from);
curcrc=crc32(str,0); } curcrc=crc32(str,0);
}
else else
curcrc=crc32(msg.from_net.addr,0); curcrc=crc32(msg.from_net.addr,0);
for(l=0;l<total_crcs;l++) for(l=0;l<total_crcs;l++)
...@@ -354,7 +337,8 @@ for(i=0;i<cfg.total_subs;i++) { ...@@ -354,7 +337,8 @@ for(i=0;i<cfg.total_subs;i++) {
,sizeof(ulong)*total_crcs))==NULL) { ,sizeof(ulong)*total_crcs))==NULL) {
printf("Error allocating %lu bytes\n" printf("Error allocating %lu bytes\n"
,sizeof(ulong)*total_crcs); ,sizeof(ulong)*total_crcs);
break; } break;
}
crc[l]=curcrc; crc[l]=curcrc;
if(cmd&ROUTE && msg.from_net.type==NET_QWK) { if(cmd&ROUTE && msg.from_net.type==NET_QWK) {
strcpy(addr,msg.from_net.addr); strcpy(addr,msg.from_net.addr);
...@@ -368,7 +352,8 @@ for(i=0;i<cfg.total_subs;i++) { ...@@ -368,7 +352,8 @@ for(i=0;i<cfg.total_subs;i++) {
,unixtodstr(&cfg,msg.hdr.when_written.time,tmp) ,unixtodstr(&cfg,msg.hdr.when_written.time,tmp)
,p,cfg.sys_id,p==addr ? 0 : '/' ,p,cfg.sys_id,p==addr ? 0 : '/'
,addr); ,addr);
fprintf(route,"%s\r\n",str); } fprintf(route,"%s\r\n",str);
}
else { else {
p=strrchr(addr,'/'); p=strrchr(addr,'/');
if(p) { if(p) {
...@@ -377,7 +362,10 @@ for(i=0;i<cfg.total_subs;i++) { ...@@ -377,7 +362,10 @@ for(i=0;i<cfg.total_subs;i++) {
,unixtodstr(&cfg,msg.hdr.when_written.time,str) ,unixtodstr(&cfg,msg.hdr.when_written.time,str)
,p ,p
,(uint)(p-addr) ,(uint)(p-addr)
,addr); } } } ,addr);
}
}
}
if(cmd&USERS) { if(cmd&USERS) {
if(msg.from_net.type!=NET_QWK) if(msg.from_net.type!=NET_QWK)
strcpy(str,cfg.sys_id); strcpy(str,cfg.sys_id);
...@@ -394,7 +382,8 @@ for(i=0;i<cfg.total_subs;i++) { ...@@ -394,7 +382,8 @@ for(i=0;i<cfg.total_subs;i++) {
else else
fprintf(users,"%-25.25s %-8.8s %s\r\n" fprintf(users,"%-25.25s %-8.8s %s\r\n"
,msg.from,str ,msg.from,str
,unixtodstr(&cfg,msg.hdr.when_written.time,tmp)); } ,unixtodstr(&cfg,msg.hdr.when_written.time,tmp));
}
if(cmd&NODES && msg.from_net.type==NET_QWK) { if(cmd&NODES && msg.from_net.type==NET_QWK) {
if(mode&TAGS) if(mode&TAGS)
gettag(msg,tag); gettag(msg,tag);
...@@ -412,20 +401,28 @@ for(i=0;i<cfg.total_subs;i++) { ...@@ -412,20 +401,28 @@ for(i=0;i<cfg.total_subs;i++) {
fprintf(nodes,"%-8.8s %s (%s)\r\n" fprintf(nodes,"%-8.8s %s (%s)\r\n"
,p+1 ,p+1
,unixtodstr(&cfg,msg.hdr.when_written.time,tmp) ,unixtodstr(&cfg,msg.hdr.when_written.time,tmp)
,str); } ,str);
}
else else
fprintf(nodes,"%-8.8s %s\r\n" fprintf(nodes,"%-8.8s %s\r\n"
,str ,str
,mode&TAGS ,mode&TAGS
? tag ? tag
: unixtodstr(&cfg,msg.hdr.when_written.time,tmp)); } : unixtodstr(&cfg,msg.hdr.when_written.time,tmp));
} } }
smb_freemsgmem(&msg); } }
}
smb_freemsgmem(&msg);
}
smb_close(&smb); smb_close(&smb);
if(kbhit()) { if(kbhit()) {
getch(); getch();
fprintf(stderr,"Key pressed.\n"); fprintf(stderr,"Key pressed.\n");
break; } } break;
}
}
fprintf(stderr,"Done.\n"); fprintf(stderr,"Done.\n");
return(0);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment