RE: [patch] SQLBOX
"Rene Kluwen" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Here it is... dbpool_mssql.c without tabs and without fprintf's... I really dont know what the first parameter of the function error(...) is for, but I figure that 0 is a safe value, since I see that more often :)... Rene Kluwen Chimit -----Original Message----- From: [email protected] [mailto:[email protected]]On Behalf Of Alexander Malysh Sent: woensdag 9 juni 2004 20:28 To: Rene Kluwen Cc: [email protected] Subject: Re: [patch] SQLBOX Hi Rene, On Wednesday 09 June 2004 20:01, Rene Kluwen wrote: > Hi Alexander, > > Attached is the file that you are looking for. hmm, do you read ML ;) I have commited it already :) > Thanks for committing the PG DBPool support already... It made the sqlbox > patch fail with some people... But that doesnt matter :)... A new patch is > available already... Including the dlr_pgsql.c as well... Hmm, I would say: Thank you for the patch! > > About dbpool_mssql.c: Will fix both issues... Sorry, this is copy/pasted > from an existing (home-made) abstraction class. ok > > Meanwhile, I have had some (really valid) questions from users by email and > I will post them to this list together with the answers later. > > Question about the userguide: Which format is it in really and which is the > preferred way to update? patch against current cvs is preferred. userguide is in Docbook format. > > Warm regards, > > Rene Kluwen > Chimit > > -----Original Message----- > From: [email protected] [mailto:[email protected]]On > Behalf Of Alexander Malysh > Sent: dinsdag 8 juni 2004 12:33 > To: [email protected] > Cc: Rene Kluwen > Subject: Re: [patch] SQLBOX > > > Hi Rene, > > I have picked PostrgeSQL DBPool support and commited in a slightly modified > version to cvs. > I believe, you forgot to include 'dlr_pgsql.c' into tar archive? > Please send it as separate patch and I will review/commit it... > Btw. userguide patch would be great too ;) > Thanks in advance! > > P.S. 'dbpool_mssql.c' included in tar archive, need some more work to be > commited: > 1) whitespaces (don't use tabs) > 2) get rid of 'fprintf' use debug/info/error provided by kannel instead > > On Friday 21 May 2004 23:36, Rene Kluwen wrote: > > For the patch: http://www.chimit.nl/kannel/sqlbox_patch.tar > > > > I know this needs more documentation, but this patch has been kept from > > the > > > mailing list so long already that I didnt want to refrain it from you > > anymore. > > > > For me also the standard excuse holds that I have been so busy lately > > that I have not been able to keep up with the list anymore. > > > > Anyhow... Here, a working version of the SQLBOX is attached. In the tar > > ball, there are a number of files that have been split up and a > > sqlbox_patch.diff that has to be applied. > > > > The patch includes Postgres, MySQL and MS-SQL support (also for DLR's) > > for anybody that feels the need to use it. > > MS-SQL client libraries are either sybase or free-tds (./configure > > autodetects). > > > > Here follows some documentation that in fact (I admit) should be included > > in the patch against the doc tree: > > There is one extra configure option in group = smsbox, which is: > > > > # bearerbox-is-sqlbox indicates if the smsbox is connected to the > > bearerbox > > > or an sql box > > bearerbox-is-sqlbox = true/false > > > > For the rest, the group = sqlbox contains the following options: > > > > group = sqlbox > > # id corresponds to id in group = mysql-connection. > > # this is analogous to id in group = dlr-db > > id = dlr-db2 > > # smsbox-id indicates the box where SQL-injected messages appear to be > > coming fr > > om > > smsbox-id = sqlbox2 > > # bearerbox host to connect to > > bearerbox-host = "127.0.0.1" > > # smsbox port to be listening on > > smsbox-port = 13005 > > smsbox-port-ssl = false > > # sql-log-table is the table used to log all sent messages > > sql-log-table = sent_sms > > # sql-insert-table is the table that is monitored for new messages to > > send sql-insert-table = send_sms > > # global sender: If no sender is specified in sql-insert-table then this > > # value is used. > > global-sender = 06121 > > # log-file = "" > > # log-level = 10 > > # ssl-client-certkey-file = "" > > # ssl-server-cert-file = "" > > # ssl-server-key-file = "" > > # ssl-trusted-ca-file = "" > > -- > Best regards / Mit besten Grüßen aus Düsseldorf > > Dipl.-Ing. > Alexander Malysh > ___________________________________________ > > Centrium GmbH > Vogelsanger Weg 80 > 40470 Düsseldorf > > Fon: +49 (0211) 74 84 51 80 > Fax: +49 (0211) 277 49 109 > > email: [email protected] > web: www.centrium.de > msn: [email protected] > icq: 98063111 > ___________________________________________ > > Please avoid sending me Word, Excel or PowerPoint attachments. > See http://www.fsf.org/philosophy/no-word-attachments.html -- Best regards / Mit besten Grüßen aus Düsseldorf Dipl.-Ing. Alexander Malysh ___________________________________________ Centrium GmbH Vogelsanger Weg 80 40470 Düsseldorf Fon: +49 (0211) 74 84 51 80 Fax: +49 (0211) 277 49 109 email: a.malysh at centrium.de web: www.centrium.de msn: olek2002 at hotmail.com icq: 98063111 ___________________________________________ Please avoid sending me Word, Excel or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html
dbpool_mssql.c
(application/octet-stream, 5.7 KB)
/* ==================================================================== * The Kannel Software License, Version 1.0 * * Copyright (c) 2001-2004 Kannel Group * Copyright (c) 1998-2001 WapIT Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Kannel Group (http://www.kannel.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Kannel" and "Kannel Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please * contact [email protected]. * * 5. Products derived from this software may not be called "Kannel", * nor may "Kannel" appear in their name, without prior written * permission of the Kannel Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Kannel Group. For more information on * the Kannel Group, please see <http://www.kannel.org/>. * * Portions of this software are based upon software originally written at * WapIT Ltd., Helsinki, Finland for the Kannel project. */ /* * dbpool_mssql.c - implement MSSQL operations for generic database connection pool * * Rene Kluwen <[email protected]> * 2004 Initial version. */ #ifdef HAVE_MSSQL #include <sybfront.h> #include <sybdb.h> #define DATELEN 26 #define TYPELEN 2 static void* mssql_open_conn(const DBConf *db_conf) { DBPROCESS *dbproc = NULL; MSSQLConf *conf = db_conf->mssql; /* make compiler happy */ BOOL success; LOGINREC *login; /* Our login information. */ /* sanity check */ if (conf == NULL) return NULL; /* ** Get a LOGINREC structure and fill it with the necessary ** login information. */ login = dblogin(); DBSETLUSER(login, octstr_get_cstr(conf->username)); DBSETLPWD(login, octstr_get_cstr(conf->password)); DBSETLAPP(login, "kannel"); /* ** Get a DBPROCESS structure for communicating with SQL Server. ** A NULL servername defaults to the server specified by DSQUERY. */ dbproc = dbopen(login, octstr_get_cstr(conf->database)); success = (dbproc && (dbproc != FAIL)); if (!success) { dbproc = NULL; return NULL; } return dbproc; } static void mssql_close_conn(void *conn) { if (conn == NULL) return; dbclose((DBPROCESS *) conn); } static int mssql_check_conn(void *conn) { if (conn == NULL) return -1; /* todo: implement alive check */ return 0; } static void mssql_conf_destroy(DBConf *db_conf) { MSSQLConf *conf = db_conf->mssql; octstr_destroy(conf->host); octstr_destroy(conf->username); octstr_destroy(conf->password); octstr_destroy(conf->database); gw_free(conf); gw_free(db_conf); } static struct db_ops mssql_ops = { .open = mssql_open_conn, .close = mssql_close_conn, .check = mssql_check_conn, .conf_destroy = mssql_conf_destroy }; /* sybase related funcs */ /* for sybase & freetds */ #define ERR_CH 0 /* is being passed as fist argument to error call */ /* for sybase: */ /* #define BOOL int */ /* for freetds: */ #define DBFAR #define CS_PUBLIC int CS_PUBLIC err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { if ((dbproc == NULL) || (DBDEAD(dbproc))) return(INT_EXIT); else { error (ERR_CH, "DB-Library error:\n\t%s\n", dberrstr); if (oserr != DBNOERR) error (ERR_CH, "Operating-system error:\n\t%s\n", oserrstr); return(INT_CANCEL); } } int CS_PUBLIC msg_handler(DBPROCESS dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { error(ERR_CH, "Msg %d, Level %d, State %d\n", msgno, severity, msgstate); if (strlen(srvname) > 0) error (ERR_CH, "Server '%s', ", srvname); if (strlen(procname) > 0) error (ERR_CH, "Procedure '%s', ", procname); if (line > 0) error (ERR_CH, "Line %d", line); error (ERR_CH, "\n\t%s\n", msgtext); return(0); } #endif /* HAVE_MSSQL */