Changeset 5828:d981716ace28 in roaraudio


Ignore:
Timestamp:
01/06/13 14:53:12 (8 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added a way to list all known paths

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • doc/man1/roar-config.1

    r5811 r5828  
    1515roar-config [{\-\-output-pc|\-\-output-normal}] [\-\-libs] [\-\-cflags] [LIB] 
    1616 
    17 roar-config [\-\-product PRODUCT] [\-\-provider PROVIDER] [\-\-universal] \-\-path PATH 
     17roar-config [\-\-product PRODUCT] [\-\-provider PROVIDER] [\-\-universal] {\-\-path PATH|\-\-list\-path} 
    1818 
    1919roar-config \-\-render\-path PATH 
     
    5151 
    5252.TP 
     53\fB--list-path\fR 
     54List all known paths with corresponding values. 
     55 
     56.TP 
    5357\fB--product PRODUCT\fR 
    54 Product string for \-\-path. 
     58Product string for \-\-path and \-\-list\-path. 
    5559 
    5660.TP 
    5761\fB--provider PROVIDER\fR 
    58 Provider string for \-\-path. 
     62Provider string for \-\-path and \-\-list\-path. 
    5963 
    6064.TP 
    6165\fB--universal\fR 
    62 Use universal path for \-\-path. 
     66Use universal path for \-\-path and \-\-list\-path. 
    6367 
    6468.TP 
  • include/libroar/config.h

    r5823 r5828  
    181181char * roar_libroar_get_path(const char * name, int null_as_universal, const char * product, const char * provider) _LIBROAR_ATTR_USE_RESULT; 
    182182 
     183// list all known paths: 
     184ssize_t roar_libroar_list_path(const char ** list, size_t len, size_t offset) _LIBROAR_ATTR_USE_RESULT _LIBROAR_ATTR_NONNULL_ALL; 
     185 
    183186#endif 
    184187 
  • libroar/config.c

    r5823 r5828  
    608608} 
    609609 
     610ssize_t roar_libroar_list_path(const char ** list, size_t len, size_t offset) { 
     611 size_t i; 
     612 ssize_t idx = 0; 
     613 
     614 if ( list == NULL ) { 
     615  roar_err_set(ROAR_ERROR_FAULT); 
     616  return -1; 
     617 } 
     618 
     619 if ( len == 0 ) 
     620  return 0; 
     621 
     622 if ( offset >= (sizeof(__paths)/sizeof(*__paths)) ) 
     623  return 0; 
     624 
     625 for (i = offset; i < (sizeof(__paths)/sizeof(*__paths)); i++) { 
     626  list[idx++] = __paths[i].name; 
     627 } 
     628 
     629 return idx; 
     630} 
     631 
    610632//ll 
  • roarclients/roar-config.c

    r5824 r5828  
    142142} 
    143143 
     144void list_path(int null_as_universal, const char * product, const char * provider) { 
     145 const char * names[32]; 
     146 char * path; 
     147 size_t offset = 0; 
     148 ssize_t ret; 
     149 ssize_t i; 
     150 const char * err; 
     151 size_t errlen; 
     152 
     153 while (1) { 
     154  ret = roar_libroar_list_path(names, sizeof(names)/sizeof(*names), offset); 
     155  if ( ret < 1 ) 
     156   break; 
     157  offset += (size_t)ret; 
     158 
     159  for (i = 0; i < ret; i++) { 
     160   path = roar_libroar_get_path(names[i], null_as_universal, product, provider); 
     161   if ( path == NULL && roar_error == ROAR_ERROR_INVAL ) 
     162    path = roar_libroar_get_path(names[i], 0, product, NULL); 
     163   if ( path == NULL && roar_error == ROAR_ERROR_INVAL ) 
     164    path = roar_libroar_get_path(names[i], 0, NULL, NULL); 
     165   if ( path == NULL ) { 
     166    err = roar_errorstring; 
     167    errlen = roar_mm_strlen(err) + roar_mm_strlen("<Error: >") + 1; 
     168    path = roar_mm_malloc(errlen); 
     169    if ( path == NULL ) 
     170     continue; 
     171    snprintf(path, errlen, "<Error: %s>", err); 
     172   } 
     173 
     174   printf("%-24s: %s\n", names[i], path); 
     175   roar_mm_free(path); 
     176  } 
     177 } 
     178} 
     179 
    144180void print_renderpath(const char * path) { 
    145181 char buf[1024]; 
     
    156192        "       roar-config --compare-versions VERSIONA OPERATOR VERSIONB\n" 
    157193        "       roar-config [{--output-pc|--output-normal}] [--libs] [--cflags] [LIB]\n" 
    158         "       roar-config [--product PRODUCT] [--provider PROVIDER] [--universal] --path PATH\n" 
     194        "       roar-config [--product PRODUCT] [--provider PROVIDER] [--universal] {--path PATH|--list-path}\n" 
    159195        "       roar-config --render-path PATH\n"); 
    160196 
     
    166202        "                      - Compare version A against B with operator OP.\n" 
    167203        "  --path NAME         - Print path NAME\n" 
    168         "  --product PRODUCT   - Product string for --path\n" 
    169         "  --provider PROVIDER - Provider string for --path\n" 
    170         "  --universal         - Use universal path for --path\n" 
     204        "  --list-path         - Print all known paths\n" 
     205        "  --product PRODUCT   - Product string for --path/--list-path\n" 
     206        "  --provider PROVIDER - Provider string for --path/--list-path\n" 
     207        "  --universal         - Use universal path for --path/--list-path\n" 
    171208        "  --render-path PATH  - Print a rendered path\n" 
    172209        "  --libs              - Show linker flags (-lxxx) needed to link library\n" 
     
    211248  } else if ( !strcmp(argv[i], "--path") ) { 
    212249   print_path(argv[++i], null_as_universal, product, provider); 
     250  } else if ( !strcmp(argv[i], "--list-path") ) { 
     251   list_path(null_as_universal, product, provider); 
    213252  } else if ( !strcmp(argv[i], "--render-path") ) { 
    214253   print_renderpath(argv[++i]); 
Note: See TracChangeset for help on using the changeset viewer.