home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / lib / PEX / include / css.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-29  |  6.5 KB  |  205 lines

  1. /* $XConsortium: css.h,v 5.2 91/03/29 14:02:42 rws Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright (c) 1989,1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Sun Microsystems,
  13. the X Consortium, and MIT not be used in advertising or publicity 
  14. pertaining to distribution of the software without specific, written 
  15. prior permission.  
  16.  
  17. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
  18. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
  19. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
  20. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24. ******************************************************************/
  25.  
  26. #ifndef PHG_CSS_H_INCLUDED
  27. #define PHG_CSS_H_INCLUDED
  28.  
  29. #include <sys/types.h>
  30.  
  31. /* structure element data */
  32. typedef union {
  33.     Pint    idata;
  34.     caddr_t    ptr;
  35. } Css_eldata;
  36.  
  37. typedef struct _set_element {
  38.     caddr_t            key;
  39.     caddr_t            data;
  40.     struct _set_element        *next;
  41. } Css_set_element;
  42.  
  43. typedef struct {
  44.     int            data_type;    /* type of data associated w/ key */
  45.     int            num_elements;    /* number of elements in the set */
  46.     Css_set_element    *elements;    /* elements of this set */
  47.     Css_set_element    *last_element;    /* last element in 'elements' */
  48. } Css_set;
  49.  
  50. typedef Css_set    *Css_set_ptr;
  51.  
  52. #define SET_DATA_SET        (0x0)
  53. #define SET_DATA_SET_OF_SETS    (0x1)
  54.  
  55. /* structure element */
  56. typedef struct _Css_structel {
  57.     Pelem_type            eltype;        /* element type */
  58.     Css_eldata            eldata;        /* element data */
  59.     struct _Css_structel    *prev;        /* backward link */
  60.     struct _Css_structel    *next;        /* forward link */
  61. } Css_structel;
  62.  
  63. typedef struct _Css_ws_on {
  64.     Ws_handle    wsh;
  65.     Pint    count;
  66. } Css_ws_on;
  67.  
  68. typedef struct _Css_ws_on *Css_ws_list;
  69.  
  70. /* structure state list */
  71. typedef struct _Css_ssl {
  72.     Pint        struct_id;        /* structure id */
  73.     Css_ws_list        ws_posted_to;        /* list of WS posted to */
  74.     Css_ws_list        ws_appear_on;        /* list of WS I appear on */
  75.     Css_set_ptr        refer_to_me;    /* set of structs which refer to me */
  76.     Css_set_ptr        i_refer_to;        /* set of structs I refer to */
  77.     Pint        num_el;         /* number of elements */
  78.     El_handle        first_el;        /* first structure element */
  79.     El_handle        last_el;        /* last structure element */
  80. } Css_ssl;
  81.  
  82. typedef int        (*Css_func)();
  83.  
  84. /* because list of types starts at 0 */
  85. #define NUM_EL_TYPES    PELEM_NUM_EL_TYPES
  86.  
  87. typedef struct _hash_block {
  88.     Pint        struct_id;    /* structure id we're looking for */
  89.     Struct_handle    struct_ptr;    /* pointer to it */
  90.     struct _hash_block    *next;        /* next block */
  91. } Css_hash_block;
  92.  
  93. typedef struct {
  94.     Css_hash_block    **table;    /* the table */
  95.     int            size;        /* size of the table */
  96.     int            nstructs;    /* number of structures in table */
  97. } Css_struct_tab;
  98.  
  99. typedef enum {                    /* type of structure store */
  100.     SSH_CSS,                    /* central structure store */
  101.     SSH_AR                    /* archive structure store */
  102. } Css_ssh_type;
  103.  
  104. typedef struct _Css_struct {
  105.     Css_func        el_funcs[NUM_EL_TYPES];    /* func vectors for el data */
  106.     Css_struct_tab    *stab;            /* structure table */
  107.     Struct_handle    open_struct;        /* pointer to open structure */
  108.     El_handle        el_ptr;            /* current element pointer*/
  109.     Pint        el_index;        /* current element index */
  110.     Pedit_mode        edit_mode;
  111.     Err_handle        erh;
  112.     caddr_t        mem;            /* mem block for general use */
  113.     int            mem_size;        /* size of memory block */
  114.     Css_ws_list        ws_list;        /* list of ws handles */
  115.     Css_ssh_type    ssh_type;        /* type of structure store */
  116. } Css_struct;
  117.  
  118. extern Css_handle
  119.     phg_css_init();
  120.  
  121. extern El_handle
  122.     phg_css_set_ep();
  123.  
  124. extern Struct_handle
  125.     phg_css_close_struct(),
  126.     phg_css_open_struct(),
  127.     phg_css_post(),
  128.     phg_css_unpost(),
  129.     phg_css_stab_search();
  130.  
  131. extern Css_ws_list
  132.     phg_css_ar_retrieve(),
  133.     phg_css_change_struct_id(),
  134.     phg_css_change_struct_idrefs(),
  135.     phg_css_change_struct_refs(),
  136.     phg_css_get_ws_on();
  137.  
  138. extern void
  139.     phg_css_archive(),
  140.     phg_css_delete_all_structs(),
  141.     phg_css_delete_el(),
  142.     phg_css_delete_net(),
  143.     phg_css_delete_struct(),
  144.     phg_css_destroy(),
  145.     phg_css_el_delete_list(),
  146.     phg_css_inq_conf(),
  147.     phg_css_inq_el_content(),
  148.     phg_css_inq_el_type_size(),
  149.     phg_css_inq_hierarchy(),
  150.     phg_css_inq_struct_status(),
  151.     phg_css_inq_struct_ids(),
  152.     phg_css_inq_ws_posted(),
  153.     phg_css_unpost_all();
  154.  
  155. extern int
  156.     phg_css_add_elem(),
  157.     phg_css_copy_struct(),
  158.     phg_css_ws_appearances(),
  159.     phg_css_ws_posted();
  160.  
  161. #define CSS_CUR_STRUCT_ID(cssh)    ((cssh)->open_struct->struct_id)
  162. #define CSS_CUR_STRUCTP(cssh)    ((cssh)->open_struct)
  163. #define CSS_CUR_ELP(cssh)    ((cssh)->el_ptr)
  164. #define CSS_INQ_EL_INDEX(cssh)    ((cssh)->el_index)
  165. #define CSS_EDIT_MODE(cssh)    ((cssh)->edit_mode)
  166. #define CSS_SET_EDIT_MODE(cssh, mode)    ((cssh)->edit_mode = (mode))
  167. #define CSS_STRUCT_EXISTS(cssh, structid) \
  168.     phg_css_stab_search( (cssh)->stab, (structid) )
  169. #define CSS_GET_WS_ON(structp)    ((structp) ? (structp)->ws_appear_on : NULL)
  170. #define CSS_STRUCT_HAS_DESCENDANTS(structp) \
  171.     ((structp)->i_refer_to->num_elements)
  172.  
  173. /* caveat emptor - this macro doesn't test for NULLs.  It therefore returns
  174.  * TRUE incorrectly if there is NOT an open structure and the structp argument
  175.  * is NULL.  The caller generally knows one or both of these conditions
  176.  * is false, so there's little point in having the macro check it again .
  177.  */
  178. #define CSS_STRUCT_IS_OPEN(cssh, structp) ((cssh)->open_struct==(structp))
  179.  
  180. /* counts backwards to get the sequential element index for the given elptr */
  181. #define CSS_GET_EL_INDEX(elptr, elindex)    \
  182.   { register El_handle _elptr = elptr;        \
  183.                         \
  184.     (elindex) = 0;                \
  185.     while (_elptr->prev) {            \
  186.     (elindex)++;                \
  187.     _elptr = _elptr->prev;            \
  188.     }                        \
  189.   }
  190.  
  191. /* use element index to find the appropriate element pointer */
  192. #define CSS_GET_EL_PTR(structp, elindex, elptr)        \
  193.   { register int _elindex = elindex;            \
  194.                             \
  195.     if (_elindex<=0 || _elindex>(structp)->num_el)    \
  196.     (elptr) = NULL;                    \
  197.     else {                        \
  198.     (elptr) = (structp)->first_el;            \
  199.     while (_elindex--)                \
  200.         (elptr) = (elptr)->next;            \
  201.     }                            \
  202.   }
  203.  
  204. #endif
  205.