<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I hope I didn't spam people with this. I sent
the original from the wrong email address:</FONT></DIV>
<DIV><FONT face=Arial
size=2>----------------------------------------------------------------------------------------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2>After debating with citats for a bit in IRC, his
idea of an abstract query interface finally made sense to me :-)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>So I set about writing it on the weekend, and it is
in a working state now.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>With this API (which I named "qint" for query
interface), (similar to how cdr.c works)....</FONT></DIV>
<DIV><FONT face=Arial size=2>1) All mySQL, and other DB specific code can
be removed from being all over Asterisk (voicemail, chan_sip, directory,
etc.)</FONT></DIV>
<DIV><FONT face=Arial size=2>2) All the #ifdef MYSQL lines of code can be
removed from Asterisk</FONT></DIV>
<DIV><FONT face=Arial size=2>3) Modules (ie: qint/qint_mysql.c, or qint_odbc.c,
or qint_radius.c) can be written that contain the specific code for the lookups
that are moved to qint.</FONT></DIV>
<DIV><FONT face=Arial size=2>4) A Single database connection can be shared by
qint, instead of having one for each piece that connects</FONT></DIV>
<DIV><FONT face=Arial size=2>5) Configuring the database connection doesnt have
to be in 3 or 4 different .conf files</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>So, here's a quick list of the changes... with more
discussion, we can figure out where to put code for others to
review:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>- new file qint.c compiles into Asterisk just like
cdr.c does, with some of its functions exported in qint.h</FONT></DIV>
<DIV><FONT face=Arial size=2>- new file qint_mysql.c which can handle any query
Asterisk would normally do from itself. (example: I already removed ALL
mysql code from chan_sip.c and put it int qint_mysql.c---- best part is it still
all works as if the code were right inside of chan_sip.c)</FONT></DIV>
<DIV><FONT face=Arial size=2>- changed chan_sip.c and removed all mysql code,
and #ifdefs. replaced with code like:</FONT></DIV>
<DIV><FONT face="Courier New" size=2>//search for user/peer code as it
exists</FONT></DIV>
<DIV><FONT face="Courier New" size=2>...</FONT></DIV>
<DIV><FONT face="Courier New" size=2>if (!u) qint_sip_find_user(&u, other
params...);</FONT></DIV>
<DIV><FONT face="Courier New" size=2>...</FONT></DIV>
<DIV><FONT face=Arial size=2>the qint_sip_find_user() function exists within
qint.c: It will dynamically find a possible registered function for
performing a sipfriends lookup in an external .so module (ie:
qint_mysql.so)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>qint_mysql.so's load_module() function just
performs a qint_register(name, desc, query_type, function_ptr) call in order to
register a function as a handler for a specific type of query.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Of course, this did require some other minor
changes....</FONT></DIV>
<DIV><FONT face=Arial size=2>- Had to make a chan_sip.h file to define some
things external of chan_sip.c (so both chan_sip.c, and qint_mysql.c can see the
sip_peer and sip_user structs for example)</FONT></DIV>
<DIV><FONT face=Arial size=2>- a #include <asterisk/qint.h> needed to be
added to chan_sip.c and so on... lots of little things.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This helps moving toward a dynamic db lookup for
the extensions.conf file as well. </FONT><FONT face=Arial size=2>With
this, I was able to catch any query for pbx_find_extension(), which was a 2 line
change to pbx.c, and a handler in qint_mysql.c to catch the call.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>If anyone would like to review the source I have,
just reply.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>----------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2>#asterisk - rgagnon</FONT></DIV></BODY></HTML>