int erts_sys_ddll_load_driver_init(void *handle, void **function) { void *fn; int res; if ((res = erts_sys_ddll_sym(handle, "driver_init", &fn)) != ERL_DE_NO_ERROR) { return res; } *function = fn; return res; }
int erts_sys_ddll_load_driver_init(void *handle, void **function) { MODULE_ID mid = (MODULE_ID) handle; char *modname; char *cp; static char statbuf[PREALLOC_BUFFER_SIZE]; char *fname = statbuf; int len; int res; void *func; int need; if((modname = moduleNameGet(mid)) == NULL) { return ERL_DE_DYNAMIC_ERROR_OFFSET - ((int) ModuleNotFound); } if((cp = strrchr(modname, '.')) == NULL) { len = strlen(modname); } else { len = cp - modname; } need = len + strlen(DRIVER_INIT_SUFFIX) + 1; if (need > PREALLOC_BUFFER_SIZE) { fname = erts_alloc(ERTS_ALC_T_DDLL_TMP_BUF, need); /* erts_alloc exits on failure */ } sys_strncpy(fname, modname, len); fname[len] = '\0'; sys_strcat(fname, DRIVER_INIT_SUFFIX); res = erts_sys_ddll_sym(handle, fname, &func); if (fname != statbuf) { erts_free(ERTS_ALC_T_DDLL_TMP_BUF, fname); } if ( res != ERL_DE_NO_ERROR) { return res; } *function = func; return ERL_DE_NO_ERROR; }