47 lines
932 B
C
47 lines
932 B
C
#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
|
|
};
|