00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "dthdr.h"
00018
00019 #ifdef DMALLOC
00020 #include "dmalloc.h"
00021 #endif
00022
00023 static char *Version = "\n@(#)cdt (AT&T Labs - kpv) 1999-11-01\0\n";
00024
00025
00026
00027
00028
00029
00030 #if __STD_C
00031 Dt_t *dtopen(Dtdisc_t * disc, Dtmethod_t * meth)
00032 #else
00033 Dt_t *dtopen(disc, meth)
00034 Dtdisc_t *disc;
00035 Dtmethod_t *meth;
00036 #endif
00037 {
00038 Dt_t *dt = (Dt_t *) Version;
00039 reg int e;
00040 Dtdata_t *data;
00041
00042 if (!disc || !meth)
00043 return NIL(Dt_t *);
00044
00045
00046 if (!(dt = (Dt_t *) malloc(sizeof(Dt_t))))
00047 return NIL(Dt_t *);
00048
00049
00050 dt->searchf = NIL(Dtsearch_f);
00051 dt->meth = NIL(Dtmethod_t *);
00052 dt->disc = NIL(Dtdisc_t *);
00053 dtdisc(dt, disc, 0);
00054 dt->nview = 0;
00055 dt->view = dt->walk = NIL(Dt_t *);
00056
00057 if (disc->eventf) {
00058 data = NIL(Dtdata_t *);
00059 if ((e =
00060 (*disc->eventf) (dt, DT_OPEN, (Void_t *) (&data),
00061 disc)) != 0) {
00062 if (e < 0 || !data || !(data->type & meth->type)) {
00063 free((Void_t *) dt);
00064 return NIL(Dt_t *);
00065 } else
00066 goto done;
00067 }
00068 }
00069
00070
00071 data =
00072 (Dtdata_t *) (dt->memoryf) (dt, NIL(Void_t *), sizeof(Dtdata_t),
00073 disc);
00074 if (!data) {
00075 free((Void_t *) dt);
00076 return NIL(Dt_t *);
00077 }
00078 data->type = meth->type;
00079 data->here = NIL(Dtlink_t *);
00080 data->htab = NIL(Dtlink_t **);
00081 data->ntab = data->size = data->loop = 0;
00082
00083 done:
00084 dt->data = data;
00085 dt->searchf = meth->searchf;
00086 dt->meth = meth;
00087
00088 return dt;
00089 }
00090
00091 #if __hppa
00092
00093
00094
00095
00096
00097
00098 #if __STD_C
00099 int _dt_dynamic_data(void)
00100 #else
00101 int _dt_dynamic_data()
00102 #endif
00103 {
00104 return (Dtset != 0) + (Dtlist != 0) + (Dttree != 0);
00105 }
00106
00107 #endif