/* get the pointer to the xl lib functions */ static int get_xl_functions(void) { if (!xl_print) { xl_print=(xl_print_log_f*)find_export("xprint", NO_SCRIPT, 0); if (!xl_print) { LOG(L_CRIT,"ERROR: cannot find \"xprint\", is module xprint loaded?\n"); return -1; } } if (!xl_parse) { xl_parse=(xl_parse_format_f*)find_export("xparse", NO_SCRIPT, 0); if (!xl_parse) { LOG(L_CRIT,"ERROR: cannot find \"xparse\", is module xprint loaded?\n"); return -1; } } if (!xl_free) { xl_free=(xl_elog_free_all_f*)find_export("xfree", NO_SCRIPT, 0); if (!xl_free) { LOG(L_CRIT,"ERROR: cannot find \"xfree\", is module xprint loaded?\n"); return -1; } } if (!xl_nul) { xl_getnul=(xl_get_nulstr_f*)find_export("xnulstr", NO_SCRIPT, 0); if (xl_getnul) { xl_nul=xl_getnul(); } if (!xl_nul){ LOG(L_CRIT,"ERROR: cannot find \"xnulstr\", is module xprint loaded?\n"); return -1; } else { LOG(L_INFO,"INFO: xprint null is \"%.*s\"\n", xl_nul->len, xl_nul->s); } } return 0; }
static int parse_xlstr(struct xlstr* s) { if (!s->s) return 0; if (!strchr(s->s, '%')) return 0; /* probably xl_log formatting */ if (!xl_print) { xl_print=(xl_print_log_f*)find_export("xprint", NO_SCRIPT, 0); if (!xl_print) { ERR(MODULE_NAME": cannot find \"xprint\", is module xprint loaded?\n"); return E_UNSPEC; } } if (!xl_parse) { xl_parse=(xl_parse_format_f*)find_export("xparse", NO_SCRIPT, 0); if (!xl_parse) { ERR(MODULE_NAME": cannot find \"xparse\", is module xprint loaded?\n"); return E_UNSPEC; } } if (!xl_nul) { xl_getnul=(xl_get_nulstr_f*)find_export("xnulstr", NO_SCRIPT, 0); if (xl_getnul) xl_nul=xl_getnul(); if (!xl_nul){ ERR(MODULE_NAME": cannot find \"xnulstr\", is module xprint loaded?\n"); return E_UNSPEC; } else INFO(MODULE_NAME": xprint null is \"%.*s\"\n", xl_nul->len, xl_nul->s); } if(xl_parse(s->s, &s->xlfmt) < 0) { ERR(MODULE_NAME": wrong format '%s'\n", s->s); return E_UNSPEC; } return 0; }