11 #define RPMHOOK_TABLE_INITSIZE 256
12 #define RPMHOOK_BUCKET_INITSIZE 5
37 sizeof(*args) +
sizeof(args->
argv) * (argc-1));
54 sizeof(*table) +
sizeof(table->
bucket) * (size-1));
65 for (i = 0; i != table->
size; i++) {
71 nextItem = item->
next;
88 unsigned long perturb;
89 unsigned long hash = 0;
90 unsigned char *bp = (
unsigned char *)name;
91 unsigned char *be = bp + strlen(name);
95 if (((*table)->used/2)*3 > (*table)->size)
98 hash ^= (
unsigned long)*bp++;
99 hash *= (
unsigned long)0x01000193;
102 ret = hash % (*table)->size;
103 bucket = &(*table)->bucket[ret];
104 while (bucket->
name &&
105 (bucket->
hash != hash || strcmp(bucket->
name, name) != 0)) {
108 ret = ((ret << 2) + ret + perturb + 1) % (*table)->size;
111 bucket = &(*table)->bucket[ret];
124 for (; i != (*table)->size; i++) {
125 if ((*table)->bucket[i].name == NULL)
128 newtable->
bucket[n].
name = (*table)->bucket[i].name;
129 newtable->
bucket[n].
item = (*table)->bucket[i].item;
131 newtable->
used = (*table)->used;
146 bucket->
name = strdup(name);
149 while (*item) item = &(*item)->
next;
150 *item =
xcalloc(1,
sizeof(**item));
151 (*item)->func = func;
153 (*item)->data = data;
159 int matchfunc,
int matchdata)
168 nextItem = item->
next;
169 if ((!matchfunc || item->
func == func) &&
170 (!matchdata || item->
data == data)) {
173 lastItem->
next = nextItem;
175 bucket->
item = nextItem;
199 for (i = 0; i != args->
argc; i++) {
202 args->
argv[i].
s = va_arg(ap,
char *);
205 args->
argv[i].
i = va_arg(ap,
int);
208 args->
argv[i].
f = (float)va_arg(ap,
double);
211 args->
argv[i].
p = va_arg(ap,
void *);
215 fprintf(stderr,
"error: unsupported type '%c' as "
216 "a hook argument\n", argt[i]);
231 if (item->
func(args, item->
data) != 0)
244 if (globalTable == NULL)
251 if (globalTable != NULL)
257 if (globalTable != NULL)
263 if (globalTable != NULL)
269 if (globalTable != NULL) {
285 if (globalTable != NULL)