48 #include <sys/resource.h>
53 #ifdef HAVE_SYS_PRCTL_H
54 #include <sys/prctl.h>
56 #ifdef SOLARIS_PRIVILEGES
84 duration.
yr, duration.
yr == 1 ?
"" :
"s",
85 duration.
day, duration.
day == 1 ?
"" :
"s",
86 duration.
hr, duration.
hr == 1 ?
"" :
"s",
87 duration.
min, duration.
min == 1 ?
"" :
"s",
88 duration.
sec, duration.
sec == 1 ?
"" :
"s",
89 duration.
ms, duration.
ms == 1 ?
"" :
"s", duration.
mms, duration.
mms == 1 ?
"" :
"s");
111 char guess_ip4[256] =
"";
112 char guess_ip6[256] =
"";
113 char old_ip4[256] =
"";
114 char old_ip6[256] =
"";
115 int ok4 = 1, ok6 = 1;
123 if (
zstr(hostname)) {
125 }
else if (strcmp(hostname, runtime.
hostname)) {
148 if (!(ok4 = !strcmp(
main_ip4, guess_ip4))) {
164 if (!(ok6 = !strcmp(
main_ip6, guess_ip6))) {
186 if (ok4 == 2 || ok6 == 2) {
222 if ((runtime.
console = fopen(console,
"a")) == 0) {
223 fprintf(stderr,
"Cannot open output file %s.\n", console);
235 #ifdef HAVE_SYS_IOCTL_H
236 #include <sys/ioctl.h>
242 CONSOLE_SCREEN_BUFFER_INFO csbi;
245 if ((ret = GetConsoleScreenBufferInfo(GetStdHandle( STD_OUTPUT_HANDLE ), &csbi))) {
246 if (x) *x = csbi.dwSize.X;
247 if (y) *y = csbi.dwSize.Y;
250 #elif defined(TIOCGWINSZ)
252 ioctl(0, TIOCGWINSZ, &w);
254 if (x) *x = w.ws_col;
255 if (y) *y = w.ws_row;
265 FILE *handle = stdout;
283 int index, tmp_index = 0;
291 if (cur == state_handler) {
294 tmp[tmp_index++] =
cur;
299 for (index = 0; index < tmp_index; index++) {
339 stream->write_function(stream,
"%s=%s\n", hi->
name, hi->
value);
362 var =
"freeswitch.local";
365 domain = strdup(var);
367 domain = (
char *) var;
394 char *val = NULL, *v;
409 char *val = NULL, *v;
441 char *v = strdup(value);
460 if (!val2 || strcmp(val, val2) != 0) {
465 }
else if (!
zstr(val2)) {
471 char *v = strdup(value);
595 mypool = pool ? 0 : 1;
630 GetModuleFileName(NULL, base_dir,
BUFSIZE);
631 lastbacklash = strrchr(base_dir,
'\\');
632 base_dir[(lastbacklash - base_dir)] =
'\0';
634 SetCurrentDirectory(base_dir);
636 strcpy(base_dir, tmp);
654 #ifdef SWITCH_MOD_DIR
665 #ifdef SWITCH_LIB_DIR
676 #ifdef SWITCH_CONF_DIR
687 #ifdef SWITCH_LOG_DIR
698 #ifdef SWITCH_RUN_DIR
709 #ifdef SWITCH_RECORDINGS_DIR
720 #ifdef SWITCH_SOUNDS_DIR
731 #ifdef SWITCH_STORAGE_DIR
742 #ifdef SWITCH_CACHE_DIR
764 #ifdef SWITCH_SCRIPT_DIR
775 #ifdef SWITCH_HTDOCS_DIR
786 #ifdef SWITCH_GRAMMAR_DIR
797 #ifdef SWITCH_FONTS_DIR
808 #ifdef SWITCH_IMAGES_DIR
819 #ifdef SWITCH_DATA_DIR
830 #ifdef SWITCH_LOCALSTATE_DIR
841 #ifdef SWITCH_CERTS_DIR
849 #ifdef SWITCH_TEMP_DIR
853 GetTempPath(dwBufSize, lpPathBuffer);
854 lpPathBuffer[strlen(lpPathBuffer)-1] = 0;
856 strcpy(lpPathBuffer, tmp);
899 #ifdef SOLARIS_PRIVILEGES
900 priv_set_t *basicset;
903 setpflags(PRIV_AWARE, 1);
906 basicset = priv_str_to_set(
"basic",
",", NULL);
907 if (setppriv(PRIV_SET, PRIV_EFFECTIVE, basicset) != 0) {
908 fprintf(stderr,
"ERROR: Failed to acquire basic privileges (%s)\n", strerror(errno));
912 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_CLOCK_HIGHRES, NULL) < 0) {
913 fprintf(stderr,
"ERROR: Failed to acquire proc_clock_highres privilege (%s)\n", strerror(errno));
918 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_SYS_RESOURCE, NULL) < 0) {
919 fprintf(stderr,
"ERROR: Failed to acquire sys_resource privilege (%s)\n", strerror(errno));
924 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_FILE_DAC_SEARCH, NULL) < 0) {
925 fprintf(stderr,
"ERROR: Failed to acquire file_dac_search privilege (%s)\n", strerror(errno));
935 return SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
937 #if defined(USE_SCHED_SETSCHEDULER) && ! defined(SOLARIS_PRIVILEGES)
941 struct sched_param sched = { 0 };
942 sched.sched_priority = 0;
943 if (sched_setscheduler(0, SCHED_OTHER, &sched) < 0) {
944 fprintf(stderr,
"ERROR: Failed to set SCHED_OTHER scheduler (%s)\n", strerror(errno));
949 #ifdef HAVE_SETPRIORITY
953 if (setpriority(PRIO_PROCESS, getpid(), 19) < 0) {
954 fprintf(stderr,
"ERROR: Could not set nice level\n");
958 if (nice(19) != 19) {
959 fprintf(stderr,
"ERROR: Could not set nice level\n");
971 return SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
973 #ifdef USE_SCHED_SETSCHEDULER
978 struct sched_param sched = { 0 };
982 #ifdef SOLARIS_PRIVILEGES
984 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_PRIOCNTL, NULL) < 0) {
985 #ifdef PRIV_PROC_PRIOUP
987 fprintf(stderr,
"WARN: Failed to acquire proc_priocntl privilege (%s)\n", strerror(errno));
988 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_PRIOUP, NULL) < 0) {
989 fprintf(stderr,
"ERROR: Failed to acquire proc_prioup privilege (%s)\n", strerror(errno));
993 fprintf(stderr,
"ERROR: Failed to acquire proc_priocntl privilege (%s)\n", strerror(errno));
998 if (sched_setscheduler(0, SCHED_FIFO, &sched) < 0) {
999 fprintf(stderr,
"WARN: Failed to set SCHED_FIFO scheduler (%s)\n", strerror(errno));
1004 if (setpriority(PRIO_PROCESS, 0, -10) < 0) {
1005 fprintf(stderr,
"ERROR: Could not set nice level\n");
1012 #ifdef USE_SCHED_SETSCHEDULER
1013 if (sched_setscheduler(0, SCHED_FIFO, &sched) < 0) {
1014 fprintf(stderr,
"ERROR: Failed to set SCHED_FIFO scheduler (%s)\n", strerror(errno));
1015 sched.sched_priority = 0;
1016 if (sched_setscheduler(0, SCHED_OTHER, &sched) < 0 ) {
1017 fprintf(stderr,
"ERROR: Failed to set SCHED_OTHER scheduler (%s)\n", strerror(errno));
1023 #ifdef HAVE_SETPRIORITY
1027 if (setpriority(PRIO_PROCESS, getpid(), -10) < 0) {
1028 fprintf(stderr,
"ERROR: Could not set nice level\n");
1032 if (nice(-10) != -10) {
1033 fprintf(stderr,
"ERROR: Could not set nice level\n");
1055 runtime.
cpu_count = sysconf (_SC_NPROCESSORS_ONLN);
1057 SYSTEM_INFO sysinfo;
1058 GetSystemInfo( &sysinfo );
1059 runtime.
cpu_count = sysinfo.dwNumberOfProcessors;
1073 uid_t runas_uid = 0;
1074 gid_t runas_gid = 0;
1075 struct passwd *runas_pw = NULL;
1081 runas_pw = getpwnam(user);
1083 fprintf(stderr,
"ERROR: Unknown user \"%s\"\n", user);
1086 runas_uid = runas_pw->pw_uid;
1090 struct group *gr = NULL;
1095 gr = getgrnam(group);
1097 fprintf(stderr,
"ERROR: Unknown group \"%s\"\n", group);
1100 runas_gid = gr->gr_gid;
1103 if (runas_uid && getuid() == runas_uid && (!runas_gid || runas_gid == getgid())) {
1109 #ifdef SOLARIS_PRIVILEGES
1111 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_SETID, NULL) < 0) {
1112 fprintf(stderr,
"ERROR: Failed to acquire proc_setid privilege (%s)\n", strerror(errno));
1116 #ifdef HAVE_SETGROUPS
1122 if (setgroups(0, NULL) < 0) {
1123 fprintf(stderr,
"ERROR: Failed to drop group access list\n");
1132 if (setgid(runas_gid) < 0) {
1133 fprintf(stderr,
"ERROR: Failed to change gid!\n");
1140 if (setgid(runas_pw->pw_gid) < 0) {
1141 fprintf(stderr,
"ERROR: Failed to change gid!\n");
1144 #ifdef HAVE_INITGROUPS
1149 if (initgroups(runas_pw->pw_name, runas_pw->pw_gid) < 0) {
1150 fprintf(stderr,
"ERROR: Failed to set group access list for user\n");
1159 if (setuid(runas_uid) < 0) {
1160 fprintf(stderr,
"ERROR: Failed to change uid!\n");
1163 #ifdef HAVE_SYS_PRCTL_H
1164 if (prctl(PR_SET_DUMPABLE, 1) < 0) {
1165 fprintf(stderr,
"ERROR: Failed to enable core dumps!\n");
1177 HANDLE shutdown_event;
1178 char path[256] =
"";
1182 switch_snprintf(path,
sizeof(path),
"Global\\Freeswitch.%d", getpid());
1183 shutdown_event = CreateEvent(NULL,
FALSE,
FALSE, path);
1184 if (shutdown_event) {
1185 WaitForSingleObject(shutdown_event, INFINITE);
1223 char *ext_list = NULL;
1225 char *argv[20] = { 0 };
1233 ext_list = strdup(ext);
1240 for (x = 0; x < argc; x++) {
1241 if (argv[x] && ptype) {
1245 if (!is_mapped_type) {
1262 char *cf =
"mime.types";
1264 char *line_buf = NULL;
1266 char *mime_path = NULL;
1271 fd = fopen(mime_path,
"rb");
1279 char *type = line_buf;
1281 if (*line_buf ==
'#') {
1285 if ((p = strchr(line_buf,
'\r')) || (p = strchr(line_buf,
'\n'))) {
1289 if ((p = strchr(type,
'\t')) || (p = strchr(type,
' '))) {
1292 while (*p ==
' ' || *p ==
'\t') {
1316 #ifdef HAVE_SETRLIMIT
1327 memset(&rlp, 0,
sizeof(rlp));
1330 setrlimit(RLIMIT_STACK, &rlp);
1333 memset(&rlp, 0,
sizeof(rlp));
1334 rlp.rlim_cur = 999999;
1335 rlp.rlim_max = 999999;
1336 setrlimit(RLIMIT_NOFILE, &rlp);
1338 memset(&rlp, 0,
sizeof(rlp));
1339 rlp.rlim_cur = RLIM_INFINITY;
1340 rlp.rlim_max = RLIM_INFINITY;
1342 setrlimit(RLIMIT_CPU, &rlp);
1343 setrlimit(RLIMIT_DATA, &rlp);
1344 setrlimit(RLIMIT_FSIZE, &rlp);
1346 setrlimit(RLIMIT_NPROC, &rlp);
1348 #ifdef RLIMIT_RTPRIO
1349 setrlimit(RLIMIT_RTPRIO, &rlp);
1352 #if !defined(__OpenBSD__) && !defined(__NetBSD__)
1353 setrlimit(RLIMIT_AS, &rlp);
1371 char *ipv6 = strchr(ip_str,
':');
1385 ip.
v4 = htonl(ip.
v4);
1394 }
else if (strchr(list_name,
'/')) {
1395 if (strchr(list_name,
',')) {
1396 char *list_name_dup = strdup(list_name);
1404 for (i = 0; i < argc; i++) {
1417 free(list_name_dup);
1438 switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, x_node = NULL, cfg = NULL;
1440 char guess_ip[16] =
"";
1442 char guess_mask[16] =
"";
1460 memset(&IP_LIST, 0,
sizeof(IP_LIST));
1465 tmp_name =
"rfc6598.auto";
1471 tmp_name =
"rfc1918.auto";
1480 tmp_name =
"wan.auto";
1491 tmp_name =
"wan_v6.auto";
1499 tmp_name =
"wan_v4.auto";
1511 tmp_name =
"any_v6.auto";
1518 tmp_name =
"any_v4.auto";
1525 tmp_name =
"nat.auto";
1537 tmp_name =
"loopback.auto";
1544 tmp_name =
"localnet.auto";
1581 const char *cidr = NULL, *host = NULL, *mask = NULL, *domain = NULL;
1620 if (
id && user_cidr) {
1635 if (
id && user_cidr) {
1649 }
else if (host && mask) {
1729 #ifdef HAVE_CPU_SET_MACROS
1735 if (!sched_setaffinity(0,
sizeof(set), &set)) {
1741 if (SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR) cpu)) {
1753 static void switch_core_set_serial(
void)
1758 int fd = -1, write_fd = -1;
1764 if ((fd = open(path, O_RDONLY, 0)) < 0) {
1779 for (i = 0; i < 8; i += 2) {
1786 if ((write_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) >= 0) {
1787 bytes = write(write_fd, buf,
sizeof(buf));
1792 bytes = read(fd, buf,
sizeof(buf) - 1);
1819 memset(&runtime, 0,
sizeof(runtime));
1848 runtime.
cpu_count = sysconf (_SC_NPROCESSORS_ONLN);
1851 SYSTEM_INFO sysinfo;
1852 GetSystemInfo( &sysinfo );
1853 runtime.
cpu_count = sysinfo.dwNumberOfProcessors;
1859 if (sqlite3_initialize() != SQLITE_OK) {
1860 *err =
"FATAL ERROR! Could not initialize SQLite\n";
1866 *err =
"FATAL ERROR! Could not initialize APR\n";
1871 *err =
"FATAL ERROR! Could not allocate memory pool\n";
1907 runtime.
flags |= flags;
1950 switch_core_set_serial();
1978 *err =
"Error activating database";
2005 static void handle_SIGBUS(
int sig)
2040 if (!strcasecmp(name,
"opus")) {
2042 }
else if (!strncasecmp(name,
"h26", 3)) {
2044 }
else if (!strncasecmp(name,
"vp", 2)) {
2074 if (!strcasecmp(var,
"G723") || !strcasecmp(var,
"iLBC")) {
2097 if (!strcasecmp(var,
"loglevel")) {
2099 if (*val > 47 && *val < 58) {
2108 #ifdef HAVE_SETRLIMIT
2109 }
else if (!strcasecmp(var,
"dump-cores") &&
switch_true(val)) {
2111 memset(&rlp, 0,
sizeof(rlp));
2112 rlp.rlim_cur = RLIM_INFINITY;
2113 rlp.rlim_max = RLIM_INFINITY;
2114 setrlimit(RLIMIT_CORE, &rlp);
2116 }
else if (!strcasecmp(var,
"debug-level")) {
2117 int tmp = atoi(val);
2118 if (tmp > -1 && tmp < 11) {
2121 }
else if (!strcasecmp(var,
"max-db-handles")) {
2122 long tmp = atol(val);
2124 if (tmp > 4 && tmp < 5001) {
2129 }
else if (!strcasecmp(var,
"db-handle-timeout")) {
2130 long tmp = atol(val);
2132 if (tmp > 0 && tmp < 5001) {
2138 }
else if (!strcasecmp(var,
"multiple-registrations")) {
2140 }
else if (!strcasecmp(var,
"auto-create-schemas")) {
2146 }
else if (!strcasecmp(var,
"session-thread-pool")) {
2152 }
else if (!strcasecmp(var,
"auto-clear-sql")) {
2158 }
else if (!strcasecmp(var,
"api-expansion")) {
2164 }
else if (!strcasecmp(var,
"enable-early-hangup") &&
switch_true(val)) {
2166 }
else if (!strcasecmp(var,
"colorize-console") &&
switch_true(val)) {
2168 }
else if (!strcasecmp(var,
"core-db-pre-trans-execute") && !
zstr(val)) {
2170 }
else if (!strcasecmp(var,
"core-db-post-trans-execute") && !
zstr(val)) {
2172 }
else if (!strcasecmp(var,
"core-db-inner-pre-trans-execute") && !
zstr(val)) {
2174 }
else if (!strcasecmp(var,
"core-db-inner-post-trans-execute") && !
zstr(val)) {
2176 }
else if (!strcasecmp(var,
"dialplan-timestamps")) {
2182 }
else if (!strcasecmp(var,
"mailer-app") && !
zstr(val)) {
2184 }
else if (!strcasecmp(var,
"mailer-app-args") && val) {
2186 }
else if (!strcasecmp(var,
"sessions-per-second") && !
zstr(val)) {
2188 }
else if (!strcasecmp(var,
"max-dtmf-duration") && !
zstr(val)) {
2189 int tmp = atoi(val);
2193 }
else if (!strcasecmp(var,
"min-dtmf-duration") && !
zstr(val)) {
2194 int tmp = atoi(val);
2198 }
else if (!strcasecmp(var,
"default-dtmf-duration") && !
zstr(val)) {
2199 int tmp = atoi(val);
2203 }
else if (!strcasecmp(var,
"enable-use-system-time")) {
2205 }
else if (!strcasecmp(var,
"enable-monotonic-timing")) {
2207 }
else if (!strcasecmp(var,
"enable-softtimer-timerfd")) {
2213 if (strcasecmp(val,
"broadcast")) {
2215 }
else if (strcasecmp(val,
"fd-per-timer")) {
2221 }
else if (!strcasecmp(var,
"enable-clock-nanosleep")) {
2223 }
else if (!strcasecmp(var,
"enable-cond-yield")) {
2225 }
else if (!strcasecmp(var,
"enable-timer-matrix")) {
2227 }
else if (!strcasecmp(var,
"max-sessions") && !
zstr(val)) {
2229 }
else if (!strcasecmp(var,
"verbose-channel-events") && !
zstr(val)) {
2236 }
else if (!strcasecmp(var,
"threaded-system-exec") && !
zstr(val)) {
2247 }
else if (!strcasecmp(var,
"min-idle-cpu") && !
zstr(val)) {
2249 }
else if (!strcasecmp(var,
"tipping-point") && !
zstr(val)) {
2251 }
else if (!strcasecmp(var,
"cpu-idle-smoothing-depth") && !
zstr(val)) {
2253 }
else if (!strcasecmp(var,
"events-use-dispatch") && !
zstr(val)) {
2255 }
else if (!strcasecmp(var,
"initial-event-threads") && !
zstr(val)) {
2261 "Implicitly setting events-use-dispatch based on usage of this initial-event-threads parameter.\n");
2279 }
else if (!strcasecmp(var,
"1ms-timer") &&
switch_true(val)) {
2281 }
else if (!strcasecmp(var,
"timer-affinity") && !
zstr(val)) {
2282 if (!strcasecmp(val,
"disabled")) {
2287 }
else if (!strcasecmp(var,
"rtp-start-port") && !
zstr(val)) {
2289 }
else if (!strcasecmp(var,
"rtp-end-port") && !
zstr(val)) {
2291 }
else if (!strcasecmp(var,
"rtp-port-usage-robustness") &&
switch_true(val)) {
2293 }
else if (!strcasecmp(var,
"core-db-name") && !
zstr(val)) {
2295 }
else if (!strcasecmp(var,
"core-db-dsn") && !
zstr(val)) {
2301 }
else if (!strcasecmp(var,
"core-non-sqlite-db-required") && !
zstr(val)) {
2303 }
else if (!strcasecmp(var,
"core-dbtype") && !
zstr(val)) {
2304 if (!strcasecmp(val,
"MSSQL")) {
2310 }
else if (!strcasecmp(var,
"rtp-enable-zrtp")) {
2313 }
else if (!strcasecmp(var,
"switchname") && !
zstr(val)) {
2316 }
else if (!strcasecmp(var,
"rtp-retain-crypto-keys")) {
2319 "rtp-retain-crypto-keys enabled. Could be used to decrypt secure media.\n");
2346 ".=============================================================.\n"
2347 "| _____ ______ _____ _____ ____ _ _ |\n"
2348 "| | ___| __ ___ ___/ ___\\ \\ / /_ _|_ _/ ___| | | | |\n"
2349 "| | |_ | '__/ _ \\/ _ \\___ \\\\ \\ /\\ / / | | | || | | |_| | |\n"
2350 "| | _|| | | __/ __/___) |\\ V V / | | | || |___| _ | |\n"
2351 "| |_| |_| \\___|\\___|____/ \\_/\\_/ |___| |_| \\____|_| |_| |\n"
2353 ".=============================================================."
2356 "| Anthony Minessale II, Michael Jerris, Brian West, Others |\n"
2357 "| FreeSWITCH (http://www.freeswitch.org) |\n"
2358 "| Paypal Donations Appreciated: paypal@freeswitch.org |\n"
2359 "| Brought to you by ClueCon http://www.cluecon.com/ |\n"
2360 ".=============================================================.\n"
2370 const char *use = NULL;
2392 *err =
"Cannot load modules";
2410 use = (x > 100) ?
cc :
cc_s;
2425 "\nFreeSWITCH Version %s (%s)\n\nFreeSWITCH Started\nMax Sessions [%u]\nSession Rate [%d]\nSQL [%s]\n",
2453 memset(duration, 0,
sizeof(*duration));
2454 duration->mms = (uint32_t) (total_ms % 1000);
2455 duration->ms = (uint32_t) (temp % 1000);
2457 duration->sec = (uint32_t) (temp % 60);
2459 duration->min = (uint32_t) (temp % 60);
2461 duration->hr = (uint32_t) (temp % 24);
2463 duration->day = (uint32_t) (temp % 365);
2464 duration->yr = (uint32_t) (temp / 365);
2474 static void win_shutdown(
void)
2477 HANDLE shutdown_event;
2480 snprintf(path,
sizeof(path),
"Global\\Freeswitch.%d", getpid());
2483 shutdown_event = OpenEvent(EVENT_MODIFY_STATE,
FALSE, path);
2485 if (shutdown_event) {
2487 SetEvent(shutdown_event);
2489 CloseHandle(shutdown_event);
2497 signal(SIGINT, SIG_IGN);
2499 signal(SIGPIPE, SIG_IGN);
2502 signal(SIGALRM, SIG_IGN);
2505 signal(SIGQUIT, SIG_IGN);
2508 signal(SIGPOLL, SIG_IGN);
2511 signal(SIGIO, SIG_IGN);
2514 signal(SIGBUS, handle_SIGBUS);
2530 int *intval = (
int *) val;
2531 int oldintval = 0, newintval = 0;
2534 oldintval = *intval;
2544 char *arg = (
char *) val;
2545 char *tech = NULL, *prof = NULL;
2551 if ((prof = strchr(tech,
':'))) {
2555 if (!strcasecmp(tech,
"flush")) {
2561 if ((prof = strchr(tech,
':'))) {
2594 if (oldintval > -1) {
2606 if (oldintval > -1) {
2618 if (oldintval > -1) {
2709 "Shutdown in progress, %u session(s) remain.\nShutting down %s\n",
2773 if (oldintval > -1) {
2783 if (oldintval > -1) {
2792 double *dval = (
double *) val;
2806 if (oldintval == -1) {
2831 if (oldintval > 0) {
2845 *intval = newintval;
2854 return runtime.
flags;
3003 #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
3005 struct rlimit rlim_save;
3007 memset(&rlim, 0,
sizeof(rlim));
3008 getrlimit(RLIMIT_STACK, &rlim);
3010 memset(&rlim_save, 0,
sizeof(rlim_save));
3011 getrlimit(RLIMIT_STACK, &rlim_save);
3013 rlim.rlim_cur = rlim.rlim_max;
3014 if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
3020 dup2(sth->
fds[1], STDOUT_FILENO);
3023 sth->
ret = system(sth->
cmd);
3025 #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
3026 if (setrlimit(RLIMIT_STACK, &rlim_save) < 0) {
3085 #if defined(HAVE_GETDTABLESIZE)
3086 max = getdtablesize();
3088 max = sysconf(_SC_OPEN_MAX);
3101 for (i = 3; i < open_max; i++) {
3103 for (j = 0; j < keep_ttl; j++) {
3150 char *dcmd = strdup(cmd);
3151 #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
3153 struct rlimit rlim_save;
3162 waitpid(pid, NULL, 0);
3168 #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
3169 memset(&rlim, 0,
sizeof(rlim));
3170 getrlimit(RLIMIT_STACK, &rlim);
3172 memset(&rlim_save, 0,
sizeof(rlim_save));
3173 getrlimit(RLIMIT_STACK, &rlim_save);
3175 rlim.rlim_cur = rlim.rlim_max;
3176 if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
3181 if (system(dcmd) == -1) {
3200 return sys_p(cmd, wait);
3211 int fds[2], pid = 0;
3223 char buf[1024] =
"";
3226 while ((bytes = read(fds[0], buf,
sizeof(buf))) > 0) {
3227 stream->raw_write_function(stream, (
unsigned char *)buf, bytes);
3230 waitpid(pid, NULL, 0);
3234 dup2(fds[1], STDOUT_FILENO);
3251 #ifdef HAVE_SETRLIMIT
3254 memset(&rlp, 0,
sizeof(rlp));
3255 getrlimit(RLIMIT_STACK, &rlp);
3257 *cur = rlp.rlim_cur;
3258 *max = rlp.rlim_max;
3276 stream->write_function(stream,
"Capturing output not supported.\n");
3286 uint16_t start_port = 0;
3297 uint16_t end_port = 0;
void switch_channel_global_uninit(void)
void switch_core_set_signal_handlers(void)
switch_memory_pool_t * switch_core_memory_init(void)
#define switch_core_permanent_strdup(_todup)
Copy a string using permanent memory allocation.
int32_t change_user_group(const char *user, const char *group)
Change user and/or group of the running process.
const char * switch_core_get_switchname(void)
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
void switch_time_sync(void)
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
uint32_t min_dtmf_duration
char * core_db_inner_post_trans_execute
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_core_mime_add_type(const char *type, const char *ext)
const char * switch_xml_attr_soft(_In_ switch_xml_t xml, _In_z_ const char *attr)
returns the value of the requested tag attribute, or "" if not found
static void check_ip(void)
switch_status_t switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool)
switch_frame_t dummy_cng_frame
switch_memory_pool_t * pool
switch_status_t switch_xml_locate_domain(_In_z_ const char *domain_name, _In_opt_ switch_event_t *params, _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain)
void switch_core_memory_reclaim_logger(void)
switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_t manage)
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
#define switch_test_subnet(_ip, _net, _mask)
void switch_core_dump_variables(switch_stream_handle_t *stream)
switch_text_channel_t
A target to write log/debug info to.
void switch_nat_shutdown(void)
Shuts down the NAT Traversal System.
switch_bool_t switch_pgsql_available(void)
#define SWITCH_CHANNEL_LOG
switch_time_t switch_core_uptime(void)
Number of microseconds the system has been up.
switch_status_t switch_core_hash_destroy(_Inout_ switch_hash_t **hash)
Destroy an existing hash table.
#define SWITCH_IMAGES_DIR
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
#define SWITCH_RECORDINGS_DIR
const char * switch_xml_attr(_In_opt_ switch_xml_t xml, _In_opt_z_ const char *attr)
returns the value of the requested tag attribute, or NULL if not found
#define switch_event_del_header(_e, _h)
const switch_state_handler_table_t * state_handlers[SWITCH_MAX_STATE_HANDLERS]
uint32_t switch_core_sessions_per_second(_In_ uint32_t new_limit)
Set/Get Session Rate Limit.
int switch_core_test_flag(int flag)
#define switch_core_hash_init(_hash)
int switch_core_add_state_handler(const switch_state_handler_table_t *state_handler)
const char * switch_version_full(void)
void switch_ssl_init_ssl_locks(void)
void switch_time_set_nanosleep(switch_bool_t enable)
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)
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)
char * core_db_post_trans_execute
int32_t set_low_priority(void)
void switch_core_memory_stop(void)
switch_bool_t switch_core_running(void)
void switch_scheduler_task_thread_start(void)
Start the scheduler system.
int switch_parse_cidr(const char *string, ip_t *ip, ip_t *mask, uint32_t *bitp)
int switch_max_file_desc(void)
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
void switch_close_extra_files(int *keep, int keep_ttl)
int switch_core_session_sync_clock(void)
switch_status_t switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize)
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
switch_memory_pool_t * pool
switch_status_t switch_core_session_read_video_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
Read a video frame from a session.
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4
Add a header to an event.
Representation of an event.
void switch_core_set_globals(void)
Initiate Globals.
void switch_core_session_init(switch_memory_pool_t *pool)
#define switch_network_list_add_cidr(_list, _cidr_str, _ok)
switch_thread_rwlock_t * global_var_rwlock
switch_status_t switch_core_session_read_lock(_In_ switch_core_session_t *session)
Acquire a read lock on the session.
void switch_event_launch_dispatch_threads(uint32_t max)
switch_management_interface_t * switch_loadable_module_get_management_interface(const char *relative_oid)
Retrieve the management interface by it's registered name.
switch_status_t switch_core_destroy(void)
Destroy the core.
uint16_t switch_core_get_rtp_port_range_start_port()
Get RTP port range start value.
switch_event_t * global_vars
void switch_scheduler_task_thread_stop(void)
Stop the scheduler system.
uint32_t switch_default_ptime(const char *name, uint32_t number)
switch_bool_t switch_network_list_validate_ip6_token(switch_network_list_t *list, ip_t ip, const char **token)
A representation of an XML tree.
switch_mutex_t * throttle_mutex
#define SWITCH_DEFAULT_DTMF_DURATION
switch_status_t switch_thread_cond_wait(switch_thread_cond_t *cond, switch_mutex_t *mutex)
uint32_t switch_core_cpu_count(void)
const char * switch_core_mime_type2ext(const char *mime)
switch_status_t switch_console_shutdown(void)
switch_status_t switch_core_init_and_modload(switch_core_flag_t flags, switch_bool_t console, const char **err)
static void switch_load_core_config(const char *file)
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
void switch_time_set_timerfd(int enable)
#define SWITCH_MAX_STATE_HANDLERS
static switch_thread_t * thread
switch_status_t switch_core_thread_set_cpu_affinity(int cpu)
switch_thread_cond_t * cond
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
switch_status_t switch_core_get_stacksizes(switch_size_t *cur, switch_size_t *max)
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
switch_port_t switch_rtp_set_start_port(switch_port_t port)
Set/Get RTP start port.
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
uint32_t switch_core_flag_t
uint32_t microseconds_per_tick
struct switch_runtime runtime
uint32_t switch_scheduler_add_task(time_t task_runtime, switch_scheduler_func_t func, const char *desc, const char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags)
Schedule a task in the future.
struct apr_thread_cond_t switch_thread_cond_t
switch_status_t switch_core_session_read_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
Read a frame from a session.
void switch_loadable_module_shutdown(void)
Shutdown the module backend and call the shutdown routine in all loaded modules.
int switch_stream_system(const char *cmd, switch_stream_handle_t *stream)
#define SWITCH_HTDOCS_DIR
switch_hash_index_t * switch_core_mime_index(void)
switch_memory_pool_t * pool
#define SWITCH_PREFIX_DIR
switch_size_t switch_core_session_id(void)
Provide the current session_id.
const switch_state_handler_table_t * switch_core_get_state_handler(int index)
uint32_t switch_core_max_dtmf_duration(uint32_t duration)
char * switch_core_get_domain(switch_bool_t dup)
switch_bool_t switch_network_list_validate_ip_token(switch_network_list_t *list, uint32_t ip, const char **token)
#define SWITCH_STORAGE_DIR
#define SWITCH_SEQ_FYELLOW
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_event_shutdown(void)
Stop the eventing system.
void switch_rtp_init(switch_memory_pool_t *pool)
Initilize the RTP System.
int switch_system(const char *cmd, switch_bool_t wait)
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
switch_status_t switch_event_init(switch_memory_pool_t *pool)
Start the eventing system.
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
#define SWITCH_MUTEX_NESTED
uint32_t switch_core_min_dtmf_duration(uint32_t duration)
void switch_channel_global_init(switch_memory_pool_t *pool)
int32_t set_auto_priority(void)
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
static int switch_system_thread(const char *cmd, switch_bool_t wait)
switch_dbtype_t odbc_dbtype
void switch_nat_init(switch_memory_pool_t *pool, switch_bool_t mapping)
Initilize the NAT Traversal System.
uint16_t switch_core_get_rtp_port_range_end_port()
Get RTP port range end value.
#define SWITCH_PATH_SEPARATOR
switch_status_t switch_threadattr_detach_set(switch_threadattr_t *attr, int32_t on)
double switch_core_idle_cpu(void)
int32_t sessions_peak_fivemin
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)
static void *SWITCH_THREAD_FUNC switch_core_service_thread(switch_thread_t *thread, void *obj)
switch_byte_t switch_byte_t * buf
switch_status_t switch_core_get_variables(switch_event_t **event)
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
switch_bool_t colorize_console
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.
void switch_stun_random_string(char *buf, uint16_t len, char *set)
Writes random characters into a buffer.
static char main_ip6[256]
static switch_bool_t switch_string_var_check(char *s, switch_bool_t disable)
char * switch_core_get_uuid(void)
Retrieve the unique identifier from the core.
switch_bool_t switch_testv6_subnet(ip_t _ip, ip_t _net, ip_t _mask)
switch_mutex_t * frame_read_mutex
#define SWITCH_MAX_DTMF_DURATION
void switch_time_set_matrix(switch_bool_t enable)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
switch_core_flag_t switch_core_flags(void)
return core flags
void switch_core_thread_session_end(switch_core_session_t *session)
void switch_core_session_uninit(void)
switch_log_level_t switch_log_str2level(_In_z_ const char *str)
Return the level number of the specified log level name.
void switch_core_setrlimits(void)
void switch_core_session_hupall(_In_ switch_call_cause_t cause)
Hangup all sessions.
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Abstract interface to a management module.
#define SWITCH_THREAD_STACKSIZE
#define SWITCH_SYSTEM_THREAD_STACKSIZE
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
void switch_core_memory_reclaim_all(void)
switch_port_t switch_rtp_set_end_port(switch_port_t port)
Set/Get RTP end port.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
int32_t set_normal_priority(void)
Set the maximum priority the process can obtain.
unsigned long switch_atoul(const char *nptr)
static void load_mime_types(void)
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
void switch_core_sqldb_resume(void)
switch_status_t switch_console_init(switch_memory_pool_t *pool)
char * switch_network_ipv4_mapped_ipv6_addr(const char *ip_str)
static switch_ip_list_t IP_LIST
switch_bool_t switch_odbc_available(void)
switch_hash_t * mime_type_exts
static void send_heartbeat(void)
An abstraction of a data frame.
void switch_core_set_variable(const char *varname, const char *value)
uint32_t db_handle_timeout
FILE * switch_core_data_channel(switch_text_channel_t channel)
Retrieve a FILE stream of a given text channel name.
switch_size_t switch_fp_read_dline(FILE *fd, char **buf, switch_size_t *len)
int switch_inet_pton(int af, const char *src, void *dst)
void switch_core_runtime_loop(int bg)
Run endlessly until the system is shutdown.
switch_mutex_t * session_hash_mutex
#define SWITCH_STANDARD_STREAM(s)
uint32_t switch_core_session_count(void)
Provide the total number of sessions.
double switch_core_min_idle_cpu(double new_limit)
void switch_nat_late_init(void)
Initilize the rest of the NAT Traversal System.
static void handle_SIGHUP(int sig)
static char main_ip4[256]
static switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id)
static int switch_system_fork(const char *cmd, switch_bool_t wait)
void * objs[SWITCH_MAX_CORE_THREAD_SESSION_OBJS]
void switch_core_memory_reclaim_events(void)
switch_status_t switch_xml_destroy(void)
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
int32_t set_realtime_priority(void)
switch_status_t switch_log_shutdown(void)
Shut down the logging engine.
switch_mutex_t * global_mutex
void switch_rtp_shutdown(void)
void switch_core_sqldb_pause(void)
void switch_cache_db_flush_handles(void)
switch_status_t switch_thread_cond_signal(switch_thread_cond_t *cond)
#define SWITCH_SOUNDS_DIR
switch_hash_t * mime_types
#define SWITCH_DEFAULT_DIR_PERMS
uint32_t max_dtmf_duration
switch_bool_t switch_core_set_var_conditional(const char *varname, const char *value, const char *val2)
uint32_t switch_core_default_dtmf_duration(uint32_t duration)
void switch_uuid_format(char *buffer, const switch_uuid_t *uuid)
char * switch_core_get_variable_pdup(const char *varname, switch_memory_pool_t *pool)
uint32_t switch_core_session_limit(_In_ uint32_t new_limit)
Set/Get Session Limit.
#define SWITCH_MIN_DTMF_DURATION
void switch_time_set_monotonic(switch_bool_t enable)
struct apr_thread_mutex_t switch_mutex_t
static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj)
switch_status_t
Common return values.
char * switch_string_replace(const char *string, const char *search, const char *replace)
switch_xml_t switch_xml_open_cfg(_In_z_ const char *file_path, _Out_ switch_xml_t *node, _In_opt_ switch_event_t *params)
open a config in the core registry
const char * switch_core_get_hostname(void)
#define SWITCH_GRAMMAR_DIR
#define SWITCH_SCRIPT_DIR
switch_status_t switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
void switch_console_save_history(void)
static void switch_core_unset_variables(void)
void *SWITCH_THREAD_FUNC * switch_thread_start_t(switch_thread_t *, void *)
void switch_core_sqldb_stop(void)
switch_status_t switch_core_hash_init_case(_Out_ switch_hash_t **hash, switch_bool_t case_sensitive)
Initialize a hash table.
#define switch_core_hash_insert(_h, _k, _d)
struct apr_thread_t switch_thread_t
#define SWITCH_LOCALSTATE_DIR
switch_log_level_t hard_log_level
void switch_time_calibrate_clock(void)
uint32_t default_dtmf_duration
#define SWITCH_SEQ_DEFAULT_COLOR
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
switch_bool_t switch_core_ready_outbound(void)
Determines if the core is ready to place outbound calls.
const char * switch_core_banner(void)
void switch_core_recovery_flush(const char *technology, const char *profile_name)
switch_filenames SWITCH_GLOBAL_filenames
void switch_uuid_get(switch_uuid_t *uuid)
#define switch_event_get_header(_e, _h)
switch_time_t switch_mono_micro_time_now(void)
#define switch_channel_set_flag(_c, _f)
switch_xml_t switch_xml_child(_In_ switch_xml_t xml, _In_z_ const char *name)
returns the first child tag (one level deeper) with the given name or NULL \ if not found ...
switch_status_t switch_core_init(switch_core_flag_t flags, switch_bool_t console, const char **err)
SWITCH_STANDARD_SCHED_FUNC(heartbeat_callback)
switch_directories SWITCH_GLOBAL_dirs
#define switch_set_string(_dst, _src)
void switch_time_set_use_system_time(switch_bool_t enable)
int switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream)
char * core_db_pre_trans_execute
uint32_t port_alloc_flags
static const char * skip(const char *in)
void switch_time_set_cond_yield(switch_bool_t enable)
const char * switch_core_mime_ext2type(const char *ext)
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
switch_bool_t switch_check_network_list_ip_token(const char *ip_str, const char *list_name, const char **token)
switch_status_t switch_loadable_module_init(switch_bool_t autoload)
Initilize the module backend and load all the modules.
A generic object to pass as a thread's session object to allow mutiple arguements and a pool...
switch_mutex_t * uuid_mutex
char * switch_core_get_variable(const char *varname)
uint32_t switch_core_debug_level(void)
struct apr_pool_t switch_memory_pool_t
switch_status_t switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, switch_memory_pool_t *pool)
switch_memory_pool_t * memory_pool
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
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_log_init(_In_ switch_memory_pool_t *pool, _In_ switch_bool_t colorize)
Initilize the logging engine.
switch_status_t switch_core_management_exec(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
Execute a management operation.
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)
switch_status_t switch_console_execute(char *xcmd, int rec, switch_stream_handle_t *istream)
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
FILE * switch_core_get_console(void)
Get the output console.
void switch_load_network_lists(switch_bool_t reload)
char * switch_core_get_variable_dup(const char *varname)
void switch_event_destroy(switch_event_t **event)
Destroy an event.
int32_t switch_core_set_process_privileges(void)
Switch on the privilege awareness for the process and request required privileges.
void switch_core_service_session_av(switch_core_session_t *session, switch_bool_t audio, switch_bool_t video)
switch_status_t(* management_function)(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
uint32_t cpu_idle_smoothing_depth
void switch_core_memory_reclaim(void)
const char * switch_version_revision_human(void)
int32_t switch_core_session_ctl(switch_session_ctl_t cmd, void *val)
send a control message to the core
char * core_db_inner_pre_trans_execute
int multiple_registrations
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
void switch_curl_init(void)
int switch_core_recovery_recover(const char *technology, const char *profile_name)
void switch_core_remove_state_handler(const switch_state_handler_table_t *state_handler)
void switch_core_state_machine_init(switch_memory_pool_t *pool)
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
switch_bool_t switch_core_ready_inbound(void)
Determines if the core is ready to take inbound calls.
#define switch_core_hash_first(_h)
switch_bool_t switch_core_ready(void)
Determines if the core is ready to take calls.
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)
void switch_console_loop(void)
A simple comand loop that reads input from the terminal.
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]
void switch_core_measure_time(switch_time_t total_ms, switch_core_time_duration_t *duration)
Breakdown a number of milliseconds into various time spec.
switch_thread_t * switch_core_launch_thread(switch_thread_start_t func, void *obj, switch_memory_pool_t *pool)
#define SWITCH_SIZE_T_FMT
void switch_ssl_destroy_ssl_locks(void)
void switch_core_screen_size(int *x, int *y)
switch_management_action_t
switch_event_header_t * headers
uint32_t switch_default_rate(const char *name, uint32_t number)
switch_status_t switch_xml_init(_In_ switch_memory_pool_t *pool, _Out_ const char **err)
initilize the core XML backend
void switch_core_session_launch_thread(_In_ switch_core_session_t *session, _In_ void *(*func)(switch_thread_t *, void *), _In_opt_ void *obj)
Launch a thread designed to exist within the scope of a given session.
switch_memory_pool_t * pool
switch_status_t switch_core_set_console(const char *console)
Set the output console to the desired file.
switch_status_t switch_threadattr_priority_set(switch_threadattr_t *attr, switch_thread_priority_t priority)