RTS API Documentation  1.10.11
Data Structures | Macros | Functions | Variables
switch_apr.c File Reference
#include <switch.h>
#include <switch_private.h>
#include "private/switch_core_pvt.h"
#include "private/switch_apr_pvt.h"
#include <fspr.h>
#include <fspr_atomic.h>
#include <fspr_pools.h>
#include <fspr_hash.h>
#include <fspr_network_io.h>
#include <fspr_errno.h>
#include <fspr_thread_proc.h>
#include <fspr_portable.h>
#include <fspr_thread_mutex.h>
#include <fspr_thread_cond.h>
#include <fspr_thread_rwlock.h>
#include <fspr_file_io.h>
#include <fspr_poll.h>
#include <fspr_strings.h>
#include <fspr_want.h>
#include <fspr_file_info.h>
#include <fspr_fnmatch.h>
#include <fspr_tables.h>
#include <fspr_lib.h>
#include <apr_md5.h>
#include <uuid/uuid.h>
+ Include dependency graph for switch_apr.c:

Go to the source code of this file.

Data Structures

struct  switch_dir
 
struct  fspr_threadattr_t
 

Macros

#define APR_WANT_STDIO
 
#define APR_WANT_STRFUNC
 

Functions

int switch_status_is_timeup (int status)
 
switch_thread_id_t switch_thread_self (void)
 
int switch_thread_equal (switch_thread_id_t tid1, switch_thread_id_t tid2)
 Compare two thread ids. More...
 
unsigned int switch_ci_hashfunc_default (const char *char_key, switch_ssize_t *klen)
 
unsigned int switch_hashfunc_default (const char *key, switch_ssize_t *klen)
 
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_strftime_nocheck (char *s, switch_size_t *retsize, switch_size_t max, const char *format, switch_time_exp_t *tm)
 
int switch_snprintf (char *buf, switch_size_t len, const char *format,...)
 
int switch_vsnprintf (char *buf, switch_size_t len, const char *format, va_list ap)
 
char * switch_copy_string (char *dst, const char *src, switch_size_t dst_size)
 
switch_status_t switch_thread_rwlock_create (switch_thread_rwlock_t **rwlock, switch_memory_pool_t *pool)
 
switch_status_t switch_thread_rwlock_destroy (switch_thread_rwlock_t *rwlock)
 
switch_memory_pool_tswitch_thread_rwlock_pool_get (switch_thread_rwlock_t *rwlock)
 
switch_status_t switch_thread_rwlock_rdlock (switch_thread_rwlock_t *rwlock)
 
switch_status_t switch_thread_rwlock_tryrdlock (switch_thread_rwlock_t *rwlock)
 
switch_status_t switch_thread_rwlock_wrlock (switch_thread_rwlock_t *rwlock)
 
switch_status_t switch_thread_rwlock_trywrlock (switch_thread_rwlock_t *rwlock)
 
switch_status_t switch_thread_rwlock_trywrlock_timeout (switch_thread_rwlock_t *rwlock, int timeout)
 
switch_status_t switch_thread_rwlock_unlock (switch_thread_rwlock_t *rwlock)
 
switch_status_t switch_mutex_init (switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
 
switch_status_t switch_mutex_destroy (switch_mutex_t *lock)
 
switch_status_t switch_mutex_lock (switch_mutex_t *lock)
 
switch_status_t switch_mutex_unlock (switch_mutex_t *lock)
 
switch_status_t switch_mutex_trylock (switch_mutex_t *lock)
 
switch_time_t switch_time_now (void)
 
switch_status_t switch_time_exp_gmt_get (switch_time_t *result, switch_time_exp_t *input)
 
switch_status_t switch_time_exp_get (switch_time_t *result, switch_time_exp_t *input)
 
switch_status_t switch_time_exp_lt (switch_time_exp_t *result, switch_time_t input)
 
switch_status_t switch_time_exp_tz (switch_time_exp_t *result, switch_time_t input, switch_int32_t offs)
 
switch_status_t switch_time_exp_gmt (switch_time_exp_t *result, switch_time_t input)
 
switch_status_t switch_rfc822_date (char *date_str, switch_time_t t)
 
switch_time_t switch_time_make (switch_time_t sec, int32_t usec)
 
switch_status_t switch_thread_cond_create (switch_thread_cond_t **cond, switch_memory_pool_t *pool)
 
switch_status_t switch_thread_cond_wait (switch_thread_cond_t *cond, switch_mutex_t *mutex)
 
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_thread_cond_signal (switch_thread_cond_t *cond)
 
switch_status_t switch_thread_cond_broadcast (switch_thread_cond_t *cond)
 
switch_status_t switch_thread_cond_destroy (switch_thread_cond_t *cond)
 
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)
 
switch_status_t switch_file_seek (switch_file_t *thefile, switch_seek_where_t where, int64_t *offset)
 
switch_status_t switch_file_copy (const char *from_path, const char *to_path, switch_fileperms_t perms, switch_memory_pool_t *pool)
 
switch_status_t switch_file_close (switch_file_t *thefile)
 
switch_status_t switch_file_trunc (switch_file_t *thefile, int64_t offset)
 
switch_status_t switch_file_lock (switch_file_t *thefile, int type)
 
switch_status_t switch_file_rename (const char *from_path, const char *to_path, switch_memory_pool_t *pool)
 
switch_status_t switch_file_remove (const char *path, switch_memory_pool_t *pool)
 
switch_status_t switch_file_read (switch_file_t *thefile, void *buf, switch_size_t *nbytes)
 
switch_status_t switch_file_write (switch_file_t *thefile, const void *buf, switch_size_t *nbytes)
 
int switch_file_printf (switch_file_t *thefile, const char *format,...)
 
switch_status_t switch_file_mktemp (switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool)
 
switch_size_t switch_file_get_size (switch_file_t *thefile)
 
switch_status_t switch_directory_exists (const char *dirname, switch_memory_pool_t *pool)
 
switch_status_t switch_file_exists (const char *filename, switch_memory_pool_t *pool)
 
switch_status_t switch_dir_make (const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
 
switch_status_t switch_dir_make_recursive (const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
 
switch_status_t switch_dir_open (switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool)
 
switch_status_t switch_dir_close (switch_dir_t *thedir)
 
uint32_t switch_dir_count (switch_dir_t *thedir)
 
const char * switch_dir_next_file (switch_dir_t *thedir, char *buf, switch_size_t len)
 
switch_status_t switch_threadattr_create (switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
 
switch_status_t switch_threadattr_detach_set (switch_threadattr_t *attr, int32_t on)
 
switch_status_t switch_threadattr_stacksize_set (switch_threadattr_t *attr, switch_size_t stacksize)
 
switch_status_t switch_threadattr_priority_set (switch_threadattr_t *attr, switch_thread_priority_t priority)
 
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)
 
switch_interval_time_t switch_interval_time_from_timeval (struct timeval *tvp)
 
switch_status_t switch_os_sock_get (switch_os_socket_t *thesock, switch_socket_t *sock)
 
switch_status_t switch_os_sock_put (switch_socket_t **sock, switch_os_socket_t *thesock, switch_memory_pool_t *pool)
 
switch_status_t switch_socket_addr_get (switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock)
 
switch_status_t switch_socket_create (switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool)
 
switch_status_t switch_socket_shutdown (switch_socket_t *sock, switch_shutdown_how_e how)
 
switch_status_t switch_socket_close (switch_socket_t *sock)
 
switch_status_t switch_socket_bind (switch_socket_t *sock, switch_sockaddr_t *sa)
 
switch_status_t switch_socket_listen (switch_socket_t *sock, int32_t backlog)
 
switch_status_t switch_socket_accept (switch_socket_t **new_sock, switch_socket_t *sock, switch_memory_pool_t *pool)
 
switch_status_t switch_socket_connect (switch_socket_t *sock, switch_sockaddr_t *sa)
 
switch_status_t switch_socket_send (switch_socket_t *sock, const char *buf, switch_size_t *len)
 
switch_status_t switch_socket_send_nonblock (switch_socket_t *sock, const char *buf, switch_size_t *len)
 
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_socket_recv (switch_socket_t *sock, char *buf, switch_size_t *len)
 
switch_status_t switch_sockaddr_create (switch_sockaddr_t **sa, switch_memory_pool_t *pool)
 
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_sockaddr_new (switch_sockaddr_t **sa, const char *ip, switch_port_t port, switch_memory_pool_t *pool)
 
switch_status_t switch_socket_opt_set (switch_socket_t *sock, int32_t opt, int32_t on)
 
switch_status_t switch_socket_timeout_get (switch_socket_t *sock, switch_interval_time_t *t)
 
switch_status_t switch_socket_timeout_set (switch_socket_t *sock, switch_interval_time_t t)
 
switch_status_t switch_sockaddr_ip_get (char **addr, switch_sockaddr_t *sa)
 
int switch_sockaddr_equal (const switch_sockaddr_t *sa1, const switch_sockaddr_t *sa2)
 
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_mcast_hops (switch_socket_t *sock, uint8_t ttl)
 
switch_status_t switch_mcast_loopback (switch_socket_t *sock, uint8_t opt)
 
switch_status_t switch_mcast_interface (switch_socket_t *sock, switch_sockaddr_t *iface)
 
const char * switch_get_addr (char *buf, switch_size_t len, switch_sockaddr_t *in)
 
int switch_socket_fd_get (switch_socket_t *sock)
 
uint16_t switch_sockaddr_get_port (switch_sockaddr_t *sa)
 
int32_t switch_sockaddr_get_family (switch_sockaddr_t *sa)
 
switch_status_t switch_getnameinfo (char **hostname, switch_sockaddr_t *sa, int32_t flags)
 
switch_status_t switch_socket_atmark (switch_socket_t *sock, int *atmark)
 
switch_status_t switch_socket_recvfrom (switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, size_t *len)
 
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_pollset_add (switch_pollset_t *pollset, const switch_pollfd_t *descriptor)
 
switch_status_t switch_pollset_remove (switch_pollset_t *pollset, const switch_pollfd_t *descriptor)
 
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. More...
 
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_poll (switch_pollfd_t *aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout)
 
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. More...
 
void switch_uuid_format (char *buffer, const switch_uuid_t *uuid)
 
void switch_uuid_get (switch_uuid_t *uuid)
 
switch_status_t switch_uuid_parse (switch_uuid_t *uuid, const char *uuid_str)
 
switch_status_t switch_md5 (unsigned char digest[SWITCH_MD5_DIGESTSIZE], const void *input, switch_size_t inputLen)
 
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_queue_create (switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
 
unsigned int switch_queue_size (switch_queue_t *queue)
 
switch_status_t switch_queue_pop (switch_queue_t *queue, void **data)
 
switch_status_t switch_queue_pop_timeout (switch_queue_t *queue, void **data, switch_interval_time_t timeout)
 
switch_status_t switch_queue_push (switch_queue_t *queue, void *data)
 
switch_status_t switch_queue_trypop (switch_queue_t *queue, void **data)
 
switch_status_t switch_queue_interrupt_all (switch_queue_t *queue)
 
switch_status_t switch_queue_term (switch_queue_t *queue)
 
switch_status_t switch_queue_trypush (switch_queue_t *queue, void *data)
 
int switch_vasprintf (char **ret, const char *fmt, va_list ap)
 
switch_status_t switch_match_glob (const char *pattern, switch_array_header_t **result, switch_memory_pool_t *pool)
 
switch_status_t switch_file_pipe_create (switch_file_t **in, switch_file_t **out, switch_memory_pool_t *pool)
 
switch_status_t switch_file_pipe_timeout_get (switch_file_t *thepipe, switch_interval_time_t *timeout)
 
switch_status_t switch_file_pipe_timeout_set (switch_file_t *thepipe, switch_interval_time_t timeout)
 
switch_status_t switch_thread_exit (switch_thread_t *thd, switch_status_t retval)
 
switch_status_t switch_thread_join (switch_status_t *retval, switch_thread_t *thd)
 
switch_status_t switch_atomic_init (switch_memory_pool_t *pool)
 
uint32_t switch_atomic_read (volatile switch_atomic_t *mem)
 
void switch_atomic_set (volatile switch_atomic_t *mem, uint32_t val)
 
void switch_atomic_add (volatile switch_atomic_t *mem, uint32_t val)
 
void switch_atomic_inc (volatile switch_atomic_t *mem)
 
int switch_atomic_dec (volatile switch_atomic_t *mem)
 
char * switch_strerror (switch_status_t statcode, char *buf, switch_size_t bufsize)
 

Variables

static char TT_KEY [] = "1"
 

Macro Definition Documentation

◆ APR_WANT_STDIO

#define APR_WANT_STDIO

Definition at line 56 of file switch_apr.c.

◆ APR_WANT_STRFUNC

#define APR_WANT_STRFUNC

Definition at line 57 of file switch_apr.c.

Function Documentation

◆ switch_copy_string()

char* switch_copy_string ( char *  dst,
const char *  src,
switch_size_t  dst_size 
)

Definition at line 222 of file switch_apr.c.

Referenced by switch_dir_next_file().

223 {
224  if (!dst)
225  return NULL;
226  if (!src) {
227  *dst = '\0';
228  return dst;
229  }
230  return fspr_cpystrn(dst, src, dst_size);
231 }

◆ switch_snprintf()

int switch_snprintf ( char *  buf,
switch_size_t  len,
const char *  format,
  ... 
)

Definition at line 207 of file switch_apr.c.

208 {
209  va_list ap;
210  int ret;
211  va_start(ap, format);
212  ret = fspr_vsnprintf(buf, len, format, ap);
213  va_end(ap);
214  return ret;
215 }
char const int const cJSON_bool format
Definition: switch_cJSON.h:153
switch_byte_t switch_byte_t * buf

◆ switch_status_is_timeup()

int switch_status_is_timeup ( int  status)

Definition at line 95 of file switch_apr.c.

Referenced by switch_core_session_thread_pool_worker().

96 {
97  return APR_STATUS_IS_TIMEUP(status);
98 }

◆ switch_thread_equal()

int switch_thread_equal ( switch_thread_id_t  tid1,
switch_thread_id_t  tid2 
)

Compare two thread ids.

Parameters
tid11st Thread ID to compare
tid22nd Thread ID to compare

Definition at line 111 of file switch_apr.c.

Referenced by switch_core_session_in_thread(), and switch_core_session_in_video_thread().

112 {
113 #ifdef WIN32
114  return (tid1 == tid2);
115 #else
116  return fspr_os_thread_equal(tid1, tid2);
117 #endif
118 
119 }

◆ switch_thread_self()

switch_thread_id_t switch_thread_self ( void  )

◆ switch_vasprintf()

int switch_vasprintf ( char **  ret,
const char *  fmt,
va_list  ap 
)

Definition at line 1290 of file switch_apr.c.

References buf, and buflen.

Referenced by switch_file_printf().

1291 {
1292 #ifdef HAVE_VASPRINTF
1293  return vasprintf(ret, fmt, ap);
1294 #else
1295  char *buf;
1296  int len;
1297  size_t buflen;
1298  va_list ap2;
1299  char *tmp = NULL;
1300 
1301 #ifdef _MSC_VER
1302 #if _MSC_VER >= 1500
1303  /* hack for incorrect assumption in msvc header files for code analysis */
1304  __analysis_assume(tmp);
1305 #endif
1306  ap2 = ap;
1307 #else
1308  va_copy(ap2, ap);
1309 #endif
1310 
1311  len = vsnprintf(tmp, 0, fmt, ap2);
1312 
1313  if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) {
1314  len = vsnprintf(buf, buflen, fmt, ap);
1315  *ret = buf;
1316  } else {
1317  *ret = NULL;
1318  len = -1;
1319  }
1320 
1321  va_end(ap2);
1322  return len;
1323 #endif
1324 }
int cJSON_bool fmt
Definition: switch_cJSON.h:150
switch_byte_t switch_byte_t * buf
switch_byte_t switch_byte_t uint32_t buflen

Variable Documentation

◆ TT_KEY

char TT_KEY[] = "1"
static

Definition at line 696 of file switch_apr.c.

Referenced by switch_thread_create().