[svn-commits] mmichelson: branch 10 r369325 - in /branches/10: ./ include/asterisk/ main/ res/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jun 25 10:52:46 CDT 2012
Author: mmichelson
Date: Mon Jun 25 10:52:42 2012
New Revision: 369325
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369325
Log:
Multiple revisions 369323-369324
........
r369323 | mmichelson | 2012-06-25 10:35:43 -0500 (Mon, 25 Jun 2012) | 9 lines
Eliminate embedding of res_adsi.so module.
The way this is done is to stop using the optional API.
Instead, res_adsi.so, when loaded fills in a table of
function pointers.
Review: https://reviewboard.asterisk.org/r/1991
........
r369324 | mmichelson | 2012-06-25 10:50:17 -0500 (Mon, 25 Jun 2012) | 2 lines
Forgot to svn add this file in my last commit.
........
Merged revisions 369323-369324 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Added:
branches/10/main/adsi.c
- copied unchanged from r369324, branches/1.8/main/adsi.c
Removed:
branches/10/res/res_adsi.exports.in
Modified:
branches/10/ (props changed)
branches/10/include/asterisk/adsi.h
branches/10/main/Makefile
branches/10/res/res_adsi.c
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/include/asterisk/adsi.h
URL: http://svnview.digium.com/svn/asterisk/branches/10/include/asterisk/adsi.h?view=diff&rev=369325&r1=369324&r2=369325
==============================================================================
--- branches/10/include/asterisk/adsi.h (original)
+++ branches/10/include/asterisk/adsi.h Mon Jun 25 10:52:42 2012
@@ -24,7 +24,6 @@
#define _ASTERISK_ADSI_H
#include "asterisk/callerid.h"
-#include "asterisk/optional_api.h"
/*! \name ADSI parameters */
/*@{ */
@@ -121,11 +120,13 @@
#define ADSI_DIR_FROM_LEFT (0)
#define ADSI_DIR_FROM_RIGHT (1)
+#define AST_ADSI_VERSION 1
+
/*@} */
-AST_OPTIONAL_API(int, ast_adsi_begin_download, (struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version), { return 0; });
-
-AST_OPTIONAL_API(int, ast_adsi_end_download, (struct ast_channel *chan), { return 0; });
+int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version);
+
+int ast_adsi_end_download(struct ast_channel *chan);
/*! Restore ADSI initialization (for applications that play with ADSI
* and want to restore it to normal. If you touch "INFO" then you
@@ -135,7 +136,7 @@
* \retval 0 on success (or adsi unavailable)
* \retval -1 on hangup
*/
-AST_OPTIONAL_API(int, ast_adsi_channel_restore, (struct ast_channel *chan), { return 0; });
+int ast_adsi_channel_restore(struct ast_channel *chan);
/*!
* \brief Display some stuff on the screen
@@ -147,7 +148,7 @@
* \retval 0 on success (or adsi unavailable)
* \retval -1 on hangup
*/
-AST_OPTIONAL_API(int, ast_adsi_print, (struct ast_channel *chan, char **lines, int *align, int voice), { return 0; });
+int ast_adsi_print(struct ast_channel *chan, char **lines, int *align, int voice);
/*!
* \brief Check if scripts for a given app are already loaded.
@@ -161,16 +162,16 @@
* \retval -1 on hangup
* \retval 1 if script already loaded.
*/
-AST_OPTIONAL_API(int, ast_adsi_load_session, (struct ast_channel *chan, unsigned char *app, int ver, int data), { return 0; });
-AST_OPTIONAL_API(int, ast_adsi_unload_session, (struct ast_channel *chan), { return 0; });
+int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data);
+int ast_adsi_unload_session(struct ast_channel *chan);
/* ADSI Layer 2 transmission functions */
-AST_OPTIONAL_API(int, ast_adsi_transmit_message, (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype), { return 0; });
-AST_OPTIONAL_API(int, ast_adsi_transmit_message_full, (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait), { return 0; });
+int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype);
+int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait);
/*! Read some encoded DTMF data.
* Returns number of bytes received
*/
-AST_OPTIONAL_API(int, ast_adsi_read_encoded_dtmf, (struct ast_channel *chan, unsigned char *buf, int maxlen), { return 0; });
+int ast_adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen);
/* ADSI Layer 3 creation functions */
@@ -184,22 +185,22 @@
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_connect_session, (unsigned char *buf, unsigned char *fdn, int ver), { return 0; });
+int ast_adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver);
/*! Build Query CPE ID of equipment.
* Returns number of bytes added to message
*/
-AST_OPTIONAL_API(int, ast_adsi_query_cpeid, (unsigned char *buf), { return 0; });
-AST_OPTIONAL_API(int, ast_adsi_query_cpeinfo, (unsigned char *buf), { return 0; });
+int ast_adsi_query_cpeid(unsigned char *buf);
+int ast_adsi_query_cpeinfo(unsigned char *buf);
/*! Get CPE ID from an attached ADSI compatible CPE.
* Returns 1 on success, storing 4 bytes of CPE ID at buf
* or -1 on hangup, or 0 if there was no hangup but it failed to find the
* device ID. Returns to voice mode if "voice" is non-zero.
*/
-AST_OPTIONAL_API(int, ast_adsi_get_cpeid, (struct ast_channel *chan, unsigned char *cpeid, int voice), { return 0; });
-
-AST_OPTIONAL_API(int, ast_adsi_get_cpeinfo, (struct ast_channel *chan, int *width, int *height, int *buttons, int voice), { return 0; });
+int ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice);
+
+int ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice);
/*!
* \brief Begin an ADSI script download
@@ -213,7 +214,7 @@
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_download_connect, (unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver), { return 0; });
+int ast_adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver);
/*!
* \brief Disconnects a running session.
@@ -222,7 +223,7 @@
* \retval number of bytes added to buffer
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_disconnect_session, (unsigned char *buf), { return 0; });
+int ast_adsi_disconnect_session(unsigned char *buf);
/*!
* \brief Disconnects (and hopefully saves) a downloaded script
@@ -231,7 +232,7 @@
* \retval number of bytes added to buffer
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_download_disconnect, (unsigned char *buf), { return 0; });
+int ast_adsi_download_disconnect(unsigned char *buf);
/*!
* \brief Puts CPE in data mode.
@@ -240,9 +241,9 @@
* \retval number of bytes added to buffer
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_data_mode, (unsigned char *buf), { return 0; });
-AST_OPTIONAL_API(int, ast_adsi_clear_soft_keys, (unsigned char *buf), { return 0; });
-AST_OPTIONAL_API(int, ast_adsi_clear_screen, (unsigned char *buf), { return 0; });
+int ast_adsi_data_mode(unsigned char *buf);
+int ast_adsi_clear_soft_keys(unsigned char *buf);
+int ast_adsi_clear_screen(unsigned char *buf);
/*!
* \brief Puts CPE in voice mode.
@@ -252,13 +253,13 @@
* \retval number of bytes added to buffer
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_voice_mode, (unsigned char *buf, int when), { return 0; });
+int ast_adsi_voice_mode(unsigned char *buf, int when);
/*!
* \brief Returns non-zero if Channel does or might support ADSI
* \param chan Channel to check
*/
-AST_OPTIONAL_API(int, ast_adsi_available, (struct ast_channel *chan), { return 0; });
+int ast_adsi_available(struct ast_channel *chan);
/*!
* \brief Loads a line of info into the display.
@@ -274,7 +275,7 @@
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_display, (unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2), { return 0; });
+int ast_adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2);
/*!
* \brief Sets the current line and page.
@@ -286,7 +287,7 @@
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_set_line, (unsigned char *buf, int page, int line), { return 0; });
+int ast_adsi_set_line(unsigned char *buf, int page, int line);
/*!
* \brief Creates "load soft key" parameters
@@ -300,7 +301,7 @@
* \retval number of bytes added to buffer
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_load_soft_key, (unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data), { return 0; });
+int ast_adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data);
/*!
* \brief Set which soft keys should be displayed
@@ -311,7 +312,7 @@
* \retval number of bytes added to buffer
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_set_keys, (unsigned char *buf, unsigned char *keys), { return 0; });
+int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys);
/*!
* \brief Set input information
@@ -325,7 +326,7 @@
* \retval number of bytes added to buffer
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_input_control, (unsigned char *buf, int page, int line, int display, int format, int just), { return 0; });
+int ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just);
/*!
* \brief Set input format
@@ -339,7 +340,41 @@
* \retval number of bytes added to buffer
* \retval -1 on error.
*/
-AST_OPTIONAL_API(int, ast_adsi_input_format, (unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2), { return 0; });
+int ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2);
+
+struct adsi_funcs {
+ unsigned int version;
+ int (*begin_download)(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version);
+ int (*end_download)(struct ast_channel *chan);
+ int (*channel_restore) (struct ast_channel *chan);
+ int (*print) (struct ast_channel *chan, char **lines, int *align, int voice);
+ int (*load_session) (struct ast_channel *chan, unsigned char *app, int ver, int data);
+ int (*unload_session) (struct ast_channel *chan);
+ int (*transmit_message) (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype);
+ int (*transmit_message_full) (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait);
+ int (*read_encoded_dtmf) (struct ast_channel *chan, unsigned char *buf, int maxlen);
+ int (*connect_session) (unsigned char *buf, unsigned char *fdn, int ver);
+ int (*query_cpeid) (unsigned char *buf);
+ int (*query_cpeinfo) (unsigned char *buf);
+ int (*get_cpeid) (struct ast_channel *chan, unsigned char *cpeid, int voice);
+ int (*get_cpeinfo) (struct ast_channel *chan, int *width, int *height, int *buttons, int voice);
+ int (*download_connect) (unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver);
+ int (*disconnect_session) (unsigned char *buf);
+ int (*download_disconnect) (unsigned char *buf);
+ int (*data_mode) (unsigned char *buf);
+ int (*clear_soft_keys) (unsigned char *buf);
+ int (*clear_screen) (unsigned char *buf);
+ int (*voice_mode) (unsigned char *buf, int when);
+ int (*available) (struct ast_channel *chan);
+ int (*display) (unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2);
+ int (*set_line) (unsigned char *buf, int page, int line);
+ int (*load_soft_key) (unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data);
+ int (*set_keys) (unsigned char *buf, unsigned char *keys);
+ int (*input_control) (unsigned char *buf, int page, int line, int display, int format, int just);
+ int (*input_format) (unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2);
+};
+
+void ast_adsi_install_funcs(const struct adsi_funcs *funcs);
#endif /* _ASTERISK_ADSI_H */
Modified: branches/10/main/Makefile
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/Makefile?view=diff&rev=369325&r1=369324&r2=369325
==============================================================================
--- branches/10/main/Makefile (original)
+++ branches/10/main/Makefile Mon Jun 25 10:52:42 2012
@@ -26,9 +26,6 @@
# otherwise modules will not have them available if none of the static
# objects use it.
OBJS+=stdtime/localtime.o
-ifneq ($(firstword $(subst :, ,$(WEAKREF))),1)
-OBJS+=../res/res_adsi.o
-endif
AST_LIBS += $(OPENSSL_LIB)
AST_LIBS += $(BKTR_LIB)
Modified: branches/10/res/res_adsi.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/res/res_adsi.c?view=diff&rev=369325&r1=369324&r2=369325
==============================================================================
--- branches/10/res/res_adsi.c (original)
+++ branches/10/res/res_adsi.c Mon Jun 25 10:52:42 2012
@@ -49,8 +49,6 @@
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/file.h"
-
-#define AST_API_MODULE
#include "asterisk/adsi.h"
#define DEFAULT_ADSI_MAX_RETRIES 3
@@ -72,6 +70,35 @@
static char speeddial[ADSI_MAX_SPEED_DIAL][3][SPEEDDIAL_MAX_LEN];
static int alignment = 0;
+
+static int adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version);
+static int adsi_end_download(struct ast_channel *chan);
+static int adsi_channel_restore(struct ast_channel *chan);
+static int adsi_print(struct ast_channel *chan, char **lines, int *align, int voice);
+static int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data);
+static int adsi_unload_session(struct ast_channel *chan);
+static int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype);
+static int adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait);
+static int adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen);
+static int adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver);
+static int adsi_query_cpeid(unsigned char *buf);
+static int adsi_query_cpeinfo(unsigned char *buf);
+static int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice);
+static int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice);
+static int adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver);
+static int adsi_disconnect_session(unsigned char *buf);
+static int adsi_download_disconnect(unsigned char *buf);
+static int adsi_data_mode(unsigned char *buf);
+static int adsi_clear_soft_keys(unsigned char *buf);
+static int adsi_clear_screen(unsigned char *buf);
+static int adsi_voice_mode(unsigned char *buf, int when);
+static int adsi_available(struct ast_channel *chan);
+static int adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2);
+static int adsi_set_line(unsigned char *buf, int page, int line);
+static int adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data);
+static int adsi_set_keys(unsigned char *buf, unsigned char *keys);
+static int adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just);
+static int adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2);
static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, struct ast_format *codec)
{
@@ -328,7 +355,7 @@
return 0;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_begin_download)(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
+static int adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
{
int bytes = 0;
unsigned char buf[256];
@@ -336,8 +363,8 @@
/* Setup the resident soft key stuff, a piece at a time */
/* Upload what scripts we can for voicemail ahead of time */
- bytes += ast_adsi_download_connect(buf + bytes, service, fdn, sec, version);
- if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) {
+ bytes += adsi_download_connect(buf + bytes, service, fdn, sec, version);
+ if (adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) {
return -1;
}
if (ast_readstring(chan, ack, 1, 10000, 10000, "")) {
@@ -350,21 +377,21 @@
return -1;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_end_download)(struct ast_channel *chan)
+static int adsi_end_download(struct ast_channel *chan)
{
int bytes = 0;
unsigned char buf[256];
/* Setup the resident soft key stuff, a piece at a time */
/* Upload what scripts we can for voicemail ahead of time */
- bytes += ast_adsi_download_disconnect(buf + bytes);
- if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) {
+ bytes += adsi_download_disconnect(buf + bytes);
+ if (adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) {
return -1;
}
return 0;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message_full)(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
+static int adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
{
unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL };
int msglens[5], msgtypes[5], newdatamode = (chan->adsicpe & ADSI_FLAG_DATAMODE), res, x, waitforswitch = 0;
@@ -440,9 +467,9 @@
return res;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message)(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
-{
- return ast_adsi_transmit_message_full(chan, msg, msglen, msgtype, 1);
+static int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
+{
+ return adsi_transmit_message_full(chan, msg, msglen, msgtype, 1);
}
static inline int ccopy(unsigned char *dst, const unsigned char *src, int max)
@@ -456,7 +483,7 @@
return x;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_load_soft_key)(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
+static int adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
{
int bytes = 0;
@@ -497,7 +524,7 @@
return bytes;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_connect_session)(unsigned char *buf, unsigned char *fdn, int ver)
+static int adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver)
{
int bytes = 0, x;
@@ -521,7 +548,7 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_download_connect)(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
+static int adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
{
int bytes = 0, x;
@@ -553,7 +580,7 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_disconnect_session)(unsigned char *buf)
+static int adsi_disconnect_session(unsigned char *buf)
{
int bytes = 0;
@@ -568,7 +595,7 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_query_cpeid)(unsigned char *buf)
+static int adsi_query_cpeid(unsigned char *buf)
{
int bytes = 0;
buf[bytes++] = ADSI_QUERY_CPEID;
@@ -578,7 +605,7 @@
return bytes;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_query_cpeinfo)(unsigned char *buf)
+static int adsi_query_cpeinfo(unsigned char *buf)
{
int bytes = 0;
buf[bytes++] = ADSI_QUERY_CONFIG;
@@ -588,7 +615,7 @@
return bytes;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_read_encoded_dtmf)(struct ast_channel *chan, unsigned char *buf, int maxlen)
+static int adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen)
{
int bytes = 0, res, gotstar = 0, pos = 0;
unsigned char current = 0;
@@ -625,20 +652,20 @@
return bytes;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_get_cpeid)(struct ast_channel *chan, unsigned char *cpeid, int voice)
+static int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
{
unsigned char buf[256] = "";
int bytes = 0, res;
- bytes += ast_adsi_data_mode(buf);
- ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
+ bytes += adsi_data_mode(buf);
+ adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
bytes = 0;
- bytes += ast_adsi_query_cpeid(buf);
- ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
+ bytes += adsi_query_cpeid(buf);
+ adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
/* Get response */
- res = ast_adsi_read_encoded_dtmf(chan, cpeid, 4);
+ res = adsi_read_encoded_dtmf(chan, cpeid, 4);
if (res != 4) {
ast_log(LOG_WARNING, "Got %d bytes back of encoded DTMF, expecting 4\n", res);
res = 0;
@@ -648,25 +675,25 @@
if (voice) {
bytes = 0;
- bytes += ast_adsi_voice_mode(buf, 0);
- ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
+ bytes += adsi_voice_mode(buf, 0);
+ adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
/* Ignore the resulting DTMF B announcing it's in voice mode */
ast_waitfordigit(chan, 1000);
}
return res;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_get_cpeinfo)(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
+static int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
{
unsigned char buf[256] = "";
int bytes = 0, res;
- bytes += ast_adsi_data_mode(buf);
- ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
+ bytes += adsi_data_mode(buf);
+ adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
bytes = 0;
- bytes += ast_adsi_query_cpeinfo(buf);
- ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
+ bytes += adsi_query_cpeinfo(buf);
+ adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
/* Get width */
if ((res = ast_readstring(chan, (char *) buf, 2, 1000, 500, "")) < 0) {
@@ -715,15 +742,15 @@
}
if (voice) {
bytes = 0;
- bytes += ast_adsi_voice_mode(buf, 0);
- ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
+ bytes += adsi_voice_mode(buf, 0);
+ adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
/* Ignore the resulting DTMF B announcing it's in voice mode */
ast_waitfordigit(chan, 1000);
}
return res;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_data_mode)(unsigned char *buf)
+static int adsi_data_mode(unsigned char *buf)
{
int bytes = 0;
@@ -738,7 +765,7 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_clear_soft_keys)(unsigned char *buf)
+static int adsi_clear_soft_keys(unsigned char *buf)
{
int bytes = 0;
@@ -753,7 +780,7 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_clear_screen)(unsigned char *buf)
+static int adsi_clear_screen(unsigned char *buf)
{
int bytes = 0;
@@ -768,7 +795,7 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_voice_mode)(unsigned char *buf, int when)
+static int adsi_voice_mode(unsigned char *buf, int when)
{
int bytes = 0;
@@ -785,7 +812,7 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_available)(struct ast_channel *chan)
+static int adsi_available(struct ast_channel *chan)
{
int cpe = chan->adsicpe & 0xff;
if ((cpe == AST_ADSI_AVAILABLE) ||
@@ -795,7 +822,7 @@
return 0;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_download_disconnect)(unsigned char *buf)
+static int adsi_download_disconnect(unsigned char *buf)
{
int bytes = 0;
@@ -810,7 +837,7 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_display)(unsigned char *buf, int page, int line, int just, int wrap,
+static int adsi_display(unsigned char *buf, int page, int line, int just, int wrap,
char *col1, char *col2)
{
int bytes = 0;
@@ -857,7 +884,7 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_input_control)(unsigned char *buf, int page, int line, int display, int format, int just)
+static int adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
{
int bytes = 0;
@@ -880,7 +907,7 @@
return bytes;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_input_format)(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
+static int adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
{
int bytes = 0;
@@ -900,7 +927,7 @@
return bytes;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_set_keys)(unsigned char *buf, unsigned char *keys)
+static int adsi_set_keys(unsigned char *buf, unsigned char *keys)
{
int bytes = 0, x;
@@ -916,7 +943,7 @@
return bytes;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_set_line)(unsigned char *buf, int page, int line)
+static int adsi_set_line(unsigned char *buf, int page, int line)
{
int bytes = 0;
@@ -947,14 +974,14 @@
static int total = 0;
static int speeds = 0;
-int AST_OPTIONAL_API_NAME(ast_adsi_channel_restore)(struct ast_channel *chan)
+static int adsi_channel_restore(struct ast_channel *chan)
{
unsigned char dsp[256] = "", keyd[6] = "";
int bytes, x;
/* Start with initial display setup */
bytes = 0;
- bytes += ast_adsi_set_line(dsp + bytes, ADSI_INFO_PAGE, 1);
+ bytes += adsi_set_line(dsp + bytes, ADSI_INFO_PAGE, 1);
/* Prepare key setup messages */
@@ -962,26 +989,26 @@
for (x = 0; x < speeds; x++) {
keyd[x] = ADSI_SPEED_DIAL + x;
}
- bytes += ast_adsi_set_keys(dsp + bytes, keyd);
- }
- ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0);
+ bytes += adsi_set_keys(dsp + bytes, keyd);
+ }
+ adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0);
return 0;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_print)(struct ast_channel *chan, char **lines, int *alignments, int voice)
+static int adsi_print(struct ast_channel *chan, char **lines, int *alignments, int voice)
{
unsigned char buf[4096];
int bytes = 0, res, x;
for (x = 0; lines[x]; x++) {
- bytes += ast_adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, alignments[x], 0, lines[x], "");
- }
- bytes += ast_adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1);
+ bytes += adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, alignments[x], 0, lines[x], "");
+ }
+ bytes += adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1);
if (voice) {
- bytes += ast_adsi_voice_mode(buf + bytes, 0);
- }
- res = ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
+ bytes += adsi_voice_mode(buf + bytes, 0);
+ }
+ res = adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
if (voice) {
/* Ignore the resulting DTMF B announcing it's in voice mode */
ast_waitfordigit(chan, 1000);
@@ -989,21 +1016,21 @@
return res;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_load_session)(struct ast_channel *chan, unsigned char *app, int ver, int data)
+static int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
{
unsigned char dsp[256] = "";
int bytes = 0, res;
char resp[2];
/* Connect to session */
- bytes += ast_adsi_connect_session(dsp + bytes, app, ver);
+ bytes += adsi_connect_session(dsp + bytes, app, ver);
if (data) {
- bytes += ast_adsi_data_mode(dsp + bytes);
+ bytes += adsi_data_mode(dsp + bytes);
}
/* Prepare key setup messages */
- if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) {
+ if (adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) {
return -1;
}
if (app) {
@@ -1028,17 +1055,17 @@
}
-int AST_OPTIONAL_API_NAME(ast_adsi_unload_session)(struct ast_channel *chan)
+static int adsi_unload_session(struct ast_channel *chan)
{
unsigned char dsp[256] = "";
int bytes = 0;
/* Connect to session */
- bytes += ast_adsi_disconnect_session(dsp + bytes);
- bytes += ast_adsi_voice_mode(dsp + bytes, 0);
+ bytes += adsi_disconnect_session(dsp + bytes);
+ bytes += adsi_voice_mode(dsp + bytes, 0);
/* Prepare key setup messages */
- if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) {
+ if (adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) {
return -1;
}
@@ -1140,19 +1167,53 @@
return 0;
}
+static struct adsi_funcs res_adsi_funcs = {
+ .version = AST_ADSI_VERSION,
+ .begin_download = adsi_begin_download,
+ .end_download = adsi_end_download,
+ .channel_restore = adsi_channel_restore,
+ .print = adsi_print,
+ .load_session = adsi_load_session,
+ .unload_session = adsi_unload_session,
+ .transmit_message = adsi_transmit_message,
+ .transmit_message_full = adsi_transmit_message_full,
+ .read_encoded_dtmf = adsi_read_encoded_dtmf,
+ .connect_session = adsi_connect_session,
+ .query_cpeid = adsi_query_cpeid,
+ .query_cpeinfo = adsi_query_cpeinfo,
+ .get_cpeid = adsi_get_cpeid,
+ .get_cpeinfo = adsi_get_cpeinfo,
+ .download_connect = adsi_download_connect,
+ .disconnect_session = adsi_disconnect_session,
+ .download_disconnect = adsi_download_disconnect,
+ .data_mode = adsi_data_mode,
+ .clear_soft_keys = adsi_clear_soft_keys,
+ .clear_screen = adsi_clear_screen,
+ .voice_mode = adsi_voice_mode,
+ .available = adsi_available,
+ .display = adsi_display,
+ .set_line = adsi_set_line,
+ .load_soft_key = adsi_load_soft_key,
+ .set_keys = adsi_set_keys,
+ .input_control = adsi_input_control,
+ .input_format = adsi_input_format,
+};
+
static int load_module(void)
{
adsi_load(0);
+ ast_adsi_install_funcs(&res_adsi_funcs);
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
/* Can't unload this once we're loaded */
+ ast_adsi_install_funcs(NULL);
return -1;
}
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "ADSI Resource",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ADSI Resource",
.load = load_module,
.unload = unload_module,
.reload = reload,
More information about the svn-commits
mailing list