/*======================================================================* * * * Program to process ExpressNET! Calls * * * *======================================================================*/ #version $50 #reserve 6 #copyright "Nhshost.cmd Written By Stephen J. Carden Copyright 1995 K-Products" #address $7000 #include runtime.h #include bbs_pro.h #define DISK2 2 #define C_MODEM 5 #define _ACK_ 6 #define _NAK_ 24 #define _EOT_ 4 char hs_buffer [40]; char callfn [40]; int node; char timeout; main() { strcpy (callfn, "Dx:>PRO>NETWORK>X_"); callfn [2] = s_netdr; printf ("%c%e%e%e%e%e __ExpressNET! Hi Speed Host Activated__%e%e",125); if (handshake()) { invoker = $C0; strcpy (parm1, callfn); chain ("NSRXFER"); } chain ("WAITCALL"); } /*==================================================================* * handshake - Attempt to handshake with the host system. * * * * Returns: 0 - unable to establish connection. * * 1 - connected, chain to netmodem. * *==================================================================*/ handshake() { byte file_here, cksum, valid; char ch, temp [10]; byte x, tries; int usernum, tempnum; trans = 0; printf ("%eHandshaking with remote caller..."); seconds = 0; ch = 0; purge_modem(); do { /* wait for $fc to start */ if (bytes_in()) ch = getd (C_MODEM); } while (ch != $fc && seconds < 20); if (ch != $fc) return (0); seconds = 0; valid = 0; tries = 0; do { ++tries; purge_modem(); putd (C_MODEM, _NAK_); /* request header */ cksum = 0; for (x = 0; x < 21; ++x) { /* 21-byte header */ hs_buffer [x] = getx (3); if (timeout) break; } if (timeout == 0) { cksum = 0; for (x = 0; x < 20; ++x) cksum = cksum + hs_buffer [x]; if (cksum == hs_buffer [20]) { node = hs_buffer [17] * 256 + hs_buffer [16]; usernum = hs_buffer [19] * 256 + hs_buffer [18]; printf("%e%e Node: %d%e", node); printf(" User: %d%e", usernum); printf("Pword: %s%e", hs_buffer); MIOsuspend(); if (open_ulog() < 128) { if (read_user (usernum) < 128) { if (strcmpi(t_pword, hs_buffer) != 0) printf("%eInvalid password!%e"); else { tempnum = valc (t_name); if (tempnum == node) valid = 1; else printf("%eInvalid node access!%e"); } } } close_ulog(); MIOresume(); } } } while (valid == 0 && tries < 10); if (tries > 9) /* couldn't handshake */ return (0); printf("%e%eNode #%d online!%e", node); strc (node, temp); strcat (callfn, temp); /* complete filename */ strcat (callfn, ".ARC"); MIOsuspend(); file_here = 1; if (open (DISK2, callfn, 4, 0) != OK) /* file to send? */ file_here = 0; close (DISK2); MIOresume(); if (file_here == 0) { printf("%e%eNo packet to send...%e", node); putd (C_MODEM, _EOT_); putd (C_MODEM, _EOT_); putd (C_MODEM, _EOT_); putd (C_MODEM, _EOT_); putd (C_MODEM, _EOT_); return (0); } else { putd (C_MODEM, _ACK_); putd (C_MODEM, _ACK_); putd (C_MODEM, _ACK_); putd (C_MODEM, _ACK_); return (1); } } /*==================================================================* * getx - get input from modem with "secs" timeout. * *==================================================================*/ getx (byte secs) { timeout = 0; seconds = 0; do { if (bytes_in()) return (getd (C_MODEM)); } while (seconds < secs); timeout = 1; } /*==================================================================* * purge_modem - remove all incoming data from the modem * *==================================================================*/ purge_modem() { char ch; while (bytes_in()) ch = getd (C_MODEM); }