home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / bsd / ci.h < prev    next >
Text File  |  1990-01-22  |  7KB  |  242 lines

  1. /*  macros and declarations for ci routine
  2.  *
  3.  * BUGS
  4.  * Must have literals for cluster prompts, cchr legal character set,
  5.  *    entry names.
  6.  *
  7.  * HISTORY
  8.  * 20-May-83  Steven Shafer (sas) at Carnegie-Mellon University
  9.  *    Added new quiet bits: CINOSEM, CINOFILE, CIFIRSTEQUAL to allow
  10.  *    user to specify that special characters are to be processed as
  11.  *    normal input data.
  12.  *
  13.  * 15-Apr-83  Steven Shafer (sas) at Carnegie-Mellon University
  14.  *    Added ciprev, ciback for "@" command; cidepth made global variable;
  15.  *    new CICMDNOINDENT bit to suppress indenting due to depth.  Changes
  16.  *    made by Dave McKeown.
  17.  *
  18.  * 21-Feb-83  Steven Shafer (sas) at Carnegie-Mellon University
  19.  *    Added cinext variable for ^ command in ci.
  20.  *
  21.  * 08-Oct-80  Steven Shafer (sas) at Carnegie-Mellon University
  22.  *    Added CLASS variables: CICLASS, ci_tclass, ci_evar.
  23.  *    Also added CICMDFPEEK.
  24.  *
  25.  * 28-Jan-80  Steven Shafer (sas) at Carnegie-Mellon University
  26.  *    Created.  Note: you must include <stdio.h> when using this file.
  27.  *
  28.  */
  29.  
  30. /* Usage:  ci (prompt, file, depth, list, helppath, cmdfpath);
  31.  */
  32. /* Name conventions:
  33.  *  <type> is either:
  34.  *    <simpletype>        int, etc.; a simple variable
  35. 7&D<simpletype>        cint, etc.; a cluster variable
  36.  *  ci_<type>        a structure declaration
  37.  *  ci_u<type>        a union element of ci_union
  38.  *  ci_t<type>        a type identifier of ci_type
  39.  *  <TYPE>        macro for declaring a clustered type
  40.  *  CI<TYPE>        macro for element of ci entry list
  41.  *
  42.  * <simpletype> is one of:
  43.  *    int    long    short    oct    hex    double    float
  44.  *    chr    string    stab    search
  45.  * with various specials (cmd, proc, end) thrown in.
  46.  */
  47.  
  48. /*  For internal use by ci only:  Clustered type structures */
  49.  
  50. typedef struct {    /* int */
  51.     int    *ci_ival;        /* ptr to int (current value) */
  52.     int    ci_imin, ci_imax;    /* min and max allowed values */
  53.     char    *ci_imsg;        /* prompt message */
  54. } ci_cint;
  55.  
  56. typedef struct {    /* short */
  57.     short    *ci_sval, ci_smin, ci_smax;
  58.     char    *ci_smsg;
  59. } ci_cshort;
  60.  
  61. typedef struct {    /* long */
  62.     long    *ci_lval, ci_lmin, ci_lmax;
  63.     char    *ci_lmsg;
  64. } ci_clong;
  65.  
  66. typedef struct {    /* octal and hex */
  67.     unsigned int    *ci_uval, ci_umin, ci_umax;
  68.     char    *ci_umsg;
  69. } ci_cunsigned;
  70.  
  71. typedef struct {    /* double */
  72.     double    *ci_dval, ci_dmin, ci_dmax;
  73.     char    *ci_dmsg;
  74. } ci_cdouble;
  75.  
  76. typedef struct {    /* float */
  77.     float    *ci_fval, ci_fmin, ci_fmax;
  78.     char    *ci_fmsg;
  79. } ci_cfloat;
  80.  
  81. typedef struct {    /* boolean */
  82.     int    *ci_bval;    /* ptr to value */
  83.     char    *ci_bmsg;    /* prompt message */
  84. } ci_cbool;
  85.  
  86. typedef struct {    /* chr */
  87.     int    *ci_cval;    /* ptr to int value */
  88.     char    *ci_cleg;    /* string of legal chars */
  89.     char    *ci_cmsg;    /* prompt message */
  90. } ci_cchr;
  91.  
  92. typedef struct {    /* string */
  93.     char    *ci_pval;    /* ptr to string */
  94.     int    ci_plen;    /* length */
  95.     char    *ci_pmsg;    /* prompt message */
  96. } ci_cstring;
  97.  
  98. typedef struct {    /* string table */
  99.     int    *ci_tval;    /* ptr to value */
  100.     char    **ci_ttab;    /* table */
  101.     char    *ci_tmsg;    /* prompt message */
  102. } ci_cstab;
  103.  
  104. /* FOR USERS: DECLARATIONS OF INSTANCES OF CLUSTERED TYPES */
  105.  
  106. #define CINT(str,var,mn,mx,msg)        int var; ci_cint str={&var,mn,mx,msg}
  107. #define CSHORT(str,var,mn,mx,msg)    short var; ci_cshort str={&var,mn,mx,msg}
  108. #define CLONG(str,var,mn,mx,msg)    long var; ci_clong str={&var,mn,mx,msg}
  109. #define COCT(str,var,mn,mx,msg)        unsigned int var; ci_cunsigned str={&var,mn,mx,msg}
  110. #define CHEX(str,var,mn,mx,msg)     unsigned int var; ci_cunsigned str={&var,mn,mx,msg}
  111. #define CDOUBLE(str,var,mn,mx,msg)    double var; ci_cdouble str={&var,mn,mx,msg}
  112. #define CFLOAT(str,var,mn,mx,msg)    float var; ci_cfloat str={&var,mn,mx,msg}
  113. #define CBOOL(s7&Ear,msg)        int var; ci_cbool str={&var,msg}
  114. #define CCHR(str,var,leg,msg)        int var; ci_cchr str={&var,leg,msg}
  115. #define CSTRING(str,var,len,msg)    char var[len]; ci_cstring str={var,len,msg}
  116. #define CSTAB(str,var,tbl,msg)        int var; ci_cstab str={&var,tbl,msg}
  117. #define CSEARCH(str,var,tbl,msg)    int var; ci_cstab str={&var,tbl,msg}
  118.  
  119. /*  For internal use in ci only:  Union of entry types */
  120.  
  121. typedef union {
  122.     int        ci_uint;
  123.     short        ci_ushort;
  124.     long        ci_ulong;
  125.     unsigned int    ci_uoct;
  126.     unsigned int    ci_uhex;
  127.     double        ci_udouble;
  128.     float        ci_ufloat;
  129.     int        ci_ubool;
  130.     char        *ci_ustring;
  131.     int        (*ci_uproc)();    /* variable procedures */
  132.     ci_cint        ci_ucint;
  133.     ci_cshort    ci_ucshort;
  134.     ci_clong    ci_uclong;
  135.     ci_cunsigned    ci_ucoct;
  136.     ci_cunsigned    ci_uchex;
  137.     ci_cdouble    ci_ucdouble;
  138.     ci_cfloat    ci_ucfloat;
  139.     ci_cbool    ci_ucbool;
  140.     ci_cchr        ci_ucchr;
  141.     ci_cstring    ci_ucstring;
  142.     ci_cstab    ci_ucstab;
  143.     ci_cstab    ci_ucsearch;
  144.     int        (*ci_ucmd) ();    /* a command, not a variable */
  145. } ci_union;
  146.  
  147. /* For internal use in ci only:  Type identifiers */
  148.  
  149. typedef enum {
  150.     ci_tint,
  151.     ci_tshort,
  152.     ci_tlong,
  153.     ci_toct,
  154.     ci_thex,
  155.     ci_tdouble,
  156.     ci_tfloat,
  157.     ci_tbool,
  158.     ci_tstring,
  159.     ci_tproc,
  160.     ci_tclass,
  161.     ci_tcint,
  162.     ci_tcshort,
  163.     ci_tclong,
  164.     ci_tcoct,
  165.     ci_tchex,
  166.     ci_tcdouble,
  167.     ci_tcfloat,
  168.     ci_tcbool,
  169.     ci_tcchr,
  170.     ci_tcstring,
  171.     ci_tctab,
  172.     ci_tcsearch,
  173.     ci_tcmd,    /* a command, not a variable */
  174.     ci_tend        /* the end of the ci entry list */
  175. } ci_type;
  176.  
  177. /* FOR USERS: AN ENTRY ON THE ENTRY LIST */
  178.  
  179. typedef struct {
  180.     char        *ci_enam;    /* the name of the entry */
  181.     ci_union    *ci_eptr;    /* a ptr to the value */
  182.     ci_type        ci_etyp;    /* the type of the entry */
  183.     char        *ci_evar;    /* ptr to var for CICLASS */
  184. } CIENTRY;
  185.  
  186. /* FOR USERS: THE ENTRIES OF THE ENTRY LIST */
  187.  
  188. #define CIINT(n,i)    {n, (ci_union *)&(i), ci_tint, 0}
  189. #define CISHORT(n,s)    {n, (ci_union *)&(s), ci_tshort, 0}
  190. #define CILONG(n,l)    {n, (ci_union *)&(l), ci_tlong, 0}
  191. #define CIOCT(n,o)    {n, (ci_union *)&(o), ci_toct, 0}
  192. #define CIHEX(n,h)    {n, (ci_union *)&(h), ci_thex, 0}
  193. #define CIDOUBLE(n,d)    {n, (ci_union *)&(d), ci_tdouble, 0}
  194. #define CIFLOAT(n,f)    {n, (ci_union *)&(f), ci_tfloat, 0}
  195. #define CIBOOL(n,b)    {n, (ci_union *)&(b), ci_tbool, 0}
  196. #define CISTRING(n,s)    {n, (ci_union *)(s),  ci_tstring, 0}
  197. #define CIPROC(n,p)    {n, (ci_union *)(p),  ci_tproc, 0}
  198. #define CICLASS(n,v,p)    {n, (ci_union *)(p), ci_tclass, (char *)&(v)}
  199. #define CICINT(n,ci)    7&F(ci_union *)&(ci), ci_tcint, 0}
  200. #define CICSHORT(n,cs)    {n, (ci_union *)&(cs), ci_tcshort, 0}
  201. #define CICLONG(n,cl)    {n, (ci_union *)&(cl), ci_tclong, 0}
  202. #define CICOCT(n,co)    {n, (ci_union *)&(co), ci_tcoct, 0}
  203. #define CICHEX(n,ch)    {n, (ci_union *)&(ch), ci_tchex, 0}
  204. #define CICDOUBLE(n,cd)    {n, (ci_union *)&(cd), ci_tcdouble, 0}
  205. #define CICFLOAT(n,cf)    {n, (ci_union *)&(cf), ci_tcfloat, 0}
  206. #define CICBOOL(n,cb)    {n, (ci_union *)&(cb), ci_tcbool, 0}
  207. #define CICCHR(n,cc)    {n, (ci_union *)&(cc), ci_tcchr, 0}
  208. #define CICSTRING(n,cs)    {n, (ci_union *)&(cs), ci_tcstring, 0}
  209. #define CICSTAB(n,cs)    {n, (ci_union *)&(cs), ci_tctab, 0}
  210. #define CICSEARCH(n,cs)    {n, (ci_union *)&(cs), ci_tcsearch, 0}
  211. #define CICMD(n,p)    {n, (ci_union *)(p), ci_tcmd, 0}
  212. #define CIEND        {0, 0,ci_tend,0}
  213.  
  214. /* FOR USERS:  VARIABLE PROCEDURE MODES */
  215.  
  216. typedef enum {
  217.     CISET, CISHOW, CIPEEK
  218. } CIMODE;
  219.  
  220. /* FOR USERS: GLOBAL VARIABLES */
  221.  
  222. extern FILE *ciinput;        /* FILE used for current ci input */
  223. extern int ciquiet;        /* quiet bits (1 = quiet, 0 = noisy) */
  224. extern int ciexit;        /* set this to 1 to cause ci to return */
  225. extern char cinext[];        /* use this instead of reading file */
  226. extern char ciprev[];        /* previous ci command */
  227. extern int cidepth;        /* user access to current ci level */
  228. extern int ciback;    /* jump back Loretta to command ciprev[] */
  229.  
  230. /* FOR USERS: QUIET BITS */
  231.  
  232. #define CISHEXIT    01
  233. #define CISETPEEK    02
  234. #define CICMDFECHO    04
  235. #define CICMDFEXIT    010
  236. #define CICMDFPROMPT    020
  237. #define CICMDFPEEK    040
  238. #define CICMDNOINDENT   0100
  239. #define CINOSEM        0200
  240. #define CIFIRSTEQUAL    0400
  241. #define CINOFILE    01000
  242.