📄 dcpsys.c
字号:
} /* switch */
} /* for */
*sendgrade = min(grade,*sendgrade);
/*--------------------------------------------------------------------*/
/* Verify the remote host name is good */
/*--------------------------------------------------------------------*/
hostp = checkreal( sysname );
if ( hostp == BADHOST )
{
if (E_anonymous != NULL)
{
hostp = checkreal( ANONYMOUS_HOST ); /* Find dummy entry */
if ( hostp == BADHOST ) /* Was it there? */
panic(); /* No --> Drop wing, run in
circles like sky is falling*/
if (!checktime( E_anonymous )) /* Good time to call? */
{
wmsg("RWrong time for anonymous system",TRUE);
printmsg(0,"Wrong time for anonymous system \"%s\"",sysname);
} /* if */
if ( !LockSystem( sysname , B_UUCICO ))
{
wmsg("RLCK",TRUE); /* Odd, we locked anonymous system? */
return CONN_TERMINATE;
}
hostp->via = newstr( sysname );
sysname = ANONYMOUS_HOST;
} /* if (E_anonymous != NULL) */
else {
wmsg("RYou are unknown to me",TRUE);
printmsg(0,"startup: Unknown host \"%s\"", sysname);
return CONN_TERMINATE;
} /* else */
} /* if ( hostp == BADHOST ) */
else if ( LockSystem( hostp->hostname , B_UUCICO ))
hostp->via = hostp->hostname;
else {
wmsg("RLCK",TRUE);
return CONN_TERMINATE;
} /* else */
/*--------------------------------------------------------------------*/
/* Correct host for this user id? */
/*--------------------------------------------------------------------*/
if ( !ValidateHost( sysname ))
/* Wrong host for user? */
{ /* Yes --> Abort */
wmsg("RLOGIN",TRUE);
printmsg(0,"startup: Access rejected for host \"%s\"", sysname);
hostp->hstatus = wrong_host;
return CONN_TERMINATE;
} /* if */
strcpy(rmtname, hostp->hostname); /* Make sure we use the
full host name */
/*--------------------------------------------------------------------*/
/* If we must call the user back, do so */
/*--------------------------------------------------------------------*/
if (securep->callback)
{
wmsg("RCB",TRUE);
hostp->hstatus = callback_req;
return CONN_TERMINATE; /* Really more complex than this */
}
/*--------------------------------------------------------------------*/
/* Set the local debug level */
/*--------------------------------------------------------------------*/
if ( xdebug > debuglevel )
{
debuglevel = xdebug;
printmsg(0, "Debuglevel set to %d by remote", debuglevel);
}
/*--------------------------------------------------------------------*/
/* Build local protocol list */
/*--------------------------------------------------------------------*/
s = plist;
for (tproto = Protolst; tproto->type != '\0' ; tproto++)
{
if ( IsNetwork() || !tproto->network )
*s++ = tproto->type;
}
*s = '\0'; /* Terminate our string */
/*--------------------------------------------------------------------*/
/* The host name is good; get the protocol */
/*--------------------------------------------------------------------*/
wmsg("ROK", TRUE);
sprintf(msg, "P%s", plist);
wmsg(msg, TRUE);
if (rmsg(msg, TRUE, M_startupTimeout, sizeof msg) == TIMEOUT)
return CONN_TERMINATE;
if (msg[0] != 'U')
{
printmsg(0,"Unexpected second message: %s", msg);
return CONN_TERMINATE;
}
if (strchr(plist, msg[1]) == nil(char))
{
printmsg(0,"startup: Host %s does not support our protocols",
rmtname );
return CONN_TERMINATE;
}
setproto(msg[1]);
/*--------------------------------------------------------------------*/
/* Report that we connected to the remote host */
/*--------------------------------------------------------------------*/
printmsg(0,"%s called by %s: %ld bps, %c protocol, %c grade",
E_nodename,
hostp->via,
(long) GetSpeed(),
msg[1],
*sendgrade );
if ( hostp == BADHOST )
panic();
hostp->hstatus = inprogress;
hostp->hstats->lconnect = time( &remote_stats.lconnect );
return CONN_CLIENT;
} /*startup_client*/
/*--------------------------------------------------------------------*/
/* s e t p r o t o */
/* */
/* set the protocol to be used */
/*--------------------------------------------------------------------*/
static void setproto(char wanted)
{
Proto *tproto;
for (tproto = Protolst;
tproto->type != '\0' && tproto->type != wanted;
tproto++) {
printmsg(3, "setproto: wanted '%c', have '%c'", wanted, tproto->type);
}
if (tproto->type == '\0') {
printmsg(0, "setproto: You said I have protocol '%c' but I cant find it!",
wanted);
panic();
}
printmsg(3, "setproto: wanted '%c', have '%c'", wanted, tproto->type);
getpkt = tproto->getpkt;
sendpkt = tproto->sendpkt;
openpk = tproto->openpk;
closepk = tproto->closepk;
rdmsg = tproto->rdmsg;
wrmsg = tproto->wrmsg;
eofpkt = tproto->eofpkt;
filepkt = tproto->filepkt;
} /*setproto*/
/*--------------------------------------------------------------------*/
/* s c a n d i r */
/* */
/* Scan spooling directory for C.* files for the remote host */
/* (rmtname) */
/*--------------------------------------------------------------------*/
XFER_STATE scandir(char *remote, const char grade )
{
static DIR *dirp = NULL;
static char *SaveRemote = NULL;
static char remotedir[FILENAME_MAX];
struct direct *dp;
/*--------------------------------------------------------------------*/
/* Determine if we must restart the directory scan */
/*--------------------------------------------------------------------*/
if (fwork != NULL )
{
fclose( fwork );
fwork = NULL;
}
if ( (remote == NULL) || ( SaveRemote == NULL ) ||
!equaln(remote, SaveRemote, sizeof SaveRemote - 1 ) )
{
if ( SaveRemote != NULL ) /* Clean up old directory? */
{ /* Yes --> Do so */
closedir(dirp);
dirp = NULL;
SaveRemote = NULL;
} /* if */
if ( remote == NULL ) /* Clean up only, no new search? */
return XFER_NOLOCAL; /* Yes --> Return to caller */
sprintf(remotedir,"%s/%.8s/C", E_spooldir, remote);
if ((dirp = opendir(remotedir)) == nil(DIR))
{
printmsg(2, "scandir: couldn't opendir() %s", remotedir);
return XFER_NOLOCAL;
} /* if */
SaveRemote = newstr( remote );
/* Flag we have an active search */
} /* if */
/*--------------------------------------------------------------------*/
/* Look for the next file in the directory */
/*--------------------------------------------------------------------*/
while ((dp = readdir(dirp)) != nil(struct direct))
{
sprintf(workfile, "%s/%s", remotedir, dp->d_name);
if ( HostGrade( workfile, remote ) > grade )
printmsg(5, "scandir: skipped \"%s\" (grade %c not met)", workfile,
grade );
else if ((fwork = FOPEN(workfile, "r",TEXT_MODE)) == nil(FILE))
{
printmsg(0,"scandir: open failed for %s",workfile);
SaveRemote = NULL;
return XFER_ABORT; /* Very bad, since we just read its
directory entry! */
}
else {
setvbuf( fwork, NULL, _IONBF, 0);
printmsg(5, "scandir: matched \"%s\"",workfile);
return XFER_REQUEST; /* Return success */
}
} /* while */
/*--------------------------------------------------------------------*/
/* No hit; clean up after ourselves and return to the caller */
/*--------------------------------------------------------------------*/
printmsg(5, "scandir: \"%s\" not matched", remotedir);
closedir(dirp);
dirp = NULL;
SaveRemote = NULL;
return XFER_NOLOCAL;
} /*scandir*/
/*--------------------------------------------------------------------*/
/* H o s t G r a d e */
/* */
/* Return host grade of a call file */
/*--------------------------------------------------------------------*/
static char HostGrade( const char *fname, const char *remote )
{
char tempname[FILENAME_MAX];
size_t len = strlen( remote );
exportpath( tempname, fname, remote );
if ( len > HOSTLEN )
len = HOSTLEN;
return tempname[len + 2 ];
} /* HostGrade */
/*--------------------------------------------------------------------*/
/* C a l l W i n d o w */
/* */
/* Determine if we can call a system */
/*--------------------------------------------------------------------*/
boolean CallWindow( const char callgrade )
{
/*--------------------------------------------------------------------*/
/* Determine if the window for calling this system is open */
/*--------------------------------------------------------------------*/
if ( !callgrade && equal(flds[FLD_CCTIME],"Never" ))
{
hostp->hstatus = wrong_time;
return FALSE;
}
/*--------------------------------------------------------------------*/
/* Check the time of day and whether or not we should call now. */
/* */
/* If calling a system to set the clock and we determine the */
/* system clock is bad (we fail the sanity check of the last */
/* connected a host to being in the future), then we ignore the */
/* time check field. */
/*--------------------------------------------------------------------*/
if (!callgrade)
{
if ((*flds[FLD_PROTO] != '*') || /* Not setting clock? */
((hostp->hstats->ltime > 630720000L )))
/* Clock okay? */
{ /* Yes--> Return */
hostp->hstatus = wrong_time;
time(&hostp->hstats->ltime); /* Save time of last attempt to call */
return FALSE;
}
} /* if */
/*--------------------------------------------------------------------*/
/* We pass the time check */
/*--------------------------------------------------------------------*/
return TRUE;
} /* CallWindow */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -