summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/sltdl/sltdl.h16
-rw-r--r--src/core/lt_core.c40
-rw-r--r--src/core/lt_path.c58
-rw-r--r--src/internal/sltdl_core.h16
4 files changed, 65 insertions, 65 deletions
diff --git a/include/sltdl/sltdl.h b/include/sltdl/sltdl.h
index 2a03d6f..cb17c4b 100644
--- a/include/sltdl/sltdl.h
+++ b/include/sltdl/sltdl.h
@@ -29,6 +29,22 @@ extern "C" {
/* default dlsym vtable, see also: slibtool -dlpreopen self */
#define lt_preloaded_symbols lt__PROGRAM__LTX_preloaded_symbols
+enum sltdl_error {
+ SLTDL_ERR_OK,
+ SLTDL_ERR_SYSTEM_ERROR,
+ SLTDL_ERR_DLFCN_ERROR,
+ SLTDL_ERR_SLTDL_ERROR,
+ SLTDL_ERR_DLEXIT_REF_COUNT,
+ SLTDL_ERR_MODULE_REF_COUNT,
+ SLTDL_ERR_MODULE_PTR_INVALID,
+ SLTDL_ERR_PATH_INVALID_FIRST_CHAR,
+ SLTDL_ERR_PATH_INVALID_SEPARATTOR_CHAR,
+ SLTDL_ERR_PATH_INVALID_MARK,
+ SLTDL_ERR_PATH_INVALID_LEN,
+ SLTDL_ERR_PATH_NO_ENTRY,
+ SLTDL_ERR_CAP,
+};
+
/* loader priority */
enum lt_dlpriority {
LT_DLLOADER_PREPEND,
diff --git a/src/core/lt_core.c b/src/core/lt_core.c
index 52c06d5..7091981 100644
--- a/src/core/lt_core.c
+++ b/src/core/lt_core.c
@@ -15,18 +15,18 @@
#include "sltdl_core.h"
static const char * lt_dlerror_desc[] = {
- [SLTDL_OK] = 0,
- [SLTDL_SYSTEM_ERROR] = 0,
- [SLTDL_DLFCN_ERROR] = 0,
- [SLTDL_SLTDL_ERROR] = "sltdl internal error",
- [SLTDL_DLEXIT_REF_COUNT] = "lt_dlexit() reference count already zero",
- [SLTDL_MODULE_REF_COUNT] = "module reference count already zero",
- [SLTDL_MODULE_PTR_INVALID] = "module handle invalid",
- [SLTDL_PATH_INVALID_FIRST_CHAR] = "invalid path (does not begin with a forward slash)",
- [SLTDL_PATH_INVALID_SEPARATTOR_CHAR] = "invalid path (separator character is not a colon)",
- [SLTDL_PATH_INVALID_MARK] = "invalid path (mark not within range)",
- [SLTDL_PATH_INVALID_LEN] = "invalid path (string too long)",
- [SLTDL_PATH_NO_ENTRY] = "invalid path (not found)",
+ [SLTDL_ERR_OK] = 0,
+ [SLTDL_ERR_SYSTEM_ERROR] = 0,
+ [SLTDL_ERR_DLFCN_ERROR] = 0,
+ [SLTDL_ERR_SLTDL_ERROR] = "sltdl internal error",
+ [SLTDL_ERR_DLEXIT_REF_COUNT] = "lt_dlexit() reference count already zero",
+ [SLTDL_ERR_MODULE_REF_COUNT] = "module reference count already zero",
+ [SLTDL_ERR_MODULE_PTR_INVALID] = "module handle invalid",
+ [SLTDL_ERR_PATH_INVALID_FIRST_CHAR] = "invalid path (does not begin with a forward slash)",
+ [SLTDL_ERR_PATH_INVALID_SEPARATTOR_CHAR] = "invalid path (separator character is not a colon)",
+ [SLTDL_ERR_PATH_INVALID_MARK] = "invalid path (mark not within range)",
+ [SLTDL_ERR_PATH_INVALID_LEN] = "invalid path (string too long)",
+ [SLTDL_ERR_PATH_NO_ENTRY] = "invalid path (not found)",
};
static int lt_refs = 0;
@@ -52,7 +52,7 @@ int lt_dlexit(void)
return 1;
if (!lt_refs) {
- lt_error = SLTDL_DLEXIT_REF_COUNT;
+ lt_error = SLTDL_ERR_DLEXIT_REF_COUNT;
pthread_mutex_unlock(&lt_lock);
return 1;
}
@@ -80,13 +80,13 @@ int lt_sunlock(int ret, int error)
return 0;
}
- if ((error < 0) || (error >= SLTDL_ERROR_CAP)) {
- error = SLTDL_SLTDL_ERROR;
+ if ((error < 0) || (error >= SLTDL_ERR_CAP)) {
+ error = SLTDL_ERR_SLTDL_ERROR;
- } else if (error == SLTDL_SYSTEM_ERROR) {
+ } else if (error == SLTDL_ERR_SYSTEM_ERROR) {
lt_errno = errno;
- } else if (error == SLTDL_DLFCN_ERROR) {
+ } else if (error == SLTDL_ERR_DLFCN_ERROR) {
if (lt_dlerr)
free(lt_dlerr);
@@ -105,15 +105,15 @@ const char * lt_dlerror(void)
lt_slock();
switch (lt_error) {
- case SLTDL_OK:
+ case SLTDL_ERR_OK:
errdesc = 0;
break;
- case SLTDL_SYSTEM_ERROR:
+ case SLTDL_ERR_SYSTEM_ERROR:
errdesc = strerror(lt_errno);
break;
- case SLTDL_DLFCN_ERROR:
+ case SLTDL_ERR_DLFCN_ERROR:
errdesc = lt_dlerr;
break;
diff --git a/src/core/lt_path.c b/src/core/lt_path.c
index c945b7f..01de5b6 100644
--- a/src/core/lt_path.c
+++ b/src/core/lt_path.c
@@ -59,14 +59,14 @@ static int lt_dlsetsearchpath_locked(const char * path)
off_t elements;
if (path[0] != '/')
- return lt_setstatus(1,SLTDL_PATH_INVALID_FIRST_CHAR);
+ return lt_setstatus(1,SLTDL_ERR_PATH_INVALID_FIRST_CHAR);
elements = 1;
for (ch=&path[1]; *ch; ch++) {
if (*ch == ':') {
if (ch[1] != '/')
- return lt_setstatus(1,SLTDL_PATH_INVALID_FIRST_CHAR);
+ return lt_setstatus(1,SLTDL_ERR_PATH_INVALID_FIRST_CHAR);
elements++;
}
@@ -84,7 +84,7 @@ static int lt_dlsetsearchpath_locked(const char * path)
lt_plocs ^= 0x3f;
if (!(lt_pathv = calloc(lt_plocs,sizeof(char *))))
- return lt_setstatus(1,SLTDL_SYSTEM_ERROR);
+ return lt_setstatus(1,SLTDL_ERR_SYSTEM_ERROR);
}
if ((ch - path) > lt_plen) {
@@ -100,7 +100,7 @@ static int lt_dlsetsearchpath_locked(const char * path)
lt_plen |= 0x7ff;
lt_plen ^= 0x7ff;
if (!(lt_upath = calloc(2*lt_plen,1)))
- return lt_setstatus(1,SLTDL_SYSTEM_ERROR);
+ return lt_setstatus(1,SLTDL_ERR_SYSTEM_ERROR);
lt_vpath = &lt_upath[lt_plen];
}
@@ -127,7 +127,7 @@ static int lt_dlsetsearchpath_locked(const char * path)
lt_vmark = pathv;
- return lt_setstatus(0,SLTDL_OK);
+ return lt_setstatus(0,SLTDL_ERR_OK);
}
int lt_dlsetsearchpath(const char * path)
@@ -147,11 +147,11 @@ static int lt_dladdsearchdir_locked(const char * path)
off_t plen;
if (path[0] != '/')
- return lt_setstatus(1,SLTDL_PATH_INVALID_FIRST_CHAR);
+ return lt_setstatus(1,SLTDL_ERR_PATH_INVALID_FIRST_CHAR);
for (ch=path; *ch; ch++)
if (*ch == ':')
- return lt_setstatus(1,SLTDL_PATH_INVALID_SEPARATTOR_CHAR);
+ return lt_setstatus(1,SLTDL_ERR_PATH_INVALID_SEPARATTOR_CHAR);
alen = strlen(path);
plen = strlen(lt_upath);
@@ -168,12 +168,12 @@ static int lt_dladdsearchdir_locked(const char * path)
*lt_vmark++ = &lt_vpath[plen];
- return lt_setstatus(0,SLTDL_OK);
+ return lt_setstatus(0,SLTDL_ERR_OK);
}
/* (allocation needed) */
if (!(buf = malloc(plen + 1 + alen + 1)))
- return lt_setstatus(1,SLTDL_SYSTEM_ERROR);
+ return lt_setstatus(1,SLTDL_ERR_SYSTEM_ERROR);
sprintf(buf,"%s:%s",lt_upath,path);
@@ -210,20 +210,20 @@ int lt_dlinsertsearchdir(const char * mark, const char * path)
lt_slock();
if (path[0] != '/')
- return lt_sunlock(1,SLTDL_PATH_INVALID_FIRST_CHAR);
+ return lt_sunlock(1,SLTDL_ERR_PATH_INVALID_FIRST_CHAR);
for (ch=path; *ch; ch++)
if (*ch == ':')
- return lt_sunlock(1,SLTDL_PATH_INVALID_SEPARATTOR_CHAR);
+ return lt_sunlock(1,SLTDL_ERR_PATH_INVALID_SEPARATTOR_CHAR);
alen = strlen(path);
plen = strlen(lt_upath);
if ((mark < lt_upath) || (mark >= &lt_upath[plen]))
- return lt_sunlock(1,SLTDL_PATH_INVALID_MARK);
+ return lt_sunlock(1,SLTDL_ERR_PATH_INVALID_MARK);
if ((mark > lt_upath) && (mark[-1] != ':'))
- return lt_sunlock(1,SLTDL_PATH_INVALID_MARK);
+ return lt_sunlock(1,SLTDL_ERR_PATH_INVALID_MARK);
mark = &lt_vpath[mark - lt_upath];
@@ -248,14 +248,14 @@ int lt_dlinsertsearchdir(const char * mark, const char * path)
memcpy(&lt_upath[offset],path,alen);
lt_upath[offset+alen] = ':';
lt_vmark++;
- return lt_sunlock(0,SLTDL_OK);
+ return lt_sunlock(0,SLTDL_ERR_OK);
}
}
}
/* (allocation needed) */
if (!(buf = malloc(plen + 1 + alen + 1)))
- return lt_sunlock(1,SLTDL_SYSTEM_ERROR);
+ return lt_sunlock(1,SLTDL_ERR_SYSTEM_ERROR);
for (dst=buf, pathv=lt_pathv; *pathv; pathv++) {
if (*pathv == mark)
@@ -289,7 +289,7 @@ static int lt_dlpathopen_locked(
char path[1024];
if ((mlen = strlen(module)) >= sizeof(path))
- return lt_setstatus(-1,SLTDL_PATH_INVALID_LEN);
+ return lt_setstatus(-1,SLTDL_ERR_PATH_INVALID_LEN);
memcpy(path,module,mlen);
@@ -298,14 +298,14 @@ static int lt_dlpathopen_locked(
if (mpath) {
if (!(*mpath = realpath(path,0))) {
close(fdmod);
- return lt_setstatus(-1,SLTDL_SYSTEM_ERROR);
+ return lt_setstatus(-1,SLTDL_ERR_SYSTEM_ERROR);
}
}
- return lt_setstatus(fdmod,SLTDL_OK);
+ return lt_setstatus(fdmod,SLTDL_ERR_OK);
}
- return lt_setstatus(-1,SLTDL_PATH_NO_ENTRY);
+ return lt_setstatus(-1,SLTDL_ERR_PATH_NO_ENTRY);
}
for (ppath=lt_pathv; ppath && *ppath; ppath++) {
@@ -315,7 +315,7 @@ static int lt_dlpathopen_locked(
for (pext=extv; *pext; pext++) {
if (mlen + (elen = strlen(*pext)) >= (sizeof(path))) {
close(fdat);
- return lt_setstatus(-1,SLTDL_PATH_INVALID_LEN);
+ return lt_setstatus(-1,SLTDL_ERR_PATH_INVALID_LEN);
}
memcpy(&path[mlen],*pext,elen);
@@ -331,14 +331,14 @@ static int lt_dlpathopen_locked(
if (!(*mpath = malloc(plen))) {
close(fdat);
close(fdmod);
- return lt_setstatus(-1,SLTDL_SYSTEM_ERROR);
+ return lt_setstatus(-1,SLTDL_ERR_SYSTEM_ERROR);
}
sprintf(*mpath,"%s/%s",*ppath,path);
}
close(fdat);
- return lt_setstatus(fdmod,SLTDL_OK);
+ return lt_setstatus(fdmod,SLTDL_ERR_OK);
}
}
@@ -346,7 +346,7 @@ static int lt_dlpathopen_locked(
}
}
- return lt_setstatus(-1,SLTDL_PATH_NO_ENTRY);
+ return lt_setstatus(-1,SLTDL_ERR_PATH_NO_ENTRY);
}
int lt_dlpathopen(const char * module, const char ** extv)
@@ -378,7 +378,7 @@ static struct lt_modctx * lt_dlopen_locked(
if (lt_modv_next == lt_modv_cap) {
if (!(modctx_buf = calloc(64,sizeof(*modctx)))) {
free(mpath);
- lt_setstatus(0,SLTDL_SYSTEM_ERROR);
+ lt_setstatus(0,SLTDL_ERR_SYSTEM_ERROR);
return 0;
}
@@ -389,7 +389,7 @@ static struct lt_modctx * lt_dlopen_locked(
/* dlopen */
if (!(maddr = dlopen(mpath,mode))) {
free(mpath);
- lt_setstatus(0,SLTDL_DLFCN_ERROR);
+ lt_setstatus(0,SLTDL_ERR_DLFCN_ERROR);
return 0;
}
@@ -433,7 +433,7 @@ struct lt_modctx * lt_dlopen(const char * module)
lt_slock();
if ((slen = strlen(module)) >= PATH_MAX) {
- lt_setstatus(0,SLTDL_SYSTEM_ERROR);
+ lt_setstatus(0,SLTDL_ERR_SYSTEM_ERROR);
lt_sunlock(0,lt_status);
return 0;
}
@@ -484,14 +484,14 @@ int lt_dlclose(struct lt_modctx * modctx)
if (pmod == modctx) {
if (pmod->mrefs) {
pmod->mrefs--;
- return lt_sunlock(0,SLTDL_OK);
+ return lt_sunlock(0,SLTDL_ERR_OK);
}
- return lt_sunlock(-1,SLTDL_MODULE_REF_COUNT);
+ return lt_sunlock(-1,SLTDL_ERR_MODULE_REF_COUNT);
}
}
- return lt_sunlock(-1,SLTDL_MODULE_PTR_INVALID);
+ return lt_sunlock(-1,SLTDL_ERR_MODULE_PTR_INVALID);
}
static int lt_dlforeachfile_one(
diff --git a/src/internal/sltdl_core.h b/src/internal/sltdl_core.h
index 35e1a24..41a47e0 100644
--- a/src/internal/sltdl_core.h
+++ b/src/internal/sltdl_core.h
@@ -1,22 +1,6 @@
#ifndef SLTDL_CORE_H
#define SLTDL_CORE_H
-enum sltdl_error {
- SLTDL_OK,
- SLTDL_SYSTEM_ERROR,
- SLTDL_DLFCN_ERROR,
- SLTDL_SLTDL_ERROR,
- SLTDL_DLEXIT_REF_COUNT,
- SLTDL_MODULE_REF_COUNT,
- SLTDL_MODULE_PTR_INVALID,
- SLTDL_PATH_INVALID_FIRST_CHAR,
- SLTDL_PATH_INVALID_SEPARATTOR_CHAR,
- SLTDL_PATH_INVALID_MARK,
- SLTDL_PATH_INVALID_LEN,
- SLTDL_PATH_NO_ENTRY,
- SLTDL_ERROR_CAP,
-};
-
void lt_slock(void);
int lt_sunlock(int,int);