[0] | 1 | //roard.c: |
---|
| 2 | |
---|
[668] | 3 | /* |
---|
[5381] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2012 |
---|
[668] | 5 | * |
---|
| 6 | * This file is part of roard a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[668] | 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
[4924] | 26 | /* ckport options: |
---|
| 27 | * Stuff checked by configure: |
---|
| 28 | * ckport: ignore-symbol: getuid of target win32 |
---|
| 29 | * ckport: ignore-symbol: setuid of target win32 |
---|
| 30 | * ckport: ignore-symbol: getgid of target win32 |
---|
| 31 | * ckport: ignore-symbol: setgid of target win32 |
---|
| 32 | * ckport: ignore-symbol: setsid of target win32 |
---|
| 33 | * ckport: ignore-symbol: kill of target win32 |
---|
| 34 | * ckport: ignore-symbol: chroot of target win32 |
---|
| 35 | * ckport: ignore-symbol: fork of target win32 |
---|
| 36 | * ckport: ignore-symbol: getservbyname of target win32 |
---|
| 37 | * ckport: ignore-symbol: nice of target win32 |
---|
| 38 | * |
---|
| 39 | */ |
---|
| 40 | |
---|
[0] | 41 | #include "roard.h" |
---|
| 42 | |
---|
[4722] | 43 | enum action { |
---|
| 44 | START, |
---|
| 45 | STOP, |
---|
| 46 | RESTART, |
---|
| 47 | RESTART_RETRY, |
---|
| 48 | SHUTDOWN |
---|
| 49 | }; |
---|
| 50 | |
---|
[4788] | 51 | enum af_mode { |
---|
| 52 | AF_MODE_NONE, |
---|
| 53 | AF_MODE_LOAD, |
---|
| 54 | AF_MODE_GEN |
---|
| 55 | }; |
---|
| 56 | |
---|
[5192] | 57 | // some stuff we only define extern globally. |
---|
[5194] | 58 | int g_verbose = ROAR_DBG_INFO_NONE; |
---|
| 59 | |
---|
[5192] | 60 | int alive; |
---|
| 61 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 62 | int g_no_listen; |
---|
| 63 | #endif |
---|
| 64 | |
---|
[5414] | 65 | uint32_t g_pos; // current position in output stream |
---|
[5192] | 66 | |
---|
| 67 | int g_standby; |
---|
| 68 | int g_autostandby; |
---|
| 69 | |
---|
| 70 | struct roard_listen g_listen[ROAR_MAX_LISTEN_SOCKETS]; |
---|
| 71 | |
---|
| 72 | int g_self_client; |
---|
| 73 | |
---|
| 74 | int g_terminate; |
---|
| 75 | |
---|
| 76 | struct roar_audio_info * g_sa, * g_max_sa; |
---|
[5194] | 77 | |
---|
| 78 | struct roard_config * g_config; |
---|
| 79 | |
---|
| 80 | struct counters g_counters; |
---|
[5192] | 81 | // end of extern block. |
---|
| 82 | |
---|
[1494] | 83 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[4967] | 84 | static char * server[ROAR_MAX_LISTEN_SOCKETS]; |
---|
[1494] | 85 | #endif |
---|
[60] | 86 | |
---|
[2104] | 87 | #if defined(ROAR_HAVE_IO_POSIX) && defined(ROAR_HAVE_FS_POSIX) |
---|
| 88 | #define SUPPORT_PIDFILE |
---|
[4967] | 89 | static char * pidfile = NULL; |
---|
[2104] | 90 | #endif |
---|
| 91 | |
---|
[2530] | 92 | #if defined(ROAR_HAVE_SETGID) || defined(ROAR_HAVE_SETUID) |
---|
[4967] | 93 | static int setids = 0; |
---|
[3374] | 94 | #endif |
---|
| 95 | |
---|
| 96 | #ifdef ROAR_HAVE_LIBX11 |
---|
[4967] | 97 | static char * x11display = NULL; |
---|
[2530] | 98 | #endif |
---|
| 99 | |
---|
[4324] | 100 | void dbg_notify_cb(struct roar_notify_core * core, struct roar_event * event, void * userdata) { |
---|
| 101 | char buf[1024] = ""; |
---|
[4338] | 102 | char estr[1024] = "/* ROAR_??? */"; |
---|
| 103 | char ttstr[1024] = "/* ROAR_OT_??? */"; |
---|
| 104 | const char * ttname; |
---|
| 105 | uint32_t ev = ROAR_EVENT_GET_TYPE(event); |
---|
| 106 | int i; |
---|
| 107 | |
---|
| 108 | ttname = roar_ot2str(event->target_type); |
---|
| 109 | if ( ttname != NULL ) { |
---|
| 110 | snprintf(ttstr, sizeof(ttstr)-1, "/* ROAR_OT_%s */", ttname); |
---|
| 111 | buf[sizeof(ttstr)-1] = 0; |
---|
| 112 | for (i = 0; ttstr[i] != 0; i++) |
---|
| 113 | if ( islower(ttstr[i]) ) |
---|
| 114 | ttstr[i] = toupper(ttstr[i]); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | if ( ev == ROAR_NOTIFY_SPECIAL ) { |
---|
| 118 | snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_SPECIAL */"); |
---|
| 119 | } else if ( ROAR_NOTIFY_IS_CMD(ev) ) { |
---|
[4345] | 120 | if ( command_get_name(ROAR_NOTIFY_EVENT2CMD(ev), &ttname) == -1 ) { |
---|
[5210] | 121 | snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_CMD2EVENT(%lu) */", (long unsigned int)ROAR_NOTIFY_EVENT2CMD(ev)); |
---|
[4345] | 122 | } else { |
---|
| 123 | snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_CMD2EVENT(ROAR_CMD_%s) */", ttname); |
---|
| 124 | for (i = 0; estr[i] != 0; i++) |
---|
| 125 | if ( islower(estr[i]) ) |
---|
| 126 | estr[i] = toupper(estr[i]); |
---|
| 127 | } |
---|
[4338] | 128 | } else if ( ROAR_NOTIFY_IS_EGRP(ev) ) { |
---|
[5210] | 129 | snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_EGRP2EVENT(%lu) */", (long unsigned int)ROAR_NOTIFY_EVENT2EGRP(ev)); |
---|
[4338] | 130 | } else if ( ROAR_NOTIFY_IS_OE(ev) ) { |
---|
| 131 | switch (ev) { |
---|
[4418] | 132 | // OE basics: |
---|
[4338] | 133 | case ROAR_OE_BASICS_CHANGE_STATE: |
---|
| 134 | snprintf(estr, sizeof(estr)-1, "/* ROAR_OE_BASICS_CHANGE_STATE */"); |
---|
| 135 | break; |
---|
| 136 | case ROAR_OE_BASICS_CHANGE_FLAGS: |
---|
| 137 | snprintf(estr, sizeof(estr)-1, "/* ROAR_OE_BASICS_CHANGE_FLAGS */"); |
---|
| 138 | break; |
---|
[4345] | 139 | case ROAR_OE_BASICS_NEW: |
---|
| 140 | snprintf(estr, sizeof(estr)-1, "/* ROAR_OE_BASICS_NEW */"); |
---|
| 141 | break; |
---|
| 142 | case ROAR_OE_BASICS_DELETE: |
---|
| 143 | snprintf(estr, sizeof(estr)-1, "/* ROAR_OE_BASICS_DELETE */"); |
---|
| 144 | break; |
---|
[4418] | 145 | // OE Streams: |
---|
| 146 | case ROAR_OE_STREAM_CHANGE_VOLUME: |
---|
| 147 | snprintf(estr, sizeof(estr)-1, "/* ROAR_OE_STREAM_CHANGE_VOLUME */"); |
---|
| 148 | break; |
---|
| 149 | case ROAR_OE_STREAM_XRUN: |
---|
| 150 | snprintf(estr, sizeof(estr)-1, "/* ROAR_OE_STREAM_XRUN */"); |
---|
| 151 | break; |
---|
[4842] | 152 | case ROAR_OE_STREAM_META_UPDATE: |
---|
| 153 | snprintf(estr, sizeof(estr)-1, "/* ROAR_OE_STREAM_META_UPDATE */"); |
---|
| 154 | break; |
---|
[4418] | 155 | // OE Default: |
---|
[4338] | 156 | default: |
---|
[5210] | 157 | snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_OE2EVENT(%lu) */", (long unsigned int)ROAR_NOTIFY_EVENT2OE(ev)); |
---|
[4338] | 158 | break; |
---|
| 159 | } |
---|
| 160 | } else if ( ROAR_NOTIFY_IS_USER(ev) ) { |
---|
[5210] | 161 | snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_USER2EVENT(%lu) */", (long unsigned int)ROAR_NOTIFY_EVENT2USER(ev)); |
---|
[4338] | 162 | } |
---|
| 163 | |
---|
| 164 | buf[sizeof(estr)-1] = 0; |
---|
[4324] | 165 | |
---|
| 166 | if ( event->flags & ROAR_EVENT_FLAG_PROXYEVENT ) { |
---|
[4338] | 167 | snprintf(buf, sizeof(buf)-1, ".event_proxy=0x%.8x%s, ", (int)event->event_proxy, estr); |
---|
[4324] | 168 | buf[sizeof(buf)-1] = 0; |
---|
| 169 | } |
---|
| 170 | |
---|
[4418] | 171 | ROAR_INFO("dbg_notify_cb(core=%p, event=%p{.flags=0x%.8x, event=0x%.8x%s, %s.emitter=%i, .target=%i, .target_type=%i%s, .arg0=%i, .arg1=%i, .arg2=%p}, userdata=%p) = (void)", |
---|
| 172 | 0 /* always print: minlevel = 0 */, |
---|
[4324] | 173 | core, event, |
---|
| 174 | (int)event->flags, |
---|
| 175 | (int)event->event, |
---|
[4338] | 176 | (event->flags & ROAR_EVENT_FLAG_PROXYEVENT ? "" : estr), |
---|
[4324] | 177 | buf, |
---|
| 178 | event->emitter, |
---|
| 179 | event->target, |
---|
| 180 | event->target_type, |
---|
[4338] | 181 | ttstr, |
---|
[4324] | 182 | event->arg0, |
---|
| 183 | event->arg1, |
---|
| 184 | event->arg2, |
---|
| 185 | userdata); |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | void dbg_notify_cb_register (void) { |
---|
| 189 | struct roar_event event; |
---|
| 190 | |
---|
| 191 | memset(&event, 0, sizeof(event)); |
---|
| 192 | |
---|
| 193 | event.event = ROAR_EGRP_ANY_EVENT; |
---|
| 194 | |
---|
| 195 | event.emitter = -1; |
---|
| 196 | event.target = -1; |
---|
| 197 | event.target_type = -1; |
---|
| 198 | |
---|
| 199 | roar_notify_core_subscribe(NULL, &event, dbg_notify_cb, NULL); |
---|
| 200 | } |
---|
| 201 | |
---|
[1503] | 202 | #ifdef ROAR_HAVE_MAIN_ARGS |
---|
[0] | 203 | void usage (void) { |
---|
| 204 | printf("Usage: roard [OPTIONS]...\n\n"); |
---|
| 205 | |
---|
[68] | 206 | printf("Misc Options:\n\n"); |
---|
| 207 | printf( |
---|
[5060] | 208 | #if defined(ROAR_HAVE_FORK) || defined(ROAR_TARGET_WIN32) |
---|
[775] | 209 | " --daemon - Bring the server into background after init\n" |
---|
[5060] | 210 | #endif |
---|
[2970] | 211 | " --verbose - Be more verbose, can be used multiple times\n" |
---|
[71] | 212 | " --terminate - Terminate after last client quited\n" |
---|
[2109] | 213 | " --start - No op parameter (starting roard is default operation)\n" |
---|
[274] | 214 | " --restart - Trys to stop an old instance and start a new with new settings\n" |
---|
[2109] | 215 | " --stop - Stops a running roard (provide --pidfile!)\n" |
---|
| 216 | " --shutdown - Terminates a running roard (provide --pidfile!)\n" |
---|
[276] | 217 | " --realtime - Trys to get realtime priority,\n" |
---|
| 218 | " give multible times for being more realtime\n" |
---|
[4245] | 219 | " --memlock LEVEL - Set default memory locking level to LEVEL\n" |
---|
[4924] | 220 | #ifdef ROAR_HAVE_CHROOT |
---|
[444] | 221 | " --chroot DIR - chroots to the given dir\n" |
---|
[4924] | 222 | #endif |
---|
| 223 | #ifdef ROAR_HAVE_SETGID |
---|
[444] | 224 | " --setgid - GroupID to the audio group as specified via -G\n" |
---|
[4924] | 225 | #endif |
---|
| 226 | #ifdef ROAR_HAVE_SETUID |
---|
[444] | 227 | " --setuid - UserID to the audio user as specified via -U\n" |
---|
[4924] | 228 | #endif |
---|
[905] | 229 | " --sysclocksync - calculate exact sample rate using the system clock\n" |
---|
[2017] | 230 | " --location LOC - Set lion readable location of server\n" |
---|
[4421] | 231 | " --description DESC - Set lion readable description of server\n" |
---|
[5279] | 232 | " --contact CONTACT - Set contact for this server\n" |
---|
| 233 | " --serial SERIAL - Set serial for this device or server\n" |
---|
| 234 | " (for embedded devices only)\n" |
---|
| 235 | " --uiurl UIURL - Set URL for userinterface of this device or server\n" |
---|
| 236 | " (for embedded devices only)\n" |
---|
[2104] | 237 | #ifdef SUPPORT_PIDFILE |
---|
| 238 | " --pidfile PIDFILE - Write a pidfile at PIDFILE\n" |
---|
| 239 | #endif |
---|
[3688] | 240 | #ifdef ROAR_HAVE_SYSLOG |
---|
| 241 | " --log-syslog - Log Warnings, Errors, ... to syslog\n" |
---|
| 242 | #endif |
---|
[4851] | 243 | #ifdef ROAR_HAVE_SYSTEM |
---|
| 244 | " --script-postdown S - Run command lion S after complet shutdown.\n" |
---|
| 245 | #endif |
---|
[68] | 246 | ); |
---|
| 247 | |
---|
[4482] | 248 | printf("\nAuth Options:\n\n"); |
---|
| 249 | printf( |
---|
[5146] | 250 | " --guest-acclev ACCLEV - Sets the access level for guest access to ACCLEV,\n" |
---|
| 251 | " Use \"none\" to disable guest access.\n" |
---|
[4482] | 252 | " --trust-acclev ACCLEV - Sets the access level for trust-authed\n" |
---|
[5146] | 253 | " connections to ACCLEV. Use \"none\" to disable trust auth.\n" |
---|
[4482] | 254 | " --trust-root - Trust root user\n" |
---|
| 255 | " --no-trust-root - Don't trust root user\n" |
---|
[4788] | 256 | " --authfile-gen FILE - Generate an new authfile\n" |
---|
[4792] | 257 | " --authfile-load FILE - Load an authfile\n" |
---|
[4788] | 258 | " --authfile-type TYPE - Type of authfile\n" |
---|
| 259 | " --authfile-acclev ACCLEV\n" |
---|
| 260 | " - Sets the access level for authfile\n" |
---|
[4789] | 261 | " --new-authfile - Parameters for new authfile follow\n" |
---|
[4482] | 262 | ); |
---|
| 263 | |
---|
[3356] | 264 | printf("\nPlugin Options:\n\n"); |
---|
| 265 | printf( |
---|
| 266 | " --plugin-load FILE - Load plugin FILE\n" |
---|
[5275] | 267 | " --plugin-args ARGS - Arguments for the plugin\n" |
---|
| 268 | " (must be given before the --plugin-load)\n" |
---|
[3356] | 269 | ); |
---|
| 270 | |
---|
[68] | 271 | printf("\nAudio Options:\n\n"); |
---|
[0] | 272 | printf( |
---|
| 273 | " -R --rate RATE - Set server rate\n" |
---|
| 274 | " -B --bits BITS - Set server bits\n" |
---|
| 275 | " -C --chans CHANNELS - Set server channels\n" |
---|
[3963] | 276 | " --aiprofile PROFILE - Use the given audio profile\n" |
---|
[0] | 277 | ); |
---|
| 278 | |
---|
[2339] | 279 | printf("\nStream Options:\n\n"); |
---|
| 280 | printf( |
---|
| 281 | " --stream-flags D=F - Set default flags for stream directions\n" |
---|
[4012] | 282 | " D is the stream direction and F is a comma separated\n" |
---|
[2339] | 283 | " list of flags in form +flag or -flag to set or unset\n" |
---|
| 284 | " a flag as default or remove it from the default\n" |
---|
| 285 | ); |
---|
[4934] | 286 | printf("\nStream Options:\n\n"); |
---|
| 287 | printf( |
---|
| 288 | " --list-rolestack - Show the current role stack\n" |
---|
| 289 | " --rolestack-push R:A - Add a rule for role R with action A on top\n" |
---|
| 290 | " of the role stack.\n" |
---|
| 291 | ); |
---|
[2339] | 292 | |
---|
[932] | 293 | printf("\nOutput Options:\n\n"); |
---|
[974] | 294 | printf(" -o --odriver DRV - Set the driver, use '--list-driver' to get a list\n"); |
---|
[932] | 295 | printf(" -O --odevice DEV - Set the device\n"); |
---|
| 296 | printf(" -oO OPTS - Set output options\n"); |
---|
| 297 | printf(" -oN - Adds another output\n"); |
---|
[961] | 298 | printf(" -oP - Mark output as primary\n"); |
---|
[4225] | 299 | #ifdef ROAR_DRIVER_DEFAULT |
---|
| 300 | printf(" --list-driver - List all drivers (default driver: %s)\n", ROAR_DRIVER_DEFAULT); |
---|
| 301 | #else |
---|
| 302 | printf(" --list-driver - List all drivers (default driver: (autodetect))\n"); |
---|
| 303 | #endif |
---|
[932] | 304 | |
---|
[2485] | 305 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[0] | 306 | printf("\nSource Options:\n\n"); |
---|
| 307 | printf(" -s --source DRV - Use DRV as input driver\n" |
---|
| 308 | " -S DEV - Use DEV as input device\n" |
---|
| 309 | " -sO OPTS - Use OPTS as input options\n" |
---|
[1512] | 310 | " -sN - Adds another source\n" |
---|
[0] | 311 | " -sP - Make souce as primary\n" |
---|
| 312 | ); |
---|
[2270] | 313 | printf(" --list-sources - List all sources\n"); |
---|
[2485] | 314 | #endif |
---|
[0] | 315 | |
---|
[4358] | 316 | #ifndef ROAR_WITHOUT_DCOMP_MIXER |
---|
| 317 | printf("\nHardware Mixer Options:\n\n"); |
---|
| 318 | printf(" -m --mixer DRV - Use DRV as mixer driver\n" |
---|
| 319 | " -M DEV - Use DEV as mixer device\n" |
---|
| 320 | " -mO OPTS - Use OPTS as mixer options\n" |
---|
| 321 | " -mN - Adds another mixer\n" |
---|
| 322 | " -mP - Make mixer as primary\n" |
---|
| 323 | ); |
---|
| 324 | printf(" --list-mixers - List all mixers\n"); |
---|
| 325 | #endif |
---|
| 326 | |
---|
[280] | 327 | printf("\nCodec Filter Options:\n\n"); |
---|
| 328 | printf(" --list-cf - List all codec filter\n" |
---|
| 329 | ); |
---|
[0] | 330 | |
---|
[2500] | 331 | #ifndef ROAR_WITHOUT_DCOMP_MIDI |
---|
[1923] | 332 | printf("\nMIDI Options:\n\n"); |
---|
[1924] | 333 | printf(" --midi-no-console - Disable console based MIDI synth\n" |
---|
[2444] | 334 | " --midi-console-enable - Enables the console based MIDI synth\n" |
---|
[1924] | 335 | " --midi-console DEV - Set device for MIDI console\n" |
---|
[2489] | 336 | #ifndef ROAR_WITHOUT_DCOMP_SSYNTH |
---|
[2451] | 337 | " --ssynth-enable - Enable simple software synth\n" |
---|
| 338 | " --ssynth-disable - Disable simple software synth\n" |
---|
[2489] | 339 | #endif |
---|
[1924] | 340 | ); |
---|
[2500] | 341 | #endif |
---|
[1923] | 342 | |
---|
[2494] | 343 | #ifndef ROAR_WITHOUT_DCOMP_LIGHT |
---|
[1923] | 344 | printf("\nLight Control Options:\n\n"); |
---|
| 345 | printf(" --light-channels NUM - Sets the number of channels for Light control (default: %i)\n", |
---|
| 346 | LIGHT_CHANNELS_DEFAULT |
---|
| 347 | ); |
---|
[2494] | 348 | #endif |
---|
[1923] | 349 | |
---|
[2725] | 350 | #ifndef ROAR_WITHOUT_DCOMP_RDTCS |
---|
[3339] | 351 | printf("\nRadio Data and Transmitter Control System Options:\n\n"); |
---|
[2725] | 352 | printf(" --rds-pi PI - Sets the RDS Programme Identification (PI)\n" |
---|
| 353 | " --rds-ps PS - Sets the RDS Programme Service Name (PS)\n" |
---|
| 354 | " --rds-pty PTY - Sets the RDS Programme Type (PTY)\n" |
---|
| 355 | " --rds-tp - Sets the RDS Traffic Programme (TP) flag\n" |
---|
| 356 | " --rds-ct - Enables sending of RDS Clock Time (CT)\n" |
---|
| 357 | ); |
---|
| 358 | #endif |
---|
| 359 | |
---|
[3374] | 360 | #ifdef ROAR_HAVE_LIBX11 |
---|
| 361 | printf("\nX11 Options:\n\n"); |
---|
| 362 | printf( |
---|
| 363 | " --x11-display DISPLAY - Set display for X11\n" |
---|
| 364 | " --display DISPLAY - Set display for X11\n" |
---|
| 365 | ); |
---|
| 366 | #endif |
---|
| 367 | |
---|
[0] | 368 | printf("\nServer Options:\n\n"); |
---|
| 369 | printf(" -t --tcp - Use TCP listen socket\n" |
---|
[3992] | 370 | #ifdef ROAR_HAVE_UNIX |
---|
[0] | 371 | " -u --unix - Use UNIX Domain listen socket (default)\n" |
---|
[3992] | 372 | #endif |
---|
[508] | 373 | #ifdef ROAR_HAVE_LIBDNET |
---|
| 374 | " -n --decnet - use DECnet listen socket\n" |
---|
| 375 | #endif |
---|
[518] | 376 | " -4 - Use IPv4 connections (implies -t)\n" |
---|
[3837] | 377 | #ifdef AF_INET6 |
---|
[518] | 378 | " -6 - Use IPv6 connections (implies -t)\n" |
---|
| 379 | #endif |
---|
| 380 | #ifdef IPV6_ADDRFORM |
---|
| 381 | " -64 - Try to downgrade sockets from IPv6 into IPv4,\n" |
---|
[4012] | 382 | " this is normaly not useful.\n" |
---|
[518] | 383 | #endif |
---|
[0] | 384 | " -p --port - TCP Port to bind to\n" |
---|
| 385 | " -b --bind - IP/Hostname to bind to\n" |
---|
[1115] | 386 | " --sock - Filename for UNIX Domain Socket\n" |
---|
[2530] | 387 | " --proto PROTO - Use PROTO as protocol on Socket\n" |
---|
[3252] | 388 | " --proto-dir DIR - Set direction parameter for protocol\n" |
---|
| 389 | " --proto-rate RATE - Set sample rate parameter for protocol\n" |
---|
| 390 | " --proto-bits BITS - Set bits per sample parameter for protocol\n" |
---|
| 391 | " --proto-codec E - Set codec parameter for protocol\n" |
---|
[4012] | 392 | " --proto-chans C - Set number of channels parameter for protocol\n" |
---|
[3954] | 393 | " --proto-aiprofile PROFILE\n" |
---|
| 394 | " - Sets the audio profile for socket\n" |
---|
[3956] | 395 | " --proto-profile P - Set profile for listen socket\n" |
---|
[3127] | 396 | " --list-proto - List supported protocols\n" |
---|
[3956] | 397 | " --list-profiles - List supported profiles for --proto-profile\n" |
---|
[4882] | 398 | " --list-aiprofiles - List supported profiles for --proto-aiprofile\n" |
---|
[4789] | 399 | " --new-sock - Parameters for new socket follow\n" |
---|
[1993] | 400 | #ifdef ROAR_HAVE_LIBSLP |
---|
| 401 | " --slp - Enable OpenSLP support\n" |
---|
| 402 | #endif |
---|
[3373] | 403 | #ifdef ROAR_HAVE_LIBX11 |
---|
| 404 | " --x11 - Enable X11 support\n" |
---|
| 405 | #endif |
---|
[3039] | 406 | " --jumbo-mtu MTU - Sets the MTU for Jumbo Packets\n" |
---|
[450] | 407 | " -G GROUP - Sets the group for the UNIX Domain Socket, (default: %s)\n" |
---|
[2737] | 408 | " You need the permissions to change the GID\n" |
---|
[444] | 409 | " -U USER - Sets the user for the UNIX Domain Socket, (default: do not set)\n" |
---|
[2737] | 410 | " You need the permissions to change the UID (normaly only root has)\n" |
---|
[548] | 411 | " --no-listen - Do not listen for new clients\n" |
---|
[4012] | 412 | " (only useful for relaing, impleys --terminate)\n" |
---|
[274] | 413 | " --client-fh - Comunicate with a client over this handle\n" |
---|
[4012] | 414 | " (only useful for relaing)\n" |
---|
[920] | 415 | " --close-fh - Closes the given fh\n" |
---|
| 416 | " --standby - Start in standby state\n" |
---|
| 417 | " --auto-standby - Automatical goes into standby if there are no streams\n", |
---|
[2755] | 418 | #ifdef ROAR_DEFAULT_SOCKGRP |
---|
[450] | 419 | ROAR_DEFAULT_SOCKGRP |
---|
[2755] | 420 | #else |
---|
| 421 | "(none)" |
---|
| 422 | #endif |
---|
[0] | 423 | ); |
---|
| 424 | // printf("\n Options:\n\n"); |
---|
| 425 | printf("\n"); |
---|
| 426 | } |
---|
[3127] | 427 | |
---|
[1503] | 428 | #endif |
---|
[0] | 429 | |
---|
[5345] | 430 | |
---|
| 431 | struct counters * counters_getptr(void) { |
---|
| 432 | return &g_counters; |
---|
| 433 | } |
---|
| 434 | |
---|
[4101] | 435 | #define _pmsg(format, args...) roar_debug_msg(type, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
[5345] | 436 | #define _pmsgc(group, counter, name) _pmsg(" Counter %-10s: %llu", (name), (long long unsigned int)(counters->group.counter)) |
---|
[4101] | 437 | void counters_print(int type, int force) { |
---|
[5345] | 438 | struct counters * counters = counters_getptr(); |
---|
[4101] | 439 | if ( type != ROAR_DEBUG_TYPE_INFO || force || (ROAR_DBG_INFOVAR) >= ROAR_DBG_INFO_INFO ) { |
---|
| 440 | _pmsg("--- Counter Listing ---"); |
---|
| 441 | _pmsg(" Current:"); |
---|
| 442 | _pmsgc(cur, clients, "Clients"); |
---|
| 443 | _pmsgc(cur, streams, "Streams"); |
---|
| 444 | _pmsg(" Total:"); |
---|
| 445 | _pmsgc(sum, clients, "Clients"); |
---|
| 446 | _pmsgc(sum, streams, "Streams"); |
---|
| 447 | _pmsg("--- End of Counter Listing ---"); |
---|
| 448 | } |
---|
| 449 | } |
---|
| 450 | #undef _pmsgc |
---|
| 451 | #undef _pmsg |
---|
| 452 | |
---|
[5255] | 453 | int restart_server (const char * server, int terminate) { |
---|
[579] | 454 | struct roar_connection con; |
---|
[2111] | 455 | #ifdef ROAR_HAVE_KILL |
---|
| 456 | char buf[80]; |
---|
| 457 | ssize_t l; |
---|
| 458 | struct roar_vio_calls fh; |
---|
| 459 | pid_t pid; |
---|
| 460 | int ok; |
---|
| 461 | |
---|
[4055] | 462 | ROAR_INFO("restart_server(server='%s', terminate=%i): trying to restart server", ROAR_DBG_INFO_INFO, server, terminate); |
---|
| 463 | |
---|
[2111] | 464 | if ( pidfile != NULL ) { |
---|
[5257] | 465 | if ( roar_vio_open_dstr_simple(&fh, pidfile, O_RDONLY) ) { |
---|
[2111] | 466 | ROAR_WARN("restart_server(*): Can not read pidfile: %s", pidfile); |
---|
| 467 | } else { |
---|
| 468 | l = roar_vio_read(&fh, buf, 80); |
---|
| 469 | roar_vio_close(&fh); |
---|
| 470 | if ( l > 0 ) { |
---|
| 471 | buf[l-1] = 0; |
---|
| 472 | buf[79] = 0; |
---|
| 473 | pid = atoi(buf); |
---|
| 474 | if ( terminate ) { |
---|
[2113] | 475 | ok = kill(pid, SIGUSR1); |
---|
[2111] | 476 | } else { |
---|
| 477 | ok = kill(pid, SIGINT); |
---|
| 478 | } |
---|
| 479 | if ( ok == 0 ) { |
---|
| 480 | return 0; |
---|
| 481 | } else { |
---|
| 482 | ROAR_WARN("restart_server(*): Can not kill roard by pidfile"); |
---|
| 483 | } |
---|
| 484 | } else { |
---|
| 485 | ROAR_WARN("restart_server(*): Can not find a PID in the pidfile"); |
---|
| 486 | } |
---|
| 487 | } |
---|
| 488 | } |
---|
| 489 | #endif |
---|
[2109] | 490 | |
---|
[4722] | 491 | if ( roar_simple_connect(&con, server, "roard") == -1 ) { |
---|
[579] | 492 | return -1; |
---|
| 493 | } |
---|
| 494 | |
---|
[2109] | 495 | if ( roar_terminate(&con, terminate) == -1 ) { |
---|
[579] | 496 | return -1; |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | return roar_disconnect(&con); |
---|
| 500 | } |
---|
| 501 | |
---|
[444] | 502 | #define R_SETUID 1 |
---|
| 503 | #define R_SETGID 2 |
---|
| 504 | |
---|
[1609] | 505 | int init_config (void) { |
---|
| 506 | int i; |
---|
| 507 | |
---|
| 508 | memset(g_config, 0, sizeof(struct roard_config)); |
---|
| 509 | |
---|
| 510 | for (i = 0; i < ROAR_DIR_DIRIDS; i++) { |
---|
| 511 | g_config->streams[i].mixer_channels = 1; |
---|
| 512 | g_config->streams[i].mixer.rpg_mul = 1; |
---|
| 513 | g_config->streams[i].mixer.rpg_div = 1; |
---|
| 514 | g_config->streams[i].mixer.scale = 65535; |
---|
| 515 | g_config->streams[i].mixer.mixer[0] = g_config->streams[i].mixer.scale; |
---|
| 516 | } |
---|
| 517 | |
---|
[2291] | 518 | g_config->streams[ROAR_DIR_PLAY ].flags = ROAR_FLAG_META; |
---|
[2413] | 519 | g_config->streams[ROAR_DIR_OUTPUT ].flags = ROAR_FLAG_PASSMIXER; |
---|
[2264] | 520 | g_config->streams[ROAR_DIR_FILTER ].flags = ROAR_FLAG_SYNC; |
---|
[1899] | 521 | g_config->streams[ROAR_DIR_MIDI_OUT].flags = ROAR_FLAG_SYNC; |
---|
[2160] | 522 | g_config->streams[ROAR_DIR_BIDIR ].flags = ROAR_FLAG_ANTIECHO; |
---|
[1899] | 523 | |
---|
[4442] | 524 | g_config->location = CONF_DEF_STRING; |
---|
| 525 | g_config->description = CONF_DEF_STRING; |
---|
[5279] | 526 | g_config->contact = NULL; |
---|
| 527 | g_config->serial = NULL; |
---|
| 528 | g_config->uiurl = NULL; |
---|
[2017] | 529 | |
---|
[4245] | 530 | g_config->memlock_level = -1; |
---|
| 531 | |
---|
[4851] | 532 | #ifdef ROAR_HAVE_SYSTEM |
---|
| 533 | g_config->scripts.post_shutdown = NULL; |
---|
| 534 | #endif |
---|
| 535 | |
---|
[1609] | 536 | return 0; |
---|
| 537 | } |
---|
| 538 | |
---|
[2530] | 539 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 540 | int init_listening (void) { |
---|
| 541 | int i; |
---|
| 542 | |
---|
[3128] | 543 | memset(g_listen, 0, sizeof(g_listen)); |
---|
| 544 | |
---|
[2530] | 545 | for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) { |
---|
[3128] | 546 | g_listen[i].proto = ROAR_PROTO_ROARAUDIO; |
---|
[2530] | 547 | server[i] = NULL; |
---|
| 548 | } |
---|
| 549 | |
---|
| 550 | return 0; |
---|
| 551 | } |
---|
| 552 | |
---|
[3731] | 553 | int get_listen(struct roard_listen ** sock, char *** sockname) { |
---|
[3730] | 554 | int i; |
---|
| 555 | |
---|
| 556 | if ( sock == NULL ) |
---|
| 557 | return -1; |
---|
| 558 | |
---|
| 559 | for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) { |
---|
[3802] | 560 | if ( ! g_listen[i].used ) { |
---|
[3730] | 561 | server[i] = NULL; |
---|
[3731] | 562 | *sock = &(g_listen[i]); |
---|
[3730] | 563 | |
---|
[3733] | 564 | if ( sockname != NULL ) |
---|
[3730] | 565 | *sockname = &(server[i]); |
---|
[3733] | 566 | |
---|
| 567 | return 0; |
---|
[3730] | 568 | } |
---|
| 569 | } |
---|
| 570 | |
---|
| 571 | return -1; |
---|
| 572 | } |
---|
| 573 | |
---|
[3956] | 574 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 575 | static struct _listen_profile { |
---|
| 576 | const char * name; |
---|
| 577 | int type; |
---|
| 578 | int port; |
---|
| 579 | const char * sockaddr; |
---|
| 580 | int proto; |
---|
| 581 | int dir; |
---|
| 582 | const char * aiprofile; |
---|
| 583 | const char * desc; |
---|
| 584 | } _g_listen_profiles[] = { |
---|
| 585 | // RoarAudio: |
---|
[3992] | 586 | #ifdef ROAR_HAVE_UNIX |
---|
[4058] | 587 | {"roar-usock", ROAR_SOCKET_TYPE_UNIX, 0, "~/" ROAR_DEFAULT_SOCK_USER, |
---|
| 588 | ROAR_PROTO_ROARAUDIO, -1, NULL, |
---|
| 589 | "RoarAudio default user profile"}, |
---|
| 590 | {"roar-gsock", ROAR_SOCKET_TYPE_UNIX, 0, ROAR_DEFAULT_SOCK_GLOBAL, |
---|
| 591 | ROAR_PROTO_ROARAUDIO, -1, NULL, |
---|
| 592 | "RoarAudio default global profile"}, |
---|
[3992] | 593 | #endif |
---|
| 594 | #ifdef ROAR_HAVE_IPV4 |
---|
[4058] | 595 | {"roar-tcp", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_PORT, ROAR_DEFAULT_INET4_HOST, |
---|
| 596 | ROAR_PROTO_ROARAUDIO, -1, NULL, |
---|
| 597 | "RoarAudio local TCP profile"}, |
---|
| 598 | {"roar-tcp-pub", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_PORT, ROAR_NET_INET4_ANYHOST, |
---|
| 599 | ROAR_PROTO_ROARAUDIO, -1, NULL, |
---|
| 600 | "RoarAudio network TCP profile"}, |
---|
[3992] | 601 | #endif |
---|
[4760] | 602 | #ifdef ROAR_HAVE_IPV6 |
---|
[5096] | 603 | {"roar-tcp6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_PORT, ROAR_DEFAULT_INET6_HOST, |
---|
[4760] | 604 | ROAR_PROTO_ROARAUDIO, -1, NULL, |
---|
| 605 | "RoarAudio local TCP profile"}, |
---|
[5096] | 606 | {"roar-tcp-pub6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_PORT, ROAR_NET_INET6_ANYHOST, |
---|
[4760] | 607 | ROAR_PROTO_ROARAUDIO, -1, NULL, |
---|
| 608 | "RoarAudio network TCP profile"}, |
---|
| 609 | #endif |
---|
[3992] | 610 | #ifdef ROAR_HAVE_LIBDNET |
---|
[4058] | 611 | {"roar-dnet", ROAR_SOCKET_TYPE_DECNET, 0, ROAR_DEFAULT_LISTEN_OBJECT, |
---|
| 612 | ROAR_PROTO_ROARAUDIO, -1, NULL, |
---|
| 613 | "RoarAudio default DECnet"}, |
---|
[3992] | 614 | #endif |
---|
| 615 | #ifdef ROAR_HAVE_UNIX |
---|
[4810] | 616 | {"roar-abstract", ROAR_SOCKET_TYPE_UNKNOWN, 0, "+abstract", ROAR_PROTO_ROARAUDIO, -1, NULL, |
---|
[4058] | 617 | "RoarAudio abstract namespace profile"}, |
---|
[3992] | 618 | #endif |
---|
[3956] | 619 | |
---|
| 620 | // EsounD: |
---|
[3992] | 621 | #if !defined(ROAR_WITHOUT_DCOMP_EMUL_ESD) && defined(ROAR_HAVE_H_ESD) |
---|
| 622 | #ifdef ROAR_HAVE_UNIX |
---|
[4058] | 623 | {"esd-unix", ROAR_SOCKET_TYPE_UNIX, 0, ROAR_DEFAULT_ESD_GSOCK, |
---|
| 624 | ROAR_PROTO_ESOUND, -1, NULL, |
---|
| 625 | "EsounD default local profile"}, |
---|
[3992] | 626 | #endif |
---|
| 627 | #ifdef ROAR_HAVE_IPV4 |
---|
[4058] | 628 | {"esd-tcp", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_ESD_PORT, ROAR_NET_INET4_LOCALHOST, |
---|
| 629 | ROAR_PROTO_ESOUND, -1, NULL, |
---|
| 630 | "EsounD local TCP profile"}, |
---|
| 631 | {"esd-tcp-pub", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_ESD_PORT, ROAR_NET_INET4_ANYHOST, |
---|
| 632 | ROAR_PROTO_ESOUND, -1, NULL, |
---|
| 633 | "EsounD network TCP profile"}, |
---|
[3992] | 634 | #endif |
---|
[4760] | 635 | #ifdef ROAR_HAVE_IPV6 |
---|
[4761] | 636 | {"esd-tcp6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_ESD_PORT, ROAR_NET_INET6_LOCALHOST, |
---|
[4760] | 637 | ROAR_PROTO_ESOUND, -1, NULL, |
---|
| 638 | "EsounD local TCP profile"}, |
---|
[4761] | 639 | {"esd-tcp-pub6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_ESD_PORT, ROAR_NET_INET6_ANYHOST, |
---|
[4760] | 640 | ROAR_PROTO_ESOUND, -1, NULL, |
---|
| 641 | "EsounD network TCP profile"}, |
---|
| 642 | #endif |
---|
[3992] | 643 | #endif |
---|
[3956] | 644 | |
---|
| 645 | // RSound: |
---|
[3992] | 646 | #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND |
---|
| 647 | #ifdef ROAR_HAVE_UNIX |
---|
[4058] | 648 | {"rsound-unix", ROAR_SOCKET_TYPE_UNIX, 0, ROAR_DEFAULT_RSOUND_GSOCK, |
---|
| 649 | ROAR_PROTO_RSOUND, -1, NULL, |
---|
| 650 | "RSound default local profile"}, |
---|
[3992] | 651 | #endif |
---|
| 652 | #ifdef ROAR_HAVE_IPV4 |
---|
[4058] | 653 | {"rsound-tcp", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_RSOUND_PORT, ROAR_NET_INET4_LOCALHOST, |
---|
| 654 | ROAR_PROTO_RSOUND, -1, NULL, |
---|
| 655 | "RSound local TCP profile"}, |
---|
| 656 | {"rsound-tcp-pub", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_RSOUND_PORT, ROAR_NET_INET4_ANYHOST, |
---|
| 657 | ROAR_PROTO_RSOUND, -1, NULL, |
---|
| 658 | "RSound network TCP profile"}, |
---|
[3992] | 659 | #endif |
---|
[4760] | 660 | #ifdef ROAR_HAVE_IPV6 |
---|
[4761] | 661 | {"rsound-tcp6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_RSOUND_PORT, ROAR_NET_INET6_LOCALHOST, |
---|
[4760] | 662 | ROAR_PROTO_RSOUND, -1, NULL, |
---|
| 663 | "RSound local TCP profile"}, |
---|
[4761] | 664 | {"rsound-tcp-pub6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_RSOUND_PORT, ROAR_NET_INET6_ANYHOST, |
---|
[4760] | 665 | ROAR_PROTO_RSOUND, -1, NULL, |
---|
| 666 | "RSound network TCP profile"}, |
---|
| 667 | #endif |
---|
[3992] | 668 | #ifdef ROAR_HAVE_LIBDNET |
---|
[4058] | 669 | {"rsound-dnet", ROAR_SOCKET_TYPE_DECNET, 0, ROAR_DEFAULT_RSOUND_OBJECT, |
---|
| 670 | ROAR_PROTO_RSOUND, -1, NULL, |
---|
| 671 | "RSound DECnet profile"}, |
---|
[3992] | 672 | #endif |
---|
| 673 | #endif |
---|
[3957] | 674 | |
---|
| 675 | // PulseAudio Simple: |
---|
[3992] | 676 | #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE |
---|
| 677 | #ifdef ROAR_HAVE_IPV4 |
---|
[4058] | 678 | {"pas-play-tcp", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_PA_PORT, ROAR_NET_INET4_ANYHOST, |
---|
| 679 | ROAR_PROTO_SIMPLE, ROAR_DIR_PLAY, "default", |
---|
| 680 | "PulseAudio Simple TCP play profile"}, |
---|
| 681 | {"pas-mon-tcp", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_PA_PORT, ROAR_NET_INET4_ANYHOST, |
---|
| 682 | ROAR_PROTO_SIMPLE, ROAR_DIR_MONITOR, "default", |
---|
| 683 | "PulseAudio Simple TCP monitor profile"}, |
---|
[3992] | 684 | #endif |
---|
[4760] | 685 | #ifdef ROAR_HAVE_IPV6 |
---|
[4761] | 686 | {"pas-play-tcp6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_PA_PORT, ROAR_NET_INET6_ANYHOST, |
---|
[4760] | 687 | ROAR_PROTO_SIMPLE, ROAR_DIR_PLAY, "default", |
---|
| 688 | "PulseAudio Simple TCP play profile"}, |
---|
[4761] | 689 | {"pas-mon-tcp6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_PA_PORT, ROAR_NET_INET6_ANYHOST, |
---|
[4760] | 690 | ROAR_PROTO_SIMPLE, ROAR_DIR_MONITOR, "default", |
---|
| 691 | "PulseAudio Simple TCP monitor profile"}, |
---|
| 692 | #endif |
---|
[3992] | 693 | #endif |
---|
[3987] | 694 | |
---|
| 695 | // RPlay: |
---|
[3992] | 696 | #ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY |
---|
| 697 | #ifdef ROAR_HAVE_IPV4 |
---|
[4058] | 698 | {"rplay-tcp", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_RPLAY_PORT, ROAR_NET_INET4_LOCALHOST, |
---|
| 699 | ROAR_PROTO_RPLAY, -1, NULL, |
---|
| 700 | "RPlay local TCP profile"}, |
---|
| 701 | {"rplay-tcp-pub", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_RPLAY_PORT, ROAR_NET_INET4_ANYHOST, |
---|
| 702 | ROAR_PROTO_RPLAY, -1, NULL, |
---|
| 703 | "RPlay network TCP profile"}, |
---|
[3992] | 704 | #endif |
---|
[4760] | 705 | #ifdef ROAR_HAVE_IPV6 |
---|
[4761] | 706 | {"rplay-tcp6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_RPLAY_PORT, ROAR_NET_INET6_LOCALHOST, |
---|
[4760] | 707 | ROAR_PROTO_RPLAY, -1, NULL, |
---|
| 708 | "RPlay local TCP profile"}, |
---|
[4761] | 709 | {"rplay-tcp-pub6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_RPLAY_PORT, ROAR_NET_INET6_ANYHOST, |
---|
[4760] | 710 | ROAR_PROTO_RPLAY, -1, NULL, |
---|
| 711 | "RPlay network TCP profile"}, |
---|
| 712 | #endif |
---|
[3992] | 713 | #endif |
---|
[3987] | 714 | |
---|
[4710] | 715 | // Gopher: |
---|
| 716 | #ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER |
---|
[4760] | 717 | #ifdef ROAR_HAVE_IPV4 |
---|
[4710] | 718 | {"gopher-tcp", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_GOPHER_PORT, ROAR_NET_INET4_LOCALHOST, |
---|
| 719 | ROAR_PROTO_GOPHER, -1, NULL, |
---|
| 720 | "Gopher local TCP profile"}, |
---|
| 721 | {"gopher-tcp-pub", ROAR_SOCKET_TYPE_TCP, ROAR_DEFAULT_GOPHER_PORT, ROAR_NET_INET4_ANYHOST, |
---|
| 722 | ROAR_PROTO_GOPHER, -1, NULL, |
---|
| 723 | "Gopher network TCP profile"}, |
---|
| 724 | #endif |
---|
[4760] | 725 | #ifdef ROAR_HAVE_IPV6 |
---|
[4761] | 726 | {"gopher-tcp6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_GOPHER_PORT, ROAR_NET_INET6_LOCALHOST, |
---|
[4760] | 727 | ROAR_PROTO_GOPHER, -1, NULL, |
---|
| 728 | "Gopher local TCP profile"}, |
---|
[4761] | 729 | {"gopher-tcp-pub6", ROAR_SOCKET_TYPE_TCP6, ROAR_DEFAULT_GOPHER_PORT, ROAR_NET_INET6_ANYHOST, |
---|
[4760] | 730 | ROAR_PROTO_GOPHER, -1, NULL, |
---|
| 731 | "Gopher network TCP profile"}, |
---|
| 732 | #endif |
---|
| 733 | #endif |
---|
[4710] | 734 | |
---|
[3987] | 735 | // End of List: |
---|
[3956] | 736 | {NULL, -1, -1, NULL, -1, -1, NULL, NULL} |
---|
| 737 | }; |
---|
| 738 | |
---|
| 739 | void listen_listen_profiles (void) { |
---|
| 740 | struct _listen_profile * p; |
---|
| 741 | char * type; |
---|
| 742 | int i; |
---|
[3987] | 743 | char port[8]; |
---|
[3956] | 744 | |
---|
[4760] | 745 | printf("Name Type Address Port Protocol Dir Audio Profile - Description\n"); |
---|
| 746 | printf("-------------------------------------------------------------------------------------------------\n"); |
---|
[3956] | 747 | //roar-tcp-pub 0.0.0.0 16002 RoarAudio unknown (null) - (null) |
---|
| 748 | |
---|
| 749 | for (i = 0; (p = &(_g_listen_profiles[i]))->name != NULL; i++) { |
---|
| 750 | switch (p->type) { |
---|
| 751 | case ROAR_SOCKET_TYPE_UNIX: type = "UNIX"; break; |
---|
| 752 | case ROAR_SOCKET_TYPE_TCP: type = "TCP"; break; |
---|
| 753 | case ROAR_SOCKET_TYPE_DECNET: type = "DECnet"; break; |
---|
[4760] | 754 | case ROAR_SOCKET_TYPE_TCP6: type = "TCP6"; break; |
---|
[3956] | 755 | default: |
---|
| 756 | type = "unknown"; |
---|
| 757 | break; |
---|
| 758 | } |
---|
[3987] | 759 | |
---|
| 760 | if ( p->port ) { |
---|
[4049] | 761 | snprintf(port, sizeof(port)-1, "%i", p->port); |
---|
| 762 | port[sizeof(port)-1] = 0; |
---|
[3987] | 763 | } else { |
---|
| 764 | strcpy(port, "(none)"); |
---|
| 765 | } |
---|
| 766 | |
---|
[4760] | 767 | printf("%-15s %-7s %-16s %-7s %-9s %-10s %-13s - %s\n", |
---|
[3956] | 768 | p->name, |
---|
| 769 | type, |
---|
[3987] | 770 | p->sockaddr, port, |
---|
[3956] | 771 | roar_proto2str(p->proto), |
---|
[3957] | 772 | p->dir == -1 ? "(none)" : roar_dir2str(p->dir), p->aiprofile == NULL ? "(none)" : p->aiprofile, |
---|
[3956] | 773 | p->desc == NULL ? "" : p->desc); |
---|
| 774 | } |
---|
| 775 | } |
---|
| 776 | |
---|
| 777 | int get_listen_profile (const char * name, |
---|
| 778 | int * port, char ** sockaddr, int * type, |
---|
| 779 | int * proto, |
---|
| 780 | int * dir, struct roar_audio_info * info) { |
---|
| 781 | static char buf[1024]; |
---|
| 782 | struct _listen_profile * p; |
---|
| 783 | int i; |
---|
| 784 | |
---|
| 785 | for (i = 0; (p = &(_g_listen_profiles[i]))->name != NULL; i++) { |
---|
| 786 | if ( !strcasecmp(p->name, name) ) { |
---|
| 787 | *port = p->port; |
---|
| 788 | |
---|
[3959] | 789 | if ( p->type == ROAR_SOCKET_TYPE_UNIX && p->sockaddr[0] != '+' ) { |
---|
| 790 | roar_env_render_path_r(buf, sizeof(buf), p->sockaddr); |
---|
| 791 | } else { |
---|
| 792 | strncpy(buf, p->sockaddr, sizeof(buf)); |
---|
| 793 | } |
---|
[3956] | 794 | *sockaddr = buf; |
---|
[4642] | 795 | *type = p->type; |
---|
[3956] | 796 | |
---|
| 797 | *proto = p->proto; |
---|
| 798 | *dir = p->dir; |
---|
| 799 | |
---|
| 800 | if ( p->aiprofile != NULL ) { |
---|
| 801 | if ( roar_profile2info(info, p->aiprofile) == -1 ) { |
---|
| 802 | ROAR_ERR("Unknown audio profile: %s", p->aiprofile); |
---|
| 803 | return -1; |
---|
| 804 | } |
---|
| 805 | } |
---|
| 806 | return 0; |
---|
| 807 | } |
---|
| 808 | } |
---|
| 809 | |
---|
| 810 | return -1; |
---|
| 811 | } |
---|
| 812 | #endif |
---|
| 813 | |
---|
[3252] | 814 | int add_listen (char * addr, int port, int sock_type, char * user, char * group, int proto, int dir, struct roar_audio_info * info) { |
---|
[2530] | 815 | #if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX) |
---|
| 816 | struct group * grp = NULL; |
---|
| 817 | #endif |
---|
| 818 | #if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX) |
---|
| 819 | struct passwd * pwd = NULL; |
---|
| 820 | #endif |
---|
| 821 | #ifdef ROAR_HAVE_UNIX |
---|
| 822 | char * env_roar_proxy_backup; |
---|
| 823 | #endif |
---|
| 824 | int sockid = -1; |
---|
[3907] | 825 | #ifdef ROAR_HAVE_UNIX |
---|
[2530] | 826 | int sock; |
---|
[3907] | 827 | #endif |
---|
[2530] | 828 | int i; |
---|
| 829 | |
---|
[4055] | 830 | ROAR_INFO("add_listen(addr='%s', port=%i, sock_type=%i, user='%s', group='%s', proto=%s(%i), dir=%s(%i), info={.rate=%u, .bits=%u, .channels=%u, .codec=%s(%u)}): trying to add listen socket", |
---|
| 831 | ROAR_DBG_INFO_INFO, |
---|
| 832 | addr, port, sock_type, user, group, roar_proto2str(proto), proto, roar_dir2str(dir), dir, |
---|
| 833 | info->rate, info->bits, info->channels, roar_codec2str(info->codec), info->codec); |
---|
| 834 | |
---|
[2530] | 835 | if ( *addr != 0 ) { |
---|
| 836 | for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) { |
---|
[3802] | 837 | if ( ! g_listen[i].used ) { |
---|
[2530] | 838 | sockid = i; |
---|
| 839 | break; |
---|
| 840 | } |
---|
| 841 | } |
---|
| 842 | |
---|
| 843 | if ( sockid == -1 ) |
---|
| 844 | return -1; |
---|
| 845 | |
---|
[3128] | 846 | g_listen[sockid].proto = proto; |
---|
[2530] | 847 | |
---|
| 848 | ROAR_DBG("add_listen(*): proto=0x%.4x", proto); |
---|
| 849 | |
---|
[3802] | 850 | if ( roar_vio_open_socket_listen(&(g_listen[sockid].sock), sock_type, addr, port) == -1 ) { |
---|
[2530] | 851 | #ifdef ROAR_HAVE_UNIX |
---|
| 852 | if ( *addr == '/' ) { |
---|
| 853 | if ( (env_roar_proxy_backup = getenv("ROAR_PROXY")) != NULL ) { |
---|
[4975] | 854 | env_roar_proxy_backup = roar_mm_strdup(env_roar_proxy_backup); |
---|
[2530] | 855 | unsetenv("ROAR_PROXY"); |
---|
| 856 | } |
---|
[5375] | 857 | if ( (sock = roar_socket_connect(ROAR_SOCKET_TYPE_UNKNOWN, addr, port)) != -1 ) { |
---|
[2530] | 858 | close(sock); |
---|
[3040] | 859 | ROAR_ERR("Can not open listen socket: Socket allready in use"); |
---|
[4641] | 860 | return -1; |
---|
[2530] | 861 | } else { |
---|
| 862 | unlink(addr); |
---|
[3802] | 863 | if ( roar_vio_open_socket_listen(&(g_listen[sockid].sock), sock_type, addr, port) == -1 ) { |
---|
[3040] | 864 | ROAR_ERR("Can not open listen socket: %s", strerror(errno)); |
---|
[4641] | 865 | return -1; |
---|
[2530] | 866 | } |
---|
| 867 | } |
---|
| 868 | if ( env_roar_proxy_backup != NULL ) { |
---|
| 869 | setenv("ROAR_PROXY", env_roar_proxy_backup, 0); |
---|
[4975] | 870 | roar_mm_free(env_roar_proxy_backup); |
---|
[2530] | 871 | } |
---|
| 872 | #else |
---|
| 873 | if (0) { // noop |
---|
| 874 | #endif |
---|
| 875 | } else { |
---|
[3041] | 876 | ROAR_ERR("Can not open listen socket: %s", strerror(errno)); |
---|
[4641] | 877 | return -1; |
---|
[2530] | 878 | } |
---|
| 879 | } |
---|
| 880 | |
---|
[4641] | 881 | ROAR_DBG("add_listen(*) = ?"); |
---|
| 882 | |
---|
[2530] | 883 | #if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX) |
---|
[2753] | 884 | if ( group != NULL ) { |
---|
| 885 | if ( (grp = getgrnam(group)) == NULL ) { |
---|
| 886 | ROAR_ERR("Can not get GID for group %s: %s", group, strerror(errno)); |
---|
| 887 | } |
---|
[2530] | 888 | } |
---|
| 889 | #endif |
---|
[4641] | 890 | |
---|
| 891 | ROAR_DBG("add_listen(*) = ?"); |
---|
| 892 | |
---|
[2530] | 893 | #if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX) |
---|
[5047] | 894 | if ( user != NULL ) { |
---|
[2530] | 895 | if ( (pwd = getpwnam(user)) == NULL ) { |
---|
| 896 | ROAR_ERR("Can not get UID for user %s: %s", user, strerror(errno)); |
---|
| 897 | } |
---|
| 898 | } |
---|
| 899 | #endif |
---|
| 900 | |
---|
[4641] | 901 | ROAR_DBG("add_listen(*) = ?"); |
---|
| 902 | |
---|
[2530] | 903 | #if defined(ROAR_HAVE_IO_POSIX) && defined(ROAR_HAVE_UNIX) |
---|
| 904 | if ( *addr == '/' ) { |
---|
[5046] | 905 | if ( grp != NULL || pwd != NULL ) { |
---|
| 906 | if ( chown(addr, pwd != NULL ? pwd->pw_uid : -1, grp != NULL ? grp->gr_gid : -1) == -1 ) |
---|
[4641] | 907 | return -1; |
---|
[2753] | 908 | } |
---|
[2530] | 909 | #ifdef ROAR_HAVE_GETUID |
---|
[5046] | 910 | if ( grp != NULL ) { |
---|
[2530] | 911 | if ( getuid() == 0 ) |
---|
| 912 | if ( chmod(addr, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1 ) |
---|
[4641] | 913 | return -1; |
---|
[2753] | 914 | } |
---|
[2530] | 915 | #endif |
---|
| 916 | } |
---|
| 917 | #endif |
---|
| 918 | } |
---|
| 919 | |
---|
[4641] | 920 | ROAR_DBG("add_listen(*) = ?"); |
---|
| 921 | |
---|
[2736] | 922 | // in case we opened the listening socket correctly. |
---|
[3256] | 923 | if ( dir == -1 ) |
---|
| 924 | dir = ROAR_DIR_PLAY; |
---|
| 925 | |
---|
[3252] | 926 | g_listen[sockid].inst.stpl.dir = dir; |
---|
| 927 | memcpy(&(g_listen[sockid].inst.stpl.info), info, sizeof(struct roar_audio_info)); |
---|
[3256] | 928 | |
---|
| 929 | switch (dir) { |
---|
| 930 | case ROAR_DIR_PLAY: |
---|
| 931 | case ROAR_DIR_RECORD: |
---|
| 932 | case ROAR_DIR_MONITOR: |
---|
| 933 | case ROAR_DIR_FILTER: |
---|
| 934 | case ROAR_DIR_BIDIR: |
---|
[5380] | 935 | case ROAR_DIR_RECPLAY: |
---|
[3256] | 936 | if ( !g_listen[sockid].inst.stpl.info.rate ) |
---|
| 937 | g_listen[sockid].inst.stpl.info.rate = g_sa->rate; |
---|
| 938 | |
---|
| 939 | if ( !g_listen[sockid].inst.stpl.info.bits ) |
---|
| 940 | g_listen[sockid].inst.stpl.info.bits = g_sa->bits; |
---|
| 941 | |
---|
| 942 | if ( !g_listen[sockid].inst.stpl.info.channels ) |
---|
| 943 | g_listen[sockid].inst.stpl.info.channels = g_sa->channels; |
---|
| 944 | |
---|
| 945 | if ( !g_listen[sockid].inst.stpl.info.codec ) |
---|
| 946 | g_listen[sockid].inst.stpl.info.codec = g_sa->codec; |
---|
| 947 | break; |
---|
| 948 | } |
---|
| 949 | |
---|
[3802] | 950 | g_listen[sockid].used = 1; |
---|
| 951 | server[sockid] = addr; |
---|
| 952 | |
---|
[2530] | 953 | return 0; |
---|
| 954 | } |
---|
| 955 | #endif |
---|
| 956 | |
---|
[5210] | 957 | #ifdef ROAR_HAVE_MAIN_ARGS |
---|
[4882] | 958 | static void list_aiprofiles (void) { |
---|
| 959 | struct roar_audio_info info; |
---|
| 960 | const char * list[1024]; |
---|
| 961 | const char * mime; |
---|
| 962 | ssize_t ret; |
---|
| 963 | ssize_t i; |
---|
| 964 | |
---|
| 965 | ret = roar_profiles_list(list, 1024, 0); |
---|
| 966 | |
---|
| 967 | if ( ret == -1 ) |
---|
| 968 | return; |
---|
| 969 | |
---|
[5350] | 970 | printf(" Name Rate Bits Channels Codec\n"); |
---|
| 971 | printf("-----------------------------------------------------------------------------\n"); |
---|
[4882] | 972 | for (i = 0; i < ret; i++) { |
---|
[5161] | 973 | if ( roar_profile2info(&info, list[i]) == -1 ) { |
---|
| 974 | printf(" %-10s --- unknown parameters ---\n", list[i]); |
---|
| 975 | continue; |
---|
| 976 | } |
---|
[4882] | 977 | |
---|
| 978 | mime = roar_codec2mime(info.codec); |
---|
| 979 | |
---|
[5350] | 980 | printf(" %-16s %5u %4u %8u %3u (%s%s%s%s)\n", list[i], |
---|
[4882] | 981 | info.rate, info.bits, info.channels, |
---|
| 982 | info.codec, roar_codec2str(info.codec), |
---|
| 983 | info.codec == ROAR_CODEC_DEFAULT ? " native" : "", |
---|
| 984 | mime == NULL ? "" : " mimetype:", |
---|
| 985 | mime == NULL ? "" : mime |
---|
| 986 | ); |
---|
| 987 | } |
---|
| 988 | } |
---|
[5210] | 989 | #endif |
---|
[4882] | 990 | |
---|
[2339] | 991 | int update_stream_flags (char * str) { |
---|
| 992 | int dir; |
---|
| 993 | char * flags; |
---|
| 994 | char * k; |
---|
| 995 | int op; |
---|
| 996 | int flag; |
---|
| 997 | |
---|
| 998 | if ( (flags = strstr(str, "=")) == NULL ) |
---|
| 999 | return -1; |
---|
| 1000 | |
---|
| 1001 | *flags = 0; |
---|
| 1002 | flags++; |
---|
| 1003 | |
---|
| 1004 | if ( (dir = roar_str2dir(str)) == -1 ) |
---|
| 1005 | return -1; |
---|
| 1006 | |
---|
| 1007 | while (flags != NULL) { |
---|
| 1008 | k = flags; |
---|
| 1009 | flags = strstr(flags, ","); |
---|
| 1010 | |
---|
| 1011 | if ( flags != NULL ) |
---|
| 1012 | *(flags++) = 0; |
---|
| 1013 | |
---|
| 1014 | switch (*k) { |
---|
[2340] | 1015 | case '+': k++; op = ROAR_SET_FLAG; break; |
---|
| 1016 | case '-': k++; op = ROAR_RESET_FLAG; break; |
---|
[2339] | 1017 | default: |
---|
[2340] | 1018 | op = ROAR_SET_FLAG; |
---|
[2339] | 1019 | } |
---|
| 1020 | |
---|
| 1021 | flag = 0; |
---|
| 1022 | |
---|
| 1023 | if ( !strcmp(k, "sync") ) { |
---|
| 1024 | flag = ROAR_FLAG_SYNC; |
---|
| 1025 | } else if ( !strcmp(k, "meta") ) { |
---|
| 1026 | flag = ROAR_FLAG_META; |
---|
| 1027 | } else if ( !strcmp(k, "cleanmeta") ) { |
---|
| 1028 | flag = ROAR_FLAG_CLEANMETA; |
---|
| 1029 | } else if ( !strcmp(k, "pause") ) { |
---|
| 1030 | flag = ROAR_FLAG_PAUSE; |
---|
| 1031 | } else if ( !strcmp(k, "mute") ) { |
---|
| 1032 | flag = ROAR_FLAG_MUTE; |
---|
| 1033 | } else if ( !strcmp(k, "antiecho") ) { |
---|
| 1034 | flag = ROAR_FLAG_ANTIECHO; |
---|
[2413] | 1035 | } else if ( !strcmp(k, "passmixer") ) { |
---|
| 1036 | flag = ROAR_FLAG_PASSMIXER; |
---|
[4815] | 1037 | } else if ( !strcmp(k, "recsource") ) { |
---|
| 1038 | flag = ROAR_FLAG_RECSOURCE; |
---|
[2339] | 1039 | } else { |
---|
| 1040 | return -1; |
---|
| 1041 | } |
---|
| 1042 | |
---|
| 1043 | g_config->streams[dir].flags |= flag; |
---|
| 1044 | |
---|
[2340] | 1045 | if ( op == ROAR_RESET_FLAG ) |
---|
[2339] | 1046 | g_config->streams[dir].flags -= flag; |
---|
| 1047 | } |
---|
| 1048 | |
---|
| 1049 | return 0; |
---|
| 1050 | } |
---|
| 1051 | |
---|
[4788] | 1052 | int add_authfile (const char * file, const char * type, enum af_mode mode, enum roard_client_acclev acclev) { |
---|
| 1053 | struct roar_authfile * authfile = NULL; |
---|
| 1054 | struct roar_authfile_key * key = NULL; |
---|
| 1055 | int af_type = ROAR_AUTHFILE_TYPE_AUTO; |
---|
[4790] | 1056 | void * keydata; |
---|
[4792] | 1057 | int i; |
---|
[4788] | 1058 | |
---|
| 1059 | if ( type == NULL ) { |
---|
| 1060 | // noop. |
---|
| 1061 | } else if ( !strcasecmp(type, "roar") ) { |
---|
| 1062 | af_type = ROAR_AUTHFILE_TYPE_ROAR; |
---|
| 1063 | } else if ( !strcasecmp(type, "roar") ) { |
---|
| 1064 | af_type = ROAR_AUTHFILE_TYPE_ROAR; |
---|
| 1065 | } else if ( !strcasecmp(type, "esd") ) { |
---|
| 1066 | af_type = ROAR_AUTHFILE_TYPE_ESD; |
---|
| 1067 | } else if ( !strcasecmp(type, "pulse") ) { |
---|
| 1068 | af_type = ROAR_AUTHFILE_TYPE_PULSE; |
---|
| 1069 | } else if ( !strcasecmp(type, "htpasswd") ) { |
---|
| 1070 | af_type = ROAR_AUTHFILE_TYPE_HTPASSWD; |
---|
| 1071 | } else if ( !strcasecmp(type, "xauth") ) { |
---|
| 1072 | af_type = ROAR_AUTHFILE_TYPE_XAUTH; |
---|
| 1073 | } else { |
---|
| 1074 | ROAR_ERR("add_authfile(*): unknown authfile type '%s'.", type); |
---|
| 1075 | return -1; |
---|
| 1076 | } |
---|
| 1077 | |
---|
| 1078 | if ( mode == AF_MODE_GEN && af_type == ROAR_AUTHFILE_TYPE_AUTO ) |
---|
| 1079 | af_type = ROAR_AUTHFILE_TYPE_ESD; |
---|
| 1080 | |
---|
| 1081 | switch (mode) { |
---|
| 1082 | case AF_MODE_NONE: |
---|
| 1083 | return 0; |
---|
| 1084 | break; |
---|
| 1085 | case AF_MODE_GEN: |
---|
| 1086 | switch (af_type) { |
---|
| 1087 | case ROAR_AUTHFILE_TYPE_ESD: |
---|
| 1088 | key = roar_authfile_key_new_random(ROAR_AUTH_T_COOKIE, 16, NULL); |
---|
| 1089 | break; |
---|
| 1090 | case ROAR_AUTHFILE_TYPE_PULSE: |
---|
| 1091 | key = roar_authfile_key_new_random(ROAR_AUTH_T_COOKIE, 256, NULL); |
---|
| 1092 | break; |
---|
| 1093 | default: |
---|
| 1094 | return -1; |
---|
| 1095 | break; |
---|
| 1096 | } |
---|
| 1097 | |
---|
| 1098 | if ( key == NULL ) { |
---|
| 1099 | ROAR_ERR("add_authfile(*): Can not generate key."); |
---|
| 1100 | return -1; |
---|
| 1101 | } |
---|
| 1102 | |
---|
| 1103 | if ( (authfile = roar_authfile_open(af_type, file, 1, ROAR_AUTHFILE_VERSION_AUTO)) == NULL ) { |
---|
| 1104 | roar_authfile_key_unref(key); |
---|
| 1105 | return -1; |
---|
| 1106 | } |
---|
| 1107 | |
---|
| 1108 | if ( roar_authfile_add_key(authfile, key) == -1 ) { |
---|
| 1109 | ROAR_WARN("add_authfile(*): Can not add key to authfile."); |
---|
| 1110 | } |
---|
| 1111 | |
---|
[4790] | 1112 | keydata = roar_mm_memdup(key->data, key->len); |
---|
| 1113 | |
---|
| 1114 | if ( keydata == NULL ) { |
---|
| 1115 | ROAR_WARN("add_authfile(*): Can not allocate memory for key."); |
---|
| 1116 | } else if ( auth_addkey_cookie(acclev, keydata, key->len) == -1 ) { |
---|
[4788] | 1117 | ROAR_WARN("add_authfile(*): Can not add key to internal key storage."); |
---|
| 1118 | } |
---|
| 1119 | |
---|
| 1120 | roar_authfile_key_unref(key); |
---|
| 1121 | if ( roar_authfile_close(authfile) != 0 ) |
---|
| 1122 | return -1; |
---|
| 1123 | return 0; |
---|
| 1124 | break; |
---|
[4792] | 1125 | case AF_MODE_LOAD: |
---|
| 1126 | if ( (authfile = roar_authfile_open(af_type, file, 0, ROAR_AUTHFILE_VERSION_AUTO)) == NULL ) { |
---|
| 1127 | return -1; |
---|
| 1128 | } |
---|
| 1129 | |
---|
| 1130 | for (i = 0; ; i++) { |
---|
| 1131 | key = roar_authfile_lookup_key(authfile, ROAR_AUTH_T_AUTO, i, NULL); |
---|
| 1132 | if ( key == NULL ) |
---|
| 1133 | break; |
---|
| 1134 | |
---|
| 1135 | if ( key->type == ROAR_AUTH_T_COOKIE ) { |
---|
| 1136 | keydata = roar_mm_memdup(key->data, key->len); |
---|
| 1137 | |
---|
| 1138 | if ( keydata == NULL ) { |
---|
| 1139 | ROAR_WARN("add_authfile(*): Can not allocate memory for key."); |
---|
| 1140 | } else if ( auth_addkey_cookie(acclev, keydata, key->len) == -1 ) { |
---|
| 1141 | ROAR_WARN("add_authfile(*): Can not add key to internal key storage."); |
---|
| 1142 | } |
---|
| 1143 | } else { |
---|
| 1144 | ROAR_WARN("add_authfile(*): Unknown key type: %i", key->type); |
---|
| 1145 | } |
---|
| 1146 | |
---|
| 1147 | roar_authfile_key_unref(key); |
---|
| 1148 | } |
---|
| 1149 | |
---|
| 1150 | if ( roar_authfile_close(authfile) != 0 ) |
---|
| 1151 | return -1; |
---|
| 1152 | return 0; |
---|
| 1153 | break; |
---|
[4788] | 1154 | } |
---|
| 1155 | |
---|
| 1156 | return -1; |
---|
| 1157 | } |
---|
| 1158 | |
---|
[3373] | 1159 | // X11: |
---|
| 1160 | #ifdef ROAR_HAVE_LIBX11 |
---|
| 1161 | int register_x11 (int unreg, char * sockname) { |
---|
| 1162 | struct roar_x11_connection * x11con = NULL; |
---|
| 1163 | int ret = 0; |
---|
| 1164 | |
---|
[4103] | 1165 | if ( (x11con = roar_x11_connect(x11display)) == NULL ) { |
---|
[4155] | 1166 | ROAR_ERR("Can not connect to X11 server for %sregistering", unreg ? "un" : ""); |
---|
[3373] | 1167 | return -1; |
---|
[4103] | 1168 | } |
---|
[3373] | 1169 | |
---|
| 1170 | if ( unreg ) { |
---|
[4103] | 1171 | if ( roar_x11_delete_prop(x11con, "ROAR_SERVER") == -1 ) { |
---|
[3373] | 1172 | ret = -1; |
---|
[4103] | 1173 | ROAR_ERR("Error while unregistereing from X11", ROAR_DBG_INFO_INFO); |
---|
| 1174 | } else { |
---|
| 1175 | ROAR_INFO("Successfully unregistered from X11", ROAR_DBG_INFO_INFO); |
---|
| 1176 | } |
---|
[3373] | 1177 | } else { |
---|
[4103] | 1178 | if ( roar_x11_set_prop(x11con, "ROAR_SERVER", sockname) == -1 ) { |
---|
[3373] | 1179 | ret = -1; |
---|
[4103] | 1180 | ROAR_ERR("Error while registereing to X11", ROAR_DBG_INFO_INFO); |
---|
| 1181 | } else { |
---|
| 1182 | ROAR_INFO("Successfully registered to X11", ROAR_DBG_INFO_INFO); |
---|
| 1183 | } |
---|
[3373] | 1184 | } |
---|
| 1185 | |
---|
| 1186 | roar_x11_disconnect(x11con); |
---|
| 1187 | |
---|
| 1188 | return ret; |
---|
| 1189 | } |
---|
| 1190 | #endif |
---|
[1993] | 1191 | |
---|
| 1192 | // SLP: |
---|
| 1193 | void register_slp_callback(SLPHandle hslp, SLPError errcode, void * cookie) { |
---|
| 1194 | /* return the error code in the cookie */ |
---|
| 1195 | *(SLPError*)cookie = errcode; |
---|
| 1196 | } |
---|
| 1197 | |
---|
| 1198 | int register_slp (int unreg, char * sockname) { |
---|
| 1199 | #ifdef ROAR_HAVE_LIBSLP |
---|
| 1200 | static int regged = 0; |
---|
| 1201 | static char * sn = NULL; |
---|
| 1202 | SLPError err; |
---|
| 1203 | SLPError callbackerr; |
---|
| 1204 | SLPHandle hslp; |
---|
| 1205 | char addr[1024]; |
---|
| 1206 | char attr[1024] = ""; |
---|
[2017] | 1207 | char * location; |
---|
[4421] | 1208 | char * description; |
---|
[4577] | 1209 | char * standards; |
---|
[1993] | 1210 | |
---|
| 1211 | if ( sockname != NULL ) |
---|
| 1212 | sn = sockname; |
---|
| 1213 | |
---|
[3076] | 1214 | snprintf(addr, sizeof(addr), ROAR_SLP_URL_TYPE_ROAR "://%s", sn); |
---|
[1993] | 1215 | |
---|
| 1216 | err = SLPOpen("en", SLP_FALSE, &hslp); |
---|
| 1217 | |
---|
| 1218 | if (err != SLP_OK) { |
---|
| 1219 | ROAR_ERR("Error opening slp handle: Error #%i", err); |
---|
| 1220 | return -1; |
---|
| 1221 | } |
---|
| 1222 | |
---|
| 1223 | if (!unreg) { |
---|
[2017] | 1224 | |
---|
| 1225 | if ( SLPEscape(g_config->location, &location, SLP_FALSE) != SLP_OK ) { |
---|
| 1226 | ROAR_ERR("Error using SLPEscape() on server location, really bad!"); |
---|
| 1227 | SLPClose(hslp); |
---|
| 1228 | return -1; |
---|
| 1229 | } |
---|
| 1230 | |
---|
[4421] | 1231 | if ( SLPEscape(g_config->description, &description, SLP_FALSE) != SLP_OK ) { |
---|
| 1232 | ROAR_ERR("Error using SLPEscape() on server location, really bad!"); |
---|
| 1233 | SLPClose(hslp); |
---|
| 1234 | return -1; |
---|
| 1235 | } |
---|
| 1236 | |
---|
[4577] | 1237 | standards = stds_string(); |
---|
| 1238 | |
---|
| 1239 | if ( standards == NULL ) { |
---|
| 1240 | if ( (standards = roar_mm_malloc(1)) == NULL ) { |
---|
| 1241 | SLPClose(hslp); |
---|
| 1242 | return -1; |
---|
| 1243 | } |
---|
| 1244 | standards[0] = 0; |
---|
| 1245 | } |
---|
| 1246 | |
---|
[1995] | 1247 | snprintf(attr, sizeof(attr), "(wave-rate=%i),(wave-channels=%i),(wave-bits=%i)," |
---|
[2494] | 1248 | #ifndef ROAR_WITHOUT_DCOMP_LIGHT |
---|
| 1249 | "(light-channels=%i)," |
---|
| 1250 | #endif |
---|
[4577] | 1251 | "(standards=%s)," |
---|
[4421] | 1252 | "(location=%s),(description=%s)", |
---|
[1995] | 1253 | g_sa->rate, g_sa->channels, g_sa->bits, |
---|
[2494] | 1254 | #ifndef ROAR_WITHOUT_DCOMP_LIGHT |
---|
[2017] | 1255 | g_light_state.channels, |
---|
[2494] | 1256 | #endif |
---|
[4577] | 1257 | standards, |
---|
[4421] | 1258 | location, description |
---|
[1995] | 1259 | ); |
---|
| 1260 | |
---|
[4577] | 1261 | roar_mm_free(standards); |
---|
| 1262 | |
---|
[1993] | 1263 | /* Register a service with SLP */ |
---|
| 1264 | err = SLPReg(hslp, |
---|
| 1265 | addr, |
---|
| 1266 | SLP_LIFETIME_MAXIMUM, |
---|
| 1267 | 0, |
---|
| 1268 | attr, |
---|
| 1269 | SLP_TRUE, |
---|
| 1270 | register_slp_callback, |
---|
| 1271 | &callbackerr); |
---|
[1994] | 1272 | regged = 1; |
---|
| 1273 | } else if ( unreg && regged ) { |
---|
| 1274 | err = SLPDereg(hslp, addr, register_slp_callback, &callbackerr); |
---|
| 1275 | regged = 0; |
---|
| 1276 | } else { |
---|
| 1277 | SLPClose(hslp); |
---|
| 1278 | return -1; |
---|
| 1279 | } |
---|
[1993] | 1280 | |
---|
[1994] | 1281 | /* err may contain an error code that occurred as the slp library */ |
---|
| 1282 | /* _prepared_ to make the call. */ |
---|
| 1283 | if ( err != SLP_OK ) { |
---|
| 1284 | ROAR_ERR("Error (de)registering service with slp: Error #%i", err); |
---|
| 1285 | return -1; |
---|
| 1286 | } |
---|
| 1287 | |
---|
| 1288 | /* callbackerr may contain an error code (that was assigned through */ |
---|
| 1289 | /* the callback cookie) that occurred as slp packets were sent on */ |
---|
| 1290 | /* the wire */ |
---|
| 1291 | if (callbackerr != SLP_OK) { |
---|
| 1292 | ROAR_ERR("Error (de)registering service with slp: Error #%i", callbackerr); |
---|
| 1293 | return -1; |
---|
[1993] | 1294 | } |
---|
| 1295 | |
---|
| 1296 | SLPClose(hslp); |
---|
| 1297 | return 0; |
---|
| 1298 | #else |
---|
| 1299 | return -1; |
---|
| 1300 | #endif |
---|
| 1301 | } |
---|
| 1302 | |
---|
[4481] | 1303 | static int auth_setup (enum roard_client_acclev none_acclev, |
---|
| 1304 | enum roard_client_acclev trust_acclev, int trust_root, uid_t trust_uid, gid_t trust_gid) { |
---|
| 1305 | union auth_typeunion * key; |
---|
| 1306 | size_t i; |
---|
| 1307 | |
---|
[4482] | 1308 | // Info: |
---|
| 1309 | // if a authlevel is <= ACCLEV_IDENTED we do not need to add this to the keyring |
---|
| 1310 | // as ACCLEV_IDENTED is already gained if IDENTIFY call was done correctly. |
---|
[4481] | 1311 | |
---|
[4482] | 1312 | if ( !(none_acclev <= ACCLEV_IDENTED) ) { |
---|
| 1313 | if ( auth_addkey_anonymous(none_acclev) == -1 ) |
---|
| 1314 | return -1; |
---|
| 1315 | } |
---|
[4481] | 1316 | |
---|
[4482] | 1317 | if ( !(trust_acclev <= ACCLEV_IDENTED) ) { |
---|
| 1318 | if ( (key = auth_regkey_simple(ROAR_AUTH_T_TRUST, trust_acclev)) == NULL ) |
---|
| 1319 | return -1; |
---|
[4481] | 1320 | |
---|
[4482] | 1321 | // zerosize all counters. |
---|
| 1322 | memset(key, 0, sizeof(union auth_typeunion)); |
---|
[4481] | 1323 | |
---|
[4482] | 1324 | i = 0; |
---|
| 1325 | |
---|
| 1326 | if ( trust_uid != -1 ) |
---|
| 1327 | key->trust.uids[i++] = trust_uid; |
---|
[4481] | 1328 | |
---|
| 1329 | #ifdef ROAR_ROOT_UID |
---|
[4482] | 1330 | if ( trust_root ) |
---|
| 1331 | key->trust.uids[i++] = ROAR_ROOT_UID; |
---|
[4481] | 1332 | #endif |
---|
| 1333 | |
---|
[4482] | 1334 | key->trust.uids_len = i; |
---|
[4481] | 1335 | |
---|
[4482] | 1336 | i = 0; |
---|
[4481] | 1337 | |
---|
[4482] | 1338 | if ( trust_gid != -1 ) |
---|
| 1339 | key->trust.gids[i++] = trust_gid; |
---|
[4481] | 1340 | |
---|
[4482] | 1341 | key->trust.gids_len = i; |
---|
| 1342 | } |
---|
[4481] | 1343 | |
---|
| 1344 | return 0; |
---|
| 1345 | } |
---|
| 1346 | |
---|
[1993] | 1347 | |
---|
| 1348 | // MAIN: |
---|
| 1349 | |
---|
[4053] | 1350 | #define _CKHAVEARGS(x) if ( (i + (x)) >= argc ) { \ |
---|
| 1351 | ROAR_ERR("Option %s requires more arguments. See --help for more details.", k); \ |
---|
| 1352 | return 70; \ |
---|
| 1353 | } |
---|
[4052] | 1354 | |
---|
[1503] | 1355 | #ifdef ROAR_HAVE_MAIN_ARGS |
---|
[0] | 1356 | int main (int argc, char * argv[]) { |
---|
[1503] | 1357 | #else |
---|
| 1358 | int main (void) { |
---|
| 1359 | #endif |
---|
| 1360 | #ifdef ROAR_HAVE_MAIN_ARGS |
---|
[4722] | 1361 | enum action action = START; |
---|
[0] | 1362 | int i; |
---|
| 1363 | char * k; |
---|
[4955] | 1364 | enum output_format print_format = FORMAT_NATIVE; |
---|
[5210] | 1365 | const struct rolestack * rolestack; |
---|
[5287] | 1366 | const char * plugin_args = NULL; |
---|
[1503] | 1367 | #endif |
---|
[2787] | 1368 | #if defined(ROAR_SUPPORT_LISTEN) && defined(ROAR_HAVE_GETUID) |
---|
[905] | 1369 | char user_sock[80] = {0}; |
---|
[1494] | 1370 | #endif |
---|
[1609] | 1371 | struct roar_audio_info sa, max_sa; |
---|
| 1372 | struct roard_config config; |
---|
[5060] | 1373 | #if defined(ROAR_HAVE_FORK) || defined(ROAR_TARGET_WIN32) |
---|
[905] | 1374 | int daemon = 0; |
---|
[1486] | 1375 | #endif |
---|
[905] | 1376 | int realtime = 0; |
---|
| 1377 | int sysclocksync = 0; |
---|
[60] | 1378 | // char * server = ROAR_DEFAULT_SOCK_GLOBAL; |
---|
[1494] | 1379 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[2530] | 1380 | int port = ROAR_DEFAULT_PORT; |
---|
| 1381 | char * sock_addr = NULL; |
---|
| 1382 | int sock_proto = ROAR_PROTO_ROARAUDIO; |
---|
[3252] | 1383 | int sock_dir = -1; |
---|
| 1384 | struct roar_audio_info sock_info = {0, 0, 0, 0}; |
---|
[1494] | 1385 | #endif |
---|
[2486] | 1386 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[5103] | 1387 | char * s_drv = NULL; |
---|
[1110] | 1388 | char * s_dev = NULL; |
---|
[444] | 1389 | char * s_con = NULL; |
---|
| 1390 | char * s_opt = NULL; |
---|
| 1391 | int s_prim = 0; |
---|
[2486] | 1392 | #endif |
---|
[1207] | 1393 | char * o_drv = getenv("ROAR_DRIVER"); |
---|
| 1394 | char * o_dev = getenv("ROAR_DEVICE"); |
---|
[932] | 1395 | char * o_opts = NULL; |
---|
[961] | 1396 | int o_prim = 0; |
---|
[1145] | 1397 | int o_count = 0; |
---|
[4358] | 1398 | #ifndef ROAR_WITHOUT_DCOMP_MIXER |
---|
| 1399 | char * m_drv = NULL; |
---|
| 1400 | char * m_dev = NULL; |
---|
| 1401 | char * m_opts = NULL; |
---|
| 1402 | int m_prim = 0; |
---|
| 1403 | int m_count = 0; |
---|
| 1404 | #endif |
---|
[4481] | 1405 | enum roard_client_acclev none_acclev = ACCLEV_ALL; |
---|
| 1406 | enum roard_client_acclev trust_acclev = ACCLEV_ALL; |
---|
| 1407 | int trust_root = 1; |
---|
[4788] | 1408 | char * af_file = NULL; |
---|
| 1409 | char * af_type = NULL; |
---|
| 1410 | enum af_mode af_mode = AF_MODE_NONE; |
---|
| 1411 | enum roard_client_acclev af_acclev = ACCLEV_ALL; |
---|
[2494] | 1412 | #ifndef ROAR_WITHOUT_DCOMP_LIGHT |
---|
[5210] | 1413 | uint32_t light_channels = LIGHT_CHANNELS_DEFAULT; |
---|
[2494] | 1414 | #endif |
---|
[2751] | 1415 | #ifdef ROAR_DEFAULT_SOCKGRP |
---|
[450] | 1416 | char * sock_grp = ROAR_DEFAULT_SOCKGRP; |
---|
[2751] | 1417 | #else |
---|
| 1418 | char * sock_grp = NULL; |
---|
| 1419 | #endif |
---|
[444] | 1420 | char * sock_user = NULL; |
---|
[1494] | 1421 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[517] | 1422 | int sock_type = ROAR_SOCKET_TYPE_UNKNOWN; |
---|
[1494] | 1423 | #endif |
---|
[1993] | 1424 | #ifdef ROAR_HAVE_LIBSLP |
---|
| 1425 | int reg_slp = 0; |
---|
| 1426 | #endif |
---|
[3373] | 1427 | #ifdef ROAR_HAVE_LIBX11 |
---|
| 1428 | int reg_x11 = 0; |
---|
| 1429 | #endif |
---|
[1486] | 1430 | #ifdef ROAR_HAVE_CHROOT |
---|
[444] | 1431 | char * chrootdir = NULL; |
---|
[1486] | 1432 | #endif |
---|
| 1433 | #if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX) |
---|
[446] | 1434 | struct group * grp = NULL; |
---|
[1486] | 1435 | #endif |
---|
| 1436 | #if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX) |
---|
[446] | 1437 | struct passwd * pwd = NULL; |
---|
[1486] | 1438 | #endif |
---|
| 1439 | #ifdef ROAR_HAVE_GETSERVBYNAME |
---|
[446] | 1440 | struct servent * serv = NULL; |
---|
[1486] | 1441 | #endif |
---|
[39] | 1442 | struct roar_client * self = NULL; |
---|
[508] | 1443 | #ifdef ROAR_HAVE_LIBDNET |
---|
| 1444 | char decnethost[80]; |
---|
| 1445 | #endif |
---|
[2104] | 1446 | #ifdef SUPPORT_PIDFILE |
---|
| 1447 | struct roar_vio_calls pidfile_vio; |
---|
| 1448 | #endif |
---|
[0] | 1449 | |
---|
[2784] | 1450 | ROAR_DBG("main(*): starting roard..."); |
---|
| 1451 | |
---|
[0] | 1452 | g_standby = 0; |
---|
[920] | 1453 | g_autostandby = 0; |
---|
[982] | 1454 | alive = 1; |
---|
[1494] | 1455 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[1155] | 1456 | g_no_listen = 0; |
---|
[1494] | 1457 | #else |
---|
| 1458 | g_terminate = 1; |
---|
| 1459 | #endif |
---|
[0] | 1460 | |
---|
[2970] | 1461 | g_verbose = ROAR_DBG_INFO_NONE; |
---|
| 1462 | |
---|
[5180] | 1463 | _LIBROAR_IGNORE_RET(roar_profile2info(&sa, "default-server")); |
---|
[0] | 1464 | |
---|
[1609] | 1465 | g_sa = &sa; |
---|
| 1466 | g_max_sa = &max_sa; |
---|
| 1467 | |
---|
| 1468 | memcpy(g_max_sa, g_sa, sizeof(max_sa)); |
---|
| 1469 | |
---|
[4101] | 1470 | counters_init(); |
---|
| 1471 | |
---|
[1609] | 1472 | g_config = &config; |
---|
| 1473 | |
---|
| 1474 | if ( init_config() == -1 ) { |
---|
| 1475 | ROAR_ERR("Can not init default config!"); |
---|
| 1476 | return 1; |
---|
| 1477 | } |
---|
[0] | 1478 | |
---|
[2968] | 1479 | // load config |
---|
[5161] | 1480 | _LIBROAR_IGNORE_RET(roar_libroar_get_config()); |
---|
[2968] | 1481 | |
---|
[4323] | 1482 | // init notify core: |
---|
| 1483 | // TODO: reconsider number of lists. |
---|
| 1484 | if ( roar_notify_core_new_global(-1) == -1 ) { |
---|
| 1485 | ROAR_ERR("Can not init notify core!"); |
---|
| 1486 | return 1; |
---|
| 1487 | } |
---|
| 1488 | |
---|
[4324] | 1489 | if ( roar_notify_core_register_proxy(NULL, roar_notify_proxy_std, NULL) == -1 ) { |
---|
| 1490 | ROAR_ERR("Can not init notify core!"); |
---|
| 1491 | return 1; |
---|
| 1492 | } |
---|
| 1493 | |
---|
| 1494 | #ifdef DEBUG |
---|
[4418] | 1495 | // enable early in case we have DEBUG set. |
---|
[4324] | 1496 | dbg_notify_cb_register(); |
---|
| 1497 | #endif |
---|
| 1498 | |
---|
[4934] | 1499 | rolestack_init(); |
---|
| 1500 | |
---|
[4469] | 1501 | if ( auth_init() == -1 ) { |
---|
| 1502 | ROAR_ERR("Can not init auth subsystem!"); |
---|
| 1503 | return 1; |
---|
| 1504 | } |
---|
| 1505 | |
---|
[2530] | 1506 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 1507 | if ( init_listening() == -1 ) { |
---|
| 1508 | ROAR_ERR("Can not init listening sockets!"); |
---|
| 1509 | return 1; |
---|
| 1510 | } |
---|
| 1511 | #endif |
---|
| 1512 | |
---|
[2500] | 1513 | #ifndef ROAR_WITHOUT_DCOMP_MIDI |
---|
[1924] | 1514 | if ( midi_init_config() == -1 ) { |
---|
| 1515 | ROAR_ERR("Can not init MIDI config!"); |
---|
| 1516 | return 1; |
---|
| 1517 | } |
---|
[2500] | 1518 | #endif |
---|
[60] | 1519 | |
---|
[2489] | 1520 | #ifndef ROAR_WITHOUT_DCOMP_SSYNTH |
---|
[2451] | 1521 | if ( ssynth_init_config() == -1 ) { |
---|
| 1522 | ROAR_ERR("Can not init ssynth config!"); |
---|
| 1523 | return 1; |
---|
| 1524 | } |
---|
[2489] | 1525 | #endif |
---|
[2451] | 1526 | |
---|
[2718] | 1527 | #ifndef ROAR_WITHOUT_DCOMP_RDTCS |
---|
| 1528 | if ( rdtcs_init_config() == -1 ) { |
---|
| 1529 | ROAR_ERR("Can not init RDTCS config!"); |
---|
| 1530 | return 1; |
---|
| 1531 | } |
---|
| 1532 | #endif |
---|
| 1533 | |
---|
[3354] | 1534 | if ( plugins_preinit() == -1 ) { |
---|
| 1535 | ROAR_ERR("Can not pre-init plugins!"); |
---|
| 1536 | return 1; |
---|
| 1537 | } |
---|
| 1538 | |
---|
[1494] | 1539 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[2767] | 1540 | #ifndef ROAR_TARGET_WIN32 |
---|
[2530] | 1541 | sock_addr = ROAR_DEFAULT_SOCK_GLOBAL; |
---|
[2767] | 1542 | #else |
---|
| 1543 | sock_addr = ROAR_DEFAULT_HOST; |
---|
| 1544 | #endif |
---|
| 1545 | |
---|
[1753] | 1546 | #ifdef ROAR_HAVE_GETUID |
---|
[1486] | 1547 | if ( getuid() != 0 && getenv("HOME") != NULL ) { |
---|
[3959] | 1548 | /* |
---|
[1486] | 1549 | snprintf(user_sock, 79, "%s/%s", (char*)getenv("HOME"), ROAR_DEFAULT_SOCK_USER); |
---|
[3959] | 1550 | */ |
---|
| 1551 | roar_env_render_path_r(user_sock, sizeof(user_sock), "~/" ROAR_DEFAULT_SOCK_USER); |
---|
[2530] | 1552 | sock_addr = user_sock; |
---|
[3959] | 1553 | ROAR_DBG("main(*): setting sock_addr='%s'", sock_addr); |
---|
[60] | 1554 | } |
---|
[1753] | 1555 | #endif |
---|
[60] | 1556 | |
---|
[279] | 1557 | if ( getenv("ROAR_SERVER") != NULL ) |
---|
[2530] | 1558 | sock_addr = getenv("ROAR_SERVER"); |
---|
[1494] | 1559 | #endif |
---|
[279] | 1560 | |
---|
[63] | 1561 | if ( clients_init() == -1 ) { |
---|
| 1562 | ROAR_ERR("Can not init clients!"); |
---|
| 1563 | return 1; |
---|
| 1564 | } |
---|
| 1565 | |
---|
| 1566 | if ( streams_init() == -1 ) { |
---|
| 1567 | ROAR_ERR("Can not init streams!"); |
---|
| 1568 | return 1; |
---|
| 1569 | } |
---|
| 1570 | |
---|
[64] | 1571 | if ( (g_self_client = clients_new()) == -1 ) { |
---|
| 1572 | ROAR_ERR("Can not create self client!"); |
---|
| 1573 | return 1; |
---|
| 1574 | } |
---|
| 1575 | |
---|
[2485] | 1576 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[0] | 1577 | if ( sources_init() == -1 ) { |
---|
| 1578 | ROAR_ERR("Can not init sources!"); |
---|
| 1579 | return 1; |
---|
| 1580 | } |
---|
| 1581 | |
---|
[64] | 1582 | if ( (sources_set_client(g_self_client)) == -1 ) { |
---|
| 1583 | ROAR_ERR("Can not init set source client!"); |
---|
| 1584 | return 1; |
---|
| 1585 | } |
---|
[2485] | 1586 | #endif |
---|
[64] | 1587 | |
---|
[1503] | 1588 | #ifdef ROAR_HAVE_MAIN_ARGS |
---|
[0] | 1589 | for (i = 1; i < argc; i++) { |
---|
| 1590 | k = argv[i]; |
---|
| 1591 | |
---|
| 1592 | if ( strcmp(k, "-h") == 0 || strcmp(k, "--help") == 0 ) { |
---|
| 1593 | usage(); |
---|
| 1594 | return 0; |
---|
| 1595 | |
---|
[2109] | 1596 | } else if ( strcmp(k, "--start") == 0 ) { |
---|
| 1597 | // this is a no op |
---|
[4722] | 1598 | action = START; |
---|
[579] | 1599 | } else if ( strcmp(k, "--restart") == 0 ) { |
---|
[4722] | 1600 | action = RESTART; |
---|
[1494] | 1601 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[2530] | 1602 | if ( restart_server(sock_addr, 1) == -1 ) { |
---|
[4722] | 1603 | ROAR_WARN("Can not terminate old server (not running at %s?), will retry later.", sock_addr); |
---|
| 1604 | action = RESTART_RETRY; |
---|
[579] | 1605 | } |
---|
[1494] | 1606 | #else |
---|
| 1607 | ROAR_ERR("--restart not supported"); |
---|
| 1608 | #endif |
---|
[2109] | 1609 | } else if ( strcmp(k, "--shutdown") == 0 ) { |
---|
[4722] | 1610 | action = SHUTDOWN; |
---|
[2109] | 1611 | } else if ( strcmp(k, "--stop") == 0 ) { |
---|
[4722] | 1612 | action = STOP; |
---|
[2109] | 1613 | |
---|
[579] | 1614 | |
---|
[775] | 1615 | } else if ( strcmp(k, "--demon") == 0 || strcmp(k, "--daemon") == 0 ) { |
---|
[5060] | 1616 | #if defined(ROAR_HAVE_FORK) || defined(ROAR_TARGET_WIN32) |
---|
[775] | 1617 | daemon = 1; |
---|
[1486] | 1618 | #else |
---|
| 1619 | ROAR_ERR("--daemon not supported"); |
---|
| 1620 | #endif |
---|
[4986] | 1621 | } else if ( strcmp(k, "--verbose") == 0 ) { |
---|
| 1622 | g_verbose++; |
---|
| 1623 | |
---|
[4955] | 1624 | } else if ( strcmp(k, "--print-format") == 0 ) { |
---|
| 1625 | k = argv[++i]; |
---|
| 1626 | if ( !strcasecmp(k, "native") ) { |
---|
| 1627 | print_format = FORMAT_NATIVE; |
---|
| 1628 | } else if ( !strcasecmp(k, "wiki") ) { |
---|
| 1629 | print_format = FORMAT_WIKI; |
---|
| 1630 | } else if ( !strcasecmp(k, "csv") ) { |
---|
| 1631 | print_format = FORMAT_CSV; |
---|
| 1632 | } else { |
---|
| 1633 | ROAR_WARN("Unknown print format: %s", k); |
---|
| 1634 | } |
---|
| 1635 | |
---|
| 1636 | } else if ( strcmp(k, "--print-format") == 0 ) { |
---|
| 1637 | _CKHAVEARGS(1); |
---|
| 1638 | |
---|
[71] | 1639 | } else if ( strcmp(k, "--terminate") == 0 ) { |
---|
| 1640 | g_terminate = 1; |
---|
[905] | 1641 | } else if ( strcmp(k, "--sysclocksync") == 0 ) { |
---|
| 1642 | sysclocksync = 1000; |
---|
[275] | 1643 | } else if ( strcmp(k, "--realtime") == 0 ) { |
---|
[276] | 1644 | realtime++; |
---|
[4245] | 1645 | } else if ( strcmp(k, "--memlock") == 0 ) { |
---|
| 1646 | _CKHAVEARGS(1); |
---|
| 1647 | g_config->memlock_level = memlock_str2level(argv[++i]); |
---|
[444] | 1648 | } else if ( strcmp(k, "--chroot") == 0 ) { |
---|
[4052] | 1649 | _CKHAVEARGS(1); |
---|
[1486] | 1650 | #ifdef ROAR_HAVE_CHROOT |
---|
[444] | 1651 | chrootdir = argv[++i]; |
---|
[1486] | 1652 | #else |
---|
| 1653 | ROAR_ERR("--chroot not supported"); |
---|
| 1654 | i++; |
---|
| 1655 | #endif |
---|
[444] | 1656 | } else if ( strcmp(k, "--setgid") == 0 ) { |
---|
[1486] | 1657 | #ifdef ROAR_HAVE_SETGID |
---|
[444] | 1658 | setids |= R_SETGID; |
---|
[1486] | 1659 | #else |
---|
| 1660 | ROAR_ERR("--setgid not supported"); |
---|
| 1661 | #endif |
---|
[444] | 1662 | } else if ( strcmp(k, "--setuid") == 0 ) { |
---|
[1486] | 1663 | #ifdef ROAR_HAVE_SETUID |
---|
[444] | 1664 | setids |= R_SETUID; |
---|
[1486] | 1665 | #else |
---|
| 1666 | ROAR_ERR("--setuid not supported"); |
---|
| 1667 | #endif |
---|
[2017] | 1668 | } else if ( strcmp(k, "--location") == 0 ) { |
---|
[4052] | 1669 | _CKHAVEARGS(1); |
---|
[2017] | 1670 | g_config->location = argv[++i]; |
---|
[4421] | 1671 | } else if ( strcmp(k, "--description") == 0 ) { |
---|
| 1672 | _CKHAVEARGS(1); |
---|
| 1673 | g_config->description = argv[++i]; |
---|
[5279] | 1674 | } else if ( strcmp(k, "--contact") == 0 ) { |
---|
| 1675 | _CKHAVEARGS(1); |
---|
| 1676 | g_config->contact = argv[++i]; |
---|
| 1677 | } else if ( strcmp(k, "--serial") == 0 ) { |
---|
| 1678 | _CKHAVEARGS(1); |
---|
| 1679 | g_config->serial = argv[++i]; |
---|
| 1680 | } else if ( strcmp(k, "--uiurl") == 0 ) { |
---|
| 1681 | _CKHAVEARGS(1); |
---|
| 1682 | g_config->uiurl = argv[++i]; |
---|
[2104] | 1683 | } else if ( strcmp(k, "--pidfile") == 0 ) { |
---|
[4052] | 1684 | _CKHAVEARGS(1); |
---|
[2104] | 1685 | #ifdef SUPPORT_PIDFILE |
---|
| 1686 | pidfile = argv[++i]; |
---|
| 1687 | #else |
---|
| 1688 | ROAR_ERR("--pidfile not supported"); |
---|
| 1689 | i++; |
---|
| 1690 | #endif |
---|
[3688] | 1691 | } else if ( strcmp(k, "--log-syslog") == 0 ) { |
---|
| 1692 | #ifdef ROAR_HAVE_SYSLOG |
---|
| 1693 | roar_debug_set_stderr_mode(ROAR_DEBUG_MODE_SYSLOG); |
---|
| 1694 | #else |
---|
| 1695 | ROAR_ERR("--log-syslog not supported"); |
---|
| 1696 | #endif |
---|
[4851] | 1697 | } else if ( strcmp(k, "--script-postdown") == 0 ) { |
---|
| 1698 | _CKHAVEARGS(1); |
---|
| 1699 | #ifdef ROAR_HAVE_SYSTEM |
---|
| 1700 | g_config->scripts.post_shutdown = argv[++i]; |
---|
| 1701 | #else |
---|
| 1702 | ROAR_ERR("--script-postdown not supported"); |
---|
| 1703 | i++; |
---|
| 1704 | #endif |
---|
[3688] | 1705 | |
---|
[68] | 1706 | |
---|
[3356] | 1707 | } else if ( strcmp(k, "--plugin-load") == 0 ) { |
---|
[4052] | 1708 | _CKHAVEARGS(1); |
---|
[5275] | 1709 | if ( plugins_load(argv[++i], plugin_args) == -1 ) { |
---|
[3356] | 1710 | ROAR_ERR("Can not load plugin"); |
---|
| 1711 | } |
---|
[5275] | 1712 | plugin_args = NULL; |
---|
| 1713 | } else if ( strcmp(k, "--plugin-args") == 0 ) { |
---|
| 1714 | _CKHAVEARGS(1); |
---|
| 1715 | plugin_args = argv[++i]; |
---|
[3356] | 1716 | |
---|
[4482] | 1717 | } else if ( strcmp(k, "--guest-acclev") == 0 ) { |
---|
| 1718 | _CKHAVEARGS(1); |
---|
| 1719 | none_acclev = clients_str2acclev(argv[++i]); |
---|
[5146] | 1720 | if ( none_acclev == -1 ) { |
---|
| 1721 | ROAR_ERR("Invalid access level: %s", argv[i]); |
---|
| 1722 | return 1; |
---|
| 1723 | } |
---|
[4482] | 1724 | } else if ( strcmp(k, "--trust-acclev") == 0 ) { |
---|
| 1725 | _CKHAVEARGS(1); |
---|
| 1726 | trust_acclev = clients_str2acclev(argv[++i]); |
---|
[5146] | 1727 | if ( trust_acclev == -1 ) { |
---|
| 1728 | ROAR_ERR("Invalid access level: %s", argv[i]); |
---|
| 1729 | return 1; |
---|
| 1730 | } |
---|
[4482] | 1731 | } else if ( strcmp(k, "--trust-root") == 0 ) { |
---|
| 1732 | trust_root = 1; |
---|
| 1733 | } else if ( strcmp(k, "--no-trust-root") == 0 ) { |
---|
| 1734 | trust_root = 0; |
---|
| 1735 | |
---|
[4788] | 1736 | } else if ( strcmp(k, "--authfile-gen") == 0 ) { |
---|
| 1737 | _CKHAVEARGS(1); |
---|
| 1738 | af_file = argv[++i]; |
---|
| 1739 | af_mode = AF_MODE_GEN; |
---|
| 1740 | } else if ( strcmp(k, "--authfile-load") == 0 ) { |
---|
| 1741 | _CKHAVEARGS(1); |
---|
| 1742 | af_file = argv[++i]; |
---|
| 1743 | af_mode = AF_MODE_LOAD; |
---|
| 1744 | } else if ( strcmp(k, "--authfile-type") == 0 ) { |
---|
| 1745 | _CKHAVEARGS(1); |
---|
| 1746 | af_type = argv[++i]; |
---|
| 1747 | } else if ( strcmp(k, "--authfile-acclev") == 0 ) { |
---|
| 1748 | _CKHAVEARGS(1); |
---|
| 1749 | af_acclev = clients_str2acclev(argv[++i]); |
---|
[4789] | 1750 | } else if ( strcmp(k, "--new-authfile") == 0 ) { |
---|
| 1751 | if ( af_mode != AF_MODE_NONE ) { |
---|
| 1752 | if ( add_authfile(af_file, af_type, af_mode, af_acclev) == -1 ) { |
---|
| 1753 | ROAR_ERR("main(*): adding authfile '%s' failed!", af_file); |
---|
| 1754 | } |
---|
| 1755 | } |
---|
| 1756 | af_file = NULL; |
---|
| 1757 | af_type = NULL; |
---|
| 1758 | af_mode = AF_MODE_NONE; |
---|
| 1759 | af_acclev = ACCLEV_ALL; |
---|
[4788] | 1760 | |
---|
[280] | 1761 | } else if ( strcmp(k, "--list-cf") == 0 ) { |
---|
| 1762 | print_codecfilterlist(); |
---|
| 1763 | return 0; |
---|
| 1764 | |
---|
[0] | 1765 | } else if ( strcmp(k, "-R") == 0 || strcmp(k, "--rate") == 0 ) { |
---|
[4052] | 1766 | _CKHAVEARGS(1); |
---|
[0] | 1767 | sa.rate = atoi(argv[++i]); |
---|
| 1768 | } else if ( strcmp(k, "-B") == 0 || strcmp(k, "--bits") == 0 ) { |
---|
[4052] | 1769 | _CKHAVEARGS(1); |
---|
[0] | 1770 | sa.bits = atoi(argv[++i]); |
---|
| 1771 | } else if ( strcmp(k, "-C") == 0 || strcmp(k, "--chans") == 0 ) { |
---|
[4052] | 1772 | _CKHAVEARGS(1); |
---|
[0] | 1773 | sa.channels = atoi(argv[++i]); |
---|
| 1774 | |
---|
[3962] | 1775 | } else if ( strcmp(k, "--aiprofile") == 0 ) { |
---|
[4052] | 1776 | _CKHAVEARGS(1); |
---|
[3962] | 1777 | if ( roar_profile2info(&sa, argv[++i]) == -1 ) { |
---|
| 1778 | ROAR_ERR("Unknown audio profile: %s", argv[i]); |
---|
| 1779 | return 1; |
---|
| 1780 | } |
---|
| 1781 | sa.codec = ROAR_CODEC_DEFAULT; |
---|
| 1782 | |
---|
[2339] | 1783 | } else if ( strcmp(k, "--stream-flags") == 0 ) { |
---|
[4052] | 1784 | _CKHAVEARGS(1); |
---|
[2339] | 1785 | if ( update_stream_flags(argv[++i]) == -1 ) { |
---|
| 1786 | ROAR_ERR("Can not set stream flags"); |
---|
| 1787 | return 1; |
---|
| 1788 | } |
---|
| 1789 | |
---|
[4934] | 1790 | } else if ( strcmp(k, "--list-rolestack") == 0 ) { |
---|
| 1791 | print_rolestack(); |
---|
| 1792 | return 0; |
---|
| 1793 | } else if ( strcmp(k, "--rolestack-push") == 0 ) { |
---|
| 1794 | _CKHAVEARGS(1); |
---|
| 1795 | if ( (rolestack = rolestack_parse(argv[++i])) == NULL ) { |
---|
| 1796 | ROAR_ERR("Can not parse rolestack request: %s", roar_error2str(roar_error)); |
---|
| 1797 | } else { |
---|
| 1798 | if ( rolestack_push(rolestack) == -1 ) { |
---|
| 1799 | ROAR_ERR("Can not push request to rolestack: %s", roar_error2str(roar_error)); |
---|
| 1800 | } |
---|
| 1801 | } |
---|
| 1802 | |
---|
[4882] | 1803 | } else if ( strcmp(k, "--list-aiprofiles") == 0 ) { |
---|
| 1804 | list_aiprofiles(); |
---|
| 1805 | return 0; |
---|
| 1806 | |
---|
[973] | 1807 | } else if ( strcmp(k, "--list-driver") == 0 ) { |
---|
[4955] | 1808 | print_driverlist(print_format); |
---|
[973] | 1809 | return 0; |
---|
[0] | 1810 | |
---|
[932] | 1811 | } else if ( strcmp(k, "-o") == 0 || strcmp(k, "--odriver") == 0 ) { |
---|
[4052] | 1812 | _CKHAVEARGS(1); |
---|
[932] | 1813 | o_drv = argv[++i]; |
---|
| 1814 | } else if ( strcmp(k, "-O") == 0 || strcmp(k, "--odevice") == 0 ) { |
---|
[4052] | 1815 | _CKHAVEARGS(1); |
---|
[932] | 1816 | o_dev = argv[++i]; |
---|
| 1817 | } else if ( strcmp(k, "-oO") == 0 ) { |
---|
[4052] | 1818 | _CKHAVEARGS(1); |
---|
[932] | 1819 | o_opts = argv[++i]; |
---|
[961] | 1820 | } else if ( strcmp(k, "-oP") == 0 ) { |
---|
| 1821 | o_prim = 1; |
---|
[932] | 1822 | } else if ( strcmp(k, "-oN") == 0 ) { |
---|
[4722] | 1823 | if ( action == START || action == RESTART ) { |
---|
[4852] | 1824 | if ( output_add(o_drv, o_dev, o_opts, o_prim, o_count) != -1 ) |
---|
[4722] | 1825 | o_count++; |
---|
[1145] | 1826 | |
---|
[4722] | 1827 | o_drv = o_dev = o_opts = NULL; |
---|
| 1828 | o_prim = 0; |
---|
| 1829 | } |
---|
[932] | 1830 | |
---|
[0] | 1831 | } else if ( strcmp(k, "-s") == 0 || strcmp(k, "--source") == 0 ) { |
---|
[4052] | 1832 | _CKHAVEARGS(1); |
---|
[2485] | 1833 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[550] | 1834 | s_drv = argv[++i]; |
---|
[2485] | 1835 | #else |
---|
| 1836 | ROAR_ERR("main(*): No support for sources compiled in"); |
---|
[4052] | 1837 | i++; |
---|
[2485] | 1838 | #endif |
---|
[550] | 1839 | } else if ( strcmp(k, "-S") == 0 ) { |
---|
[4052] | 1840 | _CKHAVEARGS(1); |
---|
[2485] | 1841 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[1110] | 1842 | s_dev = argv[++i]; |
---|
[2485] | 1843 | #else |
---|
| 1844 | ROAR_ERR("main(*): No support for sources compiled in"); |
---|
[4052] | 1845 | i++; |
---|
[2485] | 1846 | #endif |
---|
[0] | 1847 | } else if ( strcmp(k, "-sO") == 0 ) { |
---|
[4052] | 1848 | _CKHAVEARGS(1); |
---|
[2485] | 1849 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[0] | 1850 | s_opt = argv[++i]; |
---|
[2485] | 1851 | #else |
---|
| 1852 | ROAR_ERR("main(*): No support for sources compiled in"); |
---|
[4052] | 1853 | i++; |
---|
[2485] | 1854 | #endif |
---|
[0] | 1855 | } else if ( strcmp(k, "-sC") == 0 ) { |
---|
[4052] | 1856 | _CKHAVEARGS(1); |
---|
[2485] | 1857 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[0] | 1858 | s_con = argv[++i]; |
---|
[2485] | 1859 | #else |
---|
| 1860 | ROAR_ERR("main(*): No support for sources compiled in"); |
---|
[4052] | 1861 | i++; |
---|
[2485] | 1862 | #endif |
---|
[0] | 1863 | } else if ( strcmp(k, "-sP") == 0 ) { |
---|
[2485] | 1864 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[0] | 1865 | s_prim = 1; |
---|
[2485] | 1866 | #else |
---|
| 1867 | ROAR_ERR("main(*): No support for sources compiled in"); |
---|
| 1868 | #endif |
---|
[1110] | 1869 | } else if ( strcmp(k, "-sN") == 0 ) { |
---|
[2485] | 1870 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[1110] | 1871 | if ( sources_add(s_drv, s_dev, s_con, s_opt, s_prim) == -1 ) { |
---|
| 1872 | ROAR_ERR("main(*): adding source '%s' via '%s' failed!", s_dev, s_drv); |
---|
| 1873 | } |
---|
| 1874 | s_opt = s_dev = s_con = NULL; |
---|
[5103] | 1875 | s_drv = NULL; |
---|
[1110] | 1876 | s_prim = 0; |
---|
[2485] | 1877 | #else |
---|
| 1878 | ROAR_ERR("main(*): No support for sources compiled in"); |
---|
| 1879 | #endif |
---|
[2270] | 1880 | } else if ( strcmp(k, "--list-sources") == 0 ) { |
---|
[2485] | 1881 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[2270] | 1882 | print_sourcelist(); |
---|
| 1883 | return 0; |
---|
[2485] | 1884 | #else |
---|
| 1885 | ROAR_ERR("main(*): No support for sources compiled in"); |
---|
[2504] | 1886 | return 1; |
---|
[2485] | 1887 | #endif |
---|
[0] | 1888 | |
---|
[4358] | 1889 | } else if ( strcmp(k, "-m") == 0 || strcmp(k, "--mixer") == 0 ) { |
---|
| 1890 | _CKHAVEARGS(1); |
---|
| 1891 | #ifndef ROAR_WITHOUT_DCOMP_MIXER |
---|
| 1892 | m_drv = argv[++i]; |
---|
| 1893 | #else |
---|
| 1894 | ROAR_ERR("main(*): No support for mixer compiled in"); |
---|
| 1895 | return 1; |
---|
| 1896 | #endif |
---|
| 1897 | } else if ( strcmp(k, "-M") == 0 ) { |
---|
| 1898 | _CKHAVEARGS(1); |
---|
| 1899 | #ifndef ROAR_WITHOUT_DCOMP_MIXER |
---|
| 1900 | m_dev = argv[++i]; |
---|
| 1901 | #else |
---|
| 1902 | ROAR_ERR("main(*): No support for mixer compiled in"); |
---|
| 1903 | return 1; |
---|
| 1904 | #endif |
---|
| 1905 | } else if ( strcmp(k, "-mO") == 0 ) { |
---|
| 1906 | _CKHAVEARGS(1); |
---|
| 1907 | #ifndef ROAR_WITHOUT_DCOMP_MIXER |
---|
| 1908 | m_opts = argv[++i]; |
---|
| 1909 | #else |
---|
| 1910 | ROAR_ERR("main(*): No support for mixer compiled in"); |
---|
| 1911 | return 1; |
---|
| 1912 | #endif |
---|
| 1913 | } else if ( strcmp(k, "-mP") == 0 ) { |
---|
| 1914 | #ifndef ROAR_WITHOUT_DCOMP_MIXER |
---|
| 1915 | m_prim = 1; |
---|
| 1916 | #else |
---|
| 1917 | ROAR_ERR("main(*): No support for mixer compiled in"); |
---|
| 1918 | return 1; |
---|
| 1919 | #endif |
---|
| 1920 | } else if ( strcmp(k, "-mN") == 0 ) { |
---|
| 1921 | #ifndef ROAR_WITHOUT_DCOMP_MIXER |
---|
[4852] | 1922 | if ( hwmixer_add(m_drv, m_dev, m_opts, m_prim, m_count) != -1 ) |
---|
[4358] | 1923 | m_count++; |
---|
| 1924 | |
---|
| 1925 | m_drv = o_dev = o_opts = NULL; |
---|
| 1926 | m_prim = 0; |
---|
| 1927 | #else |
---|
| 1928 | ROAR_ERR("main(*): No support for mixer compiled in"); |
---|
| 1929 | return 1; |
---|
| 1930 | #endif |
---|
[4360] | 1931 | } else if ( strcmp(k, "--list-mixers") == 0 ) { |
---|
| 1932 | #ifndef ROAR_WITHOUT_DCOMP_MIXER |
---|
| 1933 | print_hwmixerlist(); |
---|
| 1934 | return 0; |
---|
| 1935 | #else |
---|
| 1936 | ROAR_ERR("main(*): No support for mixer compiled in"); |
---|
| 1937 | return 1; |
---|
| 1938 | #endif |
---|
[4358] | 1939 | |
---|
[1923] | 1940 | } else if ( strcmp(k, "--light-channels") == 0 ) { |
---|
[4052] | 1941 | _CKHAVEARGS(1); |
---|
[2494] | 1942 | #ifndef ROAR_WITHOUT_DCOMP_LIGHT |
---|
[1923] | 1943 | light_channels = atoi(argv[++i]); |
---|
[2494] | 1944 | #else |
---|
| 1945 | ROAR_WARN("main(*): no light subsystem compiled in"); |
---|
[4052] | 1946 | i++; |
---|
[2494] | 1947 | #endif |
---|
[1923] | 1948 | |
---|
[2725] | 1949 | } else if ( strcmp(k, "--rds-pi") == 0 ) { |
---|
[4052] | 1950 | _CKHAVEARGS(1); |
---|
[2725] | 1951 | #ifndef ROAR_WITHOUT_DCOMP_RDTCS |
---|
| 1952 | g_rdtcs.rds.pi = atoi(argv[++i]); |
---|
| 1953 | #else |
---|
| 1954 | ROAR_WARN("main(*): no RDTCS subsystem compiled in"); |
---|
[4052] | 1955 | i++; |
---|
[2725] | 1956 | #endif |
---|
[2728] | 1957 | } else if ( strcmp(k, "--rds-ps") == 0 ) { |
---|
[4052] | 1958 | _CKHAVEARGS(1); |
---|
[2728] | 1959 | #ifndef ROAR_WITHOUT_DCOMP_RDTCS |
---|
| 1960 | if ( rdtcs_rds_set_ps(argv[++i]) == -1 ) { |
---|
[2729] | 1961 | ROAR_ERR("Can not set RDS PS to '%s' (longer than 8 chars?)", argv[i]); |
---|
[2728] | 1962 | return 1; |
---|
| 1963 | } |
---|
| 1964 | #else |
---|
| 1965 | ROAR_WARN("main(*): no RDTCS subsystem compiled in"); |
---|
[4052] | 1966 | i++; |
---|
[2728] | 1967 | #endif |
---|
| 1968 | } else if ( strcmp(k, "--rds-pty") == 0 ) { |
---|
[4052] | 1969 | _CKHAVEARGS(1); |
---|
[2728] | 1970 | #ifndef ROAR_WITHOUT_DCOMP_RDTCS |
---|
| 1971 | if ( rdtcs_rds_set_pty(argv[++i]) == -1 ) { |
---|
[2729] | 1972 | ROAR_ERR("Can not set RDS PTY to '%s'", argv[i]); |
---|
[2728] | 1973 | return 1; |
---|
| 1974 | } |
---|
| 1975 | #else |
---|
| 1976 | ROAR_WARN("main(*): no RDTCS subsystem compiled in"); |
---|
[4052] | 1977 | i++; |
---|
[2728] | 1978 | #endif |
---|
| 1979 | } else if ( strcmp(k, "--rds-tp") == 0 ) { |
---|
| 1980 | #ifndef ROAR_WITHOUT_DCOMP_RDTCS |
---|
| 1981 | if ( rdtcs_rds_set_flag(RDTCS_RDS_FLAG_TP, 0) == -1 ) { |
---|
| 1982 | ROAR_ERR("Can not set RDS TP flag"); |
---|
| 1983 | return 1; |
---|
| 1984 | } |
---|
| 1985 | #else |
---|
| 1986 | ROAR_WARN("main(*): no RDTCS subsystem compiled in"); |
---|
| 1987 | #endif |
---|
| 1988 | } else if ( strcmp(k, "--rds-ct") == 0 ) { |
---|
| 1989 | #ifndef ROAR_WITHOUT_DCOMP_RDTCS |
---|
| 1990 | if ( rdtcs_rds_set_flag(RDTCS_RDS_FLAG_CT, 0) == -1 ) { |
---|
| 1991 | ROAR_ERR("Can not set RDS CT flag"); |
---|
| 1992 | return 1; |
---|
| 1993 | } |
---|
| 1994 | #else |
---|
| 1995 | ROAR_WARN("main(*): no RDTCS subsystem compiled in"); |
---|
| 1996 | #endif |
---|
| 1997 | |
---|
[2725] | 1998 | |
---|
[1924] | 1999 | } else if ( strcmp(k, "--midi-no-console") == 0 ) { |
---|
[2487] | 2000 | #ifndef ROAR_WITHOUT_DCOMP_CB |
---|
[1924] | 2001 | midi_config.init_cb = 0; |
---|
[2487] | 2002 | #else |
---|
| 2003 | // no warning here as this is the disable option |
---|
| 2004 | #endif |
---|
[2444] | 2005 | } else if ( strcmp(k, "--midi-console-enable") == 0 ) { |
---|
[2487] | 2006 | #ifndef ROAR_WITHOUT_DCOMP_CB |
---|
[2444] | 2007 | midi_config.init_cb = 1; |
---|
[2487] | 2008 | #else |
---|
| 2009 | ROAR_ERR("main(*): No support for MIDI subsystem part CB compiled in"); |
---|
| 2010 | #endif |
---|
[1924] | 2011 | } else if ( strcmp(k, "--midi-console") == 0 ) { |
---|
[4052] | 2012 | _CKHAVEARGS(1); |
---|
[2487] | 2013 | #ifndef ROAR_WITHOUT_DCOMP_CB |
---|
[1924] | 2014 | midi_config.console_dev = argv[++i]; |
---|
[2444] | 2015 | midi_config.init_cb = 1; |
---|
[2487] | 2016 | #else |
---|
| 2017 | ROAR_ERR("main(*): No support for MIDI subsystem part CB compiled in"); |
---|
[4052] | 2018 | i++; |
---|
[2487] | 2019 | #endif |
---|
[1924] | 2020 | |
---|
[2451] | 2021 | } else if ( strcmp(k, "--ssynth-enable") == 0 ) { |
---|
[2489] | 2022 | #ifndef ROAR_WITHOUT_DCOMP_SSYNTH |
---|
[2451] | 2023 | ssynth_conf.enable = 1; |
---|
[2489] | 2024 | #else |
---|
| 2025 | ROAR_ERR("main(*): No support for ssynth compiled in"); |
---|
| 2026 | #endif |
---|
[2451] | 2027 | } else if ( strcmp(k, "--ssynth-disable") == 0 ) { |
---|
[2489] | 2028 | #ifndef ROAR_WITHOUT_DCOMP_SSYNTH |
---|
[2451] | 2029 | ssynth_conf.enable = 0; |
---|
[2489] | 2030 | #else |
---|
| 2031 | // we can safely ignore the disable |
---|
| 2032 | #endif |
---|
[2451] | 2033 | |
---|
[3374] | 2034 | } else if ( strcmp(k, "--x11-display") == 0 || strcmp(k, "--display") == 0 ) { |
---|
[4052] | 2035 | _CKHAVEARGS(1); |
---|
[3374] | 2036 | #ifdef ROAR_HAVE_LIBX11 |
---|
| 2037 | x11display = argv[++i]; |
---|
| 2038 | #else |
---|
| 2039 | ROAR_ERR("No X11 support compiled in!"); |
---|
| 2040 | return 1; |
---|
| 2041 | #endif |
---|
| 2042 | |
---|
| 2043 | |
---|
[0] | 2044 | } else if ( strcmp(k, "-p") == 0 || strcmp(k, "--port") == 0 ) { |
---|
[4052] | 2045 | _CKHAVEARGS(1); |
---|
[4012] | 2046 | // This is only useful in INET not UNIX mode. |
---|
[1494] | 2047 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[2530] | 2048 | if ( *sock_addr == '/' ) |
---|
| 2049 | sock_addr = ROAR_DEFAULT_HOST; |
---|
[447] | 2050 | |
---|
[446] | 2051 | errno = 0; |
---|
| 2052 | if ( (port = atoi(argv[++i])) < 1 ) { |
---|
[1486] | 2053 | #ifdef ROAR_HAVE_GETSERVBYNAME |
---|
[446] | 2054 | if ( (serv = getservbyname(argv[i], "tcp")) == NULL ) { |
---|
| 2055 | ROAR_ERR("Unknown service: %s: %s", argv[i], strerror(errno)); |
---|
| 2056 | return 1; |
---|
| 2057 | } |
---|
| 2058 | // NOTE: we need to use ROAR_NET2HOST16() here even if s_port is of type int! |
---|
| 2059 | ROAR_DBG("main(*): serv = {s_name='%s', s_aliases={...}, s_port=%i, s_proto='%s'}", |
---|
| 2060 | serv->s_name, ROAR_NET2HOST16(serv->s_port), serv->s_proto); |
---|
| 2061 | port = ROAR_NET2HOST16(serv->s_port); |
---|
[1486] | 2062 | #else |
---|
| 2063 | ROAR_ERR("invalite port number: %s", argv[i]); |
---|
| 2064 | return 1; |
---|
| 2065 | #endif |
---|
[446] | 2066 | } |
---|
[1494] | 2067 | #endif |
---|
[1115] | 2068 | } else if ( strcmp(k, "-b") == 0 || strcmp(k, "--bind") == 0 || strcmp(k, "--sock") == 0 ) { |
---|
[4052] | 2069 | _CKHAVEARGS(1); |
---|
[1494] | 2070 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[2530] | 2071 | sock_addr = argv[++i]; |
---|
[4052] | 2072 | #else |
---|
| 2073 | i++; |
---|
[2530] | 2074 | #endif |
---|
| 2075 | |
---|
| 2076 | } else if ( strcmp(k, "--proto") == 0 ) { |
---|
| 2077 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[2549] | 2078 | if ( (sock_proto = roar_str2proto(argv[++i])) == -1 ) { |
---|
[2530] | 2079 | ROAR_ERR("Unknown protocol: %s", argv[i]); |
---|
| 2080 | return 1; |
---|
| 2081 | } |
---|
[1494] | 2082 | #endif |
---|
[3252] | 2083 | } else if ( strcmp(k, "--proto-dir") == 0 ) { |
---|
[4052] | 2084 | _CKHAVEARGS(1); |
---|
[3252] | 2085 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2086 | if ( (sock_dir = roar_str2dir(argv[++i])) == -1 ) { |
---|
| 2087 | ROAR_ERR("Unknown stream direction: %s", argv[i]); |
---|
| 2088 | return 1; |
---|
| 2089 | } |
---|
[4052] | 2090 | #else |
---|
| 2091 | i++; |
---|
[3252] | 2092 | #endif |
---|
| 2093 | } else if ( strcmp(k, "--proto-rate") == 0 ) { |
---|
[4052] | 2094 | _CKHAVEARGS(1); |
---|
[3252] | 2095 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2096 | sock_info.rate = atoi(argv[++i]); |
---|
[4052] | 2097 | #else |
---|
| 2098 | i++; |
---|
[3252] | 2099 | #endif |
---|
| 2100 | } else if ( strcmp(k, "--proto-bits") == 0 ) { |
---|
[4052] | 2101 | _CKHAVEARGS(1); |
---|
[3252] | 2102 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2103 | sock_info.bits = atoi(argv[++i]); |
---|
[4052] | 2104 | #else |
---|
| 2105 | i++; |
---|
[3252] | 2106 | #endif |
---|
| 2107 | } else if ( strcmp(k, "--proto-chans") == 0 ) { |
---|
[4052] | 2108 | _CKHAVEARGS(1); |
---|
[3252] | 2109 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2110 | sock_info.channels = atoi(argv[++i]); |
---|
[4052] | 2111 | #else |
---|
| 2112 | i++; |
---|
[3252] | 2113 | #endif |
---|
| 2114 | } else if ( strcmp(k, "--proto-codec") == 0 ) { |
---|
[4052] | 2115 | _CKHAVEARGS(1); |
---|
[3252] | 2116 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2117 | if ( (sock_info.codec = roar_str2codec(argv[++i])) == -1 ) { |
---|
| 2118 | ROAR_ERR("Unknown codec: %s", argv[i]); |
---|
| 2119 | return 1; |
---|
| 2120 | } |
---|
[4052] | 2121 | #else |
---|
| 2122 | i++; |
---|
[3252] | 2123 | #endif |
---|
[3954] | 2124 | } else if ( strcmp(k, "--proto-aiprofile") == 0 ) { |
---|
[4052] | 2125 | _CKHAVEARGS(1); |
---|
[3954] | 2126 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2127 | if ( roar_profile2info(&sock_info, argv[++i]) == -1 ) { |
---|
| 2128 | ROAR_ERR("Unknown audio profile: %s", argv[i]); |
---|
| 2129 | return 1; |
---|
| 2130 | } |
---|
[4052] | 2131 | #else |
---|
| 2132 | i++; |
---|
[3954] | 2133 | #endif |
---|
[3956] | 2134 | } else if ( strcmp(k, "--list-profiles") == 0 ) { |
---|
| 2135 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2136 | listen_listen_profiles(); |
---|
| 2137 | return 0; |
---|
| 2138 | #endif |
---|
| 2139 | } else if ( strcmp(k, "--proto-profile") == 0 ) { |
---|
[4052] | 2140 | _CKHAVEARGS(1); |
---|
[3956] | 2141 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2142 | if ( get_listen_profile(argv[++i], &port, &sock_addr, &sock_type, &sock_proto, &sock_dir, &sock_info) == -1 ) { |
---|
| 2143 | ROAR_ERR("Unknown listen profile: %s", argv[i]); |
---|
| 2144 | return 1; |
---|
| 2145 | } |
---|
[4052] | 2146 | #else |
---|
| 2147 | i++; |
---|
[3956] | 2148 | #endif |
---|
[3252] | 2149 | |
---|
| 2150 | |
---|
[3127] | 2151 | } else if ( strcmp(k, "--list-proto") == 0 ) { |
---|
[5275] | 2152 | print_protolist(print_format); |
---|
[3127] | 2153 | return 0; |
---|
[518] | 2154 | |
---|
[573] | 2155 | } else if ( strcmp(k, "-t") == 0 || strcmp(k, "--tcp") == 0 ) { |
---|
[1494] | 2156 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[518] | 2157 | if ( sock_type != ROAR_SOCKET_TYPE_TCP && sock_type != ROAR_SOCKET_TYPE_TCP6 ) |
---|
| 2158 | sock_type = ROAR_SOCKET_TYPE_TCP; |
---|
| 2159 | |
---|
[2530] | 2160 | if ( *sock_addr == '/' ) |
---|
| 2161 | sock_addr = ROAR_DEFAULT_HOST; |
---|
[1494] | 2162 | #endif |
---|
[518] | 2163 | |
---|
| 2164 | } else if ( strcmp(k, "-4") == 0 ) { |
---|
[1494] | 2165 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[517] | 2166 | sock_type = ROAR_SOCKET_TYPE_TCP; |
---|
[2530] | 2167 | if ( *sock_addr == '/' ) |
---|
| 2168 | sock_addr = ROAR_DEFAULT_HOST; |
---|
[1494] | 2169 | #endif |
---|
[518] | 2170 | } else if ( strcmp(k, "-6") == 0 ) { |
---|
[1494] | 2171 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[3837] | 2172 | #ifdef AF_INET6 |
---|
[518] | 2173 | sock_type = ROAR_SOCKET_TYPE_TCP6; |
---|
[2530] | 2174 | if ( *sock_addr == '/' ) |
---|
| 2175 | sock_addr = ROAR_DEFAULT_HOST; |
---|
[519] | 2176 | #else |
---|
| 2177 | ROAR_ERR("No IPv6 support compiled in!"); |
---|
| 2178 | return 1; |
---|
| 2179 | #endif |
---|
[1494] | 2180 | #endif |
---|
[518] | 2181 | |
---|
[573] | 2182 | } else if ( strcmp(k, "-u") == 0 || strcmp(k, "--unix") == 0 ) { |
---|
[1494] | 2183 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[62] | 2184 | // ignore this case as it is the default behavor. |
---|
[517] | 2185 | sock_type = ROAR_SOCKET_TYPE_UNIX; |
---|
[1494] | 2186 | #endif |
---|
[518] | 2187 | |
---|
[573] | 2188 | } else if ( strcmp(k, "-n") == 0 || strcmp(k, "--decnet") == 0 ) { |
---|
[1494] | 2189 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[508] | 2190 | #ifdef ROAR_HAVE_LIBDNET |
---|
| 2191 | port = ROAR_DEFAULT_NUM; |
---|
| 2192 | strcpy(decnethost, ROAR_DEFAULT_LISTEN_OBJECT); |
---|
[2530] | 2193 | sock_addr = decnethost; |
---|
[517] | 2194 | sock_type = ROAR_SOCKET_TYPE_DECNET; |
---|
[508] | 2195 | #else |
---|
| 2196 | ROAR_ERR("No DECnet support compiled in!"); |
---|
| 2197 | return 1; |
---|
| 2198 | #endif |
---|
[1494] | 2199 | #endif |
---|
[2530] | 2200 | } else if ( strcmp(k, "--new-sock") == 0 ) { |
---|
| 2201 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[4722] | 2202 | if ( action == START || action == RESTART ) { |
---|
| 2203 | if ( add_listen(sock_addr, port, sock_type, sock_user, sock_grp, sock_proto, sock_dir, &sock_info) != 0 ) { |
---|
| 2204 | ROAR_ERR("Can not open listen socket!"); |
---|
| 2205 | return 1; |
---|
| 2206 | } |
---|
[2530] | 2207 | } |
---|
| 2208 | #endif |
---|
[518] | 2209 | |
---|
[1993] | 2210 | } else if ( strcmp(k, "--slp") == 0 ) { |
---|
| 2211 | #ifdef ROAR_HAVE_LIBSLP |
---|
| 2212 | reg_slp = 1; |
---|
| 2213 | #else |
---|
[3373] | 2214 | ROAR_ERR("No OpenSLP support compiled in!"); |
---|
| 2215 | return 1; |
---|
[1993] | 2216 | #endif |
---|
| 2217 | |
---|
[3373] | 2218 | } else if ( strcmp(k, "--x11") == 0 ) { |
---|
| 2219 | #ifdef ROAR_HAVE_LIBX11 |
---|
| 2220 | reg_x11 = 1; |
---|
| 2221 | #else |
---|
| 2222 | ROAR_ERR("No X11 support compiled in!"); |
---|
| 2223 | return 1; |
---|
| 2224 | #endif |
---|
| 2225 | |
---|
| 2226 | |
---|
[3039] | 2227 | } else if ( strcmp(k, "--jumbo-mtu") == 0 ) { |
---|
[4052] | 2228 | _CKHAVEARGS(1); |
---|
[3039] | 2229 | g_config->jumbo_mtu = atoi(argv[++i]); |
---|
| 2230 | |
---|
[60] | 2231 | } else if ( strcmp(k, "-G") == 0 ) { |
---|
[4052] | 2232 | _CKHAVEARGS(1); |
---|
[444] | 2233 | sock_grp = argv[++i]; |
---|
| 2234 | } else if ( strcmp(k, "-U") == 0 ) { |
---|
[4052] | 2235 | _CKHAVEARGS(1); |
---|
[444] | 2236 | sock_user = argv[++i]; |
---|
[0] | 2237 | |
---|
[68] | 2238 | } else if ( strcmp(k, "--no-listen") == 0 ) { |
---|
[1494] | 2239 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[2530] | 2240 | sock_addr = ""; |
---|
[548] | 2241 | g_terminate = 1; |
---|
[1155] | 2242 | g_no_listen = 1; |
---|
[1494] | 2243 | #endif |
---|
[68] | 2244 | } else if ( strcmp(k, "--client-fh") == 0 ) { |
---|
[4052] | 2245 | _CKHAVEARGS(1); |
---|
[3737] | 2246 | if ( clients_new_from_fh(atoi(argv[++i]), ROAR_PROTO_ROARAUDIO, ROAR_BYTEORDER_NETWORK, 1) == -1 ) { |
---|
[68] | 2247 | ROAR_ERR("main(*): Can not set client's fh"); |
---|
| 2248 | return 1; |
---|
| 2249 | } |
---|
[501] | 2250 | } else if ( strcmp(k, "--close-fh") == 0 ) { |
---|
[4052] | 2251 | _CKHAVEARGS(1); |
---|
[1486] | 2252 | #ifdef ROAR_HAVE_IO_POSIX |
---|
[501] | 2253 | close(atoi(argv[++i])); |
---|
[1486] | 2254 | #else |
---|
| 2255 | i++; |
---|
| 2256 | ROAR_WARN("can not close file handle %s (closing not supported)", argv[i]); |
---|
| 2257 | #endif |
---|
[68] | 2258 | |
---|
[920] | 2259 | } else if ( strcmp(k, "--standby") == 0 ) { |
---|
| 2260 | g_standby = 1; |
---|
| 2261 | } else if ( strcmp(k, "--auto-standby") == 0 ) { |
---|
| 2262 | g_autostandby = 1; |
---|
[0] | 2263 | } else { |
---|
| 2264 | usage(); |
---|
| 2265 | return 1; |
---|
| 2266 | } |
---|
| 2267 | |
---|
| 2268 | } |
---|
[1503] | 2269 | #endif |
---|
[0] | 2270 | |
---|
[4722] | 2271 | #ifdef ROAR_HAVE_MAIN_ARGS |
---|
| 2272 | switch (action) { |
---|
| 2273 | case START: |
---|
| 2274 | // NO-OP. |
---|
| 2275 | break; |
---|
| 2276 | case RESTART: |
---|
| 2277 | // NO-OP, done before. |
---|
| 2278 | break; |
---|
| 2279 | case STOP: |
---|
| 2280 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2281 | if ( restart_server(sock_addr, 0) == -1 ) { |
---|
| 2282 | ROAR_WARN("Can not stop old server (not running at %s?)", sock_addr); |
---|
| 2283 | return 1; |
---|
| 2284 | } |
---|
| 2285 | return 0; |
---|
| 2286 | #else |
---|
| 2287 | ROAR_ERR("--stop not supported"); |
---|
| 2288 | return 1; |
---|
| 2289 | #endif |
---|
| 2290 | break; |
---|
| 2291 | case SHUTDOWN: |
---|
| 2292 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2293 | if ( restart_server(sock_addr, 1) == -1 ) { |
---|
| 2294 | ROAR_WARN("Can not terminate old server (not running at %s?)", sock_addr); |
---|
| 2295 | return 1; |
---|
| 2296 | } |
---|
| 2297 | return 0; |
---|
| 2298 | #else |
---|
| 2299 | ROAR_ERR("--shutdown not supported"); |
---|
| 2300 | return 1; |
---|
| 2301 | #endif |
---|
| 2302 | break; |
---|
| 2303 | case RESTART_RETRY: |
---|
| 2304 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 2305 | if ( restart_server(sock_addr, 1) == -1 ) { |
---|
| 2306 | ROAR_WARN("Can not terminate old server (again) (not running at %s?), tring to continue anyway", sock_addr); |
---|
| 2307 | action = RESTART; |
---|
| 2308 | } |
---|
| 2309 | #endif |
---|
| 2310 | break; |
---|
| 2311 | } |
---|
| 2312 | #endif |
---|
| 2313 | |
---|
[4418] | 2314 | #ifndef DEBUG |
---|
| 2315 | // notify dbg if requested, if in DEBUG mode |
---|
| 2316 | // do not able because it got enabled early. |
---|
| 2317 | if ( g_verbose >= 4 ) |
---|
| 2318 | dbg_notify_cb_register(); |
---|
| 2319 | #endif |
---|
| 2320 | |
---|
[4788] | 2321 | if ( af_mode != AF_MODE_NONE ) { |
---|
| 2322 | if ( add_authfile(af_file, af_type, af_mode, af_acclev) == -1 ) { |
---|
| 2323 | ROAR_ERR("main(*): adding authfile '%s' failed!", af_file); |
---|
| 2324 | } |
---|
| 2325 | } |
---|
| 2326 | |
---|
[4358] | 2327 | #ifndef ROAR_WITHOUT_DCOMP_MIXER |
---|
| 2328 | if ( m_drv != NULL ) { |
---|
[4852] | 2329 | if ( hwmixer_add(m_drv, m_dev, m_opts, m_prim, m_count) == -1 ) { |
---|
[4358] | 2330 | ROAR_ERR("main(*): adding mixer '%s' via '%s' failed!", m_dev, m_drv); |
---|
| 2331 | } |
---|
| 2332 | } |
---|
| 2333 | #endif |
---|
| 2334 | |
---|
[2485] | 2335 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[5103] | 2336 | if ( s_drv != NULL || s_dev != NULL ) { |
---|
[1110] | 2337 | if ( sources_add(s_drv, s_dev, s_con, s_opt, s_prim) == -1 ) { |
---|
| 2338 | ROAR_ERR("main(*): adding source '%s' via '%s' failed!", s_dev, s_drv); |
---|
| 2339 | } |
---|
| 2340 | } |
---|
[2485] | 2341 | #endif |
---|
[1110] | 2342 | |
---|
[4852] | 2343 | if ( output_add_default(o_drv, o_dev, o_opts, o_prim, o_count) == -1 ) { |
---|
[4848] | 2344 | ROAR_ERR("Can not initialize default driver"); |
---|
| 2345 | return 1; |
---|
| 2346 | } |
---|
[932] | 2347 | |
---|
[4055] | 2348 | ROAR_INFO("Server config: rate=%i, bits=%i, chans=%i", ROAR_DBG_INFO_NOTICE, sa.rate, sa.bits, sa.channels); |
---|
[0] | 2349 | |
---|
[2945] | 2350 | if ( waveform_init() == -1 ) { |
---|
| 2351 | ROAR_ERR("Can not initialize Waveform subsystem"); |
---|
| 2352 | return 1; |
---|
| 2353 | } |
---|
| 2354 | |
---|
[2500] | 2355 | #ifndef ROAR_WITHOUT_DCOMP_MIDI |
---|
[1819] | 2356 | if ( midi_init() == -1 ) { |
---|
[281] | 2357 | ROAR_ERR("Can not initialize MIDI subsystem"); |
---|
[1819] | 2358 | } |
---|
[2500] | 2359 | #endif |
---|
[1819] | 2360 | |
---|
[2489] | 2361 | #ifndef ROAR_WITHOUT_DCOMP_SSYNTH |
---|
[2451] | 2362 | if ( ssynth_init() == -1 ) { |
---|
| 2363 | ROAR_ERR("Can not initialize ssynth subsystem"); |
---|
| 2364 | } |
---|
[2489] | 2365 | #endif |
---|
[2451] | 2366 | |
---|
[2494] | 2367 | #ifndef ROAR_WITHOUT_DCOMP_LIGHT |
---|
[1819] | 2368 | if ( light_init(light_channels) == -1 ) { |
---|
| 2369 | ROAR_ERR("Can not initialize light control subsystem"); |
---|
| 2370 | } |
---|
[2494] | 2371 | #endif |
---|
[281] | 2372 | |
---|
[2718] | 2373 | #ifndef ROAR_WITHOUT_DCOMP_RDTCS |
---|
| 2374 | if ( rdtcs_init() == -1 ) { |
---|
| 2375 | ROAR_ERR("Can not initialize RDTCS subsystem"); |
---|
| 2376 | } |
---|
| 2377 | #endif |
---|
| 2378 | |
---|
[3354] | 2379 | if ( plugins_init() == -1 ) { |
---|
| 2380 | ROAR_ERR("Can not initialize plugins"); |
---|
| 2381 | } |
---|
| 2382 | |
---|
[1494] | 2383 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[3760] | 2384 | if ( !g_no_listen ) { |
---|
| 2385 | if ( add_listen(sock_addr, port, sock_type, sock_user, sock_grp, sock_proto, sock_dir, &sock_info) != 0 ) { |
---|
| 2386 | ROAR_ERR("Can not open listen socket!"); |
---|
| 2387 | return 1; |
---|
| 2388 | } |
---|
[60] | 2389 | } |
---|
[1494] | 2390 | #endif |
---|
[60] | 2391 | |
---|
[0] | 2392 | if ( output_buffer_init(&sa) == -1 ) { |
---|
| 2393 | ROAR_ERR("Can not init output buffer!"); |
---|
| 2394 | return 1; |
---|
| 2395 | } |
---|
| 2396 | |
---|
[44] | 2397 | if ( samples_init() == -1 ) { |
---|
| 2398 | ROAR_ERR("Can not init samples!"); |
---|
| 2399 | return 1; |
---|
| 2400 | } |
---|
| 2401 | |
---|
| 2402 | |
---|
[1486] | 2403 | // we should handle this on microcontrollers, too. |
---|
[1753] | 2404 | #if !defined(ROAR_TARGET_MICROCONTROLLER) && !defined(ROAR_TARGET_WIN32) |
---|
[0] | 2405 | signal(SIGINT, on_sig_int); |
---|
[2732] | 2406 | signal(SIGTERM, on_sig_term); |
---|
[285] | 2407 | signal(SIGCHLD, on_sig_chld); |
---|
[2112] | 2408 | signal(SIGUSR1, on_sig_usr1); |
---|
[0] | 2409 | signal(SIGPIPE, SIG_IGN); // ignore broken pipes |
---|
[1486] | 2410 | #endif |
---|
[0] | 2411 | |
---|
[4245] | 2412 | if ( g_config->memlock_level == -1 ) { |
---|
| 2413 | g_config->memlock_level = MEMLOCK_DEFAULT; |
---|
| 2414 | } |
---|
| 2415 | |
---|
| 2416 | if ( memlock_set_level(g_config->memlock_level) == -1 ) { |
---|
| 2417 | ROAR_WARN("Can not set memory locking level to target level."); |
---|
| 2418 | } |
---|
| 2419 | |
---|
[275] | 2420 | if ( realtime ) { |
---|
[278] | 2421 | #ifdef DEBUG |
---|
[4246] | 2422 | ROAR_WARN("compiled with -DDEBUG but realtime is enabled: for real realtime support compile without -DDEBUG"); |
---|
[278] | 2423 | #endif |
---|
| 2424 | |
---|
[1486] | 2425 | #ifdef ROAR_HAVE_NICE |
---|
[4739] | 2426 | // this stupid error check is because type of returned data of nice() changed |
---|
| 2427 | // too often. On some systems it may return 0/-1, on some new nice value or |
---|
| 2428 | // mixed forms of both. |
---|
[275] | 2429 | errno = 0; |
---|
[4739] | 2430 | (void)nice(-5*realtime); // -5 for each --realtime |
---|
[1486] | 2431 | if ( errno ) { |
---|
| 2432 | ROAR_WARN("Can not decrease nice value by %i: %s", 5*realtime, strerror(errno)); |
---|
| 2433 | } |
---|
| 2434 | #else |
---|
| 2435 | ROAR_WARN("Can not decrease nice value by %i: %s", 5*realtime, strerror(errno)); |
---|
| 2436 | #endif |
---|
[277] | 2437 | /* |
---|
[276] | 2438 | #ifdef __linux__ |
---|
[277] | 2439 | if ( ioprio_set(IOPRIO_WHO_PROCESS, getpid(), IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0)) == -1 ) |
---|
| 2440 | ROAR_WARN("Can not set io priority: %s", strerror(errno)); |
---|
[276] | 2441 | #endif |
---|
[277] | 2442 | */ |
---|
[275] | 2443 | } |
---|
| 2444 | |
---|
[2756] | 2445 | #if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX) |
---|
[444] | 2446 | if ( setids & R_SETGID ) { |
---|
[2754] | 2447 | if ( sock_grp == NULL ) { |
---|
| 2448 | ROAR_ERR("Can not set GID if no groupname is supplied"); |
---|
| 2449 | return 1; |
---|
| 2450 | } |
---|
[2584] | 2451 | if ( (grp = getgrnam(sock_grp)) == NULL ) { |
---|
| 2452 | ROAR_ERR("Can not get GID for group %s: %s", sock_grp, strerror(errno)); |
---|
| 2453 | return 1; |
---|
| 2454 | } |
---|
[444] | 2455 | if ( setgroups(0, (const gid_t *) NULL) == -1 ) { |
---|
| 2456 | ROAR_ERR("Can not clear supplementary group IDs: %s", strerror(errno)); |
---|
| 2457 | } |
---|
[5160] | 2458 | if ( grp == NULL || setgid(grp->gr_gid) == -1 ) { |
---|
[444] | 2459 | ROAR_ERR("Can not set GroupID: %s", strerror(errno)); |
---|
| 2460 | } |
---|
| 2461 | } |
---|
[1486] | 2462 | #endif |
---|
[444] | 2463 | |
---|
[0] | 2464 | |
---|
[39] | 2465 | clients_set_pid(g_self_client, getpid()); |
---|
[1753] | 2466 | #ifdef ROAR_HAVE_GETUID |
---|
[440] | 2467 | clients_set_uid(g_self_client, getuid()); |
---|
[1753] | 2468 | #endif |
---|
| 2469 | #ifdef ROAR_HAVE_GETGID |
---|
[440] | 2470 | clients_set_gid(g_self_client, getgid()); |
---|
[1753] | 2471 | #endif |
---|
[39] | 2472 | clients_get(g_self_client, &self); |
---|
[37] | 2473 | |
---|
[39] | 2474 | if ( self == NULL ) { |
---|
| 2475 | ROAR_ERR("Can not get self client!"); |
---|
| 2476 | return 1; |
---|
| 2477 | } |
---|
| 2478 | |
---|
[775] | 2479 | strcpy(self->name, "RoarAudio daemon internal"); |
---|
[68] | 2480 | |
---|
[2815] | 2481 | if ( roar_nnode_free(&(self->nnode)) == -1 ) |
---|
| 2482 | return 1; |
---|
| 2483 | |
---|
| 2484 | // not fully correct but ok as workaorund |
---|
| 2485 | // so tools assume that roard runs on the same machine as |
---|
| 2486 | // they in case they use AF_UNIX: |
---|
| 2487 | if ( roar_nnode_new(&(self->nnode), ROAR_SOCKET_TYPE_UNIX) == -1 ) |
---|
| 2488 | return 1; |
---|
| 2489 | |
---|
[5060] | 2490 | #if defined(ROAR_HAVE_FORK) || defined(ROAR_TARGET_WIN32) |
---|
[775] | 2491 | if ( daemon ) { |
---|
[3613] | 2492 | #ifdef ROAR_HAVE_SYSLOG |
---|
| 2493 | roar_debug_set_stderr_mode(ROAR_DEBUG_MODE_SYSLOG); |
---|
| 2494 | #else |
---|
[3609] | 2495 | roar_debug_set_stderr_fh(-1); |
---|
[3613] | 2496 | #endif |
---|
[3609] | 2497 | |
---|
[5060] | 2498 | #ifdef ROAR_TARGET_WIN32 |
---|
| 2499 | FreeConsole(); |
---|
| 2500 | #else |
---|
| 2501 | |
---|
[68] | 2502 | close(ROAR_STDIN ); |
---|
| 2503 | close(ROAR_STDOUT); |
---|
| 2504 | close(ROAR_STDERR); |
---|
[1753] | 2505 | |
---|
[68] | 2506 | if ( fork() ) |
---|
[1486] | 2507 | ROAR_U_EXIT(0); |
---|
[1753] | 2508 | |
---|
| 2509 | #ifdef ROAR_HAVE_SETSID |
---|
| 2510 | setsid(); |
---|
| 2511 | #endif |
---|
[1046] | 2512 | clients_set_pid(g_self_client, getpid()); // reset pid as it changed |
---|
[5060] | 2513 | #endif |
---|
[68] | 2514 | } |
---|
[1486] | 2515 | #endif |
---|
[68] | 2516 | |
---|
[2757] | 2517 | #if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX) |
---|
| 2518 | // early test for UID as we need this for the pidfile and the setuid() |
---|
| 2519 | if ( sock_user != NULL ) { |
---|
| 2520 | if ( (pwd = getpwnam(sock_user)) == NULL ) { |
---|
| 2521 | ROAR_ERR("Can not get UID for user %s: %s", sock_user, strerror(errno)); |
---|
| 2522 | return 1; |
---|
| 2523 | } |
---|
| 2524 | } |
---|
| 2525 | #endif |
---|
| 2526 | |
---|
[4423] | 2527 | ROAR_INFO("Process ID: %i", ROAR_DBG_INFO_INFO, (int)getpid()); |
---|
| 2528 | |
---|
[2104] | 2529 | #ifdef SUPPORT_PIDFILE |
---|
[2106] | 2530 | if ( pidfile != NULL ) { |
---|
[5257] | 2531 | if ( roar_vio_open_dstr_simple(&pidfile_vio, pidfile, O_WRONLY|O_CREAT) == -1 ) { |
---|
[2106] | 2532 | ROAR_ERR("Can not write pidfile: %s", pidfile); |
---|
| 2533 | } else { |
---|
| 2534 | roar_vio_printf(&pidfile_vio, "%i\n", getpid()); |
---|
| 2535 | roar_vio_close(&pidfile_vio); |
---|
| 2536 | } |
---|
[2765] | 2537 | #if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX) |
---|
[5160] | 2538 | if ( pwd != NULL || grp != NULL ) { |
---|
| 2539 | if ( chown(pidfile, pwd != NULL ? pwd->pw_uid : -1, grp != NULL ? grp->gr_gid : -1) == -1 ) { |
---|
[2759] | 2540 | ROAR_WARN("Can not change ownership of pidfile: %s: %s", pidfile, strerror(errno)); |
---|
| 2541 | } |
---|
| 2542 | } |
---|
| 2543 | if ( chmod(pidfile, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) == -1 ) { |
---|
| 2544 | ROAR_WARN("Can not change permissions of pidfile: %s: %s", pidfile, strerror(errno)); |
---|
| 2545 | } |
---|
[2765] | 2546 | #endif |
---|
[2104] | 2547 | } |
---|
| 2548 | #endif |
---|
| 2549 | |
---|
[1486] | 2550 | #ifdef ROAR_HAVE_CHROOT |
---|
[444] | 2551 | if (chrootdir) { |
---|
| 2552 | if ( chroot(chrootdir) == -1 ) { |
---|
| 2553 | ROAR_ERR("Can not chroot to %s: %s", chrootdir, strerror(errno)); |
---|
| 2554 | return 2; |
---|
| 2555 | } |
---|
| 2556 | if ( chdir("/") == -1 ) { |
---|
| 2557 | ROAR_ERR("Can not chdir to /: %s", strerror(errno)); |
---|
| 2558 | return 2; |
---|
| 2559 | } |
---|
| 2560 | } |
---|
[1486] | 2561 | #endif |
---|
[444] | 2562 | |
---|
[2756] | 2563 | #if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX) |
---|
[444] | 2564 | if ( setids & R_SETUID ) { |
---|
[2752] | 2565 | if ( sock_user == NULL ) { |
---|
| 2566 | ROAR_ERR("Can not set UID if no username is supplied"); |
---|
| 2567 | return 1; |
---|
| 2568 | } |
---|
[5160] | 2569 | if ( pwd == NULL || setuid(pwd->pw_uid) == -1 ) { |
---|
[444] | 2570 | ROAR_ERR("Can not set UserID: %s", strerror(errno)); |
---|
| 2571 | return 3; |
---|
| 2572 | } |
---|
[1753] | 2573 | #ifdef ROAR_HAVE_GETUID |
---|
[444] | 2574 | clients_set_uid(g_self_client, getuid()); |
---|
[1753] | 2575 | #endif |
---|
[444] | 2576 | } |
---|
[1486] | 2577 | #endif |
---|
[444] | 2578 | |
---|
[4481] | 2579 | // setup auth: |
---|
[4690] | 2580 | #if defined(ROAR_HAVE_GETUID) && defined(ROAR_HAVE_GETGID) |
---|
[4481] | 2581 | if ( auth_setup(none_acclev, trust_acclev, trust_root, getuid(), getgid()) == -1 ) { |
---|
[4690] | 2582 | #else |
---|
| 2583 | if ( auth_setup(none_acclev, trust_acclev, trust_root, -1, -1) == -1 ) { |
---|
| 2584 | #endif |
---|
[4481] | 2585 | ROAR_ERR("Can not set up auth. Bad."); |
---|
| 2586 | alive = 0; |
---|
| 2587 | } |
---|
| 2588 | |
---|
[1993] | 2589 | // Register with OpenSLP: |
---|
[2028] | 2590 | #ifdef ROAR_HAVE_LIBSLP |
---|
[1993] | 2591 | if ( reg_slp ) { |
---|
[2530] | 2592 | register_slp(0, sock_addr); |
---|
[1993] | 2593 | } |
---|
[2028] | 2594 | #endif |
---|
[1993] | 2595 | |
---|
[3373] | 2596 | #ifdef ROAR_HAVE_LIBX11 |
---|
| 2597 | if ( reg_x11 ) { |
---|
| 2598 | register_x11(0, sock_addr); |
---|
| 2599 | } |
---|
| 2600 | #endif |
---|
| 2601 | |
---|
[4846] | 2602 | // update sync counter. |
---|
| 2603 | streams_change_sync_num(-1, 0); |
---|
| 2604 | |
---|
[4103] | 2605 | ROAR_INFO("Startup complet", ROAR_DBG_INFO_INFO); |
---|
| 2606 | |
---|
[0] | 2607 | // start main loop... |
---|
[4055] | 2608 | ROAR_INFO("Entering main loop", ROAR_DBG_INFO_INFO); |
---|
[4811] | 2609 | main_loop(&sa, sysclocksync); |
---|
[4055] | 2610 | ROAR_INFO("Left main loop", ROAR_DBG_INFO_INFO); |
---|
[0] | 2611 | |
---|
| 2612 | // clean up. |
---|
| 2613 | clean_quit_prep(); |
---|
| 2614 | output_buffer_free(); |
---|
| 2615 | |
---|
[4323] | 2616 | roar_notify_core_free(NULL); |
---|
| 2617 | |
---|
[4851] | 2618 | ROAR_INFO("Shuting down complete", ROAR_DBG_INFO_INFO); |
---|
| 2619 | |
---|
[5210] | 2620 | #ifdef ROAR_HAVE_SYSTEM |
---|
[4851] | 2621 | if ( g_config->scripts.post_shutdown != NULL ) |
---|
| 2622 | system(g_config->scripts.post_shutdown); |
---|
[5210] | 2623 | #endif |
---|
[4851] | 2624 | |
---|
[4055] | 2625 | ROAR_INFO("Exiting, no error", ROAR_DBG_INFO_INFO); |
---|
[0] | 2626 | return 0; |
---|
| 2627 | } |
---|
| 2628 | |
---|
[574] | 2629 | void cleanup_listen_socket (int terminate) { |
---|
[2530] | 2630 | int i; |
---|
| 2631 | |
---|
[4055] | 2632 | ROAR_DBG("cleanup_listen_socket(terminate=%i) = (void)?", terminate); |
---|
| 2633 | |
---|
| 2634 | ROAR_INFO("Cleaning up listen sockets", ROAR_DBG_INFO_INFO); |
---|
| 2635 | |
---|
[1993] | 2636 | // Deregister from SLP: |
---|
[2028] | 2637 | #ifdef ROAR_HAVE_LIBSLP |
---|
[1993] | 2638 | register_slp(1, NULL); |
---|
[2028] | 2639 | #endif |
---|
[580] | 2640 | |
---|
[3373] | 2641 | #ifdef ROAR_HAVE_LIBX11 |
---|
| 2642 | register_x11(1, NULL); |
---|
| 2643 | #endif |
---|
| 2644 | |
---|
[1494] | 2645 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[2530] | 2646 | for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) { |
---|
[3802] | 2647 | if ( g_listen[i].used ) { |
---|
| 2648 | roar_vio_close(&(g_listen[i].sock)); |
---|
[60] | 2649 | |
---|
[3802] | 2650 | g_listen[i].used = 0; |
---|
[576] | 2651 | |
---|
[1486] | 2652 | #ifdef ROAR_HAVE_UNIX |
---|
[2530] | 2653 | if ( server[i] != NULL ) |
---|
| 2654 | if ( *(server[i]) == '/' ) |
---|
| 2655 | unlink(server[i]); |
---|
[1486] | 2656 | #endif |
---|
[2530] | 2657 | } |
---|
[580] | 2658 | } |
---|
[60] | 2659 | |
---|
[1494] | 2660 | #endif |
---|
| 2661 | |
---|
[574] | 2662 | if ( terminate ) |
---|
| 2663 | g_terminate = 1; |
---|
| 2664 | } |
---|
| 2665 | |
---|
| 2666 | void clean_quit_prep (void) { |
---|
| 2667 | cleanup_listen_socket(0); |
---|
[60] | 2668 | |
---|
[3354] | 2669 | plugins_free(); |
---|
| 2670 | |
---|
[2485] | 2671 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
[0] | 2672 | sources_free(); |
---|
[2485] | 2673 | #endif |
---|
[0] | 2674 | streams_free(); |
---|
| 2675 | clients_free(); |
---|
[2489] | 2676 | #ifndef ROAR_WITHOUT_DCOMP_SSYNTH |
---|
[2451] | 2677 | ssynth_free(); |
---|
[2489] | 2678 | #endif |
---|
[2487] | 2679 | #ifndef ROAR_WITHOUT_DCOMP_CB |
---|
[282] | 2680 | midi_cb_stop(); // stop console beep |
---|
[2487] | 2681 | #endif |
---|
[2500] | 2682 | #ifndef ROAR_WITHOUT_DCOMP_MIDI |
---|
[281] | 2683 | midi_free(); |
---|
[2500] | 2684 | #endif |
---|
[2494] | 2685 | #ifndef ROAR_WITHOUT_DCOMP_LIGHT |
---|
[1819] | 2686 | light_free(); |
---|
[2494] | 2687 | #endif |
---|
[2718] | 2688 | #ifndef ROAR_WITHOUT_DCOMP_RDTCS |
---|
| 2689 | rdtcs_free(); |
---|
| 2690 | #endif |
---|
[2104] | 2691 | |
---|
[2945] | 2692 | waveform_free(); |
---|
| 2693 | |
---|
[2104] | 2694 | #ifdef SUPPORT_PIDFILE |
---|
| 2695 | if ( pidfile != NULL ) |
---|
| 2696 | unlink(pidfile); |
---|
| 2697 | #endif |
---|
[4469] | 2698 | |
---|
| 2699 | auth_free(); |
---|
[0] | 2700 | } |
---|
| 2701 | |
---|
| 2702 | void clean_quit (void) { |
---|
[4055] | 2703 | ROAR_INFO("Shuting down", ROAR_DBG_INFO_INFO); |
---|
| 2704 | |
---|
[4101] | 2705 | counters_print(ROAR_DEBUG_TYPE_INFO, 0); |
---|
| 2706 | |
---|
[0] | 2707 | clean_quit_prep(); |
---|
| 2708 | // output_buffer_free(); |
---|
[4055] | 2709 | |
---|
[4323] | 2710 | roar_notify_core_free(NULL); |
---|
| 2711 | |
---|
[4851] | 2712 | ROAR_INFO("Shuting down complete", ROAR_DBG_INFO_INFO); |
---|
| 2713 | |
---|
[5210] | 2714 | #ifdef ROAR_HAVE_SYSTEM |
---|
[4851] | 2715 | if ( g_config->scripts.post_shutdown != NULL ) |
---|
| 2716 | system(g_config->scripts.post_shutdown); |
---|
[5210] | 2717 | #endif |
---|
[4851] | 2718 | |
---|
[4055] | 2719 | ROAR_INFO("Exiting, no error", ROAR_DBG_INFO_INFO); |
---|
[0] | 2720 | exit(0); |
---|
| 2721 | } |
---|
| 2722 | |
---|
| 2723 | //ll |
---|