Changeset 5353:de96f27919bf in roaraudio for roarclients


Ignore:
Timestamp:
12/12/11 19:11:39 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

serveral updates to roarpluginrunner and plugin API in general

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarpluginrunner.c

    r5347 r5353  
    4141 fprintf(stderr, "\nOptions:\n\n"); 
    4242 
    43  fprintf(stderr, " -h --help         - This help.\n" 
    44                  "    --verbose      - Be verbose. Can be used multiple times.\n" 
    45                  "    --run          - Run plugin.\n" 
    46                  "    --explain      - Explain plugin.\n"); 
     43 fprintf(stderr, " -h --help            - This help.\n" 
     44                 "    --verbose         - Be verbose. Can be used multiple times.\n" 
     45                 "    --server SERVER   - Set default server to SERVER.\n" 
     46                 "    --run             - Run plugin.\n" 
     47                 "    --explain         - Explain plugin.\n" 
     48                 "    --appname NAME    - Sets the appname.\n" 
     49                 "    --abiversion ABI  - Set the ABI version.\n" 
     50                 "    --args ARGS       - Set plugin arguments.\n" 
     51        ); 
    4752} 
    4853 
     
    6671 
    6772static const char * _ptr2str(const void * p) { 
     73#ifdef ROAR_HAVE_DLADDR 
     74 static char buf[80]; 
     75 Dl_info info; 
     76#else 
    6877 static char buf[24]; 
     78#endif 
    6979 
    7080 if ( p == NULL ) 
    7181  return "<not set>"; 
    7282 
     83#ifdef ROAR_HAVE_DLADDR 
     84 if ( dladdr(p, &info) != 0 ) { 
     85  if ( p == info.dli_saddr ) { 
     86   snprintf(buf, sizeof(buf), "%p <%s in \"%s\">", p, info.dli_sname, info.dli_fname); 
     87   return buf; 
     88  } 
     89 } 
     90#endif 
     91 
    7392 snprintf(buf, sizeof(buf), "%p", p); 
    7493 
     
    7796 
    7897static const char * _ptrrange2str(const void * p, size_t len) { 
    79  static char buf[48]; 
     98 static char buf[80]; 
    8099 
    81100 if ( p == NULL ) 
     
    112131 lib = func(g_para); 
    113132 if ( lib == NULL ) { 
    114   fprintf(stderr, "Warning: Can not RA init: %s\n", name); 
     133  fprintf(stderr, "Warning: Can not RA init: %s: %s\n", name, roar_error2str(roar_error)); 
    115134  roar_dl_unref(lhandle); 
    116135  return 0; 
     
    122141 
    123142 printf("lib                     = %s\n", _ptr2str(lib)); 
    124  printf("|-> version             = %i (%smatch)\n", lib->version, lib->version == ROAR_DL_LIBINST_VERSION ? "" : "no "); 
    125  printf("%c-> len                 = %zu (%smatch)\n", libok ? '|' : '\\', lib->len, lib->len == sizeof(*lib) ? "" : "no "); 
     143 if ( g_verbose || !libok ) { 
     144  printf("|-> version             = %i (%smatch)\n", lib->version, lib->version == ROAR_DL_LIBINST_VERSION ? "" : "no "); 
     145  printf("%c-> len                 = %zu (%smatch)\n", libok ? '|' : '\\', lib->len, lib->len == sizeof(*lib) ? "" : "no "); 
     146 } 
    126147 
    127148 if ( libok ) { 
    128   printf("|-> unload              = %s\n", _ptr2str(lib->unload)); 
     149  if ( g_verbose || lib->unload != NULL ) 
     150   printf("|-> unload              = %s\n", _ptr2str(lib->unload)); 
    129151  printf("|-> func                = {"); 
    130152  i = 0; 
     
    151173    libnameok = 1; 
    152174   } 
    153    printf("|   |-> version         = %i (%smatch)\n", lib->libname->version, 
    154                                                       lib->libname->version == ROAR_DL_LIBNAME_VERSION ? "" : "no "); 
    155    printf("|   %c-> len             = %zu (%smatch)\n", libnameok ? '|' : '\\', lib->libname->len, 
    156                                                       lib->libname->len == sizeof(*(lib->libname)) ? "" : "no "); 
     175   if ( g_verbose || !libnameok ) { 
     176    printf("|   |-> version         = %i (%smatch)\n", lib->libname->version, 
     177                                                       lib->libname->version == ROAR_DL_LIBNAME_VERSION ? "" : "no "); 
     178    printf("|   %c-> len             = %zu (%smatch)\n", libnameok ? '|' : '\\', lib->libname->len, 
     179                                                         lib->libname->len == sizeof(*(lib->libname)) ? "" : "no "); 
     180   } 
     181 
    157182   if ( libnameok ) { 
    158183#define _ps(k,name) \ 
    159184    tmp = (lib->libname->name) != NULL; \ 
     185    if ( tmp || g_verbose || (k) == '\\' ) \ 
    160186    printf("|   %c-> %-15s = %s%s%s\n", (k), #name, tmp ? "\"" : "", \ 
    161187                                    tmp ? (lib->libname->name) : "<not set>", tmp ? "\"" : ""); 
     
    172198   } 
    173199  } 
    174   printf("|-> global_data_len     = %zu\n", lib->global_data_len); 
    175   printf("|-> global_data_init    = %s\n", _ptrrange2str(lib->global_data_init, lib->global_data_len)); 
    176   printf("|-> global_data_pointer = %s\n", _ptr2str(lib->global_data_pointer)); 
     200  if ( g_verbose || lib->global_data_pointer != NULL ) 
     201   printf("|-> global_data_len     = %zu\n", lib->global_data_len); 
     202  if ( g_verbose || lib->global_data_init != NULL ) 
     203   printf("|-> global_data_init    = %s\n", _ptrrange2str(lib->global_data_init, lib->global_data_len)); 
     204  if ( g_verbose || lib->global_data_pointer != NULL ) 
     205   printf("|-> global_data_pointer = %s\n", _ptr2str(lib->global_data_pointer)); 
     206 
    177207  if ( lib->libdep != NULL && lib->libdep_len ) { 
    178208   printf("|-> libdep              = %s\n", _ptr2str(lib->libdep)); 
     
    186216     libdepok = 0; 
    187217    } 
    188     printf("|   %c   |-> version     = %i (%smatch)\n", c, lib->libdep[iter].version, 
    189                                                         lib->libdep[iter].version == ROAR_DL_LIBDEP_VERSION ? "" : "no "); 
    190     printf("|   %c   %c-> len         = %zu (%smatch)\n", c, libdepok ? '|' : '\\', 
    191                                                        lib->libdep[iter].len, 
    192                                                        lib->libdep[iter].len == sizeof(struct roar_dl_librarydep) ? 
    193                                                        "" : "no "); 
     218    if ( g_verbose || !libdepok ) { 
     219     printf("|   %c   |-> version     = %i (%smatch)\n", c, lib->libdep[iter].version, 
     220                                                         lib->libdep[iter].version == ROAR_DL_LIBDEP_VERSION ? "" : "no "); 
     221     printf("|   %c   %c-> len         = %zu (%smatch)\n", c, libdepok ? '|' : '\\', 
     222                                                        lib->libdep[iter].len, 
     223                                                        lib->libdep[iter].len == sizeof(struct roar_dl_librarydep) ? 
     224                                                        "" : "no "); 
     225    } 
     226 
    194227    if ( libdepok ) { 
    195228     printf("|   %c   |-> flags       = 0x%.8lX\n", c, (unsigned long int)lib->libdep[iter].flags); 
    196229#define _ps(k,name) \ 
    197230    tmp = (lib->libdep[iter].name) != NULL; \ 
     231    if ( tmp || g_verbose || (k) == '\\' ) \ 
    198232    printf("|   %c   %c-> %-11s = %s%s%s\n", c, (k), #name, tmp ? "\"" : "", \ 
    199233                                    tmp ? (lib->libdep[iter].name) : "<not set>", tmp ? "\"" : ""); 
     
    209243   printf("|-> libdep_len          = %zu (invalid)\n", lib->libdep_len); 
    210244  } 
    211   printf("\\-> appsched            = %s\n", _ptr2str(lib->appsched)); 
    212   if ( lib->appsched != NULL ) { 
    213    printf("    |-> init            = %s\n", _ptr2str(lib->appsched->init)); 
    214    printf("    |-> free            = %s\n", _ptr2str(lib->appsched->free)); 
    215    printf("    |-> update          = %s\n", _ptr2str(lib->appsched->update)); 
    216    printf("    |-> tick            = %s\n", _ptr2str(lib->appsched->tick)); 
    217    printf("    \\-> wait            = %s\n", _ptr2str(lib->appsched->wait)); 
    218   } 
     245  if ( g_verbose || lib->appsched != NULL ) { 
     246   printf("|-> appsched            = %s\n", _ptr2str(lib->appsched)); 
     247   if ( lib->appsched != NULL ) { 
     248    if ( lib->appsched->init != NULL ) 
     249     printf("|   |-> init            = %s\n", _ptr2str(lib->appsched->init)); 
     250    if ( lib->appsched->free != NULL ) 
     251     printf("|   |-> free            = %s\n", _ptr2str(lib->appsched->free)); 
     252    if ( lib->appsched->update != NULL ) 
     253     printf("|   |-> update          = %s\n", _ptr2str(lib->appsched->update)); 
     254    if ( lib->appsched->tick != NULL ) 
     255     printf("|   |-> tick            = %s\n", _ptr2str(lib->appsched->tick)); 
     256    printf("|   \\-> wait            = %s\n", _ptr2str(lib->appsched->wait)); 
     257   } 
     258  } 
     259#define _ps(k,name) \ 
     260    tmp = (lib->name) != NULL; \ 
     261    if ( tmp || g_verbose || (k) == '\\' ) \ 
     262    printf("%c-> %-19s = %s%s%s\n", (k), #name, tmp ? "\"" : "", \ 
     263                                    tmp ? (lib->name) : "<not set>", tmp ? "\"" : ""); 
     264  _ps('|', host_appname); 
     265  _ps('\\', host_abiversion); 
     266#undef _ps 
    219267 } 
    220268 
     
    247295 
    248296int main (int argc, char * argv[]) { 
    249  const char * appname    = "roarpluginrunner"; 
    250  const char * abiversion = NULL; 
     297 const char * appname    = "roarpluginrunner " ROAR_VSTR_ROARAUDIO; 
     298 const char * abiversion = "1.0beta0"; 
    251299 const char * pluginargs = NULL; 
    252300 enum action action = RUN; 
     
    267315  } else if ( !strcmp(k, "--verbose") ) { 
    268316   g_verbose++; 
     317  } else if ( !strcmp(k, "--server") ) { 
     318   roar_libroar_set_server(argv[++i]); 
    269319  } else if ( !strcmp(k, "--appname") ) { 
    270320   appname = argv[++i]; 
Note: See TracChangeset for help on using the changeset viewer.