home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / mm / mm-ccmd-0.91-20031009.tar.gz / mm-ccmd-0.91-20031009.tar / work / ccmd / cmfnc.h < prev    next >
C/C++ Source or Header  |  2002-05-07  |  14KB  |  536 lines

  1. /*
  2.  Copyright (c) 1986, 1990 by The Trustees of Columbia University in
  3.  the City of New York.  Permission is granted to any individual or
  4.  institution to use, copy, or redistribute this software so long as it
  5.  is not sold for profit, provided this copyright notice is retained.
  6.  
  7.  Author: Andrew Lowry
  8. */
  9. /* cmfnc.h
  10. **
  11. ** This file contains function-specific symbols and declarations needed
  12. ** by application programs that wish to make use of the ccmd package.
  13. ** It is generated by m4 by means of the cmfnc.h4 file in conjunction with
  14. ** individual configuration files (as in cm???.cnf).  The initial portion
  15. ** of the file, including this comment, is copied verbatim from the file
  16. ** cmfnc.top.
  17. **
  18. ** Function codes are given names like _CMTTT, where TTT is the three-
  19. ** letter abbreviation for the type, and are assigned small positive
  20. ** integer values.
  21. **
  22. ** Function-specific error codes are given names of the form TTTxEEE,
  23. ** where TTT is the three-letter abbreviation for the parse type, and
  24. ** EEE is an abbreviation for the error.  The values assigned to these
  25. ** symbols are in two parts.  The left half contains the function code
  26. ** for the parse function, and the right half contains an integer
  27. ** in the range 0 to n-1, where there are n errors defined for the parse
  28. ** type.  Generic error codes for the ccmd package as a whole are given
  29. ** names like CMxEEE, and have zeros in the left half.
  30. **
  31. ** Flag values are generally given names like TTT_FFF, where FFF is a
  32. ** mnemonic for the flag.  Other constants are given names like _TTTCCC,
  33. ** where CCC is a mnemonic for the constant.
  34. **/
  35.  
  36. /* Macro to build error code values from the function code and error
  37. ** sub-code values.
  38. **/
  39.  
  40. #define CMERR(fcode,ecode)    ((fcode << 8) | ecode)
  41.  
  42.  
  43.  
  44. /* Generic ccmd package error codes, all with zero in left half */
  45.  
  46. #define CMxOK    CMERR(0,0)
  47. #define CMxRPT    CMERR(0,1)
  48. #define CMxNOP    CMERR(0,2)
  49. #define CMxUNKF    CMERR(0,3)
  50. #define CMxBOVF    CMERR(0,4)
  51. #define CMxAOVF    CMERR(0,5)
  52. #define CMxEOF    CMERR(0,6)
  53. #define CMxINC    CMERR(0,7)
  54. #define CMxNFDB    CMERR(0,8)
  55. #define CMxGO    CMERR(0,9)
  56. #define CMxDFR    CMERR(0,10)
  57. #define CMxNOAR    CMERR(0,11)
  58. #define CMxNDEF    CMERR(0,12)
  59. #define CMxIOVF    CMERR(0,13)
  60. #define CMxIO    CMERR(0,14)
  61. #define CMxBUFS    CMERR(0,15)
  62. #define CMxPMT    CMERR(0,16)
  63. #define CMxAGN    CMERR(0,17)
  64. #define CMxNOAE    CMERR(0,18)
  65. #define CMxBEL    CMERR(0,19)
  66. #define CMxBEG    CMERR(0,20)
  67. #define CMxSOF    CMERR(0,21)
  68. #define CMxSUF    CMERR(0,22)
  69. #define CMxPRE    CMERR(0,23)
  70.  
  71. /* Configuration information for cmcfm */
  72.  
  73. #define _CMCFM 1
  74.  
  75. /* Macro to prevent loading of cmcfm support */
  76.  
  77. #define CFM_STUB ftspec ft_cfm = { NULL, NULL, NULL, 0, NULL }; \
  78.     fnerr fe_cfm = { 0, NULL };
  79.  
  80.  
  81. /* cfm error codes */
  82.  
  83. #define CFMxNOC    CMERR(1,0)
  84.  
  85. /* Configuration information for cmkey */
  86.  
  87. #define _CMKEY 2
  88.  
  89. /* Macro to prevent loading of cmkey support */
  90.  
  91. #define KEY_STUB ftspec ft_key = { NULL, NULL, NULL, 0, NULL }; \
  92.     fnerr fe_key = { 0, NULL };
  93.  
  94.  
  95. /* keyword parse errors */
  96.  
  97. #define KEYxNM    CMERR(2,0)
  98. #define KEYxAMB    CMERR(2,1)
  99. #define KEYxABR    CMERR(2,2)
  100.  
  101. /*
  102.  * KEYWRD structure specifies one entry in a keyword table.  KEYTAB
  103.  * structure describes a table of keywords.
  104.  */
  105.  
  106. #ifdef notdef
  107. /*
  108.  * we want to return "anything" as the value of a keyword,
  109.  * so we need to know what is the 'largest' type in a machine independent 
  110.  * way.   I can't figure out a way to do this at compile time, so we'll use a 
  111.  * generated include file.
  112.  */
  113.  
  114. #include "cmkeyval.h"        /* this defines the keyval type */
  115. #endif
  116.  
  117. #ifdef KEYVAL_TYPE
  118. typedef KEYVAL_TYPE keyval;
  119. #else
  120. typedef long keyval;
  121. #endif
  122.  
  123.  
  124. typedef struct KEYWRD {
  125.     char *    _kwkwd;    /* keyword string */
  126.     short    _kwflg;    /* flags (see below) */
  127.     keyval    _kwval;    /* arbitrary value, not used internally */
  128.             /*  except for abbreviations... see KEY_ABR */
  129.             /*  flag below */
  130. } keywrd;
  131.  
  132. typedef struct KEYTAB {
  133.     int    _ktcnt;    /* number of keywords in table */
  134.     keywrd * _ktwds;/* array of keyword entries */
  135.     int    _ktwid;    /* fixed column width for help */
  136. } keytab;
  137.  
  138. /* Valid flags in fdb */
  139. #define KEY_EMO 0x0001        /* exact match only */
  140. #define KEY_PTR 0x0002        /* return pointer to keywrd struct */
  141. #define KEY_WID 0x0004        /* fixed width on help */
  142.  
  143. /* flags that can be present in a keyword entry */
  144.  
  145. #define KEY_ABR 0x0008        /* keyword is an abbreviation for the */
  146.             /* keyword indexed by this entry's _kwval value */
  147.  
  148. #define KEY_NOR 0x0010        /* Ignore this keyword (do not recognize */
  149.             /*  any prefix, or even an exact match) */
  150. #define KEY_IGN KEY_NOR
  151. #define KEY_INV 0x0020        /* Invisible keyword (not shown with help) */
  152. #define KEY_MAT 0x0040        /* This keyword matches current input */
  153.             /*  (used internally) */
  154.  
  155.  
  156. /* Configuration information for cmnum */
  157.  
  158. #define _CMNUM 3
  159.  
  160. /* Macro to prevent loading of cmnum support */
  161.  
  162. #define NUM_STUB ftspec ft_num = { NULL, NULL, NULL, 0, NULL }; \
  163.     fnerr fe_num = { 0, NULL };
  164.  
  165.  
  166. /* number parsing errors */
  167.  
  168. #define NUMxRAD    CMERR(3,0)
  169. #define NUMxSGN    CMERR(3,1)
  170. #define NUMxNP    CMERR(3,2)
  171. #define NUMxOV    CMERR(3,3)
  172.  
  173. /* Parse flags for number parse */
  174.  
  175. #define NUM_US 0x0001        /* unsigned integer parse */
  176. #define NUM_BNP 0x0002        /* integer can break on non-punctuation */
  177. #define NUM_PO 0x0004        /* parse-only (no conversion to binary) */
  178.  
  179. /* Configuration information for cmqst */
  180.  
  181. #define _CMQST 4
  182.  
  183. /* Macro to prevent loading of cmqst support */
  184.  
  185. #define QST_STUB ftspec ft_qst = { NULL, NULL, NULL, 0, NULL }; \
  186.     fnerr fe_qst = { 0, NULL };
  187.  
  188.  
  189. /* quoted string error codes */
  190.  
  191. #define QSTxQC    CMERR(4,0)
  192. #define QSTxBC    CMERR(4,1)
  193. #define QSTxNP    CMERR(4,2)
  194.  
  195. /* Configuration information for cmnoi */
  196.  
  197. #define _CMNOI 5
  198.  
  199. /* Macro to prevent loading of cmnoi support */
  200.  
  201. #define NOI_STUB ftspec ft_noi = { NULL, NULL, NULL, 0, NULL }; \
  202.     fnerr fe_noi = { 0, NULL };
  203.  
  204.  
  205. /* noise word parse errors */
  206.  
  207. #define NOIxNP    CMERR(5,0)
  208.  
  209. /* Configuration information for cmtxt */
  210.  
  211. #define _CMTXT 6
  212.  
  213. /* Macro to prevent loading of cmtxt support */
  214.  
  215. #define TXT_STUB ftspec ft_txt = { NULL, NULL, NULL, 0, NULL }; \
  216.     fnerr fe_txt = { 0, NULL };
  217.  
  218. /* text line parse errors */
  219.  
  220. #define TXTxNP    CMERR(6,0)
  221.  
  222. /* Configuration information for cmfld */
  223.  
  224. #define _CMFLD 7
  225.  
  226. /* Macro to prevent loading of cmfld support */
  227.  
  228. #define FLD_STUB ftspec ft_fld = { NULL, NULL, NULL, 0, NULL }; \
  229.     fnerr fe_fld = { 0, NULL };
  230.  
  231.  
  232. /* Field (word) parse errors */
  233.  
  234. #define FLDxNM    CMERR(7,0)
  235.  
  236. /* don't allow empty fields */
  237. #define FLD_EMPTY 0x0001
  238. /* all unterminated fields */
  239. #define FLD_WAK 0x0002
  240.  
  241. /* Configuration information for cmswi */
  242.  
  243. #define _CMSWI 8
  244.  
  245. /* Macro to prevent loading of cmswi support */
  246.  
  247. #define SWI_STUB ftspec ft_swi = { NULL, NULL, NULL, 0, NULL }; \
  248.     fnerr fe_swi = { 0, NULL };
  249.  
  250.  
  251. /* switch parsing errors */
  252.  
  253. #define SWIxNM    CMERR(8,0)
  254. #define SWIxAMB    CMERR(8,1)
  255. #define SWIxABR    CMERR(8,2)
  256. #define SWIxBEG    CMERR(8,3)
  257. #define SWIxEND    CMERR(8,4)
  258.  
  259. /*
  260.  * SWTCH structure specifies one entry in a switch table.  SWITAB
  261.  * structure describes a table of switches.  (We use the name
  262.  * swtch instead of switch because the latter is a C reserved word.)
  263.  */
  264.  
  265. typedef struct SWTCH {
  266.     char *    _swswi;        /* switch string (without punctuation)  */
  267.     short    _swflg;        /* flags (see below) */
  268.     int    _swval;        /* arbitrary value, not used internally */
  269.                 /*  except for abbreviations... see SWI_ABR */
  270.                 /*  flag below */
  271. } swtch;
  272.  
  273. typedef struct SWITAB {
  274.     int    _stcnt;        /* number of switches in table */
  275.     swtch  * _stwds;    /* array of switch entries  */
  276. } switab;
  277.  
  278. /* Flags that can be present in a switch entry */
  279.  
  280. #define SWI_ABR 0x0001            /* switch is an abbreviation for the */
  281.                 /* switch indexed by this entry's _swval */
  282.                 /* value */
  283. #define SWI_NOR 0x0002            /* Ignore this switch (do not recognize */
  284.                 /*  any prefix, or even an exact match) */
  285. #define SWI_INV 0x0004            /* Invisible switch (not shown with help) */
  286. #define SWI_MAT 0x0008            /* This switch matches current input (used */
  287.                 /*  internally) */
  288.  
  289. /* Configuration information for cmtok */
  290.  
  291. #define _CMTOK 9
  292.  
  293. /* Macro to prevent loading of cmtok support */
  294.  
  295. #define TOK_STUB ftspec ft_tok = { NULL, NULL, NULL, 0, NULL }; \
  296.     fnerr fe_tok = { 0, NULL };
  297.  
  298. /* token parse errors */
  299.  
  300. #define TOKxNP    CMERR(9,0)
  301.  
  302. /* Wake up on match */
  303. #define TOK_WAK 0x0001
  304.  
  305. /* Configuration information for cmtad */
  306.  
  307. #define _CMTAD 10
  308.  
  309. /* Macro to prevent loading of cmtad support */
  310.  
  311. #define TAD_STUB ftspec ft_tad = { NULL, NULL, NULL, 0, NULL }; \
  312.     fnerr fe_tad = { 0, NULL };
  313.  
  314.  
  315. #include "datime.h"        /* need these symbols to use _CMTAD */
  316.  
  317. /* time/date parse errors */
  318.  
  319. #define TADxNTD    CMERR(10,0)
  320. #define TADxTIM    CMERR(10,1)
  321. #define TADxDAT    CMERR(10,2)
  322. #define TADxDT    CMERR(10,3)
  323.  
  324.  
  325. /* Configuration information for cmfil */
  326.  
  327. #define _CMFIL 11
  328.  
  329. /* Macro to prevent loading of cmfil support */
  330.  
  331. #define FIL_STUB ftspec ft_fil = { NULL, NULL, NULL, 0, NULL }; \
  332.     fnerr fe_fil = { 0, NULL };
  333.  
  334.  
  335. /* filename parse errors */
  336.  
  337. #define FILxNM    CMERR(11,0)
  338. #define FILxAMB    CMERR(11,1)
  339. #define FILxNWLD    CMERR(11,2)
  340. #define FILxINV    CMERR(11,3)
  341. #define FILxBAD    CMERR(11,4)
  342. #define FILxPMA    CMERR(11,5)
  343.  
  344. /*
  345.  * FILBLK structure describes a data block to be passed to the file
  346.  * name parser
  347.  */
  348. typedef struct FILBLK {
  349.     char **pathv;        /* NULL terminated vector of dirs */
  350.     char *exceptionspec;    /* regexp of exceptions */
  351.     char **def_extension;   /* list of extensions to use */
  352. } filblk;
  353.  
  354. /*
  355.  * flags that can be present in a filename fdb 
  356.  */
  357.  
  358. #define FIL_OLD 0x0001            /* existing file */
  359. #define FIL_PO 0x0002            /* nonexisting file */
  360. #define FIL_VAL 0x0004            /* "validate" on PO parse */
  361. #define FIL_DIR 0x0008            /* a directory */
  362. #define FIL_RD 0x0010            /* a readable file */
  363. #define FIL_WR 0x0020            /* a writable file */
  364. #define FIL_EXEC 0x0040            /* an executable file */
  365. #define FIL_WLD 0x0080            /* wild cards allowed */
  366. #define FIL_NOPTH 0x0100            /* only display filename in help */
  367. #define FIL_NOEXT 0x0200            /* don't display extention in help */
  368. #define FIL_TYPE 0x0400            /* display the type of file in help */
  369. #define FIL_NODIR 0x0800            /* don't complete on directories */
  370. #if CCMD_OS_MSDOS
  371. #define FIL_HID 0x1000            /* a hidden file (MSDOS) */
  372. #define FIL_SYS 0x2000            /* a system file (MSDOS) */
  373. #endif /* CCMD_OS_MSDOS */
  374. #ifdef undef
  375. #define FIL_REGEXP 0x4000            /* regexp's allowed */
  376. #endif 
  377. #if CCMD_OS_MSDOS
  378. #define FIL_ALL (FIL_DIR|FIL_RD|FIL_WR|FIL_EXEC|FIL_HID|FIL_SYS)
  379. #else
  380. #define FIL_ALL (FIL_DIR|FIL_RD|FIL_WR|FIL_EXEC)
  381. #endif /* CCMD_OS_MSDOS */
  382.  
  383. typedef char **pvfil;        /* return a NULL terminated string vector */
  384.  
  385.  
  386.  
  387. /* Configuration information for cmusr */
  388.  
  389. #define _CMUSR 12
  390.  
  391. /* Macro to prevent loading of cmusr support */
  392.  
  393. #define USR_STUB ftspec ft_usr = { NULL, NULL, NULL, 0, NULL }; \
  394.     fnerr fe_usr = { 0, NULL };
  395.  
  396.  
  397. /* username parse errors */
  398. #define USRxNM    CMERR(12,0)
  399. #define USRxAMB    CMERR(12,1)
  400.  
  401. /* parse a wild username */
  402. #define USR_WILD 0x0001                /* allow wild users */
  403. #define USR_NOUPD 0x0002                /* defer update of user table */
  404.                     /* even if /etc/passwd has been  */
  405.                     /* updated */
  406. #define USR_UPDONLY 0x0004                /* forced update of user table */
  407.                     /* parse will fail. */
  408.                     /* allows table to updated with  */
  409.                     /* no parse done. */
  410.                     /* when using this flag, you */
  411.                     /* must trap errors yourself, or */
  412.                     /* a "no such user error" will be */
  413.                     /* displayed */
  414. #if unix /* CCMD_OS_UNIX */ /* XXX KLH: THIS IS BROKEN!!!!! */ 
  415. #include <pwd.h>
  416. #else
  417. struct passwd {
  418.   int x;
  419. };
  420. #endif
  421.  
  422. /* Configuration information for cmgrp */
  423.  
  424. #define _CMGRP 13
  425.  
  426. /* Macro to prevent loading of cmgrp support */
  427.  
  428. #define GRP_STUB ftspec ft_grp = { NULL, NULL, NULL, 0, NULL }; \
  429.     fnerr fe_grp = { 0, NULL };
  430.  
  431.  
  432. /* groupname parse errors */
  433. #define GRPxNM    CMERR(13,0)
  434. #define GRPxAMB    CMERR(13,1)
  435.  
  436. #define GRP_WILD 0x0001                /* allow wild groups */
  437. #define GRP_NOUPD 0x0002                /* defer update of group table */
  438.                     /* even if /etc/group has been  */
  439.                     /* updated */
  440. #define GRP_UPDONLY 0x0004                /* forced update of group table */
  441.                     /* parse will fail. */
  442.                     /* allows table to updated with  */
  443.                     /* no parse done. */
  444.  
  445. #if unix /* CCMD_OS_UNIX */ /* XXX KLH: THIS IS BROKEN!!!!! */ 
  446. #include <grp.h>
  447. #else
  448. struct group {
  449.   int x;
  450. };
  451. #endif
  452.  
  453. /* Configuration information for cmpara */
  454.  
  455. #define _CMPARA 14
  456.  
  457. /* Macro to prevent loading of cmpara support */
  458.  
  459. #define PARA_STUB ftspec ft_para = { NULL, NULL, NULL, 0, NULL }; \
  460.     fnerr fe_para = { 0, NULL };
  461.  
  462.  
  463. /*
  464.  * para_actions:
  465.  * a structure to hold an action character, and an associated function
  466.  * to call for that action
  467.  */
  468.  
  469. typedef struct {
  470.   char actionchar;
  471.   char * (* actionfunc)();
  472. } para_actions;
  473.  
  474. /*
  475.  * para_data:
  476.  * input data to paragraph parser.
  477.  * holds text to install at the beginning of the buffer, and
  478.  * a NULL terminated vector of para_actions.
  479.  */
  480.  
  481. typedef struct {
  482.   char *buf;
  483.   para_actions *actions;
  484. } para_data;
  485.  
  486. #define PARAxNM    CMERR(14,0)
  487.  
  488. /*
  489.  * the PARA_DEF flag is used to specify that the default actions should be
  490.  * set, and then the user specified actions should be installed.
  491.  * Used to make additions to the default actions
  492.  */
  493. #define PARA_DEF 0x0001
  494.  
  495. #ifndef DEF_EDITOR
  496. #if CCMD_OS_UNIX
  497. #define DEF_EDITOR "emacs"
  498. #endif
  499.  
  500. #if CCMD_OS_MSDOS
  501. #ifdef RAINBOW
  502. #define DEF_EDITOR "mince"
  503. #else
  504. #define DEF_EDITOR "epsilon"
  505. #endif /*  RAINBOW */
  506. #endif /*  CCMD_OS_MSDOS */
  507. #endif
  508. ;
  509.  
  510.  
  511. /* Configuration information for cmchar */
  512.  
  513. #define _CMCHAR 15
  514.  
  515. /* Macro to prevent loading of cmchar support */
  516.  
  517. #define CHAR_STUB ftspec ft_char = { NULL, NULL, NULL, 0, NULL }; \
  518.     fnerr fe_char = { 0, NULL };
  519.  
  520.  
  521. /* Union declaration for parse return values */
  522.  
  523. typedef union PVAL {
  524.     int _pvint;
  525.     float _pvflt;
  526.     char _pvchr;
  527.     char *_pvstr;
  528.     char **_pvstrvec;
  529.         keyval _pvkey;
  530.         datime _pvtad;
  531.         pvfil _pvfil;
  532.         struct passwd ** _pvusr;
  533.         struct group ** _pvgrp;
  534.         char * _pvpara;
  535. } pval;
  536.