7 /* dictionary memory manager
11 /* DICT *dict_alloc(dict_type, dict_name, size)
12 /* const char *dict_type;
13 /* const char *dict_name;
16 /* void dict_free(dict)
19 /* dict_alloc() allocates memory for a dictionary structure of
20 /* \fIsize\fR bytes, initializes all generic dictionary
21 /* properties to default settings,
22 /* and installs default methods that do not support any operation.
23 /* The caller is supposed to override the default methods with
24 /* ones that it supports.
25 /* The purpose of the default methods is to trap an attempt to
26 /* invoke an unsupported method.
28 /* dict_free() releases memory and cleans up after dict_alloc().
29 /* It is up to the caller to dispose of any memory that was allocated
34 /* The official name for this type of dictionary, as used by
35 /* dict_open(3) etc. This is stored under the \fBtype\fR
38 /* Dictionary name. This is stored as the \fBname\fR member.
40 /* The size in bytes of the dictionary subclass structure instance.
44 /* Fatal errors: the process invokes a default method.
48 /* The Secure Mailer license must be distributed with this software.
51 /* IBM T.J. Watson Research
53 /* Yorktown Heights, NY 10598, USA
56 /* System libraries. */
60 /* Utility library. */
66 /* dict_default_lookup - trap unimplemented operation */
68 static const char *dict_default_lookup(DICT
*dict
, const char *unused_key
)
70 msg_fatal("%s table %s: lookup operation is not supported",
71 dict
->type
, dict
->name
);
74 /* dict_default_update - trap unimplemented operation */
76 static void dict_default_update(DICT
*dict
, const char *unused_key
,
77 const char *unused_value
)
79 msg_fatal("%s table %s: update operation is not supported",
80 dict
->type
, dict
->name
);
83 /* dict_default_delete - trap unimplemented operation */
85 static int dict_default_delete(DICT
*dict
, const char *unused_key
)
87 msg_fatal("%s table %s: delete operation is not supported",
88 dict
->type
, dict
->name
);
91 /* dict_default_sequence - trap unimplemented operation */
93 static int dict_default_sequence(DICT
*dict
, int unused_function
,
94 const char **unused_key
, const char **unused_value
)
96 msg_fatal("%s table %s: sequence operation is not supported",
97 dict
->type
, dict
->name
);
100 /* dict_default_close - trap unimplemented operation */
102 static void dict_default_close(DICT
*dict
)
104 msg_fatal("%s table %s: close operation is not supported",
105 dict
->type
, dict
->name
);
108 /* dict_alloc - allocate dictionary object, initialize super-class */
110 DICT
*dict_alloc(const char *dict_type
, const char *dict_name
, ssize_t size
)
112 DICT
*dict
= (DICT
*) mymalloc(size
);
114 dict
->type
= mystrdup(dict_type
);
115 dict
->name
= mystrdup(dict_name
);
116 dict
->flags
= DICT_FLAG_FIXED
;
117 dict
->lookup
= dict_default_lookup
;
118 dict
->update
= dict_default_update
;
119 dict
->delete = dict_default_delete
;
120 dict
->sequence
= dict_default_sequence
;
121 dict
->close
= dict_default_close
;
129 /* dict_free - super-class destructor */
131 void dict_free(DICT
*dict
)
135 myfree((char *) dict
);