+ File lengths and offsets. This section is expected to grow as we
+ support long files on 32-bit platforms. We want this data type to be
+ signed because so many functions return either a file size or a negative
+ value to indicate an error.
+*/
+#ifndef CK_OFF_T
+#ifdef OS2
+#ifdef NT
+#define CK_OFF_T __int64
+#else
+#define CK_OFF_T long
+#endif /* NT */
+#endif /* OS2 */
+#endif /* CK_OFF_T */
+
+/* FreeBSD and OpenBSD set off_t to the appropriate size unconditionally */
+
+#ifndef CK_OFF_T
+#ifdef __FreeBSD__
+#define CK_OFF_T off_t
+#else
+#ifdef __OpenBSD__
+#define CK_OFF_T off_t
+#endif /* __OpenBSD__ */
+#endif /* __FreeBSD__ */
+#endif /* CK_OFF_T */
+
+/* 32-bit platforms that support long files thru "transitional interface" */
+/* These include Linux, Solaris, NetBSD... */
+
+#ifdef AIXRS
+#ifdef _LARGE_FILES
+#ifndef CK_OFF_T
+#define CK_OFF_T off_t
+#endif /* CK_OFF_T */
+#endif /* _LARGE_FILES */
+#endif /* AIXRS */
+
+#ifdef _LARGEFILE_SOURCE
+#ifndef CK_OFF_T
+#define CK_OFF_T off_t
+#endif /* CK_OFF_T */
+#ifdef IRIX
+#define CKFSEEK(a,b,c) fseek64(a,b,c)
+#define CKFTELL(a) ftell64(a)
+#else /* IRIX */
+#define CKFSEEK(a,b,c) fseeko(a,b,c)
+#define CKFTELL(a) ftello(a)
+#endif /* IRIX */
+#else /* Not _LARGEFILE_SOURCE */
+#define CKFSEEK(a,b,c) fseek(a,b,c)
+#define CKFTELL(a) ftell(a)
+/* See below the next section for the catch-all case */
+#endif /* _LARGEFILE_SOURCE */
+
+/* 32-bit or 64-bit platforms */
+
+/* CK_64BIT is a compile-time symbol indicating a true 64-bit build */
+/* meaning that longs and pointers are 64 bits */
+
+#ifndef VMS /* VMS Alpha and IA64 are 32-bit! */
+#ifndef CK_64BIT
+#ifdef _LP64 /* Solaris */
+#define CK_64BIT
+#else
+#ifdef __LP64__ /* MacOS X 10.4 (or _LP64,__ppc64__) */
+#define CK_64BIT
+#else
+#ifdef __arch64__ /* gcc alpha, sparc */
+#define CK_64BIT
+#else
+#ifdef __alpha /* Alpha decc (or __ALPHA) */
+#define CK_64BIT
+#else
+#ifdef __amd64 /* AMD x86_64 (or __x86_64) */
+#define CK_64BIT
+#else
+#ifdef __ia64 /* Intel IA64 */
+#ifndef HPUX
+#define CK_64BIT
+#endif /* HPUX */
+#endif /* __ia64 */
+#endif /* __amd64 */
+#endif /* __alpha */
+#endif /* __arch64__ */
+#endif /* __LP64__ */
+#endif /* _LP64 */
+#endif /* CK_64BIT */
+#endif /* VMS */
+
+#ifndef CK_OFF_T
+#ifdef CK_64BIT
+#define CK_OFF_T off_t /* This has to be signed */
+#else /* CK_64BIT */
+#define CK_OFF_T long /* Signed */
+#endif /* CK_64BIT */
+#endif /* CK_OFF_T */
+
+#ifndef TLOG
+#define tlog(a,b,c,d)
+#else
+#ifndef CKCMAI
+/* Debugging included. Declare debug log flag in main program only. */
+extern int tralog, tlogfmt;
+#endif /* CKCMAI */
+_PROTOTYP(VOID dotlog,(int, char *, char *, CK_OFF_T));
+#define tlog(a,b,c,d) if (tralog && tlogfmt) dotlog(a,b,c,(CK_OFF_T)d)
+_PROTOTYP(VOID doxlog,(int, char *, CK_OFF_T, int, int, char *));
+#endif /* TLOG */
+
+#ifndef DEBUG
+/* Compile all the debug() statements away. Saves a lot of space and time. */
+#define debug(a,b,c,d)
+#define ckhexdump(a,b,c)
+/* Now define the debug() macro. */
+#else /* DEBUG */
+_PROTOTYP(int dodebug,(int,char *,char *,CK_OFF_T));
+_PROTOTYP(int dohexdump,(CHAR *,CHAR *,int));
+#ifdef IFDEBUG
+/* Use this form to avoid function calls: */
+#ifdef COMMENT
+#define debug(a,b,c,d) if (deblog) dodebug(a,b,(char *)(c),(CK_OFF_T)(d))
+#define ckhexdump(a,b,c) if (deblog) dohexdump((CHAR *)(a),(CHAR *)(b),c)
+#else
+#ifdef CK_ANSIC
+#define debug(a,b,c,d) \
+((void)(deblog?dodebug(a,b,(char *)(c),(CK_OFF_T)(d)):0))
+#define ckhexdump(a,b,c) \
+((void)(deblog?dohexdump((CHAR *)(a),(CHAR *)(b),c):0))
+#else
+#define debug(a,b,c,d) (deblog?dodebug(a,b,(char *)(c),(CK_OFF_T)(d)):0)
+#define ckhexdump(a,b,c) (deblog?dohexdump((CHAR *)(a),(CHAR *)(b),c):0)
+#endif /* CK_ANSIC */
+#endif /* COMMENT */
+#else /* IFDEBUG */
+/* Use this form to save space: */
+#define debug(a,b,c,d) dodebug(a,b,(char *)(c),(CK_OFF_T)(d))
+#define ckhexdump(a,b,c) dohexdump((CHAR *)(a),(CHAR *)(b),c)
+#endif /* IFDEBUG */
+#endif /* DEBUG */
+
+
+/* Structure definitions for Kermit file attributes */
+/* All strings come as pointer and length combinations */
+/* Empty string (or for numeric variables, -1) = unused attribute. */
+
+struct zstr { /* string format */
+ int len; /* length */
+ char *val; /* value */
+};
+
+struct zattr { /* Kermit File Attribute structure */
+ CK_OFF_T lengthk; /* (!) file length in K */
+ struct zstr type; /* (") file type (text or binary) */
+ struct zstr date; /* (#) file creation date yyyymmdd[ hh:mm[:ss]] */
+ struct zstr creator; /* ($) file creator id */
+ struct zstr account; /* (%) file account */
+ struct zstr area; /* (&) area (e.g. directory) for file */
+ struct zstr password; /* (') password for area */
+ long blksize; /* (() file blocksize */
+ struct zstr xaccess; /* ()) file access: new, supersede, append, warn */
+ struct zstr encoding; /* (*) encoding (transfer syntax) */
+ struct zstr disp; /* (+) disposition (mail, message, print, etc) */
+ struct zstr lprotect; /* (,) protection (local syntax) */
+ struct zstr gprotect; /* (-) protection (generic syntax) */
+ struct zstr systemid; /* (.) ID for system of origin */
+ struct zstr recfm; /* (/) record format */
+ struct zstr sysparam; /* (0) system-dependent parameter string */
+ CK_OFF_T length; /* (1) exact length on system of origin */
+ struct zstr charset; /* (2) transfer syntax character set */
+#ifdef OS2
+ struct zstr longname; /* OS/2 longname if applicable */
+#endif /* OS2 */
+ struct zstr reply; /* This goes last, used for attribute reply */
+};
+
+/* Kermit file information structure */
+
+struct filinfo {
+ int bs; /* Blocksize */
+ int cs; /* Character set */
+ long rl; /* Record length */
+ int org; /* Organization */
+ int fmt; /* Record format */
+ int cc; /* Carriage control */
+ int typ; /* Type (text/binary) */
+ int dsp; /* Disposition */
+ char *os_specific; /* OS-specific attributes */
+#ifdef OS2
+ unsigned long int lblopts; /* LABELED FILE options bitmask */
+#else
+ int lblopts;
+#endif /* OS2 */
+};
+
+
+/*