diff --git a/.gitignore b/.gitignore index 819a368..dd7819b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ # General rules *.o +ckcpro.c wart wermit UNINSTALL diff --git a/COPYING.TXT b/COPYING.TXT index 200f236..cb09065 100644 --- a/COPYING.TXT +++ b/COPYING.TXT @@ -5,19 +5,19 @@ Fri Jun 24 14:43:35 2011 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - + + Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + + Neither the name of Columbia University nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/NOTES.TXT b/NOTES.TXT index 498f272..93e8028 100644 --- a/NOTES.TXT +++ b/NOTES.TXT @@ -50,7 +50,7 @@ C-KERMIT UPDATE HISTORY * [25]Change logs for C-Kermit releases 1985-2011 (plain text) * [26]Announcements of older C-Kermit releases (plain text) - Grüße aus Bronx <- (pay no attention, this is to make sure that EMACS + Gr��e aus Bronx <- (pay no attention, this is to make sure that EMACS didn't mess up this page's UTF-8 encoding) This page, which as of May 2022 would be about 200 pages long if @@ -138,7 +138,7 @@ C-Kermit>set speed ? Serial-port speed (bits per second), one of the following: 6 October 2022: - ckutio.c changes from Pali Rohár to get at the higher serial speeds + ckutio.c changes from Pali Roh�r to get at the higher serial speeds supported by newer UARTs. + ckutio.c ttsspd() was missing the new high-speed baud rates @@ -749,7 +749,7 @@ C-Kermit 10.0 Beta.01 16 May 2022 and Beta.02 17 May 2022 |> New features * Serial-port speed selections for 1000000, 2000000, 2500000, - 3000000, 3500000, and 4000000 bps, suggested by Pali Rohár. The new + 3000000, 3500000, and 4000000 bps, suggested by Pali Roh�r. The new high speeds have not been tested because I no longer have a computer with serial port. * New VDIRECTORY command with 1-letter synonym V, a convenient alias @@ -1536,7 +1536,7 @@ def MAXPATHLEN 1024 doubled as it should be, but the next byte is skipped. Fixed in ckutio.c ttptycmd() about line 14998. * 30 Sep 2021: - From Sébastien Villemot; a printw() statement was changed to + From S�bastien Villemot; a printw() statement was changed to fputs() to avoid gcc -Wformat -Werror=format-security warning on Debian. ckuusx.c, * 8 May 2021: @@ -1635,12 +1635,12 @@ ckvioc.c C-Kermit 9.0.305 Alpha.02 19 September 2020 - From Sébastien Villemot (Debian): Remove clauses from the linux+krb5, + From S�bastien Villemot (Debian): Remove clauses from the linux+krb5, linux+ssl, and linux+krb5+ssl makefile targets that tested to see if an executable was actually created, because they violate Debian policy. makefile, 18 September 2020. - From Sébastien Villemot (Debian): Add another "else if" to the search + From S�bastien Villemot (Debian): Add another "else if" to the search for the Kerberos 5 com_err library for Multiarch systems. makefile, 18 September 2020. @@ -5240,7 +5240,7 @@ make: [solaris9g+openssl+shadow+pam+zlib] Error 2 out the linuxnc (and linuxc) targets needed the same treatment as the Linux one for 64-bit Linuxes. makefile, 3 Mar 2009. - From Günter Knauf: 64-bit builds were failing on SuSE Linux because + From G�nter Knauf: 64-bit builds were failing on SuSE Linux because libresolv and libcrypt were in lib64 rather than lib; updated the tests in the linux makefile target to find them. makefile, 12 Jan 2009. diff --git a/android.mk b/android.mk index ba486bc..f222c76 100644 --- a/android.mk +++ b/android.mk @@ -28,4 +28,3 @@ LOCAL_MODULE := kermit LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE_TAGS := eng include $(BUILD_EXECUTABLE) - diff --git a/ck_crp.c b/ck_crp.c index 0c47408..7c97fa5 100644 --- a/ck_crp.c +++ b/ck_crp.c @@ -99,11 +99,7 @@ int cmd_quoting = 0; #ifdef OS2 /* Copied from ckctel.c */ char * -#ifdef CK_ANSIC tel_unk(int opt) /* "UNKNOWN-%u" string. */ -#else -tel_unk(opt) int opt; -#endif /* CK_ANSIC */ { /* 2024-03-27 SMS. Added (decimal) value to "UNKNOWN" messages. */ static char val_str[ 20]; @@ -114,7 +110,8 @@ tel_unk(opt) int opt; #ifndef TELOPT_MACRO int -telopt_index(opt) int opt; { +telopt_index(int opt) +{ if ( opt >= 0 && opt <= TELOPT_SEND_URL ) return(opt); else if ( opt >= TELOPT_PRAGMA_LOGON && opt <= TELOPT_PRAGMA_HEARTBEAT ) @@ -124,13 +121,15 @@ telopt_index(opt) int opt; { } int -telopt_ok(opt) int opt; { +telopt_ok(int opt) +{ return((opt >= TELOPT_BINARY && opt <= TELOPT_SEND_URL) || (opt >= TELOPT_PRAGMA_LOGON && opt <= TELOPT_PRAGMA_HEARTBEAT)); } CHAR * -telopt(opt) int opt; { +telopt(int opt) +{ if ( telopt_ok(opt) ) return(telopts[telopt_index(opt)]); else @@ -198,7 +197,8 @@ tn_debug( char * s ) static char myprtfstr[4096]; int -Vscrnprintf(const char * format, ...) { +Vscrnprintf(const char * format, ...) +{ int i, len, rc=0; char *cp; va_list ap; @@ -368,8 +368,7 @@ static Block weak_keys[NUM_WEAK_KEY]={ {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}}; int -ck_des_is_weak_key(key) -Block key; +ck_des_is_weak_key(Block key) { int i; @@ -397,8 +396,7 @@ Block key; #include unsigned long -unix_time_gmt_unixsec (usecptr) - unsigned long *usecptr; +unix_time_gmt_unixsec(unsigned long *usecptr) { struct timeval now; @@ -431,7 +429,7 @@ des_new_random_key(Block B) /* WARNING: This might need to have the "rc = " removed because this is VOID in later, and maybe even all, versions. - */ + */ rc = des_random_key(B); return(rc); } @@ -934,7 +932,7 @@ static struct key_info { int keylen; int dir; int *modep; - Encryptions *(*getcrypt)(); + Encryptions *(*getcrypt)(int); } ki[2] = { { { 0 }, 0, DIR_ENCRYPT, &encrypt_mode, findencryption }, { { 0 }, 0, DIR_DECRYPT, &decrypt_mode, finddecryption }, @@ -1081,7 +1079,7 @@ encrypt_support(unsigned char *_typelist, int _cnt) encrypt_support(_typelist, _cnt) unsigned char * _typelist; int _cnt; #endif { - register int type, use_type = 0; + int type, use_type = 0; unsigned char * typelist = _typelist; int cnt = _cnt; Encryptions *ep; @@ -1155,7 +1153,7 @@ encrypt_is(data, cnt) unsigned char *data; int cnt; #endif /* CK_ANSIC */ { Encryptions *ep; - register int type, ret; + int type, ret; if (--cnt < 0) return(-1); @@ -1219,7 +1217,7 @@ encrypt_reply(data, cnt) unsigned char *data; int cnt; #endif { Encryptions *ep; - register int ret, type; + int ret, type; if (--cnt < 0) return(-1); @@ -1469,7 +1467,7 @@ encrypt_keyid(kp, keyid, len) { Encryptions *ep; int dir = kp->dir; - register int ret = 0; + int ret = 0; if (!(ep = (*kp->getcrypt)(*kp->modep))) { if (len == 0) @@ -1589,8 +1587,8 @@ encrypt_start_output(type) int type; #endif { Encryptions *ep; - register unsigned char *p; - register int i; + unsigned char *p; + int i; #ifdef CK_SSL if (TELOPT_SB(TELOPT_START_TLS).start_tls.me_follows) @@ -1740,8 +1738,8 @@ encrypt_send_request_start(VOID) encrypt_send_request_start() #endif { - register unsigned char *p; - register int i; + unsigned char *p; + int i; #ifdef CK_SSL if (TELOPT_SB(TELOPT_START_TLS).start_tls.me_follows) @@ -2059,7 +2057,7 @@ ofb64_init(server) void fb64_init(fbp) - register struct des_fb *fbp; + struct des_fb *fbp; { memset((void *)fbp, 0, sizeof(*fbp)); fbp->state[0] = fbp->state[1] = xFAILED; @@ -2100,7 +2098,7 @@ fb64_start(fbp, dir, server) { int x; unsigned char *p; - register int state; + int state; switch (dir) { case DIR_DECRYPT: @@ -2225,7 +2223,7 @@ fb64_is(data, cnt, fbp) struct des_fb *fbp; { unsigned char *p; - register int state = fbp->state[DIR_DECRYPT-1]; + int state = fbp->state[DIR_DECRYPT-1]; if (cnt-- < 1) goto failure; @@ -2354,7 +2352,7 @@ fb64_reply(data, cnt, fbp) int cnt; struct des_fb *fbp; { - register int state = fbp->state[DIR_ENCRYPT-1]; + int state = fbp->state[DIR_ENCRYPT-1]; if (cnt-- < 1) goto failure; @@ -2536,7 +2534,7 @@ fb64_keyid(dir, kp, lenp, fbp) unsigned char *kp; struct des_fb *fbp; { - register int state = fbp->state[dir-1]; + int state = fbp->state[dir-1]; if (*lenp != 1 || (*kp != '\0')) { *lenp = 0; @@ -2558,7 +2556,7 @@ fb64_printsub(data, cnt, buf, buflen, type) int cnt, buflen; { char lbuf[64]; - register int i; + int i; char *cp; buf[buflen-1] = '\0'; /* make sure it's NULL terminated */ @@ -2625,7 +2623,7 @@ ofb64_printsub(data, cnt, buf, buflen) void fb64_stream_iv(seed, stp) Block seed; - register struct des_stinfo *stp; + struct des_stinfo *stp; { int rc=0; @@ -2660,7 +2658,7 @@ fb64_stream_iv(seed, stp) void fb64_stream_key(key, stp) Block key; - register struct des_stinfo *stp; + struct des_stinfo *stp; { int rc = 0; @@ -2725,11 +2723,11 @@ fb64_stream_key(key, stp) void cfb64_encrypt(s, c) - register unsigned char *s; + unsigned char *s; int c; { - register struct des_stinfo *stp = &des_fb[CFB].streams[DIR_ENCRYPT-1]; - register int index; + struct des_stinfo *stp = &des_fb[CFB].streams[DIR_ENCRYPT-1]; + int index; index = stp->str_index; while (c-- > 0) { @@ -2756,7 +2754,7 @@ int cfb64_decrypt(data) int data; { - register struct des_stinfo *stp = &des_fb[CFB].streams[DIR_DECRYPT-1]; + struct des_stinfo *stp = &des_fb[CFB].streams[DIR_DECRYPT-1]; int index; if (data == -1) { @@ -2809,11 +2807,11 @@ cfb64_decrypt(data) */ void ofb64_encrypt(s, c) - register unsigned char *s; + unsigned char *s; int c; { - register struct des_stinfo *stp = &des_fb[OFB].streams[DIR_ENCRYPT-1]; - register int index; + struct des_stinfo *stp = &des_fb[OFB].streams[DIR_ENCRYPT-1]; + int index; index = stp->str_index; while (c-- > 0) { @@ -2837,7 +2835,7 @@ int ofb64_decrypt(data) int data; { - register struct des_stinfo *stp = &des_fb[OFB].streams[DIR_DECRYPT-1]; + struct des_stinfo *stp = &des_fb[OFB].streams[DIR_DECRYPT-1]; int index; if (data == -1) { @@ -2899,7 +2897,7 @@ des3_ofb64_init(server) void des3_fb64_init(fbp) - register struct des3_fb *fbp; + struct des3_fb *fbp; { memset((void *)fbp, 0, sizeof(*fbp)); fbp->state[0] = fbp->state[1] = xFAILED; @@ -2940,7 +2938,7 @@ des3_fb64_start(fbp, dir, server) { int x; unsigned char *p; - register int state; + int state; switch (dir) { case DIR_DECRYPT: @@ -3054,7 +3052,7 @@ des3_fb64_is(data, cnt, fbp) struct des3_fb *fbp; { unsigned char *p; - register int state = fbp->state[DIR_DECRYPT-1]; + int state = fbp->state[DIR_DECRYPT-1]; if (cnt-- < 1) goto failure; @@ -3183,7 +3181,7 @@ des3_fb64_reply(data, cnt, fbp) int cnt; struct des3_fb *fbp; { - register int state = fbp->state[DIR_ENCRYPT-1]; + int state = fbp->state[DIR_ENCRYPT-1]; if (cnt-- < 1) goto failure; @@ -3405,7 +3403,7 @@ des3_fb64_keyid(dir, kp, lenp, fbp) unsigned char *kp; struct des3_fb *fbp; { - register int state = fbp->state[dir-1]; + int state = fbp->state[dir-1]; if (*lenp != 1 || (*kp != '\0')) { *lenp = 0; @@ -3427,7 +3425,7 @@ des3_fb64_printsub(data, cnt, buf, buflen, type) int cnt, buflen; { char lbuf[64]; - register int i; + int i; char *cp; buf[buflen-1] = '\0'; /* make sure it's NULL terminated */ @@ -3494,7 +3492,7 @@ des3_ofb64_printsub(data, cnt, buf, buflen) void des3_fb64_stream_iv(seed, stp) Block seed; - register struct des3_stinfo *stp; + struct des3_stinfo *stp; { int rc=0, i = 0;; @@ -3527,7 +3525,7 @@ des3_fb64_stream_iv(seed, stp) void des3_fb64_stream_key(key, stp) Block * key; - register struct des3_stinfo *stp; + struct des3_stinfo *stp; { int rc = 0, i = 0; @@ -3586,11 +3584,11 @@ des3_fb64_stream_key(key, stp) void des3_cfb64_encrypt(s, c) - register unsigned char *s; + unsigned char *s; int c; { - register struct des3_stinfo *stp = &des3_fb[CFB].streams[DIR_ENCRYPT-1]; - register int index; + struct des3_stinfo *stp = &des3_fb[CFB].streams[DIR_ENCRYPT-1]; + int index; index = stp->str_index; while (c-- > 0) { @@ -3623,7 +3621,7 @@ int des3_cfb64_decrypt(data) int data; { - register struct des3_stinfo *stp = &des3_fb[CFB].streams[DIR_DECRYPT-1]; + struct des3_stinfo *stp = &des3_fb[CFB].streams[DIR_DECRYPT-1]; int index; if (data == -1) { @@ -3686,11 +3684,11 @@ des3_cfb64_decrypt(data) */ void des3_ofb64_encrypt(s, c) - register unsigned char *s; + unsigned char *s; int c; { - register struct des3_stinfo *stp = &des3_fb[OFB].streams[DIR_ENCRYPT-1]; - register int index; + struct des3_stinfo *stp = &des3_fb[OFB].streams[DIR_ENCRYPT-1]; + int index; index = stp->str_index; while (c-- > 0) { @@ -3720,7 +3718,7 @@ int des3_ofb64_decrypt(data) int data; { - register struct des3_stinfo *stp = &des3_fb[OFB].streams[DIR_DECRYPT-1]; + struct des3_stinfo *stp = &des3_fb[OFB].streams[DIR_DECRYPT-1]; int index; if (data == -1) { @@ -3947,16 +3945,14 @@ static int _cast_ofb64_decrypt P((int, struct cast_stinfo *)); #ifndef CAST_EXPORT_ENCRYPTION void -cast_cfb64_init(server) - int server; +cast_cfb64_init(int server) { cast_fb64_init(&cast_fb[CFB_128]); cast_fb[CFB_128].fb_feed[4] = ENCTYPE_CAST128_CFB64; } void -cast_ofb64_init(server) - int server; +cast_ofb64_init(int server) { cast_fb64_init(&cast_fb[OFB_128]); cast_fb[OFB_128].fb_feed[4] = ENCTYPE_CAST128_OFB64; @@ -3964,24 +3960,21 @@ cast_ofb64_init(server) #endif void -castexp_cfb64_init(server) - int server; +castexp_cfb64_init(int server) { cast_fb64_init(&cast_fb[CFB_40]); cast_fb[CFB_40].fb_feed[4] = ENCTYPE_CAST5_40_CFB64; } void -castexp_ofb64_init(server) - int server; +castexp_ofb64_init(int server) { cast_fb64_init(&cast_fb[OFB_40]); cast_fb[OFB_40].fb_feed[4] = ENCTYPE_CAST5_40_OFB64; } static void -cast_fb64_init(fbp) - register struct cast_fb *fbp; +cast_fb64_init(struct cast_fb *fbp) { memset((void *)fbp, 0, sizeof(*fbp)); fbp->key_isset = 0; @@ -4002,48 +3995,37 @@ cast_fb64_init(fbp) */ #ifndef CAST_EXPORT_ENCRYPTION int -cast_cfb64_start(dir, server) - int dir; - int server; +cast_cfb64_start(int dir, int server) { return(cast_fb64_start(&cast_fb[CFB_128], dir, server)); } int -cast_ofb64_start(dir, server) - int dir; - int server; +cast_ofb64_start(int dir, int server) { return(cast_fb64_start(&cast_fb[OFB_128], dir, server)); } #endif int -castexp_cfb64_start(dir, server) - int dir; - int server; +castexp_cfb64_start(int dir, int server) { return(cast_fb64_start(&cast_fb[CFB_40], dir, server)); } int -castexp_ofb64_start(dir, server) - int dir; - int server; +castexp_ofb64_start(int dir, int server) { return(cast_fb64_start(&cast_fb[OFB_40], dir, server)); } static int -cast_fb64_start(fbp, dir, server) - struct cast_fb *fbp; - int dir; - int server; +cast_fb64_start(struct cast_fb *fbp, int dir, int server) { Block b; int x; unsigned char *p; - register int state; + int state; switch (dir) { case DIR_DECRYPT: @@ -4107,48 +4089,37 @@ cast_fb64_start(fbp, dir, server) */ #ifndef CAST_EXPORT_ENCRYPTION int -cast_cfb64_is(data, cnt) - unsigned char *data; - int cnt; +cast_cfb64_is(unsigned char *data, int cnt) { return(cast_fb64_is(data, cnt, &cast_fb[CFB_128])); } int -cast_ofb64_is(data, cnt) - unsigned char *data; - int cnt; +cast_ofb64_is(unsigned char *data, int cnt) { return(cast_fb64_is(data, cnt, &cast_fb[OFB_128])); } #endif int -castexp_cfb64_is(data, cnt) - unsigned char *data; - int cnt; +castexp_cfb64_is(unsigned char *data, int cnt) { return(cast_fb64_is(data, cnt, &cast_fb[CFB_40])); } int -castexp_ofb64_is(data, cnt) - unsigned char *data; - int cnt; +castexp_ofb64_is(unsigned char *data, int cnt) { return(cast_fb64_is(data, cnt, &cast_fb[OFB_40])); } static int -cast_fb64_is(data, cnt, fbp) - unsigned char *data; - int cnt; - struct cast_fb *fbp; +cast_fb64_is(unsigned char *data,int cnt, struct cast_fb *fbp) { int x; unsigned char *p; Block b; - register int state = fbp->state[DIR_DECRYPT-1]; + int state = fbp->state[DIR_DECRYPT-1]; if (cnt-- < 1) goto failure; @@ -4216,48 +4187,37 @@ cast_fb64_is(data, cnt, fbp) */ #ifndef CAST_EXPORT_ENCRYPTION int -cast_cfb64_reply(data, cnt) - unsigned char *data; - int cnt; +cast_cfb64_reply(unsigned char *data, int cnt) { return(cast_fb64_reply(data, cnt, &cast_fb[CFB_128])); } int -cast_ofb64_reply(data, cnt) - unsigned char *data; - int cnt; +cast_ofb64_reply(unsigned char *data, int cnt) { return(cast_fb64_reply(data, cnt, &cast_fb[OFB_128])); } #endif int -castexp_cfb64_reply(data, cnt) - unsigned char *data; - int cnt; +castexp_cfb64_reply(unsigned char *data, int cnt) { return(cast_fb64_reply(data, cnt, &cast_fb[CFB_40])); } int -castexp_ofb64_reply(data, cnt) - unsigned char *data; - int cnt; +castexp_ofb64_reply(unsigned char *data, int cnt) { return(cast_fb64_reply(data, cnt, &cast_fb[OFB_40])); } static int -cast_fb64_reply(data, cnt, fbp) - unsigned char *data; - int cnt; - struct cast_fb *fbp; +cast_fb64_reply(unsigned char *data, int cnt, struct cast_fb *fbp) { int x; unsigned char *p; Block b; - register int state = fbp->state[DIR_ENCRYPT-1]; + int state = fbp->state[DIR_ENCRYPT-1]; if (cnt-- < 1) goto failure; @@ -4295,34 +4255,26 @@ cast_fb64_reply(data, cnt, fbp) #ifndef CAST_EXPORT_ENCRYPTION int -cast_cfb64_session(key, server) - Session_Key *key; - int server; +cast_cfb64_session(Session_Key *key, int server) { return(cast_fb64_session(key, server, &cast_fb[CFB_128], 1)); } int -cast_ofb64_session(key, server) - Session_Key *key; - int server; +cast_ofb64_session(Session_Key *key, int server) { return(cast_fb64_session(key, server, &cast_fb[OFB_128], 1)); } #endif int -castexp_cfb64_session(key, server) - Session_Key *key; - int server; +castexp_cfb64_session(Session_Key *key, int server) { return(cast_fb64_session(key, server, &cast_fb[CFB_40], 0)); } int -castexp_ofb64_session(key, server) - Session_Key *key; - int server; +castexp_ofb64_session(Session_Key *key, int server) { return(cast_fb64_session(key, server, &cast_fb[OFB_40], 0)); } @@ -4331,11 +4283,7 @@ castexp_ofb64_session(key, server) #define CAST5_40_KEYLEN 5 /* 40 bits */ static int -cast_fb64_session(key, server, fbp, fs) - Session_Key *key; - int server; - struct cast_fb *fbp; - int fs; +cast_fb64_session(Session_Key *key, int server, struct cast_fb *fbp, int fs) { int klen; unsigned char * kptr; @@ -4402,45 +4350,34 @@ cast_fb64_session(key, server, fbp, fs) */ #ifndef CAST_EXPORT_ENCRYPTION int -cast_cfb64_keyid(dir, kp, lenp) - int dir, *lenp; - unsigned char *kp; +cast_cfb64_keyid(int dir, unsigned char *kp, int *lenp) { return(cast_fb64_keyid(dir, kp, lenp, &cast_fb[CFB_128])); } int -cast_ofb64_keyid(dir, kp, lenp) - int dir, *lenp; - unsigned char *kp; +cast_ofb64_keyid(int dir, unsigned char *kp, int *lenp) { return(cast_fb64_keyid(dir, kp, lenp, &cast_fb[OFB_128])); } #endif int -castexp_cfb64_keyid(dir, kp, lenp) - int dir, *lenp; - unsigned char *kp; +castexp_cfb64_keyid(int dir, unsigned char *kp, int *lenp) { return(cast_fb64_keyid(dir, kp, lenp, &cast_fb[CFB_40])); } int -castexp_ofb64_keyid(dir, kp, lenp) - int dir, *lenp; - unsigned char *kp; +castexp_ofb64_keyid(int dir, unsigned char *kp, int *lenp) { return(cast_fb64_keyid(dir, kp, lenp, &cast_fb[OFB_40])); } static int -cast_fb64_keyid(dir, kp, lenp, fbp) - int dir, *lenp; - unsigned char *kp; - struct cast_fb *fbp; +cast_fb64_keyid(int dir, unsigned char *kp, int *lenp, struct cast_fb *fbp) { - register int state = fbp->state[dir-1]; + int state = fbp->state[dir-1]; if (*lenp != 1 || (*kp != '\0')) { *lenp = 0; @@ -4456,12 +4393,11 @@ cast_fb64_keyid(dir, kp, lenp, fbp) } static void -cast_fb64_printsub(data, cnt, buf, buflen, type) - unsigned char *data, *buf, *type; - int cnt, buflen; +cast_fb64_printsub(unsigned char *data, int cnt, unsigned char *buf, + int buflen, unsigned char *type) { char lbuf[64]; - register int i; + int i; char *cp; buf[buflen-1] = '\0'; /* make sure it's NULL terminated */ @@ -4499,25 +4435,21 @@ cast_fb64_printsub(data, cnt, buf, buflen, type) } void -cast_cfb64_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; +cast_cfb64_printsub(unsigned char *data, int cnt, unsigned char *buf, + int buflen) { cast_fb64_printsub(data, cnt, buf, buflen, "CFB64"); } void -cast_ofb64_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; +cast_ofb64_printsub(unsigned char *data, int cnt, unsigned char *buf, + int buflen) { cast_fb64_printsub(data, cnt, buf, buflen, "OFB64"); } static void -cast_fb64_stream_iv(seed, stp) - Block seed; - register struct cast_stinfo *stp; +cast_fb64_stream_iv(Block seed, struct cast_stinfo *stp) { memcpy((void *)stp->str_iv, (void *)seed, sizeof(Block)); memcpy((void *)stp->str_output, (void *)seed, sizeof(Block)); @@ -4526,10 +4458,7 @@ cast_fb64_stream_iv(seed, stp) } static void -cast_fb64_stream_key(key, stp, fs) - unsigned char * key; - register struct cast_stinfo *stp; - int fs; +cast_fb64_stream_key(unsigned char *key, struct cast_stinfo *stp, int fs) { #ifndef CAST_EXPORT_ENCRYPTION if(fs) @@ -4566,29 +4495,22 @@ cast_fb64_stream_key(key, stp, fs) */ #ifndef CAST_EXPORT_ENCRYPTION void -cast_cfb64_encrypt(s, c) - register unsigned char *s; - int c; +cast_cfb64_encrypt(unsigned char *s, int c) { _cast_cfb64_encrypt(s, c, &cast_fb[CFB_128].streams[DIR_ENCRYPT-1]); } #endif void -castexp_cfb64_encrypt(s, c) - register unsigned char *s; - int c; +castexp_cfb64_encrypt(unsigned char *s, int c) { _cast_cfb64_encrypt(s, c, &cast_fb[CFB_40].streams[DIR_ENCRYPT-1]); } static void -_cast_cfb64_encrypt(s, c, stp) - register unsigned char *s; - int c; - register struct cast_stinfo *stp; +_cast_cfb64_encrypt(unsigned char *s, int c, struct cast_stinfo *stp) { - register int index; + int index; index = stp->str_index; while (c-- > 0) { @@ -4609,24 +4531,20 @@ _cast_cfb64_encrypt(s, c, stp) #ifndef CAST_EXPORT_ENCRYPTION int -cast_cfb64_decrypt(data) - int data; +cast_cfb64_decrypt(int data) { return _cast_cfb64_decrypt(data, &cast_fb[CFB_128].streams[DIR_DECRYPT-1]); } #endif int -castexp_cfb64_decrypt(data) - int data; +castexp_cfb64_decrypt(int data) { return _cast_cfb64_decrypt(data, &cast_fb[CFB_40].streams[DIR_DECRYPT-1]); } static int -_cast_cfb64_decrypt(data, stp) - int data; - register struct cast_stinfo *stp; +_cast_cfb64_decrypt(int data, struct cast_stinfo *stp) { int index; @@ -4676,29 +4594,22 @@ _cast_cfb64_decrypt(data, stp) */ #ifndef CAST_EXPORT_ENCRYPTION void -cast_ofb64_encrypt(s, c) - register unsigned char *s; - int c; +cast_ofb64_encrypt(unsigned char *s, int c) { _cast_ofb64_encrypt(s, c, &cast_fb[OFB_128].streams[DIR_ENCRYPT-1]); } #endif void -castexp_ofb64_encrypt(s, c) - register unsigned char *s; - int c; +castexp_ofb64_encrypt(unsigned char *s, int c) { _cast_ofb64_encrypt(s, c, &cast_fb[OFB_40].streams[DIR_ENCRYPT-1]); } static void -_cast_ofb64_encrypt(s, c, stp) - register unsigned char *s; - int c; - register struct cast_stinfo *stp; +_cast_ofb64_encrypt(unsigned char *s, int c, struct cast_stinfo *stp) { - register int index; + int index; index = stp->str_index; while (c-- > 0) { @@ -4716,24 +4627,20 @@ _cast_ofb64_encrypt(s, c, stp) #ifndef CAST_EXPORT_ENCRYPTION int -cast_ofb64_decrypt(data) - int data; +cast_ofb64_decrypt(int data) { return _cast_ofb64_decrypt(data, &cast_fb[OFB_128].streams[DIR_DECRYPT-1]); } #endif int -castexp_ofb64_decrypt(data) - int data; +castexp_ofb64_decrypt(int data) { return _cast_ofb64_decrypt(data, &cast_fb[OFB_40].streams[DIR_DECRYPT-1]); } static int -_cast_ofb64_decrypt(data, stp) - int data; - register struct cast_stinfo *stp; +_cast_ofb64_decrypt(int data, struct cast_stinfo *stp) { int index; @@ -4976,11 +4883,8 @@ static uint32 S4[] = { /* Encrypt/decrypt one 64-bit block of data */ void -ck_cast_ecb_encrypt(out, in, sched, mode) - uint8p out; - uint8p in; - CastKeySched * sched; - int mode; /* zero means encrypt */ +ck_cast_ecb_encrypt(uint8p out, uint8p in, CastKeySched *sched, + int mode /* zero means encrypt */) { uint32 t[2]; @@ -5010,14 +4914,11 @@ ck_cast_ecb_encrypt(out, in, sched, mode) } void -ck_cast_ecb_crypt(data, sched, mode) - uint32p data; - CastKeySched * sched; - int mode; -{ - register uint32 L, R, temp; - register struct CastSubkeyPair * kp; - register uint8p Ia, Ib, Ic, Id; +ck_cast_ecb_crypt(uint32p data, CastKeySched *sched, int mode) +{ + uint32 L, R, temp; + struct CastSubkeyPair * kp; + uint8p Ia, Ib, Ic, Id; uint32 I; #ifdef LITTLE_ENDIAN @@ -5292,9 +5193,7 @@ static uint32 S8[] = { /* Initialize a key schedule from a 128-bit key */ static void -cast_key_sched(sched, key) - CastKeySched * sched; - uint8p key; +cast_key_sched(CastKeySched *sched, uint8p key) { uint8p x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xA, xB, xC, xD, xE, xF; uint8p z0, z1, z2, z3, z4, z5, z6, z7, z8, z9, zA, zB, zC, zD, zE, zF; @@ -5433,9 +5332,7 @@ cast_key_sched(sched, key) #ifndef CAST_EXPORT_ENCRYPTION void -ck_cast128_key_sched(sched, key) - CastKeySched * sched; - uint8 * key; +ck_cast128_key_sched(CastKeySched *sched, uint8 *key) { sched->ksize = 16; cast_key_sched(sched, key); @@ -5445,10 +5342,7 @@ ck_cast128_key_sched(sched, key) /* Handle reduced-keysize variants */ static void -cast5_key_sched(sched, key, sz) - CastKeySched * sched; - uint8 * key; - int sz; +cast5_key_sched(CastKeySched *sched, uint8 *key, int sz) { uint8 buf[16]; @@ -5461,26 +5355,20 @@ cast5_key_sched(sched, key, sz) /* 40, 64, and 80-bit keys - all use 12 rounds */ void -ck_cast5_40_key_sched(sched, key) - CastKeySched * sched; - uint8 * key; +ck_cast5_40_key_sched(CastKeySched *sched, uint8 *key) { cast5_key_sched(sched, key, 5); } #ifndef CAST_EXPORT_ENCRYPTION void -ck_cast5_64_key_sched(sched, key) - CastKeySched * sched; - uint8 * key; +ck_cast5_64_key_sched(CastKeySched *sched, uint8 *key) { cast5_key_sched(sched, key, 8); } void -ck_cast5_80_key_sched(sched, key) - CastKeySched * sched; - uint8 * key; +ck_cast5_80_key_sched(CastKeySched *sched, uint8 *key) { cast5_key_sched(sched, key, 10); } @@ -5489,7 +5377,7 @@ ck_cast5_80_key_sched(sched, key) #ifdef CRYPT_DLL static char * -ck_crypt_dll_version() +ck_crypt_dll_version(void) { return(ckcrpv); } diff --git a/ck_ssl.c b/ck_ssl.c index 8fa452f..df7ff9c 100644 --- a/ck_ssl.c +++ b/ck_ssl.c @@ -139,6 +139,11 @@ int ssl_finished_messages = (OPENSSL_VERSION_NUMBER >= 0x0090581fL); #endif /* OPENSSL_VERSION_NUMBER */ #endif /* SSLDLL */ +/* Compatibility helpers follow. Avoid using deprecated accessors when + * possible; adapters below return owned references using non-deprecated + * APIs where available. + */ + static int auth_ssl_valid = 0; static char *auth_ssl_name = 0; /* this holds the oneline name */ char ssl_err[SSL_ERR_BFSZ]=""; @@ -146,6 +151,64 @@ char ssl_err[SSL_ERR_BFSZ]=""; BIO *bio_err=NULL; X509_STORE *crl_store = NULL; +/* Replacement helpers for deprecated OpenSSL APIs (OpenSSL 3.0+) + * - X509_NAME_oneline is deprecated; provide helpers that use + * X509_NAME_print_ex and a memory BIO to produce equivalent strings. + * - Use these helpers throughout the file instead of the deprecated call. + */ +#ifndef XN_FLAG_RFC2253 +#define XN_FLAG_RFC2253 0 +#endif + +static char * +x509_name_oneline_alloc(const X509_NAME *name) +{ + BIO *bio = BIO_new(BIO_s_mem()); + char *ret = NULL; + BUF_MEM *bptr = NULL; + + if (!bio) + return NULL; + + /* Use RFC2253 style by default when available */ + if (X509_NAME_print_ex(bio, (X509_NAME *)name, 0, XN_FLAG_RFC2253) < 0) { + BIO_free(bio); + return NULL; + } + + BIO_get_mem_ptr(bio, &bptr); + if (bptr && bptr->length > 0) { + ret = (char *)malloc((size_t)bptr->length + 1); + if (ret) { + memcpy(ret, bptr->data, (size_t)bptr->length); + ret[bptr->length] = '\0'; + } + } + BIO_free(bio); + return ret; +} + +static int +x509_name_oneline_buf(const X509_NAME *name, char *buf, int sz) +{ + char *s = x509_name_oneline_alloc(name); + int len = 0; + + if (!buf || sz <= 0) { + free(s); + return 0; + } + if (!s) { + buf[0] = '\0'; + return 0; + } + strncpy(buf, s, (size_t) (sz > 0 ? sz - 1 : 0)); + buf[sz - 1] = '\0'; + len = (int)strlen(buf); + free(s); + return len; +} + #ifndef NOFTP #ifndef SYSFTP SSL *ssl_ftp_con = NULL; @@ -257,10 +320,16 @@ X509_STORE_CTX *ctx; * certificate that is being verified ... and if we cannot * determine that then something is seriously wrong! */ - makestr(&subject, - (char *)X509_NAME_oneline(X509_get_subject_name(xs),NULL,0)); - makestr(&issuer, - (char *)X509_NAME_oneline(X509_get_issuer_name(xs),NULL,0)); + { + char *tmp = x509_name_oneline_alloc(X509_get_subject_name(xs)); + makestr(&subject, tmp); + if (tmp) free(tmp); + } + { + char *tmp = x509_name_oneline_alloc(X509_get_issuer_name(xs)); + makestr(&issuer, tmp); + if (tmp) free(tmp); + } if (!subject || !subject[0] || !issuer || !issuer[0]) { ok = 0; goto return_time; @@ -401,7 +470,7 @@ X509_STORE_CTX *ctx; goto return_time; } #else /* XN_FLAG_SEP_MULTILINE */ - X509_NAME_oneline(X509_get_subject_name(xs),subject,256); + x509_name_oneline_buf(X509_get_subject_name(xs), subject, 256); if (!subject[0]) { int len; ERR_print_errors(bio_err); @@ -412,7 +481,7 @@ X509_STORE_CTX *ctx; goto return_time; } - X509_NAME_oneline(X509_get_issuer_name(xs),issuer,256); + x509_name_oneline_buf(X509_get_issuer_name(xs), issuer, 256); if (!issuer[0]) { int len; ERR_print_errors(bio_err); @@ -573,7 +642,7 @@ X509_STORE_CTX *ctx; "\n notAfter=",ssl_err, NULL,NULL,NULL,NULL,NULL,NULL); uq_ok(prefix, "Rejecting Connection", 1, NULL, 0); - + /* sometimes it is really handy to be able to debug things * and still get a connection! */ @@ -644,7 +713,7 @@ X509_STORE_CTX *ctx; #ifdef NT if (ok) { /* if the user decides to accept the certificate - * offer to store it for future connections in + * offer to store it for future connections in * the user's private store */ ok = uq_ok( @@ -828,6 +897,146 @@ static BIGNUM *get_RSA_F4() return bn; } +/* EVP-based helper: generate an RSA EVP_PKEY (returns new EVP_PKEY or NULL). */ +static EVP_PKEY * +evp_generate_rsa_key(int bits) +{ + EVP_PKEY_CTX *pctx = NULL; + EVP_PKEY *pkey = NULL; + + pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL); + if (!pctx) + return NULL; + if (EVP_PKEY_keygen_init(pctx) <= 0) { + EVP_PKEY_CTX_free(pctx); + return NULL; + } + if (EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, bits) <= 0) { + EVP_PKEY_CTX_free(pctx); + return NULL; + } + /* try to set public exponent, ignore errors */ + /* default public exponent (RSA_F4) is used by providers; no explicit set */ + if (EVP_PKEY_keygen(pctx, &pkey) <= 0) { + EVP_PKEY_CTX_free(pctx); + return NULL; + } + EVP_PKEY_CTX_free(pctx); + return pkey; +} + +/* EVP-based helper: construct an EVP_PKEY DH from p/g bytes. Works for OpenSSL 3 via + * EVP_PKEY_fromdata and for older OpenSSL by creating a DH and wrapping it in EVP_PKEY. + */ +static EVP_PKEY * +evp_pkey_from_dh_bytes(const unsigned char *pbytes, int plen, + const unsigned char *gbytes, int glen) +{ + EVP_PKEY *pkey = NULL; +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + EVP_PKEY_CTX *pctx = NULL; + OSSL_PARAM params[3]; + + if (!pbytes || plen <= 0 || !gbytes || glen <= 0) + return NULL; + + pctx = EVP_PKEY_CTX_new_from_name(NULL, "DH", NULL); + if (!pctx) + return NULL; + if (EVP_PKEY_fromdata_init(pctx) <= 0) { + EVP_PKEY_CTX_free(pctx); + return NULL; + } + params[0] = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_FFC_P, + (void *)pbytes, (size_t)plen); + params[1] = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_FFC_G, + (void *)gbytes, (size_t)glen); + params[2] = OSSL_PARAM_construct_end(); + if (EVP_PKEY_fromdata(pctx, &pkey, 0, params) <= 0 || pkey == NULL) { + EVP_PKEY_CTX_free(pctx); + return NULL; + } + EVP_PKEY_CTX_free(pctx); + return pkey; +#else /* OpenSSL < 3.0.0 */ + /* legacy OpenSSL: build DH and wrap in EVP_PKEY */ + DH *dh = NULL; + BIGNUM *p = NULL, *g = NULL; + + if (!pbytes || plen <= 0 || !gbytes || glen <= 0) + return NULL; + + dh = DH_new(); + if (!dh) + return NULL; + p = BN_bin2bn(pbytes, plen, NULL); + g = BN_bin2bn(gbytes, glen, NULL); + if (!p || !g) { + DH_free(dh); + BN_free(p); + BN_free(g); + return NULL; + } +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + if (DH_set0_pqg(dh, p, NULL, g) == 0) { + DH_free(dh); + BN_free(p); + BN_free(g); + return NULL; + } +#else /* OpenSSL < 1.1.0 */ + dh->p = p; + dh->g = g; +#endif /* OpenSSL < 1.1.0 */ + pkey = EVP_PKEY_new(); + if (!pkey) { + DH_free(dh); + return NULL; + } + /* EVP_PKEY takes ownership of dh */ + if (!EVP_PKEY_assign(pkey, EVP_PKEY_DH, dh)) { + EVP_PKEY_free(pkey); + DH_free(dh); + return NULL; + } + return pkey; +#endif /* OpenSSL < 3.0.0 */ +} + +/* Compatibility: extract and return a new RSA * from an EVP_PKEY (upref). Returns + * NULL if not possible. Caller frees returned RSA*. + */ +static RSA * +evp_pkey_get1_rsa(EVP_PKEY *pkey) +{ +#if OPENSSL_VERSION_NUMBER < 0x30000000L + return EVP_PKEY_get1_RSA(pkey); +#else + /* On OpenSSL 3+ direct extraction of raw RSA* is deprecated; callers + should use EVP_PKEY-based APIs instead. Return NULL so guarded + legacy paths can detect absence. */ + (void)pkey; + return NULL; +#endif +} + +/* Compatibility: extract and return a new DH * from an EVP_PKEY (upref). Returns + * NULL if not possible. Caller frees returned DH*. + */ +static DH * +evp_pkey_get1_dh(EVP_PKEY *pkey) +{ +#if OPENSSL_VERSION_NUMBER < 0x30000000L + return EVP_PKEY_get1_DH(pkey); +#else + /* On OpenSSL 3+ direct extraction of raw DH* is deprecated; callers + should use EVP_PKEY-based APIs instead. Return NULL so guarded + legacy paths can detect absence. */ + (void)pkey; + return NULL; +#endif +} + static RSA MS_CALLBACK * #ifdef CK_ANSIC tmp_rsa_cb(SSL * s, int export, int keylength) @@ -838,28 +1047,52 @@ int export; int keylength; #endif /* CK_ANSIC */ { - static RSA *rsa_tmp=NULL; + static RSA *rsa_tmp = NULL; #ifndef NO_RSA - if (rsa_tmp == NULL) - { +#if OPENSSL_VERSION_NUMBER < 0x30000000L + /* Legacy path: keep existing behavior for older OpenSSL versions. */ + if (rsa_tmp == NULL) { if (ssl_debug_flag) - printf("Generating temporary (%d bit) RSA key...\r\n",keylength); - - rsa_tmp = RSA_new(); - if (rsa_tmp) { - int error = RSA_generate_key_ex(rsa_tmp, keylength, get_RSA_F4(),NULL); - if (error) { - if (ssl_debug_flag) - printf(" error %d", error); - RSA_free(rsa_tmp); - rsa_tmp = NULL; - } - } + printf("Generating temporary (%d bit) RSA key...\r\n", keylength); + + /* Prefer EVP_PKEY keygen when available (OpenSSL 1.0+). */ +#if OPENSSL_VERSION_NUMBER >= 0x10000000L + { + EVP_PKEY *pkey = evp_generate_rsa_key(keylength); + if (pkey) { + rsa_tmp = evp_pkey_get1_rsa(pkey); + EVP_PKEY_free(pkey); + } + } +#endif /* OPENSSL_VERSION_NUMBER >= 1.0.0 */ + +#if OPENSSL_VERSION_NUMBER < 0x30000000L + /* Fallback to legacy API if EVP keygen didn't produce a key */ + if (rsa_tmp == NULL) { + rsa_tmp = RSA_new(); + if (rsa_tmp) { + int error = RSA_generate_key_ex(rsa_tmp, keylength, get_RSA_F4(), NULL); + if (error == 0) { + if (ssl_debug_flag) + printf(" error %d", error); + RSA_free(rsa_tmp); + rsa_tmp = NULL; + } + } + } +#endif if (ssl_debug_flag) printf("\r\n"); } +#else + /* On OpenSSL 3.x, the tmp RSA callback and raw RSA APIs are deprecated. + * Return NULL to let OpenSSL select appropriate ephemeral keys via providers. + */ + (void)s; (void)export; (void)keylength; + return NULL; +#endif /* OPENSSL_VERSION_NUMBER */ #else /* NO_RSA */ if (ssl_debug_flag) printf("Unable to generate temporary RSA key...\r\n"); @@ -962,28 +1195,41 @@ static unsigned char dh2048_g[]={ 0x02, }; +#if OPENSSL_VERSION_NUMBER < 0x30000000L static DH * -get_dh512() +dh_from_pg(const unsigned char *pbytes, int plen, + const unsigned char *gbytes, int glen) { - DH *dh=NULL; - BIGNUM *p = NULL; - BIGNUM *g = NULL; + DH *dh = NULL; + BIGNUM *p = NULL, *g = NULL; - if ((dh=DH_new()) == NULL) - return(NULL); -#if OPENSSL_VERSION_NUMBER >= 0x10100005L - p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL); - g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL); - if ((p == NULL) || (g == NULL)) { - BN_free(g); - BN_free(p); - DH_free(dh); - return(NULL); + if (!pbytes || plen <= 0 || !gbytes || glen <= 0) + return NULL; + + dh = DH_new(); + if (!dh) + return NULL; + +#if OPENSSL_VERSION_NUMBER >= 0x10100005L + p = BN_bin2bn(pbytes, plen, NULL); + g = BN_bin2bn(gbytes, glen, NULL); + if (!p || !g) { + DH_free(dh); + BN_free(p); + BN_free(g); + return NULL; } - DH_set0_pqg(dh, p, NULL, g); -#else - dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL); - dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL); + + if (DH_set0_pqg(dh, p, NULL, g) == 0) { + DH_free(dh); + BN_free(p); + BN_free(g); + return NULL; + } + /* DH_set0_pqg takes ownership of p and g on success */ +#else /* OpenSSL < 1.1.0 */ + dh->p = BN_bin2bn(pbytes, plen, NULL); + dh->g = BN_bin2bn(pbytes, plen, NULL); if ((dh->p == NULL) || (dh->g == NULL)) { BN_free(dh->g); BN_free(dh->p); @@ -991,135 +1237,69 @@ get_dh512() return(NULL); } #endif - return(dh); + return dh; } - +#else /* OpenSSL > 3.0.0 */ static DH * -get_dh768() +dh_from_pg(const unsigned char *pbytes, int plen, + const unsigned char *gbytes, int glen) { - DH *dh=NULL; - BIGNUM *p = NULL; - BIGNUM *g = NULL; + EVP_PKEY *pkey = NULL; + EVP_PKEY_CTX *pctx = NULL; + OSSL_PARAM params[3]; - if ((dh=DH_new()) == NULL) - return(NULL); -#if OPENSSL_VERSION_NUMBER >= 0x10100005L - p=BN_bin2bn(dh768_p,sizeof(dh768_p),NULL); - g=BN_bin2bn(dh768_g,sizeof(dh768_g),NULL); - if ((p == NULL) || (g == NULL)) { - BN_free(g); - BN_free(p); - DH_free(dh); - return(NULL); + if (!pbytes || plen <= 0 || !gbytes || glen <= 0) + return NULL; + + /* Build an EVP_PKEY for the DH parameters using the centralized helper. + * The helper hides provider details and returns an EVP_PKEY when + * successful. For compatibility we try to extract a legacy DH* via + * `evp_pkey_get1_dh()` (which returns NULL on OpenSSL 3 by design); + * callers that need raw DH should be migrated to EVP_PKEY. + */ + pkey = evp_pkey_from_dh_bytes(pbytes, plen, gbytes, glen); + if (!pkey) + return NULL; + /* Attempt to provide a legacy DH* for callers compiled with older OpenSSL. + * On OpenSSL 3 this will return NULL; on older releases it will return + * an owned DH* which the caller must free. + */ + { + DH *dh = evp_pkey_get1_dh(pkey); + EVP_PKEY_free(pkey); + return dh; } - DH_set0_pqg(dh, p, NULL, g); -#else - dh->p=BN_bin2bn(dh768_p,sizeof(dh768_p),NULL); - dh->g=BN_bin2bn(dh768_g,sizeof(dh768_g),NULL); - if ((dh->p == NULL) || (dh->g == NULL)) { - BN_free(dh->g); - BN_free(dh->p); - DH_free(dh); - return(NULL); - } -#endif - return(dh); } +#endif /* OPENSSL_VERSION_NUMBER */ static DH * -get_dh1024() +get_dh512() { - DH *dh=NULL; - BIGNUM *p = NULL; - BIGNUM *g = NULL; + return dh_from_pg(dh512_p, sizeof(dh512_p), dh512_g, sizeof(dh512_g)); +} - if ((dh=DH_new()) == NULL) - return(NULL); -#if OPENSSL_VERSION_NUMBER >= 0x10100005L - p=BN_bin2bn(dh1024_p,sizeof(dh1024_p),NULL); - g=BN_bin2bn(dh1024_g,sizeof(dh1024_g),NULL); - if ((p == NULL) || (g == NULL)) { - BN_free(g); - BN_free(p); - DH_free(dh); - return(NULL); - } - DH_set0_pqg(dh, p, NULL, g); -#else - dh->p=BN_bin2bn(dh1024_p,sizeof(dh1024_p),NULL); - dh->g=BN_bin2bn(dh1024_g,sizeof(dh1024_g),NULL); - if ((dh->p == NULL) || (dh->g == NULL)) { - BN_free(dh->g); - BN_free(dh->p); - DH_free(dh); - return(NULL); - } -#endif - return(dh); +static DH * +get_dh768() +{ + return dh_from_pg(dh768_p, sizeof(dh768_p), dh768_g, sizeof(dh768_g)); } static DH * -get_dh1536() +get_dh1024() { - DH *dh=NULL; - BIGNUM *p = NULL; - BIGNUM *g = NULL; + return dh_from_pg(dh1024_p, sizeof(dh1024_p), dh1024_g, sizeof(dh1024_g)); +} - if ((dh=DH_new()) == NULL) - return(NULL); -#if OPENSSL_VERSION_NUMBER >= 0x10100005L - p=BN_bin2bn(dh1536_p,sizeof(dh1536_p),NULL); - g=BN_bin2bn(dh1536_g,sizeof(dh1536_g),NULL); - if ((p == NULL) || (g == NULL)) { - BN_free(g); - BN_free(p); - DH_free(dh); - return(NULL); - } - DH_set0_pqg(dh, p, NULL, g); -#else - dh->p=BN_bin2bn(dh1536_p,sizeof(dh1536_p),NULL); - dh->g=BN_bin2bn(dh1536_g,sizeof(dh1536_g),NULL); - if ((dh->p == NULL) || (dh->g == NULL)) { - BN_free(dh->g); - BN_free(dh->p); - DH_free(dh); - return(NULL); - } -#endif - return(dh); +static DH * +get_dh1536() +{ + return dh_from_pg(dh1536_p, sizeof(dh1536_p), dh1536_g, sizeof(dh1536_g)); } static DH * get_dh2048() { - DH *dh=NULL; - BIGNUM *p = NULL; - BIGNUM *g = NULL; - - if ((dh=DH_new()) == NULL) - return(NULL); -#if OPENSSL_VERSION_NUMBER >= 0x10100005L - p=BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL); - g=BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL); - if ((p == NULL) || (g == NULL)) { - BN_free(g); - BN_free(p); - DH_free(dh); - return(NULL); - } - DH_set0_pqg(dh, p, NULL, g); -#else - dh->p=BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL); - dh->g=BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL); - if ((dh->p == NULL) || (dh->g == NULL)) { - BN_free(dh->g); - BN_free(dh->p); - DH_free(dh); - return(NULL); - } -#endif - return(dh); + return dh_from_pg(dh2048_p, sizeof(dh2048_p), dh2048_g, sizeof(dh2048_g)); } #endif /* NO_DH */ @@ -1135,7 +1315,7 @@ int keylength; { static DH *dh_tmp=NULL; BIO *bio=NULL; - +#if OPENSSL_VERSION_NUMBER < 0x30000000L #ifndef NO_DH if (dh_tmp == NULL) { @@ -1162,6 +1342,11 @@ int keylength; if (ssl_debug_flag) printf("DH not supported...\r\n"); #endif /* NO_DH */ +#else /* OpenSSL 3+ */ + /* OpenSSL 3+: do not use legacy DH PEM or DH APIs; providers supply parameters */ + (void)s; (void)export; (void)keylength; (void)bio; + return NULL; +#endif /* OPENSSL_VERSION_NUMBER */ return(dh_tmp); } @@ -1233,13 +1418,13 @@ int verbose; cipher_list=""; printf("[TLS - shared ciphers=%s]\r\n", cipher_list); - } + } if ( server || tn_deb ) { peer=SSL_get_peer_certificate(ssl_con); if (peer != NULL) { - X509_NAME_oneline(X509_get_subject_name(peer),buf,512); + x509_name_oneline_buf(X509_get_subject_name(peer), buf, 512); printf("[TLS - subject=%s]\r\n",buf); - X509_NAME_oneline(X509_get_issuer_name(peer),buf,512); + x509_name_oneline_buf(X509_get_issuer_name(peer), buf, 512); printf("[TLS - issuer=%s]\r\n",buf); /* X509_free(peer); */ } else if (!tls_is_krb5(0)) { @@ -1521,19 +1706,47 @@ ssl_once_init() (per Dr. Stephen Henson) */ +#ifdef NO_OPENSSL_VERSION_CHECK +/* + * Accept any version of OpenSSL regardless of the potential risk + * of ABI compatibility. + */ +#define COMPAT_VERSION_MASK 0x00000000 /* MNNffppS */ +#else /* NO_OPENSSL_VERSION_CHECK */ +#ifdef OPENSSL_300 +/* + * Different major version or development version of OpenSSL means + * means ABI may break compatibility. OpenSSL >= 3.0.0 + */ +#define COMPAT_VERSION_MASK 0xf000000f /* MNNffppS, major+status */ +#else /* OPENSSL_300 */ +#ifdef OPENSSL_100 +/* Different major/minor version or development version of OpenSSL + * means ABI may break compatibility. + * Modified by Adam Friedlander for OpenSSL >= 1.0.0 + * (See for OpenSSL version encoding details.) + */ +#define COMPAT_VERSION_MASK 0xfff0000f /* MNNffppS, major+minor+status */ +#else /* OPENSSL_100 */ +/* Different major/minor/fix/development (not patch) version of OpenSSL + * means ABI may break compatibility. */ +#define COMPAT_VERSION_MASK 0xfffff00f /* MNNFFppS, major+minor+fix+status */ +#endif /* OPENSSL_100 */ +#endif /* OPENSSL_300 */ +#endif /* NO_OPENSSL_VERSION_CHECK */ + debug(F111,"Kermit built for OpenSSL",OPENSSL_VERSION_TEXT,SSLEAY_VERSION_NUMBER); -#ifndef OS2ONLY debug(F111,"OpenSSL Library",SSLeay_version(SSLEAY_VERSION), - SSLeay()); + SSLeay()); debug(F110,"OpenSSL Library",SSLeay_version(SSLEAY_BUILT_ON),0); debug(F110,"OpenSSL Library",SSLeay_version(SSLEAY_CFLAGS),0); debug(F110,"OpenSSL Library",SSLeay_version(SSLEAY_PLATFORM),0); /* The following test is suggested by Richard Levitte */ - /* if (((OPENSSL_VERSION_NUMBER ^ SSLeay()) & 0xffffff0f) */ + /* if (((OPENSSL_VERSION_NUMBER ^ OpenSSL_version_num()) & 0xffffff0f) */ /* Modified by Adam Friedlander for OpenSSL >= 1.0.0 */ - if (OPENSSL_VERSION_NUMBER > SSLeay() - || ((OPENSSL_VERSION_NUMBER ^ SSLeay()) & COMPAT_VERSION_MASK) + if (SSLEAY_VERSION_NUMBER > SSLeay() + || ((SSLEAY_VERSION_NUMBER ^ SSLeay()) & COMPAT_VERSION_MASK) #ifdef OS2 /* DG 2024-08-05: Not sure what the point of this was. Presumably the goal was * to prevent updated OpenSSL libraries from being used, though why you'd @@ -1541,24 +1754,43 @@ ssl_once_init() * SSH code was built way back in the early 2000s I guess. Today Kermit 95s * use of OpenSSL is largely the same as how C-Kermit uses it on other * platforms so I don't see any reason to treat it differently here. - || ckstrcmp(OPENSSL_VERSION_TEXT,(char *)SSLeay_version(SSLEAY_VERSION),-1,1) -*/ + * + * JA 2025-11-20: Kermit 95 was a commercial product that shipped with its own + * version of OpenSSL which included the exact set of crypto algorithms for + * which Columbia University was granted an export license and excluded all + * algorithms for which there might be patent claims. + * + * In addition, on both Windows and OS/2 there was no equivalent of + * Assemblies https://learn.microsoft.com/en-us/windows/win32/msi/assemblies + * to ensure that only the desired DLL could be loaded by LoadLibrary(). + * The check below ensured that only the custom built OpenSSL DLL against + * which Kermit 95 was built could be loaded. + * + || ckstrcmp(OPENSSL_VERSION_TEXT,(char *)SSLeay_version(SSLEAY_VERSION),-1,1) + */ #endif /* OS2 */ ) { ssl_installed = 0; - debug(F111,"OpenSSL Version does not match. Built with", - SSLeay_version(SSLEAY_VERSION),SSLEAY_VERSION_NUMBER); + debug(F111,"OpenSSL Version does not match. Built with", + SSLeay_version(SSLEAY_VERSION),SSLEAY_VERSION_NUMBER); printf("?OpenSSL libraries do not match required version:\r\n"); printf(" . C-Kermit built with %s\r\n",OPENSSL_VERSION_TEXT); printf(" . Version found %s\r\n",SSLeay_version(SSLEAY_VERSION)); +#ifdef OPENSSL_300 + printf(" OpenSSL versions 3.0.0 or newer must be the same\r\n"); + printf(" major version number, and Kermit may not be used with\r\n"); + printf(" a version of OpenSSL older than the one supplied at\r\n"); + printf(" compilation time.\r\n"); +#else /* OPENSSL_300 */ #ifdef OPENSSL_100 printf(" OpenSSL versions 1.0.0 or newer must be the same\r\n"); printf(" major and minor version number, and Kermit may not\r\n"); printf(" be used with a version of OpenSSL older than the one\r\n"); printf(" supplied at compile time.\r\n"); -#else +#else /* OPENSSL_100 */ printf(" OpenSSL versions prior to 1.0.0 must be the same.\r\n"); #endif /* OPENSSL_100 */ +#endif /* OPENSSL_300 */ s = "R"; #ifdef SOLARIS @@ -1605,22 +1837,30 @@ the build.\r\n\r\n"); #endif /* SSLDLL */ return; } -#endif /* OS2ONLY */ /* init things so we will get meaningful error messages * rather than numbers */ +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + /* OpenSSL 3.0+: use the new init functions */ + OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS +#ifdef OPENSSL_INIT_ADD_ALL_CIPHERS + | OPENSSL_INIT_ADD_ALL_CIPHERS +#endif +#ifdef OPENSSL_INIT_ADD_ALL_DIGESTS + | OPENSSL_INIT_ADD_ALL_DIGESTS +#endif + , NULL); +#else SSL_load_error_strings(); #ifdef SSHBUILTIN OPENSSL_add_all_algorithms_noconf(); #else - /* SSL_library_init() only loads those ciphers needs for SSL */ - /* These happen to be a similar set to those required for SSH */ - /* but they are not a complete set of ciphers provided by the */ - /* crypto library. */ + /* SSL_library_init() only loads those ciphers needed for SSL */ SSL_library_init(); #endif /* SSHBUILTIN */ +#endif /* OPENSSL_VERSION_NUMBER >= 3.0.0 */ #ifndef OPENSSL_NO_COMP #ifdef ZLIB @@ -1765,7 +2005,7 @@ ssl_tn_init(mode) int mode; } /* TLS 1.0 is the new default as of 5 Feb 2015. - Previously this was commented out because + Previously this was commented out because "too many web servers still do not support TLSv1". Now we try TLS 1.0 first, falling back to SSL 2.3 and SSL 3.0 in that order. Maybe there should be @@ -1980,6 +2220,7 @@ ssl_tn_init(mode) int mode; * one now! */ +#if OPENSSL_VERSION_NUMBER < 0x30000000L SSL_CTX_set_tmp_rsa_callback(ssl_ctx, tmp_rsa_cb); SSL_CTX_set_tmp_dh_callback( ssl_ctx, tmp_dh_cb); SSL_CTX_set_tmp_rsa_callback(tls_ctx, tmp_rsa_cb); @@ -1988,6 +2229,12 @@ ssl_tn_init(mode) int mode; dh = tmp_dh_cb(NULL,0,512); SSL_CTX_set_tmp_dh(ssl_ctx,dh); SSL_CTX_set_tmp_dh(tls_ctx,dh); +#else + /* OpenSSL 3+: temporary RSA/DH callbacks and raw DH/RSA APIs are + * deprecated. Providers will provide appropriate ephemeral keys + * so we skip installing legacy callbacks. + */ +#endif /* The following code is only called if we are using a * certificate with an RSA public key and where the @@ -1996,42 +2243,63 @@ ssl_tn_init(mode) int mode; * the greatest legal privacy level with exportable clients. */ +#if OPENSSL_VERSION_NUMBER < 0x30000000L if (SSL_CTX_need_tmp_RSA(ssl_ctx) || SSL_CTX_need_tmp_RSA(tls_ctx)) { - RSA *rsa; + RSA *rsa = NULL; if ( ssl_debug_flag ) printf("Generating temp (512 bit) RSA key ...\r\n"); - rsa = RSA_new(); - if (rsa) { - int error = RSA_generate_key_ex(rsa,512,get_RSA_F4(),NULL); - if (error) { - RSA_free(rsa); - rsa = NULL; - } - } + +/* Prefer EVP key generation and extract an RSA when needed. */ + { + EVP_PKEY *pkey = evp_generate_rsa_key(512); + if (pkey) { + rsa = evp_pkey_get1_rsa(pkey); + EVP_PKEY_free(pkey); + } + } + +#if OPENSSL_VERSION_NUMBER < 0x30000000L + if (!rsa) { + rsa = RSA_new(); + if (rsa) { + int error = RSA_generate_key_ex(rsa,512,get_RSA_F4(),NULL); + if (error == 0) { + RSA_free(rsa); + rsa = NULL; + } + } + } +#endif + if ( ssl_debug_flag ) printf("Generation of temp (512 bit) RSA key done\r\n"); - if (SSL_CTX_need_tmp_RSA(ssl_ctx)) { - if (!SSL_CTX_set_tmp_rsa(ssl_ctx,rsa)) { - if ( ssl_debug_flag ) - printf( + if (rsa) { + if (SSL_CTX_need_tmp_RSA(ssl_ctx)) { + if (!SSL_CTX_set_tmp_rsa(ssl_ctx,rsa)) { + if ( ssl_debug_flag ) + printf( "Failed to assign generated temp RSA key to SSL!\r\n"); + } } - } - if (SSL_CTX_need_tmp_RSA(tls_ctx)) { - if (!SSL_CTX_set_tmp_rsa(tls_ctx,rsa)) { - if ( ssl_debug_flag ) - printf( + if (SSL_CTX_need_tmp_RSA(tls_ctx)) { + if (!SSL_CTX_set_tmp_rsa(tls_ctx,rsa)) { + if ( ssl_debug_flag ) + printf( "Failed to assign generated temp RSA key to TLS!\r\n"); + } } + RSA_free(rsa); + if ( ssl_debug_flag ) + printf("Assigned temp (512 bit) RSA key\r\n"); } - RSA_free(rsa); - if ( ssl_debug_flag ) - printf("Assigned temp (512 bit) RSA key\r\n"); } +#else + /* OpenSSL 3+: providers supply ephemeral keys; no legacy temp RSA needed */ +#endif } } @@ -2049,7 +2317,7 @@ ssl_tn_init(mode) int mode; char path[CKMAXPATH]; ckmakmsg(path,CKMAXPATH,exedir,"certs",NULL,NULL); - if (isdir(path) && + if (isdir(path) && SSL_CTX_load_verify_locations(tls_ctx,NULL,path) == 1) { debug(F110,"ssl_tn_init certificate verify dir",path,0); if (ssl_debug_flag) @@ -2073,7 +2341,7 @@ ssl_tn_init(mode) int mode; SSL_CTX_load_verify_locations(ssl_ctx,NULL,path); } ckmakmsg(path,CKMAXPATH,exedir,"ca_certs.pem",NULL,NULL); - if (zchki(path) > 0 && + if (zchki(path) > 0 && SSL_CTX_load_verify_locations(tls_ctx,path,NULL) == 1) { debug(F110,"ssl_tn_init certificate verify file",path,0); if (ssl_debug_flag) @@ -2081,7 +2349,7 @@ ssl_tn_init(mode) int mode; SSL_CTX_load_verify_locations(ssl_ctx,path,NULL); } ckmakmsg(path,CKMAXPATH,GetAppData(1),"kermit 95/ca_certs.pem",NULL,NULL); - if (zchki(path) > 0 && + if (zchki(path) > 0 && SSL_CTX_load_verify_locations(tls_ctx,path,NULL) == 1) { debug(F110,"ssl_tn_init certificate verify file",path,0); if (ssl_debug_flag) @@ -2089,7 +2357,7 @@ ssl_tn_init(mode) int mode; SSL_CTX_load_verify_locations(ssl_ctx,path,NULL); } ckmakmsg(path,CKMAXPATH,GetAppData(0),"kermit 95/ca_certs.pem",NULL,NULL); - if (zchki(path) > 0 && + if (zchki(path) > 0 && SSL_CTX_load_verify_locations(tls_ctx,path,NULL) == 1) { debug(F110,"ssl_tn_init certificate verify file",path,0); if (ssl_debug_flag) @@ -2103,7 +2371,7 @@ ssl_tn_init(mode) int mode; char path[CKMAXPATH]; ckmakmsg(path,CKMAXPATH,exedir,"certs",NULL,NULL); - if (isdir(path) && + if (isdir(path) && SSL_CTX_load_verify_locations(tls_ctx,NULL,path) == 1) { debug(F110,"ssl_tn_init certificate verify dir",path,0); if (ssl_debug_flag) @@ -2111,7 +2379,7 @@ ssl_tn_init(mode) int mode; SSL_CTX_load_verify_locations(ssl_ctx,NULL,path); } ckmakmsg(path,CKMAXPATH,exedir,"ca_certs.pem",NULL,NULL); - if (zchki(path) > 0 && + if (zchki(path) > 0 && SSL_CTX_load_verify_locations(tls_ctx,path,NULL) == 1) { debug(F110,"ssl_tn_init certificate verify file",path,0); if (ssl_debug_flag) @@ -2126,7 +2394,7 @@ ssl_tn_init(mode) int mode; #endif /* OS2 */ if (ssl_verify_file) { - if (zchki(ssl_verify_file) > 0 && + if (zchki(ssl_verify_file) > 0 && SSL_CTX_load_verify_locations(tls_ctx,ssl_verify_file,NULL) == 1) { debug(F110,"ssl_tn_init certificate verify file",ssl_verify_file,0); if (ssl_debug_flag) @@ -2177,23 +2445,23 @@ ssl_tn_init(mode) int mode; } #ifdef NT ckmakmsg(path,CKMAXPATH,GetAppData(1),"kermit 95/crls",NULL,NULL); - if (isdir(path) && + if (isdir(path) && X509_STORE_load_locations(crl_store,NULL,path) == 1) { debug(F110,"ssl_tn_init crl dir",path,0); if (ssl_debug_flag) printf(" CRL Directory: %s\r\n",path); } ckmakmsg(path,CKMAXPATH,GetAppData(0),"kermit 95/crls",NULL,NULL); - if (isdir(path) && + if (isdir(path) && X509_STORE_load_locations(crl_store,NULL,path) == 1) { debug(F110,"ssl_tn_init crl dir",path,0); if (ssl_debug_flag) printf(" CRL Directory: %s\r\n",path); } #endif /* NT */ - + ckmakmsg(path,CKMAXPATH,exedir,"ca_crls.pem",NULL,NULL); - if (zchki(path) > 0 && + if (zchki(path) > 0 && X509_STORE_load_locations(crl_store,path,NULL) == 1) { debug(F110,"ssl_tn_init crl file",path,0); if (ssl_debug_flag) @@ -2201,14 +2469,14 @@ ssl_tn_init(mode) int mode; } #ifdef NT ckmakmsg(path,CKMAXPATH,GetAppData(1),"kermit 95/ca_crls.pem",NULL,NULL); - if (zchki(path) > 0 && + if (zchki(path) > 0 && X509_STORE_load_locations(crl_store,path,NULL) == 1) { debug(F110,"ssl_tn_init crl file",path,0); if (ssl_debug_flag) printf(" CRL File: %s\r\n",path); } ckmakmsg(path,CKMAXPATH,GetAppData(0),"kermit 95/ca_crls.pem",NULL,NULL); - if (zchki(path) > 0 && + if (zchki(path) > 0 && X509_STORE_load_locations(crl_store,path,NULL) == 1) { debug(F110,"ssl_tn_init crl file",path,0); if (ssl_debug_flag) @@ -2218,7 +2486,7 @@ ssl_tn_init(mode) int mode; #endif /* OS2 */ if (ssl_crl_file || ssl_crl_dir) { - if (ssl_crl_file && zchki(ssl_crl_file) > 0 && + if (ssl_crl_file && zchki(ssl_crl_file) > 0 && X509_STORE_load_locations(crl_store,ssl_crl_file,NULL) == 1) { debug(F110,"ssl_tn_init crl file",ssl_crl_file,0); if (ssl_debug_flag) @@ -2230,7 +2498,7 @@ ssl_tn_init(mode) int mode; if (ssl_debug_flag) printf(" CRL Directory: %s\r\n",ssl_crl_dir); } - } + } #ifndef OS2 else { X509_STORE_set_default_paths(crl_store); @@ -2398,7 +2666,7 @@ ssl_http_init(hostname) char * hostname; if (!tls_http_ctx ) { /* TLS 1.0 is the new default as of 5 Feb 2015. - Previously this was commented out because + Previously this was commented out because "too many web servers still do not support TLSv1". Now we try TLS 1.0 first, falling back to SSL 2.3 and SSL 3.0 in that order. Maybe there should be @@ -2571,7 +2839,7 @@ ssl_http_init(hostname) char * hostname; printf("?Unable to load crl-dir: %s\r\n",path); } #endif /* NT */ - + ckmakmsg(path,CKMAXPATH,exedir,"ca_crls.pem",NULL,NULL); if (X509_STORE_load_locations(crl_store,path,NULL) == 0) { debug(F110,"ssl_http_init unable to load file",path,0); @@ -2792,7 +3060,7 @@ ssl_get_issuer_name(ssl) SSL * ssl; name[0] = '\0'; if ((server_cert = SSL_get_peer_certificate(ssl))) { - X509_NAME_oneline(X509_get_issuer_name(server_cert),name,sizeof(name)); + x509_name_oneline_buf(X509_get_issuer_name(server_cert), name, sizeof(name)); X509_free(server_cert); return name; } @@ -2815,8 +3083,8 @@ ssl_get_subject_name(ssl) SSL * ssl; X509 *server_cert; name[0] = '\0'; - if ((server_cert = SSL_get_peer_certificate(ssl))) { - X509_NAME_oneline(X509_get_subject_name(server_cert),name,sizeof(name)); + if ((server_cert = SSL_get_peer_certificate(ssl))) { + x509_name_oneline_buf(X509_get_subject_name(server_cert), name, sizeof(name)); X509_free(server_cert); return name; } @@ -3036,8 +3304,8 @@ ssl_verify_crl(int ok, X509_STORE_CTX *ctx) serial = ASN1_INTEGER_get(revoked->serialNumber); #endif - cp = X509_NAME_oneline(issuer, NULL, 0); - free(cp); + cp = x509_name_oneline_alloc(issuer); + if (cp) free(cp); X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_REVOKED); #if OPENSSL_VERSION_NUMBER >= 0x10100005L @@ -3224,7 +3492,7 @@ show_hostname_warning(char *s1, char *s2) int ok = 1; setverbosity(); ckmakxmsg(prefix,1024, - "Warning: Hostname (\"", s1, + "Warning: Hostname (\"", s1, "\") does not match server's certificate (\"", s2, "\")", NULL,NULL,NULL,NULL,NULL,NULL,NULL); if (ssl_verify_flag) @@ -3385,7 +3653,7 @@ ssl_check_server_name(SSL * ssl, char * hostname) return 0; } rv = show_hostname_warning(hostname, - (char *)((dNSName[i - 1] == NULL) ? + (char *)((dNSName[i - 1] == NULL) ? (char *)"UNKNOWN" : (char *)dNSName[i - 1])) ? 0 : -1; for (i = 0; dNSName[i]; i++) @@ -4201,7 +4469,7 @@ ck_ssl_incoming(fd) int fd; X509_NAME_get_text_by_NID(X509_get_subject_name(peer), #ifndef NID_x500UniqueIdentifier NID_uniqueIdentifier, -#else +#else NID_x500UniqueIdentifier, #endif str,256 @@ -4287,7 +4555,7 @@ ck_ssl_outgoing(fd) int fd; return(-1); } else { tls_active_flag = 1; - if ( !ssl_certsok_flag && (ssl_verify_flag & SSL_VERIFY_PEER) && + if ( !ssl_certsok_flag && (ssl_verify_flag & SSL_VERIFY_PEER) && !tls_is_krb5(0) ) { char *subject = ssl_get_subject_name(tls_con); @@ -4535,7 +4803,7 @@ ck_ssl_renegotiate_ciphers() } #ifdef NT -int +int ck_X509_save_cert_to_user_store(X509 *cert) { #ifdef X509V3_EXT_DUMP_UNKNOWN @@ -4551,7 +4819,7 @@ ck_X509_save_cert_to_user_store(X509 *cert) ckmakmsg(path,CKMAXPATH,GetAppData(0),"kermit 95/certs/", hash,".0"); - + out=BIO_new(BIO_s_file()); if (out == NULL) { @@ -4596,8 +4864,11 @@ X509_to_user(X509 *peer_cert, char *userid, int len) return -1; userid[0] = '\0'; - debug(F110,"X509_to_user() subject", - X509_NAME_oneline(X509_get_subject_name(peer_cert),NULL,0),0); + { + char *__tmp = x509_name_oneline_alloc(X509_get_subject_name(peer_cert)); + debug(F110,"X509_to_user() subject", __tmp ? __tmp : "(null)",0); + if (__tmp) free(__tmp); + } /* userid is in cert subject /UID */ err = X509_NAME_get_text_by_NID(X509_get_subject_name(peer_cert), @@ -4627,8 +4898,11 @@ X509_to_user(X509 *peer_cert, char *userid, int len) userid[0] = '\0'; email[0] = '\0'; - debug(F110,"X509_to_user() subject", - X509_NAME_oneline(X509_get_subject_name(peer_cert),NULL,0),0); + { + char *__tmp = x509_name_oneline_alloc(X509_get_subject_name(peer_cert)); + debug(F110,"X509_to_user() subject", __tmp ? __tmp : "(null)",0); + if (__tmp) free(__tmp); + } if ((i = X509_get_ext_by_NID(peer_cert, NID_subject_alt_name, -1))<0) return -1; diff --git a/ck_ssl.h b/ck_ssl.h index 7b16a59..146a218 100644 --- a/ck_ssl.h +++ b/ck_ssl.h @@ -39,8 +39,8 @@ #include #endif /* OPENSSL_NO_COMP */ #endif /* ZLIB */ -/* We place the following to avoid loading openssl/mdc2.h since it - * relies on the OpenSSL des.h. Since we do not need the MDC2 +/* We place the following to avoid loading openssl/mdc2.h since it + * relies on the OpenSSL des.h. Since we do not need the MDC2 * definitions there is no reason to have it included by openssl/evp.h */ #define OPENSSL_NO_MDC2 @@ -55,16 +55,6 @@ #ifndef OPENSSL_098 /* sms 15 November 2022 */ #define OPENSSL_098 #endif /* OPENSSL_098 */ -/* Different major/minor version or development version of OpenSSL - * means ABI may break compatibility. - * Modified by Adam Friedlander for OpenSSL >= 1.0.0 - * (See for OpenSSL version encoding details.) - */ -#define COMPAT_VERSION_MASK 0xfff0000f /* MNNffppS, major+minor+status */ -#else -/* Different major/minor/fix/development (not patch) version of OpenSSL - * means ABI may break compatibility. */ -#define COMPAT_VERSION_MASK 0xfffff00f /* MNNFFppS, major+minor+fix+status */ #endif /* OPENSSL_100 */ #ifdef OPENSSL_098 @@ -92,6 +82,11 @@ #include #include #include +#if OPENSSL_VERSION_NUMBER >= 0x30000000L +#include +#include +#include +#endif #ifdef SSL_KRB5 #include #endif /* SSL_KRB5 */ diff --git a/ckcdeb.h b/ckcdeb.h index e8b5992..37c93f7 100644 --- a/ckcdeb.h +++ b/ckcdeb.h @@ -1661,7 +1661,7 @@ _PROTOTYP(int ckxfprintf,(FILE *, const char *, ...)); #endif /* CK_POSIX_SIG */ #endif /* QNX */ -/* +/* void type, normally available only in ANSI compilers. The HP-UX exception (for its "bundled" non-ANSI C compiler) is known to be valid back to HP-UX 6.5. @@ -1800,11 +1800,19 @@ _PROTOTYP(int ckxfprintf,(FILE *, const char *, ...)); #define SIGRETURN return(0) #endif /* SIGRETURN */ -#ifdef CKNTSIG -/* This does not work, so don't use it. */ -#define signal ckntsignal -SIGTYP (*ckntsignal(int type, SIGTYP (*)(int)))(int); -#endif /* CKNTSIG */ +#ifdef CK_ANSIC +#ifdef OS2 +#ifdef NT +typedef SIGTYP (*sig_t)(int); +#else /* !NT */ +typedef SIGTYP (volatile *sig_t)(int); +#endif /* NT */ +#else /* !OS2 */ +typedef SIGTYP (*sig_t)(int); +#endif /* OS2 */ +#else /* !CK_ANSIC */ +typedef SIGTYP (*sig_t)(); +#endif /* CK_ANSIC */ /* We want all characters to be unsigned if the compiler supports it */ @@ -7180,7 +7188,7 @@ _PROTOTYP(int ck_auth_unloaddll, (VOID)); #endif /* OS2 */ #ifdef NT -_PROTOTYP(DWORD ckGetLongPathname,(LPCSTR lpFileName, +_PROTOTYP(DWORD ckGetLongPathname,(LPCSTR lpFileName, LPSTR lpBuffer, DWORD cchBuffer)); _PROTOTYP(DWORD ckGetShortPathName,(LPCSTR lpszLongPath, LPSTR lpszShortPath, DWORD cchBuffer)); diff --git a/ckcfn2.c b/ckcfn2.c index 6045c78..929e0e2 100644 --- a/ckcfn2.c +++ b/ckcfn2.c @@ -2796,7 +2796,7 @@ int *s = NUL; /* Temporarily null-terminate data field */ if (xunchar(chk) != chk1((CHAR *)(buf+1),buflen-2)) { /* Check it */ /* - In C-Kermit 9.0 and later, an S or I packet can have a + In C-Kermit 9.0 and later, an S or I packet can have a Type 3 Block check ("help set block-check" for details). */ unsigned crc; /* Failed... Try Type 3 block check */ diff --git a/ckcfnp.h b/ckcfnp.h index 43ab4df..987072d 100644 --- a/ckcfnp.h +++ b/ckcfnp.h @@ -469,6 +469,7 @@ long pty_cleanup( char *, int, int ); long pty_initialize_slave ( int ); long pty_open_ctty( char *, int *, int ); long pty_open_slave( char *, int *, int ); +void exec_cmd(char *s); long tod2sec( char * ); struct passwd * sgetpwnam( char * ); struct stringarray * cksplit( int,int,char *, char *,char *, int,int,int,int ); diff --git a/ckcfns.c b/ckcfns.c index e2f36b8..775a20d 100644 --- a/ckcfns.c +++ b/ckcfns.c @@ -435,7 +435,7 @@ encstr(s) CHAR* s; maximum packet size. Previously we were limited to the length of encbuf[]. Also, to return a failure code if the entire encoded string would not fit. Modified 14 Jul 1998 to return length of encoded string. - Modified 18 Oct 2021 to not truncate filename in F packet. + Modified 18 Oct 2021 to not truncate filename in F packet. */ int m, rc, slen; char *p; /* data is a pointer to send-packet data declared in ckcmai.c */ @@ -515,7 +515,7 @@ puttrm(c) register char c; #endif /* NOSPL */ /* This routine is used (among other things) for printing the server's answer - to a REMOTE command. But REMOTE CD is special because it isn't really + to a REMOTE command. But REMOTE CD is special because it isn't really asking for an answer from the server. Thus some people want to suppress the confirmation message (e.g. when the server sends back the actual path of the directory CD'd to), and expect to be able to do this with SET QUIET @@ -974,7 +974,7 @@ xpnbyte(a,tcs,fcs,fn) int a, tcs, fcs; int (*fn)(); &colorcmd ); #endif /* COMMENT */ - } else + } else #endif /* OS2 */ #endif /* IKSDONLY */ { @@ -1000,7 +1000,7 @@ xpnbyte(a,tcs,fcs,fn) int a, tcs, fcs; int (*fn)(); wherex[VCMD], &colorcmd ); - } else + } else #endif /* OS2 */ #endif /* IKSDONLY */ { @@ -1025,7 +1025,7 @@ xpnbyte(a,tcs,fcs,fn) int a, tcs, fcs; int (*fn)(); wherex[VCMD], &colorcmd ); - } else + } else #endif /* OS2 */ #endif /* IKSDONLY */ { @@ -2019,7 +2019,7 @@ static int xlaptr = 0; Returns: >= 0: A translated byte suitable for writing. < 0: Fatal error (such as EOF on input source). - As of Sat Sep 7 18:37:41 2002: + As of Sat Sep 7 18:37:41 2002: When the output character-set is UCS-2, bytes are ALWAYS returned in big-endian order (previously they could also be returned in LE order under certain conditions, which was just way too confusing). @@ -2561,7 +2561,7 @@ xgnbyte(tcs,fcs,fn) int tcs, fcs, (*fn)(); return(-2); } #ifdef COMMENT -/* +/* If there is a return() statement here, some compilers complain about "statement not reached". If there is no return() statement, other compilers complain that "Non-void function should return a value". @@ -3693,7 +3693,7 @@ Please confirm output file specification or supply an alternative:"; We haven't yet received the A packet so we don't yet know it's e-mail, so in fact we go ahead and convert it anyway, but later we get the original back from ofilnam[]. -*/ +*/ dispos = 0; ckstrncpy(ofilnam,(char *)srvcmd,CKMAXPATH+1); @@ -5633,7 +5633,7 @@ gnfile() { fullname[0] = NUL; #ifdef VMS - /* + /* In VMS, zopeni() sets binary 0/1 automatically from the file attributes. Don't undo it here. */ diff --git a/ckcftp.c b/ckcftp.c index 7780cdd..b995694 100644 --- a/ckcftp.c +++ b/ckcftp.c @@ -27,7 +27,7 @@ char *ckftpv = "FTP Client, 10.0.281, 18 Sep 2023"; . Implement recursive NLST downloads by trying to CD to each filename. If it works, it's a directory; if not, it's a file -- GET it. But - that won't work with servers like wu-ftpd that don't send directory + that won't work with servers like wu-ftpd that don't send directory names. Recursion with MLSD is done. . Make syslog entries for session? Files? @@ -963,59 +963,6 @@ char * ftp_apw = NULL; /* Anonymous password */ /* Definitions and typedefs needed for prototypes */ -/* - #define sig_t my_sig_t - - I don't understand the statement above, which has been in this code going - back to at least C-Kermit 8.0, because my_sig_t is not defined anywhere. - And yet sig_t is used below with no complaint, no matter whether the the - above #define is commented out or not. However, if I #define sig_t SIGTYP - (which is what it should be according to ckcdeb.h), all hell breaks loose. - Same if I replace all references to sig_t by SIGTYPE. On the other hand, if - I remove the sig_t definition, there is no complaint, so where is the sig_t - definition coming from? I find this in Ubuntu signal.h: - - 4.4 BSD uses the name 'sig_t' for this. - typedef __sighandler_t sig_t; - - In NetBSD I find this in sys/signal.h: - - typedef void (*sig_t)(int); - - Can we really count on sig_t being defined in some nook or cranny - on every single Unix, VMS, and Windows system? - - Jeff Altman says to use sighandler_t, which is ok on Ubuntu but - not on (say) NetBSD. So I can't do this: - -#ifndef sig_t -#define sig_t sighandler_t -#endif - - I think the only alternative is to leave my_sig_t undefined and then - see who squawks. Since the previous 'my_sig_t' definition apparently - had no effect, I'm hoping there will be no change in behavior after - commenting it out. -fdc Fri Jun 23 06:53:23 2023 - - P.S. All this is aside from the fact that signal() has long since been - "deprecated" in favor of sigaction(), defined in POSIX.1-1988; see: - - https://man7.org/linux/man-pages/man2/signal.2.html - https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html - - but C-Kermit can't be switched over because it has to build and run on - pre-POSIX operating systems that don't have sigaction(0) (despite the fact - that C-Kermit's ckupty.c function ptyint_vhangup() calls it... how did - *that* happen?). -*/ -#define sigtype SIGTYP - -#ifdef CK_ANSIC -typedef sigtype (*sig_t)(int); -#else -typedef sigtype (*sig_t)(); -#endif /* CK_ANSIC */ - /* Made this global static -fdc 21 June 2023 */ /* It's used in many ckcftp.c routines but wasn't declared in all of them */ static sig_t oldintr; @@ -1068,9 +1015,9 @@ static int sendrequest( char *, char *, char *, int, int, int, int ); static int syncdir( char *, int ); static int tmcompare( struct tm *, struct tm * ); static int xlatec( int, int, int, int ); -static sigtype cancelrecv( int ); -static sigtype cancelsend( int ); -static sigtype cmdcancel( int ); +static SIGTYP cancelrecv( int ); +static SIGTYP cancelsend( int ); +static SIGTYP cmdcancel( int ); #endif /* CK_ANSIC */ @@ -1267,7 +1214,7 @@ FILE * fp_nml = NULL; /* Namelist file pointer */ static int csocket = -1; /* Control socket */ static int connected = 0; /* Connected to FTP server */ -/* static unsigned short ftp_port = 0; */ /* FTP port */ +/* static unsigned short ftp_port = 0; */ /* FTP port */ /* static int ftp_port = 0; */ /* SMS 2007/02/15 */ static int ftp_port = 0; /* fdc 2007/08/30 */ #ifdef FTPHOST @@ -2023,7 +1970,7 @@ _PROTOTYP(static VOID lostpeer, (void)); _PROTOTYP(static VOID cancel_remote, (int)); _PROTOTYP(static VOID changetype, (int, int)); -_PROTOTYP(static sigtype cmdcancel, (int)); +_PROTOTYP(static SIGTYP cmdcancel, (int)); #ifdef FTP_SRP _PROTOTYP(static int srp_reset, ()); @@ -2917,7 +2864,7 @@ dosetftp() { } case FTS_BUG: { - if ((x = cmkey(ftpbugtab,nftpbug,"","",xxstring)) < 0) + if ((x = cmkey(ftpbugtab,nftpbug,"","",xxstring)) < 0) return(x); switch (x) { #ifdef CK_SSL @@ -3831,7 +3778,7 @@ syncdir(local,sim) char * local; int sim; cdsimlvl++; } else { if (!doftpxmkd(p,0)) { /* Can't CD - try to create */ - debug(F110,"ftp syncdir mkdir failed",p,0); + debug(F110,"ftp syncdir mkdir failed",p,0); /* Suppose we are executing SEND /RECURSIVE. Locally we have a directory FOO but the remote has a regular file with the same name. We can't CD @@ -3841,7 +3788,7 @@ syncdir(local,sim) char * local; int sim; quiet = saveq; return(0); } - debug(F110,"ftp syncdir mkdir OK",p,0); + debug(F110,"ftp syncdir mkdir OK",p,0); if (fdispla == XYFD_B) { printf(" CREATED DIRECTORY %s\n",p); } else if (fdispla) { @@ -3850,12 +3797,12 @@ syncdir(local,sim) char * local; int sim; ftscreen(SCR_ST,ST_MSG,(CK_OFF_T)0,msgbuf); } if (!doftpcwd(p,0)) { /* Try again to CD */ - debug(F110,"ftp syncdir CD failed",p,0); + debug(F110,"ftp syncdir CD failed",p,0); quiet = saveq; return(0); } if (fdispla == XYFD_B) printf(" CWD %s\n",p); - debug(F110,"ftp syncdir CD OK",p,0); + debug(F110,"ftp syncdir CD OK",p,0); } } cdlevel++; @@ -4252,7 +4199,7 @@ chkmodtime(local,remote,fc) char * local, * remote; int fc; */ int xx; #ifdef COMMENT -#ifdef DEBUG +#ifdef DEBUG if (deblog) { dbtime("LOCAL",tmlocal); dbtime("REMOT",&tmremote); @@ -5050,7 +4997,7 @@ zzsend(fd,c) int fd; CHAR c; if (iscanceled()) /* Check for cancellation */ return(-9); -#ifdef FTP_TIMEOUT +#ifdef FTP_TIMEOUT ftp_timed_out = 0; if (check_data_connection(fd,1) < 0) { ftp_timed_out = 1; @@ -7773,7 +7720,7 @@ doftpget(cx,who) int cx, who; tmpsrc = NULL; src = mgetlist[mgetx]; usrpath = srclen+1; - } + } } } /* @@ -10425,7 +10372,7 @@ ftpopen(remote, service, use_tls) char * remote, * service; int use_tls; #ifdef FTP_SECURITY if (ftp_aut) { if (ftp_auth()) { - if (ftp_cry + if (ftp_cry #ifdef OS2 && ck_crypt_is_installed() #endif /* OS2 */ @@ -10515,7 +10462,7 @@ ssl_auth() { ssl_ftp_ctx = NULL; } - /* The SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS + /* The SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS * was added to OpenSSL 0.9.6e and 0.9.7. It does not exist in previous * versions */ @@ -10702,7 +10649,7 @@ ssl_auth() { printf("?Unable to load crl-dir: %s\r\n",path); } #endif /* NT */ - + ckmakmsg(path,CKMAXPATH,exedir,"ca_crls.pem",NULL,NULL); if (X509_STORE_load_locations(crl_store,path,NULL) == 0) { debug(F110,"ftp ssl auth unable to load file",path,0); @@ -10817,7 +10764,7 @@ ssl_auth() { } #endif /* CK_SSL */ -static sigtype +static SIGTYP #ifdef CK_ANSIC cmdcancel( int sig ) #else @@ -11203,7 +11150,7 @@ parsefacts(s) char * s; while ((p = ckstrchr(s,'='))) { *p = NUL; /* s points to fact */ - i = xlookup(facttab,s,nfacttab,&x); + i = xlookup(facttab,s,nfacttab,&x); debug(F111,"ftp parsefact fact",s,i); *p = '='; s = p+1; /* Now s points to arg */ @@ -11773,7 +11720,7 @@ empty(mask, cnt, sec) int * mask, sec; #endif /* IBMSELECT */ #endif /* BSDSELECT */ -static sigtype +static SIGTYP #ifdef CK_ANSIC cancelsend( int sig ) #else @@ -12123,7 +12070,7 @@ doftpsend2(threadinfo) VOID * threadinfo; register int c, d = 0; int n, x, notafile, unique = 0; char *buf, *bufp; - + #ifdef NTSIG if (threadinfo) { /* Thread local storage... */ TlsSetValue(TlsIndex,threadinfo); @@ -12241,7 +12188,7 @@ doftpsend2(threadinfo) VOID * threadinfo; which means STOU is not accepted, period. */ if ((x == 5) && stouarg && (ftpcode != 502)) { - x = ftpcmd(ftpsnd.cmd,NULL,ftpsnd.incs,ftpsnd.outcs,ftp_vbm); + x = ftpcmd(ftpsnd.cmd,NULL,ftpsnd.incs,ftpsnd.outcs,ftp_vbm); if (x == REPLY_PRELIM) /* If accepted */ stouarg = 0; /* flag no STOU arg for this server */ } @@ -12292,7 +12239,7 @@ doftpsend2(threadinfo) VOID * threadinfo; errno = d = 0; #ifdef VMS /* - This is because VMS zxin() is C-Library fread() + This is because VMS zxin() is C-Library fread() but the file was opened with zopeni(), which is RMS. */ while (((c = zminchar()) > -1) && !cancelfile) { @@ -12495,7 +12442,7 @@ sendrequest( cmd, local, remote, xlate, incs, outcs, restart ) if (sndfilter) /* If sending thru a filter */ pipesend = 1; /* set this for open and i/o */ #endif /* PIPESEND */ - + #ifdef VMS debug(F101,"XXX before openi binary","",binary); debug(F101,"XXX before openi ftp_typ","",ftp_typ); @@ -12539,7 +12486,7 @@ sendrequest( cmd, local, remote, xlate, incs, outcs, restart ) return(ftpsndret); } -static sigtype +static SIGTYP #ifdef CK_ANSIC cancelrecv( int sig ) #else @@ -13052,7 +12999,7 @@ Please confirm output file specification or supply an alternative:"; } #ifdef FTP_TIMEOUT if (c == -3) { - debug(F100,"ftp recvrequest timeout","",0); + debug(F100,"ftp recvrequest timeout","",0); bytes = (CK_OFF_T)-1; ftp_timed_out = 1; ftpcode = -3; @@ -13130,8 +13077,8 @@ Please confirm output file specification or supply an alternative:"; #endif /* COMMENT */ #ifdef OS2 - if ( out2screen && /* we're translating to UCS-2 */ - !k95stdout && !inserver) /* for the real screen... */ + if ( out2screen && /* we're translating to UCS-2 */ + !k95stdout && !inserver) /* for the real screen... */ { union { USHORT ucs2; @@ -13149,7 +13096,7 @@ Please confirm output file specification or supply an alternative:"; &colorcmd ); - } else + } else #endif /* OS2 */ { if ((x = xpnbyte(c0,TC_UCS2,ftprecv.fcs,fn)) < 0) break; @@ -13272,7 +13219,7 @@ Please confirm output file specification or supply an alternative:"; close(ftprecv.din); #endif /* TCPIPLIB */ ftprecv.reply = getreply(0,ftprecv.fcs,ftprecv.rcs,ftp_vbm,0); - ftprecvret = ((ftpcode < 0 || ftprecv.reply == REPLY_TRANSIENT || + ftprecvret = ((ftpcode < 0 || ftprecv.reply == REPLY_TRANSIENT || ftprecv.reply == REPLY_ERROR) ? -1 : 0); #ifdef NTSIG ckThreadEnd(threadinfo); @@ -13359,7 +13306,7 @@ recvrequest(cmd,local,remote,lmode,printnames,recover,pipename,xlate,fcs,rcs) #ifdef COMMENT if (!out2screen && !pipename && ftprecv.is_retr) { /* To real file */ if (recursive && ckstrchr(local,'/')) { - + } } #endif /* COMMENT */ @@ -13938,7 +13885,7 @@ dataconn(lmode) char *lmode; } #ifdef FTP_PROXY -static sigtype +static SIGTYP pscancel(sig) int sig; { cancelfile++; } @@ -14064,7 +14011,7 @@ pswitch(flag) int flag; { } } -static sigtype +static SIGTYP #ifdef CK_ANSIC cancelpt( int sig ) #else @@ -14089,7 +14036,7 @@ proxtrans(cmd, local, remote, unique) char *cmd, *local, *remote; int unique; { #ifdef BSDSELECT fd_set mask; #endif /* BSDSELECT */ - sigtype cancelpt(); + SIGTYP cancelpt(); if (strcmp(cmd, "RETR")) cmd2 = "RETR"; @@ -14757,7 +14704,7 @@ setpbsz(size) unsigned int size; } else maxbuf = actualbuf; ucbufsiz = maxbuf - FUDGE_FACTOR; - debug(F101,"setpbsz ucbufsiz","",ucbufsiz); + debug(F101,"setpbsz ucbufsiz","",ucbufsiz); reply_parse = NULL; return(0); } @@ -14982,7 +14929,7 @@ fts_cpl( int x ) fts_cpl(x) int x; #endif /* CK_ANSIC */ { - if (!auth_type + if (!auth_type #ifdef OS2 || !ck_crypt_is_installed() #endif /* OS2 */ @@ -15568,7 +15515,7 @@ ftp_login(host) char * host; else ckmakmsg(prompt,PROMPTSIZ," Name (",host,"): ",NULL); tmp[0] = '\0'; - + ok = uq_txt(NULL,prompt,1,NULL,tmp,PASSBUFSIZ,NULL, DEFAULT_UQ_TIMEOUT); if (!ok || *tmp == '\0') @@ -16036,14 +15983,14 @@ remote_files(new_query, arg, pattern, proxy_switch) if (!forced || !mgetmethod) /* Not forced... */ mgetmethod = (sfttab[0] && sfttab[SFT_MLST]) ? /* so pick one */ SND_MLS : - SND_NLS; -/* + SND_NLS; +/* User's Command: Result: mget /nlst NLST (NULL) mget /nlst foo NLST foo - mget /nlst *.txt NLST *.txt + mget /nlst *.txt NLST *.txt mget /nlst /match:*.txt NLST (NULL) - mget /nlst /match:*.txt foo NLST foo + mget /nlst /match:*.txt foo NLST foo mget /mlsd MLSD (NULL) mget /mlsd foo MLSD foo mget /mlsd *.txt MLSD (NULL) @@ -16162,7 +16109,7 @@ remote_files(new_query, arg, pattern, proxy_switch) rfrc = -3; /* means we're done */ return(NULL); } - printf("POPPING(%d)...\n",mlsdepth-1); + printf("POPPING(%d)...\n",mlsdepth-1); if (tmpfilnam[mlsdepth]) free(tmpfilnam[mlsdepth]); mlsdepth--; doftpcdup(); @@ -16215,7 +16162,7 @@ remote_files(new_query, arg, pattern, proxy_switch) if (mlsdepth < MLSDEPTH) { char * p2 = NULL; mlsdepth++; - printf("RECURSING [%s](%d)...\n",p,mlsdepth); + printf("RECURSING [%s](%d)...\n",p,mlsdepth); if (doftpcwd(p,0) > 0) { int x; if (!ckstrchr(p,'/')) { @@ -16263,8 +16210,8 @@ remote_files(new_query, arg, pattern, proxy_switch) if (deblog) { debug(F101,"remote_files havesize","",havesize); debug(F101,"remote_files havetype","",havetype); - debug(F110,"remote_files havemdtm",havemdtm,0); - debug(F110,"remote_files name",p,0); + debug(F110,"remote_files havemdtm",havemdtm,0); + debug(F110,"remote_files name",p,0); } #endif /* DEBUG */ return((CHAR *)p); @@ -16444,7 +16391,7 @@ secure_write(fd, buf, nbyte) { int ret; -#ifdef FTP_TIMEOUT +#ifdef FTP_TIMEOUT ftp_timed_out = 0; if (check_data_connection(fd,1) < 0) { ftp_timed_out = 1; @@ -16925,7 +16872,7 @@ secure_getc(fd,fc) int fd,fc; nin = bufp = 0; ftp_timed_out = 1; return(-3); - } + } #endif /* FTP_TIMEOUT */ nin = bufp = recv(fd,(char *)ucbuf,actualbuf,0); @@ -17837,7 +17784,7 @@ ftp_mput(argc, argv) int argc; char **argv; { register int i; int ointer; char *tp; - sigtype mcancel(); + SIGTYP mcancel(); if (argc < 2 && !another(&argc, &argv, "local-files")) { printf("usage: %s local-files\n", argv[0]); @@ -17956,7 +17903,7 @@ ftp_mget(argc, argv) int argc; char **argv; { int rc = -1; int ointer; char *cp, *tp, *tp2, tmpbuf[CKMAXPATH]; - sigtype mcancel(); + SIGTYP mcancel(); if (argc < 2 && !another(&argc, &argv, "remote-files")) { printf("usage: %s remote-files\n", argv[0]); @@ -18015,7 +17962,7 @@ static int mdelete(argc, argv) int argc; char **argv; { int ointer; char *cp; - sigtype mcancel(); + SIGTYP mcancel(); if (argc < 2 && !another(&argc, &argv, "remote-files")) { printf("usage: %s remote-files\n", argv[0]); @@ -18055,7 +18002,7 @@ static int mls(argc, argv) int argc; char **argv; { int ointer, i; char *cmd, mode[1], *dest; - sigtype mcancel(); + SIGTYP mcancel(); int rc = -1; if (argc < 2 && !another(&argc, &argv, "remote-files")) diff --git a/ckcftp.h b/ckcftp.h deleted file mode 100644 index 012ae3c..0000000 --- a/ckcftp.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Prototypes for static functions defined in ckcftp.c */ -#ifdef CK_ANSIC - -static VOID bytswap( int *, int * ); -static VOID cancel_remote( int ); -static VOID changetype( int, int ); -static VOID dbtime( char *, struct tm * ); -static VOID ftscreen( int, char, CK_OFF_T, char * ); -static char * ftp_hookup( char *, int, int ); -static char * radix_error( int ); -static char * shopl( int ); -static char * strval( char *, char * ); -static int check_data_connection( int, int ); -static int chkmodtime( char *, char *, int ); -static int dataconn( char * ); -static int doftpcwd( char *, int ); -static int doftpdir( int ); -static int doftpxmkd( char *, int ); -static int ftp_login( char * ); -static int ftp_rename( char *, char * ); -static int ftp_umask( char * ); -static int ftp_user( char *, char *, char * ); -static int ftpcmd( char *, char *, int, int, int ); -static int fts_cpl( int ); -static int fts_dpl( int ); -static int getfile( char *, char *, int, int, char *, int, int, int ); -static int getreply( int, int, int, int, int ); -static int ispathsep( int ); -static int looping_read(int, register char *, register int ); -static int looping_write( int, register CONST char *, int ); -static int openftp( char *, int ); -static int putfile( int, char *, char *, int, int, char *, char *, char *, int, int, int, int, int, int, int ); -static int recvrequest(char *, char *, char *, char *, int, int, char *, int, int, int ); -static int secure_flush( int ); -static int secure_getbyte( int, int ); -static int secure_read( int fd, char *, int ); -static int sendrequest( char *, char *, char *, int, int, int, int ); -static int syncdir( char *, int ); - -static int tmcompare( struct tm *, struct tm * ); -static int xlatec( int, int, int, int ); -static sigtype cancelrecv( int ); -static sigtype cancelsend( int ); -static sigtype cmdcancel( int ); - -#endif /* CK_ANSIC */ diff --git a/ckclib.c b/ckclib.c index 8f17748..d3fd76c 100644 --- a/ckclib.c +++ b/ckclib.c @@ -124,7 +124,7 @@ static char rxresult[RXRESULT+1]; . ckstrncpy() returns a number. Use ckstrncpy() when you want to: - . Copy a NUL-terminated string into a buffer without overrun, truncating + . Copy a NUL-terminated string into a buffer without overrun, truncating it if necessary to fit in the buffer, and null-terminating it. . Get the length of the string back. @@ -1494,7 +1494,7 @@ ispattern(s) char * s; #endif /* CK_ANSIC */ { int quote = 0, sbflag = 0, sb = 0, cbflag = 0, cb = 0; - + char c = 0; if (*s == '^') return(1); while ((c = *s++)) { @@ -2202,7 +2202,7 @@ isfloat(s,flag) char *s; int flag; Negative...-1 = nearest ten, -2 = nearest 100, -3 = nearest thousand, etc. obuf Output buffer for string result if desired. - obuflen + obuflen Length of output buffer. Returns: Result as CKFLOAT (which is not going to be as exact as the string result) @@ -2260,7 +2260,7 @@ ckround(fpnum,places,obuf,obuflen) s += p; /* Go to desired spot */ if (*s > '4' && *s <= '9') /* Check value of digit */ carry = 1; - *s = 0; /* And end the string */ + *s = 0; /* And end the string */ s--; /* Point to last digit */ } } else if (p == 0) { /* Rounding to integer */ @@ -2850,7 +2850,7 @@ char * #ifdef CK_ANSIC ulongtohex( unsigned long z, int n ) #else -ulongtohex(z,n) unsigned long z; int n; +ulongtohex(z,n) unsigned long z; int n; #endif /* CK_ANSIC */ /* ulongtohex */ { static char hexbuf[17]; @@ -3479,9 +3479,9 @@ cksplit(fc,n1,s1,s2,s3,n2,n3,n4,n5) return(&ck_sval); } else { /* Succeed otherwise */ ck_sval.a_size = wordnum; -/* +/* Always put a null element at the end of the array. It does no harm in - the normal case, and it's required if we're making an argv[] array to + the normal case, and it's required if we're making an argv[] array to pass to execvp(). This element is not included in the count. */ if (wordnum < MAXWORDS) diff --git a/ckcmai.c b/ckcmai.c index a84b9cb..4050324 100644 --- a/ckcmai.c +++ b/ckcmai.c @@ -98,7 +98,7 @@ int offtsize = 0; /* Size of OFF_T */ The C-Kermit Version number is major.minor.edit (integers). Major version always goes up. - The Minor version is an artifact from the DECSYSTEM-20 versioning + The Minor version is an artifact from the DECSYSTEM-20 versioning system and hasn't been used since C-Kermit 7.1. The Edit number is sequential, always goes up, but there can be gaps. @@ -106,7 +106,7 @@ int offtsize = 0; /* Size of OFF_T */ is no longer shown as of C-Kermit 10.0, but we still need to keep it, and it should always be incremented, for the benefit of packagers like Debian who depend on it. - + Also the custom-format version numbers for the original 1980s Macintosh is gone as there is no more Mac Kermit (for the original Macintosh), just C-Kermit for each platform (except the original Mac) and Kermit 95. @@ -2767,7 +2767,7 @@ makever ( ) return; } x += y + 1; - + if (*ck_s_who) { y = strlen(ck_s_who); if (CKVERLEN < x + y + 1) @@ -3660,7 +3660,7 @@ MAINNAME( argc, argv ) int argc; char **argv; #ifdef HAVE_LOCALE if (nolocale) { /* --nolocale option on command line */ setlocale(LC_ALL, "C"); /* Restore our locale to default */ - } + } #endif /* HAVE_LOCALE */ #ifndef NOTCPIP @@ -3743,7 +3743,7 @@ MAINNAME( argc, argv ) int argc; char **argv; #endif /* NOCMDL */ #else /* not NOICP */ #ifdef HAVE_LOCALE - if (!nolocale) { + if (!nolocale) { /* Can also disable locale processing by setting K_NOLOCALE=1 */ char *s = getenv("K_NOLOCALE"); /* environment variable */ if (s) diff --git a/ckcnet.c b/ckcnet.c index 1d99b0b..ae9e29d 100644 --- a/ckcnet.c +++ b/ckcnet.c @@ -27,7 +27,7 @@ char *cknetv = "Network support, 10.0.304, 18 Sep 2023"; Frank da Cruz (fdc@columbia.edu), Columbia University Academic Information Systems, New York City. - Jeffrey E Altman (jaltman@secure-endpoints.com) -- Primary + Jeffrey E Altman (jaltman@secure-endpoints.com) -- Primary maintainer/developer since about 1996. netopen() routine for TCP/IP originally by Ken Yap, Rochester University (ken@cs.rochester.edu) (no longer at that address). @@ -1200,7 +1200,7 @@ ttbufr() { /* TT Buffer Read */ len = BIO_read(bio_err,ssl_err,SSL_ERR_BFSZ); ssl_err[len < SSL_ERR_BFSZ ? len : SSL_ERR_BFSZ] = '\0'; debug(F110,"ttbufr SSL_ERROR_SSL",ssl_err,0); - if (ssl_debug_flag) + if (ssl_debug_flag) printf(ssl_err); } else if (ssl_debug_flag) { debug(F100,"ttbufr SSL_ERROR_SSL","",0); @@ -1354,7 +1354,7 @@ ttbufr() { /* TT Buffer Read */ #ifdef RLOGCODE /* blah */ if (ttnproto == NP_RLOGIN || ttnproto == NP_K4LOGIN || ttnproto == NP_EK4LOGIN || - ((ttnproto == NP_K5LOGIN || ttnproto == NP_EK5LOGIN) && + ((ttnproto == NP_K5LOGIN || ttnproto == NP_EK5LOGIN) && !rlog_inband) ) { @@ -4771,7 +4771,7 @@ _PROTOTYP(SIGTYP x25oobh, (int) ); /* Yes, so if raw port not requested */ #ifdef COMMENT /* Jeff 2005/12/30 */ - if (ttnproto != NP_TCPRAW && ttnproto != NP_SSL_RAW && + if (ttnproto != NP_TCPRAW && ttnproto != NP_SSL_RAW && ttnproto != NP_TLS_RAW && ttnproto != NP_NONE) #else /* fdc 2005/12/04 */ @@ -5086,7 +5086,7 @@ _PROTOTYP(SIGTYP x25oobh, (int) ); tcp_http_proxy ? proxycopy : #endif /* NOHTTP */ (tcp_rdns && host && host->h_name && host->h_name[0]) ? - (char *)host->h_name : (namecopy2[0] ? namecopy2 : + (char *)host->h_name : (namecopy2[0] ? namecopy2 : (namecopy[0] ? namecopy : ipaddr)), ipaddr, uidbuf, @@ -5864,7 +5864,7 @@ nettchk() { /* for reading from network */ if ( ssl_active_flag || tls_active_flag ) { ckhexdump("nettchk got real data",&ttibuf[ttibp+ttibn],x); ttibn += x; - } else + } else #endif /* CK_SSL */ { debug(F101,"nettchk socket_read char","",c); @@ -7627,7 +7627,7 @@ rlog_ini(hostname, port, l_addr, r_addr) quote rule so that binary data from the server does not confuse the client. */ -int +int #ifdef CK_ANSIC rlog_ctrl( unsigned char *cp, int n ) #else @@ -10514,7 +10514,7 @@ http_open(hostname, svcname, use_ssl, rdns_name, rdns_len, agent) if (!svcname) svcname = ""; if (!*hostname || !*svcname) return(-1); - + service = ckgetservice(hostname,svcname,http_ip,20); if (service == NULL) { @@ -10568,15 +10568,15 @@ http_open(hostname, svcname, use_ssl, rdns_name, rdns_len, agent) return(-1); } - /* copy the proxyname and remove the service if any so we can use - * it as the hostname + /* copy the proxyname and remove the service if any so we can use + * it as the hostname */ ckstrncpy(namecopy,tcp_http_proxy,NAMECPYL); p = namecopy; /* Was a service requested? */ while (*p != '\0' && *p != ':') p++; /* Look for colon */ if (*p == ':') { /* Have a colon */ *p = '\0'; /* terminate string */ - } + } hostname = namecopy; /* use proxy as hostname */ } @@ -10881,10 +10881,10 @@ http_open(hostname, svcname, use_ssl, rdns_name, rdns_len, agent) if ( tcp_http_proxy ) { #ifdef OS2 - if (!agent) + if (!agent) agent = "Kermit 95"; /* Default user agent */ #else - if (!agent) + if (!agent) agent = "C-Kermit"; #endif /* OS2 */ @@ -11697,7 +11697,7 @@ http_inc(timo) int timo; savefd = ttyfd; ttyfd = httpfd; x = nettchk(); - ttyfd = savefd; + ttyfd = savefd; debug(F101,"http_inc nettchk","",x); if (x > HTTP_INBUFLEN) x = HTTP_INBUFLEN; diff --git a/ckcpro.c b/ckcpro.c deleted file mode 100644 index 3100279..0000000 --- a/ckcpro.c +++ /dev/null @@ -1,3997 +0,0 @@ - -/* WARNING -- This C source program generated by Wart preprocessor. */ -/* Do not edit this file; edit the Wart-format source file instead, */ -/* and then run it through Wart to produce a new C source file. */ - -/* Wart Version Info: */ -char *wartv = "Wart Version 2.17, 04 February 2024 "; - -char *protv = /* -*-C-*- */ -"C-Kermit Protocol Module 10.0.170, 21 Mar 2024"; - -int kactive = 0; /* Kermit protocol is active */ -/* - This file, ckcpro.w, is the source file for the Kermit protocol state table - switcher: ckcpro.c, which is created by running ckcpro.w through the "wart" - program via "make ckcpro.c", which converts the part enclosed in double - percent signs from Lex format to the C module called ckcpro.c. - - In November 2022 this file was retired on the unwise assumption that the - Kermit protocol would never change again. - - Starting with edit 10.0.168 of 29 January 2024, ckcpro.w is reinstated - because it proved impossible to make protocol changes or additions by - editing ckcpro.c directly when a few simple client/server fuctions were - needed: REMOTE CDUP and REMOTE STATUS. The makefile has not changed - however, except for putting back "make wart" and "make ckcpro.c", so - ckcpro.w is not automatically converted by the 'wart' program as it was - before. - - In short, if you want to change the protocol module (this file), you have to - build it by hand with: - - make wart - make ckcpro.c -*/ -#define PKTZEROHACK - -/* C K C P R O -- C-Kermit Protocol Module, in Wart preprocessor notation. */ -/* - Author: Frank da Cruz , - Columbia University Academic Information Systems, New York City. - - Copyright (C) 1985, 2024 - 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. -*/ -#ifndef NOXFER -#include "ckcsym.h" -#include "ckcdeb.h" -#include "ckcasc.h" -#include "ckcker.h" -#ifdef OS2 -#ifndef NT -#define INCL_NOPM -#define INCL_VIO /* Needed for ckocon.h */ -#include -#undef COMMENT -#endif /* NT */ -#include "ckocon.h" -#endif /* OS2 */ - -#ifdef CK_AUTHENTICATION -#include "ckuath.h" /* fdc 2021-12-17 */ -#endif /* CK_AUTHENTICATION */ -#include "ckcfnp.h" /* Prototypes (must be last) */ - -/* - Note -- This file may also be preprocessed by the UNIX Lex program, but - you must indent the above #include statements before using Lex, and then - restore them to the left margin in the resulting C program before compilation. - Also, the invocation of the "wart()" function below must be replaced by an - invocation of the "yylex()" function. It might also be necessary to remove - comments in the (%)(%)...(%)(%) section. -*/ - -/* State definitions for Wart (or Lex) */ -#define ipkt 1 -#define rfile 2 -#define rattr 3 -#define rdpkt 4 -#define ssinit 5 -#define ssfile 6 -#define ssattr 7 -#define ssdata 8 -#define sseof 9 -#define sseot 10 -#define serve 11 -#define generic 12 -#define get 13 -#define rgen 14 -#define ssopkt 15 -#define ropkt 16 - -_PROTOTYP(static VOID xxproto,(void)); -_PROTOTYP(static VOID wheremsg,(void)); -_PROTOTYP(int wart,(void)); -_PROTOTYP(static int sgetinit,(int,int)); -_PROTOTYP(int sndspace,(int)); - -/* External C-Kermit variable declarations */ - extern char *versio, *srvtxt, *cmarg, *cmarg2, **cmlist, *rf_err; - extern char * rfspec, * sfspec, * srfspec, * rrfspec; - extern char * prfspec, * psfspec, * psrfspec, * prrfspec; - extern char *cdmsgfile[]; - extern char * snd_move, * snd_rename, * srimsg; - extern char filnam[], ofilnam[], fspec[], ttname[], ofn1[]; - extern CHAR sstate, *srvptr, *data; - extern int timint, rtimo, nfils, hcflg, xflg, flow, mdmtyp, network; - extern int oopts, omode, oname, opath, nopush, isguest, xcmdsrc, rcdactive; - extern int rejection, moving, fncact, bye_active, urserver, fatalio; - extern int protocol, prefixing, carrier, fnspath, interrupted; - extern long filcnt; - extern int recursive, inserver, nzxopts, idletmo, srvidl, xfrint; - extern struct ck_p ptab[]; - extern int remfile, rempipe, xferstat, filestatus, wearealike, fackpath; - extern int patterns, filepeek, gnferror; - extern char * remdest; - -#ifdef PKTZEROHACK -#define PKTZEROLEN 32 -static char ipktack[PKTZEROLEN]; -static int ipktlen = 0; -#endif /* PKTZEROHACK */ - -static int s_timint = -1; /* For saving timeout value */ -static int myjob = 0; -static int havefs = 0; -#ifdef CK_LOGIN -static int logtries = 0; -#endif /* CK_LOGIN */ - -static int cancel = 0; -int fackbug = 0; - -#ifdef STREAMING -extern int streaming, streamok; - -static VOID -streamon() { - if (streamok) { - debug(F100,"streamon","",0); - streaming = 1; - timint = 0; /* No timeouts while streaming. */ - } -} - -#ifdef COMMENT /* (not used) */ -static VOID -streamoff() { - if (streaming) { - debug(F100,"streamoff","",0); - streaming = 0; - timint = s_timint; /* Restore timeout */ - } -} -#endif /* COMMENT */ -#else /* STREAMING */ -#define streamon() -#define streamoff() -#endif /* STREAMING */ - -#ifndef NOSPL -_PROTOTYP( int addmac, (char *, char *) ); -_PROTOTYP( int zzstring, (char *, char **, int *) ); -#endif /* NOSPL */ -#ifndef NOICP -_PROTOTYP( int cmdsrc, (void) ); -#endif /* NOICP */ - -#ifndef NOSERVER - extern char * x_user, * x_passwd, * x_acct; - extern int x_login, x_logged; -#endif /* NOSERVER */ - -#include "ckcnet.h" - -#ifdef TNCODE - extern int ttnproto; /* Network protocol */ -#endif /* TNCODE */ - -#ifdef CK_SPEED - extern short ctlp[]; /* Control-character prefix table */ -#endif /* CK_SPEED */ - -#ifdef TNCODE - extern int tn_b_nlm, tn_b_xfer, tn_nlm; -#ifdef CK_ENCRYPTION - extern int tn_no_encrypt_xfer; -#endif /* CK_ENCRYPTION */ -#endif /* TNCODE */ - -#ifdef TCPSOCKET -#ifndef NOLISTEN - extern int tcpsrfd; -#endif /* NOLISTEN */ -#endif /* TCPSOCKET */ - - extern int cxseen, czseen, server, srvdis, local, displa, bctu, bctr, bctl; - extern int bctf; - extern int quiet, tsecs, parity, backgrd, nakstate, atcapu, wslotn, winlo; - extern int wslots, success, xitsta, rprintf, discard, cdtimo, keep, fdispla; - extern int timef, stdinf, rscapu, sendmode, epktflg, epktrcvd, epktsent; - extern int binary, fncnv, dest; - extern long speed, crc16; - extern CK_OFF_T calibrate, ffc; -#ifdef COMMENT - extern char *TYPCMD, *DIRCMD, *DIRCM2; -#endif /* COMMENT */ -#ifndef OS2 - extern char *SPACMD, *SPACM2, *WHOCMD; -#endif /* OS2 */ - extern CHAR *rdatap; - extern struct zattr iattr; - -#ifdef VMS - extern int batch; -#endif /* VMS */ - -#ifdef GFTIMER - extern CKFLOAT fptsecs; -#endif /* GFTIMER */ - - extern CHAR *srvcmd; - extern CHAR *epktmsg; - -#ifdef CK_TMPDIR -extern int f_tmpdir; /* Directory changed temporarily */ -extern char savdir[]; /* For saving current directory */ -extern char * dldir; -#endif /* CK_TMPDIR */ - - extern int query; /* Query-active flag */ -#ifndef NOSPL - extern int cmdlvl; - char querybuf[QBUFL+1] = { NUL, NUL }; /* QUERY response buffer */ - char *qbufp = querybuf; /* Pointer to it */ - int qbufn = 0; /* Length of data in it */ -#else - extern int tlevel; -#endif /* NOSPL */ - -#ifndef NOICP - extern int escape; -#endif /* NOICP */ -/* - If the following flag is nonzero when the protocol module is entered, - then server mode persists for exactly one transaction, rather than - looping until BYE or FINISH is received. -*/ -extern int justone; - -static int r_save = -1; -static int p_save = -1; - -/* Function to let remote-mode user know where their file(s) went */ - -int whereflg = 1; /* Unset with SET XFER REPORT */ - -static VOID -wheremsg() { - extern int quiet; - extern long filrej; - long n; - n = filcnt - filrej; - debug(F101,"wheremsg n","",n); - - debug(F110,"wheremsg prfspec",prfspec,0); - debug(F110,"wheremsg rfspec",rfspec,0); - debug(F110,"wheremsg psfspec",psfspec,0); - debug(F110,"wheremsg sfspec",sfspec,0); - - debug(F110,"wheremsg prrfspec",prrfspec,0); - debug(F110,"wheremsg rrfspec",rrfspec,0); - debug(F110,"wheremsg psrfspec",psrfspec,0); - debug(F110,"wheremsg srfspec",srfspec,0); - - if (!quiet && !local) { - if (n == 1) { - switch (myjob) { - case 's': - if (sfspec) { - printf(" SENT: [%s]",sfspec); - if (srfspec) - printf(" To: [%s]",srfspec); - printf(" (%s)\r\n", success ? "OK" : "FAILED"); - } - break; - case 'r': - case 'v': - if (rrfspec) { - printf(" RCVD: [%s]",rrfspec); - if (rfspec) - printf(" To: [%s]",rfspec); - printf(" (%s)\r\n", success ? "OK" : "FAILED"); - } - } - } else if (n > 1) { - switch (myjob) { - case 's': - if (sfspec) { - printf(" SENT: (%ld files)",n); - if (srfspec) - printf(" Last: [%s]",srfspec); - printf(" (%s)\r\n", success ? "OK" : "FAILED"); - } - break; - case 'r': - case 'v': - if (rrfspec) { - printf(" RCVD: (%ld files)",n); - if (rfspec) - printf(" Last: [%s]",rfspec); - printf(" (%s)\r\n", success ? "OK" : "FAILED"); - } - } - } else if (n == 0) { - if (myjob == 's') - printf(" SENT: (0 files) \r\n"); - else if (myjob == 'r' || myjob == 'v') - printf(" RCVD: (0 files) \r\n"); - } - } -} - -static VOID -rdebug() { - if (server) - debug(F111,"RESUME","server=1",justone); - else - debug(F111,"RESUME","server=0",justone); -} - -/* Flags for the ENABLE and DISABLE commands */ -extern int - en_cpy, en_cwd, en_del, en_dir, en_fin, en_get, en_bye, en_mai, en_pri, - en_hos, en_ren, en_sen, en_spa, en_set, en_typ, en_who, en_ret, en_xit, - en_mkd, en_rmd; -#ifndef NOSPL -extern int en_asg, en_que; -#endif /* NOSPL */ -extern int what, lastxfer; - -/* Global variables declared here */ - - int whatru = 0; /* What are you. */ - int whatru2 = 0; /* What are you, cont'd. */ - -/* Local variables */ - - static char vstate = 0; /* Saved State */ - static char vcmd = 0; /* Saved Command */ - static int reget = 0; /* Flag for executing REGET */ - static int retrieve = 0; /* Flag for executing RETRIEVE */ - static int opkt = 0; /* Send Extended GET packet */ - - static int x; /* General-purpose integer */ - static char *s; /* General-purpose string pointer */ - -/* Macros - Note, BEGIN is predefined by Wart (and Lex) as "state = ", */ -/* BEGIN is NOT a GOTO! */ -#define TINIT if (tinit(1) < 0) return(-9) -#define SERVE { TINIT; resetc(); nakstate=1; what=W_NOTHING; cmarg2=""; \ -sendmode=SM_SEND; havefs=0; recursive=r_save; fnspath=p_save; BEGIN serve; } -#define RESUME { rdebug(); if (!server) { wheremsg(); return(0); } else \ -if (justone) { justone=0; wheremsg(); return(0); } else { SERVE; } } - -#ifdef GFTIMER -#define QUIT x=quiet; quiet=1; clsif(); clsof(1); tsecs=gtimer(); \ - fptsecs=gftimer(); quiet=x; return(success) -#else -#define QUIT x=quiet; quiet=1; clsif(); clsof(1); tsecs=gtimer(); quiet=x; \ - return(success) -#endif /* GFTIMER */ - -/* - By late 1999, the big switch() statement generated from the following state - table began choking even gcc, so here we extract the code from the larger - states into static routines to reduce the size of the cases and the - switch() overall. The routines follow the state table; the prototypes are - here. Each of these routines simply contains the text from the - corresponding case, but with return(-1) added in appropriate places; see - instructions after the state table switcher. -*/ -static int rc; /* Return code for these routines */ -static int rcv_s_pkt(); /* Received an S packet */ -static int rcv_firstdata(); /* Received first Data packet */ -static int rcv_shortreply(); /* Short reply to a REMOTE command */ -static int srv_query(); /* Server answers an query */ -static int srv_copy(); /* Server executes REMOTE COPY */ -static int srv_rename(); /* Server executes REMOTE RENAME */ -static int srv_login(); /* Server executes REMOTE LOGIN */ -static int srv_timeout(); /* Server times out */ - - -#define BEGIN state = - -int state = 0; - -int -wart() -{ - int c,actno; - extern char tbl[]; - while (1) { - c = input() - 32; - debug(F000,"PROTO input",ckitoa(state),c+32); - if (c < 0 || c > 95) c = 0; - if ((actno = tbl[c + state*96]) != -1) - switch(actno) { -case 1: - { TINIT; /* Send file(s) */ - if (sinit() > 0) BEGIN ssinit; - else RESUME; } - break; -case 2: - { TINIT; nakstate = 1; BEGIN get; } - break; -case 3: - { /* Client sends a GET command */ - TINIT; - vstate = get; - reget = 0; - retrieve = 0; - opkt = 0; - vcmd = 0; -#ifdef PKTZEROHACK - ipktack[0] = NUL; -#endif /* PKTZEROHACK */ - if (sipkt('I') >= 0) - BEGIN ipkt; - else - RESUME; -} - break; -case 4: - { /* Client sends a RETRIEVE command */ - TINIT; - vstate = get; - reget = 0; - retrieve = 1; - opkt = 0; - vcmd = 0; - if (sipkt('I') >= 0) - BEGIN ipkt; - else - RESUME; -} - break; -case 5: - { /* Client sends a REGET command */ - TINIT; - vstate = get; - reget = 1; - retrieve = 0; - opkt = 0; - vcmd = 0; - if (sipkt('I') >= 0) - BEGIN ipkt; - else - RESUME; -} - break; -case 6: - { /* Client sends Extended GET Packet */ - TINIT; - vstate = get; - reget = oopts & GOPT_RES; - retrieve = oopts & GOPT_DEL; - opkt = 1; - vcmd = 0; - if (sipkt('I') >= 0) - BEGIN ipkt; - else - RESUME; -} - break; -case 7: - { /* Client sends a Host command */ - TINIT; - vstate = rgen; - vcmd = 'C'; - if (sipkt('I') >= 0) - BEGIN ipkt; - else - RESUME; -} - break; -case 8: - { TINIT; /* Client sends a Kermit command */ - vstate = rgen; - vcmd = 'K'; - if (sipkt('I') >= 0) - BEGIN ipkt; - else - RESUME; -} - break; -case 9: - { /* Client sends a REMOTE command */ - TINIT; - vstate = rgen; - vcmd = 'G'; - if (sipkt('I') >= 0) - BEGIN ipkt; - else - RESUME; -} - break; -case 10: - { /* Enter server mode */ - int x; - x = justone; - if (!ENABLED(en_del)) { /* If DELETE is disabled */ - if (fncact == XYFX_B || /* undo any file collision action */ - fncact == XYFX_U || /* that could result in deletion or */ - fncact == XYFX_A || /* modification of existing files. */ - fncact == XYFX_X) { -#ifndef NOICP - extern int g_fncact; - g_fncact = fncact; /* Save current setting */ -#endif /* NOICP */ - fncact = XYFX_R; /* Change to RENAME */ - debug(F101,"server DELETE disabled so fncact RENAME","",fncact); - } - } - SERVE; /* tinit() clears justone... */ - justone = x; -#ifdef IKSDB - if (ikdbopen) slotstate(what, "SERVER", "", ""); -#endif /* IKSDB */ -} - break; -case 11: - { - int b1 = 0, b2 = 0; - if (!data) TINIT; /* "ABEND" -- Tell other side. */ - - if (!bctf) { /* Block check 3 forced on all packets */ -#ifndef pdp11 - if (epktflg) { /* If because of E-PACKET command */ - b1 = bctl; b2 = bctu; /* Save block check type */ - bctl = bctu = 1; /* set it to 1 */ - } -#endif /* pdp11 */ - } - errpkt((CHAR *)"User cancelled"); /* Send the packet */ - if (!bctf) { /* Block check 3 forced on all packets */ -#ifndef pdp11 - if (epktflg) { /* Restore the block check */ - epktflg = 0; - bctl = b1; bctu = b2; - } - } -#endif /* pdp11 */ - success = 0; - return(0); /* Return from protocol. */ -} - break; -case 12: - { /* Receive Send-Init packet. */ - rc = rcv_s_pkt(); - cancel = 0; /* Reset cancellation counter */ - debug(F101,"rcv_s_pkt","",rc); - if (rc > -1) return(rc); /* (see below) */ -} - break; -case 13: - { /* Get ack for I-packet */ - int x = 0; -#ifdef PKTZEROHACK - ckstrncpy(ipktack,(char *)rdatap,PKTZEROLEN); /* Save a copy of the ACK */ - ipktlen = strlen(ipktack); -#endif /* PKTZEROHACK */ - spar(rdatap); /* Set parameters */ - cancel = 0; - winlo = 0; /* Set window-low back to zero */ - debug(F101,"Y winlo","",winlo); - urserver = 1; /* So I know I'm talking to a server */ - if (vcmd) { /* If sending a generic command */ - if (tinit(0) < 0) return(-9); /* Initialize many things */ - x = scmd(vcmd,(CHAR *)cmarg); /* Do that */ - if (x >= 0) x = 0; /* (because of O-Packet) */ - debug(F101,"proto G packet scmd","",x); - vcmd = 0; /* and then un-remember it. */ - } else if (vstate == get) { - debug(F101,"REGET sstate","",sstate); - x = srinit(reget, retrieve, opkt); /* GET or REGET, etc */ - } - if (x < 0) { /* If command was too long */ - if (!srimsg) - srimsg = "Error sending string"; - errpkt((CHAR *)srimsg); /* cancel both sides. */ - success = 0; - RESUME; - } else if (x > 0) { /* Need to send more O-Packets */ - BEGIN ssopkt; - } else { - rtimer(); /* Reset the elapsed seconds timer. */ -#ifdef GFTIMER - rftimer(); -#endif /* GFTIMER */ - winlo = 0; /* Window back to 0, again. */ - debug(F101,"Y vstate","",vstate); - nakstate = 1; /* Can send NAKs from here. */ - BEGIN vstate; /* Switch to desired state */ - } -} - break; -case 14: - { /* Got ACK to O-Packet */ - debug(F100,"CPCPRO Y","",0); - x = sopkt(); - debug(F101,"CPCPRO Y x","",x); - if (x < 0) { /* If error */ - errpkt((CHAR *)srimsg); /* cancel both sides. */ - success = 0; - RESUME; - } else if (x == 0) { /* This was the last O-Packet */ - rtimer(); /* Reset the elapsed seconds timer. */ -#ifdef GFTIMER - rftimer(); -#endif /* GFTIMER */ - winlo = 0; /* Window back to 0, again. */ - debug(F101,"Y winlo","",winlo); - nakstate = 1; /* Can send NAKs from here. */ - BEGIN vstate; /* Switch to desired state */ - } - debug(F101,"CPCPRO Y not changing state","",x); -} - break; -case 15: - { /* Ignore Error reply to I packet */ - int x = 0; - winlo = 0; /* Set window-low back to zero */ - debug(F101,"E winlo","",winlo); - if (vcmd) { /* In case other Kermit doesn't */ - if (tinit(0) < 0) return(-9); - x = scmd(vcmd,(CHAR *)cmarg); /* understand I-packets. */ - if (x >= 0) x = 0; /* (because of O-Packet) */ - vcmd = 0; /* Otherwise act as above... */ - } else if (vstate == get) x = srinit(reget, retrieve, opkt); - if (x < 0) { /* If command was too long */ - errpkt((CHAR *)srimsg); /* cancel both sides. */ - success = 0; - RESUME; - } else if (x > 0) { /* Need to send more O-Packets */ - BEGIN ssopkt; - } else { - freerpkt(winlo); /* Discard the Error packet. */ - debug(F101,"E winlo","",winlo); - winlo = 0; /* Back to packet 0 again. */ - nakstate = 1; /* Can send NAKs from here. */ - BEGIN vstate; - } -} - break; -case 16: - { /* Resend of previous I-pkt ACK, same seq number */ - freerpkt(0); /* Free the ACK's receive buffer */ - resend(0); /* Send the GET packet again. */ -} - break; -case 17: - { /* Get I-packet */ -#ifndef NOSERVER - spar(rdatap); /* Set parameters from it */ - ack1(rpar()); /* Respond with our own parameters */ -#ifdef COMMENT - pktinit(); /* Reinitialize packet numbers */ -#else -#ifdef COMMENT - /* This can't be right - it undoes the stuff we just negotiated */ - x = justone; - tinit(1); /* Reinitialize EVERYTHING */ - justone = x; /* But this... */ -#else - tinit(0); /* Initialize most things */ -#endif /* COMMENT */ -#endif /* COMMENT */ -#endif /* NOSERVER */ - cancel = 0; /* Reset cancellation counter */ -} - break; -case 18: - { /* GET */ -#ifndef NOSERVER - if (x_login && !x_logged) { - errpkt((CHAR *)"Login required"); - SERVE; - } else if (sgetinit(0,0) < 0) { - RESUME; - } else { -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "GET", (char *)srvcmd); -#endif /* CKSYSLOG */ - BEGIN ssinit; - } -#endif /* NOSERVER */ -} - break; -case 19: - { /* GET /DELETE (RETRIEVE) */ -#ifndef NOSERVER - if (x_login && !x_logged) { - errpkt((CHAR *)"Login required"); - RESUME; - } else if (!ENABLED(en_del)) { - errpkt((CHAR *)"Deleting files is disabled"); - RESUME; - } else if (sgetinit(0,0) < 0) { - RESUME; - } else { - moving = 1; -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "GET /DELETE", (char *)srvcmd); -#endif /* CKSYSLOG */ - BEGIN ssinit; - } -#endif /* NOSERVER */ -} - break; -case 20: - { /* GET /RECURSIVE */ -#ifndef NOSERVER - recursive = 1; /* Set these before sgetinit() */ - if (fnspath == PATH_OFF) - fnspath = PATH_REL; /* Don't worry, they will be */ - if (x_login && !x_logged) { /* reset next time through. */ - errpkt((CHAR *)"Login required"); - RESUME; - } else if (sgetinit(0,0) < 0) { - RESUME; - } else { -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "GET /RECURSIVE", (char *)srvcmd); -#endif /* CKSYSLOG */ - BEGIN ssinit; - } -#endif /* NOSERVER */ -} - break; -case 21: - { /* GET /RECURSIVE /DELETE */ -#ifndef NOSERVER - recursive = 1; /* Set these before sgetinit() */ - if (fnspath == PATH_OFF) - fnspath = PATH_REL; /* Don't worry, they will be */ - moving = 1; /* reset next time through. */ - if (x_login && !x_logged) { - errpkt((CHAR *)"Login required"); - RESUME; - } else if (!ENABLED(en_del)) { - errpkt((CHAR *)"Deleting files is disabled"); - RESUME; - } else if (sgetinit(0,0) < 0) { - RESUME; - } else { -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR,1,"server", - "GET /RECURSIVE /DELETE",(char *)srvcmd); -#endif /* CKSYSLOG */ - BEGIN ssinit; - } -#endif /* NOSERVER */ -} - break; -case 22: - { /* GET /RECOVER (REGET) */ -#ifndef NOSERVER - if (x_login && !x_logged) { - errpkt((CHAR *)"Login required"); - SERVE; - } else if (sgetinit(1,0) < 0) { - RESUME; - } else { -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "GET /RECOVER", (char *)srvcmd); -#endif /* CKSYSLOG */ - BEGIN ssinit; - } -#endif /* NOSERVER */ -} - break; -case 23: - { /* Extended GET */ -#ifndef NOSERVER - if (x_login && !x_logged) { /* (any combination of options) */ - errpkt((CHAR *)"Login required"); - SERVE; - } else if ((x = sgetinit(0,1)) < 0) { - debug(F101,"CKCPRO O sgetinit fail","",x); - RESUME; - } else if (x == 0) { - debug(F101,"CKCPRO O sgetinit done","",x); -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "EXTENDED GET", (char *)srvcmd); -#endif /* CKSYSLOG */ - BEGIN ssinit; - } else { /* Otherwise stay in this state */ - debug(F101,"CKCPRO O sgetinit TBC","",x); - ack(); - BEGIN ropkt; - } -#endif /* NOSERVER */ -} - break; -case 24: - { -#ifndef NOSERVER - if (x_login && !x_logged) { /* (any combination of options) */ - errpkt((CHAR *)"Login required"); - SERVE; - } else if ((x = sgetinit(0,1)) < 0) { - debug(F101,"CKCPRO O sgetinit fail","",x); - RESUME; - } else if (x == 0) { - debug(F101,"CKCPRO O sgetinit done","",x); -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "EXTENDED GET", (char *)srvcmd); -#endif /* CKSYSLOG */ - BEGIN ssinit; - } else { /* Otherwise stay in this state */ - debug(F101,"CKCPRO O sgetinit TBC","",x); - ack(); - } -#endif /* NOSERVER */ -} - break; -case 25: - { /* Generic server command */ -#ifndef NOSERVER - srvptr = srvcmd; /* Point to command buffer */ - decode(rdatap,putsrv,0); /* Decode packet data into it */ - putsrv(NUL); /* Insert a couple nulls */ - putsrv(NUL); /* for termination */ - if (srvcmd[0]) { - sstate = srvcmd[0]; /* Set requested start state */ - if (x_login && !x_logged && /* Login required? */ - /* Login, Logout, and Help are allowed when not logged in */ - sstate != 'I' && sstate != 'L' && sstate != 'H') { - errpkt((CHAR *)"Login required"); - SERVE; - } else { - nakstate = 0; /* Now I'm the sender. */ - what = W_REMO; /* Doing a REMOTE command. */ -#ifdef STREAMING - if (!streaming) -#endif /* STREAMING */ - if (timint < 1) - timint = chktimo(rtimo,timef); /* Switch to per-packet timer */ - binary = XYFT_T; /* Switch to text mode */ - BEGIN generic; /* Switch to generic command state */ - } - } else { - errpkt((CHAR *)"Badly formed server command"); /* report error */ - RESUME; /* & go back to server command wait */ - } -#endif /* NOSERVER */ -} - break; -case 26: - { /* Receive Host command */ -#ifndef NOSERVER - if (x_login && !x_logged) { - errpkt((CHAR *)"Login required"); - SERVE; - } else if (!ENABLED(en_hos)) { - errpkt((CHAR *)"REMOTE HOST disabled"); - RESUME; - } else if (nopush) { - errpkt((CHAR *)"HOST commands not available"); - RESUME; - } else { - srvptr = srvcmd; /* Point to command buffer */ - decode(rdatap,putsrv,0); /* Decode command packet into it */ - putsrv(NUL); /* Null-terminate */ - nakstate = 0; /* Now sending, not receiving */ - binary = XYFT_T; /* Switch to text mode */ - if (syscmd((char *)srvcmd,"")) { /* Try to execute the command */ - what = W_REMO; /* Doing a REMOTE command. */ -#ifdef STREAMING - if (!streaming) -#endif /* STREAMING */ - if (timint < 1) - timint = chktimo(rtimo,timef); /* Switch to per-packet timer */ -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE HOST", (char *)srvcmd); -#endif /* CKSYSLOG */ - BEGIN ssinit; /* If OK, send back its output */ - } else { /* Otherwise */ - errpkt((CHAR *)"Can't do system command"); /* report error */ - RESUME; /* & go back to server command wait */ - } - } -#endif /* NOSERVER */ -} - break; -case 27: - { /* Interrupted or connection lost */ - rc = srv_timeout(); - debug(F101,"srv_timeout","",rc); - if (rc > -1) return(rc); /* (see below) */ -} - break; -case 28: - { /* Server got a NAK in command-wait */ -#ifndef NOSERVER - errpkt((CHAR *)"Did you say RECEIVE instead of GET?"); - RESUME; -#endif /* NOSERVER */ -} - break; -case 29: - { /* Any other command in this state */ -#ifndef NOSERVER - if (c != ('E' - SP) && c != ('Y' - SP)) /* except E and Y packets. */ - errpkt((CHAR *)"Unimplemented server function"); - /* If we answer an E with an E, we get an infinite loop. */ - /* A Y (ACK) can show up here if we sent back a short-form reply to */ - /* a G packet and it was echoed. ACKs can be safely ignored here. */ - RESUME; /* Go back to server command wait. */ -#endif /* NOSERVER */ -} - break; -case 30: - { /* Login/Out */ - rc = srv_login(); - debug(F101,"I srv_login","",rc); - if (rc > -1) return(rc); /* (see below) */ -} - break; -case 31: - { /* Got REMOTE CD command */ -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE CD", (char *)srvcmd); -#endif /* CKSYSLOG */ - if (!ENABLED(en_cwd)) { - errpkt((CHAR *)"REMOTE CD disabled"); - RESUME; - } else { - char * p = NULL; - x = cwd((char *)(srvcmd+1)); /* Try to change directory */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE CD", (char *)(srvcmd+2), ""); -#endif /* IKSDB */ - if (!x) { /* Failed */ - errpkt((CHAR *)"Can't change directory"); - RESUME; /* Back to server command wait */ - } else if (x == 2) { /* User wants message */ - if (!ENABLED(en_typ)) { /* Messages (REMOTE TYPE) disabled? */ - errpkt((CHAR *)"REMOTE TYPE disabled"); - RESUME; - } else { /* TYPE is enabled */ - int i; - for (i = 0; i < 8; i++) { - if (zchki(cdmsgfile[i]) > -1) { - break; - } - } - binary = XYFT_T; /* Use text mode for this. */ - if (i < 8 && sndtype(cdmsgfile[i])) { /* Have readme file? */ - BEGIN ssinit; /* OK */ - } else { /* not OK */ - p = zgtdir(); - if (!p) p = ""; - success = (*p) ? 1 : 0; - ack1((CHAR *)p); /* ACK with new directory name */ - success = 1; - RESUME; /* wait for next server command */ - } - } - } else { /* User doesn't want message */ - p = zgtdir(); - if (!p) p = ""; - success = (*p) ? 1 : 0; - ack1((CHAR *)p); - success = 1; - RESUME; /* Wait for next server command */ - } - } -#endif /* NOSERVER */ -} - break; -case 32: - { /* Got REMOTE CDUP command */ -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE CDUP", (char *)srvcmd); -#endif /* CKSYSLOG */ - if (!ENABLED(en_cwd)) { - errpkt((CHAR *)"REMOTE CD disabled"); - RESUME; - } else { - char * p = NULL; - char * s = NULL; -#ifdef VMS - s = "[-]"; -#else -#ifdef datageneral - s = "^"; -#else - s = ".."; -#endif /* datageneral */ -#endif /* VMS */ - x = cwd(s); /* Try to change directory */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE CD", (char *)(srvcmd+2), ""); -#endif /* IKSDB */ - if (!x) { /* Failed */ - errpkt((CHAR *)"Can't change directory"); - RESUME; /* Back to server command wait */ - } else if (x == 2) { /* User wants message */ - if (!ENABLED(en_typ)) { /* Messages (REMOTE TYPE) disabled? */ - errpkt((CHAR *)"REMOTE TYPE disabled"); - RESUME; - } else { /* TYPE is enabled */ - int i; - for (i = 0; i < 8; i++) { - if (zchki(cdmsgfile[i]) > -1) { - break; - } - } - binary = XYFT_T; /* Use text mode for this. */ - if (i < 8 && sndtype(cdmsgfile[i])) { /* Have readme file? */ - BEGIN ssinit; /* OK */ - } else { /* not OK */ - p = zgtdir(); - if (!p) p = ""; - success = (*p) ? 1 : 0; - ack1((CHAR *)p); /* ACK with new directory name */ - success = 1; - RESUME; /* wait for next server command */ - } - } - } else { /* User doesn't want message */ - p = zgtdir(); - if (!p) p = ""; - success = (*p) ? 1 : 0; - ack1((CHAR *)p); - success = 1; - RESUME; /* Wait for next server command */ - } - } -#endif /* NOSERVER */ -} - break; -case 33: - { /* Got REMOTE PWD command */ -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE PWD", NULL); -#endif /* CKSYSLOG */ - if (!ENABLED(en_cwd)) { - errpkt((CHAR *)"REMOTE CD disabled"); - RESUME; - } else { - if (encstr((CHAR *)zgtdir()) > -1) { /* Encode current directory */ - ack1(data); /* If it fits, send it back in ACK */ - success = 1; - } else { /* Failed */ - ack(); /* Send empty ACK */ - success = 0; /* and indicate failure locally */ - } - RESUME; /* Back to server command wait */ - } -#endif /* NOSERVER */ -} - break; -case 34: - { /* REMOTE DIRECTORY command */ -#ifndef NOSERVER - char *n2; -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE DIRECTORY", (char *)srvcmd); -#endif /* CKSYSLOG */ - if (!ENABLED(en_dir)) { /* If DIR is disabled, */ - errpkt((CHAR *)"REMOTE DIRECTORY disabled"); /* refuse. */ - RESUME; - } else { /* DIR is enabled. */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE DIR", (char *)(srvcmd+2), ""); -#endif /* IKSDB */ - if (!ENABLED(en_cwd)) { /* But CWD is disabled */ - zstrip((char *)(srvcmd+2),&n2); /* and they included a pathname, */ - if (strcmp((char *)(srvcmd+2),n2)) { /* so refuse. */ - errpkt((CHAR *)"Access denied"); - RESUME; /* Remember, this is not a goto! */ - } - } - if (state == generic) { /* It's OK to go ahead. */ -#ifdef COMMENT - n2 = (*(srvcmd+2)) ? DIRCMD : DIRCM2; - if (syscmd(n2,(char *)(srvcmd+2))) /* If it can be done */ -#else - int x; - if ((x = snddir((char*)(srvcmd+2))) > 0) -#endif /* COMMENT */ - { - BEGIN ssinit; /* send the results back; */ - } else { /* otherwise */ - if (x < 0) - errpkt((CHAR *)"No files match"); - else - errpkt((CHAR *)"Can't list directory"); - RESUME; /* return to server command wait */ - } - } - } -#endif /* NOSERVER */ -} - break; -case 35: - { /* REMOTE DELETE (Erase) */ -#ifndef NOSERVER - char *n2; -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE DELETE", (char *)srvcmd); -#endif /* CKSYSLOG */ - if (!ENABLED(en_del)) { - errpkt((CHAR *)"REMOTE DELETE disabled"); - RESUME; - } else { /* DELETE is enabled */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE DELETE", (char *)(srvcmd+2), ""); -#endif /* IKSDB */ - if (!ENABLED(en_cwd)) { /* but CWD is disabled */ - zstrip((char *)(srvcmd+2),&n2); /* and they included a pathname, */ - if (strcmp((char *)(srvcmd+2),n2)) { /* so refuse. */ - errpkt((CHAR *)"Access denied"); - RESUME; /* Remember, this is not a goto! */ - } - } else if (isdir((char *)(srvcmd+2))) { /* A directory name? */ - errpkt((CHAR *)"It's a directory"); - RESUME; - } - if (state == generic) { /* It's OK to go ahead. */ - int x; - if ((x = snddel((char*)(srvcmd+2))) > 0) { - BEGIN ssinit; /* If OK send results back */ - } else { /* otherwise */ - if (x < 0) - errpkt((CHAR *)"File not found"); /* report failure */ - else - errpkt((CHAR *)"DELETE failed"); - RESUME; /* & return to server command wait */ - } - } - } -#endif /* NOSERVER */ -} - break; -case 36: - { /* FINISH */ -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "FINISH", NULL); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"SERVER FINISH", "", ""); -#endif /* IKSDB */ - if (!ENABLED(en_fin)) { - errpkt((CHAR *)"FINISH disabled"); - RESUME; - } else { - ack(); /* Acknowledge */ - xxscreen(SCR_TC,0,0L,""); /* Display */ - success = 1; - return(0); /* Done */ - } -#endif /* NOSERVER */ -} - break; -case 37: - { /* EXIT */ -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE EXIT", NULL); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE EXIT", "", ""); -#endif /* IKSDB */ - if (!ENABLED(en_xit)) { - errpkt((CHAR *)"EXIT disabled"); - RESUME; - } else { - ack(); /* Acknowledge */ - xxscreen(SCR_TC,0,0L,""); /* Display */ - doexit(GOOD_EXIT,xitsta); - } -#endif /* NOSERVER */ -} - break; -case 38: - { /* BYE (Logout) */ -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "BYE", NULL); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"SERVER BYE", "", ""); -#endif /* IKSDB */ - if (!ENABLED(en_bye)) { - errpkt((CHAR *)"BYE disabled"); - RESUME; - } else { - ack(); /* Acknowledge */ - success = 1; - msleep(750); /* Give the ACK time to get out */ - if (local) - ttres(); /* Reset the terminal */ - xxscreen(SCR_TC,0,0L,""); /* Display */ - doclean(1); /* Clean up files, etc */ -#ifdef DEBUG - debug(F100,"C-Kermit BYE - Logging out...","",0); - zclose(ZDFILE); -#endif /* DEBUG */ -#ifdef IKSD -#ifdef CK_LOGIN - if (inserver) - ckxlogout(); - else -#endif /* CK_LOGIN */ -#endif /* IKSD */ -#ifdef TCPSOCKET -#ifndef NOLISTEN - if (network && tcpsrfd > 0 && !inserver) - doexit(GOOD_EXIT,xitsta); - else -#endif /* NOLISTEN */ -#endif /* TCPSOCKET */ - return(zkself()); /* Try to log self out */ - } -#endif /* NOSERVER */ -} - break; -case 39: - { /* REMOTE HELP */ -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE HELP", NULL); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE HELP", "", ""); -#endif /* IKSDB */ -#ifndef NOSERVER - if (sndhlp()) { - BEGIN ssinit; /* try to send it */ - } else { /* If not ok, */ - errpkt((CHAR *)"Can't send help"); /* send error message instead */ - RESUME; /* and return to server command wait */ - } -#endif /* NOSERVER */ -} - break; -case 40: - { /* REMOTE STATUS */ -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE STATUS", NULL); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE STATUS", "", ""); -#endif /* IKSDB */ -#ifndef NOSERVER - if (sndstatus()) { - BEGIN ssinit; /* try to send it */ - } else { /* If not ok, */ - errpkt((CHAR *)"Can't send status"); /* send error message instead */ - RESUME; /* and return to server command wait */ - } -#endif /* NOSERVER */ -} - break; -case 41: - { /* REMOTE RENAME */ - rc = srv_rename(); - debug(F101,"srv_rename","",rc); - if (rc > -1) return(rc); /* (see below) */ -} - break; -case 42: - { /* REMOTE COPY */ - rc = srv_copy(); - debug(F101,"srv_copy","",rc); - if (rc > -1) return(rc); /* (see below) */ -} - break; -case 43: - { /* REMOTE SET */ -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE SET", (char *)srvcmd); -#endif /* CKSYSLOG */ -#ifndef NOSERVER -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE SET", (char *)(srvcmd+1), ""); -#endif /* IKSDB */ - if (!ENABLED(en_set)) { - errpkt((CHAR *)"REMOTE SET disabled"); - RESUME; - } else { - if (remset((char *)(srvcmd+1))) { /* Try to do what they ask */ - success = 1; - ack(); /* If OK, then acknowledge */ - } else /* Otherwise */ - errpkt((CHAR *)"Unknown REMOTE SET parameter"); /* give error msg */ - RESUME; /* Return to server command wait */ - } -#endif /* NOSERVER */ -} - break; -case 44: - { /* REMOTE TYPE */ -#ifndef NOSERVER - char *n2; -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE TYPE", (char *)srvcmd); -#endif /* CKSYSLOG */ - if (!ENABLED(en_typ)) { - errpkt((CHAR *)"REMOTE TYPE disabled"); - RESUME; - } else { -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE TYPE", (char *)(srvcmd+2), ""); -#endif /* IKSDB */ - if (!ENABLED(en_cwd)) { /* If CWD disabled */ - zstrip((char *)(srvcmd+2),&n2); /* and they included a pathname, */ - if (strcmp((char *)(srvcmd+2),n2)) { /* refuse. */ - errpkt((CHAR *)"Access denied"); - RESUME; /* Remember, this is not a goto! */ - } - } - if (state == generic) { /* It's OK to go ahead. */ - binary = XYFT_T; /* Use text mode for this. */ - if ( /* (RESUME didn't change state) */ -#ifdef COMMENT - syscmd(TYPCMD,(char *)(srvcmd+2)) /* Old way */ -#else - sndtype((char *)(srvcmd+2)) /* New way */ -#endif /* COMMENT */ - ) - BEGIN ssinit; /* OK */ - else { /* not OK */ - errpkt((CHAR *)"Can't type file"); /* give error message */ - RESUME; /* wait for next server command */ - } - } - } -#endif /* NOSERVER */ -} - break; -case 45: - { /* REMOTE MKDIR */ -#ifndef NOSERVER -#ifdef CK_MKDIR -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE MKDIR", (char *)srvcmd); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE MKDIR", (char *)(srvcmd+2), ""); -#endif /* IKSDB */ - if (!ENABLED(en_mkd)) { - errpkt((CHAR *)"REMOTE MKDIR disabled"); - RESUME; - } else if (!ENABLED(en_cwd)) { /* If CWD disabled */ - errpkt((CHAR *)"Directory access restricted"); - RESUME; /* Remember, this is not a goto! */ - } - if (state == generic) { /* OK to go ahead. */ - char *p = NULL; - x = ckmkdir(0,(char *)(srvcmd+2),&p,0,1); /* Make the directory */ - if (!p) p = ""; - if (x > -1) { - encstr((CHAR *)p); /* OK - encode the name */ - ack1(data); /* Send short-form response */ - success = 1; - RESUME; - } else { /* not OK */ - if (!*p) p = "Directory creation failure"; - errpkt((CHAR *)p); /* give error message */ - RESUME; /* Wait for next server command */ - } - } -#else - errpkt((CHAR *)"REMOTE MKDIR not available"); - RESUME; -#endif /* CK_MKDIR */ -#endif /* NOSERVER */ -} - break; -case 46: - { /* REMOTE RMDIR */ -#ifndef NOSERVER -#ifdef CK_MKDIR -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE RMDIR", (char *)srvcmd); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE RMDIR", (char *)(srvcmd+2), ""); -#endif /* IKSDB */ - if (!ENABLED(en_rmd)) { - errpkt((CHAR *)"REMOTE RMDIR disabled"); - RESUME; - } else if (!ENABLED(en_cwd)) { /* If CWD disabled */ - errpkt((CHAR *)"Directory access restricted"); - RESUME; /* Remember, this is not a goto! */ - } - if (state == generic) { /* OK to go ahead. */ - char *p = NULL; - x = ckmkdir(1,(char *)(srvcmd+2),&p,0,1); - if (!p) p = ""; - if (x > -1) { - encstr((CHAR *)p); /* OK - encode the name */ - ack1(data); /* Send short-form response */ - success = 1; - RESUME; - } else { /* not OK */ - if (!*p) p = "Directory removal failure"; - errpkt((CHAR *)p); /* give error message */ - RESUME; /* Wait for next server command */ - } - } -#else - errpkt((CHAR *)"REMOTE RMDIR not available"); - RESUME; -#endif /* CK_MKDIR */ -#endif /* NOSERVER */ -} - break; -case 47: - { /* REMOTE SPACE */ -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE SPACE", (char *)srvcmd); -#endif /* CKSYSLOG */ - if (!ENABLED(en_spa)) { - errpkt((CHAR *)"REMOTE SPACE disabled"); - RESUME; - } else { - x = srvcmd[1]; /* Get area to check */ - x = ((x == NUL) || (x == SP) -#ifdef OS2 - || (x == '!') || (srvcmd[3] == ':') -#endif /* OS2 */ - ); -#ifdef IKSDB - if (ikdbopen) slotstate(what, - "REMOTE SPACE", - (x ? "" : (char *)srvcmd), - "" - ); -#endif /* IKSDB */ - if (!x && !ENABLED(en_cwd)) { /* CWD disabled */ - errpkt((CHAR *)"Access denied"); /* and non-default area given, */ - RESUME; /* refuse. */ - } else { -#ifdef OS2 -_PROTOTYP(int sndspace,(int)); - if (sndspace(x ? toupper(srvcmd[2]) : 0)) { - BEGIN ssinit; /* send the report. */ - } else { /* If not ok, */ - errpkt((CHAR *)"Can't send space"); /* send error message */ - RESUME; /* and return to server command wait */ - } -#else - if (nopush) - x = 0; - else - x = (x ? syscmd(SPACMD,"") : syscmd(SPACM2,(char *)(srvcmd+2))); - if (x) { /* If we got the info */ - BEGIN ssinit; /* send it */ - } else { /* otherwise */ - errpkt((CHAR *)"Can't check space"); /* send error message */ - RESUME; /* and await next server command */ - } -#endif /* OS2 */ - } - } -#endif /* NOSERVER */ -} - break; -case 48: - { /* REMOTE WHO */ -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE WHO", (char *)srvcmd); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE WHO", (char *)(srvcmd+2), ""); -#endif /* IKSDB */ - if (!ENABLED(en_who)) { - errpkt((CHAR *)"REMOTE WHO disabled"); - RESUME; - } else { -#ifdef OS2 -_PROTOTYP(int sndwho,(char *)); - if (sndwho((char *)(srvcmd+2))) { - BEGIN ssinit; /* try to send it */ - } else { /* If not ok, */ - errpkt((CHAR *)"Can't do who command"); /* send error msg */ - RESUME; /* and return to server command wait */ - } -#else - if (syscmd(WHOCMD,(char *)(srvcmd+2))) { - BEGIN ssinit; - } else { - errpkt((CHAR *)"Can't do who command"); - RESUME; - } -#endif /* OS2 */ - } -#endif /* NOSERVER */ -} - break; -case 49: - { /* Variable query or set */ - rc = srv_query(); - debug(F101,"srv_query","",rc); - if (rc > -1) return(rc); -} - break; -case 50: - { /* REMOTE MESSAGE command */ -#ifndef NOSERVER - debug(F110,"RMSG",(char *)srvcmd+2,0); - xxscreen(SCR_MS,0,0L,(char *)(srvcmd+2)); - ack(); - RESUME; -#endif /* NOSERVER */ -} - break; -case 51: - { /* Interrupted or connection lost */ -#ifndef NOSERVER - if (fatalio) { /* Connection lost */ -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "Interrupted", NULL); -#endif /* CKSYSLOG */ - success = 0; - xitsta |= (what & W_KERMIT); - QUIT; - } else if (interrupted) { - if (!ENABLED(en_fin)) { /* Ctrl-C typed */ - errpkt((CHAR *)"QUIT disabled"); - RESUME; - } else { -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "Interrupted", NULL); -#endif /* CKSYSLOG */ - success = 0; - xitsta |= (what & W_KERMIT); - QUIT; - } - } else { /* Shouldn't happen */ - debug(F100,"SERVER (generic) GOT UNEXPECTED 'q'","",0); - QUIT; - } -#endif /* NOSERVER */ -} - break; -case 52: - { /* Anything else in this state... */ -#ifndef NOSERVER - errpkt((CHAR *)"Unimplemented REMOTE command"); /* Complain */ - RESUME; /* and return to server command wait */ -#endif /* NOSERVER */ -} - break; -case 53: - { /* Sent BYE and connection broken */ - if (bye_active && ttchk() < 0) { - msleep(500); - bye_active = 0; - ttclos(0); /* Close our end of the connection */ - clsof(0); - return(success = 1); - } else { /* Other generic command */ - return(success = 0); /* or connection not broken */ - } -} - break; -case 54: - { /* Short-Form reply */ - rc = rcv_shortreply(); - debug(F101,"Y rcv_shortreply","",rc); - if (rc > -1) return(rc); -} - break; -case 55: - { /* File header */ - /* char *n2; */ - extern int rsn; - debug(F101,"F winlo 1","",winlo); - xflg = 0; /* Not screen data */ - if (!czseen) - cancel = 0; /* Reset cancellation counter */ -#ifdef CALIBRATE - if (dest == DEST_N) - calibrate = 1; -#endif /* CALIBRATE */ - if (!rcvfil(filnam)) { /* Figure out local filename */ - errpkt((CHAR *)rf_err); /* Trouble */ - RESUME; - } else { /* Real file, OK to receive */ - char * fnp; - debug(F111,"F winlo 2",fspec,winlo); - if (filcnt == 1) /* rcvfil set this to 1 for 1st file */ - crc16 = 0L; /* Clear file CRC */ - fnp = fspec; /* This is the full path */ - if (server && !ENABLED(en_cwd) || /* if DISABLE CD */ - !fackpath /* or F-ACK-PATH OFF */ - ) { - zstrip(fspec,&fnp); /* don't send back full path */ -#ifdef UNIX -/* - fdc, November 2012. Unix pathnames are getting longer, causing the full - pathname that remote C-Kermit, when receiving a file, sends back to a local - Kermit (e.g. K95) to overflow the file transfer display, so the user can't - see which file is being transferred. Here we try to shorten the pathname - that is sent from the remote receiver back to the local sender. -*/ - } else if (!local) { /* Try to shorten by using '~' */ - extern char homedirpath[]; /* Filled in at startup time */ - char *p; - int len = 0, ok = 0; -/* - fdc, March 2013: If the file is being received to Kermit's current - directory, don't send the current-directory path. -*/ - p = zgtdir(); /* Get current directory */ - if (p) if (*p) { /* If we got one... */ - len = strlen(p); /* and it matches the filespec path */ - if (ckindex(p,fspec,0,0,1) == 1 && len > 3) { - fnp = fspec + len; - ok = 1; - } - } - if (!ok) { -/* - Nov 2012: If not the current directory then if it is being sent - from somewhere in the user's home directory tree, it can be shortened - using ~ notation. -*/ - p = homedirpath; /* Get home directory path */ - if (p) if (*p) { /* If we got one... */ - len = strlen(p); /* and it matches the filespec path */ - if (ckindex(p,fspec,0,0,1) == 1 && len > 3) { - int i = 0; - char * s; - fspec[i++] = '~'; /* ...replace it with "~/" */ - fspec[i++] = '/'; - s = (char *)fspec + len; - while (*s) { - fspec[i++] = *s++; - } - fspec[i] = '\0'; - fnp = fspec; - } - } - } -#endif /* UNIX */ - } - encstr((CHAR *)fnp); - if (fackbug) - ack(); - else - ack1(data); /* Send it back in ACK */ - initattr(&iattr); /* Clear file attribute structure */ - streamon(); - if (window(wslotn) < 0) { /* Allocate negotiated window slots */ - errpkt((CHAR *)"Can't open window"); - RESUME; - } -#ifdef IKSDB - if (ikdbopen) slotstate(what, - server ? "SERVER" : "", - "RECEIVE", - fspec - ); -#endif /* IKSDB */ - BEGIN rattr; /* Now expect Attribute packets */ - } -} - break; -case 56: - { /* X-packet instead of file header */ - xflg = 1; /* Screen data */ - if (!czseen) - cancel = 0; /* Reset cancellation counter */ - ack(); /* Acknowledge the X-packet */ - initattr(&iattr); /* Initialize attribute structure */ - streamon(); - if (window(wslotn) < 0) { /* allocate negotiated window slots */ - errpkt((CHAR *)"Can't open window"); - RESUME; - } -#ifndef NOSPL - if (query) { /* If this is the response to */ - qbufp = querybuf; /* a query that we sent, initialize */ - qbufn = 0; /* the response buffer */ - querybuf[0] = NUL; - } -#endif /* NOSPL */ - what = W_REMO; /* we're doing a REMOTE command */ -#ifdef IKSDB - if (ikdbopen) slotstate(what, - server ? "SERVER" : "", - "RECEIVE", - fspec - ); -#endif /* IKSDB */ - BEGIN rattr; /* Expect Attribute packets */ -} - break; -case 57: - { /* Attribute packet */ - if (gattr(rdatap,&iattr) == 0) { /* Read into attribute structure */ -#ifdef CK_RESEND - ack1((CHAR *)iattr.reply.val); /* Reply with data */ -#else - ack(); /* If OK, acknowledge */ -#endif /* CK_RESEND */ - } else { /* Otherwise */ - extern CK_OFF_T fsize; - char *r; - r = getreason(iattr.reply.val); - ack1((CHAR *)iattr.reply.val); /* refuse to accept the file */ - xxscreen(SCR_ST,ST_REFU,0L,r); /* reason */ -#ifdef TLOG - if (tralog && !tlogfmt) - doxlog(what,filnam,fsize,binary,1,r); -#endif /* TLOG */ - } -} - break; -case 58: - { /* First data packet */ - debug(F100," D firstdata","",0); - rc = rcv_firstdata(); - debug(F101,"rcv_firstdata rc","",rc); - if (rc > -1) return(rc); /* (see below) */ -} - break; -case 59: - { /* EOT, no more files */ - ack(); /* Acknowledge the B packet */ - reot(); /* Do EOT things */ -#ifdef CK_TMPDIR -/* If we were cd'd temporarily to another device or directory ... */ - if (f_tmpdir) { - int x; - x = zchdir((char *) savdir); /* ... restore previous directory */ - f_tmpdir = 0; /* and remember we did it. */ - debug(F111,"ckcpro.w B tmpdir restoring",savdir,x); - } -#endif /* CK_TMPDIR */ - RESUME; /* and quit */ -} - break; -case 60: - { /* Got Data packet */ - debug(F101,"D cxseen","",cxseen); - debug(F101,"D czseen","",czseen); - if (cxseen || czseen || discard) { /* If file or group interruption */ - CHAR * msg; - msg = czseen ? (CHAR *)"Z" : (CHAR *)"X"; -#ifdef STREAMING - if (streaming) { /* Need to cancel */ - debug(F111,"D streaming cancel",msg,cancel); - if (cancel++ == 0) { /* Only do this once */ - ack1(msg); /* Put "X" or "Z" in ACK */ - } else if (czseen) { - errpkt((CHAR *)"User canceled"); - RESUME; - } else { - fastack(); - } - } else -#endif /* STREAMING */ - ack1(msg); - } else { /* No interruption */ - int rc, qf; -#ifndef NOSPL - qf = query; -#else - qf = 0; -#endif /* NOSPL */ -#ifdef CKTUNING - rc = (binary && !parity) ? - bdecode(rdatap,putfil): - decode(rdatap, qf ? puttrm : putfil, 1); -#else - rc = decode(rdatap, qf ? puttrm : putfil, 1); -#endif /* CKTUNING */ - if (rc < 0) { - discard = (keep == 0 || (keep == SET_AUTO && binary != XYFT_T)); - errpkt((CHAR *)"Error writing data"); /* If failure, */ - RESUME; - } else /* Data written OK, send ACK */ -#ifdef STREAMING - if (streaming) - fastack(); - else -#endif /* STREAMING */ - ack(); - } -} - break; -case 61: - { /* EOF immediately after A-Packet. */ - rf_err = "Can't create file"; - timint = s_timint; - if (discard) { /* Discarding a real file... */ - x = 1; - } else if (xflg) { /* If screen data */ - if (remfile) { /* redirected to file */ - if (rempipe) /* or pipe */ - x = openc(ZOFILE,remdest); /* Pipe: start command */ - else - x = opena(remdest,&iattr); /* File: open with attributes */ - } else { /* otherwise */ - x = opent(&iattr); /* "open" the screen */ - } -#ifdef CALIBRATE - } else if (calibrate) { /* If calibration run */ - x = ckopenx(&iattr); /* do this */ -#endif /* CALIBRATE */ - } else { /* otherwise */ - x = opena(filnam,&iattr); /* open the file, with attributes */ - if (x == -17) { /* REGET skipped because same size */ - discard = 1; - rejection = 1; - } - } - if (!x || reof(filnam, &iattr) < 0) { /* Close output file */ - errpkt((CHAR *) rf_err); /* If problem, send error msg */ - RESUME; /* and quit */ - } else { /* otherwise */ - if (x == -17) - xxscreen(SCR_ST,ST_SKIP,SKP_RES,""); - ack(); /* acknowledge the EOF packet */ - BEGIN rfile; /* and await another file */ - } -} - break; -case 62: - { /* Ctrl-C or connection loss. */ - timint = s_timint; - window(1); /* Set window size back to 1... */ - cxseen = 1; - x = clsof(1); /* Close file */ - return(success = 0); /* Failed */ -} - break; -case 63: - { /* End Of File (EOF) Packet */ -/* wslots = 1; */ /* (don't set) Window size back to 1 */ -#ifndef COHERENT /* Coherent compiler blows up on this switch() statement. */ - x = reof(filnam, &iattr); /* Handle the EOF packet */ - switch (x) { /* reof() sets the success flag */ - case -5: /* Handle problems */ - errpkt((CHAR *)"RENAME failed"); /* Fatal */ - RESUME; - break; - case -4: - errpkt((CHAR *)"MOVE failed"); /* Fatal */ - RESUME; - break; - case -3: /* If problem, send error msg */ - errpkt((CHAR *)"Can't print file"); /* Fatal */ - RESUME; - break; - case -2: - errpkt((CHAR *)"Can't mail file"); /* Fatal */ - RESUME; - break; - case 2: /* Not fatal */ - case 3: - xxscreen(SCR_EM,0,0L,"Receiver can't delete temp file"); - RESUME; - break; - default: - if (x < 0) { /* Fatal */ - errpkt((CHAR *)"Can't close file"); - RESUME; - } else { /* Success */ -#ifndef NOSPL - if (query) /* Query reponses generally */ - conoll(""); /* don't have line terminators */ -#endif /* NOSPL */ - if (czseen) { /* Batch canceled? */ - if (cancel++ == 0) { /* If we haven't tried this yet */ - ack1((CHAR *)"Z"); /* Try it once */ - } else { /* Otherwise */ - errpkt((CHAR *)"User canceled"); /* quite with Error */ - RESUME; - } - } else - ack(); /* Acknowledge the EOF packet */ - BEGIN rfile; /* and await another file */ - } - } -#else - if (reof(filnam, &iattr) < 0) { /* Close the file */ - errpkt((CHAR *)"Error at end of file"); - RESUME; - } else { /* reof() sets success flag */ - ack(); - BEGIN rfile; - } -#endif /* COHERENT */ -} - break; -case 64: - { /* ACK for Send-Init */ - spar(rdatap); /* set parameters from it */ - cancel = 0; - if (bctf) { - bctu = 3; - bctl = 3; - } else { - bctu = bctr; /* switch to agreed-upon block check */ - bctl = (bctu == 4) ? 2 : bctu; /* Set block-check length */ - } - -#ifdef CK_RESEND - if ((sendmode == SM_RESEND) && (!atcapu || !rscapu)) { /* RESEND */ - errpkt((CHAR *) "RESEND capabilities not negotiated"); - RESUME; - } else { -#endif /* CK_RESEND */ - what = W_SEND; /* Remember we're sending */ - lastxfer = W_SEND; - x = sfile(xflg); /* Send X or F header packet */ - cancel = 0; /* Reset cancellation counter */ - if (x) { /* If the packet was sent OK */ - if (!xflg && filcnt == 1) /* and it's a real file */ - crc16 = 0L; /* Clear the file CRC */ - resetc(); /* reset per-transaction counters */ - rtimer(); /* reset timers */ -#ifdef GFTIMER - rftimer(); -#endif /* GFTIMER */ - streamon(); /* turn on streaming */ -#ifdef IKSDB - if (ikdbopen) slotstate(what, - (server ? "SERVER" : ""), - "SEND", - filnam - ); -#endif /* IKSDB */ - BEGIN ssfile; /* and switch to receive-file state */ - } else { /* otherwise send error msg & quit */ - s = xflg ? "Can't execute command" : (char *)epktmsg; - if (!*s) s = "Can't open file"; - errpkt((CHAR *)s); - RESUME; - } -#ifdef CK_RESEND - } -#endif /* CK_RESEND */ -} - break; -case 65: - { /* R packet was retransmitted. */ - xsinit(); /* Resend packet 0 */ -} - break; -case 66: - { /* Same deal if G packet comes again */ - xsinit(); -} - break; -case 67: - { /* Same deal if C packet comes again */ - xsinit(); -} - break; -case 68: - { /* ACK for F or X packet */ - srvptr = srvcmd; /* Point to string buffer */ - decode(rdatap,putsrv,0); /* Decode data field, if any */ - putsrv(NUL); /* Terminate with null */ - ffc = 0L; /* Reset file byte counter */ - debug(F101,"Y cxseen","",cxseen); - if (*srvcmd) { /* If remote name was recorded */ - if (sendmode != SM_RESEND) { - if (fdispla == XYFD_C || fdispla == XYFD_S) - xxscreen(SCR_AN,0,0L,(char *)srvcmd); - tlog(F110," remote name:",(char *) srvcmd,0L); - makestr(&psrfspec,(char *)srvcmd); - } - } - if (cxseen||czseen) { /* Interrupted? */ - debug(F101,"Y canceling","",0); - x = clsif(); /* Close input file */ - sxeof(1); /* Send EOF(D) */ - BEGIN sseof; /* and switch to EOF state. */ - } else if (atcapu) { /* If attributes are to be used */ - if (sattr(xflg | stdinf, 1) < 0) { /* send them */ - errpkt((CHAR *)"Can't send attributes"); /* if problem, say so */ - RESUME; /* and quit */ - } else BEGIN ssattr; /* if ok, switch to attribute state */ - } else { /* Attributes not negotiated */ - if (window(wslotn) < 0) { /* Open window */ - errpkt((CHAR *)"Can't open window"); - RESUME; - } else if ((x = sdata()) == -2) { /* Send first data packet data */ - window(1); /* Connection lost, reset window */ - x = clsif(); /* Close input file */ - return(success = 0); /* Return failure */ - } else if (x == -9) { /* User interrupted */ - errpkt((CHAR *)"User cancelled"); /* Send Error packet */ - window(1); /* Set window size back to 1... */ - timint = s_timint; /* Restore timeout */ - return(success = 0); /* Failed */ - } else if (x < 0) { /* EOF (empty file) or interrupted */ - window(1); /* put window size back to 1, */ - debug(F101,"Y cxseen","",cxseen); - x = clsif(); /* If not ok, close input file, */ - if (x < 0) /* treating failure as interruption */ - cxseen = 1; /* Send EOF packet */ - seof(cxseen||czseen); - BEGIN sseof; /* and switch to EOF state. */ - } else { /* First data sent OK */ - BEGIN ssdata; /* All ok, switch to send-data state */ - } - } -} - break; -case 69: - { /* Got ACK to A packet */ - ffc = 0L; /* Reset file byte counter */ - debug(F101,"Y cxseen","",cxseen); - if (cxseen||czseen) { /* Interrupted? */ - debug(F101,"Y canceling","",0); - x = clsif(); /* Close input file */ - sxeof(1); /* Send EOF(D) */ - BEGIN sseof; /* and switch to EOF state. */ - } else if (rsattr(rdatap) < 0) { /* Was the file refused? */ - discard = 1; /* Set the discard flag */ - clsif(); /* Close the file */ - sxeof(1); /* send EOF with "discard" code */ - BEGIN sseof; /* switch to send-EOF state */ - } else if ((x = sattr(xflg | stdinf, 0)) < 0) { /* Send more? */ - errpkt((CHAR *)"Can't send attributes"); /* Trouble... */ - RESUME; - } else if (x == 0) { /* No more to send so now the data */ - if (window(wslotn) < 0) { /* Allocate negotiated window slots */ - errpkt((CHAR *)"Can't open window"); - RESUME; - } - if ((x = sdata()) == -2) { /* File accepted, send first data */ - window(1); /* Connection broken */ - x = clsif(); /* Close file */ - return(success = 0); /* Return failure */ - } else if (x == -9) { /* User interrupted */ - errpkt((CHAR *)"User cancelled"); /* Send Error packet */ - window(1); /* Set window size back to 1... */ - timint = s_timint; /* Restore timeout */ - return(success = 0); /* Failed */ - } else if (x < 0) { /* If data was not sent */ - window(1); /* put window size back to 1, */ - debug(F101,"Y cxseen","",cxseen); - if (clsif() < 0) /* Close input file */ - cxseen = 1; /* Send EOF packet */ - seof(cxseen||czseen); - BEGIN sseof; /* and switch to EOF state. */ - } else { - BEGIN ssdata; /* All ok, switch to send-data state */ - } - } -} - break; -case 70: - { /* Ctrl-C or connection loss. */ - window(1); /* Set window size back to 1... */ - cxseen = 1; /* To indicate interruption */ - x = clsif(); /* Close file */ - return(success = 0); /* Failed */ -} - break; -case 71: - { /* Got ACK to Data packet */ - canned(rdatap); /* Check if file transfer cancelled */ - debug(F111,"Y cxseen",rdatap,cxseen); - debug(F111,"Y czseen",rdatap,czseen); - if ((x = sdata()) == -2) { /* Try to send next data */ - window(1); /* Connection lost, reset window */ - x = clsif(); /* Close file */ - return(success = 0); /* Failed */ - } else if (x == -9) { /* User interrupted */ - errpkt((CHAR *)"User cancelled"); /* Send Error packet */ - window(1); /* Set window size back to 1... */ - timint = s_timint; /* Restore original timeout */ - return(success = 0); /* Failed */ - } else if (x < 0) { /* EOF - finished sending data */ - debug(F101,"Y cxseen","",cxseen); - window(1); /* Set window size back to 1... */ - if (clsif() < 0) /* Close input file */ - cxseen = 1; /* Send EOF packet */ - debug(F101,"Y CALLING SEOF()","",cxseen); - seof(cxseen||czseen); - BEGIN sseof; /* and enter send-eof state */ - } - /* NOTE: If x == 0 it means we're draining: see sdata()! */ -} - break; -case 72: - { /* Got ACK to EOF */ - int g, xdiscard; - canned(rdatap); /* Check if file transfer cancelled */ - debug(F111,"Y cxseen",rdatap,cxseen); - debug(F111,"Y czseen",rdatap,czseen); - debug(F111,"Y discard",rdatap,discard); - xdiscard = discard; - discard = 0; - success = (cxseen == 0 && czseen == 0); /* Transfer status... */ - debug(F101,"Y success","",success); - if (success && rejection > 0) /* If rejected, succeed if */ - if (rejection != '#' && /* reason was date */ - rejection != 1 && rejection != '?') /* or name; */ - success = 0; /* fail otherwise. */ - cxseen = 0; /* This goes back to zero. */ - if (success) { /* Only if transfer succeeded... */ - xxscreen(SCR_ST,ST_OK,0L,""); - if (!xdiscard) { - makestr(&sfspec,psfspec); /* Record filenames for WHERE */ - makestr(&srfspec,psrfspec); - } - if (moving) { /* If MOVE'ing */ - x = zdelet(filnam); /* Try to delete the source file */ -#ifdef TLOG - if (tralog) { - if (x > -1) { - tlog(F110," deleted",filnam,0); - } else { - tlog(F110," delete failed:",ck_errstr(),0); - } - } -#endif /* TLOG */ - } else if (snd_move) { /* Or move it */ - int x; - x = zrename(filnam,snd_move); -#ifdef TLOG - if (tralog) { - if (x > -1) { - tlog(F110," moved to ",snd_move,0); - } else { - tlog(F110," move failed:",ck_errstr(),0); - } - } -#endif /* TLOG */ - } else if (snd_rename) { /* Or rename it */ - char *s = snd_rename; /* Renaming string */ -#ifndef NOSPL - int y; /* Pass it thru the evaluator */ - extern int cmd_quoting; /* for \v(filename) */ - if (cmd_quoting) { /* But only if cmd_quoting is on */ - y = MAXRP; - s = (char *)srvcmd; - zzstring(snd_rename,&s,&y); - s = (char *)srvcmd; - } -#endif /* NOSPL */ - if (s) if (*s) { - int x; - x = zrename(filnam,s); -#ifdef TLOG - if (tralog) { - if (x > -1) { - tlog(F110," renamed to",s,0); - } else { - tlog(F110," rename failed:",ck_errstr(),0); - } - } -#endif /* TLOG */ -#ifdef COMMENT - *s = NUL; -#endif /* COMMENT */ - } - } - } - if (czseen) { /* Check group interruption flag */ - g = 0; /* No more files if interrupted */ - } else { /* Otherwise... */ -#ifdef COMMENT - /* This code makes any open error fatal to a file-group transfer. */ - g = gnfile(); - debug(F111,"Y gnfile",filnam,g); - if (g > 0) { /* Any more files to send? */ - if (sfile(xflg)) /* Yes, try to send next file header */ - BEGIN ssfile; /* if ok, enter send-file state */ - else { /* otherwise */ - s = xflg ? "Can't execute command" : (char *)epktmsg; - if (!*s) s = "Can't open file"; - errpkt((CHAR *)s); /* send error message */ - RESUME; /* and quit */ - } - } else { /* No next file */ - tsecs = gtimer(); /* get statistics timers */ -#ifdef GFTIMER - fptsecs = gftimer(); -#endif /* GFTIMER */ - seot(); /* send EOT packet */ - BEGIN sseot; /* enter send-eot state */ - } -#else /* COMMENT */ - while (1) { /* Keep trying... */ - g = gnfile(); /* Get next file */ - debug(F111,"Y gnfile",filnam,g); - if (g == 0 && gnferror == 0) /* No more, stop trying */ - break; - if (g > 0) { /* Have one */ - if (sfile(xflg)) { /* Try to open and send F packet */ - BEGIN ssfile; /* If OK, enter send-file state */ - break; /* and break out of loop. */ - } - } /* Otherwise keep trying to get one we can send... */ - } - } - if (g == 0) { - debug(F101,"Y no more files","",czseen); - tsecs = gtimer(); /* Get statistics timers */ -#ifdef GFTIMER - fptsecs = gftimer(); -#endif /* GFTIMER */ - seot(); /* Send EOT packet */ - BEGIN sseot; /* Enter send-eot state */ - } -#endif /* COMMENT */ -} - break; -case 73: - { /* Got ACK to EOT */ - debug(F101,"sseot justone","",justone); - RESUME; /* All done, just quit */ -} - break; -case 74: - { /* Got Error packet, in any state */ - char *s = ""; - window(1); /* Close window */ - timint = s_timint; /* Restore original timeout */ - if (*epktmsg) /* Message from Error packet */ - s = (char *)epktmsg; - if (!*s) { /* If not there then maybe here */ - s = (char *)rdatap; - ckstrncpy((char *)epktmsg,(char *)rdatap,PKTMSGLEN); - } - if (!*s) /* Hopefully we'll never see this. */ - s = "Unknown error"; - success = 0; /* For IF SUCCESS/FAIL. */ - debug(F101,"ckcpro.w justone at E pkt","",justone); - - success = 0; /* Transfer failed */ - xferstat = success; /* Remember transfer status */ - if (!epktsent) { - x = quiet; quiet = 1; /* Close files silently, */ - epktrcvd = 1; /* Prevent messages from clsof() */ - clsif(); - clsof(1); /* discarding any output file. */ - ermsg(s); /* Issue the message (calls screen). */ - quiet = x; /* Restore quiet state */ - } - tstats(); /* Get stats */ -/* - If we are executing commands from a command file or macro, let the command - file or macro decide whether to exit, based on SET { TAKE, MACRO } ERROR. -*/ - if ( -#ifndef NOICP - !xcmdsrc && -#endif /* NOICP */ - backgrd && !server) - fatal("Protocol error"); - xitsta |= (what & W_KERMIT); /* Save this for doexit(). */ -#ifdef CK_TMPDIR -/* If we were cd'd temporarily to another device or directory ... */ - if (f_tmpdir) { - int x; - x = zchdir((char *) savdir); /* ... restore previous directory */ - f_tmpdir = 0; /* and remember we did it. */ - debug(F111,"ckcpro.w E tmpdir restored",savdir,x); - } -#endif /* CK_TMPDIR */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"ERROR", (char *)epktmsg, ""); -#endif /* IKSDB */ - RESUME; -} - break; -case 75: - { success = 0; QUIT; } - break; -case 76: - { /* Anything not accounted for above */ - errpkt((CHAR *)"Unexpected packet type"); /* Give error message */ - window(1); - xitsta |= (what & W_KERMIT); /* Save this for doexit(). */ - RESUME; /* and quit */ -} - break; - - } - } -} - -char tbl[] = { - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 15, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 13, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 59, 76, 76, 74, 55, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 56, 76, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 57, 76, 76, 58, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 61, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 60, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 63, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 62, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 67, 76, 74, 76, 66, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 65, 76, 76, 76, 76, 76, 76, 64, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 68, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 69, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 71, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 70, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 72, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 73, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 26, 29, 29, 29, 25, 19, 17, 22, 29, 29, 29, 28, 23, - 29, 29, 18, 12, 29, 29, 20, 21, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 11, 29, 7, 29, 29, 29, 9, 4, 29, 5, 8, 29, 29, 29, 6, - 29, 27, 3, 1, 29, 29, 2, 29, 10, 29, 29, 29, 29, 29, 29, 29, - -1, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 33, 52, 31, 34, 35, 36, 52, 39, 30, 52, 42, 38, 50, 52, 52, - 52, 40, 41, 43, 44, 47, 49, 48, 37, 52, 52, 52, 52, 52, 52, 52, - 52, 11, 52, 7, 46, 52, 52, 9, 4, 52, 5, 8, 52, 45, 52, 6, - 52, 51, 3, 1, 52, 32, 2, 52, 10, 52, 52, 52, 52, 52, 52, 52, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 76, 76, 76, 17, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 12, 76, 76, 76, 76, 76, 16, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 55, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 12, 76, 76, 76, 76, 56, 54, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 53, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - -1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 14, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76, 76, - 0, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 24, - 76, 76, 76, 12, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 11, 76, 7, 76, 76, 76, 9, 4, 76, 5, 8, 76, 76, 76, 6, - 76, 75, 3, 1, 76, 76, 2, 76, 10, 76, 76, 76, 76, 76, 76,76 -}; - - -/* - From here down to proto() are routines that were moved out of the state - table switcher because the resulting switch() had become too large. - To move the contents of a state-table case to a routine: - 1. Add a prototype to the list above the state table switcher. - 2. Make a routine with an appropriate name, returning int. - 3. Move the code into it. - 4. Put a call to the new routine in the former spot: - rc = name_of_routine(); - if (rc > -1) return(rc); - 5. Add "return(-1);" after every RESUME, SERVE, or BEGIN macro and - at the end if the code is open-ended. -*/ -static int -rcv_firstdata() { - extern int dispos; - debug(F101,"rcv_firstdata","",dispos); - - if (discard) { /* if we're discarding the file */ - ack1((CHAR *)"X"); /* just ack the data like this. */ - cancel++; /* and count it */ - BEGIN rdpkt; /* and wait for more data packets. */ - return(-1); - } else { /* Not discarding. */ - rf_err = "Can't open file"; - if (xflg) { /* If screen data */ - if (remfile) { /* redirected to file */ - if (rempipe) /* or pipe */ - x = openc(ZOFILE,remdest); /* Pipe: start command */ - else - x = opena(remdest,&iattr); /* File: open with attributes */ - } else { /* otherwise */ - x = opent(&iattr); /* "open" the screen */ - } - } else { /* otherwise */ -#ifdef CALIBRATE - if (calibrate) { /* If calibration run */ - x = ckopenx(&iattr); /* open nothing */ -#ifdef STREAMING - if (streaming) /* Streaming */ - fastack(); /* ACK without ACKing. */ - else -#endif /* STREAMING */ - ack(); /* Send real ACK */ - BEGIN rdpkt; /* Proceed to next state */ - return(-1); - } else -#endif /* CALIBRATE */ -#ifdef UNIX -/* - In UNIX we can pipe the file data into the mail program, which is to be - preferred to writing it out to a temp file and then mailing it afterwards. - This depends rather heavily on all UNIXes having a mail command that - accepts '-s "subject"' on the command line. MAILCMD (e.g. mail, Mail, mailx) - is defined in ckufio.c. -*/ - if (dispos == 'M') { /* Mail... */ - char *s; - char * tmp = NULL; - int n = 0; - extern char *MAILCMD; - s = iattr.disp.val + 1; - n = (int)strlen(MAILCMD) + /* Mail command */ - (int)strlen(s) + /* address */ - (int)strlen(ofilnam) + 32; /* subject */ - if ((tmp = (char *)malloc(n))) { - ckmakxmsg(tmp,n, - MAILCMD," -s \"",ofilnam,"\" ",s, - NULL,NULL,NULL,NULL,NULL,NULL,NULL); - debug(F111,"rcv_firsdata mail",tmp,(int)strlen(tmp)); - x = openc(ZOFILE,(char *)tmp); - free(tmp); - } else - x = 0; - } else if (dispos == 'P') { /* Ditto for print */ - char * tmp = NULL; - int n; - extern char *PRINTCMD; - n = (int)strlen(PRINTCMD) + (int)strlen(iattr.disp.val+1) + 4; - if ((tmp = (char *)malloc(n))) { - sprintf(tmp, /* safe (prechecked) */ - "%s %s", PRINTCMD, iattr.disp.val + 1); - x = openc(ZOFILE,(char *)tmp); - free(tmp); - } else - x = 0; - } else -#endif /* UNIX */ - x = opena(filnam,&iattr); /* open the file, with attributes */ - } - if (x) { /* If file was opened ok */ - int rc, qf; -#ifndef NOSPL - qf = query; -#else - qf = 0; -#endif /* NOSPL */ - -#ifdef CKTUNING - rc = (binary && !parity) ? - bdecode(rdatap,putfil): - decode(rdatap, qf ? puttrm : putfil, 1); -#else - rc = decode(rdatap, qf ? puttrm : putfil, 1); -#endif /* CKTUNING */ - if (rc < 0) { - errpkt((CHAR *)"Error writing data"); - RESUME; - return(-1); - } -#ifdef STREAMING - if (streaming) /* Streaming was negotiated */ - fastack(); /* ACK without ACKing. */ - else -#endif /* STREAMING */ - ack(); /* acknowledge it */ - BEGIN rdpkt; /* and switch to receive-data state */ - return(-1); - } else { /* otherwise */ - errpkt((CHAR *) rf_err); /* send error packet */ - RESUME; /* and quit. */ - return(-1); - } - } -} - -static int -rcv_shortreply() { -#ifdef PKTZEROHACK - success = 0; - debug(F111,"rcv_shortreply",rdatap,ipktlen); - if (ipktack[0] && !strncmp(ipktack,(char *)rdatap,ipktlen)) { - /* No it's the ACK to the I packet again */ - x = scmd(vcmd,(CHAR *)cmarg); /* So send the REMOTE command again */ - /* Maybe this should be resend() */ - debug(F110,"IPKTZEROHACK",ipktack,x); - if (x < 0) { - errpkt((CHAR *)srimsg); - RESUME; - return(-1); - } - } else { - ipktack[0] = NUL; -#endif /* PKTZEROHACK */ - urserver = 1; -#ifndef NOSERVER -#ifndef NOSPL - if (query) { /* If to query, */ - qbufp = querybuf; /* initialize query response buffer */ - qbufn = 0; - querybuf[0] = NUL; - } -#endif /* NOSPL */ - x = 1; - if (remfile) { /* Response redirected to file */ - rf_err = "Can't open file"; - if (rempipe) /* or pipe */ - x = -#ifndef NOPUSH - zxcmd(ZOFILE,remdest) /* Pipe: Start command */ -#else - 0 -#endif /* NOPUSH */ - ; - else - x = opena(remdest,&iattr); /* File: Open with attributes */ - debug(F111,"rcv_shortreply remfile",remdest,x); - } else { - x = opent(&iattr); /* "open" the screen */ - } - if (x) { /* If file was opened ok */ - if (decode(rdatap, -#ifndef NOSPL - (query || !remfile) ? puttrm : -#else - !remfile ? puttrm : -#endif /* NOSPL */ - zputfil, 1) < 0) { /* Note: zputfil, not putfil. */ - errpkt((CHAR *)"Error writing data"); - RESUME; - return(-1); - } else { - if (rdatap) { /* If we had data */ - if (*rdatap) { /* add a line terminator */ - if (remfile) { /* to file */ - zsoutl(ZOFILE,""); - } else { /* or to screen. */ -#ifndef NOICP - if (!query || !xcmdsrc) -#endif /* NOICP */ - if (!(quiet && rcdactive)) - conoll(""); - } - } - } - if (bye_active && network) { /* I sent BYE or REMOTE LOGOUT */ - msleep(500); /* command and got the ACK... */ - bye_active = 0; - ttclos(0); - } - clsof(0); - if (!epktsent && !epktrcvd) /* If no error packet... */ - success = 1; /* success. */ - RESUME; - return(-1); - } - } else { /* File not opened OK */ - errpkt((CHAR *) rf_err); /* send error message */ - RESUME; /* and quit. */ - return(-1); - } -#endif /* NOSERVER */ -#ifdef PKTZEROHACK - } -#endif /* PKTZEROHACK */ - debug(F101,"rcv_shortreply fallthru","",success); - return(-1); -} - - -static int -srv_query() { -#ifndef NOSERVER -#ifndef NOSPL - char c; -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE QUERY", (char *)srvcmd); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE QUERY", (char *)(srvcmd+2), ""); -#endif /* IKSDB */ - c = *(srvcmd+2); /* Q = Query, S = Set */ - if (c == 'Q') { /* Query */ - if (!ENABLED(en_que)) { /* Security */ - errpkt((CHAR *)"REMOTE QUERY disabled"); - RESUME; - return(-1); - } else { /* Query allowed */ - int n; char *p, *q; - qbufp = querybuf; /* Wipe out old stuff */ - qbufn = 0; - querybuf[0] = NUL; - p = (char *) srvcmd + 3; /* Pointer for making wrapper */ - n = strlen((char *)srvcmd); /* Position of end */ - c = *(srvcmd+4); /* Which type of variable */ - - if (*(srvcmd+6) == CMDQ) { /* Starts with command quote? */ - p = (char *) srvcmd + 6; /* Take it literally */ - if (*p == CMDQ) p++; - } else { /* They played by the rules */ - if (c == 'K') { /* Kermit variable */ - int k; - k = (int) strlen(p); - if (k > 0 && p[k-1] == ')') { - p = (char *)(srvcmd + 4); - *(srvcmd+4) = CMDQ; - *(srvcmd+5) = 'f'; /* Function, so make it \f...() */ - } else { - *(srvcmd+3) = CMDQ; /* Stuff wrapping into buffer */ - *(srvcmd+4) = 'v'; /* Variable, so make it \v(...) */ - *(srvcmd+5) = '('; /* around variable name */ - *(srvcmd+n) = ')'; - *(srvcmd+n+1) = NUL; - } - } else { - *(srvcmd+3) = CMDQ; /* Stuff wrapping into buffer */ - *(srvcmd+4) = 'v'; /* Variable, so make it \v(...) */ - *(srvcmd+5) = '('; /* around variable name */ - *(srvcmd+n) = ')'; - *(srvcmd+n+1) = NUL; - if (c == 'S') { /* System variable */ - *(srvcmd+4) = '$'; /* so it's \$(...) */ - } else if (c == 'G') { /* Non-\ Global variable */ - *(srvcmd+4) = 'm'; /* so wrap it in \m(...) */ - } - } - } /* Now evaluate it */ - n = QBUFL; /* Max length */ - q = querybuf; /* Where to put it */ - if (zzstring(p,&q,&n) < 0) { - errpkt((n > 0) ? (CHAR *)"Can't get value" - : (CHAR *)"Value too long" - ); - RESUME; - return(-1); - } else { - if (encstr((CHAR *)querybuf) > -1) { /* Encode it */ - ack1(data); /* If it fits, send it back in ACK */ - success = 1; - RESUME; - return(-1); - } else if (sndstring(querybuf)) { /* Long form response */ - BEGIN ssinit; - return(-1); - } else { /* sndhlp() fails */ - errpkt((CHAR *)"Can't send value"); - RESUME; - return(-1); - } - } - } - } else if (c == 'S') { /* Set (assign) */ - if (!ENABLED(en_asg)) { /* Security */ - errpkt((CHAR *)"REMOTE ASSIGN disabled"); - RESUME; - return(-1); - } else { /* OK */ - int n; - n = xunchar(*(srvcmd+3)); /* Length of name */ - n = 3 + n + 1; /* Position of length of value */ - *(srvcmd+n) = NUL; /* Don't need it */ - if (addmac((char *)(srvcmd+4),(char *)(srvcmd+n+1)) < 0) - errpkt((CHAR *)"REMOTE ASSIGN failed"); - else { - ack(); - success = 1; - } - RESUME; - return(-1); - } - } else { - errpkt((CHAR *)"Badly formed server command"); - RESUME; - return(-1); - } -#else - errpkt((CHAR *)"Variable query/set not available"); - RESUME; - return(-1); -#endif /* NOSPL */ -#endif /* NOSERVER */ -} - -static int -srv_copy() { -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE COPY", (char *)srvcmd); -#endif /* CKSYSLOG */ -#ifdef ZCOPY - if (!ENABLED(en_cpy)) { - errpkt((CHAR *)"REMOTE COPY disabled"); - RESUME; - return(-1); - } else { - char *str1, *str2, f1[256], f2[256]; - int len1, len2; - len1 = xunchar(srvcmd[1]); /* Separate the parameters */ - len2 = xunchar(srvcmd[2+len1]); - strncpy(f1,(char *)(srvcmd+2),len1); - f1[len1] = NUL; - strncpy(f2,(char *)(srvcmd+3+len1),len2); - f2[len2] = NUL; -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE COPY", f1, f2); -#endif /* IKSDB */ - if (!ENABLED(en_cwd)) { /* If CWD is disabled */ - zstrip(f1,&str1); /* and they included a pathname, */ - zstrip(f2,&str2); - if (strcmp(f1,str1) || strcmp(f2,str2)) { /* Refuse. */ - errpkt((CHAR *)"Access denied"); - RESUME; /* Remember, this is not a goto! */ - return(-1); - } - } - if (state == generic) { /* It's OK to go ahead. */ - if (zcopy(f1,f2)) { /* Try */ - errpkt((CHAR *)"Can't copy file"); /* give error message */ - } else { - success = 1; - ack(); - } - RESUME; /* wait for next server command */ - return(-1); - } - } - return(-1); -#else /* no ZCOPY */ - errpkt((CHAR *)"REMOTE COPY not available"); /* give error message */ - RESUME; /* wait for next server command */ - return(-1); -#endif /* ZCOPY */ -#endif /* NOSERVER */ -} - -static int -srv_rename() { -#ifndef NOSERVER -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE RENAME", (char *)srvcmd); -#endif /* CKSYSLOG */ -#ifdef ZRENAME - if (!ENABLED(en_ren)) { - errpkt((CHAR *)"REMOTE RENAME disabled"); - RESUME; - return(-1); - } else { /* RENAME is enabled */ - char *str1, *str2, f1[256], f2[256]; - int len1, len2; - len1 = xunchar(srvcmd[1]); /* Separate the parameters */ - len2 = xunchar(srvcmd[2+len1]); - strncpy(f1,(char *)(srvcmd+2),len1); - f1[len1] = NUL; - strncpy(f2,(char *)(srvcmd+3+len1),len2); - f2[len2] = NUL; - len2 = xunchar(srvcmd[2+len1]); - strncpy(f1,(char *)(srvcmd+2),len1); - f1[len1] = NUL; - strncpy(f2,(char *)(srvcmd+3+len1),len2); - f2[len2] = NUL; -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE RENAME", f1, f2); -#endif /* IKSDB */ - if (!ENABLED(en_cwd)) { /* If CWD is disabled */ - zstrip(f1,&str1); /* and they included a pathname, */ - zstrip(f2,&str2); - if ( strcmp(f1,str1) || strcmp(f2,str2) ) { /* refuse. */ - errpkt((CHAR *)"Access denied"); - RESUME; /* Remember, this is not a goto! */ - return(-1); - } - } - if (state == generic) { /* It's OK to go ahead. */ - if (zrename(f1,f2)) { /* Try */ - errpkt((CHAR *)"Can't rename file"); /* Give error msg */ - } else { - success = 1; - ack(); - } - RESUME; /* Wait for next server command */ - return(-1); - } - } - return(-1); -#else /* no ZRENAME */ - /* Give error message */ - errpkt((CHAR *)"REMOTE RENAME not available"); - RESUME; /* Wait for next server command */ - return(-1); -#endif /* ZRENAME */ -#endif /* NOSERVER */ -} - -static int -srv_login() { -#ifndef NOSERVER - char f1[LOGINLEN+1], f2[LOGINLEN+1], f3[LOGINLEN+1]; - CHAR *p; - int len, i; - - debug(F101,"REMOTE LOGIN x_login","",x_login); - debug(F101,"REMOTE LOGIN x_logged","",x_logged); - - f1[0] = NUL; f2[0] = NUL; f3[0] = NUL; - len = 0; - if (srvcmd[1]) /* First length field */ - len = xunchar(srvcmd[1]); /* Separate the parameters */ - - if (x_login) { /* Login required */ - if (x_logged) { /* And already logged in */ - if (len > 0) { /* Logging in again */ - errpkt((CHAR *)"Already logged in."); - } else { /* Logging out */ - debug(F101,"REMOTE LOGOUT","",x_logged); -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE LOGOUT", NULL); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"REMOTE LOGOUT", "", ""); -#endif /* IKSDB */ - tlog(F110,"Logged out",x_user,0); - ack1((CHAR *)"Logged out"); - success = 1; - msleep(500); -#ifdef CK_LOGIN - x_logged = 0; -#ifdef IKSD - if (inserver) - ckxlogout(); -#endif /* IKSD */ -#endif /* CK_LOGIN */ - } - } else { /* Not logged in yet */ - debug(F101,"REMOTE LOGIN len","",len); - if (len > 0) { /* Have username */ -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "REMOTE LOGIN", NULL); -#endif /* CKSYSLOG */ - if (len > LOGINLEN) { - errpkt((CHAR *)"Username too long"); - } - p = srvcmd + 2; /* Point to it */ - for (i = 0; i < len; i++) /* Copy it */ - f1[i] = p[i]; - f1[len] = NUL; /* Terminate it */ - p += len; /* Point to next length field */ - if (*p) { /* If we have one */ - len = xunchar(*p++); /* decode it */ - if (len > 0 && len <= LOGINLEN) { - for (i = 0; i < len; i++) /* Same deal for password */ - f2[i] = p[i]; - f2[len] = NUL; - p += len; /* And account */ - if (*p) { - len = xunchar(*p++); - if (len > 0 && len <= LOGINLEN) { - for (i = 0; i < len; i++) - f3[i] = p[i]; /* Set but never used */ - f3[len] = NUL; /* (because account not used) */ - } - } - } - } - debug(F101,"REMOTE LOGIN 1","",x_logged); -#ifdef IKSD -#ifdef CK_LOGIN - if (inserver) { /* Log in to system for real */ - x_logged = ckxlogin((CHAR *)f1,(CHAR *)f2,NULL,0); - debug(F101,"REMOTE LOGIN 2","",x_logged); - if (x_logged) { /* Count attempts */ - logtries = 0; - justone = 1; - } else { - logtries++; - sleep(logtries); - } - } else -#endif /* CK_LOGIN */ -#endif /* IKSD */ - if (x_user && x_passwd) { /* User and password must match */ - if (!strcmp(x_user,f1)) /* SET SERVER LOGIN */ - if (!strcmp(x_passwd,f2)) - x_logged = 1; - debug(F101,"REMOTE LOGIN 3","",x_logged); - } else if (x_user) { /* Only username given, no password */ - if (!strcmp(x_user,f1)) /* so only username must match */ - x_logged = 1; - debug(F101,"REMOTE LOGIN 4","",x_logged); - } -#ifdef CK_LOGIN - else { - x_logged = ckxlogin((CHAR *)f1,(CHAR *)f2,NULL,0); - debug(F101,"REMOTE LOGIN 5","",x_logged); - } -#endif /* CK_LOGIN */ - if (x_logged) { /* Logged in? */ - tlog(F110,"Logged in", x_user, 0); - if (isguest) - ack1((CHAR *)"Logged in as guest - restrictions apply"); - else - ack1((CHAR *)"Logged in"); - success = 1; - } else { - tlog(F110,"Login failed", f1, 0); - errpkt((CHAR *)"Access denied."); -#ifdef IKSD -#ifdef CK_LOGIN - if (inserver && logtries > 2) - ckxlogout(); -#endif /* CK_LOGIN */ -#endif /* IKSD */ - } - } else { /* LOGOUT */ - errpkt((CHAR *)"Logout ignored"); - } - } - } else { /* Login not required */ - if (len > 0) - errpkt((CHAR *)"Login ignored."); - else - errpkt((CHAR *)"Logout ignored."); - } -#endif /* NOSERVER */ - RESUME; - return(-1); -} - -static int -srv_timeout() { - /* K95 does this its own way */ - if (idletmo) { -#ifdef IKSD - if (inserver) { - printf("\r\nIKSD IDLE TIMEOUT: %d sec\r\n", srvidl); - doexit(GOOD_EXIT,xitsta); - } -#endif /* IKSD */ - idletmo = 0; - printf("\r\nSERVER IDLE TIMEOUT: %d sec\r\n", srvidl); - xitsta |= (what & W_KERMIT); - QUIT; - } -#ifndef NOSERVER - else if (fatalio) { /* Connection lost */ -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "Connection lost", NULL); -#endif /* CKSYSLOG */ -#ifdef IKSDB - if (ikdbopen) slotstate(what,"SERVER DISCONNECT",(char *)srvcmd, ""); -#endif /* IKSDB */ - xitsta |= what; - QUIT; - } else if (interrupted) { /* Interrupted by hand */ - if (!ENABLED(en_fin)) { - errpkt((CHAR *)"QUIT disabled"); - RESUME; - return(-1); - } else { - if (what == W_SEND || what == W_RECV || what == W_REMO) { - success = 0; -#ifdef CKSYSLOG - if (ckxsyslog >= SYSLG_PR && ckxlogging) - cksyslog(SYSLG_PR, 1, "server", "Interrupted", NULL); -#endif /* CKSYSLOG */ - } else if (what == W_NOTHING && filcnt == 0) { - success = 1; - } /* Otherwise leave success alone */ - xitsta |= (what & W_KERMIT); - QUIT; - } - } else { /* Shouldn't happen */ - debug(F100,"SERVER (top) GOT UNEXPECTED 'q'","",0); - QUIT; - } -#endif /* NOSERVER */ -} - -static int -rcv_s_pkt() { -#ifndef NOSERVER - if (state == rgen) - urserver = 1; - if (/* state == serve && */ x_login && !x_logged) { - errpkt((CHAR *)"Login required"); - SERVE; - } else -#endif /* NOSERVER */ - if (state == serve && !ENABLED(en_sen)) { /* Not in server mode */ - errpkt((CHAR *)"SEND disabled"); /* when SEND is disabled. */ - RESUME; - return(-1); - } else { /* OK to go ahead. */ -#ifdef CK_TMPDIR - if (dldir && !f_tmpdir) { /* If they have a download directory */ - debug(F110,"receive download dir",dldir,0); - if ((s = zgtdir())) { /* Get current directory */ - debug(F110,"receive current dir",s,0); - if (zchdir(dldir)) { /* Change to download directory */ - debug(F100,"receive zchdir ok","",0); - ckstrncpy(savdir,s,TMPDIRLEN); - f_tmpdir = 1; /* Remember that we did this */ - } else - debug(F100,"receive zchdir failed","",0); - } - } -#endif /* CK_TMPDIR */ - nakstate = 1; /* Can send NAKs from here. */ - rinit(rdatap); /* Set parameters */ - if (bctf) { - bctu = 3; - bctl = 3; - } else { - bctu = bctr; /* switch to agreed-upon block check */ - bctl = (bctu == 4) ? 2 : bctu; /* Set block-check length */ - } - what = W_RECV; /* Remember we're receiving */ - lastxfer = W_RECV; - resetc(); /* Reset counters */ - rtimer(); /* Reset timer */ -#ifdef GFTIMER - rftimer(); -#endif /* GFTIMER */ - streamon(); - BEGIN rfile; /* Go into receive-file state */ - } - return(-1); -} - - -/* END OF ROUTINES MOVED OUT OF STATE MACHINE */ - - -/* P R O T O -- Protocol entry function */ - -static int is_tn = 0; /* It's a Telnet connection */ - -#ifdef CK_SPEED -int f_ctlp = 0; /* Control-character prefix table */ -#ifdef COMMENT -short s_ctlp[256]; -#endif /* COMMENT */ -#endif /* CK_SPEED */ - -/* - This is simply a wrapper for the real protocol function just below, - that saves any items that might be changed automatically by protocol - negotiations and then restores them upon exit from protocol mode. -*/ -VOID -proto() { - extern int b_save, f_save, c_save, ss_save, slostart, reliable, urclear; -#ifndef NOCSETS - extern int fcharset, fcs_save, tcharset, tcs_save; -#endif /* NOCSETS */ - -#ifdef PIPESEND - extern int pipesend; -#endif /* PIPESEND */ -#ifndef NOLOCAL -#ifdef OS2 - extern int cursorena[], cursor_save, term_io; - extern BYTE vmode; - int term_io_save; -#endif /* OS2 */ -#endif /* NOLOCAL */ -#ifdef TNCODE - int _u_bin=0, _me_bin = 0; -#ifdef IKS_OPTION - int /* _u_start=0, */ _me_start = 0; -#endif /* IKS_OPTION */ -#endif /* TNCODE */ -#ifdef PATTERNS - int pa_save; - int i; -#endif /* PATTERNS */ - int scan_save; - -#ifdef PATTERNS - pa_save = patterns; -#endif /* PATTERNS */ - scan_save = filepeek; - - myjob = sstate; - -#ifdef CK_LOGIN - if (isguest) { /* If user is anonymous */ - en_pri = 0; /* disable printing */ - en_mai = 0; /* and disable email */ - en_del = 0; /* and file deletion */ - } -#endif /* CK_LOGIN */ - -#ifndef NOLOCAL -#ifdef OS2 - cursor_save = cursorena[vmode]; - cursorena[vmode] = 0; - term_io_save = term_io; - term_io = 0; -#endif /* OS2 */ -#endif /* NOLOCAL */ - b_save = binary; /* SET FILE TYPE */ - f_save = fncnv; /* SET FILE NAMES */ - c_save = bctr; - p_save = fnspath; - r_save = recursive; - s_timint = timint; - ss_save = slostart; -#ifndef NOCSETS - fcs_save = fcharset; - tcs_save = tcharset; -#endif /* NOCSETS */ - -#ifdef COMMENT -/* Don't do this because then user can never find out what happened. */ -#ifdef CK_SPEED - for (i = 0; i < 256; i++) - s_ctlp[i] = ctlp[i]; - f_ctlp = 1; -#endif /* CK_SPEED */ -#endif /* COMMENT */ - if (reliable == SET_ON) - slostart = 0; - is_tn = (!local && sstelnet) -#ifdef TNCODE - || (local && network && ttnproto == NP_TELNET) -#endif /* TNCODE */ - ; -#ifdef TNCODE - if (is_tn) { - if (tn_b_xfer && !(sstelnet || inserver)) { - /* Save the current state of Telnet Binary */ - _u_bin = TELOPT_U(TELOPT_BINARY); - _me_bin = TELOPT_ME(TELOPT_BINARY); - - /* If either direction is not Binary attempt to negotiate it */ - if (!_u_bin && TELOPT_U_MODE(TELOPT_BINARY) != TN_NG_RF) { - tn_sopt(DO,TELOPT_BINARY); - TELOPT_UNANSWERED_DO(TELOPT_BINARY) = 1; - } - if (!_me_bin && TELOPT_ME_MODE(TELOPT_BINARY) != TN_NG_RF) { - tn_sopt(WILL,TELOPT_BINARY); - TELOPT_UNANSWERED_WILL(TELOPT_BINARY) = 1; - } - if (!(_me_bin && _u_bin)) - tn_wait("proto set binary mode"); - } -#ifdef IKS_OPTION -#ifdef CK_XYZ - if (protocol != PROTO_K) { /* Non-Kermit protocol selected */ - if (TELOPT_U(TELOPT_KERMIT) && - TELOPT_SB(TELOPT_KERMIT).kermit.u_start) { - iks_wait(KERMIT_REQ_STOP,0); /* Stop the other Server */ - /* _u_start = 1; */ - } - if (TELOPT_ME(TELOPT_KERMIT) && - TELOPT_SB(TELOPT_KERMIT).kermit.me_start) { - tn_siks(KERMIT_STOP); /* I'm not servering */ - TELOPT_SB(TELOPT_KERMIT).kermit.me_start = 0; - _me_start = 1; - } - } else -#endif /* CK_XYZ */ - if (sstate == 'x' || sstate == 'v') { /* Responding to a request */ - if (!inserver && TELOPT_U(TELOPT_KERMIT) && - TELOPT_SB(TELOPT_KERMIT).kermit.u_start) { - iks_wait(KERMIT_REQ_STOP,0); /* Stop the other Server */ - /* _u_start = 1; */ - } - if (TELOPT_ME(TELOPT_KERMIT) && - !TELOPT_SB(TELOPT_KERMIT).kermit.me_start) { - tn_siks(KERMIT_START); /* Send Kermit-Server Start */ - TELOPT_SB(TELOPT_KERMIT).kermit.me_start = 1; - } - } else { /* Initiating a request */ - if (TELOPT_ME(TELOPT_KERMIT) && - TELOPT_SB(TELOPT_KERMIT).kermit.me_start) { - tn_siks(KERMIT_STOP); /* I'm not servering */ - TELOPT_SB(TELOPT_KERMIT).kermit.me_start = 0; - _me_start = 1; - } - if (TELOPT_U(TELOPT_KERMIT) && - !TELOPT_SB(TELOPT_KERMIT).kermit.u_start) { - /* Send Req-Server-Start */ - if (!iks_wait(KERMIT_REQ_START,0)) { - if (sstate != 's') { - success = 0; /* Other Kermit refused to serve */ - if (local) - printf("A Kermit Server is not available\r\n"); - debug(F110,"proto()", - "A Kermit Server is not available",0); - tlog(F110,"IKS client/server failure", - "A Kermit Server is not available",0); - goto xxprotox; - } - } - } - } -#endif /* IKS_OPTION */ -#ifdef CK_ENCRYPTION - if (tn_no_encrypt_xfer && !(sstelnet || inserver)) { - ck_tn_enc_stop(); /* fdc 2021-12-17 */ - } -#endif /* CK_ENCRYPTION */ - } -#endif /* TNCODE */ - - if (!xfrint) connoi(); - xxproto(); /* Call the real protocol function */ - -#ifdef IKS_OPTION - xxprotox: -#endif /* IKS_OPTION */ - xferstat = success; /* Remember transfer status */ - kactive = 0; - -#ifdef TNCODE -#ifdef CK_ENCRYPTION - if (tn_no_encrypt_xfer && !(sstelnet || inserver)) { - ck_tn_enc_start(); /* fdc 2021-12-17 */ - } -#endif /* CK_ENCRYPTION */ -#ifdef IKS_OPTION - if (TELOPT_ME(TELOPT_KERMIT) && - TELOPT_SB(TELOPT_KERMIT).kermit.me_start && !_me_start) { - tn_siks(KERMIT_STOP); /* Server is stopped */ - TELOPT_SB(TELOPT_KERMIT).kermit.me_start = 0; - } -#endif /* IKS_OPTION */ - if (is_tn && tn_b_xfer && !(sstelnet || inserver)) { - /* if we negotiated Binary mode try to reset it */ - if (!_u_bin) { - /* Check to see if the state changed during the transfer */ - if (TELOPT_U(TELOPT_BINARY)) { - tn_sopt(DONT,TELOPT_BINARY); - TELOPT_UNANSWERED_DONT(TELOPT_BINARY) = 1; - } else - _u_bin = 1; /* So we don't call tn_wait() */ - } - if (!_me_bin) { - /* Check to see if the state changed during the transfer */ - if (TELOPT_ME(TELOPT_BINARY)) { - tn_sopt(WONT,TELOPT_BINARY); - TELOPT_UNANSWERED_WONT(TELOPT_BINARY) = 1; - } else - _me_bin = 1; /* So we don't call tn_wait() */ - } - if (!(_me_bin && _u_bin)) - tn_wait("proto reset binary mode"); - } -#endif /* TNCODE */ - -#ifdef PATTERNS - patterns = pa_save; -#endif /* PATTERNS */ - filepeek = scan_save; - -#ifdef STREAMING - streaming = 0; - /* streamok = 0; */ -#endif /* STREAMING */ -#ifdef COMMENT -#ifdef CK_SPEED - for (i = 0; i < 256; i++) - ctlp[i] = s_ctlp[i]; - f_ctlp = 0; -#endif /* CK_SPEED */ -#endif /* COMMENT */ - urclear = 0; - if (!success) { - xitsta |= (what & W_KERMIT); - tlog(F110," failed:",(char *)epktmsg,0); - } - debug(F111,"proto xferstat",epktmsg,xferstat); - slostart = ss_save; - if (s_timint > -1) { /* Because of REMOTE SET */ - timint = s_timint; - s_timint = -1; - } - recursive = r_save; - fnspath = p_save; - if (c_save > -1) { /* Because of REMOTE SET */ - bctr = c_save; - c_save = -1; - } - fncnv = f_save; - binary = b_save; -#ifdef PIPESEND - pipesend = 0; /* Next time might not be pipesend */ -#endif /* PIPESEND */ -#ifndef NOLOCAL -#ifdef OS2 - cursorena[vmode] = cursor_save; - term_io = term_io_save; -#endif /* OS2 */ -#endif /* NOLOCAL */ -} - -static VOID -xxproto() { - int x; - long lx; -#ifdef CK_XYZ -#ifdef XYZ_INTERNAL -_PROTOTYP( int pxyz, (int) ); -#endif /* XYZ_INTERNAL */ -#endif /* CK_XYZ */ - - char xss[2]; /* String representation of sstate */ - xss[0] = sstate; - xss[1] = NUL; - s_timint = timint; - - debug(F101,"xxproto entry justone","",justone); - success = 0; - - retrieve = 0; /* Reset these ... */ - reget = 0; - opkt = 0; - - if (local && ttchk() < 0) { /* Giving BYE or FIN */ - if (bye_active) { /* but there is no connection */ - ttclos(0); - success = 1; - return; - } - /* Ditto for any REMOTE command */ - if (sstate == 'g' && cmarg ) { - if (*cmarg == 'L' || *cmarg == 'F' || *cmarg == 'X') - success = 1; - else - printf("?No connection\r\n"); - return; - } - } - -/* Set up the communication line for file transfer. */ -/* NOTE: All of the xxscreen() calls prior to the wart() invocation */ -/* could just as easily be printf's or, for that matter, hints. */ - - if (local && (speed < 0L) && (network == 0)) { - xxscreen(SCR_EM,0,0L,"Sorry, you must 'set speed' first"); - return; - } - x = -1; - if (ttopen(ttname,&x,mdmtyp,cdtimo) < 0) { - debug(F111,"failed: proto ttopen local",ttname,local); - xxscreen(SCR_EM,0,0L,"Can't open line"); - return; - } - if (x > -1) local = x; - debug(F111,"proto ttopen local",ttname,local); - - lx = (local && !network) ? speed : -1; -#ifdef NETCONN -#ifdef CK_SPEED - if (is_tn) { - ctlp[(unsigned)255] = ctlp[CK_CR] = 1; - if (parity == 'e' || parity == 'm') ctlp[127] = 1; - if (flow == FLO_XONX) { /* Also watch out for Xon/Xoff */ - ctlp[17] = ctlp[19] = 1; - ctlp[17+128] = ctlp[19+128] = 1; - } - } -#endif /* CK_SPEED */ -#endif /* NETCONN */ - if (ttpkt(lx,flow,parity) < 0) { /* Put line in packet mode, */ - xxscreen(SCR_EM,0,0L,"Can't condition line"); - return; - } - if (local && !network && carrier != CAR_OFF) { - int x; /* Serial connection */ - x = ttgmdm(); /* with carrier checking */ - if (x > -1) { - if (!(x & BM_DCD)) { - debug(F101,"proto ttgmdm","",0); - xxscreen(SCR_EM,0,0L,"Carrier required but not detected"); - return; - } - } - } - /* Send remote side's "receive" or "server" startup string, if any */ - if (local && ckindex((char *)xss,"srgcjhk",0,0,1)) { - char *s = NULL; - if ( -#ifdef IKS_OPTION - /* Don't send auto-blah string if we know other side is serving */ - !TELOPT_U(TELOPT_KERMIT) || - !TELOPT_SB(TELOPT_KERMIT).kermit.u_start -#else - 1 -#endif /* IKS_OPTION */ - ) { - if (sstate == 's') { /* Sending file(s) */ - s = binary ? ptab[protocol].h_b_init : ptab[protocol].h_t_init; - } else if (protocol == PROTO_K) { /* Command for server */ - s = ptab[protocol].h_x_init; - } - } -#ifdef CK_SPEED -#ifndef UNPREFIXZERO - if (protocol == PROTO_K) /* Because of C-strings... */ - ctlp[0] = 1; -#endif /* UNPREFIXZERO */ -#endif /* CK_SPEED */ - if (s) if (*s) { /* If we have a command to send... */ - char tmpbuf[356]; - int tmpbufsiz = 356; - int stuff = -1, stuff2 = -1, len = 0; - extern int tnlm; - if (sstate == 's') { /* Sending file(s) */ -#ifdef CK_XYZ - if (protocol == PROTO_X) { - char * s2; - s2 = cmarg2[0] ? cmarg2 : cmarg; - if ((int)strlen(s) + (int)strlen(s2) + 4 < 356) - sprintf(tmpbuf, s, s2); - else - tmpbuf[0] = NUL; - } else { -#endif /* CK_XYZ */ - ckmakmsg(tmpbuf, 356, s, NULL, NULL, NULL); -#ifdef CK_XYZ - } -#endif /* CK_XYZ */ - } else { /* Command for server */ - ckstrncpy(tmpbuf,s,356); - } - ckstrncat(tmpbuf, "\015",sizeof(tmpbuf)); - if (tnlm) /* TERMINAL NEWLINE ON */ - stuff = LF; /* Stuff LF */ -#ifdef TNCODE - /* TELNET NEWLINE MODE */ - if (is_tn) { - switch (TELOPT_ME(TELOPT_BINARY) ? tn_b_nlm : tn_nlm) { - case TNL_CR: - break; - case TNL_CRNUL: - break; - case TNL_CRLF: - stuff2 = stuff; - stuff = LF; - break; - } - } -#endif /* TNCODE */ - -#ifdef NETCONN -#ifdef TCPSOCKET -#ifdef RLOGCODE - if (network && ttnproto == NP_RLOGIN) { - switch (tn_b_nlm) { /* Always BINARY */ - case TNL_CR: - break; - case TNL_CRNUL: - stuff2 = stuff; - stuff = NUL; - break; - case TNL_CRLF: - stuff2 = stuff; - stuff = LF; - break; - } - } -#endif /* RLOGCODE */ -#endif /* TCPSOCKET */ -#endif /* NETCONN */ - - len = strlen(tmpbuf); - if (stuff >= 0 && len < tmpbufsiz - 1) { - tmpbuf[len++] = stuff; - if (stuff2 >= 0 && len < tmpbufsiz - 1) - tmpbuf[len++] = stuff2; - tmpbuf[len] = NUL; - } - ttol((CHAR *)tmpbuf,len); - if (protocol == PROTO_K) /* Give remote Kermit time to start */ - msleep(400); - } - } - -#ifdef CK_XYZ - if (protocol != PROTO_K) { /* Non-Kermit protocol selected */ - char tmpbuf[356]; - int tmpbufsiz = 356; - char * s = ""; - -#ifdef CK_TMPDIR - if (sstate == 'v') { /* If receiving and... */ - if (dldir && !f_tmpdir) { /* if they have a download directory */ - if ((s = zgtdir())) { /* Get current directory */ - if (zchdir(dldir)) { /* Change to download directory */ - ckstrncpy(savdir,s,TMPDIRLEN); - f_tmpdir = 1; /* Remember that we did this */ - } - } - } - } -#endif /* CK_TMPDIR */ - -#ifdef XYZ_INTERNAL /* Internal */ - success = !pxyz(sstate); -#else -#ifdef CK_REDIR /* External */ - switch (sstate) { - case 's': /* 'Tis better to SEND... */ - s = binary ? ptab[protocol].p_b_scmd : ptab[protocol].p_t_scmd; - break; - case 'v': /* ... than RECEIVE */ - s = binary ? ptab[protocol].p_b_rcmd : ptab[protocol].p_t_rcmd; - break; - } - if (!s) s = ""; - if (*s) { - if (sstate == 's') { /* Sending */ - extern int xfermode; - int k = 0, x = 0, b = binary; - /* - If just one file we can scan it to set the xfer mode. - Otherwise it's up to the external protocol program. - */ - if (patterns && xfermode == XMODE_A && !iswild(fspec)) { - extern int nscanfile; - k = scanfile(fspec,&x,nscanfile); - if (k > -1) { - b = (k == FT_BIN) ? XYFT_B : XYFT_T; - s = b ? - ptab[protocol].p_b_scmd : - ptab[protocol].p_t_scmd; - } - } - if ((int)strlen(s) + (int)strlen(fspec) < tmpbufsiz) { - sprintf(tmpbuf,s,fspec); /* safe (prechecked) */ - tlog(F110,"Sending",fspec,0L); - } - } else { /* Receiving */ - if ((int)strlen(s) + (int)strlen(cmarg2) < tmpbufsiz) { - sprintf(tmpbuf,s,cmarg2); /* safe (prechecked) */ - tlog(F110,"Receiving",cmarg2,0L); - } - } - tlog(F110," via external protocol:",tmpbuf,0); - debug(F110,"ckcpro ttruncmd",tmpbuf,0); - success = ttruncmd(tmpbuf); - tlog(F110," status:",success ? "OK" : "FAILED", 0); - } else { - printf("?Sorry, no external protocol defined for %s\r\n", - ptab[protocol].p_name - ); - } -#else - printf( -"Sorry, only Kermit protocol is supported in this version of Kermit\n" - ); -#endif /* CK_REDIR */ -#endif /* XYZ_INTERNAL */ - return; - } -#endif /* CK_XYZ */ - -#ifdef NTSIGX - conraw(); - connoi(); -#else - if (!local) - connoi(); /* No console interrupts if remote */ -#endif /* NTSIG */ - - kactive = 1; - if (sstate == 'x') { /* If entering server mode, */ - extern int howcalled; - server = 1; /* set flag, */ - debug(F101,"server backgrd","",backgrd); - debug(F101,"server quiet","",quiet); - debug(F100,"SHOULD NOT SEE THIS IF IN BACKGROUND!","",0); - if (howcalled == I_AM_SSHSUB) { /* and issue appropriate message. */ - ttol((CHAR *)"KERMIT READY TO SERVE...\015\012",26); - } else if (!local) { - if (!quiet && !backgrd -#ifdef IKS_OPTION - && !TELOPT_ME(TELOPT_KERMIT) /* User was told by negotiation */ -#endif /* IKS_OPTION */ - ) { - conoll(srvtxt); - conoll("KERMIT READY TO SERVE..."); - } - } else { - conol("Entering server mode on "); - conoll(ttname); - conoll("Type Ctrl-C to quit."); - if (srvdis) intmsg(-1L); -#ifdef TCPSOCKET -#ifndef NOLISTEN - if (network && tcpsrfd > 0) - ttol((CHAR *)"KERMIT READY TO SERVE...\015\012",26); -#endif /* NOLISTEN */ -#endif /* TCPSOCKET */ - } - } else - server = 0; -#ifdef VMS - if (!quiet && !backgrd) /* So message doesn't overwrite prompt */ - conoll(""); - if (local) conres(); /* So Ctrl-C will work */ -#endif /* VMS */ -/* - If in remote mode, not shushed, not in background, and at top command level, - issue a helpful message telling what to do... -*/ - if (!local && !quiet && !backgrd) { - if (sstate == 'v') { - conoll("Return to your local Kermit and give a SEND command."); - conoll(""); - conoll("KERMIT READY TO RECEIVE..."); - } else if (sstate == 's') { - conoll("Return to your local Kermit and give a RECEIVE command."); - conoll(""); - conoll("KERMIT READY TO SEND..."); - } else if ( sstate == 'g' || sstate == 'r' || sstate == 'h' || - sstate == 'j' || sstate == 'c' ) { - conoll("Return to your local Kermit and give a SERVER command."); - conoll(""); - conoll((sstate == 'r' || sstate == 'j' || sstate == 'h') ? - "KERMIT READY TO GET..." : - "KERMIT READY TO SEND SERVER COMMAND..."); - } - } -#ifdef COMMENT - if (!local) sleep(1); -#endif /* COMMENT */ -/* - The 'wart()' function is generated by the wart program. It gets a - character from the input() routine and then based on that character and - the current state, selects the appropriate action, according to the state - table above, which is transformed by the wart program into a big case - statement. The function is active for one transaction. -*/ - rtimer(); /* Reset elapsed-time timer */ -#ifdef GFTIMER - rftimer(); -#endif /* GFTIMER */ - resetc(); /* & other per-transaction counters. */ - - debug(F101,"proto calling wart, justone","",justone); - - wart(); /* Enter the state table switcher. */ -/* - Note: the following is necessary in case we have just done a remote-mode - file transfer, in which case the controlling terminal modes have been - changed by ttpkt(). In particular, special characters like Ctrl-C and - Ctrl-\ might have been turned off (see ttpkt). So this call to ttres() is - essential. IMPORTANT: restore interrupt handlers first, otherwise any - terminal interrupts that occur before this is done in the normal place - later will cause a crash. -*/ -#ifdef OS2 - ttres(); /* Reset the communication device */ -#else - if (!local) { - setint(); /* Arm interrupt handlers FIRST */ - msleep(500); - ttres(); /* Then restore terminal. */ - } -#endif /* OS2 */ - xxscreen(SCR_TC,0,0L,""); /* Transaction complete */ - x = quiet; - quiet=1; - clsif(); /* Failsafe in case we missed */ - clsof(1); /* a case in the state machine. */ - quiet = x; - - if (server) { /* Back from packet protocol. */ - if (!quiet && !backgrd -#ifdef IKSD - && !inserver -#endif /* IKSD */ - ) { /* Give appropriate message */ - conoll(""); - conoll("C-Kermit server done"); - } - server = 0; /* Not a server any more */ - } -} - -/* S G E T I N I T -- Handle incoming GET-Class packets */ - -/* - Returns: - -1: On error - 0: GET packet processed OK - ready to Send. - 1: Extended GET processed OK - wait for another. -*/ -static int -#ifdef CK_ANSIC -sgetinit(int reget, int xget) -#else -sgetinit(reget,xget) int reget, xget; -#endif /* CK_ANSIC */ -{ /* Server end of GET command */ - char * fs = NULL; /* Pointer to filespec */ - int i, n, done = 0; -#ifdef PIPESEND - extern int usepipes, pipesend; -#endif /* PIPESEND */ - extern int nolinks; - - if (!ENABLED(en_get)) { /* Only if not disabled! */ - errpkt((CHAR *)"GET disabled"); - return(-1); - } - - /* OK to proceed */ - - nolinks = recursive; - filcnt = 0; - -#ifdef WHATAMI - /* If they are alike this was already done in whoarewe() */ - debug(F101,"sgetinit whatru","",whatru); - if (whatru & WMI_FLAG) { /* Did we get WHATAMI info? */ - debug(F101,"sgetinit binary (1)","",binary); -#ifdef VMS - if (binary != XYFT_I && binary != XYFT_L) -#else -#ifdef OS2 - if (binary != XYFT_L) -#endif /* OS2 */ -#endif /* VMS */ - binary = (whatru & WMI_FMODE) ? /* Yes, set file type */ - XYFT_B : XYFT_T; /* automatically */ - debug(F101,"sgetinit binary (2)","",binary); - if (!wearealike) - fncnv = (whatru & WMI_FNAME) ? 1 : 0; /* And name conversion */ - } -#endif /* WHATAMI */ - - fs = (char *)srvcmd; - srvptr = srvcmd; /* Point to server command buffer */ - decode(rdatap,putsrv,0); /* Decode the GET command into it */ - /* Accept multiple filespecs */ - cmarg2 = ""; /* Don't use cmarg2 */ - cmarg = ""; /* Don't use cmarg */ - - done = 1; /* Only 1 packet needed... */ - if (xget) { /* Special decoding for Extended GET */ - char L, next, c; /* PLV items */ - int len, val; /* More PLV items */ - char * p = (char *)srvcmd; /* String to decode */ - - done = 0; /* Maybe more packets needed */ - fs = NULL; /* We don't know the filespec yet */ - c = *p++; /* Get first parameter */ - - while (c) { /* For all parameters... */ - debug(F000,"sgetinit c","",c); - L = *p++; /* Get length */ - if (L >= SP) /* Decode length */ - len = xunchar(L); - else if (c == '@') { /* Allow missing EOP length field */ - len = 0; - } else { - len = (xunchar(*p++) * 95); - len += xunchar(*p++); - } - debug(F101,"sgetinit len","",len); - next = *(p+len); /* Get next parameter */ - *(p+len) = NUL; /* Zero it out to terminal value */ - debug(F110,"sgetinit p",p,0); - switch (c) { /* Do the parameter */ - case 'O': /* GET Options */ - val = atoi(p); /* Convert to int */ - debug(F101,"sgetinit O val","",val); - if (val & GOPT_DEL) moving = 1; - if (val & GOPT_RES) reget = 1; - if (val & GOPT_REC) { - recursive = 1; - nolinks = 2; - if (fnspath == PATH_OFF) - fnspath = PATH_REL; - } - break; - case 'M': /* Transfer Mode */ - val = atoi(p); - debug(F101,"sgetinit M val","",val); - if (val < 1) - break; - patterns = 0; /* Takes precedence over patterns */ - filepeek = 0; /* and FILE SCAN */ - if (val == GMOD_TXT) binary = XYFT_T; /* Text */ - if (val == GMOD_BIN) binary = XYFT_B; /* Binary */ - if (val == GMOD_LBL) binary = XYFT_L; /* Labeled */ - break; - case 'F': /* Filename */ - fs = p; - debug(F110,"sgetinit filename",fs,0); - break; - case '@': /* End Of Parameters */ - done = 1; - debug(F100,"sgetinit EOP","",0); - break; - default: - errpkt((CHAR *)"Unknown GET Parameter"); - debug(F100,"sgetinit unknown parameter","",0); - return(-1); - } - p += (len + 1); - c = next; - } - } - if (!fs) fs = ""; /* A filename is required */ - if (*fs) { - havefs = 1; - n = 0; /* Check for quoted name */ - if ((n = strlen(fs)) > 1) { - /* Note: this does not allow for multiple quoted names */ - if ((fs[0] == '{' && fs[n-1] == '}') || - (fs[0] == '"' && fs[n-1] == '"')) { - fs[n-1] = '\0'; - fs++; - debug(F111,"sgetinit unquoted filename",fs,n); - } else - n = 0; /* This means no quoting */ - } - -#ifdef PIPESEND - debug(F111,"sgetinit",fs,usepipes); - if (usepipes && ENABLED(en_hos) && *fs == '!') { - cmarg = fs + 1; /* Point past the bang */ - *fs = NUL; - nfils = -1; - pipesend = 1; - debug(F111,"sgetinit pipesend",cmarg,pipesend); - } - if (!pipesend) { /* If it's not a pipe */ -#endif /* PIPESEND */ - if (n == 0) { /* If the name was not quoted */ -#ifndef NOMSEND - nfils = fnparse(fs); /* Allow it to be a list of names */ - debug(F111,"sgetinit A",fs,nfils); -#ifdef COMMENT -/* This doesn't work if a GET-PATH is set. */ - if (nfils == 1 && !iswild(fs)) { /* Single file */ - char * m; - if ((x = zchki(fs)) < 0) { /* Check if it's sendable */ - switch (x) { - case -1: m = "File not found"; break; - case -2: m = "Not a regular file"; break; - case -3: m = "Read access denied"; break; - } - errpkt((CHAR *)m); - return(-1); - } - } -#endif /* COMMENT */ - } else { /* If it was quoted */ -#endif /* NOMSEND */ - nzxopts = 0; -#ifdef UNIXOROSK - if (matchdot) nzxopts |= ZX_MATCHDOT; -#endif /* UNIXOROSK */ - if (recursive) nzxopts |= ZX_RECURSE; - /* Treat as a single filespec */ - nfils = 0 - nzxpand(fs,nzxopts); - debug(F111,"sgetinit B",fs,nfils); - cmarg = fs; - } -#ifdef PIPESEND - } -#endif /* PIPESEND */ - } - if (!done) { /* Need more O packets... */ - debug(F100,"sgetinit O-Packet TBC","",0); /* To Be Continued */ - return(1); - } - debug(F100,"sgetinit O-Packet done - havefs","",havefs); - if (!havefs) { /* Done - make sure we have filename */ - errpkt((CHAR *)"GET without filename"); - return(-1); - } - freerpkt(winlo); - winlo = 0; /* Back to packet 0 again. */ - debug(F101,"sgetinit winlo","",winlo); - nakstate = 0; /* Now I'm the sender! */ - if (reget) sendmode = SM_RESEND; - if (sinit() > 0) { /* Send Send-Init */ -#ifdef STREAMING - if (!streaming) -#endif /* STREAMING */ - timint = chktimo(rtimo,timef); /* Switch to per-packet timer */ - return(0); /* If successful, switch state */ - } else return(-1); /* Else back to server command wait */ -} - -#else /* NOXFER */ - -#include "ckcdeb.h" - -VOID -proto() { - extern int success; - success = 0; -} -#endif /* NOXFER */ diff --git a/ckctel.c b/ckctel.c index 807de7f..0d5d820 100644 --- a/ckctel.c +++ b/ckctel.c @@ -2481,7 +2481,7 @@ iks_tn_sb(sb, n) CHAR * sb; int n; #ifdef CK_AUTODL #ifdef OS2 if (local && (IsConnectMode() && autodl) || - (!IsConnectMode() && + (!IsConnectMode() && (inautodl || sstate == 'x' || sstate == 'v')) ) tn_siks(KERMIT_RESP_START); /* START */ @@ -3566,7 +3566,7 @@ tn_debug(s) char *s; } ReleaseVscrnMutex(VTERM) ; #else - if (what != W_CONNECT && what != W_DIALING && + if (what != W_CONNECT && what != W_DIALING && what != W_COMMAND && what != W_NOTHING) return; /* CONNECT/command must be active */ conoll(s); @@ -4702,7 +4702,7 @@ tn_xdoop(z, echo, fn) CHAR z; int echo; int (*fn)(); extern int authentication_version; #ifdef CK_SSL - /* if we have an outstanding DO START_TLS then we must + /* if we have an outstanding DO START_TLS then we must * wait for the response before we determine what to do */ if (TELOPT_UNANSWERED_DO(TELOPT_START_TLS)) { diff --git a/ckuath.c b/ckuath.c index 4dec4df..9539c37 100644 --- a/ckuath.c +++ b/ckuath.c @@ -3008,7 +3008,7 @@ auth_send(parsedat,end_sub) unsigned char *parsedat; int end_sub; /* Construct and send Authentication Name subnegotiation */ if ( plen < sizeof(buf) - 6 ) { - sprintf((char *)buf, "%c%c%c%c", IAC, SB, + sprintf((char *)buf, "%c%c%c%c", IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME); memcpy(&buf[4], pname, plen); /* safe */ @@ -3021,7 +3021,7 @@ auth_send(parsedat,end_sub) unsigned char *parsedat; int end_sub; ReleaseTelnetMutex(); #endif } else { - sprintf((char *)buf, "%c%c%c%c%c%c", IAC, SB, + sprintf((char *)buf, "%c%c%c%c%c%c", IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, IAC, SE); /* safe */ #ifdef OS2 @@ -3775,7 +3775,7 @@ ck_krb4_autoget_TGT(char * realm) if ( krb4_init.principal == NULL || krb4_init.principal[0] == '\0') { - int ok = uq_txt(NULL, + int ok = uq_txt(NULL, k4prprompt && k4prprompt[0] ? k4prprompt : "Kerberos 4 Principal: ", @@ -7453,7 +7453,7 @@ ck_krb5_prompter( krb5_context context, tb[i].t_lbl = prompts[i].prompt; tb[i].t_dflt = NULL; tb[i].t_echo = (prompts[i].hidden ? 2 : 1); - } + } ok = uq_mtxt((char *)banner,NULL,num_prompts,tb); if ( ok ) { @@ -8203,7 +8203,7 @@ ck_krb5_initTGT(op,init,k4_init) } } - if ( !password ) + if ( !password ) password = ""; code = krb5_get_in_tkt_with_password(kcontext, options, #ifdef HEIMDAL @@ -8232,7 +8232,7 @@ ck_krb5_initTGT(op,init,k4_init) goto exit_k5_init; } } - if ( !password ) + if ( !password ) password = ""; code = krb5_get_in_tkt_with_password(kcontext, options, #ifdef HEIMDAL @@ -8331,9 +8331,9 @@ ck_krb5_initTGT(op,init,k4_init) goto exit_k5_init; } - if ( init->getk4 && + if ( init->getk4 && #ifdef KRB524_CONV - !try_convert524(kcontext,me,ccache) && + !try_convert524(kcontext,me,ccache) && #endif /* KRB524_CONV */ k4_init ) { int k4rc = ck_krb4_initTGT(op,k4_init); @@ -11335,7 +11335,7 @@ rcmd_stream_init_krb5(in_keyblock, encrypt_flag, lencheck, am_client, return; } - encivec_i[0].length = encivec_i[1].length = + encivec_i[0].length = encivec_i[1].length = encivec_o[0].length = encivec_o[1].length = blocksize; if ((encivec_i[0].data = malloc(encivec_i[0].length * 4)) == NULL) { @@ -11503,7 +11503,7 @@ ck_krb_rlogin(hostname, port, get_cred = NULL; (void) krb5_cc_close(k5_context, ccache); - if (status) + if (status) goto bad; /* Reset internal flags; these should not be set. */ @@ -11660,7 +11660,7 @@ ck_krb_rlogin(hostname, port, status = krb5_write_message(k5_context, (krb5_pointer)&ttyfd, &outbuf); - } + } if ((c = ttinc(0)) < 0) { if (c==-1) { @@ -11936,7 +11936,7 @@ krb5_des_read(fd, buf, len, secondary) return cc; /* read error */ } if (cc == 1) { - if (c == 0 || !do_lencheck) + if (c == 0 || !do_lencheck) break; } } @@ -11949,7 +11949,7 @@ krb5_des_read(fd, buf, len, secondary) if ((cc = net_read(fd, &c, 1)) != 1) return 0; rd_len = (rd_len << 8) | c; - if (status = krb5_c_encrypt_length(k5_context, + if (status = krb5_c_encrypt_length(k5_context, #ifdef HEIMDAL k5_session_key->keytype, #else @@ -12000,7 +12000,7 @@ krb5_des_read(fd, buf, len, secondary) errno = EIO; return(-1); } - + store_ptr = storage; nstored = rd_len; diff --git a/ckucmd.c b/ckucmd.c index 22dec67..6562f4e 100644 --- a/ckucmd.c +++ b/ckucmd.c @@ -3082,7 +3082,7 @@ cmfld(xhlp,xdef,xp,f) char *xhlp, *xdef, **xp; xx_strp f; /* fdc 2013/12/06 - allow a field to be empty if it is the name of a variable that has no value. - */ + */ isavar = (atmbuf[0] == '\\'); /* Remember if it was a var */ /* Replace by new value -- for MINPUT only keep all chars */ @@ -4103,12 +4103,12 @@ cmdelta(yy, mo, dd, hh, mm, ss, sign, dyy, dmo, ddd, dhh, dmm, dss) } sprintf(datebuf,"%04d%02d%02d %02d:%02d:%02d",yy,mo,dd,hh,mm,ss); d1 = mjd(datebuf); - debug(F111,"cmdelta mjd",datebuf,d1); + debug(F111,"cmdelta mjd",datebuf,d1); t1 = hh * 3600 + mm * 60 + ss; /* Base time to secs since midnight */ t2 = dhh * 3600 + dmm * 60 + dss; /* Delta time, ditto */ t3 = t1 + (sign * t2); /* Get sum (or difference) */ - + d2 = (sign * ddd); /* Delta days */ d2 += t3 / 86400L; @@ -4185,7 +4185,7 @@ delta2sec(s,result) char * s; long * result; ((c == 'd' || c == 'D') && !isalpha(*(p2+1)))) { /* Days */ ddays = atol(p); - if (!*(p2+1)) + if (!*(p2+1)) state = 0; else /* if anything is left */ state = NEED_HRS; /* now we want hours. */ @@ -4444,8 +4444,8 @@ cmcvtdate(s,t) char * s; int t; return(NULL); } debug(F101,"cmcvtdate asctime month","",xx); - monbuf[0] = (xx / 10) + '0'; - monbuf[1] = (xx % 10) + '0'; + monbuf[0] = (xx / 10) + '0'; + monbuf[1] = (xx % 10) + '0'; monbuf[2] = NUL; daybuf[0] = (s[8] == ' ' ? '0' : s[8]); daybuf[1] = s[9]; @@ -4720,7 +4720,7 @@ cmcvtdate(s,t) char * s; int t; fld[++i] = p; /* No, record pointer to this one */ } else { break; - } + } } else if ((*p == 'T' || *p == 't') && isdigit(*(p+1))) { /* Time */ *p++ = NUL; break; @@ -4798,16 +4798,16 @@ cmcvtdate(s,t) char * s; int t; if (xx > 0) if (p3[xx-1] == ',') { p3[xx-1] = NUL; if (rdigits(p3)) { - k = 1; + k = 1; ft[1] = 1; } else p3[xx-1] = ','; } } if (k > 1) { /* We can have only one non-numeric */ if (nodate) - makestr(&cmdatemsg,"Unrecognized word in date"); + makestr(&cmdatemsg,"Unrecognized word in date"); else if (!ft[2] && isdigit(*(fld[2]))) - makestr(&cmdatemsg,"Invalid date-time separator"); + makestr(&cmdatemsg,"Invalid date-time separator"); else makestr(&cmdatemsg,"Too many non-numeric fields in date"); debug(F111,"cmcvtdate",cmdatemsg,-1); @@ -4959,7 +4959,7 @@ cmcvtdate(s,t) char * s; int t; return(NULL); } if (!*p && t == 0) { - sprintf(zbuf,"%04d%02d%02d",atoi(year),atoi(month),nday); + sprintf(zbuf,"%04d%02d%02d",atoi(year),atoi(month),nday); dp = zbuf; goto xcvtdate; } @@ -5170,7 +5170,7 @@ cmcvtdate(s,t) char * s; int t; break; default: /* Ignore seconds or fractions */ break; - } + } } else if (*p == ':') { /* Colon */ state++; d = 0; @@ -5202,7 +5202,7 @@ cmcvtdate(s,t) char * s; int t; pc++; } p2++; - } + } while (*p2 == SP) /* Skip past spaces */ p2++; if (!*p2) /* Anything left? */ @@ -5243,25 +5243,25 @@ cmcvtdate(s,t) char * s; int t; ((c == 'd' || c == 'D') && !isalpha(*(p2+1)))) { /* Days */ ddays = atoi(p); - if (!*(p2+1)) + if (!*(p2+1)) state = 0; else /* if anything is left */ state = NEED_HRS; /* now we want hours. */ } else if ((c == 'W' || c == 'w') && !isalpha(*(p2+1))) { ddays = atoi(p) * 7; /* weeks... */ - if (!*(p2+1)) + if (!*(p2+1)) state = 0; else state = NEED_HRS; } else if ((c == 'M' || c == 'm') && !isalpha(*(p2+1))) { dmonths = atoi(p); /* months... */ - if (!*(p2+1)) + if (!*(p2+1)) state = 0; else state = NEED_HRS; } else if ((c == 'Y' || c == 'y') && !isalpha(*(p2+1))) { dyears = atoi(p); /* years... */ - if (!*(p2+1)) + if (!*(p2+1)) state = 0; else state = NEED_HRS; @@ -5626,7 +5626,7 @@ cmdiffdate(d1,d2) char * d1, * d2; mm2 = atoi(&d2[12]); ss2 = atoi(&d2[15]); ckstrncpy(d2buf,d2,9); - + jd1 = mjd(d1buf); /* Get the two Julian dates */ jd2 = mjd(d2buf); f1 = ss1 + 60 * mm1 + 3600 * hh1; /* Convert first time to seconds */ @@ -5636,9 +5636,9 @@ cmdiffdate(d1,d2) char * d1, * d2; debug(F101,"cmdiffdate f1","",f1); debug(F101,"cmdiffdate jd2","",jd2); debug(F101,"cmdiffdate f2","",f2); - + if (jd2 > jd1 || (jd1 == jd2 && f2 > f1)) { - sign = -1; + sign = -1; if (f1 > f2) {jd2--; f2 += 86400L;} jd = jd2 - jd1; fx = f2 - f1; @@ -5650,7 +5650,7 @@ cmdiffdate(d1,d2) char * d1, * d2; } debug(F111,"cmdiffdate sign jd",sign<0?"-":"+",jd); debug(F101,"cmdiffdate fx","",fx); - + hh = (int) (fx / 3600L); /* Convert seconds to hh:mm:ss */ mm = (int) (fx % 3600L) / 60L; @@ -6983,7 +6983,7 @@ gtword(brk) int brk; #ifdef FUNCTIONTEST debug(F110,"XXX atmbuf",atmbuf,0); debug(F110,"XXX pp",pp,0); - debug(F101,"XXX brkchar","",c); + debug(F101,"XXX brkchar","",c); #endif /* FUNCTIONTEST */ inword = cmflgs = 0; return(0); @@ -7939,7 +7939,7 @@ cmdconchk() { #ifdef __FILE_defined /* glibc 2.28 1 Aug 2018 */ x = (int) ((stdin->_IO_read_end) - (stdin->_IO_read_ptr)); debug(F101,"cmdconchk __FILE_defined","",x); -#else /* __FILE_defined */ +#else /* __FILE_defined */ #ifdef _IO_file_flags /* Linux (glibc 2.28 removed this symbol */ x = (int) ((stdin->_IO_read_end) - (stdin->_IO_read_ptr)); debug(F101,"cmdconchk _IO_file_flags","",x); @@ -8548,7 +8548,7 @@ xlookup(table,cmd,n,x) struct keytab table[]; char *cmd; int n, *x; if (one) { /* Name is one char long */ if (!*(s+1)) { if (x) *x = i; - *cmd = c; + *cmd = c; return(table[i].kwval); /* So is table entry */ } } else { /* Otherwise do string comparison */ diff --git a/ckucns.c b/ckucns.c index 7389de1..a36db9e 100644 --- a/ckucns.c +++ b/ckucns.c @@ -1383,7 +1383,7 @@ conect() { signal(SIGQUIT, SIG_IGN); debug(F101,"CONNECT carrier-watch","",carrier); - if ((!network + if ((!network #ifdef TN_COMPORT || istncomport() #endif /* TN_COMPORT */ @@ -1810,7 +1810,7 @@ conect() { outxcount = b_to_u((CHAR)c,outxbuf,OUTXBUFSIZ,tcssize); outxbuf[outxcount] = NUL; } else if (unicode == 2) { /* Local is UTF-8 */ - + x = u_to_b((CHAR)c); if (x < 0) continue; @@ -2649,7 +2649,7 @@ doesc(c) char c; conoll(temp); if (hwparity) sprintf(temp," Parity[hardware]: %s",parnam(hwparity)); - else + else sprintf(temp," Parity: %s", parnam(parity)); conoll(temp); #ifndef NOXFER diff --git a/ckucon.c b/ckucon.c index da83bf6..0686da5 100644 --- a/ckucon.c +++ b/ckucon.c @@ -1778,7 +1778,7 @@ conect() { debug(F101,"CONNECT ttvt ok, escape","",escape); debug(F101,"CONNECT carrier-watch","",carrier); - if ((!network + if ((!network #ifdef TN_COMPORT || istncomport() #endif /* TN_COMPORT */ @@ -2605,7 +2605,7 @@ doesc(c) char c; conoll(temp); if (hwparity) sprintf(temp," Parity[hardware]: %s",parnam((char)hwparity)); - else + else sprintf(temp," Parity: %s", parnam((char)parity)); conoll(temp); sprintf(temp," Autodownload: %s", autodl ? "on" : "off"); diff --git a/ckudia.c b/ckudia.c index 68eb778..a27876b 100644 --- a/ckudia.c +++ b/ckudia.c @@ -4456,13 +4456,8 @@ char fbuf[FULLNUML]; static ckjmpbuf sjbuf; -#ifdef CK_ANSIC -static SIGTYP (*savalrm)(int); /* For saving alarm handler */ -static SIGTYP (*savint)(int); /* For saving interrupt handler */ -#else -static SIGTYP (*savalrm)(); /* For saving alarm handler */ -static SIGTYP (*savint)(); /* For saving interrupt handler */ -#endif /* CK_ANSIC */ +static sig_t savalrm; /* For saving alarm handler */ +static sig_t savint; /* For saving interrupt handler */ #ifdef CKLOGDIAL static VOID @@ -5936,7 +5931,7 @@ _dodial(threadinfo) VOID * threadinfo; if (x > LBUFL) x = LBUFL; x = ttxin(x,(CHAR *)lbuf); if ((x > 0) && dialdpy) conol(lbuf); - } else if (network + } else if (network #ifdef TN_COMPORT && !istncomport() #endif /* TN_COMPORT */ @@ -8109,7 +8104,7 @@ dialhup() { #ifdef TN_COMPORT && !istncomport() /* (without RFC 2217) */ #endif /* TN_COMPORT */ - ) { + ) { dialsta = DIA_HANG; if (dialdpy) /* a modem server, just print a msg */ printf(" WARNING - modem hangup failed\r\n"); /* don't hangup! */ diff --git a/ckufio.c b/ckufio.c index 244b37d..17f03c0 100644 --- a/ckufio.c +++ b/ckufio.c @@ -172,12 +172,12 @@ extern int eofmethod; #ifndef BSD44 #ifndef V7 /* Not sure why this is here. What it implies is that the code bracketed - by SYSUTIMEH is valid on all platforms on which we support time + by SYSUTIMEH is valid on all platforms on which we support time functionality. But we know that is not true because the BSD44 and V7 platforms do not support sys/utime.h and the data structures which are defined in them. Now this worked before because prior to today's changes the UTIMEH definition for BSD44 and V7 did not take place - until after SYSUTIMEH was defined. It also would not have been a + until after SYSUTIMEH was defined. It also would not have been a problem if the ordering of all the time blocks was consistent. All but one of the blocks were BSD44, V7, SYSUTIMEH, . That one case is where this problem was triggered. @@ -595,10 +595,10 @@ _PROTOTYP( struct passwd * getpwent, (void) ); #endif /* __APPLE__ */ #ifdef SOLARIS -#define PAM_CONST +#define PAM_CONST #else /* SOLARIS */ #define PAM_CONST CONST -#endif +#endif static char * pam_pw = NULL; @@ -1636,7 +1636,7 @@ zopeno(n,name,zz,fcb) int n; char *name; struct zattr *zz; struct filinfo *fcb; } debug(F111,"zopeno open flags",name,flags); fd = open(name,O_WRONLY|flags,0600); - debug(F111,"zopeno open",name,fd); + debug(F111,"zopeno open",name,fd); if (fd > -1) { if (isatty(fd)) { filefd = fd; @@ -2722,7 +2722,7 @@ zchko(name) char *name; debug(F111,"zchko open mode",name,flags); /* Must attempt to open it so isatty() can be used */ fd = open(name,O_WRONLY|O_CREAT|flags,0600); - debug(F111,"zchko open",name,fd); + debug(F111,"zchko open",name,fd); if (fd > -1) { /* to get a file descriptor */ if (isatty(fd)) /* for isatty() */ istty++; @@ -3464,7 +3464,7 @@ zxcmd(filnum,comand) int filnum; char *comand; if (priv_chk()) { debug(F100,"zxcmd priv_chk failed","",0); return(0); - } + } errno = 0; fp[filnum] = popen(comand,"w"); debug(F111,"zxcmd popen",fp[filnum] ? "OK" : "Failed", errno); @@ -3693,7 +3693,7 @@ zclosf(filnum) int filnum; { Depends on external variable wildxpand: 0 means we expand wildcards internally, nonzero means we call the shell to do it. - + AND in C-Kermit 8.0.212 and later, on extern wildena: 1 means wildcards are enabled, 0 means disabled, the characters are taken literally. */ @@ -7071,7 +7071,7 @@ whoami() { if ((c = getlogin()) != NULL) { /* name from utmp file */ ckstrncpy (loginname, c, UIDBUFLEN); - debug(F110,"whoami loginname",loginname,0); + debug(F110,"whoami loginname",loginname,0); if ((p = getpwnam(loginname)) != NULL) /* get passwd entry */ if (p->pw_uid == ruid) /* for loginname */ ckstrncpy(realname, envname, UIDBUFLEN); /* if uid's are same */ @@ -7080,7 +7080,7 @@ whoami() { /* Use first name we get for ruid */ if ((p = getpwuid(ruid)) == NULL) { /* name for uid */ - debug(F101,"whoami no username for ruid","",ruid); + debug(F101,"whoami no username for ruid","",ruid); realname[0] = '\0'; /* no user name */ ruid = -1; return(NULL); @@ -7379,7 +7379,8 @@ zshcmd(s) char *s; #ifdef CK_CHILD int child; /* Child's exit status */ #endif /* CK_CHILD */ - SIGTYP (*istat)(), (*qstat)(); + sig_t istat; + sig_t qstat; if (pid == (PID_T) -1) return(-1); /* fork() failed? */ @@ -8648,7 +8649,7 @@ zsyslog() { #ifdef __FreeBSD__ /* 299 This was necessary in */ #ifndef NODCLINITGROUPS /* FreeBSD 4.4, don't know */ #define NODCLINITGROUPS /* about other versions... */ -#endif /* NODCLINITGROUPS */ +#endif /* NODCLINITGROUPS */ #endif /* __FreeBSD__ */ int diff --git a/ckuker.nr b/ckuker.nr index f9fd46a..55725f2 100644 --- a/ckuker.nr +++ b/ckuker.nr @@ -84,7 +84,7 @@ here with pointers to additional information elsewhere. .PP or: .PP -.B kermit +.B kermit .I URL .PP If the first command\(hyline argument is the name of a file, interactive\(hymode @@ -130,7 +130,7 @@ platforms. For example, C\(hyKermit can't be built with TCP/IP support on a platform that does not have TCP/IP header files and libraries (and even if Kermit does include TCP/IP support, it can't be used to make TCP/IP connections on a computer that does -not have a TCP/IP stack installed). If your version of +not have a TCP/IP stack installed). If your version of C\(hyKermit lacks a feature mentioned here, use its SHOW FEATURES command to see what might have been excluded. .PP @@ -158,7 +158,7 @@ followed by Return or Enter.) .SH OPTIONS Here is a list of C\(hyKermit's single\(hyletter command\(hyline options, which start with a single dash (\-), in ASCII ("alphabetical") order. Alphabetic -case is significant (\-A is not the same as \-a). Action options are +case is significant (\-A is not the same as \-a). Action options are tagged "ACTION". .TP \-0 @@ -316,7 +316,7 @@ name or number. Equivalent to the TELNET command. Also see: \-J, \-F. .TP \-k -(ACTION) Receive file(s) to standard output, which normally +(ACTION) Receive file(s) to standard output, which normally would be piped to another process. Also see: \-r, \-G. .TP @@ -672,7 +672,7 @@ Tells whether previous command succeeded or failed. DATE [ date\(hyand/or\(hytime ] Shows current date\(hytime or interprets given date\(hytime. .TP -RUN [ extern\(hycommand [ parameters... ] +RUN [ extern\(hycommand [ parameters... ] Runs the given external command. Synonym: !. .TP EXEC [ extern\(hycommand [ params... ] @@ -688,16 +688,16 @@ Local File Management TYPE [ options ] filename Displays the contents of the given file. .TP -MORE [ options ] filename +MORE [ options ] filename Equivalent to TYPE /PAGE (pause after each screenful). .TP -CAT [ options ] filename +CAT [ options ] filename Equivalent to TYPE /NOPAGE. .TP -HEAD [ options ] filename +HEAD [ options ] filename Displays the first few lines of a given file. .TP -TAIL [ options ] filename +TAIL [ options ] filename Displays the last few lines of a given file. .TP GREP [ options ] pattern filespec @@ -707,7 +707,7 @@ the pattern. Synonym: FIND. DIRECTORY [ options ] [filespec ] Lists files (built\(hyin, many options). .TP -LS [ options ] [ filespec ] +LS [ options ] [ filespec ] Lists files (runs external "ls" command). .TP DELETE [ options ] [ filespec ] @@ -753,7 +753,7 @@ Removes a directory. Making Connections .RS .TP -SET LINE [ options ] devicename +SET LINE [ options ] devicename Opens the named serial port. Synonym: SET PORT. .TP OPEN LINE [ options ] devicename @@ -777,7 +777,7 @@ Performs secure authentication on a TCP/IP connection. SET NETWORK TYPE { TCP/IP, X.25, ... } Selects network type for subsequent SET HOST commands. .TP -SET HOST [ options ] host [ port ] +SET HOST [ options ] host [ port ] Opens a network connection to the given host and port. .TP SET HOST * port @@ -864,7 +864,7 @@ Closes the currently open FTP connection. HTTP CLOSE Closes the currently open HTTP connection. .TP -EXIT +EXIT Also closes all connections. Synonym: QUIT. .TP SET EXIT WARNING OFF @@ -883,7 +883,7 @@ Sends all files that match. RESEND [ options ] filespec Resumes an interrupted SEND from the point of failure. .TP -RECEIVE [ options ] [ as\(hyname ] +RECEIVE [ options ] [ as\(hyname ] Waits passively for files to arrive. Synonym: R. .TP LOG TRANSACTIONS [ filename ] @@ -898,7 +898,7 @@ Use cautious and less fast file\(hytransfer settings. ROBUST Use ultra\(hyconservative and slow file\(hytransfer settings. .TP -STATISTICS [ options ] +STATISTICS [ options ] Gives statistics about the most recent file transfer. .TP WHERE @@ -936,13 +936,13 @@ Enters Server state. Client of Kermit or FTP Server .RS .TP -[ REMOTE ] LOGIN [ user password ] +[ REMOTE ] LOGIN [ user password ] Logs in to a Kermit server or IKSD that requires it. .TP [ REMOTE ] LOGOUT Logs out from a Kermit server or IKSD. .TP -SEND [ options ] filename [ as\(hyname ] +SEND [ options ] filename [ as\(hyname ] Sends the given file to the server. Synonyms: S, PUT. .TP SEND [ options ] filespec @@ -1032,7 +1032,7 @@ in the middle of a keyword or filename, not just at the beginning. For example, "send x?" lists all the files in the current directory whose names start with 'x'. .SH INITIALIZATION FILE -In its default configuration, C\(hyKermit executes commands from a file +In its default configuration, C\(hyKermit executes commands from a file called .kermrc in your home directory when it starts, unless it is given the \-Y or \-y command\(hyline option. Custom configurations might substitute a shared system\(hywide initialization file. The SHOW FILE command tells what @@ -1194,11 +1194,11 @@ At the C\(hyKermit command prompt, simply type: telnet foo.bar.com .fi .sp -(substituting desired hostname or address). +(substituting desired hostname or address). You can also include a port number: .sp .nf - telnet xyzcorp.com 3000 ; + telnet xyzcorp.com 3000 ; .fi .sp If the connection is successful, Kermit automically enters Connect @@ -1267,7 +1267,7 @@ PARITY, and so on, and Kermit relays them to the terminal server using the protocol specified in the RFC. .sp More info: HELP SET MODEM, HELP SET LINE, HELP SET SPEED, HELP SET -FLOW, HELP DIAL, HELP SET DIAL, HELP SET MODEM, HELP SET +FLOW, HELP DIAL, HELP SET DIAL, HELP SET MODEM, HELP SET CARRIER\-WATCH, SHOW COMMUNICATIONS, SHOW MODEM, SHOW DIAL. .TP Direct Serial Port @@ -1287,7 +1287,7 @@ eliminator). From Computer A: connect ; Enter Connect (terminal) state .fi .sp -This assumes Computer B is set up to let you log in. If it isn't, you +This assumes Computer B is set up to let you log in. If it isn't, you can run a copy of Kermit on Computer B and follow approximately the same directions. More info: As above plus HELP CONNECT. .PP diff --git a/ckupty.c b/ckupty.c index fdc0a1a..ba23ea2 100644 --- a/ckupty.c +++ b/ckupty.c @@ -1741,7 +1741,7 @@ getptyslave(fd, fc) int * fd, fc; #else /* HPUX */ #ifdef USE_TERMIO /* - Settings for all other termios/termio based systems, other than + Settings for all other termios/termio based systems, other than 4.4BSD. In 4.4BSD the kernel does the initial terminal setup. */ #ifdef BSD42 @@ -1882,7 +1882,7 @@ exec_cmd(s) char * s; args = q->a_head + 1; -#ifdef DEBUG +#ifdef DEBUG { int i, n; n = q->a_size; @@ -1899,7 +1899,7 @@ exec_cmd(s) char * s; } } - } + } } #endif /* DEBUG */ diff --git a/ckupty.h b/ckupty.h index 374c508..3ee1841 100644 --- a/ckupty.h +++ b/ckupty.h @@ -190,4 +190,3 @@ extern struct error_table et_pty_error_table; #define __LIBPTY_H__ #endif /* __LIBPTY_H__ */ - diff --git a/ckuscr.c b/ckuscr.c index 6c6136c..d821d75 100644 --- a/ckuscr.c +++ b/ckuscr.c @@ -544,15 +544,7 @@ dologin( char *cmdstr ) dologin(cmdstr) char *cmdstr; #endif /* CK_ANSIC */ { -#ifdef OS2 -#ifdef NT - SIGTYP (* savealm)(int); /* Save incoming alarm function */ -#else /* NT */ - SIGTYP (* volatile savealm)(int); /* Save incoming alarm function */ -#endif /* NT */ -#else /* OS2 */ - SIGTYP (*savealm)(); /* Save incoming alarm function */ -#endif /* OS2 */ + sig_t savealm; /* Save incoming alarm function */ char *e; s = cmdstr; /* Make global to this module */ diff --git a/ckusig.h b/ckusig.h index 3482900..90b66aa 100644 --- a/ckusig.h +++ b/ckusig.h @@ -76,4 +76,3 @@ _PROTOTYP( int cc_alrm_execute, ck_sigfunc) ); /* End of ckusig.h */ - diff --git a/ckutio.c b/ckutio.c index e3f786c..57d186d 100644 --- a/ckutio.c +++ b/ckutio.c @@ -1289,23 +1289,23 @@ static int gotsigs = 0; static time_t tcount = (time_t)0; /* Elapsed time counter */ -static SIGTYP (*saval)() = NULL; /* For saving alarm() handler */ -static SIGTYP (*savquit)() = NULL; /* and other signal handlers */ +static sig_t saval; /* For saving alarm() handler */ +static sig_t savquit; /* and other signal handlers */ #ifdef SIGUSR1 -static SIGTYP (*savusr1)() = NULL; +static sig_t savusr1; #endif /* SIGUSR1 */ #ifdef SIGUSR2 -static SIGTYP (*savusr2)() = NULL; +static sig_t savusr2; #endif /* SIGUSR2 */ #ifdef SIGPIPE -static SIGTYP (*savpipe)() = NULL; +static sig_t savpipe; #endif /* SIGPIPE */ #ifdef SIGDANGER -static SIGTYP (*savdanger)() = NULL; +static sig_t savdanger; #endif /* SIGDANGER */ #ifndef NOJC -static SIGTYP (*jchdlr)() = NULL; /* For checking suspend handler */ +static sig_t jchdlr; /* For checking suspend handler */ #endif /* NOJC */ static int jcshell = -1; /* And flag for result */ @@ -1717,7 +1717,7 @@ xtimerh(foo) int foo; /* Control-C trap for communication line input functions */ int cc_int; /* Flag */ -SIGTYP (* occt)(); /* For saving old SIGINT handler */ +sig_t occt; /* For saving old SIGINT handler */ /*ARGSUSED*/ SIGTYP @@ -2193,7 +2193,7 @@ sysinit() { #endif /* NOSIGWINCH */ #ifdef SIGXFSZ - signal(SIGXFSZ,SIG_IGN); /* Ignore writing past file limit */ + signal(SIGXFSZ,SIG_IGN); /* Ignore writing past file limit */ #endif /* SIGXFSZ */ #ifndef NOJC @@ -2656,12 +2656,7 @@ debug(F110,"XXX netopen in ifdef NETCONN...","A",0); close(pipe0[1]); dup2(pipe1[0], 0); close(pipe1[0]); -/* - I can't image what this is; system() executes a shell command. - ttname holds the name of terminal device, it's not a command. - --fdc Fri Sep 18 15:51:18 2020 - system(ttname); -*/ + exec_cmd(ttname); /* Command to run is in ttname as with NET_PTY */ _exit(0); default: /* Parent */ close(pipe0[1]); @@ -2795,7 +2790,7 @@ debug(F110,"XXX netopen in ifdef NETCONN...","A",0); equivalent until you have a file descriptor that you can give to ttyname(). But this can cause a race condition between Kermit and [m]getty. So see the [#]else part... -*/ +*/ /* In the following section, we open the tty device for read/write. @@ -3153,7 +3148,7 @@ debug(F110,"XXX netopen in ifdef NETCONN...","A",0); #ifdef Plan9 /* take this opportunity to open the control channel */ - if (p9openttyctl(fnam) < 0) + if (p9openttyctl(fnam) < 0) #else if (!ttfdflg && !isatty(ttyfd) && strcmp(fnam,"/dev/null")) #endif /* Plan9 */ @@ -3566,7 +3561,7 @@ do_open(ttname) char *ttname; 0 : (ttcarr != CAR_ON) ? O_NONBLOCK : 0) ) - ); + ); #else /* !QNX6 */ #ifndef O_NDELAY /* O_NDELAY not defined */ @@ -3804,7 +3799,7 @@ ttclos(foo) int foo; tcsetattr(ttyfd,TCSANOW,&ttold); #else /* !BSD44ORPOSIX */ #ifdef ATTSV - ioctl(ttyfd,TCSETAW,&ttold); + ioctl(ttyfd,TCSETAW,&ttold); #else /* !ATTSV */ stty(ttyfd,&ttold); #endif /* ATTSV */ @@ -4171,7 +4166,7 @@ tthang() { #endif /* DEBUG */ #else /* HUP_CLOSE_POSIX */ - + /* General BSD44ORPOSIX case (Linux, BSDI, FreeBSD, etc) */ debug(F100,"tthang BSD44ORPOSIX B0","",0); @@ -4652,7 +4647,7 @@ ttres() { /* Restore the tty to normal. */ int rc = -1; if ((rc = tnsetflow(ttflow)) < 0) return(rc); - if (ttspeed <= 0) + if (ttspeed <= 0) ttspeed = tnc_get_baud(); else if ((rc = tnc_set_baud(ttspeed)) < 0) return(rc); @@ -6506,7 +6501,7 @@ ttpkt(speed,xflow,parity) long speed; int xflow, parity; ttflow = flow; } if (speed != ttspeed) { - if (speed <= 0) + if (speed <= 0) speed = tnc_get_baud(); else if ((rc = tnc_set_baud(speed)) < 0) return(rc); @@ -6535,7 +6530,7 @@ ttpkt(speed,xflow,parity) long speed; int xflow, parity; tnc_set_parity(5); break; } - } else + } else #endif /* HWPARITY */ { tnc_set_parity(1); /* None */ @@ -7202,7 +7197,7 @@ ttvt(speed,flow) long speed; int flow; ttflow = flow; } if (speed != ttspeed) { - if (speed <= 0) + if (speed <= 0) speed = tnc_get_baud(); else if ((rc = tnc_set_baud(speed)) < 0) return(rc); @@ -7482,7 +7477,7 @@ ttvt(speed,flow) long speed; int flow; debug(F101,"ttvt ATTSV ioctl TCSETAW","",x); if (x < 0) { /* set new modes . */ debug(F101,"ttvt ATTSV ioctl TCSETAW errno","",errno); - return(-1); + return(-1); } #endif /* BSD44ORPOSIX */ #endif /* Plan9 */ @@ -9769,7 +9764,7 @@ conbgt(flag) int flag; */ if (x < 0 && !flag && !sigint_ign) { /* Didn't get good results above... */ - SIGTYP (*osigint)(); + sig_t osigint; osigint = signal(SIGINT,SIG_IGN); /* What is SIGINT set to? */ sigint_ign = 1; @@ -11398,7 +11393,7 @@ ttinl(dest,max,timo,eol) int max,timo; CHAR *dest, eol; NOTE: This code reworked to (a) execute even if the debug log isn't active; and (b) actually work. -fdc, 2007/02/22. And again 2007/08/12-13 to also work on encrypted connections. -*/ +*/ debug(F101,"TTINL my_count","",my_count); if ((n & ttpmsk) != eol) { /* Not the packet terminator */ int x; @@ -11410,7 +11405,7 @@ ttinl(dest,max,timo,eol) int max,timo; CHAR *dest, eol; CHAR ch = x; ck_tn_decrypt((char *)&ch,1); x = ch; - debug(F000,"TTINL lkdecr char","",x); + debug(F000,"TTINL lkdecr char","",x); } #endif /* CK_ENCRYPTION */ /* @@ -13889,42 +13884,42 @@ ttgmdm() { #ifdef TIOCM_CTS /* Clear To Send */ if (y & TIOCM_CTS) z |= BM_CTS; - debug(F101,"ttgmdm TIOCM_CTS defined","",TIOCM_CTS); + debug(F101,"ttgmdm TIOCM_CTS defined","",TIOCM_CTS); #else debug(F100,"ttgmdm TIOCM_CTS not defined","",0); #endif #ifdef TIOCM_DSR /* Data Set Ready */ if (y & TIOCM_DSR) z |= BM_DSR; - debug(F101,"ttgmdm TIOCM_DSR defined","",TIOCM_DSR); + debug(F101,"ttgmdm TIOCM_DSR defined","",TIOCM_DSR); #else debug(F100,"ttgmdm TIOCM_DSR not defined","",0); #endif #ifdef TIOCM_CAR /* Carrier */ if (y & TIOCM_CAR) z |= BM_DCD; - debug(F101,"ttgmdm TIOCM_CAR defined","",TIOCM_CAR); + debug(F101,"ttgmdm TIOCM_CAR defined","",TIOCM_CAR); #else debug(F100,"ttgmdm TIOCM_CAR not defined","",0); #endif #ifdef TIOCM_RNG /* Ring Indicate */ if (y & TIOCM_RNG) z |= BM_RNG; - debug(F101,"ttgmdm TIOCM_RNG defined","",TIOCM_RNG); + debug(F101,"ttgmdm TIOCM_RNG defined","",TIOCM_RNG); #else debug(F100,"ttgmdm TIOCM_RNG not defined","",0); #endif #ifdef TIOCM_DTR /* Data Terminal Ready */ if (y & TIOCM_DTR) z |= BM_DTR; - debug(F101,"ttgmdm TIOCM_DTR defined","",TIOCM_DTR); + debug(F101,"ttgmdm TIOCM_DTR defined","",TIOCM_DTR); #else debug(F100,"ttgmdm TIOCM_DTR not defined","",0); #endif #ifdef TIOCM_RTS /* Request To Send */ if (y & TIOCM_RTS) z |= BM_RTS; - debug(F101,"ttgmdm TIOCM_RTS defined","",TIOCM_RTS); + debug(F101,"ttgmdm TIOCM_RTS defined","",TIOCM_RTS); #else debug(F100,"ttgmdm TIOCM_RTS not defined","",0); #endif @@ -14515,7 +14510,7 @@ tt_is_secure() { /* Tells whether the current connection is secure */ } #ifdef CK_REDIR - + /* External protocol handler parameters from ckuus3.c */ extern int exp_handler, exp_stderr, exp_timo; @@ -14897,7 +14892,7 @@ pty_get_status(fd,pid) int fd; PID_T pid; if (x > 0) { if (x != pty_fork_pid) debug(F101, - "pty_get_status waitpid pid doesn't match","",pty_fork_pid); + "pty_get_status waitpid pid doesn't match","",pty_fork_pid); debug(F101,"pty_get_status waitpid status","",status); debug(F101,"pty_get_status waitpid errno","",errno); if (WIFEXITED(status)) { @@ -14950,7 +14945,7 @@ pty_get_status(fd,pid) int fd; PID_T pid; tested on some platforms (NetBSD, luckily) but not others (Solaris, Linux). - On the network side, we use ttinc() and ttoc(), which, for network + On the network side, we use ttinc() and ttoc(), which, for network connections, handle any active security methods. Call with s = command. @@ -14967,7 +14962,7 @@ pty_get_status(fd,pid) int fd; PID_T pid; */ static int have_pty = 0; /* Do we have a pty? */ -static SIGTYP (*save_sigchld)() = NULL; /* For catching SIGCHLD */ +static sig_t save_sigchld; /* For catching SIGCHLD */ static VOID #ifdef CK_ANSIC @@ -15149,7 +15144,7 @@ ttptycmd(s) char *s; exit(1); } signal(SIGINT,SIG_IGN); /* Let upper fork catch this */ - + #ifdef COMMENT #ifdef TIOCSCTTY /* Make pty the controlling terminal for the process */ @@ -15178,13 +15173,13 @@ ttptycmd(s) char *s; #endif /* COMMENT */ #ifdef COMMENT -#ifdef SIGTTOU +#ifdef SIGTTOU /* Ignore terminal output interrupts */ /* THIS HAS NO EFFECT */ debug(F100,"ttptycmd ignoring SIGTTOU","",0); signal(SIGTTOU, SIG_IGN); #endif /* SIGTTOU */ -#ifdef SIGTSTP +#ifdef SIGTSTP /* Ignore terminal output interrupts */ /* THIS HAS NO EFFECT */ debug(F100,"ttptycmd ignoring SIGTSTP","",0); @@ -15223,7 +15218,7 @@ ttptycmd(s) char *s; makestr(&(args[i]),NULL); } } - } + } } #ifdef COMMENT /* @@ -15242,7 +15237,7 @@ ttptycmd(s) char *s; debug(F101,"ttptycmd execvp failed","",errno); close(slavefd); exit(1); - } + } /* (there are better ways to do this...) */ msleep(1000); /* Make parent wait for child to be ready */ ptyfd = masterfd; /* We talk to the master */ @@ -15260,7 +15255,7 @@ ttptycmd(s) char *s; debug(F101,"ttptycmd PTY_TBUF_SIZE","",PTY_TBUF_SIZE); #ifdef PTY_USE_NDELAY - /* + /* NOTE: If select() and ioctl(ptyfd,FIONREAD,&n) return true indications on the pty, we don't need nonblocking reads. Performance of either method seems to be about the same, so use whatever works. @@ -15349,7 +15344,7 @@ ttptycmd(s) char *s; if (have_pty) { /* This is not right -- sleeping won't accomplish anything */ debug(F101,"ttptycmd msleep","",100); - msleep(100); + msleep(100); } else { debug(F100,"ttptycmd no pty - quitting loop","",0); break; @@ -15359,7 +15354,7 @@ ttptycmd(s) char *s; if (seconds_to_wait > 0L) { /* Timeout in case nothing happens */ tv.tv_sec = seconds_to_wait; /* for a long time */ - tv.tv_usec = 0L; + tv.tv_usec = 0L; tv2 = &tv; } else { tv2 = NULL; @@ -15373,7 +15368,7 @@ ttptycmd(s) char *s; break; } if (x == 0) { - debug(F101,"ttptycmd +++ select timeout","",seconds_to_wait); + debug(F101,"ttptycmd +++ select timeout","",seconds_to_wait); if (have_pty) { status = pty_get_status(ptyfd,pty_fork_pid); debug(F101,"ttptycmd pty_get_status A","",status); @@ -15404,7 +15399,7 @@ ttptycmd(s) char *s; c = 0x00; dbuf[x++] = c; debug(F000,">>> CR-NUL","",c); - } + } } dbuf[x++] = c; /* Copy and count it */ debug(F000,">>> char",ckitoa(in_state),c); @@ -15474,14 +15469,14 @@ ttptycmd(s) char *s; tset++; debug(F100,"ttptycmd FD_ISSET ttyfd in","",0); n = in_chk(1,ttyfd); - debug(F101,"ttptycmd in_chk(ttyfd)","",n); + debug(F101,"ttptycmd in_chk(ttyfd)","",n); if (n < 0 || ttyfd == -1) { debug(F101,"ttptycmd +++ ttyfd errno","",errno); net_err++; } else if (n > 0) { if (n > PTY_TBUF_SIZE - tbuf_avail) n = PTY_TBUF_SIZE - tbuf_avail; - debug(F101,"ttptycmd net read size adjusted","",n); + debug(F101,"ttptycmd net read size adjusted","",n); if (xlocal && netconn) { /* We have to use a byte loop here because ttxin() @@ -15569,7 +15564,7 @@ ttptycmd(s) char *s; debug(F100,msgbuf,"",0); } else { x = ttxin(n,tbuf+tbuf_avail); - debug(F101,"ttptycmd ttxin x","",x); + debug(F101,"ttptycmd ttxin x","",x); } if (x < 0) { @@ -15595,14 +15590,14 @@ ttptycmd(s) char *s; */ n = pty_chk(ptyfd); #endif /* PTY_USE_NDELAY */ - debug(F101,"ttptycmd pty_chk() n","",n); + debug(F101,"ttptycmd pty_chk() n","",n); if (n < 0) n = 0; if (n > 0) { if (n > PTY_PBUF_SIZE - pbuf_avail) n = PTY_PBUF_SIZE - pbuf_avail; - debug(F101,"ttptycmd pty read size adjusted","",n); + debug(F101,"ttptycmd pty read size adjusted","",n); errno = 0; x = read(ptyfd,pbuf+pbuf_avail,n); #ifdef DEBUG @@ -15648,7 +15643,7 @@ ttptycmd(s) char *s; msleep(100); /* sleep a bit */ } x = 0; - } + } /* Hopefully the next two are no longer needed... */ if (!pty_err && ( #ifndef PTY_USE_NDELAY @@ -15693,7 +15688,7 @@ ttptycmd(s) char *s; /* See if we can exit */ - x1 = pbuf_avail - pbuf_written; + x1 = pbuf_avail - pbuf_written; x2 = tbuf_avail - tbuf_written; debug(F101,"ttptycmd pty_err LOOP EXIT TEST pty_err","",pty_err); @@ -15718,7 +15713,7 @@ ttptycmd(s) char *s; } if (pty_err) { /* Pty error? */ if (have_pty) { - if (pexitstat < 0) { + if (pexitstat < 0) { status = pty_get_status(ptyfd,pty_fork_pid); debug(F101,"ttptycmd pty_get_status E","",status); if (status > -1) pexitstat = status; @@ -15856,7 +15851,8 @@ external protocols over secure connections not supported in this OS.\n" debug(F101,"ttruncmd system",s,x); _exit(x ? BAD_EXIT : 0); } else { - SIGTYP (*istat)(), (*qstat)(); + sig_t istat; + sig_t qstat; if (pid == (PID_T) -1) /* fork() failed? */ return(0); istat = signal(SIGINT,SIG_IGN); /* Let the fork handle keyboard */ diff --git a/ckuus2.c b/ckuus2.c index 3e8bd45..75d096c 100644 --- a/ckuus2.c +++ b/ckuus2.c @@ -1903,7 +1903,7 @@ static char *hmxxchange[] = { " /DESTINATION:name Store resulting changed files in named directory.", " If neither of these options is given, original files are overwritten.", " ", -" String selection switches:", +" String selection switches:", " ", " /CASE:{ON,OFF} OFF (default) = ignore case in string1; \ ON = don't ignore", @@ -2531,7 +2531,7 @@ static char *hmxxpat[] = { "All other commands and functions use anchored patterns, meaning that ^ and $", "are not treated specially, and * is not assumed at the beginning or end of", "the pattern. This is true mainly of filename patterns (wildcards), since", -"you would not want a command like \"delete x\" to delete all files whose", +"you would not want a command like \"delete x\" to delete all files whose", "names contained \"x\"!", " ", @@ -7811,7 +7811,7 @@ static char *hxymouse[] = { " Button 1 Ctrl-Shift-Drag = Kverb: \\Kdump", " Button 2 Double-Click = Kverb: \\Kpaste", " Button 2 Drag = Kverb: \\Kmarkcopyhost", -" Button 2 Alt-Drag = Kverb: \\Kmarkcopyhost_noeol ", +" Button 2 Alt-Drag = Kverb: \\Kmarkcopyhost_noeol ", " Button 3 Double-Click = Kverb: \\Kpaste", #ifndef NOSCROLLWHEEL " Wheel Up = Kverb: \\Kupone", @@ -8623,7 +8623,7 @@ Enter CONNECT (terminal) mode automatically if the connection is successful.", " SET HOST madlab.sprl.umich.edu 3000", " SET HOST xyzcorp.com 2000 /RAW-SOCKET", #ifdef SSHBUILTIN -" SET HOST /NET:SSH kermit.columbia.edu /x11-forwarding:on", +" SET HOST /NET:SSH kermit.columbia.edu /x11-forwarding:on", #endif /* SSHBUILTIN */ #ifdef NETCMD " SET HOST /CONNECT /COMMAND rlogin xyzcorp.com", @@ -12065,7 +12065,7 @@ Returns number:\n"); 0 if file not found or not recognized;\n\ 1 if orientation is landscape;\n\ 2 if orientation is portrait;\n\ - 3 if the image is square.\n"); + 3 if the image is square.\n"); printf("\n\ If an array name is included, and if the function's return value is\n\ greater than 0, element 1 of the array is filled in with the image\n\ @@ -12080,7 +12080,7 @@ width in pixels, element 2 the image height, and element 3 is the image's\n\ printf("Returns integer:\n\ -1 on failure to get information;\n\ 1 if n1 is the ID of an active process;\n\ - 0 if the process does not exist.\n"); + 0 if the process does not exist.\n"); break; case FN_FUNC: @@ -12088,7 +12088,7 @@ width in pixels, element 2 the image height, and element 3 is the image's\n\ s1 = name of function.\n"); printf("Returns integer:\n\ 1 if s1 is the name of an available built-in function;\n\ - 0 otherwise.\n"); + 0 otherwise.\n"); break; case FN_RECURSE: @@ -14364,181 +14364,181 @@ dohkverb(xx) int xx; { case K_I31_F01: printf("\\Ki31_f01 Transmit IBM 31xx: F1\n"); break; - case K_I31_F02: + case K_I31_F02: printf("\\Ki31_f02 Transmit IBM 31xx: F2\n"); break; - case K_I31_F03: + case K_I31_F03: printf("\\Ki31_f03 Transmit IBM 31xx: F3\n"); break; - case K_I31_F04: + case K_I31_F04: printf("\\Ki31_f04 Transmit IBM 31xx: F4\n"); break; - case K_I31_F05: + case K_I31_F05: printf("\\Ki31_f05 Transmit IBM 31xx: F5\n"); break; - case K_I31_F06: + case K_I31_F06: printf("\\Ki31_f06 Transmit IBM 31xx: F6\n"); break; - case K_I31_F07: + case K_I31_F07: printf("\\Ki31_f07 Transmit IBM 31xx: F7\n"); break; - case K_I31_F08: + case K_I31_F08: printf("\\Ki31_f08 Transmit IBM 31xx: F8\n"); break; - case K_I31_F09: + case K_I31_F09: printf("\\Ki31_f09 Transmit IBM 31xx: F9\n"); break; - case K_I31_F10: + case K_I31_F10: printf("\\Ki31_f10 Transmit IBM 31xx: F10\n"); break; - case K_I31_F11: + case K_I31_F11: printf("\\Ki31_f11 Transmit IBM 31xx: F11\n"); break; - case K_I31_F12: + case K_I31_F12: printf("\\Ki31_f12 Transmit IBM 31xx: F12\n"); break; - case K_I31_F13: + case K_I31_F13: printf("\\Ki31_f13 Transmit IBM 31xx: F13\n"); break; - case K_I31_F14: + case K_I31_F14: printf("\\Ki31_f14 Transmit IBM 31xx: F14\n"); break; - case K_I31_F15: + case K_I31_F15: printf("\\Ki31_f15 Transmit IBM 31xx: F15\n"); break; - case K_I31_F16: + case K_I31_F16: printf("\\Ki31_f16 Transmit IBM 31xx: F16\n"); break; - case K_I31_F17: + case K_I31_F17: printf("\\Ki31_f17 Transmit IBM 31xx: F17\n"); break; - case K_I31_F18: + case K_I31_F18: printf("\\Ki31_f18 Transmit IBM 31xx: F18\n"); break; - case K_I31_F19: + case K_I31_F19: printf("\\Ki31_f19 Transmit IBM 31xx: F19\n"); break; - case K_I31_F20: + case K_I31_F20: printf("\\Ki31_f20 Transmit IBM 31xx: F20\n"); break; - case K_I31_F21: + case K_I31_F21: printf("\\Ki31_f21 Transmit IBM 31xx: F21\n"); break; - case K_I31_F22: + case K_I31_F22: printf("\\Ki31_f22 Transmit IBM 31xx: F22\n"); break; - case K_I31_F23: + case K_I31_F23: printf("\\Ki31_f23 Transmit IBM 31xx: F23\n"); break; - case K_I31_F24: + case K_I31_F24: printf("\\Ki31_f24 Transmit IBM 31xx: F24\n"); break; - case K_I31_F25: + case K_I31_F25: printf("\\Ki31_f25 Transmit IBM 31xx: F25\n"); break; - case K_I31_F26: + case K_I31_F26: printf("\\Ki31_f26 Transmit IBM 31xx: F26\n"); break; - case K_I31_F27: + case K_I31_F27: printf("\\Ki31_f27 Transmit IBM 31xx: F27\n"); break; - case K_I31_F28: + case K_I31_F28: printf("\\Ki31_f28 Transmit IBM 31xx: F28\n"); break; - case K_I31_F29: + case K_I31_F29: printf("\\Ki31_f29 Transmit IBM 31xx: F29\n"); break; - case K_I31_F30: + case K_I31_F30: printf("\\Ki31_f30 Transmit IBM 31xx: F30\n"); break; - case K_I31_F31: + case K_I31_F31: printf("\\Ki31_f31 Transmit IBM 31xx: F31\n"); break; - case K_I31_F32: + case K_I31_F32: printf("\\Ki31_f32 Transmit IBM 31xx: F32\n"); break; - case K_I31_F33: + case K_I31_F33: printf("\\Ki31_f33 Transmit IBM 31xx: F33\n"); break; - case K_I31_F34: + case K_I31_F34: printf("\\Ki31_f34 Transmit IBM 31xx: F34\n"); break; - case K_I31_F35: + case K_I31_F35: printf("\\Ki31_f35 Transmit IBM 31xx: F35\n"); break; - case K_I31_F36: + case K_I31_F36: printf("\\Ki31_f36 Transmit IBM 31xx: F36\n"); break; - case K_I31_PA1: + case K_I31_PA1: printf("\\Ki31_pa1 Transmit IBM 31xx: PA1\n"); break; - case K_I31_PA2: + case K_I31_PA2: printf("\\Ki31_pa2 Transmit IBM 31xx: PA2\n"); break; - case K_I31_PA3: + case K_I31_PA3: printf("\\Ki31_pa3 Transmit IBM 31xx: PA3\n"); break; case K_I31_RESET: printf("\\Ki31_reset Transmit IBM 31xx: Reset\n"); - break; - case K_I31_JUMP: + break; + case K_I31_JUMP: printf("\\Ki31_jump Transmit IBM 31xx: Jump\n"); break; - case K_I31_CLEAR: + case K_I31_CLEAR: printf("\\Ki31_clear Transmit IBM 31xx: Clear\n"); break; - case K_I31_ERASE_EOF: + case K_I31_ERASE_EOF: printf("\\Ki31_erase_eof Transmit IBM 31xx: Erase to End of Field\n"); break; - case K_I31_ERASE_EOP: + case K_I31_ERASE_EOP: printf("\\Ki31_eop Transmit IBM 31xx: Erase to End of Page\n"); break; - case K_I31_ERASE_INP: + case K_I31_ERASE_INP: printf("\\Ki31_inp Transmit IBM 31xx: Erase Input Operation\n"); break; - case K_I31_INSERT_CHAR: + case K_I31_INSERT_CHAR: printf("\\Ki31_ins_char Transmit IBM 31xx: Insert Character\n"); break; case K_I31_INSERT_SPACE: printf("\\Ki31_ins_space Transmit IBM 31xx: Insert Space\n"); break; - case K_I31_DELETE: + case K_I31_DELETE: printf("\\Ki31_delete Transmit IBM 31xx: Delete Character\n"); break; - case K_I31_INS_LN: + case K_I31_INS_LN: printf("\\Ki31_ins_line Transmit IBM 31xx: Insert Line\n"); break; - case K_I31_DEL_LN: + case K_I31_DEL_LN: printf("\\Ki31_del_ln Transmit IBM 31xx: Delete Line\n"); break; - case K_I31_PRINT_LINE: + case K_I31_PRINT_LINE: printf("\\Ki31_prt_line Transmit IBM 31xx: Print Line\n"); break; - case K_I31_PRINT_MSG: + case K_I31_PRINT_MSG: printf("\\Ki31_prt_msg Transmit IBM 31xx: Print Message\n"); break; - case K_I31_PRINT_SHIFT: + case K_I31_PRINT_SHIFT: printf("\\Ki31_prt_shift Transmit IBM 31xx: Print Shift\n"); break; - case K_I31_CANCEL: + case K_I31_CANCEL: printf("\\Ki31_cancel Transmit IBM 31xx: Cancel\n"); break; - case K_I31_SEND_LINE: + case K_I31_SEND_LINE: printf("\\Ki31_send_line Transmit IBM 31xx: Send Line\n"); break; - case K_I31_SEND_MSG: + case K_I31_SEND_MSG: printf("\\Ki31_send_msg Transmit IBM 31xx: Send Message\n"); break; - case K_I31_SEND_PAGE: + case K_I31_SEND_PAGE: printf("\\Ki31_send_page Transmit IBM 31xx: Send Page\n"); break; - case K_I31_HOME: + case K_I31_HOME: printf("\\Ki31_home Transmit IBM 31xx: Home\n"); break; - case K_I31_BACK_TAB: + case K_I31_BACK_TAB: printf("\\Ki31_back_tab Transmit IBM 31xx: Back Tab\n"); break; - case K_SUN_STOP: + case K_SUN_STOP: printf("\\Ksunstop Transmit SUN Console: Stop\n"); break; case K_SUN_AGAIN: @@ -14547,28 +14547,28 @@ dohkverb(xx) int xx; { case K_SUN_PROPS: printf("\\Ksunprops Transmit SUN Console: Props\n"); break; - case K_SUN_UNDO: + case K_SUN_UNDO: printf("\\Ksunundo Transmit SUN Console: Undo\n"); break; case K_SUN_FRONT: printf("\\Ksunfront Transmit SUN Console: Front\n"); break; - case K_SUN_COPY: + case K_SUN_COPY: printf("\\Ksuncopy Transmit SUN Console: Copy\n"); break; - case K_SUN_OPEN: + case K_SUN_OPEN: printf("\\Ksunopen Transmit SUN Console: Open\n"); break; case K_SUN_PASTE: printf("\\Ksunpaste Transmit SUN Console: Paste\n"); break; - case K_SUN_FIND: + case K_SUN_FIND: printf("\\Ksunfind Transmit SUN Console: Find\n"); break; - case K_SUN_CUT: + case K_SUN_CUT: printf("\\Ksuncut Transmit SUN Console: Cut\n"); break; - case K_SUN_HELP: + case K_SUN_HELP: printf("\\Ksunhelp Transmit SUN Console: Help\n"); break; diff --git a/ckuus3.c b/ckuus3.c index 3480f12..d8010e4 100644 --- a/ckuus3.c +++ b/ckuus3.c @@ -2284,7 +2284,7 @@ parsdir(cx) int cx; dirpath[0] = '\0'; len = strlen(env) + 2*strlen(startupdir) + 2*strlen(inidir) - + (appdata0?2*strlen(appdata0):0) + + (appdata0?2*strlen(appdata0):0) + (appdata1?2*strlen(appdata1):0) + 2*strlen(zhome()) + 2*strlen(exedir) + 8*strlen("PHONES/") + 12; @@ -2296,13 +2296,13 @@ parsdir(cx) int cx; (env[0] && env[strlen(env)-1] == ';') ? "" : ";", startupdir, startupdir, "PHONES/", - appdata1 ? appdata1 : "", + appdata1 ? appdata1 : "", appdata1 ? "Kermit 95;" : "", - appdata1 ? appdata1 : "", + appdata1 ? appdata1 : "", appdata1 ? "Kermit 95/PHONES/;" : "", - appdata0 ? appdata0 : "", + appdata0 ? appdata0 : "", appdata0 ? "Kermit 95;" : "", - appdata0 ? appdata0 : "", + appdata0 ? appdata0 : "", appdata0 ? "Kermit 95/PHONES/;" : "", inidir, inidir, "PHONES/", @@ -2655,7 +2655,7 @@ extern int gui_dialog; /* u q _ o k -- User Query, get Yes/No or OK Cancel */ /* - Call with: + Call with: preface: Explanatory text to print, or NULL. prompt: Prompt. mask: Bitmask for legal responses: 1 = OK or Yes; 2 = No or Cancel. @@ -2664,7 +2664,7 @@ extern int gui_dialog; Returns: -1: Invalid argument(s). 0: User said No or Cancel. - 1 User said Yes or OK. + 1 User said Yes or OK. Notes: preface and prompt should not include final line terminator but may include embedded ones. Help text is in case GUI dialog needs a Help @@ -2711,7 +2711,7 @@ uq_ok(preface,prompt,mask,help,dflt) free(text); if (!rc) return(-1); - else + else return(1); } else #endif /* KUI */ @@ -2733,7 +2733,7 @@ uq_ok(preface,prompt,mask,help,dflt) rc = MessageBox(hwndConsole, text ? text : prompt, prompt, - MB_YESNO | MB_ICONINFORMATION | MB_TASKMODAL | + MB_YESNO | MB_ICONINFORMATION | MB_TASKMODAL | (dflt == 2 ? MB_DEFBUTTON2 : MB_DEFBUTTON1)); #ifndef CKT_NT35_OR_31 ShowWindowAsync(hwndConsole,SW_SHOWNORMAL); @@ -2764,9 +2764,9 @@ uq_ok(preface,prompt,mask,help,dflt) /* u q _ t x t -- User Query, get single text response */ /* - Call with: + Call with: preface: Explanatory text to print, or NULL. - prompt: Prompt. + prompt: Prompt. echo: 0 = don't echo; 1 = echo; 2 = echo with asterisks. help: Help text (array of strings or NULL) [not used by parser]. buf: Pointer to result buffer. @@ -2775,17 +2775,17 @@ uq_ok(preface,prompt,mask,help,dflt) timer: Optional Timeout Returns: 0: User said No or Cancel. - 1 User said Yes or OK. + 1 User said Yes or OK. Notes: preface, prompt, and help as for uq_ok(). */ int #ifdef CK_ANSIC -uq_txt(char * preface, char * prompt, int echo, char ** help, char * buf, +uq_txt(char * preface, char * prompt, int echo, char ** help, char * buf, int buflen, char *dflt, int timer) #else /* CK_ANSIC */ uq_txt(preface,prompt,echo,help,buf,buflen,dflt,timer) - char * preface, * prompt, ** help, * buf, * dflt; + char * preface, * prompt, ** help, * buf, * dflt; int buflen, echo, timer; #endif /* CK_ANSIC */ { @@ -2806,7 +2806,7 @@ uq_txt(preface,prompt,echo,help,buf,buflen,dflt,timer) return(rc); } /* Otherwise, the dialog could not be created. Fallback to text mode */ - } + } #endif /* KUI */ #ifndef NOLOCAL #ifdef OS2 @@ -2837,14 +2837,14 @@ uq_txt(preface,prompt,echo,help,buf,buflen,dflt,timer) /* u q _ m t x t -- User Query, get multiple text responses */ /* - Call with: + Call with: preface: Explanatory text to print, or NULL. help: Help text (array of strings or NULL) [not used by parser]. n: Number of responses wanted. field: Array of struct txtbox, one element per field, see ckuusr.h. Returns: 0: User said No or Cancel. - 1 User said Yes or OK. + 1 User said Yes or OK. Notes: preface and help as for uq_ok(). */ @@ -2853,7 +2853,7 @@ int uq_mtxt(char * preface,char **help, int n, struct txtbox field[]) #else /* CK_ANSIC */ uq_mtxt(preface,help,n,field) - char * preface; char ** help; int n; struct txtbox field[]; + char * preface; char ** help; int n; struct txtbox field[]; #endif /* CK_ANSIC */ { #ifndef NOLOCAL @@ -2909,12 +2909,12 @@ uq_mtxt(preface,help,n,field) /* u q _ f i l e -- User Query, get file or directory name */ /* - Call with: + Call with: preface: Explanatory text to print, or NULL. prompt: Prompt string. fc: Function code: 1 = input (existing) file - 2 = existing directory + 2 = existing directory 3 = create new output file 4 = output file allowing append access 5 = same as 3, but don't label the GUI save button "Download" @@ -4844,12 +4844,12 @@ dochk() { extern int nolocale; int ok = 0; ok = (nolocale ? 0 : 1); - if (msgflg) + if (msgflg) printf(" locale%s available\n", ok ? "" : " not"); else if (nolocale && !backgrd) printf(" CHECK: locale not available\n"); return(success = ok); - } + } #endif /* HAVE_LOCALE */ #ifndef NOPUSH if (!ckstrcmp(line,"push",(int)strlen(line),0)) { @@ -6467,7 +6467,7 @@ settapi() { success = seton(&tapipass); tapipass = !tapipass; return (success); -#endif /* NODIAL */ +#endif /* NODIAL */ } case XYTAPI_LOC: { /* TAPI LOCATION */ extern char tapiloc[]; @@ -6536,7 +6536,7 @@ setvareval() { #endif /* DCMDBUF */ if ((x = cmkey(varevaltab, - nvarevaltab, + nvarevaltab, "Method for evaluating \\%x and \\&x[] variables", "", xxstring)) < 0) @@ -7184,7 +7184,7 @@ setextern() { /* SET EXTERNAL-PROTOCOL */ return(y); exp_handler = x; break; - + #ifdef COMMENT case EXP_STDERR: if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0) @@ -7804,7 +7804,7 @@ setprinter(xx) int xx; #endif /* OS2ORUNIX */ #ifdef OS2 - if ( pv[PRN_CS].ival > 0 ) + if ( pv[PRN_CS].ival > 0 ) prncs = pv[PRN_CS].ival; if ( pv[PRN_PS].ival > 0 ) { @@ -9530,7 +9530,7 @@ VOID #ifdef CK_ANSIC setexitwarn( int x ) #else -setexitwarn(x) int x; +setexitwarn(x) int x; #endif /* CK_ANSIC */ { xitwarn = x; @@ -9657,7 +9657,7 @@ case XYPAD: /* SET PAD ... */ case MCH_FIFO: return(success = seton(&matchfifo)); case MCH_DOTF: - x = seton(&matchdot); + x = seton(&matchdot); if (x < 0) return(x); dir_dots = -1; return(success = x); @@ -9807,7 +9807,7 @@ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"); /* Construct default name */ if (z == NET_PIPE) { /* Named pipe */ defnam = "kermit"; /* Default name is always "kermit" */ - } + } #ifdef CK_NETBIOS else { /* NetBIOS */ if (NetBiosName[0] != SP) { /* If there is already a name, */ @@ -10028,7 +10028,7 @@ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"); return(x); } ckstrncpy((n == UPW_USER) ? ubuf : - ((n == UPW_PASS) ? pbuf : abuf), s, + ((n == UPW_PASS) ? pbuf : abuf), s, (n == UPW_AGENT) ? 256 : (LOGINLEN+1)); } } @@ -12248,7 +12248,7 @@ case XYDEBU: /* SET DEBUG { on, off, session } */ if (ftpisopen()) { /* If an FTP connection is open */ extern int ftp_xfermode; /* change its transfer mode too */ ftp_xfermode = xfermode; - } + } #endif /* NEWFTP */ return(success = 1); @@ -12353,16 +12353,16 @@ case XYDEBU: /* SET DEBUG { on, off, session } */ } switch (y) { case WILD_ON: - wildena = 1; + wildena = 1; break; case WILD_OFF: - wildena = 0; + wildena = 0; break; case WILD_KER: wildxpand = 0; /* These are the previous */ break; /* hardwired values */ case WILD_SHE: - wildxpand = 1; + wildxpand = 1; break; } matchdot = z; @@ -14116,7 +14116,7 @@ case XYDEBU: /* SET DEBUG { on, off, session } */ if (!setlocale(LC_NUMERIC, s)) {perror("NUMERIC");return(success=0);} if (!setlocale(LC_TIME, s)) {perror("TIME");return(success=0);} #endif /* COMMENT */ - return(success=1); + return(success=1); #endif /* HAVE_LOCALE */ default: diff --git a/ckuus4.c b/ckuus4.c index dc65d39..1a081bc 100644 --- a/ckuus4.c +++ b/ckuus4.c @@ -30,7 +30,7 @@ #include "ckcxla.h" /* Character sets */ #ifdef HAVE_LOCALE -#include +#include #endif /* HAVE_LOCALE */ #ifdef CK_AUTHENTICATION @@ -1379,7 +1379,7 @@ findinpath(arg) char * arg; len = strlen(scriptenv) + strlen(keymapenv) + 3*strlen(startupdir) + 3*strlen(inidir) + 3*strlen(zhome()) + 3*strlen(exedir) - + (appdata0 ? 3*strlen(appdata0) : 0) + + (appdata0 ? 3*strlen(appdata0) : 0) + (appdata1 ? 3*strlen(appdata1) : 0) + 6*strlen("SCRIPTS/") + 6*strlen("KEYMAPS/") + 16; @@ -1397,7 +1397,7 @@ findinpath(arg) char * arg; startupdir, startupdir, "SCRIPTS/", startupdir, "KEYMAPS/", - appdata1 ? appdata1 : "", + appdata1 ? appdata1 : "", appdata1 ? "Kermit 95;" : "", appdata1 ? appdata1 : "", appdata1 ? "Kermit 95/SCRIPTS/;" : "", @@ -2610,14 +2610,9 @@ transmit(s,t,xlate,binary,xxecho) char *s; char t; int xlate, binary, xxecho; #else int count = 0; #ifdef OS2 -#ifdef NT SIGTYP (* oldsig)(int); /* For saving old interrupt trap. */ -#else /* NT */ - SIGTYP (* volatile oldsig)(int); -#endif /* NT */ - #else /* OS2 */ - SIGTYP (* oldsig)(); + sig_t oldsig; #endif /* OS2 */ #endif /* MAC */ int eof = 0; /* End of File flag */ @@ -3302,14 +3297,8 @@ xlate(fin, fout, csin, csout) char *fin, *fout; int csin, csout; extern int k95stdout; extern int wherex[], wherey[]; extern unsigned char colorcmd; -#ifdef NT - SIGTYP (* oldsig)(int); /* For saving old interrupt trap. */ -#else /* NT */ - SIGTYP (* volatile oldsig)(int); /* For saving old interrupt trap. */ -#endif /* NT */ -#else /* OS2 */ - SIGTYP (* oldsig)(); #endif /* OS2 */ + sig_t oldsig; #endif /* MAC */ #ifdef CK_ANSIC int (*fn)(char); /* Output function pointer */ @@ -3731,7 +3720,7 @@ homepath() { extern char hompthbuf[]; extern char * myhome; char * h; - + /* myhome = SET CD HOME; zhome() uses API to get home directory */ h = myhome ? myhome : zhome(); hompthbuf[0] = NUL; @@ -6813,7 +6802,7 @@ doinput(timo,ms,mp,flags,count) if (local) { /* In local mode... */ if ((waiting = ttchk()) < 0) { /* check that connection is open */ if (!quiet) { - if ((!network + if ((!network #ifdef TN_COMPORT || istncomport() #endif /* TN_COMPORT */ @@ -7080,7 +7069,7 @@ doinput(timo,ms,mp,flags,count) #ifdef IKS_OPTION tx = scriptwrtbuf((USHORT)y); if (tx == 4) { - if (TELOPT_U(TELOPT_KERMIT) && + if (TELOPT_U(TELOPT_KERMIT) && TELOPT_SB(TELOPT_KERMIT).kermit.u_start && !tcp_incoming ) { @@ -7284,7 +7273,7 @@ doinput(timo,ms,mp,flags,count) ckstrncpy(matchbuf,ms[y],MATCHBUFSIZ); matchindex = 0; instatus = INP_OK; /* Yes, */ - x = 1; + x = 1; break; /* done. */ } mi[y] = i; /* No, remember match-position */ @@ -7323,7 +7312,7 @@ doinput(timo,ms,mp,flags,count) #endif /* OS2 */ #endif /* NOLOCAL */ - if ((!network + if ((!network #ifdef TN_COMPORT || istncomport() #endif /* TN_COMPORT */ @@ -8117,7 +8106,7 @@ dokwval(s,sep) char * s, * sep; debug(F110,"kwval value",vp,0); x = addmac(kw,vp); debug(F111,"kwval addmac",kw,x); - xdokwval: + xdokwval: if (p) free(p); return((x < 0) ? "-1" : rc); } @@ -8149,7 +8138,7 @@ isaarray(s) char * s; /* J P G D A T E -- Get "date taken" from JPG file Exif data */ /* - This routine doesn't follow the Exif spec, it just hunts for + This routine doesn't follow the Exif spec, it just hunts for date-time strings in the first 8K of the JPG and keeps the earliest one. Call with file pointer, returns Exif date-time string "yyyy:mm:dd hh:mm:ss" or an empty string if none found. @@ -8196,7 +8185,7 @@ jpgdate(fp) FILE * fp; return(""); } p = (CHAR *) buf; - z = p + JPGDATEBUF; + z = p + JPGDATEBUF; while (p < z) { c = *p++; @@ -8481,7 +8470,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; #endif /* COMMENT */ if (cx == FN_CON) { /* Contents of variable, unexpanded. */ char c; - int subscript = 0; + int subscript = 0; if (!(p = argp[0]) || !*p) { failed = 1; p = fnval; @@ -8556,7 +8545,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; } else { /* Array not declared or element */ fnval[0] = NUL; /* out of range - return null string */ p = fnval; /* fdc 2010-12-30 */ - goto fnend; + goto fnend; } } else { failed = 1; @@ -8653,7 +8642,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; if (argn != old) debug(F101,"fneval adjusted argn","",argn); #endif /* DEBUG */ - } + } /* From this point on, bp[0..argn-1] are not NULL and all must be freed @@ -9076,7 +9065,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; i = 0; while (start >= 0 && j <= desired) { for (i = start; - (i >= 0) && + (i >= 0) && !(k = ckmatch(pat,s+i,inpcas[cmdlvl],1+4)); i--) ; if (k < 1) { /* No match */ @@ -9099,7 +9088,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; i = ckmatch(pat,&s[start],inpcas[cmdlvl],1+4); if (i == 0 || j == desired) break; start += i + 1; - } + } if (j == desired && i != 0) i += start; else @@ -9128,7 +9117,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; bp[1] = match string (len2) bp[2] = replacement string (len3) bp[3] = which occurrence (default = all); - bp[4] = context sensitive ("word mode") 20171005 + bp[4] = context sensitive ("word mode") 20171005 fnval = p = destination (result) string */ if (argn < 1) /* Nothing */ @@ -9179,7 +9168,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; } else { ragain: s = bp[0]; /* Point to beginning of source string */ - + xx = 0; /* Match counter */ while (*s) { /* For each character in it...*/ /* Compare current segment with target string */ @@ -9198,7 +9187,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; if (c != 32 && c != '.') left = 1; } - c = *(s+len2); /* Check following char */ + c = *(s+len2); /* Check following char */ if (c != '.' && (c == SP || c == '\0')) right = 1; } else if (isalphanum(bp[1])) { @@ -9237,7 +9226,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; ok = 1; /* OK to replace */ xx++; /* Count this match */ } - } else + } else #endif /* RPLWORDMODE */ xx++; /* Straight replace - count every match */ @@ -10298,7 +10287,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; x = atoi(bp[0]); } #ifdef COMMENT - sprintf(fnval,"%d", (x > 0 && k > 0) || (x < 0 && k < 0) ? k % x : + sprintf(fnval,"%d", (x > 0 && k > 0) || (x < 0 && k < 0) ? k % x : (x == 0 ? 0 : (0 - (k % (-x))))); #else debug(F111,"rand",ckitoa(x),k); @@ -10772,7 +10761,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; /* Element 4 - Permissions string */ -#ifdef UNIX +#ifdef UNIX if (zgfs_link) s = "lrwxrwxrwx"; else @@ -10797,7 +10786,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; makestr(&(a_ptr[x][5]),s); /* Element 6 - Size in bytes */ - + #ifdef UNIX /* [fdc] 2021-09-14 only Unix has file links */ s = zgfs_link ? ckitoa((int)strlen((char *)linkname)) : ckfstoa(z); #else @@ -10805,7 +10794,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; #endif /* UNIX */ a_ptr[x][6] = NULL; makestr(&(a_ptr[x][6]),s); - + /* Element 7 - File type */ j = 0; @@ -11902,7 +11891,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; n = 0; /* reset space counter */ *p++ = *s++; /* copy char to destination */ continue; - } + } if (n++ > 0) { /* Have blank or tab */ s++; /* don't copy more than one */ continue; @@ -12836,7 +12825,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; goto fnend; } } - } + } } picend: @@ -12923,7 +12912,7 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; /* NOTE: This is vulnerable to SIGINT and whatnot... */ int tmp = vareval; /* Save VARIABLE-EVALUATION setting */ vareval = 1; /* Force it to RECURSIVE */ - zzstring(bp[0],&s,&n); /* Expand arg into result space */ + zzstring(bp[0],&s,&n); /* Expand arg into result space */ vareval = tmp; /* Restore VARIABLE-EVALUATION */ } goto fnend; @@ -12931,16 +12920,16 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; if (cx == FN_XLATE) { /* f_cvtcset() */ #ifdef NOFRILLS - ckstrncpy(fnval,bp[0],FNVALL); + ckstrncpy(fnval,bp[0],FNVALL); #else #ifndef NOUNICODE _PROTOTYP( char * cvtstring, (char *, int, int) ); char * string, * cset1, * cset2; int id1, id2; #endif /* NOUNICODE */ - fnval[0] = NUL; + fnval[0] = NUL; #ifdef NOUNICODE - ckstrncpy(fnval,bp[0],FNVALL); + ckstrncpy(fnval,bp[0],FNVALL); #else string = bp[0] ? bp[0] : ""; /* String to convert */ if (!*string) goto fnend; /* It's empty */ @@ -13066,8 +13055,8 @@ fneval(fn,argp,argn,xp) char *fn, *argp[]; int argn; char * xp; if (argn > 4) { s = *(bp[4]) ? evalx(bp[4]) : "-1"; /* -1 = whole thing */ if (chknum(s)) len = atoi(s); - } - } + } + } } if (start > 0) start--; /* start is 0-based internally */ s1 = bp[0]; /* Get length of first arg */ @@ -14242,7 +14231,7 @@ char * /* Evaluate builtin variable */ } #endif /* Not VMS */ } - makestr(&tempdir,p); /* Save result where we can find it next time */ + makestr(&tempdir,p); /* Save result where we can find it next time */ return(vvbuf); } /* Break up long switch statements... */ @@ -15302,7 +15291,7 @@ char * /* Evaluate builtin variable */ case VN_LOG_CON: /* \v(...) for log files */ #ifdef CKLOGDIAL return(diafil); -#else +#else return(""); #endif case VN_LOG_PKT: @@ -15866,7 +15855,7 @@ zzstring(s,s2,n) char *s; char **s2; int *n; #endif /* DEBUG */ { /* In case the function name itself is constructed */ - char buf[64]; char * p = buf; int n = 64; + char buf[64]; char * p = buf; int n = 64; if (zzstring(vnambuf,&p,&n) > -1) ckstrncpy(vnambuf,buf,64); } @@ -15965,7 +15954,7 @@ zzstring(s,s2,n) char *s; char **s2; int *n; vp = getenv(vnambuf); /* This way for environment variable */ } else if (x == 'm' || x == 's' || x == ':') { /* Macro / substr */ int k, x1 = -1, x2 = -1; - char c = NUL; + char c = NUL; k = strlen(vnambuf); /* \s(name[n:m]) -- Compact substring notation */ if ((x == 's' || x == ':') && (k > 1)) { /* Substring wanted */ diff --git a/ckuus5.c b/ckuus5.c index fdd286b..45431f5 100644 --- a/ckuus5.c +++ b/ckuus5.c @@ -689,7 +689,7 @@ char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,", "do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)", ""}; -/* +/* FOR macro for \%i-style loop variables (see dofor()...) \%1 = Loop variable \%2 = Initial value (can be an expression) @@ -2156,7 +2156,7 @@ getncm(s,n) char *s; int n; /* Next char is command separator... */ /* Sun May 11 17:24:12 2003 */ (kp < 1 && pp < 1 && (*(macp[maclvl]+1) == ',')) - ) + ) dq = 0; /* Close the quote */ } else if (dq == 0) { /* Open quote only if at beginning or preceded by space */ @@ -2696,7 +2696,7 @@ cmderr() { case 3: printf("Command stack:\n"); - shostack(); + shostack(); } } } @@ -5905,7 +5905,7 @@ shotabs() { n = (j+2)/100; if (n) printf("%d",n); - else + else printf("%c",'.'); break; case 9: @@ -5914,7 +5914,7 @@ shotabs() { printf("%d",n); else if (j>90) printf("0"); - else + else printf("%c",'.'); break; case 0: @@ -6104,9 +6104,9 @@ shotrm() { if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; } printf(" %19s: %-13s %13s: %-15s\n","Cursor", #ifdef KUI - (tt_cursor == 2) ? (tt_cursor_blink ? + (tt_cursor == 2) ? (tt_cursor_blink ? "full (*)" : "full (.)") : - (tt_cursor == 1) ? (tt_cursor_blink ? + (tt_cursor == 1) ? (tt_cursor_blink ? "half (*)" : "half (.)") : (tt_cursor_blink ? "underline (*)" : "underline (.)"), #else /* KUI */ @@ -6115,7 +6115,7 @@ shotrm() { #endif /* KUI */ #ifdef CK_AUTODL "autodownload",(autodl == TAD_ON && adl_ask == 0) ? - (adl_err ? "on, error stop" : "on, error continue") : + (adl_err ? "on, error stop" : "on, error continue") : (autodl == TAD_ON && adl_ask == 1) ? (adl_err ? "ask, error stop" : "ask, error continue") : "off" @@ -6356,7 +6356,7 @@ shotrm() { printf( " Attribute: \ blink: %-3s dim: %-3s italic: %-3s reverse: %-3s underline: %-3s\n", - trueblink?"on":"off", truedim?"on":"off", trueitalic?"on":"off", + trueblink?"on":"off", truedim?"on":"off", trueitalic?"on":"off", truereverse?"on":"off", trueunderline?"on":"off"); if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; } } @@ -9222,7 +9222,7 @@ xarray(s) char * s; Returns: -1 on failure 0 on success -*/ +*/ int #ifdef CK_ANSIC @@ -9261,7 +9261,7 @@ boundspair(s,sep,lo,hi,zz) char *s, *sep, *zz; int *lo, *hi; s2 = ckstrchr(sep,*p); /* Check for separator */ if (s2) { debug(F000,"boundspair *s2","",*s2); - if (c) { + if (c) { debug(F000,"boundspair","Too many separators",*s2); makestr(&tmp,NULL); return(-1); @@ -10011,7 +10011,7 @@ xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; newerrmsg("Internal error: maclvl < 0"); } debug(F101," xwords splitting macro arguments.. maclvl","",maclvl); - + /* Space is the only separator; grouping is with "" or {} */ q = cksplit(1,0,p," ","ALL",1+2,0,0,1); z = q->a_size; /* Number of "words" in string */ diff --git a/ckuus6.c b/ckuus6.c index c4c74a1..048d086 100644 --- a/ckuus6.c +++ b/ckuus6.c @@ -917,14 +917,14 @@ int asktimedout = 0; static struct keytab asktab[] = { { "/default", ASK_DEF, CM_ARG }, - { "/gui", ASK_GUI, + { "/gui", ASK_GUI, #ifdef KUI 0 #else /* KUI */ CM_INV #endif /* KUI */ }, - { "/popup", ASK_PUP, + { "/popup", ASK_PUP, #ifdef OS2 0 #else /* OS2 */ @@ -940,7 +940,7 @@ static int nasktab = sizeof(asktab)/sizeof(struct keytab)-1; static struct keytab askqtab[] = { { "/default", ASK_DEF, CM_ARG }, { "/echo", ASK_ECH, CM_ARG }, - { "/gui", ASK_GUI, + { "/gui", ASK_GUI, #ifdef KUI 0 #else /* KUI */ @@ -948,7 +948,7 @@ static struct keytab askqtab[] = { #endif /* KUI */ }, { "/noecho", ASK_QUI, CM_INV }, - { "/popup", ASK_PUP, + { "/popup", ASK_PUP, #ifdef OS2 0 #else /* OS2 */ @@ -995,7 +995,7 @@ doask(cx) int cx; char vnambuf[VNAML+1]; /* Buffer for variable names */ char *vnp = NULL; /* Pointer to same */ - + dfbuf[0] = NUL; vnambuf[0] = NUL; @@ -1161,10 +1161,10 @@ doask(cx) int cx; if (peek) { /* GETC /CHECK */ /* This was intended to mean "check how many characters are waiting to be - read from standard input". Conchk() was supposed to do that but it + read from standard input". Conchk() was supposed to do that but it doesn't when stdin is redirected. The best I can do is ask isatty(0) whether stdin is a terminal. If not we'll assume it's redirected stdin. - Btw, even if stdin really is a terminal conchk() returns 0, even if + Btw, even if stdin really is a terminal conchk() returns 0, even if there is typeahead. - fdc, 21 Apr 2017. */ int itsatty = -1; @@ -3093,7 +3093,7 @@ dodial(cx) int cx; dialsta = DIA_NOLI; return(success = 0); } - if ((!network + if ((!network #ifdef TN_COMPORT || istncomport() #endif /* TN_COMPORT */ @@ -3446,7 +3446,7 @@ Disabling flow control temporarily %s...\n", if (x && atmbuf[0]) { /* They gave a new one */ s = atmbuf; makestr(&(dn_p2[j]), s); - } + } #else /* COMMENT */ @@ -4067,15 +4067,7 @@ dotype(file, paging, first, head, pat, width, prefix, incs, outcs, outfile, z) #endif /* NT */ #ifndef MAC -#ifdef OS2 -#ifdef NT - SIGTYP (* oldsig)(int); /* For saving old interrupt trap. */ -#else /* NT */ - SIGTYP (* volatile oldsig)(int); -#endif /* NT */ -#else /* OS2 */ - SIGTYP (* oldsig)(); -#endif /* OS2 */ + sig_t oldsig; #endif /* MAC */ #ifdef KUI @@ -4409,7 +4401,7 @@ dotype(file, paging, first, head, pat, width, prefix, incs, outcs, outfile, z) gui_text_popup_append(uch[i]); gui_text_popup_append(CK_CR); gui_text_popup_append(LF); - } + } else #endif /* NORICHEDIT */ #endif /* KUI */ @@ -5568,7 +5560,7 @@ domydir(cx) int cx; int changeinplace = 0; int changebackup = 0; int changes = 0; /* Change counter per file */ - int totalchanges = 0; /* Change counter all files */ + int totalchanges = 0; /* Change counter all files */ #ifndef NOSPL char array = NUL; @@ -5718,7 +5710,7 @@ domydir(cx) int cx; x = cmfdb(&sw); /* Parse something */ debug(F101,"domydir cmfdb","",x); if (x < 0) - return(x); + return(x); if (cmresult.fcode != _CMKEY) /* Break out if not a switch */ break; c = cmgbrk(); @@ -6023,7 +6015,7 @@ domydir(cx) int cx; ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Safe copy of filespec */ /* ^^^ START MULTIPLE */ - + while (!touch && !change) { /* Multiple filespecs only for DIR */ x = cmfld("Another filespec or Enter","",&s,xxstring); if (x == -3) @@ -6045,7 +6037,7 @@ domydir(cx) int cx; if (change) { /* Finish parsing CHANGE command */ debug(F110,"CHANGE source file",line,0); - x = cmfld("Text to be changed","",&s,xxstring); + x = cmfld("Text to be changed","",&s,xxstring); if (x < 0) { if (x == -3) { printf("?You must specify the text to be changed\n"); @@ -6058,7 +6050,7 @@ domydir(cx) int cx; s1len = ckstrncpy(string1,s,1024); debug(F110,"CHANGE string1",string1,0); - x = cmfld("Text to change it to","",&s2,xxstring); + x = cmfld("Text to change it to","",&s2,xxstring); if (x < 0 && x != -3) return(x); s2 = brstrip(s2); s2len = ckstrncpy(string2,s2,1024); @@ -6456,7 +6448,7 @@ domydir(cx) int cx; if (!tempdir) { /* Need a temporary directory */ x++; } else if (!*tempdir) { - x++; + x++; } /* It might make more sense to fall back on the current directory, or the @@ -6484,7 +6476,7 @@ domydir(cx) int cx; success = 0; goto xdomydir; } - } + } } else { /* Making a new copy of the file */ char * p = name, * p2 = NULL; debug(F110,"CHANGE chgdestdir",chgdestdir,0); @@ -6508,7 +6500,7 @@ domydir(cx) int cx; tmpfile,ck_errstr()); success = 0; goto xdomydir; - } + } } } if (changebackup) { /* Backing up original file? */ @@ -6533,8 +6525,8 @@ domydir(cx) int cx; backupfile,ck_errstr()); success = 0; goto xdomydir; - } - } + } + } } if ((ifp = fopen(name,"r")) == NULL) { /* Open input file */ printf("?Can't open file %s: %s\n",s,ck_errstr()); @@ -6670,7 +6662,7 @@ domydir(cx) int cx; goto xdomydir; } } else { /* Making new file... */ - result = tmpfile; + result = tmpfile; } if (chmtopt == CHMT_P) { /* If preserving file dates */ debug(F110,"Setting modtime",result,0); @@ -8881,7 +8873,7 @@ _PROTOTYP(int zcmpfn,(char *, char *)); #ifndef NOFRILLS #ifdef NT -int +int dolink() { /* Parse a file or a directory name */ int x, z, listing = 0, havename = 0, wild = 0, rc = 1; @@ -9823,7 +9815,7 @@ gnirts(s1, s2, len) char * s1, * s2; int len; Worker function to rename one file for dorenam() (below). old = name of file or directory to be renamed new = new name (not required for /UPPER, /LOWER, and /REPLACE) - replacing = 1 if doing string replacement on the name + replacing = 1 if doing string replacement on the name casing = 1 if converting name to lowercase, 2 if to uppercase all = if doing case conversion on all names, not just monocase ones converting = 1 if converting character sets @@ -9877,7 +9869,7 @@ renameone(old,new, int minus = 0; /* Occurrence is negative */ int allbut = 0; /* Occurrence is "all but" */ int arg2isfile = 0; /* Arg2 ("new") is a filename */ - + debug(F110,"RENAMEONE old",old,0); debug(F110,"RENAMEONE new",new,0); debug(F110,"RENAMEONE ren_sub[0]",ren_sub[0],0); @@ -9927,7 +9919,7 @@ renameone(old,new, ckstrncpy(dir,new,CKMAXPATH); /* put it here */ } else { /* otherwise */ arg2isfile++; /* flag that it's a filename */ - } + } } if (!casing && !replacing && !converting) { if (!*new) @@ -9943,7 +9935,7 @@ renameone(old,new, #else ckmakmsg(buf,size,new, old, NULL, NULL); #endif /* VMS */ - debug(F110,"RENAMEONE new new",new,0); + debug(F110,"RENAMEONE new new",new,0); new = buf; size = CKMAXPATH; } @@ -10043,17 +10035,17 @@ renameone(old,new, if (s0) { (VOID) gnirts(bp[0],s0,len0+1); bp[0] = s0; - } else return(0); + } else return(0); s1 = (char *)malloc(len1+1); /* Reverse target string */ if (s1) { (VOID) gnirts(bp[1],s1,len1+1); bp[1] = s1; - } else return(0); + } else return(0); s2 = (char *)malloc(len2+1); /* Reverse replacement string */ if (s2) { (VOID) gnirts(bp[2],s2,len2+1); bp[2] = s2; - } else return(0); + } else return(0); debug(F111,"RENAMEONE s0",s0,len0); debug(F111,"RENAMEONE s1",s1,len1); debug(F111,"RENAMEONE s2",s2,len2); @@ -10159,8 +10151,8 @@ renameone(old,new, } } debug(F110,"RENAMEONE new",new,0); - debug(F101,"RENAMEONE flag","",flag); - debug(F101,"RENAMEONE skip","",skip); + debug(F101,"RENAMEONE flag","",flag); + debug(F101,"RENAMEONE skip","",skip); debug(F100,"RENAMEONE ----------------","",0); if (skip == 3) { @@ -10556,7 +10548,7 @@ dorenam() { znext(line); if (!line[0]) break; - rc = renameone((char *)line,p, + rc = renameone((char *)line,p, replacing,casing,all,converting,cset1,cset2, listing,nolist,sim,TMPBUFSIZ,collision); } @@ -12247,7 +12239,7 @@ boolexp(cx) int cx; IF condition without having to enclose it in \m(...). */ if ( -#ifdef FNFLOAT +#ifdef FNFLOAT !isfloat(cmresult.sresult,0) /* Not a number */ #else !chknum(cmresult.sresult) /* Not a number */ diff --git a/ckuus7.c b/ckuus7.c index 3c11c6f..0b46f83 100644 --- a/ckuus7.c +++ b/ckuus7.c @@ -1857,7 +1857,7 @@ static struct keytab fdtab[] = { /* SET FILE DISPLAY options */ #endif /* CK_CURSES */ #ifdef KUI { "gui", XYFD_G, 0 }, /* GUI */ -#endif /* KUI */ +#endif /* KUI */ { "none", XYFD_N, 0 }, /* No display */ { "off", XYFD_N, CM_INV }, /* Ditto */ { "on", XYFD_R, CM_INV }, /* On = Serial */ @@ -4267,7 +4267,7 @@ setcmask(x) int x; cmask = 0377; parity = 0; } -#ifdef KUI +#ifdef KUI KuiSetProperty(KUI_TERM_CMASK,x,0); #endif /* KUI */ } @@ -4282,7 +4282,7 @@ setautodl(x,y) int x,y; { autodl = x; adl_ask = y; -#ifdef KUI +#ifdef KUI KuiSetProperty(KUI_TERM_AUTODOWNLOAD,x?(y?2:1):0,0); #endif /* KUI */ } @@ -4292,7 +4292,7 @@ setautodl(x,y) int x,y; VOID seturlhl(int x) { tt_url_hilite = x; -#ifdef KUI +#ifdef KUI KuiSetProperty(KUI_TERM_URL_HIGHLIGHT,x,0); #endif /* KUI */ } @@ -7140,7 +7140,7 @@ Make sure your timeout interval is long enough for %d-byte packets.\n",z); if ((x = cmcfm()) < 0) return(x); #endif /* COMMENT */ - + /* Check directory existence if absolute */ /* THIS MEANS IT CAN'T INCLUDE ANY DEFERRED VARIABLES! */ if (s) if (*s) { @@ -7325,7 +7325,7 @@ or type carriage return to confirm the command"; debug(F101,"remcfm local","",local); debug(F110,"remcfm s",s,0); debug(F101,"remcfm cmd","",xzcmd); -/* +/* This check was added in C-Kermit 6.0 or 7.0 but it turns out to be unhelpful in the situation where the remote is running a script that sends REMOTE commands to the local workstation. What happens is, the local @@ -9034,15 +9034,15 @@ cx_fail(msg, text) int msg; char * text; */ int #ifdef CK_ANSIC -cx_net( int net, int protocol, char * xhost, char * svc, +cx_net( int net, int protocol, char * xhost, char * svc, char * username, char * password, char * command, int param1, int param2, int param3, int cx, int sx, int flag, int gui) #else /* CK_ANSIC */ cx_net(net, protocol, xhost, svc, username, password, command, param1, param2, param3, cx, sx, flag, gui) - char * xhost, * svc, * username, *password, *command; - int net, protocol, cx, sx, flag, param1, param2, param3, gui; + char * xhost, * svc, * username, *password, *command; + int net, protocol, cx, sx, flag, param1, param2, param3, gui; #endif /* CK_ANSIC */ /* cx_net */ { @@ -9119,7 +9119,7 @@ cx_net(net, protocol, xhost, svc, /* XXX - Is this right? */ /* Should we be returning without doing anything ? */ /* Yes it's right -- we closed the old connection just above. */ - return(success = 1); + return(success = 1); } } success = 0; @@ -9740,7 +9740,7 @@ cx_net(net, protocol, xhost, svc, char * realm; /* We don't have the full hostname at yet so */ - /* we do a DNS lookup before calling ttopen() */ + /* we do a DNS lookup before calling ttopen() */ realm = ck_krb4_realmofhost(ckgetfqhostname(hostname)); ckmakmsg(tgt,256,"krbtgt.",realm,"@",realm); @@ -10188,11 +10188,11 @@ cx_net(net, protocol, xhost, svc, int #ifdef CK_ANSIC -cx_serial(char *device, +cx_serial(char *device, int cx, int sx, int shr, int flag, int gui, int special) #else /* CK_ANSIC */ cx_serial(device, cx, sx, shr, flag, gui, special) - char * device; int cx, sx, shr, flag, gui, special; + char * device; int cx, sx, shr, flag, gui, special; #endif /* CK_ANSIC */ /* cx_serial */ { int y, msg; @@ -10236,7 +10236,7 @@ cx_serial(device, cx, sx, shr, flag, gui, special) debug(F110,"OS2 SET PORT final s",s,""); #endif /* OS2 */ - /* Open the new line */ + /* Open the new line */ ckstrncpy(ttname,s,TTNAMLEN); if ((y = ttopen(s,&_local,mdmtyp,cdtimo)) > -1) { @@ -11057,10 +11057,10 @@ setlin(xx, zz, fc) int xx, zz, fc; if (line[0]) { if (strcmp(line,"*")) { /* If remote, begin with */ char * p = NULL; - makestr(&p,line); + makestr(&p,line); ckstrncpy(line,"\\\\",LINBUFSIZ); /* server name */ ckstrncat(line,p,LINBUFSIZ); - makestr(&p,NULL); + makestr(&p,NULL); } else { line[0]='\0'; } @@ -11121,7 +11121,7 @@ setlin(xx, zz, fc) int xx, zz, fc; #endif /* SUPERLAT */ #ifdef DECNET - if (mynet == NET_DEC) { + if (mynet == NET_DEC) { if (!line[0]) { /* If they gave a host name... */ printf("?hostname required\n"); return(-3); @@ -14913,7 +14913,7 @@ sho_auth(cx) int cx; printf(" Verify dir: %s\n",ssl_verify_dir? ssl_verify_dir:"(none)"); if (++n > cmd_rows - 3) { if (!askmore()) return(0); else n = 0; } - printf(" Cipher list: %s\n",ssl_cipher_list ? ssl_cipher_list : + printf(" Cipher list: %s\n",ssl_cipher_list ? ssl_cipher_list : DEFAULT_CIPHER_LIST); if (++n > cmd_rows - 3) { if (!askmore()) return(0); else n = 0; } if (ssl_con == NULL) { diff --git a/ckuusr.c b/ckuusr.c index 36462dd..29c6279 100644 --- a/ckuusr.c +++ b/ckuusr.c @@ -6269,7 +6269,7 @@ dodcl(cx) int cx; "]", NULL,NULL,NULL,NULL,NULL,NULL,NULL ); - + rc = cmfld((char *)tmp,"",&s,xxstring); /* Get field */ if (rc < 0) { /* Error... */ if (rc == -3) { /* Empty element */ @@ -8052,7 +8052,7 @@ redossh() { /* Like hmsga() in ckuus2.c but takes a single substitution parameter, s2, which replaces every occurrence of "%s" in the first argument. - Added to print text containing the copyright year, so the year doesn't + Added to print text containing the copyright year, so the year doesn't have to be hardwired into lots of scattered text strings. */ int /* Print an array of lines, */ @@ -8168,7 +8168,7 @@ isinternalmacro(x) int x; internal = 1; } } - } + } debug(F101," internal macro","B",internal); } } @@ -9375,7 +9375,7 @@ docmd(cx) int cx; } else { printf(" Long name: %s\n",line); printf(" Short name: %s\n",tmpbuf); - } + } #endif /* NT */ } return(success = ((int)strlen(pwp) > 0)); @@ -9712,7 +9712,7 @@ docmd(cx) int cx; x = cmresult.nresult; #ifdef CKFLOAT if (inscale != 1.0) /* Scale */ - x *= inscale; + x *= inscale; #endif /* CKFLOAT */ havetime++; break; @@ -9744,7 +9744,7 @@ docmd(cx) int cx; havetime++; } break; - default: + default: printf("?Internal error\n"); return(-9); } @@ -10568,7 +10568,7 @@ docmd(cx) int cx; return(0); } if (cx == XXTAK) { /* TAKE */ - char * scriptenv = NULL; + char * scriptenv = NULL; #ifdef OS2 char * GetAppData(int); extern char startupdir[],exedir[],inidir[]; @@ -11257,7 +11257,7 @@ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"); } } #endif /* NOSPL */ -#ifdef LOCUS +#ifdef LOCUS if (autolocus) setlocus(1,1); #endif /* LOCUS */ @@ -11693,7 +11693,7 @@ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"); struct FDB df, sw; /* - * char * sshkey_default_file(int keytype) + * char * sshkey_default_file(int keytype) * will provide the default filename for a given keytype * is it possible to have the default value for the 2nd * FDB set and changed when a /TYPE switch is provided? @@ -12206,7 +12206,7 @@ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"); } } #endif /* NOSPL */ -#ifdef LOCUS +#ifdef LOCUS if (autolocus) setlocus(1,1); #endif /* LOCUS */ @@ -12499,7 +12499,7 @@ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"); } } #endif /* NOSPL */ -#ifdef LOCUS +#ifdef LOCUS if (autolocus) setlocus(1,1); #endif /* LOCUS */ @@ -12527,7 +12527,7 @@ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"); case SFTP_RMDIR: case SFTP_LINK: case SFTP_VER: - if ((y = cmtxt("command parameters","",&s,xxstring)) < 0) + if ((y = cmtxt("command parameters","",&s,xxstring)) < 0) return(y); if (ssh_tchk() < 0 || !ssh_get_iparam(SSH_IPARAM_CAS) || strcmp(ssh_get_sparam(SSH_SPARAM_CMD), "sftp")) { @@ -13970,16 +13970,16 @@ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n" vars[2] = "exedir"; legend[2] = "K95 Program directory"; vars[3] = "inidir"; legend[3] = "K95 Initialization file directory"; vars[4] = "startup"; legend[4] = "Current directory when started"; - + vars[5] = "common"; legend[5] = "K95 data for all users and K95SITE.INI file"; - + vars[6] = "personal"; legend[6] = "Your personal data directory tree"; vars[7] = "desktop"; legend[7] = "Your deskop directory tree"; - + vars[8] = "appdata"; legend[8] = "Your personal K95 data tree and K95CUSTOM.INI file"; - + vars[9] = "download"; legend[9] = "Your K95 download directory"; vars[10] = "tmpdir"; legend[10] = "Your TEMP directory"; vars[11] = NULL; legend[11] = NULL; diff --git a/ckuusr.h b/ckuusr.h index fde5fbf..0751f66 100644 --- a/ckuusr.h +++ b/ckuusr.h @@ -3111,11 +3111,11 @@ _PROTOTYP(int BuildFontTable, (struct keytab ** pTable, struct keytab ** pTable2, int * pN)); #endif /* KUI */ -_PROTOTYP(int cx_net, (int net, int protocol, char * xhost, char * svc, +_PROTOTYP(int cx_net, (int net, int protocol, char * xhost, char * svc, char * username, char * password, char * command, - int param1, int param2, int param3, + int param1, int param2, int param3, int cx, int sx, int flag, int gui)); -_PROTOTYP(int cx_serial, (char *device, +_PROTOTYP(int cx_serial, (char *device, int cx, int sx, int shr, int flag, int gui, int special)); #endif /* CKUUSR_H */ diff --git a/ckuusx.c b/ckuusx.c index eaafcf0..c218fde 100644 --- a/ckuusx.c +++ b/ckuusx.c @@ -53,7 +53,7 @@ #define NOHTERMCAP #else #ifdef MACOSX -#ifndef OLDMACOSX +#ifndef OLDMACOSX #include /* macOS after 10.12 */ #include #endif /* OLDMACOSX */ @@ -476,7 +476,7 @@ extern int server, bctu, rptflg, ebqflg, spsiz, urpsiz, wmax, czseen, cxseen, rpackets, fncnv, bye_active, discard, inserver, diractive, cdactive; extern long filcnt, filrej, rptn, filcps, tfcps, cps, peakcps; -extern CK_OFF_T ffc, tfc, fsize; +extern CK_OFF_T ffc, tfc, fsize; long oldcps = 0L; @@ -571,7 +571,7 @@ shoesc(escape) int escape; printf(" Escape character: Code %d",escape); if (escape > 160 && escape < 256) printf(" (%c)",escape); - printf(": %s\r\n", tt_escape ? "enabled" : "disabled"); + printf(": %s\r\n", tt_escape ? "enabled" : "disabled"); } return(0); } @@ -1674,7 +1674,7 @@ scanfile(name,flag,nscanfile) char * name; int * flag, nscanfile; #endif /* DEBUG */ binary = 1; break; - } + } #endif /* NOPCLSCAN */ #ifndef NOPJLSCAN else if (buf[0] == '\033' && (buf[1] == 'E' || buf[1] == '%')) { @@ -3263,7 +3263,7 @@ trap(sig) int sig; debug(F100,"*********************","",0); if (sig == SIGINT) debug(F101,"trap caught SIGINT","",sig); - else + else debug(F101,"trap caught signal","",sig); debug(F100,"*********************","",0); } @@ -4898,7 +4898,7 @@ doclean(fc) int fc; if (local && exithangup) { /* Close communication connection */ extern int haslock; int x; - + x = ttchk(); debug(F101,"doclean ttchk()","",x); #ifdef OS2ORUNIX diff --git a/ckuusy.c b/ckuusy.c index d2e4d3b..17e4238 100644 --- a/ckuusy.c +++ b/ckuusy.c @@ -454,7 +454,7 @@ urlparse(s,url) char *s; struct urldata * url; makestr(&url->psw,p); } /* Save a copy of the full url if one was found. */ - if (url->svc) + if (url->svc) makestr(&url->sav,s); free(urlbuf); return(url->svc ? 1 : 0); @@ -627,7 +627,7 @@ xx_ftp(host, port) char * host, * port; haveftpuid = 0; /* "ftp://:@host" given. */ uidbuf[0] = NUL; makestr(&ftp_logname,NULL); - } + } debug(F111,"ftp xx_ftp uidbuf 2",uidbuf,haveftpuid); } #endif /* NOURL */ @@ -644,11 +644,11 @@ xx_ftp(host, port) char * host, * port; if (!port) { #ifdef CK_URL if (haveurl) { - if (g_url.por) + if (g_url.por) port = g_url.por; else if (g_url.svc) port = g_url.svc; - else + else port = "ftp"; } else #endif /* CK_URL */ @@ -808,7 +808,7 @@ cmdlin() { char rdns[128]; #ifdef OS2 char * agent = "Kermit 95"; -#else +#else char * agent = "C-Kermit"; #endif /* OS2 */ @@ -827,7 +827,7 @@ cmdlin() { } rdns[0] = '\0'; lfile = ""; - x = (http_open(g_url.hos,g_url.por ? g_url.por : g_url.svc, + x = (http_open(g_url.hos,g_url.por ? g_url.por : g_url.svc, type == URL_HTTPS, rdns,128,NULL) == 0); if (x) { #ifdef KUI @@ -874,7 +874,7 @@ cmdlin() { printf("?HTTP Connection failed.\r\n"); } doexit(x ? GOOD_EXIT : BAD_EXIT, -1); - } else + } else #endif /* CK_URL */ #endif /* NOICP */ { @@ -1063,7 +1063,7 @@ cmdlin() { 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); @@ -1088,7 +1088,7 @@ cmdlin() { #ifdef CK_URL if (haveurl) doftparg('U'); - else + else #endif /* CK_URL */ { while (--xargc > 0) { /* Go through command line words */ @@ -1422,7 +1422,7 @@ cmdlin() { ckstrncat(ttname,":",TTNAMLEN+1); ckstrncat(ttname,ssh_get_sparam(SSH_SPARAM_PRT),TTNAMLEN+1); } - else + else #endif /* CK_URL */ { while (--xargc > 0) { /* Go through command line words */ @@ -1548,8 +1548,8 @@ cmdlin() { if (k >= 0) { /* If found, */ if (dodo(k,ttname,0) > -1) /* set it up, */ parser(1); /* and execute it */ - } - } + } + } } #endif /* NOSPL */ return(0); diff --git a/ckvtio.c b/ckvtio.c index 6e98b12..ed13d9c 100644 --- a/ckvtio.c +++ b/ckvtio.c @@ -1148,7 +1148,7 @@ ttinl(dest,max,timo,eol,start,turn) int max,timo,turn; CHAR *dest,eol,start; #endif /* NOXFER */ #endif /* TTXBUF */ -SIGTYP (*saval)() = NULL; /* For saving alarm handler */ +sig_t saval; /* For saving alarm handler */ VOID ttimoff() { /* Turn off any timer interrupts */ @@ -2207,7 +2207,7 @@ ttsspd(cps) int cps; { /* C O N I N T -- Console Interrupt setter */ -static SIGTYP (*cctrap)(); +static sig_t cctrap; VOID #ifdef CK_ANSIC diff --git a/makefile b/makefile index 6c7b628..6c87784 100644 --- a/makefile +++ b/makefile @@ -74,7 +74,7 @@ CKVER= "10.0 Beta.12" # separated by whitespace. Some versions of "make" understand these as # directives, which older make versions do not understand. Uppercase letters # remove the danger, e.g. "# If you have..." -# +# # WARNING: This is a huge makefile. Although it is less likely since the # turn of the century, some "make" programs might run out of memory. If this # happens to you, edit away the parts that do not apply to your platform and @@ -849,7 +849,7 @@ CKVER= "10.0 Beta.12" # prefix statement changed in 10.0 Beta.06 to allow prefix to be specified # from the make command line e.g. $ env PREFIX=/usr/pkg make install. # October 2022. -# +# prefix = $${PREFIX:-/usr/local} srproot = $(prefix) sslroot = $(prefix) @@ -869,14 +869,14 @@ SSLINC=-I$(sslroot)/ssl/include # To override these assignments; for example, if your OpenSSL files are # not in /usr/local/ssl, invoke the desired target like this: -# +# # make solaris9+openssl "SSLINC=-I/opt/openssl-0.9.8k/include" \ # "SSLLIB=-L/opt/openssl-0.9.8k/lib" # -# (don't set the variables and then do "make -e" because that breaks +# (don't set the variables and then do "make -e" because that breaks # chaining of makefile targets.) # -# Here are some up-to-date secure targets as of Sep 2009: +# Here are some up-to-date secure targets as of Sep 2009: # # aix+openssl: IBM AIX 4.2 or later with OpenSSL # freebsd44+srp+openssl FreeBSD 4.4 with SRP and OpenSSL @@ -891,7 +891,7 @@ SSLINC=-I$(sslroot)/ssl/include # linux+ssl OpenSSL only # linux+krb5+ssl Linux with Kerberos 5 and OpenSSL # linux+krb5: Kerberos 5 only -# +# # The following secure Linux targets have not been updated or tested recently. # linux+krb5+krb4: # linux+srp: @@ -917,7 +917,7 @@ SSLINC=-I$(sslroot)/ssl/include # linux+krb5+krb4+srp+openssl+zlib+pam: # linux+krb5+krb4+openssl+shadow+pam: # linux+krb5+openssl+zlib+shadow+pam: -# +# # The following have not been tested recently either and might # need adjustment. # @@ -1254,7 +1254,7 @@ install: # UN-Install C-Kermit after building # Please to not remove the extra blanks before and after '{}' within the -# functions. You would get syntax errors for some older Bourne shells! Best is +# functions. You would get syntax errors for some older Bourne shells! Best is # you don't change or remove anything. # uninstall: @@ -2351,7 +2351,7 @@ oldmacosx10ncx: @rm -f ./curses.h #Mac OS X 10.3 (Panther) - Assumes ncurses is installed. -oldmacosx103: +oldmacosx103: @echo Making C-Kermit $(CKVER) for `uname -s` + ncurses... $(MAKE) CC=$(CC) CC2=$(CC2) xermit KTARGET=$${KTARGET:-$(@)} \ "CFLAGS= -DMACOSX10 -DMACOSX103 -DCK_NCURSES -DTCPSOCKET -DCKHTTP \ @@ -3976,7 +3976,7 @@ solaris2xg+openssl+pam+shadow: "LIBS= $(SSLLIB) -ltermlib \ -lsocket -lnsl -lm -lresolv -lssl -lcrypto -lpam" -solaris2xg+openssl+zlib+srp+pam+shadow: +solaris2xg+openssl+zlib+srp+pam+shadow: @echo 'Making C-Kermit $(CKVER) for Solaris 2.x with gcc, OpenSSL...' @echo 'Please read the comments that accompany the solaris2xg target.' $(MAKE) xermit KTARGET=$${KTARGET:-$(@)} CC=gcc CC2=gcc \ @@ -4236,7 +4236,7 @@ solaris9g+krb5+krb4: -lkrb4 -lcrypto -lgssapi_krb5 -lkrb5 -lcom_err -lk5crypto \ -ldes $(LIBS)" -#Solaris 9, 10, or 11 with gcc... +#Solaris 9, 10, or 11 with gcc... #Uses streams PTYs rather than BSD ptys as in C-Kermit 8.0 and earlier. #This target is chained to be the secure solaris9g+xxx targets below. solaris9g solaris10g solaris11g: @@ -5751,9 +5751,9 @@ unisys5r2: sys5hdb: $(MAKE) "MAKE=$(MAKE)" sys3hdb -#Create the common header line for all hpux[5-11]* entries and above. This -#extra entry is here because our header message length may differ for each -#C-Kermit version. Don't use 'fold -s' for HP-UX 5.x - 7.x! This option is +#Create the common header line for all hpux[5-11]* entries and above. This +#extra entry is here because our header message length may differ for each +#C-Kermit version. Don't use 'fold -s' for HP-UX 5.x - 7.x! This option is #available only for HP-UX 8.0 and above! hpux-header: @HPUX=`uname -r | sed -e 's/^[^1-9]*//' -e 's/\.00$$/.0/'` ; \ @@ -6182,7 +6182,7 @@ hpux0900gcc: #to KFLAGS. These should be harmless in 10.00 and 10.10, if any of examples #of those still exist, but I have no way to test this hypothesis. #OK: 2009/11/16 -#As of version 9.0305 Alpha.06 we have to add KFLAG "-DNO_PTY_XOPEN_SOURCE" +#As of version 9.0305 Alpha.06 we have to add KFLAG "-DNO_PTY_XOPEN_SOURCE" #to "make hpux1000" and "make hpux1000t" because "#define _XOPEN_SOURCE 500" #that was added to ckupty.c in 2014 triggers big problems with the HP C #compiler in default (i.e. pre-ANSI K&R) mode. @@ -6573,6 +6573,12 @@ linux gnu-linux: fi; \ fi; \ fi; \ + HAVE_LIBTINFO=''; \ + if test -z '$$HAVE_LIBTINFO'; then \ + if ld -ltinfo > /dev/null 2> /dev/null; then \ + HAVE_LIBTINFO='-ltinfo'; \ + fi; \ + fi; \ HAVE_RESOLV=''; \ if ld -lresolv > /dev/null 2> /dev/null; then \ HAVE_RESOLV='-lresolv'; \ @@ -6607,7 +6613,7 @@ linux gnu-linux: $(MAKE) KTARGET=$${KTARGET:-$(@)} \ "KFLAGS=$$HAVE_CURSES $$HAVE_PTMX $$HAVE_LOCKDEV $$HAVE_CRYPT_H \ $$HAVE_BAUDBOY $$HAVE_OPENPTY $$HAVE_LARGEFILES $(KFLAGS)" \ - "LIBS=$(LIBS) $$LIB_UTIL \ + "LIBS=$(LIBS) $$LIB_UTIL $$HAVE_LIBTINFO \ $$HAVE_LIBCURSES $$HAVE_RESOLV $$HAVE_CRYPT $$HAVE_LOCKDEV" \ linuxa @@ -6664,7 +6670,7 @@ linuxmin: #Modified 17 Aug 2005 to use openpty() if available because the other stuff #dumps core in 64-bit ia64 and x86_64 builds. # -#Added HAVE_LOCKDEV on openSuSE >= 11.3, which uses ttylock directly instead +#Added HAVE_LOCKDEV on openSuSE >= 11.3, which uses ttylock directly instead #of baudboy 2010/08/23 linux-2015: @if test \ @@ -6982,7 +6988,7 @@ linux+krb5+krb4: $(MAKE) linux+krb5 KTARGET=$${KTARGET:-$(@)} \ "KFLAGS=-DKRB4 -DKRB524 $(KFLAGS)" "LIBS=$(LIBS) -lkrb4" -# Linux with OpenSSL +# Linux with OpenSSL # In Linux, SSL libs are often in /lib or /usr/lib and so found by default. # This targets takes into account the DES library might or might not # exist. If it does exist, however, the target will require some editing