Lines Matching full:stack
2 * services/modstack.c - stack of modules
39 * This file contains functions to help maintain a stack of modules.
92 modstack_init(struct module_stack* stack) in modstack_init() argument
94 stack->num = 0; in modstack_init()
95 stack->mod = NULL; in modstack_init()
99 modstack_free(struct module_stack* stack) in modstack_free() argument
101 if(!stack) in modstack_free()
103 stack->num = 0; in modstack_free()
104 free(stack->mod); in modstack_free()
105 stack->mod = NULL; in modstack_free()
109 modstack_config(struct module_stack* stack, const char* module_conf) in modstack_config() argument
113 stack->num = count_modules(module_conf); in modstack_config()
114 if(stack->num == 0) { in modstack_config()
118 if(stack->num > MAX_MODULE) { in modstack_config()
120 stack->num, MAX_MODULE); in modstack_config()
123 stack->mod = (struct module_func_block**)calloc((size_t) in modstack_config()
124 stack->num, sizeof(struct module_func_block*)); in modstack_config()
125 if(!stack->mod) { in modstack_config()
129 for(i=0; i<stack->num; i++) { in modstack_config()
130 stack->mod[i] = module_factory(&module_conf); in modstack_config()
131 if(!stack->mod[i]) { in modstack_config()
236 modstack_call_startup(struct module_stack* stack, const char* module_conf, in modstack_call_startup() argument
240 if(stack->num != 0) in modstack_call_startup()
243 if(!modstack_config(stack, module_conf)) { in modstack_call_startup()
246 for(i=0; i<stack->num; i++) { in modstack_call_startup()
247 if(stack->mod[i]->startup == NULL) in modstack_call_startup()
250 i, stack->mod[i]->name); in modstack_call_startup()
251 fptr_ok(fptr_whitelist_mod_startup(stack->mod[i]->startup)); in modstack_call_startup()
252 if(!(*stack->mod[i]->startup)(env, i)) { in modstack_call_startup()
254 stack->mod[i]->name); in modstack_call_startup()
262 modstack_call_init(struct module_stack* stack, const char* module_conf, in modstack_call_init() argument
267 for(i=0; i<stack->num; i++) { in modstack_call_init()
270 if(strncmp(stack->mod[i]->name, module_conf, in modstack_call_init()
271 strlen(stack->mod[i]->name))) { in modstack_call_init()
272 if(stack->mod[i]->startup || stack->mod[i]->destartup) { in modstack_call_init()
279 module_conf += strlen(stack->mod[i]->name); in modstack_call_init()
282 modstack_free(stack); in modstack_call_init()
283 if(!modstack_config(stack, module_conf)) { in modstack_call_init()
288 for(i=0; i<stack->num; i++) { in modstack_call_init()
290 i, stack->mod[i]->name); in modstack_call_init()
291 fptr_ok(fptr_whitelist_mod_init(stack->mod[i]->init)); in modstack_call_init()
292 if(!(*stack->mod[i]->init)(env, i)) { in modstack_call_init()
294 stack->mod[i]->name); in modstack_call_init()
302 modstack_call_deinit(struct module_stack* stack, struct module_env* env) in modstack_call_deinit() argument
305 for(i=0; i<stack->num; i++) { in modstack_call_deinit()
306 fptr_ok(fptr_whitelist_mod_deinit(stack->mod[i]->deinit)); in modstack_call_deinit()
307 (*stack->mod[i]->deinit)(env, i); in modstack_call_deinit()
312 modstack_call_destartup(struct module_stack* stack, struct module_env* env) in modstack_call_destartup() argument
315 for(i=0; i<stack->num; i++) { in modstack_call_destartup()
316 if(stack->mod[i]->destartup == NULL) in modstack_call_destartup()
318 fptr_ok(fptr_whitelist_mod_destartup(stack->mod[i]->destartup)); in modstack_call_destartup()
319 (*stack->mod[i]->destartup)(env, i); in modstack_call_destartup()
324 modstack_find(struct module_stack* stack, const char* name) in modstack_find() argument
327 for(i=0; i<stack->num; i++) { in modstack_find()
328 if(strcmp(stack->mod[i]->name, name) == 0) in modstack_find()