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