Changeset 2975

Move struct opbx_custom_function into pbx.c since it's private
now. Rename to opbx_func - apps aren't "custom", funcs don't
need the baggage.

Committed by:  mjagdis
Date:  Jun 12 2007 * 11:07 (about 1 year ago)

Affected files:

callweaver/trunk/configure.ac (unified diff)

r2967r2975
184184 dnl check for host compiler when cross compiling
185185 if test "$host" = "$build"; then
186186 HOST_CC="${CC}"
187 case "${host}" in
188 x86_64-*)
189 # X86_64 Linux machines may have both 64 bit and 32 bit libraries. We need to choose the right set
190 AC_CHECK_FILE([/usr/lib64], [TESTLIBS="$TESTLIBS -L/usr/lib64"], AC_CHECK_FILE([/usr/lib], [TESTLIBS="$TESTLIBS -L/usr/lib"]))
191 AC_CHECK_FILE([/usr/local/lib64], [TESTLIBS="$TESTLIBS -L/usr/local/lib64"], AC_CHECK_FILE([/usr/local/lib], [TESTLIBS="$TESTLIBS -L/usr/local/lib"]))
192 AC_CHECK_FILE([/usr/X11R6/lib64], [TESTLIBS="$TESTLIBS -L/usr/X11R6/lib64"], AC_CHECK_FILE([/usr/X11R6/lib], [TESTLIBS="$TESTLIBS -L/usr/X11R6/lib"]))
193 ;;
194 esac
187195 else
188196 HOST_CC="${HOST_CC-gcc}"
189197 fi

callweaver/trunk/corelib/pbx.c (unified diff)

r2973r2975
214214 const char *description; /* Description (help text) for 'show application <name>' */
215215 };
216216
217 /* opbx_func: A function */
218 struct opbx_func {
219 struct opbx_func *next;
220 unsigned int hash;
221 char *(*read)(struct opbx_channel *chan, char *cmd, int argc, char **argv, char *buf, size_t len);
222 void (*write)(struct opbx_channel *chan, char *cmd, int argc, char **argv, const char *value);
223 const char *name;
224 const char *synopsis;
225 const char *syntax;
226 const char *desc;
227 };
228
217229 /* opbx_state_cb: An extension state notify */
218230 struct opbx_state_cb
219231 {
------
275287 static int countcalls = 0;
276288
277289 OPBX_MUTEX_DEFINE_STATIC(funcs_lock); /* Lock for the custom function list */
278 static struct opbx_custom_function *funcs_head = NULL;
290 static struct opbx_func *funcs_head = NULL;
279291
280292 static struct pbx_builtin {
281293 char *name;
------
14951507
14961508 static int handle_show_functions(int fd, int argc, char *argv[])
14971509 {
1498 struct opbx_custom_function *acf;
1510 struct opbx_func *acf;
14991511 int count_acf = 0;
15001512
15011513 opbx_cli(fd, "Installed Custom Functions:\n--------------------------------------------------------------------------------\n");
------
15101522
15111523 static int handle_show_function(int fd, int argc, char *argv[])
15121524 {
1513 struct opbx_custom_function *acf;
1525 struct opbx_func *acf;
15141526 /* Maximum number of characters added by terminal coloring is 22 */
15151527 char infotitle[64 + OPBX_MAX_APP + 22], syntitle[40], destitle[40];
15161528 char info[64 + OPBX_MAX_APP], *synopsis = NULL, *description = NULL;
------
15191531
15201532 if (argc < 3) return RESULT_SHOWUSAGE;
15211533
1522 if (!(acf = opbx_custom_function_find(argv[2])))
1534 if (!(acf = opbx_function_find(argv[2])))
15231535 {
15241536 opbx_cli(fd, "No function by that name registered.\n");
15251537 return RESULT_FAILURE;
------
15661578
15671579 static char *complete_show_function(char *line, char *word, int pos, int state)
15681580 {
1569 struct opbx_custom_function *acf;
1581 struct opbx_func *acf;
15701582 int which = 0;
15711583
15721584 /* try to lock functions list ... */
------
15951607 return NULL;
15961608 }
15971609
1598 struct opbx_custom_function* opbx_custom_function_find(const char *name)
1610 struct opbx_func* opbx_function_find(const char *name)
15991611 {
1600 struct opbx_custom_function *p;
1612 struct opbx_func *p;
16011613 unsigned int hash = opbx_hash_app_name(name);
16021614
16031615 if (opbx_mutex_lock(&funcs_lock)) {
------
16161628
16171629 int opbx_unregister_function(void *func)
16181630 {
1619 struct opbx_custom_function **p;
1631 struct opbx_func **p;
16201632 int ret;
16211633
16221634 if (!func)
------
16401652
16411653 if (!ret) {
16421654 if (option_verbose > 1)
1643 opbx_verbose(VERBOSE_PREFIX_2 "Unregistered custom function %s\n", ((struct opbx_custom_function *)func)->name);
1655 opbx_verbose(VERBOSE_PREFIX_2 "Unregistered custom function %s\n", ((struct opbx_func *)func)->name);
16441656 free(func);
16451657 }
16461658
------
16531665 const char *synopsis, const char *syntax, const char *description)
16541666 {
16551667 char tmps[80];
1656 struct opbx_custom_function *p;
1668 struct opbx_func *p;
16571669 unsigned int hash;
16581670
16591671 if (opbx_mutex_lock(&funcs_lock)) {
------
17061718 char *argv[100]; /* No function can take more than 100 args unless it parses them itself */
17071719 char *args = NULL, *function, *p;
17081720 char *ret = "0";
1709 struct opbx_custom_function *acfptr;
1721 struct opbx_func *acfptr;
17101722
17111723 function = opbx_strdupa(in);
17121724
------
17201732 opbx_log(LOG_WARNING, "Function doesn't contain parentheses. Assuming null argument.\n");
17211733 }
17221734
1723 if ((acfptr = opbx_custom_function_find(function))) {
1735 if ((acfptr = opbx_function_find(function))) {
17241736 if (acfptr->read)
17251737 return (*acfptr->read)(chan, function, opbx_separate_app_args(args, ',', arraysize(argv), argv), argv, workspace, len);
17261738 opbx_log(LOG_ERROR, "Function %s cannot be read\n", function);
------
17351747 {
17361748 char *argv[100]; /* No function can take more than 100 args unless it parses them itself */
17371749 char *args = NULL, *function, *p;
1738 struct opbx_custom_function *acfptr;
1750 struct opbx_func *acfptr;
17391751
17401752 /* FIXME: unnecessary dup? */
17411753 function = opbx_strdupa(in);
------
17501762 opbx_log(LOG_WARNING, "Function doesn't contain parentheses. Assuming null argument.\n");
17511763 }
17521764
1753 if ((acfptr = opbx_custom_function_find(function))) {
1765 if ((acfptr = opbx_function_find(function))) {
17541766 if (acfptr->write) {
17551767 (*acfptr->write)(chan, function, opbx_separate_app_args(args, ',', arraysize(argv), argv), argv, value);
17561768 return;

callweaver/trunk/include/callweaver/ast.h (unified diff)

r2973r2975
179179 #define ast_copy_string opbx_copy_string
180180 #define ast_ctime opbx_ctime
181181 #define ast_ctime_r opbx_ctime_r
182 #define ast_custom_function_find opbx_custom_function_find
182 #define ast_custom_function_find opbx_function_find
183183 #define ast_custom_function_register opbx_register_function
184184 #define ast_custom_function_unregister opbx_unregister_function
185185 #define ast_db_del opbx_db_del

callweaver/trunk/include/callweaver/pbx.h (unified diff)

r2973r2975
9999
100100 typedef int (*opbx_state_cb_type)(char *context, char* id, enum opbx_extension_states state, void *data);
101101
102 /*! Data structure associated with a custom function */
103 struct opbx_custom_function {
104 struct opbx_custom_function *next;
105 unsigned int hash;
106 char *(*read)(struct opbx_channel *chan, char *cmd, int argc, char **argv, char *buf, size_t len);
107 void (*write)(struct opbx_channel *chan, char *cmd, int argc, char **argv, const char *value);
108 const char *name;
109 const char *synopsis;
110 const char *syntax;
111 const char *desc;
112 };
113102
114103 /*! Data structure associated with an callweaver switch */
115104 struct opbx_switch
------
646635 int opbx_explicit_gotolabel(struct opbx_channel *chan, const char *context, const char *exten, const char *priority);
647636 int opbx_async_goto_if_exists(struct opbx_channel *chan, char* context, char *exten, int priority);
648637
649 extern struct opbx_custom_function *opbx_custom_function_find(const char *name);
638 extern struct opbx_func *opbx_function_find(const char *name);
650639 extern int opbx_unregister_function(void *function);
651640 extern void *opbx_register_function(const char *name,
652641 char *(*read)(struct opbx_channel *chan, char *cmd, int argc, char **argv, char *buf, size_t len),

callweaver/trunk/res/res_ogi.c (unified diff)

r2956r2975
11551155 if (argc != 3)
11561156 return RESULT_SHOWUSAGE;
11571157
1158 /* check if we want to execute an opbx_custom_function */
1158 /* check if we want to execute a function */
11591159 if (!opbx_strlen_zero(argv[2]) && (argv[2][strlen(argv[2]) - 1] == ')')) {
11601160 ret = opbx_func_read(chan, argv[2], tempstr, sizeof(tempstr));
11611161 } else {