Changeset 5747:17e1c9dacc8f in roaraudio
- Timestamp:
- 11/14/12 04:32:25 (11 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r5743 r5747 8 8 protocol-rplay and protocol-gopher (Closes: #311) 9 9 * Allow RAT builds on systems with full linkage. 10 * Provide a more common interface for path config. 10 11 11 12 v. 1.0beta7 - Tue Oct 23 2012 23:28 CEST -
doc/man1/roar-config.1
r5672 r5747 27 27 28 28 .TP 29 \fB--product PRODUCT\fR 30 Product string for --path. 31 32 .TP 33 \fB--provider PROVIDER\fR 34 Provider string for --path. 35 36 .TP 37 \fB--universal\fR 38 Use universal path for --path. 39 40 .TP 29 41 \fB--libs\fR 30 42 Show linker flags (\-lxxx) needed to link library -
include/libroar/config.h
r5465 r5747 153 153 #define roar_libroar_iswarn(cfg) (((cfg) == NULL ? roar_libroar_get_config_ptr() : (cfg))->nowarncounter ? 0 : 1) 154 154 155 // get a buffer to a system local path (prefix). 156 // name is the symbolic name of the path, e.g. "prefix-lib". 157 // null_as_universal tells of NULL is considered as "universal". 158 // if not set NULL is considered 'do not add product path, give root prefix'. 159 // product is the name of the product in standard "product <id/vendor>" format. 160 // provider is the "<id/vendor>" format. If NULL this is ignored. 161 // Returns buffer which needs to be freed with roar_mm_free(). 162 // Not all paths support product/provider part. If not supported they are ignored. 163 char * roar_libroar_get_path(const char * name, int null_as_universal, const char * product, const char * provider); 164 155 165 #endif 156 166 -
libroar/config.c
r5466 r5747 432 432 } 433 433 434 static const struct { 435 const char * name; 436 const char * path; 437 const int with_product; 438 const int with_provider; 439 } __paths[] = { 440 {"prefix", ROAR_PREFIX, 0, 0}, 441 {"prefix-bin", ROAR_PREFIX_BIN, 0, 0}, 442 {"prefix-lib", ROAR_PREFIX_LIB, 0, 0}, 443 {"prefix-inc", ROAR_PREFIX_INC, 0, 0}, 444 {"prefix-man", ROAR_PREFIX_MAN, 0, 0}, 445 {"prefix-pc", ROAR_PREFIX_PC, 0, 0}, 446 {"prefix-comp-libs", ROAR_PREFIX_COMP_LIBS, 0, 0}, 447 {"prefix-comp-bins", ROAR_PREFIX_COMP_BINS, 0, 0}, 448 {"prefix-plugins", ROAR_PREFIX_PLUGINS, 1, 1}, 449 {"prefix-buildsystem", ROAR_PREFIX_BUILDSYSTEM, 0, 0} 450 }; 451 452 static int __product2path(char * path, size_t pathlen, int null_as_universal, const char * product) { 453 const char * c; 454 const char * e; 455 const char * s; 456 const char * b; 457 458 if ( product == NULL ) { 459 if ( null_as_universal ) { 460 snprintf(path, pathlen, "/universal/universal"); 461 } else { 462 path[0] = 0; 463 } 464 return 0; 465 } 466 467 b = strstr(product, " "); 468 c = strstr(product, "<"); 469 e = strstr(product, ">"); 470 471 if ( b == NULL || c == NULL || e == NULL || c < b || e < c ) { 472 roar_err_set(ROAR_ERROR_ILLSEQ); 473 return -1; 474 } 475 476 c++; 477 478 s = strstr(c, "/"); 479 480 if ( s == NULL ) { 481 snprintf(path, pathlen, "/unreg-%.*s/%.*s", (int)(size_t)(e-c), c, (int)(size_t)(b-product), product); 482 } else { 483 snprintf(path, pathlen, "/%.*s-%.*s/%.*s", (int)(size_t)(s-c), c, (int)(size_t)(e-s-1), s+1, (int)(size_t)(b-product), product); 484 } 485 486 return 0; 487 } 488 489 static int __provider2path(char * path, size_t pathlen, const char * provider) { 490 const char * c; 491 const char * e; 492 const char * s; 493 494 if ( provider == NULL ) { 495 path[0] = 0; 496 return 0; 497 } 498 499 c = strstr(provider, "<"); 500 e = strstr(provider, ">"); 501 502 if ( c == NULL || e == NULL || e < c ) { 503 roar_err_set(ROAR_ERROR_ILLSEQ); 504 return -1; 505 } 506 507 c++; 508 509 s = strstr(c, "/"); 510 511 if ( s == NULL ) { 512 snprintf(path, pathlen, "/unreg-%.*s", (int)(size_t)(e-c), c); 513 } else { 514 snprintf(path, pathlen, "/%.*s-%.*s", (int)(size_t)(s-c), c, (int)(size_t)(e-s-1), s+1); 515 } 516 517 return 0; 518 519 roar_err_set(ROAR_ERROR_NOTSUP); 520 return -1; 521 } 522 523 char * roar_libroar_get_path(const char * name, int null_as_universal, const char * product, const char * provider) { 524 char buf_product[1024]; 525 char buf_provider[1024]; 526 ssize_t len_prefix, len_product, len_provider; 527 size_t i; 528 char * ret, * p; 529 530 if ( name == NULL ) { 531 roar_err_set(ROAR_ERROR_NOENT); 532 return NULL; 533 } 534 535 for (i = 0; i < (sizeof(__paths)/sizeof(*__paths)); i++) { 536 if ( !!strcmp(__paths[i].name, name) ) 537 continue; 538 539 if ( ((null_as_universal || product != NULL) && !__paths[i].with_product) || 540 (provider != NULL && !__paths[i].with_provider) ) { 541 roar_err_set(ROAR_ERROR_INVAL); 542 return NULL; 543 } 544 545 if ( __product2path(buf_product, sizeof(buf_product), null_as_universal, product) == -1 ) 546 return NULL; 547 548 if ( __provider2path(buf_provider, sizeof(buf_provider), provider) == -1 ) 549 return NULL; 550 551 len_prefix = roar_mm_strlen(__paths[i].path); 552 len_product = roar_mm_strlen(buf_product); 553 len_provider = roar_mm_strlen(buf_provider); 554 555 p = ret = roar_mm_malloc(len_prefix+len_product+len_provider+1); 556 if ( ret == NULL ) 557 return NULL; 558 559 memcpy(p, __paths[i].path, len_prefix); 560 p += len_prefix; 561 if ( p[-1] == '/' ) 562 p--; 563 memcpy(p, buf_product, len_product); 564 p += len_product; 565 memcpy(p, buf_provider, len_provider); 566 p += len_provider; 567 568 *p = 0; 569 570 return ret; 571 } 572 573 roar_err_set(ROAR_ERROR_NOENT); 574 return NULL; 575 } 576 434 577 //ll -
roarclients/Makefile
r5737 r5747 90 90 $L 91 91 roar-config: roar-config.o 92 $ (LNL)92 $L 93 93 roarvorbis: roarvorbis.o 94 94 ${CC} ${LDFLAGS} -o roarvorbis roarvorbis.o $(VORBISLIBS) $(LIBS) -
roarclients/roar-config.c
r5674 r5747 53 53 }, * flags_ptr = NULL; 54 54 55 const struct path { 56 const char * name; 57 const char * path; 58 } paths[] = { 59 {"prefix", ROAR_PREFIX}, 60 {"prefix-bin", ROAR_PREFIX_BIN}, 61 {"prefix-lib", ROAR_PREFIX_LIB}, 62 {"prefix-inc", ROAR_PREFIX_INC}, 63 {"prefix-man", ROAR_PREFIX_MAN}, 64 {"prefix-pc", ROAR_PREFIX_PC}, 65 {"prefix-comp-libs", ROAR_PREFIX_COMP_LIBS}, 66 {"prefix-comp-bins", ROAR_PREFIX_COMP_BINS}, 67 {"prefix-plugins", ROAR_PREFIX_PLUGINS}, 68 {"prefix-buildsystem", ROAR_PREFIX_BUILDSYSTEM}, 69 {"<<<END>>>", NULL} 70 }; 71 72 void print_path(const char * name) { 73 size_t i; 74 75 for (i = 0; i < (sizeof(paths)/sizeof(*paths)); i++) { 76 if ( !strcasecmp(name, paths[i].name) ) { 77 printf("%s\n", paths[i].path); 78 return; 79 } 80 } 55 void print_path(const char * name, int null_as_universal, const char * product, const char * provider) { 56 char * path = roar_libroar_get_path(name, null_as_universal, product, provider); 57 if ( path == NULL ) 58 return; 59 printf("%s\n", path); 60 roar_mm_free(path); 81 61 } 82 62 … … 87 67 88 68 printf( 89 " --version - Show version of library\n" 90 " --path NAME - Print path NAME\n" 91 " --libs - Show linker flags (-lxxx) needed to link library\n" 92 " --cflags - Show compiler flags needed to link library\n" 93 " --output-pc - Output PC format\n" 94 " --output-normal - Output PC format\n" 69 " --version - Show version of library\n" 70 " --path NAME - Print path NAME\n" 71 " --product PRODUCT - Product string for --path\n" 72 " --provider PROVIDER - Provider string for --path\n" 73 " --universal - Use universal path for --path\n" 74 " --libs - Show linker flags (-lxxx) needed to link library\n" 75 " --cflags - Show compiler flags needed to link library\n" 76 " --output-pc - Output PC format\n" 77 " --output-normal - Output PC format\n" 95 78 ); 96 79 … … 101 84 int main (int argc, char * argv[]) { 102 85 enum { NORMAL, PC } mode = NORMAL; 86 int null_as_universal = 0; 87 const char * product = NULL; 88 const char * provider = NULL; 103 89 int i, h; 104 90 int cflags = 0; … … 117 103 usage(); 118 104 return 0; 105 } else if ( !strcmp(argv[i], "--product") ) { 106 product = argv[++i]; 107 } else if ( !strcmp(argv[i], "--provider") ) { 108 provider = argv[++i]; 109 } else if ( !strcmp(argv[i], "--universal") ) { 110 null_as_universal = 1; 119 111 } else if ( !strcmp(argv[i], "--path") ) { 120 print_path(argv[++i] );112 print_path(argv[++i], null_as_universal, product, provider); 121 113 } else if ( !strcmp(argv[i], "--libs") ) { 122 114 libs = 1;
Note: See TracChangeset
for help on using the changeset viewer.