📄 ckcfns.c
字号:
x = 1; if (rln >= 8) { x = s[8] - '0'; if ((x < 1) || (x > 3)) x = 1; } bctr = x;/* Repeat prefix */ if (rln >= 9) { rptq = s[9]; rptflg = ((rptq > 32 && rptq < 63) || (rptq > 95 && rptq < 127)); } else rptflg = 0;/* Capabilities */ atcapu = lpcapu = swcapu = 0; if (rln >= 10) { x = xunchar(s[10]); atcapu = (x & atcapb) && atcapr; lpcapu = (x & lpcapb) && lpcapr; swcapu = (x & swcapb) && swcapb; for (capas = 10; (xunchar(s[capas]) & 1) && (rln >= capas); capas++) ; }/* Long Packets */ if (lpcapu) { if (rln > capas+2) { x = xunchar(s[capas+2]) * 95 + xunchar(s[capas+3]); if (spsizf) { /* If overriding negotiations */ spsiz = (x < lpsiz) ? x : lpsiz; /* do this, */ } else { /* otherwise */ spsiz = (x > MAXSP) ? MAXSP : x; /* do this. */ } if (spsiz < 10) spsiz = 80; /* Be defensive... */ } }/* Sliding Windows */ if (swcapu) { if (rln > capas+1) { x = xunchar(s[capas+1]); wsize = x > MAXWS ? MAXWS : x; } else wsize = 1; } if (deblog) sdebu(rln); /* Record parameters in debug log */}/* G N F I L E -- Get the next file name from a file group. *//* Returns 1 if there's a next file, 0 otherwise */gnfile() { int x; long y;#ifdef datageneral int dgfiles = 0; /* Number of files expanded */ static int dgnfils = -1; /* Saved nfils value */#endif/* If file group interruption (C-Z) occured, fail. */ debug(F101,"gnfile: czseen","",czseen); if (czseen) { tlog(F100,"Transaction cancelled","",0l); return(0); }/* If input was stdin or memory string, there is no next file. */ if (sndsrc == 0) return(0);/* If file list comes from command line args, get the next list element. */ y = -1; while (y < 0) { /* Keep trying till we get one... */ if (sndsrc > 0) { if (nfils-- > 0) {#ifdef datageneral/* The DG does not internally expand the file names when a string of *//* filenames is given. So we must in this case. */ if (dgnfils == -1) { /* This is executed first time only! */ strcpy(filnam,*cmlist++); dgfiles = zxpand(filnam); /* Expand the string */ debug(F111,"gnfile:cmlist filnam (x-init)",filnam,dgfiles); dgnfils = nfils + 1; debug(F111,"gnfile:cmlist filnam (x-init)",filnam,dgnfils); } x = znext(filnam); if (x > 0) { /* Get the next file in the expanded list */ debug(F111,"gnfile znext: filnam (exp-x=)",filnam,x); nfils = dgnfils; /* The virtual number of files left */ } if (x == 0) { /* Expand the next command argument */ if (dgnfils == 1) { dgnfils = -1; /* The last argument resets things */ *filnam = '\0'; debug(F101,"gnfile cmlist: nfils","",nfils); return(0); } strcpy(filnam,*cmlist++); /* Finish expanding last arg */ dgfiles = zxpand(filnam); /* Expand the string */ debug(F111,"gnfile: cmlist filnam (exp)",filnam,dgnfils); x = znext(filnam); debug(F111,"gnfile znext: filnam (exp)",filnam,x); nfils = dgnfils--; } #else strcpy(filnam,*cmlist++); debug(F111,"gnfile: cmlist filnam",filnam,nfils);#endif } else { *filnam = '\0'; debug(F101,"gnfile cmlist: nfils","",nfils); return(0); } }/* Otherwise, step to next element of internal wildcard expansion list. */ if (sndsrc < 0) { x = znext(filnam); debug(F111,"gnfile znext: filnam",filnam,x); if (x == 0) return(0); }/* Get here with a filename. */ y = zchki(filnam); /* Check if file readable */ if (y < 0) { debug(F110,"gnfile skipping:",filnam,0); tlog(F111,filnam,"not sent, reason",(long)y); screen(SCR_ST,ST_SKIP,0l,filnam); } else fsize = y; } return(1);}/* O P E N I -- Open an existing file for input */openi(name) char *name; { int x, filno; if (memstr) return(1); /* Just return if file is memory. */ debug(F110,"openi",name,0); debug(F101," sndsrc","",sndsrc); filno = (sndsrc == 0) ? ZSTDIO : ZIFILE; /* ... */ debug(F101," file number","",filno); if (zopeni(filno,name)) { /* Otherwise, try to open it. */ debug(F110," ok",name,0); return(1); } else { /* If not found, */ char xname[100]; /* convert the name */ zrtol(name,xname); /* to local form and then */ x = zopeni(filno,xname); /* try opening it again. */ debug(F101," zopeni","",x); if (x) { debug(F110," ok",xname,0); return(1); /* It worked. */ } else { screen(SCR_EM,0,0l,"Can't open file"); /* It didn't work. */ tlog(F110,xname,"could not be opened",0l); debug(F110," openi failed",xname,0); return(0); } }}/* O P E N O -- Open a new file for output. *//* Returns actual name under which the file was opened in string 'name2'. */openo(name,name2) char *name, *name2; { char xname[100], *xp; if (stdouf) /* Receiving to stdout? */ return(zopeno(ZSTDIO,"")); debug(F110,"openo: name",name,0); if (cxseen || czseen) { /* If interrupted, get out before */ debug(F100," open cancelled","",0); /* destroying existing file. */ return(1); /* Pretend to succeed. */ } xp = xname; /* OK to proceed. */ if (fncnv) /* If desired, */ zrtol(name,xp); /* convert name to local form */ else /* otherwise, */ strcpy(xname,name); /* use it literally */ debug(F110,"openo: xname",xname,0); if (warn) { /* File collision avoidance? */ if (zchki(xname) != -1) { /* Yes, file exists? */ znewn(xname,&xp); /* Yes, make new name. */ strcpy(xname,xp); debug(F110," exists, new name ",xname,0); } } if (zopeno(ZOFILE,xname) == 0) { /* Try to open the file */ debug(F110,"openo failed",xname,0); tlog(F110,"Failure to open",xname,0l); return(0); } else { strcpy(name2,xname); debug(F110,"openo ok, name2",name2,0); return(1); }}/* O P E N T -- Open the terminal for output, in place of a file */opent() { ffc = tfc = 0; return(zopeno(ZCTERM,""));}/* C L S I F -- Close the current input file. */clsif() {#ifdef datageneral if ((local) && (!quiet)) /* Only do this if local & not quiet */ if (nfils < 1) /* More files to send ... leave it on! */ connoi_mt();#endif if (memstr) { /* If input was memory string, */ memstr = 0; /* indicate no more. */ } else zclose(ZIFILE); /* else close input file. */ if (czseen || cxseen) screen(SCR_ST,ST_DISC,0l,""); else screen(SCR_ST,ST_OK,0l,""); cxseen = hcflg = 0; /* Reset flags, */ *filnam = '\0'; /* and current file name */}/* C L S O F -- Close an output file. *//* Call with disp != 0 if file is to be discarded. *//* Returns -1 upon failure to close, 0 or greater on success. */clsof(disp) int disp; { int x;#ifdef datageneral if ((local) && (!quiet)) /* Only do this if local & not quiet */ connoi_mt();#endif if ((x = zclose(ZOFILE)) < 0) { /* Try to close the file */ tlog(F100,"Failure to close",filnam,0l); screen(SCR_ST,ST_ERR,0l,""); } else if (disp && (keep == 0)) { /* Delete it if interrupted, */ if (*filnam) zdelet(filnam); /* and not keeping incomplete files */ debug(F100,"Discarded","",0); tlog(F100,"Discarded","",0l); screen(SCR_ST,ST_DISC,0l,""); } else { /* Nothing wrong, just keep it */ debug(F100,"Closed","",0); /* and give comforting messages. */ screen(SCR_ST,ST_OK,0l,""); } *filnam = '\0'; /* Zero the current file name. */ return(x); /* Send back zclose() return code. */}/* S N D H L P -- Routine to send builtin help */sndhlp() { nfils = 0; /* No files, no lists. */ xflg = 1; /* Flag we must send X packet. */ strcpy(cmdstr,"help text"); /* Data for X packet. */ first = 1; /* Init getchx lookahead */ memstr = 1; /* Just set the flag. */ memptr = hlptxt; /* And the pointer. */ if (binary) { /* If file mode is binary, */ binary = 0; /* turn it back to text for this, */ savmod = 1; /* remember to restore it later. */ } return(sinit());}/* C W D -- Change current working directory *//* String passed has first byte as length of directory name, rest of string is name. Fails if can't connect, else ACKs (with name) and succeeds. */cwd(vdir) char *vdir; { char *cdd, *zgtdir(); vdir[xunchar(*vdir) + 1] = '\0'; /* End with a null */ if (zchdir(vdir+1)) { cdd = zgtdir(); /* Get new working directory. */ encstr(cdd); ack1(data); tlog(F110,"Changed directory to",cdd,0l); return(1); } else { tlog(F110,"Failed to change directory to",vdir+1,0l); return(0); }}/* S Y S C M D -- Do a system command *//* Command string is formed by concatenating the two arguments. */syscmd(prefix,suffix) char *prefix, *suffix; { char *cp; if (prefix == NULL || *prefix == '\0') return(0);#ifdef datageneral/* A kludge for now -- the real change needs to be done elsewhere... */ { extern char *WHOCMD; if ((strcmp(prefix,WHOCMD) == 0) && (*suffix == 0)) strcpy(suffix,"[!pids]"); }#endif for (cp = cmdstr; *prefix != '\0'; *cp++ = *prefix++) ; while (*cp++ = *suffix++) ; debug(F110,"syscmd",cmdstr,0); if (zopeni(ZSYSFN,cmdstr) > 0) { debug(F100,"syscmd zopeni ok",cmdstr,0); nfils = sndsrc = 0; /* Flag that input from stdin */ xflg = hcflg = 1; /* And special flags for pipe */ if (binary) { /* If file mode is binary, */ binary = 0; /* turn it back to text for this, */ savmod = 1; /* remember to restore it later. */ } return (sinit()); /* Send S packet */ } else { debug(F100,"syscmd zopeni failed",cmdstr,0); return(0); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -