km_db_postgres.c

Go to the documentation of this file.
00001 /*
00002  * $Id$ 
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  * Copyright (C) 2008 1&1 Internet AG
00006  *
00007  * This file is part of Kamailio, a free SIP server.
00008  *
00009  * Kamailio is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * Kamailio is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License 
00020  * along with this program; if not, write to the Free Software 
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  */
00023 
00036 #include <stdio.h>
00037 #include "../../sr_module.h"
00038 #include "../../lib/srdb1/db_con.h"
00039 #include "../../lib/srdb1/db.h"
00040 #include "../../lib/srdb1/db_query.h"
00041 #include "km_dbase.h"
00042 #include "km_db_postgres.h"
00043 
00044 
00045 /*MODULE_VERSION*/
00046 
00047 /*
00048  * PostgreSQL database module interface
00049  */
00050 
00051 static kam_cmd_export_t cmds[]={
00052         {"db_bind_api",     (cmd_function)db_postgres_bind_api,     0, 0, 0, 0},
00053         {0,0,0,0,0,0}
00054 };
00055 
00056 
00057 
00058 struct kam_module_exports kam_exports = {
00059         "db_postgres",
00060         DEFAULT_DLFLAGS, /* dlopen flags */
00061         cmds,
00062         0,        /*  module parameters */
00063         0,        /* exported statistics */
00064         0,        /* exported MI functions */
00065         0,        /* exported pseudo-variables */
00066         0,        /* extra processes */
00067         km_postgres_mod_init, /* module initialization function */
00068         0,        /* response function*/
00069         0,        /* destroy function */
00070         0         /* per-child init function */
00071 };
00072 
00073 
00074 int km_postgres_mod_init(void)
00075 {
00076         return 0;
00077 }
00078 
00079 int db_postgres_bind_api(db_func_t *dbb)
00080 {
00081         if(dbb==NULL)
00082                 return -1;
00083 
00084         memset(dbb, 0, sizeof(db_func_t));
00085 
00086         dbb->use_table        = db_postgres_use_table;
00087         dbb->init             = db_postgres_init;
00088         dbb->init2            = db_postgres_init2;
00089         dbb->close            = db_postgres_close;
00090         dbb->query            = db_postgres_query;
00091         dbb->fetch_result     = db_postgres_fetch_result;
00092         dbb->raw_query        = db_postgres_raw_query;
00093         dbb->free_result      = db_postgres_free_result;
00094         dbb->insert           = db_postgres_insert;
00095         dbb->delete           = db_postgres_delete; 
00096         dbb->update           = db_postgres_update;
00097         dbb->replace          = db_postgres_replace;
00098         dbb->affected_rows    = db_postgres_affected_rows;
00099         dbb->start_transaction= db_postgres_start_transaction;
00100         dbb->end_transaction  = db_postgres_end_transaction;
00101         dbb->abort_transaction= db_postgres_abort_transaction;
00102 
00103         return 0;
00104 }