Changeset 5275:811818eb5b81 in roaraudio
- Timestamp:
- 11/19/11 22:54:26 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r5272 r5275 5 5 * Removed old functions from API (Closes: #186, See: #130) 6 6 * Removed old roarclients (See: #130) 7 * Improved plugin loader a lot (Closes: #190) 7 8 8 9 v. 0.4 - Fri Nov 11 2011 20:12 CET -
doc/man1/roard.1
r5159 r5275 152 152 .SH "PLUGINS" 153 153 .TP 154 \fB--plugin-load \fR154 \fB--plugin-load FILENAME\fR 155 155 Load the given plugin. 156 157 .TP 158 \fB--plugin-args ARGS\fR 159 Arguments for the plugin. 160 (must be given before the --plugin-load). 156 161 157 162 .SH "SECURITY" -
include/libroar/roardl.h
r4708 r5275 57 57 #define ROAR_DL_FN_PROTO 11 58 58 //#define ROAR_DL_FN_ 9 59 #define ROAR_DL_FN_MAX 1659 #define ROAR_DL_FN_MAX 24 60 60 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 63 64 64 65 #define ROAR_DL_PLUGIN(lib) struct roar_dl_libraryinst * \ … … 74 75 static int _inited = 0; \ 75 76 static struct roar_dl_libraryinst lib; \ 77 static struct roar_dl_libraryname libname; \ 76 78 (void)para; \ 77 79 if ( _inited ) \ … … 80 82 lib.version = ROAR_DL_LIBINST_VERSION; \ 81 83 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; \ 82 89 do 83 90 … … 87 94 } 88 95 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 89 98 #define ROAR_DL_PLUGIN_REG(fn, funcptr) (lib.func[(fn)] = (funcptr)) 90 99 #define ROAR_DL_PLUGIN_REG_UNLOAD(func) (lib.unload = (func)) 91 100 92 101 struct 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 132 struct 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). 95 142 }; 96 143 … … 100 147 int (*unload)(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib); 101 148 int (*func[ROAR_DL_FN_MAX])(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib); 149 struct roar_dl_libraryname * libname; 102 150 }; 103 151 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 }; 152 struct roar_dl_librarypara * roar_dl_para_new(const char * args, void * binargv, 153 const char * appname, const char * abiversion); 154 int roar_dl_para_ref (struct roar_dl_librarypara * para); 155 int roar_dl_para_unref (struct roar_dl_librarypara * para); 156 int roar_dl_para_check_version (struct roar_dl_librarypara * para, 157 const char * appname, const char * abiversion); 113 158 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); 159 struct roar_dl_lhandle * roar_dl_open (const char * filename, int flags, 160 int ra_init, struct roar_dl_librarypara * para); 161 int roar_dl_close (struct roar_dl_lhandle * lhandle); 116 162 117 void * roar_dl_getsym (struct roar_dl_lhandle * lhandle, const char * sym, int type);163 void * roar_dl_getsym (struct roar_dl_lhandle * lhandle, const char * sym, int type); 118 164 119 int roar_dl_ra_init(struct roar_dl_lhandle * lhandle, const char * prefix); 165 int roar_dl_ra_init(struct roar_dl_lhandle * lhandle, 166 const char * prefix, 167 struct roar_dl_librarypara * para); 120 168 121 char * roar_dl_errstr(struct roar_dl_lhandle * lhandle); 169 const char * roar_dl_errstr (struct roar_dl_lhandle * lhandle); 170 171 struct roar_dl_librarypara * roar_dl_getpara(struct roar_dl_lhandle * lhandle); 172 const struct roar_dl_libraryname * roar_dl_getlibname(struct roar_dl_lhandle * lhandle); 122 173 123 174 #endif -
libroar/roardl.c
r5270 r5275 40 40 #endif 41 41 42 struct roar_dl_lhandle { 43 struct roar_dl_librarypara * para; 44 struct roar_dl_libraryinst * lib; 45 #if defined(ROAR_HAVE_LIBDL) 46 void * handle; 47 #endif 48 }; 49 50 51 struct roar_dl_librarypara * roar_dl_para_new(const char * args, void * binargv, 52 const char * appname, const char * abiversion) { 53 struct roar_dl_librarypara * ret = roar_mm_malloc(sizeof(struct roar_dl_librarypara)); 54 ssize_t argc; 55 int err; 56 57 if ( ret == NULL ) 58 return NULL; 59 60 memset(ret, 0, sizeof(struct roar_dl_librarypara)); 61 62 ret->version = ROAR_DL_LIBPARA_VERSION; 63 ret->len = sizeof(struct roar_dl_librarypara); 64 ret->refc = 1; 65 ret->argc = 0; 66 ret->argv = NULL; 67 ret->args_store = NULL; 68 ret->binargv = binargv; 69 ret->appname = appname; 70 ret->abiversion = abiversion; 71 72 if ( args != NULL ) { 73 ret->args_store = roar_mm_strdup(args); 74 if ( ret->args_store == NULL ) { 75 err = roar_error; 76 roar_mm_free(ret); 77 roar_error = err; 78 return NULL; 79 } 80 81 argc = roar_keyval_split(&(ret->argv), ret->args_store, NULL, NULL, 0); 82 if ( argc == -1 ) { 83 err = roar_error; 84 roar_mm_free(ret->args_store); 85 roar_mm_free(ret); 86 roar_error = err; 87 return NULL; 88 } 89 90 ret->argc = argc; 91 } 92 93 return ret; 94 } 95 96 int roar_dl_para_ref (struct roar_dl_librarypara * para) { 97 if ( para == NULL ) { 98 roar_err_set(ROAR_ERROR_FAULT); 99 return -1; 100 } 101 102 para->refc++; 103 104 return 0; 105 } 106 107 int roar_dl_para_unref (struct roar_dl_librarypara * para) { 108 if ( para == NULL ) { 109 roar_err_set(ROAR_ERROR_FAULT); 110 return -1; 111 } 112 113 para->refc--; 114 115 if ( para->refc == 0 ) { 116 if ( para->args_store != NULL ) { 117 roar_mm_free(para->args_store); 118 roar_mm_free(para->argv); 119 } 120 roar_mm_free(para); 121 } 122 123 return 0; 124 } 125 int roar_dl_para_check_version (struct roar_dl_librarypara * para, 126 const char * appname, const char * abiversion) { 127 if ( para == NULL ) { 128 roar_err_set(ROAR_ERROR_FAULT); 129 return -1; 130 } 131 132 // check if both appnames are NULL or non-NULL. 133 if ( (para->appname == NULL && appname != NULL) || (para->appname != NULL && appname == NULL) ) { 134 roar_err_set(ROAR_ERROR_BADVERSION); 135 return -1; 136 } 137 138 // check if the appname matches if given. 139 if ( para->appname != NULL && !!strcmp(para->appname, appname) ) { 140 roar_err_set(ROAR_ERROR_BADVERSION); 141 return -1; 142 } 143 144 // check if both ABI versions are NULL or non-NULL. 145 if ( (para->abiversion == NULL && abiversion != NULL) || (para->abiversion != NULL && abiversion == NULL) ) { 146 roar_err_set(ROAR_ERROR_BADVERSION); 147 return -1; 148 } 149 150 // check if the ABI versions matches if given. 151 if ( para->abiversion != NULL && !!strcmp(para->abiversion, abiversion) ) { 152 roar_err_set(ROAR_ERROR_BADVERSION); 153 return -1; 154 } 155 156 return 0; 157 } 158 159 42 160 #if defined(ROAR_HAVE_LIBDL) 43 161 static void * _roardl2ldl (struct roar_dl_lhandle * lhandle) { … … 52 170 #endif 53 171 54 struct roar_dl_lhandle * roar_dl_open(const char * filename, int flags, int ra_init) { 172 struct roar_dl_lhandle * roar_dl_open(const char * filename, int flags, 173 int ra_init, struct roar_dl_librarypara * para) { 55 174 struct roar_dl_lhandle * ret = NULL; 175 int err; 56 176 57 177 // early errors just return. 58 178 59 if ( flags != ROAR_DL_FLAG_DEFAUTS ) 60 return NULL; 179 if ( flags != ROAR_DL_FLAG_DEFAUTS ) { 180 roar_err_set(ROAR_ERROR_NOTSUP); 181 return NULL; 182 } 61 183 62 184 if ( (ret = roar_mm_malloc(sizeof(struct roar_dl_lhandle))) == NULL ) … … 80 202 #else 81 203 roar_mm_free(ret); 204 roar_err_set(ROAR_ERROR_NOSYS); 82 205 return NULL; 83 206 #endif 84 207 85 if ( ret == NULL ) 86 return NULL; 208 ret->para = para; 87 209 88 210 if ( ra_init ) { 89 roar_dl_ra_init(ret, NULL); 90 } 211 if ( roar_dl_ra_init(ret, NULL, para) == -1 ) { 212 err = roar_error; 213 ROAR_WARN("roar_dl_open(filename='%s', flags=%i, ra_init=%i, para=%p): Can not init RA lib: %s", filename, flags, ra_init, para, roar_error2str(err)); 214 #if defined(ROAR_HAVE_LIBDL) 215 dlclose(ret->handle); 216 #endif 217 roar_mm_free(ret); 218 roar_error = err; 219 return NULL; 220 } 221 } 222 223 if ( para != NULL ) 224 roar_dl_para_ref(para); 91 225 92 226 return ret; … … 96 230 int ret = -1; 97 231 98 if ( lhandle == ROAR_DL_HANDLE_DEFAULT )99 r eturn -1;100 if ( lhandle == ROAR_DL_HANDLE_NEXT )101 return -1;232 if ( lhandle == ROAR_DL_HANDLE_DEFAULT || lhandle == ROAR_DL_HANDLE_NEXT ) { 233 roar_err_set(ROAR_ERROR_BADFH); 234 return -1; 235 } 102 236 103 237 if ( lhandle->lib != NULL && lhandle->lib->unload != NULL ) … … 110 244 #endif 111 245 246 if ( lhandle->para != NULL ) 247 roar_dl_para_unref(lhandle->para); 248 112 249 roar_mm_free(lhandle); 113 250 … … 129 266 } 130 267 131 int roar_dl_ra_init(struct roar_dl_lhandle * lhandle, const char * prefix) { 268 int roar_dl_ra_init(struct roar_dl_lhandle * lhandle, 269 const char * prefix, 270 struct roar_dl_librarypara * para) { 132 271 #define _SUFFIX "_roaraudio_library_init" 133 272 char name[80] = _SUFFIX; 134 273 struct roar_dl_libraryinst * (*func)(struct roar_dl_librarypara * para); 135 274 struct roar_dl_libraryinst * lib; 136 struct roar_dl_librarypara * para = NULL;137 275 int i; 138 276 … … 141 279 return -1; 142 280 } else { 143 para = lhandle->para; 281 if ( para == NULL ) 282 para = lhandle->para; 144 283 } 145 284 … … 181 320 } 182 321 183 c har *roar_dl_errstr(struct roar_dl_lhandle * lhandle) {322 const char * roar_dl_errstr(struct roar_dl_lhandle * lhandle) { 184 323 #if defined(ROAR_HAVE_LIBDL) 185 324 (void)lhandle; … … 190 329 } 191 330 331 struct roar_dl_librarypara * roar_dl_getpara(struct roar_dl_lhandle * lhandle) { 332 if ( (void*)lhandle < (void*)128 ) { 333 roar_err_set(ROAR_ERROR_NOTSUP); 334 return NULL; 335 } 336 337 if ( lhandle->para == NULL ) { 338 roar_err_set(ROAR_ERROR_NOENT); 339 return NULL; 340 } 341 342 if ( roar_dl_para_ref(lhandle->para) == -1 ) 343 return NULL; 344 345 return lhandle->para; 346 } 347 348 const struct roar_dl_libraryname * roar_dl_getlibname(struct roar_dl_lhandle * lhandle) { 349 if ( (void*)lhandle < (void*)128 ) { 350 roar_err_set(ROAR_ERROR_NOTSUP); 351 return NULL; 352 } 353 354 if ( lhandle->lib == NULL ) { 355 roar_err_set(ROAR_ERROR_BADLIB); 356 return NULL; 357 } 358 359 if ( lhandle->lib->libname == NULL ) { 360 roar_err_set(ROAR_ERROR_NOENT); 361 return NULL; 362 } 363 364 if ( lhandle->lib->libname->version != ROAR_DL_LIBNAME_VERSION ) { 365 roar_err_set(ROAR_ERROR_BADVERSION); 366 return NULL; 367 } 368 369 if ( lhandle->lib->libname->len != sizeof(struct roar_dl_libraryname) ) { 370 roar_err_set(ROAR_ERROR_HOLE); 371 return NULL; 372 } 373 374 return lhandle->lib->libname; 375 } 376 192 377 //ll -
libroar/vio_dstr.c
r5270 r5275 289 289 290 290 static void _roar_vio_dstr_init_otherlibs (void) { 291 roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroardsp" );292 roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroareio" );293 roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroarlight" );294 roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroarmidi" );291 roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroardsp", NULL); 292 roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroareio", NULL); 293 roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroarlight", NULL); 294 roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroarmidi", NULL); 295 295 } 296 296 -
plugins/roard/listenpty.c
r5267 r5275 59 59 60 60 ROAR_DL_PLUGIN_START(roard_discard_protocol) { 61 ROARD_DL_CHECK_VERSIONS(); 62 63 libname.license = "GPL-3.0"; 64 61 65 ROARD_DL_REGFN_SCHED(); 62 66 } ROAR_DL_PLUGIN_END -
plugins/universal/protocol-daytime.c
r5193 r5275 59 59 60 60 static struct roard_proto proto[1] = { 61 {ROAR_PROTO_DAYTIME, new_client, NULL, NULL, flushed_client}61 {ROAR_PROTO_DAYTIME, ROAR_SUBSYS_NONE, "The Internet daytime protocol", new_client, NULL, NULL, flushed_client} 62 62 }; 63 63 … … 65 65 66 66 ROAR_DL_PLUGIN_START(roard_daytime_protocol) { 67 ROARD_DL_CHECK_VERSIONS(); 68 69 libname.license = "GPL-3.0"; 70 67 71 ROARD_DL_REGFN_PROTO(); 68 72 } ROAR_DL_PLUGIN_END -
plugins/universal/protocol-discard.c
r5264 r5275 42 42 43 43 static struct roard_proto proto[1] = { 44 {ROAR_PROTO_DISCARD, NULL, check_client, NULL, NULL}44 {ROAR_PROTO_DISCARD, ROAR_SUBSYS_NONE, "Discard all data send to the server", NULL, check_client, NULL, NULL} 45 45 }; 46 46 … … 48 48 49 49 ROAR_DL_PLUGIN_START(roard_discard_protocol) { 50 ROARD_DL_CHECK_VERSIONS(); 51 52 libname.license = "GPL-3.0"; 53 50 54 ROARD_DL_REGFN_PROTO(); 51 55 } ROAR_DL_PLUGIN_END -
plugins/universal/protocol-echo.c
r5193 r5275 57 57 58 58 static struct roard_proto proto[1] = { 59 {ROAR_PROTO_ECHO, NULL, check_client, NULL, NULL}59 {ROAR_PROTO_ECHO, ROAR_SUBSYS_NONE, "Send all data send to the server back to the client", NULL, check_client, NULL, NULL} 60 60 }; 61 61 … … 63 63 64 64 ROAR_DL_PLUGIN_START(roard_echo_protocol) { 65 ROARD_DL_CHECK_VERSIONS(); 66 67 libname.license = "GPL-3.0"; 68 65 69 ROARD_DL_REGFN_PROTO(); 66 70 } ROAR_DL_PLUGIN_END -
roard/clients.c
r5242 r5275 38 38 #ifndef ROAR_WITHOUT_DCOMP_EMUL_ESD 39 39 #ifdef ROAR_HAVE_H_ESD 40 {ROAR_PROTO_ESOUND, NULL, emul_esd_check_client, NULL, NULL},40 {ROAR_PROTO_ESOUND, ROAR_SUBSYS_WAVEFORM, "EsounD emulation", NULL, emul_esd_check_client, NULL, NULL}, 41 41 #endif 42 42 #endif 43 43 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY 44 {ROAR_PROTO_RPLAY, NULL, emul_rplay_check_client, NULL, NULL},44 {ROAR_PROTO_RPLAY, ROAR_SUBSYS_WAVEFORM, "RPlay emulation", NULL, emul_rplay_check_client, NULL, NULL}, 45 45 #endif 46 46 #ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER 47 {ROAR_PROTO_GOPHER, NULL, emul_gopher_check_client, NULL, emul_gopher_flushed_client},48 #endif 49 {-1, NULL}47 {ROAR_PROTO_GOPHER, ROAR_SUBSYS_WAVEFORM, "The Internet Gopher Protocol", NULL, emul_gopher_check_client, NULL, emul_gopher_flushed_client}, 48 #endif 49 {-1, 0, NULL, NULL, NULL, NULL, NULL} 50 50 }; 51 51 … … 58 58 for (i = 0; i < ROAR_CLIENTS_MAX; i++) 59 59 g_clients[i] = NULL; 60 61 for (i = 0; g_proto[i].proto != -1; i++); 62 63 for (; i < MAX_PROTOS; i++) 64 g_proto[i].proto = -1; 60 65 61 66 return 0; … … 826 831 memcpy(&(g_proto[i]), proto, sizeof(*g_proto)); 827 832 828 i++; 829 830 memset(&(g_proto[i]), 0, sizeof(*g_proto)); 831 g_proto[i].proto = -1; 832 833 return 0; 834 } 835 833 return 0; 834 } 835 836 int clients_unregister_proto(int proto) { 837 const size_t len = sizeof(g_proto)/sizeof(*g_proto); 838 size_t i; 839 840 if ( proto < 0 ) { 841 roar_err_set(ROAR_ERROR_RANGE); 842 return -1; 843 } 844 845 for (i = 0; i < len; i++) { 846 if ( g_proto[i].proto == proto ) { 847 memset(&(g_proto[i]), 0, sizeof(*g_proto)); 848 g_proto[i].proto = -1; 849 return 0; 850 } 851 } 852 853 roar_err_set(ROAR_ERROR_NOENT); 854 return -1; 855 } 856 857 void print_protolist (enum output_format format) { 858 const size_t len = sizeof(g_proto)/sizeof(*g_proto); 859 struct roard_proto * p; 860 char subsys[7] = " "; 861 size_t i; 862 863 switch (format) { 864 case FORMAT_NATIVE: 865 printf(" Protocol Flag Subsys - Description\n"); 866 printf("------------------------------------------------------\n"); 867 printf(" roar WM LRX - RoarAudio native protocol\n"); 868 #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE 869 printf(" simple WM LRX - PulseAudio simple protocol\n"); 870 #endif 871 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 872 printf(" rsound W - RSound emulation\n"); 873 #endif 874 break; 875 case FORMAT_WIKI: 876 printf("||=Protocol =||=Flag =||=Subsys =||=Description =||\n"); 877 printf("||roar || ||WM LRX ||RoarAudio native protocol ||\n"); 878 #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE 879 printf("||simple || ||WM LRX ||PulseAudio simple protocol ||\n"); 880 #endif 881 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 882 printf("||rsound || ||W ||RSound emulation ||\n"); 883 #endif 884 break; 885 case FORMAT_CSV: 886 printf("Protocol,Flag,Subsys,Description\n"); 887 printf("roar,,WM LRX,RoarAudio native protocol\n"); 888 #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE 889 printf("simple,,WM LRX,PulseAudio simple protocol\n"); 890 #endif 891 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 892 printf("rsound,,W,RSound emulation\n"); 893 #endif 894 break; 895 default: 896 roar_err_set(ROAR_ERROR_NOTSUP); 897 return; 898 } 899 900 for (i = 0; i < len; i++) { 901 p = &(g_proto[i]); 902 if ( p->proto == -1 ) 903 continue; 904 905 strncpy(subsys, " ", 6); 906 907 if ( p->subsystems & ROAR_SUBSYS_WAVEFORM ) 908 subsys[0] = 'W'; 909 if ( p->subsystems & ROAR_SUBSYS_MIDI ) 910 subsys[1] = 'M'; 911 if ( p->subsystems & ROAR_SUBSYS_CB ) 912 subsys[2] = 'C'; 913 if ( p->subsystems & ROAR_SUBSYS_LIGHT ) 914 subsys[3] = 'L'; 915 if ( p->subsystems & ROAR_SUBSYS_RAW ) 916 subsys[4] = 'R'; 917 if ( p->subsystems & ROAR_SUBSYS_COMPLEX ) 918 subsys[5] = 'X'; 919 920 switch (format) { 921 case FORMAT_NATIVE: 922 printf(" %-13s %s - %s\n", roar_proto2str(p->proto), subsys, p->description); 923 break; 924 case FORMAT_WIKI: 925 printf("||%s || ||%s ||%s ||\n", roar_proto2str(p->proto), subsys, p->description); 926 break; 927 case FORMAT_CSV: 928 printf("%s,,%s,%s\n", roar_proto2str(p->proto), subsys, p->description); 929 break; 930 } 931 } 932 } 836 933 837 934 int client_stream_exec (int client, int stream) { -
roard/include/client.h
r5192 r5275 76 76 struct roard_proto { 77 77 int proto; 78 int subsystems; 79 const char * description; 78 80 int (*new_client)(int client, struct roar_vio_calls * vio, struct roard_listen * lsock); 79 81 int (*check_client)(int client, struct roar_vio_calls * vio); … … 114 116 115 117 // proto support 116 int clients_register_proto(struct roard_proto * proto); 118 int clients_register_proto (struct roard_proto * proto); 119 int clients_unregister_proto(int proto); 120 void print_protolist (enum output_format format); 117 121 118 122 // stream functions -
roard/include/plugins.h
r5266 r5275 29 29 #include <roaraudio.h> 30 30 31 #define ROARD_DL_APPNAME "roard <0/RoarAudio>" 32 #define ROARD_DL_ABIVERSION NULL 33 31 34 struct roard_plugins_sched { 32 35 int (*init)(void); … … 40 43 int plugins_update (void); 41 44 42 int plugins_load (const char * filename );45 int plugins_load (const char * filename, const char * args); 43 46 44 47 int plugins_reg_sched(struct roard_plugins_sched * sched); … … 62 65 ROARD_DL_REG__UNI_POST 63 66 67 // Register Scheduler callbacks: 64 68 #define ROARD_DL_REGFN_SCHED() ROAR_DL_PLUGIN_REG(ROAR_DL_FN_ROARDSCHED, __reg_sched) 65 69 … … 70 74 ROARD_DL_REG__UNI_POST 71 75 76 // Register Protocol callbacks: 72 77 #define ROARD_DL_REGFN_PROTO() ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto) 78 79 // Check version: 80 #define ROARD_DL_CHECK_VERSIONS() ROAR_DL_PLUGIN_CHECK_VERSIONS(ROARD_DL_APPNAME, ROARD_DL_ABIVERSION) 73 81 74 82 #endif -
roard/plugins.c
r4708 r5275 31 31 struct roar_dl_lhandle * lhandle; 32 32 struct roard_plugins_sched * sched; 33 int protocols[MAX_PROTOS]; 33 34 } g_plugins[MAX_PLUGINS]; 34 35 static struct _roard_plugin * _pp = NULL; … … 53 54 } 54 55 56 static void inline plugins_delete(struct _roard_plugin * plugin) { 57 int i; 58 59 if ( plugin->sched != NULL ) 60 if ( plugin->sched->free != NULL ) 61 plugin->sched->free(); 62 63 for (i = 0; i < MAX_PROTOS; i++) { 64 if ( plugin->protocols[i] != -1 ) { 65 clients_unregister_proto(plugin->protocols[i]); 66 } 67 } 68 69 roar_dl_close(plugin->lhandle); 70 memset(plugin, 0, sizeof(struct _roard_plugin)); 71 plugin->lhandle = NULL; 72 } 73 55 74 int plugins_init (void) { 56 75 int i; … … 62 81 _pp->sched = NULL; 63 82 64 roar_dl_ra_init(g_plugins[i].lhandle, NULL); 83 if ( roar_dl_ra_init(g_plugins[i].lhandle, NULL, NULL) == -1 ) { 84 ROAR_WARN("plugins_init(void): Can not RA init lib at %p: %s", g_plugins[i].lhandle, roar_error2str(roar_error)); 85 plugins_delete(&(g_plugins[i])); 86 continue; 87 } 65 88 66 89 if ( g_plugins[i].sched != NULL ) … … 80 103 for (i = 0; i < MAX_PLUGINS; i++) { 81 104 if ( g_plugins[i].lhandle != NULL ) { 82 if ( g_plugins[i].sched != NULL ) 83 if ( g_plugins[i].sched->free != NULL ) 84 g_plugins[i].sched->free(); 85 86 roar_dl_close(g_plugins[i].lhandle); 105 plugins_delete(&(g_plugins[i])); 87 106 } 88 107 } … … 105 124 } 106 125 107 int plugins_load (const char * filename ) {126 int plugins_load (const char * filename, const char * args) { 108 127 struct _roard_plugin * next = _find_free(); 128 struct roar_dl_librarypara * para; 129 int i; 109 130 110 131 if ( next == NULL ) 111 132 return -1; 112 133 113 next->lhandle = roar_dl_open(filename, -1, 0 /* we delay this until plugins_init() */); 134 for (i = 0; i < MAX_PROTOS; i++) 135 next->protocols[i] = -1; 136 137 if ( (para = roar_dl_para_new(args, NULL, ROARD_DL_APPNAME, ROARD_DL_ABIVERSION)) == NULL ) { 138 ROAR_WARN("Can not load plugin (allocate para set): %s: %s", filename, roar_error2str(roar_error)); 139 return -1; 140 } 141 142 next->lhandle = roar_dl_open(filename, ROAR_DL_FLAG_DEFAUTS, 0 /* we delay this until plugins_init() */, para); 143 roar_dl_para_unref(para); 144 114 145 if ( next->lhandle == NULL ) { 115 146 ROAR_ERR("plugins_load(filename='%s'): can not load plugin: %s", filename, roar_dl_errstr(NULL)); … … 130 161 131 162 int plugins_reg_proto(struct roard_proto * proto) { 163 int i; 164 132 165 if ( _pp == NULL ) 133 166 return -1; 167 168 for (i = 0; i < MAX_PROTOS; i++) { 169 if ( _pp->protocols[i] == -1 ) { 170 _pp->protocols[i] = proto->proto; 171 break; 172 } 173 } 174 175 if ( i == MAX_PROTOS ) { 176 roar_err_set(ROAR_ERROR_NOMEM); 177 return -1; 178 } 134 179 135 180 return clients_register_proto(proto); -
roard/roard.c
r5257 r5275 260 260 printf( 261 261 " --plugin-load FILE - Load plugin FILE\n" 262 " --plugin-args ARGS - Arguments for the plugin\n" 263 " (must be given before the --plugin-load)\n" 262 264 ); 263 265 … … 417 419 // printf("\n Options:\n\n"); 418 420 printf("\n"); 419 }420 421 static void list_proto (void) {422 printf(" Protocol Flag Subsys - Description\n");423 printf("------------------------------------------------------\n");424 printf(" roar WM LRX - RoarAudio native protocol\n");425 #if !defined(ROAR_WITHOUT_DCOMP_EMUL_ESD) && defined(ROAR_HAVE_H_ESD)426 printf(" esd W - EsounD emulation\n");427 #endif428 #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE429 printf(" simple WM LRX - PulseAudio simple protocol\n");430 #endif431 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND432 printf(" rsound W - RSound emulation\n");433 #endif434 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY435 printf(" rplay W - RPlay emulation\n");436 #endif437 #ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER438 printf(" gopher - The Internet Gopher Protocol\n");439 #endif440 421 } 441 422 … … 1380 1361 int sysclocksync = 0; 1381 1362 // char * server = ROAR_DEFAULT_SOCK_GLOBAL; 1363 const char * plugin_args = NULL; 1382 1364 #ifdef ROAR_SUPPORT_LISTEN 1383 1365 int port = ROAR_DEFAULT_PORT; … … 1701 1683 } else if ( strcmp(k, "--plugin-load") == 0 ) { 1702 1684 _CKHAVEARGS(1); 1703 if ( plugins_load(argv[++i] ) == -1 ) {1685 if ( plugins_load(argv[++i], plugin_args) == -1 ) { 1704 1686 ROAR_ERR("Can not load plugin"); 1705 1687 } 1688 plugin_args = NULL; 1689 } else if ( strcmp(k, "--plugin-args") == 0 ) { 1690 _CKHAVEARGS(1); 1691 plugin_args = argv[++i]; 1706 1692 1707 1693 } else if ( strcmp(k, "--guest-acclev") == 0 ) { … … 2140 2126 2141 2127 } else if ( strcmp(k, "--list-proto") == 0 ) { 2142 list_proto();2128 print_protolist(print_format); 2143 2129 return 0; 2144 2130
Note: See TracChangeset
for help on using the changeset viewer.