📄 ckuusy.c
字号:
break; } } free(p); break; }#endif /* CK_SSL */ case 'h': /* Help */ default: printf("Usage: %s host [ options... ]\n",xarg0); conola(http_hlp); doexit(GOOD_EXIT,-1); } } else { /* No dash - must be hostname */ host = *xargv; if (xargc > 1) { svc = *(xargv+1); if (svc) if (*svc == '-' || !*svc) svc = NULL; if (svc) { xargv++; xargc--; } } } } if (!svc) svc = ""; if (!*svc) svc = "http"; if (!host) XFATAL("No http host given"); /* Check action args before opening the connection */ if (http_action) { if (http_action == HTTP_PUT) { if (!lpath) XFATAL("No local path for http PUT"); } if (!path) XFATAL("No remote path for http action"); } /* Now it's OK to open the connection */ rdns[0] = NUL; x = (http_open(host, svc,!ckstrcmp("https",svc,-1,0),rdns,128,NULL ) == 0); if (!x) { if (!quiet) printf("?HTTP Connection failed.\r\n"); doexit(BAD_EXIT,-1); } if (!quiet) { if (rdns[0]) printf("Connected to %s [%s]\r\n",host,rdns); else printf("Connected to %s\r\n",host); } if (http_action) { int pcpy = 0; if (http_action != HTTP_PUT) { /* Supply default */ if (!lpath) { /* local path... */ zstrip(path,&lpath); if (!lpath) lpath = ""; if (!*lpath) lpath = "index.html"; } } if (*path != '/') { char * p = (char *) malloc(strlen(path)+2); if (!p) fatal("?Memory allocation error\n"); *p = '/'; strcpy(&p[1],path); /* safe */ path = p; pcpy = 1; } switch (http_action) { case HTTP_GET: x = http_get(agent,NULL,user,pswd,0,lpath,path,0); break; case HTTP_PUT: x = http_put(agent,NULL,"text/HTML", user,pswd,0,lpath,path,NULL,0); break; case HTTP_HED: x = http_head(agent,NULL,user,pswd,0,lpath,path,0); break; } debug(F101,"cmdline http result","",x); x = (http_close() == 0); if (pcpy) free(path); doexit(x ? GOOD_EXIT : BAD_EXIT, -1); } return(0); } } else#endif /* NOHTTP */#ifdef NEWFTP if (howcalled == I_AM_FTP) { /* If I was called as FTP... */ debug(F100,"ftp personality","",0);#ifdef CK_URL if (haveurl) doftparg('U'); else #endif /* CK_URL */ { while (--xargc > 0) { /* Go through command line words */ xargv++; debug(F111,"cmdlin ftp xargv",*xargv,xargc); if (**xargv == '-') { /* Got an option */ int xx; x = *(*xargv+1); /* Get the option letter */ xx = doftparg(x); if (xx < 0) { if (what == W_COMMAND) return(0); else doexit(BAD_EXIT,1); } } else { /* No dash - must be hostname */ makestr(&ftp_host,*xargv); if (xargc > 1) { port = *(xargv+1); if (port) if (*port == '-' || !*port) port = NULL; if (port) { xargv++; xargc--; } } debug(F110,"cmdlin ftp host",ftp_host,0); debug(F110,"cmdlin ftp port",port,0); } } /* while */ } /* if (haveurl) */ if (ftp_host) { int xx;#ifdef NODIAL xx = xx_ftp(ftp_host,port); if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);#else#ifdef NOICP xx = xx_ftp(ftp_host,port); if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);#else if (*ftp_host == '=') { /* Skip directory lookup */ xx = xx_ftp(&ftp_host[1],port); if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1); } else { /* Want lookup */ int i; nhcount = 0; /* Check network directory */ debug(F101,"cmdlin nnetdir","",nnetdir); if (nnetdir > 0) /* If there is a directory... */ lunet(ftp_host); /* 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) { xx = xx_ftp(ftp_host,port); if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1); } else { for (i = 0; i < nhcount; i++) { if (ckstrcmp(nh_p2[i],"tcp/ip",6,0)) continue; makestr(&ftp_host,nh_p[i]); debug(F110,"cmdlin calling xx_ftp",ftp_host,0); if (!quiet) printf("Trying %s...\n",ftp_host); if (xx_ftp(ftp_host,port) > -1) break; } } }#endif /* NODIAL */#endif /* NOICP */ if (!ftpisconnected()) doexit(BAD_EXIT,-1); } return(0); }#endif /* NEWFTP */#ifdef TNCODE if (howcalled == I_AM_TELNET) { /* If I was called as Telnet... */ while (--xargc > 0) { /* Go through command line words */ xargv++; debug(F111,"cmdlin telnet xargv",*xargv,xargc); if (**xargv == '=') return(0); if (!strcmp(*xargv,"--")) /* getopt() conformance */ return(0);#ifdef VMS else if (**xargv == '/') continue;#endif /* VMS */ else if (**xargv == '-') { /* Got an option (begins with dash) */ int xx; x = *(*xargv+1); /* Get the option letter */ debug(F111,"cmdlin telnet args 1",*xargv,xargc); xx = dotnarg(x); debug(F101,"cmdlin telnet doarg","",xx); debug(F111,"cmdlin telnet args 2",*xargv,xargc); if (xx < 0) {#ifndef NOICP if (what == W_COMMAND) return(0); else#endif /* NOICP */ {#ifdef OS2 sleep(1); /* Give it a chance... */#endif /* OS2 */ doexit(BAD_EXIT,1); /* Go handle option */ } } } else { /* No dash must be hostname */ ckstrncpy(ttname,*xargv,TTNAMLEN+1); debug(F110,"cmdlin telnet host",ttname,0);#ifndef NOICP#ifndef NODIAL nhcount = 0; /* Check network directory */ debug(F101,"cmdlin telnet 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 telnet lunet nhcount","",nhcount); if (nhcount > 0) { debug(F110,"cmdlin telnet lunet nh_p[0]",nh_p[0],0); debug(F110,"cmdlin telnet lunet nh_p2[0]",nh_p2[0],0); debug(F110,"cmdlin telnet 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 telnet lunet substitution",ttname,0); }#endif /* NODIAL */#endif /* NOICP */ if (--xargc > 0 && !haveurl) { /* Service from command line? */ xargv++; ckstrncat(ttname,":",TTNAMLEN+1); ckstrncat(ttname,*xargv,TTNAMLEN+1); 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]) { ckstrncat(ttname,":",TTNAMLEN+1); ckstrncat(ttname,nh_px[0][0],TTNAMLEN+1); } }#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 */ break; } } return(0); }#endif /* TNCODE */#ifdef RLOGCODE else if (howcalled == I_AM_RLOGIN) { /* If I was called as Rlogin... */ while (--xargc > 0) { /* Go through command line words */ xargv++; debug(F111,"cmdlin rlogin xargv",*xargv,xargc); if (**xargv == '=') return(0); if (!strcmp(*xargv,"--")) /* getopt() conformance */ return(0);#ifdef VMS else if (**xargv == '/') continue;#endif /* VMS */ else if (**xargv == '-') { /* Got an option (begins with dash) */ int xx; x = *(*xargv+1); /* Get the option letter */ debug(F111,"cmdlin rlogin args 1",*xargv,xargc); xx = dorlgarg(x); debug(F101,"cmdlin rlogin doarg","",xx); debug(F111,"cmdlin rlogin args 2",*xargv,xargc); if (xx < 0) {#ifndef NOICP if (what == W_COMMAND) return(0); else#endif /* NOICP */ {#ifdef OS2 sleep(1); /* Give it a chance... */#endif /* OS2 */ doexit(BAD_EXIT,1); /* Go handle option */ } } } else { /* No dash must be hostname */ ckstrncpy(ttname,*xargv,TTNAMLEN+1); debug(F110,"cmdlin rlogin host",ttname,0);#ifndef NOICP#ifndef NODIAL nhcount = 0; /* Check network directory */ debug(F101,"cmdlin rlogin 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 rlogin lunet nhcount","",nhcount); if (nhcount > 0) { debug(F110,"cmdlin rlogin lunet nh_p[0]",nh_p[0],0); debug(F110,"cmdlin rlogin lunet nh_p2[0]",nh_p2[0],0); debug(F110,"cmdlin rlogin 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 rlogin lunet substitution",ttname,0); }#endif /* NODIAL */#endif /* NOICP */ if (!haveurl) { /* Service from command line? */ ckstrncat(ttname,":login",TTNAMLEN+1); debug(F110,"cmdlin rlogin host2",ttname,0); } 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 */ break; } } return(0); }#endif /* RLOGCODE */#endif /* TCPSOCKET */#ifdef SSHBUILTIN if (howcalled == I_AM_SSH) { /* If I was called as SSH... */ extern char * ssh_hst, * ssh_cmd, * ssh_prt; debug(F100,"ssh personality","",0);#ifdef CK_URL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -