/* * Mbuni - Open Source MMS Gateway * * Mbuni MSISDN mapper shell caller * * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * * This program is free software, distributed under the terms of * the GNU General Public License, with a few exceptions granted (see LICENSE) */ #include #include #include "mms_detokenize.h" #include "mms_util.h" Octstr *script; static int mms_detokenizer_init(char *settings) { script = octstr_create(settings); info(0, "Detokenizer script set to \"%s\"", settings); return 0; } static int mms_detokenizer_fini(void) { return 0; } static Octstr *mms_detokenize(Octstr * token) { Octstr *cmd = NULL, *msisdn = NULL; FILE *fp; char buf[4096]; if (script == NULL || octstr_len(script) == 0) return NULL; cmd = octstr_format("%s '%s'", octstr_get_cstr(script), octstr_get_cstr(token)); info(0, "Calling \"%s\"", octstr_get_cstr(cmd)); if ((fp = popen(octstr_get_cstr(cmd), "r"))) { if (fgets(buf, 4096, fp) == buf) { msisdn = octstr_create(buf); octstr_strip_crlfs(msisdn); } pclose(fp); } octstr_destroy(cmd); return msisdn; } /* The function itself. */ MmsDetokenizerFuncStruct mms_detokenizefuncs = { mms_detokenizer_init, mms_detokenize, mms_detokenizer_fini };