MCPcopy Create free account
hub / github.com/csound/csound / csoundLoadExternal

Function csoundLoadExternal

Top/csmodule.c:383–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381/* returns zero on success */
382
383static CS_NOINLINE int csoundLoadExternal(CSOUND *csound,
384 const char *libraryPath)
385{
386 csoundModule_t m;
387 volatile jmp_buf tmpExitJmp;
388 csoundModule_t *mp;
389 char *fname;
390 void *h, *p;
391 int (*infoFunc)(void);
392 int err;
393
394 /* check for a valid name */
395 if (UNLIKELY(libraryPath == NULL || libraryPath[0] == '\0'))
396 return CSOUND_ERROR;
397 /* remove leading directory components from name */
398 fname = (char*) libraryPath + (int) strlen(libraryPath);
399 for ( ; fname[0] != DIRSEP && fname != (char*) libraryPath; fname--)
400 ;
401 if (fname[0] == DIRSEP)
402 fname++;
403 if (UNLIKELY(fname[0] == '\0'))
404 return CSOUND_ERROR;
405 /* load library */
406/* #if defined(LINUX) */
407 //printf("About to open library '%s'\n", libraryPath);
408/* #endif */
409 err = csoundOpenLibrary(&h, libraryPath);
410 if (UNLIKELY(err)) {
411 char ERRSTR[256];
412 #if !(defined(NACL)) && (defined(LINUX) || defined(__HAIKU__))
413 snprintf(ERRSTR, 256, Str("could not open library '%s' (%s)"),
414 libraryPath, dlerror());
415 #else
416 snprintf(ERRSTR, 256, Str("could not open library '%s' (%d)"),
417 libraryPath, err);
418 #endif
419 if (csound->delayederrormessages == NULL) {
420 csound->delayederrormessages = csound->Malloc(csound, strlen(ERRSTR)+1);
421 strcpy(csound->delayederrormessages, ERRSTR);
422 }
423 else {
424 char *new =
425 csound->ReAlloc(csound, csound->delayederrormessages,
426 strlen(csound->delayederrormessages)+strlen(ERRSTR)+11);
427 if (UNLIKELY(new==NULL)) {
428 csound->Free(csound, csound->delayederrormessages);
429 return CSOUND_ERROR;
430 }
431 csound->delayederrormessages = new;
432 strcat(csound->delayederrormessages, "\nWARNING: ");
433 strcat(csound->delayederrormessages, ERRSTR);
434 }
435 return CSOUND_ERROR;
436 }
437 /* check if the library is compatible with this version of Csound */
438 infoFunc = (int (*)(void)) csoundGetLibrarySymbol(h, InfoFunc_Name);
439 if (infoFunc != NULL) {
440 if (UNLIKELY(check_plugin_compatibility(csound, fname, infoFunc()) != 0)) {

Callers 3

csoundLoadModulesFunction · 0.85
csoundLoadExternalsFunction · 0.85
csoundLoadAndInitModuleFunction · 0.85

Calls 5

csoundOpenLibraryFunction · 0.85
csoundGetLibrarySymbolFunction · 0.85
csoundCloseLibraryFunction · 0.85
print_module_errorFunction · 0.85

Tested by

no test coverage detected