Changeset 5838:52ca1a88734e in roaraudio


Ignore:
Timestamp:
01/07/13 02:36:01 (8 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

handle setting of server name in connection object in a better way. also added new command "servername" to roarctl to debug this a bit. This is one little step needed by ##337

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • doc/man1/roarctl.1

    r5159 r5838  
    6767 
    6868This is not supported on all platforms. 
     69 
     70.TP 
     71\fBservername\fR 
     72This command shows the server address of the server currently connected to. 
     73This can be diffrent from what has given e.g. in case of special server 
     74names like +fork. 
    6975 
    7076.TP 
  • libroar/basic.c

    r5832 r5838  
    4646 int r; 
    4747 char fhstr[12]; 
     48 size_t len; 
    4849 
    4950 if ( !strncmp(server, "+fork=", 6) ) { 
     
    7879  daemonimage = "roard"; 
    7980 
     81 len = roar_mm_strlen(daemonimage) + 9; // 9 = '+fork=' + 'X:' + '\0' 
     82 con->server_name = roar_mm_malloc(len); 
     83 if ( con->server_name != NULL ) { 
     84  snprintf(con->server_name, len, "+fork=%s%s", mode == NORMAL ? "d:" : "!", daemonimage); 
     85 } 
     86 
    8087 if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) { 
    8188  roar_err_from_errno(); 
     
    164171 int fh = -1; 
    165172 int err; 
     173 int ret; 
    166174 
    167175 if ( con == NULL || server == NULL ) { 
     
    177185   return -1; 
    178186  con->flags |= ROAR_CON_FLAGS_VIO; 
     187  con->server_name = roar_mm_strdup(server); 
    179188  return 0; 
    180189 } else if ( !strcmp(server, "+fork") || !strncmp(server, "+fork=", 6) ) { 
    181190  return _start_server(con, server, type, flags, timeout); 
    182191 } else if ( !strcmp(server, "+internal") || !strncmp(server, "+internal=", 10) ) { 
    183   return _connect_internal(con, server, type, flags, timeout); 
     192  ret = _connect_internal(con, server, type, flags, timeout); 
     193  if ( ret == 0 ) 
     194   con->server_name = roar_mm_strdup(server); 
     195  return ret; 
    184196 } 
    185197 
     
    217229 
    218230  if ( *obj == 0 ) { 
    219 #ifdef DN_MAXOBJL 
    220231   roar_mm_strlcat(user_sock, ROAR_DEFAULT_OBJECT, sizeof(user_sock)-1); 
    221232   user_sock[sizeof(user_sock)-1] = 0; 
    222 #else 
    223    ROAR_ERR("roar_connect_raw(*): size of DECnet object unknown."); 
    224 #endif 
    225   } 
    226    ROAR_DBG("roar_connect_raw(*): user_sock='%s'", user_sock); 
     233  } 
     234 
     235  ROAR_DBG("roar_connect_raw(*): user_sock='%s'", user_sock); 
    227236 } 
    228237 
     
    265274 } 
    266275 
     276 con->server_name = roar_mm_strdup(server); 
     277 
    267278 roar_err_set(ROAR_ERROR_NONE); 
    268279 return 0; 
     
    449460  return -1; 
    450461 
    451  // TODO: this should be moved to be within _connect_server() so it also stores server names of auto located servers. 
    452  if ( server != NULL ) { 
    453   con->server_name = roar_mm_strdup(server); 
    454  } 
    455  
    456462 return 0; 
    457463} 
  • libroar/config.c

    r5833 r5838  
    3636#include "libroar.h" 
    3737 
     38#define LEN_AUTHFILE 1024 
     39 
    3840static struct roar_libroar_config_codec * 
    3941           roar_libroar_config_codec_get_conf(int32_t codec, int create, struct roar_libroar_config * config); 
     
    4345 static struct roar_libroar_config config; 
    4446 static int    inited = 0; 
    45  static char   authfile[1024]; 
     47 static char   authfile[LEN_AUTHFILE]; 
    4648 const  char * home = roar_env_get_home(0); 
    4749 
     
    102104  config->codecs.num = 0; 
    103105 } 
     106 
     107 if ( config->x11.display != NULL ) 
     108  roar_mm_free(config->x11.display); 
     109 config->x11.display = NULL; 
     110 
     111 if ( config->daemonimage != NULL ) 
     112  roar_mm_free(config->daemonimage); 
     113 config->daemonimage = NULL; 
    104114 
    105115 return 0; 
     
    308318    roar_libroar_set_server(v); 
    309319  } else if ( !strcmp(k, "set-authfile") ) { 
    310    strncpy(config->authfile, v, 1023); 
    311    config->authfile[1023] = 0; 
     320   strncpy(config->authfile, v, LEN_AUTHFILE-1); 
     321   config->authfile[LEN_AUTHFILE-1] = 0; 
    312322  } else if ( !strcmp(k, "x11-display") ) { 
    313    config->x11.display = v; 
     323   if ( config->x11.display != NULL ) 
     324    roar_mm_free(config->x11.display); 
     325   config->x11.display = roar_mm_strdup(v); 
    314326  } else if ( !strcmp(k, "daemonimage") ) { 
    315    config->daemonimage = v; 
     327   if ( config->daemonimage != NULL ) 
     328    roar_mm_free(config->daemonimage); 
     329   config->daemonimage = roar_mm_strdup(v); 
    316330  } else if ( !strcmp(k, "serverflags") ) { 
    317331   if ( !strcmp(v, "nonblock") ) { 
  • roarclients/roarctl.c

    r5837 r5838  
    7878        "  ping  NUM               - Do NUM pings using NOOP commands\n" 
    7979#endif 
     80        "  servername              - Show name of server currently connected to\n" 
    8081        "  whoami                  - Get own client ID\n" 
    8182        "\n" 
     
    12721273    i++; 
    12731274#endif 
     1275  } else if ( !strcmp(k, "servername") ) { 
     1276   printf("Server Name           : %s\n", roar_get_connection_server(&con)); 
    12741277 
    12751278  } else if ( !strcmp(k, "standby") || !strcmp(k, "off") ) { 
Note: See TracChangeset for help on using the changeset viewer.