├── .gitignore ├── COPYING.TXT ├── NOTES.TXT ├── README.TXT ├── android.mk ├── android.txt ├── ck_crp.c ├── ck_des.c ├── ck_ssl.c ├── ck_ssl.h ├── ckcasc.h ├── ckcdeb.h ├── ckcdebu.h ├── ckcfn2.c ├── ckcfn3.c ├── ckcfns.c ├── ckcftp.c ├── ckcker.h ├── ckclib.c ├── ckclib.h ├── ckcmai.c ├── ckcmdb.c ├── ckcnet.c ├── ckcnet.h ├── ckcpro.c ├── ckcpro.w ├── ckcsig.h ├── ckcssl.h ├── ckcsym.h ├── ckctel.c ├── ckctel.h ├── ckcuni.c ├── ckcuni.h ├── ckcxla.h ├── ckermit.ini ├── ckpker.mak ├── cku2tm.c ├── ckuat2.h ├── ckuath.c ├── ckuath.h ├── ckubs2.mak ├── ckucmd.c ├── ckucmd.h ├── ckucns.c ├── ckucon.c ├── ckudia.c ├── ckufio.c ├── ckuker.nr ├── ckupty.c ├── ckupty.h ├── ckuscr.c ├── ckusig.c ├── ckusig.h ├── ckustr.c ├── ckustr.sed ├── ckutio.c ├── ckutiox.c ├── ckuus2.c ├── ckuus3.c ├── ckuus4.c ├── ckuus5.c ├── ckuus6.c ├── ckuus7.c ├── ckuusr.c ├── ckuusr.h ├── ckuusx.c ├── ckuusy.c ├── ckuver.h ├── ckuxla.c ├── ckuxla.h ├── ckwart.c └── makefile /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # This is the root .gitignore for C-Kermit 3 | # 4 | # Please don't add files that are generated in specific subdirectories 5 | # here. This file should only contain rules for the entire tree, 6 | # and entries specific to the top level directory. 7 | # 8 | # After changing this file, please run 9 | # git ls-files -i --exclude-standard 10 | # to check that you haven't inadvertently ignored any tracked files. 11 | 12 | # General rules 13 | 14 | *.o 15 | wart 16 | wermit 17 | UNINSTALL 18 | -------------------------------------------------------------------------------- /COPYING.TXT: -------------------------------------------------------------------------------- 1 | THE C-KERMIT 9.0 LICENSE 2 | 3 | Fri Jun 24 14:43:35 2011 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | + Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | + Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in 14 | the documentation and/or other materials provided with the 15 | distribution. 16 | 17 | + Neither the name of Columbia University nor the names of any 18 | contributors may be used to endorse or promote products derived 19 | from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /NOTES.TXT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KermitProject/ckermit/e29898407545ac1bc4030675e759373816efbf55/NOTES.TXT -------------------------------------------------------------------------------- /README.TXT: -------------------------------------------------------------------------------- 1 | C-KERMIT 10.0 DEVELOPMENT 2 | 3 | C-Kermit 10.0 Beta.06 14 October 2022 4 | 5 | Beta.06 fixes a couple problems in Beta.05 and adds numerous 6 | improvements for (Open)VMS from SMS. For details see: 7 | 8 | https://www.kermitproject.org/ckupdates.html 9 | 10 | which contains an account of all the previous development 11 | versions, Alphas, and Betas since C-Kermit 9.0 was released 12 | in 2011. 13 | -------------------------------------------------------------------------------- /android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | # ======================================================== 4 | # nano 5 | # ======================================================== 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_SRC_FILES:= \ 9 | ckcmai.c ckclib.c ckutio.c ckufio.c \ 10 | ckcfns.c ckcfn2.c ckcfn3.c ckuxla.c \ 11 | ckcpro.c ckucmd.c ckuus2.c ckuus3.c \ 12 | ckuus4.c ckuus5.c ckuus6.c ckuus7.c \ 13 | ckuusx.c ckuusy.c ckuusr.c ckucns.c \ 14 | ckudia.c ckuscr.c ckcnet.c ckusig.c \ 15 | ckctel.c ckcuni.c ckupty.c ckcftp.c \ 16 | ckuath.c ck_crp.c ck_ssl.c 17 | LOCAL_C_INCLUDES += \ 18 | $(LOCAL_PATH) 19 | LOCAL_CFLAGS += \ 20 | -DFNFLOAT -DCK_NEWTERM -DTCPSOCKET \ 21 | -DLINUXFSSTND -DNOCOTFMC -DUSE_STRERROR \ 22 | -DHAVE_PTMX -D_LARGEFILE_SOURCE -DNO_OPENPTY \ 23 | -D_FILE_OFFSET_BITS=64 -DPOSIX -DUSE_FILE_R\ 24 | -DKTARGET=\"android\" -DNO_DNS_SRV -DNOIKSD \ 25 | -DNOTIMESTAMP -DNOZLOCALTIME -DNOUUCP \ 26 | -DNO_NL_LANGINFO -DNO_LOCALE 27 | LOCAL_MODULE := kermit 28 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 29 | LOCAL_MODULE_TAGS := eng 30 | include $(BUILD_EXECUTABLE) 31 | 32 | -------------------------------------------------------------------------------- /android.txt: -------------------------------------------------------------------------------- 1 | cka - C-Kermit for Android 2 | 3 | This archive contains the source code for building C-Kermit 9.0.302 for 4 | Android. It has been taken from the source code downloaded from: 5 | 6 | ftp://ftp.kermitproject.org/kermit/archives/cku302.zip 7 | 8 | At this point the changes here are not part of the official release. 9 | all issues related to C-Kermit for Android should be directed at the 10 | github project, which can be found here: 11 | 12 | http://github.com/tesneddon/cka 13 | 14 | Assuming the Android NDK procedure "ndk-build" is in your PATH, you can 15 | use the following command to build the software for all ABIs: 16 | 17 | $ ndk-build NDK_PROJECT_PATH=./ \ 18 | APP_BUILD_SCRIPT=./android.mk \ 19 | APP_ABI=all \ 20 | LOCAL_DISABLE_FORMAT_STRING_CHECKS=true 21 | 22 | If you have any problems, flames, suggestions, praise, disbelief, etc. 23 | then please feel free to create an issue on the github page and I will 24 | follow it up as I get the opportunity. 25 | 26 | Tim Sneddon 27 | 28 | (with updates from Jake Thompson, 17 Nov 2013) 29 | -------------------------------------------------------------------------------- /ck_des.c: -------------------------------------------------------------------------------- 1 | /* 2 | C K _ D E S . C - libDES interface for Kermit 95" 3 | 4 | Copyright (C) 1998, 2001, Trustees of Columbia University in the City of New 5 | York. The C-Kermit software may not be, in whole or in part, licensed or 6 | sold for profit as a software product itself, nor may it be included in or 7 | distributed with commercial products or otherwise distributed by commercial 8 | concerns to their clients or customers without written permission of the 9 | Office of Kermit Development and Distribution, Columbia University. This 10 | copyright notice must not be removed, altered, or obscured. 11 | 12 | Author: 13 | Jeffrey E Altman (jaltman@secure-endpoints.com) 14 | */ 15 | 16 | /* 17 | This file contains wrappers so that the following functions will be imported 18 | into the k95crypt.dll/k2crypt.dll files in such a form that they can be 19 | re-exported to k95.exe/k2.exe. This subset of the DES library is needed to 20 | provide DES based Kerberos authentication. 21 | */ 22 | 23 | 24 | #ifdef LIBDES 25 | /* The following is specific to my installation, but since I'm the only one */ 26 | /* that uses this file ... */ 27 | #include "ckcdeb.h" 28 | #include "ckuath.h" 29 | #define CK_DES_C 30 | #include "ckuat2.h" 31 | #ifdef NT 32 | #ifdef _M_ALPHA 33 | #include 34 | #else 35 | #include 36 | #endif 37 | #else 38 | #include 39 | #endif 40 | 41 | int 42 | libdes_random_key(des_cblock B) 43 | { 44 | des_random_key(B); 45 | return(0); 46 | } 47 | 48 | void 49 | libdes_random_seed(des_cblock B) 50 | { 51 | des_random_seed(B); 52 | } 53 | 54 | void 55 | libdes_key_sched(des_cblock * B, des_key_schedule S) 56 | { 57 | des_key_sched(B,S); 58 | } 59 | 60 | void 61 | libdes_ecb_encrypt(des_cblock * B1, des_cblock * B2, des_key_schedule S, int n) 62 | { 63 | des_ecb_encrypt(B1,B2,S,n); 64 | } 65 | 66 | int 67 | libdes_string_to_key(char * s, des_cblock * B) 68 | { 69 | des_string_to_key(s,B); 70 | return(0); 71 | } 72 | 73 | void 74 | libdes_fixup_key_parity(des_cblock * B) 75 | { 76 | des_set_odd_parity(B); 77 | } 78 | 79 | void 80 | libdes_pcbc_encrypt(des_cblock *input, des_cblock *output, long length, 81 | des_key_schedule schedule, des_cblock *ivec, int enc) 82 | { 83 | des_pcbc_encrypt(input,output,length,schedule,ivec,enc); 84 | } 85 | 86 | void 87 | libdes_dll_init(struct _crypt_dll_init * init) 88 | { 89 | init->p_install_funcs("libdes_random_key",libdes_random_key); 90 | init->p_install_funcs("libdes_random_seed",libdes_random_seed); 91 | init->p_install_funcs("libdes_key_sched",libdes_key_sched); 92 | init->p_install_funcs("libdes_ecb_encrypt",libdes_ecb_encrypt); 93 | init->p_install_funcs("libdes_string_to_key",libdes_string_to_key); 94 | init->p_install_funcs("libdes_fixup_key_parity",libdes_fixup_key_parity); 95 | init->p_install_funcs("libdes_pcbc_encrypt",libdes_pcbc_encrypt); 96 | 97 | } 98 | #endif /* LIBDES */ 99 | -------------------------------------------------------------------------------- /ck_ssl.h: -------------------------------------------------------------------------------- 1 | /* 2 | C K _ S S L . H -- OpenSSL Interface Header for C-Kermit 3 | 4 | Copyright (C) 1985, 2020, 5 | Trustees of Columbia University in the City of New York. 6 | All rights reserved. See the C-Kermit COPYING.TXT file or the 7 | copyright text in the ckcmai.c module for disclaimer and permissions. 8 | 9 | Authors: Jeffrey E Altman (jaltman@secure-endpoints.com) 10 | Secure Endpoints Inc., New York City 11 | David Goodwin, New Zealand 12 | SMS 13 | Last update: Tue Oct 4 16:01:53 2022 14 | */ 15 | 16 | #ifdef CK_SSL 17 | #ifndef CK_ANSIC 18 | #define NOPROTO 19 | #endif /* CK_ANSIC */ 20 | 21 | #ifdef COMMENT /* Not for C-Kermit 7.1 */ 22 | #ifdef KRB5 23 | #ifndef NOSSLK5 24 | #ifndef SSL_KRB5 25 | #define SSL_KRB5 26 | #endif /* SSL_KRB5 */ 27 | #endif /* NOSSLK5 */ 28 | #endif /* KRB5 */ 29 | #endif /* COMMENT */ 30 | 31 | #ifdef OS2 32 | #ifndef ZLIB 33 | #define ZLIB 34 | #endif /* ZLIB */ 35 | #endif /* OS2 */ 36 | 37 | #ifdef ZLIB 38 | #ifndef OPENSSL_NO_COMP 39 | #include 40 | #endif /* OPENSSL_NO_COMP */ 41 | #endif /* ZLIB */ 42 | /* We place the following to avoid loading openssl/mdc2.h since it 43 | * relies on the OpenSSL des.h. Since we do not need the MDC2 44 | * definitions there is no reason to have it included by openssl/evp.h 45 | */ 46 | #define OPENSSL_NO_MDC2 47 | #ifdef OPENSSL_100 48 | #define OPENSSL_098 49 | 50 | /* Different major/minor version or development version of OpenSSL 51 | * means ABI may break compatibility. 52 | * Modified by Adam Friedlander for OpenSSL >= 1.0.0 53 | * (See for OpenSSL version encoding details.) 54 | */ 55 | #define COMPAT_VERSION_MASK 0xfff0000f /* MNNffppS, major+minor+status */ 56 | #else 57 | /* Different major/minor/fix/development (not patch) version of OpenSSL 58 | * means ABI may break compatibility. */ 59 | #define COMPAT_VERSION_MASK 0xfffff00f /* MNNFFppS, major+minor+fix+status */ 60 | #endif /* OPENSSL_100 */ 61 | 62 | #ifdef OPENSSL_098 63 | #define OPENSSL_097 64 | #endif /* OPENSSL_098 */ 65 | #ifdef CK_DES 66 | #include 67 | #endif /* CK_DES */ 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | #include 74 | #include 75 | #include 76 | #include 77 | #include 78 | #include 79 | #include 80 | #include 81 | #include 82 | #include 83 | #include 84 | #include 85 | #ifdef SSL_KRB5 86 | #include 87 | #endif /* SSL_KRB5 */ 88 | 89 | extern BIO *bio_err; 90 | extern SSL *ssl_con; 91 | extern SSL_CTX *ssl_ctx; 92 | extern int ssl_debug_flag; 93 | extern int ssl_only_flag; 94 | extern int ssl_active_flag; 95 | extern int ssl_verify_flag; 96 | extern int ssl_verbose_flag; 97 | extern int ssl_certsok_flag; 98 | extern int ssl_dummy_flag; 99 | extern int ssl_verify_depth; 100 | 101 | extern char *ssl_rsa_cert_file; 102 | extern char *ssl_rsa_cert_chain_file; 103 | extern char *ssl_rsa_key_file; 104 | extern char *ssl_dsa_cert_file; 105 | extern char *ssl_dsa_cert_chain_file; 106 | extern char *ssl_dh_key_file; 107 | extern char *ssl_cipher_list; 108 | extern char *ssl_crl_file; 109 | extern char *ssl_crl_dir; 110 | extern char *ssl_verify_file; 111 | extern char *ssl_verify_dir; 112 | extern char *ssl_dh_param_file; 113 | extern char *ssl_rnd_file; 114 | 115 | extern SSL_CTX *tls_ctx; 116 | extern SSL *tls_con; 117 | extern int tls_only_flag; 118 | extern int tls_active_flag; 119 | extern int x509_cert_valid; 120 | extern X509_STORE *crl_store; 121 | 122 | extern int ssl_raw_flag; 123 | extern int tls_raw_flag; 124 | 125 | #ifndef NOHTTP 126 | extern SSL_CTX *tls_http_ctx; 127 | extern SSL *tls_http_con; 128 | extern int tls_http_active_flag; 129 | #endif /* NOHTTP */ 130 | 131 | extern int ssl_initialized; 132 | 133 | _PROTOTYP(VOID ssl_once_init,(void)); 134 | _PROTOTYP(int ssl_tn_init,(int)); 135 | _PROTOTYP(int ssl_http_init,(char *)); 136 | _PROTOTYP(int ck_ssl_http_client,(int,char *)); 137 | _PROTOTYP(int ssl_display_connect_details,(SSL *,int,int)); 138 | _PROTOTYP(int ssl_server_verify_callback,(int, X509_STORE_CTX *)); 139 | _PROTOTYP(int ssl_client_verify_callback,(int, X509_STORE_CTX *)); 140 | _PROTOTYP(int ssl_reply,(int, unsigned char *, int)); 141 | _PROTOTYP(int ssl_is,(unsigned char *, int)); 142 | _PROTOTYP(int ck_ssl_incoming,(int)); 143 | _PROTOTYP(int ck_ssl_outgoing,(int)); 144 | _PROTOTYP(int tls_is_user_valid,(SSL *, const char *)); 145 | _PROTOTYP(char * ssl_get_dnsName,(SSL *)); 146 | _PROTOTYP(char * ssl_get_commonName,(SSL *)); 147 | _PROTOTYP(char * ssl_get_issuer_name,(SSL *)); 148 | _PROTOTYP(char * ssl_get_subject_name,(SSL *)); 149 | _PROTOTYP(int ssl_get_client_finished,(char *, int)); 150 | _PROTOTYP(int ssl_get_server_finished,(char *, int)); 151 | _PROTOTYP(int ssl_passwd_callback,(char *, int, int, VOID *)); 152 | _PROTOTYP(VOID ssl_client_info_callback,(const SSL *,int, int)); 153 | _PROTOTYP(int ssl_anonymous_cipher,(SSL * ssl)); 154 | _PROTOTYP(int tls_load_certs,(SSL_CTX * ctx, SSL * con, int server)); 155 | _PROTOTYP(int ssl_verify_crl,(int, X509_STORE_CTX *)); 156 | _PROTOTYP(int tls_is_krb5,(int)); 157 | _PROTOTYP(int X509_userok,(X509 *,const char *)); 158 | _PROTOTYP(int ck_X509_save_cert_to_user_store,(X509 *)); 159 | /* SMS 2007/02/15 */ 160 | _PROTOTYP(int ssl_check_server_name,(SSL * ssl, char * hostname)); 161 | #ifdef COMMENT 162 | /* [jt] 2013/11/21 - Kermit 95 is no longer a special case */ 163 | #ifdef OS2 164 | #include "ckosslc.h" 165 | #include "ckossl.h" 166 | #endif /* OS2 */ 167 | #endif /* COMMENT */ 168 | 169 | #define SSL_CLIENT 0 170 | #define SSL_SERVER 1 171 | #define SSL_HTTP 2 172 | 173 | #define SSL_ERR_BFSZ 4096 174 | 175 | #ifdef SSL_KRB5 176 | #define DEFAULT_CIPHER_LIST "HIGH:MEDIUM:LOW:+KRB5:+ADH:+EXP" 177 | #else 178 | #define DEFAULT_CIPHER_LIST "HIGH:MEDIUM:LOW:+ADH:+EXP" 179 | #endif /* SSL_KRB5 */ 180 | #endif /* CK_SSL */ 181 | -------------------------------------------------------------------------------- /ckcasc.h: -------------------------------------------------------------------------------- 1 | /* 2 | File CKCASC.H 3 | Mnemonics for ASCII control characters (and Space) for use with C-Kermit. 4 | */ 5 | /* 6 | Author: Frank da Cruz (fdc@columbia.edu). 7 | Columbia University Academic Information Systems, New York City. 8 | 9 | Copyright (C) 1985, 2022, 10 | Trustees of Columbia University in the City of New York. 11 | All rights reserved. See the C-Kermit COPYING.TXT file or the 12 | copyright text in the ckcmai.c module for disclaimer and permissions. 13 | */ 14 | #ifndef CKCASC_H 15 | #define CKCASC_H 16 | 17 | #define NUL '\0' /* Null Ctrl-@ */ 18 | #define SOH 1 /* Start of header Ctrl-A */ 19 | #define STX 2 /* Ctrl-B */ 20 | #define ETX 3 /* Ctrl-C */ 21 | #define EOT 4 /* Ctrl-D */ 22 | #define ENQ 5 /* ENQ Ctrl-E */ 23 | #define ACK 6 /* Ctrl-F */ 24 | #define BEL 7 /* Bell (Beep) Ctrl-G */ 25 | #define BS 8 /* Backspace Ctrl-H */ 26 | #define HT 9 /* Horizontal Tab Ctrl-I */ 27 | #define LF 10 /* Linefeed Ctrl-J */ 28 | #define VT 11 /* Vertical Tab Ctrl-K */ 29 | #define NL '\n' /* Newline */ 30 | #define FF 12 /* Formfeed Ctrl-L */ 31 | #define CK_CR 13 /* Carriage Return Ctrl-M (CR Windows conflict) */ 32 | #define SO 14 /* Shift Out Ctrl-N */ 33 | #define SI 15 /* Shift In Ctrl-O */ 34 | #define DLE 16 /* Datalink Escape Ctrl-P */ 35 | #define XON 17 /* XON Ctrl-Q */ 36 | #define DC1 17 37 | #define DC2 18 /* Ctrl-R */ 38 | #define XOFF 19 /* XOFF Ctrl-S */ 39 | #define DC3 19 40 | #define DC4 20 /* Ctrl-T */ 41 | #define NAK 21 /* Ctrl-U */ 42 | #define SYN 22 /* SYN, Ctrl-V */ 43 | #define ETB 23 /* Ctrl-W */ 44 | #define CAN 24 /* CAN, Ctrl-X */ 45 | #define XEM 25 /* Ctrl-Y (was EM but conflicts with OpenSSL) */ 46 | #define SUB 26 /* SUB Ctrl-Z */ 47 | #define ESC 27 /* Escape Ctrl-[ */ 48 | #define XFS 28 /* Field Separator, Ctrl-Backslash */ 49 | #define XGS 29 /* Group Separator, Ctrl-Rightbracket */ 50 | #define XRS 30 /* Record Separator, Ctrl-Circumflex */ 51 | #define US 31 /* Unit Separator, Ctrl-Underscore */ 52 | #define SP 32 /* Space */ 53 | #define DEL 127 /* Delete (Rubout) */ 54 | #define RUB 127 /* Delete (Rubout) */ 55 | 56 | #ifdef OS2 57 | /* 58 | These are needed in OS/2, so let's not cause any unnecessary conflicts. 59 | */ 60 | #define _CSI 0233 /* 8-bit Control Sequence Introducer */ 61 | #define _SS2 0216 /* 8-bit Single Shift 2 */ 62 | #define _SS3 0217 /* 8-bit Single Shift 3 */ 63 | #define _DCS 0220 /* 8-bit Device Control String Introducer */ 64 | #define _ST8 0234 /* 8-bit String Terminator */ 65 | #define _OSC 0235 /* 8-bit Operating System Command */ 66 | #define _PM8 0236 /* 8-bit Privacy Message */ 67 | #define _APC 0237 /* 8-bit Application Program Command */ 68 | #endif /* OS2 */ 69 | #endif /* CKCASC_H */ 70 | -------------------------------------------------------------------------------- /ckclib.h: -------------------------------------------------------------------------------- 1 | /* ckclib.h -- C-Kermit library routine prototypes */ 2 | /* 3 | Author: Frank da Cruz , 4 | Columbia University Academic Information Systems, New York City. 5 | 6 | Copyright (C) 2002, 2009, 7 | Trustees of Columbia University in the City of New York. 8 | All rights reserved. See the C-Kermit COPYING.TXT file or the 9 | copyright text in the ckcmai.c module for disclaimer and permissions. 10 | */ 11 | #ifndef CKCLIB_H 12 | #define CKCLIB_H 13 | 14 | struct stringarray { 15 | char ** a_head; 16 | int a_size; 17 | }; 18 | 19 | #ifdef CK_ANSIC 20 | _PROTOTYP( int ckstrncpy, (char *, const char *, int) ); 21 | _PROTOTYP( int ckstrncat, (char *, const char *, int) ); 22 | #else 23 | _PROTOTYP( int ckstrncpy, (char *, char *, int) ); 24 | _PROTOTYP( int ckstrncat, (char *, char *, int) ); 25 | #endif /* CK_ANSIC */ 26 | 27 | _PROTOTYP( int ckmakmsg, (char *, int, char *, char *, char *, char *) ); 28 | _PROTOTYP( int ckmakxmsg, (char *, int, 29 | char *, char *, char *, char *, char *, char *, 30 | char *, char *, char *, char *, char *, char *) ); 31 | 32 | _PROTOTYP( char * ckstrpbrk, (char *, char *) ); 33 | _PROTOTYP( char * ckstrstr, (char *, char *) ); 34 | _PROTOTYP( char * chartostr, (int) ); 35 | _PROTOTYP( int cklower, (char *) ); 36 | _PROTOTYP( int ckupper, (char *) ); 37 | _PROTOTYP( int ckindex, (char *, char *, int, int, int) ); 38 | _PROTOTYP( char * ckctoa, (char) ); 39 | _PROTOTYP( char * ckctox, (CHAR, int) ); 40 | _PROTOTYP( char * ckitoa, (int) ); 41 | _PROTOTYP( char * ckuitoa, (unsigned int) ); 42 | _PROTOTYP( char * ckltoa, (long) ); 43 | _PROTOTYP( char * ckultoa, (unsigned long) ); 44 | _PROTOTYP( char * ckfstoa, (CK_OFF_T) ); 45 | _PROTOTYP( CK_OFF_T ckatofs, (char *) ); 46 | _PROTOTYP( char * ckitox, (int) ); 47 | _PROTOTYP( char * ckltox, (long) ); 48 | _PROTOTYP( int ispattern, (char *) ); 49 | _PROTOTYP( int ckmatch, (char *, char *, int, int ) ); 50 | _PROTOTYP( VOID ckmemcpy, (char *, char *, int) ); 51 | _PROTOTYP( char * ckstrchr, (char *, char) ); 52 | _PROTOTYP( char * ckstrrchr, (char *, char) ); 53 | _PROTOTYP( int ckrchar, (char *) ); 54 | _PROTOTYP( int ckstrcmp, (char *, char *, int, int) ); 55 | #define xxstrcmp(a,b,c) ckstrcmp(a,b,c,0) 56 | _PROTOTYP( int ckstrpre, (char *, char *) ); 57 | _PROTOTYP( VOID sh_sort, (char **, char **, int, int, int, int) ); 58 | _PROTOTYP( char * brstrip, (char *) ); 59 | _PROTOTYP( char * fnstrip, (char *) ); 60 | #ifdef COMMENT 61 | _PROTOTYP( char * brace, (char *) ); 62 | #endif /* COMMENT */ 63 | _PROTOTYP( int dquote, (char *, int, int) ); 64 | _PROTOTYP( int untabify, (char *, char *, int) ); 65 | _PROTOTYP( VOID makelist, (char *, char *[], int) ); 66 | #ifndef CK_ANSIC 67 | _PROTOTYP( VOID makestr, (char **, char *) ); 68 | _PROTOTYP( VOID xmakestr, (char **, char *) ); 69 | #else /* CK_ANSIC */ 70 | _PROTOTYP( VOID makestr, (char **, const char *) ); 71 | _PROTOTYP( VOID xmakestr, (char **, const char *) ); 72 | #endif /* CK_ANSIC */ 73 | _PROTOTYP( int chknum, (char *) ); 74 | _PROTOTYP( int rdigits, (char *) ); 75 | _PROTOTYP( char * ckradix, (char *,int,int) ); 76 | 77 | /* Base-64 conversion needed for script programming and HTTP */ 78 | 79 | #ifndef NOB64 80 | _PROTOTYP( int b8tob64, (char *,int,char *,int)); 81 | _PROTOTYP( int b64tob8, (char *,int,char *,int)); 82 | #endif /* NOB64 */ 83 | 84 | #ifdef CKFLOAT 85 | _PROTOTYP( int isfloat, (char *,int) ); 86 | #ifndef CKCLIB_C 87 | #ifndef CKWART_C 88 | extern CKFLOAT floatval; 89 | #endif /* CKWART_C */ 90 | #endif /* CKCLIB_C */ 91 | #endif /* CKFLOAT */ 92 | 93 | _PROTOTYP( char * parnam, (char) ); 94 | _PROTOTYP( char *hhmmss, (long) ); 95 | 96 | _PROTOTYP( VOID lset, (char *, char *, int, int) ); 97 | _PROTOTYP( VOID rset, (char *, char *, int, int) ); 98 | _PROTOTYP( char * ulongtohex, (unsigned long, int) ); 99 | _PROTOTYP( long hextoulong, (char *, int) ); 100 | _PROTOTYP( struct stringarray * cksplit, (int,int, 101 | char *,char *,char *,int,int,int,int) ); 102 | 103 | _PROTOTYP( int ckhexbytetoint, (char *) ); 104 | #endif /* CKCLIB_H */ 105 | -------------------------------------------------------------------------------- /ckcmdb.c: -------------------------------------------------------------------------------- 1 | /* 2 | C K C M D B . C -- malloc debugger. 3 | */ 4 | 5 | /* 6 | Author: Howie Kaye, Columbia University Center for Computing Activities. 7 | 8 | Copyright (C) 1985, 1999, 9 | Trustees of Columbia University in the City of New York. 10 | All rights reserved. See the C-Kermit COPYING.TXT file or the 11 | copyright text in the ckcmai.c module for disclaimer and permissions. 12 | */ 13 | /* Use the real ones in this module! */ 14 | #ifdef malloc 15 | #undef malloc 16 | #endif /* malloc */ 17 | #ifdef calloc 18 | #undef calloc 19 | #endif /* calloc */ 20 | #ifdef realloc 21 | #undef realloc 22 | #endif /* realloc */ 23 | #ifdef free 24 | #undef free 25 | #endif /* free */ 26 | 27 | #include "ckcsym.h" 28 | #include 29 | #include "ckcdeb.h" 30 | 31 | #ifdef COHERENT 32 | _PROTOTYP ( FILE * fdopen, (int, char *) ); 33 | #endif /* COHERENT */ 34 | 35 | /* 36 | memdebug: 37 | variable to control memory debugging. 38 | if memdebug == 1, then action is always taken. 39 | if memdebug == 0, then no action is taken. 40 | if memdebug == -1, then the user is asked (works well with gdb). 41 | */ 42 | int memdebug = -1; 43 | int disabled = 0; 44 | int inited = 0; 45 | /* 46 | To use this package, compile your program with: 47 | -Dmalloc=dmalloc -Dfree=dfree =Dcalloc=dcalloc ... -DMDEBUG 48 | and then link it with ckcmdb.c. 49 | */ 50 | #ifdef MDEBUG 51 | 52 | #ifndef M_SIZE_T 53 | #ifdef NEXT 54 | #define M_SIZE_T size_t 55 | #else 56 | #ifdef SUNOS41 57 | #define M_SIZE_T unsigned 58 | #else 59 | #define M_SIZE_T int 60 | #endif /* SUNOS41 */ 61 | #endif /* NEXT */ 62 | #endif /* M_SIZE_T */ 63 | 64 | #ifdef CK_ANSIC 65 | _PROTOTYP( void free, (void *) ); 66 | _PROTOTYP( void * malloc, (size_t) ); 67 | _PROTOTYP( void * realloc, (void *, size_t) ); 68 | #else 69 | _PROTOTYP( VOID free, (char *) ); 70 | _PROTOTYP( char * malloc, (M_SIZE_T) ); 71 | _PROTOTYP( char * realloc, (char *, M_SIZE_T) ); 72 | #endif /* NEXT */ 73 | 74 | _PROTOTYP( VOID m_insert, (char *) ); 75 | _PROTOTYP( int m_delete, (char *) ); 76 | 77 | _PROTOTYP( char * dmalloc, (int) ); 78 | _PROTOTYP( char * dcalloc, (int, int) ); 79 | _PROTOTYP( char * drealloc, (char *, int) ); 80 | 81 | _PROTOTYP( char *set_range_check, (char *, int) ); 82 | _PROTOTYP( char *check_range, (char *) ); 83 | _PROTOTYP( static char *maybe_check_range, (char *) ); 84 | 85 | _PROTOTYP( static VOID maybe_quit, (char *) ); 86 | _PROTOTYP( static int ask, (char *) ); 87 | 88 | #ifndef min 89 | #define min(x,y) ((x) < (y) ? (x) : (y)) 90 | #endif /* min */ 91 | #define RANGE "ABCDEFGHIJKLMNOP" 92 | #define INTSIZE sizeof(int) 93 | #define LONGSIZE sizeof(long) 94 | #define RSIZE sizeof(RANGE) 95 | #define RFRONT min((RSIZE/2),LONGSIZE) 96 | #define RBACK min((RSIZE-RFRONT),LONGSIZE) 97 | 98 | char * 99 | dmalloc(size) int size; { 100 | char *cp; 101 | 102 | cp = malloc(size + RSIZE + INTSIZE); 103 | if (cp) { 104 | cp = set_range_check(cp, size); 105 | m_insert(cp); 106 | } 107 | return(cp); 108 | } 109 | 110 | char * 111 | dcalloc(nelem, elsize) int nelem, elsize; { 112 | char *cp; 113 | 114 | cp = dmalloc(nelem * elsize); 115 | if (cp) 116 | memset(cp, 0, nelem * elsize); 117 | return(cp); 118 | } 119 | 120 | char * 121 | drealloc(bp,size) char *bp; int size; { 122 | char *cp; 123 | 124 | if (bp == NULL) { 125 | maybe_quit("Freeing NULL pointer"); 126 | } else { 127 | m_delete(bp); 128 | cp = check_range(bp); 129 | } 130 | cp = realloc(cp, size + RSIZE + INTSIZE); 131 | if (cp) { 132 | cp = set_range_check(cp, size); 133 | m_insert(cp); 134 | } 135 | return(cp); 136 | } 137 | 138 | VOID 139 | dfree(cp) char *cp; { 140 | if (cp == NULL) 141 | maybe_quit("Freeing NULL pointer"); 142 | else { 143 | switch(m_delete(cp)) { 144 | case 0: 145 | cp = maybe_check_range(cp); 146 | break; 147 | case 1: 148 | cp = check_range(cp); 149 | break; 150 | case 2: 151 | break; 152 | } 153 | } 154 | #ifndef CK_ANSIC 155 | return(free(cp)); 156 | #endif /* CK_ANSIC */ 157 | } 158 | 159 | char * 160 | set_range_check(cp,size) char *cp; int size; { 161 | register int i; 162 | int tmp = size; 163 | 164 | for(i = 0; i < INTSIZE; i++) { /* set the size in the string */ 165 | cp[i] = tmp & 0xff; 166 | tmp >>= 8; 167 | } 168 | cp += INTSIZE; /* skip the size */ 169 | 170 | for(i = 0; i < RFRONT; i++) /* set the front of the range check */ 171 | cp[i] = RANGE[i]; /* string */ 172 | 173 | cp += RFRONT; /* skip the front range check */ 174 | 175 | for(i = 0; i < RBACK; i++) /* set the back odf the range check */ 176 | cp[i+size] = RANGE[i+RFRONT]; 177 | 178 | return(cp); 179 | } 180 | 181 | /* 182 | Put calls to this routine in your code any place where you want to 183 | check whether you've copied too many characters into a malloc'd space. 184 | */ 185 | char * 186 | check_range(cp) char *cp; { 187 | register char *bp = cp - RFRONT - INTSIZE; 188 | char *xp = bp; 189 | register int i; 190 | int size = 0; 191 | 192 | for(i = 0 ; i < INTSIZE; i++) { /* get the size out of the string */ 193 | size <<= 8; 194 | size |= bp[INTSIZE-i-1] & 0xff; 195 | } 196 | bp += INTSIZE; 197 | 198 | for(i = 0; i < RFRONT; i++) /* check front range check */ 199 | if (bp[i] != RANGE[i]) { 200 | maybe_quit("leftside malloc buffer overrun"); 201 | break; 202 | } 203 | bp += RFRONT; /* skip front range check */ 204 | 205 | for(i = 0; i < RBACK; i++) /* check back range check */ 206 | if (bp[i+size] != RANGE[i+RFRONT]) { 207 | maybe_quit("rightside malloc buffer overrun"); 208 | break; 209 | } 210 | return(xp); 211 | } 212 | 213 | static char * 214 | maybe_check_range(cp) char *cp; { 215 | register char *bp = cp - RFRONT - INTSIZE; 216 | char *xp = bp; 217 | register int i; 218 | int size = 0; 219 | 220 | for(i = 0 ; i < INTSIZE; i++) { /* get the size out of the string */ 221 | size <<= 8; 222 | size |= bp[INTSIZE-i-1] & 0xff; 223 | } 224 | bp += INTSIZE; 225 | 226 | for(i = 0; i < RFRONT; i++) /* check front range check */ 227 | if (bp[i] != RANGE[i]) { 228 | return(cp); 229 | } 230 | bp += RFRONT; /* skip front range check */ 231 | 232 | for(i = 0; i < RBACK; i++) /* check back range check */ 233 | if (bp[i+size] != RANGE[i+RFRONT]) { 234 | fprintf(stderr,"rightside malloc buffer overrun\n"); 235 | abort(); 236 | break; 237 | } 238 | return(xp); 239 | } 240 | 241 | #define BUCKETS 10000 242 | char *m_used[BUCKETS]; 243 | char *m_used2[BUCKETS]; 244 | 245 | VOID 246 | m_insert(cp) register char *cp; { 247 | register int i; 248 | 249 | if (disabled) 250 | return; 251 | 252 | for(i = 0; i < BUCKETS; i++) 253 | if (m_used[i] == 0) { 254 | m_used[i] = cp; 255 | return; 256 | } 257 | disabled ++; 258 | } 259 | 260 | static VOID 261 | m_insert2(cp) register char *cp; { 262 | register int i; 263 | 264 | if (disabled) 265 | return; 266 | for(i = 0; i < BUCKETS; i++) 267 | if (m_used2[i] == 0) { 268 | m_used2[i] = cp; 269 | return; 270 | } 271 | disabled ++; 272 | } 273 | 274 | int 275 | m_delete(cp) register char *cp; { 276 | register int i; 277 | 278 | for(i = 0; i < BUCKETS; i++) 279 | if (m_used[i] == cp) { 280 | m_used[i] = 0; 281 | return(1); 282 | } 283 | for(i = 0; i < BUCKETS; i++) 284 | if (m_used2[i] == cp) { 285 | m_used2[i] = 0; 286 | return(2); 287 | } 288 | if (disabled) 289 | return(0); 290 | 291 | maybe_quit("Freeing unmalloc'ed pointer"); 292 | return(0); 293 | } 294 | 295 | VOID 296 | m_init() { 297 | register int i; 298 | 299 | inited = 1; 300 | disabled = 0; 301 | #ifdef NEXT 302 | malloc_debug(2+4+8+16); 303 | #endif /* NEXT */ 304 | 305 | for(i = 0; i < BUCKETS; i++) 306 | m_used[i] = 0; 307 | } 308 | 309 | VOID 310 | m_done() { 311 | register int i,j=0; 312 | 313 | if (disabled) 314 | return; 315 | for(i = 0; i < BUCKETS; i++) 316 | if (m_used[i] != 0) { 317 | if (memdebug) { 318 | if (j == 0) 319 | fprintf(stderr,"unfree'ed buffers, indices: "); 320 | fprintf(stderr,"%d, ", i); 321 | j++; 322 | } 323 | } 324 | if (j) 325 | fprintf(stderr,"\n"); 326 | for(i = 0; i < BUCKETS; i++) 327 | if (m_used2[i] != 0) { 328 | if (memdebug) { 329 | if (j == 0) 330 | fprintf(stderr,"unfree'ed registered buffers, indices: "); 331 | fprintf(stderr,"%d, ", i); 332 | j++; 333 | } 334 | } 335 | if (j) 336 | fprintf(stderr,"\n"); 337 | if (j) 338 | maybe_quit("Unfree'ed malloc buffers"); 339 | } 340 | 341 | VOID 342 | m_checkranges() { 343 | int i; 344 | 345 | for ( i = 0; i < BUCKETS; i++) 346 | if (m_used[i]) 347 | check_range(m_used[i]); 348 | } 349 | 350 | static VOID 351 | maybe_quit(str) char *str; { 352 | debug(F100,"mdebug maybe_quit","",0); 353 | if (memdebug == 0) 354 | return; 355 | fprintf(stderr,"%s\n",str); 356 | if (memdebug == 1) 357 | abort(); 358 | if (memdebug == -1) 359 | if (ask("Quit? ")) 360 | abort(); 361 | } 362 | 363 | static int 364 | ask(str) char *str; { 365 | char buf[100]; 366 | FILE *in; 367 | int fd; 368 | 369 | fd = dup(fileno(stdin)); 370 | in = fdopen(fd, "r"); 371 | while(1) { 372 | fprintf(stderr,str); 373 | fflush(stderr); 374 | if (fgets(buf, 99, in) == NULL) /* EOF? */ 375 | return(0); 376 | if (buf[0] == 'n' || buf[0] == 'N') { 377 | fclose(in); 378 | return(0); 379 | } 380 | if (buf[0] == 'y' || buf[0] == 'Y') { 381 | fclose(in); 382 | return(1); 383 | } 384 | fprintf(stderr,"please answer y/n.\n"); 385 | } 386 | } 387 | #endif /* MDEBUG */ 388 | -------------------------------------------------------------------------------- /ckcsig.h: -------------------------------------------------------------------------------- 1 | /* C K C S I G . H */ 2 | 3 | /* Definitions and prototypes for signal handling */ 4 | 5 | /* 6 | Author: Jeffrey E Altman (jaltman@secure-endpoints.com), 7 | Secure Endpoints Inc., New York City. 8 | 9 | Copyright (C) 1985, 2013 10 | Trustees of Columbia University in the City of New York. 11 | All rights reserved. See the C-Kermit COPYING.TXT file or the 12 | copyright text in the ckcmai.c module for disclaimer and permissions. 13 | */ 14 | #ifdef OS2 15 | #ifndef NT 16 | #ifndef __HEV__ /* INCL_SEMAPHORE may also define HEV */ 17 | #define __HEV__ 18 | typedef ULONG HEV; /* hev */ 19 | typedef HEV *PHEV; 20 | #endif /* __HEV__ */ 21 | #endif /* NT */ 22 | struct _threadinfo { 23 | int inuse; 24 | int child; 25 | int sibling; 26 | #ifdef NT 27 | HANDLE id; 28 | HANDLE handle; 29 | HANDLE parent; 30 | HANDLE CompletionSem ; 31 | HANDLE DieSem ; 32 | #else /* NT */ 33 | TID id; 34 | TID parent; 35 | HEV CompletionSem; 36 | HEV DieSem; 37 | #endif /* NT */ 38 | }; 39 | #endif /* OS2 */ 40 | 41 | #ifdef CK_ANSIC 42 | typedef SIGTYP (*ck_sigfunc)(void *); 43 | typedef SIGTYP (*ck_sighand)(int); 44 | #else 45 | typedef SIGTYP (*ck_sigfunc)(); 46 | typedef SIGTYP (*ck_sighand)(); 47 | #endif /* CK_ANSIC */ 48 | 49 | /* Macros for POSIX vs old-style signal handling. */ 50 | 51 | #ifdef CK_POSIX_SIG 52 | typedef sigjmp_buf ckjmpbuf; 53 | #else 54 | #ifdef NT 55 | #define NOCRYPT 56 | #include 57 | #ifdef NTASM 58 | typedef struct { 59 | CONTEXT context; 60 | DWORD retcode; 61 | } ckjmpbuf; 62 | #else /* NTASM */ 63 | typedef jmp_buf ckjmpbuf; 64 | #endif /* NTASM */ 65 | #else 66 | typedef jmp_buf ckjmpbuf; 67 | #endif 68 | #endif /* CK_POSIX_SIG */ 69 | /* 70 | Suppose you want to pass the address of a jmp_buf bar to a function foo. 71 | Since jmp_buf is normally defined (typedef'd) as an array, you would do 72 | it like this: foo(bar), where foo = foo(jmp_buf bar). But suppose a 73 | jmp_buf is (say) a struct rather than an array. Then you must do 74 | foo(&bar) where foo is foo(jmp_buf * bar). This is controlled here in 75 | the traditional fashion, by ifdefs. By default, we assume that jmp_buf 76 | is an array. Define the symbol JBNOTARRAY if jmp_buf is not an array. 77 | */ 78 | #ifndef JBNOTARRAY 79 | #ifdef NT 80 | #define JBNOTARRAY 81 | #endif /* NT */ 82 | #endif /* JBNOTARRAY */ 83 | 84 | #ifdef JBNOTARRAY 85 | typedef ckjmpbuf * ckjptr; 86 | #define ckjaddr(x) & x 87 | #define ckjdref(x) * x 88 | #ifdef CK_POSIX_SIG 89 | #define cksetjmp(x) sigsetjmp(x,1) 90 | #define cklongjmp(x,y) siglongjmp(x,y) 91 | #else 92 | #ifdef NT 93 | #ifdef COMMENT 94 | __inline int 95 | #else 96 | static __inline int /* duplicate definition issue */ 97 | #endif /* COMMENT */ 98 | 99 | ck_ih(void) { 100 | extern int TlsIndex; 101 | #ifdef NTSIG 102 | struct _threadinfo * threadinfo; 103 | threadinfo = (struct _threadinfo *) TlsGetValue(TlsIndex); 104 | if (threadinfo) { 105 | if (WaitAndResetSem(threadinfo->DieSem,0)) { 106 | ckThreadDie(threadinfo); 107 | return 1; /* This should never execute */ 108 | } 109 | } 110 | #ifdef COMMENT 111 | else debug( F100, "ck_ih() threadinfo is NULL","",0); 112 | #endif /* COMMENT */ 113 | #endif /* NTSIG */ 114 | return 0; 115 | } 116 | #ifdef NTSIG 117 | #define cksetjmp(x) setjmp(x) 118 | #define cklongjmp(x,y) longjmp(x,y) 119 | #else /* NTSIG */ 120 | #ifdef NTASM 121 | __inline DWORD 122 | cksetjmp( ckjptr jmp ) { 123 | extern int isinterrupted; 124 | jmp->retcode = 0; 125 | memset( &jmp->context, 0, sizeof(CONTEXT) ); 126 | jmp->context.ContextFlags = CONTEXT_FULL ; 127 | if ( !GetThreadContext( GetCurrentThread(), &jmp->context ) ) 128 | debug( F101, "cksetjmp GetThreadContext failed","",GetLastError()); 129 | debug(F101,"cksetjmp returns","",jmp->retcode); 130 | isinterrupted = 0; 131 | return (jmp->retcode); 132 | } 133 | 134 | __inline void 135 | cklongjmp( ckjptr jmp, int retval ) { 136 | extern HANDLE tidCommand; 137 | extern int ttyfd, mdmtyp ; 138 | extern DWORD CommandID; 139 | extern int isinterrupted; 140 | 141 | connoi(); 142 | isinterrupted = 1; 143 | jmp->retcode = ( retval ? retval : 1 ); 144 | debug(F101,"about to SetThreadContext for thread","", CommandID); 145 | debug(F101,"from Thread","",GetCurrentThreadId()); 146 | if ( mdmtyp >= 0 ) { 147 | PurgeComm( (HANDLE) ttyfd, PURGE_TXABORT | PURGE_RXABORT ); 148 | } 149 | if (SetThreadContext( tidCommand, &jmp->context )) 150 | debug(F100,"cklongjmp SetThreadContext success","",0); 151 | else 152 | debug(F101,"cklongjmp SetThreadContext failed","",GetLastError()); 153 | msleep(50); 154 | cmini(1); /* Reset command parser */ 155 | putkey(13); /* Stuff a carriage return */ 156 | /* PostEventAvailSem(); */ 157 | } 158 | #else /* NTASM */ 159 | void crash( void ) ; 160 | #define cksetjmp(x) setjmp(x) 161 | __inline void 162 | cklongjmp( ckjptr jmp, int retval ) { 163 | extern HANDLE tidCommand; 164 | extern int ttyfd, mdmtyp; 165 | extern DWORD CommandID; 166 | CONTEXT context; 167 | 168 | if ( mdmtyp >= 0 ) { 169 | PurgeComm( (HANDLE) ttyfd, PURGE_TXABORT | PURGE_RXABORT ) ; 170 | } 171 | memset( &context, 0, sizeof(CONTEXT) ); 172 | context.ContextFlags = CONTEXT_FULL; 173 | if ( !GetThreadContext( tidCommand, &context ) ) 174 | debug( F101, "cklongjmp GetThreadContext failed","",GetLastError()); 175 | 176 | /* Invalidate the instruction pointer */ 177 | context.Eip = (unsigned long) crash; 178 | 179 | debug(F101,"about to SetThreadContext for thread","", CommandID); 180 | debug(F101,"from Thread","",GetCurrentThreadId()); 181 | if (SetThreadContext( tidCommand, &context )) 182 | debug(F100,"cklongjmp SetThreadContext success","",0); 183 | else 184 | debug(F101,"cklongjmp SetThreadContext failed","",GetLastError()); 185 | } 186 | #endif /* NTASM */ 187 | #endif /* NTSIG */ 188 | #else /* NT */ 189 | #define cksetjmp(x) setjmp(x) 190 | #define cklongjmp(x,y) longjmp(x,y) 191 | #endif /* NT */ 192 | #endif /* CK_POSIX_SIG */ 193 | #else /* jmp_buf is an array */ 194 | typedef ckjmpbuf ckjptr; 195 | #define ckjaddr(x) x 196 | #define ckjdref(x) x 197 | #ifdef CK_POSIX_SIG 198 | #define cksetjmp(x) sigsetjmp(x,1) 199 | #define cklongjmp(x,y) siglongjmp(x,y) 200 | #else 201 | #define cksetjmp(x) setjmp(x) 202 | #define cklongjmp(x,y) longjmp(x,y) 203 | #endif /* CK_POSIX_SIG */ 204 | #endif /* JBNOTARRAY */ 205 | 206 | _PROTOTYP( int cc_execute, (ckjptr, ck_sigfunc, ck_sigfunc) ); 207 | _PROTOTYP( int alrm_execute, 208 | (ckjptr, 209 | int /* timo */, 210 | ck_sighand /* handler */, 211 | ck_sigfunc, ck_sigfunc) ); 212 | _PROTOTYP( int cc_alrm_execute, 213 | (ckjptr, 214 | int /* timo */, 215 | ck_sighand /* handler */, 216 | ck_sigfunc, 217 | ck_sigfunc) ); 218 | 219 | /* End of ckusig.h */ 220 | -------------------------------------------------------------------------------- /ckcssl.h: -------------------------------------------------------------------------------- 1 | #ifdef CK_SSL 2 | #ifndef CK_ANSIC 3 | #define NOPROTO 4 | #endif /* CK_ANSIC */ 5 | #include "bio.h" 6 | #include "buffer.h" 7 | #include "x509.h" 8 | #include "pem.h" 9 | #include "ssl.h" 10 | 11 | extern BIO *bio_err; 12 | extern SSL *ssl_con; 13 | extern SSL_CTX *ssl_ctx; 14 | extern int ssl_debug_flag; 15 | extern int ssl_only_flag; 16 | extern int ssl_active_flag; 17 | extern int ssl_verify_flag; 18 | extern int ssl_secure_flag; 19 | extern int ssl_verbose_flag; 20 | extern int ssl_disabled_flag; 21 | extern int ssl_cert_required; 22 | extern int ssl_certsok_flag; 23 | extern int ssl_dummy_flag; 24 | 25 | extern char *ssl_log_file; 26 | extern char *ssl_rsa_cert_file; 27 | extern char *ssl_rsa_key_file; 28 | extern char *ssl_dsa_cert_file; 29 | extern char *ssl_dh_key_file; 30 | extern char *ssl_cipher_list; 31 | 32 | extern SSL_CTX *tls_ctx; 33 | extern SSL *tls_con; 34 | extern int tls_only_flag; 35 | extern int tls_active_flag; 36 | extern int tls_secure_flag; 37 | 38 | _PROTOTYP(int ssl_do_init,(int)); 39 | _PROTOTYP(int ssl_display_connect_details,(SSL *,int)); 40 | _PROTOTYP(int ssl_server_verify_callback,(int, X509_STORE_CTX *)); 41 | _PROTOTYP(int ssl_client_verify_callback,(int, X509_STORE_CTX *)); 42 | 43 | #ifdef OS2 44 | #define SSL_get_error ck_SSL_get_error 45 | #define SSL_read ck_SSL_read 46 | #define SSL_peek ck_SSL_peek 47 | #define SSL_connect ck_SSL_connect 48 | #define SSL_set_fd ck_SSL_set_fd 49 | #define SSL_free ck_SSL_free 50 | #define SSL_shutdown ck_SSL_shutdown 51 | #define SSL_write ck_SSL_write 52 | #define SSL_pending ck_SSL_pending 53 | #define SSL_load_error_strings ck_SSL_load_error_strings 54 | #define SSL_get_peer_certificate ck_SSL_get_peer_certificate 55 | #define SSL_CIPHER_get_name ck_SSL_CIPHER_get_name 56 | #define SSL_get_current_cipher ck_SSL_get_current_cipher 57 | #define SSL_get_shared_ciphers ck_SSL_get_shared_ciphers 58 | #define SSL_get_ciphers ck_SSL_get_ciphers 59 | #define SSL_get_cipher_list ck_SSL_get_cipher_list 60 | #define SSL_CTX_set_default_verify_paths ck_SSL_CTX_set_default_verify_paths 61 | #define SSL_use_RSAPrivateKey_file ck_SSL_use_RSAPrivateKey_file 62 | #define SSL_use_DSAPrivateKey_file ck_SSL_use_DSAPrivateKey_file 63 | #define SSL_use_PrivateKey_file ck_SSL_use_PrivateKey_file 64 | #define SSL_use_certificate_file ck_SSL_use_certificate_file 65 | #define SSL_CTX_use_PrivateKey_file ck_SSL_CTX_use_PrivateKey_file 66 | #define SSL_CTX_use_certificate_file ck_SSL_CTX_use_certificate_file 67 | #define SSL_set_verify ck_SSL_set_verify 68 | #define SSL_new ck_SSL_new 69 | #define SSL_CTX_ctrl ck_SSL_CTX_ctrl 70 | #define SSL_CTX_new ck_SSL_CTX_new 71 | #define SSL_CTX_free ck_SSL_CTX_free 72 | #define SSL_CTX_set_default_passwd_cb ck_SSL_CTX_set_default_passwd_cb 73 | #define SSLv23_method ck_SSLv23_method 74 | #ifndef OPENSSL_NO_SSL3 75 | #define SSLv3_method ck_SSLv3_method 76 | #endif /* OPENSSL_NO_SSL3 */ 77 | #define TLSv1_method ck_TLSv1_method 78 | #define SSLv23_client_method ck_SSLv23_client_method 79 | #ifndef OPENSSL_NO_SSL3 80 | #define SSLv3_client_method ck_SSLv3_client_method 81 | #endif /* OPENSSL_NO_SSL3 */ 82 | #define TLSv1_client_method ck_TLSv1_client_method 83 | #define SSLv23_server_method ck_SSLv23_server_method 84 | #ifndef OPENSSL_NO_SSL3 85 | #define SSLv3_server_method ck_SSLv3_server_method 86 | #endif /* OPENSSL_NO_SSL3 */ 87 | #define TLSv1_server_method ck_TLSv1_server_method 88 | #define SSL_library_init ck_SSL_library_init 89 | #define SSL_state_string ck_SSL_state_string 90 | #define SSL_state_string_long ck_SSL_state_string_long 91 | #define SSL_accept ck_SSL_accept 92 | #define SSL_set_cipher_list ck_SSL_set_cipher_list 93 | 94 | #define ERR_print_errors ck_ERR_print_errors 95 | #define ERR_print_errors_fp ck_ERR_print_errors_fp 96 | #define ERR_error_string ck_ERR_error_string 97 | #define ERR_get_error ck_ERR_get_error 98 | 99 | #define BIO_printf ck_BIO_printf 100 | #define BIO_ctrl ck_BIO_ctrl 101 | #define BIO_new ck_BIO_new 102 | #define BIO_s_file ck_BIO_s_file 103 | #define BIO_s_mem ck_BIO_s_mem 104 | #define BIO_s_null ck_BIO_s_null 105 | #define BIO_read ck_BIO_read 106 | #define BIO_new_file ck_BIO_new_file 107 | #define BIO_free ck_BIO_free 108 | 109 | #define X509_get_issuer_name ck_X509_get_issuer_name 110 | #define X509_verify_cert_error_string ck_X509_verify_cert_error_string 111 | #define X509_NAME_oneline ck_X509_NAME_oneline 112 | #define X509_get_subject_name ck_X509_get_subject_name 113 | #define X509_STORE_CTX_get_current_cert ck_X509_STORE_CTX_get_current_cert 114 | #define X509_get_default_cert_dir ck_X509_get_default_cert_dir 115 | #define X509_free ck_X509_free 116 | 117 | #define RSA_free ck_RSA_free 118 | #define RSA_generate_key ck_RSA_generate_key 119 | 120 | #define DH_new ck_DH_new 121 | #define DH_free ck_DH_free 122 | #define DH_generate_key ck_DH_generate_key 123 | #define DH_generate_parameters ck_DH_generate_parameters 124 | 125 | #define DSA_free ck_DSA_free 126 | #define DSA_generate_key ck_DSA_generate_key 127 | #define DSA_generate_parameters ck_DSA_generate_parameters 128 | 129 | #define PEM_read_bio_DHparams ck_PEM_read_bio_DHparams 130 | #define BN_bin2bn ck_BN_bin2bn 131 | #endif /* OS2 */ 132 | #endif /* CK_SSL */ 133 | -------------------------------------------------------------------------------- /ckcsym.h: -------------------------------------------------------------------------------- 1 | /* This file is for use with compilers that don't have the capability to 2 | * #define symbols on the C compiler command line. This file must 3 | * be #include'd before all other ck*.h files so that the symbols #define'd 4 | * here can be used for any subsequent conditional code. 5 | */ 6 | -------------------------------------------------------------------------------- /ckcuni.h: -------------------------------------------------------------------------------- 1 | /* C K C U N I . H -- Unicode/Terminal character-set translations */ 2 | 3 | /* 4 | Copyright (C) 1999, 2022, 5 | Trustees of Columbia University in the City of New York. 6 | All rights reserved. See the C-Kermit COPYING.TXT file or the 7 | copyright text in the ckcmai.c module for disclaimer and permissions. 8 | 9 | Authors: 10 | Frank da Cruz 11 | The Kermit Project, New York City. 12 | Jeffrey E Altman 13 | Secure Endpoints Inc., New York City 14 | */ 15 | 16 | /* Terminal character sets */ 17 | 18 | #ifndef CKOUNI_H 19 | #define CKOUNI_H 20 | #ifdef OS2 21 | #ifndef CKOUNI 22 | #define CKOUNI /* Use UNICODE for OS/2 functions */ 23 | #endif /* CKOUNI */ 24 | #ifdef KUI 25 | #define X_CKOUNI_IN /* Use Unicode Input */ 26 | #define CKOUNI_OUT 27 | #endif /* KUI */ 28 | #endif /* OS2 */ 29 | 30 | /* Terminal Character Sets */ 31 | 32 | #define TX_ASCII 0 /* US ASCII */ 33 | #define TX_BRITISH 1 /* British ISO 646 */ 34 | #define TX_CN_FRENCH 2 /* Canadian French NRC */ 35 | #define TX_CUBAN 3 /* Cuba */ 36 | #define TX_CZECH 4 /* Czech Republic */ 37 | #define TX_DANISH 5 /* Denmark / Norway ISO 646 */ 38 | #define TX_DUTCH 6 /* Dutch NRC */ 39 | #define TX_FINNISH 7 /* Finnish NRC */ 40 | #define TX_FRENCH 8 /* French ISO 646 */ 41 | #define TX_GERMAN 9 /* German ISO 646 */ 42 | #define TX_HE7 10 /* Hebrew 7 (DEC) */ 43 | #define TX_HUNGARIAN 11 /* Hungarian ISO 646 */ 44 | #define TX_ICELANDIC 12 /* Icelandic NRC */ 45 | #define TX_ITALIAN 13 /* Italian ISO 646 */ 46 | #define TX_J201R 14 /* JIS 0201 Japanese Roman */ 47 | #define TX_J201K 15 /* JIS 0201 Katakana */ 48 | #define TX_KOI7 16 /* Short KOI */ 49 | #define TX_NORWEGIAN 17 /* Denmark / Norway ISO 646 */ 50 | #define TX_PORTUGUESE 18 /* Portuguese ISO 646 */ 51 | #define TX_SPANISH 19 /* Spanish ISO 646 */ 52 | #define TX_SWEDISH 20 /* Swedish ISO 646 */ 53 | #define TX_SWE_2 21 /* Swedish for names ISO 646 */ 54 | #define TX_SWISS 22 /* Swiss NRC */ 55 | #define TX_8859_1 23 /* Latin-1 */ 56 | #define TX_8859_2 24 /* Latin-2 */ 57 | #define TX_8859_3 25 /* Latin-3 */ 58 | #define TX_8859_4 26 /* Latin-4 */ 59 | #define TX_8859_5 27 /* Latin/Cyrillic */ 60 | #define TX_8859_6 28 /* Latin/Arabic */ 61 | #define TX_8859_7 29 /* Latin/Greek */ 62 | #define TX_8859_8 30 /* Latin/Hebrew */ 63 | #define TX_8859_9 31 /* Latin-5 */ 64 | #define TX_8859_10 32 /* Latin-6 */ 65 | 66 | #define TX_KOI8 33 /* GOST 19768-74 KOI-8 */ 67 | 68 | #define TX_JIS7 34 /* JIS-7 */ 69 | #define TX_SHJIS 35 /* Shift JIS */ 70 | #define TX_JEUC 36 /* Japanese EUC */ 71 | #define TX_JDEC 37 /* Japanese DEC Kanji */ 72 | 73 | #define TX_DECMCS 38 /* DEC MCS */ 74 | #define TX_NEXT 39 /* NeXT */ 75 | #define TX_DGI 40 /* Data General International */ 76 | #define TX_MACL1 41 /* Macintosh Latin-1 */ 77 | #define TX_HPR8 42 /* HP Roman 8 */ 78 | 79 | /* Code pages */ 80 | 81 | #define TX_CP437 43 /* Original */ 82 | #define TX_CP850 44 /* Multinational (Western Europe) */ 83 | #define TX_CP852 45 /* Eastern Europe */ 84 | #define TX_CP857 46 /* Turkey */ 85 | #define TX_CP862 47 /* Hebrew */ 86 | #define TX_CP864 48 /* Arabic */ 87 | #define TX_CP866 49 /* Cyrillic */ 88 | #define TX_CP869 50 /* Greek */ 89 | 90 | #define TX_DECSPEC 51 /* DEC Special Graphics */ 91 | #define TX_DECTECH 52 /* DEC Technical */ 92 | #define TX_C0PICT 53 /* C0 Display Controls */ 93 | #define TX_C1PICT 54 /* C1 Display Controls */ 94 | #define TX_IBMC0GRPH 55 /* IBM C0 Graphics (smileys) */ 95 | #define TX_H19GRAPH 56 /* Heath/Zenith 19 Graphics */ 96 | #define TX_TVIGRAPH 57 /* Televideo Graphics */ 97 | #define TX_WYSE60G_N 58 /* Wyse 60 Native Mode Graphics */ 98 | #define TX_WYSE60G_1 59 /* Wyse 60 Graphics 1 */ 99 | #define TX_WYSE60G_2 60 /* Wyse 60 Graphics 2 */ 100 | #define TX_WYSE60G_3 61 /* Wyse 60 Graphics 3 */ 101 | 102 | /* New ones that came too late for the nice grouping... */ 103 | 104 | #define TX_ELOT927 62 /* Greek ELOT 927 */ 105 | #define TX_DGPCGRPH 63 /* DG PC Graphics */ 106 | #define TX_DGLDGRPH 64 /* DG Line Drawing Graphics */ 107 | #define TX_DGWPGRPH 65 /* DG Word Processing (etc) Graphics */ 108 | #define TX_HPLINE 66 /* HP Line Drawing */ 109 | #define TX_HPMATH 67 /* HP Math/Technical */ 110 | #define TX_QNXGRPH 68 /* QNX Graphics */ 111 | 112 | /* Siemens Nixdorf character sets */ 113 | 114 | #define TX_SNIBRACK 69 /* SNI 97801 Brackets */ 115 | #define TX_SNIEURO 70 /* SNI 97801 Euro */ 116 | #define TX_SNIFACET 71 /* SNI 97801 Facet */ 117 | #define TX_SNIIBM 72 /* SNI 97801 "IBM" */ 118 | #define TX_SNIBLANK 73 /* SNI 97801 Blanks */ 119 | 120 | /* Windows Code pages */ 121 | 122 | #define TX_CP1252 74 /* Latin-1 Windows */ 123 | #define TX_CP1250 75 /* Latin-2 Windows */ 124 | #define TX_CP1251 76 /* Cyrillic Windows */ 125 | #define TX_CP1253 77 /* Greece Windows */ 126 | #define TX_CP1254 78 /* Turkey Windows */ 127 | #define TX_CP1257 79 /* Latin-4 Windows */ 128 | 129 | #define TX_CP856 80 /* Bulgaria CP856 (DATECS Ltd) */ 130 | #define TX_CP855 81 131 | #define TX_CP819 82 /* Same as ISO 8859-1 */ 132 | #define TX_CP912 83 /* Same as ISO 8859-2 */ 133 | #define TX_CP913 84 /* Same as ISO 8859-3 */ 134 | #define TX_CP914 85 /* Same as ISO 8859-4 */ 135 | #define TX_CP915 86 /* Same as ISO 8859-5 */ 136 | #define TX_CP1089 87 /* Same as ISO 8859-6 */ 137 | #define TX_CP813 88 /* Same as ISO 8859-7 */ 138 | #define TX_CP916 89 /* Same as ISO 8859-8 */ 139 | #define TX_CP920 90 /* Same as ISO 8859-9 */ 140 | #define TX_CP1051 91 /* Same as HP Roman 8 */ 141 | #define TX_CP858 92 /* Multinational (W. Europe) w/Euro */ 142 | #define TX_8859_15 93 /* Latin-9 */ 143 | #define TX_CP923 94 /* Same as ISO 8859-15 */ 144 | 145 | #define TX_ELOT928 95 /* Same as ISO 8859-7 */ 146 | #define TX_CP10000 96 /* Same as original Apple Quickdraw */ 147 | #define TX_CP37 97 /* EBCDIC */ 148 | #define TX_CP1255 98 /* Israel Windows */ 149 | #define TX_CP1256 99 /* Arabic Windows */ 150 | #define TX_CP1258 100 /* Viet Nam Windows */ 151 | #define TX_MAZOVIA 101 152 | #define TX_TRANSP 102 /* Transparent - no translation */ 153 | #define TX_HZ1500 103 /* Hazeltine 1500 graphics set */ 154 | #define TX_KOI8R 104 /* KOI8R - Russian */ 155 | #define TX_KOI8U 105 /* KOI8U - Ukrainian */ 156 | #define TX_APL1 106 /* APL ISO IR 68 */ 157 | #define TX_APL2 107 /* Dyadic Systems Inc APL */ 158 | #define TX_APL3 108 /* APL-Plus (APL-2000) */ 159 | #define TX_APL4 109 /* IBM APL/2 */ 160 | #define TX_APL5 110 /* APL-2741 */ 161 | 162 | #define MAXTXSETS 111 /* Number of terminal character sets */ 163 | 164 | /* The following are not implemented yet */ 165 | /* UTF-8 is supported as a special mode in Kermit 95 (see utf8 flag) */ 166 | 167 | #define TX_UTF7 128 168 | #define TX_UTF8 129 169 | 170 | #define TX_HEXBYTES 242 /* Hex bytes */ 171 | #define TX_DEBUG 243 /* Debugging but not hex bytes */ 172 | 173 | /* These are actually used */ 174 | 175 | #define TX_UNDEF 255 /* Unknown character-set */ 176 | 177 | /* Flag bit values */ 178 | 179 | #define X2U_STD 1 /* Has standard ISO 4873 layout */ 180 | #define X2U_ISO 2 /* ISO standard character set */ 181 | #define X2U_JIS 4 /* Japan Industrial Standard */ 182 | #define X2U_CP 8 /* PC Code Page */ 183 | #define X2U_DEC 16 /* DEC Private character set */ 184 | #define X2U_CXG 32 /* Control codes used for graphics */ 185 | 186 | struct x_to_unicode { 187 | int size; /* 94, 96, 128, or other */ 188 | int offset; /* 0, 32, 33, 128, 160, ... */ 189 | int flags; 190 | int family; /* Language family, writing system */ 191 | char * keywd; /* Keyword name */ 192 | char * name; /* Descriptive name */ 193 | int code; /* ISO reg number if Standard */ 194 | /* CP number if Code-page, etc. */ 195 | char * final; /* Esc seq final char(s) (ISO, DEC) */ 196 | unsigned short map[256]; /* Mapping table */ 197 | }; 198 | 199 | extern struct keytab txrtab[]; 200 | extern int ntxrtab; 201 | 202 | #ifndef NULL 203 | #define NULL (char *)0 204 | #endif /* NULL */ 205 | 206 | #ifndef USHORT 207 | #define USHORT unsigned short 208 | #endif /* USHORT */ 209 | 210 | #ifndef ULONG 211 | #define ULONG unsigned long 212 | #endif /* ULONG */ 213 | 214 | #ifndef CHAR 215 | #define CHAR unsigned char 216 | #endif /* CHAR */ 217 | 218 | #ifdef CK_ANSIC 219 | extern USHORT (*xl_u[MAXTXSETS+1])(CHAR); /* Blah-to-Unicode functions */ 220 | extern int (*xl_tx[MAXTXSETS+1])(USHORT); /* Unicode-to-Blah functions */ 221 | #else 222 | extern USHORT (*xl_u[MAXTXSETS+1])(); 223 | extern int (*xl_tx[MAXTXSETS+1])(); 224 | #endif /* CK_ANSIC */ 225 | extern struct x_to_unicode * txrinfo[MAXTXSETS+1]; 226 | 227 | _PROTOTYP(int ck_isunicode, (void)); 228 | 229 | _PROTOTYP(int utf8_to_ucs2, (CHAR, USHORT **)); 230 | _PROTOTYP(int ucs2_to_utf8, (USHORT, CHAR **)); 231 | _PROTOTYP(int tx_cpsub, (USHORT)); 232 | _PROTOTYP(int u_to_b, (CHAR) ); 233 | _PROTOTYP(int u_to_b2, (void) ); 234 | _PROTOTYP(int b_to_u, (CHAR, CHAR *, int, int) ); 235 | 236 | #ifdef KANJI 237 | _PROTOTYP(USHORT sj_to_un, (USHORT) ); /* Shift-JIS to Unicode */ 238 | _PROTOTYP(USHORT un_to_sj, (USHORT) ); /* Unicode to Shift-JIS */ 239 | #endif /* KANJI */ 240 | 241 | #ifdef OS2 242 | #ifdef NT 243 | #ifdef COMMENT 244 | _inline 245 | #else 246 | /* [jt] 2013/11/21 - duplicate definition issue */ 247 | static _inline 248 | #endif /* COMMENT */ 249 | #else 250 | #ifdef __WATCOMC__ 251 | inline 252 | #else 253 | _Inline 254 | #endif /* __WATCOMC__ */ 255 | #endif /* NT */ 256 | int 257 | ck_isunicode( 258 | #ifdef CK_ANSIC 259 | void 260 | #endif /* CK_ANSIC */ 261 | ) { 262 | extern int tt_unicode; 263 | #ifdef NT 264 | #ifdef KUI 265 | return(tt_unicode); 266 | #else /* KUI */ 267 | if (tt_unicode && !isWin95()) 268 | return(1); 269 | else 270 | return(0); 271 | #endif /* KUI */ 272 | #else /* NT */ 273 | return(0); 274 | #endif /* NT */ 275 | } 276 | #endif /* OS2 */ 277 | #endif /* CKOUNI_H */ 278 | -------------------------------------------------------------------------------- /ckcxla.h: -------------------------------------------------------------------------------- 1 | /* 2 | File CKCXLA.H 3 | 4 | System-independent character-set translation header file for C-Kermit. 5 | */ 6 | 7 | /* 8 | Author: Frank da Cruz , 9 | The Kermit Project - Columbia University, New York City. 10 | 11 | Copyright (C) 1985, 2009, 12 | Trustees of Columbia University in the City of New York. 13 | All rights reserved. See the C-Kermit COPYING.TXT file or the 14 | copyright text in the ckcmai.c module for disclaimer and permissions. 15 | */ 16 | /* 17 | NOTE: 18 | ISO 204 is Latin-1 + Euro. 19 | ISO 205 is Latin-4 + Euro. 20 | ISO 206 is Latin-7 + Euro. 21 | */ 22 | #ifndef CKCXLA_H /* Guard against multiple inclusion */ 23 | #define CKCXLA_H 24 | 25 | #ifndef KANJI /* Systems supporting Kanji */ 26 | #ifdef OS2 27 | #define KANJI 28 | #endif /* OS2 */ 29 | #endif /* KANJI */ 30 | 31 | #ifdef NOKANJI /* Except if NOKANJI is defined. */ 32 | #ifdef KANJI 33 | #undef KANJI 34 | #endif /* KANJI */ 35 | #endif /* NOKANJI */ 36 | 37 | #ifndef NOUNICODE 38 | #ifndef UNICODE /* Unicode support */ 39 | #ifdef OS2ORUNIX /* Only for K95, UNIX, VMS,... */ 40 | #define UNICODE 41 | #else 42 | #ifdef VMS 43 | #define UNICODE 44 | #endif /* VMS */ 45 | #endif /* OS2ORUNIX */ 46 | #endif /* UNICODE */ 47 | #endif /* NOUNICODE */ 48 | 49 | #define XLA_NONE 0 /* Translation types - none */ 50 | #define XLA_BYTE 1 /* Byte-for-byte */ 51 | #define XLA_JAPAN 2 /* Japanese */ 52 | #define XLA_UNICODE 3 /* Unicode */ 53 | 54 | #ifndef UNIORKANJI /* Unicode OR Kanji */ 55 | #ifdef UNICODE /* i.e. some support for */ 56 | #define UNIORKANJI /* multibyte character sets */ 57 | #endif /* UNICODE */ 58 | #ifdef KANJI 59 | #define UNIORKANJI 60 | #endif /* KANJI */ 61 | #endif /* UNIORKANJI */ 62 | /* 63 | Disable all support for all classes of character sets 64 | if NOCSETS is defined. 65 | */ 66 | #ifdef NOCSETS 67 | 68 | #ifdef CKOUNI 69 | #undef CKOUNI 70 | #endif /* CKOUNI */ 71 | #ifdef KANJI 72 | #undef KANJI 73 | #endif /* KANJI */ 74 | #ifdef CYRILLIC 75 | #undef CYRILLIC 76 | #endif /* CYRILLIC */ 77 | #ifdef LATIN2 78 | #undef LATIN2 79 | #endif /* LATIN2 */ 80 | #ifdef HEBREW 81 | #undef HEBREW 82 | #endif /* HEBREW */ 83 | #ifdef UNICODE 84 | #undef UNICODE 85 | #endif /* UNICODE */ 86 | #ifndef NOUNICODE 87 | #define NOUNICODE 88 | #endif /* NOUNICODE */ 89 | 90 | #else /* Not NOCSETS - Rest of this file... */ 91 | 92 | #ifdef NOUNICODE /* Unicode */ 93 | #ifdef UNICODE 94 | #undef UNICODE 95 | #endif /* UNICODE */ 96 | #endif /* NOUNICODE */ 97 | 98 | #ifdef UNICODE 99 | #ifdef OS2 100 | #ifndef CKOUNI 101 | #define CKOUNI /* Special Unicode features for K95 */ 102 | #endif /* CKOUNI */ 103 | #endif /* OS2 */ 104 | #endif /* UNICODE */ 105 | 106 | #ifndef OS2 107 | #ifdef CKOUNI 108 | #undef CKOUNI 109 | #endif /* CKOUNI */ 110 | #endif /* OS2 */ 111 | 112 | #ifndef NOLATIN2 /* If they didn't say "no Latin-2" */ 113 | #ifndef LATIN2 /* Then if LATIN2 isn't already */ 114 | #define LATIN2 /* defined, define it. */ 115 | #endif /* LATIN2 */ 116 | #endif /* NOLATIN2 */ 117 | 118 | #ifdef NOCYRILLIC /* (spelling variant...) */ 119 | #ifndef NOCYRIL 120 | #define NOCYRIL 121 | #endif /* NOCYRIL */ 122 | #endif /* NOCYRILLIC */ 123 | 124 | #ifndef NOCYRIL /* If they didn't say "no Cyrillic" */ 125 | #ifndef CYRILLIC /* Then if CYRILLIC isn't already */ 126 | #define CYRILLIC /* defined, define it. */ 127 | #endif /* CYRILLIC */ 128 | #endif /* NOCYRIL */ 129 | 130 | #ifndef NOHEBREW /* If they didn't say "no Hebrew" */ 131 | #ifndef HEBREW /* Then if HEBREW isn't already */ 132 | #define HEBREW /* defined, define it. */ 133 | #endif /* HEBREW */ 134 | #endif /* NOHEBREW */ 135 | 136 | #ifndef NOGREEK /* If not no Greek */ 137 | #ifndef GREEK /* then if GREEK isn't already */ 138 | #define GREEK /* defined, define it. */ 139 | #endif /* GREEK */ 140 | #endif /* NOGREEK */ 141 | 142 | #ifndef NOKANJI /* If not no Kanji */ 143 | #ifndef KANJI /* then if KANJI isn't already */ 144 | #define KANJI /* defined, define it. */ 145 | #endif /* KANJI */ 146 | #endif /* NOKANJI */ 147 | 148 | /* File ckcxla.h -- Character-set-related definitions, system independent */ 149 | 150 | /* Codes for Kermit Transfer Syntax Level (obsolete) */ 151 | 152 | #define TS_L0 0 /* Level 0 (Transparent) */ 153 | #define TS_L1 1 /* Level 1 (one standard character set) */ 154 | #define TS_L2 2 /* Level 2 (multiple character sets in same file) */ 155 | 156 | #define UNK 63 /* Symbol to use for unknown character (63 = ?) */ 157 | 158 | /* 159 | Codes for the base alphabet of a given character set. 160 | These are assigned in roughly ISO 8859 order. 161 | (Each is assumed to include ASCII/Roman.) 162 | */ 163 | #define AL_UNIV 0 /* Universal (like ISO 10646) */ 164 | #define AL_ROMAN 1 /* Roman (Latin) alphabet */ 165 | #define AL_CYRIL 2 /* Cyrillic alphabet */ 166 | #define AL_ARABIC 3 /* Arabic */ 167 | #define AL_GREEK 4 /* Greek */ 168 | #define AL_HEBREW 5 /* Hebrew */ 169 | #define AL_KANA 6 /* Japanese Katakana */ 170 | #define AL_JAPAN 7 /* Japanese Katakana+Kanji ideograms */ 171 | #define AL_HAN 8 /* Chinese/Japanese/Korean ideograms */ 172 | #define AL_INDIA 9 /* Indian scripts (ISCII) */ 173 | #define AL_VIET 10 /* Vietnamese (VISCII) */ 174 | /* Add more here... */ 175 | #define AL_UNK 999 /* Unknown (transparent) */ 176 | 177 | /* Codes for languages */ 178 | /* 179 | NOTE: It would perhaps be better to use ISO 639-1988 2-letter "Codes for 180 | Representation of Names of Languages" here, shown in the comments below. 181 | */ 182 | #define L_ASCII 0 /* EN ASCII, English */ 183 | #define L_USASCII 0 /* EN ASCII, English */ 184 | #define L_DUTCH 1 /* NL Dutch */ 185 | #define L_FINNISH 2 /* FI Finnish */ 186 | #define L_FRENCH 3 /* FR French */ 187 | #define L_GERMAN 4 /* DE German */ 188 | #define L_HUNGARIAN 5 /* HU Hungarian */ 189 | #define L_ITALIAN 6 /* IT Italian */ 190 | #define L_NORWEGIAN 7 /* NO Norwegian */ 191 | #define L_PORTUGUESE 8 /* PT Portuguese */ 192 | #define L_SPANISH 9 /* ES Spanish */ 193 | #define L_SWEDISH 10 /* SV Swedish */ 194 | #define L_SWISS 11 /* RM Swiss (Rhaeto-Romance) */ 195 | #define L_DANISH 12 /* DA Danish */ 196 | #define L_ICELANDIC 13 /* IS Icelandic */ 197 | #define L_RUSSIAN 14 /* RU Russian */ 198 | #define L_JAPANESE 15 /* JA Japanese */ 199 | #define L_HEBREW 16 /* IW Hebrew */ 200 | #define L_GREEK 17 /* Greek */ 201 | 202 | #define MAXLANG 17 /* Number of languages */ 203 | 204 | /* 205 | File character-sets are defined in the system-specific ck?xla.h file, 206 | except for the following ones, which must be available to all versions: 207 | */ 208 | #define FC_TRANSP 254 /* Transparent */ 209 | #define FC_UNDEF 255 /* Undefined */ 210 | /* 211 | Designators for Kermit's transfer character sets. These are all standard 212 | sets, or based on them. Symbols must be unique in the first 8 characters, 213 | because some C preprocessors have this limit. 214 | */ 215 | /* LIST1 */ 216 | #define TC_TRANSP 0 /* Transparent, no character translation */ 217 | #define TC_USASCII 1 /* ISO 646 IRV / US 7-bit ASCII */ 218 | #define TC_1LATIN 2 /* ISO 8859-1, Latin Alphabet 1 */ 219 | #define TC_2LATIN 3 /* ISO 8859-2, Latin Alphabet 2 */ 220 | #define TC_CYRILL 4 /* ISO 8859-5, Latin/Cyrillic */ 221 | #define TC_JEUC 5 /* Japanese EUC = JIS 0201+0202+0208 */ 222 | #define TC_HEBREW 6 /* ISO 8859-8, Latin/Hebrew */ 223 | #define TC_GREEK 7 /* ISO 8859-7, Latin/Greek */ 224 | #define TC_9LATIN 8 /* ISO 8859-15 Latin Alphabet 9 (with Euro) */ 225 | #define TC_UCS2 9 /* ISO 10646 / Unicode UCS-2 */ 226 | #define TC_UTF8 10 /* ISO 10646 / Unicode UTF-8 */ 227 | 228 | #define MAXTCSETS 10 /* Highest Transfer Character Set Number */ 229 | 230 | #ifdef COMMENT 231 | /* 232 | Not used and probably won't be due to ISO-10646 / Unicode. 233 | */ 234 | #define TC_3LATIN 11 /* ISO 8859-3, Latin-3 */ 235 | #define TC_4LATIN 12 /* ISO 8859-4, Latin-4 */ 236 | #define TC_5LATIN 13 /* ISO 8859-9, Latin-5 */ 237 | #define TC_ARABIC 14 /* ISO-8859-6, Latin/Arabic */ 238 | #define TC_JIS208 15 /* Japanese JIS X 0208 multibyte set */ 239 | #define TC_CHINES 16 /* Chinese Standard GB 2312-80 */ 240 | #define TC_KOREAN 17 /* Korean KS C 5601-1987 */ 241 | #define TC_ISCII 18 /* Indian standard code for ii... */ 242 | #define TC_VSCII 19 /* Vietnam standard code for ii... */ 243 | /* etc... */ 244 | #endif /* COMMENT */ 245 | 246 | /* Structure for character-set information */ 247 | 248 | struct csinfo { 249 | char *name; /* Descriptive name of character set */ 250 | int size; /* Size (e.g. 128, 256, 16384) */ 251 | int code; /* Like TC_1LATIN, etc. */ 252 | char *designator; /* Designator, like I2/100 = Latin-1 */ 253 | int alphabet; /* Base alphabet */ 254 | char *keyword; /* Keyword for this character-set */ 255 | }; 256 | 257 | /* Structure for language information */ 258 | 259 | struct langinfo { 260 | int id; /* Language ID code (L_whatever) */ 261 | int fc; /* File character set to use */ 262 | int tc; /* Transfer character set to use */ 263 | char *description; /* Description of language */ 264 | }; 265 | 266 | /* Now take in the system-specific definitions */ 267 | 268 | #ifdef UNIX 269 | #include "ckuxla.h" 270 | #endif /* UNIX */ 271 | 272 | #ifdef OSK /* OS-9 */ 273 | #include "ckuxla.h" 274 | #endif /* OS-9 */ 275 | 276 | #ifdef VMS /* VAX/VMS */ 277 | #include "ckuxla.h" 278 | #endif /* VMS */ 279 | 280 | #ifdef GEMDOS /* Atari ST */ 281 | #include "ckuxla.h" 282 | #endif /* GEMDOS */ 283 | 284 | #ifdef MAC /* Macintosh */ 285 | #include "ckmxla.h" 286 | #endif /* MAC */ 287 | 288 | #ifdef OS2 /* OS/2 */ 289 | #include "ckuxla.h" /* Uses big UNIX version */ 290 | #endif /* OS2 */ 291 | 292 | #ifdef AMIGA /* Commodore Amiga */ 293 | #include "ckuxla.h" 294 | #endif /* AMIGA */ 295 | 296 | #ifdef datageneral /* Data General MV AOS/VS */ 297 | #include "ckuxla.h" 298 | #endif /* datageneral */ 299 | 300 | #ifdef STRATUS /* Stratus Computer, Inc. VOS */ 301 | #include "ckuxla.h" 302 | #endif /* STRATUS */ 303 | 304 | #ifdef UNICODE 305 | #include "ckcuni.h" /* Unicode */ 306 | #endif /* UNICODE */ 307 | 308 | #ifdef KANJI 309 | #define UNKSJIS 0x817f 310 | _PROTOTYP(USHORT eu_to_sj, (USHORT) ); /* EUC-JP to Shift-JIS */ 311 | _PROTOTYP(USHORT sj_to_eu, (USHORT) ); /* Shift-JIS to EUC-JP */ 312 | _PROTOTYP( int xkanjf, (void) ); 313 | _PROTOTYP( int xkanji, (int, int (*)(char)) ); 314 | _PROTOTYP( int xkanjz, (int (*)(char) ) ); 315 | _PROTOTYP( int zkanjf, (void) ); 316 | _PROTOTYP( int zkanji, (int (*)(void)) ); /* Kanji function prototypes */ 317 | _PROTOTYP( int zkanjz, (void) ); 318 | _PROTOTYP(VOID j7init, ( void ) ); /* Initialize JIS-7 parser */ 319 | _PROTOTYP(int getj7, ( void ) ); /* Get next JIS-7 character */ 320 | #endif /* KANJI */ 321 | 322 | #ifndef MAC 323 | #ifndef NOLOCAL 324 | _PROTOTYP( int cs_size, (int) ); 325 | _PROTOTYP( int cs_is_std, (int) ); 326 | _PROTOTYP( int cs_is_nrc, (int) ); 327 | _PROTOTYP( VOID setremcharset, (int, int) ); 328 | _PROTOTYP( VOID setlclcharset, (int) ); 329 | #endif /* NOLOCAL */ 330 | #endif /* MAC */ 331 | 332 | _PROTOTYP(VOID setxlatype, (int, int)); 333 | 334 | #endif /* NOCSETS */ 335 | #endif /* CKCXLA_H */ 336 | 337 | /* End of ckcxla.h */ 338 | -------------------------------------------------------------------------------- /ckermit.ini: -------------------------------------------------------------------------------- 1 | COMMENT - Standard C-Kermit initialization file 2 | ; 3 | echo 4 | echo The very long standard initialization file that was distributed 5 | echo with C-Kermit 6, 7, and 8 is no longer recommended as "standard", 6 | echo since its features were little used. It is still available in 7 | echo the C-Kermit distribution as ockermit.ini. 8 | echo 9 | -------------------------------------------------------------------------------- /ckpker.mak: -------------------------------------------------------------------------------- 1 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | /* 20 | * These should probably be placed in an include file. If you add anything 21 | * here then you will also have to modify /usr/src/usr.lib/libstubs/stubs.c 22 | * (if for no other reason than to add the stub code). 23 | */ 24 | 25 | #define CTIME 1 26 | #define ASCTIME 2 27 | #define TZSET 3 28 | #define LOCALTIME 4 29 | #define GMTIME 5 30 | #define OFFTIME 6 31 | 32 | #define GETPWENT 7 33 | #define GETPWNAM 8 34 | #define GETPWUID 9 35 | #define SETPASSENT 10 36 | #define ENDPWENT 11 37 | 38 | extern struct tm *offtime(); 39 | 40 | jmp_buf env; 41 | char *cp; 42 | char junk[256 + sizeof (struct passwd) + 4]; 43 | long off; 44 | time_t l; 45 | void timeout(), checkppid(); 46 | struct tm tmtmp, *tp; 47 | 48 | main() 49 | { 50 | register int i; 51 | register struct passwd *pw; 52 | struct itimerval it; 53 | u_char c, xxx; 54 | int len, tosslen; 55 | uid_t uid; 56 | 57 | signal(SIGPIPE, SIG_DFL); 58 | for (i = getdtablesize(); --i > 2; ) 59 | close(i); 60 | /* 61 | * Need a timer running while we disassociate from the control terminal 62 | * in case of a modem line which has lost carrier. 63 | */ 64 | timerclear(&it.it_interval); 65 | it.it_value.tv_sec = 5; 66 | it.it_value.tv_usec = 0; 67 | signal(SIGALRM, timeout); 68 | setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL); 69 | if (setjmp(env) == 0) 70 | { 71 | i = open("/dev/tty", 0); 72 | if (i >= 0) 73 | { 74 | ioctl(i, TIOCNOTTY, NULL); 75 | close(i); 76 | } 77 | } 78 | /* 79 | * Now start a timer with one minute refresh. In the signal service 80 | * routine, check the parent process id to see if this process has 81 | * been orphaned and if so exit. This is primarily aimed at removing 82 | * the 'ctimed' process left behind by 'sendmail's multi-fork startup 83 | * but may prove useful in preventing accumulation of 'ctimed' processes 84 | * in other circumstances as well. Normally this process is short 85 | * lived. 86 | */ 87 | it.it_interval.tv_sec = 60; 88 | it.it_interval.tv_usec = 0; 89 | it.it_value.tv_sec = 60; 90 | it.it_value.tv_usec = 0; 91 | signal(SIGALRM, checkppid); 92 | setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL); 93 | 94 | while (read(fileno(stdin), &c, 1) == 1) 95 | { 96 | switch (c) 97 | { 98 | case CTIME: 99 | l = 0L; 100 | getb(fileno(stdin), &l, sizeof l); 101 | cp = ctime(&l); 102 | write(fileno(stdout), cp, 26); 103 | break; 104 | case ASCTIME: 105 | getb(fileno(stdin), &tmtmp, sizeof tmtmp); 106 | cp = asctime(&tmtmp); 107 | write(fileno(stdout), cp, 26); 108 | break; 109 | case TZSET: 110 | (void) tzset(); 111 | break; 112 | case LOCALTIME: 113 | l = 0L; 114 | getb(fileno(stdin), &l, sizeof l); 115 | tp = localtime(&l); 116 | write(fileno(stdout), tp, sizeof (*tp)); 117 | strcpy(junk, tp->tm_zone); 118 | junk[24] = '\0'; 119 | write(fileno(stdout), junk, 24); 120 | break; 121 | case GMTIME: 122 | l = 0L; 123 | getb(fileno(stdin), &l, sizeof l); 124 | tp = gmtime(&l); 125 | write(fileno(stdout), tp, sizeof (*tp)); 126 | strcpy(junk, tp->tm_zone); 127 | junk[24] = '\0'; 128 | write(fileno(stdout), junk, 24); 129 | break; 130 | case OFFTIME: 131 | getb(fileno(stdin), &l, sizeof l); 132 | getb(fileno(stdin), &off, sizeof off); 133 | #ifdef __bsdi__ 134 | l += off; 135 | tp = localtime(&l); 136 | #else 137 | tp = offtime(&l, off); 138 | #endif 139 | write(fileno(stdout), tp, sizeof (*tp)); 140 | break; 141 | case GETPWENT: 142 | pw = getpwent(); 143 | do_pw(pw); 144 | break; 145 | case GETPWNAM: 146 | getb(fileno(stdin), &len, sizeof (int)); 147 | if (len > UT_NAMESIZE) 148 | { 149 | tosslen = len - UT_NAMESIZE; 150 | len = UT_NAMESIZE; 151 | } 152 | else 153 | tosslen = 0; 154 | getb(fileno(stdin), junk, len); 155 | for (;tosslen; tosslen--) 156 | getb(fileno(stdin), &xxx, 1); 157 | junk[len] = '\0'; 158 | pw = getpwnam(junk); 159 | do_pw(pw); 160 | break; 161 | case GETPWUID: 162 | getb(fileno(stdin), &uid, sizeof (uid_t)); 163 | pw = getpwuid(uid); 164 | do_pw(pw); 165 | break; 166 | case SETPASSENT: 167 | getb(fileno(stdin), &len, sizeof (int)); 168 | if (setpassent(len)) 169 | len = 1; 170 | else 171 | len = 0; 172 | write(fileno(stdout), &len, sizeof (int)); 173 | break; 174 | case ENDPWENT: 175 | endpwent(); 176 | break; 177 | default: 178 | abort("switch"); 179 | } 180 | } 181 | } 182 | 183 | getb(f, p, n) 184 | int f; 185 | register char *p; 186 | register int n; 187 | { 188 | register int i; 189 | 190 | while (n) 191 | { 192 | i = read(f, p, n); 193 | if (i <= 0) 194 | return; 195 | p += i; 196 | n -= i; 197 | } 198 | } 199 | 200 | void 201 | timeout() 202 | { 203 | 204 | longjmp(env, 1); 205 | } 206 | 207 | void 208 | checkppid() 209 | { 210 | 211 | if (getppid() == 1) 212 | exit(0); 213 | } 214 | 215 | do_pw(pw) 216 | struct passwd *pw; 217 | { 218 | int len; 219 | 220 | if (!pw) 221 | { 222 | len = 0; 223 | write(fileno(stdout), &len, sizeof (int)); 224 | return; 225 | } 226 | len = packpwtobuf(pw, junk); 227 | write(fileno(stdout), &len, sizeof (int)); 228 | write(fileno(stdout), pw, sizeof (*pw)); 229 | write(fileno(stdout), junk, len); 230 | return; 231 | } 232 | 233 | packpwtobuf(pw, buf) 234 | register struct passwd *pw; 235 | char *buf; 236 | { 237 | register char *cp = buf; 238 | register char *dp; 239 | 240 | dp = pw->pw_name; 241 | pw->pw_name = (char*) 0; 242 | while (*cp++ = *dp++) 243 | ; 244 | dp = pw->pw_passwd; 245 | pw->pw_passwd = (char*) (cp - buf); 246 | while (*cp++ = *dp++) 247 | ; 248 | dp = pw->pw_class; 249 | pw->pw_class = (char*) (cp - buf); 250 | while (*cp++ = *dp++) 251 | ; 252 | dp = pw->pw_gecos; 253 | pw->pw_gecos = (char*) (cp - buf); 254 | while (*cp++ = *dp++) 255 | ; 256 | dp = pw->pw_dir; 257 | pw->pw_dir = (char*) (cp - buf); 258 | while (*cp++ = *dp++) 259 | ; 260 | dp = pw->pw_shell; 261 | pw->pw_shell = (char*) (cp - buf); 262 | while (*cp++ = *dp++) 263 | ; 264 | return(cp - buf); 265 | } 266 | -------------------------------------------------------------------------------- /ckuat2.h: -------------------------------------------------------------------------------- 1 | /* 2 | C K U A T 2 . H -- Kerberos headers for C-Kermit 3 | 4 | Copyright (C) 1985, 2009, 5 | Trustees of Columbia University in the City of New York. 6 | All rights reserved. See the C-Kermit COPYING.TXT file or the 7 | copyright text in the ckcmai.c module for disclaimer and permissions. 8 | 9 | Author: 10 | Kerberos IV and V intergration. 11 | Jeffrey E Altman (jaltman@secure-endpoints.com) 12 | Secure Endpoints Inc., New York City 13 | */ 14 | /* 15 | * Based on a concatenation of all necessary include files distributed with 16 | * the Kerberos 5 NT Alpha 2 Telnet package from MIT. 17 | */ 18 | 19 | #ifndef KRB5_TELNET_H 20 | #define KRB5_TELNET_H 21 | /*- 22 | * Copyright (c) 1991, 1993 23 | * The Regents of the University of California. All rights reserved. 24 | * 25 | * Redistribution and use in source and binary forms, with or without 26 | * modification, are permitted provided that the following conditions 27 | * are met: 28 | * 1. Redistributions of source code must retain the above copyright 29 | * notice, this list of conditions and the following disclaimer. 30 | * 2. Redistributions in binary form must reproduce the above copyright 31 | * notice, this list of conditions and the following disclaimer in the 32 | * documentation and/or other materials provided with the distribution. 33 | * 3. All advertising materials mentioning features or use of this software 34 | * must display the following acknowledgement: 35 | * This product includes software developed by the University of 36 | * California, Berkeley and its contributors. 37 | * 4. Neither the name of the University nor the names of its contributors 38 | * may be used to endorse or promote products derived from this software 39 | * without specific prior written permission. 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * @(#)encrypt.h 8.1 (Berkeley) 6/4/93 54 | */ 55 | 56 | /* 57 | * Copyright (C) 1990 by the Massachusetts Institute of Technology 58 | * 59 | * Export of this software from the United States of America may 60 | * require a specific license from the United States Government. 61 | * It is the responsibility of any person or organization contemplating 62 | * export to obtain such a license before exporting. 63 | * 64 | * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 65 | * distribute this software and its documentation for any purpose and 66 | * without fee is hereby granted, provided that the above copyright 67 | * notice appear in all copies and that both that copyright notice and 68 | * this permission notice appear in supporting documentation, and that 69 | * the name of M.I.T. not be used in advertising or publicity pertaining 70 | * to distribution of the software without specific, written prior 71 | * permission. M.I.T. makes no representations about the suitability of 72 | * this software for any purpose. It is provided "as is" without express 73 | * or implied warranty. 74 | */ 75 | 76 | #ifdef CK_ENCRYPTION 77 | 78 | #ifndef __ENCRYPTION__ 79 | #define __ENCRYPTION__ 80 | 81 | #define DIR_DECRYPT 1 82 | #define DIR_ENCRYPT 2 83 | 84 | #ifndef CK_DES_C 85 | #ifndef NOBLOCKDEF 86 | typedef unsigned char Block[8]; 87 | #endif /* NOBLOCKDEF */ 88 | typedef unsigned char *BlockT; 89 | #ifndef KRB4 /* already defined in kerberosiv/des.h */ 90 | typedef struct des_ks_struct { Block _; } Schedule[16]; 91 | #else /* KRB4 */ 92 | #ifndef OS2 93 | #ifndef NOBLOCKDEF /* already defined in kerberosiv/des.h */ 94 | typedef struct des_ks_struct { Block _; } Schedule[16]; 95 | #endif /* NOBLOCKDEF */ 96 | #endif /* OS2 */ 97 | #endif /* KRB4 */ 98 | 99 | #define VALIDKEY(key) (key[0]|key[1]|key[2]|key[3]|key[4]|key[5]|key[6]|key[7]) 100 | 101 | #define SAMEKEY(k1, k2) (!memcmp((void *)k1, (void *)k2, sizeof(Block))) 102 | #endif /* CK_DES_C */ 103 | 104 | typedef struct _session_key { 105 | short type; 106 | int length; 107 | unsigned char *data; 108 | } Session_Key; 109 | 110 | #ifdef __STDC__ 111 | typedef struct { 112 | char *name; 113 | int type; 114 | void (*output)(unsigned char *, int); 115 | int (*input)(int); 116 | void (*init)(int); 117 | int (*start)(int, int); 118 | int (*is)(unsigned char *, int); 119 | int (*reply)(unsigned char *, int); 120 | int (*session)(Session_Key *, int); 121 | int (*keyid)(int, unsigned char *, int *); 122 | void (*printsub)(unsigned char *, int, unsigned char *, int); 123 | } Encryptions; 124 | #if !defined(P) 125 | #define P(x) x 126 | #endif 127 | #else 128 | typedef struct { 129 | char *name; 130 | int type; 131 | void (*output)(); 132 | int (*input)(); 133 | void (*init)(); 134 | int (*start)(); 135 | int (*is)(); 136 | int (*reply)(); 137 | int (*session)(); 138 | int (*keyid)(); 139 | void (*printsub)(); 140 | } Encryptions; 141 | #if !defined(P) 142 | #define P(x) () 143 | #endif 144 | #endif 145 | 146 | int encrypt_parse(unsigned char *, int); 147 | 148 | #ifdef DEBUG 149 | int printsub(char, unsigned char *, size_t); 150 | #endif 151 | 152 | #define SK_GENERIC 0 /* Just a string of bits */ 153 | #define SK_DES 1 /* Matched Kerberos v5 ENCTYPE_DES */ 154 | 155 | void encrypt_init P((kstream,int)); 156 | Encryptions *findencryption P((int)); 157 | void encrypt_send_support P((void)); 158 | void encrypt_auto P((int)); 159 | void decrypt_auto P((int)); 160 | int encrypt_is P((unsigned char *, int)); 161 | int encrypt_reply P((unsigned char *, int)); 162 | void encrypt_start_input P((int)); 163 | int encrypt_session_key P((Session_Key *, int)); 164 | int encrypt_dont_support P((int)); 165 | void encrypt_end_input P((void)); 166 | void encrypt_start_output P((int)); 167 | void encrypt_end_output P((void)); 168 | void encrypt_send_request_start P((void)); 169 | void encrypt_send_request_end P((void)); 170 | void encrypt_send_end P((void)); 171 | void encrypt_wait P((void)); 172 | int encrypt_is_encrypting P((void)); 173 | void encrypt_send_support P((void)); 174 | int encrypt_send_keyid P((int, unsigned char *, int, int)); 175 | 176 | int encrypt_cmd P((int, char **)); 177 | void encrypt_display P((void)); 178 | 179 | #ifdef CK_KERBEROS 180 | void krbdes_encrypt P((unsigned char *, int)); 181 | int krbdes_decrypt P((int)); 182 | int krbdes_is P((unsigned char *, int)); 183 | int krbdes_reply P((unsigned char *, int)); 184 | void krbdes_init P((int)); 185 | int krbdes_start P((int, int)); 186 | void krbdes_session P((Session_Key *, int)); 187 | void krbdes_printsub P((unsigned char *, int, unsigned char *, int)); 188 | #endif /* CK_KERBEROS */ 189 | 190 | void cfb64_encrypt P((unsigned char *, int)); 191 | int cfb64_decrypt P((int)); 192 | void cfb64_init P((int)); 193 | int cfb64_start P((int, int)); 194 | int cfb64_is P((unsigned char *, int)); 195 | int cfb64_reply P((unsigned char *, int)); 196 | int cfb64_session P((Session_Key *, int)); 197 | int cfb64_keyid P((int, unsigned char *, int *)); 198 | void cfb64_printsub P((unsigned char *, int, unsigned char *, int)); 199 | 200 | void ofb64_encrypt P((unsigned char *, int)); 201 | int ofb64_decrypt P((int)); 202 | void ofb64_init P((int)); 203 | int ofb64_start P((int, int)); 204 | int ofb64_is P((unsigned char *, int)); 205 | int ofb64_reply P((unsigned char *, int)); 206 | int ofb64_session P((Session_Key *, int)); 207 | int ofb64_keyid P((int, unsigned char *, int *)); 208 | void ofb64_printsub P((unsigned char *, int, unsigned char *, int)); 209 | 210 | void des3_cfb64_encrypt P((unsigned char *, int)); 211 | int des3_cfb64_decrypt P((int)); 212 | void des3_cfb64_init P((int)); 213 | int des3_cfb64_start P((int, int)); 214 | int des3_cfb64_is P((unsigned char *, int)); 215 | int des3_cfb64_reply P((unsigned char *, int)); 216 | int des3_cfb64_session P((Session_Key *, int)); 217 | int des3_cfb64_keyid P((int, unsigned char *, int *)); 218 | void des3_cfb64_printsub P((unsigned char *, int, unsigned char *, int)); 219 | 220 | void des3_ofb64_encrypt P((unsigned char *, int)); 221 | int des3_ofb64_decrypt P((int)); 222 | void des3_ofb64_init P((int)); 223 | int des3_ofb64_start P((int, int)); 224 | int des3_ofb64_is P((unsigned char *, int)); 225 | int des3_ofb64_reply P((unsigned char *, int)); 226 | int des3_ofb64_session P((Session_Key *, int)); 227 | int des3_ofb64_keyid P((int, unsigned char *, int *)); 228 | void des3_ofb64_printsub P((unsigned char *, int, unsigned char *, int)); 229 | 230 | #ifdef CAST_ENCRYPTION 231 | void cast_cfb64_encrypt P((unsigned char *, int)); 232 | int cast_cfb64_decrypt P((int)); 233 | void cast_cfb64_init P((int)); 234 | int cast_cfb64_start P((int, int)); 235 | int cast_cfb64_is P((unsigned char *, int)); 236 | int cast_cfb64_reply P((unsigned char *, int)); 237 | int cast_cfb64_session P((Session_Key *, int)); 238 | int cast_cfb64_keyid P((int, unsigned char *, int *)); 239 | void cast_cfb64_printsub P((unsigned char *, int, unsigned char *, int)); 240 | 241 | void cast_ofb64_encrypt P((unsigned char *, int)); 242 | int cast_ofb64_decrypt P((int)); 243 | void cast_ofb64_init P((int)); 244 | int cast_ofb64_start P((int, int)); 245 | int cast_ofb64_is P((unsigned char *, int)); 246 | int cast_ofb64_reply P((unsigned char *, int)); 247 | int cast_ofb64_session P((Session_Key *, int)); 248 | int cast_ofb64_keyid P((int, unsigned char *, int *)); 249 | void cast_ofb64_printsub P((unsigned char *, int, unsigned char *, int)); 250 | 251 | void castexp_cfb64_encrypt P((unsigned char *, int)); 252 | int castexp_cfb64_decrypt P((int)); 253 | void castexp_cfb64_init P((int)); 254 | int castexp_cfb64_start P((int, int)); 255 | int castexp_cfb64_is P((unsigned char *, int)); 256 | int castexp_cfb64_reply P((unsigned char *, int)); 257 | int castexp_cfb64_session P((Session_Key *, int)); 258 | int castexp_cfb64_keyid P((int, unsigned char *, int *)); 259 | void castexp_cfb64_printsub P((unsigned char *, int, unsigned char *, int)); 260 | 261 | void castexp_ofb64_encrypt P((unsigned char *, int)); 262 | int castexp_ofb64_decrypt P((int)); 263 | void castexp_ofb64_init P((int)); 264 | int castexp_ofb64_start P((int, int)); 265 | int castexp_ofb64_is P((unsigned char *, int)); 266 | int castexp_ofb64_reply P((unsigned char *, int)); 267 | int castexp_ofb64_session P((Session_Key *, int)); 268 | int castexp_ofb64_keyid P((int, unsigned char *, int *)); 269 | void castexp_ofb64_printsub P((unsigned char *, int, unsigned char *, int)); 270 | #endif /* CAST_ENCRYPTION */ 271 | 272 | /* int des_string_to_key P((char *, Block)); */ 273 | 274 | #ifdef DEBUG 275 | extern int encrypt_debug_mode; 276 | #endif 277 | 278 | int decrypt_ks_hack(unsigned char *, int); 279 | 280 | #endif /* __ENCRYPTION__ */ 281 | #endif /* ENCRYPTION */ 282 | 283 | #ifdef CRYPT_DLL 284 | struct _crypt_dll_init { 285 | int version; 286 | 287 | /* Version 1 variables */ 288 | int (*p_ttol)(char *,int); 289 | int (*p_dodebug)(int,char *,char *,CK_OFF_T); 290 | int (*p_dohexdump)(char *,char *,int); 291 | void (*p_tn_debug)(char *); 292 | int (*p_vscrnprintf)(char *, ...); 293 | 294 | /* Version 2 variables */ 295 | void * p_k5_context; 296 | 297 | /* Version 3 variables */ 298 | void (*p_install_funcs)(char *,void *); 299 | 300 | /* Version 5 variables */ 301 | unsigned long (*p_reqtelmutex)(unsigned long); 302 | unsigned long (*p_reltelmutex)(void); 303 | }; 304 | #endif /* CRYPT_DLL */ 305 | 306 | /* per Kerberos v5 protocol spec */ 307 | #ifndef ENCTYPE_NULL 308 | #define ENCTYPE_NULL 0x0000 309 | #endif 310 | #ifndef ENCTYPE_DES_CBC_CRC 311 | #define ENCTYPE_DES_CBC_CRC 0x0001 /* DES cbc mode with CRC-32 */ 312 | #endif 313 | #ifndef ENCTYPE_DES_CBC_MD4 314 | #define ENCTYPE_DES_CBC_MD4 0x0002 /* DES cbc mode with RSA-MD4 */ 315 | #endif 316 | #ifndef ENCTYPE_DES_CBC_MD5 317 | #define ENCTYPE_DES_CBC_MD5 0x0003 /* DES cbc mode with RSA-MD5 */ 318 | #endif 319 | #ifndef ENCTYPE_DES_CBC_RAW 320 | #define ENCTYPE_DES_CBC_RAW 0x0004 /* DES cbc mode raw */ 321 | #endif 322 | /* XXX deprecated? */ 323 | #ifndef ENCTYPE_DES3_CBC_SHA 324 | #define ENCTYPE_DES3_CBC_SHA 0x0005 /* DES-3 cbc mode with NIST-SHA */ 325 | #endif 326 | #ifndef ENCTYPE_DES3_CBC_RAW 327 | #define ENCTYPE_DES3_CBC_RAW 0x0006 /* DES-3 cbc mode raw */ 328 | #endif 329 | #ifndef ENCTYPE_DES_HMAC_SHA1 330 | #define ENCTYPE_DES_HMAC_SHA1 0x0008 331 | #endif 332 | #ifndef ENCTYPE_DES3_CBC_SHA1 333 | #define ENCTYPE_DES3_CBC_SHA1 0x0010 334 | #endif 335 | #ifndef ENCTYPE_AES128_CTS_HMAC_SHA1_96 336 | #define ENCTYPE_AES128_CTS_HMAC_SHA1_96 0x0011 337 | #endif 338 | #ifndef ENCTYPE_AES256_CTS_HMAC_SHA1_96 339 | #define ENCTYPE_AES256_CTS_HMAC_SHA1_96 0x0012 340 | #endif 341 | #ifndef ENCTYPE_ARCFOUR_HMAC 342 | #define ENCTYPE_ARCFOUR_HMAC 0x0017 343 | #endif 344 | #ifndef ENCTYPE_ARCFOUR_HMAC_EXP 345 | #define ENCTYPE_ARCFOUR_HMAC_EXP 0x0018 346 | #endif 347 | #ifndef ENCTYPE_LOCAL_RC4_MD4 348 | #define ENCTYPE_LOCAL_RC4_MD4 0xFFFFFF80 349 | #endif 350 | #ifndef ENCTYPE_UNKNOWN 351 | #define ENCTYPE_UNKNOWN 0x01ff 352 | #endif 353 | /* local crud */ 354 | /* marc's DES-3 with 32-bit length */ 355 | #ifndef ENCTYPE_LOCAL_DES3_HMAC_SHA1 356 | #define ENCTYPE_LOCAL_DES3_HMAC_SHA1 0x7007 357 | #endif 358 | #endif /* KRB5_TELNET_H */ 359 | -------------------------------------------------------------------------------- /ckuath.h: -------------------------------------------------------------------------------- 1 | /* C K U A T H . H -- "C-Kermit to Authentication" interface */ 2 | 3 | /* 4 | Author: Jeffrey E Altman , 5 | Secure Endpoints Inc., New York City. 6 | 7 | Copyright (C) 1999, 2009, 8 | Trustees of Columbia University in the City of New York. 9 | All rights reserved. See the C-Kermit COPYING.TXT file or the 10 | copyright text in the ckcmai.c module for disclaimer and permissions. 11 | */ 12 | 13 | /* 14 | * Based on a concatenation of all necessary include files distributed with 15 | * the Kerberos 5 NT Alpha 2 Telnet package from MIT. 16 | */ 17 | 18 | #ifndef KRB5_KERMIT_H 19 | #define KRB5_KERMIT_H 20 | 21 | #ifndef BOOL 22 | #define BOOL int 23 | #endif 24 | 25 | /* Header file for encrypted-stream library. 26 | * Written by Ken Raeburn (Raeburn@Cygnus.COM). 27 | * Copyright (C) 1991, 1992, 1994 by Cygnus Support. 28 | * 29 | * Permission to use, copy, modify, and 30 | * distribute this software and its documentation for any purpose and 31 | * without fee is hereby granted, provided that the above copyright 32 | * notice appear in all copies and that both that copyright notice and 33 | * this permission notice appear in supporting documentation. 34 | * Cygnus Support makes no representations about the suitability of 35 | * this software for any purpose. It is provided "as is" without express 36 | * or implied warranty. 37 | */ 38 | 39 | #ifndef K5STREAM_H 40 | #define K5STREAM_H 41 | 42 | typedef void *kstream_ptr; /* Data send on the kstream */ 43 | struct kstream_data_block { 44 | kstream_ptr ptr; 45 | size_t length; 46 | }; 47 | 48 | typedef struct kstream_int { /* Object we pass around */ 49 | int fd; /* Open socket descriptor */ 50 | int (*encrypt)(struct kstream_data_block *, /* output */ 51 | struct kstream_data_block *); /* input */ 52 | int encrypt_type; 53 | int (*decrypt)(struct kstream_data_block *, /* output */ 54 | struct kstream_data_block *); /* input */ 55 | int decrypt_type; 56 | } *kstream; 57 | 58 | /* Prototypes */ 59 | 60 | int kstream_destroy(); 61 | void kstream_set_buffer_mode(int); 62 | int kstream_create_from_fd(int fd, kstream_ptr); 63 | int kstream_write(void *, size_t); 64 | int kstream_read(void *, size_t); 65 | 66 | #endif /* K5STREAM_H */ 67 | 68 | /* 69 | * Implements Telnet authentication and encryption 70 | */ 71 | 72 | #ifndef TELNET_AUTH_H 73 | #define TELNET_AUTH_H 74 | 75 | int auth_parse(unsigned char *, int); 76 | 77 | int auth_init(kstream); 78 | 79 | void auth_destroy(void); 80 | 81 | int auth_encrypt(struct kstream_data_block *, struct kstream_data_block *); 82 | 83 | int auth_decrypt(struct kstream_data_block *, struct kstream_data_block *); 84 | 85 | extern BOOL forward_flag; 86 | extern BOOL forwardable_flag; 87 | extern BOOL forwarded_tickets; 88 | #endif /* TEL_AUTH_H */ 89 | 90 | 91 | /* C-Kermit specific functions */ 92 | _PROTOTYP(void auth_finished,(int)); 93 | _PROTOTYP(int ck_auth_init, (char *, char *, char *, int)); 94 | _PROTOTYP(int ck_tn_auth_valid, (VOID)); 95 | _PROTOTYP(int ck_tn_auth_in_progress,(VOID)); 96 | _PROTOTYP(int ck_tn_sb_auth, (char *, int)); 97 | _PROTOTYP(int ck_tn_sb_encrypt, (char *, int)); 98 | _PROTOTYP(int ck_tn_auth_request, (VOID)); 99 | _PROTOTYP(void ck_tn_encrypt, (char *, int)); 100 | _PROTOTYP(void ck_tn_decrypt, (char *, int)); 101 | _PROTOTYP(void ck_tn_enc_start, (VOID)); 102 | _PROTOTYP(void ck_tn_enc_stop, (VOID)); 103 | _PROTOTYP(int ck_tn_authenticated, (VOID)); 104 | #ifdef CK_ENCRYPTION 105 | _PROTOTYP(int ck_tn_encrypting, (VOID)); 106 | _PROTOTYP(int ck_tn_decrypting, (VOID)); 107 | #endif /* CK_ENCRYPTION */ 108 | #ifdef CK_SSL 109 | _PROTOTYP(int ck_tn_tls_negotiate, (VOID)); 110 | _PROTOTYP(int SendSSLAuthSB, (int, void *, int)); 111 | #endif /* CK_SSL */ 112 | 113 | #ifdef CK_KERBEROS 114 | /* Define MIT_CURRENT to compile the code for use with versions of */ 115 | /* Kerberos later than KRB5 1.0.5. Note. This will not compile */ 116 | /* successfully in Kermit 95 due to the segmentation of crypto */ 117 | /* into a separate DLL. */ 118 | 119 | #ifndef KRB5_INIT_ETS 120 | /* krb5_init_ets() is a no-op in Kerberos 1.4.x and later */ 121 | /* and in some installations it can't be found so now by default */ 122 | /* we don't use it. */ 123 | #define NO_KRB5_INIT_ETS 124 | #endif /* KRB5_INIT_ETS */ 125 | 126 | #define KRB_DEFTIM 600 /* Default lifetime (minutes) */ 127 | 128 | /* Kerberos structure definitions */ 129 | 130 | struct krb_op_data { /* Operational data for all actions */ 131 | int version; /* Kerberos version */ 132 | char * cache; /* Kerberos cache file */ 133 | }; 134 | 135 | struct krb4_init_data { /* INITIALIZE data structure */ 136 | int lifetime; 137 | char * principal; /* Principal string */ 138 | char * instance; 139 | char * realm; /* Realm string */ 140 | char * password; /* Kerberos password */ 141 | int preauth; /* Use preauth mode? */ 142 | int verbose; /* Verbose output? */ 143 | }; 144 | 145 | #define KRB5_NUM_OF_ADDRS 16 146 | struct krb5_init_data { /* INITIALIZE data structure */ 147 | int forwardable; /* Switch values */ 148 | int proxiable; /* Correspond to switch names... */ 149 | int lifetime; 150 | int renew; 151 | int renewable; 152 | int validate; 153 | char * postdate; 154 | char * service; 155 | char * principal; /* Principal string */ 156 | char * instance; 157 | char * realm; /* Realm string */ 158 | char * password; /* Kerberos password */ 159 | int preauth; /* Use preauth mode? */ 160 | int verbose; /* Verbose output? */ 161 | int getk4; /* Get K4 TGT? */ 162 | char * addrs[KRB5_NUM_OF_ADDRS+1]; /* List of IP Addresses */ 163 | int no_addresses; /* Do not include IP Addresses */ 164 | }; 165 | 166 | struct krb5_list_cred_data { /* List Credentials data */ 167 | int encryption; 168 | int flags; 169 | int addr; 170 | }; 171 | 172 | _PROTOTYP(int ck_krb5_autoget_TGT, (char *)); 173 | _PROTOTYP(int ck_krb5_initTGT, (struct krb_op_data *,struct krb5_init_data *, 174 | struct krb4_init_data *)); 175 | _PROTOTYP(int ck_krb5_destroy, (struct krb_op_data *)); 176 | _PROTOTYP(int ck_krb5_list_creds, (struct krb_op_data *, 177 | struct krb5_list_cred_data *)); 178 | _PROTOTYP(char * ck_krb5_getrealm, (char *)); 179 | _PROTOTYP(char * ck_krb5_getprincipal, (char *)); 180 | _PROTOTYP(char * ck_krb5_get_cc_name, (VOID)); 181 | 182 | _PROTOTYP(int ck_krb4_autoget_TGT, (char *)); 183 | _PROTOTYP(int ck_krb4_initTGT, (struct krb_op_data *,struct krb4_init_data *)); 184 | _PROTOTYP(int ck_krb4_destroy, (struct krb_op_data *)); 185 | _PROTOTYP(int ck_krb4_list_creds, (struct krb_op_data *)); 186 | _PROTOTYP(char * ck_krb4_getrealm, (VOID)); 187 | _PROTOTYP(char * ck_krb4_getprincipal, (VOID)); 188 | 189 | _PROTOTYP(int ck_krb4_get_tkts, (VOID)); 190 | _PROTOTYP(char * ck_krb4_get_next_tkt, (VOID)); 191 | _PROTOTYP(int ck_krb4_tkt_isvalid,(char *)); 192 | _PROTOTYP(int ck_krb4_is_tgt_valid,(VOID)); 193 | _PROTOTYP(int ck_krb4_tkt_time,(char *)); 194 | 195 | _PROTOTYP(int ck_krb5_get_tkts, (char *)); 196 | _PROTOTYP(char * ck_krb5_get_next_tkt, (VOID)); 197 | _PROTOTYP(int ck_krb5_tkt_isvalid,(char *,char *)); 198 | _PROTOTYP(char * ck_krb5_tkt_flags,(char *,char *)); 199 | _PROTOTYP(int ck_krb5_is_tgt_valid,(VOID)); 200 | _PROTOTYP(int ck_krb5_tkt_time,(char *,char *)); 201 | 202 | _PROTOTYP(int krb4_des_avail,(int)); 203 | _PROTOTYP(int krb4_des_write,(int,char *,int)); 204 | _PROTOTYP(int krb4_des_read, (int,char *,int)); 205 | _PROTOTYP(int krb5_des_avail,(int)); 206 | _PROTOTYP(int krb5_des_write,(int,char *,int,int)); 207 | _PROTOTYP(int krb5_des_read, (int,char *,int,int)); 208 | _PROTOTYP(int krb5_u2u_avail,(int)); 209 | _PROTOTYP(int krb5_u2u_write,(int,char *,int)); 210 | _PROTOTYP(int krb5_u2u_read, (int,char *,int)); 211 | _PROTOTYP(int k5_user_to_user_server_auth,(VOID)); 212 | _PROTOTYP(int k5_user_to_user_client_auth,(VOID)); 213 | #endif /* CK_KERBEROS */ 214 | 215 | _PROTOTYP(int ck_krb5_is_installed,(void)); 216 | _PROTOTYP(int ck_krb4_is_installed,(void)); 217 | _PROTOTYP(int ck_srp_is_installed,(void)); 218 | _PROTOTYP(int ck_ntlm_is_installed,(void)); 219 | _PROTOTYP(int ck_crypt_is_installed,(void)); 220 | _PROTOTYP(int ck_ssleay_is_installed,(void)); 221 | _PROTOTYP(int ck_gssapi_is_installed,(void)); 222 | _PROTOTYP(int ck_krypto_is_installed,(void)); 223 | 224 | _PROTOTYP(VOID ck_encrypt_send_support,(VOID)); 225 | _PROTOTYP(int ck_get_crypt_table,(struct keytab **, int *)); 226 | _PROTOTYP(char * ck_krb4_realmofhost,(char *)); 227 | _PROTOTYP(char * ck_krb5_realmofhost,(char *)); 228 | 229 | #define FORWARD /* allow forwarding of credential */ 230 | #ifdef FORWARD 231 | _PROTOTYP(int kerberos5_forward,(VOID)); 232 | #endif /* FORWARD */ 233 | 234 | #define AUTHTYPLSTSZ 8 235 | #endif /*KRB5_KERMIT_H*/ 236 | -------------------------------------------------------------------------------- /ckubs2.mak: -------------------------------------------------------------------------------- 1 | # CKUBS2.MAK Sun May 23 11:52:55 1999 2 | # 3 | CKVER= "7.0.195 Beta.07" 4 | # 5 | # Abbreviated version for 2.10 / 2.11 BSD, which chokes on full-size makefile 6 | # because "Make: out of memory". 7 | # 8 | # C-Kermit 6.0 was the last version that could be built with an interactive 9 | # command parser under the 2.11 BSD memory model -- it fit into the overlay 10 | # structure with only a few bytes to spare. 11 | # 12 | # C-Kermit 7.0 and later can be built only in command-line form. 13 | # 14 | # Instructions: 15 | # 1. Make sure there are no other files called "makefile" or "Makefile" 16 | # in the same directory. 17 | # 2. Change the name of this file to "makefile". 18 | # 3. Read below about the strings file. 19 | # 4. "make bsd211" (for interactive version) or 20 | # "make bsd211noicp" (for command-line-only version). 21 | # 5. If you are not on a system with /usr/lib/ctimed (2.10BSD for example), 22 | # type "make bsd210" (which will compile cku2tm.c into 'ctimed') 23 | # and then install 'ctimed' in the right place (default is /usr/lib). 24 | # 6. 2.11BSD includes ctimed and the necessary stub routines. The 'ctimed' 25 | # path is in . The "libstubs.a" (obtained via a "-lstubs" at 26 | # link time) contains the stub routines. 27 | # 28 | # Authors: Frank da Cruz, Columbia University, fdc@columbia.edu, 29 | # and Steven M Schultz, sms@wlv.iipo.gtegsc.com. 30 | # 31 | # Modified 4 July 1992 to reshuffle overlays (because the first one got too 32 | # big) and to improve the method of defining the string file. fdc. 33 | # And again 23 Aug 1992. fdc. 34 | # And again 06 Sep 1992 to work around ckudia.c blowing up optimizers. sms. 35 | # And again 09 Sep 1992 to incorporate cku2tm.c and new ckustr.c. sms. 36 | # & again 19 Sep 92 to add -DMINIDIAL to reduce size of DIAL module. fdc. 37 | # & again 7 Nov 92 because two of the segments got too big. fdc. 38 | # & again 15-18 Apr 94, ditto, fdc. 39 | # + again 11-13 Jun 96, for version 6.0.192, fdc. 40 | # 18 Jul 96 to incorporate new 'ctimed' and stubs, sms. 41 | # 22 Aug 96 to reshuffle overlays, fdc. 42 | # 23 May 99 for C-Kermit 7.0: add new modules and command-line-only build, fdc. 43 | ########################################################################### 44 | # 45 | # 2.10BSD and 2.11BSD (the latter to a larger extent) are the same as 4.3BSD 46 | # but without a large address space. 47 | # 48 | # A string extraction method is used to put approx. 16KB of strings into a 49 | # file. The module ckustr.c needs to find this file when C-Kermit runs. 50 | # The pathname where this file will reside is defined below (change it if 51 | # necessary). After make is finished, the file cku195.sr must be moved to 52 | # where ckustr.c has been told to look for it, or you can define an 53 | # environment variable KSTR to override the built-in pathname, for example: 54 | # 55 | # setenv KSTR `pwd`/cku195.sr 56 | # 57 | # If the resulting wermit program sprews garbage all over your screen, it's 58 | # because it is reading the wrong strings file. 59 | # 60 | # If the resulting wermit program doesn't run at all because UNIX says it 61 | # is too big, it's most likely because the data segment, the root segment, 62 | # or one of the overlays is too big. The sum of the data (mostly strings.o) 63 | # and bss (mostly static buffers) sizes must be less than about 52K (56K is 64 | # the maximum, but about 4K is needed for stdio buffers that are added in at 65 | # runtime). If the comibed data+bss size exceeds 52K, start chopping away 66 | # at static buffers. When it is borderline (> 52K but < 56K), performance 67 | # will be terrible -- screen output will be very slow and jerky because 68 | # stdio functions are doing a system call per character because they could 69 | # not allocate any buffers. 70 | # 71 | # The maximum number of overlays is 15, but the fewer overlays, the better 72 | # the peformance. The smaller the root segment, the bigger the overlays can 73 | # be: 74 | # 75 | # Root Overlay 76 | # 56KB 8KB 77 | # 48KB 16KB 78 | # 40KB 24KB <-- This arrangement used in 6.0.192 79 | # 32KB 32KB 80 | # 24KB 40KB 81 | # 16KB 48KB 82 | # 8KB 56KB 83 | # 84 | # The hardest-hit modules should go into the root segment, so top priority 85 | # goes to ckutio and ckufio, the low-level i/o modules. It would also be 86 | # good to put ckcpro and ckucmd in the root segment but they are too big. 87 | # 88 | # Here is the layout for 6.0.192: 89 | # 90 | # % size wermit 91 | # text data bss dec hex 92 | # 34368 25574 26414 86356 15154 total text: 126912 93 | # overlays: 23936,24512,23872,20224 94 | # 95 | # This shows root segment text is less than 40K, 96 | # data+bss is less than 52K, and each overlay is less than 24K. 97 | # 98 | ########################################################################### 99 | # 100 | # Compile and Link variables: 101 | # 102 | # EXT is the extension (file type) for object files, normally o. 103 | # EFLAGS is the CFLAGS _without_ the optimize flag (that is added separately). 104 | # The optimizer can not handle a couple modules (ckcpro.c and ckudia.c). 105 | # Sometimes this happens silently -- it just dies. 106 | # In that case there might be a message like: 107 | # Fatal error in /lib/c2 (which is the optimizer) 108 | # mv: x.o: Cannot access: No such file or directory 109 | # NOTE: You can't add any more -D's to these because there is already 110 | # the maximum number of them. See ckcker.h and ckucmd.h for additional 111 | # PDP-11 feature disabling. 112 | EXT=o 113 | OPT=-O 114 | EFLAGS=-DBSD43 -DLCKDIR -DNODEBUG -DNOTLOG -DNODIAL \ 115 | -DNOCSETS -DNOHELP -DNOSCRIPT -DNOSPL -DNOXMIT -DNOSETBUF \ 116 | -DNOMSEND -DNOFRILLS -DNOPARSEN -DNOAPC $(KFLAGS) \ 117 | -DSTR_FILE=\\\"/usr/local/lib/cku195.sr\\\" 118 | LNKFLAGS= -i 119 | CC=./ckustr.sed 120 | CC2=cc 121 | # 122 | ########################################################################### 123 | # 124 | # Dependencies section and overlay structure for the command-line only version. 125 | 126 | wermit: ckcmai.$(EXT) ckucmd.$(EXT) ckuusr.$(EXT) ckuus2.$(EXT) \ 127 | ckuus3.$(EXT) ckuus4.$(EXT) ckuus5.$(EXT) ckcpro.$(EXT) \ 128 | ckcfns.$(EXT) ckcfn2.$(EXT) ckcfn3.$(EXT) ckuxla.$(EXT) \ 129 | ckucon.$(EXT) ckutio.$(EXT) ckufio.$(EXT) ckudia.$(EXT) \ 130 | ckuscr.$(EXT) ckcnet.$(EXT) ckuus6.$(EXT) ckuus7.$(EXT) \ 131 | ckuusx.$(EXT) ckuusy.$(EXT) ckusig.$(EXT) ckustr.o strings.o \ 132 | ckctel.$(EXT) ckclib.$(EXT) 133 | $(CC2) $(LNKFLAGS) -o wermit \ 134 | ckutio.$(EXT) ckusig.$(EXT) \ 135 | -Z ckcfns.$(EXT) ckuus3.$(EXT) ckuusy.$(EXT) \ 136 | ckclib.$(EXT) ckcmai.$(EXT) \ 137 | -Z ckcpro.$(EXT) ckuus4.$(EXT) ckuus5.$(EXT) \ 138 | ckuus6.$(EXT) ckuus2.$(EXT) ckctel.$(EXT) \ 139 | -Z ckucmd.$(EXT) ckuxla.$(EXT) ckuscr.$(EXT) \ 140 | ckuusr.$(EXT) ckuus7.$(EXT) ckudia.$(EXT) \ 141 | ckcfn2.$(EXT) ckcfn3.$(EXT) \ 142 | -Z ckcnet.$(EXT) ckuusx.$(EXT) ckufio.$(EXT) ckucon.$(EXT) \ 143 | -Y ckustr.o strings.o $(LIBS) 144 | 145 | # This is for the interactive version, which is too big as of C-Kermit 7.0. 146 | 147 | wermiti: ckcmai.$(EXT) ckucmd.$(EXT) ckuusr.$(EXT) ckuus2.$(EXT) \ 148 | ckuus3.$(EXT) ckuus4.$(EXT) ckuus5.$(EXT) ckcpro.$(EXT) \ 149 | ckcfns.$(EXT) ckcfn2.$(EXT) ckcfn3.$(EXT) ckuxla.$(EXT) \ 150 | ckucon.$(EXT) ckutio.$(EXT) ckufio.$(EXT) ckudia.$(EXT) \ 151 | ckuscr.$(EXT) ckcnet.$(EXT) ckuus6.$(EXT) ckuus7.$(EXT) \ 152 | ckuusx.$(EXT) ckuusy.$(EXT) ckusig.$(EXT) ckustr.o strings.o 153 | $(CC2) $(LNKFLAGS) -o wermit \ 154 | ckufio.$(EXT) ckutio.$(EXT) ckcmai.$(EXT) ckusig.$(EXT) \ 155 | -Z ckcfns.$(EXT) ckuus3.$(EXT) ckuusy.$(EXT) \ 156 | -Z ckcpro.$(EXT) ckuus4.$(EXT) ckuus5.$(EXT) \ 157 | ckuus6.$(EXT) ckuus2.$(EXT) \ 158 | -Z ckucmd.$(EXT) ckuxla.$(EXT) ckuscr.$(EXT) \ 159 | ckuusr.$(EXT) ckuus7.$(EXT) ckudia.$(EXT) \ 160 | -Z ckcfn2.$(EXT) ckcfn3.$(EXT) ckucon.$(EXT) \ 161 | ckcnet.$(EXT) ckuusx.$(EXT) \ 162 | -Y ckustr.o strings.o $(LIBS) 163 | 164 | strings.o: strings 165 | xstr 166 | cc -c xs.c 167 | mv -f xs.o strings.o 168 | rm -f xs.c 169 | 170 | ########################################################################### 171 | # Dependencies for each module... 172 | # 173 | ckcmai.$(EXT): ckcmai.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcnet.h ckcsig.h \ 174 | ckctel.h ckclib.h 175 | 176 | ckclib.$(EXT): ckclib.c ckclib.h ckcdeb.h ckcasc.h ckcsym.h 177 | 178 | ckcpro.$(EXT): ckcpro.c ckcker.h ckcdeb.h ckcasc.h ckctel.h ckclib.h 179 | $(CC) CFLAGS=${EFLAGS} -c ckcpro.c 180 | 181 | ckcpro.c: ckcpro.w wart ckcdeb.h ckcasc.h ckcker.h 182 | ./wart ckcpro.w ckcpro.c 183 | 184 | ckcfns.$(EXT): ckcfns.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcxla.h \ 185 | ckuxla.h ckctel.h ckclib.h 186 | 187 | ckcfn2.$(EXT): ckcfn2.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcxla.h ckuxla.h \ 188 | ckctel.h ckclib.h 189 | 190 | ckcfn3.$(EXT): ckcfn3.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcxla.h \ 191 | ckuxla.h ckctel.h ckclib.h 192 | 193 | ckuxla.$(EXT): ckuxla.c ckcker.h ckcdeb.h ckcxla.h ckuxla.h ckctel.h ckclib.h 194 | 195 | ckuusr.$(EXT): ckuusr.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \ 196 | ckcasc.h ckcnet.h ckctel.h ckclib.h 197 | 198 | ckuus2.$(EXT): ckuus2.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \ 199 | ckcasc.h ckctel.h ckclib.h 200 | 201 | ckuus3.$(EXT): ckuus3.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \ 202 | ckcasc.h ckcnet.h ckctel.h ckclib.h 203 | 204 | ckuus4.$(EXT): ckuus4.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \ 205 | ckcasc.h ckcnet.h ckctel.h ckclib.h 206 | 207 | ckuus5.$(EXT): ckuus5.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcasc.h \ 208 | ckctel.h ckclib.h 209 | 210 | ckuus6.$(EXT): ckuus6.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcasc.h \ 211 | ckctel.h ckclib.h 212 | 213 | ckuus7.$(EXT): ckuus7.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \ 214 | ckcasc.h ckcnet.h ckctel.h ckclib.h 215 | 216 | ckuusx.$(EXT): ckuusx.c ckcker.h ckuusr.h ckcdeb.h ckcasc.h ckcsig.h \ 217 | ckctel.h ckclib.h 218 | 219 | ckuusy.$(EXT): ckuusy.c ckcker.h ckcdeb.h ckcasc.h ckctel.h ckclib.h 220 | 221 | ckucmd.$(EXT): ckucmd.c ckcasc.h ckucmd.h ckcdeb.h ckctel.h ckclib.h 222 | 223 | ckufio.$(EXT): ckufio.c ckcdeb.h ckuver.h ckctel.h ckclib.h 224 | 225 | ckutio.$(EXT): ckutio.c ckcdeb.h ckcnet.h ckuver.h ckctel.h ckclib.h 226 | 227 | ckucon.$(EXT): ckucon.c ckcker.h ckcdeb.h ckcasc.h ckcnet.h ckcsig.h \ 228 | ckctel.h ckclib.h 229 | 230 | ckcnet.$(EXT): ckcnet.c ckcdeb.h ckcker.h ckcnet.h ckcsig.h ckctel.h ckclib.h 231 | 232 | ckctel.$(EXT): ckcsym.h ckcdeb.h ckcker.h ckcnet.h ckctel.h ckclib.h 233 | 234 | wart: ckwart.$(EXT) 235 | $(CC) $(LNKFLAGS) -o wart ckwart.$(EXT) 236 | 237 | ckcmdb.$(EXT): ckcmdb.c ckcdeb.h 238 | 239 | ckwart.$(EXT): ckwart.c 240 | 241 | ckudia.$(EXT): ckudia.c ckcker.h ckcdeb.h ckucmd.h ckcasc.h ckcsig.h \ 242 | ckctel.h ckclib.h 243 | $(CC) CFLAGS=${EFLAGS} -c ckudia.c 244 | 245 | ckuscr.$(EXT): ckuscr.c ckcker.h ckcdeb.h ckcasc.h ckcsig.h ckctel.h ckclib.h 246 | 247 | ckusig.$(EXT): ckusig.c ckcsig.h ckcasc.h ckcdeb.h ckcker.h ckcnet.h ckuusr.h \ 248 | ckctel.h ckclib.h 249 | 250 | #2.11BSD 251 | # 252 | bsd211: 253 | @echo "Making C-Kermit $(CKVER) for 2.10/2.11BSD with overlays..." 254 | @echo -n "Be sure to install cku195.sr with the same pathname" 255 | @echo " specified in ckustr.c!" 256 | chmod +x ckustr.sed 257 | make wermiti CFLAGS="${OPT} ${EFLAGS}" LIBS=-lstubs 258 | 259 | bsd211noicp: 260 | @echo "Making C-Kermit $(CKVER) for 2.10/2.11BSD NOICP..." 261 | @echo -n "Be sure to install cku195.sr with the same pathname" 262 | @echo " specified in ckustr.c!" 263 | chmod +x ckustr.sed 264 | make wermit CFLAGS="${OPT} ${EFLAGS} -DNOICP" LIBS=-lstubs 265 | 266 | #2.10BSD 267 | # 268 | bsd210: 269 | @echo -n "Be sure to install ctimed with the same pathname" 270 | @echo " specified in ckustr.c for STR_CTIMED!" 271 | @echo "Making C-Kermit $(CKVER) for 2.10/2.11BSD with overlays..." 272 | @echo -n "Be sure to install cku195.sr with the same pathname" 273 | @echo " specified in ckustr.c!" 274 | chmod +x ckustr.sed 275 | make wermiti CFLAGS="${OPT} ${EFLAGS} \ 276 | -DSTR_CTIMED=\\\"/usr/lib/ctimed\\\"" 277 | 278 | ctimed: 279 | $(CC2) $OPT $(EFLAGS) $(LNKFLAGS) -o ctimed cku2tm.c 280 | 281 | #Clean up intermediate and object files 282 | clean: 283 | @echo 'Removing intermediate files...' 284 | -rm -f *.$(EXT) ckcpro.c wart strings cku195.sr ctimed wermit xs.c 285 | -rm -f xxmk.c mk.c x.c 286 | -------------------------------------------------------------------------------- /ckucmd.h: -------------------------------------------------------------------------------- 1 | /* C K U C M D . H -- Header file for interactive command parser */ 2 | 3 | /* 4 | Author: Frank da Cruz 5 | Columbia University Kermit Project, New York City. 6 | 7 | Copyright (C) 1985, 2022, 8 | Trustees of Columbia University in the City of New York. 9 | All rights reserved. See the C-Kermit COPYING.TXT file or the 10 | copyright text in the ckcmai.c module for disclaimer and permissions. 11 | 12 | Note: the name of these files really should be ckccmd.h and ckccmd.c 13 | because they are for all platforms, not just Unix. But "don't fix 14 | what ain't broke". 15 | 16 | Last update: Sat Sep 24 14:05:17 2022 -fdc 17 | Removed redundant arrow-key #ifdefs (they only need to be in ckcdeb.h) 18 | */ 19 | 20 | #ifndef CKUCMD_H 21 | #define CKUCMD_H 22 | 23 | /* Command recall */ 24 | 25 | #ifdef pdp11 /* Not enough room for this */ 26 | #ifndef NORECALL 27 | #define NORECALL 28 | #endif /* NORECALL */ 29 | #endif /* pdp11 */ 30 | 31 | #ifdef DYNAMIC /* Dynamic command buffers */ 32 | /* 33 | Use malloc() to allocate the many command-related buffers in ckucmd.c. 34 | */ 35 | #ifndef DCMDBUF 36 | #ifndef NORECALL 37 | #define NORECALL 38 | #endif /* NORECALL */ 39 | #endif /* DCMDBUF */ 40 | 41 | #ifndef NORECALL 42 | #define CK_RECALL 43 | #else 44 | #ifdef CK_RECALL 45 | #undef CK_RECALL 46 | #endif /* CK_RECALL */ 47 | #endif /* NORECALL */ 48 | #else 49 | #ifndef NORECALL 50 | #define NORECALL 51 | #endif /* NORECALL */ 52 | #endif /* DYNAMIC */ 53 | 54 | #ifdef NORECALL 55 | #ifdef CK_RECALL 56 | #undef CK_RECALL 57 | #endif /* CK_RECALL */ 58 | #endif /* NORECALL */ 59 | 60 | /* Special getchars */ 61 | 62 | #ifdef VMS 63 | #ifdef getchar /* This is for VMS GCC */ 64 | #undef getchar 65 | #endif /* getchar */ 66 | #define getchar() vms_getchar() 67 | int vms_getchar(void); 68 | #endif /* VMS */ 69 | 70 | #ifdef aegis 71 | #undef getchar 72 | #define getchar() coninc(0) 73 | #endif /* aegis */ 74 | 75 | #ifdef AMIGA 76 | #undef getchar 77 | #define getchar() coninc(0) 78 | #endif /* AMIGA */ 79 | 80 | #ifdef Plan9 81 | #undef getchar 82 | #define getchar() coninc(0) 83 | #undef putchar 84 | #define putchar(c) conoc(c) 85 | #undef printf 86 | #define printf conprint 87 | #endif /* Plan9 */ 88 | 89 | /* Sizes of things */ 90 | 91 | #ifndef CMDDEP 92 | #ifdef BIGBUFOK 93 | #define CMDDEP 64 /* Maximum command recursion depth */ 94 | #else 95 | #define CMDDEP 20 96 | #endif /* BIGBUFOK */ 97 | #endif /* CMDDEP */ 98 | #define HLPLW 78 /* Width of ?-help line */ 99 | #define HLPCW 19 /* Width of ?-help column */ 100 | #define HLPBL 100 /* Help string buffer length */ 101 | #ifdef BIGBUFOK 102 | #define ATMBL 10238 /* Command atom buffer length */ 103 | #else 104 | #ifdef NOSPL 105 | #define ATMBL 256 106 | #else 107 | #define ATMBL 1024 108 | #endif /* NOSPL */ 109 | #endif /* BIGBUFOK */ 110 | 111 | #ifndef CMDBL 112 | #ifdef NOSPL 113 | /* No script programming language, save some space */ 114 | #define CMDBL 608 /* Command buffer length */ 115 | #else 116 | #ifdef BIGBUFOK 117 | #define CMDBL 32763 118 | #else 119 | #define CMDBL 4092 120 | #endif /* OS2 */ 121 | #endif /* NOSPL */ 122 | #endif /* CMDBL */ 123 | 124 | /* Special characters */ 125 | 126 | #define RDIS 0022 /* Redisplay (^R) */ 127 | #define LDEL 0025 /* Delete line (^U) */ 128 | #define WDEL 0027 /* Delete word (^W) */ 129 | #ifdef CK_RECALL 130 | #define C_UP 0020 /* Go Up in recall buffer (^P) */ 131 | #define C_UP2 0002 /* Alternate Go Up (^B) for VMS */ 132 | #define C_DN 0016 /* Go Down in recall buffer (^N) */ 133 | #endif /* CK_RECALL */ 134 | 135 | /* Keyword flags (bits, powers of 2) */ 136 | 137 | #define CM_INV 1 /* Invisible keyword */ 138 | #define CM_ABR 2 /* Abbreviation for another keyword */ 139 | #define CM_HLP 4 /* Help-only keyword */ 140 | #define CM_ARG 8 /* An argument is required */ 141 | #define CM_NOR 16 /* No recall for this command */ 142 | #define CM_PRE 32 /* Long-form cmdline arg for prescan */ 143 | #define CM_PSH 64 /* Command disabled if nopush */ 144 | #define CM_LOC 128 /* Command disabled if nolocal */ 145 | 146 | /* 147 | A long-form command line option is a keyword using the regular struct keytab 148 | and lookup mechanisms. Flags that make sense in this context are CM_ARG, 149 | indicating this option requires an argument (operand), and CM_PRE, which 150 | means this option must be processed before the initialization file. The 151 | absence of CM_PRE means the option is to be processed after the 152 | initialization file in the normal manner. 153 | */ 154 | 155 | /* Token flags (numbers) */ 156 | 157 | #define CMT_COM 0 /* Comment (; or #) */ 158 | #define CMT_SHE 1 /* Shell escape (!) */ 159 | #define CMT_LBL 2 /* Label (:) */ 160 | #define CMT_FIL 3 /* Indirect filespec (@) (not used) */ 161 | 162 | /* Path separator for path searches */ 163 | 164 | #ifdef OS2 165 | #define PATHSEP ';' 166 | #else 167 | #ifdef UNIX 168 | #define PATHSEP ':' 169 | #else 170 | #define PATHSEP ',' 171 | #endif /* UNIX */ 172 | #endif /* OS2 */ 173 | 174 | #ifndef CK_KEYTAB 175 | #define CK_KEYTAB 176 | 177 | /* Keyword Table Template perhaps already defined in ckcdeb.h */ 178 | 179 | struct keytab { /* Keyword table */ 180 | char *kwd; /* Pointer to keyword string */ 181 | int kwval; /* Associated value */ 182 | int flgs; /* Flags (as defined above) */ 183 | }; 184 | #endif /* CK_KEYTAB */ 185 | 186 | /* String preprocessing function */ 187 | 188 | #ifdef CK_ANSIC /* ANSI C */ 189 | #ifdef M_SYSV /* SCO Microsoft C wants no args */ 190 | typedef int (*xx_strp)(); 191 | #else 192 | typedef int (*xx_strp)(char *, char **, int *); 193 | #endif /* M_SYSV */ 194 | #else /* Not ANSI C */ 195 | typedef int (*xx_strp)(); 196 | #endif /* CK_ANSIC */ 197 | 198 | /* FLDDB struct */ 199 | 200 | typedef struct FDB { 201 | int fcode; /* Function code */ 202 | char * hlpmsg; /* Help message */ 203 | char * dflt; /* Default */ 204 | char * sdata; /* Additional string data */ 205 | int ndata1; /* Additional numeric data 1 */ 206 | int ndata2; /* Additional numeric data 2 */ 207 | xx_strp spf; /* String processing function */ 208 | struct keytab * kwdtbl; /* Keyword table */ 209 | struct FDB * nxtfdb; /* Pointer to next alternative */ 210 | } fdb; 211 | 212 | typedef struct OFDB { 213 | struct FDB * fdbaddr; /* Address of succeeding FDB struct */ 214 | int fcode; /* Function code */ 215 | char * sresult; /* String result */ 216 | int nresult; /* Integer result */ 217 | int kflags; /* Keyword flags if any */ 218 | CK_OFF_T wresult; /* Long integer ("wide") result */ 219 | } ofdb; 220 | 221 | #ifndef CKUCMD_C 222 | extern struct OFDB cmresult; 223 | #endif /* CKUCMD_C */ 224 | 225 | /* Codes for primary parsing function */ 226 | 227 | #define _CMNUM 0 /* Number */ 228 | #define _CMOFI 1 /* Output file */ 229 | #define _CMIFI 2 /* Input file */ 230 | #define _CMFLD 3 /* Arbitrary field */ 231 | #define _CMTXT 4 /* Text string */ 232 | #define _CMKEY 5 /* Keyword */ 233 | #define _CMCFM 6 /* Confirmation */ 234 | #define _CMDAT 7 /* Date/time */ 235 | #define _CMNUW 8 /* Wide version of cmnum */ 236 | 237 | /* Function prototypes */ 238 | 239 | _PROTOTYP( int xxesc, (char **) ); 240 | _PROTOTYP( int cmrini, (int) ); 241 | _PROTOTYP( VOID cmsetp, (char *) ); 242 | _PROTOTYP( VOID cmsavp, (char [], int) ); 243 | _PROTOTYP( char * cmgetp, (void) ); 244 | _PROTOTYP( VOID prompt, (xx_strp) ); 245 | _PROTOTYP( VOID pushcmd, (char *) ); 246 | _PROTOTYP( VOID cmres, (void) ); 247 | _PROTOTYP( VOID cmini, (int) ); 248 | _PROTOTYP( int cmgbrk, (void) ); 249 | _PROTOTYP( int cmgkwflgs, (void) ); 250 | _PROTOTYP( int cmpush, (void) ); 251 | _PROTOTYP( int cmpop, (void) ); 252 | _PROTOTYP( VOID untab, (char *) ); 253 | _PROTOTYP( int cmnum, (char *, char *, int, int *, xx_strp ) ); 254 | _PROTOTYP( int cmnumw, (char *, char *, int, CK_OFF_T *, xx_strp ) ); 255 | _PROTOTYP( int cmofi, (char *, char *, char **, xx_strp ) ); 256 | _PROTOTYP( int cmifi, (char *, char *, char **, int *, xx_strp ) ); 257 | _PROTOTYP( int cmiofi, (char *, char *, char **, int *, xx_strp ) ); 258 | _PROTOTYP( int cmifip,(char *, char *, char **, int *, int, char *, xx_strp )); 259 | _PROTOTYP( int cmifi2,(char *,char *,char **,int *,int,char *,xx_strp,int )); 260 | _PROTOTYP( int cmdir, (char *, char *, char **, xx_strp ) ); 261 | _PROTOTYP( int cmdirp, (char *, char *, char **, char *, xx_strp ) ); 262 | _PROTOTYP( int cmfld, (char *, char *, char **, xx_strp ) ); 263 | _PROTOTYP( int cmtxt, (char *, char *, char **, xx_strp ) ); 264 | _PROTOTYP( int cmkey, (struct keytab [], int, char *, char *, xx_strp) ); 265 | _PROTOTYP( int cmkeyx, (struct keytab [], int, char *, char *, xx_strp) ); 266 | _PROTOTYP( int cmkey2,(struct keytab [],int,char *,char *,char *,xx_strp,int)); 267 | _PROTOTYP( int cmswi, (struct keytab [], int, char *, char *, xx_strp) ); 268 | _PROTOTYP( int cmdate,(char *, char *, char **, int, xx_strp) ); 269 | _PROTOTYP( char * cmpeek, (void) ); 270 | _PROTOTYP( int cmfdb, (struct FDB *) ); 271 | _PROTOTYP( VOID cmfdbi, (struct FDB *, 272 | int, char *, char *, char *, int, int, xx_strp, 273 | struct keytab *, struct FDB *) ); 274 | _PROTOTYP( int chktok, (char *) ); 275 | _PROTOTYP( int cmcfm, (void) ); 276 | _PROTOTYP( int lookup, (struct keytab [], char *, int, int *) ); 277 | _PROTOTYP( VOID kwdhelp, (struct keytab[],int,char *,char *,char *,int,int) ); 278 | _PROTOTYP( int ungword, (void) ); 279 | _PROTOTYP( VOID unungw, (void) ); 280 | _PROTOTYP( int cmdsquo, (int) ); 281 | _PROTOTYP( int cmdgquo, (void) ); 282 | _PROTOTYP( char * ckcvtdate, (char *, int) ); 283 | _PROTOTYP( int cmdgetc, (int)); 284 | #ifndef NOARROWKEYS 285 | _PROTOTYP( int cmdconchk, (void) ); 286 | #endif /* NOARROWKEYS */ 287 | 288 | #ifdef CK_RECALL 289 | _PROTOTYP( char * cmgetcmd, (char *) ); 290 | _PROTOTYP( VOID addcmd, (char *) ); 291 | _PROTOTYP( VOID cmaddnext, (void) ); 292 | #endif /* CK_RECALL */ 293 | _PROTOTYP( char * cmcvtdate, (char *, int) ); 294 | _PROTOTYP( char * cmdiffdate, (char *, char *) ); 295 | _PROTOTYP( char * cmdelta, (int, 296 | int,int,int,int,int,int,int,int,int,int,int,int )); 297 | _PROTOTYP( char * shuffledate, (char *, int) ); 298 | _PROTOTYP( int filhelp, (int, char *, char *, int, int) ); 299 | _PROTOTYP( int xfilhelp, (int, char *, char *, int, int, 300 | int, 301 | char *, char *, char *, char *, 302 | CK_OFF_T, CK_OFF_T, 303 | int, int, 304 | char **) ); 305 | _PROTOTYP( int delta2sec, (char *, long *) ); 306 | 307 | #ifdef DCMDBUF 308 | _PROTOTYP( int cmsetup, (void) ); 309 | #endif /* DCMDBUF */ 310 | 311 | #endif /* CKUCMD_H */ 312 | 313 | /* End of ckucmd.h */ 314 | -------------------------------------------------------------------------------- /ckupty.h: -------------------------------------------------------------------------------- 1 | /* C K U P T Y . H -- Includes and definitions for ckupty.c */ 2 | 3 | /* 4 | Copyright 1995 by the Massachusetts Institute of Technology. 5 | 6 | Modified for use in C-Kermit by: 7 | 8 | Jeffrey E Altman 9 | Secure Endpoints Inc., New York City 10 | November 1999 11 | */ 12 | #ifndef __PTY_INT_H__ 13 | #include 14 | 15 | /* #define WANT_UTMP */ 16 | /* We don't want all the utmp/wtmp stuff */ 17 | 18 | #ifdef WANT_UTMP 19 | #ifdef HAVE_UTMP_H 20 | #include 21 | #endif /* HAVE_UTMP_H */ 22 | #ifdef HAVE_UTMPX_H 23 | #include 24 | #endif /* HAVE_UTMPX_H */ 25 | #endif /* WANT_UTMP */ 26 | 27 | #ifdef HAVE_UNISTD_H 28 | #include 29 | #endif /* HAVE_UNISTD_H */ 30 | #ifdef __SCO__ 31 | #include 32 | #endif /* __SCO__ */ 33 | #ifdef HAVE_STDLIB_H 34 | #include 35 | #endif /* HAVE_STDLIB_H */ 36 | 37 | #include 38 | 39 | #include 40 | #ifndef SUNOS41 41 | #include 42 | #endif /* SUNOS41 */ 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #ifdef HAVE_SYS_LABEL_H 52 | /* only SunOS 4? */ 53 | #include 54 | #include 55 | #include 56 | #endif /* HAVE_SYS_LABEL_H */ 57 | 58 | #include 59 | 60 | #ifdef HPUX 61 | #include 62 | #endif /* HPUX */ 63 | #ifdef sysvimp 64 | #include 65 | #endif /* sysvimp */ 66 | 67 | #ifdef COMMENT 68 | /* I don't think we actually use this for anything */ 69 | /* and it kills Slackware builds, where there is no select.h. */ 70 | #ifndef NO_SYS_SELECT_H 71 | #ifdef HAVE_SYS_SELECT_H 72 | #include 73 | #endif /* HAVE_SYS_SELECT_H */ 74 | #endif /* NO_SYS_SELECT_H */ 75 | #endif /* COMMENT */ 76 | 77 | #ifdef HAVE_STREAMS 78 | #include 79 | #include 80 | #endif /* HAVE_STREAMS */ 81 | 82 | #ifdef POSIX_TERMIOS 83 | #ifndef ultrix 84 | #include 85 | #else 86 | #include 87 | #endif /* ultrix */ 88 | #else /* POSIX_TERMIOS */ 89 | #include 90 | #endif /* POSIX_TERMIOS */ 91 | 92 | #include 93 | /* #include */ 94 | #ifndef ultrix 95 | #include 96 | #endif /* ultrix */ 97 | /* #include */ /* (now done in ckcdeb.h) */ 98 | 99 | #ifdef HAVE_STREAMS 100 | /* krlogin doesn't test sys/tty... */ 101 | #ifdef HAVE_SYS_TTY_H 102 | #include 103 | #endif /* HAVE_SYS_TTY_H */ 104 | 105 | #ifdef HAVE_SYS_PTYVAR_H 106 | /* Solaris actually uses packet mode, so the real macros are needed too */ 107 | #include 108 | #endif /* HAVE_SYS_PTYVAR_H */ 109 | #endif /* HAVE_STREAMS */ 110 | 111 | #ifdef COMMENT 112 | /* This block moved to ckcdeb.h */ 113 | #ifndef NO_OPENPTY 114 | /* For NetBSD, see makefile */ 115 | #ifndef HAVE_OPENPTY 116 | #ifdef __FreeBSD__ 117 | #define HAVE_OPENPTY 118 | #else 119 | #ifdef MACOSX10 120 | #define HAVE_OPENPTY 121 | #endif /* MACOSX10 */ 122 | #endif /* __FreeBSD__ */ 123 | #endif /* HAVE_OPENPTY */ 124 | #endif /* NO_OPENPTY */ 125 | #endif /* COMMENT */ 126 | 127 | #ifdef HAVE_VHANGUP 128 | #ifndef OPEN_CTTY_ONLY_ONCE 129 | /* 130 | Breaks under Ultrix and others where you cannot get controlling 131 | terminal twice. 132 | */ 133 | #define VHANG_first 134 | #define VHANG_LAST 135 | #endif /* OPEN_CTTY_ONLY_ONCE */ 136 | #endif /* HAVE_VHANGUP */ 137 | 138 | /* Internal functions */ 139 | _PROTOTYP(long ptyint_void_association,(void)); 140 | _PROTOTYP(long ptyint_open_ctty ,(char *, int *)); 141 | _PROTOTYP(VOID ptyint_vhangup, (void)); 142 | 143 | #ifdef WANT_UTMP 144 | _PROTOTYP(long ptyint_update_wtmp, (struct utmp *, char *, char *)); 145 | #endif /* WANT_UTMP */ 146 | 147 | #define __PTY_INT_H__ 148 | #endif /* __PTY_INT_H__ */ 149 | 150 | #ifndef __LIBPTY_H__ 151 | 152 | #ifdef WANT_UTMP 153 | /* Constants for pty_update_utmp */ 154 | #define PTY_LOGIN_PROCESS 0 155 | #define PTY_USER_PROCESS 1 156 | #define PTY_DEAD_PROCESS 2 157 | #define PTY_TTYSLOT_USABLE (0x1) /* flags to update_utmp*/ 158 | #define PTY_UTMP_USERNAME_VALID (0x2) 159 | #endif /* WANT_UTMP */ 160 | 161 | _PROTOTYP(long pty_init,(void)); 162 | _PROTOTYP(long pty_getpty, ( int *, char *, int)); 163 | _PROTOTYP(long pty_open_slave, (char *, int *, int)); 164 | _PROTOTYP(long pty_open_ctty, (char *, int *, int)); 165 | _PROTOTYP(long pty_initialize_slave, (int)); 166 | #ifdef WANT_UTMP 167 | _PROTOTYP(long pty_update_utmp, (int, int, char *, char *, char *, int)); 168 | _PROTOTYP(long pty_logwtmp, (char *, char *, char *)); 169 | #endif /* WANT_UTMP */ 170 | _PROTOTYP(long pty_cleanup, (char *, int, int)); 171 | 172 | #define PTY_GETPTY_STREAMS (44806912L) 173 | #define PTY_GETPTY_FSTAT (44806913L) 174 | #define PTY_GETPTY_NOPTY (44806914L) 175 | #define PTY_GETPTY_SLAVE_TOOLONG (44806915L) 176 | #define PTY_OPEN_SLAVE_OPENFAIL (44806916L) 177 | #define PTY_OPEN_SLAVE_CHMODFAIL (44806917L) 178 | #define PTY_OPEN_SLAVE_NOCTTY (44806918L) 179 | #define PTY_OPEN_SLAVE_CHOWNFAIL (44806919L) 180 | #define PTY_OPEN_SLAVE_LINE_PUSHFAIL (44806920L) 181 | #define PTY_OPEN_SLAVE_PUSH_FAIL (44806921L) 182 | #define PTY_OPEN_SLAVE_REVOKEFAIL (44806922L) 183 | #ifdef WANT_UTMP 184 | #define PTY_UPDATE_UTMP_PROCTYPE_INVALID (44806923L) 185 | #endif /* WANT_UTMP */ 186 | #define PTY_OPEN_SLAVE_TOOSHORT (44806924L) 187 | #define ERROR_TABLE_BASE_pty (44806912L) 188 | 189 | extern struct error_table et_pty_error_table; 190 | 191 | #define __LIBPTY_H__ 192 | #endif /* __LIBPTY_H__ */ 193 | 194 | -------------------------------------------------------------------------------- /ckuscr.c: -------------------------------------------------------------------------------- 1 | #include "ckcsym.h" 2 | 3 | #ifndef NOICP 4 | #ifndef NOSCRIPT 5 | char *loginv = "Script Command, 10.0.032, 23 Sep 2022"; 6 | 7 | /* C K U S C R -- expect-send script implementation */ 8 | 9 | /* 10 | Copyright (C) 1985, 2022, 11 | Trustees of Columbia University in the City of New York. 12 | All rights reserved. See the C-Kermit COPYING.TXT file or the 13 | copyright text in the ckcmai.c module for disclaimer and permissions. 14 | 15 | Original (version 1, 1985) author: Herm Fischer, Encino, CA. 16 | Contributed to Columbia University in 1985 for inclusion in C-Kermit 4.0. 17 | Maintained since 1985 by Frank da Cruz, fdc@columbia.edu. 18 | 19 | The module takes a UUCP-style script of the "expect send [expect send] ..." 20 | format. It is intended to operate similarly to the way the common 21 | UUCP L.sys login entries work. Conditional responses are supported: 22 | expect[-send-expect[...]], as with UUCP. The send keyword EOT sends a 23 | Control-d, and the keyword BREAK sends a break. Letters prefixed 24 | by '~' are '~b' backspace, '~s' space, '~n' linefeed, '~r' return, '~x' xon, 25 | '~t' tab, '~q' ? (not allowed on kermit command lines), '~' ~, '~'', 26 | '~"', '~c' don't append return, '~o[o[o]]' octal character. As with 27 | some uucp systems, sent strings are followed by ~r (not ~n) unless they 28 | end with ~c. Null expect strings (e.g., ~0 or --) cause a short 29 | delay, and are useful for sending sequences requiring slight pauses. 30 | 31 | This module calls externally defined system-dependent functions for 32 | communications i/o, as defined in ckcplm.txt, the C-Kermit Program Logic 33 | Manual, and thus should be portable to all systems that implement those 34 | functions, and where alarm() and signal() work as they do in UNIX. 35 | */ 36 | #include "ckcdeb.h" 37 | #include 38 | #ifdef NT 39 | #include 40 | #else /* NT */ 41 | #include 42 | #endif /* NT */ 43 | #include "ckcasc.h" 44 | #include "ckcker.h" 45 | #include "ckuusr.h" 46 | #include "ckcnet.h" 47 | #include "ckcsig.h" 48 | 49 | _PROTOTYP( VOID flushi, (void) ); 50 | _PROTOTYP( static VOID myflsh, (void) ); 51 | _PROTOTYP( static int sequenc, (void) ); 52 | _PROTOTYP( static VOID recvseq, (void) ); 53 | _PROTOTYP( static int outseq, (void) ); 54 | 55 | #ifdef MAC 56 | #define signal msignal 57 | #define SIGTYP long 58 | #define alarm malarm 59 | #define SIG_IGN 0 60 | #define SIGALRM 1 61 | #define SIGINT 2 62 | SIGTYP (*msignal(int type, SIGTYP (*func)(int)))(int); 63 | #endif /* MAC */ 64 | 65 | #ifdef AMIGA 66 | #define signal asignal 67 | #define alarm aalarm 68 | #define SIGALRM (_NUMSIG+1) 69 | #define SIGTYP void 70 | SIGTYP (*asignal(int type, SIGTYP (*func)(int)))(int); 71 | unsigned aalarm(unsigned); 72 | #endif /* AMIGA */ 73 | 74 | #ifdef STRATUS 75 | /* VOS doesn't have alarm(), but it does have some things we can work with. */ 76 | /* however, we have to catch all the signals in one place to do this, so */ 77 | /* we intercept the signal() routine and call it from our own replacement. */ 78 | #define signal vsignal 79 | #define alarm valarm 80 | SIGTYP (*vsignal(int type, SIGTYP (*func)(int)))(int); 81 | int valarm(int interval); 82 | #endif /* STRATUS */ 83 | 84 | extern int sessft; 85 | extern int local, flow, seslog, mdmtyp, msgflg, duplex, backgrd, secho, quiet; 86 | extern int network, nettype, ttnproto; 87 | extern long speed; 88 | extern char ttname[]; 89 | 90 | #ifdef NTSIG 91 | extern int TlsIndex; 92 | #endif /* NTSIG */ 93 | #ifdef IKSD 94 | extern int inserver; 95 | #endif /* IKSD */ 96 | 97 | static int is_tn = 0; /* Do Telnet negotiations */ 98 | 99 | #ifndef NOSPL 100 | #ifdef DCMDBUF 101 | extern struct cmdptr *cmdstk; 102 | #else 103 | extern struct cmdptr cmdstk[]; 104 | #endif /* DCMDBUF */ 105 | extern int techo, cmdlvl; 106 | extern int mecho; 107 | #endif /* NOSPL */ 108 | 109 | static int scr_echo; /* Whether to echo script commands */ 110 | 111 | static int exp_alrm = 15; /* Time to wait for expect string */ 112 | #define SND_ALRM 15 /* Time to allow for sending string */ 113 | #define NULL_EXP 2 /* Time to pause on null expect strg*/ 114 | #define DEL_MSEC 300 /* Milliseconds to pause on ~d */ 115 | 116 | #define SBUFL 512 117 | static char seq_buf[SBUFL+2], *s; /* expect-send sequence buffer */ 118 | static int got_it, no_cr; 119 | 120 | /* Connect state parent/child communication signal handlers */ 121 | 122 | #ifdef COMMENT 123 | #ifdef CK_POSIX_SIG 124 | static sigjmp_buf alrmrng; 125 | #else 126 | static jmp_buf alrmrng; 127 | #endif /* CK_POSIX_SIG */ 128 | #else 129 | static ckjmpbuf alrmrng; 130 | #endif /* COMMENT */ 131 | 132 | static SIGTYP 133 | #ifdef CK_ANSIC 134 | scrtime(int foo) /* modem read failure handler, */ 135 | #else 136 | scrtime(foo) int foo; /* Alarm handler */ 137 | #endif /* CK_ANSIC */ 138 | /* scrtime */ { 139 | 140 | #ifdef BEBOX 141 | #ifdef BE_DR_7 142 | alarm_expired(); 143 | #endif /* BE_DR_7 */ 144 | #endif /* BEBOX */ 145 | #ifdef NTSIG 146 | if (foo == SIGALRM) 147 | PostAlarmSigSem(); 148 | else 149 | PostCtrlCSem(); 150 | #else /* NTSIG */ 151 | #ifdef NT 152 | cklongjmp(ckjaddr(alrmrng),1); 153 | #else /* NT */ 154 | cklongjmp(alrmrng,1); 155 | #endif /* NT */ 156 | #endif /* NTSIG */ 157 | SIGRETURN; 158 | } 159 | 160 | /* 161 | Sequence interpreter -- pick up next sequence from command string, 162 | decode escapes and place into seq_buf. 163 | 164 | If string contains a ~d (delay) then sequenc() returns a 1 expecting 165 | to be called again after the ~d executes. 166 | */ 167 | static int 168 | sequenc() { 169 | int i; 170 | char c, oct_char; 171 | 172 | no_cr = 0; /* output needs cr appended */ 173 | for (i = 0; i < SBUFL; ) { 174 | if (*s == '\0' || *s == '-' || isspace(*s) ) { /* done */ 175 | seq_buf[i] = '\0'; 176 | return(0) ; 177 | } 178 | if (*s == '~') { /* escape character */ 179 | s++; 180 | switch (c = *s) { 181 | case 'n': seq_buf[i++] = LF; break; 182 | case 'r': seq_buf[i++] = CK_CR; break; 183 | case 't': seq_buf[i++] = '\t'; break; 184 | case 'b': seq_buf[i++] = '\b'; break; 185 | case 'q': seq_buf[i++] = '?'; break; 186 | #ifdef COMMENT 187 | /* The default case should catch these now... */ 188 | case '~': seq_buf[i++] = '~'; break; 189 | case '-': seq_buf[i++] = '-'; break; 190 | #endif /* COMMENT */ 191 | case '\'': seq_buf[i++] = '\''; break; 192 | case '\"': seq_buf[i++] = '\"'; break; 193 | case 's': seq_buf[i++] = ' '; break; 194 | case 'x': seq_buf[i++] = '\021'; break; 195 | case 'c': no_cr = 1; break; 196 | case 'd': { /* send what we have & then */ 197 | seq_buf[i] = '\0'; /* expect to send rest after */ 198 | no_cr = 1; /* sender delays a little */ 199 | s++; 200 | return(1); 201 | } 202 | case 'w': { /* wait count */ 203 | exp_alrm = 15; /* default to 15 sec */ 204 | if (isdigit(*(s+1))) { 205 | s++; 206 | exp_alrm = *s & 15; 207 | if (isdigit(*(s+1)) ) { 208 | s++; 209 | exp_alrm = exp_alrm * 10 + (*s & 15); 210 | } 211 | } 212 | break; 213 | } 214 | default: 215 | if ( isdigit(c) ) { /* octal character */ 216 | oct_char = (char) (c & 7); /* most significant digit */ 217 | if (isdigit( *(s+1) ) ) { 218 | s++; 219 | oct_char = (char) ((oct_char<<3) | ( *s & 7 )); 220 | if (isdigit( *(s+1) ) ) { 221 | s++; 222 | oct_char = (char) ((oct_char<<3) | ( *s & 7 )); 223 | } 224 | } 225 | seq_buf[i++] = oct_char; 226 | break; 227 | } else seq_buf[i++] = *s; /* Treat ~ as quote */ 228 | } 229 | } else seq_buf[i++] = *s; /* Plain old character */ 230 | s++; 231 | } 232 | seq_buf[i] = '\0'; 233 | return(0); /* end of space, return anyway */ 234 | } 235 | 236 | 237 | /* Output buffering for "recvseq" and "flushi" */ 238 | 239 | #define MAXBURST 256 /* maximum size of input burst */ 240 | static CHAR conbuf[MAXBURST]; /* buffer to hold output for console */ 241 | static int concnt = 0; /* number of characters buffered */ 242 | static CHAR sesbuf[MAXBURST]; /* buffer to hold output for session log */ 243 | static int sescnt = 0; /* number of characters buffered */ 244 | 245 | static VOID 246 | myflsh() { 247 | if (concnt > 0) { 248 | conxo(concnt, (char *) conbuf); 249 | concnt = 0; 250 | } 251 | if (sescnt > 0) { 252 | logstr((char *) sesbuf, sescnt); 253 | sescnt = 0; 254 | } 255 | } 256 | 257 | /* these variables are used to pass data between the recvseq() */ 258 | /* and the dorseq(). They are necessary because in some versions */ 259 | /* dorseq() is executed in a separate thread and data cannot be */ 260 | /* passed by parameter. */ 261 | 262 | static char *rseqe, * rseqgot, * rseqtrace ; 263 | static int rseql; 264 | 265 | static SIGTYP 266 | #ifdef CK_ANSIC 267 | dorseq(void * threadinfo) 268 | #else /* CK_ANSIC */ 269 | dorseq(threadinfo) VOID * threadinfo; 270 | #endif /* CK_ANSIC */ 271 | /* dorseq */ { 272 | int i, x; 273 | int burst = 0; /* chars remaining in input burst */ 274 | 275 | #ifdef NTSIG 276 | setint(); 277 | if (threadinfo) { /* Thread local storage... */ 278 | TlsSetValue(TlsIndex,threadinfo); 279 | } 280 | #endif /* NTSIG */ 281 | #ifdef CK_LOGIN 282 | #ifdef NT 283 | #ifdef IKSD 284 | if (inserver) 285 | setntcreds(); 286 | #endif /* IKSD */ 287 | #endif /* NT */ 288 | #endif /* CK_LOGIN */ 289 | 290 | while (!got_it) { 291 | for (i = 0; i < rseql-1; i++) rseqgot[i] = rseqgot[i+1]; 292 | x = ttinc(0); /* Read a character */ 293 | debug(F101,"recvseq","",x); 294 | if (x < 0) { 295 | #ifdef NTSIG 296 | ckThreadEnd(threadinfo); 297 | #endif /* NTSIG */ 298 | SIGRETURN; /* Check for error */ 299 | } 300 | #ifdef NETCONN 301 | #ifdef TNCODE 302 | /* Check for telnet protocol negotiation */ 303 | if (((x & 0xff) == IAC) && is_tn) { /* Telnet negotiation */ 304 | myflsh(); 305 | burst = 0; 306 | switch (tn_doop((CHAR)(x & 0xff),duplex,ttinc)) { 307 | case 2: duplex = 0; continue; 308 | case 1: duplex = 1; 309 | default: continue; 310 | } 311 | } 312 | #endif /* TNCODE */ 313 | #endif /* NETCONN */ 314 | rseqgot[rseql-1] = (char) (x & 0x7f); /* Got a character */ 315 | burst--; /* One less waiting */ 316 | if (scr_echo) conbuf[concnt++] = rseqgot[rseql-1]; /* Buffer it */ 317 | if (seslog) /* Log it in session log */ 318 | #ifdef UNIX 319 | if (sessft != 0 || rseqgot[rseql-1] != '\r') 320 | #else 321 | #ifdef OSK 322 | if (sessft != 0 || rseqgot[rseql-1] != '\012') 323 | #endif /* OSK */ 324 | #endif /* UNIX */ 325 | if (rseqgot[rseql-1]) /* Filter out NULs */ 326 | sesbuf[sescnt++] = rseqgot[rseql-1]; 327 | if ((int)strlen(rseqtrace) < SBUFL-2 ) 328 | strcat(rseqtrace,dbchr(rseqgot[rseql-1])); 329 | got_it = (!strncmp(rseqe, rseqgot, rseql)); 330 | if (burst <= 0) { /* Flush buffered output */ 331 | myflsh(); 332 | if ((burst = ttchk()) < 0) { /* Get size of next input burst */ 333 | #ifdef NTSIG 334 | ckThreadEnd(threadinfo); 335 | #endif /* NTSIG */ 336 | SIGRETURN; 337 | } 338 | /* prevent overflow of "conbuf" and "sesbuf" */ 339 | if (burst > MAXBURST) 340 | burst = MAXBURST; 341 | } 342 | } 343 | #ifdef NTSIG 344 | ckThreadEnd(threadinfo); 345 | #endif /* NTSIG */ 346 | SIGRETURN; 347 | } 348 | 349 | static SIGTYP 350 | #ifdef CK_ANSIC 351 | failrseq(void * threadinfo) 352 | #else /* CK_ANSIC */ 353 | failrseq(threadinfo) VOID * threadinfo; 354 | #endif /* CK_ANSIC */ 355 | /* failrseq */ { 356 | got_it = 0; /* Timed out here */ 357 | SIGRETURN; 358 | } 359 | 360 | /* 361 | Receive sequence -- see if expected response comes, 362 | return success (or failure) in got_it. 363 | */ 364 | static VOID 365 | recvseq() { 366 | char *e, got[7], trace[SBUFL]; 367 | int i, l; 368 | 369 | sequenc(); 370 | l = (int)strlen(e=seq_buf); /* no more than 7 chars allowed */ 371 | if (l > 7) { 372 | e += l-7; 373 | l = 7; 374 | } 375 | tlog(F111,"expecting sequence",e,(long) l); 376 | if (l == 0) { /* null sequence, delay a little */ 377 | sleep (NULL_EXP); 378 | got_it = 1; 379 | tlog(F100,"got it (null sequence)","",0L); 380 | return; 381 | } 382 | *trace = '\0'; 383 | for (i = 0; i < 7; i++) got[i]='\0'; 384 | 385 | rseqtrace = trace; 386 | rseqe = e; 387 | rseqgot = got; 388 | rseql = l; 389 | 390 | alrm_execute(ckjaddr(alrmrng), exp_alrm, scrtime, dorseq, failrseq); 391 | 392 | tlog(F110,"received sequence: ",trace,0L); 393 | tlog(F101,"returning with got-it code","",(long) got_it); 394 | myflsh(); /* Flush buffered output */ 395 | return; 396 | } 397 | 398 | /* 399 | Output A Sequence starting at pointer s, 400 | return 0 if okay, 401 | 1 if failed to read (modem hangup or whatever) 402 | */ 403 | static int oseqret = 0; /* Return code for outseq */ 404 | /* Out here to prevent clobbering */ 405 | /* by longjmp. */ 406 | 407 | static SIGTYP 408 | #ifdef CK_ANSIC 409 | dooseq(void * threadinfo) 410 | #else /* CK_ANSIC */ 411 | dooseq(threadinfo) VOID * threadinfo; 412 | #endif /* CK_ANSIC */ 413 | { 414 | int l; 415 | char *sb; 416 | #ifdef TCPSOCKET 417 | extern int tn_nlm, tn_b_nlm; 418 | #endif /* TCPSOCKET */ 419 | 420 | #ifdef NTSIG 421 | setint(); 422 | if (threadinfo) { /* Thread local storage... */ 423 | TlsSetValue(TlsIndex,threadinfo); 424 | } 425 | #endif /* NTSIG */ 426 | #ifdef CK_LOGIN 427 | #ifdef NT 428 | #ifdef IKSD 429 | if (inserver) 430 | setntcreds(); 431 | #endif /* IKSD */ 432 | #endif /* NT */ 433 | #endif /* CK_LOGIN */ 434 | 435 | l = (int)strlen(seq_buf); 436 | tlog(F111,"sending sequence ",seq_buf,(long) l); 437 | 438 | if (!strcmp(seq_buf,"EOT")) { 439 | ttoc(dopar('\004')); 440 | if (scr_echo) conol(""); 441 | if (seslog && duplex) 442 | logstr("",5); 443 | } else if (!strcmp(seq_buf,"BREAK") || 444 | !strcmp(seq_buf,"\\b") || 445 | !strcmp(seq_buf,"\\B")) { 446 | ttsndb(); 447 | if (scr_echo) conol(""); 448 | if (seslog) 449 | logstr("{BREAK}",7); 450 | } else { 451 | if (l > 0) { 452 | for ( sb = seq_buf; *sb; sb++) 453 | *sb = dopar(*sb); /* add parity */ 454 | ttol((CHAR *)seq_buf,l); /* send it */ 455 | if (scr_echo && duplex) { 456 | #ifndef NOLOCAL 457 | #ifdef OS2 458 | { /* Echo to emulator */ 459 | char *s = seq_buf; 460 | while (*s) { 461 | scriptwrtbuf((USHORT)*s); 462 | } 463 | } 464 | #endif /* OS2 */ 465 | #endif /* NOLOCAL */ 466 | conxo(l,seq_buf); 467 | } 468 | if (seslog && duplex) /* log it */ 469 | logstr(seq_buf,strlen(seq_buf)); 470 | } 471 | if (!no_cr) { 472 | ttoc( dopar(CK_CR) ); 473 | #ifdef TCPSOCKET 474 | if (is_tn) { 475 | if (!TELOPT_ME(TELOPT_BINARY) && tn_nlm != TNL_CR) 476 | ttoc((char)((tn_nlm == TNL_CRLF) ? 477 | dopar(LF) : dopar(NUL))); 478 | else if (TELOPT_ME(TELOPT_BINARY) && 479 | (tn_b_nlm == TNL_CRLF || tn_b_nlm == TNL_CRNUL)) 480 | ttoc((char)((tn_b_nlm == TNL_CRLF) ? 481 | dopar(LF) : dopar(NUL))); 482 | } 483 | #endif /* TCPSOCKET */ 484 | if (seslog && duplex) 485 | logchar(dopar(CK_CR)); 486 | } 487 | } 488 | #ifdef NTSIG 489 | ckThreadEnd(threadinfo); 490 | #endif /* NTSIG */ 491 | SIGRETURN; 492 | } 493 | 494 | SIGTYP 495 | #ifdef CK_ANSIC 496 | failoseq(void * threadinfo) 497 | #else /* CK_ANSIC */ 498 | failoseq(threadinfo) VOID * threadinfo; 499 | #endif /* CK_ANSIC */ 500 | /* failoseq */ { 501 | oseqret = -1; /* else -- alarm rang */ 502 | SIGRETURN; 503 | } 504 | 505 | static int 506 | outseq() { 507 | int delay; 508 | 509 | oseqret = 0; /* Initialize return code */ 510 | while(1) { 511 | delay = sequenc(); 512 | alrm_execute( ckjaddr(alrmrng), SND_ALRM, scrtime, dooseq, failoseq ) ; 513 | 514 | if (!delay) 515 | return(oseqret); 516 | #ifndef MAC 517 | msleep(DEL_MSEC); /* delay, loop to next send */ 518 | #endif /* MAC */ 519 | } 520 | } 521 | 522 | 523 | /* L O G I N -- (historical misnomer) Execute the SCRIPT command */ 524 | 525 | int 526 | dologin(cmdstr) char *cmdstr; { 527 | 528 | #ifdef OS2 529 | #ifdef NT 530 | SIGTYP (* savealm)(int); /* Save incoming alarm function */ 531 | #else /* NT */ 532 | SIGTYP (* volatile savealm)(int); /* Save incoming alarm function */ 533 | #endif /* NT */ 534 | #else /* OS2 */ 535 | SIGTYP (*savealm)(); /* Save incoming alarm function */ 536 | #endif /* OS2 */ 537 | char *e; 538 | 539 | s = cmdstr; /* Make global to this module */ 540 | 541 | tlog(F100,loginv,"",0L); 542 | 543 | if (speed < 0L) speed = ttgspd(); 544 | if (ttopen(ttname,&local,mdmtyp,0) < 0) { 545 | ckmakmsg(seq_buf,SBUFL,"Sorry, can't open ",ttname,NULL,NULL); 546 | perror(seq_buf); 547 | return(0); 548 | } 549 | /* Whether to echo script commands ... */ 550 | scr_echo = (!quiet && !backgrd && secho); 551 | #ifndef NOSPL 552 | if (scr_echo && cmdlvl > 1) { 553 | if (cmdstk[cmdlvl].src == CMD_TF) 554 | scr_echo = techo; 555 | if (cmdstk[cmdlvl].src == CMD_MD) 556 | scr_echo = mecho; 557 | } 558 | #endif /* NOSPL */ 559 | if (scr_echo) { 560 | #ifdef NETCONN 561 | if (network) 562 | printf("Executing SCRIPT to host %s.\n",ttname); 563 | else 564 | #endif /* NETCONN */ 565 | printf("Executing SCRIPT through %s, speed %ld.\n",ttname,speed); 566 | } 567 | #ifdef TNCODE 568 | /* TELNET input must be scanned for IAC */ 569 | is_tn = (local && network && IS_TELNET()) || 570 | (!local && sstelnet); 571 | #endif /* TNCODE */ 572 | 573 | *seq_buf = 0; 574 | for (e = s; *e; e++) ckstrncat(seq_buf,dbchr(*e),SBUFL); 575 | #ifdef COMMENT 576 | /* Skip this because it tends to contain a password... */ 577 | if (scr_echo) printf("SCRIPT string: %s\n",seq_buf); 578 | #endif /* COMMENT */ 579 | tlog(F110,"SCRIPT string: ",seq_buf, 0L); 580 | 581 | /* Condition console terminal and communication line... */ 582 | 583 | if (ttvt(speed,flow) < 0) { 584 | printf("Sorry, Can't condition communication line\n"); 585 | return(0); 586 | } 587 | /* Save initial timer interrupt value */ 588 | savealm = signal(SIGALRM,SIG_IGN); 589 | 590 | flushi(); /* Flush stale input */ 591 | 592 | /* start expect - send sequence */ 593 | 594 | while (*s) { /* While not done with buffer */ 595 | 596 | while (*s && isspace(*s)) s++; /* Skip over separating whitespaces */ 597 | /* Gather up expect sequence */ 598 | got_it = 0; 599 | recvseq(); 600 | 601 | while (!got_it) { /* Have it yet? */ 602 | if (*s++ != '-') /* No, is there a conditional send? */ 603 | goto failret; /* No, return failure */ 604 | flushi(); /* Yes, flush out input buffer */ 605 | if (outseq()) /* If unable to send, */ 606 | goto failret; /* return failure. */ 607 | if (*s++ != '-') /* If no conditional response here, */ 608 | goto failret; /* return failure. */ 609 | recvseq(); /* All OK, read response from host. */ 610 | } /* Loop back and check got_it */ 611 | 612 | while (*s && !isspace(*s++) ) ; /* Skip over conditionals */ 613 | while (*s && isspace(*s)) s++; /* Skip over separating whitespaces */ 614 | flushi(); /* Flush */ 615 | if (*s) if (outseq()) goto failret; /* If any */ 616 | } 617 | signal(SIGALRM,savealm); 618 | if (scr_echo) printf("Script successful.\n"); 619 | tlog(F100,"Script successful.","",0L); 620 | return(1); 621 | 622 | failret: 623 | signal(SIGALRM,savealm); 624 | if (scr_echo) printf("Sorry, script failed\n"); 625 | tlog(F100,"Script failed","",0L); 626 | return(0); 627 | } 628 | 629 | /* F L U S H I -- Flush, but log, SCRIPT input buffer */ 630 | 631 | VOID 632 | flushi() { 633 | int n, x; 634 | if ( 635 | seslog /* Logging session? */ 636 | || scr_echo /* Or console echoing? */ 637 | #ifdef NETCONN 638 | #ifdef TNCODE 639 | /* TELNET input must be scanned for IAC */ 640 | || is_tn 641 | #endif /* TNCODE */ 642 | #endif /* NETCONN */ 643 | ) { 644 | if ((n = ttchk()) < 0) /* Yes, anything in buffer? */ 645 | return; 646 | if (n > MAXBURST) n = MAXBURST; /* Make sure not too much, */ 647 | myflsh(); /* and that buffers are empty. */ 648 | while (n-- > 0) { 649 | x = ttinc(0); /* Collect a character */ 650 | #ifdef NETCONN 651 | #ifdef TNCODE 652 | /* Check for telnet protocol negotiation */ 653 | if (is_tn && ((x & 0xff) == IAC) ) { 654 | myflsh(); /* Sync output */ 655 | switch (tn_doop((CHAR)(x & 0xff),duplex,ttinc)) { 656 | case 2: duplex = 0; break; 657 | case 1: duplex = 1; 658 | default: break; 659 | } 660 | 661 | /* Recalculate flush count */ 662 | if ((n = ttchk()) < 0) 663 | return; 664 | if (n > MAXBURST) n = MAXBURST; 665 | continue; 666 | } 667 | #endif /* TNCODE */ 668 | #endif /* NETCONN */ 669 | if (scr_echo) conbuf[concnt++] = (CHAR) x; /* buffer for console */ 670 | if (seslog) 671 | #ifdef UNIX 672 | if (sessft != 0 || x != '\r') 673 | #else 674 | #ifdef OSK 675 | if (sessft != 0 || x != '\012') 676 | #endif /* OSK */ 677 | #endif /* UNIX */ 678 | sesbuf[sescnt++] = (CHAR) x; /* buffer for session log */ 679 | } 680 | myflsh(); 681 | } else ttflui(); /* Otherwise just flush. */ 682 | } 683 | 684 | #else /* NOSCRIPT */ 685 | char *loginv = "Script Command Disabled"; 686 | #endif /* NOSCRIPT */ 687 | #endif /* NOICP */ 688 | -------------------------------------------------------------------------------- /ckusig.c: -------------------------------------------------------------------------------- 1 | char *ckusigv = "Signal support, 10.0.100, 23 Sep 2022"; 2 | 3 | /* C K U S I G -- Kermit signal handling for Unix and OS/2 systems */ 4 | 5 | /* 6 | Author: Jeffrey Altman (jaltman@secure-endpoints.com), 7 | Secure Endpoints Inc., New York City. 8 | 9 | Copyright (C) 1985, 2022, 10 | Trustees of Columbia University in the City of New York. 11 | All rights reserved. See the C-Kermit COPYING.TXT file or the 12 | copyright text in the ckcmai.c module for disclaimer and permissions. 13 | */ 14 | #include "ckcsym.h" 15 | #include "ckcasc.h" /* ASCII character symbols */ 16 | #include "ckcdeb.h" /* Debug & other symbols */ 17 | #include "ckcker.h" /* Kermit symbols */ 18 | #include "ckcnet.h" /* Network symbols */ 19 | #ifndef NOSPL 20 | #include "ckuusr.h" 21 | #endif /* NOSPL */ 22 | 23 | #include 24 | #ifdef NT 25 | #include 26 | #include 27 | #else /* NT */ 28 | #include 29 | #endif /* NT */ 30 | #include "ckcsig.h" 31 | 32 | #ifdef NOCCTRAP 33 | extern ckjmpbuf cmjbuf; 34 | #endif /* NOCCTRAP */ 35 | 36 | #ifdef MAC 37 | #define signal msignal 38 | #define SIGTYP long 39 | #define alarm malarm 40 | #define SIG_IGN 0 41 | #define SIGALRM 1 42 | #define SIGINT 2 43 | SIGTYP (*msignal(int type, SIGTYP (*func)(int)))(int); 44 | #endif /* MAC */ 45 | 46 | #ifdef STRATUS 47 | /* We know these are set here. MUST unset them before the definitions. */ 48 | #define signal vsignal 49 | #define alarm valarm 50 | SIGTYP (*vsignal(int type, SIGTYP (*func)(int)))(int); 51 | int valarm(int interval); 52 | #endif /* STRATUS */ 53 | 54 | #ifdef AMIGA 55 | #define signal asignal 56 | #define alarm aalarm 57 | #define SIGALRM (_NUMSIG+1) 58 | #define SIGTYP void 59 | SIGTYP (*asignal(int type, SIGTYP (*func)(int)))(int); 60 | unsigned aalarm(unsigned); 61 | #endif /* AMIGA */ 62 | 63 | #ifdef NTASM 64 | DWORD 65 | ckgetIP(void) 66 | { 67 | __asm 68 | { 69 | mov eax, dword ptr [esp+0x10] 70 | jmp ckgetIP + 0x18 71 | } 72 | return 1; 73 | 74 | } 75 | #endif /* NTASM */ 76 | 77 | #ifdef NT 78 | DWORD 79 | exception_filter( void ) 80 | { 81 | GetExceptionInformation ; 82 | return( EXCEPTION_EXECUTE_HANDLER ) ; 83 | } 84 | void 85 | crash( void ) 86 | { 87 | int x = 0, y = 0 ; 88 | x / y ; 89 | } 90 | #endif /* NT */ 91 | 92 | #ifndef NOCCTRAP 93 | int 94 | #ifdef CK_ANSIC 95 | cc_execute( ckjptr(sj_buf), ck_sigfunc dofunc, ck_sigfunc failfunc ) 96 | #else 97 | cc_execute( sj_buf, dofunc, failfunc) 98 | ckjptr(sj_buf); 99 | ck_sigfunc dofunc; 100 | ck_sigfunc failfunc; 101 | #endif /* CK_ANSIC */ 102 | /* cc_execute */ { 103 | int rc = 0 ; 104 | #ifdef NTASM 105 | DWORD Eip, Esp ; 106 | isinterrupted = 0; 107 | sj_buf->retcode = 0 ; 108 | sj_buf->Id = GetCurrentThreadId() ; 109 | memset( &sj_buf->context, 0, sizeof(CONTEXT) ); 110 | sj_buf->context.ContextFlags = CONTEXT_FULL ; 111 | #ifndef COMMENT 112 | GetThreadContext(GetCurrentThread(), &(sj_buf->context) ) ; 113 | __asm 114 | { 115 | mov ecx,dword ptr [sj_buf] 116 | mov dword ptr [ecx+0xc4],esp 117 | } 118 | sj_buf->context.EFlags = 530 ; 119 | sj_buf->context.Eip = ckgetIP()+0x0C ; 120 | #else /* COMMENT */ 121 | __asm 122 | { 123 | mov eax, dword ptr [sj_buf] 124 | push eax 125 | mov eax, 0xfffffffe 126 | push eax 127 | mov eax, 0x00000039 128 | mov edx,esp 129 | int 0x2e 130 | pop eax 131 | pop eax 132 | } 133 | #endif /* COMMENT */ 134 | #endif /* NTASM */ 135 | if ( 136 | #ifdef NTASM 137 | isinterrupted 138 | #else 139 | cksetjmp(ckjdref(sj_buf)) 140 | #endif /* NTASM */ 141 | ) { 142 | #ifdef NTASM 143 | __asm 144 | { 145 | mov esp, ESPToRestore 146 | } 147 | isinterrupted = 0 ; 148 | #endif /* NTASM */ 149 | (*failfunc)(NULL) ; 150 | #ifdef NTASM 151 | rc = sj_buf->retcode ; 152 | #else /* NTASM */ 153 | rc = -1 ; 154 | #endif /* NTASM */ 155 | } else { 156 | #ifdef NT 157 | __try { 158 | (*dofunc)(NULL); 159 | } 160 | __except(exception_filter()) 161 | { 162 | debug(F100,"cc_execute __except","",0); 163 | debug(F111, 164 | "exception_filter", 165 | "_exception_code", 166 | etExceptionCode() 167 | ); 168 | longjmp(ckjdref(sj_buf),SIGINT); 169 | } 170 | #else /* NT */ 171 | (*dofunc)(NULL); 172 | #endif /* NT */ 173 | } 174 | return rc ; 175 | } 176 | #endif /* NOCCTRAP */ 177 | 178 | int 179 | #ifdef CK_ANSIC /* ANSIC C declaration... */ 180 | alrm_execute(ckjptr(sj_buf), 181 | int timo, 182 | ck_sighand handler, 183 | ck_sigfunc dofunc, 184 | ck_sigfunc failfunc 185 | ) 186 | 187 | #else /* Not ANSIC C ... */ 188 | 189 | alrm_execute(sj_buf, 190 | timo, 191 | handler, 192 | dofunc, 193 | failfunc 194 | ) 195 | ckjptr(sj_buf); 196 | int timo; 197 | ck_sighand handler; 198 | ck_sigfunc dofunc; 199 | ck_sigfunc failfunc; 200 | #endif /* CK_ANSIC */ 201 | 202 | /* alrm_execute */ { 203 | 204 | int rc = 0; 205 | int savalrm = 0; 206 | _PROTOTYP(SIGTYP (*savhandler), (int)); 207 | 208 | savalrm = alarm(timo); 209 | savhandler = signal(SIGALRM, handler); 210 | 211 | #ifdef NTASM 212 | sj_buf->retcode = 0 ; 213 | sj_buf->Id = GetCurrentThreadId(); 214 | memset(&sj_buf->context, 0, sizeof(CONTEXT)); 215 | sj_buf->context.ContextFlags = CONTEXT_FULL; 216 | #ifndef COMMENT 217 | GetThreadContext(GetCurrentThread(), &(sj_buf->context)); 218 | #else 219 | __asm 220 | { 221 | mov eax, dword ptr [sj_buf] 222 | push eax 223 | mov eax, 0xfffffffe 224 | push eax 225 | mov eax, 0x00000039 226 | mov edx,esp 227 | int 0x2e 228 | pop eax 229 | pop eax 230 | } 231 | #endif 232 | isinterrupted = 0; 233 | #endif /* NTASM */ 234 | if ( 235 | #ifdef NTASM 236 | sj_buf->retcode 237 | #else 238 | cksetjmp(ckjdref(sj_buf)) 239 | #endif /* NTASM */ 240 | ) { 241 | (*failfunc)(NULL) ; 242 | rc = -1 ; 243 | } else { 244 | #ifdef NT 245 | __try { 246 | (*dofunc)(NULL) ; 247 | } 248 | __except( exception_filter() ) 249 | { 250 | debug(F100,"alrm_execute __except","",0); 251 | debug(F111,"exception_filter", 252 | "_exception_code", 253 | GetExceptionCode() 254 | ); 255 | longjmp(ckjdref(sj_buf),SIGINT); 256 | } 257 | #else /* NT */ 258 | (*dofunc)(NULL) ; 259 | #endif /* NT */ 260 | } 261 | alarm(savalrm) ; 262 | if ( savhandler ) 263 | signal( SIGALRM, savhandler ) ; 264 | return rc ; 265 | } 266 | 267 | int 268 | #ifdef CK_ANSIC /* ANSIC C declaration... */ 269 | cc_alrm_execute(ckjptr(sj_buf), 270 | int timo, 271 | ck_sighand handler, 272 | ck_sigfunc dofunc, 273 | ck_sigfunc failfunc 274 | ) 275 | 276 | #else /* Not ANSIC C ... */ 277 | 278 | cc_alrm_execute(sj_buf, 279 | timo, 280 | handler, 281 | dofunc, 282 | failfunc 283 | ) 284 | ckjptr(sj_buf); 285 | int timo; 286 | ck_sighand handler; 287 | ck_sigfunc dofunc; 288 | ck_sigfunc failfunc; 289 | #endif /* CK_ANSIC */ 290 | 291 | /* cc_alrm_execute */ { 292 | 293 | int rc = 0; 294 | int savalrm = 0; 295 | _PROTOTYP(SIGTYP (*savhandler), (int)); 296 | savalrm = alarm(timo); 297 | savhandler = signal( SIGALRM, handler ); 298 | 299 | #ifdef NTASM 300 | sj_buf->retcode = 0 ; 301 | sj_buf->Id = GetCurrentThreadId() ; 302 | memset( &sj_buf->context, 0, sizeof(CONTEXT) ); 303 | sj_buf->context.ContextFlags = CONTEXT_FULL ; 304 | #ifndef COMMENT 305 | GetThreadContext( GetCurrentThread(), &(sj_buf->context) ) ; 306 | #else 307 | __asm 308 | { 309 | mov eax, dword ptr [sj_buf] 310 | push eax 311 | mov eax, 0xfffffffe 312 | push eax 313 | mov eax, 0x00000039 314 | mov edx,esp 315 | int 0x2e 316 | pop eax 317 | pop eax 318 | } 319 | #endif 320 | isinterrupted = 0; 321 | #endif /* NTASM */ 322 | if ( 323 | #ifdef NTASM 324 | sj_buf->retcode 325 | #else 326 | cksetjmp(ckjdref(sj_buf)) 327 | #endif /* NTASM */ 328 | ) { 329 | (*failfunc)(NULL) ; 330 | rc = -1 ; 331 | } else { 332 | #ifdef NT 333 | __try { 334 | (*dofunc)(NULL) ; 335 | } 336 | __except( exception_filter() ) 337 | { 338 | debug(F100,"cc_alrm_execute __except","",0); 339 | debug(F111, 340 | "exception_filter", 341 | "_exception_code", 342 | GetExceptionCode() 343 | ); 344 | longjmp(ckjdref(sj_buf),SIGINT) ; 345 | } 346 | #else /* NT */ 347 | (*dofunc)(NULL) ; 348 | #endif /* NT */ 349 | } 350 | alarm(savalrm); 351 | if (savhandler) 352 | signal(SIGALRM,savhandler); 353 | return(rc); 354 | } 355 | -------------------------------------------------------------------------------- /ckusig.h: -------------------------------------------------------------------------------- 1 | /* C K U S I G . H */ 2 | 3 | /* Definitions and prototypes for signal handling */ 4 | 5 | /* 6 | Author: Jeffrey E Altman (jaltman@secure-endpoints.com), 7 | Secure Endpoints Inc., New York City. 8 | 9 | Copyright (C) 1985, 2009, 10 | Trustees of Columbia University in the City of New York. 11 | All rights reserved. See the C-Kermit COPYING.TXT file or the 12 | copyright text in the ckcmai.c module for disclaimer and permissions. 13 | */ 14 | 15 | #ifdef CK_ANSIC 16 | typedef void (*ck_sigfunc)(void *); 17 | typedef void (*ck_sighand)(int); 18 | #else 19 | typedef VOID (*ck_sigfunc)(); 20 | typedef VOID (*ck_sighand)(); 21 | #endif /* CK_ANSIC */ 22 | 23 | /* Macros for POSIX vs old-style signal handling. */ 24 | 25 | #ifdef CK_POSIX_SIG 26 | typedef sigjmp_buf ckjmpbuf; 27 | #else 28 | typedef jmp_buf ckjmpbuf; 29 | #endif /* CK_POSIX_SIG */ 30 | /* 31 | Suppose you want to pass the address of a jmp_buf bar to a function foo. 32 | Since jmp_buf is normally defined (typedef'd) as an array, you would do 33 | it like this: foo(bar), where foo = foo(jmp_buf bar). But suppose a 34 | jmp_buf is (say) a struct rather than an array. Then you must do 35 | foo(&bar) where foo is foo(jmp_buf * bar). This is controlled here in 36 | the traditional fashion, by ifdefs. By default, we assume that jmp_buf 37 | is an array. Define the symbol JBNOTARRAY if jmp_buf is not an array. 38 | */ 39 | #ifndef JBNOTARRAY 40 | #ifdef NT 41 | #define JBNOTARRAY 42 | #endif /* NT */ 43 | #endif /* JBNOTARRAY */ 44 | 45 | #ifdef JBNOTARRAY 46 | typedef ckjmpbuf * ckjptr; 47 | #define ckjaddr(x) & x 48 | #define ckjdref(x) * x 49 | #ifdef CK_POSIX_SIG 50 | #define cksetjmp(x) sigsetjmp(x,1) 51 | #else 52 | #define cksetjmp(x) setjmp(x,1) 53 | #endif /* CK_POSIX_SIG */ 54 | #else /* jmp_buf is an array */ 55 | typedef ckjmpbuf ckjptr; 56 | #define ckjaddr(x) x 57 | #define ckjdref(x) x 58 | #ifdef CK_POSIX_SIG 59 | #define cksetjmp sigsetjmp 60 | #else 61 | #define cksetjmp setjmp 62 | #endif /* CK_POSIX_SIG */ 63 | #endif /* JBNOTARRAY */ 64 | 65 | _PROTOTYP( int cc_execute, (ckjptr, ck_sigfunc, ck_sigfunc) ); 66 | _PROTOTYP( int alrm_execute, 67 | (ckjptr, 68 | int timo, 69 | ck_sighand handler, 70 | ck_sigfunc, ck_sigfunc) ); 71 | _PROTOTYP( int cc_alrm_execute, 72 | (ckjptr, 73 | int timo, 74 | ck_sighand handler, 75 | ck_sigfunc, 76 | ck_sigfunc) ); 77 | 78 | /* End of ckusig.h */ 79 | 80 | -------------------------------------------------------------------------------- /ckustr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ckustr.c - string extraction/restoration routines 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | STR_FILE must be defined as a quoted string on the cc command line, 12 | for example: 13 | 14 | -DSTR_FILE=\\\"/usr/local/lib/cku196.sr\\\" 15 | 16 | This is the file where the strings go, and where C-Kermit looks for them 17 | at runtime. 18 | */ 19 | 20 | #ifdef STR_FILE 21 | char *StringFile = STR_FILE; 22 | #else 23 | char *StringFile = "/usr/local/lib/cku196.sr"; 24 | #endif /* STR_FILE */ 25 | 26 | /* 27 | * If _PATH_CTIMED is defined (in ) then use that definition. 2.11BSD 28 | * has this defined but 2.10BSD and other systems do not. 29 | */ 30 | 31 | #ifndef _PATH_CTIMED 32 | #define _PATH_CTIMED STR_CTIMED 33 | #endif 34 | 35 | extern int errno; 36 | static int strfile = -1, ourpid = 0; 37 | 38 | #define BUFLEN 256 39 | 40 | errprep(offset, buf) 41 | unsigned short offset; 42 | char *buf; 43 | { 44 | register int pid = getpid(); 45 | 46 | if (pid != ourpid) { 47 | ourpid = pid; 48 | if (strfile >= 0) { 49 | close(strfile); 50 | strfile = -1; 51 | } 52 | } 53 | if (strfile < 0) { 54 | char *p, *getenv(); 55 | if (p = getenv("KSTR")) 56 | if (strlen(p)) 57 | StringFile = p; 58 | strfile = open(StringFile, 0); 59 | if (strfile < 0) { 60 | oops: 61 | fprintf(stderr, "Cannot find %s\r\n", StringFile); 62 | exit(EX_OSFILE); 63 | } 64 | } 65 | if (lseek(strfile, (long) offset, 0) < 0 66 | || read(strfile, buf, BUFLEN) <= 0) 67 | goto oops; 68 | } 69 | 70 | /* extracted string front end for printf() */ 71 | /*VARARGS1*/ 72 | strprerror(fmt, va_alist) 73 | int fmt; 74 | va_dcl 75 | { 76 | va_list ap; 77 | char buf[BUFLEN]; 78 | 79 | errprep(fmt, buf); 80 | va_start(ap); 81 | vprintf(buf, ap); 82 | va_end(ap); 83 | } 84 | 85 | /* extracted string front end for sprintf() */ 86 | /*VARARGS1*/ 87 | strsrerror(fmt, obuf, va_alist) 88 | int fmt; 89 | char *obuf; 90 | va_dcl 91 | { 92 | char buf[BUFLEN]; 93 | va_list ap; 94 | 95 | errprep(fmt, buf); 96 | va_start(ap); 97 | vsprintf(obuf, buf, ap); 98 | va_end(ap); 99 | } 100 | 101 | /* extracted string front end for fprintf() */ 102 | /*VARARGS1*/ 103 | strfrerror(fmt, fd, va_alist) 104 | int fmt; 105 | FILE *fd; 106 | va_dcl 107 | { 108 | va_list ap; 109 | char buf[BUFLEN]; 110 | 111 | errprep(fmt, buf); 112 | va_start(ap); 113 | vfprintf(fd, buf, ap); 114 | va_end(ap); 115 | } 116 | 117 | /* extracted string front end for perror() */ 118 | strperror(fmt) 119 | int fmt; 120 | { 121 | char buf[BUFLEN]; 122 | register int saverr = errno; 123 | 124 | errprep(fmt, buf); 125 | errno = saverr; 126 | perror(buf); 127 | } 128 | 129 | perror(str) 130 | char *str; 131 | { 132 | 133 | printf("%s: errno %d\n", str, errno); 134 | } 135 | 136 | /* 137 | * The following is needed _only_ on systems which do not have the C library 138 | * stubs for the ctime() and getpw*() functions. In 2.11BSD these are 139 | * present in the libstubs.a library and accessed via "-lstubs" at link time. 140 | * 141 | * 2.10BSD's cpp has the BSD2_10 symbol builtin. Other systems without 142 | * libstubs.a will need to define (via a -D option in CFLAGS) 'BSD2_10'. 143 | */ 144 | 145 | #ifdef BSD2_10 146 | 147 | #include 148 | #include 149 | #include 150 | #include 151 | 152 | #define SEND_FD W[1] 153 | #define RECV_FD R[0] 154 | 155 | #define CTIME 1 156 | #define ASCTIME 2 157 | #define TZSET 3 158 | #define LOCALTIME 4 159 | #define GMTIME 5 160 | #define OFFTIME 6 161 | 162 | #define GETPWENT 7 163 | #define GETPWNAM 8 164 | #define GETPWUID 9 165 | #define SETPASSENT 10 166 | #define ENDPWENT 11 167 | 168 | static int R[2], W[2], inited; 169 | static char result[256 + 4]; 170 | static struct tm tmtmp; 171 | static struct passwd _pw, *getandfixpw(); 172 | 173 | char * 174 | ctime(t) 175 | time_t *t; 176 | { 177 | u_char fnc = CTIME; 178 | 179 | sewer(); 180 | write(SEND_FD, &fnc, sizeof fnc); 181 | write(SEND_FD, t, sizeof (*t)); 182 | getb(RECV_FD, result, 26); 183 | return(result); 184 | } 185 | 186 | char * 187 | asctime(tp) 188 | struct tm *tp; 189 | { 190 | u_char fnc = ASCTIME; 191 | 192 | sewer(); 193 | write(SEND_FD, &fnc, sizeof fnc); 194 | write(SEND_FD, tp, sizeof (*tp)); 195 | getb(RECV_FD, result, 26); 196 | return(result); 197 | } 198 | 199 | void 200 | tzset() 201 | { 202 | u_char fnc = TZSET; 203 | 204 | sewer(); 205 | write(SEND_FD, &fnc, sizeof fnc); 206 | } 207 | 208 | struct tm * 209 | localtime(tp) 210 | time_t *tp; 211 | { 212 | u_char fnc = LOCALTIME; 213 | 214 | sewer(); 215 | write(SEND_FD, &fnc, sizeof fnc); 216 | write(SEND_FD, tp, sizeof (*tp)); 217 | getb(RECV_FD, &tmtmp, sizeof tmtmp); 218 | getb(RECV_FD, result, 24); 219 | tmtmp.tm_zone = result; 220 | return(&tmtmp); 221 | } 222 | 223 | struct tm * 224 | gmtime(tp) 225 | time_t *tp; 226 | { 227 | u_char fnc = GMTIME; 228 | 229 | sewer(); 230 | write(SEND_FD, &fnc, sizeof fnc); 231 | write(SEND_FD, tp, sizeof (*tp)); 232 | getb(RECV_FD, &tmtmp, sizeof tmtmp); 233 | getb(RECV_FD, result, 24); 234 | tmtmp.tm_zone = result; 235 | return(&tmtmp); 236 | } 237 | 238 | struct tm * 239 | offtime(clock, offset) 240 | time_t *clock; 241 | long offset; 242 | { 243 | u_char fnc = OFFTIME; 244 | 245 | sewer(); 246 | write(SEND_FD, &fnc, sizeof fnc); 247 | write(SEND_FD, clock, sizeof (*clock)); 248 | write(SEND_FD, &offset, sizeof offset); 249 | getb(RECV_FD, &tmtmp, sizeof tmtmp); 250 | tmtmp.tm_zone = ""; 251 | return(&tmtmp); 252 | } 253 | 254 | struct passwd * 255 | getpwent() 256 | { 257 | u_char fnc = GETPWENT; 258 | 259 | sewer(); 260 | write(SEND_FD, &fnc, sizeof fnc); 261 | return(getandfixpw()); 262 | } 263 | 264 | struct passwd * 265 | getpwnam(nam) 266 | char *nam; 267 | { 268 | u_char fnc = GETPWNAM; 269 | char lnam[UT_NAMESIZE + 1]; 270 | int len; 271 | 272 | len = strlen(nam); 273 | if (len > UT_NAMESIZE) 274 | len = UT_NAMESIZE; 275 | bcopy(nam, lnam, len); 276 | lnam[len] = '\0'; 277 | 278 | sewer(); 279 | write(SEND_FD, &fnc, 1); 280 | write(SEND_FD, &len, sizeof (int)); 281 | write(SEND_FD, lnam, len); 282 | return(getandfixpw()); 283 | } 284 | 285 | struct passwd * 286 | getpwuid(uid) 287 | uid_t uid; 288 | { 289 | u_char fnc = GETPWUID; 290 | 291 | sewer(); 292 | write(SEND_FD, &fnc, sizeof fnc); 293 | write(SEND_FD, &uid, sizeof (uid_t)); 294 | return(getandfixpw()); 295 | } 296 | 297 | setpwent() 298 | { 299 | return(setpassent(0)); 300 | } 301 | 302 | setpassent(stayopen) 303 | int stayopen; 304 | { 305 | u_char fnc = SETPASSENT; 306 | int sts; 307 | 308 | sewer(); 309 | write(SEND_FD, &fnc, sizeof fnc); 310 | write(SEND_FD, &stayopen, sizeof (int)); 311 | getb(RECV_FD, &sts, sizeof (int)); 312 | return(sts); 313 | } 314 | 315 | void 316 | endpwent() 317 | { 318 | u_char fnc = ENDPWENT; 319 | 320 | sewer(); 321 | write(SEND_FD, &fnc, sizeof fnc); 322 | return; 323 | } 324 | 325 | /* setpwfile() is deprecated */ 326 | void 327 | setpwfile(file) 328 | char *file; 329 | { 330 | return; 331 | } 332 | 333 | struct passwd * 334 | getandfixpw() 335 | { 336 | short sz; 337 | 338 | getb(RECV_FD, &sz, sizeof (int)); 339 | if (sz == 0) 340 | return(NULL); 341 | getb(RECV_FD, &_pw, sizeof (_pw)); 342 | getb(RECV_FD, result, sz); 343 | _pw.pw_name += (int)result; 344 | _pw.pw_passwd += (int)result; 345 | _pw.pw_class += (int)result; 346 | _pw.pw_gecos += (int)result; 347 | _pw.pw_dir += (int)result; 348 | _pw.pw_shell += (int)result; 349 | return(&_pw); 350 | } 351 | 352 | getb(f, p, n) 353 | register int f, n; 354 | register char *p; 355 | { 356 | int i; 357 | 358 | while (n) 359 | { 360 | i = read(f, p, n); 361 | if (i <= 0) 362 | return; 363 | p += i; 364 | n -= i; 365 | } 366 | } 367 | 368 | sewer() 369 | { 370 | register int pid, ourpid = getpid(); 371 | 372 | if (inited == ourpid) 373 | return; 374 | if (inited) 375 | { 376 | close(SEND_FD); 377 | close(RECV_FD); 378 | } 379 | pipe(W); 380 | pipe(R); 381 | pid = vfork(); 382 | if (pid == 0) 383 | { /* child */ 384 | alarm(0); /* cancel alarms */ 385 | dup2(W[0], 0); /* parent write side to our stdin */ 386 | dup2(R[1], 1); /* parent read side to our stdout */ 387 | close(SEND_FD); /* copies made, close the... */ 388 | close(RECV_FD); /* originals now */ 389 | execl(_PATH_CTIMED, "ctimed", 0); 390 | _exit(EX_OSFILE); 391 | } 392 | if (pid == -1) 393 | abort(); /* nothing else really to do */ 394 | close(W[0]); /* close read side of SEND channel */ 395 | close(R[1]); /* close write side of RECV channel */ 396 | inited = ourpid; /* don't do this again in this proc */ 397 | } 398 | 399 | XXctime() 400 | { 401 | 402 | if (SEND_FD) 403 | close(SEND_FD); 404 | if (RECV_FD) 405 | close(RECV_FD); 406 | SEND_FD = RECV_FD = 0; 407 | inited = 0; 408 | } 409 | #endif /* BSD2_10 */ 410 | -------------------------------------------------------------------------------- /ckustr.sed: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Special cc preprocessor for using mkstr(1) to extract strings from the 3 | # kermit source. Change the "CC=cc" line to "CC=./ckustr.sed" to use 4 | # string extraction. NOTE: the file ckustr.c might need the StringFile 5 | # declaration modified to suit local system requirements. When installing 6 | # the kermit executable be sure to install kermit.sr and make it readable 7 | # by the public (mode 444). 8 | 9 | STRINGS=cku195.sr 10 | 11 | # Get filename and arguments. 12 | initargs=$@ 13 | while [ -n "$1" ] 14 | do 15 | if [ $1 = -o ] 16 | then 17 | exec cc $initargs 18 | exit 1 19 | fi 20 | if [ `expr substr $1 1 1` = - ] 21 | then 22 | if [ $1 != -c ] 23 | then 24 | args="$args $1" 25 | fi 26 | else 27 | csrc=$1 28 | fi 29 | shift 30 | done 31 | 32 | # Only process compilations, and then only for certain files. 33 | if [ $csrc = ckustr.c -o $csrc = ckwart.c ] 34 | then 35 | exec cc $initargs 36 | exit 1 37 | fi 38 | 39 | # String extractions 40 | echo Extracting strings from ${csrc}... 41 | cc -E $args $csrc > xxmk.c 42 | sed -e 's/ferror(/strferrorf(/' \ 43 | -e 's/perror("/strperror("/' \ 44 | -e 's/experror(/strexperrorf(/' \ 45 | -e 's/sprintf(\([^,][^,]*\),[ ]*\("[^"]*"\)\([,)]\)/strsrerror(\2, \1\3/' \ 46 | -e '/sprintf(\([^,][^,]*\),/{N 47 | s/sprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strsrerror(\2, \1\3/ 48 | }' \ 49 | -e 's/fprintf(\([^,][^,]*\),[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/' \ 50 | -e '/fprintf(\([^,][^,]*\),/{N 51 | s/fprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/ 52 | }' \ 53 | -e 's/printf[ ]*("/strprerror("/' \ 54 | -e '/printf[ ]*(/{N 55 | s/printf[ ]*(\n"/strprerror("/ 56 | }' xxmk.c > mk.c 57 | mkstr - $STRINGS xx mk.c 58 | sed -e 's/^# \([0-9]\)/#line \1/' xxmk.c | xstr -c - 59 | echo Compiling... 60 | cc -Dstrferrorf=ferror -Dstrexperrorf=experror $args -c x.c 61 | mv x.o `basename $csrc .c`.o 62 | rm -f x.c mk.c xxmk.c 63 | -------------------------------------------------------------------------------- /ckuver.h: -------------------------------------------------------------------------------- 1 | /* ckuver.h -- C-Kermit UNIX Version heralds */ 2 | /* 3 | Author: Frank da Cruz . 4 | 5 | Copyright (C) 1985, 2022, 6 | Trustees of Columbia University in the City of New York. 7 | All rights reserved. See the C-Kermit COPYING.TXT file or the 8 | copyright text in the ckcmai.c module for disclaimer and permissions. 9 | */ 10 | 11 | #ifndef CKUVER_H 12 | #define CKUVER_H 13 | 14 | /* Arranged more or less alphabetically by compiler symbol */ 15 | /* Must be included AFTER ckcdeb.h. */ 16 | 17 | #ifdef BEOS 18 | #ifdef BEOS45 19 | #define HERALD " BeOS 4.5" 20 | #else 21 | #define HERALD " BeOS" 22 | #endif /* BEOS45 */ 23 | #else 24 | #ifdef BEBOX 25 | #ifdef BE_DR_7 26 | #define HERALD " BeBox DR7" 27 | #else 28 | #define HERALD " BeBox" 29 | #endif /* BE_DR_7 */ 30 | #endif /* BEBOX */ 31 | #endif /* BEOS */ 32 | 33 | #ifdef BELLV10 34 | #define HERALD " Bell Labs Research UNIX V10" 35 | #endif /* BELLV10 */ 36 | 37 | #ifdef APOLLOSR10 38 | #define HERALD " Apollo SR10" 39 | #endif /* APOLLOSR10 */ 40 | 41 | #ifdef MAC 42 | #define HERALD " Apple Macintosh" 43 | #endif /* MAC */ 44 | 45 | #ifdef A986 46 | #define HERALD " Altos 986 / Xenix 3.0" 47 | #endif /* A986 */ 48 | 49 | #ifdef AS400 50 | #define HERALD " AS/400" 51 | #endif /* AS400 */ 52 | 53 | #ifdef aegis 54 | #ifdef BSD4 55 | #define HERALD " Apollo DOMAIN/IX 4.2 BSD" 56 | #else 57 | #ifdef ATTSV 58 | #define HERALD " Apollo DOMAIN/IX System V" 59 | #else 60 | #define HERALD " Apollo Aegis" 61 | #endif /* BSD4 */ 62 | #endif /* ATTSV */ 63 | #endif /* aegis */ 64 | 65 | #ifndef HERALD 66 | 67 | #ifdef AIXRS 68 | 69 | #ifdef AIX53 70 | #define HERALD " IBM AIX 5.3" 71 | #else 72 | #ifdef AIX52 73 | #define HERALD " IBM AIX 5.2" 74 | #else 75 | #ifdef AIX51 76 | #define HERALD " IBM AIX 5.1" 77 | #else 78 | #ifdef AIX45 79 | #define HERALD " IBM AIX 5.0" 80 | #else 81 | #ifdef AIX45 82 | #define HERALD " IBM AIX 4.5" 83 | #else 84 | #ifdef AIX44 85 | #define HERALD " IBM AIX 4.4" 86 | #else 87 | #ifdef AIX43 88 | #define HERALD " IBM AIX 4.3" 89 | #else 90 | #ifdef AIX42 91 | #define HERALD " IBM AIX 4.2" 92 | #else 93 | #ifdef SVR4 94 | #ifdef AIX41 95 | #define HERALD " IBM AIX 4.1" 96 | #else 97 | #define HERALD " IBM RS/6000 AIX 3.2" 98 | #endif /* AIX41 */ 99 | #else 100 | #define HERALD " IBM RS/6000 AIX 3.0/3.1" 101 | #endif /* SVR4 */ 102 | #endif /* AIX42 */ 103 | #endif /* AIX43 */ 104 | #endif /* AIX44 */ 105 | #endif /* AIX45 */ 106 | #endif /* AIX50 */ 107 | #endif /* AIX51 */ 108 | #endif /* AIX52 */ 109 | #endif /* AIX53 */ 110 | #endif /* AIXRS */ 111 | 112 | #ifdef PS2AIX10 113 | #define HERALD " IBM PS/2 AIX 1.x" 114 | #endif /* PS2AIX10 */ 115 | 116 | #ifdef AIXPS2 117 | #define HERALD " IBM PS/2 AIX 3.x" 118 | #endif /* AIXPS2 */ 119 | 120 | #ifdef AIX370 121 | #ifndef HERALD 122 | #define HERALD " IBM System/370 AIX/370" 123 | #endif 124 | #endif /* AIX370 */ 125 | 126 | #ifdef AIXESA 127 | #ifndef HERALD 128 | #define HERALD " IBM AIX/ESA version 2.1" 129 | #endif 130 | #endif /* AIXESA */ 131 | 132 | #ifdef ATT6300 133 | #define HERALD " AT&T 6300" 134 | #endif /* ATT6300 */ 135 | 136 | #ifdef ATT7300 137 | #ifdef UNIX351M 138 | #define HERALD " AT&T 7300 UNIX PC UNIX 3.51m" 139 | #else 140 | #define HERALD " AT&T 7300 UNIX PC" 141 | #endif /* UNIX351M */ 142 | #endif /* ATT7300 */ 143 | 144 | #ifdef AUX 145 | #define HERALD " Apple Macintosh AUX" 146 | #endif /* AUX */ 147 | 148 | #ifdef BSD44 149 | #ifdef MACOSX 150 | #define HERALD " Mac OS X" 151 | #else 152 | #ifdef __OpenBSD__ 153 | #define HERALD " OpenBSD" 154 | #else 155 | #ifdef __bsdi__ 156 | #ifdef BSDI4 157 | #define HERALD " BSDI BSD/OS 4.0" 158 | #else 159 | #ifdef BSDI3 160 | #define HERALD " BSDI BSD/OS 3.0" 161 | #else 162 | #ifdef BSDI2 163 | #define HERALD " BSDI BSD/OS 2.0" /* 1.1++ name... */ 164 | #else 165 | #define HERALD " BSDI BSD/386" /* Original 1.0 name */ 166 | #endif /* BSDI2 */ 167 | #endif /* BSDI3 */ 168 | #endif /* BSDI4 */ 169 | #else /* __bsdi__ */ 170 | #ifdef __NetBSD__ 171 | #ifndef HERALD 172 | #ifdef NETBSD16 173 | #define HERALD " NetBSD 1.6" 174 | #else 175 | #ifdef NETBSD15 176 | #define HERALD " NetBSD 1.5" 177 | #else 178 | #define HERALD " NetBSD" 179 | #endif /* NETBSD15 */ 180 | #endif /* NETBSD16 */ 181 | #endif /* HERALD */ 182 | #else /* __NetBSD__ */ 183 | #ifdef __FreeBSD__ 184 | #ifdef FREEBSD51 185 | #define HERALD " FreeBSD 5.1" 186 | #else 187 | #ifdef FREEBSD50 188 | #define HERALD " FreeBSD 5.0" 189 | #else 190 | #ifdef FREEBSD49 191 | #define HERALD " FreeBSD 4.9" 192 | #else 193 | #ifdef FREEBSD48 194 | #define HERALD " FreeBSD 4.8" 195 | #else 196 | #ifdef FREEBSD47 197 | #define HERALD " FreeBSD 4.7" 198 | #else 199 | #ifdef FREEBSD46 200 | #define HERALD " FreeBSD 4.6" 201 | #else 202 | #ifdef FREEBSD45 203 | #define HERALD " FreeBSD 4.5" 204 | #else 205 | #ifdef FREEBSD44 206 | #define HERALD " FreeBSD 4.4" 207 | #else 208 | #ifdef FREEBSD43 209 | #define HERALD " FreeBSD 4.3" 210 | #else 211 | #ifdef FREEBSD42 212 | #define HERALD " FreeBSD 4.2" 213 | #else 214 | #ifdef FREEBSD41 215 | #define HERALD " FreeBSD 4.1" 216 | #else 217 | #ifdef FREEBSD4 218 | #define HERALD " FreeBSD 4.0" 219 | #else 220 | #ifdef FREEBSD3 221 | #define HERALD " FreeBSD 3.0" 222 | #else 223 | #ifdef FREEBSD2 224 | #define HERALD " FreeBSD 2.0" 225 | #else 226 | #define HERALD " FreeBSD" 227 | #endif /* FREEBSD2 */ 228 | #endif /* FREEBSD3 */ 229 | #endif /* FREEBSD4 */ 230 | #endif /* FREEBSD41 */ 231 | #endif /* FREEBSD42 */ 232 | #endif /* FREEBSD43 */ 233 | #endif /* FREEBSD44 */ 234 | #endif /* FREEBSD45 */ 235 | #endif /* FREEBSD46 */ 236 | #endif /* FREEBSD47 */ 237 | #endif /* FREEBSD48 */ 238 | #endif /* FREEBSD49 */ 239 | #endif /* FREEBSD50 */ 240 | #endif /* FREEBSD51 */ 241 | #else 242 | #ifdef __386BSD__ 243 | #define HERALD " 386BSD" 244 | #else 245 | #define HERALD " 4.4BSD" 246 | #endif /* __386BSD__ */ 247 | #endif /* __FreeBSD__ */ 248 | #endif /* __NetBSD__ */ 249 | #endif /* __bsdi__ */ 250 | #endif /* __OpenBSD__ */ 251 | #endif /* MACOSX */ 252 | #endif /* BSD44 */ 253 | 254 | #ifdef ENCORE 255 | #ifdef BSD43 256 | #define HERALD " Encore Multimax UMAX 4.3" 257 | #else 258 | #define HERALD " Encore Multimax UMAX 4.2" 259 | #endif 260 | #endif /* ENCORE */ 261 | 262 | #ifdef BSD29 263 | #define HERALD " 2.9 BSD" 264 | #endif /* BSD29 */ 265 | 266 | #ifdef BSD41 267 | #define HERALD " 4.1 BSD" 268 | #endif /* BSD41 */ 269 | 270 | #ifdef C70 271 | #define HERALD " BBN C/70" 272 | #endif /* c70 */ 273 | 274 | #ifdef CIE 275 | #define HERALD " CIE Systems 680/20 Regulus" 276 | #endif /* CIE */ 277 | 278 | #ifdef COHERENT 279 | #ifdef _I386 280 | #define HERALD " MWC Coherent 386 4.x" 281 | #ifndef i386 282 | #define i386 283 | #endif /* i386 */ 284 | #else 285 | #define HERALD " PC/AT MWC Coherent 286 3.x" 286 | #ifndef i286 287 | #define i286 288 | #endif /* i286 */ 289 | #endif /* _I386 */ 290 | #endif /* COHERENT */ 291 | 292 | #ifdef CONVEX9 293 | #define HERALD " Convex/OS" 294 | #endif /* CONVEX9 */ 295 | 296 | #ifdef CONVEX10 297 | #define HERALD " Convex/OS 10.1" 298 | #endif /* CONVEX10 */ 299 | 300 | #ifdef _CRAY 301 | #ifdef _CRAYCOM 302 | #define HERALD " Cray CSOS" 303 | #else /* _CRAYCOM */ 304 | #define HERALD " Cray UNICOS" 305 | #endif /* _CRAYCOM */ 306 | #endif /* _CRAY */ 307 | 308 | #ifdef DGUX 309 | #ifdef DGUX54420 310 | #define HERALD " Data General DG/UX R4.20" 311 | #else 312 | #ifdef DGUX54411 313 | #define HERALD " Data General DG/UX R4.11" 314 | #else 315 | #ifdef DGUX54410 316 | #define HERALD " Data General DG/UX R4.10" 317 | #else 318 | #ifdef DGUX54310 319 | #define HERALD " Data General DG/UX 5.4R3.10" 320 | #else 321 | #ifdef DGUX543 322 | #define HERALD " Data General DG/UX 5.4R3.00" 323 | #else 324 | #ifdef DGUX540 325 | #define HERALD " Data General DG/UX 5.4" 326 | #else 327 | #ifdef DGUX430 328 | #define HERALD " Data General DG/UX 4.30" 329 | #else 330 | #define HERALD " Data General DG/UX" 331 | #endif /* DGUX430 */ 332 | #endif /* DGUX540 */ 333 | #endif /* DGUX543 */ 334 | #endif /* DGUX54310 */ 335 | #endif /* DGUX54410 */ 336 | #endif /* DGUX54411 */ 337 | #endif /* DGUX54420 */ 338 | #endif /* DGUX */ 339 | 340 | #ifdef datageneral 341 | #ifndef HERALD 342 | #define HERALD " Data General AOS/VS" 343 | #endif /* HERALD */ 344 | #endif /* datageneral */ 345 | 346 | #ifdef SINIX 347 | #ifdef SNI544 348 | #define HERALD " Siemens Nixdorf Reliant UNIX V5.44" 349 | #else 350 | #ifdef SNI543 351 | #define HERALD " Siemens Nixdorf Reliant UNIX V5.43" 352 | #else 353 | #ifdef SNI541 354 | #define HERALD " Siemens Nixdorf SINIX V5.41" 355 | #else 356 | #define HERALD " Siemens Nixdorf SINIX V5.42" 357 | #endif /* SNI541 */ 358 | #endif /* SNI543 */ 359 | #endif /* SNI544 */ 360 | #endif /* SINIX */ 361 | 362 | #ifdef POWERMAX 363 | #define HERALD " Concurrent PowerMAX OS" 364 | #endif /* POWERMAX */ 365 | 366 | #ifdef DELL_SVR4 367 | #define HERALD " Dell System V R4" 368 | #endif /* DELL_SVR4 */ 369 | 370 | #ifdef NCRMPRAS 371 | #define HERALD " NCR MP-RAS" 372 | #endif /* NCRMPRAS */ 373 | 374 | #ifdef UNIXWARE 375 | #define HERALD " UnixWare" 376 | #else 377 | #ifdef OLD_UNIXWARE 378 | #define HERALD " UnixWare" 379 | #endif /* OLD_UNIXWARE */ 380 | #endif /* UNIXWARE */ 381 | 382 | #ifdef ICL_SVR4 383 | #define HERALD " ICL System V R4 DRS N/X" 384 | #endif /* ICL_SVR4 */ 385 | 386 | #ifdef FT18 387 | #ifdef FT21 388 | #define HERALD " Fortune For:Pro 2.1" 389 | #else 390 | #define HERALD " Fortune For:Pro 1.8" 391 | #endif /* FT21 */ 392 | #endif /* FT18 */ 393 | 394 | #ifdef GEMDOS 395 | #define HERALD " Atari ST GEM 1.0" 396 | #endif /* GEMDOS */ 397 | 398 | #ifdef XF68R3V6 399 | #define HERALD " Motorola UNIX System V/68 R3V6" 400 | #endif /* XF68R3V6 */ 401 | 402 | #ifdef XF88R32 403 | #define HERALD " Motorola UNIX System V/88 R32" 404 | #endif /* XF88R32 */ 405 | 406 | #ifdef I386IX 407 | #ifdef SVR3JC 408 | #define HERALD " Interactive UNIX System V/386 R3.2" 409 | #else 410 | #define HERALD " Interactive Systems Corp 386/ix" 411 | #endif /* SVR3JC */ 412 | #endif /* I386IX */ 413 | 414 | #ifdef IRIX65 415 | #define HERALD " Silicon Graphics IRIX 6.5" 416 | #else 417 | #ifdef IRIX64 418 | #define HERALD " Silicon Graphics IRIX 6.4" 419 | #else 420 | #ifdef IRIX63 421 | #define HERALD " Silicon Graphics IRIX 6.3" 422 | #else 423 | #ifdef IRIX62 424 | #define HERALD " Silicon Graphics IRIX 6.2" 425 | #else 426 | #ifdef IRIX60 427 | #define HERALD " Silicon Graphics IRIX 6.0" 428 | #else 429 | #ifdef IRIX53 430 | #define HERALD " Silicon Graphics IRIX 5.3" 431 | #else 432 | #ifdef IRIX52 433 | #define HERALD " Silicon Graphics IRIX 5.2" 434 | #else 435 | #ifdef IRIX51 436 | #define HERALD " Silicon Graphics IRIX 5.1" 437 | #else 438 | #ifdef IRIX40 439 | #define HERALD " Silicon Graphics IRIX 4.0" 440 | #endif /* IRIX40 */ 441 | #endif /* IRIX51 */ 442 | #endif /* IRIX52 */ 443 | #endif /* IRIX53 */ 444 | #endif /* IRIX60 */ 445 | #endif /* IRIX62 */ 446 | #endif /* IRIX63 */ 447 | #endif /* IRIX64 */ 448 | #endif /* IRIX65 */ 449 | 450 | #ifdef ISIII 451 | #define HERALD " Interactive Systems Corp System III" 452 | #endif /* ISIII */ 453 | 454 | #ifdef IX370 455 | #define HERALD " IBM IX/370" 456 | #endif /* IX370 */ 457 | 458 | #ifdef HPUX 459 | #ifdef HPUX5 460 | #define HERALD " HP-UX 5.00" 461 | #else 462 | #ifdef HPUX6 463 | #define HERALD " HP-UX 6.00" 464 | #else 465 | #ifdef HPUX7 466 | #define HERALD " HP-UX 7.00" 467 | #else 468 | #ifdef HPUX8 469 | #define HERALD " HP-UX 8.00" 470 | #else 471 | #ifdef HPUX9 472 | #define HERALD " HP-UX 9.00" 473 | #else 474 | #ifdef HPUX1100 475 | #define HERALD " HP-UX 11.00" 476 | #else 477 | #ifdef HPUX10 478 | #ifdef HPUX1030 479 | #define HERALD " HP-UX 10.30" 480 | #else 481 | #ifdef HPUX1020 482 | #define HERALD " HP-UX 10.20" 483 | #else 484 | #ifdef HPUX1010 485 | #define HERALD " HP-UX 10.10" 486 | #else 487 | #ifdef HPUX10xx 488 | #define HERALD " HP-UX 10.xx" 489 | #else 490 | #define HERALD " HP-UX 10.00" 491 | #endif /* HPUX10XX */ 492 | #endif /* HPUX1010 */ 493 | #endif /* HPUX1020 */ 494 | #endif /* HPUX1030 */ 495 | #else 496 | #define HERALD " HP-UX" 497 | #endif /* HPUX10 */ 498 | #endif /* HPUX1100 */ 499 | #endif /* HPUX9 */ 500 | #endif /* HPUX8 */ 501 | #endif /* HPUX7 */ 502 | #endif /* HPUX6 */ 503 | #endif /* HPUX5 */ 504 | #endif /* HPUX */ 505 | 506 | #ifndef MINIX 507 | #ifdef MINIX340 508 | #define MINIX 509 | #endif /* MINIX340 */ 510 | #endif /* MINIX */ 511 | 512 | #ifndef MINIX 513 | #ifdef MINIX315 514 | #define MINIX 515 | #endif /* MINIX315 */ 516 | #endif /* MINIX */ 517 | 518 | #ifndef MINIX 519 | #ifdef MINIX3 520 | #define MINIX 521 | #endif /* MINIX3 */ 522 | #endif /* MINIX */ 523 | 524 | #ifdef MINIX 525 | #ifdef MINIX340 526 | #define HERALD " Minix 3.4.0" 527 | #ifndef MINIX3 528 | #define MINIX3 529 | #endif /* MINIX3 */ 530 | #endif /* MINIX340 */ 531 | #ifdef MINIX315 532 | #define HERALD " Minix 3.1.5" 533 | #ifndef MINIX3 534 | #define MINIX3 535 | #endif /* MINIX3 */ 536 | #endif /* MINIX315 */ 537 | #ifdef MINIX3 538 | #ifndef MINIX2 539 | #define MINIX2 540 | #endif /* MINIX2 */ 541 | #ifndef HERALD 542 | #define HERALD " Minix 3.0" 543 | #endif /* HERALD */ 544 | #else 545 | #ifdef MINIX2 546 | #define HERALD " Minix 2.0" 547 | #else 548 | #define HERALD " Minix 1.0" 549 | #endif /* MINIX3 */ 550 | #endif /* MINIX2 */ 551 | #endif /* MINIX */ 552 | 553 | #ifdef MIPS 554 | #define HERALD " MIPS RISC/OS SVR3" 555 | #endif /* MIPS */ 556 | 557 | #ifdef NEXT 558 | #ifdef OPENSTEP42 559 | #define HERALD " OPENSTEP 4.2" 560 | #else 561 | #ifdef NEXT33 562 | #define HERALD " NeXTSTEP 3.3" 563 | #else 564 | #define HERALD " NeXTSTEP" 565 | #endif /* NEXT33 */ 566 | #endif /* OPENSTEP42 */ 567 | #endif /* NEXT */ 568 | 569 | #ifdef OSF 570 | #ifdef i386 571 | #define HERALD " DECpc OSF/1" 572 | #ifdef __GNUC 573 | #define OSFPC 574 | #endif /* __GNUC */ 575 | #else /* Not i386 so Alpha */ 576 | 577 | #ifdef TRU64 578 | 579 | #ifdef OSF51B 580 | #define HERALD " Compaq Tru64 UNIX 5.1B" 581 | #else 582 | #ifdef OSF51A 583 | #define HERALD " Compaq Tru64 UNIX 5.1A" 584 | #else 585 | #ifdef OSF50 586 | #define HERALD " Compaq Tru64 UNIX 5.0A" 587 | #else 588 | #ifdef OSF40G 589 | #define HERALD " Compaq Tru64 UNIX 4.0G" 590 | #else 591 | #ifdef OSF40F 592 | #define HERALD " Compaq Tru64 UNIX 4.0F" 593 | #else 594 | #ifdef OSF40E 595 | #define HERALD " Compaq Tru64 UNIX 4.0E" 596 | #endif /* OSF40E */ 597 | #endif /* OSF40F */ 598 | #endif /* OSF40G */ 599 | #endif /* OSF50 */ 600 | #endif /* OSF51A */ 601 | #endif /* OSF51B */ 602 | 603 | #else /* Not TRU64 */ 604 | 605 | #ifdef OSF40 606 | #define HERALD " Digital UNIX 4.0" 607 | #else 608 | #ifdef OSF32 609 | #define HERALD " Digital UNIX 3.2" 610 | #else 611 | #define HERALD " DEC OSF/1 Alpha" 612 | #endif /* OSF40 */ 613 | #endif /* OSF32 */ 614 | 615 | #endif /* TRU64 */ 616 | #endif /* i386 */ 617 | #endif /* OSF */ 618 | 619 | #ifdef PCIX 620 | #define HERALD " PC/IX" 621 | #endif /* PCIX */ 622 | 623 | #ifdef sxaE50 624 | #define HERALD " PFU SX/A V10/L50" 625 | #endif /* sxaE50 */ 626 | 627 | #ifdef PROVX1 628 | #define HERALD " DEC Professional 300 (Venix 1.0)" 629 | #endif /* PROVX1 */ 630 | 631 | #ifdef PYRAMID 632 | #ifdef SVR4 633 | #define HERALD " Pyramid DC/OSx" 634 | #else 635 | #define HERALD " Pyramid Dual Port OSx" 636 | #endif /* SVR4 */ 637 | #endif /* PYRAMID */ 638 | 639 | #ifdef RTAIX 640 | #define HERALD " IBM RT PC (AIX 2.2)" 641 | #endif /* RTAIX */ 642 | 643 | #ifdef RTU 644 | #define HERALD " Masscomp/Concurrent RTU" 645 | #endif /* RTU */ 646 | 647 | #ifdef sony_news 648 | #define HERALD " SONY NEWS" 649 | #endif /* sony_news */ 650 | 651 | #ifdef SOLARIS24 652 | #define HERALD " Solaris 2.4" 653 | #else 654 | #ifdef SOLARIS23 655 | #define HERALD " Solaris 2.3" 656 | #else 657 | #ifdef SOLARIS 658 | #define HERALD " Solaris 2.x" 659 | #endif /* SOLARIS */ 660 | #endif /* SOLARIS23 */ 661 | #endif /* SOLARIS24 */ 662 | 663 | #ifdef SUNOS4 664 | #ifdef BSD4 665 | #ifdef SUNOS41 666 | #define HERALD " SunOS 4.1" 667 | #else 668 | #define HERALD " SunOS 4.0" 669 | #endif /* SUNOS41 */ 670 | #endif /* BSD4 */ 671 | #endif /* SUNOS4 */ 672 | 673 | #ifdef SUN4S5 674 | #ifdef HDBUUCP 675 | #define HERALD " SunOS 4.1 (SVR3)" 676 | #else 677 | #define HERALD " SunOS 4.0 (SVR3)" 678 | #endif /* HDBUUCP */ 679 | #endif /* SUN4S5 */ 680 | 681 | #ifdef STRATUS 682 | #define HERALD " Stratus VOS" 683 | #endif /* STRATUS */ 684 | 685 | #ifdef TOWER1 686 | #define HERALD " NCR Tower 1632 OS 1.02" 687 | #endif /* TOWER1 */ 688 | 689 | #ifdef TRS16 690 | #define HERALD " Tandy 16/6000 Xenix 3.0" 691 | #ifndef CKCPU 692 | #define CKCPU "mc68000" 693 | #endif /* CKCPU */ 694 | #endif /* TRS16 */ 695 | 696 | #ifdef u3b2 697 | #ifndef HERALD 698 | #ifdef SVR3 699 | #define HERALD " AT&T 3B2 System V R3" 700 | #else 701 | #define HERALD " AT&T 3B2 System V" 702 | #endif /* SVR3 */ 703 | #endif /* HERALD */ 704 | #endif /* u3b2 */ 705 | 706 | #ifdef ultrix 707 | #ifdef vax 708 | #ifdef ULTRIX3 709 | #define HERALD " VAX/ULTRIX 3.0" 710 | #else 711 | #define HERALD " VAX/ULTRIX" 712 | #endif /* ULTRIX3 */ 713 | #else 714 | #ifdef mips 715 | #ifdef ULTRIX43 716 | #define HERALD " DECstation/ULTRIX 4.3" 717 | #else 718 | #ifdef ULTRIX44 719 | #define HERALD " DECstation/ULTRIX 4.4" 720 | #else 721 | #ifdef ULTRIX45 722 | #define HERALD " DECstation/ULTRIX 4.5" 723 | #else 724 | #define HERALD " DECstation/ULTRIX" 725 | #endif /* ULTRIX45 */ 726 | #endif /* ULTRIX44 */ 727 | #endif /* ULTRIX43 */ 728 | #else 729 | #define HERALD " ULTRIX" 730 | #endif /* mips */ 731 | #endif /* vax */ 732 | #endif /* ultrix */ 733 | 734 | #ifdef OXOS 735 | #define HERALD " Olivetti X/OS" 736 | #endif /* OXOS */ 737 | 738 | #ifdef _386BSD 739 | #define HERALD " 386BSD" 740 | #endif /* _386BSD */ 741 | 742 | #ifdef POSIX 743 | #ifdef PTX 744 | #ifdef PTX4 745 | #define HERALD " DYNIX/ptx V4" 746 | #else 747 | #define HERALD " DYNIX/ptx" 748 | #endif /* PTX4 */ 749 | #else /* PTX */ 750 | #ifndef OSF /* Let OSF -DPOSIX keep previously defined HERALD */ 751 | #ifdef HERALD 752 | #undef HERALD 753 | #endif /* HERALD */ 754 | #endif /* OSF */ 755 | #ifdef OU8 756 | #define HERALD " OpenUNIX 8" 757 | #else 758 | #ifdef UW7 759 | #define HERALD " Unixware 7" 760 | #else 761 | #ifdef QNX 762 | #ifdef QNX16 763 | #define HERALD " QNX 16-bit" 764 | #else 765 | #define HERALD " QNX 32-bit" 766 | #endif /* QNX16 */ 767 | #else 768 | #ifdef NEUTRINO 769 | #define HERALD " QNX Neutrino 2" 770 | #else /* NEUTRINO */ 771 | #ifdef QNX6 772 | #define HERALD " QNX6" 773 | #else /* QNX6 */ 774 | #ifdef __linux__ 775 | #ifdef ZSL5500 776 | #define HERALD " Sharp Zaurus SL-5500" 777 | #else 778 | #ifdef RH90 779 | #define HERALD " Red Hat Linux 9.0" 780 | #else 781 | #ifdef RH80 782 | #define HERALD " Red Hat Linux 8.0" 783 | #else 784 | #ifdef RH73 785 | #define HERALD " Red Hat Linux 7.3" 786 | #else 787 | #ifdef RH72 788 | #define HERALD " Red Hat Linux 7.2" 789 | #else 790 | #ifdef RH71 791 | #define HERALD " Red Hat Linux 7.1" 792 | #else 793 | #ifdef ANDROID 794 | #define HERALD " Android" 795 | #else 796 | #define HERALD " Linux" 797 | #endif /* ANDROID */ 798 | #endif /* RH71 */ 799 | #endif /* RH72 */ 800 | #endif /* RH73 */ 801 | #endif /* RH80 */ 802 | #endif /* RH90 */ 803 | #endif /* ZSL5500 */ 804 | #else /* __linux__ */ 805 | #ifdef _386BSD /* 386BSD Jolix */ 806 | #define HERALD " 386BSD" 807 | #else 808 | #ifdef LYNXOS /* Lynx OS 2.2 */ 809 | #define HERALD " Lynx OS" 810 | #else 811 | #ifdef Plan9 812 | #define HERALD " Plan 9 from Bell Labs" 813 | #else 814 | #ifdef SOLARIS11 815 | #define HERALD " Solaris 11" 816 | #else 817 | #ifdef SOLARIS10 818 | #define HERALD " Solaris 10" 819 | #else 820 | #ifdef SOLARIS9 821 | #define HERALD " Solaris 9" 822 | #else 823 | #ifdef SOLARIS8 824 | #define HERALD " Solaris 8" 825 | #else 826 | #ifdef SOLARIS7 827 | #define HERALD " Solaris 7" 828 | #else 829 | #ifdef SOLARIS26 830 | #define HERALD " Solaris 2.6" 831 | #else 832 | #ifdef SOLARIS25 833 | #define HERALD " Solaris 2.5" 834 | #else 835 | #ifdef SOLARIS24 836 | #define HERALD " Solaris 2.4" 837 | #else 838 | #ifdef SOLARIS 839 | #define HERALD " Solaris 2.x" 840 | #endif /* SOLARIS */ 841 | #endif /* SOLARIS24 */ 842 | #endif /* SOLARIS25 */ 843 | #endif /* SOLARIS26 */ 844 | #endif /* SOLARIS7 */ 845 | #endif /* SOLARIS8 */ 846 | #endif /* SOLARIS9 */ 847 | #endif /* SOLARIS10 */ 848 | #endif /* SOLARIS11 */ 849 | #endif /* Plan9 */ 850 | #endif /* LYNXOS */ 851 | #endif /* _386BSD */ 852 | #endif /* __linux__ */ 853 | #endif /* QNX6 */ 854 | #endif /* NEUTRINO */ 855 | #endif /* QNX */ 856 | #endif /* UW7 */ 857 | #endif /* OU8 */ 858 | #endif /* PTX */ 859 | #endif /* POSIX */ 860 | 861 | #ifdef UTS24 862 | #define HERALD " Amdahl UTS 2.4" 863 | #endif /* UTS24 */ 864 | 865 | #ifdef UTSV 866 | #define HERALD " Amdahl UTS V" 867 | #endif /* UTSV */ 868 | 869 | #ifdef VXVE 870 | #define HERALD " CDC VX/VE 5.2.1 System V" 871 | #endif /* VXVE */ 872 | 873 | #ifdef SCO234 874 | #ifdef HERALD 875 | #undef HERALD 876 | #endif /* HERALD */ 877 | #define HERALD " SCO XENIX 2.3.4" 878 | #else 879 | #ifdef CK_SCO32V4 880 | #ifdef HERALD 881 | #undef HERALD 882 | #endif /* HERALD */ 883 | #ifdef ODT30 884 | #define HERALD " SCO ODT 3.0" 885 | #else 886 | #define HERALD " SCO UNIX/386 V4" 887 | #endif /* ODT30 */ 888 | #else 889 | #ifdef CK_SCOV5 890 | #ifdef HERALD 891 | #undef HERALD 892 | #endif /* HERALD */ 893 | #ifdef SCO_OSR507 894 | #define HERALD " SCO OpenServer R5.0.7" 895 | #else 896 | #ifdef SCO_OSR506A 897 | #define HERALD " SCO OpenServer R5.0.6a" 898 | #else 899 | #ifdef SCO_OSR506 900 | #define HERALD " SCO OpenServer R5.0.6" 901 | #else 902 | #ifdef SCO_OSR505 903 | #define HERALD " SCO OpenServer R5.0.5" 904 | #else 905 | #ifdef SCO_OSR504 906 | #define HERALD " SCO OpenServer R5.0.4" 907 | #else 908 | #ifdef SCO_OSR502 909 | #define HERALD " SCO OpenServer R5.0.2" 910 | #else 911 | #define HERALD " SCO OpenServer R5.0" 912 | #endif /* SCO_OSR502 */ 913 | #endif /* SCO_OSR504 */ 914 | #endif /* SCO_OSR505 */ 915 | #endif /* SCO_OSR506 */ 916 | #endif /* SCO_OSR506A */ 917 | #endif /* SCO_OSR507 */ 918 | #else 919 | #ifdef XENIX 920 | #ifdef HERALD 921 | #undef HERALD 922 | #endif /* HERALD */ 923 | #ifdef M_UNIX 924 | #define HERALD " SCO UNIX/386" 925 | #else 926 | #ifdef M_I386 927 | #define HERALD " Xenix/386" 928 | #else 929 | #ifdef M_I286 930 | #define HERALD " Xenix/286" 931 | #else 932 | #define HERALD " Xenix" 933 | #endif /* M_I286 */ 934 | #endif /* M_I386 */ 935 | #endif /* M_UNIX */ 936 | #endif /* XENIX */ 937 | #endif /* CK_SCOV5 */ 938 | #endif /* CK_SCOV32V4 */ 939 | #endif /* SCO234 */ 940 | 941 | #ifdef ZILOG 942 | #define HERALD " Zilog S8000 Zeus 3.21+" 943 | #endif /* ZILOG */ 944 | 945 | #ifdef UTEK 946 | #define HERALD " UTek" 947 | #endif /* UTEK */ 948 | 949 | /* Catch-alls for anything not defined explicitly above */ 950 | 951 | #ifndef HERALD 952 | #ifdef SVR4 953 | #ifdef i386 954 | #define HERALD " AT&T System V/386 R4" 955 | #else 956 | #ifdef AMIX 957 | #define HERALD " Commodore Amiga System V/m68k R4" 958 | #else 959 | #define HERALD " AT&T System V R4" 960 | #endif /* AMIX */ 961 | #endif /* i386 */ 962 | #else 963 | #ifdef SVR3 964 | #define HERALD " AT&T System V R3" 965 | #else 966 | #ifdef ATTSV 967 | #define HERALD " AT&T System III / System V" 968 | #else 969 | #ifdef BSD43 970 | #ifdef pdp11 971 | #define HERALD " 2.10 BSD PDP-11" 972 | #else 973 | #ifdef vax 974 | #define HERALD " 4.3 BSD VAX" 975 | #else 976 | #define HERALD " 4.3 BSD" 977 | #endif /* vax */ 978 | #endif /* pdp11 */ 979 | #else 980 | #ifdef BSD4 981 | #ifdef vax 982 | #define HERALD " 4.2 BSD VAX" 983 | #else 984 | #define HERALD " 4.2 BSD" 985 | #endif /* vax */ 986 | #else 987 | #ifdef V7 988 | #define HERALD " UNIX Version 7" 989 | #endif /* V7 */ 990 | #endif /* BSD4 */ 991 | #endif /* BSD43 */ 992 | #endif /* ATTSV */ 993 | #endif /* SVR3 */ 994 | #endif /* SVR4 */ 995 | #endif /* HERALD */ 996 | #endif /* HERALD */ 997 | 998 | #ifdef OS2 999 | #ifdef HERALD 1000 | #undef HERALD 1001 | #endif /* HERALD */ 1002 | #ifdef NT 1003 | #define HERALD " Windows" 1004 | #else /* NT */ 1005 | #define HERALD " 32-bit OS/2" 1006 | #endif /* NT */ 1007 | #endif /* OS/2 */ 1008 | 1009 | #ifndef HERALD 1010 | #define HERALD " Unknown Version" 1011 | #endif /* HERALD */ 1012 | 1013 | /* Hardware type */ 1014 | 1015 | #ifdef vax /* DEC VAX */ 1016 | #ifndef CKCPU 1017 | #define CKCPU "vax" 1018 | #endif /* CKCPU */ 1019 | #endif /* vax */ 1020 | #ifdef pdp11 /* DEC PDP-11 */ 1021 | #ifndef CKCPU 1022 | #define CKCPU "pdp11" 1023 | #endif /* CKCPU */ 1024 | #endif /* pdp11 */ 1025 | 1026 | #ifdef __ALPHA /* DEC Alpha */ 1027 | #ifndef CKCPU 1028 | #define CKCPU "Alpha" 1029 | #endif /* CKCPU */ 1030 | #endif /* __ALPHA */ 1031 | 1032 | #ifdef __alpha /* OSF/1 uses lowercase... */ 1033 | #ifndef CKCPU 1034 | #define CKCPU "Alpha" 1035 | #endif /* CKCPU */ 1036 | #endif /* __alpha */ 1037 | 1038 | #ifdef DGUX /* Override Motorola 88k assumption */ 1039 | #ifndef CKCPU /* New AViiONs are Intel based... */ 1040 | #ifdef i586 1041 | #define CKCPU "i586" 1042 | #else 1043 | #ifdef i486 1044 | #define CKCPU "i486" 1045 | #else 1046 | #ifdef i386 1047 | #define CKCPU "i386" 1048 | #endif /* i386 */ 1049 | #endif /* i486 */ 1050 | #endif /* i586 */ 1051 | #endif /* CKCPU */ 1052 | #endif /* DGUX */ 1053 | 1054 | /* HP 9000 */ 1055 | 1056 | #ifdef __hp9000s700 1057 | #ifndef CKCPU 1058 | #define CKCPU "hp9000s700" 1059 | #endif /* CKCPU */ 1060 | #endif /* __hp9000s700 */ 1061 | 1062 | #ifdef __hp9000s800 1063 | #ifndef CKCPU 1064 | #define CKCPU "hp9000s800" 1065 | #endif /* CKCPU */ 1066 | #endif /* __hp9000s800 */ 1067 | 1068 | #ifdef __hp9000s500 1069 | #ifndef CKCPU 1070 | #define CKCPU "hp9000s500" 1071 | #endif /* CKCPU */ 1072 | #endif /* __hp9000s500 */ 1073 | 1074 | #ifdef __hp9000s400 1075 | #ifndef CKCPU 1076 | #define CKCPU "hp9000s400" 1077 | #endif /* CKCPU */ 1078 | #endif /* __hp9000s400 */ 1079 | 1080 | #ifdef __hp9000s300 1081 | #ifndef CKCPU 1082 | #define CKCPU "hp9000s300" 1083 | #endif /* CKCPU */ 1084 | #endif /* __hp9000s300 */ 1085 | 1086 | #ifdef __hp9000s200 1087 | #ifndef CKCPU 1088 | #define CKCPU "hp9000s200" 1089 | #endif /* CKCPU */ 1090 | #endif /* __hp9000s200 */ 1091 | 1092 | #ifdef m88000 /* Motorola 88000 */ 1093 | #ifndef CKCPU 1094 | #define CKCPU "mc88000" 1095 | #endif /* CKCPU */ 1096 | #endif /* m88000 */ 1097 | #ifdef __using_M88KBCS /* DG symbol for Motorola 88000 */ 1098 | #ifndef CKCPU 1099 | #define CKCPU "mc88000" 1100 | #endif /* CKCPU */ 1101 | #endif /* __using_M88KBCS */ 1102 | #ifdef m88k /* Motorola symbol for 88000 */ 1103 | #ifndef CKCPU 1104 | #define CKCPU "mc88000" 1105 | #endif /* CKCPU */ 1106 | #endif /* m88k */ 1107 | #ifdef mc68040 /* Motorola 68040 */ 1108 | #ifndef CKCPU 1109 | #define CKCPU "mc68040" 1110 | #endif /* CKCPU */ 1111 | #endif /* mc68040 */ 1112 | #ifdef mc68030 /* Motorola 68030 */ 1113 | #ifndef CKCPU 1114 | #define CKCPU "mc68030" 1115 | #endif /* CKCPU */ 1116 | #endif /* mc68030 */ 1117 | #ifdef mc68020 /* Motorola 68020 */ 1118 | #ifndef CKCPU 1119 | #define CKCPU "mc68020" 1120 | #endif /* CKCPU */ 1121 | #endif /* mc68020 */ 1122 | #ifdef mc68010 /* Motorola 68010 */ 1123 | #ifndef CKCPU 1124 | #define CKCPU "mc68010" 1125 | #endif /* CKCPU */ 1126 | #endif /* mc68010 */ 1127 | #ifdef mc68000 /* Motorola 68000 */ 1128 | #ifndef CKCPU 1129 | #define CKCPU "mc68000" 1130 | #endif /* CKCPU */ 1131 | #endif /* mc68000 */ 1132 | #ifdef mc68k /* Ditto (used by DIAB DS90) */ 1133 | #ifndef CKCPU 1134 | #define CKCPU "mc68000" 1135 | #endif /* CKCPU */ 1136 | #endif /* mc68k */ 1137 | #ifdef m68 /* Ditto */ 1138 | #ifndef CKCPU 1139 | #define CKCPU "mc68000" 1140 | #endif /* CKCPU */ 1141 | #endif /* m68 */ 1142 | #ifdef m68k /* Ditto */ 1143 | #ifndef CKCPU 1144 | #define CKCPU "mc68000" 1145 | #endif /* CKCPU */ 1146 | #endif /* m68k */ 1147 | 1148 | #ifdef ia64 /* IA64 / Itanium */ 1149 | #ifndef CKCPU 1150 | #define CKCPU "ia64" 1151 | #endif /* CKCPU */ 1152 | #endif /* i686 */ 1153 | 1154 | #ifdef i686 /* Intel 80686 */ 1155 | #ifndef CKCPU 1156 | #define CKCPU "i686" 1157 | #endif /* CKCPU */ 1158 | #endif /* i686 */ 1159 | 1160 | #ifdef i586 /* Intel 80586 */ 1161 | #ifndef CKCPU 1162 | #define CKCPU "i586" 1163 | #endif /* CKCPU */ 1164 | #endif /* i586 */ 1165 | 1166 | #ifdef i486 /* Intel 80486 */ 1167 | #ifndef CKCPU 1168 | #define CKCPU "i486" 1169 | #endif /* CKCPU */ 1170 | #endif /* i80486 */ 1171 | #ifdef i386 /* Intel 80386 */ 1172 | #ifndef CKCPU 1173 | #define CKCPU "i386" 1174 | #endif /* CKCPU */ 1175 | #endif /* i80386 */ 1176 | #ifdef i286 /* Intel 80286 */ 1177 | #ifndef CKCPU 1178 | #define CKCPU "i286" 1179 | #endif /* CKCPU */ 1180 | #endif /* i286 */ 1181 | #ifdef i186 /* Intel 80186 */ 1182 | #ifndef CKCPU 1183 | #define CKCPU "i186" 1184 | #endif /* CKCPU */ 1185 | #endif /* i186 */ 1186 | #ifdef M_I586 /* Intel 80586 */ 1187 | #ifndef CKCPU 1188 | #define CKCPU "i586" 1189 | #endif /* CKCPU */ 1190 | #endif /* M_I586 */ 1191 | #ifdef M_I486 /* Intel 80486 */ 1192 | #ifndef CKCPU 1193 | #define CKCPU "i486" 1194 | #endif /* CKCPU */ 1195 | #endif /* M_I486 */ 1196 | #ifdef _M_I386 /* Intel 80386 */ 1197 | #ifndef CKCPU 1198 | #define CKCPU "i386" 1199 | #endif /* CKCPU */ 1200 | #endif /* _M_I386 */ 1201 | #ifdef M_I286 /* Intel 80286 */ 1202 | #ifndef CKCPU 1203 | #define CKCPU "i286" 1204 | #endif /* CKCPU */ 1205 | #endif /* M_I286 */ 1206 | #ifdef M_I86 /* Intel 80x86 */ 1207 | #ifndef CKCPU 1208 | #define CKCPU "ix86" 1209 | #endif /* CKCPU */ 1210 | #endif /* M_I86 */ 1211 | #ifdef sparc /* SUN SPARC */ 1212 | #ifndef CKCPU 1213 | #define CKCPU "sparc" 1214 | #endif /* CKCPU */ 1215 | #endif /* sparc */ 1216 | #ifdef mips /* MIPS RISC processor */ 1217 | #ifndef CKCPU 1218 | #define CKCPU "mips" 1219 | #endif /* CKCPU */ 1220 | #endif /* mips */ 1221 | #ifdef _IBMR2 /* IBM RS/6000 */ 1222 | #ifndef CKCPU /* (what do they call the chip?) */ 1223 | #define CKCPU "rs6000" 1224 | #endif /* CKCPU */ 1225 | #endif /* rs6000 */ 1226 | #ifdef u3b5 /* WE32000 MAC-32, AT&T 3Bx */ 1227 | #ifndef CKCPU 1228 | #define CKCPU "u3b5" 1229 | #endif /* CKCPU */ 1230 | #endif /* u3b5 */ 1231 | #ifdef n3b 1232 | #ifndef CKCPU 1233 | #define CKCPU "n3b" 1234 | #endif /* CKCPU */ 1235 | #endif /* n3b */ 1236 | #ifdef u3b 1237 | #ifndef CKCPU 1238 | #define CKCPU "u3b" 1239 | #endif /* CKCPU */ 1240 | #endif /* u3b */ 1241 | #ifdef n16 /* Encore Multimax */ 1242 | #ifndef CKCPU 1243 | #define CKCPU "n16" 1244 | #endif /* CKCPU */ 1245 | #endif /* n16 */ 1246 | #ifdef u370 /* IBM 370 */ 1247 | #ifndef CKCPU 1248 | #define CKCPU "u370" 1249 | #endif /* CKCPU */ 1250 | #endif /* u370 */ 1251 | #ifdef MAC /* Macintosh catch-all */ 1252 | #ifndef CKCPU 1253 | #define CKCPU "mc68000" 1254 | #endif /* CKCPU */ 1255 | #endif /* MAC */ 1256 | 1257 | #ifdef STRATUS 1258 | #ifndef CKCPU 1259 | #ifdef __I860__ 1260 | #define CKCPU "I860 Family" 1261 | #else 1262 | #ifdef __MC68K__ 1263 | #define CKCPU "MC680x0 Family" 1264 | #else 1265 | #define CKCPU "Stratus unknown processor" 1266 | #endif /* __MC68K__ */ 1267 | #endif /* __I860__ */ 1268 | #endif /* CKCPU */ 1269 | #endif /* STRATUS */ 1270 | 1271 | #ifdef COMMENT 1272 | #ifndef CKCPU /* All others */ 1273 | #define CKCPU "unknown" 1274 | #endif /* CKCPU */ 1275 | #endif /* COMMENT */ 1276 | 1277 | #endif /* CKUVER_H */ 1278 | -------------------------------------------------------------------------------- /ckuxla.h: -------------------------------------------------------------------------------- 1 | /* 2 | File CKUXLA.H 3 | 4 | C-Kermit language and character-set support for UNIX, VMS, OS/2, 5 | AOS/VS, and other systems. 6 | 7 | This file should be used as a template for the language support files 8 | for other C-Kermit implementations -- Macintosh, etc. 9 | */ 10 | /* 11 | Author: Frank da Cruz , 12 | Columbia University Academic Information Systems, New York City. 13 | 14 | Copyright (C) 1985, 2009, 15 | Trustees of Columbia University in the City of New York. 16 | All rights reserved. See the C-Kermit COPYING.TXT file or the 17 | copyright text in the ckcmai.c module for disclaimer and permissions. 18 | 19 | */ 20 | 21 | #ifndef CKUXLA_H 22 | #define CKUXLA_H 23 | 24 | /* Codes for file character sets */ 25 | 26 | /* ISO 646 and other ISO-646-like 7-bit sets */ 27 | 28 | #define FC_USASCII 0 /* US ASCII */ 29 | #define FC_UKASCII 1 /* United Kingdom ASCII */ 30 | #define FC_DUASCII 2 /* Dutch ISO 646 NRC */ 31 | #define FC_FIASCII 3 /* Finnish ISO 646 NRC */ 32 | #define FC_FRASCII 4 /* French ISO 646 NRC */ 33 | #define FC_FCASCII 5 /* French Canadian ISO 646 NRC */ 34 | #define FC_GEASCII 6 /* German ISO 646 NRC */ 35 | #define FC_HUASCII 7 /* Hungarian ISO 646 NRC */ 36 | #define FC_ITASCII 8 /* Italian *ISO 646 NRC */ 37 | #define FC_NOASCII 9 /* Norwegian and Danish ISO 646 NRC */ 38 | #define FC_POASCII 10 /* Portuguese ISO 646 NRC */ 39 | #define FC_SPASCII 11 /* Spanish ISO 646 NRC */ 40 | #define FC_SWASCII 12 /* Swedish ISO 646 NRC */ 41 | #define FC_CHASCII 13 /* Swiss ISO 646 NRC */ 42 | 43 | /* 8-bit Roman character sets */ 44 | 45 | #define FC_1LATIN 14 /* ISO 8859-1 Latin Alphabet 1 */ 46 | #define FC_2LATIN 15 /* ISO 8859-2 Latin Alphabet 2 */ 47 | #define FC_DECMCS 16 /* DEC Multinational Character Set */ 48 | #define FC_NEXT 17 /* NeXT workstation character set */ 49 | #define FC_CP437 18 /* IBM PC Code Page 437 */ 50 | #define FC_CP850 19 /* IBM PC Code Page 850 */ 51 | #define FC_CP852 20 /* IBM PC Code Page 852 */ 52 | #define FC_APPQD 21 /* Apple Quickdraw */ 53 | #define FC_DGMCS 22 /* Data General International Character Set */ 54 | #define FC_HPR8 23 /* HP Roman8 */ 55 | 56 | /* Cyrillic sets */ 57 | 58 | #define FC_CYRILL 24 /* ISO 8859-5 Latin/Cyrillic */ 59 | #define FC_CP866 25 /* PC Code Page 866 Cyrillic */ 60 | #define FC_KOI7 26 /* KOI-7 = Short KOI */ 61 | #define FC_KOI8 27 /* KOI-8 */ 62 | 63 | /* Japanese sets */ 64 | 65 | #define FC_JIS7 28 /* JIS-7 */ 66 | #define FC_SHJIS 29 /* Shifted JIS = CP932 */ 67 | #define FC_JEUC 30 /* Japanese EUC (JAE) */ 68 | #define FC_JDEC 31 /* Japanese DEC Kanji */ 69 | 70 | /* Hebrew sets */ 71 | 72 | #define FC_HE7 32 /* 7-Bit DEC Hebrew */ 73 | #define FC_HEBREW 33 /* 8-Bit ISO 8859-8 Latin/Hebrew */ 74 | #define FC_CP862 34 /* Hebrew PC Code Page */ 75 | 76 | /* Greek sets */ 77 | 78 | #define FC_ELOT 35 /* 7-Bit ELOT 927 Greek */ 79 | #define FC_GREEK 36 /* 8-Bit ISO 8859-7 Latin/Greek */ 80 | #define FC_CP869 37 /* Greek PC Code Page */ 81 | 82 | /* New Roman sets with Euro symbol */ 83 | 84 | #define FC_9LATIN 38 /* ISO 8859-15 Latin Alphabet 9 */ 85 | #define FC_CP923 38 /* Same as Latin-9 */ 86 | #define FC_CP858 39 /* Western Europe with Euro */ 87 | 88 | /* Other new additions */ 89 | 90 | #define FC_CP855 40 /* Cyrillic PC Code Page */ 91 | #define FC_CP1251 41 /* Cyrillic Windows */ 92 | #define FC_BULGAR 42 /* Bulgarian PC code page */ 93 | #define FC_CP1250 43 /* Latin 2 Windows (different from Latin-2)*/ 94 | #define FC_MAZOVIA 44 /* Polish Mazovia PC code page */ 95 | 96 | /* Unicode */ 97 | 98 | #define FC_UCS2 45 /* ISO-10646 / Unicode UCS-2 */ 99 | #define FC_UTF8 46 /* ISO-10646 / Unicode UTF-8 */ 100 | 101 | /* Recent additions */ 102 | 103 | #define FC_KOI8R 47 /* KOI8-R (RFC1489) - Russian + boxdrawing */ 104 | #define FC_KOI8U 48 /* KOI8-U (RFC2319) - Ukrainian + boxdrawing */ 105 | #define FC_CP1252 49 /* Latin 1 Windows */ 106 | 107 | #define MAXFCSETS 49 /* Highest file character set number */ 108 | 109 | #ifdef OS2 110 | #define FC_DECSPEC 253 /* Not real character-sets */ 111 | #define FC_DECTECH 252 112 | #endif /* OS2 */ 113 | 114 | #ifdef UNICODE 115 | _PROTOTYP( VOID initxlate, (int, int) ); 116 | #endif /* UNICODE */ 117 | 118 | #endif /* CKUXLA_H */ 119 | -------------------------------------------------------------------------------- /ckwart.c: -------------------------------------------------------------------------------- 1 | #include "ckcsym.h" 2 | char *wartv = "Wart Version 2.15, 18 September 2020 "; 3 | 4 | #define CKWART_C 5 | 6 | #ifdef MDEBUG 7 | /* Use the real ones in this module only */ 8 | #ifdef malloc 9 | #undef malloc 10 | #endif /* malloc */ 11 | #ifdef calloc 12 | #undef calloc 13 | #endif /* calloc */ 14 | #ifdef realloc 15 | #undef realloc 16 | #endif /* realloc */ 17 | #ifdef free 18 | #undef free 19 | #endif /* free */ 20 | #endif /* MDEBUG */ 21 | 22 | #ifdef MAC 23 | #define VOID void 24 | #endif /* MAC */ 25 | 26 | /* W A R T */ 27 | 28 | /* 29 | A small subset of "lex". 30 | 31 | Authors: Jeff Damens, Frank da Cruz 32 | Columbia University Center for Computing Activites. 33 | First released November 1984. 34 | Copyright (C) 1984, 2009, 35 | Trustees of Columbia University in the City of New York. 36 | All rights reserved. See the C-Kermit COPYING.TXT file or the 37 | copyright text in the ckcmai.c module for disclaimer and permissions. 38 | */ 39 | 40 | /* 41 | * input format is: 42 | * lines to be copied | %state 43 | * %% 44 | * | CHAR { actions } 45 | * ... 46 | * %% 47 | * more lines to be copied 48 | */ 49 | 50 | #include "ckcdeb.h" /* Includes */ 51 | 52 | #ifdef STRATUS 53 | /* Actually call printf, not our printf-catcher for Kermit */ 54 | #ifdef printf 55 | #undef printf 56 | #endif /* printf */ 57 | #ifdef fprintf 58 | #undef fprintf 59 | #endif /* fprintf */ 60 | #endif /* STRATUS */ 61 | 62 | #ifdef MAC 63 | /* Same deal for Macintosh */ 64 | #ifdef printf 65 | #undef printf 66 | #endif /* printf */ 67 | #ifdef fprintf 68 | #undef fprintf 69 | #endif /* fprintf */ 70 | #endif /* MAC */ 71 | 72 | #ifdef UNIX 73 | /* And UNIX */ 74 | #ifdef printf 75 | #undef printf 76 | #endif /* printf */ 77 | #ifdef fprintf 78 | #undef fprintf 79 | #endif /* fprintf */ 80 | #endif /* UNIX */ 81 | /* 82 | The following "char" should be changed to "short", "int", or "long" if your 83 | wart program will generate more than 127 states. Since wart is used mainly 84 | with C-Kermit, which has about 80 states, "char" is adequate. This keeps 85 | the program about 3K-4K smaller, which can be critical on 16-bit 86 | architectures. 87 | */ 88 | #ifdef IRIX60 89 | /* 90 | Also use short or int if your compiler complains inordinately about 91 | "integer conversion resulted in a change of sign"... 92 | */ 93 | #define TBL_TYPE "short" /* C data type of state table */ 94 | #else 95 | #define TBL_TYPE "char" /* C data type of state table */ 96 | #endif /* IRIX60 */ 97 | 98 | #define C_L 014 /* Formfeed */ 99 | 100 | #define SEP 1 /* Token types */ 101 | #define LBRACK 2 102 | #define RBRACK 3 103 | #define WORD 4 104 | #define COMMA 5 105 | 106 | /* Storage sizes */ 107 | 108 | #define MAXSTATES 50 /* max number of states */ 109 | #define MAXWORD 50 /* max # of chars/word */ 110 | #define SBYTES ((MAXSTATES+6)/8) /* # of bytes for state bitmask */ 111 | 112 | /* Name of wart function in generated program */ 113 | 114 | #ifndef FNAME 115 | #define FNAME "wart" 116 | #endif /* FNAME */ 117 | 118 | /* Structure for state information */ 119 | 120 | struct transx { 121 | CHAR states[SBYTES]; /* included states */ 122 | int anyst; /* true if this good from any state */ 123 | CHAR inchr; /* input character */ 124 | int actno; /* associated action */ 125 | struct transx *nxt; 126 | }; /* next transition */ 127 | typedef struct transx *trans; 128 | 129 | /* Function prototypes */ 130 | 131 | _PROTOTYP( VOID setwstate, (int, trans) ); 132 | _PROTOTYP( int teststate, (int, trans) ); 133 | _PROTOTYP( trans rdinput, (FILE *, FILE *) ); 134 | _PROTOTYP( VOID initial, (FILE *, FILE *) ); 135 | _PROTOTYP( int isin, (char *, int) ); 136 | _PROTOTYP( int isword, (int) ); 137 | _PROTOTYP( VOID rdword, (FILE *, char *) ); 138 | _PROTOTYP( VOID rdstates, (FILE *, FILE *) ); 139 | _PROTOTYP( trans newtrans, (void) ); 140 | _PROTOTYP( trans rdrules, (FILE *, FILE *) ); 141 | _PROTOTYP( VOID statelist, (FILE *, trans) ); 142 | _PROTOTYP( VOID copyact, (FILE *, FILE *, int) ); 143 | _PROTOTYP( int faction, (trans, int, int) ); 144 | _PROTOTYP( VOID emptytbl, (void) ); 145 | _PROTOTYP( VOID addaction, (int, int, int) ); 146 | _PROTOTYP( VOID writetbl, (FILE *) ); 147 | _PROTOTYP( VOID warray, (FILE *, char *, int [], int, char *) ); 148 | _PROTOTYP( VOID prolog, (FILE *) ); 149 | _PROTOTYP( VOID epilogue, (FILE *) ); 150 | _PROTOTYP( VOID copyrest, (FILE *, FILE *) ); 151 | _PROTOTYP( int gettoken, (FILE *) ); 152 | _PROTOTYP( VOID rdcmnt, (FILE *) ); 153 | _PROTOTYP( VOID clrhash, (void) ); 154 | _PROTOTYP( int hash, (char *) ); 155 | _PROTOTYP( VOID enter, (char *, int) ); 156 | _PROTOTYP( int lkup, (char *) ); 157 | _PROTOTYP( static char* copy, (char *s) ); 158 | 159 | /* Variables and tables */ 160 | 161 | /* lt 1992-10-08 Begin 162 | * provide definition for deblog variable 163 | * ckcdeb.h declares as extern. DECC AXP is strict about ref/def model 164 | * Variable is unused herein, to the best of my knowledge. 165 | */ 166 | #ifdef VMS 167 | int deblog; 168 | #endif /* VMS */ 169 | /* lt 1992-10-08 End 170 | */ 171 | 172 | static int lines, nstates, nacts; 173 | 174 | static char tokval[MAXWORD]; 175 | 176 | static int tbl[MAXSTATES*96]; 177 | 178 | char *tbl_type = TBL_TYPE; 179 | 180 | char *txt1 = "\n#define BEGIN state =\n\nint state = 0;\n\nint\n"; 181 | 182 | char *fname = FNAME; /* Generated function name goes here */ 183 | 184 | /* rest of program... */ 185 | 186 | char *txt2 = "()\n\ 187 | {\n\ 188 | int c,actno;\n\ 189 | extern "; 190 | 191 | /* Data type of state table is inserted here (short or int) */ 192 | 193 | char *txt2a = 194 | " tbl[];\n\ 195 | while (1) {\n\ 196 | c = input() - 32;\n\ 197 | debug(F000,\"PROTO input\",ckitoa(state),c+32);\n\ 198 | if (c < 0 || c > 95) c = 0;\n"; 199 | 200 | char *txt2b = " if ((actno = tbl[c + state*96]) != -1)\n\ 201 | switch(actno) {\n"; 202 | 203 | /* this program's output goes here, followed by final text... */ 204 | 205 | char *txt3 = "\n }\n }\n}\n\n"; 206 | 207 | 208 | /* 209 | * turn on the bit associated with the given state 210 | * 211 | */ 212 | VOID 213 | setwstate(state,t) int state; trans t; { 214 | int idx,msk; 215 | idx = state/8; /* byte associated with state */ 216 | msk = 0x80 >> (state % 8); /* bit mask for state */ 217 | t->states[idx] |= msk; 218 | } 219 | 220 | /* 221 | * see if the state is involved in the transition 222 | * 223 | */ 224 | int 225 | teststate(state,t) int state; trans t; { 226 | int idx,msk; 227 | idx = state/8; 228 | msk = 0x80 >> (state % 8); 229 | return(t->states[idx] & msk); 230 | } 231 | 232 | 233 | /* 234 | * read input from here... 235 | * 236 | */ 237 | 238 | trans 239 | rdinput(infp,outfp) FILE *infp,*outfp; { 240 | trans x; 241 | lines = 1; /* line counter */ 242 | nstates = 0; /* no states */ 243 | nacts = 0; /* no actions yet */ 244 | fprintf(outfp,"\n%c* WARNING -- This C source program generated by ",'/'); 245 | fprintf(outfp,"Wart preprocessor. */\n"); 246 | fprintf(outfp,"%c* Do not edit this file; edit the Wart-format ",'/'); 247 | fprintf(outfp,"source file instead, */\n"); 248 | fprintf(outfp,"%c* and then run it through Wart to produce a new ",'/'); 249 | fprintf(outfp,"C source file. */\n\n"); 250 | fprintf(outfp,"%c* Wart Version Info: */\n",'/'); 251 | fprintf(outfp,"char *wartv = \"%s\";\n\n",wartv); 252 | 253 | initial(infp,outfp); /* read state names, initial defs */ 254 | prolog(outfp); /* write out our initial code */ 255 | x = rdrules(infp,outfp); /* read rules */ 256 | epilogue(outfp); /* write out epilogue code */ 257 | return(x); 258 | } 259 | 260 | 261 | /* 262 | * initial - read initial definitions and state names. Returns 263 | * on EOF or %%. 264 | * 265 | */ 266 | VOID 267 | initial(infp,outfp) FILE *infp, *outfp; { 268 | int c; 269 | char wordbuf[MAXWORD]; 270 | while ((c = getc(infp)) != EOF) { 271 | if (c == '%') { 272 | rdword(infp,wordbuf); 273 | if (strcmp(wordbuf,"states") == 0) 274 | rdstates(infp,outfp); 275 | else if (strcmp(wordbuf,"%") == 0) return; 276 | else fprintf(outfp,"%%%s",wordbuf); 277 | } 278 | else putc(c,outfp); 279 | if (c == '\n') lines++; 280 | } 281 | } 282 | 283 | /* 284 | * boolean function to tell if the given character can be part of 285 | * a word. 286 | * 287 | */ 288 | int 289 | isin(s,c) char *s; int c; { 290 | for (; *s != '\0'; s++) 291 | if (*s == (char) c) return(1); 292 | return(0); 293 | } 294 | int 295 | isword(c) int c; { 296 | static char special[] = ".%_-$@"; /* these are allowable */ 297 | return(isalnum(c) || isin(special,c)); 298 | } 299 | 300 | /* 301 | * read the next word into the given buffer. 302 | * 303 | */ 304 | VOID 305 | rdword(fp,buf) FILE *fp; char *buf; { 306 | int len = 0,c; 307 | while (isword(c = getc(fp)) && ++len < MAXWORD) *buf++ = (char) c; 308 | *buf++ = '\0'; /* tie off word */ 309 | ungetc(c,fp); /* put break char back */ 310 | } 311 | 312 | /* 313 | * read state names, up to a newline. 314 | * 315 | */ 316 | VOID 317 | rdstates(fp,ofp) FILE *fp,*ofp; { 318 | int c; 319 | char wordbuf[MAXWORD]; 320 | while ((c = getc(fp)) != EOF && c != '\n') { 321 | if (isspace(c) || c == C_L) continue; /* skip whitespace */ 322 | ungetc(c,fp); /* put char back */ 323 | rdword(fp,wordbuf); /* read the whole word */ 324 | enter(wordbuf,++nstates); /* put into symbol tbl */ 325 | fprintf(ofp,"#define %s %d\n",wordbuf,nstates); 326 | } 327 | lines++; 328 | } 329 | 330 | /* 331 | * allocate a new, empty transition node 332 | * 333 | */ 334 | trans 335 | newtrans() { 336 | trans new; 337 | int i; 338 | new = (trans) malloc(sizeof (struct transx)); 339 | for (i=0; istates[i] = 0; 340 | new->anyst = 0; 341 | new->nxt = NULL; 342 | return(new); 343 | } 344 | 345 | 346 | /* 347 | * read all the rules. 348 | * 349 | */ 350 | 351 | trans 352 | rdrules(fp,out) FILE *fp,*out; { 353 | trans head,cur,prev; 354 | int curtok; 355 | head = cur = prev = NULL; 356 | while ((curtok = gettoken(fp)) != SEP) 357 | 358 | switch(curtok) { 359 | case LBRACK: 360 | if (cur == NULL) 361 | cur = newtrans(); 362 | else 363 | fatal("duplicate state list"); 364 | statelist(fp,cur); /* set states */ 365 | continue; /* prepare to read char */ 366 | 367 | case WORD: 368 | if ((int)strlen(tokval) != 1) 369 | fatal("multiple chars in state"); 370 | if (cur == NULL) { 371 | cur = newtrans(); 372 | cur->anyst = 1; 373 | } 374 | cur->actno = ++nacts; 375 | cur->inchr = (char) (tokval[0] - 32); 376 | if (head == NULL) 377 | head = cur; 378 | else 379 | prev->nxt = cur; 380 | prev = cur; 381 | cur = NULL; 382 | copyact(fp,out,nacts); 383 | break; 384 | default: fatal("bad input format"); 385 | } 386 | return(head); 387 | } 388 | 389 | /* 390 | * read a list of (comma-separated) states, set them in the 391 | * given transition. 392 | * 393 | */ 394 | VOID 395 | statelist(fp,t) FILE *fp; trans t; { 396 | int curtok,sval; 397 | curtok = COMMA; 398 | while (curtok != RBRACK) { 399 | if (curtok != COMMA) fatal("missing comma"); 400 | if ((curtok = gettoken(fp)) != WORD) fatal("missing state name"); 401 | if ((sval = lkup(tokval)) == -1) { 402 | fprintf(stderr,"state %s undefined\n",tokval); 403 | fatal("undefined state"); 404 | } 405 | setwstate(sval,t); 406 | curtok = gettoken(fp); 407 | } 408 | } 409 | 410 | /* 411 | * copy an action from the input to the output file 412 | * 413 | */ 414 | VOID 415 | copyact(inp,outp,actno) FILE *inp,*outp; int actno; { 416 | int c,bcnt; 417 | fprintf(outp,"case %d:\n",actno); 418 | while (c = getc(inp), (isspace(c) || c == C_L)) 419 | if (c == '\n') lines++; 420 | if (c == '{') { 421 | bcnt = 1; 422 | fputs(" {",outp); 423 | while (bcnt > 0 && (c = getc(inp)) != EOF) { 424 | if (c == '{') bcnt++; 425 | else if (c == '}') bcnt--; 426 | else if (c == '\n') lines++; 427 | putc(c,outp); 428 | } 429 | if (bcnt > 0) fatal("action doesn't end"); 430 | } else { 431 | while (c != '\n' && c != EOF) { 432 | putc(c,outp); 433 | c = getc(inp); 434 | } 435 | lines++; 436 | } 437 | fprintf(outp,"\n break;\n"); 438 | } 439 | 440 | /* 441 | * find the action associated with a given character and state. 442 | * returns -1 if one can't be found. 443 | * 444 | */ 445 | int 446 | faction(hd,state,chr) trans hd; int state,chr; { 447 | while (hd != NULL) { 448 | if (hd->anyst || teststate(state,hd)) 449 | if (hd->inchr == ('.' - 32) || hd->inchr == (char) chr) 450 | return(hd->actno); 451 | hd = hd->nxt; 452 | } 453 | return(-1); 454 | } 455 | 456 | /* 457 | * empty the table... 458 | * 459 | */ 460 | VOID 461 | emptytbl() { 462 | int i; 463 | for (i=0; i 1) { 512 | if ((infile = fopen(argv[1],"r")) == NULL) { 513 | fprintf(stderr,"Can't open %s\n",argv[1]); 514 | fatal("unreadable input file"); 515 | } 516 | } else infile = stdin; 517 | 518 | if (argc > 2) { 519 | if ((outfile = fopen(argv[2],"w")) == NULL) { 520 | fprintf(stderr,"Can't write to %s\n",argv[2]); 521 | fatal("bad output file"); 522 | } 523 | } else outfile = stdout; 524 | 525 | clrhash(); /* empty hash table */ 526 | head = rdinput(infile,outfile); /* read input file */ 527 | emptytbl(); /* empty our tables */ 528 | for (state = 0; state <= nstates; state++) 529 | for (c = 1; c < 96; c++) /* find actions, */ 530 | addaction(faction(head,state,c),state,c); /* add to tbl */ 531 | writetbl(outfile); 532 | copyrest(infile,outfile); 533 | printf("%d states, %d actions\n",nstates,nacts); 534 | exit(GOOD_EXIT); 535 | } 536 | 537 | 538 | /* 539 | * fatal error handler 540 | * 541 | */ 542 | 543 | VOID 544 | fatal(msg) char *msg; { 545 | fprintf(stderr,"error in line %d: %s\n",lines,msg); 546 | exit(BAD_EXIT); 547 | } 548 | 549 | VOID 550 | prolog(outfp) FILE *outfp; { 551 | int c; 552 | while ((c = *txt1++) != '\0') putc(c,outfp); 553 | while ((c = *fname++) != '\0') putc(c,outfp); 554 | while ((c = *txt2++) != '\0') putc(c,outfp); 555 | while ((c = *tbl_type++) != '\0') putc(c,outfp); 556 | while ((c = *txt2a++) != '\0') putc(c,outfp); 557 | while ((c = *txt2b++) != '\0') putc(c,outfp); 558 | } 559 | 560 | VOID 561 | epilogue(outfp) FILE *outfp; { 562 | int c; 563 | while ((c = *txt3++) != '\0') putc(c,outfp); 564 | } 565 | 566 | VOID 567 | copyrest(in,out) FILE *in,*out; { 568 | int c; 569 | while ((c = getc(in)) != EOF) putc(c,out); 570 | } 571 | 572 | /* 573 | * gettoken - returns token type of next token, sets tokval 574 | * to the string value of the token if appropriate. 575 | * 576 | */ 577 | 578 | int 579 | gettoken(fp) FILE *fp; { 580 | int c; 581 | while (1) { /* loop if reading comments... */ 582 | do { 583 | c = getc(fp); 584 | if (c == '\n') lines++; 585 | } while ((isspace(c) || c == C_L)); /* skip whitespace */ 586 | switch(c) { 587 | case EOF: 588 | return(SEP); 589 | case '%': 590 | if ((c = getc(fp)) == '%') return(SEP); 591 | tokval[0] = '%'; 592 | tokval[1] = (char) c; 593 | rdword(fp,tokval+2); 594 | return(WORD); 595 | case '<': 596 | return(LBRACK); 597 | case '>': 598 | return(RBRACK); 599 | case ',': 600 | return(COMMA); 601 | case '/': 602 | if ((c = getc(fp)) == '*') { 603 | rdcmnt(fp); /* skip over the comment */ 604 | continue; 605 | } else { /* and keep looping */ 606 | ungetc(c,fp); /* put this back into input */ 607 | c = '/'; /* put character back, fall thru */ 608 | } 609 | 610 | default: 611 | if (isword(c)) { 612 | ungetc(c,fp); 613 | rdword(fp,tokval); 614 | return(WORD); 615 | } else fatal("Invalid character in input"); 616 | } 617 | } 618 | } 619 | 620 | /* 621 | * skip over a comment 622 | * 623 | */ 624 | 625 | VOID 626 | rdcmnt(fp) FILE *fp; { 627 | int c,star,prcnt; 628 | prcnt = star = 0; /* no star seen yet */ 629 | while (!((c = getc(fp)) == '/' && star)) { 630 | if (c == EOF || (prcnt && c == '%')) fatal("Unterminated comment"); 631 | prcnt = (c == '%'); 632 | star = (c == '*'); 633 | if (c == '\n') lines++; 634 | } 635 | } 636 | 637 | /* 638 | * symbol table management for wart 639 | * 640 | * entry points: 641 | * clrhash - empty hash table. 642 | * enter - enter a name into the symbol table 643 | * lkup - find a name's value in the symbol table. 644 | * 645 | */ 646 | 647 | #define HASHSIZE 101 /* # of entries in hash table */ 648 | 649 | struct sym { 650 | char *name; /* symbol name */ 651 | int val; /* value */ 652 | struct sym *hnxt; /* next on collision chain */ 653 | } *htab[HASHSIZE]; /* the hash table */ 654 | 655 | /* 656 | * empty the hash table before using it... 657 | * 658 | */ 659 | VOID 660 | clrhash() { 661 | int i; 662 | for (i=0; iname = copy(name); 705 | cur->val = svalue; 706 | cur->hnxt = htab[h]; 707 | htab[h] = cur; 708 | } 709 | 710 | /* 711 | * find name in the symbol table, return its value. Returns -1 712 | * if not found. 713 | * 714 | */ 715 | int 716 | lkup(name) char *name; { 717 | struct sym *cur; 718 | for (cur = htab[hash(name)]; cur != NULL; cur = cur->hnxt) 719 | if (strcmp(cur->name,name) == 0) return(cur->val); 720 | return(-1); 721 | } 722 | --------------------------------------------------------------------------------