dbtext.c

Go to the documentation of this file.
00001 /*
00002  * $Id: dbtext.c 4518 2008-07-28 15:39:28Z henningw $
00003  *
00004  * DBText module interface
00005  *
00006  * Copyright (C) 2001-2003 FhG Fokus
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  * 
00024  * History:
00025  * --------
00026  * 2003-01-30 created by Daniel
00027  * 2003-03-11 New module interface (janakj)
00028  * 2003-03-16 flags export parameter added (janakj)
00029  * 
00030  */
00031 
00032 #include <stdio.h>
00033 #include <unistd.h>
00034 
00035 #include "../../sr_module.h"
00036 #include "../../db/db.h"
00037 #include "dbtext.h"
00038 #include "dbt_lib.h"
00039 #include "dbt_api.h"
00040 
00041 MODULE_VERSION
00042 
00043 static int mod_init(void);
00044 static void destroy(void);
00045 
00046 /*
00047  * Module parameter variables
00048  */
00049 int db_mode = 0;  /* Database usage mode: 0 = cache, 1 = no cache */
00050 
00051 int dbt_bind_api(db_func_t *dbb);
00052 
00053 /*
00054  * Exported functions
00055  */
00056 static cmd_export_t cmds[] = {
00057    {"db_bind_api",    (cmd_function)dbt_bind_api,   0, 0, 0, 0},
00058    {0, 0, 0, 0, 0, 0}
00059 };
00060 
00061 
00062 /*
00063  * Exported parameters
00064  */
00065 static param_export_t params[] = {
00066    {"db_mode", INT_PARAM, &db_mode},
00067    {0, 0, 0}
00068 };
00069 
00070 
00071 struct module_exports exports = {   
00072    "db_text",
00073    DEFAULT_DLFLAGS, /* dlopen flags */
00074    cmds,     /* Exported functions */
00075    params,   /* Exported parameters */
00076    0,        /* exported statistics */
00077    0,        /* exported MI functions */
00078    0,        /* exported pseudo-variables */
00079    0,        /* extra processes */
00080    mod_init, /* module initialization function */
00081    0,        /* response function*/
00082    destroy,  /* destroy function */
00083    0         /* per-child init function */
00084 };
00085 
00086 
00087 static int mod_init(void)
00088 {
00089    if(dbt_init_cache())
00090       return -1;
00091    /* return make_demo(); */
00092    
00093    return 0;
00094 }
00095 
00096 static void destroy(void)
00097 {
00098    LM_DBG("destroy ...\n");
00099    dbt_cache_print(0);
00100    dbt_cache_destroy();
00101 }
00102 
00103 
00104 
00105 int dbt_bind_api(db_func_t *dbb)
00106 {
00107    if(dbb==NULL)
00108       return -1;
00109 
00110    memset(dbb, 0, sizeof(db_func_t));
00111 
00112    dbb->use_table   = dbt_use_table;
00113    dbb->init        = dbt_init;
00114    dbb->close       = dbt_close;
00115    dbb->query       = (db_query_f)dbt_query;
00116    dbb->free_result = dbt_free_result;
00117    dbb->insert      = (db_insert_f)dbt_insert;
00118    dbb->delete      = (db_delete_f)dbt_delete; 
00119    dbb->update      = (db_update_f)dbt_update;
00120 
00121    return 0;
00122 }
00123 

Generated on Tue May 22 14:00:25 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6