Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:47:55 2009

## Asterisk developer's documentation

# res_odbc.h

Go to the documentation of this file.

    00001 /*
    00002  * Asterisk -- An open source telephony toolkit.
    00003  *
    00004  * Copyright (C) 1999 - 2005, Digium, Inc.
    00005  * Copyright (C) 2004 - 2005, Anthony Minessale II
    00006  *
    00007  * Mark Spencer <markster@digium.com>
    00008  * Anthony Minessale <anthmct@yahoo.com>
    00009  *
    00010  * See http://www.asterisk.org for more information about
    00011  * the Asterisk project. Please do not directly contact
    00012  * any of the maintainers of this project for assistance;
    00013  * the project provides a web site, mailing lists and IRC
    00014  * channels for your use.
    00015  *
    00016  * This program is free software, distributed under the terms of
    00017  * the GNU General Public License Version 2. See the LICENSE file
    00018  * at the top of the source tree.
    00019  */
    00020
    00021 /*! \file
    00022  * \brief ODBC resource manager
    00023  */
    00024
    00025 #ifndef _ASTERISK_RES_ODBC_H
    00026 #define _ASTERISK_RES_ODBC_H
    00027
    00028 #include <sql.h>
    00029 #include <sqlext.h>
    00030 #include <sqltypes.h>
    00031
    00032 typedef struct odbc_obj odbc_obj;
    00033
    00034 typedef enum { ODBC_SUCCESS=0,ODBC_FAIL=-1} odbc_status;
    00035
    00036 struct odbc_obj {
    00037    char *name;
    00038    char *dsn;
    00039    char *username;
    00040    char *password;
    00041    SQLHENV  env;                   /* ODBC Environment */
    00042    SQLHDBC  con;                   /* ODBC Connection Handle */
    00043    SQLHSTMT stmt;                  /* ODBC Statement Handle */
    00044    ast_mutex_t lock;
    00045    int up;
    00046
    00047 };
    00048
    00049 /* functions */
    00050 odbc_obj *new_odbc_obj(char *name,char *dsn,char *username, char *password);
    00051 odbc_status odbc_obj_connect(odbc_obj *obj);
    00052 odbc_status odbc_obj_disconnect(odbc_obj *obj);
    00053 void destroy_odbc_obj(odbc_obj **obj);
    00054 int register_odbc_obj(char *name,odbc_obj *obj);
    00055 odbc_obj *fetch_odbc_obj(const char *name, int check);
    00056 int odbc_dump_fd(int fd,odbc_obj *obj);
    00057 int odbc_sanity_check(odbc_obj *obj);
    00058 SQLHSTMT odbc_prepare_and_execute(odbc_obj *obj, SQLHSTMT (*prepare_cb)(odbc_obj *obj, void *data), void *data);
    00059 int odbc_smart_execute(odbc_obj *obj, SQLHSTMT stmt);
    00060 int odbc_smart_direct_execute(odbc_obj *obj, SQLHSTMT stmt, char *sql);
    00061
    00062 #endif /* _ASTERISK_RES_ODBC_H */