Changeset 5275:811818eb5b81 in roaraudio for include


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

Improved plugin loader a lot (Closes: #190)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/roardl.h

    r4708 r5275  
    5757#define ROAR_DL_FN_PROTO               11 
    5858//#define ROAR_DL_FN_               9 
    59 #define ROAR_DL_FN_MAX                 16 
     59#define ROAR_DL_FN_MAX                 24 
    6060 
    61 #define ROAR_DL_LIBPARA_VERSION         0 
    62 #define ROAR_DL_LIBINST_VERSION         0 
     61#define ROAR_DL_LIBPARA_VERSION         1 
     62#define ROAR_DL_LIBNAME_VERSION         0 
     63#define ROAR_DL_LIBINST_VERSION         1 
    6364 
    6465#define ROAR_DL_PLUGIN(lib) struct roar_dl_libraryinst *                                          \ 
     
    7475                                     static int _inited = 0;                                      \ 
    7576                                     static struct roar_dl_libraryinst lib;                       \ 
     77                                     static struct roar_dl_libraryname libname;                   \ 
    7678                                     (void)para;                                                  \ 
    7779                                     if ( _inited )                                               \ 
     
    8082                                     lib.version = ROAR_DL_LIBINST_VERSION;                       \ 
    8183                                     lib.len     = sizeof(lib);                                   \ 
     84                                     memset(&libname, 0, sizeof(libname));                        \ 
     85                                     libname.version = ROAR_DL_LIBNAME_VERSION;                   \ 
     86                                     libname.len     = sizeof(libname);                           \ 
     87                                     libname.name = #xlib;                                        \ 
     88                                     lib.libname  = &libname;                                     \ 
    8289                                     do 
    8390 
     
    8794                                   } 
    8895 
     96#define ROAR_DL_PLUGIN_ABORT_LOADING(err) roar_err_set((err)); return NULL 
     97#define ROAR_DL_PLUGIN_CHECK_VERSIONS(app,abi) if ( roar_dl_para_check_version(para, (app), (abi)) == -1 ) return NULL 
    8998#define ROAR_DL_PLUGIN_REG(fn, funcptr) (lib.func[(fn)] = (funcptr)) 
    9099#define ROAR_DL_PLUGIN_REG_UNLOAD(func) (lib.unload = (func)) 
    91100 
    92101struct roar_dl_librarypara { 
    93  int version; 
    94  size_t len; 
     102 int version;               // version of this struct type (must be ROAR_DL_LIBPARA_VERSION) 
     103 size_t len;                // Length of this struct type (must be sizeof(struct roar_dl_librarypara) 
     104 
     105 size_t refc;               // Reference counter. 
     106 
     107 size_t argc;               // number of elements in argv 
     108 struct roar_keyval * argv; // Parameter for the plugin 
     109 void * args_store;         // Storage area for argv's data. 
     110                            // If not NULL this and argv will be freed. 
     111                            // If NULL argv will be left untouched. 
     112 
     113 void * binargv;            // A pointer with binary data arguments. 
     114                            // This can be used to pass any non-string data to 
     115                            // the plugin. Normally this is NULL or the pointer 
     116                            // to a struct with members of whatever is needed. 
     117 
     118 const char * appname;      // application name in common format: 
     119                            // Product/Version <VendorID/VendorName> (comments) 
     120                            // Version and comment are optional and should be avoided. 
     121                            // When no vendor ID is registered use <VendorName>. 
     122                            // The VendorName MUST NOT contain a slash and SHOULD 
     123                            // be as unique as possible. 
     124                            // Examples: roard <0/RoarAudio>, MyAPP <myapp.org>, 
     125                            //           AnAPP <Musterman GbR> 
     126 const char * abiversion;   // The ABI version. For libraries this should be the SONAME. 
     127                            // For applications this should be the version of the release 
     128                            // which introduced the current ABI. 
     129                            // Examples: libroar2, 0.5.1 
     130}; 
     131 
     132struct roar_dl_libraryname { 
     133 int      version; 
     134 size_t   len; 
     135 const char * name;        //Format: shortname 
     136 const char * libversion;  //Format: Product/Version <VendorID/VendorName> (comments) 
     137 const char * description; //Free form. 
     138 const char * contact;     //Format: first ["']nick["'] last (comment) <email>/OpenPGPkey/Phone/Room 
     139 const char * authors;     //Other authors as free form. 
     140 const char * license;     //Format: LicenseName-Version (options) 
     141                           //Examples: GPL-3.0, LGPL-2.1, LGPL-3.0 (or later). 
    95142}; 
    96143 
     
    100147 int    (*unload)(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib); 
    101148 int    (*func[ROAR_DL_FN_MAX])(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib); 
     149 struct roar_dl_libraryname * libname; 
    102150}; 
    103151 
    104 struct roar_dl_lhandle { 
    105  struct roar_dl_librarypara * para; 
    106  struct roar_dl_libraryinst * lib; 
    107 #if defined(ROAR_HAVE_LIBDL) 
    108  void * handle; 
    109 #else 
    110  char dummy[8]; 
    111 #endif 
    112 }; 
     152struct roar_dl_librarypara * roar_dl_para_new(const char * args, void * binargv, 
     153                                              const char * appname, const char * abiversion); 
     154int roar_dl_para_ref                    (struct roar_dl_librarypara * para); 
     155int roar_dl_para_unref                  (struct roar_dl_librarypara * para); 
     156int roar_dl_para_check_version          (struct roar_dl_librarypara * para, 
     157                                         const char * appname, const char * abiversion); 
    113158 
    114 struct roar_dl_lhandle * roar_dl_open(const char * filename, int flags, int ra_init); 
    115 int                      roar_dl_close(struct roar_dl_lhandle * lhandle); 
     159struct roar_dl_lhandle * roar_dl_open   (const char * filename, int flags, 
     160                                         int ra_init, struct roar_dl_librarypara * para); 
     161int                      roar_dl_close  (struct roar_dl_lhandle * lhandle); 
    116162 
    117 void                   * roar_dl_getsym(struct roar_dl_lhandle * lhandle, const char * sym, int type); 
     163void                   * roar_dl_getsym (struct roar_dl_lhandle * lhandle, const char * sym, int type); 
    118164 
    119 int                      roar_dl_ra_init(struct roar_dl_lhandle * lhandle, const char * prefix); 
     165int                      roar_dl_ra_init(struct roar_dl_lhandle * lhandle, 
     166                                         const char * prefix, 
     167                                         struct roar_dl_librarypara * para); 
    120168 
    121 char *                   roar_dl_errstr(struct roar_dl_lhandle * lhandle); 
     169const char *             roar_dl_errstr (struct roar_dl_lhandle * lhandle); 
     170 
     171struct roar_dl_librarypara       * roar_dl_getpara(struct roar_dl_lhandle * lhandle); 
     172const struct roar_dl_libraryname * roar_dl_getlibname(struct roar_dl_lhandle * lhandle); 
    122173 
    123174#endif 
Note: See TracChangeset for help on using the changeset viewer.