Changeset 5828:d981716ace28 in roaraudio for roarclients


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

added a way to list all known paths

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.