static int dbops_fixup_func(void** param, int init_act) { struct dbops_action **p, *a; char *c; int res; /* check if is it a declare_no that references to declare_xxxx */ c = *param; eat_spaces(c); *param = c; eat_alphanum(c); if (*c == 0) { a = find_action_by_name(*param, -1); if (!a) { ERR(MODULE_NAME": fixup_func: query (%s) not declared\n", (char*) *param); return -1; } *param = (void*) a; return 0; } for (p = &dbops_actions; *p; p=&(*p)->next); /* add at the end of list */ res = parse_ops(*param, p, init_act == 0 /* declare query has name */); if (res < 0) return res; /* pkg_free(*param); do not free it!*/ *param = (void*) *p; if (init_act) return init_action(*p); /* fixup is acquired after init_mod() therefore initialize new action */ else return 0; }
int player_go(char **tab, t_player *pl, t_zaap *zaap) { t_action *action; if (pl->nba >= 10) return (-1); action = init_action(AVC, tab[1], 7); add_action_player(action, pl, zaap); return (0); }
static int mod_init(void) { struct dbops_action* p; xlbuf = pkg_malloc((xlbuf_size+1)*sizeof(char)); if (!xlbuf) { ERR(MODULE_NAME": out of memory, cannot create xlbuf\n"); return E_OUT_OF_MEM; } for (p=dbops_actions; p; p=p->next) { int res; res = init_action(p); if (res < 0) { pkg_free(xlbuf); xlbuf = NULL; return res; } } if(register_script_cb(dbops_pre_script_cb, REQUEST_CB | ONREPLY_CB | PRE_SCRIPT_CB, 0)<0) { LM_ERR("failed to register pre script callback\n"); pkg_free(xlbuf); xlbuf = NULL; return -1; } if(register_script_cb(dbops_post_script_cb, REQUEST_CB | ONREPLY_CB | POST_SCRIPT_CB, 0)<0) { LM_ERR("failed to register post script callback\n"); pkg_free(xlbuf); xlbuf = NULL; return -1; } register_select_table(sel_declaration); return 0; }
action *new_action(void(*f)(action *), bouton *b, int shortcut, int enabled, void *data, int flag) { return init_action(malloc(sizeof(action)), f, b, shortcut, enabled, data, flag); }
int main(int argc, char** argv) { cmdline_t options; exittype_t exit_type; parser_t* ctx = NULL; bool_t success = 0; // Parse the command line. fetchdeps_cmdline_init(&options, argc, argv); exit_type = fetchdeps_cmdline_parse(&options); if (exit_type == EXIT_FAIL) goto failure; if (exit_type == EXIT_OK) { fetchdeps_cmdline_cleanup(&options); exit(0); } // If no fname was given try to find the default deps file. if (!options.fname) options.fname = fetchdeps_filesys_default_deps_file(); if (!options.fname) { fetchdeps_errors_set(ERR_NO_DEPS); goto failure; } switch (options.action) { case ACTION_HELP: success = help_action(&options); break; case ACTION_INIT: success = init_action(&options); break; case ACTION_GET: success = get_action(&options); break; case ACTION_LIST: success = list_action(&options); break; case ACTION_INSTALL: success = install_action(&options); break; case ACTION_UNINSTALL: success = uninstall_action(&options); break; case ACTION_DELETE: success = delete_action(&options); break; case ACTION_VARS: success = vars_action(&options); break; default: success = 0; break; } if (!success) goto failure; // Clean up. fetchdeps_cmdline_cleanup(&options); return 0; failure: fetchdeps_errors_print(stderr); fetchdeps_cmdline_cleanup(&options); if (ctx) fetchdeps_parser_free(ctx); return 1; }