📄 dcpsys.c
字号:
/*--------------------------------------------------------------------*/
/* d c p s y s . c */
/* */
/* System support functions for UUCICO */
/* */
/* Changes Copyright (c) 1990-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* Changes Copyright (c) 1989 by Andrew H. Derbyshire. */
/* */
/* All rights reserved except those explicitly granted by the */
/* UUPC/extended license agreement. */
/* */
/* Copyright (c) Richard H. Lamb 1985, 1986, 1987 */
/* Changes Copyright (c) Stuart Lynne 1987 */
/* */
/* Updated: */
/* */
/* 13May89 - Modified checkname to only examine first token of */
/* name. */
/* Modified rmsg to initialize input character before */
/* use. */
/* 16May89 - Moved checkname to router.c - ahd */
/* 17May89 - Wrote real checktime() - ahd */
/* 17May89 - Changed getsystem to return 'I' instead of 'G' */
/* 25Jun89 - Added Reach-Out America to keyword table for */
/* checktime */
/* 22Sep89 - Password file support for hosts */
/* 25Sep89 - Change 'ExpectStr' message to debuglevel 2 */
/* 01Jan90 - Revert 'ExpectStr' message to debuglevel 1 */
/* 28Jan90 - Alter callup() to use table driven modem driver. */
/* Add direct(), qx() procedures. */
/* 8 Jul90 - Add John DuBois's expectstr() routine to fix */
/* problems with long input buffers. */
/* 11Nov90 - Delete QX support, add ddelay, ssleep calls */
/* 21Sep92 - Insure system system name and time do not crash */
/* UUCICO - from the original fix by Eugene */
/* Nesterenko, Moscow, Russia */
/*--------------------------------------------------------------------*/
/*
* $Id: dcpsys.c 1.24 1993/10/03 22:34:33 ahd Exp $
*
* $Log: dcpsys.c $
* Revision 1.24 1993/10/03 22:34:33 ahd
* Alter format of numbers printed
*
* Revision 1.23 1993/09/29 04:52:03 ahd
* Use additional state in support of suspend port code
*
* Revision 1.22 1993/09/28 01:38:19 ahd
* Add configurable timeout for conversation start up phase
*
* Revision 1.21 1993/09/27 04:04:06 ahd
* Normalize references to modem speed to avoid incorrect displays
*
* Revision 1.20 1993/09/27 00:48:43 ahd
* Allow 't' protocol under 16 bit OS/2
*
* Revision 1.19 1993/09/21 01:42:13 ahd
* Move declare of protocol list into source from header
*
* Revision 1.18 1993/09/20 04:48:25 ahd
* TCP/IP support from Dave Watt
* 't' protocol support
* OS/2 2.x support (BC++ 1.0 for OS/2)
*
* Revision 1.17 1993/08/26 05:00:25 ahd
* Debugging code for odd failures on J. McBride's network
*
* Revision 1.16 1993/05/30 00:01:47 ahd
* Multiple commuications drivers support
*
* Revision 1.15 1993/05/09 03:41:47 ahd
* Make wmsg accept const string
* Make sending/receiving of -x string to/from remote UUCICO optional
* Delete rejection of high levels of debug for anonymous UUCICO's
*
* Revision 1.14 1993/05/06 03:41:48 ahd
* Save true host name of caller in hostp->via field for use by
* SYSLOG processing.
*
* Revision 1.13 1993/04/11 00:34:11 ahd
* Global edits for year, TEXT, etc.
*
* Revision 1.12 1993/04/05 04:35:40 ahd
* Add timestamp, file size to directory information
*
* Revision 1.11 1993/01/23 19:08:09 ahd
* Don't update system stats in sysend()
*
* Revision 1.10 1992/12/11 12:45:11 ahd
* Shorten remote display to improve OS/2 windowed scrolling
*
* Revision 1.9 1992/12/01 04:37:03 ahd
* Modify *nbstime call restrictions to make it less agressive
*
* Revision 1.8 1992/11/22 21:20:45 ahd
* Use strpool for const string allocation
*
* Revision 1.7 1992/11/21 06:17:08 ahd
* Transmit only one character in response to P (protocol) request
*
* Revision 1.6 1992/11/19 03:00:51 ahd
* drop rcsid
*
* Revision 1.5 1992/11/18 03:49:21 ahd
* Move check of call window to avoid premature lock file overhead
*
* Revision 1.4 1992/11/17 13:46:42 ahd
* If host lookup fails, issue real error message, not malloc failure!
*
* Revision 1.3 1992/11/16 02:14:17 ahd
* Initialize previous directory scanned variable in scandir
*
* Revision 1.2 1992/11/15 20:11:07 ahd
* Clean up modem file support for different protocols
*
*/
/*--------------------------------------------------------------------*/
/* system include files */
/*--------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "arpadate.h"
#include "checktim.h"
#include "dcp.h"
#include "dcpfpkt.h"
#include "dcpgpkt.h"
#include "dcptpkt.h"
#include "dcplib.h"
#include "dcpsys.h"
#include "export.h"
#include "hlib.h"
#include "hostable.h"
#include "hostatus.h"
#include "modem.h"
#include "lock.h"
#include "nbstime.h"
#include "uundir.h"
#include "ssleep.h"
#include "security.h"
#include "commlib.h"
currentfile();
/*--------------------------------------------------------------------*/
/* Define available protocols */
/*--------------------------------------------------------------------*/
typedef struct {
char type;
procref getpkt, sendpkt, openpk, closepk, rdmsg, wrmsg, eofpkt,
filepkt;
boolean network;
} Proto;
Proto Protolst[] = {
{ 'g', ggetpkt, gsendpkt, gopenpk, gclosepk,
grdmsg, gwrmsg, geofpkt, gfilepkt,
FALSE,
} ,
{ 'G', ggetpkt, gsendpkt, Gopenpk, gclosepk,
grdmsg, gwrmsg, geofpkt, gfilepkt,
FALSE,
} ,
{ 'f', fgetpkt, fsendpkt, fopenpk, fclosepk,
frdmsg, fwrmsg, feofpkt, ffilepkt,
FALSE,
} ,
{ 'v', ggetpkt, gsendpkt, vopenpk, gclosepk,
grdmsg, gwrmsg, geofpkt, gfilepkt,
FALSE,
} ,
#if defined(_Windows) || defined(BIT32ENV) || defined(FAMILYAPI)
{ 't', tgetpkt, tsendpkt, topenpk, tclosepk,
grdmsg, gwrmsg, geofpkt, gfilepkt, // Yup, same as 'g'
TRUE,
} ,
#endif
{ '\0' }
};
procref getpkt, sendpkt, openpk, closepk, rdmsg, wrmsg, eofpkt, filepkt;
char *flds[60];
int kflds;
static char protocols[5];
static char S_sysline[BUFSIZ];
static void setproto(char wanted);
static char HostGrade( const char *fname, const char *remote );
/****************************************/
/* Sub Systems */
/****************************************/
/*--------------------------------------------------------------------*/
/* g e t s y s t e m */
/* */
/* Process a systems file (L.sys) entry. */
/* Null lines or lines starting with '#' are comments. */
/*--------------------------------------------------------------------*/
CONN_STATE getsystem( const char sendgrade )
{
do {
char *p;
/* flush to next non-comment line */
if (fgets(S_sysline, BUFSIZ, fsys) == nil(char))
return CONN_EXIT;
p = S_sysline + strlen( S_sysline );
/*--------------------------------------------------------------------*/
/* Trim trailing white space */
/*--------------------------------------------------------------------*/
while ((p-- > S_sysline) && isspace( *p ))
*p = '\0';
} while ((*S_sysline == '\0') || (*S_sysline == '#'));
printmsg(8, "sysline=\"%s\"", S_sysline);
kflds = getargs(S_sysline, flds);
/*--------------------------------------------------------------------*/
/* Blitz all the extra fields we don't need */
/*--------------------------------------------------------------------*/
if ( kflds < FLD_EXPECT )
{
printmsg(0,"getsystem: Invalid system entry "
"for %s (missing dial script)",
flds[FLD_REMOTE] );
return CONN_INITIALIZE;
}
strcpy(protocols, flds[FLD_PROTO]);
strcpy(rmtname, flds[FLD_REMOTE]);
/*--------------------------------------------------------------------*/
/* Summarize the host data */
/*--------------------------------------------------------------------*/
printmsg(2,
"remote=%s, when=%s, device=%s, phone=%s, protocol=%s",
rmtname, flds[FLD_CCTIME], flds[FLD_TYPE], flds[FLD_PHONE],
protocols);
/*--------------------------------------------------------------------*/
/* Determine if the remote is valid */
/*--------------------------------------------------------------------*/
hostp = checkreal( rmtname );
if ( hostp == NULL )
{
printmsg(0,"getsystem: Internal lookup error for system %s",
rmtname);
panic();
}
/*--------------------------------------------------------------------*/
/* Display the send/expect fields */
/*--------------------------------------------------------------------*/
if (debuglevel >= 4) {
int i;
flds[ kflds ] = ""; /* Insure valid send string */
for (i = FLD_EXPECT; i < kflds; i += 2)
printmsg(6, "expect [%02d]:\t%s\nsend [%02d]:\t%s",
i, flds[i], i + 1, flds[i + 1]);
}
/*--------------------------------------------------------------------*/
/* Determine if we want to call this host */
/* */
/* The following if statement breaks down to: */
/* */
/* if host not successfully called this run and */
/* ( we are calling all hosts or */
/* we are calling this host or */
/* we are hosts with work and this host has work ) */
/* then call this host */
/*--------------------------------------------------------------------*/
fwork = nil(FILE);
if ((hostp->hstatus != called) &&
(equal(Rmtname, "all") || equal(Rmtname, rmtname) ||
(equal(Rmtname, "any") &&
(scandir(rmtname,sendgrade) == XFER_REQUEST))))
{
if (fwork != nil(FILE)) /* in case matched with scandir */
fclose(fwork);
scandir( NULL, sendgrade); /* Reset directory search as well */
/*--------------------------------------------------------------------*/
/* We want to call the host; is it defined in our security table? */
/*--------------------------------------------------------------------*/
securep = GetSecurity( hostp );
if ( securep == NULL )
{
printmsg(0,"getsystem: system \"%s\" not defined in "
"PERMISSIONS file", hostp->hostname);
return CONN_INITIALIZE;
}
memset( &remote_stats, 0, sizeof remote_stats);
return CONN_CHECKTIME; /* startup this system */
} /* if */
else
return CONN_INITIALIZE; /* Look for next system to process */
} /*getsystem*/
/*--------------------------------------------------------------------*/
/* s y s e n d */
/* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -