From: Mark Michelson Date: Mon, 25 Jun 2012 15:35:43 +0000 (+0000) Subject: Eliminate embedding of res_adsi.so module. X-Git-Tag: 1.8.15.0-rc1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd11706d8eebbdd43b3709dd61b1a475a1357ce3;p=thirdparty%2Fasterisk.git 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 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@369323 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/include/asterisk/adsi.h b/include/asterisk/adsi.h index c4ffedda16..31db2acb95 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 67f8b2ea08..72465e56df 100644 --- a/main/Makefile +++ b/main/Makefile @@ -26,9 +26,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 AST_LIBS += $(OPENSSL_LIB) AST_LIBS += $(BKTR_LIB) diff --git a/res/res_adsi.c b/res/res_adsi.c index 05174def87..3579e48da0 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, format_t codec) { int sum, x, bytes = 0; @@ -326,7 +353,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]; @@ -334,8 +361,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, "")) { @@ -348,21 +375,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 = (chan->adsicpe & ADSI_FLAG_DATAMODE), res, x, writeformat = chan->writeformat, readformat = chan->readformat, waitforswitch = 0; @@ -433,9 +460,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) @@ -449,7 +476,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; @@ -490,7 +517,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; @@ -514,7 +541,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; @@ -546,7 +573,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; @@ -561,7 +588,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; @@ -571,7 +598,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; @@ -581,7 +608,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; @@ -618,20 +645,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; @@ -641,25 +668,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) { @@ -708,15 +735,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; @@ -731,7 +758,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; @@ -746,7 +773,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; @@ -761,7 +788,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; @@ -778,7 +805,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 = chan->adsicpe & 0xff; if ((cpe == AST_ADSI_AVAILABLE) || @@ -788,7 +815,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; @@ -803,7 +830,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; @@ -850,7 +877,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; @@ -873,7 +900,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; @@ -893,7 +920,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; @@ -909,7 +936,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; @@ -940,14 +967,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 */ @@ -955,26 +982,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); @@ -982,21 +1009,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) { @@ -1021,17 +1048,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; } @@ -1133,19 +1160,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 fd7527b368..0000000000 --- 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: - *; -};