home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / ckucmd.h < prev    next >
C/C++ Source or Header  |  2020-01-01  |  9KB  |  307 lines

  1. /*  C K U C M D . H  --  Header file for Unix cmd package  */
  2.  
  3. /*
  4.   Author: Frank da Cruz <fdc@columbia.edu>
  5.   Columbia University Kermit Project, New York City.
  6.  
  7.   Copyright (C) 1985, 2004,
  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. #ifndef CKUCMD_H
  14. #define CKUCMD_H
  15.  
  16. /* Command recall */
  17.  
  18. #ifdef pdp11                /* Not enough room for this */
  19. #ifndef NORECALL
  20. #define NORECALL
  21. #endif /* NORECALL */
  22. #endif /* pdp11 */
  23.  
  24. #ifdef DYNAMIC                /* Dynamic command buffers */
  25. /*
  26.   Use malloc() to allocate the many command-related buffers in ckucmd.c.
  27. */
  28. #ifndef DCMDBUF
  29. #ifndef NORECALL
  30. #define NORECALL
  31. #endif /* NORECALL */
  32. #endif /* DCMDBUF */
  33.  
  34. #ifndef NORECALL
  35. #define CK_RECALL
  36. #else
  37. #ifdef CK_RECALL
  38. #undef CK_RECALL
  39. #endif /* CK_RECALL */
  40. #endif /* NORECALL */
  41. #else
  42. #ifndef NORECALL
  43. #define NORECALL
  44. #endif /*  NORECALL */
  45. #endif /* DYNAMIC */
  46.  
  47. #ifdef NORECALL
  48. #ifdef CK_RECALL
  49. #undef CK_RECALL
  50. #endif /* CK_RECALL */
  51. #endif /* NORECALL */
  52.  
  53. #ifdef NORECALL
  54. #ifndef NOARROWKEYS
  55. #define NOARROWKEYS
  56. #endif /* NOARROWKEYS */
  57. #endif /* NORECALL */
  58.  
  59. /* Special getchars */
  60.  
  61. #ifdef VMS
  62. #ifdef getchar                /* This is for VMS GCC */
  63. #undef getchar
  64. #endif /* getchar */
  65. #define getchar()   vms_getchar()
  66. int vms_getchar(void);
  67. #endif /* VMS */
  68.  
  69. #ifdef aegis
  70. #undef getchar
  71. #define getchar()   coninc(0)
  72. #endif /* aegis */
  73.  
  74. #ifdef AMIGA
  75. #undef getchar
  76. #define getchar() coninc(0)
  77. #endif /* AMIGA */
  78.  
  79. #ifdef Plan9
  80. #undef getchar
  81. #define getchar() coninc(0)
  82. #undef putchar
  83. #define putchar(c) conoc(c)
  84. #undef printf
  85. #define printf conprint
  86. #endif /* Plan9 */
  87.  
  88. /* Sizes of things */
  89.  
  90. #ifndef CMDDEP
  91. #ifdef BIGBUFOK
  92. #define CMDDEP  64            /* Maximum command recursion depth */
  93. #else
  94. #define CMDDEP  20
  95. #endif /* BIGBUFOK */
  96. #endif /* CMDDEP */
  97. #define HLPLW   78            /* Width of ?-help line */
  98. #define HLPCW   19            /* Width of ?-help column */
  99. #define HLPBL  100            /* Help string buffer length */
  100. #ifdef BIGBUFOK
  101. #define ATMBL 10238            /* Command atom buffer length*/
  102. #else
  103. #ifdef NOSPL
  104. #define ATMBL  256
  105. #else
  106. #define ATMBL  1024
  107. #endif /* NOSPL */
  108. #endif /* BIGBUFOK */
  109.  
  110. #ifndef CMDBL
  111. #ifdef NOSPL
  112. /* No script programming language, save some space */
  113. #define CMDBL 608            /* Command buffer length */
  114. #else
  115. #ifdef BIGBUFOK
  116. #define CMDBL 32763
  117. #else
  118. #define CMDBL 4092
  119. #endif /* OS2 */
  120. #endif /* NOSPL */
  121. #endif /* CMDBL */
  122.  
  123. /* Special characters */
  124.  
  125. #define RDIS 0022            /* Redisplay   (^R) */
  126. #define LDEL 0025            /* Delete line (^U) */
  127. #define WDEL 0027            /* Delete word (^W) */
  128. #ifdef CK_RECALL
  129. #define C_UP 0020            /* Go Up in recall buffer (^P) */
  130. #define C_UP2 0002            /* Alternate Go Up (^B) for VMS */
  131. #define C_DN 0016            /* Go Down in recall buffer (^N) */
  132. #endif /* CK_RECALL */
  133.  
  134. /* Keyword flags (bits, powers of 2) */
  135.  
  136. #define CM_INV 1            /* Invisible keyword */
  137. #define CM_ABR 2            /* Abbreviation for another keyword */
  138. #define CM_HLP 4            /* Help-only keyword */
  139. #define CM_ARG 8            /* An argument is required */
  140. #define CM_NOR 16            /* No recall for this command */
  141. #define CM_PRE 32            /* Long-form cmdline arg for prescan */
  142. #define CM_PSH 64            /* Command disabled if nopush */
  143. #define CM_LOC 128            /* Command disabled if nolocal */
  144.  
  145. /*
  146.   A long-form command line option is a keyword using the regular struct keytab
  147.   and lookup mechanisms.  Flags that make sense in this context are CM_ARG,
  148.   indicating this option requires an argument (operand), and CM_PRE, which
  149.   means this option must be processed before the initialization file.  The
  150.   absence of CM_PRE means the option is to be processed after the
  151.   initialization file in the normal manner.
  152. */
  153.  
  154. /* Token flags (numbers) */
  155.  
  156. #define CMT_COM 0            /* Comment (; or #) */
  157. #define CMT_SHE 1            /* Shell escape (!) */
  158. #define CMT_LBL 2            /* Label (:) */
  159. #define CMT_FIL 3            /* Indirect filespec (@) (not used) */
  160.  
  161. /* Path separator for path searches */
  162.  
  163. #ifdef OS2
  164. #define PATHSEP ';'
  165. #else
  166. #ifdef UNIX
  167. #define PATHSEP ':'
  168. #else
  169. #define PATHSEP ','
  170. #endif /* UNIX */
  171. #endif /* OS2 */
  172.  
  173. #ifndef CK_KEYTAB
  174. #define CK_KEYTAB
  175.  
  176. /* Keyword Table Template perhaps already defined in ckcdeb.h */
  177.  
  178. struct keytab {                /* Keyword table */
  179.     char *kwd;                /* Pointer to keyword string */
  180.     int kwval;                /* Associated value */
  181.     int flgs;                /* Flags (as defined above) */
  182. };
  183. #endif /* CK_KEYTAB */
  184.  
  185. /* String preprocessing function */
  186.  
  187. #ifdef CK_ANSIC                /* ANSI C */
  188. #ifdef M_SYSV                /* SCO Microsoft C wants no args */
  189. typedef int (*xx_strp)();
  190. #else
  191. typedef int (*xx_strp)(char *, char **, int *);
  192. #endif /* M_SYSV */
  193. #else                    /* Not ANSI C */
  194. typedef int (*xx_strp)();
  195. #endif /* CK_ANSIC */
  196.  
  197. /* FLDDB struct */
  198.  
  199. typedef struct FDB {
  200.     int fcode;                /* Function code */
  201.     char * hlpmsg;            /* Help message */
  202.     char * dflt;            /* Default */
  203.     char * sdata;            /* Additional string data */
  204.     int ndata1;                /* Additional numeric data 1 */
  205.     int ndata2;                /* Additional numeric data 2 */
  206.     xx_strp spf;            /* String processing function */
  207.     struct keytab * kwdtbl;        /* Keyword table */
  208.     struct FDB * nxtfdb;        /* Pointer to next alternative */
  209. } fdb;
  210.  
  211. typedef struct OFDB {
  212.     struct FDB * fdbaddr;        /* Address of succeeding FDB struct */
  213.     int fcode;                /* Function code */
  214.     char * sresult;            /* String result */
  215.     int nresult;            /* Integer result */
  216.     int kflags;                /* Keyword flags if any */
  217.     CK_OFF_T wresult;            /* Long integer ("wide") result */
  218. } ofdb;
  219.  
  220. #ifndef CKUCMD_C
  221. extern struct OFDB cmresult;
  222. #endif /* CKUCMD_C */
  223.  
  224. /* Codes for primary parsing function  */
  225.  
  226. #define _CMNUM 0            /* Number */
  227. #define _CMOFI 1            /* Output file */
  228. #define _CMIFI 2            /* Input file */
  229. #define _CMFLD 3            /* Arbitrary field */
  230. #define _CMTXT 4            /* Text string */
  231. #define _CMKEY 5            /* Keyword */
  232. #define _CMCFM 6            /* Confirmation */
  233. #define _CMDAT 7            /* Date/time */
  234. #define _CMNUW 8            /* Wide version of cmnum */
  235.  
  236. /* Function prototypes */
  237.  
  238. _PROTOTYP( int xxesc, (char **) );
  239. _PROTOTYP( int cmrini, (int) );
  240. _PROTOTYP( VOID cmsetp, (char *) );
  241. _PROTOTYP( VOID cmsavp, (char [], int) );
  242. _PROTOTYP( char * cmgetp, (void) );
  243. _PROTOTYP( VOID prompt, (xx_strp) );
  244. _PROTOTYP( VOID pushcmd, (char *) );
  245. _PROTOTYP( VOID cmres, (void) );
  246. _PROTOTYP( VOID cmini, (int) );
  247. _PROTOTYP( int cmgbrk, (void) );
  248. _PROTOTYP( int cmgkwflgs, (void) );
  249. _PROTOTYP( int cmpush, (void) );
  250. _PROTOTYP( int cmpop, (void) );
  251. _PROTOTYP( VOID untab, (char *) );
  252. _PROTOTYP( int cmnum, (char *, char *, int, int *, xx_strp ) );
  253. _PROTOTYP( int cmnumw, (char *, char *, int, CK_OFF_T *, xx_strp ) );
  254. _PROTOTYP( int cmofi, (char *, char *, char **, xx_strp ) );
  255. _PROTOTYP( int cmifi, (char *, char *, char **, int *, xx_strp ) );
  256. _PROTOTYP( int cmiofi, (char *, char *, char **, int *, xx_strp ) );
  257. _PROTOTYP( int cmifip,(char *, char *, char **, int *, int, char *, xx_strp ));
  258. _PROTOTYP( int cmifi2,(char *,char *,char **,int *,int,char *,xx_strp,int ));
  259. _PROTOTYP( int cmdir, (char *, char *, char **, xx_strp ) );
  260. _PROTOTYP( int cmdirp, (char *, char *, char **, char *, xx_strp ) );
  261. _PROTOTYP( int cmfld, (char *, char *, char **, xx_strp ) );
  262. _PROTOTYP( int cmtxt, (char *, char *, char **, xx_strp ) );
  263. _PROTOTYP( int cmkey,  (struct keytab [], int, char *, char *, xx_strp) );
  264. _PROTOTYP( int cmkeyx, (struct keytab [], int, char *, char *, xx_strp) );
  265. _PROTOTYP( int cmkey2,(struct keytab [],int,char *,char *,char *,xx_strp,int));
  266. _PROTOTYP( int cmswi,  (struct keytab [], int, char *, char *, xx_strp) );
  267. _PROTOTYP( int cmdate,(char *, char *, char **, int, xx_strp) );
  268. _PROTOTYP( char * cmpeek, (void) );
  269. _PROTOTYP( int cmfdb, (struct FDB *) );
  270. _PROTOTYP( VOID cmfdbi, (struct FDB *,
  271.             int, char *, char *, char *, int, int, xx_strp,
  272.             struct keytab *, struct FDB *) );
  273. _PROTOTYP( int chktok, (char *) );
  274. _PROTOTYP( int cmcfm, (void) );
  275. _PROTOTYP( int lookup, (struct keytab [], char *, int, int *) );
  276. _PROTOTYP( VOID kwdhelp, (struct keytab[],int,char *,char *,char *,int,int) );
  277. _PROTOTYP( int ungword, (void) );
  278. _PROTOTYP( VOID unungw, (void) );
  279. _PROTOTYP( int cmdsquo, (int) );
  280. _PROTOTYP( int cmdgquo, (void) );
  281. _PROTOTYP( char * ckcvtdate, (char *, int) );
  282. _PROTOTYP( int cmdgetc, (int));
  283. #ifndef NOARROWKEYS
  284. _PROTOTYP( int cmdconchk, (void) );
  285. #endif /* NOARROWKEYS */
  286.  
  287. #ifdef CK_RECALL
  288. _PROTOTYP( char * cmgetcmd, (char *) );
  289. _PROTOTYP( VOID addcmd, (char *) );
  290. _PROTOTYP( VOID cmaddnext, (void) );
  291. #endif /* CK_RECALL */
  292. _PROTOTYP( char * cmcvtdate, (char *, int) );
  293. _PROTOTYP( char * cmdiffdate, (char *, char *) );
  294. _PROTOTYP( char * cmdelta, (int,
  295.                 int,int,int,int,int,int,int,int,int,int,int,int ));
  296. _PROTOTYP( char * shuffledate, (char *, int) );
  297. _PROTOTYP( int filhelp, (int, char *, char *, int, int) );
  298. _PROTOTYP( int delta2sec, (char *, long *) );
  299.  
  300. #ifdef DCMDBUF
  301. _PROTOTYP( int cmsetup, (void) );
  302. #endif /* DCMDBUF */
  303.  
  304. #endif /* CKUCMD_H */
  305.  
  306. /* End of ckucmd.h */
  307.