[asterisk-commits] trunk r21338 - in /trunk: channel.c include/asterisk/say.h say.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Apr 19 00:23:25 MST 2006


Author: rizzo
Date: Wed Apr 19 02:23:22 2006
New Revision: 21338

URL: http://svn.digium.com/view/asterisk?rev=21338&view=rev
Log:
move to a different file (channel.c for the time being) the
wrappers around the basic 'say' functions, and redeclare these
wrappers as ordinary functions rather than function pointers.

This way, alternative implementations of the 'say' functions
will only have to implement the basic functions and not the
wrappers.


Modified:
    trunk/channel.c
    trunk/include/asterisk/say.h
    trunk/say.c

Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=21338&r1=21337&r2=21338&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Wed Apr 19 02:23:22 2006
@@ -4219,3 +4219,58 @@
 }
 
 #endif
+
+/*
+ * Wrappers for various ast_say_*() functions that call the full version
+ * of the same functions.
+ * The proper place would be say.c, but that file is optional and one
+ * must be able to build asterisk even without it (using a loadable 'say'
+ * implementation that only supplies the 'full' version of the functions.
+ */
+
+int ast_say_number(struct ast_channel *chan, int num,
+	const char *ints, const char *language, const char *options)
+{
+        return ast_say_number_full(chan, num, ints, language, options, -1, -1);
+}
+
+int ast_say_enumeration(struct ast_channel *chan, int num,
+	const char *ints, const char *language, const char *options)
+{
+        return ast_say_enumeration_full(chan, num, ints, language, options, -1, -1);
+}
+
+int ast_say_digits(struct ast_channel *chan, int num,
+	const char *ints, const char *lang)
+{
+        return ast_say_digits_full(chan, num, ints, lang, -1, -1);
+}
+
+int ast_say_digit_str(struct ast_channel *chan, const char *str,
+	const char *ints, const char *lang)
+{
+        return ast_say_digit_str_full(chan, str, ints, lang, -1, -1);
+}
+
+int ast_say_character_str(struct ast_channel *chan, const char *str,
+	const char *ints, const char *lang)
+{
+        return ast_say_character_str_full(chan, str, ints, lang, -1, -1);
+}
+
+int ast_say_phonetic_str(struct ast_channel *chan, const char *str,
+	const char *ints, const char *lang)
+{
+        return ast_say_phonetic_str_full(chan, str, ints, lang, -1, -1);
+}
+
+int ast_say_digits_full(struct ast_channel *chan, int num,
+	const char *ints, const char *lang, int audiofd, int ctrlfd)
+{
+        char buf[256];
+
+        snprintf(buf, sizeof(buf), "%d", num);
+        return ast_say_digit_str_full(chan, buf, ints, lang, audiofd, ctrlfd);
+}
+
+/* end of file */

Modified: trunk/include/asterisk/say.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/say.h?rev=21338&r1=21337&r2=21338&view=diff
==============================================================================
--- trunk/include/asterisk/say.h (original)
+++ trunk/include/asterisk/say.h Wed Apr 19 02:23:22 2006
@@ -33,11 +33,16 @@
 #endif
 
 /*! \brief
- * All ast_say_* functions are implemented as function pointers,
+ * The basic 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
+ * Other interfaces, declared here as regular functions, are simply
+ * wrappers around the basic functions.
+ *
+ * An implementation of the basic ast_say functions (e.g. from say.c or from
  * a dynamically loaded module) will just have to reassign the pointers
  * to the relevant functions to override the previous implementation.
+ *
+ * \todo XXX
  * 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
@@ -70,7 +75,8 @@
  * Vocally says a number on a given channel
  * Returns 0 on success, DTMF digit on interrupt, -1 on failure
  */
-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);
+int ast_say_number(struct ast_channel *chan, int num,
+	const char *ints, const char *lang, const char *options);
 
 /* Same as above with audiofd for received audio and returns 1 on ctrlfd being readable */
 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);
@@ -85,7 +91,9 @@
  * 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
  */
-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);
+int ast_say_enumeration(struct ast_channel *chan, int num,
+	const char *ints, const char *lang, const char *options);
+
 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
@@ -96,8 +104,11 @@
  * Vocally says digits of a given number
  * Returns 0 on success, dtmf if interrupted, -1 on failure
  */
-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);
+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);
 
 /* says digits of a string
  * \param chan channel to act upon
@@ -107,7 +118,9 @@
  * Vocally says the digits of a given string
  * Returns 0 on success, dtmf if interrupted, -1 on failure
  */
-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);
+int ast_say_digit_str(struct ast_channel *chan, const char *num,
+	const char *ints, const char *lang);
+
 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);
 
 /*
@@ -115,9 +128,18 @@
  * 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);
+
+/*
+ * other function to pronounce character and phonetic strings
+ */
+int ast_say_character_str(struct ast_channel *chan, const char *num,
+	const char *ints, const char *lang);
+
 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);
+
+int ast_say_phonetic_str(struct ast_channel *chan, const char *num,
+	const char *ints, const char *lang);
+
 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);
 
 SAY_EXTERN int (* ast_say_datetime)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime);

Modified: trunk/say.c
URL: http://svn.digium.com/view/asterisk/trunk/say.c?rev=21338&r1=21337&r2=21338&view=diff
==============================================================================
--- trunk/say.c (original)
+++ trunk/say.c Wed Apr 19 02:23:22 2006
@@ -132,11 +132,6 @@
 	return res;
 }
 
-static int say_character_str(struct ast_channel *chan, const char *str, const char *ints, const char *lang)
-{
-	return ast_say_character_str_full(chan, str, ints, lang, -1, -1);
-}
-
 static int say_phonetic_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
 {
 	const char *fn;
@@ -211,11 +206,6 @@
 	return res;
 }
 
-static int say_phonetic_str(struct ast_channel *chan, const char *str, const char *ints, const char *lang)
-{
-	return ast_say_phonetic_str_full(chan, str, ints, lang, -1, -1);
-}
-
 static int say_digit_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
 {
 	const char *fn;
@@ -260,24 +250,6 @@
 	}
 
 	return res;
-}
-
-static int say_digit_str(struct ast_channel *chan, const char *str, const char *ints, const char *lang)
-{
-	return ast_say_digit_str_full(chan, str, ints, lang, -1, -1);
-}
-
-static int say_digits_full(struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd)
-{
-	char fn2[256];
-
-	snprintf(fn2, sizeof(fn2), "%d", num);
-	return ast_say_digit_str_full(chan, fn2, ints, lang, audiofd, ctrlfd);
-}
-
-static int say_digits(struct ast_channel *chan, int num, const char *ints, const char *lang)
-{
-	return ast_say_digits_full(chan, num, ints, lang, -1, -1);
 }
 
 /* Forward declarations */
@@ -454,12 +426,6 @@
 
 	/* Default to english */
 	return(ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd));
-}
-
-/*! \brief  ast_say_number: call language-specific functions without file descriptors */
-static int say_number(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
-{
-	return(ast_say_number_full(chan, num, ints, language, options, -1, -1));
 }
 
 /*! \brief  ast_say_number_full_en: English syntax */
@@ -2288,12 +2254,6 @@
 	return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd));
 }
 
-/*! \brief  ast_say_enumeration: call language-specific functions without file descriptors */
-static int say_enumeration(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
-{
-	return(ast_say_enumeration_full(chan, num, ints, language, options, -1, -1));
-}
-
 /*! \brief  ast_say_enumeration_full_en: English syntax */
 /* This is the default syntax, if no other syntax defined in this file is used */
 static int ast_say_enumeration_full_en(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
@@ -6201,17 +6161,10 @@
  */
 static void __attribute__((constructor)) __say_init(void)
 {
-	ast_say_number = say_number;
 	ast_say_number_full = say_number_full;
-	ast_say_enumeration = say_enumeration;
 	ast_say_enumeration_full = say_enumeration_full;
-	ast_say_digits = say_digits;
-	ast_say_digits_full = say_digits_full;
-	ast_say_digit_str = say_digit_str;
 	ast_say_digit_str_full = say_digit_str_full;
-	ast_say_character_str = say_character_str;
 	ast_say_character_str_full = say_character_str_full;
-	ast_say_phonetic_str = say_phonetic_str;
 	ast_say_phonetic_str_full = say_phonetic_str_full;
 	ast_say_datetime = say_datetime;
 	ast_say_time = say_time;



More information about the asterisk-commits mailing list