summaryrefslogtreecommitdiff
path: root/include/asterisk/say.h
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2006-03-23 14:28:16 +0000
committerLuigi Rizzo <rizzo@icir.org>2006-03-23 14:28:16 +0000
commitdde76c531cbe762ca52775abc25f37acea688add (patch)
tree3d4ec3a8d3305673b945bdec58afa7bb58632fbd /include/asterisk/say.h
parent408a6e25e41d82882013cf8a4300b8ee683299ca (diff)
Replace ast_say_* functionn with function pointers, so that modules
can override them. On passing, fix a potential problem in the top level Makefile: if a static library is not referenced by any of the core objects, it is not linked in the main program, and will not be available to modules, which leads to failure at runtime when the modules are loaded. This is the case of stdtime/localtime.o, which supplies some core symbolx, but is only linked in as a library. Fix the problem by linking in the object. NOTE: this is intended as a temporary aid to replace the existing say.c with a newer implementation. Once the task is completed, we may decide whether or not the ast_say*() functions should be pluggable or not and possibly revert part of this change. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@14382 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/say.h')
-rw-r--r--include/asterisk/say.h68
1 files changed, 51 insertions, 17 deletions
diff --git a/include/asterisk/say.h b/include/asterisk/say.h
index ac498cde2..6c2396fc9 100644
--- a/include/asterisk/say.h
+++ b/include/asterisk/say.h
@@ -32,6 +32,35 @@
extern "C" {
#endif
+/*! \brief
+ * All ast_say_* functions are implemented as function pointers,
+ * initialized to the function say_stub() which simply returns an error.
+ * An implementation of these functions (e.g. say.c, if available, or
+ * a dynamically loaded module) will just have to reassign the pointers
+ * to the relevant functions to override the previous implementation.
+ * As the conversion from the old implementation of say.c to the new
+ * implementation will be completed, and the API suitably reworked by
+ * removing redundant functions and/or arguments, this mechanism may be
+ * reverted back to pure static functions, if needed.
+ */
+#if defined(SAY_STUBS)
+/* provide declarations for the *say*() functions
+ * and initialize them to the stub function
+ */
+static int say_stub(struct ast_channel *chan, ...)
+{
+ ast_log(LOG_WARNING, "no implementation for the say() functions\n");
+ return -1;
+};
+
+#undef SAY_STUBS
+#define SAY_INIT(x) = (typeof (x))say_stub
+#define SAY_EXTERN
+#else
+#define SAY_INIT(x)
+#define SAY_EXTERN extern
+#endif
+
/* says a number
* \param chan channel to say them number on
* \param num number to say on the channel
@@ -41,10 +70,10 @@ extern "C" {
* Vocally says a number on a given channel
* Returns 0 on success, DTMF digit on interrupt, -1 on failure
*/
-int ast_say_number(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options);
+SAY_EXTERN int (*ast_say_number)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options) SAY_INIT(ast_say_number);
/* Same as above with audiofd for received audio and returns 1 on ctrlfd being readable */
-int ast_say_number_full(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd);
+SAY_EXTERN int (* ast_say_number_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_number_full);
/* says an enumeration
* \param chan channel to say them enumeration on
@@ -56,8 +85,8 @@ int ast_say_number_full(struct ast_channel *chan, int num, const char *ints, con
* especially useful for dates and messages. says 'last' if num equals to INT_MAX
* Returns 0 on success, DTMF digit on interrupt, -1 on failure
*/
-int ast_say_enumeration(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options);
-int ast_say_enumeration_full(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd);
+SAY_EXTERN int (* ast_say_enumeration)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options) SAY_INIT(ast_say_enumeration);
+SAY_EXTERN int (* ast_say_enumeration_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_enumeration_full);
/* says digits
* \param chan channel to act upon
@@ -67,8 +96,8 @@ int ast_say_enumeration_full(struct ast_channel *chan, int num, const char *ints
* Vocally says digits of a given number
* Returns 0 on success, dtmf if interrupted, -1 on failure
*/
-int ast_say_digits(struct ast_channel *chan, int num, const char *ints, const char *lang);
-int ast_say_digits_full(struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd);
+SAY_EXTERN int (*ast_say_digits)(struct ast_channel *chan, int num, const char *ints, const char *lang) SAY_INIT(ast_say_digits);
+SAY_EXTERN int (*ast_say_digits_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_digits_full);
/* says digits of a string
* \param chan channel to act upon
@@ -78,22 +107,27 @@ int ast_say_digits_full(struct ast_channel *chan, int num, const char *ints, con
* Vocally says the digits of a given string
* Returns 0 on success, dtmf if interrupted, -1 on failure
*/
-int ast_say_digit_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang);
-int ast_say_digit_str_full(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd);
-int ast_say_character_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang);
-int ast_say_character_str_full(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd);
-int ast_say_phonetic_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang);
-int ast_say_phonetic_str_full(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd);
+SAY_EXTERN int (* ast_say_digit_str)(struct ast_channel *chan, const char *num, const char *ints, const char *lang) SAY_INIT(ast_say_digit_str);
+SAY_EXTERN int (* ast_say_digit_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_digit_str_full);
-int ast_say_datetime(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
+/*
+ * the generic 'say' routine, with the first chars in the string
+ * defining the format to use
+ */
+SAY_EXTERN int (* ast_say_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_full);
+SAY_EXTERN int (* ast_say_character_str)(struct ast_channel *chan, const char *num, const char *ints, const char *lang) SAY_INIT(ast_say_character_str);
+SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full);
+SAY_EXTERN int (* ast_say_phonetic_str)(struct ast_channel *chan, const char *num, const char *ints, const char *lang) SAY_INIT(ast_say_phonetic_str);
+SAY_EXTERN int (* ast_say_phonetic_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_phonetic_str_full);
-int ast_say_time(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
+SAY_EXTERN int (* ast_say_datetime)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime);
+SAY_EXTERN int (* ast_say_time)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_time);
-int ast_say_date(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
+SAY_EXTERN int (* ast_say_date)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_date);
-int ast_say_datetime_from_now(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
+SAY_EXTERN int (* ast_say_datetime_from_now)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime_from_now);
-int ast_say_date_with_format(struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *timezone);
+SAY_EXTERN int (* ast_say_date_with_format)(struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *timezone) SAY_INIT(ast_say_date_with_format);
#if defined(__cplusplus) || defined(c_plusplus)
}