summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2013-03-03 00:24:00 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2013-03-03 00:24:00 +0100
commit262442599d5352f8c48018d975b7f50a53dab33c (patch)
tree43cc9cd31d496c2366dfe499ec9a8116a03afa3a /common
parent7f791662efeea219395c79b45f1dc1465ddedd62 (diff)
downloadeurephia-262442599d5352f8c48018d975b7f50a53dab33c.tar.gz
eurephia-262442599d5352f8c48018d975b7f50a53dab33c.tar.xz
eurephia-262442599d5352f8c48018d975b7f50a53dab33c.zip
common: Added possibility to do dlsym() lookups as optional via eGetSym_optional()
Will be used by the authentication plug-in framework. Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'common')
-rw-r--r--common/eurephia_getsym.c26
-rw-r--r--common/eurephia_getsym.h1
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_ */