1
0
Fork 0
mbuni/mbuni/mmsc/mms_billing_shell.c

77 lines
1.6 KiB
C
Raw Normal View History

2005-10-23 16:52:51 +00:00
/*
* Mbuni - Open Source MMS Gateway
*
* Mbuni sample billing handler module
*
* 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>
2010-01-25 09:40:23 +00:00
#ifndef DARWIN
2010-09-12 16:54:08 +00:00
#ifndef FREEBSD
2010-01-25 09:40:23 +00:00
#include <wait.h>
#endif
2010-09-12 16:54:08 +00:00
#endif
2008-12-04 09:06:26 +00:00
#include <sys/wait.h>
2009-09-08 12:47:33 +00:00
2008-12-04 09:06:26 +00:00
#include "mms_billing.h"
static Octstr *script = NULL;
static void *mms_billingmodule_init(char *settings)
{
script = octstr_create(settings);
return NULL;
}
static int mms_billingmodule_fini(void *module_data)
{
if (script) {
octstr_destroy(script);
script = NULL;
}
return 0;
}
2007-08-29 13:33:11 +00:00
static int mms_billmsg(Octstr *from, List *to, unsigned long msg_size, Octstr *vaspid, Octstr *msgid, void *module_data)
{
int i;
if (script == NULL || octstr_len(script) == 0)
return 0;
for (i=0;i<gwlist_len(to);i++) {
Octstr *s;
2007-08-29 13:33:11 +00:00
s = octstr_format("%s '%s' '%s' '%S'", octstr_get_cstr(script), octstr_get_cstr(from),
octstr_get_cstr(gwlist_get(to, i)), msgid);
if (s) {
int ret = system(octstr_get_cstr(s));
octstr_destroy(s);
if (ret < 0)
return -2;
else if (WEXITSTATUS(ret) != 0)
return -1;
}
}
return 0;
}
static int mms_logcdr(MmsCdrStruct *cdr)
{
return 0;
}
/* The function itself. */
MmsBillingFuncStruct mms_billfuncs_shell = {
mms_billingmodule_init,
mms_logcdr,
mms_billmsg,
mms_billingmodule_fini
};