44 lines
864 B
C
44 lines
864 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "mms_detokenize.h"
|
|
#include "mms_util.h"
|
|
|
|
Octstr *script;
|
|
|
|
static int mms_detokenizer_init(char *settings)
|
|
{
|
|
script = octstr_create(settings);
|
|
return 0;
|
|
}
|
|
|
|
static int mms_detokenizer_fini(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static Octstr *mms_detokenize(Octstr * token)
|
|
{
|
|
Octstr *s;
|
|
FILE *fp;
|
|
char buf[4096];
|
|
|
|
if (script == NULL || octstr_len(script) == 0)
|
|
return NULL;
|
|
|
|
s = octstr_format("%s '%s'", octstr_get_cstr(script), octstr_get_cstr(token));
|
|
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. */
|
|
MmsDetokenizerFuncStruct mms_detokenizefuncs = {
|
|
mms_detokenizer_init,
|
|
mms_detokenize,
|
|
mms_detokenizer_fini
|
|
};
|