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

📄 ckuusy.c

📁 C-Kermit源码。是使用串口/Modem和网络通讯的程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#include "ckcsym.h"#define XFATAL fatal#ifndef NOCMDL/*  C K U U S Y --  "User Interface" for Unix Kermit, part Y  *//*  Command-Line Argument Parser *//*  Author: Frank da Cruz <fdc@columbia.edu>  Columbia University, New York City.  Copyright (C) 1985, 2000,    Trustees of Columbia University in the City of New York.    All rights reserved.  See the C-Kermit COPYING.TXT file or the    copyright text in the ckcmai.c module for disclaimer and permissions.*/#include "ckcdeb.h"#include "ckcasc.h"#include "ckcker.h"#include "ckucmd.h"#include "ckcnet.h"#include "ckuusr.h"#include <signal.h>#ifdef OS2#include <io.h>#endif /* OS2 */extern int inserver, fncnv, f_save, xfermode;#ifdef PATTERNSextern int patterns;#endif /* PATTERNS */#ifndef NOICPextern int cmdint;#endif /* NOICP */extern int suspend;#ifdef NETCONN#ifdef ANYX25extern int revcall, closgr, cudata;extern char udata[];extern int x25fd;#endif /* ANYX25 */#ifndef VMS#ifndef OS2#ifndef OSKextern#endif /* OSK */#endif /* OS2 */#endif /* VMS */int telnetfd;extern struct keytab netcmd[];extern int tn_exit;#ifndef NOICP#ifndef NODIALextern int nnets, nnetdir;              /* Network services directory */extern char *netdir[];extern char *nh_p[];                    /* Network directory entry pointers */extern char *nh_p2[];                   /* Network directory entry nettype */extern char *nh_px[4][MAXDNUMS + 1];#endif /* NODIAL */extern int nhcount;extern char * n_name;                   /* Network name pointer */#endif /* NOICP */#endif /* NETCONN */#ifndef NOSPLextern int nmac;extern struct mtab *mactab;extern char uidbuf[];#endif /* NOSPL */#ifdef CK_LOGINextern int logintimo;#endif /* CK_LOGIN */extern char * myname, * dftty;extern int howcalled;extern char *ckxsys, *ckzsys, **xargv, **cmlist, *clcmds;extern int action, cflg, xargc, cnflg, local, quiet, escape, network, mdmtyp,  bgset, backgrd, xargs, binary, parity, turn, turnch, duplex, flow, clfils,  noinit, stayflg, nettype, cfilef, noherald, cmask, cmdmsk, exitonclose,  haveline, justone, cxtype, xfinish, ttnproto;extern long speed;extern char ttname[];extern char * pipedata, * cmdfil;char * xargv0 = "";#ifndef NOXFERextern char *cmarg, *cmarg2;extern int nfils, stdouf, stdinf, displa, maxrps, rpsiz, ckwarn, urpsiz,  wslotr, swcapr, ckdelay, recursive, reliable, xreliable, fnspath, fncact,  clearrq, setreliable;#ifdef PIPESENDextern int usepipes, pipesend;#endif /* PIPESEND */extern int protocol;#endif /* NOXFER */#ifdef OS2extern struct keytab os2devtab[];extern int nos2dev;extern int ttslip;#ifdef OS2PMextern int os2pm;#endif /* OS2PM */#endif /* OS2 */#ifdef CK_NETBIOSextern unsigned char NetBiosAdapter;#endif /* CK_NETBIOS */#ifdef XFATAL#undef XFATAL#endif /* XFATAL */#ifndef NOICP#ifndef NODIALextern int nmdm, telephony;extern struct keytab mdmtab[];extern int usermdm, dialudt;#endif /* NODIAL */extern int what;_PROTOTYP(static int pmsg, (char *) );_PROTOTYP(static int fmsg, (char *) );static int pmsg(s) char *s; { printf("%s\n", s); return(0); }static int fmsg(s) char *s; { fatal(s); return(0); }#define XFATAL(s) return(what==W_COMMAND?pmsg(s):fmsg(s))#else#define XFATAL fatal#endif /* NOICP */#ifndef NOCMDL/* Command-Line usage message (must fit in 24x80) */staticchar *hlp1[] = {#ifndef NOICP" [cmdfile] [-x arg [-x arg]...[-yyy]..] [ = text ] ]\n",#else"[-x arg [-x arg]...[-yyy]..]\n",#endif /* NOICP */"  -x is an option requiring an argument, -y an option with no argument.\n","actions:\n","  -s files  send files                  -r  receive files\n","  -s -      send from stdin             -k  receive files to stdout\n",#ifndef NOSERVER"  -x        enter server mode           -f  finish remote server\n",#else"  -f        finish remote server\n",#endif /* NOSERVER */"  -g files  get remote files from server (quote wildcards)\n","  -a name   alternate file name, used with -s, -r, -g\n",#ifndef NOLOCAL"  -c        connect (before file transfer), used with -l and -b\n","  -n        connect (after file transfer), used with -l and -b\n",#endif /* NOLOCAL */"settings:\n",#ifndef NOLOCAL"  -l dev    communication line device   -q  quiet during file transfer\n",#ifdef NETCONN"  -j host   network host name[:port]    -i  binary transfer (-T = text)\n",#else"  -i        binary file transfer\n",#endif /* NETCONN */"  -b bps    line speed, e.g. 19200      -t  half duplex, xon handshake\n",#else"  -i        binary file transfer\n",#endif /* NOLOCAL */#ifdef DEBUG"  -p x      parity, x = e,o,m,s, or n   -d  log debug info to debug.log\n",#else"  -p x      parity, x = e,o,m,s, or n\n",#endif /* DEBUG */#ifndef NOICP"  -y name   alternate init file name    -Y  no init file\n",#else#endif /* NOICP */"  -e n      receive packet length       -w  write over files\n",#ifdef UNIX"  -v n      sliding window slots        -z  force foreground\n",#else"  -v n      sliding window slots\n",#endif /* UNIX */#ifndef NODIAL"  -m name   modem type                  -R  remote-only advisory\n",#endif /* NODIAL *//*  If all this stuff is defined, we run off the screen...*/#ifdef CK_NETBIOS"  -N n      NetBIOS adapter number\n",#endif /* CK_NETBIOS */#ifdef ANYX25" -o index   X.25 closed user group call -X  X.25 address\n"," -U string  X.25 call user data         -u  X.25 reverse charge call\n"," -Z n       X.25 connection open file descriptor\n",#endif /* ANYX25 */#ifndef NOICP"If no action command is included, or -S is, enter interactive dialog.\n","Type HELP OPTIONS at the prompt for further info.\n",#else"Operation by command-line options only.\n","See the manual \"Using C-Kermit\" for complete information.\n",#endif /* NOICP */""};#ifndef NOHELP/* Command-line option help lines.  Update this when adding new options! */char * opthlp[128];                     /* Option help */char * arghlp[128];                     /* Argument for option */int optact[128];                        /* Action-option flag */#endif /* NOHELP */VOIDfatal2(msg1,msg2) char *msg1, *msg2; {    char buf[256];    if (!msg1) msg1 = "";    if (!msg2) msg2 = "";    sprintf(buf,"\"%s\" - %s",msg1,msg2);#ifndef NOICP    if (what == W_COMMAND)      printf("%s\n",buf);    else#endif /* NOICP */      fatal((char *)buf);}static SIGTYP#ifdef CK_ANSIcl_int(int dummy)#else /* CK_ANSI */cl_int(dummy) int dummy;#endif /* CK_ANSI */{					/* Command-line interrupt handler */    doexit(BAD_EXIT,1);    SIGRETURN;}/*  U S A G E */VOIDusage() {#ifndef MINIX    conol("Usage: ");    conol(xargv0);    conola(hlp1);#else    conol("Usage: ");    conol(xargv0);    conol(" [-x arg [-x arg]...[-yyy]..] ]\n");#endif /* MINIX */}#endif /* NOCMDL *//*  C M D L I N  --  Get arguments from command line  */intcmdlin() {    char x;                             /* Local general-purpose char */#ifndef NOXFER    cmarg = "";                         /* Initialize globals */    cmarg2 = "";#endif /* NOXFER */    action = 0;    cflg = 0;    xargv0 = xargv[0];    debug(F111,"cmdlin myname",myname,howcalled);    signal(SIGINT,cl_int);/* Here we handle different "Command Line Personalities" */#ifdef TCPSOCKET    if (howcalled == I_AM_TELNET) {     /* If I was called as Telnet... */        if (--xargc > 0) {              /* And I have a hostname... */            xargv++;            ckstrncpy(ttname,*xargv,TTNAMLEN+1);            debug(F110,"cmdlin telnet host",ttname,0);#ifndef NOICP#ifndef NODIAL            nhcount = 0;                /* Check network directory */            debug(F101,"cmdlin nnetdir","",nnetdir);            if (nnetdir > 0)            /* If there is a directory... */              lunet(*xargv);            /* Look up the name */            else                        /* If no directory */              nhcount = 0;              /* we didn't find anything there */#ifdef DEBUG            if (deblog) {                debug(F101,"cmdlin lunet nhcount","",nhcount);                if (nhcount > 0) {                    debug(F110,"cmdlin lunet nh_p[0]",nh_p[0],0);                    debug(F110,"cmdlin lunet nh_p2[0]",nh_p2[0],0);                    debug(F110,"cmdlin lunet nh_px[0][0]",nh_px[0][0],0);                }            }#endif /* DEBUG */            if (nhcount > 0 && nh_p2[0]) /* If network type specified */              if (ckstrcmp(nh_p2[0],"tcp/ip",6,0)) /* it must be TCP/IP */                nhcount = 0;            if (nhcount == 1) {         /* Still OK, so make substitution */                ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);                debug(F110,"cmdlin lunet substitution",ttname,0);            }#endif /* NODIAL */#endif /* NOICP */            if (--xargc > 0) {          /* Service specified on cmd line? */                xargv++;                strcat(ttname,":");                strcat(ttname,*xargv);                debug(F110,"cmdlin telnet host2",ttname,0);            }#ifndef NOICP#ifndef NODIAL            else if (nhcount) {         /* No - how about in net directory? */                if (nh_px[0][0]) {                    strcat(ttname,":");                    strcat(ttname,nh_px[0][0]);                }            }#endif /* NODIAL */#endif /* NOICP */            local = 1;                  /* Try to open the connection */            nettype = NET_TCPB;            mdmtyp = -nettype;            if (ttopen(ttname,&local,mdmtyp,0) < 0) {                XFATAL("can't open host connection");            }            network = 1;                /* It's open */#ifdef CKLOGDIAL            dolognet();#endif /* CKLOGDIAL */#ifndef NOXFER            reliable = 1;               /* It's reliable */            xreliable = 1;              /* ... */            setreliable = 1;#endif /* NOXFER */            cflg = 1;                   /* Connect */            stayflg = 1;                /* Stay */            tn_exit = 1;                /* Telnet-like exit condition */            quiet = 1;            exitonclose = 1;            /* Exit when connection closes */#ifndef NOSPL            if (local) {                if (nmac) {                     /* Any macros defined? */                    int k;                      /* Yes */                    k = mlook(mactab,"on_open",nmac);   /* Look this up */                    if (k >= 0) {                       /* If found, */                        if (dodo(k,ttname,0) > -1)      /* set it up, */                          parser(1);                    /* and execute it */                    }                }            }#endif /* NOSPL */        }        return(0);    }#ifdef COMMENT#ifdef RLOGCODE    else if (howcalled == I_AM_RLOGIN) { /* If I was called as Rlogin... */        /* Add rlogin command-line parsing here... */        return(0);    }#endif /* RLOGCODE */#endif /* COMMENT */#endif /* TCPSOCKET *//*  From here down: We were called as "kermit" or "iksd".  If we were started directly from a Kermit application file, its name is  in argv[1], so skip past it.*/    if (xargc > 1) {        int n = 1;        if (*xargv[1] != '-') {#ifdef KERBANG            /* If we were started with a Kerbang script, the script */            /* arguments were already picked up in prescan / cmdini() */            /* and there is nothing here for us anyway. */            if (!strcmp(xargv[1],"+"))              return(0);#endif /* KERBANG */            if (cfilef) {               /* Command file found in prescan() */                xargc -= n;             /* Skip past it */                xargv += n;                cfilef = 0;                debug(F101,"cmdlin cfilef set to 0","",cfilef);            }        }    }/* Regular Unix-style command line parser, conforming with 'A Proposed Command Syntax Standard for Unix Systems', Hemenway & Armitage, Unix/World, Vol.1, No.3, 1984.*/    while (--xargc > 0) {               /* Go through command line words */        xargv++;        debug(F111,"cmdlin xargv",*xargv,xargc);        if (**xargv == '=')          return(0);

⌨️ 快捷键说明

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