From c1bc8a5ad71d000bc03d3c1f1345458bda682993 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Thu, 1 Aug 2013 14:37:28 -0400 Subject: [PATCH] FS-5657 --resolve fix mod_rayo build errors in CentOS 5 --- src/mod/event_handlers/mod_rayo/Makefile | 2 + src/mod/event_handlers/mod_rayo/iks_helpers.c | 87 +++++++++++++ src/mod/event_handlers/mod_rayo/iks_helpers.h | 97 ++------------- .../event_handlers/mod_rayo/rayo_elements.c | 117 ++++++++++++++++++ .../event_handlers/mod_rayo/rayo_elements.h | 82 ++---------- 5 files changed, 221 insertions(+), 164 deletions(-) create mode 100644 src/mod/event_handlers/mod_rayo/rayo_elements.c diff --git a/src/mod/event_handlers/mod_rayo/Makefile b/src/mod/event_handlers/mod_rayo/Makefile index d15ae1cbb1..6fccfdf318 100644 --- a/src/mod/event_handlers/mod_rayo/Makefile +++ b/src/mod/event_handlers/mod_rayo/Makefile @@ -10,6 +10,7 @@ LOCAL_OBJS= $(IKS_LA) \ iks_helpers.o \ nlsml.o \ rayo_components.o \ + rayo_elements.o \ rayo_input_component.o \ rayo_output_component.o \ rayo_prompt_component.o \ @@ -21,6 +22,7 @@ LOCAL_SOURCES= \ iks_helpers.c \ nlsml.c \ rayo_components.c \ + rayo_elements.c \ rayo_input_component.c \ rayo_output_component.c \ rayo_prompt_component.c \ diff --git a/src/mod/event_handlers/mod_rayo/iks_helpers.c b/src/mod/event_handlers/mod_rayo/iks_helpers.c index 46fd1c4cea..0b5616a1f3 100644 --- a/src/mod/event_handlers/mod_rayo/iks_helpers.c +++ b/src/mod/event_handlers/mod_rayo/iks_helpers.c @@ -305,6 +305,93 @@ int value_matches(const char *value, const char *rule) return 0; } +/** + * Validate boolean + * @param value + * @return SWTICH_TRUE if boolean + */ +int iks_attrib_is_bool(const char *value) +{ + if (value && *value && (!strcasecmp("true", value) || !strcasecmp("false", value))) { + return SWITCH_TRUE; + } + return SWITCH_FALSE; +} + +/** + * Validate integer + * @param value + * @return SWTICH_TRUE if not negative + */ +int iks_attrib_is_not_negative(const char *value) +{ + if (value && *value && switch_is_number(value)) { + int value_i = atoi(value); + if (value_i >= 0) { + return SWITCH_TRUE; + } + } + return SWITCH_FALSE; +} + +/** + * Validate integer + * @param value + * @return SWTICH_TRUE if positive + */ +int iks_attrib_is_positive(const char *value) +{ + if (value && *value && switch_is_number(value)) { + int value_i = atoi(value); + if (value_i > 0) { + return SWITCH_TRUE; + } + } + return SWITCH_FALSE; +} + +/** + * Validate integer + * @param value + * @return SWTICH_TRUE if positive or -1 + */ +int iks_attrib_is_positive_or_neg_one(const char *value) +{ + if (value && *value && switch_is_number(value)) { + int value_i = atoi(value); + if (value_i == -1 || value_i > 0) { + return SWITCH_TRUE; + } + } + return SWITCH_FALSE; +} + +/** + * Validate string + * @param value + * @return SWTICH_TRUE + */ +int iks_attrib_is_any(const char *value) +{ + return SWITCH_TRUE; +} + +/** + * Validate decimal + * @param value + * @return SWTICH_TRUE if 0.0 <= x <= 1.0 + */ +int iks_attrib_is_decimal_between_zero_and_one(const char *value) +{ + if (value && *value && switch_is_number(value)) { + double value_d = atof(value); + if (value_d >= 0.0 || value_d <= 1.0) { + return SWITCH_TRUE; + } + } + return SWITCH_FALSE; +} + #define IKS_SHA256_HEX_DIGEST_LENGTH ((SHA256_DIGEST_LENGTH * 2) + 1) /** diff --git a/src/mod/event_handlers/mod_rayo/iks_helpers.h b/src/mod/event_handlers/mod_rayo/iks_helpers.h index 442722a267..90a5ca688d 100644 --- a/src/mod/event_handlers/mod_rayo/iks_helpers.h +++ b/src/mod/event_handlers/mod_rayo/iks_helpers.h @@ -73,101 +73,20 @@ extern char *iks_server_dialback_key(const char *secret, const char *receiving_s /** A function to validate attribute value */ typedef int (*iks_attrib_validation_function)(const char *); -#define ELEMENT(name) inline int VALIDATE_##name(iks *node) { int result = 1; if (!node) return 0; +#define ELEMENT_DECL(name) extern int VALIDATE_##name(iks *node); +#define ELEMENT(name) int VALIDATE_##name(iks *node) { int result = 1; if (!node) return 0; #define ATTRIB(name, def, rule) result &= iks_attrib_is_##rule(iks_find_attrib_default(node, #name, #def)); #define STRING_ATTRIB(name, def, rule) result &= value_matches(iks_find_attrib_default(node, #name, #def), rule); #define ELEMENT_END return result; } extern int value_matches(const char *value, const char *rule); -#define ATTRIB_RULE(rule) inline int iks_attrib_is_ ## rule (const char *value) - -/** - * Validate boolean - * @param value - * @return SWTICH_TRUE if boolean - */ -ATTRIB_RULE(bool) -{ - if (value && *value && (!strcasecmp("true", value) || !strcasecmp("false", value))) { - return SWITCH_TRUE; - } - return SWITCH_FALSE; -} - -/** - * Validate integer - * @param value - * @return SWTICH_TRUE if not negative - */ -ATTRIB_RULE(not_negative) -{ - if (value && *value && switch_is_number(value)) { - int value_i = atoi(value); - if (value_i >= 0) { - return SWITCH_TRUE; - } - } - return SWITCH_FALSE; -} - -/** - * Validate integer - * @param value - * @return SWTICH_TRUE if positive - */ -ATTRIB_RULE(positive) -{ - if (value && *value && switch_is_number(value)) { - int value_i = atoi(value); - if (value_i > 0) { - return SWITCH_TRUE; - } - } - return SWITCH_FALSE; -} - -/** - * Validate integer - * @param value - * @return SWTICH_TRUE if positive or -1 - */ -ATTRIB_RULE(positive_or_neg_one) -{ - if (value && *value && switch_is_number(value)) { - int value_i = atoi(value); - if (value_i == -1 || value_i > 0) { - return SWITCH_TRUE; - } - } - return SWITCH_FALSE; -} - -/** - * Validate string - * @param value - * @return SWTICH_TRUE - */ -ATTRIB_RULE(any) -{ - return SWITCH_TRUE; -} - -/** - * Validate decimal - * @param value - * @return SWTICH_TRUE if 0.0 <= x <= 1.0 - */ -ATTRIB_RULE(decimal_between_zero_and_one) -{ - if (value && *value && switch_is_number(value)) { - double value_d = atof(value); - if (value_d >= 0.0 || value_d <= 1.0) { - return SWITCH_TRUE; - } - } - return SWITCH_FALSE; -} +extern int iks_attrib_is_bool(const char *value); +extern int iks_attrib_is_not_negative(const char *value); +extern int iks_attrib_is_positive(const char *value); +extern int iks_attrib_is_positive_or_neg_one(const char *value); +extern int iks_attrib_is_any(const char *value); +extern int iks_attrib_is_decimal_between_zero_and_one(const char *value); #endif diff --git a/src/mod/event_handlers/mod_rayo/rayo_elements.c b/src/mod/event_handlers/mod_rayo/rayo_elements.c new file mode 100644 index 0000000000..07051c1474 --- /dev/null +++ b/src/mod/event_handlers/mod_rayo/rayo_elements.c @@ -0,0 +1,117 @@ +/* + * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013, Grasshopper + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is Grasshopper + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Chris Rienzo + * + * rayo_elements.c -- Rayo XML element definition + * + */ +#include "rayo_elements.h" + +/** + * component validation + */ +ELEMENT(RAYO_INPUT) + STRING_ATTRIB(mode, any, "any,dtmf,voice") + ATTRIB(terminator,, any) + ATTRIB(recognizer,, any) + ATTRIB(language, en-US, any) + ATTRIB(initial-timeout, -1, positive_or_neg_one) + ATTRIB(inter-digit-timeout, -1, positive_or_neg_one) + ATTRIB(sensitivity, 0.5, decimal_between_zero_and_one) + ATTRIB(min-confidence, 0, decimal_between_zero_and_one) + ATTRIB(max-silence, -1, positive_or_neg_one) + /* for now, only NLSML */ + STRING_ATTRIB(match-content-type, application/nlsml+xml, "application/nlsml+xml") + /* internal attribs for prompt support */ + ATTRIB(barge-event, false, bool) + ATTRIB(start-timers, true, bool) +ELEMENT_END + +/** + * component validation + */ +ELEMENT(RAYO_OUTPUT) + ATTRIB(start-offset, 0, not_negative) + ATTRIB(start-paused, false, bool) + ATTRIB(repeat-interval, 0, not_negative) + ATTRIB(repeat-times, 1, not_negative) + ATTRIB(max-time, -1, positive_or_neg_one) + ATTRIB(renderer,, any) + ATTRIB(voice,, any) +ELEMENT_END + +/** + * validation + */ +ELEMENT(RAYO_OUTPUT_SEEK) + STRING_ATTRIB(direction,, "forward,back") + ATTRIB(amount,-1, positive) +ELEMENT_END + +/** + * component validation + */ +ELEMENT(RAYO_PROMPT) + ATTRIB(barge-in, true, bool) +ELEMENT_END + +/** + * component validation + */ +ELEMENT(RAYO_RECORD) + ATTRIB(format, mp3, any) + ATTRIB(start-beep, false, bool) + ATTRIB(stop-beep, false, bool) + ATTRIB(start-paused, false, bool) + ATTRIB(max-duration, -1, positive_or_neg_one) + ATTRIB(initial-timeout, -1, positive_or_neg_one) + ATTRIB(final-timeout, -1, positive_or_neg_one) + STRING_ATTRIB(direction, duplex, "duplex,send,recv") + ATTRIB(mix, false, bool) +ELEMENT_END + +/** + * command validation + */ +ELEMENT(RAYO_JOIN) + /* for now, only allow duplex + STRING_ATTRIB(direction, duplex, "send,recv,duplex"); */ + STRING_ATTRIB(direction, duplex, "duplex") + STRING_ATTRIB(media, bridge, "bridge,direct") + ATTRIB(call-uri,, any) + ATTRIB(mixer-name,, any) +ELEMENT_END + + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet + */ + diff --git a/src/mod/event_handlers/mod_rayo/rayo_elements.h b/src/mod/event_handlers/mod_rayo/rayo_elements.h index be2d68d054..c780f160cf 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_elements.h +++ b/src/mod/event_handlers/mod_rayo/rayo_elements.h @@ -23,7 +23,7 @@ * Contributor(s): * Chris Rienzo * - * rayo_elements.h -- Rayo XML element definition + * rayo_elements.h -- Rayo XML elements * */ #ifndef RAYO_ELEMENTS_H @@ -31,80 +31,12 @@ #include "iks_helpers.h" -/** - * component validation - */ -ELEMENT(RAYO_INPUT) - STRING_ATTRIB(mode, any, "any,dtmf,voice") - ATTRIB(terminator,, any) - ATTRIB(recognizer,, any) - ATTRIB(language, en-US, any) - ATTRIB(initial-timeout, -1, positive_or_neg_one) - ATTRIB(inter-digit-timeout, -1, positive_or_neg_one) - ATTRIB(sensitivity, 0.5, decimal_between_zero_and_one) - ATTRIB(min-confidence, 0, decimal_between_zero_and_one) - ATTRIB(max-silence, -1, positive_or_neg_one) - /* for now, only NLSML */ - STRING_ATTRIB(match-content-type, application/nlsml+xml, "application/nlsml+xml") - /* internal attribs for prompt support */ - ATTRIB(barge-event, false, bool) - ATTRIB(start-timers, true, bool) -ELEMENT_END - -/** - * component validation - */ -ELEMENT(RAYO_OUTPUT) - ATTRIB(start-offset, 0, not_negative) - ATTRIB(start-paused, false, bool) - ATTRIB(repeat-interval, 0, not_negative) - ATTRIB(repeat-times, 1, not_negative) - ATTRIB(max-time, -1, positive_or_neg_one) - ATTRIB(renderer,, any) - ATTRIB(voice,, any) -ELEMENT_END - -/** - * validation - */ -ELEMENT(RAYO_OUTPUT_SEEK) - STRING_ATTRIB(direction,, "forward,back") - ATTRIB(amount,-1, positive) -ELEMENT_END - -/** - * component validation - */ -ELEMENT(RAYO_PROMPT) - ATTRIB(barge-in, true, bool) -ELEMENT_END - -/** - * component validation - */ -ELEMENT(RAYO_RECORD) - ATTRIB(format, mp3, any) - ATTRIB(start-beep, false, bool) - ATTRIB(stop-beep, false, bool) - ATTRIB(start-paused, false, bool) - ATTRIB(max-duration, -1, positive_or_neg_one) - ATTRIB(initial-timeout, -1, positive_or_neg_one) - ATTRIB(final-timeout, -1, positive_or_neg_one) - STRING_ATTRIB(direction, duplex, "duplex,send,recv") - ATTRIB(mix, false, bool) -ELEMENT_END - -/** - * command validation - */ -ELEMENT(RAYO_JOIN) - /* for now, only allow duplex - STRING_ATTRIB(direction, duplex, "send,recv,duplex"); */ - STRING_ATTRIB(direction, duplex, "duplex") - STRING_ATTRIB(media, bridge, "bridge,direct") - ATTRIB(call-uri,, any) - ATTRIB(mixer-name,, any) -ELEMENT_END +ELEMENT_DECL(RAYO_INPUT) +ELEMENT_DECL(RAYO_OUTPUT) +ELEMENT_DECL(RAYO_OUTPUT_SEEK) +ELEMENT_DECL(RAYO_PROMPT) +ELEMENT_DECL(RAYO_RECORD) +ELEMENT_DECL(RAYO_JOIN) #endif