/* * Mbuni - Open Source MMS Gateway * * Mbuni sample billing handler module * * 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_billing.h" /* This module provides a basic biller and CDR implementation. Totally no frills, but a basis * for implementing a 'real' module. * It does CDR but no billing (of course). */ static void *mms_billingmodule_init(char *settings) { return fopen(settings, "a"); /* Settings is interpreted as a file name. */ } static int mms_billingmodule_fini(void *module_data) { return module_data ? fclose(module_data) : -1; } static double mms_billmsg(Octstr *from, List *to, unsigned long msg_size, void *module_data) { return 0; } static int mms_logcdr(MmsCdrStruct *cdr) { if (cdr && cdr->module_data) { char buf[CBUFSIZE]; struct tm tm; localtime_r(&cdr->sdate, &tm); gw_strftime(buf, sizeof buf, "%Y-%m-%d %H:%M:%S", &tm); fprintf(cdr->module_data, "%s\t%.128s\t%.256s\t%.256s\t%ld\n", buf, cdr->from, cdr->to, cdr->msgid, cdr->msg_size); fflush(cdr->module_data); } else return -1; return 0; } /* The function itself. */ MmsBillingFuncStruct mms_billfuncs = { mms_billingmodule_init, mms_logcdr, mms_billmsg, mms_billingmodule_fini };