Graphviz
2.41.20171026.1811
Main Page
Data Structures
Files
File List
Globals
lib
cdt
dtopen.c
Go to the documentation of this file.
1
#include "
dthdr.h
"
2
static
char
*
Version
=
"\n@(#)$Id$\0\n"
;
3
4
/* Make a new dictionary
5
**
6
** Written by Kiem-Phong Vo (5/25/96)
7
*/
8
9
Dt_t
*
dtopen
(
Dtdisc_t
* disc,
Dtmethod_t
* meth)
10
{
11
Dt_t
* dt = (
Dt_t
*)
Version
;
/* shut-up unuse warning */
12
reg
int
e;
13
Dtdata_t
*
data
;
14
15
if
(!disc || !meth)
16
return
NIL
(
Dt_t
*);
17
18
/* allocate space for dictionary */
19
if
(!(dt = (
Dt_t
*) malloc(
sizeof
(
Dt_t
))))
20
return
NIL
(
Dt_t
*);
21
22
/* initialize all absolutely private data */
23
dt->
searchf
=
NIL
(
Dtsearch_f
);
24
dt->
meth
=
NIL
(
Dtmethod_t
*);
25
dt->
disc
=
NIL
(
Dtdisc_t
*);
26
dtdisc
(dt,disc,0);
27
dt->
type
=
DT_MALLOC
;
28
dt->
nview
= 0;
29
dt->
view
= dt->
walk
=
NIL
(
Dt_t
*);
30
dt->
user
=
NIL
(
void
*);
31
32
if
(disc->
eventf
)
33
{
/* if shared/persistent dictionary, get existing data */
34
data =
NIL
(
Dtdata_t
*);
35
if
((e = (*disc->
eventf
)(dt,
DT_OPEN
,(
void
*)(&data),disc)) < 0)
36
goto
err_open;
37
else
if
(e > 0)
38
{
if
(data)
39
{
if
(data->
type
&meth->
type
)
40
goto
done;
41
else
goto
err_open;
42
}
43
44
if
(!disc->
memoryf
)
45
goto
err_open;
46
47
free((
void
*)dt);
48
if
(!(dt = (*disc->
memoryf
)(0, 0,
sizeof
(
Dt_t
), disc)) )
49
return
NIL
(
Dt_t
*);
50
dt->
searchf
=
NIL
(
Dtsearch_f
);
51
dt->
meth
=
NIL
(
Dtmethod_t
*);
52
dt->
disc
=
NIL
(
Dtdisc_t
*);
53
dtdisc
(dt,disc,0);
54
dt->
type
=
DT_MEMORYF
;
55
dt->
nview
= 0;
56
dt->
view
= dt->
walk
=
NIL
(
Dt_t
*);
57
}
58
}
59
60
/* allocate sharable data */
61
if
(!(data = (
Dtdata_t
*)(dt->
memoryf
)(dt,
NIL
(
void
*),
sizeof
(
Dtdata_t
),disc)) )
62
{ err_open:
63
free((
void
*)dt);
64
return
NIL
(
Dt_t
*);
65
}
66
67
data->
type
= meth->
type
;
68
data->
here
=
NIL
(
Dtlink_t
*);
69
data->htab =
NIL
(
Dtlink_t
**);
70
data->
ntab
= data->
size
= data->
loop
= 0;
71
data->
minp
= 0;
72
73
done:
74
dt->
data
= data;
75
dt->
searchf
= meth->
searchf
;
76
dt->
meth
= meth;
77
78
if
(disc->
eventf
)
79
(*disc->
eventf
)(dt,
DT_ENDOPEN
, (
void
*)dt, disc);
80
81
return
dt;
82
}
_dt_s::disc
Dtdisc_t * disc
Definition:
cdt.h:101
_dt_s::searchf
Dtsearch_f searchf
Definition:
cdt.h:100
_dt_s::type
int type
Definition:
cdt.h:105
_dtdisc_s::memoryf
Dtmemory_f memoryf
Definition:
cdt.h:88
_dtmethod_s::type
int type
Definition:
cdt.h:61
reg
#define reg
Definition:
dthdr.h:14
_dtdisc_s::eventf
Dtevent_f eventf
Definition:
cdt.h:89
_dtdata_s
Definition:
cdt.h:65
dtdisc
CDT_API Dtdisc_t * dtdisc(Dt_t *dt, Dtdisc_t *, int)
Definition:
dtdisc.c:22
_dtdisc_s
Definition:
cdt.h:80
DT_ENDOPEN
#define DT_ENDOPEN
Definition:
cdt.h:160
dtopen
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
Definition:
dtopen.c:9
_dtmethod_s
Definition:
cdt.h:59
_dt_s::walk
Dt_t * walk
Definition:
cdt.h:108
DT_MALLOC
#define DT_MALLOC
Definition:
dthdr.h:26
_dtdata_s::size
int size
Definition:
cdt.h:73
NIL
#define NIL(t)
Definition:
dthdr.h:13
DT_OPEN
#define DT_OPEN
Definition:
cdt.h:156
_dtlink_s
Definition:
cdt.h:44
DT_MEMORYF
#define DT_MEMORYF
Definition:
dthdr.h:27
_dt_s::user
void * user
Definition:
cdt.h:109
Dtsearch_f
void *(* Dtsearch_f)(Dt_t *, void *, int)
Definition:
cdt.h:37
_dtmethod_s::searchf
Dtsearch_f searchf
Definition:
cdt.h:60
_dt_s::view
Dt_t * view
Definition:
cdt.h:107
_dt_s::nview
int nview
Definition:
cdt.h:106
_dtdata_s::here
Dtlink_t * here
Definition:
cdt.h:67
dthdr.h
_dt_s::meth
Dtmethod_t * meth
Definition:
cdt.h:104
_dtdata_s::ntab
int ntab
Definition:
cdt.h:72
_dt_s
Definition:
cdt.h:99
_dtdata_s::minp
int minp
Definition:
cdt.h:75
_dt_s::data
Dtdata_t * data
Definition:
cdt.h:102
_dtdata_s::type
int type
Definition:
cdt.h:66
Version
EXTERN char * Version
Definition:
globals.h:55
_dtdata_s::loop
int loop
Definition:
cdt.h:74
_dt_s::memoryf
Dtmemory_f memoryf
Definition:
cdt.h:103
data
Definition:
legal.c:60
Generated by
1.8.5