summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2012-06-25 15:55:25 +0000
committerMark Michelson <mmichelson@digium.com>2012-06-25 15:55:25 +0000
commit453e01725de7d16f538ca928065fcee3a6d0e650 (patch)
treecf4b1ac303894a749fe6544f1cf2782a71bcee3f
parent87810af23dc9ca98a6f544fee78dcd58022c813a (diff)
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 ........ Merged revisions 369325 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369326 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--include/asterisk/adsi.h93
-rw-r--r--main/Makefile3
-rw-r--r--main/adsi.c351
-rw-r--r--res/res_adsi.c185
-rw-r--r--res/res_adsi.exports.in33
5 files changed, 538 insertions, 127 deletions
diff --git a/include/asterisk/adsi.h b/include/asterisk/adsi.h
index c4ffedda1..31db2acb9 100644
--- a/include/asterisk/adsi.h
+++ b/include/asterisk/adsi.h
@@ -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; });
+int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version);
-AST_OPTIONAL_API(int, ast_adsi_end_download, (struct ast_channel *chan), { return 0; });
+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 @@ AST_OPTIONAL_API(int, ast_adsi_end_download, (struct ast_channel *chan), { retur
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_channel_restore, (struct ast_channel *chan), { re
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_print, (struct ast_channel *chan, char **lines, i
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_read_encoded_dtmf, (struct ast_channel *chan, uns
* \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; });
+int ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice);
-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_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice);
/*!
* \brief Begin an ADSI script download
@@ -213,7 +214,7 @@ AST_OPTIONAL_API(int, ast_adsi_get_cpeinfo, (struct ast_channel *chan, int *widt
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_download_connect, (unsigned char *buf, char *serv
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_disconnect_session, (unsigned char *buf), { retur
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_download_disconnect, (unsigned char *buf), { retu
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_clear_screen, (unsigned char *buf), { return 0; }
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_available, (struct ast_channel *chan), { return 0
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_display, (unsigned char *buf, int page, int line,
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_set_line, (unsigned char *buf, int page, int line
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_load_soft_key, (unsigned char *buf, int key, cons
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_set_keys, (unsigned char *buf, unsigned char *key
* \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 @@ AST_OPTIONAL_API(int, ast_adsi_input_control, (unsigned char *buf, int page, int
* \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 */
diff --git a/main/Makefile b/main/Makefile
index 3429723b6..4d446f08c 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -29,9 +29,6 @@ OBJS=$(filter-out $(OBJSFILTER),$(SRC:.c=.o))
# 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
ASTSSL_LIBS:=$(OPENSSL_LIB)
AST_LIBS+=$(BKTR_LIB)
diff --git a/main/adsi.c b/main/adsi.c
new file mode 100644
index 000000000..870b13291
--- /dev/null
+++ b/main/adsi.c
@@ -0,0 +1,351 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief ADSI Support (built upon Caller*ID)
+ */
+
+#include "asterisk.h"
+
+#include "asterisk/adsi.h"
+#include "asterisk/lock.h"
+
+static const struct adsi_funcs *installed_funcs;
+static const int current_adsi_version = AST_ADSI_VERSION;
+AST_RWLOCK_DEFINE_STATIC(func_lock);
+
+int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->begin_download) {
+ res = installed_funcs->begin_download(chan, service, fdn, sec, version);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_end_download(struct ast_channel *chan)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->end_download) {
+ res = installed_funcs->end_download(chan);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_channel_restore(struct ast_channel *chan)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->channel_restore) {
+ res = installed_funcs->channel_restore(chan);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_print(struct ast_channel *chan, char **lines, int *align, int voice)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->print) {
+ res = installed_funcs->print(chan, lines, align, voice);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->load_session) {
+ res = installed_funcs->load_session(chan, app, ver, data);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_unload_session(struct ast_channel *chan)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->unload_session) {
+ res = installed_funcs->unload_session(chan);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->transmit_message) {
+ res = installed_funcs->transmit_message(chan, msg, msglen, msgtype);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->transmit_message_full) {
+ res = installed_funcs->transmit_message_full(chan, msg, msglen, msgtype, dowait);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->read_encoded_dtmf) {
+ res = installed_funcs->read_encoded_dtmf(chan, buf, maxlen);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->connect_session) {
+ res = installed_funcs->connect_session(buf, fdn, ver);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_query_cpeid(unsigned char *buf)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->query_cpeid) {
+ res = installed_funcs->query_cpeid(buf);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_query_cpeinfo(unsigned char *buf)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->query_cpeinfo) {
+ res = installed_funcs->query_cpeinfo(buf);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->get_cpeid) {
+ res = installed_funcs->get_cpeid(chan, cpeid, voice);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->get_cpeinfo) {
+ res = installed_funcs->get_cpeinfo(chan, width, height, buttons, voice);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->download_connect) {
+ res = installed_funcs->download_connect(buf, service, fdn, sec, ver);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_disconnect_session(unsigned char *buf)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->disconnect_session) {
+ res = installed_funcs->disconnect_session(buf);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_download_disconnect(unsigned char *buf)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->download_disconnect) {
+ res = installed_funcs->download_disconnect(buf);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_data_mode(unsigned char *buf)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->data_mode) {
+ res = installed_funcs->data_mode(buf);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_clear_soft_keys(unsigned char *buf)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->clear_soft_keys) {
+ res = installed_funcs->clear_soft_keys(buf);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_clear_screen(unsigned char *buf)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->clear_screen) {
+ res = installed_funcs->clear_screen(buf);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_voice_mode(unsigned char *buf, int when)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->voice_mode) {
+ res = installed_funcs->voice_mode(buf, when);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_available(struct ast_channel *chan)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->available) {
+ res = installed_funcs->available(chan);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->display) {
+ res = installed_funcs->display(buf, page, line, just, wrap, col1, col2);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_set_line(unsigned char *buf, int page, int line)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->set_line) {
+ res = installed_funcs->set_line(buf, page, line);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->load_soft_key) {
+ res = installed_funcs->load_soft_key(buf, key, llabel, slabel, ret, data);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->set_keys) {
+ res = installed_funcs->set_keys(buf, keys);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->input_control) {
+ res = installed_funcs->input_control(buf, page, line, display, format, just);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+int ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
+{
+ int res = 0;
+ ast_rwlock_rdlock(&func_lock);
+ if (installed_funcs && installed_funcs->input_format) {
+ res = installed_funcs->input_format(buf, num, dir, wrap, format1, format2);
+ }
+ ast_rwlock_unlock(&func_lock);
+ return res;
+}
+
+void ast_adsi_install_funcs(const struct adsi_funcs *funcs)
+{
+ if (funcs->version < current_adsi_version) {
+ ast_log(LOG_WARNING, "Cannot install ADSI function pointers due to version mismatch."
+ "Ours: %u, Theirs: %u\n", current_adsi_version, funcs->version);
+ return;
+ }
+
+ ast_rwlock_wrlock(&func_lock);
+ installed_funcs = funcs;
+ ast_rwlock_unlock(&func_lock);
+}
diff --git a/res/res_adsi.c b/res/res_adsi.c
index f00ec8648..92987f072 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -49,8 +49,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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
@@ -73,6 +71,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)
{
int sum, x, bytes = 0;
@@ -328,7 +355,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_begin_download)(struct ast_channel *chan, cha
/* 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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_begin_download)(struct ast_channel *chan, cha
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 = (ast_channel_adsicpe(chan) & ADSI_FLAG_DATAMODE), res, x, waitforswitch = 0;
@@ -440,9 +467,9 @@ int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message_full)(struct ast_channel *ch
return res;
}
-int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message)(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
+static int 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);
+ 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 @@ static inline int ccopy(unsigned char *dst, const unsigned char *src, int max)
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_load_soft_key)(unsigned char *buf, int key, c
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_connect_session)(unsigned char *buf, unsigned
}
-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_download_connect)(unsigned char *buf, char *s
}
-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_disconnect_session)(unsigned char *buf)
}
-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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_query_cpeid)(unsigned char *buf)
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_query_cpeinfo)(unsigned char *buf)
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_read_encoded_dtmf)(struct ast_channel *chan,
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_get_cpeid)(struct ast_channel *chan, unsigned
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_get_cpeinfo)(struct ast_channel *chan, int *w
}
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_data_mode)(unsigned char *buf)
}
-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_soft_keys)(unsigned char *buf)
}
-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_clear_screen)(unsigned char *buf)
}
-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_voice_mode)(unsigned char *buf, int when)
}
-int AST_OPTIONAL_API_NAME(ast_adsi_available)(struct ast_channel *chan)
+static int adsi_available(struct ast_channel *chan)
{
int cpe = ast_channel_adsicpe(chan) & 0xff;
if ((cpe == AST_ADSI_AVAILABLE) ||
@@ -795,7 +822,7 @@ int AST_OPTIONAL_API_NAME(ast_adsi_available)(struct ast_channel *chan)
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_download_disconnect)(unsigned char *buf)
}
-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_display)(unsigned char *buf, int page, int li
}
-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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_input_control)(unsigned char *buf, int page,
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_input_format)(unsigned char *buf, int num, in
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_set_keys)(unsigned char *buf, unsigned char *
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_set_line)(unsigned char *buf, int page, int l
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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_channel_restore)(struct ast_channel *chan)
for (x = 0; x < speeds; x++) {
keyd[x] = ADSI_SPEED_DIAL + x;
}
- bytes += ast_adsi_set_keys(dsp + bytes, keyd);
+ bytes += adsi_set_keys(dsp + bytes, keyd);
}
- ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0);
+ 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 += 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_set_line(buf + bytes, ADSI_INFO_PAGE, 1);
if (voice) {
- bytes += ast_adsi_voice_mode(buf + bytes, 0);
+ bytes += adsi_voice_mode(buf + bytes, 0);
}
- res = ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 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 @@ int AST_OPTIONAL_API_NAME(ast_adsi_print)(struct ast_channel *chan, char **lines
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_load_session)(struct ast_channel *chan, unsig
}
-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 @@ static int reload(void)
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,
diff --git a/res/res_adsi.exports.in b/res/res_adsi.exports.in
deleted file mode 100644
index fd7527b36..000000000
--- a/res/res_adsi.exports.in
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- global:
- LINKER_SYMBOL_PREFIX*ast_adsi_available;
- LINKER_SYMBOL_PREFIX*ast_adsi_begin_download;
- LINKER_SYMBOL_PREFIX*ast_adsi_channel_restore;
- LINKER_SYMBOL_PREFIX*ast_adsi_clear_screen;
- LINKER_SYMBOL_PREFIX*ast_adsi_clear_soft_keys;
- LINKER_SYMBOL_PREFIX*ast_adsi_connect_session;
- LINKER_SYMBOL_PREFIX*ast_adsi_data_mode;
- LINKER_SYMBOL_PREFIX*ast_adsi_disconnect_session;
- LINKER_SYMBOL_PREFIX*ast_adsi_display;
- LINKER_SYMBOL_PREFIX*ast_adsi_download_connect;
- LINKER_SYMBOL_PREFIX*ast_adsi_download_disconnect;
- LINKER_SYMBOL_PREFIX*ast_adsi_end_download;
- LINKER_SYMBOL_PREFIX*ast_adsi_get_cpeid;
- LINKER_SYMBOL_PREFIX*ast_adsi_get_cpeinfo;
- LINKER_SYMBOL_PREFIX*ast_adsi_input_control;
- LINKER_SYMBOL_PREFIX*ast_adsi_input_format;
- LINKER_SYMBOL_PREFIX*ast_adsi_load_session;
- LINKER_SYMBOL_PREFIX*ast_adsi_load_soft_key;
- LINKER_SYMBOL_PREFIX*ast_adsi_print;
- LINKER_SYMBOL_PREFIX*ast_adsi_query_cpeid;
- LINKER_SYMBOL_PREFIX*ast_adsi_query_cpeinfo;
- LINKER_SYMBOL_PREFIX*ast_adsi_read_encoded_dtmf;
- LINKER_SYMBOL_PREFIX*ast_adsi_set_keys;
- LINKER_SYMBOL_PREFIX*ast_adsi_set_line;
- LINKER_SYMBOL_PREFIX*ast_adsi_transmit_message;
- LINKER_SYMBOL_PREFIX*ast_adsi_transmit_message_full;
- LINKER_SYMBOL_PREFIX*ast_adsi_unload_session;
- LINKER_SYMBOL_PREFIX*ast_adsi_voice_mode;
- local:
- *;
-};