ckucmd.h 8.8 KB

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