36 #include <switch_private.h> 43 #include <fspr_atomic.h> 44 #include <fspr_pools.h> 45 #include <fspr_hash.h> 46 #include <fspr_network_io.h> 47 #include <fspr_errno.h> 48 #include <fspr_thread_proc.h> 49 #include <fspr_portable.h> 50 #include <fspr_thread_mutex.h> 51 #include <fspr_thread_cond.h> 52 #include <fspr_thread_rwlock.h> 53 #include <fspr_file_io.h> 54 #include <fspr_poll.h> 55 #include <fspr_strings.h> 56 #define APR_WANT_STDIO 57 #define APR_WANT_STRFUNC 58 #include <fspr_want.h> 59 #include <fspr_file_info.h> 60 #include <fspr_fnmatch.h> 61 #include <fspr_tables.h> 64 #include "fspr_arch_networkio.h" 67 #define SOL_TCP IPPROTO_TCP 74 #if (defined(HAVE_LIBMD5) || defined(HAVE_LIBMD) || defined(HAVE_MD5INIT)) 76 #elif defined(HAVE_LIBCRYPTO) 77 #ifndef OPENSSL_VERSION_NUMBER 78 #include <openssl/opensslv.h> 80 #if OPENSSL_VERSION_NUMBER < 0x30000000 81 #include <openssl/md5.h> 83 #include <openssl/evp.h> 90 #include <uuid/uuid.h> 97 return APR_STATUS_IS_TIMEUP(status);
105 return fspr_os_thread_current();
114 return (tid1 == tid2);
116 return fspr_os_thread_equal(tid1, tid2);
123 unsigned int hash = 0;
124 const unsigned char *
key = (
const unsigned char *) char_key;
125 const unsigned char *p;
128 if (*klen == APR_HASH_KEY_STRING) {
129 for (p = key; *p; p++) {
130 hash = hash * 33 + tolower(*p);
134 for (p = key, i = *klen; i; i--, p++) {
135 hash = hash * 33 + tolower(*p);
145 return fspr_hashfunc_default(key, klen);
199 return fspr_strftime(s, retsize, max, format, (fspr_time_exp_t *) tm);
204 return fspr_strftime(s, retsize, max, format, (fspr_time_exp_t *) tm);
211 va_start(ap, format);
212 ret = fspr_vsnprintf(buf, len, format, ap);
219 return fspr_vsnprintf(buf, len, format, ap);
230 return fspr_cpystrn(dst, src, dst_size);
237 return fspr_thread_rwlock_create(rwlock, pool);
242 return fspr_thread_rwlock_destroy(rwlock);
247 return fspr_thread_rwlock_pool_get(rwlock);
252 return fspr_thread_rwlock_rdlock(rwlock);
257 return fspr_thread_rwlock_tryrdlock(rwlock);
262 return fspr_thread_rwlock_wrlock(rwlock);
267 return fspr_thread_rwlock_trywrlock(rwlock);
272 int sanity = timeout * 2;
288 return fspr_thread_rwlock_unlock(rwlock);
300 return fspr_thread_mutex_create(lock, flags, pool);
305 return fspr_thread_mutex_destroy(lock);
310 return fspr_thread_mutex_lock(lock);
315 return fspr_thread_mutex_unlock(lock);
320 return fspr_thread_mutex_trylock(lock);
327 #if defined(HAVE_CLOCK_GETTIME) && defined(SWITCH_USE_CLOCK_FUNCS) 329 clock_gettime(CLOCK_REALTIME, &ts);
330 return ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec / 1000);
338 return fspr_time_exp_gmt_get((fspr_time_t *) result, (fspr_time_exp_t *) input);
343 return fspr_time_exp_get((fspr_time_t *) result, (fspr_time_exp_t *) input);
348 return fspr_time_exp_lt((fspr_time_exp_t *) result, input);
353 return fspr_time_exp_tz((fspr_time_exp_t *) result, input, (fspr_int32_t) offs);
358 return fspr_time_exp_gmt((fspr_time_exp_t *) result, input);
363 return fspr_rfc822_date(date_str, t);
375 return fspr_thread_cond_create(cond, pool);
380 return fspr_thread_cond_wait(cond, mutex);
385 fspr_status_t st = fspr_thread_cond_timedwait(cond, mutex, timeout);
387 if (st == APR_TIMEUP) {
396 return fspr_thread_cond_signal(cond);
401 return fspr_thread_cond_broadcast(cond);
406 return fspr_thread_cond_destroy(cond);
414 return fspr_file_open(newf, fname, flag, perm, pool);
420 fspr_off_t off = (fspr_off_t) (*offset);
421 rv = fspr_file_seek(thefile, where, &off);
422 *offset = (int64_t) off;
428 return fspr_file_copy(from_path, to_path, perms, pool);
434 return fspr_file_close(thefile);
439 return fspr_file_trunc(thefile, offset);
444 return fspr_file_lock(thefile, type);
449 return fspr_file_rename(from_path, to_path, pool);
454 return fspr_file_remove(path, pool);
459 return fspr_file_read(thefile, buf, nbytes);
464 return fspr_file_write(thefile, buf, nbytes);
473 va_start(ap, format);
488 return fspr_file_mktemp(thefile, templ, flags, pool);
493 struct fspr_finfo_t finfo;
499 fspr_dir_t *dir_handle;
508 if ((status = fspr_dir_open(&dir_handle, dirname, pool)) == APR_SUCCESS) {
509 fspr_dir_close(dir_handle);
521 int32_t wanted = APR_FINFO_TYPE;
524 fspr_finfo_t info = { 0 };
526 if (
zstr(filename)) {
534 fspr_stat(&info, filename, wanted, pool ? pool : our_pool);
535 if (info.filetype != APR_NOFILE) {
548 return fspr_dir_make(path, perm, pool);
553 return fspr_dir_make_recursive(path, perm, pool);
571 memset(dir, 0,
sizeof(*dir));
572 if ((status = fspr_dir_open(&(dir->
dir_handle), dirname, pool)) == APR_SUCCESS) {
593 fspr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME;
600 if (thedir->
finfo.filetype != APR_REG && thedir->
finfo.filetype != APR_LNK) {
604 if (!(name = thedir->
finfo.fname)) {
605 name = thedir->
finfo.name;
620 const char *fname = NULL;
621 fspr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME;
626 if (thedir->
finfo.filetype != APR_REG && thedir->
finfo.filetype != APR_LNK) {
630 if (!(name = thedir->
finfo.fname)) {
631 name = thedir->
finfo.name;
659 fspr_size_t stacksize;
680 return fspr_threadattr_detach_set(attr, on);
685 return fspr_threadattr_stacksize_set(attr, stacksize);
702 return fspr_thread_create(new_thread, attr, func, data, cont);
714 return fspr_os_sock_get(thesock, sock);
719 return fspr_os_sock_put(sock, thesock, pool);
724 return fspr_socket_addr_get(sa, (fspr_interface_e) remote, sock);
729 return fspr_socket_create(new_sock, family, type, protocol, pool);
734 return fspr_socket_shutdown(sock, (fspr_shutdown_how_e) how);
739 return fspr_socket_close(sock);
744 return fspr_socket_bind(sock, sa);
749 return fspr_socket_listen(sock, backlog);
754 return fspr_socket_accept(new_sock, sock, pool);
759 return fspr_socket_connect(sock, sa);
770 status = fspr_socket_send(sock, buf + wrote, &need);
772 if (++to_count > 60000) {
789 if (!sock || !buf || !len) {
793 return fspr_socket_send(sock, buf, len);
799 if (!where || !buf || !len || !*len) {
802 return fspr_socket_sendto(sock, where, flags, buf, len);
809 r = fspr_socket_recv(sock, buf, len);
811 if (r == 35 || r == 730035) {
821 unsigned short family = APR_INET;
823 new_sa = fspr_pcalloc(pool,
sizeof(fspr_sockaddr_t));
827 new_sa->family = family;
828 new_sa->sa.sin.sin_family = family;
830 new_sa->salen =
sizeof(
struct sockaddr_in);
831 new_sa->addr_str_len = 16;
832 new_sa->ipaddr_ptr = &(new_sa->sa.sin.sin_addr);
833 new_sa->ipaddr_len =
sizeof(
struct in_addr);
842 return fspr_sockaddr_info_get(sa, hostname, family, port, flags, pool);
848 fspr_sockaddr_t *new_sa;
851 if (!sa || !pool || !ip) {
855 new_sa = fspr_pcalloc(pool,
sizeof(fspr_sockaddr_t));
861 if (strchr(ip,
':')) {
862 struct sockaddr_in6 sa6 = { 0 };
865 inet_pton(family, ip, &(sa6.sin6_addr));
866 memcpy(&new_sa->sa, &sa6,
sizeof(
struct sockaddr_in6));
870 struct sockaddr_in sa4 = { 0 };
873 inet_pton(family, ip, &(sa4.sin_addr));
874 memcpy(&new_sa->sa, &sa4,
sizeof(
struct sockaddr_in));
877 new_sa->hostname = fspr_pstrdup(pool, ip);
878 new_sa->family = family;
879 new_sa->sa.sin.sin_family = family;
882 new_sa->sa.sin.sin_port = htons(port);
886 if (family == APR_INET) {
887 new_sa->salen =
sizeof(
struct sockaddr_in);
888 new_sa->addr_str_len = 16;
889 new_sa->ipaddr_ptr = &(new_sa->sa.sin.sin_addr);
890 new_sa->ipaddr_len =
sizeof(
struct in_addr);
893 else if (family == APR_INET6) {
894 new_sa->salen =
sizeof(
struct sockaddr_in6);
895 new_sa->addr_str_len = 46;
896 new_sa->ipaddr_ptr = &(new_sa->sa.sin6.sin6_addr);
897 new_sa->ipaddr_len =
sizeof(
struct in6_addr);
910 #if defined(TCP_KEEPIDLE) 912 r = setsockopt(sock->socketdes, SOL_TCP, TCP_KEEPIDLE, (
void *)&on,
sizeof(on));
920 #if defined(TCP_KEEPINTVL) 922 r = setsockopt(sock->socketdes, SOL_TCP, TCP_KEEPINTVL, (
void *)&on,
sizeof(on));
929 return fspr_socket_opt_set(sock, opt, on);
934 fspr_interval_time_t at = 0;
943 return fspr_socket_timeout_set(sock, t);
948 return fspr_sockaddr_ip_get(addr, sa);
953 return fspr_sockaddr_equal(sa1, sa2);
958 return fspr_mcast_join(sock, join, iface, source);
963 return fspr_mcast_hops(sock, ttl);
968 return fspr_mcast_loopback(sock, opt);
973 return fspr_mcast_interface(sock, iface);
987 if (in->family == AF_INET) {
988 get_addr(buf, len, (
struct sockaddr *) &in->sa, in->salen);
992 get_addr6(buf, len, (
struct sockaddr_in6 *) &in->sa, in->salen);
998 return fspr_socket_fd_get(sock);
1013 return fspr_getnameinfo(hostname, sa, flags);
1018 return fspr_socket_atmark(sock, atmark);
1025 if (from && sock && (r = fspr_socket_recvfrom(from, sock, flags, buf, len)) == APR_SUCCESS) {
1026 from->port = ntohs(from->sa.sin.sin_port);
1032 if (r == 35 || r == 730035) {
1043 return fspr_pollset_create(pollset, size, pool, flags);
1048 if (!pollset || !descriptor) {
1052 return fspr_pollset_add((fspr_pollset_t *) pollset, (
const fspr_pollfd_t *) descriptor);
1057 if (!pollset || !descriptor) {
1061 return fspr_pollset_remove((fspr_pollset_t *) pollset, (
const fspr_pollfd_t *) descriptor);
1066 if (!pollfd || !sock) {
1077 (*pollfd)->reqevents = flags;
1078 (*pollfd)->desc.s = sock;
1079 (*pollfd)->client_data = client_data;
1090 st = fspr_pollset_poll((fspr_pollset_t *) pollset, timeout, num, (
const fspr_pollfd_t **) descriptors);
1092 if (st == APR_TIMEUP) {
1105 st = fspr_poll((fspr_pollfd_t *) aprset, numsock, nsds, timeout);
1107 if (numsock == 1 && ((aprset[0].rtnevents & APR_POLLERR) || (aprset[0].rtnevents & APR_POLLHUP) || (aprset[0].rtnevents & APR_POLLNVAL))) {
1109 }
else if (st == APR_TIMEUP) {
1143 uuid_unparse_lower(uuid->
data, buffer);
1146 UuidToString((
const UUID *) uuid, &buf);
1147 strcpy(buffer, (
const char *) buf);
1148 RpcStringFree(&buf);
1156 uuid_generate(uuid->
data);
1158 UuidCreate((UUID *) uuid);
1166 if (uuid_parse(uuid_str, uuid->
data)) {
1171 return UuidFromString((RPC_CSTR) uuid_str, (UUID *) uuid);
1177 #if (defined(HAVE_LIBMD5) || defined(HAVE_LIBMD) || defined(HAVE_MD5INIT)) 1178 MD5_CTX md5_context;
1180 MD5Init(&md5_context);
1181 MD5Update(&md5_context, input, inputLen);
1182 MD5Final(digest, &md5_context);
1185 #elif defined(HAVE_LIBCRYPTO) 1186 #if OPENSSL_VERSION_NUMBER < 0x30000000 1187 MD5_CTX md5_context;
1189 MD5_Init(&md5_context);
1190 MD5_Update(&md5_context, input, inputLen);
1191 MD5_Final(digest, &md5_context);
1193 EVP_MD_CTX *md5_context;
1196 md5_context = EVP_MD_CTX_new();
1197 EVP_DigestInit_ex(md5_context, EVP_md5(), NULL);
1199 EVP_DigestUpdate(md5_context, input, inputLen);
1201 EVP_DigestFinal_ex(md5_context, digest, NULL);
1202 EVP_MD_CTX_free(md5_context);
1218 digest_str[SWITCH_MD5_DIGEST_STRING_SIZE - 1] =
'\0';
1221 b = (digest[x] >> 4) & 15;
1222 digest_str[i++] = b + (b > 9 ?
'a' - 10 :
'0');
1224 digest_str[i++] = b + (b > 9 ?
'a' - 10 :
'0');
1226 digest_str[i] =
'\0';
1259 }
while (s == APR_EINTR);
1285 }
while (s == APR_EINTR);
1292 #ifdef HAVE_VASPRINTF 1293 return vasprintf(ret, fmt, ap);
1302 #if _MSC_VER >= 1500 1304 __analysis_assume(tmp);
1311 len = vsnprintf(tmp, 0, fmt, ap2);
1313 if (len > 0 && (buf = malloc((buflen = (
size_t) (len + 1)))) != NULL) {
1314 len = vsnprintf(buf, buflen, fmt, ap);
1328 return fspr_match_glob(pattern, (fspr_array_header_t **) result, pool);
1339 return fspr_file_pipe_create((fspr_file_t **) in, (fspr_file_t **) out, pool);
1349 return fspr_file_pipe_timeout_get((fspr_file_t *) thepipe, (fspr_interval_time_t *) timeout);
1360 return fspr_file_pipe_timeout_set((fspr_file_t *) thepipe, (fspr_interval_time_t) timeout);
1371 return fspr_thread_exit((fspr_thread_t *) thd, retval);
1386 return fspr_thread_join((fspr_status_t *) retval, (fspr_thread_t *) thd);
1392 return fspr_atomic_init((fspr_pool_t *) pool);
1397 #ifdef fspr_atomic_t 1398 return fspr_atomic_read((fspr_atomic_t *)mem);
1400 return fspr_atomic_read32((fspr_uint32_t *)mem);
1406 #ifdef fspr_atomic_t 1407 fspr_atomic_set((fspr_atomic_t *)mem, val);
1409 fspr_atomic_set32((fspr_uint32_t *)mem, val);
1415 #ifdef fspr_atomic_t 1416 fspr_atomic_add((fspr_atomic_t *)mem, val);
1418 fspr_atomic_add32((fspr_uint32_t *)mem, val);
1424 #ifdef fspr_atomic_t 1425 fspr_atomic_inc((fspr_atomic_t *)mem);
1427 fspr_atomic_inc32((fspr_uint32_t *)mem);
1433 #ifdef fspr_atomic_t 1434 return fspr_atomic_dec((fspr_atomic_t *)mem);
1436 return fspr_atomic_dec32((fspr_uint32_t *)mem);
1442 return fspr_strerror(statcode, buf, bufsize);
switch_status_t switch_socket_connect(switch_socket_t *sock, switch_sockaddr_t *sa)
unsigned int switch_queue_size(switch_queue_t *queue)
#define SWITCH_MUTEX_DEFAULT
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_directory_exists(const char *dirname, switch_memory_pool_t *pool)
switch_status_t switch_time_exp_get(switch_time_t *result, switch_time_exp_t *input)
switch_status_t switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool)
uint16_t switch_sockaddr_get_port(switch_sockaddr_t *sa)
switch_status_t switch_file_write(switch_file_t *thefile, const void *buf, switch_size_t *nbytes)
switch_status_t switch_mutex_destroy(switch_mutex_t *lock)
#define SWITCH_CHANNEL_LOG
int switch_status_is_timeup(int status)
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
switch_status_t switch_time_exp_gmt(switch_time_exp_t *result, switch_time_t input)
switch_status_t switch_socket_bind(switch_socket_t *sock, switch_sockaddr_t *sa)
switch_status_t switch_mcast_hops(switch_socket_t *sock, uint8_t ttl)
switch_status_t switch_socket_create_pollfd(switch_pollfd_t **pollfd, switch_socket_t *sock, int16_t flags, void *client_data, switch_memory_pool_t *pool)
Create a pollfd out of a socket.
switch_status_t switch_queue_pop_timeout(switch_queue_t *queue, void **data, switch_interval_time_t timeout)
switch_status_t switch_atomic_init(switch_memory_pool_t *pool)
char * switch_copy_string(char *dst, const char *src, switch_size_t dst_size)
switch_status_t switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize)
switch_status_t switch_socket_timeout_set(switch_socket_t *sock, switch_interval_time_t t)
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
switch_memory_pool_t * pool
void switch_atomic_inc(volatile switch_atomic_t *mem)
#define SWITCH_SO_TCP_KEEPIDLE
switch_status_t switch_pollset_remove(switch_pollset_t *pollset, const switch_pollfd_t *descriptor)
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
int32_t switch_sockaddr_get_family(switch_sockaddr_t *sa)
switch_interval_time_t switch_interval_time_from_timeval(struct timeval *tvp)
unsigned int switch_ci_hashfunc_default(const char *char_key, switch_ssize_t *klen)
switch_status_t switch_thread_cond_timedwait(switch_thread_cond_t *cond, switch_mutex_t *mutex, switch_interval_time_t timeout)
switch_status_t switch_file_seek(switch_file_t *thefile, switch_seek_where_t where, int64_t *offset)
switch_status_t switch_time_exp_lt(switch_time_exp_t *result, switch_time_t input)
#define SWITCH_MD5_DIGEST_STRING_SIZE
switch_status_t switch_thread_cond_wait(switch_thread_cond_t *cond, switch_mutex_t *mutex)
switch_status_t switch_socket_recv(switch_socket_t *sock, char *buf, switch_size_t *len)
switch_status_t switch_queue_pop(switch_queue_t *queue, void **data)
char const int const cJSON_bool format
int switch_socket_fd_get(switch_socket_t *sock)
switch_status_t switch_strftime_nocheck(char *s, switch_size_t *retsize, switch_size_t max, const char *format, switch_time_exp_t *tm)
struct switch_runtime runtime
switch_status_t switch_thread_rwlock_destroy(switch_thread_rwlock_t *rwlock)
switch_status_t switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, size_t *len)
fspr_status_t switch_apr_queue_trypop(switch_apr_queue_t *queue, void **data)
fspr_status_t switch_apr_queue_term(switch_apr_queue_t *queue)
switch_status_t switch_file_remove(const char *path, switch_memory_pool_t *pool)
int switch_atomic_dec(volatile switch_atomic_t *mem)
switch_status_t switch_socket_addr_get(switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock)
switch_status_t switch_uuid_parse(switch_uuid_t *uuid, const char *uuid_str)
switch_status_t switch_socket_send(switch_socket_t *sock, const char *buf, switch_size_t *len)
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_file_rename(const char *from_path, const char *to_path, switch_memory_pool_t *pool)
#define SWITCH_MUTEX_NESTED
int switch_file_printf(switch_file_t *thefile, const char *format,...)
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_socket_accept(switch_socket_t **new_sock, switch_socket_t *sock, switch_memory_pool_t *pool)
switch_status_t switch_threadattr_detach_set(switch_threadattr_t *attr, int32_t on)
switch_byte_t switch_byte_t * buf
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
switch_status_t switch_sockaddr_ip_get(char **addr, switch_sockaddr_t *sa)
switch_status_t switch_socket_sendto(switch_socket_t *sock, switch_sockaddr_t *where, int32_t flags, const char *buf, switch_size_t *len)
switch_status_t switch_thread_cond_destroy(switch_thread_cond_t *cond)
switch_thread_id_t switch_thread_self(void)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
switch_status_t switch_file_pipe_timeout_get(switch_file_t *thepipe, switch_interval_time_t *timeout)
switch_status_t switch_dir_make(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
switch_status_t switch_sockaddr_create(switch_sockaddr_t **sa, switch_memory_pool_t *pool)
void switch_atomic_set(volatile switch_atomic_t *mem, uint32_t val)
switch_status_t switch_socket_create_pollset(switch_pollfd_t **poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool)
Create a set of file descriptors to poll from a socket.
switch_status_t switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_socket_listen(switch_socket_t *sock, int32_t backlog)
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
#define SWITCH_BLANK_STRING
struct fspr_pollset_t switch_pollset_t
switch_status_t switch_socket_opt_set(switch_socket_t *sock, int32_t opt, int32_t on)
switch_status_t switch_md5(unsigned char digest[SWITCH_MD5_DIGESTSIZE], const void *input, switch_size_t inputLen)
switch_status_t switch_thread_join(switch_status_t *retval, switch_thread_t *thd)
switch_status_t switch_file_pipe_create(switch_file_t **in, switch_file_t **out, switch_memory_pool_t *pool)
switch_status_t switch_socket_atmark(switch_socket_t *sock, int *atmark)
switch_status_t switch_time_exp_gmt_get(switch_time_t *result, switch_time_exp_t *input)
switch_byte_t switch_byte_t uint32_t buflen
switch_status_t switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool)
switch_status_t switch_mcast_interface(switch_socket_t *sock, switch_sockaddr_t *iface)
pthread_t switch_thread_id_t
switch_status_t switch_rfc822_date(char *date_str, switch_time_t t)
int64_t switch_interval_time_t
fspr_status_t switch_apr_queue_push(switch_apr_queue_t *queue, void *data)
switch_status_t switch_file_pipe_timeout_set(switch_file_t *thepipe, switch_interval_time_t timeout)
int32_t switch_fileperms_t
switch_status_t switch_file_read(switch_file_t *thefile, void *buf, switch_size_t *nbytes)
const char * switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len)
switch_status_t switch_time_exp_tz(switch_time_exp_t *result, switch_time_t input, switch_int32_t offs)
switch_status_t switch_poll(switch_pollfd_t *aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout)
char * switch_strerror(switch_status_t statcode, char *buf, switch_size_t bufsize)
struct fspr_sockaddr_t switch_sockaddr_t
fspr_status_t switch_apr_queue_pop(switch_apr_queue_t *queue, void **data)
fspr_status_t switch_apr_queue_trypush(switch_apr_queue_t *queue, void *data)
struct fspr_thread_mutex_t switch_mutex_t
switch_status_t switch_sockaddr_new(switch_sockaddr_t **sa, const char *ip, switch_port_t port, switch_memory_pool_t *pool)
switch_status_t switch_thread_cond_signal(switch_thread_cond_t *cond)
switch_status_t switch_os_sock_get(switch_os_socket_t *thesock, switch_socket_t *sock)
void *(SWITCH_THREAD_FUNC * switch_thread_start_t)(switch_thread_t *, void *)
switch_status_t switch_mcast_loopback(switch_socket_t *sock, uint8_t opt)
switch_status_t switch_file_exists(const char *filename, switch_memory_pool_t *pool)
void switch_uuid_format(char *buffer, const switch_uuid_t *uuid)
switch_status_t switch_socket_create(switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool)
switch_thread_rwlock_t * rwlock
switch_status_t switch_file_mktemp(switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool)
switch_status_t
Common return values.
const char *const const char *const path
#define switch_goto_status(_status, _label)
#define SWITCH_SO_TCP_KEEPINTVL
switch_status_t switch_file_trunc(switch_file_t *thefile, int64_t offset)
int switch_vasprintf(char **ret, const char *fmt, va_list ap)
switch_status_t switch_pollset_create(switch_pollset_t **pollset, uint32_t size, switch_memory_pool_t *pool, uint32_t flags)
switch_status_t switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
switch_status_t switch_socket_close(switch_socket_t *sock)
switch_status_t switch_queue_interrupt_all(switch_queue_t *queue)
void switch_core_memory_pool_set_data(switch_memory_pool_t *pool, const char *key, void *data)
switch_status_t switch_socket_shutdown(switch_socket_t *sock, switch_shutdown_how_e how)
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_pollset_poll(switch_pollset_t *pollset, switch_interval_time_t timeout, int32_t *num, const switch_pollfd_t **descriptors)
switch_status_t switch_pollset_add(switch_pollset_t *pollset, const switch_pollfd_t *descriptor)
switch_status_t switch_file_copy(const char *from_path, const char *to_path, switch_fileperms_t perms, switch_memory_pool_t *pool)
struct fspr_thread_cond_t switch_thread_cond_t
unsigned int switch_hashfunc_default(const char *key, switch_ssize_t *klen)
void switch_uuid_get(switch_uuid_t *uuid)
struct fspr_file_t switch_file_t
switch_status_t switch_file_lock(switch_file_t *thefile, int type)
uint32_t switch_dir_count(switch_dir_t *thedir)
switch_status_t switch_queue_trypush(switch_queue_t *queue, void *data)
fspr_status_t switch_apr_queue_pop_timeout(switch_apr_queue_t *queue, void **data, fspr_interval_time_t timeout)
switch_status_t switch_match_glob(const char *pattern, switch_array_header_t **result, switch_memory_pool_t *pool)
switch_status_t switch_socket_send_nonblock(switch_socket_t *sock, const char *buf, switch_size_t *len)
switch_status_t switch_queue_term(switch_queue_t *queue)
char * get_addr6(char *buf, switch_size_t len, struct sockaddr_in6 *sa, socklen_t salen)
switch_status_t switch_mcast_join(switch_socket_t *sock, switch_sockaddr_t *join, switch_sockaddr_t *iface, switch_sockaddr_t *source)
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
switch_mutex_t * uuid_mutex
switch_status_t switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, switch_memory_pool_t *pool)
switch_status_t switch_thread_exit(switch_thread_t *thd, switch_status_t retval)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_status_t switch_strftime(char *s, switch_size_t *retsize, switch_size_t max, const char *format, switch_time_exp_t *tm)
switch_status_t switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
switch_status_t switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
uint32_t switch_atomic_read(volatile switch_atomic_t *mem)
switch_time_t switch_time_make(switch_time_t sec, int32_t usec)
struct fspr_pool_t switch_memory_pool_t
switch_status_t switch_thread_rwlock_trywrlock_timeout(switch_thread_rwlock_t *rwlock, int timeout)
switch_status_t switch_file_open(switch_file_t **newf, const char *fname, int32_t flag, switch_fileperms_t perm, switch_memory_pool_t *pool)
const char * switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t *in)
switch_status_t switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
switch_status_t switch_thread_cond_broadcast(switch_thread_cond_t *cond)
int switch_vsnprintf(char *buf, switch_size_t len, const char *format, va_list ap)
void switch_atomic_add(volatile switch_atomic_t *mem, uint32_t val)
int switch_thread_equal(switch_thread_id_t tid1, switch_thread_id_t tid2)
Compare two thread ids.
struct fspr_socket_t switch_socket_t
fspr_status_t switch_apr_queue_interrupt_all(switch_apr_queue_t *queue)
switch_status_t switch_getnameinfo(char **hostname, switch_sockaddr_t *sa, int32_t flags)
switch_status_t switch_file_close(switch_file_t *thefile)
struct fspr_thread_t switch_thread_t
switch_time_t switch_time_now(void)
switch_status_t switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname, int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool)
switch_status_t switch_socket_timeout_get(switch_socket_t *sock, switch_interval_time_t *t)
struct fspr_thread_rwlock_t switch_thread_rwlock_t
int switch_snprintf(char *buf, switch_size_t len, const char *format,...)
unsigned int switch_apr_queue_size(switch_apr_queue_t *queue)
switch_memory_pool_t * switch_thread_rwlock_pool_get(switch_thread_rwlock_t *rwlock)
switch_status_t switch_os_sock_put(switch_socket_t **sock, switch_os_socket_t *thesock, switch_memory_pool_t *pool)
fspr_status_t switch_apr_queue_create(switch_apr_queue_t **q, unsigned int queue_capacity, fspr_pool_t *a)
#define SWITCH_MD5_DIGESTSIZE
switch_size_t switch_file_get_size(switch_file_t *thefile)
switch_status_t switch_md5_string(char digest_str[SWITCH_MD5_DIGEST_STRING_SIZE], const void *input, switch_size_t inputLen)
switch_status_t switch_thread_rwlock_trywrlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_dir_close(switch_dir_t *thedir)
switch_status_t switch_threadattr_priority_set(switch_threadattr_t *attr, switch_thread_priority_t priority)
int switch_sockaddr_equal(const switch_sockaddr_t *sa1, const switch_sockaddr_t *sa2)