diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/eurephia_getsym.c | 26 | ||||
-rw-r--r-- | common/eurephia_getsym.h | 1 |
2 files changed, 22 insertions, 5 deletions
diff --git a/common/eurephia_getsym.c b/common/eurephia_getsym.c index 1b9a63e..9460c3a 100644 --- a/common/eurephia_getsym.c +++ b/common/eurephia_getsym.c @@ -43,20 +43,36 @@ * * @return Returns a pointer to the function if it was found, otherwise NULL is returned. */ -void *eGetSym(eurephiaCTX *ctx, void *dlh, const char *symnam) +void *eGetSym_optional(eurephiaCTX *ctx, void *dlh, const char *symnam) { - void *func = NULL; - if( ctx->fatal_error > 0 ) { return NULL; } DEBUG(ctx, 30, "Locating driver function '%s'", symnam); - func = dlsym(dlh, symnam); + return dlsym(dlh, symnam); +} + + +/** + * Similar to @eGetSym_optional(), but will trigger a panic error if symnam isn't found. + * + * @param ctx eurephiaCTX + * @param dlh Handler which dlopen() returned + * @param symnam Name of the function to find + * + * @return Returns a pointer to the function if it was found, otherwise NULL is returned. + */ +void *eGetSym(eurephiaCTX *ctx, void *dlh, const char *symnam) { + void *func = NULL; + + if( ctx->fatal_error > 0 ) { + return NULL; + } + func = eGetSym_optional(ctx, dlh, symnam); if( func == NULL ) { eurephia_log(ctx, LOG_PANIC, 0, "Could not find needed '%s' function in driver", symnam); ctx->fatal_error = 1; } return func; } - diff --git a/common/eurephia_getsym.h b/common/eurephia_getsym.h index 8ca4bc3..73c8aa0 100644 --- a/common/eurephia_getsym.h +++ b/common/eurephia_getsym.h @@ -31,6 +31,7 @@ #ifndef EUREPHIA_GETSYM_H_ #define EUREPHIA_GETSYM_H_ +void *eGetSym_optional(eurephiaCTX *ctx, void *dlh, const char *symnam); void *eGetSym(eurephiaCTX *ctx, void *dlh, const char *symnam); #endif /* !EUREPHIA_GETSYM_H_ */ |