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 &&
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)
131 newtable->
used = (*table)->used;
146 bucket->
name = strdup(name);
149 while (*item) item = &(*item)->
next;
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)
static void rpmhookTableAddItem(rpmhookTable *table, const char *name, rpmhookFunc func, void *data)
struct rpmhookItem_s * next
struct rpmhookItem_s * rpmhookItem
struct rpmhookTable_s * rpmhookTable
rpmhookArgs rpmhookArgsNew(int argc)
static void rpmhookTableCallArgs(rpmhookTable *table, const char *name, rpmhookArgs args)
rpmhookArgs rpmhookArgsFree(rpmhookArgs args)
void rpmhookUnregisterAny(const char *name, rpmhookFunc func)
static rpmhookTable globalTable
void rpmhookUnregister(const char *name, rpmhookFunc func, void *data)
struct rpmhookArgs_s * rpmhookArgs
struct rpmhookBucket_s * rpmhookBucket
static rpmhookTable rpmhookTableNew(int size)
void * xcalloc(size_t nmemb, size_t size)
#define RPMHOOK_TABLE_INITSIZE
fprintf(stderr,"--> %s(%p,%p,%p) sig %p sigp %p\n", __FUNCTION__, dig, t, rsactx, sig, sigp)
static void rpmhookTableRehash(rpmhookTable *table)
static rpmhookArgs rpmhookArgsParse(const char *argt, va_list ap)
static int rpmhookTableFindBucket(rpmhookTable *table, const char *name)
struct rpmhookBucket_s bucket[1]
return strcmp(ame->name, bme->name)
static void rpmhookTableDelItem(rpmhookTable *table, const char *name, rpmhookFunc func, void *data, int matchfunc, int matchdata)
void rpmhookUnregisterAll(const char *name)
void rpmhookRegister(const char *name, rpmhookFunc func, void *data)
void rpmhookCallArgs(const char *name, rpmhookArgs args)
void rpmhookCall(const char *name, const char *argt,...)
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
int(* rpmhookFunc)(rpmhookArgs args, void *data)