⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckcmai.c

📁 linux终端仿真程序
💻 C
📖 第 1 页 / 共 5 页
字号:
	return(0);    }}/* Tell if a pathname is absolute (vs relative) *//* This should be parceled out to each of the ck*fio.c modules... */intisabsolute(path) char * path; {    int rc = 0;    int x;    if (!path)      return(0);    if (!*path)      return(0);        x = (int) strlen(path);    debug(F111,"isabsolute",path,x);#ifdef VMS    rc = 0;    if (x = ckindex(":",path,1,0,0))      if (x = ckindex("[",path,x,0,0))	if (x = ckindex("]",path,x,0,0))	  rc = 1;#else#ifdef UNIX    if (*path == '/' ||#ifdef DTILDE	*path == '~' ||#endif /* DTILDE */	*path == '.'	)      rc = 1;#else#ifdef OS2    if (*path == '/' || *path == '\\' || *path == '.')      rc = 1;    else if (isalpha(*path) && x > 1)      if (*(path+1) == ':')	rc = 1;#else#ifdef AMIGA    if (*path == '/' ||#ifdef DTILDE	*path == '~' ||#endif /* DTILDE */	*path == '.'	)      rc = 1;#else#ifdef OSK    if (*path == '/' ||#ifdef DTILDE	*path == '~' ||#endif /* DTILDE */	*path == '.'	)      rc = 1;#else#ifdef datageneral    if (*path == ':')      rc = 1;#else#ifdef MAC    rc = 0;				/* Fill in later... */#else#ifdef STRATUS    rc = 0;				/* Fill in later... */     #else#ifdef GEMDOS    if (*path == '/' || *path == '\\' || *path == '.')      rc = 1;    else if (isalpha(*path) && x > 1)      if (*(path+1) == ':')	rc = 1;#endif /* GEMDOS */#endif /* STRATUS */#endif /* MAC */#endif /* datageneral */#endif /* OSK */#endif /* AMIGA */#endif /* OS2 */#endif /* UNIX */#endif /* VMS */    debug(F111,"isabsolute returns","",rc);    return(rc);}/*  See if I have direct access to the keyboard  */intis_a_tty(n) int n; {#ifdef KUI   return 1;#else /* KUI */#ifdef NT    if (isWin95())      return(1);    else      return(_isatty(n));#else    return(isatty(n));#endif /* NT */#endif /* KUI */}/* Info associated with a system ID */struct sysdata sysidlist[] = {		/* Add others as needed... */    "0",  "anonymous",    0, NUL,  0, 0, 0,    "A1", "Apple II",     0, NUL,  0, 0, 3, /* fix this */    "A3", "Macintosh",    1, ':',  0, 2, 1,    "D7", "VMS",          0, ']',  1, 0, 0,    "DA", "RSTS/E",       0, ']',  1, 0, 3, /* (i think...) */    "DB", "RT11",         0, NUL,  1, 0, 3, /* (maybe...) */    "F3", "AOS/VS",       1, ':',  0, 0, 2,     "I1", "VM/CMS",       0, NUL,  0, 0, 0,    "I2", "MVS/TSO",      0, NUL,  0, 0, 0,    "I4", "MUSIC",        0, NUL,  0, 0, 0,    "I7", "CICS",         0, NUL,  0, 0, 0,    "I9", "MVS/ROSCOE",   0, NUL,  0, 0, 0,    "K2", "Atari ST",     1, '\\', 1, 0, 3,    "L3", "Amiga",        1, '/',  1, 0, 2,    "MV", "Stratus VOS",  1, '>',  0, 1, 0,    "N3", "Apollo Aegis", 1, '/',  0, 3, 2,    "U1", "UNIX",         1, '/',  0, 3, 2,    "U8", "MS-DOS",       1, '\\', 1, 0, 3,    "UD", "OS-9",         1, '/',  0, 3, 2,    "UN", "Windows-32",   1, '\\', 1, 2, 3,    "UO", "OS/2",         1, '\\', 1, 2, 3};static int nxxsysids = (sizeof(sysidlist) / sizeof(struct sysdata));/* Given a Kermit system ID code, return the associated name string *//* and some properties of the filenames... */char *getsysid(s) char * s; {			/* Get system-type name */    int i;    if (!s) return("");    for (i = 0; i < nxxsysids; i++)      if (!strcmp(sysidlist[i].sid_code,s))	return(sysidlist[i].sid_name);    return(s);}intgetsysix(s) char *s; {			/* Get system-type index */    int i;    if (!s) return(-1);    for (i = 0; i < nxxsysids; i++)      if (!strcmp(sysidlist[i].sid_code,s))	return(i);    return(-1);}/* Initialize file transfer protocols */VOID initproto(y, upbstr, uptstr, sndbstr, sndtstr, rcvbstr, rcvtstr)    int y;    char * upbstr, * uptstr, * sndbstr, * sndtstr, * rcvbstr, * rcvtstr;/* initproto */ {    char * p;    int n;    if (upbstr)				/* Convert null strings */      if (!*upbstr)			/* to null pointers */	upbstr = NULL;    if (uptstr)				/* Convert null strings */      if (!*uptstr)			/* to null pointers */	uptstr = NULL;    if (sndbstr)      if (!*sndbstr)	sndbstr = NULL;    if (sndtstr)      if (!*sndtstr)	sndtstr = NULL;    if (rcvbstr)      if (!*rcvbstr)	rcvbstr = NULL;    if (rcvtstr)      if (!*rcvtstr)	rcvtstr = NULL;    protocol = y;			/* Set protocol */    if (ptab[protocol].rpktlen > -1)       urpsiz = ptab[protocol].rpktlen;    if (ptab[protocol].spktflg > -1)       spsizf = ptab[protocol].spktflg;    if (ptab[protocol].spktlen > -1) {	spsiz = ptab[protocol].spktlen;	if (spsizf) 	  spsizr = spmax = spsiz;    }    if (ptab[protocol].winsize > -1)       wslotr = ptab[protocol].winsize;    if (ptab[protocol].prefix > -1)       prefixing = ptab[protocol].prefix;    if (ptab[protocol].fnca > -1)       fncact  = ptab[protocol].fnca;    if (ptab[protocol].fncn > -1)       fncnv   = ptab[protocol].fncn;    if (ptab[protocol].fnsp > -1)       fnspath = ptab[protocol].fnsp;    if (ptab[protocol].fnrp > -1)       fnrpath = ptab[protocol].fnrp;        makestr(&(ptab[protocol].h_b_init),upbstr);    makestr(&(ptab[protocol].h_t_init),uptstr);    makestr(&(ptab[protocol].p_b_scmd),sndbstr);    makestr(&(ptab[protocol].p_t_scmd),sndtstr);    makestr(&(ptab[protocol].p_b_rcmd),rcvbstr);    makestr(&(ptab[protocol].p_t_rcmd),rcvtstr);}/*   M A K E S T R  --  Creates a dynamically allocated string.   Makes a new copy of string s and sets pointer p to its address.   Handles degenerate cases, like when buffers overlap or are the same,   one or both arguments are NULL, etc.*/VOIDmakestr(p,s) char **p, *s; {    int x;    char *q = NULL;    if (*p == s)			/* The two pointers are the same. */      return;				/* Don't do anything. */    if (!s) {				/* New definition is null? */	if (*p)				/* Free old storage. */	  free(*p);	*p = NULL;			/* Return null pointer. */	return;    }    if ((x = strlen(s)) >= 0) {		/* Get length, even of empty string. */	q = malloc(x + 1);		/* Get and point to temp storage. */	if (q)	  strcpy(q,s);    } else      q = NULL;				/* Length of string is zero */    if (*p)				/* Now free the original storage. */      free(*p);    *p = NULL;    if (!q)      return;    if (x > 0) {			/* Get length. */	if (*p = malloc(x + 1))	  strcpy(*p,q);    }    free(q);				/* Free temporary buffer. */}/*  X X S T R C M P  --  Caseless string comparison  *//*  Call with pointers to the two strings, s1 and s2, and a length, n.  Compares up to n characters of the two strings and returns:    1 if s1 > t1    0 if s1 = s2   -1 if s1 < t1*/intxxstrcmp(s1,s2,n) char *s1, *s2; int n; { /* Caseless string comparison. */    char t1, t2;			    if (n < 1) return(0);    if (!s1) s1 = "";			/* Watch out for null pointers. */    if (!s2) s2 = "";    while (n--) {	t1 = *s1++;			/* Get next character from each. */	t2 = *s2++;	if (!t1) return(t2 ? -1 : 0);	if (!t2) return(t1 ? -1 : 0);	if (isupper(t1)) t1 = tolower(t1);	if (isupper(t2)) t2 = tolower(t2);	if (t1 < t2) return(-1);	/* s1 < s2 */	if (t1 > t2) return(1);		/* s1 > s2 */    }    return(0);				/* They're equal */}#ifndef NOCMDLVOID#ifdef CK_ANSICdocmdline(void * threadinfo)#else /* CK_ANSIC */docmdline(threadinfo) VOID * threadinfo; #endif /* CK_ANSIC */{#ifdef NTSIG    if (threadinfo) {			/* Thread local storage... */       TlsSetValue(TlsIndex,threadinfo);       debug( F100, "docmdline called with threadinfo block", "", 0 );    }   else debug( F100, "docmdline threadinfo is NULL","",0) ;#endif /* NTSIG */    proto();				/* Take any requested action, then */    if (!quiet)				/* put cursor back at left margin, */      conoll("");#ifndef NOLOCAL    if (cnflg) doconect(0);		/* connect if requested. */#endif /* NOLOCAL */#ifdef NTSIG     ckThreadEnd(threadinfo);#endif /* NTSIG */   return;}VOID #ifdef CK_ANSICfailcmdline(void * foo)#else /* CK_ANSIC */failcmdline(foo) VOID * foo; #endif /* CK_ANSIC */{#ifdef GEMDOS    cc_clean();#endif /* GEMDOS */#ifndef NOLOCAL    if (cnflg) doconect(0);		/* connect again if requested. */#endif /* NOLOCAL */}#endif /* NOCMDL */#ifndef NOICPVOID  #ifdef CK_ANSICdotakeini(void * threadinfo)		/* Execute init file. */#else  /* CK_ANSIC */dotakeini(threadinfo) VOID * threadinfo; /* Execute init file. */#endif /* CK_ANSIC *//* dotakeini */ {#ifdef NTSIG    if (threadinfo) {			/* Thread local storage... */       TlsSetValue(TlsIndex,threadinfo);       debug( F100, "dotakeini called with threadinfo block","", 0 ) ;    } else      debug( F100, "dotakeini - threadinfo is NULL", "", 0 ) ;#endif /* NTSIG */    cmdini();				/* Sets tlevel */    doinit();    debug(F101,"main executing init file","",tlevel);    while (tlevel > -1) {	sstate = (CHAR) parser(1);	/* Execute one command at a time. */	if (sstate) proto();		/* Enter protocol if requested. */#ifdef NTSIG       ck_ih();#endif /* NTSIG */    }    debug(F101,"main exits init file","",tlevel);#ifdef NTSIG     ckThreadEnd(threadinfo);#endif /* NTSIG */    return;}VOID #ifdef CK_ANSICfailtakeini(void * threadinfo) #else /* CK_ANSIC */failtakeini(threadinfo) VOID * threadinfo; #endif /* CK_ANSIC *//* failtakeini */ {#ifdef GEMDOS    cc_clean();				/* Atari: Clean up after ^C-trap. */#endif /* GEMDOS */    conoll("Interrupt during initialization or command-line processing.");    conoll("C-Kermit quitting...");    doexit(BAD_EXIT,-1);		/* Exit with bad status. */}VOID #ifdef CK_ANSICdoicp(void * threadinfo) #else /* CK_ANSIC */doicp(threadinfo) VOID * threadinfo; #endif /* CK_ANSIC *//* doicp */ {#ifdef NTSIG    if (threadinfo) {			/* Thread local storage... */       if (!TlsSetValue(TlsIndex,threadinfo))          debug(F101,"doicp TlsSetValue failed","",GetLastError() ) ;       debug( F101, "doicp a threadinfo block - TlsIndex", "", TlsIndex ) ;    } else {        debug( F100, "doicp received a null threadinfo", "", 0 ) ;    }#endif /* NTSIG */#ifdef MAC    while (1) {	extern char *lfiles;		/* Fake pointer cast */	if (connected) {	    debug(F100, "main: calling macparser", "", 0);	    sstate = newparser(1, 1, 0L);	    /* ignore null command state */	    if (sstate == 'n')	      sstate = '\0';	    if (sstate)	      proto();#ifdef NTSIG       ck_ih();#endif /* NTSIG */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -