home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / libcs / include / ci.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-12  |  8.7 KB  |  273 lines

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