ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const char *header_name, const char *val)
{
esl_event_header_t *hp, *lp = NULL, *tp;
- esl_status_t status = ESL_FALSE;
+ esl_status_t status = (esl_status_t) ESL_FALSE;
int x = 0;
esl_ssize_t hlen = -1;
unsigned long hash = 0;
if (!(cj = cJSON_Parse(json))) {
- return ESL_FALSE;
+ return (esl_status_t) ESL_FALSE;
}
if (esl_event_create(&new_event, ESL_EVENT_CLONE) != ESL_SUCCESS) {
cJSON_Delete(cj);
- return ESL_FALSE;
+ return (esl_status_t) ESL_FALSE;
}
for (cjp = cj->child; cjp; cjp = cjp->next) {
SWITCH_DECLARE(char *) switch_uuid_str(char *buf, switch_size_t len);
SWITCH_DECLARE(char *) switch_format_number(const char *num);
+SWITCH_DECLARE(unsigned int) switch_atoui(const char *nptr);
+SWITCH_DECLARE(unsigned long) switch_atoul(const char *nptr);
+
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
uint32_t max_members_val;
errno = 0; /* sanity first */
max_members_val = strtol(max_members_str, NULL, 0); /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */
- if (errno == ERANGE || errno == EINVAL || max_members_val < 0 || max_members_val == 1) {
+ if (errno == ERANGE || errno == EINVAL || (int32_t) max_members_val < 0 || max_members_val == 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"conference_max_members variable %s is invalid, not setting a limit\n", max_members_str);
} else {
} else if (!strcasecmp(var, "max-members") && !zstr(val)) {
errno = 0; /* sanity first */
max_members = strtol(val, NULL, 0); /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */
- if (errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) {
+ if (errno == ERANGE || errno == EINVAL || (int32_t) max_members < 0 || max_members == 1) {
/* a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound
* stuff is added, see comments above
*/
switch_api_interface_t *commands_api_interface;
switch_limit_interface_t *limit_interface;
- memset(&globals, 0, sizeof(&globals));
+ memset(&globals, 0, sizeof(globals));
strncpy(globals.hostname, switch_core_get_switchname(), sizeof(globals.hostname));
globals.pool = pool;
uint32_t digit_timeout = 1500;
uint32_t input_timeout = 0;
const char *var;
- uint32_t tmp;
if ((var = switch_channel_get_variable(channel, "bind_digit_digit_timeout"))) {
- tmp = (uint32_t) atol(var);
- if (tmp < 0) tmp = 0;
- digit_timeout = tmp;
+ digit_timeout = switch_atoul(var);
}
if ((var = switch_channel_get_variable(channel, "bind_digit_input_timeout"))) {
- tmp = (uint32_t) atol(var);
- if (tmp < 0) tmp = 0;
- input_timeout = tmp;
+ input_timeout = switch_atoul(var);
}
switch_ivr_dmachine_create(&dmachine, "DPTOOLS", NULL, digit_timeout, input_timeout, NULL, digit_nomatch_action_callback, session);
}
if (argc > 6) {
- digit_timeout = atoi(argv[6]);
- if (digit_timeout < 0) {
- digit_timeout = 0;
- }
+ digit_timeout = switch_atoui(argv[6]);
}
if (min_digits <= 1) {
}
if (argc > 9) {
- digit_timeout = atoi(argv[9]);
- if (digit_timeout < 0) {
- digit_timeout = 0;
- }
+ digit_timeout = switch_atoui(argv[9]);
}
if (argc > 10) {
l++;
}
if (l) {
- limit = atoi(l);
- if (limit < 0) {
- limit = 0;
- }
+ limit = switch_atoui(l);
}
}
if (argv[2]) {
- fh.thresh = atoi(argv[2]);
- if (fh.thresh < 0) {
- fh.thresh = 0;
- }
+ fh.thresh = switch_atoui(argv[2]);
}
if (argv[3]) {
- fh.silence_hits = atoi(argv[3]);
- if (fh.silence_hits < 0) {
- fh.silence_hits = 0;
- }
+ fh.silence_hits = switch_atoui(argv[3]);
}
if ((tmp = switch_channel_get_variable(channel, "record_rate"))) {
listen_hits = atoi(argv[2]);
if (argv[3]) {
- if ((timeout_ms = atoi(argv[3])) < 0) {
- timeout_ms = 0;
- }
+ timeout_ms = switch_atoui(argv[3]);
}
if (thresh > 0 && silence_hits > 0 && listen_hits > 0) {
switch_limit_interface_t *limit_interface;
switch_status_t status;
- memset(&globals, 0, sizeof(&globals));
+ memset(&globals, 0, sizeof(globals));
globals.pool = pool;
status = switch_event_reserve_subclass(LIMIT_EVENT_USAGE);
if (!strcmp(var, "logfile")) {
new_profile->logfile = strdup(val);
} else if (!strcmp(var, "rollover")) {
- new_profile->roll_size = atoi(val);
- if (new_profile->roll_size < 0) {
- new_profile->roll_size = 0;
- }
+ new_profile->roll_size = switch_atoui(val);
} else if (!strcmp(var, "maximum-rotate")) {
- new_profile->max_rot = atoi(val);
- if (new_profile->max_rot < 0) {
+ new_profile->max_rot = switch_atoui(val);
+ if (new_profile->max_rot == 0) {
new_profile->max_rot = MAX_ROT;
}
} else if (!strcmp(var, "uuid") && switch_true(val)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set a negative timeout!\n");
}
} else if (!strcasecmp(var, "delay") && !zstr(val)) {
- globals.delay = (uint32_t) atoi(val);
+ globals.delay = switch_atoui(val);
} else if (!strcasecmp(var, "log-b-leg")) {
globals.log_b = switch_true(val);
} else if (!strcasecmp(var, "prefix-a-leg")) {
globals.encode = switch_true(val) ? ENCODING_DEFAULT : ENCODING_NONE;
}
} else if (!strcasecmp(var, "retries") && !zstr(val)) {
- globals.retries = (uint32_t) atoi(val);
+ globals.retries = switch_atoui(val);
} else if (!strcasecmp(var, "rotate") && !zstr(val)) {
globals.rotate = switch_true(val);
} else if (!strcasecmp(var, "log-dir")) {
}
}
- if (globals.retries < 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Retries is negative, setting to 0\n");
- globals.retries = 0;
- }
- if (globals.retries && globals.delay <= 0) {
+ if (globals.retries && globals.delay == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Retries set but delay 0 setting to 5 seconds\n");
globals.delay = 5;
}
#ifndef WIN32
static void handle_SIGUSR2(int sig)
{
- if (sig);
+ if (sig) {};
system_ready = 1;
int status = 0;
int pid = 0;
- if (sig);
+ if (sig) {};
pid = wait(&status);
SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t ** sa, switch_bool_t remote, switch_socket_t *sock)
{
- return apr_socket_addr_get(sa, remote, sock);
+ return apr_socket_addr_get(sa, (apr_interface_e) remote, sock);
}
SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t ** new_sock, int family, int type, int protocol, switch_memory_pool_t *pool)
new_sa = apr_pcalloc(pool, sizeof(apr_sockaddr_t));
switch_assert(new_sa);
new_sa->pool = pool;
- memset(new_sa, 0, sizeof(new_sa));
+ memset(new_sa, 0, sizeof(*new_sa));
new_sa->family = family;
new_sa->sa.sin.sin_family = family;
memset(*pollfd, 0, sizeof(switch_pollfd_t));
- (*pollfd)->desc_type = APR_POLL_SOCKET;
+ (*pollfd)->desc_type = (switch_pollset_type_t) APR_POLL_SOCKET;
(*pollfd)->reqevents = flags;
(*pollfd)->desc.s = sock;
(*pollfd)->client_data = client_data;
SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2callstate(const char *str)
{
uint8_t x;
- switch_channel_callstate_t callstate = SWITCH_CAUSE_NONE;
+ switch_channel_callstate_t callstate = (switch_channel_callstate_t) SWITCH_CAUSE_NONE;
if (*str > 47 && *str < 58) {
callstate = atoi(str);
}
}
}
- return callstate;
+ return (switch_call_cause_t) callstate;
}
switch_mutex_unlock(channel->state_mutex);
- return SWITCH_STATUS_SUCCESS;
+ return (switch_channel_state_t) SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
if (!zstr(var) && !zstr(val)) {
uint32_t *p;
- uint32_t v = (unsigned long) atol(val);
+ uint32_t v = switch_atoul(val);
if (!strcasecmp(var, "G723") || !strcasecmp(var, "iLBC")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error adding %s, defaults cannot be changed\n", var);
continue;
}
- if (v < 0) {
+ if (v == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error adding %s, invalid ptime\n", var);
continue;
}
switch_core_file_seek(fhp, &pos, target, SEEK_SET);
} else {
- samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
- if (samps < 0) {
- samps = 0;
- }
+ samps = switch_atoui(p) * (codec->implementation->samples_per_second / 1000);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", samps);
switch_core_file_seek(fhp, &pos, samps, SEEK_SET);
}
return SQLSetConnectAttr(handle->con, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER *) SQL_AUTOCOMMIT_OFF, 0 );
}
#else
- return SWITCH_FALSE;
+ return (switch_odbc_status_t) SWITCH_FALSE;
#endif
}
return SQLEndTran(SQL_HANDLE_DBC, handle->con, SQL_ROLLBACK);
}
#else
- return SWITCH_FALSE;
+ return (switch_odbc_status_t) SWITCH_FALSE;
#endif
}
if (!xt || !tm) {
return;
}
- memset(xt, 0, sizeof(xt));
+ memset(xt, 0, sizeof(*xt));
xt->tm_sec = tm->tm_sec;
xt->tm_min = tm->tm_min;
}
+SWITCH_DECLARE(unsigned int) switch_atoui(const char *nptr)
+{
+ int tmp = atoi(nptr);
+ if (tmp < 0) return 0;
+ else return (unsigned int) tmp;
+}
+
+SWITCH_DECLARE(unsigned long) switch_atoul(const char *nptr)
+{
+ long tmp = atol(nptr);
+ if (tmp < 0) return 0;
+ else return (unsigned long) tmp;
+}
+
/* For Emacs:
* Local Variables:
* mode:c