|
|
1.1 root 1: #line 1 "MAIN_WFC.C"
2:
3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
4:
5: #include "sbbs.h"
6: #include "etext.h"
7: #include "cmdshell.h"
8: #include "qwk.h"
9:
10: extern char onquiet,nmi,llo,qwklogon;
11: extern char term_ret;
12: extern ulong connect_rate; /* already connected at xbps */
13: extern char *wday[],*mon[];
14: extern char *hungupstr;
15: extern char cidarg[];
16:
17: void reset_logon_vars(void)
18: {
19: int i;
20:
21: sys_status&=~(SS_USERON|SS_TMPSYSOP|SS_LCHAT|SS_ABORT
22: |SS_PAUSEON|SS_PAUSEOFF|SS_EVENT|SS_NEWUSER|SS_NEWDAY);
23: keybufbot=keybuftop=lbuflen=slcnt=altul=timeleft_warn=0;
24: logon_uls=logon_ulb=logon_dls=logon_dlb=0;
25: logon_posts=logon_emails=logon_fbacks=0;
1.1.1.2 ! root 26: posts_read=0;
1.1 root 27: batdn_total=batup_total=0;
28: usrgrps=usrlibs=0;
29: curgrp=curlib=0;
30: for(i=0;i<total_libs;i++)
31: curdir[i]=0;
32: for(i=0;i<total_grps;i++)
33: cursub[i]=0;
34: }
35:
36: void mail_maint(void)
37: {
38: int i;
39:
40: lprintf("\r\n\r\nPurging deleted/expired e-mail...");
41: sprintf(smb.file,"%sMAIL",data_dir);
42: smb.retry_time=smb_retry_time;
43: if((i=smb_open(&smb))!=0)
44: errormsg(WHERE,ERR_OPEN,smb.file,i);
45: else {
46: if((i=smb_locksmbhdr(&smb))!=0)
47: errormsg(WHERE,ERR_LOCK,smb.file,i);
48: else
49: delmail(0,MAIL_ALL);
50: smb_close(&smb); }
51: }
52:
53: /*************************************************************/
54: /* Returns 0 to reinitialize modem and start WFC cycle again */
55: /* Returns 1 to continue checking things peacefully */
56: /*************************************************************/
57: char wfc_events(time_t lastnodechk)
58: {
59: char str[256],str2[256],*buf;
60: int i,j,k,file,ret=1,chunk;
61: ulong l,m;
62: user_t user;
63: node_t node;
64: struct ffblk ff;
65: struct tm *gm;
66: struct date lastdate;
67:
68: for(i=0;i<total_qhubs;i++) {
69: gm=localtime(&now); /* Qnet call out based on time */
70: unixtodos(qhub[i]->last,&date,&curtime);
71: if(node_num==qhub[i]->node /* or frequency */
72: && (qhub[i]->last==-1L
73: || ((qhub[i]->freq
74: && (now-qhub[i]->last)/60>qhub[i]->freq)
75: || (qhub[i]->time
76: && (gm->tm_hour*60)+gm->tm_min>=qhub[i]->time
77: && (gm->tm_mday!=date.da_day || gm->tm_mon!=date.da_mon-1)))
78: && qhub[i]->days&(1<<gm->tm_wday))) {
79: offhook();
80: lputc(FF);
81: sprintf(str,"%sQNET\\%s.NOW"
82: ,data_dir,qhub[i]->id);
83: remove(str); /* Remove semaphore file */
84: sprintf(str,"%sQNET\\%s.PTR"
85: ,data_dir,qhub[i]->id);
86: file=nopen(str,O_RDONLY);
87: for(j=0;j<qhub[i]->subs;j++) {
88: sub[qhub[i]->sub[j]]->ptr=0;
89: lseek(file,sub[qhub[i]->sub[j]]->ptridx*4L,SEEK_SET);
90: read(file,&sub[qhub[i]->sub[j]]->ptr,4); }
91: if(file!=-1)
92: close(file);
93: if(pack_rep(i)) {
94: if((file=nopen(str,O_WRONLY|O_CREAT))==-1)
95: errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_CREAT);
96: else {
97: for(j=l=0;j<qhub[i]->subs;j++) {
98: while(filelength(file)<sub[qhub[i]->sub[j]]->ptridx*4L)
99: write(file,&l,4); /* initialize ptrs to null */
100: lseek(file,sub[qhub[i]->sub[j]]->ptridx*4L,SEEK_SET);
101: write(file,&sub[qhub[i]->sub[j]]->ptr,4); }
102: close(file); } }
103: delfiles(temp_dir,"*.*");
104:
105: qhub[i]->last=time(NULL);
106: sprintf(str,"%sQNET.DAB",ctrl_dir);
107: if((file=nopen(str,O_WRONLY))==-1) {
108: errormsg(WHERE,ERR_OPEN,str,O_WRONLY);
109: bail(1); }
110: lseek(file,sizeof(time_t)*i,SEEK_SET);
111: write(file,&qhub[i]->last,sizeof(time_t));
112: close(file);
113:
114: if(qhub[i]->call[0]) {
115: getnodedat(node_num,&thisnode,1);
116: thisnode.status=NODE_NETTING;
117: putnodedat(node_num,thisnode);
118: lputc(FF);
119: external(cmdstr(qhub[i]->call,nulstr,nulstr,NULL),EX_SWAP);
120: ret=0; }
121: for(j=0;j<10;j++) {
122: sprintf(str,"%s%s.QW%c",data_dir,qhub[i]->id,j ? (j-1)+'0' : 'K');
123: if(fexist(str)) {
124: lclini(node_scrnlen-1);
125: delfiles(temp_dir,"*.*");
126: unpack_qwk(str,i); } }
127: lputc(FF); } }
128:
129: for(i=0;i<total_phubs;i++) {
130: gm=localtime(&now); /* PostLink call out based on time */
131: unixtodos(phub[i]->last,&date,&curtime);
132: if(node_num==phub[i]->node /* or frequency */
133: && ((phub[i]->freq
134: && (now-phub[i]->last)/60>phub[i]->freq)
135: || (phub[i]->time
136: && (gm->tm_hour*60)+gm->tm_min>=phub[i]->time
137: && (gm->tm_mday!=date.da_day || gm->tm_mon!=date.da_mon-1)))
138: && phub[i]->days&(1<<gm->tm_wday)) {
139: offhook();
140: lputc(FF);
141:
142: phub[i]->last=time(NULL);
143: sprintf(str,"%sPNET.DAB",ctrl_dir);
144: if((file=nopen(str,O_WRONLY))==-1) {
145: errormsg(WHERE,ERR_OPEN,str,O_WRONLY);
146: bail(1); }
147: lseek(file,sizeof(time_t)*i,SEEK_SET);
148: write(file,&phub[i]->last,sizeof(time_t));
149: close(file);
150:
151: if(phub[i]->call[0]) {
152: getnodedat(node_num,&thisnode,1);
153: thisnode.status=NODE_NETTING;
154: putnodedat(node_num,thisnode);
155: lputc(FF);
156: external(cmdstr(phub[i]->call,nulstr,nulstr,NULL),EX_SWAP);
157: ret=0; } } }
158:
159: for(i=0;i<total_events;i++) {
160: if(!event[i]->node || event[i]->node>sys_nodes)
161: continue;
162: gm=localtime(&now);
163: unixtodos(event[i]->last,&date,&curtime);
164: if(event[i]->last==-1
165: || ((gm->tm_hour*60)+gm->tm_min>=event[i]->time
166: && (gm->tm_mday!=date.da_day || gm->tm_mon!=date.da_mon-1)
167: && event[i]->days&(1<<gm->tm_wday))) {
168:
169: if(event[i]->misc&EVENT_EXCL) { /* exclusive event */
170: offhook();
171: lputc(FF);
172: if(event[i]->node!=node_num) {
173: lprintf("Waiting for node %d to run timed event.\r\n\r\n"
174: ,event[i]->node);
175: lputs("Hit any key to abort wait...");
176: getnodedat(node_num,&thisnode,1);
177: thisnode.status=NODE_EVENT_LIMBO;
178: thisnode.aux=event[i]->node;
179: putnodedat(node_num,thisnode);
180: lastnodechk=0; /* really last event time check */
181: while(!lkbrd(0)) {
182: mswait(1);
183: now=time(NULL);
184: if(now-lastnodechk<10)
185: continue;
186: getnodedat(node_num,&thisnode,0);
187: if(thisnode.misc&NODE_DOWN)
188: return(0);
189: lastnodechk=now;
190: sprintf(str,"%sTIME.DAB",ctrl_dir);
191: if((file=nopen(str,O_RDONLY))==-1) {
192: errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
193: event[i]->last=now;
194: return(0); }
195: lseek(file,(long)i*4L,SEEK_SET);
196: read(file,&event[i]->last,sizeof(time_t));
197: close(file);
198: if(now-event[i]->last<(60*60)) /* event is done */
199: break; }
200: sprintf(str,"%s%s.NOW",data_dir,event[i]->code);
201: remove(str);
202: event[i]->last=now;
203: ret=0; }
204: else {
205: lputs("Waiting for all nodes to become inactive before "
206: "running timed event.\r\n\r\n");
207: lputs("Hit any key to abort wait and run event now...\r\n\r\n");
208: getnodedat(node_num,&thisnode,1);
209: thisnode.status=NODE_EVENT_WAITING;
210: putnodedat(node_num,thisnode);
211: lastnodechk=0;
212: while(!lkbrd(0)) {
213: mswait(1);
214: now=time(NULL);
215: if(now-lastnodechk<10)
216: continue;
217: lastnodechk=now;
218: getnodedat(node_num,&thisnode,0);
219: if(thisnode.misc&NODE_DOWN)
220: return(0);
221: for(j=1;j<=sys_nodes;j++) {
222: if(j==node_num)
223: continue;
224: getnodedat(j,&node,0);
225: if(node.status!=NODE_OFFLINE
226: && node.status!=NODE_EVENT_LIMBO)
227: break; }
228: if(j>sys_nodes) /* all nodes either offline or in limbo */
229: break;
230: lprintf("\rWaiting for node %d (status=%d)"
231: ,j,node.status);
232: lputc(CLREOL); } } }
233: if(event[i]->node!=node_num)
234: event[i]->last=now;
235: else {
236: sprintf(str,"%s%s.NOW",data_dir,event[i]->code);
237: remove(str);
238: offhook();
239: lputc(FF);
240: getnodedat(node_num,&thisnode,1);
241: thisnode.status=NODE_EVENT_RUNNING;
242: putnodedat(node_num,thisnode);
243: if(event[i]->dir[0]) {
244: if(event[i]->dir[1]==':') /* drive letter specified */
245: setdisk(toupper(event[i]->dir[0])-'A');
246: if(chdir(event[i]->dir))
247: errormsg(WHERE,ERR_CHDIR,event[i]->dir,0); }
248:
249: external(cmdstr(event[i]->cmd,nulstr,nulstr,NULL),0); /* EX_CC */
250: event[i]->last=time(NULL);
251: sprintf(str,"%sTIME.DAB",ctrl_dir);
252: if((file=nopen(str,O_WRONLY))==-1) {
253: errormsg(WHERE,ERR_OPEN,str,O_WRONLY);
254: return(ret); }
255: lseek(file,(long)i*4L,SEEK_SET);
256: write(file,&event[i]->last,sizeof(time_t));
257: close(file);
258: ret=0; } } }
259:
260:
261: if(sys_status&SS_DAILY || thisnode.misc&NODE_EVENT) { /* daily events */
262:
263: offhook();
264: lputc(FF);
265:
266: if(sys_status&SS_DAILY) {
267:
268: getnodedat(node_num,&thisnode,1);
269: now=time(NULL);
270: j=lastuser();
271: thisnode.status=NODE_EVENT_RUNNING;
272: putnodedat(node_num,thisnode);
273:
274: lprintf("Running system daily maintenance...\r\n\r\n");
275: logentry("!:","Ran system daily maintenance");
276: for(i=1;i<=j;i++) {
277:
278: lprintf("\rChecking user %5u of %-5u",i,j);
279: user.number=i;
280: getuserdat(&user);
281:
282: /***********************************************/
283: /* Fix name (NAME.DAT and USER.DAT) mismatches */
284: /***********************************************/
285: if(user.misc&DELETED) {
286: if(strcmp(username(i,str2),"DELETED USER"))
287: putusername(i,nulstr);
288: continue; }
289:
290: if(strcmp(user.alias,username(i,str2)))
291: putusername(i,user.alias);
292:
293: if(!(user.misc&(DELETED|INACTIVE))
294: && user.expire && (ulong)user.expire<=(ulong)now) {
295: putsmsg(i,text[AccountHasExpired]);
296: sprintf(str,"%s #%u Expired",user.alias,user.number);
297: logentry("!%",str);
298: if(level_misc[user.level]&LEVEL_EXPTOVAL
299: && level_expireto[user.level]<10) {
300: user.flags1=val_flags1[level_expireto[user.level]];
301: user.flags2=val_flags2[level_expireto[user.level]];
302: user.flags3=val_flags3[level_expireto[user.level]];
303: user.flags4=val_flags4[level_expireto[user.level]];
304: user.exempt=val_exempt[level_expireto[user.level]];
305: user.rest=val_rest[level_expireto[user.level]];
306: if(val_expire[level_expireto[user.level]])
307: user.expire=now
308: +(val_expire[level_expireto[user.level]]*24*60*60);
309: else
310: user.expire=0;
311: user.level=val_level[level_expireto[user.level]]; }
312: else {
313: if(level_misc[user.level]&LEVEL_EXPTOLVL)
314: user.level=level_expireto[user.level];
315: else
316: user.level=expired_level;
317: user.flags1&=~expired_flags1; /* expired status */
318: user.flags2&=~expired_flags2; /* expired status */
319: user.flags3&=~expired_flags3; /* expired status */
320: user.flags4&=~expired_flags4; /* expired status */
321: user.exempt&=~expired_exempt;
322: user.rest|=expired_rest;
323: user.expire=0; }
324: putuserrec(i,U_LEVEL,2,itoa(user.level,str,10));
325: putuserrec(i,U_FLAGS1,8,ultoa(user.flags1,str,16));
326: putuserrec(i,U_FLAGS2,8,ultoa(user.flags2,str,16));
327: putuserrec(i,U_FLAGS3,8,ultoa(user.flags3,str,16));
328: putuserrec(i,U_FLAGS4,8,ultoa(user.flags4,str,16));
329: putuserrec(i,U_EXPIRE,8,ultoa(user.expire,str,16));
330: putuserrec(i,U_EXEMPT,8,ultoa(user.exempt,str,16));
331: putuserrec(i,U_REST,8,ultoa(user.rest,str,16));
332: if(expire_mod[0]) {
333: useron=user;
334: online=ON_LOCAL;
335: exec_bin(expire_mod,&main_csi);
336: online=0; }
337: }
338:
339: /***********************************************************/
340: /* Auto deletion based on expiration date or days inactive */
341: /***********************************************************/
342: if(!(user.exempt&FLAG('P')) /* Not a permanent account */
343: && !(user.misc&(DELETED|INACTIVE)) /* alive */
344: && (sys_autodel && (now-user.laston)/(long)(24L*60L*60L)
345: > sys_autodel)) { /* Inactive too long */
346: sprintf(str,"Auto-Deleted %s #%u",user.alias,user.number);
347: logentry("!*",str);
348: delallmail(i);
349: putusername(i,nulstr);
350: putuserrec(i,U_MISC,8,ultoa(user.misc|DELETED,str,16)); }
351:
352: if(!(user.misc&(DELETED|INACTIVE))
353: && preqwk_ar[0] && chk_ar(preqwk_ar,user)) { /* Pre-QWK */
354: for(k=1;k<=sys_nodes;k++) {
355: getnodedat(k,&node,0);
356: if((node.status==NODE_INUSE || node.status==NODE_QUIET
357: || node.status==NODE_LOGON) && node.useron==i)
358: break; }
359: if(k<=sys_nodes) /* Don't pre-pack with user online */
360: continue;
361: lclini(node_scrnlen-1);
362: lclatr(LIGHTGRAY);
363: lputc(FF);
364: console|=CON_L_ECHO;
365: lprintf("Pre-packing QWK for %s...\r\n"
366: ,user.alias);
367: useron=user;
368: online=ON_LOCAL;
369: statline=sys_def_stat;
370: statusline();
371: useron.qwk&=~QWK_FILES; /* turn off for pre-packing */
372: useron.misc|=(ANSI|COLOR);
373: delfiles(temp_dir,"*.*");
374: getmsgptrs();
375: getusrsubs();
376: batdn_total=0;
377: sprintf(str,"%sFILE\\%04u.QWK"
378: ,data_dir,useron.number);
379: if(pack_qwk(str,&l,1)) {
380: qwk_success(l,0,1);
381: putmsgptrs(); }
382: delfiles(temp_dir,"*.*");
383: lclatr(LIGHTGRAY);
384: lclini(node_scrnlen);
385: online=0;
386: lputc(FF); } }
387:
388: mail_maint();
389:
390: lprintf("\r\n\r\nRunning system daily event...\r\n");
391: logentry("!:","Ran system daily event");
392: sys_status&=~SS_DAILY;
393: if(sys_daily[0])
394: external(cmdstr(sys_daily,nulstr,nulstr,NULL),0); } /* EX_CC */
395:
396: if(thisnode.misc&NODE_EVENT) {
397: getnodedat(node_num,&thisnode,1);
398: thisnode.status=NODE_EVENT_RUNNING;
399: putnodedat(node_num,thisnode);
400: if(node_daily[0])
401: external(cmdstr(node_daily,nulstr,nulstr,NULL),0); /* EX_CC */
402: getnodedat(node_num,&thisnode,1);
403: thisnode.misc&=~NODE_EVENT;
404: putnodedat(node_num,thisnode); }
405: ret=0; }
406: return(ret);
407: }
408:
409: /****************************************************************************/
410: /* This function waits for either a caller or a local logon. It returns 0 */
411: /* if the user failed the logon procedure, a 1 if the user succeeded */
412: /* Called from function main */
413: /****************************************************************************/
414: char waitforcall()
415: {
416: static uint calls;
417: uchar str[256],str2[256],cname[LEN_CID+1],c,gotcaller=0,x,y,dcd,*p
418: ,ans=0,hbeat=0,menuon=0,blank=0
419: ,*ok=mdm_misc&MDM_VERBAL ? "OK":"0"
420:
421: /* IP logging vars added by enigma */
422: , ipstr[256], *ips;
423:
424: uint i,j,k,nodes,lastnodes=0;
425: long l,m;
426: int file,result_code=0;
427: time_t start,lastnodechk=0,laststatchk=0,laststatfdate=0;
428: node_t node;
429: struct tm *gm;
430: struct dfree d;
431: stats_t stats,node_stats;
432:
433: reset_logon_vars();
434: ipstr[0]=cid[0]=cname[0]=0;
435: online=console=0;
436: start=time(NULL);
437:
438: getnodedat(node_num,&thisnode,1);
439: thisnode.status=NODE_WFC;
440: thisnode.misc&=~(NODE_INTR|NODE_MSGW|NODE_NMSG|NODE_UDAT|NODE_POFF|NODE_AOFF);
441: putnodedat(node_num,thisnode);
442: catsyslog(0);
443: if(term_ret)
444: return(terminal());
445: /***
446: if(com_port)
447: rioctl(0x10f); /* for blanking debug line */
448: ***/
449:
450: if(qoc && calls) {
451: if(qoc==1)
452: offhook();
453: lclini(node_scrnlen);
454: lputc(FF);
455: bail(0); }
456: useron.misc=0;
457: rows=24;
458: lputc(FF);
459: if(node_misc&NM_RESETVID) {
460: textmode(C40);
461: textmode(C80);
462: _setcursortype(_NORMALCURSOR); }
463:
464: lclatr(curatr=LIGHTGRAY);
465: lclini(node_scrnlen);
466:
467:
468: lputc(FF);
469: if(com_port && !connect_rate) { /* Initialize the modem */
470: lprintf("\rSetting DTE rate: %lu baud",com_rate);
471: lputc(CLREOL);
472: #ifdef __OS2__
473: if((i=setbaud(com_rate))!=0) {
474: #else
475: if((i=setbaud((uint)(com_rate&0xffffL)))!=0) {
476: #endif
477: lprintf(" - Failed! (%d)\r\n",i);
478: bail(1); }
479: c=0;
480: if(!nmi && !(mdm_misc&MDM_DUMB)) /* if not dumb */
481: while(c<4) {
482: rioctl(IOFB);
483: rioctl(IOCM|PAUSE|ABORT);
484: rioctl(IOCS|PAUSE|ABORT);
485:
486: if(mdm_misc&MDM_CTS)
487: if(!(rioctl(IOSTATE)&CTS)) {
488: lputs("\rWaiting up to 30 seconds for CTS to raise ( )\b\b\b");
489: for(i=0;i<30 && !lkbrd(0);i++) { /* wait upto 15 seconds */
490: lprintf("%2d\b\b",i+1);
491: mswait(1000);
492: if(rioctl(IOSTATE)&CTS)
493: break; }
494: if(i==30) {
495: lputs("\r\n\r\nModem configured for hardware flow "
496: "control and CTS is stuck low.\r\n");
497: logline("@!","CTS stuck low. Can't initialize.");
498: bail(1); } }
499:
500: lputs("\rInitializing modem...");
501: lputc(CLREOL);
502:
503: dtr(5); /* in case we're still connected to somebody */
504: dtr(1);
505: mswait(750); /* DTR is sometimes slow */
506: rioctl(IOFB); /* crap comes in when dtr is raised ? */
507: if(rioctl(IOSTATE)&DCD && mdm_hang[0]) {
508: mdmcmd(mdm_hang);
509: if(strcmp(str,"0") && strcmp(str,"OK"))
510: getmdmstr(str,SEC_OK); }
511:
512: /******************************************/
513: /* Take phone off-hook while initializing */
514: /******************************************/
515: offhook();
516: getmdmstr(str,SEC_OK);
517: if(strcmp(str,"0") && strcmp(str,"OK"))
518: getmdmstr(str,SEC_OK);
519:
520: /*********************************************************/
521: /* Send User Configured (broken?) initialization strings */
522: /*********************************************************/
523: mdmcmd(mdm_init);
524: if(mdm_spec[0]) {
525: getmdmstr(str,SEC_OK);
526: if(strcmp(str,"0") && strcmp(str,"OK"))
527: getmdmstr(str,SEC_OK);
528: mdmcmd(mdm_spec); }
529: getmdmstr(str,SEC_OK);
530: if(strcmp(str,"0") && strcmp(str,"OK"))
531: getmdmstr(str,SEC_OK);
532:
533: /*****************************/
534: /* Send AT&C1 if DCD is high */
535: /*****************************/
536: if(rioctl(IOSTATE)&DCD) {
537: lputs("\r\nDCD is high. Sending AT&C1 to modem...");
538: mdmcmd("AT&C1");
539: getmdmstr(str,SEC_OK);
540: if(strcmp(str,ok))
541: getmdmstr(str,SEC_OK); }
542:
543: /**********************************************/
544: /* DCD still high? Pause and try dropping DTR */
545: /**********************************************/
546: if(rioctl(IOSTATE)&DCD) {
547: lputs("\r\nDCD is high. Pausing...");
548: dtr(0);
549: mswait(2000);
550: rioctl(MSR);
551: if(rioctl(IOSTATE)&DCD) {
552: lputs("\rDCD was high after modem init.\r\n");
553: logentry("@!","DCD was high after modem init");
554: if(mdm_misc&MDM_NODTR)
555: mdmcmd(mdm_hang);
556: else
557: dtr(15);
558: if(rioctl(IOSTATE)&DCD) {
559: lputs("Hanging up failed to lower DCD.\r\n");
560: logentry("@!","Hanging up failed to lower DCD");
561: if(++c==4)
562: break;
563: continue; } }
564: dtr(1); }
565:
566: /************************************************************/
567: /* Let's repair any damage the user configured init strings */
568: /* may have caused */
569: /************************************************************/
570: for(i=0;i<4;i++) {
571: rioctl(IOFB);
572: mdmcmd("AT");
573: if(!getmdmstr(str,SEC_OK) || !strcmp(str,ok))
574: break;
575: if(!strcmp(str,"AT")) { /* Echoing commands? */
576: getmdmstr(str,SEC_OK); /* Get OK */
577: lputs("\r\nCommand echoed. Sending ATE0 to modem...");
578: mdmcmd("ATE0"); }
579: else if(mdm_misc&MDM_VERBAL && !strcmp(str,"0")) { /* numeric? */
580: lputs("\r\nNumeric response. Sending ATV1 to modem...");
581: mdmcmd("ATV1"); }
582: else if(!(mdm_misc&MDM_VERBAL) && !strcmp(str,"OK")) {
583: lputs("\r\nVerbal response. Sending ATV0 to modem...");
584: mdmcmd("ATV0"); }
585: else {
586: lprintf("\r\nUnrecognized response '%s'. Sending AT to modem..."
587: ,str);
588: mdmcmd("AT"); }
589: if(getmdmstr(str,SEC_OK) && !strcmp(str,ok))
590: break; }
591:
592: /************************************************/
593: /* Put phone back on-hook and check result code */
594: /************************************************/
595: if(!mdm_hang[0])
596: mdmcmd("ATH");
597: else
598: mdmcmd(mdm_hang);
599: if(!getmdmstr(str,SEC_OK)) {
600: lputs("\r\nNo response.\r\n");
601: logentry("@!","No response"); }
602: else {
603: if(!strcmp(str,ok))
604: break;
605: lprintf("\r\nInvalid result code: '%s' "
606: "instead of '%s'.\r\n",str,ok);
607: sprintf(tmp,"Invalid result code: '%s' instead of '%s'.",str,ok);
608: logentry("@!",tmp); }
609: if(++c==4)
610: break;
611: rioini(0,0); /* remove com routines */
612: sys_status&=~SS_COMISR;
613: comini();
614: setrate(); }
615: if(c==4) {
616: lputs("\r\nModem failed initialization.\r\n");
617: errorlog("Modem failed initialization.");
618: offhook();
619: bail(1); }
620: lputc(FF); }
621:
622: else if(com_port && connect_rate) {
623: gotcaller=1;
624: console=CON_R_ECHO|CON_L_ECHO|CON_R_INPUT|CON_L_INPUT;
625: online=ON_REMOTE;
626: sprintf(connection,"%lu",connect_rate);
627: cur_rate=connect_rate;
628: cur_cps=connect_rate/10;
629: connect_rate=0;
630: if(cidarg[0]) { /* Caller-id passed as argument */
631: mdm_misc|=MDM_CALLERID;
632: p=strstr(cidarg,"NUMBER:");
633: if(p) p+=8;
634: else {
635: p=strstr(cidarg,"NMBR");
636: if(p) p+=7; }
637: if(p) { /* 3 message format */
638: sprintf(cid,"%.*s",LEN_CID,p);
639: for(i=strlen(cid);!isdigit(cid[i]) && i;i--)
640: ;
641: cid[i+1]=0; /* chop off non-numbers */
642: p=strstr(cidarg,"NAME:");
643: if(p) p+=6;
644: else {
645: p=strstr(cidarg,"NAME");
646: if(p) p+=7; }
647: if(p)
648: sprintf(cname,"%.*s",LEN_CID,p); }
649: else if(strlen(cidarg)>12) /* Single message format */
650: sprintf(cid,"%.*s",LEN_CID,cidarg+12);
651: else
652: sprintf(cid,"ERROR: '%s'",cidarg); } }
653:
654:
655: if(!online) {
656: /*******************************************************/
657: /* To make sure that BBS print routines work correctly */
658: /*******************************************************/
659: useron.number=1;
660: getuserdat(&useron);
661: if(!useron.number)
662: useron.misc=ANSI|COLOR; }
663:
664: useron.misc&=~UPAUSE; /* make sure pause is off */
665:
666: if(llo) {
667: quicklogonstuff();
668: sys_status&=~SS_USERON;
669: gotcaller=1; }
670:
671: if(!(useron.misc&EXPERT) && !gotcaller) { /* Novice sysop */
672: console=CON_L_ECHO;
673: online=ON_LOCAL;
674: lputc(FF);
675: tos=1;
676: lncntr=0;
677: menu("WFC");
678: menuon=1;
679: online=0; }
680:
681: while(!gotcaller) {
682: mswait(0); /* give up rest of time slice */
683:
684: console=CON_L_ECHO;
685: now=time(NULL);
686:
687: if(node_scrnblank && (now-start)/60>node_scrnblank
688: && !blank) { /* blank screen */
689: lputc(FF);
690: menuon=0;
691: blank=1; }
692: if(mdm_reinit && (now-start)/60>mdm_reinit) /* reinitialize modem */
693: return(0);
694: if(now-lastnodechk>node_sem_check) { /* check node.dab every x seconds */
695:
696: #if 1
697: if((i=heapcheck())!=_HEAPOK) {
698: lputc(FF);
699: offhook();
700: errormsg(WHERE,ERR_CHK,"heap",i);
701: bail(1); }
702: #endif
703:
704: for(i=0;i<total_qhubs;i++)
705: if(node_num==qhub[i]->node) {
706: sprintf(str,"%sQNET\\%s.NOW",data_dir,qhub[i]->id);
707: if(fexist(str))
708: qhub[i]->last=-1; }
709:
710: for(i=0;i<total_events;i++)
711: if(node_num==event[i]->node || event[i]->misc&EVENT_EXCL) {
712: sprintf(str,"%s%s.NOW",data_dir,event[i]->code);
713: if(fexist(str))
714: event[i]->last=-1; }
715:
716: lastnodechk=now;
717: getnodedat(node_num,&thisnode,0);
718: if(thisnode.misc&NODE_DOWN) {
719: lputc(FF);
720: offhook();
721: bail(0); }
722: if(thisnode.status!=NODE_WFC) {
723: getnodedat(node_num,&thisnode,1);
724: thisnode.status=NODE_WFC;
725: putnodedat(node_num,thisnode); }
726: if(thisnode.misc&NODE_RRUN) { /* Re-run the node */
727: offhook();
728: lputc(FF);
729: getnodedat(node_num,&thisnode,1);
730: thisnode.status=NODE_OFFLINE;
731: thisnode.misc=0;
732: putnodedat(node_num,thisnode);
733: close(nodefile);
734: close(node_ext);
735: sys_status&=~SS_NODEDAB;
736: if(sys_status&SS_LOGOPEN)
737: close(logfile);
738: if(sys_status&SS_COMISR)
739: rioini(0,0);
740: sys_status&=~(SS_COMISR|SS_INITIAL|SS_LOGOPEN);
741: p=strchr(orgcmd,' ');
742: if(p)
743: p++;
744: close(5);
745: if(execle(orgcmd,orgcmd,p,NULL,envp)) {
746: lprintf("\r\nCouldn't execute %s!\r\n",orgcmd);
747: bail(1); } } }
748:
749: if(!wfc_events(lastnodechk))
750: return(0);
751:
752: if(!menuon) {
753: /******************/
754: /* Roaming cursor */
755: /******************/
756: x=lclwx();
757: y=lclwy();
758: switch(random(5)) {
759: case 0:
760: if(x>1)
761: x--;
762: break;
763: case 1:
764: if(x<79)
765: x++;
766: break;
767: case 2:
768: if(y>1)
769: y--;
770: break;
771: case 4:
772: if(y<node_scrnlen-2)
773: y++;
774: break; } }
775: else { /* across the bottom */
776: y=25;
777: x=lclwx();
778: if(x%2) x+=2;
779: else x-=2;
780: if(x<1)
781: x=1;
782: else if(x>80)
783: x=80;
784: /*
785: lclxy(x,y);
786: gettext(x,y,x,y,&i);
787: lclatr(random(0xf)+1);
788: lputc(i);
789: lclatr(LIGHTGRAY);
790: */
791: /**
792: mswait(100);
793: puttext(x,y,x,y,&i);
794: **/ }
795:
796: #ifndef __FLAT__ // Heart beat always for 32-bit OSs
797: if(inDV) {
798: #endif
799: lclxy(80,1);
800: if(hbeat) {
801: lclatr(RED|HIGH);
802: lputc(3); }
803: else
804: lputc(0);
805: hbeat=!hbeat;
806: lclatr(LIGHTGRAY);
807: #ifndef __FLAT__
808: }
809: #endif
810:
811: lclxy(x,y);
812: mswait(100);
813:
814: /* Wait for call screen */
815: /* check every 10 seconds */
816:
817: if(node_misc&NM_WFCSCRN && now-laststatchk>node_stat_check
818: && !menuon && !blank) {
819: laststatchk=now;
820: sprintf(str,"%sDSTS.DAB",ctrl_dir);
821: if(fdate(str)!=laststatfdate) { /* system statistics */
822: lclxy(1,1);
823: lclatr(LIGHTGRAY);
824: lputs("Retrieving Statistics.");
825: lputc(CLREOL);
826: if(!laststatfdate) /* First time this WFC */
827: getstats(node_num,&node_stats);
828: lputc('.');
829: laststatfdate=fdate(str);
830: getstats(0,&stats);
831: lputc('.');
832: l=m=0;
833: if(node_misc&NM_WFCMSGS) {
834: for(i=0;i<total_subs;i++)
835: l+=getposts(i); /* l=total posts */
836: lputc('.');
837: for(i=0;i<total_dirs;i++)
838: m+=getfiles(i); /* m=total files */
839: lputc('.'); }
840: i=getmail(0,0); /* i=total email */
841: lputc('.');
842: j=getmail(1,0); /* j=total fback */
843: lclxy(1,1);
844: lclatr(GREEN);
845: lprintf("Node #: ");
846: lclatr(GREEN|HIGH);
847: gm=localtime(&now);
848: lprintf("%-3u ",node_num);
849: lclatr(GREEN);
850: lprintf("%-3.3s %-2u Space: ",mon[gm->tm_mon],gm->tm_mday);
851: if(temp_dir[1]==':')
852: k=temp_dir[0]-'A'+1;
853: else k=0;
854: getdfree(k,&d);
855: if((ulong)d.df_bsec*(ulong)d.df_sclus
856: *(ulong)d.df_avail<((ulong)min_dspace*1024L)*2L)
857: lclatr(RED|HIGH|BLINK);
858: else
859: lclatr(GREEN|HIGH);
860: sprintf(str,"%sk",ultoac(((ulong)d.df_bsec
861: *(ulong)d.df_sclus*(ulong)d.df_avail)/1024UL,tmp));
862: lprintf("%-12.12s",str);
863: if(lastuseron[0]) {
864: lclatr(GREEN);
865: lprintf("Laston: ");
866: lclatr(GREEN|HIGH);
867: lprintf(lastuseron);
868: lclatr(GREEN);
869: if(thisnode.connection)
870: lprintf(" %u",thisnode.connection);
871: else
872: lprintf(" Local"); }
873: lprintf("\r\n");
874: lclatr(GREEN);
875: lprintf("Logons: ");
876: lclatr(GREEN|HIGH);
877: sprintf(tmp,"%lu/%lu",node_stats.ltoday,stats.ltoday);
878: lprintf("%-12.12s",tmp);
879: lclatr(GREEN);
880: lprintf("Total: ");
881: lclatr(GREEN|HIGH);
882: lprintf("%-12.12s",ultoac(stats.logons,tmp));
883: lclatr(GREEN);
884: lprintf("Timeon: ");
885: lclatr(GREEN|HIGH);
886: sprintf(tmp,"%lu/%lu",node_stats.ttoday,stats.ttoday);
887: lprintf("%-12.12s",tmp);
888: lclatr(GREEN);
889: lprintf("Total: ");
890: lclatr(GREEN|HIGH);
891: lprintf("%-12.12s\r\n",ultoac(stats.timeon,tmp));
892: lclatr(GREEN);
893: lprintf("Emails: ");
894: lclatr(GREEN|HIGH);
895: sprintf(str,"%u/%u",(uint)stats.etoday,i);
896: lprintf("%-12.12s",str);
897: lclatr(GREEN);
898: lprintf("Posts: ");
899: lclatr(GREEN|HIGH);
900: sprintf(str,"%u",(uint)stats.ptoday);
901: if(node_misc&NM_WFCMSGS) {
902: strcat(str,"/");
903: strcat(str,ultoa(l,tmp,10)); }
904: lprintf("%-12.12s",str);
905: lclatr(GREEN);
906: lprintf("Fbacks: ");
907: lclatr(GREEN|HIGH);
908: sprintf(str,"%u/%u",(uint)stats.ftoday,j);
909: lprintf("%-12.12s",str);
910: lclatr(GREEN);
911: lprintf("Users: ");
912: lclatr(GREEN|HIGH);
913: sprintf(str,"%u/%u",stats.nusers,lastuser());
914: lprintf("%-12.12s\r\n",str);
915: lclatr(GREEN);
916: lprintf("Uloads: ");
917: lclatr(GREEN|HIGH);
918: ultoac(stats.ulb/1024UL,tmp);
919: strcat(tmp,"k");
920: lprintf("%-12.12s",tmp);
921: lclatr(GREEN);
922: lprintf("Files: ");
923: lclatr(GREEN|HIGH);
924: sprintf(str,"%u",(uint)stats.uls);
925: if(node_misc&NM_WFCMSGS) {
926: strcat(str,"/");
927: strcat(str,ultoa(m,tmp,10)); }
928: lprintf("%-12.12s",str);
929: lclatr(GREEN);
930: lprintf("Dloads: ");
931: lclatr(GREEN|HIGH);
932: ultoac(stats.dlb/1024UL,tmp);
933: strcat(tmp,"k");
934: lprintf("%-12.12s",tmp);
935: lclatr(GREEN);
936: lprintf("Files: ");
937: lclatr(GREEN|HIGH);
938: lprintf("%-12.12s\r\n",ultoac(stats.dls,tmp)); }
939: lclatr(curatr=LIGHTGRAY);
940: lclxy(1,6);
941: nodes=0;
942: for(i=1;i<=sys_nodes;i++) {
943: getnodedat(i,&node,0);
944: if((node.status!=NODE_WFC && node.status!=NODE_OFFLINE)
945: || node.errors) {
946: lputc(CLREOL);
947: printnodedat(i,node);
948: nodes++; } }
949: if(nodes<lastnodes) {
950: i=j=lclwy();
951: j+=(lastnodes-nodes)+1;
952: for(;i<=node_scrnlen && i<j;i++) {
953: lclxy(1,i);
954: lputc(CLREOL); } }
955: lastnodes=nodes;
956: lclatr(curatr=LIGHTGRAY); }
957:
958:
959: if(!(node_misc&NM_NO_LKBRD) && lkbrd(1)) {
960: start=time(NULL);
961: /* menuon=0; */
962: lputc(FF);
963: tos=1;
964: lncntr=0;
965: i=lkbrd(0);
966: if(!(i&0xff) && (i>=0x3b00 && i<=0x4400)
967: || i==0x8500 || i==0x8600) { /* F1-F12 */
968: if(i>=0x3b00 && i<=0x4400)
969: i=((i-0x3b00)>>8);
970: else if(i==0x8500)
971: i=10;
972: else
973: i=11;
974: offhook();
975: external(cmdstr(wfc_scmd[i],nulstr,nulstr,NULL),EX_SWAP);
976: return(0); }
977:
978: if(isdigit(i&0xff)) {
979: offhook();
980: external(cmdstr(wfc_cmd[i&0xf],nulstr,nulstr,NULL),0);
981: return(0); }
982:
983: switch(toupper(i)) {
984: case 'A': /* forced answer */
985: ans=1;
986: break;
987: case 'C': /* configure */
988: if(node_misc&NM_SYSPW) {
989: quicklogonstuff();
990: if(!chksyspass(1))
991: return(0); }
992: offhook();
993: if(sys_status&SS_LOGOPEN) {
994: close(logfile);
995: sys_status&=~SS_LOGOPEN; }
996: if(sys_status&SS_COMISR) {
997: rioini(0,0); /* replace COM i/o vectors */
998: sys_status&=~SS_COMISR; }
999: close(nodefile);
1000: close(node_ext);
1001: sys_status&=~SS_NODEDAB;
1002: sprintf(str,"%sEXECSBBS.%s",exec_dir,
1003: #ifdef __OS2__
1004: "EXE"
1005: #else
1006: "COM"
1007: #endif
1008: );
1009: sprintf(tmp,"\"%s \"",cmdstr(scfg_cmd,nulstr,nulstr,NULL));
1010: if(execl(str,str,".",tmp,orgcmd,NULL,envp)) {
1011: errormsg(WHERE,ERR_EXEC,str,0);
1012: bail(1); }
1013: case 'D': /* Dos shell */
1014: offhook();
1015: external(comspec,0);
1016: return(0);
1017: case 'F': /* Force Network Call-out */
1018: quicklogonstuff();
1019: lclatr(YELLOW);
1020: lputs("QWK Hub ID: ");
1021: lclatr(WHITE);
1022: if(!getstr(str,8,K_UPPER))
1023: return(0);
1024: for(i=0;i<total_qhubs;i++)
1025: if(!stricmp(str,qhub[i]->id)) {
1026: if(qhub[i]->node==node_num)
1027: qhub[i]->last=-1;
1028: else {
1029: sprintf(tmp,"%sQNET\\%s.NOW",data_dir,str);
1030: if((file=nopen(tmp,O_CREAT|O_TRUNC|O_WRONLY))
1031: !=-1)
1032: close(file); }
1033: break; }
1034: return(0);
1035: case 'L': /* Log */
1036: if(node_misc&NM_SYSPW) {
1037: quicklogonstuff();
1038: if(!chksyspass(1))
1039: return(0); }
1040: offhook();
1041: now=time(NULL);
1042: unixtodos(now,&date,&curtime);
1043: sprintf(str,"%sLOGS\\%2.2d%2.2d%2.2d.LOG"
1.1.1.2 ! root 1044: ,data_dir,date.da_mon,date.da_day,TM_YEAR(date.da_year-1900));
1.1 root 1045: external(cmdstr(node_viewer,str,nulstr,NULL),0);
1046: return(0);
1047: case 'M': /* Read all mail */
1048: quicklogonstuff();
1049: if(node_misc&NM_SYSPW && !chksyspass(1))
1050: return(0);
1051: readmail(1,MAIL_ALL);
1052: online=console=0;
1053: return(0);
1054: case 'N': /* Node statistics */
1055: quicklogonstuff();
1056: if(node_misc&NM_SYSPW && !chksyspass(1))
1057: return(0);
1058: useron.misc|=UPAUSE;
1059: printstatslog(node_num);
1060: pause();
1061: return(0);
1062: case 'Q': /* Quit */
1063: offhook();
1064: bail(0);
1065: case 'R': /* Read feedback */
1066: quicklogonstuff();
1067: if(node_misc&NM_SYSPW && !chksyspass(1))
1068: return(0);
1069: readmail(1,MAIL_YOUR);
1070: return(0);
1071: case 'K': /* Sent mail */
1072: quicklogonstuff();
1073: if(node_misc&NM_SYSPW && !chksyspass(1))
1074: return(0);
1075: readmail(1,MAIL_SENT);
1076: return(0);
1077: case 'S': /* System Statistics */
1078: quicklogonstuff();
1079: if(node_misc&NM_SYSPW && !chksyspass(1))
1080: return(0);
1081: useron.misc|=UPAUSE;
1082: printstatslog(0);
1083: pause();
1084: return(0);
1085: case 'T': /* Terminal mode */
1086: if(!com_port) {
1087: lprintf("No COM port configured.");
1088: getch();
1089: lputc(FF);
1090: return(0); }
1091: if(node_misc&NM_SYSPW) {
1092: quicklogonstuff();
1093: if(!chksyspass(1))
1094: return(0); }
1095: return(terminal());
1096: case 'U': /* User edit */
1097: quicklogonstuff();
1098: useredit(0,1);
1099: return(0);
1100: case 'E':
1101: case 'W': /* Write e-mail */
1102: quicklogonstuff();
1103: if(node_misc&NM_SYSPW && !chksyspass(1))
1104: return(0);
1105: bputs(text[Email]);
1106: if(!getstr(str,50,0))
1107: return(0);
1108: if(!strchr(str,'@') && (i=finduser(str))!=0)
1109: email(i,nulstr,nulstr,WM_EMAIL);
1110: else
1111: netmail(str,nulstr,0);
1112: return(0);
1113: case 'X': /* Exit with phone on-hook */
1114: bail(0);
1115: case 'Y': /* Yesterday's log */
1116: if(node_misc&NM_SYSPW) {
1117: quicklogonstuff();
1118: if(!chksyspass(1))
1119: return(0); }
1120: offhook();
1121: now=time(NULL);
1122: now-=(ulong)60L*24L*60L;
1123: unixtodos(now,&date,&curtime);
1124: sprintf(str,"%sLOGS\\%2.2d%2.2d%2.2d.LOG"
1.1.1.2 ! root 1125: ,data_dir,date.da_mon,date.da_day,TM_YEAR(date.da_year-1900));
1.1 root 1126: external(cmdstr(node_viewer,str,nulstr,NULL),0);
1127: return(0);
1128: case 'Z':
1129: mail_maint();
1130: return(0);
1131: case '?': /* Menu */
1132: if(menuon) {
1133: menuon=0;
1134: lputc(FF);
1135: laststatchk=0;
1136: laststatfdate=0; }
1137: else {
1138: online=ON_LOCAL;
1139: menu("WFC");
1140: menuon=1;
1141: blank=0;
1142: online=0; }
1143: continue;
1144: case SP: /* Log on */
1145: lclatr(WHITE|HIGH); lputc('Y'); lclatr(GREEN);
1146: lputs(" Yes\r\n");
1147: lclatr(WHITE|HIGH); lputc('Z'); lclatr(GREEN);
1148: lputs(" Yes, Quiet\r\n");
1149: lclatr(WHITE|HIGH); lputc('F'); lclatr(GREEN);
1150: lputs(" Fast User #1\r\n");
1151: lclatr(WHITE|HIGH); lputc('Q'); lclatr(GREEN);
1152: lputs(" Fast User #1, Quiet\r\n");
1153: lclatr(BROWN|HIGH);
1154: lputs("\r\nLog on? [No]: ");
1155: lclatr(LIGHTGRAY);
1156: i=getch();
1157: switch(toupper(i)) {
1158: case 'Z':
1159: onquiet=1;
1160: case 'Y': /* Yes, logon */
1161: lputc(FF);
1162: quicklogonstuff();
1163: sys_status&=~SS_USERON;
1164: useron.misc=(UPAUSE|ANSI|COLOR);
1165: gotcaller=1;
1166: continue;
1167: case 'Q':
1168: onquiet=1;
1169: case 'F':
1170: lputc(FF);
1171: quicklogonstuff();
1172: if(sys_misc&SM_REQ_PW || node_misc&NM_SYSPW) {
1173: useron.misc=(UPAUSE|ANSI|COLOR);
1174: gotcaller=1;
1175: continue; }
1176: if(!useron.number) {
1177: lputc(7);
1178: lputs("A Sysop account hasn't been created");
1179: getch();
1180: return(0); }
1181: return(logon());
1182: default:
1183: return(0); }
1184: default:
1185: lputs("Hit '?' for a menu.");
1186: continue; } }
1187: if(com_port) {
1188: if(mdm_misc&MDM_VERBAL) {
1189: if(rioctl(RXBC)) {
1190: lputc(FF);
1191: getmdmstr(str,SEC_RING);
1192: if(!strcmp(str,"RING"))
1193: ans=1; } }
1194: else { /* numeric */
1195: if(incom()=='2')
1196: ans=1; }
1197: if(mdm_misc&MDM_DUMB && DCDHIGH)
1198: ans=1; }
1.1.1.2 ! root 1199: if(ans && com_port) {
1.1 root 1200: lputc(FF);
1201: if(mdm_misc&MDM_CALLERID) {
1202: lputs("Obtaining Caller-ID...");
1203: getmdmstr(str,SEC_CID);
1204: lprintf("\r\nCID: %s",str);
1205: if(!strncmpi(str,"TIME:",5)) { /* 3 message format */
1206: getmdmstr(str,SEC_CID);
1207: lprintf("\r\nCID: %s",str);
1208: p=strchr(str,':');
1209: if(p)
1210: strcpy(cid,p+2); /* Phone Number */
1211: getmdmstr(str,SEC_CID);
1212: lprintf("\r\nCID: %s",str);
1213: p=strchr(str,':');
1214: if(p)
1215: sprintf(cname,"%.*s",LEN_CID,p+2); } /* Caller Name */
1216: else if(!strncmpi(str,"DATE =",6)) { /* Supra format */
1217: getmdmstr(str,SEC_CID);
1218: lprintf("\r\nCID: %s",str); /* TIME = line */
1219: getmdmstr(str,SEC_CID);
1220: lprintf("\r\nCID: %s",str); /* NMBR = line */
1221: p=strchr(str,'=');
1222: if(p)
1223: sprintf(strstr(str,"NAME") ? cname:cid,"%.*s",LEN_CID,p+2);
1224: getmdmstr(str,SEC_CID); /* NAME = line */
1225: lprintf("\r\nCID: %s",str);
1226: p=strchr(str,'=');
1227: if(p)
1228: sprintf(strstr(str,"NAME") ? cname:cid,"%.*s",LEN_CID,p+2);
1229: }
1230: else if(strlen(str)>12) /* Single message format */
1231: sprintf(cid,"%.*s",LEN_CID,str+12);
1232: else
1233: sprintf(cid,"ERROR: '%s'",str);
1234: lputs(crlf); }
1235: cur_rate=cur_cps=0;
1236: connection[0]=0;
1237: result_code=0;
1238: if(!(mdm_misc&MDM_DUMB)) {
1239: if(mdm_rings>1) {
1240: lputs("Ring\r\n");
1241: for(i=1;i<mdm_rings;i++)
1242: if(!getmdmstr(str,10))
1243: break;
1244: else
1245: lputs("Ring\r\n");
1246: if(i<mdm_rings)
1247: return(0);
1248: lputs(crlf); }
1249: lputs("Answering...");
1250: mdmcmd(mdm_answ);
1251: rioctl(IOFI); // flush extra ring results
1252: while(!cur_rate || rioctl(RXBC)) { // no connect or more rsults
1253: if(!getmdmstr(str,SEC_ANSWER)) {
1254: if(cur_rate)
1255: break;
1256: lprintf("\r\nNO CARRIER\r\n");
1257: if(!(mdm_misc&MDM_NODTR)) {
1258: dtr(15);
1259: dtr(1);
1260: mswait(500); }
1261: mdmcmd(nulstr);
1262: hangup();
1263: return(0); }
1264: i=0;
1265: while(i<2
1266: && (!strcmp(str,"2")
1267: || !strcmp(str,"RING"))) { /* Ring? Get next result */
1268: lputs("Ring\r\n");
1269: if(i) {
1270: mdmcmd(mdm_answ); /* Give a second ATA */
1271: rioctl(IOFI); }
1272: if(!getmdmstr(str,SEC_ANSWER)) {
1273: if(!(mdm_misc&MDM_NODTR)) {
1274: dtr(15);
1275: dtr(1);
1276: mswait(500); }
1277: mdmcmd(nulstr);
1278: hangup(); /* Get next result code from modem */
1279: return(0); }
1280: i++; }
1281: if(!strcmp(str,"3") || !strcmp(str,"NO CARRIER")) {
1282: lprintf("\r\nNO CARRIER\r\n");
1283: hangup();
1284: return(0); }
1285:
1286: lprintf("\r\nResult Code: %s\r\n",str);
1287:
1288: /* IP (vmodem) logging additions by enigma */
1289: ips = strstr(str, "TEL FROM ");
1290: if(ips) {
1291: strcpy(ipstr, ips+9);
1292: }
1293:
1294: if(strstr(str,"FAX") || strstr(str,"+FCO")) {
1295: /* Just for the ZyXEL's */
1296: mswait(1500); /* 1 and a half second wait for ZyXEL */
1297: sys_misc&=~SM_ERRALARM;
1298: bail(100); }
1299:
1300: if(mdm_misc&MDM_VERBAL) {
1301: if(!cur_rate
1302: && (!strnicmp(str,"CONNECT ",8)
1303: || !strnicmp(str,"CARRIER ",8))) {
1304: cur_rate=atol(str+8);
1305: // build description
1306: for(i=8,j=0;str[i] && j<LEN_MODEM;i++) {
1307: if(j==2 && isdigit(str[i])
1308: && str[i+1]=='0' && str[i+2]=='0'
1309: && !isdigit(str[i+3]) && j+1<LEN_MODEM) {
1310: connection[j++]='.';
1311: connection[j++]=str[i];
1312: i+=2; }
1313: else
1314: connection[j++]=str[i]; }
1315: connection[j]=0; }
1316: if(!cur_rate && !strcmp(str,"CONNECT"))
1317: cur_rate=com_rate;
1318: if(cur_rate
1319: && (strstr(str,"ARQ") || strstr(str,"MNP")
1320: || strstr(str,"V42") || strstr(str,"LAPM")
1321: || strstr(str,"REL")))
1322: cur_cps=cur_rate/9; }
1323: else { /* numeric */
1324: j=atoi(str);
1325: for(i=0;i<mdm_results;i++)
1326: if(mdm_result[i].code==j) break;
1327: if(!cur_rate) {
1328: if(i==mdm_results) {
1329: lprintf("Unknown result code: '%s'\r\n",str);
1330: sprintf(tmp,"Unknown modem result code: '%s'",str);
1331: errorlog(tmp);
1332: if(mdm_misc&MDM_KNOWNRES || !mdm_results) {
1333: hangup();
1334: return(0); } /* Don't allow invalid codes */
1335: i--; } /* Use last configured result code */
1336: else
1337: result_code=mdm_result[i].code; }
1338: if(!strncmpi(mdm_result[i].str,"EXIT ",5))
1339: bail(atoi(mdm_result[i].str+5));
1340: if(!strcmpi(mdm_result[i].str,"FAX")) {
1341: lputs("FAX Connection\r\n");
1342: bail(100); }
1343: if(!strcmpi(mdm_result[i].str,"IGNORE") || cur_rate)
1344: lputs("Ignored\r\n");
1345: else {
1346: cur_rate=mdm_result[i].rate;
1347: cur_cps=mdm_result[i].cps;
1348: strcpy(connection,mdm_result[i].str); } } } }
1349: else /* dumb modem */
1350: cur_rate=com_rate;
1351:
1352: if(!connection[0])
1353: sprintf(connection,"%lu",cur_rate);
1354: lprintf("Logging Caller in at %s\r\n",connection);
1355: if(!cur_cps)
1356: cur_cps=cur_rate/10L;
1357:
1358: rioctl(IOCE|((RXLOST|FERR|PERR|OVRR)<<8)); /* clear error flags */
1359: console=CON_R_ECHO|CON_L_ECHO|CON_R_INPUT|CON_L_INPUT;
1360: online=ON_REMOTE;
1361: gotcaller=1;
1362: putcom(crlf);
1363: #if defined(__OS2__)
1364: putcom(decrypt(VersionNoticeOS2,0));
1365: #elif defined(__WIN32__)
1366: putcom(decrypt(VersionNoticeW32,0));
1367: #else
1368: putcom(decrypt(VersionNoticeDOS,0));
1369: #endif
1370: putcom(crlf);
1371: lprintf("Pausing %u Seconds...",mdm_ansdelay);
1372: if(node_misc&NM_ANSALARM) {
1373: now=time(NULL);
1374: while(time(NULL)-now<mdm_ansdelay)
1375: for(x=0;x<10;x++)
1376: for(y=0;y<10;y++)
1377: beep((x*100)+(y*5),10); }
1378: else
1379: secwait(mdm_ansdelay);
1380: nosound();
1381: rioctl(IOFI); } } /* flush input buffer */
1382:
1383: reset_logon_vars();
1384: calls++;
1385: useron.misc=0;
1386: answertime=logontime=starttime=time(NULL);
1387: if(online==ON_REMOTE) {
1388: setrate();
1389:
1390: now=time(NULL);
1391: gm=localtime(&now);
1392: sprintf(str,"%02d:%02d%c %s %s %02d %u Node %3u %5lubps (%s)"
1393: ,gm->tm_hour>12 ? gm->tm_hour-12 : gm->tm_hour==0 ? 12 : gm->tm_hour
1394: ,gm->tm_min,gm->tm_hour>=12 ? 'p' : 'a',wday[gm->tm_wday]
1395: ,mon[gm->tm_mon],gm->tm_mday,gm->tm_year+1900,node_num,cur_rate
1396: ,connection);
1397: if(result_code) {
1398: sprintf(tmp," [%d]",result_code);
1399: strcat(str,tmp); }
1400: logline("@",str);
1401:
1402: /* IP trashcan modification by enigma */
1403: if(trashcan(ipstr,"IP")) {
1404: sprintf(tmp, "IP Trashcan: %s, hanging up!\r\n", ipstr);
1405: logline("@!",tmp);
1406: hangup();
1407: return(0); }
1408:
1409: if(mdm_misc&MDM_CALLERID) {
1410: outcom(0xC);
1411: #if defined(__OS2__)
1412: putcom(decrypt(VersionNoticeOS2,0));
1413: #elif defined(__WIN32__)
1414: putcom(decrypt(VersionNoticeW32,0));
1415: #else
1416: putcom(decrypt(VersionNoticeDOS,0));
1417: #endif
1418: putcom(crlf);
1419: sprintf(str,"CID: %-*s %s",LEN_CID,cid,cname);
1420: logline("@*",str);
1421: if(trashcan(cid,"CID")) {
1422: hangup();
1423: return(0); } } }
1424: lclini(node_scrnlen-1);
1425: if(online==ON_REMOTE) {
1426: if(node_dollars_per_call) { /* Billing node stuff */
1427: now=time(NULL);
1428: bprintf(text[BillingNodeMsg],sys_name,node_dollars_per_call);
1429: while(online && now-answertime<30) {
1430: if(incom()!=NOINP) {
1431: if(!(mdm_misc&MDM_NODTR))
1432: dtr(15);
1433: else
1434: mdmcmd(mdm_hang); }
1435: checkline();
1436: now=time(NULL); }
1437: if(!online)
1438: return(0); }
1439: rioctl(IOFI);
1440: putcom("\x1b[99B\x1b[6n\x1b[!_\x1b[0t_\x1b[0m_\xC");
1441: lputc(FF);
1442: i=l=lncntr=autoterm=0;
1443: tos=1;
1444: #if defined(__OS2__)
1445: strcpy(str,decrypt(VersionNoticeOS2,0));
1446: #elif defined(__WIN32__)
1447: strcpy(str,decrypt(VersionNoticeW32,0));
1448: #else
1449: strcpy(str,decrypt(VersionNoticeDOS,0));
1450: #endif
1451: strcat(str,decrypt(CopyrightNotice,0));
1452: center(str);
1.1.1.2 ! root 1453: mswait(500);
1.1 root 1454: while(i++<30 && l<40) { /* wait up to 3 seconds for response */
1455: if((c=(incom()&0x7f))=='R') { /* break immediately if response */
1456: str[l++]=c;
1457: mswait(110);
1458: break; }
1459: if(c) {
1460: str[l++]=c;
1461: if(l==1 && c!=ESC)
1462: break; }
1463: else
1464: mswait(100); }
1465:
1466: if(rioctl(RXBC)) /* wait a bit for extra RIP reply chars */
1467: mswait(550);
1468:
1469: while((i=(incom()&0x7f))!=NOINP && l<40)
1470: str[l++]=i;
1471: str[l]=0;
1472:
1473: #if 0
1474: for(i=0;str[i];i++)
1475: lprintf("%02X ",str[i]);
1476: lputs(crlf);
1477: #endif
1478:
1479: if(l) {
1480: if(str[0]==ESC && str[1]=='[') {
1481: useron.misc|=(ANSI|COLOR);
1482: autoterm|=ANSI;
1483: rows=((str[2]&0xf)*10)+(str[3]&0xf);
1484: if(rows<10 || rows>99) rows=24; }
1485: truncsp(str);
1486: if(strstr(str,"RIPSCRIP")) {
1487: logline("@R",strstr(str,"RIPSCRIP"));
1488: useron.misc|=(RIP|COLOR|ANSI);
1489: autoterm|=(RIP|COLOR|ANSI); }
1490: else if(strstr(str,"DC-TERM")
1491: && toupper(*(strstr(str,"DC-TERM")+12))=='W') {
1492: logline("@W",strstr(str,"DC-TERM"));
1493: useron.misc|=(WIP|COLOR|ANSI);
1494: autoterm|=(WIP|COLOR|ANSI); } }
1495: rioctl(IOFI); /* flush left-over or late response chars */
1496: sprintf(str,"%sANSWER",text_dir);
1497: sprintf(tmp,"%s.%s",str,autoterm&WIP ? "WIP":"RIP");
1498: sprintf(str2,"%s.ANS",str);
1499: if(autoterm&(RIP|WIP) && fexist(tmp))
1500: strcat(str,autoterm&WIP ? ".WIP":".RIP");
1501: else if(autoterm&ANSI && fexist(str2))
1502: strcat(str,".ANS");
1503: else
1504: strcat(str,".ASC");
1505: rioctl(IOSM|PAUSE);
1506: sys_status|=SS_PAUSEON;
1507: tos=1;
1508: printfile(str,P_NOABORT);
1509: sys_status&=~SS_PAUSEON;
1510: CRLF; }
1511: else
1512: useron.misc=(UPAUSE|ANSI|COLOR);
1513:
1514: useron.number=0;
1515:
1516: exec_bin(login_mod,&main_csi);
1517:
1518: if(!useron.number)
1519: hangup();
1520: if(!online) {
1521: logout();
1522: return(0); }
1523:
1524: if(online==ON_REMOTE && mdm_misc&MDM_CALLERID) {
1525: strcpy(useron.note,cid);
1526: putuserrec(useron.number,U_NOTE,LEN_NOTE,useron.note); }
1527:
1528: /* log the IP by enigma */
1529:
1530: if(online==ON_REMOTE && ipstr[0]!='\0') {
1531: sprintf(useron.note, "Telnet: %s", ipstr);
1532: putuserrec(useron.number,U_NOTE,LEN_NOTE,useron.note);
1533: logline("@*", useron.note); }
1534:
1535: if(!(sys_status&SS_USERON)) {
1536: errormsg(WHERE,ERR_CHK,"User not logged on",0);
1537: hangup();
1538: logout();
1539: return(0); }
1540:
1541: return(1);
1542: }
1543:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.