Changeset 953:97c259da32cc in roaraudio for roard/driver_shout.c


Ignore:
Timestamp:
12/08/08 18:53:28 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

support config via device string: [http[s]:][user[:pw]@][host][:port]mp.ogg

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/driver_shout.c

    r952 r953  
    3131 char * s_server = NULL; 
    3232 char * s_mount  = NULL; 
     33 char * s_user   = NULL; 
    3334 char * s_pw     = NULL; 
    3435 int    s_port   = -1; 
     
    3839 char * s_url    = NULL; 
    3940 int    s_public = 0; 
     41 char * a, * b, * c; 
    4042 shout_t * shout; 
    4143 
     
    4850 } 
    4951 
     52 if ( device != NULL ) { 
     53  // device sould be an URL in this form: 
     54  // [http[s]://][user[:pw]@]host[:port][/mp.ogg] 
     55 
     56  if ( (a = strstr(device, "://")) != NULL ) { 
     57   *a = 0; 
     58   if ( strcmp(device, "http") ) { 
     59    return -1; 
     60   } 
     61   device = a + 3; 
     62  } 
     63 
     64  // [user[:pw]@]host[:port][/mp.ogg] 
     65 
     66  if ( (a = strstr(device, "@")) != NULL ) { 
     67   *a = 0; 
     68   s_user = device; 
     69   device = a + 1; 
     70  } 
     71 
     72  if ( s_user != NULL ) { 
     73   if ( (a = strstr(s_user, ":")) != NULL ) { 
     74    *a = 0; 
     75    s_pw = a+1; 
     76   } 
     77  } 
     78 
     79  if ( s_user != NULL && ! *s_user ) 
     80   s_user = NULL; 
     81 
     82  if ( s_pw != NULL && ! *s_pw ) 
     83   s_pw = NULL; 
     84 
     85  // host[:port][/mp.ogg] 
     86 
     87  if ( (a = strstr(device, "/")) != NULL ) { 
     88   *a = 0; 
     89   s_server = device; 
     90   device = a + 1; 
     91  } else { 
     92   s_server  = device; 
     93   device   += strlen(device); 
     94  } 
     95 
     96  if ( (a = strstr(s_server, ":")) != NULL ) { 
     97   *a = 0; 
     98   s_port = atoi(a+1); 
     99  } 
     100 
     101  if ( ! *s_server ) 
     102   s_server = NULL; 
     103 
     104  // [/mp.ogg] 
     105 
     106  if ( *device ) { 
     107   s_mount = device; 
     108  } 
     109 } 
     110 
     111 ROAR_DBG("driver_shout_open_vio(*): user='%s', pw='%s', server='%s', port=%i, mount='%s'", 
     112                   s_user, s_pw, s_server, s_port, s_mount); 
     113 
    50114 if ( s_server == NULL ) 
    51115  s_server = "localhost"; 
     
    57121  s_pw     = "hackme"; 
    58122 
     123 if ( s_user == NULL ) 
     124  s_user     = "source"; 
     125 
    59126 if ( s_port == -1 ) 
    60127  s_port   = 8000; 
     
    93160 } 
    94161 
    95  if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS) { 
     162 if (shout_set_user(shout, s_user) != SHOUTERR_SUCCESS) { 
    96163  ROAR_ERR("Error setting user: %s", shout_get_error(shout)); 
    97164  return 1; 
Note: See TracChangeset for help on using the changeset viewer.