Changeset 5895:2bcffab4cd73 in roaraudio


Ignore:
Timestamp:
04/14/13 13:38:03 (6 years ago)
Author:
phi
Branch:
default
Message:

Moved away from roar_libroar_get_path_static()

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5893 r5895  
    11v. 1.0beta10 - ? 
    22        * Added build summery feature to RABS and configure script. 
     3        * Moved away from roar_libroar_get_path_static(). 
    34 
    45v. 1.0beta9 - Mon Feb 18 2013 23:28 CET 
  • libroar.ckport

    r5865 r5895  
    520520roar_libroar_get_server         ok 
    521521roar_libroar_get_path           ok 
    522 roar_libroar_get_path_static    maybe   Should be avoided in flavor of roar_libroar_get_path() 
     522roar_libroar_get_path_static    legacy  Migrate to roar_libroar_get_path() 
    523523roar_libroar_list_path          ok 
    524524roar_libroar_set_memmgrapi      ok 
  • libroar/basic.c

    r5848 r5895  
    4343static int _connect_server(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout); 
    4444 
    45 int __get_daemonimage(const char ** daemonimage, enum mode * mode, const char * server) { 
     45int __get_daemonimage(char ** daemonimage, enum mode * mode, const char * server) { 
     46 const char * tmp = NULL; 
     47 
    4648 *daemonimage = NULL; 
    4749 *mode = NORMAL; 
     
    6163  } else if ( server[0] == 'd' && server[1] == ':' ) { 
    6264   server += 2; 
    63    *daemonimage = server; 
     65   tmp = server; 
    6466   *mode = NORMAL; 
    6567  } else if ( server[0] == '!' ) { 
    6668   server += 1; 
    67    *daemonimage = server; 
     69   tmp = server; 
    6870   *mode = SYSTEM; 
    6971  } else { 
     
    7375 } 
    7476 
     77 if ( tmp == NULL || *tmp == 0 ) 
     78  tmp = roar_libroar_get_config()->daemonimage; 
     79 
     80 // we keep this step to be compatible with older versions. 
     81 if ( tmp == NULL || *tmp == 0 ) { 
     82  tmp = roar_env_get("ROAR_DAEMONIMAGE"); 
     83  if ( tmp != NULL ) { 
     84   ROAR_WARN("__get_daemonimage(*): Usage of $ROAR_DAEMONIMAGE is obsolete. Use ROAR_OPTIONS=daemonimage:..."); 
     85  } 
     86 } 
     87 
     88 if ( tmp != NULL && *tmp != 0 ) { 
     89  *daemonimage = roar_mm_strdup(tmp); 
     90  return 0; 
     91 } 
     92 
     93 *daemonimage = roar_libroar_get_path("bin-default-daemonimage", 0, NULL, NULL); 
    7594 if ( *daemonimage == NULL ) 
    76   *daemonimage = roar_libroar_get_config()->daemonimage; 
    77  
    78  // we keep this step to be compatible with older versions. 
    79  if ( *daemonimage == NULL || **daemonimage == 0 ) { 
    80   *daemonimage = roar_env_get("ROAR_DAEMONIMAGE"); 
    81   if ( *daemonimage != NULL ) { 
    82    ROAR_WARN("__get_daemonimage(*): Usage of $ROAR_DAEMONIMAGE is obsolete. Use ROAR_OPTIONS=daemonimage:..."); 
    83   } 
    84  } 
    85  
    86  if ( *daemonimage == NULL || **daemonimage == 0 ) 
    87   *daemonimage = roar_libroar_get_path_static("bin-default-daemonimage"); 
     95  return -1; 
    8896 
    8997 return 0; 
     
    94102static int _start_server_win32(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout) { 
    95103 enum mode mode = NORMAL; 
    96  const char * daemonimage = NULL; 
     104 char * daemonimage = NULL; 
    97105 char buf[64]; 
    98106 int port; 
     
    105113 
    106114 if ( mode != NORMAL ) { 
     115  roar_mm_free(daemonimage); 
    107116  roar_err_set(ROAR_ERROR_NOSYS); 
    108117  return -1; 
     
    122131 
    123132 if ( i == NUM_TRIES ) { 
     133  roar_mm_free(daemonimage); 
    124134  roar_err_set(ROAR_ERROR_LOOP); 
    125135  return -1; 
     
    141151  roar_err_update(); 
    142152  ROAR_ERR("_start_server_win32(server='%s', ...): Can not start server: %s: %s", server, daemonimage, roar_errorstring); 
    143   return -1; 
    144  } 
     153  err = roar_error; 
     154  roar_mm_free(daemonimage); 
     155  roar_error = err; 
     156  return -1; 
     157 } 
     158 
     159 roar_mm_free(daemonimage); 
    145160 
    146161 snprintf(buf, sizeof(buf), "localhost:%i", port); 
     
    166181static int _start_server_posix(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout) { 
    167182 enum mode mode = NORMAL; 
    168  const char * daemonimage = NULL; 
     183 char * daemonimage = NULL; 
    169184 int socks[2]; 
    170185 int r; 
    171186 char fhstr[12]; 
    172187 size_t len; 
     188 char * bin_sh; 
     189 int err; 
    173190 
    174191 if ( __get_daemonimage(&daemonimage, &mode, server) == -1 ) 
     
    183200 if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) { 
    184201  roar_err_from_errno(); 
     202  err = roar_error; 
     203  roar_mm_free(daemonimage); 
     204  roar_error = err; 
    185205  return -1; 
    186206 } 
     
    190210 if ( r == -1 ) { // error! 
    191211  ROAR_ERR("_start_server(*): Can not fork: %s", roar_error2str(roar_error)); 
     212  err = roar_error; 
    192213  close(socks[0]); 
    193214  close(socks[1]); 
     215  roar_mm_free(daemonimage); 
     216  roar_error = err; 
    194217  return -1; 
    195218 } else if ( r == 0 ) { // we are the child 
     
    211234     dup2(socks[1], ROAR_STDIN ); 
    212235     dup2(socks[1], ROAR_STDOUT); 
    213      execl(roar_libroar_get_path_static("bin-sh"), roar_libroar_get_path_static("bin-sh"), "-c", daemonimage, (_LIBROAR_GOOD_CAST char*)NULL); 
     236     bin_sh = roar_libroar_get_path("bin-sh", 0, NULL, NULL); 
     237     if ( bin_sh != NULL ) { 
     238      execl(bin_sh, bin_sh, "-c", daemonimage, (_LIBROAR_GOOD_CAST char*)NULL); 
     239      roar_mm_free(bin_sh); 
     240     } 
    214241     execlp("sh", "sh", "-c", daemonimage, (_LIBROAR_GOOD_CAST char*)NULL); 
    215242    break; 
    216243  } 
     244 
     245  roar_mm_free(daemonimage); 
    217246 
    218247  // we are still alive? 
     
    221250 } else { // we are the parent 
    222251  close(socks[1]); 
     252  roar_mm_free(daemonimage); 
    223253  if ( roar_vio_open_fh_socket(con->viocon, socks[0]) == -1 ) { 
    224254   close(socks[0]); 
     
    398428#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) 
    399429 struct passwd * pwd; 
     430 char * sysconf_roarserver; 
    400431#endif 
    401432#ifdef ROAR_HAVE_LIBDNET 
     
    437468 
    438469#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) 
    439  if ( (server == NULL || *server == 0) && (i = readlink(roar_libroar_get_path_static("sysconf-roarserver"), user_sock, sizeof(user_sock)-1)) != -1 ) { 
    440    user_sock[i] = 0; 
    441    server = user_sock; 
     470 sysconf_roarserver = roar_libroar_get_path("sysconf-roarserver", 0, NULL, NULL); 
     471 if ( sysconf_roarserver != NULL ) { 
     472  if ( (server == NULL || *server == 0) && (i = readlink(sysconf_roarserver, user_sock, sizeof(user_sock)-1)) != -1 ) { 
     473    user_sock[i] = 0; 
     474    server = user_sock; 
     475  } 
     476  roar_mm_free(sysconf_roarserver); 
    442477 } 
    443478#endif 
     
    467502  if ( roar_server == NULL ) { 
    468503#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) 
    469    if ( (pwd = getpwuid(getuid())) == NULL ) { 
    470     roar_server = roar_libroar_get_path_static("dir-nx-home"); 
    471    } else { 
     504   if ( (pwd = getpwuid(getuid())) != NULL ) { 
    472505    roar_server = pwd->pw_dir; 
    473506   } 
    474 #else 
    475    roar_server = "/WIN32-SUCKS"; 
    476 #endif 
    477   } 
    478  
    479   snprintf(user_sock, sizeof(user_sock)-1, "%s/%s", roar_server, ROAR_DEFAULT_SOCK_USER); 
    480   user_sock[sizeof(user_sock)-1] = 0; 
    481  
    482   if ( _connect_server(con, user_sock, ROAR_SOCKET_TYPE_UNIX, flags, timeout) == 0 ) 
    483    return 0; 
     507#endif 
     508  } 
     509 
     510  if ( roar_server != NULL ) { 
     511   snprintf(user_sock, sizeof(user_sock)-1, "%s/%s", roar_server, ROAR_DEFAULT_SOCK_USER); 
     512   user_sock[sizeof(user_sock)-1] = 0; 
     513 
     514   if ( _connect_server(con, user_sock, ROAR_SOCKET_TYPE_UNIX, flags, timeout) == 0 ) 
     515    return 0; 
     516  } 
    484517 
    485518  if ( _connect_server(con, ROAR_DEFAULT_SOCK_GLOBAL, ROAR_SOCKET_TYPE_UNIX, flags, timeout) == 0 ) 
  • libroar/cdrom.c

    r5832 r5895  
    5353 pid_t pid; 
    5454 int fh[2]; 
     55 char * bin_cdparanoia = NULL, * dev_stdin = NULL; 
     56 int err; 
    5557 
    5658 ROAR_DBG("roar_cdrom_run_cdparanoia(cdrom=%i, data=%i, track=%i, pos='%s') = ?", cdrom, data, track, pos); 
     
    9193 close(fh[1]); 
    9294 
    93  execl(roar_libroar_get_path_static("bin-cdparanoia"), roar_libroar_get_path_static("bin-cdparanoia"), "--force-cdrom-device", roar_libroar_get_path_static("dev-stdin"), "-q", 
     95 bin_cdparanoia = roar_libroar_get_path("bin-cdparanoia", 0, NULL, NULL); 
     96 if ( bin_cdparanoia == NULL ) 
     97  return -1; 
     98 dev_stdin = roar_libroar_get_path("dev-stdin", 0, NULL, NULL); 
     99 if ( dev_stdin == NULL ) { 
     100  err = roar_error; 
     101  roar_mm_free(bin_cdparanoia); 
     102  roar_error = err; 
     103  return -1; 
     104 } 
     105 execl(bin_cdparanoia, bin_cdparanoia, "--force-cdrom-device", dev_stdin, "-q", 
    94106                ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT, pos, "-", NULL); 
     107 
     108 roar_mm_free(bin_cdparanoia); 
     109 roar_mm_free(dev_stdin); 
    95110 
    96111 ROAR_CDROM_ERROR_NORETURN("We are still alive after exec()!, very bad!, error was: %s", strerror(errno)); 
  • libroar/config.c

    r5884 r5895  
    572572 
    573573 // special dirs: 
    574  {"dir-nx-home",                "/NX-HOME-DIR", 0, 0} 
     574 {"dir-nx-home",                "/NX-HOME-DIR", 0, 0}, 
     575#ifdef ROAR_TARGET_WIN32 
     576 {"dir-win32-sucks",            "/WIN32-SUCKS", 0, 0} 
     577#endif 
    575578}; 
    576579 
  • libroar/enumdev.c

    r5832 r5895  
    145145 
    146146#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) 
    147   if ( (i = readlink(roar_libroar_get_path_static("sysconf-roarserver"), buf, sizeof(buf)-1)) != -1 ) { 
    148     buf[i] = 0; 
    149     _add(buf); 
     147  tmp = roar_libroar_get_path("sysconf-roarserver", 0, NULL, NULL); 
     148  if ( tmp != NULL ) { 
     149   if ( (i = readlink(tmp, buf, sizeof(buf)-1)) != -1 ) { 
     150     buf[i] = 0; 
     151     _add(buf); 
     152   } 
     153   roar_mm_free(tmp); 
    150154  } 
    151155#endif 
  • libroar/pinentry.c

    r5832 r5895  
    4848#ifdef _CAN_OPERATE 
    4949 int in[2], out[2]; 
     50 char * bin_pinentry; 
    5051 
    5152 if ( pe == NULL ) 
     
    112113     ROAR_U_EXIT(1); 
    113114 
    114     execlp(roar_libroar_get_path_static("bin-pinentry"), "RoarAudio", "--display", display, "--ttytype", term, "--ttyname", tty, NULL); 
     115    bin_pinentry = roar_libroar_get_path("bin-pinentry", 0, NULL, NULL); 
     116    if ( bin_pinentry == NULL ) 
     117     ROAR_U_EXIT(1); 
     118 
     119    execlp(bin_pinentry, "RoarAudio", "--display", display, "--ttytype", term, "--ttyname", tty, NULL); 
     120 
     121    roar_mm_free(bin_pinentry); 
    115122 
    116123    ROAR_U_EXIT(1); 
  • libroar/socket.c

    r5832 r5895  
    11071107 const char * proxy_addr = roar_env_get("ssh_proxy"); 
    11081108 char * sep; 
     1109 char * bin_ssh; 
    11091110 char   cmd[1024] = {0}, rcmd[1024] = {0}; 
    11101111 int    proxy_port = 22; 
     
    11641165 ROAR_DBG("roar_socket_open_ssh(*): proxy_port=%i, user='%s', proxy_addr='%s'", proxy_port, user, proxy_addr); 
    11651166 ROAR_DBG("roar_socket_open_ssh(*): rcmd: %s", rcmd); 
    1166  snprintf(cmd, 1023, "%s -p %i -l '%s' '%s' '%s'", roar_libroar_get_path_static("bin-ssh"), proxy_port, user, proxy_addr, rcmd); 
     1167 bin_ssh = roar_libroar_get_path("bin-ssh", 0, NULL, NULL); 
     1168 if ( bin_ssh == NULL ) 
     1169  return -1; 
     1170 
     1171 snprintf(cmd, 1023, "%s -p %i -l '%s' '%s' '%s'", bin_ssh, proxy_port, user, proxy_addr, rcmd); 
    11671172 cmd[1023] = 0; 
     1173 
     1174 roar_mm_free(bin_ssh); 
    11681175 
    11691176 
  • libroar/vio_cmd.c

    r5832 r5895  
    141141int roar_vio_cmd_fork(struct roar_vio_cmd_child * child) { 
    142142 int in[2], out[2]; 
     143 char * bin_sh; 
    143144 
    144145 if ( child == NULL ) 
     
    185186     ROAR_U_EXIT(1); 
    186187 
    187     execlp(roar_libroar_get_path_static("bin-sh"), roar_libroar_get_path_static("bin-sh"), "-c", child->cmd, (_LIBROAR_GOOD_CAST char*)NULL); 
     188    bin_sh = roar_libroar_get_path("bin-sh", 0, NULL, NULL); 
     189    if ( bin_sh == NULL ) 
     190     ROAR_U_EXIT(1); 
     191 
     192    execlp(bin_sh, bin_sh, "-c", child->cmd, (_LIBROAR_GOOD_CAST char*)NULL); 
     193 
     194    roar_mm_free(bin_sh); 
    188195 
    189196    ROAR_U_EXIT(1); 
     
    621628 char command[1024]; 
    622629 char para[1024] = {0}; 
     630 char * bin_gpg; 
    623631 int pwpipe[2]; 
    624632 int ret; 
     633 int err; 
    625634 
    626635/* 
     
    640649  strncat(para, "--textmode ", 16); 
    641650 
     651 bin_gpg = roar_libroar_get_path("bin-gpg", 0, NULL, NULL); 
     652 if ( bin_gpg == NULL ) 
     653  return -1; 
     654 
    642655 if ( pw != NULL ) { 
    643   if ( pipe(pwpipe) == -1 ) 
     656  if ( pipe(pwpipe) == -1 ) { 
     657   err = roar_error; 
     658   roar_mm_free(bin_gpg); 
     659   roar_error = err; 
    644660   return -1; 
    645  
    646   snprintf(command, 1024, "%s --batch --no-verbose --quiet --passphrase-repeat 0 --passphrase-fd %i %s %s", roar_libroar_get_path_static("bin-gpg"), pwpipe[0], para, opts); 
     661  } 
     662 
     663  snprintf(command, 1024, "%s --batch --no-verbose --quiet --passphrase-repeat 0 --passphrase-fd %i %s %s", bin_gpg, pwpipe[0], para, opts); 
    647664 
    648665  write(pwpipe[1], pw, strlen(pw)); 
     
    650667  close(pwpipe[1]); 
    651668 } else { 
    652   snprintf(command, 1024, "%s --no-verbose --quiet %s %s", roar_libroar_get_path_static("bin-gpg"), para, opts); 
    653  } 
     669  snprintf(command, 1024, "%s --no-verbose --quiet %s %s", bin_gpg, para, opts); 
     670 } 
     671 
     672 roar_mm_free(bin_gpg); 
    654673 
    655674 if ( wronly ) { 
  • roard/driver_dmx.c

    r5832 r5895  
    3333 int err; 
    3434 const char * dev = device; 
     35 char * dev_default_dmx4linux = NULL; 
    3536 
    3637 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY, 0644) == -1 ) 
     
    4647   dev = roar_env_get("DMX"); 
    4748 
    48   if ( dev == NULL ) 
    49    dev = roar_libroar_get_path_static("dev-default-dmx4linux"); 
     49  if ( dev == NULL ) { 
     50   dev_default_dmx4linux = roar_libroar_get_path("dev-default-dmx4linux", 0, NULL, NULL); 
     51   dev = dev_default_dmx4linux; 
     52  } 
    5053 
    5154  if ( roar_vio_open_dstr(vio, dev, &def, 1) == -1 ) { 
    5255   err = roar_error; 
    5356   roar_mm_free(vio); 
     57   if ( dev_default_dmx4linux != NULL ) 
     58    roar_mm_free(dev_default_dmx4linux); 
    5459   roar_error = err; 
    5560   return -1; 
    5661  } 
     62  if ( dev_default_dmx4linux != NULL ) 
     63   roar_mm_free(dev_default_dmx4linux); 
    5764 } else { 
    5865  if ( roar_vio_open_fh(vio, fh) == -1 ) { 
Note: See TracChangeset for help on using the changeset viewer.