Changeset 1494:687defe4fca9 in roaraudio


Ignore:
Timestamp:
03/31/09 20:04:32 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

test for ROAR_SUPPORT_LISTEN, disable listening socket code if not set

Location:
roard
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • roard/include/roard.h

    r1482 r1494  
    7878 
    7979int alive; 
     80#ifdef ROAR_SUPPORT_LISTEN 
    8081int g_no_listen; 
     82#endif 
    8183 
    8284uint32_t g_pos; // current possition in output stream 
     
    9395void on_sig_chld (int signum); 
    9496 
     97#ifdef ROAR_SUPPORT_LISTEN 
    9598int g_listen_socket; 
     99#endif 
    96100 
    97101int g_self_client; 
  • roard/loop.c

    r1488 r1494  
    5858  ROAR_DBG("main_loop(*): looping..."); 
    5959 
     60#ifdef ROAR_SUPPORT_LISTEN 
    6061  if ( g_listen_socket != -1 ) { 
    6162   ROAR_DBG("main_loop(*): check for new clients..."); 
    6263   net_check_listen(); 
    6364  } 
     65#endif 
    6466 
    6567  ROAR_DBG("main_loop(*): check for new data..."); 
     68#ifdef ROAR_SUPPORT_LISTEN 
    6669  if ( clients_check_all() == 0 && g_terminate && g_listen_socket == -1 ) { 
     70#else 
     71  if ( clients_check_all() == 0 && g_terminate ) { 
     72#endif 
    6773   term  = 1; 
    6874  } 
  • roard/network.c

    r1484 r1494  
    2424 
    2525#include "roard.h" 
     26 
     27#ifdef ROAR_SUPPORT_LISTEN 
    2628 
    2729#ifdef ROAR_BROKEN_PEERCRED 
     
    110112#endif 
    111113 
     114#endif 
     115 
    112116//ll 
  • roard/roard.c

    r1486 r1494  
    2525#include "roard.h" 
    2626 
     27#ifdef ROAR_SUPPORT_LISTEN 
    2728char * server = ROAR_DEFAULT_SOCK_GLOBAL; // global server address 
     29#endif 
    2830 
    2931void usage (void) { 
     
    270272 int i; 
    271273 char * k; 
     274#ifdef ROAR_SUPPORT_LISTEN 
    272275 char user_sock[80]  = {0}; 
     276#endif 
    273277 struct roar_audio_info sa; 
    274278#ifdef ROAR_HAVE_FORK 
     
    281285 char * opts      = NULL; 
    282286// char * server = ROAR_DEFAULT_SOCK_GLOBAL; 
     287#ifdef ROAR_SUPPORT_LISTEN 
    283288 int      port    = ROAR_DEFAULT_PORT; 
     289#endif 
    284290 int               drvid; 
    285291 char * s_drv     = "cf"; 
     
    295301 char * sock_grp  = ROAR_DEFAULT_SOCKGRP; 
    296302 char * sock_user = NULL; 
     303#ifdef ROAR_SUPPORT_LISTEN 
    297304 int    sock_type = ROAR_SOCKET_TYPE_UNKNOWN; 
     305#endif 
    298306#ifdef ROAR_HAVE_CHROOT 
    299307 char * chrootdir = NULL; 
     
    320328#endif 
    321329 
    322  g_listen_socket = -1; 
    323330 g_standby       =  0; 
    324331 g_autostandby   =  0; 
    325332 alive           =  1; 
     333#ifdef ROAR_SUPPORT_LISTEN 
    326334 g_no_listen     =  0; 
     335 g_listen_socket = -1; 
     336#else 
     337 g_terminate     =  1; 
     338#endif 
    327339 
    328340 sa.bits     = ROAR_BITS_DEFAULT; 
     
    334346 
    335347 
     348#ifdef ROAR_SUPPORT_LISTEN 
    336349 if ( getuid() != 0 && getenv("HOME") != NULL ) { 
    337350  snprintf(user_sock, 79, "%s/%s", (char*)getenv("HOME"), ROAR_DEFAULT_SOCK_USER); 
     
    341354 if ( getenv("ROAR_SERVER") != NULL ) 
    342355  server = getenv("ROAR_SERVER"); 
     356#endif 
    343357 
    344358 if ( clients_init() == -1 ) { 
     
    375389 
    376390  } else if ( strcmp(k, "--restart") == 0 ) { 
     391#ifdef ROAR_SUPPORT_LISTEN 
    377392   if ( restart_server(server) == -1 ) { 
    378393    ROAR_WARN("Can not terminate old server (not running at %s?), tring to continue anyway", server); 
    379394   } 
     395#else 
     396   ROAR_ERR("--restart not supported"); 
     397#endif 
    380398 
    381399  } else if ( strcmp(k, "--demon") == 0 || strcmp(k, "--daemon") == 0 ) { 
     
    472490  } else if ( strcmp(k, "-p") == 0 || strcmp(k, "--port") == 0 ) { 
    473491   // This is only usefull in INET not UNIX mode. 
     492#ifdef ROAR_SUPPORT_LISTEN 
    474493   if ( *server == '/' ) 
    475494    server = ROAR_DEFAULT_HOST; 
     
    491510#endif 
    492511   } 
     512#endif 
    493513  } else if ( strcmp(k, "-b") == 0 || strcmp(k, "--bind") == 0 || strcmp(k, "--sock") == 0 ) { 
     514#ifdef ROAR_SUPPORT_LISTEN 
    494515   server = argv[++i]; 
     516#endif 
    495517 
    496518  } else if ( strcmp(k, "-t") == 0 || strcmp(k, "--tcp") == 0 ) { 
     519#ifdef ROAR_SUPPORT_LISTEN 
    497520   if ( sock_type != ROAR_SOCKET_TYPE_TCP && sock_type != ROAR_SOCKET_TYPE_TCP6 ) 
    498521    sock_type = ROAR_SOCKET_TYPE_TCP; 
     
    500523   if ( *server == '/' ) 
    501524    server = ROAR_DEFAULT_HOST; 
     525#endif 
    502526 
    503527  } else if ( strcmp(k, "-4") == 0 ) { 
     528#ifdef ROAR_SUPPORT_LISTEN 
    504529   sock_type = ROAR_SOCKET_TYPE_TCP; 
    505530   if ( *server == '/' ) 
    506531    server = ROAR_DEFAULT_HOST; 
     532#endif 
    507533  } else if ( strcmp(k, "-6") == 0 ) { 
     534#ifdef ROAR_SUPPORT_LISTEN 
    508535#ifdef PF_INET6 
    509536   sock_type = ROAR_SOCKET_TYPE_TCP6; 
     
    514541    return 1; 
    515542#endif 
     543#endif 
    516544 
    517545  } else if ( strcmp(k, "-u") == 0 || strcmp(k, "--unix") == 0 ) { 
     546#ifdef ROAR_SUPPORT_LISTEN 
    518547   // ignore this case as it is the default behavor. 
    519548   sock_type = ROAR_SOCKET_TYPE_UNIX; 
     549#endif 
    520550 
    521551  } else if ( strcmp(k, "-n") == 0 || strcmp(k, "--decnet") == 0 ) { 
     552#ifdef ROAR_SUPPORT_LISTEN 
    522553#ifdef ROAR_HAVE_LIBDNET 
    523554    port   = ROAR_DEFAULT_NUM; 
     
    529560    return 1; 
    530561#endif 
     562#endif 
    531563 
    532564  } else if ( strcmp(k, "-G") == 0 ) { 
     
    536568 
    537569  } else if ( strcmp(k, "--no-listen") == 0 ) { 
     570#ifdef ROAR_SUPPORT_LISTEN 
    538571   *server     = 0; 
    539572   g_terminate = 1; 
    540573   g_no_listen = 1; 
     574#endif 
    541575  } else if ( strcmp(k, "--client-fh") == 0 ) { 
    542576   if ( clients_set_fh(clients_new(), atoi(argv[++i])) == -1 ) { 
     
    576610  ROAR_ERR("Can not initialize MIDI subsystem"); 
    577611 
     612#ifdef ROAR_SUPPORT_LISTEN 
    578613 if ( *server != 0 ) { 
    579614  if ( (g_listen_socket = roar_socket_listen(sock_type, server, port)) == -1 ) { 
     
    635670#endif 
    636671 } 
     672#endif 
    637673 
    638674 if ( output_buffer_init(&sa) == -1 ) { 
     
    759795void cleanup_listen_socket (int terminate) { 
    760796 
     797#ifdef ROAR_SUPPORT_LISTEN 
    761798 if ( g_listen_socket != -1 ) { 
    762799#ifdef ROAR_HAVE_IO_POSIX 
     
    771808#endif 
    772809 } 
     810 
     811#endif 
    773812 
    774813 if ( terminate ) 
Note: See TracChangeset for help on using the changeset viewer.