Skip to content
Snippets Groups Projects
Commit 7483ea84 authored by deuce's avatar deuce
Browse files

Fix dropfile and command line parsing, add an exit function which turns off

doorway mode.
parent 371f8fac
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,17 @@ ...@@ -2,8 +2,17 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
xpd_init();
xpd_parse_cmdline(argc, argv); xpd_parse_cmdline(argc, argv);
xpd_parse_dropfile(); xpd_parse_dropfile();
xpd_init();
cprintf("Drop path: %s\r\n",xpd_info.drop.path?xpd_info.drop.path:"<Unknown>");
cprintf("Welcome %s!\r\n\r\n",xpd_info.drop.user.full_name?xpd_info.drop.user.full_name:"<unknown>");
cputs("Press <ENTER> to exit: ");
getch();
cputs("\r\n");
xpd_exit();
return(1); return(1);
} }
...@@ -140,21 +140,37 @@ void xpd_parse_cmdline(int argc, char **argv) ...@@ -140,21 +140,37 @@ void xpd_parse_cmdline(int argc, char **argv)
int i; int i;
for(i=0; i<argc; i++) { for(i=0; i<argc; i++) {
if(strncmp(argv[i],"--io-type=",10)) { if(strncmp(argv[i],"--io-type=",10)==0) {
if(stricmp(argv[i]+10, "stdio")) if(stricmp(argv[i]+10, "stdio")==0)
xpd_info.io_type=XPD_IO_STDIO; xpd_info.io_type=XPD_IO_STDIO;
else if(stricmp(argv[i]+10, "com")) else if(stricmp(argv[i]+10, "com")==0)
xpd_info.io_type=XPD_IO_COM; xpd_info.io_type=XPD_IO_COM;
else if(stricmp(argv[i]+10, "socket")) else if(stricmp(argv[i]+10, "socket")==0)
xpd_info.io_type=XPD_IO_SOCKET; xpd_info.io_type=XPD_IO_SOCKET;
else if(stricmp(argv[i]+10, "telnet")) else if(stricmp(argv[i]+10, "telnet")==0)
xpd_info.io_type=XPD_IO_TELNET; xpd_info.io_type=XPD_IO_TELNET;
else if(stricmp(argv[i]+10, "local")) else if(stricmp(argv[i]+10, "local")==0)
xpd_info.io_type=XPD_IO_LOCAL; xpd_info.io_type=XPD_IO_LOCAL;
} }
else if(strncmp(argv[i],"--io-com=",9)==0) {
xpd_info.io_type=XPD_IO_COM;
xpd_info.io.com=atoi(argv[i]+9);
}
else if(strncmp(argv[i],"--io-socket=",12)==0) {
xpd_info.io_type=XPD_IO_SOCKET;
xpd_info.io.sock=atoi(argv[i]+12);
}
else if(strncmp(argv[i],"--drop-path=",12)==0) {
xpd_info.drop.path=strdup(argv[i]+12);
}
} }
} }
int xpd_exit()
{
ansi_ciolib_setdoorway(0);
}
int xpd_init() int xpd_init()
{ {
struct text_info ti; struct text_info ti;
...@@ -178,7 +194,7 @@ int xpd_init() ...@@ -178,7 +194,7 @@ int xpd_init()
#define GETBUF() if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing #define GETBUF() if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing
#define GETIBUF(x) if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing; x = atoi(buf) #define GETIBUF(x) if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing; x = atoi(buf)
#define GETSBUF(x) if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing; x = strdup(buf) #define GETSBUF(x) if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing; x = strdup(truncnl(buf))
#define GETDBUF(x) if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing; { \ #define GETDBUF(x) if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing; { \
int m,d,y; \ int m,d,y; \
char *p; \ char *p; \
...@@ -190,12 +206,24 @@ int xpd_init() ...@@ -190,12 +206,24 @@ int xpd_init()
if(p) { \ if(p) { \
y=strtol(buf,NULL,10); y+=(y<100?2000:1900); if(y > xpDateTime_now().date.year) y-=100; x = isoDate_create(y,m,d); \ y=strtol(buf,NULL,10); y+=(y<100?2000:1900); if(y > xpDateTime_now().date.year) y-=100; x = isoDate_create(y,m,d); \
}}}} }}}}
#define GETTBUF(x) if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing; { \
int h,m; \
char *p; \
p=strtok(buf,":"); \
if(p) { \
h=strtol(buf,NULL,10); p=strtok(NULL, ":"); \
if(p) { \
m=strtol(buf,NULL,10); x = isoTime_create(h,m,0); \
}}}
#define GETBBUF(x) if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing; if(buf[0]=='Y' || buf[0]=='y') x=TRUE
#define GETCBUF(x) if(fgets(buf,sizeof(buf),df)==NULL) goto done_parsing; x=buf[0]
int xpd_parse_dropfile() int xpd_parse_dropfile()
{ {
FILE *df=NULL; FILE *df=NULL;
char *p; char *p;
char buf[1024]; char buf[1024];
int tmp;
if(xpd_info.drop.path==NULL) if(xpd_info.drop.path==NULL)
goto error_return; goto error_return;
...@@ -205,10 +233,10 @@ int xpd_parse_dropfile() ...@@ -205,10 +233,10 @@ int xpd_parse_dropfile()
p=getfname(xpd_info.drop.path); p=getfname(xpd_info.drop.path);
if(p==NULL) if(p==NULL)
goto error_return; goto error_return;
if(stricmp(p,"door.sys")) { if(stricmp(p,"door.sys")==0) {
/* COM0:, COM1:, COM0:STDIO, COM0:SOCKET123 */ /* COM0:, COM1:, COM0:STDIO, COM0:SOCKET123 */
GETBUF(); GETBUF();
if(strcmp(buf,"COM0:STDIO"==0)) { if(strcmp(buf,"COM0:STDIO")==0) {
xpd_info.io_type=XPD_IO_STDIO; xpd_info.io_type=XPD_IO_STDIO;
} }
else if(strncmp(buf,"COM0:SOCKET",11)==0) { else if(strncmp(buf,"COM0:SOCKET",11)==0) {
...@@ -222,6 +250,7 @@ int xpd_parse_dropfile() ...@@ -222,6 +250,7 @@ int xpd_parse_dropfile()
GETBUF(); GETBUF();
GETBUF(); GETBUF();
GETBUF(); GETBUF();
GETBUF();
GETSBUF(xpd_info.drop.user.full_name); GETSBUF(xpd_info.drop.user.full_name);
GETSBUF(xpd_info.drop.user.location); GETSBUF(xpd_info.drop.user.location);
GETSBUF(xpd_info.drop.user.home_phone); GETSBUF(xpd_info.drop.user.home_phone);
...@@ -230,6 +259,46 @@ int xpd_parse_dropfile() ...@@ -230,6 +259,46 @@ int xpd_parse_dropfile()
GETIBUF(xpd_info.drop.user.level); GETIBUF(xpd_info.drop.user.level);
GETIBUF(xpd_info.drop.user.times_on); GETIBUF(xpd_info.drop.user.times_on);
GETDBUF(xpd_info.drop.user.last_call_date); GETDBUF(xpd_info.drop.user.last_call_date);
GETIBUF(xpd_info.drop.user.seconds_remaining);
GETIBUF(tmp);
if(tmp*60 > xpd_info.drop.user.seconds_remaining)
xpd_info.drop.user.seconds_remaining = tmp*60;
xpd_info.end_time=time(NULL)+xpd_info.drop.user.seconds_remaining;
GETBUF();
if(strcmp(buf,"GR"))
xpd_info.drop.user.dflags |= XPD_ANSI_SUPPORTED|XPD_CP437_SUPPORTED;
else if(strcmp(buf,"NG"))
xpd_info.drop.user.dflags |= XPD_CP437_SUPPORTED;
GETIBUF(xpd_info.drop.user.rows);
GETBBUF(xpd_info.drop.user.expert);
GETDBUF(xpd_info.drop.user.expiration);
GETIBUF(xpd_info.drop.user.number);
GETCBUF(xpd_info.drop.user.protocol);
GETIBUF(xpd_info.drop.user.uploads);
GETIBUF(xpd_info.drop.user.downloads);
GETIBUF(xpd_info.drop.user.download_k_today);
GETIBUF(xpd_info.drop.user.max_download_k_today);
GETDBUF(xpd_info.drop.user.birthday);
GETSBUF(xpd_info.drop.sys.main_dir);
GETSBUF(xpd_info.drop.sys.gen_dir);
GETSBUF(xpd_info.drop.sys.sysop_name);
GETSBUF(xpd_info.drop.user.alias);
GETBUF();
GETBUF();
GETBUF();
GETBUF();
GETIBUF(xpd_info.drop.sys.default_attr);
GETBUF();
GETBUF();
GETTBUF(xpd_info.drop.user.call_time);
GETTBUF(xpd_info.drop.user.last_call_time);
GETIBUF(xpd_info.drop.user.max_files_per_day);
GETIBUF(xpd_info.drop.user.downloads_today);
GETIBUF(xpd_info.drop.user.total_upload_k);
GETIBUF(xpd_info.drop.user.total_download_k);
GETSBUF(xpd_info.drop.user.comment);
GETIBUF(xpd_info.drop.user.total_doors);
GETIBUF(xpd_info.drop.user.total_messages);
} }
error_return: error_return:
...@@ -263,8 +332,8 @@ int xpd_rwrite(const char *data, int data_len) ...@@ -263,8 +332,8 @@ int xpd_rwrite(const char *data, int data_len)
ciolib_ansi_writebyte_cb=dummy_writebyte_cb; ciolib_ansi_writebyte_cb=dummy_writebyte_cb;
/* Send data to cterm */ /* Send data to cterm */
cterm_write(data, data_len, NULL, 0, NULL); cterm_write((char *)data, data_len, NULL, 0, NULL);
xpd_ansi_writestr_cb(data,data_len); xpd_ansi_writestr_cb((char *)data,data_len);
/* Re-enable ciolib */ /* Re-enable ciolib */
ciolib_ansi_writebyte_cb=xpd_ansi_writebyte_cb; ciolib_ansi_writebyte_cb=xpd_ansi_writebyte_cb;
......
...@@ -23,11 +23,12 @@ struct xpd_user_info { ...@@ -23,11 +23,12 @@ struct xpd_user_info {
int rows; int rows;
BOOL expert; BOOL expert;
isoDate_t expiration; isoDate_t expiration;
int user_num; int number;
char protocol; char protocol;
int uploads; int uploads;
int downloads; int downloads;
int download_k_today; // KiB downloaded today int download_k_today; // KiB downloaded today
int max_download_k_today; // KiB downloaded today
isoDate_t birthday; isoDate_t birthday;
char *alias; char *alias;
isoTime_t call_time; isoTime_t call_time;
...@@ -93,7 +94,6 @@ struct xpd_telnet_io { ...@@ -93,7 +94,6 @@ struct xpd_telnet_io {
struct xpd_info { struct xpd_info {
enum io_type io_type; enum io_type io_type;
int io_flags;
union { union {
COM_HANDLE com; COM_HANDLE com;
SOCKET sock; SOCKET sock;
...@@ -111,10 +111,15 @@ extern struct xpd_info xpd_info; ...@@ -111,10 +111,15 @@ extern struct xpd_info xpd_info;
void xpd_parse_cmdline(int argc, char **argv); void xpd_parse_cmdline(int argc, char **argv);
/* /*
* Initialize * Initialize (turns on Doorway mode)
*/ */
int xpd_init(); int xpd_init();
/*
* Exit (turns off Doorway mode)
*/
int xpd_exit(void);
/* /*
* Parse dropfile * Parse dropfile
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment