39 #ifndef SWITCH_UTILS_H 40 #define SWITCH_UTILS_H 47 #define SWITCH_URL_UNSAFE "\r\n #%&+:;<=>?@[\\]^`{|}\"" 49 #define MAX_NETWORK_PORTS 10 66 ee = new_buf + new_datalen;
69 for (p = buf; p < e && pp < ee - 4; p++) {
70 if (snprintf(pp, 4,
"%.2x ", (
int)*p) < 0) {
103 uint32_t ebx = (0x7f7f7f7ful & eax) + 0x05050505ul;
104 ebx = (0x7f7f7f7ful & ebx) + 0x1a1a1a1aul;
105 ebx = ((ebx & ~eax) >> 2 ) & 0x20202020ul;
114 uint32_t ebx = (0x7f7f7f7ful & eax) + 0x25252525ul;
115 ebx = (0x7f7f7f7ful & ebx) + 0x1a1a1a1aul;
116 ebx = ((ebx & ~eax) >> 2) & 0x20202020ul;
126 static inline uint64_t switch_toupper64(uint64_t eax)
128 uint64_t ebx = (0x7f7f7f7f7f7f7f7full & eax) + 0x0505050505050505ull;
129 ebx = (0x7f7f7f7f7f7f7f7full & ebx) + 0x1a1a1a1a1a1a1a1aull;
130 ebx = ((ebx & ~eax) >> 2 ) & 0x2020202020202020ull;
137 static inline uint64_t switch_tolower64(uint64_t eax)
139 uint64_t ebx = (0x7f7f7f7f7f7f7f7full & eax) + 0x2525252525252525ull;
140 ebx = (0x7f7f7f7f7f7f7f7full & ebx) + 0x1a1a1a1a1a1a1a1aull;
141 ebx = ((ebx & ~eax) >> 2) & 0x2020202020202020ull;
157 *b = (uint64_t) switch_toupper64(*b);
185 *b = (uint64_t) switch_tolower64(*b);
287 #define switch_goto_status(_status, _label) status = _status; goto _label 288 #define switch_goto_int(_n, _i, _label) _n = _i; goto _label 289 #define switch_samples_per_packet(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval))) 290 #define SWITCH_SMAX 32767 291 #define SWITCH_SMIN -32768 292 #define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX; else if (n < SWITCH_SMIN) n = SWITCH_SMIN; 293 #define switch_codec2str(codec,buf,len) snprintf(buf, len, "%s@%uh@%ui", \ 294 codec->implementation->iananame, \ 295 codec->implementation->samples_per_second, \ 296 codec->implementation->microseconds_per_packet / 1000) 308 if (*s ==
'\0')
return 1;
312 #define zstr(x) (_zstr(x) ? 1 : __analysis_assume(x),0) 314 #define zstr(x) _zstr(x) 316 #define switch_strlen_zero(x) zstr(x) 317 #define switch_strlen_zero_buf(x) zstr_buf(x) 318 #define zstr_buf(s) (*(s) == '\0') 321 if (
zstr(s) || !strcasecmp(s,
"silence") || !strcasecmp(s,
"indicate_hold")) {
328 #define zset(_a, _b) if (!zstr(_b)) _a = _b 342 if (!*p)
return NULL;
345 const char *a = allowed;
348 if (*p == find)
break;
366 if (!acceptable)
return NULL;
374 #define switch_arraylen(_a) (sizeof(_a) / sizeof(_a[0])) 375 #define switch_split(_data, _delim, _array) switch_separate_string(_data, _delim, _array, switch_arraylen(_array)) 376 #define switch_split_cheap(_data, _delim, _array, _larray) switch_separate_string_cheap(_data, _delim, (const char **)_array, _larray, switch_arraylen(_array)) 378 #define switch_is_valid_rate(_tmp) (_tmp == 8000 || _tmp == 12000 || _tmp == 16000 || _tmp == 24000 || _tmp == 32000 || _tmp == 11025 || _tmp == 22050 || _tmp == 44100 || _tmp == 48000) 382 #pragma warning(disable:6011) 390 i = strchr(in,
'\\');
392 while (i && *i ==
'\\') {
394 if (*i ==
'\\' || *i ==
'n' || *i ==
's' || *i ==
't' || *i ==
'\'') {
403 #pragma warning(default:6011) 419 for (i = 7; i >= 0; i--) {
420 buf[j++] = (*byte & (1 << i)) ?
'1' :
'0';
429 if (buf[j-1] ==
' ') j--;
441 if (*s < 48 || *s > 57) {
454 if (i > 9 && i < 14) {
469 if (!(r = atoi(s))) {
470 int l = tolower((
unsigned char)*s);
471 if (l > 96 && l < 101) {
482 case 0:
return 64000;
483 case 3:
return 13200;
486 case 8:
return 64000;
487 case 9:
return 64000;
488 case 18:
return 8000;
521 return ((expr && ( !strcasecmp(expr,
"yes") ||
522 !strcasecmp(expr,
"on") ||
523 !strcasecmp(expr,
"true") ||
524 !strcasecmp(expr,
"t") ||
525 !strcasecmp(expr,
"enabled") ||
526 !strcasecmp(expr,
"active") ||
527 !strcasecmp(expr,
"allow") ||
536 #define switch_true_buf(expr)\ 537 ((( !strcasecmp(expr, "yes") ||\ 538 !strcasecmp(expr, "on") ||\ 539 !strcasecmp(expr, "true") ||\ 540 !strcasecmp(expr, "t") ||\ 541 !strcasecmp(expr, "enabled") ||\ 542 !strcasecmp(expr, "active") ||\ 543 !strcasecmp(expr, "allow") ||\ 544 (switch_is_number(expr) && atoi(expr)))) ? SWITCH_TRUE : SWITCH_FALSE) 553 return ((expr && ( !strcasecmp(expr,
"no") ||
554 !strcasecmp(expr,
"off") ||
555 !strcasecmp(expr,
"false") ||
556 !strcasecmp(expr,
"f") ||
557 !strcasecmp(expr,
"disabled") ||
558 !strcasecmp(expr,
"inactive") ||
559 !strcasecmp(expr,
"disallow") ||
633 #define SWITCH_STATUS_IS_BREAK(x) (x == SWITCH_STATUS_BREAK || x == 730035 || x == 35 || x == SWITCH_STATUS_INTR) 638 #define switch_errno() WSAGetLastError() 642 return errcode == WSAEWOULDBLOCK || errcode == WSAEINPROGRESS || errcode == WSAEINTR;
647 #define switch_errno() errno 651 return errcode == EAGAIN || errcode == EWOULDBLOCK || errcode == EINPROGRESS || errcode == EINTR || errcode == ETIMEDOUT;
683 #define is_dtmf(key) ((key > 47 && key < 58) || (key > 64 && key < 69) || (key > 96 && key < 101) || key == 35 || key == 42 || key == 87 || key == 119 || key == 70 || key == 102) 685 #define end_of(_s) *(*_s == '\0' ? _s : _s + strlen(_s) - 1) 686 #define end_of_p(_s) (*_s == '\0' ? _s : _s + strlen(_s) - 1) 693 #define switch_test_flag(obj, flag) ((obj)->flags & flag) 700 #define switch_set_flag(obj, flag) (obj)->flags |= (flag) 707 #define switch_set_flag_locked(obj, flag) assert((obj)->flag_mutex != NULL); \ 708 switch_mutex_lock((obj)->flag_mutex); \ 709 (obj)->flags |= (flag);\ 710 switch_mutex_unlock((obj)->flag_mutex); 717 #define switch_clear_flag_locked(obj, flag) switch_mutex_lock((obj)->flag_mutex); (obj)->flags &= ~(flag); switch_mutex_unlock((obj)->flag_mutex); 724 #define switch_clear_flag(obj, flag) (obj)->flags &= ~(flag) 732 #define switch_copy_flags(dest, src, flags) (dest)->flags &= ~(flags); (dest)->flags |= ((src)->flags & (flags)) 734 #define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst)) 745 if (!(strchr(p,
'/') || strchr(p,
':') || strchr(p,
'@') || strchr(p,
'%'))) {
749 while ((q = strrchr(p,
'@')))
752 while ((q = strrchr(p,
'%')))
755 for (i = 0; i < (int) strlen(warp); i++) {
756 while (p && (q = strchr(p, warp[i])))
768 for (p = s; p && *p; p++) {
779 }
else if (*p !=
'\\') {
793 for (p = s; p && *p; p++) {
799 }
else if (*p !=
'\\') {
816 for (p = s; p && *p; p++) {
817 uint8_t x = (uint8_t) * p;
818 if ((x < 32) && x !=
'\n' && x !=
'\r') {
830 for (p = s; p && *p; p++) {
831 uint8_t x = (uint8_t) * p;
832 if ((x < 32) || x ==
'\'' || x ==
'"' || x ==
'<' || x ==
'>' || x ==
'\\' || x ==
':' || x ==
'@' || x ==
'/') {
835 if ( (p == s) && (*p ==
' ') ) {
853 return nptr ? atoi(nptr) : dft;
865 return nptr ? atol(nptr) : dft;
877 return nptr ? atoll(nptr) : dft;
885 #define switch_safe_free(it) if (it) {free(it);it=NULL;} 898 #pragma warning(disable:6011) 927 #pragma warning(default:6011) 939 char *p, *S = NULL, *Q = NULL;
954 for (p = S; p && *p; p++) {
966 for (p = Q; p && *p; p++) {
993 #define switch_str_nil(s) (s ? s : "") 998 #define switch_yield(ms) switch_sleep(ms); 1006 #define switch_time_from_sec(sec) ((switch_time_t)(sec) * 1000000) 1013 #define SWITCH_DECLARE_GLOBAL_STRING_FUNC(fname, vname) static void fname(const char *string) { if (!string) return;\ 1014 if (vname) {free(vname); vname = NULL;}vname = strdup(string);} static void fname(const char *string) 1097 #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK || status == SWITCH_STATUS_INUSE) 1112 r = (int32_t)((
double)(w * h * fps * quality) * 0.07) / 1000;
1114 if (!quality) r /= 2;
1116 if (quality < 0.0f) {
1117 r = (int) ((
float)r * quality);
1130 fpsP->
ms = (int)(1000.0f / fps);
1131 fpsP->
fps = 1000.0f / fpsP->
ms;
1132 fpsP->
samples = (int)(samplerate / 1000 * fpsP->
ms);
1135 #define switch_calc_video_fps(fpsP, fps) switch_calc_fps(fpsP, fps, 90000) 1143 if (!strcasecmp(bwv,
"auto")) {
1147 if ((bw = (
float) atof(bwv))) {
1148 if (bw < 0)
return 0;
1150 if (strstr(bwv,
"KB")) {
1152 }
else if (strstr(bwv,
"mb")) {
1154 }
else if (strstr(bwv,
"MB")) {
1159 return (int32_t) roundf(bw);
1169 if (!strcasecmp(cpu,
"auto")) {
1170 return (uint32_t)((cpu_count * 3) / 2);
1173 if (!strncasecmp(cpu,
"cpu/", 4)) {
1174 const char *has_max = cpu;
1176 int max = cpu_count;
1180 has_max = strchr(cpu,
'/');
1182 if (has_max > cpu) {
1183 max = atoi(has_max + 1);
1186 divisor = (float)atof(cpu);
1188 if (divisor <= 0) divisor = 1;
1190 ncpu = (int)(cpu_count / divisor);
1192 if (ncpu <= 0)
return 1;
1194 if (ncpu > max)
return (uint32_t)max;
1196 return (uint32_t)ncpu;
1197 }
else if (!strcasecmp(cpu,
"cpu")) {
1202 if (strrchr(cpu,
'%')) {
1203 ncpu = (int) (cpu_count * ((
float)ncpu / 100));
1207 if (ncpu > cpu_count)
return (uint32_t)cpu_count;
1209 if (ncpu <= 0)
return 1;
1216 const char hex[] =
"0123456789ABCDEF";
1220 for(p = s; p && *p; p++) {
1221 if (*p ==
'%' && e-p > 1) {
1222 if (strchr(hex, *(p+1)) && strchr(hex, *(p+2))) {
1248 const char *headers,
1249 const char *body,
const char *file,
const char *convert_cmd,
const char *convert_ext);
1255 char *space = strdup(file);
1260 *file_portion = NULL;
1261 *params_portion = NULL;
1263 while (*file ==
'{') {
1266 while(*file ==
' ') file++;
1271 *file_portion = strdup((
char *)file);
1273 *params_portion = (
char *)space;
1275 *file_portion = (
char *)space;
1290 while(*file ==
'{') {
1293 while(*file ==
' ') file++;
1298 r = (*file ==
'\\' || *(file + 1) ==
':' || *file ==
'/' || strstr(file,
SWITCH_URL_SEPARATOR));
1317 while(*a ==
' ') a++;
1324 while(*b ==
' ') b++;
1328 return strcmp(a, b);
1334 const char *field = NULL;
1353 field =
"copyright";
1366 #define switch_network_list_add_cidr(_list, _cidr_str, _ok) switch_network_list_add_cidr_token(_list, _cidr_str, _ok, NULL) 1378 #define switch_network_list_validate_ip(_list, _ip) switch_network_list_validate_ip_token(_list, _ip, NULL); 1380 #define switch_test_subnet(_ip, _net, _mask) (_mask ? ((_net & _mask) == (_ip & _mask)) : _net ? _net == _ip : 1) 1406 #ifdef __clang_analyzer__ 1407 #define calloc switch_calloc 1412 #define switch_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr ) 1413 #define switch_zmalloc(ptr, len) (void)( (!!(ptr = calloc(1, (len)))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) 1414 #if (_MSC_VER >= 1500) // VC9+ 1415 #define switch_strdup(ptr, s) (void)( (!!(ptr = _strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) 1417 #define switch_strdup(ptr, s) (void)( (!!(ptr = strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) 1420 #if (_MSC_VER >= 1500) // VC9+ 1421 #define switch_malloc(ptr, len) (void)(assert(((ptr) = malloc((len)))),ptr);__analysis_assume( ptr ) 1422 #define switch_zmalloc(ptr, len) (void)(assert((ptr = calloc(1, (len)))),ptr);__analysis_assume( ptr ) 1423 #define switch_strdup(ptr, s) (void)(assert(((ptr) = _strdup(s))),ptr);__analysis_assume( ptr ) 1425 #define switch_malloc(ptr, len) (void)(switch_assert(((ptr) = malloc((len)))),ptr) 1426 #define switch_zmalloc(ptr, len) (void)(switch_assert((ptr = calloc(1, (len)))),ptr) 1427 #define switch_strdup(ptr, s) (void)(switch_assert(((ptr) = strdup((s)))),ptr) 1431 #define DUMP_EVENT(_e) {char *event_str;switch_event_serialize(_e, &event_str, SWITCH_FALSE);switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DUMP\n%s\n", event_str);free(event_str);} 1434 #define switch_inet_ntop inet_ntop static void switch_tolower_max(char *s)
int switch_isdigit(int c)
unsigned int switch_atoui(const char *nptr)
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
const char * switch_priority_name(switch_priority_t priority)
Return a printable name of a switch_priority_t.
int switch_isspace(int c)
int switch_islower(int c)
switch_status_t switch_frame_buffer_free(switch_frame_buffer_t *fb, switch_frame_t **frameP)
const char *const const double number
char * switch_find_end_paren(const char *s, char open, char close)
static void switch_toupper_max(char *s)
static char * switch_sanitize_number(char *number)
int switch_wait_sock(switch_os_socket_t sock, uint32_t ms, switch_poll_t flags)
static char * switch_get_hex_bytes(switch_byte_t *buf, switch_size_t datalen, char *new_buf, switch_size_t new_datalen)
char * switch_strip_nonnumerics(char *in, char *out, switch_size_t len)
int switch_frame_buffer_size(switch_frame_buffer_t *fb)
switch_status_t switch_frame_buffer_trypush(switch_frame_buffer_t *fb, void *ptr)
switch_status_t switch_network_list_create(switch_network_list_t **list, const char *name, switch_bool_t default_type, switch_memory_pool_t *pool)
#define SWITCH_END_EXTERN_C
char * switch_core_url_encode_opt(switch_memory_pool_t *pool, const char *url, switch_bool_t double_encode)
int switch_iscntrl(int c)
switch_status_t switch_network_list_add_cidr_token(switch_network_list_t *list, const char *cidr_str, switch_bool_t ok, const char *token)
switch_size_t switch_b64_decode(const char *in, char *out, switch_size_t olen)
static int switch_errno_is_break(int errcode)
static void switch_separate_file_params(const char *file, char **file_portion, char **params_portion)
static char * switch_var_clean_string(char *s)
switch_status_t switch_frame_buffer_trypop(switch_frame_buffer_t *fb, void **ptr)
static int switch_string_has_escaped_data(const char *in)
switch_uri_flags
flags to be used with switch_build_uri()
unsigned int switch_separate_string_string(char *buf, char *delim, _Post_count_(return) char **array, unsigned int arraylen)
int get_addr_int(switch_sockaddr_t *sa)
static long int switch_safe_atol(const char *nptr, long int dft)
Turn a string into a long integer (default if NULL)
int switch_build_uri(char *uri, switch_size_t size, const char *scheme, const char *user, const switch_sockaddr_t *sa, int flags)
build a URI string from components
switch_bool_t switch_is_leading_number(const char *str)
int switch_parse_cidr(const char *string, ip_t *ip, ip_t *mask, uint32_t *bitp)
switch_status_t switch_frame_alloc(switch_frame_t **frame, switch_size_t size)
#define SWITCH_URL_SEPARATOR
switch_priority_t
Priority Indication.
switch_bool_t switch_is_uint_in_range(const char *str, unsigned int from, unsigned int to)
Check if a 32 bit unsigned number is in a range.
switch_memory_pool_t * pool
void switch_http_dump_request(switch_http_request_t *request)
Representation of an event.
char * switch_amp_encode(char *s, char *buf, switch_size_t len)
switch_status_t switch_frame_free(switch_frame_t **frame)
char * switch_format_number(const char *num)
switch_status_t switch_network_list_add_host_port_mask(switch_network_list_t *list, const char *host, const char *mask_str, switch_bool_t ok, switch_network_port_range_p port)
int old_switch_toupper(int c)
char * switch_util_quote_shell_arg_pool(const char *string, switch_memory_pool_t *pool)
Quote shell argument, allocating from pool if provided.
switch_bool_t switch_network_list_validate_ip6_port_token(switch_network_list_t *list, ip_t ip, int port, const char **token)
switch_status_t switch_http_parse_header(char *buffer, uint32_t datalen, switch_http_request_t *request)
char * switch_find_parameter(const char *str, const char *param, switch_memory_pool_t *pool)
char * switch_print_host(switch_sockaddr_t *addr, char *buf, switch_size_t len)
switch_bool_t switch_is_number(const char *str)
char * switch_strip_whitespace(const char *str)
switch_bool_t switch_network_list_validate_ip6_token(switch_network_list_t *list, ip_t ip, const char **token)
switch_size_t switch_fd_read_line(int fd, char *buf, switch_size_t len)
uint32_t switch_core_cpu_count(void)
int switch_isgraph(int c)
void switch_split_date(const char *exp, int *year, int *month, int *day)
char * switch_url_encode(const char *url, char *buf, size_t len)
static int32_t switch_calc_bitrate(int w, int h, float quality, double fps)
static void switch_calc_fps(switch_fps_t *fpsP, float fps, int samplerate)
int switch_strcasecmp_any(const char *str,...)
switch_status_t switch_frame_buffer_dup(switch_frame_buffer_t *fb, switch_frame_t *orig, switch_frame_t **clone)
static int32_t switch_parse_bandwidth_string(const char *bwv)
switch_bool_t switch_is_lan_addr(const char *ip)
const char * content_type
switch_status_t switch_frame_buffer_destroy(switch_frame_buffer_t **fbP)
unsigned int switch_separate_string_cheap(_In_ const char *buf, char delim, _Post_count_(return) const char **array, _Post_count_(return) unsigned int larray[], unsigned int arraylen)
Separate a string into an array based on a character delimiter, no memory corruption! DOESN'T support...
#define SWITCH_URL_UNSAFE
static uint32_t switch_known_bitrate(switch_payload_t payload)
static uint32_t switch_parse_cpu_string(const char *cpu)
switch_bool_t _destroy_headers
static int switch_safe_atoi(const char *nptr, int dft)
Turn a string into an integer (default if NULL)
static char * switch_strchr_strict(const char *in, char find, const char *allowed)
switch_status_t switch_resolve_host(const char *host, char *buf, size_t buflen)
switch_bool_t switch_network_list_validate_ip_token(switch_network_list_t *list, uint32_t ip, const char **token)
static char * switch_safe_strdup(const char *it)
switch_bool_t switch_dow_cmp(const char *exp, int val)
const char * switch_memory_usage_stream(switch_stream_handle_t *stream)
char * switch_jwt_sign(const char *secret, const uint8_t *payload, switch_size_t size)
void switch_getcputime(switch_cputime *t)
switch_status_t switch_network_list_add_host_mask(switch_network_list_t *list, const char *host, const char *mask_str, switch_bool_t ok)
switch_byte_t switch_byte_t * buf
unsigned int switch_separate_string(_In_ char *buf, char delim, _Post_count_(return) char **array, unsigned int arraylen)
Separate a string into an array based on a character delimiter.
static switch_bool_t switch_strstr(char *s, char *q)
Test if one string is inside another with extra case checking.
static switch_bool_t switch_string_var_check(char *s, switch_bool_t disable)
switch_bool_t switch_testv6_subnet(ip_t _ip, ip_t _net, ip_t _mask)
int ports[MAX_NETWORK_PORTS]
static switch_bool_t switch_is_moh(const char *s)
unsigned short get_port(struct sockaddr *sa)
get the port number of an ip address
int switch_cmp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *sa2, switch_bool_t ip_only)
int switch_split_user_domain(char *in, char **user, char **domain)
Split a user string as user and domain.
switch_status_t switch_b64_encode(unsigned char *in, switch_size_t ilen, unsigned char *out, switch_size_t olen)
int old_switch_tolower(int c)
int switch_isxdigit(int c)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
static uint32_t switch_toupper(uint32_t eax)
int switch_isprint(int c)
unsigned long switch_atoul(const char *nptr)
char * switch_network_ipv4_mapped_ipv6_addr(const char *ip_str)
char * switch_escape_string(const char *in, char *out, switch_size_t outlen)
char * switch_strip_commas(char *in, char *out, switch_size_t len)
char * switch_strerror_r(int errnum, char *buf, switch_size_t buflen)
An abstraction of a data frame.
switch_size_t switch_fp_read_dline(FILE *fd, char **buf, switch_size_t *len)
int switch_socket_waitfor(switch_pollfd_t *poll, int ms)
Wait for a socket.
static switch_bool_t switch_string_var_check_const(const char *s)
switch_byte_t switch_byte_t uint32_t buflen
struct switch_http_request_s switch_http_request_t
char * switch_url_decode(char *s)
char switch_rfc2833_to_char(int event)
Return the RFC2833 character based on an event id.
int switch_inet_pton(int af, const char *src, void *dst)
void switch_split_time(const char *exp, int *hour, int *min, int *sec)
char * switch_replace_char(char *str, char from, char to, switch_bool_t dup)
int switch_isalpha(int c)
char * switch_must_strdup(const char *_s)
void switch_http_free_request(switch_http_request_t *request)
#define MAX_NETWORK_PORTS
char * switch_util_quote_shell_arg(const char *string)
Quote shell argument.
static char * switch_clean_string(char *s)
char * switch_core_session_url_encode_opt(switch_core_session_t *session, const char *url, switch_bool_t double_encode)
int switch_ispunct(int c)
unsigned char switch_char_to_rfc2833(char key)
Return the RFC2833 event based on an key character.
struct fspr_sockaddr_t switch_sockaddr_t
char * switch_url_encode_opt(const char *url, char *buf, size_t len, switch_bool_t double_encode)
char * switch_pool_strip_whitespace(switch_memory_pool_t *pool, const char *str)
static char switch_itodtmf(char i)
char * switch_core_url_encode(switch_memory_pool_t *pool, const char *url)
static _Check_return_ int _zstr(_In_opt_z_ const char *s)
Test for NULL or zero length string.
char * switch_separate_paren_args(char *str)
const char * switch_dow_int2str(int val)
switch_status_t switch_frame_buffer_push(switch_frame_buffer_t *fb, void *ptr)
switch_status_t switch_network_list_add_cidr_port_token(switch_network_list_t *list, const char *cidr_str, switch_bool_t ok, const char *token, switch_network_port_range_p port)
static char * switch_lc_strdup(const char *it)
switch_size_t content_length
static int switch_filecmp(const char *a, const char *b)
static char * switch_uc_strdup(const char *it)
switch_status_t
Common return values.
char * switch_string_replace(const char *string, const char *search, const char *replace)
char * switch_uuid_str(char *buf, switch_size_t len)
int switch_tod_cmp(const char *exp, int val)
static int switch_needs_url_encode(const char *s)
switch_status_t switch_frame_buffer_create(switch_frame_buffer_t **fbP, switch_size_t qlen)
char * get_addr(char *buf, switch_size_t len, struct sockaddr *sa, socklen_t salen)
find the char representation of an ip adress
switch_status_t switch_string_match(const char *string, size_t string_len, const char *search, size_t search_len)
static switch_bool_t switch_is_file_path(const char *file)
int switch_dow_str2int(const char *exp)
switch_bool_t switch_simple_email(const char *to, const char *from, const char *headers, const char *body, const char *file, const char *convert_cmd, const char *convert_ext)
switch_bool_t switch_network_list_validate_ip_port_token(switch_network_list_t *list, uint32_t ip, int port, const char **token)
unsigned long switch_getpid(void)
switch_status_t switch_frame_buffer_pop(switch_frame_buffer_t *fb, void **ptr)
switch_status_t switch_frame_dup(switch_frame_t *orig, switch_frame_t **clone)
char * switch_escape_char(switch_memory_pool_t *pool, char *in, const char *delim, char esc)
Escape a string by prefixing a list of characters with an escape character.
char * switch_html_strip(const char *str)
int switch_number_cmp(const char *exp, int val)
switch_status_t switch_digest_string(const char *digest_name, char **digest_str, const void *input, switch_size_t inputLen, unsigned int *outputlen)
void * switch_calloc(size_t nmemb, size_t size)
switch_status_t switch_digest(const char *digest_name, unsigned char **digest, const void *input, switch_size_t inputLen, unsigned int *outputlen)
void switch_http_parse_qs(switch_http_request_t *request, char *qs)
char * get_addr6(char *buf, switch_size_t len, struct sockaddr_in6 *sa, socklen_t salen)
static int switch_dtmftoi(char *s)
int switch_isalnum(int c)
const char * switch_stristr(const char *instr, const char *str)
static switch_bool_t switch_is_digit_string(const char *s)
switch_status_t switch_find_local_ip(_Out_opt_bytecapcount_(len) char *buf, _In_ int len, _In_opt_ int *mask, _In_ int family)
find local ip of the box
static int switch_false(const char *expr)
Evaluate the falsefullness of a string expression.
struct fspr_pool_t switch_memory_pool_t
switch_status_t switch_find_interface_ip(_Out_opt_bytecapcount_(len) char *buf, _In_ int len, _In_opt_ int *mask, _In_ const char *ifname, _In_ int family)
find primary ip of the specified interface
static long long int switch_safe_atoll(const char *nptr, long long int dft)
Turn a string into a long long integer (default if NULL)
switch_size_t switch_fd_read_dline(int fd, char **buf, switch_size_t *len)
cJSON * switch_jwt_verify(const char *secret, const char *token)
static uint32_t switch_round_to_step(uint32_t num, uint32_t step)
const char * switch_cut_path(const char *in)
Create a pointer to the file name in a given file path eliminating the directory name.
static uint32_t switch_tolower(uint32_t eax)
switch_bool_t switch_ast2regex(const char *pat, char *rbuf, size_t len)
char * switch_strip_spaces(char *str, switch_bool_t dup)
switch_network_port_range_t * switch_network_port_range_p
static const char * switch_parse_audio_col(switch_audio_col_t col)
switch_time_t switch_str_time(const char *in)
Converts a string representation of a date into a switch_time_t.
static char * switch_clean_name_string(char *s)
char * switch_core_session_url_encode(switch_core_session_t *session, const char *url)
int switch_fulldate_cmp(const char *exp, switch_time_t *ts)
switch_size_t bytes_header
static switch_byte_t switch_true_byte(const char *expr)
int switch_isupper(int c)
switch_size_t bytes_buffered
int switch_cp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *sa2)
char * switch_escape_string_pool(const char *in, switch_memory_pool_t *pool)
static char * switch_print_bits(const unsigned char *byte, char *buf, switch_size_t buflen)
int switch_wait_socklist(switch_waitlist_t *waitlist, uint32_t len, uint32_t ms)
#define SWITCH_BEGIN_EXTERN_C