annotate toolboxes/graph_visualisation/include/graphviz/cdt.h @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 /* $Id: cdt.h,v 1.11 2009/07/24 21:10:19 arif Exp $ $Revision: 1.11 $ */
wolffd@0 2 /* vim:set shiftwidth=4 ts=8: */
wolffd@0 3
wolffd@0 4 /**********************************************************
wolffd@0 5 * This software is part of the graphviz package *
wolffd@0 6 * http://www.graphviz.org/ *
wolffd@0 7 * *
wolffd@0 8 * Copyright (c) 1994-2004 AT&T Corp. *
wolffd@0 9 * and is licensed under the *
wolffd@0 10 * Common Public License, Version 1.0 *
wolffd@0 11 * by AT&T Corp. *
wolffd@0 12 * *
wolffd@0 13 * Information and Software Systems Research *
wolffd@0 14 * AT&T Research, Florham Park NJ *
wolffd@0 15 **********************************************************/
wolffd@0 16
wolffd@0 17 #ifndef _CDT_H
wolffd@0 18 #define _CDT_H 1
wolffd@0 19
wolffd@0 20 /* Public interface for the dictionary library
wolffd@0 21 **
wolffd@0 22 ** Written by Kiem-Phong Vo (05/25/96)
wolffd@0 23 */
wolffd@0 24
wolffd@0 25 #define CDT_VERSION 19991101L
wolffd@0 26
wolffd@0 27 #define Void_t void
wolffd@0 28 #define _ARG_(x) x
wolffd@0 29 #ifndef NIL
wolffd@0 30 #define NIL(type) ((type)0)
wolffd@0 31 #endif
wolffd@0 32
wolffd@0 33 #include <string.h>
wolffd@0 34
wolffd@0 35 #if _PACKAGE_ast
wolffd@0 36 # include <ast_std.h>
wolffd@0 37 #elif _BLD_cdt
wolffd@0 38 # include "ast_common.h"
wolffd@0 39 #endif
wolffd@0 40
wolffd@0 41 #ifdef __cplusplus
wolffd@0 42 extern "C" {
wolffd@0 43 #endif
wolffd@0 44
wolffd@0 45 typedef struct _dtlink_s Dtlink_t;
wolffd@0 46 typedef struct _dthold_s Dthold_t;
wolffd@0 47 typedef struct _dtdisc_s Dtdisc_t;
wolffd@0 48 typedef struct _dtmethod_s Dtmethod_t;
wolffd@0 49 typedef struct _dtdata_s Dtdata_t;
wolffd@0 50 typedef struct _dt_s Dt_t;
wolffd@0 51 typedef struct _dt_s Dict_t; /* for libdict compatibility */
wolffd@0 52 typedef struct _dtstat_s Dtstat_t;
wolffd@0 53 typedef Void_t *(*Dtsearch_f) _ARG_((Dt_t *, Void_t *, int));
wolffd@0 54 typedef Void_t *(*Dtmake_f) _ARG_((Dt_t *, Void_t *, Dtdisc_t *));
wolffd@0 55 typedef void (*Dtfree_f) _ARG_((Dt_t *, Void_t *, Dtdisc_t *));
wolffd@0 56 typedef int (*Dtcompar_f)
wolffd@0 57 _ARG_((Dt_t *, Void_t *, Void_t *, Dtdisc_t *));
wolffd@0 58 typedef unsigned int (*Dthash_f) _ARG_((Dt_t *, Void_t *, Dtdisc_t *));
wolffd@0 59 typedef Void_t *(*Dtmemory_f)
wolffd@0 60 _ARG_((Dt_t *, Void_t *, size_t, Dtdisc_t *));
wolffd@0 61 typedef int (*Dtevent_f) _ARG_((Dt_t *, int, Void_t *, Dtdisc_t *));
wolffd@0 62
wolffd@0 63 struct _dtlink_s {
wolffd@0 64 Dtlink_t *right; /* right child */
wolffd@0 65 union {
wolffd@0 66 unsigned int _hash; /* hash value */
wolffd@0 67 Dtlink_t *_left; /* left child */
wolffd@0 68 } hl;
wolffd@0 69 };
wolffd@0 70
wolffd@0 71 /* private structure to hold an object */
wolffd@0 72 struct _dthold_s {
wolffd@0 73 Dtlink_t hdr; /* header */
wolffd@0 74 Void_t *obj; /* user object */
wolffd@0 75 };
wolffd@0 76
wolffd@0 77 /* method to manipulate dictionary structure */
wolffd@0 78 struct _dtmethod_s {
wolffd@0 79 Dtsearch_f searchf; /* search function */
wolffd@0 80 int type; /* type of operation */
wolffd@0 81 };
wolffd@0 82
wolffd@0 83 /* stuff that may be in shared memory */
wolffd@0 84 struct _dtdata_s {
wolffd@0 85 int type; /* type of dictionary */
wolffd@0 86 Dtlink_t *here; /* finger to last search element */
wolffd@0 87 union {
wolffd@0 88 Dtlink_t **_htab; /* hash table */
wolffd@0 89 Dtlink_t *_head; /* linked list */
wolffd@0 90 } hh;
wolffd@0 91 int ntab; /* number of hash slots */
wolffd@0 92 int size; /* number of objects */
wolffd@0 93 int loop; /* number of nested loops */
wolffd@0 94 };
wolffd@0 95
wolffd@0 96 /* structure to hold methods that manipulate an object */
wolffd@0 97 struct _dtdisc_s {
wolffd@0 98 int key; /* where the key begins in an object */
wolffd@0 99 int size; /* key size and type */
wolffd@0 100 int link; /* offset to Dtlink_t field */
wolffd@0 101 Dtmake_f makef; /* object constructor */
wolffd@0 102 Dtfree_f freef; /* object destructor */
wolffd@0 103 Dtcompar_f comparf; /* to compare two objects */
wolffd@0 104 Dthash_f hashf; /* to compute hash value of an object */
wolffd@0 105 Dtmemory_f memoryf; /* to allocate/free memory */
wolffd@0 106 Dtevent_f eventf; /* to process events */
wolffd@0 107 };
wolffd@0 108
wolffd@0 109 /* the dictionary structure itself */
wolffd@0 110 struct _dt_s {
wolffd@0 111 Dtsearch_f searchf; /* search function */
wolffd@0 112 Dtdisc_t *disc; /* method to manipulate objs */
wolffd@0 113 Dtdata_t *data; /* sharable data */
wolffd@0 114 Dtmemory_f memoryf; /* function to alloc/free memory */
wolffd@0 115 Dtmethod_t *meth; /* dictionary method */
wolffd@0 116 int type; /* type information */
wolffd@0 117 int nview; /* number of parent view dictionaries */
wolffd@0 118 Dt_t *view; /* next on viewpath */
wolffd@0 119 Dt_t *walk; /* dictionary being walked */
wolffd@0 120 };
wolffd@0 121
wolffd@0 122 /* structure to get status of a dictionary */
wolffd@0 123 struct _dtstat_s {
wolffd@0 124 int dt_meth; /* method type */
wolffd@0 125 int dt_size; /* number of elements */
wolffd@0 126 int dt_n; /* number of chains or levels */
wolffd@0 127 int dt_max; /* max size of a chain or a level */
wolffd@0 128 int *dt_count; /* counts of chains or levels by size */
wolffd@0 129 };
wolffd@0 130
wolffd@0 131 /* supported storage methods */
wolffd@0 132 #define DT_SET 0000001 /* set with unique elements */
wolffd@0 133 #define DT_BAG 0000002 /* multiset */
wolffd@0 134 #define DT_OSET 0000004 /* ordered set (self-adjusting tree) */
wolffd@0 135 #define DT_OBAG 0000010 /* ordered multiset */
wolffd@0 136 #define DT_LIST 0000020 /* linked list */
wolffd@0 137 #define DT_STACK 0000040 /* stack */
wolffd@0 138 #define DT_QUEUE 0000100 /* queue */
wolffd@0 139 #define DT_METHODS 0000177 /* all currently supported methods */
wolffd@0 140
wolffd@0 141 /* asserts to dtdisc() */
wolffd@0 142 #define DT_SAMECMP 0000001 /* compare methods equivalent */
wolffd@0 143 #define DT_SAMEHASH 0000002 /* hash methods equivalent */
wolffd@0 144
wolffd@0 145 /* types of search */
wolffd@0 146 #define DT_INSERT 0000001 /* insert object if not found */
wolffd@0 147 #define DT_DELETE 0000002 /* delete object if found */
wolffd@0 148 #define DT_SEARCH 0000004 /* look for an object */
wolffd@0 149 #define DT_NEXT 0000010 /* look for next element */
wolffd@0 150 #define DT_PREV 0000020 /* find previous element */
wolffd@0 151 #define DT_RENEW 0000040 /* renewing an object */
wolffd@0 152 #define DT_CLEAR 0000100 /* clearing all objects */
wolffd@0 153 #define DT_FIRST 0000200 /* get first object */
wolffd@0 154 #define DT_LAST 0000400 /* get last object */
wolffd@0 155 #define DT_MATCH 0001000 /* find object matching key */
wolffd@0 156 #define DT_VSEARCH 0002000 /* search using internal representation */
wolffd@0 157 #define DT_ATTACH 0004000 /* attach an object to the dictionary */
wolffd@0 158 #define DT_DETACH 0010000 /* attach an object to the dictionary */
wolffd@0 159
wolffd@0 160 /* events */
wolffd@0 161 #define DT_OPEN 1 /* a dictionary is being opened */
wolffd@0 162 #define DT_CLOSE 2 /* a dictionary is being closed */
wolffd@0 163 #define DT_DISC 3 /* discipline is about to be changed */
wolffd@0 164 #define DT_METH 4 /* method is about to be changed */
wolffd@0 165
wolffd@0 166
wolffd@0 167 #if _BLD_cdt && defined(__EXPORT__)
wolffd@0 168 #define extern __EXPORT__
wolffd@0 169 #endif
wolffd@0 170 #if !_BLD_cdt && defined(GVDLL)
wolffd@0 171 #define extern __declspec(dllimport)
wolffd@0 172 #endif
wolffd@0 173 #if !_BLD_cdt && defined(__IMPORT__)
wolffd@0 174 #define extern __IMPORT__
wolffd@0 175 #endif
wolffd@0 176 /*visual studio*/
wolffd@0 177 #ifdef WIN32_DLL
wolffd@0 178 #ifndef CDT_EXPORTS
wolffd@0 179 #define extern __declspec(dllimport)
wolffd@0 180 #else
wolffd@0 181 #define extern __declspec(dllexport)
wolffd@0 182 #endif
wolffd@0 183 #endif
wolffd@0 184 /*end visual studio*/
wolffd@0 185
wolffd@0 186
wolffd@0 187 extern Dtmethod_t *Dtset;
wolffd@0 188 extern Dtmethod_t *Dtbag;
wolffd@0 189 extern Dtmethod_t *Dtoset;
wolffd@0 190 extern Dtmethod_t *Dtobag;
wolffd@0 191 extern Dtmethod_t *Dtlist;
wolffd@0 192 extern Dtmethod_t *Dtstack;
wolffd@0 193 extern Dtmethod_t *Dtqueue;
wolffd@0 194
wolffd@0 195 /* compatibility stuff; will go away */
wolffd@0 196 #ifndef KPVDEL
wolffd@0 197 extern Dtmethod_t *Dtorder;
wolffd@0 198 extern Dtmethod_t *Dttree;
wolffd@0 199 extern Dtmethod_t *Dthash;
wolffd@0 200 extern Dtmethod_t _Dttree;
wolffd@0 201 extern Dtmethod_t _Dthash;
wolffd@0 202 extern Dtmethod_t _Dtlist;
wolffd@0 203 extern Dtmethod_t _Dtqueue;
wolffd@0 204 extern Dtmethod_t _Dtstack;
wolffd@0 205 #endif
wolffd@0 206
wolffd@0 207 #undef extern
wolffd@0 208 #if _BLD_cdt && defined(__EXPORT__)
wolffd@0 209 #define extern __EXPORT__
wolffd@0 210 #endif
wolffd@0 211 #if !_BLD_cdt && defined(__IMPORT__) && defined(__EXPORT__)
wolffd@0 212 #define extern __IMPORT__
wolffd@0 213 #endif
wolffd@0 214 extern Dt_t *dtopen _ARG_((Dtdisc_t *, Dtmethod_t *));
wolffd@0 215 extern int dtclose _ARG_((Dt_t *));
wolffd@0 216 extern Dt_t *dtview _ARG_((Dt_t *, Dt_t *));
wolffd@0 217 extern Dtdisc_t *dtdisc _ARG_((Dt_t * dt, Dtdisc_t *, int));
wolffd@0 218 extern Dtmethod_t *dtmethod _ARG_((Dt_t *, Dtmethod_t *));
wolffd@0 219
wolffd@0 220 extern Dtlink_t *dtflatten _ARG_((Dt_t *));
wolffd@0 221 extern Dtlink_t *dtextract _ARG_((Dt_t *));
wolffd@0 222 extern int dtrestore _ARG_((Dt_t *, Dtlink_t *));
wolffd@0 223
wolffd@0 224 extern int dtwalk
wolffd@0 225 _ARG_((Dt_t *, int (*)(Dt_t *, Void_t *, Void_t *), Void_t *));
wolffd@0 226
wolffd@0 227 extern Void_t *dtrenew _ARG_((Dt_t *, Void_t *));
wolffd@0 228
wolffd@0 229 extern int dtsize _ARG_((Dt_t *));
wolffd@0 230 extern int dtstat _ARG_((Dt_t *, Dtstat_t *, int));
wolffd@0 231 extern unsigned int dtstrhash _ARG_((unsigned int, Void_t *, int));
wolffd@0 232
wolffd@0 233 #undef extern
wolffd@0 234
wolffd@0 235 #define _DT_(d) ((Dt_t*)(d))
wolffd@0 236 #define dtvnext(d) (_DT_(d)->view)
wolffd@0 237 #define dtvcount(d) (_DT_(d)->nview)
wolffd@0 238 #define dtvhere(d) (_DT_(d)->walk)
wolffd@0 239 #define dtlink(d,e) (((Dtlink_t*)(e))->right)
wolffd@0 240 #define dtobj(d,e) ((_DT_(d)->disc->link < 0) ? (((Dthold_t*)(e))->obj) : \
wolffd@0 241 (Void_t*)((char*)(e) - _DT_(d)->disc->link) )
wolffd@0 242 #define dtfinger(d) (_DT_(d)->data->here ? dtobj((d),_DT_(d)->data->here) : \
wolffd@0 243 (Void_t*)(0) )
wolffd@0 244 #define dtfirst(d) (*(_DT_(d)->searchf))((d),(Void_t*)(0),DT_FIRST)
wolffd@0 245 #define dtnext(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_NEXT)
wolffd@0 246 #define dtlast(d) (*(_DT_(d)->searchf))((d),(Void_t*)(0),DT_LAST)
wolffd@0 247 #define dtprev(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_PREV)
wolffd@0 248 #define dtsearch(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_SEARCH)
wolffd@0 249 #define dtmatch(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_MATCH)
wolffd@0 250 #define dtinsert(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_INSERT)
wolffd@0 251 #define dtdelete(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_DELETE)
wolffd@0 252 #define dtattach(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_ATTACH)
wolffd@0 253 #define dtdetach(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_DETACH)
wolffd@0 254 #define dtclear(d) (*(_DT_(d)->searchf))((d),(Void_t*)(0),DT_CLEAR)
wolffd@0 255 /* A linear congruential hash: h*17 + c + 97531 */
wolffd@0 256 #define dtcharhash(h,c) ((((unsigned int)(h))<<4) + ((unsigned int)(h)) + \
wolffd@0 257 ((unsigned char)(c)) + 97531 )
wolffd@0 258 #ifdef __cplusplus
wolffd@0 259 }
wolffd@0 260 #endif
wolffd@0 261 #endif /* _CDT_H */