Changeset 5832:f0b38d5ea016 in roaraudio
- Timestamp:
- 01/06/13 16:15:56 (11 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/config.h
r5828 r5832 181 181 char * roar_libroar_get_path(const char * name, int null_as_universal, const char * product, const char * provider) _LIBROAR_ATTR_USE_RESULT; 182 182 183 // This is similar roar_libroar_get_path() with the following diffrences: 184 // * No product, provider or universal attribute can be passed. 185 // The result is as if they were 0, NULL, NULL. 186 // * The returned buffer is some read-only memory which does not need to be 187 // freed. 188 const char * roar_libroar_get_path_static(const char * name); 189 183 190 // list all known paths: 184 191 ssize_t roar_libroar_list_path(const char ** list, size_t len, size_t offset) _LIBROAR_ATTR_USE_RESULT _LIBROAR_ATTR_NONNULL_ALL; -
libroar/basic.c
r5823 r5832 108 108 dup2(socks[1], ROAR_STDIN ); 109 109 dup2(socks[1], ROAR_STDOUT); 110 execl( "/bin/sh", "/bin/sh", "-c", daemonimage, (_LIBROAR_GOOD_CAST char*)NULL);110 execl(roar_libroar_get_path_static("bin-sh"), roar_libroar_get_path_static("bin-sh"), "-c", daemonimage, (_LIBROAR_GOOD_CAST char*)NULL); 111 111 execlp("sh", "sh", "-c", daemonimage, (_LIBROAR_GOOD_CAST char*)NULL); 112 112 break; … … 321 321 322 322 #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) 323 if ( (server == NULL || *server == 0) && (i = readlink( "/etc/roarserver", user_sock, sizeof(user_sock)-1)) != -1 ) {323 if ( (server == NULL || *server == 0) && (i = readlink(roar_libroar_get_path_static("sysconf-roarserver"), user_sock, sizeof(user_sock)-1)) != -1 ) { 324 324 user_sock[i] = 0; 325 325 server = user_sock; … … 352 352 #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) 353 353 if ( (pwd = getpwuid(getuid())) == NULL ) { 354 roar_server = "/NX-HOME-DIR";354 roar_server = roar_libroar_get_path_static("dir-nx-home"); 355 355 } else { 356 356 roar_server = pwd->pw_dir; -
libroar/cdrom.c
r5823 r5832 91 91 close(fh[1]); 92 92 93 execl( ROAR_HAVE_BIN_CDPARANOIA, "cdparanoia", "--force-cdrom-device", "/dev/stdin", "-q",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", 94 94 ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT, pos, "-", NULL); 95 95 -
libroar/config.c
r5831 r5832 436 436 } 437 437 438 static const struct {438 static const struct pathinfo { 439 439 const char * name; 440 440 const char * path; … … 487 487 {"bin-pinentry", ROAR_HAVE_BIN_PINENTRY, 0, 0}, 488 488 {"bin-ssh_askpass", ROAR_HAVE_BIN_SSH_ASKPASS, 0, 0}, 489 {"bin-gtk _led_askpass", ROAR_HAVE_BIN_GTK_LED_ASKPASS, 0, 0},490 {"bin-x11 _ssh_askpass", ROAR_HAVE_BIN_X11_SSH_ASKPASS, 0, 0},491 {"bin-gnome _ssh_askpass", ROAR_HAVE_BIN_GNOME_SSH_ASKPASS, 0, 0},489 {"bin-gtk-led-askpass", ROAR_HAVE_BIN_GTK_LED_ASKPASS, 0, 0}, 490 {"bin-x11-ssh-askpass", ROAR_HAVE_BIN_X11_SSH_ASKPASS, 0, 0}, 491 {"bin-gnome-ssh-askpass", ROAR_HAVE_BIN_GNOME_SSH_ASKPASS, 0, 0}, 492 492 {"bin-gpg", ROAR_HAVE_BIN_GPG, 0, 0}, 493 493 {"bin-eject", ROAR_HAVE_BIN_EJECT, 0, 0}, 494 494 495 495 // devices: 496 {"dev-stdin", ROAR_PREFIX_DEV "/stdin", 0, 0},496 {"dev-stdin", ROAR_PREFIX_DEV "/stdin", 0, 0}, 497 497 {"dev-default-pwmled", ROAR_PREFIX_DEV "/ttyS0", 0, 0}, 498 {"dev-default-dmx4linux", ROAR_PREFIX_DEV "/dmx", 0, 0}, 498 499 499 500 #ifdef ROAR_DEFAULT_CDROM … … 512 513 // proc: 513 514 #ifdef ROAR_PROC_NET_DECNET 514 {"proc-net-decnet", ROAR_PROC_NET_DECNET, 0, 0},515 {"proc-net-decnet", ROAR_PROC_NET_DECNET, 0, 0}, 515 516 #endif 516 517 #ifdef ROAR_PROC_NET_DECNET_NEIGH 517 {"proc-net-decnet-neigh", ROAR_PROC_NET_DECNET_NEIGH, 0, 0},518 {"proc-net-decnet-neigh", ROAR_PROC_NET_DECNET_NEIGH, 0, 0}, 518 519 #endif 519 520 #ifdef ROAR_PROC_NET_ARP 520 {"proc-net-arp", ROAR_PROC_NET_ARP, 0, 0},521 {"proc-net-arp", ROAR_PROC_NET_ARP, 0, 0}, 521 522 #endif 522 523 523 524 // sysconf: 524 {"sysconf-hosts", ROAR_PREFIX_SYSCONF "/hosts", 0, 0},525 {"sysconf-roarserver", ROAR_PREFIX_SYSCONF "/roarserver", 0, 0},525 {"sysconf-hosts", ROAR_PREFIX_SYSCONF "/hosts", 0, 0}, 526 {"sysconf-roarserver", ROAR_PREFIX_SYSCONF "/roarserver", 0, 0}, 526 527 527 528 // special dirs: 528 {"dir-nx-home", "/NX-HOME-DIR", 0, 0}529 {"dir-nx-home", "/NX-HOME-DIR", 0, 0} 529 530 }; 530 531 … … 606 607 } 607 608 609 static const struct pathinfo * __lookup_path(const char * name) { 610 size_t i; 611 612 if ( name == NULL ) { 613 roar_err_set(ROAR_ERROR_FAULT); 614 return NULL; 615 } 616 617 for (i = 0; i < (sizeof(__paths)/sizeof(*__paths)); i++) 618 if ( !strcmp(__paths[i].name, name) ) 619 return &(__paths[i]); 620 621 roar_err_set(ROAR_ERROR_NOENT); 622 return NULL; 623 } 624 608 625 char * roar_libroar_get_path(const char * name, int null_as_universal, const char * product, const char * provider) { 626 const struct pathinfo * path; 609 627 char buf_product[384]; 610 628 char buf_provider[384]; 611 629 ssize_t len_prefix, len_product, len_provider; 612 size_t i;613 630 char * ret, * p; 614 631 615 632 ROAR_DBG("roar_libroar_get_path(name='%s', null_as_universal=%i, product='%s', provider='%s') = ?", name, null_as_universal, product, provider); 616 633 617 if ( name == NULL ) { 618 roar_err_set(ROAR_ERROR_FAULT); 619 return NULL; 620 } 621 622 for (i = 0; i < (sizeof(__paths)/sizeof(*__paths)); i++) { 623 if ( !!strcmp(__paths[i].name, name) ) 624 continue; 625 626 if ( ((null_as_universal || product != NULL) && !__paths[i].with_product) || 627 (provider != NULL && !__paths[i].with_provider) ) { 628 roar_err_set(ROAR_ERROR_INVAL); 629 return NULL; 630 } 631 632 if ( __product2path(buf_product, sizeof(buf_product), null_as_universal, product, __paths[i].with_product) == -1 ) 633 return NULL; 634 635 if ( __provider2path(buf_provider, sizeof(buf_provider), provider) == -1 ) 636 return NULL; 637 638 len_prefix = roar_mm_strlen(__paths[i].path); 639 len_product = roar_mm_strlen(buf_product); 640 len_provider = roar_mm_strlen(buf_provider); 641 642 p = ret = roar_mm_malloc(len_prefix+len_product+len_provider+1); 643 if ( ret == NULL ) 644 return NULL; 645 646 memcpy(p, __paths[i].path, len_prefix); 647 p += len_prefix; 648 if ( p[-1] == '/' ) 649 p--; 650 memcpy(p, buf_product, len_product); 651 p += len_product; 652 memcpy(p, buf_provider, len_provider); 653 p += len_provider; 654 655 *p = 0; 656 657 return ret; 658 } 659 660 roar_err_set(ROAR_ERROR_NOENT); 661 return NULL; 634 path = __lookup_path(name); 635 if ( path == NULL ) 636 return NULL; 637 638 if ( ((null_as_universal || product != NULL) && !path->with_product) || 639 (provider != NULL && !path->with_provider) ) { 640 roar_err_set(ROAR_ERROR_INVAL); 641 return NULL; 642 } 643 644 if ( __product2path(buf_product, sizeof(buf_product), null_as_universal, product, path->with_product) == -1 ) 645 return NULL; 646 647 if ( __provider2path(buf_provider, sizeof(buf_provider), provider) == -1 ) 648 return NULL; 649 650 len_prefix = roar_mm_strlen(path->path); 651 len_product = roar_mm_strlen(buf_product); 652 len_provider = roar_mm_strlen(buf_provider); 653 654 p = ret = roar_mm_malloc(len_prefix+len_product+len_provider+1); 655 if ( ret == NULL ) 656 return NULL; 657 658 memcpy(p, path->path, len_prefix); 659 p += len_prefix; 660 if ( p[-1] == '/' ) 661 p--; 662 memcpy(p, buf_product, len_product); 663 p += len_product; 664 memcpy(p, buf_provider, len_provider); 665 p += len_provider; 666 667 *p = 0; 668 669 return ret; 670 } 671 672 const char * roar_libroar_get_path_static(const char * name) { 673 const struct pathinfo * path; 674 675 path = __lookup_path(name); 676 if ( path == NULL ) 677 return NULL; 678 679 return path->path; 662 680 } 663 681 -
libroar/enumdev.c
r5823 r5832 145 145 146 146 #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) 147 if ( (i = readlink( "/etc/roarserver", buf, sizeof(buf)-1)) != -1 ) {147 if ( (i = readlink(roar_libroar_get_path_static("sysconf-roarserver"), buf, sizeof(buf)-1)) != -1 ) { 148 148 buf[i] = 0; 149 149 _add(buf); … … 230 230 {ROAR_PROC_NET_ARP, NULL, 1}, 231 231 #endif 232 // { "/etc/hosts", NULL, 0},232 // {roar_libroar_get_path_static("sysconf-hosts"), NULL, 0}, 233 233 {NULL, NULL, 0} 234 234 }; -
libroar/pinentry.c
r5823 r5832 112 112 ROAR_U_EXIT(1); 113 113 114 execlp( ROAR_HAVE_BIN_PINENTRY, "RoarAudio", "--display", display, "--ttytype", term, "--ttyname", tty, NULL);114 execlp(roar_libroar_get_path_static("bin-pinentry"), "RoarAudio", "--display", display, "--ttytype", term, "--ttyname", tty, NULL); 115 115 116 116 ROAR_U_EXIT(1); -
libroar/socket.c
r5823 r5832 1164 1164 ROAR_DBG("roar_socket_open_ssh(*): proxy_port=%i, user='%s', proxy_addr='%s'", proxy_port, user, proxy_addr); 1165 1165 ROAR_DBG("roar_socket_open_ssh(*): rcmd: %s", rcmd); 1166 snprintf(cmd, 1023, ROAR_HAVE_BIN_SSH " -p %i -l '%s' '%s' '%s'", proxy_port, user, proxy_addr, 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 1167 cmd[1023] = 0; 1168 1168 -
libroar/vio_cmd.c
r5823 r5832 185 185 ROAR_U_EXIT(1); 186 186 187 execlp( "/bin/sh", "/bin/sh", "-c", child->cmd, (_LIBROAR_GOOD_CAST char*)NULL);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 188 189 189 ROAR_U_EXIT(1); … … 644 644 return -1; 645 645 646 snprintf(command, 1024, "%s --batch --no-verbose --quiet --passphrase-repeat 0 --passphrase-fd %i %s %s", ROAR_HAVE_BIN_GPG, pwpipe[0], para, opts);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); 647 647 648 648 write(pwpipe[1], pw, strlen(pw)); … … 650 650 close(pwpipe[1]); 651 651 } else { 652 snprintf(command, 1024, "%s --no-verbose --quiet %s %s", ROAR_HAVE_BIN_GPG, para, opts);652 snprintf(command, 1024, "%s --no-verbose --quiet %s %s", roar_libroar_get_path_static("bin-gpg"), para, opts); 653 653 } 654 654 -
roard/driver_dmx.c
r5823 r5832 47 47 48 48 if ( dev == NULL ) 49 dev = "/dev/dmx";49 dev = roar_libroar_get_path_static("dev-default-dmx4linux"); 50 50 51 51 if ( roar_vio_open_dstr(vio, dev, &def, 1) == -1 ) {
Note: See TracChangeset
for help on using the changeset viewer.