home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / c-kermit / ckmdef.h < prev    next >
C/C++ Source or Header  |  2020-01-01  |  12KB  |  439 lines

  1. /* $Id: ckmdef.h,v 1.6 91/12/15 23:16:54 rick Exp $
  2.  * $Source: /uw/mackermit/RCS/ckmdef.h,v $
  3.  *------------------------------------------------------------------
  4.  * $Log:    ckmdef.h,v $
  5.  * Revision 1.6  91/12/15  23:16:54  rick
  6.  * ut9
  7.  * 
  8.  * Revision 1.5  91/10/01  12:16:25  rick
  9.  * UT(5)
  10.  * 
  11.  * Revision 1.4  91/09/25  12:16:52  rick
  12.  * Command window in TE. Multiple vt100 windows for command window.
  13.  * 
  14.  * Revision 1.3  91/09/12  21:50:38  rick
  15.  * UT(3). Install on watsun
  16.  * 
  17.  * Revision 1.2  1991/09/10  22:21:40  rick
  18.  * Update to UTexas(2)
  19.  *
  20.  * Revision 1.1  1991/09/10  19:17:50  rick
  21.  * Initial revision
  22.  *
  23.  *------------------------------------------------------------------
  24.  * $Endlog$
  25.  */
  26. /*
  27.   Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New
  28.   York.  Permission is granted to any individual or institution to use this
  29.   software as long as it is not sold for profit.  This copyright notice must be
  30.   retained.  This software may not be included in commercial products without
  31.   written permission of Columbia University.
  32. */
  33. /* Version 0.8(35) - Jim Noble at Planning Research Corporation, June 1987. */
  34. /* Ported to Megamax native Macintosh C compiler. */
  35.  
  36. #ifdef MPW
  37.  
  38. /**** includes for MPW 3.0 ****/
  39. #include <Controls.h>
  40. #include <Desk.h>
  41. #include <Devices.h>
  42. #include <Dialogs.h>
  43. #include <Errors.h>
  44. #include <Events.h>
  45. #include <Files.h>
  46. #include <Fonts.h>
  47. #include <Memory.h>
  48. #include <Menus.h>
  49. #include <OSEvents.h>
  50. #include <OSUtils.h>
  51. #include <Packages.h>
  52. #include <Printing.h>
  53. #include <QuickDraw.h>
  54. #include <Resources.h>
  55. #include <Scrap.h>
  56. #include <Script.h>
  57. #include <Segload.h>
  58. #include <Serial.h>
  59. #include <Strings.h>
  60. #include <SysEqu.h>
  61. #include <TextEdit.h>
  62. #include <ToolUtils.h>
  63. #include <Traps.h>
  64. #include <Windows.h>
  65.  
  66. #include <ctype.h>
  67.  
  68. #ifdef MPW2
  69. /****************************************************************************/
  70. pascal void
  71. Debugger ()
  72. /****************************************************************************/
  73. extern 0xA9FF;            /* invoke MacsBug */
  74. #endif /* MPW2 */
  75.  
  76. #ifdef PROFILE
  77. #include <Perf.h>
  78. TP2PerfGlobals ThePGlobals = nil;
  79. #endif /* PROFILE */
  80.  
  81. #define NULL            0
  82.  
  83. #else /* MPW */
  84.  
  85. /**** includes for THINK C ****/
  86. #ifdef COMMENT
  87. #include <Controls.h>
  88. #include <Desk.h>
  89. #include <Devices.h>
  90. #include <Dialogs.h>
  91. #include <Errors.h>
  92. #include <Events.h>
  93. #include <Files.h>
  94. #include <Fonts.h>
  95. #include <Memory.h>
  96. #include <Menus.h>
  97. #include <OSEvents.h>
  98. #include <OSUtils.h>
  99. #include <Packages.h>
  100. #include <Printing.h>
  101. #include <QuickDraw.h>
  102. #include <Resources.h>
  103. #include <Scrap.h>
  104. #include <Script.h>
  105. #include <Segload.h>
  106. #include <Serial.h>
  107. #include <String.h>
  108. #include <SysEqu.h>
  109. #include <TextEdit.h>
  110. #include <ToolUtils.h>
  111. #include <Traps.h>
  112. #include <Windows.h>
  113. #endif /* COMMENT */
  114.  
  115. #include <Script.h>
  116. #include <Serial.h>
  117. #include <Printing.h>
  118.  
  119. /* #include <asm.h> */
  120. /* #include <pascal.h> */
  121.  
  122. #include <ctype.h>
  123.  
  124. /* pascal void Debugger(...) = { 0xA9FF }; */
  125.  
  126. #endif /* MPW */
  127.  
  128. /* Symbol Definitions */
  129.  
  130. #define TRUE      1        /* Boolean constants */
  131. #define FALSE     0
  132. #define NIL                0
  133. #define NILPTR        (Ptr) NIL
  134. #define NILPROC        (ProcPtr) NIL
  135. #define ALLTYPES -1        /* All types for SFGetFile */
  136.  
  137. #define MYBUFSIZE   8192    /* Serial driver replacement buffer (was 2048) */
  138.  
  139. #define OKBtn    ok        /* OK and Cancel constants */
  140. #define QuitBtn    cancel        /* Defined by Dialog Mgr */
  141.  
  142. #define btnOff    0
  143. #define btnOn    1
  144.  
  145. #define getctlhdl(item,dp) (ControlHandle) gethdl(item,dp)
  146.  
  147. #define ApplCreator 'KR09'
  148.  
  149. /* settings for parity */
  150.  
  151. #define MPARITY_ODD (oddParity+stop10+data7)
  152. #define MPARITY_EVEN (evenParity+stop10+data7)
  153. #define MPARITY_MARK (noParity+stop20+data7)
  154. #define MPARITY_SPACE (noParity+stop10+data8)
  155. #define MPARITY_NONE (noParity+stop10+data8)
  156.  
  157. #define KPARITY_ODD 'o'
  158. #define KPARITY_EVEN 'e'
  159. #define KPARITY_MARK 'm'
  160. #define KPARITY_SPACE 's'
  161. #define KPARITY_NONE 0
  162.  
  163. typedef struct {        /* file arguments since Kermit */
  164.     char fillcl[64], filrem[64];/* doesn't pass all the info */
  165.     int filflg;            /* we need... */
  166.     int fildflg;        /* default flags */
  167.     short filvol;        /* file volume */
  168.     int filfldr;        /* file folder for new files */
  169.     long filsiz;        /* size of file after open */
  170.     long rsrcsiz;        /* size of resource fork (for MacBinary fmt) */
  171. }   FILINF;
  172.  
  173.  
  174. /* Flags in filflg, fildflg */
  175.  
  176. #define FIL_BINA     1
  177. #define FIL_TEXT     2
  178. #define FIL_RSRC     4
  179. #define FIL_DATA     8
  180. #define FIL_OKILL 16        /* same as kermit's !warn */
  181. #define FIL_DODLG 32        /* show dialogs on recv */
  182. #define FIL_ALLFL 64        /* send all files from the curr folder */
  183.  
  184. #define FIL_RBDT (FIL_RSRC | FIL_BINA | FIL_DATA | FIL_TEXT)
  185.  
  186. /* (PWP) MacBinary is selected when both FIL_RSRC and FIL_DATA are selected */
  187.  
  188. /* MacBinary format is the following header, the data fork (padded to 128),
  189.    and the resource fork (padded to 128) */
  190. /* MacBinary header structure (lifted from NCSA Telnet 2.2) */
  191. typedef struct MBHead {        /* MacBinary Header */
  192.     char zero1;
  193.     char name[64];
  194.     char type[4];
  195.     char creator[4];
  196.     char flags;
  197.     char zero2;
  198.     char location[6];
  199.     char protected;
  200.     char zero3;
  201.     char dflen[4];
  202.     char rflen[4];
  203.     char cdate[4];
  204.     char mdate[4];
  205.     char filler[27];
  206.     char typeid[2];
  207. } MBHead;
  208.  
  209.  
  210. /* type definitions for keyboard macro structures */
  211. typedef struct {
  212.     short code;            /* key and modification code for this
  213.                  * keymacro */
  214.     char flags;            /* flags for this key macro definition */
  215.     char len;            /* length of the macro string in bytes */
  216.     long macro;            /* if len <=4 contains the macrostring else */
  217. }   macrorec;            /* it contains a pointer to the macrostring */
  218.  
  219. #define shortBreak    1    /* flag for short break */
  220. #define longBreak    2    /* flag for long break */
  221.  
  222. #define leftArrowKey    3    /* send left arrow */
  223. #define rightArrowKey    4    /* send right arrow */
  224. #define upArrowKey    5
  225. #define downArrowKey    6
  226.  
  227. #define keypf1        7
  228. #define keypf2        8
  229. #define keypf3        9
  230. #define keypf4        10
  231.  
  232. #define keycomma    11
  233. #define keyminus    12
  234. #define keyperiod    13
  235.           /* there is no keyslash */
  236. #define key0        15
  237. #define key1        16
  238. #define key2        17
  239. #define key3        18
  240. #define key4        19
  241. #define key5        20
  242. #define key6        21
  243. #define key7        22
  244. #define key8        23
  245. #define key9        24
  246.  
  247. #define keyenter    25
  248.  
  249. #define NUMOFMODS 4
  250. typedef struct {
  251.     short modbits;        /* modifier combination */
  252.     char prefix[20];        /* prefix string */
  253. }   modrec;
  254.  
  255. /* the following type is used as an overlay for a memory     */
  256. /* block which contains the macros. It is !not! used for a */
  257. /* static variable. So don't worry about its size                  */
  258. typedef struct {
  259.     modrec modtab[NUMOFMODS];    /* modifier table */
  260.     short numOfMacros;        /* number of macros the table contains */
  261.     macrorec mcr[1024];        /* array of macro definitions */
  262. }   macrodefs;
  263.  
  264. typedef struct {        /* dummy struct definiton to get the size of */
  265.     /* the base fields in macrodefs easily */
  266.     modrec modtab[NUMOFMODS];    /* modifier table */
  267.     short numOfMacros;        /* number of macros the table contains */
  268. }   macrodefsize;
  269.  
  270. #define MacroBaseSize sizeof(macrodefsize)
  271.  
  272. typedef macrodefs **hmacrodefs;    /* handle to a macrodefs structure */
  273.  
  274. /* Globals Kermit variables */
  275.  
  276. extern char *cmarg,        /* pointer to cmd argument (file) */
  277.    *cmarg2,            /* pointer to second cmd argument */
  278.     mypadc,            /* padding char to ask for */
  279.     padch, eol,            /* end of line char to send */
  280.     seol, mystch,        /* outbound packet start character */
  281.     stchr, sstate;        /* kermit protocol state */
  282.  
  283. extern long ffc,        /* file character count  */
  284.     fsize;            /* size of current file */
  285.  
  286. extern int speed,        /* speed of port */
  287.     parity,            /* current parity setting */
  288.     flow,            /* TRUE if using flow control */
  289.     duplex,            /* TRUE if full duplex */
  290.     binary,            /* TRUE if file mode is binary */
  291.     displa,            /* TRUE for calls to screen() */
  292.     seslog,            /* TRUE if writing session log */
  293.     tralog,            /* TRUE if writing transaction log */
  294.     pktlog,            /* TRUE if writing packet log */
  295.     bctr,            /* block check type (1, 2, or 3) */
  296.     delay,            /* initial delay before sending */
  297.     mypadn,            /* something to do with padding */
  298.     npad, timint,        /* timeout interval in seconds */
  299.     rtimo, spsiz,        /* max packet size we send */
  300.     rpsiz, urpsiz,        /* user requested packet size */
  301.     wslots, wslotn, wslotr,    /* sliding window size used, neg. and requested */
  302.     swcapr,            /* sliding window capability requested */
  303.     sbufnum, rbufnum,        /* number of sliding window buffers avail */
  304.     turnch,            /* line "turnaround" character */
  305.     turn,            /* if TRUE "turnaround" enabled */
  306.     quiet,            /* if TRUE screen() should be quiet */
  307.     nfils,            /* */
  308.     warn,            /* TRUE does name conversion, else */
  309.                 /* deletes duplicate names on recv */
  310.     server,            /* TRUE if we are in server mode */
  311.     cxseen,            /* if TRUE abort file */
  312.     czseen,            /* if TRUE abort group */
  313.     keep,            /* Keep incomplete files */
  314.     tlevel,            /* > -1 if take file is running */
  315.     sendusercvdef;        /* use rec. file mode defaults as send defaults */
  316.  
  317. extern Boolean mcmdactive,    /* TRUE if menu command keys are active */
  318.     have_multifinder,        /* becomes true if we are running MF */
  319.     in_background,        /* TRUE if we are a multifinder background task */
  320.     fkeysactive;        /* TRUE if FKEYs are enabled */
  321.  
  322. #define ASCII_SET    0    /* (UoR) VT100 character set numbers */
  323.  
  324. #define GRAF_SET    2    /* (PWP) Note: these refer to the 7 bit      */
  325. #define TECH_SET    3    /*  character set part.  Eg. full ISO 8859/1 */
  326. #define DECINTL_SET    4    /*  is formed by USA_SET in GL and LAT1_SET  */
  327. #define LAT1_SET    5    /*  in GR.  Read ISO 2022 about 4 times and  */
  328. #define LAT2_SET    6    /*  you will understand what is going on     */
  329. #define LAT3_SET    7
  330. #define LAT4_SET    8
  331. #define LATCYR_SET    9
  332. #define LATARAB_SET    10
  333. #define LATGREEK_SET    11
  334. #define LATHEBREW_SET    12
  335. #define LAT5_SET    13
  336.  
  337. /* the order of these must match that of ckmres.h */
  338. #define USA_NAT        0    /* (PWP) "national" character set numbers */
  339. #define UK_NAT        1
  340. #define DUTCH_NAT    2
  341. #define FINNISH_NAT    3
  342. #define FRENCH_NAT    4
  343. #define FRENCHCAN_NAT    5
  344. #define GERMAN_NAT    6
  345. #define ITALIAN_NAT    7
  346. #define NORWEGIAN_NAT    8
  347. #define PORTUGUESE_NAT    9
  348. #define SPANISH_NAT    10
  349. #define SWEDISH_NAT    11
  350. #define SWISS_NAT    12
  351.  
  352.  
  353. /* Mac global variables */
  354.  
  355. extern short innum,        /* serial line input number */
  356.     outnum;            /* serial line output number */
  357.  
  358. extern int protocmd;        /* current cmd that made us enter */
  359.  /* protocol or 0 if protocol is */
  360.  /* not running, or -1 if remote cmd */
  361. extern FILINF filargs;        /* file information flags */
  362.  
  363. /*
  364.  * ScrDmpEnb is a flag byte used by the toolbox event manager to say
  365.  * whether command-shift-1 through command-shift-9 do anything special
  366.  * like dump the screen, eject the diskettes, etc.  This byte is used in
  367.  * INIT0, the keyboard mapping routine (see IM index under scrdmpenb).
  368.  *
  369.  * N.B: The location of this value may change if MAC comes out with a
  370.  * new SYSTEM.
  371.  *
  372.  */
  373.  
  374. /* #define ScrDmpEnb (*(unsigned char *) 0x2f8) */
  375. /* ScrDmpEnb is in <SysEqu.h> */
  376.  
  377. #define scrdmpenabled ((unsigned char) 0xff)
  378. #define scrdmpdisabled ((unsigned char) 0x00)
  379.  
  380. /*
  381.  * Extern function definitions
  382.  * (I assume this will be compiled with an ANSI C compiler
  383.  */
  384.  
  385. extern StringPtr c2p_tmp(char *s);
  386. extern StringPtr c2p_tmp2(char *s);
  387. extern char *p2c_tmp (StringPtr s);
  388. extern char *p2c_tmp2 (StringPtr s);
  389. extern void pstring_copy (StringPtr d, StringPtr s);
  390.  
  391. extern void ssetgen (char *stor, char type, char *arg1, char *arg2,
  392.              char *arg3);
  393.  
  394. /*
  395.  * lfile
  396.  * Info about data files we were launched with.
  397.  */
  398. struct lfile {
  399.     struct lfile *next;
  400.     char *name;
  401.     short vRefNum;
  402. };
  403.  
  404.  
  405. /*
  406.  * Common definitions here because ckmptp.h needs them.
  407.  */
  408. typedef void (*PFV) ();
  409. typedef void (*PFV_NA) ();    /* pointer to func returning void, no args */
  410.  
  411. #define PIPESIZE 128
  412. typedef struct {
  413.     int charsleft;        /* nuber of unread characters in the buffer */
  414.     PFV refill;            /* pointer to the refill procedure */
  415.     char *currptr;        /* characters left before next pipe refill */
  416.     char pipebuf[PIPESIZE];    /* buffer to keep the pipes content */
  417. }   MACPIPE;
  418.  
  419. typedef struct {
  420.     short frefnum;        /* file reference number (pascal) */
  421.     int fstatus;        /* file status bits */
  422.     MACPIPE *fpipe;        /* pointer to a pipe */
  423. }   MACFILE;
  424.  
  425. typedef struct {
  426.     int resval;
  427.     unsigned serval;
  428. }   RESSERTBL;
  429.  
  430.  
  431. /*
  432.  * Junk so Emacs will set local variables to be compatible with Mac/MPW.
  433.  * Should be at end of file.
  434.  * 
  435.  * Local Variables:
  436.  * tab-width: 4
  437.  * End:
  438.  */
  439.