[3297] | 1 | //roardl.h: |
---|
| 2 | |
---|
| 3 | /* |
---|
[5381] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2012 |
---|
[3297] | 5 | * |
---|
| 6 | * This file is part of libroar a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * libroar is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[3297] | 23 | * |
---|
| 24 | * NOTE for everyone want's to change something and send patches: |
---|
| 25 | * read README and HACKING! There a addition information on |
---|
| 26 | * the license of this document you need to read before you send |
---|
| 27 | * any patches. |
---|
| 28 | * |
---|
| 29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
| 30 | * or libpulse*: |
---|
| 31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
| 32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
| 33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
| 34 | */ |
---|
| 35 | |
---|
| 36 | #ifndef _LIBROARROARDL_H_ |
---|
| 37 | #define _LIBROARROARDL_H_ |
---|
| 38 | |
---|
| 39 | #include "libroar.h" |
---|
| 40 | |
---|
[5317] | 41 | #define ROAR_DL_FLAG_DEFAULTS -1 |
---|
[5427] | 42 | #define ROAR_DL_FLAG_PLUGIN -2 |
---|
[5317] | 43 | #define ROAR_DL_FLAG_NONE 0x0000 |
---|
| 44 | #define ROAR_DL_FLAG_STATIC 0x0001 /* plugins are linked statically -lfoo */ |
---|
[5344] | 45 | #define ROAR_DL_FLAG_LAZY 0x0002 |
---|
[5427] | 46 | #define ROAR_DL_FLAG_PLUGINPATH 0x0004 /* Use plugin search path */ |
---|
[3303] | 47 | |
---|
[3297] | 48 | #define ROAR_DL_HANDLE_DEFAULT ((struct roar_dl_lhandle*)(void*)0) |
---|
| 49 | #define ROAR_DL_HANDLE_NEXT ((struct roar_dl_lhandle*)(void*)1) |
---|
[5511] | 50 | #define ROAR_DL_HANDLE_LIBROAR ((struct roar_dl_lhandle*)(void*)2) |
---|
| 51 | #define ROAR_DL_HANDLE_APPLICATION ((struct roar_dl_lhandle*)(void*)3) |
---|
[3297] | 52 | |
---|
[5511] | 53 | #define ROAR_DL_FN_DSTR 0 /* VIO and DSTR drivers */ |
---|
| 54 | #define ROAR_DL_FN_CDRIVER 1 /* Client drivers, libroareio */ |
---|
| 55 | #define ROAR_DL_FN_TRANSCODER 2 /* Transcoder, libroardsp */ |
---|
| 56 | #define ROAR_DL_FN_DRIVER 3 /* Driver, roard? */ |
---|
| 57 | #define ROAR_DL_FN_SOURCE 4 /* Sources, roard? */ |
---|
| 58 | #define ROAR_DL_FN_FILTER 5 /* Filter, libroardsp */ |
---|
| 59 | #define ROAR_DL_FN_FF 6 /* file format??? */ |
---|
| 60 | #define ROAR_DL_FN_AUTH 7 /* Auth */ |
---|
| 61 | #define ROAR_DL_FN_BRIDGE 8 /* Bridges, roard? */ |
---|
| 62 | #define ROAR_DL_FN_ROARDSCHED 9 /* Like appsched, but roard specific, old */ |
---|
| 63 | #define ROAR_DL_FN_APPSCHED 10 /* AppSched, old interface */ |
---|
| 64 | #define ROAR_DL_FN_PROTO 11 /* Protocols, roard? */ |
---|
| 65 | #define ROAR_DL_FN_NOTIFY 12 /* ??? */ |
---|
[5317] | 66 | #define ROAR_DL_FN_INIT 13 /* global plugin instance init. should be avoided */ |
---|
[5511] | 67 | #define ROAR_DL_FN_REGFN 14 /* FN Registrations */ |
---|
| 68 | #define ROAR_DL_FN_APPLICATION 15 /* Application specific stuff */ |
---|
[3299] | 69 | //#define ROAR_DL_FN_ 9 |
---|
[5275] | 70 | #define ROAR_DL_FN_MAX 24 |
---|
[3300] | 71 | |
---|
[5275] | 72 | #define ROAR_DL_LIBPARA_VERSION 1 |
---|
| 73 | #define ROAR_DL_LIBNAME_VERSION 0 |
---|
| 74 | #define ROAR_DL_LIBINST_VERSION 1 |
---|
[5347] | 75 | #define ROAR_DL_LIBDEP_VERSION 0 |
---|
[3300] | 76 | |
---|
| 77 | #define ROAR_DL_PLUGIN(lib) struct roar_dl_libraryinst * \ |
---|
[3306] | 78 | _##lib##_roaraudio_library_init(struct roar_dl_librarypara * para); \ |
---|
| 79 | struct roar_dl_libraryinst * \ |
---|
[3300] | 80 | _roaraudio_library_init(struct roar_dl_librarypara * para) { \ |
---|
| 81 | return _##lib##_roaraudio_library_init(para); \ |
---|
| 82 | } \ |
---|
| 83 | struct roar_dl_libraryinst * \ |
---|
| 84 | _##lib##_roaraudio_library_init(struct roar_dl_librarypara * para) \ |
---|
[3299] | 85 | |
---|
[3308] | 86 | #define ROAR_DL_PLUGIN_START(xlib) ROAR_DL_PLUGIN(xlib) { \ |
---|
| 87 | static int _inited = 0; \ |
---|
| 88 | static struct roar_dl_libraryinst lib; \ |
---|
[5275] | 89 | static struct roar_dl_libraryname libname; \ |
---|
[4681] | 90 | (void)para; \ |
---|
[3308] | 91 | if ( _inited ) \ |
---|
| 92 | return &lib; \ |
---|
[5501] | 93 | if ( para != NULL && \ |
---|
| 94 | (para->version != ROAR_DL_LIBPARA_VERSION || \ |
---|
| 95 | para->len < sizeof(struct roar_dl_librarypara)) ) { \ |
---|
[5512] | 96 | /* we should set ROAR_ERROR_NSVERSION here but can not */ \ |
---|
| 97 | /* because that would require the plugin to be linked */ \ |
---|
| 98 | /* aginst libroar */ \ |
---|
[5501] | 99 | return NULL; \ |
---|
| 100 | } \ |
---|
[3308] | 101 | memset(&lib, 0, sizeof(lib)); \ |
---|
| 102 | lib.version = ROAR_DL_LIBINST_VERSION; \ |
---|
| 103 | lib.len = sizeof(lib); \ |
---|
[5275] | 104 | memset(&libname, 0, sizeof(libname)); \ |
---|
| 105 | libname.version = ROAR_DL_LIBNAME_VERSION; \ |
---|
| 106 | libname.len = sizeof(libname); \ |
---|
| 107 | libname.name = #xlib; \ |
---|
| 108 | lib.libname = &libname; \ |
---|
[3308] | 109 | do |
---|
| 110 | |
---|
| 111 | #define ROAR_DL_PLUGIN_END while(0); \ |
---|
| 112 | _inited = 1; \ |
---|
| 113 | return &lib; \ |
---|
| 114 | } |
---|
| 115 | |
---|
[5335] | 116 | // general stuff: |
---|
[5275] | 117 | #define ROAR_DL_PLUGIN_ABORT_LOADING(err) roar_err_set((err)); return NULL |
---|
[5453] | 118 | #define ROAR_DL_PLUGIN_CHECK_VERSIONS(app,abi) (((lib.host_appname = (app)) != NULL) | \ |
---|
| 119 | ((lib.host_abiversion = (abi)) != NULL) ) |
---|
[5353] | 120 | // should we keep this macro at all? Is it helpfull at all? |
---|
| 121 | // if a plugin can handle multiple hosts it needs to call roar_dl_para_check_version() itself anyway. |
---|
| 122 | #define ROAR_DL_PLUGIN_CHECK_VERSIONS_NOW(app,abi) if ( roar_dl_para_check_version(para, (app), (abi)) == -1 ) return NULL |
---|
[5335] | 123 | |
---|
| 124 | // register stuff: |
---|
[3363] | 125 | #define ROAR_DL_PLUGIN_REG(fn, funcptr) (lib.func[(fn)] = (funcptr)) |
---|
[3360] | 126 | #define ROAR_DL_PLUGIN_REG_UNLOAD(func) (lib.unload = (func)) |
---|
[5317] | 127 | #define ROAR_DL_PLUGIN_REG_APPSCHED(sched) (lib.appsched = (sched)) |
---|
[5313] | 128 | #define ROAR_DL_PLUGIN_REG_GLOBAL_DATA(ptr,init) lib.global_data_len = sizeof((init)); \ |
---|
| 129 | lib.global_data_init = &(init); \ |
---|
| 130 | lib.global_data_pointer = (void*)&(ptr) |
---|
[5353] | 131 | #define ROAR_DL_PLUGIN_REG_LIBDEP(deps) (((lib.libdep = (deps)) == NULL) ? \ |
---|
[5347] | 132 | (ssize_t)-1 : \ |
---|
[5353] | 133 | (ssize_t)(lib.libdep_len = sizeof((deps))/sizeof(struct roar_dl_librarydep))) |
---|
[3314] | 134 | |
---|
[5582] | 135 | // register objects using FN: |
---|
[5578] | 136 | #define ROAR_DL_PLUGIN_REG_FN(subtype,obj,version) roar_dl_register_fn(NULL, -1, (subtype), &(obj), sizeof((obj)), (version), ROAR_DL_FNREG_OPT_NONE) |
---|
| 137 | |
---|
[5582] | 138 | // Do a FN reg callback registration: |
---|
| 139 | #define ROAR_DL_RFNREG(lhandle,obj) roar_dl_register_fn((lhandle), ROAR_DL_FN_REGFN, ROAR_DL_FNREG_SUBTYPE, &(obj), sizeof((obj)), ROAR_DL_FNREG_VERSION, ROAR_DL_FNREG_OPT_NONE) |
---|
| 140 | |
---|
[5335] | 141 | // meta data stuff: |
---|
| 142 | #define ROAR_DL_PLUGIN_META_PRODUCT(x) (libname.libname = (x)) |
---|
| 143 | #define ROAR_DL_PLUGIN_META_PRODUCT_NV(name,vendor) ROAR_DL_PLUGIN_META_PRODUCT(name " <" vendor ">") |
---|
[5338] | 144 | #define ROAR_DL_PLUGIN_META_PRODUCT_NIV_REAL(name,id,vendor) ROAR_DL_PLUGIN_META_PRODUCT(name " <" #id "/" vendor ">") |
---|
| 145 | #define ROAR_DL_PLUGIN_META_PRODUCT_NIV(name,id,vendor) ROAR_DL_PLUGIN_META_PRODUCT_NIV_REAL(name,id,vendor) |
---|
[5335] | 146 | #define ROAR_DL_PLUGIN_META_VERSION(x) (libname.libversion = (x)) |
---|
| 147 | #define ROAR_DL_PLUGIN_META_ABI(x) (libname.abiversion = (x)) |
---|
| 148 | #define ROAR_DL_PLUGIN_META_DESC(x) (libname.description = (x)) |
---|
| 149 | #define ROAR_DL_PLUGIN_META_CONTACT(x) (libname.contact = (x)) |
---|
| 150 | #define ROAR_DL_PLUGIN_META_CONTACT_FL(first,last) ROAR_DL_PLUGIN_META_CONTACT(first " " last) |
---|
| 151 | #define ROAR_DL_PLUGIN_META_CONTACT_FLE(first,last,email) ROAR_DL_PLUGIN_META_CONTACT(first " " last " <" email ">") |
---|
| 152 | #define ROAR_DL_PLUGIN_META_CONTACT_FLNE(first,last,nick,email) ROAR_DL_PLUGIN_META_CONTACT(first " \"" nick "\" " last " <" email ">") |
---|
| 153 | #define ROAR_DL_PLUGIN_META_AUTHORS(x) (libname.authors = (x)) |
---|
| 154 | #define ROAR_DL_PLUGIN_META_LICENSE(x) (libname.license = (x)) |
---|
| 155 | #define ROAR_DL_PLUGIN_META_LICENSE_TAG(x) ROAR_DL_PLUGIN_META_LICENSE(ROAR_LICENSE_ ## x) |
---|
| 156 | |
---|
[5322] | 157 | enum roar_dl_loadercmd { |
---|
[5327] | 158 | ROAR_DL_LOADER_NOOP = 0, |
---|
| 159 | ROAR_DL_LOADER_PRELOAD, |
---|
| 160 | ROAR_DL_LOADER_LOAD, |
---|
| 161 | ROAR_DL_LOADER_POSTLOAD, |
---|
| 162 | ROAR_DL_LOADER_PREUNLOAD, |
---|
| 163 | ROAR_DL_LOADER_UNLOAD, |
---|
| 164 | ROAR_DL_LOADER_POSTUNLOAD |
---|
[5322] | 165 | }; |
---|
| 166 | |
---|
[5335] | 167 | struct roar_plugincontainer; |
---|
| 168 | |
---|
[3297] | 169 | struct roar_dl_librarypara { |
---|
[5275] | 170 | int version; // version of this struct type (must be ROAR_DL_LIBPARA_VERSION) |
---|
| 171 | size_t len; // Length of this struct type (must be sizeof(struct roar_dl_librarypara) |
---|
| 172 | |
---|
| 173 | size_t refc; // Reference counter. |
---|
| 174 | |
---|
| 175 | size_t argc; // number of elements in argv |
---|
| 176 | struct roar_keyval * argv; // Parameter for the plugin |
---|
| 177 | void * args_store; // Storage area for argv's data. |
---|
| 178 | // If not NULL this and argv will be freed. |
---|
| 179 | // If NULL argv will be left untouched. |
---|
| 180 | |
---|
| 181 | void * binargv; // A pointer with binary data arguments. |
---|
| 182 | // This can be used to pass any non-string data to |
---|
| 183 | // the plugin. Normally this is NULL or the pointer |
---|
| 184 | // to a struct with members of whatever is needed. |
---|
| 185 | |
---|
| 186 | const char * appname; // application name in common format: |
---|
| 187 | // Product/Version <VendorID/VendorName> (comments) |
---|
| 188 | // Version and comment are optional and should be avoided. |
---|
| 189 | // When no vendor ID is registered use <VendorName>. |
---|
| 190 | // The VendorName MUST NOT contain a slash and SHOULD |
---|
| 191 | // be as unique as possible. |
---|
| 192 | // Examples: roard <0/RoarAudio>, MyAPP <myapp.org>, |
---|
| 193 | // AnAPP <Musterman GbR> |
---|
| 194 | const char * abiversion; // The ABI version. For libraries this should be the SONAME. |
---|
| 195 | // For applications this should be the version of the release |
---|
| 196 | // which introduced the current ABI. |
---|
| 197 | // Examples: libroar2, 0.5.1 |
---|
[5317] | 198 | struct roar_notify_core * notifycore; |
---|
[5335] | 199 | struct roar_plugincontainer * container; |
---|
| 200 | int (*loader)(struct roar_dl_librarypara * lhandle, void * loader_userdata, enum roar_dl_loadercmd cmd, void * argp); |
---|
| 201 | void * loader_userdata; |
---|
[5275] | 202 | }; |
---|
| 203 | |
---|
| 204 | struct roar_dl_libraryname { |
---|
| 205 | int version; |
---|
| 206 | size_t len; |
---|
| 207 | const char * name; //Format: shortname |
---|
[5317] | 208 | const char * libname; //This is the same as appname in struct roar_dl_librarypara. |
---|
| 209 | //Format: Product <VendorID/VendorName> (comments) |
---|
| 210 | const char * libversion; //This is the pure version number of the library. |
---|
| 211 | const char * abiversion; //This is the same as abiversion in struct roar_dl_librarypara. |
---|
| 212 | //Format: Version |
---|
[5275] | 213 | const char * description; //Free form. |
---|
| 214 | const char * contact; //Format: first ["']nick["'] last (comment) <email>/OpenPGPkey/Phone/Room |
---|
| 215 | const char * authors; //Other authors as free form. |
---|
| 216 | const char * license; //Format: LicenseName-Version (options) |
---|
| 217 | //Examples: GPL-3.0, LGPL-2.1, LGPL-3.0 (or later). |
---|
[3297] | 218 | }; |
---|
| 219 | |
---|
[5317] | 220 | struct roar_dl_librarydep { |
---|
| 221 | int version; |
---|
| 222 | size_t len; |
---|
[5335] | 223 | uint32_t flags; |
---|
[5317] | 224 | const char * name; |
---|
| 225 | const char * libname; |
---|
| 226 | const char * abiversion; |
---|
| 227 | }; |
---|
| 228 | |
---|
[5347] | 229 | #define ROAR_DL_DEP(__flags,__name,__libname,__abiversion) \ |
---|
| 230 | {.version = ROAR_DL_LIBDEP_VERSION, \ |
---|
| 231 | .len = sizeof(struct roar_dl_librarydep), \ |
---|
| 232 | .flags = __flags, \ |
---|
| 233 | .name = __name, \ |
---|
| 234 | .libname = __libname, \ |
---|
| 235 | .abiversion = __abiversion} |
---|
| 236 | |
---|
[3297] | 237 | struct roar_dl_libraryinst { |
---|
[3299] | 238 | int version; |
---|
| 239 | size_t len; |
---|
[3301] | 240 | int (*unload)(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib); |
---|
[3299] | 241 | int (*func[ROAR_DL_FN_MAX])(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib); |
---|
[5275] | 242 | struct roar_dl_libraryname * libname; |
---|
[5312] | 243 | size_t global_data_len; |
---|
| 244 | void * global_data_init; |
---|
| 245 | void ** global_data_pointer; |
---|
[5317] | 246 | struct roar_dl_librarydep * libdep; |
---|
| 247 | size_t libdep_len; |
---|
| 248 | struct roar_dl_appsched * appsched; |
---|
[5353] | 249 | const char * host_appname; |
---|
| 250 | const char * host_abiversion; |
---|
[3297] | 251 | }; |
---|
| 252 | |
---|
[5313] | 253 | struct roar_dl_appsched { |
---|
[5317] | 254 | int (*init) (struct roar_dl_librarypara * para); |
---|
| 255 | int (*free) (struct roar_dl_librarypara * para); |
---|
| 256 | int (*update)(struct roar_dl_librarypara * para); |
---|
[5335] | 257 | int (*tick) (struct roar_dl_librarypara * para); |
---|
| 258 | int (*wait) (struct roar_dl_librarypara * para); |
---|
[5317] | 259 | }; |
---|
| 260 | |
---|
| 261 | enum roar_dl_appsched_trigger { |
---|
| 262 | ROAR_DL_APPSCHED_INIT = 1, |
---|
| 263 | #define ROAR_DL_APPSCHED_INIT ROAR_DL_APPSCHED_INIT |
---|
| 264 | ROAR_DL_APPSCHED_FREE, |
---|
| 265 | #define ROAR_DL_APPSCHED_FREE ROAR_DL_APPSCHED_FREE |
---|
[5335] | 266 | ROAR_DL_APPSCHED_UPDATE, |
---|
[5317] | 267 | #define ROAR_DL_APPSCHED_UPDATE ROAR_DL_APPSCHED_UPDATE |
---|
[5335] | 268 | ROAR_DL_APPSCHED_TICK, |
---|
| 269 | #define ROAR_DL_APPSCHED_TICK ROAR_DL_APPSCHED_TICK |
---|
| 270 | ROAR_DL_APPSCHED_WAIT |
---|
| 271 | #define ROAR_DL_APPSCHED_WAIT ROAR_DL_APPSCHED_WAIT |
---|
[5313] | 272 | }; |
---|
| 273 | |
---|
[5312] | 274 | // parameter functions: |
---|
[5275] | 275 | struct roar_dl_librarypara * roar_dl_para_new(const char * args, void * binargv, |
---|
| 276 | const char * appname, const char * abiversion); |
---|
| 277 | int roar_dl_para_ref (struct roar_dl_librarypara * para); |
---|
| 278 | int roar_dl_para_unref (struct roar_dl_librarypara * para); |
---|
| 279 | int roar_dl_para_check_version (struct roar_dl_librarypara * para, |
---|
| 280 | const char * appname, const char * abiversion); |
---|
| 281 | |
---|
[5312] | 282 | // 'core' dynamic loader functions. |
---|
[5275] | 283 | struct roar_dl_lhandle * roar_dl_open (const char * filename, int flags, |
---|
| 284 | int ra_init, struct roar_dl_librarypara * para); |
---|
[5321] | 285 | int roar_dl_ref (struct roar_dl_lhandle * lhandle); |
---|
| 286 | int roar_dl_unref (struct roar_dl_lhandle * lhandle); |
---|
| 287 | #define roar_dl_close(x) roar_dl_unref((x)) |
---|
[3301] | 288 | |
---|
[5275] | 289 | void * roar_dl_getsym (struct roar_dl_lhandle * lhandle, const char * sym, int type); |
---|
[3297] | 290 | |
---|
[5275] | 291 | int roar_dl_ra_init(struct roar_dl_lhandle * lhandle, |
---|
| 292 | const char * prefix, |
---|
| 293 | struct roar_dl_librarypara * para); |
---|
[3297] | 294 | |
---|
[5275] | 295 | const char * roar_dl_errstr (struct roar_dl_lhandle * lhandle); |
---|
[3297] | 296 | |
---|
[5312] | 297 | // getting meta data: |
---|
[5275] | 298 | struct roar_dl_librarypara * roar_dl_getpara(struct roar_dl_lhandle * lhandle); |
---|
| 299 | const struct roar_dl_libraryname * roar_dl_getlibname(struct roar_dl_lhandle * lhandle); |
---|
[3364] | 300 | |
---|
[5312] | 301 | // context switching: |
---|
| 302 | // _restore() is to switch from main to library context. _store() is to store library context |
---|
| 303 | // and switch back to main context. |
---|
| 304 | int roar_dl_context_restore(struct roar_dl_lhandle * lhandle); |
---|
| 305 | int roar_dl_context_store(struct roar_dl_lhandle * lhandle); |
---|
| 306 | |
---|
[5317] | 307 | // appsched: |
---|
| 308 | int roar_dl_appsched_trigger(struct roar_dl_lhandle * lhandle, enum roar_dl_appsched_trigger trigger); |
---|
| 309 | |
---|
[5511] | 310 | // FN Registration: |
---|
| 311 | |
---|
| 312 | // Actions objects can emit: |
---|
| 313 | enum roar_dl_fnreg_action { |
---|
| 314 | ROAR_DL_FNREG = 1, // The object is been registered |
---|
| 315 | ROAR_DL_FNUNREG = 2 // The object is been unregistered |
---|
| 316 | }; |
---|
| 317 | |
---|
| 318 | // Callback for registering/unregistering objects: |
---|
| 319 | struct roar_dl_fnreg { |
---|
| 320 | int fn; // Filter: The FN of the registering object or -1 for any. |
---|
| 321 | int subtype; // Filter: The subtype of the registering object or -1 for any. |
---|
| 322 | int version; // Filter: The version of the registering object or -1 for any. |
---|
| 323 | int (*callback)( // Callback to call on register/unregister. |
---|
| 324 | enum roar_dl_fnreg_action action, // The action happening |
---|
| 325 | int fn, // The FN of the object |
---|
| 326 | int subtype, // The subtype of the object |
---|
| 327 | const void * object, // Pointer to the object |
---|
| 328 | size_t objectlen, // Length of the object |
---|
| 329 | int version, // Version of the object |
---|
| 330 | int options, // Object Options. |
---|
| 331 | void * userdata, // User data for the callback. |
---|
| 332 | struct roar_dl_lhandle * lhandle // The registering handle. |
---|
| 333 | // This is valid until the object is unregistered. |
---|
[5606] | 334 | // Only roar_dl_context_restore(), roar_dl_context_store() |
---|
| 335 | // and roar_dl_getpara() may be used on this object. |
---|
| 336 | // Result of all other functions is undefined. |
---|
[5511] | 337 | ); |
---|
| 338 | void * userdata; // The user data pointer passed to the callback. |
---|
| 339 | }; |
---|
| 340 | |
---|
| 341 | // Parameters for FNREG registration: |
---|
| 342 | #define ROAR_DL_FNREG_SUBTYPE 0 |
---|
| 343 | #define ROAR_DL_FNREG_VERSION 0 |
---|
| 344 | #define ROAR_DL_FNREG_SIZE sizeof(struct roar_dl_fnreg) |
---|
| 345 | |
---|
| 346 | |
---|
[5576] | 347 | // Common protocol interface: |
---|
| 348 | struct roar_dl_proto { |
---|
| 349 | const int proto; |
---|
| 350 | const char * description; |
---|
| 351 | const int flags; |
---|
[5606] | 352 | int (*set_proto)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 353 | int (*unset_proto)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 354 | int (*handle)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 355 | int (*flush)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 356 | int (*flushed)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 357 | int (*status)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
[5576] | 358 | }; |
---|
| 359 | |
---|
| 360 | #define ROAR_DL_PROTO_FLAGS_NONE 0 |
---|
| 361 | |
---|
| 362 | #define ROAR_DL_PROTO_STATUS_RX_READY 0x0001 |
---|
| 363 | #define ROAR_DL_PROTO_STATUS_TX_READY 0x0002 |
---|
| 364 | #define ROAR_DL_PROTO_STATUS_WAIT_NOTIFY 0x0004 |
---|
| 365 | |
---|
| 366 | // Parameters for FNREG registration: |
---|
| 367 | #define ROAR_DL_PROTO_SUBTYPE 1 /* 0 = roard */ |
---|
| 368 | #define ROAR_DL_PROTO_VERSION 0 |
---|
| 369 | #define ROAR_DL_PROTO_SIZE sizeof(struct roar_dl_proto) |
---|
| 370 | |
---|
[5511] | 371 | // Reg FN: |
---|
| 372 | |
---|
| 373 | // Options: |
---|
| 374 | #define ROAR_DL_FNREG_OPT_NONE 0 /* no options */ |
---|
| 375 | |
---|
| 376 | // Register an FN. |
---|
| 377 | int roar_dl_register_fn(struct roar_dl_lhandle * lhandle, int fn, int subtype, const void * object, size_t objectlen, int version, int options); |
---|
| 378 | |
---|
| 379 | // Unregister FN for the given plugin. |
---|
| 380 | // This should not be called directly and is called internally when needed. |
---|
| 381 | int roar_dl_unregister_fn(struct roar_dl_lhandle * lhandle); |
---|
| 382 | |
---|
[3297] | 383 | #endif |
---|
| 384 | |
---|
| 385 | //ll |
---|