1
0
Fork 0
mbuni/mbuni/mmlib/mms_resolve_shell.c

59 lines
1.3 KiB
C

/*
* Mbuni - Open Source MMS Gateway
*
* Resolving MSISDNs to local/remote MMSCs - calling shell scripts
*
* Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com
*
* Paul Bagyenda <bagyenda@dsmagic.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License, with a few exceptions granted (see LICENSE)
*/
#include <stdio.h>
#include <stdlib.h>
#include "mms_resolve.h"
#include "mms_util.h"
static Octstr *script = NULL;
static void *mms_resolvermodule_init(char *settings)
{
script = octstr_imm(settings);
return NULL;
}
static int mms_resolvermodule_fini(void *module_data)
{
return 0;
}
static Octstr *mms_resolve(Octstr * phonenum, void *module_data, void *settings_p, void *proxyrelays_p)
{
Octstr *s;
FILE *fp;
char buf[4096];
if (script == NULL || octstr_len(script) == 0)
return 0;
s = octstr_format("%s '%s' ", octstr_get_cstr(phonenum));
fp = popen(octstr_get_cstr(s), "r");
octstr_destroy(s);
fgets(buf, 4096, fp);
s = octstr_create(buf);
octstr_strip_crlfs(s);
pclose(fp);
return s;
}
/* The function itself. */
MmsResolverFuncStruct mms_resolvefuncs = {
mms_resolvermodule_init,
mms_resolve,
mms_resolvermodule_fini
};