[Asterisk-Dev] Current database abstraction effort ?

James Sharp jsharp at psychoses.org
Wed Dec 31 14:48:08 MST 2003


> I need to finish redoing the odbc voicemail stuff and app_directory and
> maybe write res_odbc.c where we can have a global connection that every
> app can use to interact with the datasource.
>
> Any thoughts on how to do this?

I came up with this in my PAM attempt (which I'm still working on).

Function prototypes

ast_db_query(const char *identifier, const char *keyname, const char
*keyvalue, const int numofelements, const char *name1, char *value1, ...)

You pass it an identifier like "chan_sip" or "voicemail", the number of
elements you want information from, and then a series of pairs of
name/pointers to the odbc functions.

Example:

ast_db_query("app_voicemail","extension","2317",3,"name",&name,"password",&password,"email",&email);

The call then percolates through and after it returns, the pointers of
&name, &password, and &email are filled with the appropriate data.

You config your res_odbc to query a particular DSN for a given identifier.
 Something like this:

[odbc]
app_voicemail=dsn_mysql_voicemail
chan_sip=dsn_db2
chan_iax=dsn_mssql
default=dsn_text_files





More information about the asterisk-dev mailing list