summaryrefslogtreecommitdiffstats
path: root/PC/os2emx/dlfcn.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-09 16:14:21 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-09 16:14:21 (GMT)
commit7f14f0d8a0228c50d5b5de2acbfe9a64ebc6749a (patch)
treed25489e9531c01f1e9244012bbfaa929f382883e /PC/os2emx/dlfcn.c
parentb7d943625cf4353f6cb72df16252759f2dbd8e06 (diff)
downloadcpython-7f14f0d8a0228c50d5b5de2acbfe9a64ebc6749a.zip
cpython-7f14f0d8a0228c50d5b5de2acbfe9a64ebc6749a.tar.gz
cpython-7f14f0d8a0228c50d5b5de2acbfe9a64ebc6749a.tar.bz2
Recorded merge of revisions 81032 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r81032 | antoine.pitrou | 2010-05-09 17:52:27 +0200 (dim., 09 mai 2010) | 9 lines Recorded merge of revisions 81029 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........ ................
Diffstat (limited to 'PC/os2emx/dlfcn.c')
-rw-r--r--PC/os2emx/dlfcn.c286
1 files changed, 143 insertions, 143 deletions
diff --git a/PC/os2emx/dlfcn.c b/PC/os2emx/dlfcn.c
index 9e88d5e..47c046c 100644
--- a/PC/os2emx/dlfcn.c
+++ b/PC/os2emx/dlfcn.c
@@ -46,178 +46,178 @@ PERFORMANCE OF THIS SOFTWARE.
#include <malloc.h>
typedef struct _track_rec {
- char *name;
- HMODULE handle;
- void *id;
- struct _track_rec *next;
+ char *name;
+ HMODULE handle;
+ void *id;
+ struct _track_rec *next;
} tDLLchain, *DLLchain;
-static DLLchain dlload = NULL; /* A simple chained list of DLL names */
-static char dlerr [256]; /* last error text string */
+static DLLchain dlload = NULL; /* A simple chained list of DLL names */
+static char dlerr [256]; /* last error text string */
static void *last_id;
static DLLchain find_id(void *id)
{
- DLLchain tmp;
+ DLLchain tmp;
- for (tmp = dlload; tmp; tmp = tmp->next)
- if (id == tmp->id)
- return tmp;
+ for (tmp = dlload; tmp; tmp = tmp->next)
+ if (id == tmp->id)
+ return tmp;
- return NULL;
+ return NULL;
}
/* load a dynamic-link library and return handle */
void *dlopen(char *filename, int flags)
{
- HMODULE hm;
- DLLchain tmp;
- char err[256];
- char *errtxt;
- int rc = 0, set_chain = 0;
-
- for (tmp = dlload; tmp; tmp = tmp->next)
- if (strnicmp(tmp->name, filename, 999) == 0)
- break;
-
- if (!tmp)
- {
- tmp = (DLLchain) malloc(sizeof(tDLLchain));
- if (!tmp)
- goto nomem;
- tmp->name = strdup(filename);
- tmp->next = dlload;
- set_chain = 1;
- }
-
- switch (rc = DosLoadModule((PSZ)&err, sizeof(err), filename, &hm))
- {
- case NO_ERROR:
- tmp->handle = hm;
- if (set_chain)
- {
- do
- last_id++;
- while ((last_id == 0) || (find_id(last_id)));
- tmp->id = last_id;
- dlload = tmp;
- }
- return tmp->id;
- case ERROR_FILE_NOT_FOUND:
- case ERROR_PATH_NOT_FOUND:
- errtxt = "module `%s' not found";
- break;
- case ERROR_TOO_MANY_OPEN_FILES:
- case ERROR_NOT_ENOUGH_MEMORY:
- case ERROR_SHARING_BUFFER_EXCEEDED:
+ HMODULE hm;
+ DLLchain tmp;
+ char err[256];
+ char *errtxt;
+ int rc = 0, set_chain = 0;
+
+ for (tmp = dlload; tmp; tmp = tmp->next)
+ if (strnicmp(tmp->name, filename, 999) == 0)
+ break;
+
+ if (!tmp)
+ {
+ tmp = (DLLchain) malloc(sizeof(tDLLchain));
+ if (!tmp)
+ goto nomem;
+ tmp->name = strdup(filename);
+ tmp->next = dlload;
+ set_chain = 1;
+ }
+
+ switch (rc = DosLoadModule((PSZ)&err, sizeof(err), filename, &hm))
+ {
+ case NO_ERROR:
+ tmp->handle = hm;
+ if (set_chain)
+ {
+ do
+ last_id++;
+ while ((last_id == 0) || (find_id(last_id)));
+ tmp->id = last_id;
+ dlload = tmp;
+ }
+ return tmp->id;
+ case ERROR_FILE_NOT_FOUND:
+ case ERROR_PATH_NOT_FOUND:
+ errtxt = "module `%s' not found";
+ break;
+ case ERROR_TOO_MANY_OPEN_FILES:
+ case ERROR_NOT_ENOUGH_MEMORY:
+ case ERROR_SHARING_BUFFER_EXCEEDED:
nomem:
- errtxt = "out of system resources";
- break;
- case ERROR_ACCESS_DENIED:
- errtxt = "access denied";
- break;
- case ERROR_BAD_FORMAT:
- case ERROR_INVALID_SEGMENT_NUMBER:
- case ERROR_INVALID_ORDINAL:
- case ERROR_INVALID_MODULETYPE:
- case ERROR_INVALID_EXE_SIGNATURE:
- case ERROR_EXE_MARKED_INVALID:
- case ERROR_ITERATED_DATA_EXCEEDS_64K:
- case ERROR_INVALID_MINALLOCSIZE:
- case ERROR_INVALID_SEGDPL:
- case ERROR_AUTODATASEG_EXCEEDS_64K:
- case ERROR_RELOCSRC_CHAIN_EXCEEDS_SEGLIMIT:
- errtxt = "invalid module format";
- break;
- case ERROR_INVALID_NAME:
- errtxt = "filename doesn't match module name";
- break;
- case ERROR_SHARING_VIOLATION:
- case ERROR_LOCK_VIOLATION:
- errtxt = "sharing violation";
- break;
- case ERROR_INIT_ROUTINE_FAILED:
- errtxt = "module initialization failed";
- break;
- default:
- errtxt = "cause `%s', error code = %d";
- break;
- }
- snprintf(dlerr, sizeof(dlerr), errtxt, &err, rc);
- if (tmp)
- {
- if (tmp->name)
- free(tmp->name);
- free(tmp);
- }
- return 0;
+ errtxt = "out of system resources";
+ break;
+ case ERROR_ACCESS_DENIED:
+ errtxt = "access denied";
+ break;
+ case ERROR_BAD_FORMAT:
+ case ERROR_INVALID_SEGMENT_NUMBER:
+ case ERROR_INVALID_ORDINAL:
+ case ERROR_INVALID_MODULETYPE:
+ case ERROR_INVALID_EXE_SIGNATURE:
+ case ERROR_EXE_MARKED_INVALID:
+ case ERROR_ITERATED_DATA_EXCEEDS_64K:
+ case ERROR_INVALID_MINALLOCSIZE:
+ case ERROR_INVALID_SEGDPL:
+ case ERROR_AUTODATASEG_EXCEEDS_64K:
+ case ERROR_RELOCSRC_CHAIN_EXCEEDS_SEGLIMIT:
+ errtxt = "invalid module format";
+ break;
+ case ERROR_INVALID_NAME:
+ errtxt = "filename doesn't match module name";
+ break;
+ case ERROR_SHARING_VIOLATION:
+ case ERROR_LOCK_VIOLATION:
+ errtxt = "sharing violation";
+ break;
+ case ERROR_INIT_ROUTINE_FAILED:
+ errtxt = "module initialization failed";
+ break;
+ default:
+ errtxt = "cause `%s', error code = %d";
+ break;
+ }
+ snprintf(dlerr, sizeof(dlerr), errtxt, &err, rc);
+ if (tmp)
+ {
+ if (tmp->name)
+ free(tmp->name);
+ free(tmp);
+ }
+ return 0;
}
/* return a pointer to the `symbol' in DLL */
void *dlsym(void *handle, char *symbol)
{
- int rc = 0;
- PFN addr;
- char *errtxt;
- int symord = 0;
- DLLchain tmp = find_id(handle);
-
- if (!tmp)
- goto inv_handle;
-
- if (*symbol == '#')
- symord = atoi(symbol + 1);
-
- switch (rc = DosQueryProcAddr(tmp->handle, symord, symbol, &addr))
- {
- case NO_ERROR:
- return (void *)addr;
- case ERROR_INVALID_HANDLE:
+ int rc = 0;
+ PFN addr;
+ char *errtxt;
+ int symord = 0;
+ DLLchain tmp = find_id(handle);
+
+ if (!tmp)
+ goto inv_handle;
+
+ if (*symbol == '#')
+ symord = atoi(symbol + 1);
+
+ switch (rc = DosQueryProcAddr(tmp->handle, symord, symbol, &addr))
+ {
+ case NO_ERROR:
+ return (void *)addr;
+ case ERROR_INVALID_HANDLE:
inv_handle:
- errtxt = "invalid module handle";
- break;
- case ERROR_PROC_NOT_FOUND:
- case ERROR_INVALID_NAME:
- errtxt = "no symbol `%s' in module";
- break;
- default:
- errtxt = "symbol `%s', error code = %d";
- break;
- }
- snprintf(dlerr, sizeof(dlerr), errtxt, symbol, rc);
- return NULL;
+ errtxt = "invalid module handle";
+ break;
+ case ERROR_PROC_NOT_FOUND:
+ case ERROR_INVALID_NAME:
+ errtxt = "no symbol `%s' in module";
+ break;
+ default:
+ errtxt = "symbol `%s', error code = %d";
+ break;
+ }
+ snprintf(dlerr, sizeof(dlerr), errtxt, symbol, rc);
+ return NULL;
}
/* free dynamicaly-linked library */
int dlclose(void *handle)
{
- int rc;
- DLLchain tmp = find_id(handle);
-
- if (!tmp)
- goto inv_handle;
-
- switch (rc = DosFreeModule(tmp->handle))
- {
- case NO_ERROR:
- free(tmp->name);
- dlload = tmp->next;
- free(tmp);
- return 0;
- case ERROR_INVALID_HANDLE:
+ int rc;
+ DLLchain tmp = find_id(handle);
+
+ if (!tmp)
+ goto inv_handle;
+
+ switch (rc = DosFreeModule(tmp->handle))
+ {
+ case NO_ERROR:
+ free(tmp->name);
+ dlload = tmp->next;
+ free(tmp);
+ return 0;
+ case ERROR_INVALID_HANDLE:
inv_handle:
- strcpy(dlerr, "invalid module handle");
- return -1;
- case ERROR_INVALID_ACCESS:
- strcpy(dlerr, "access denied");
- return -1;
- default:
- return -1;
- }
+ strcpy(dlerr, "invalid module handle");
+ return -1;
+ case ERROR_INVALID_ACCESS:
+ strcpy(dlerr, "access denied");
+ return -1;
+ default:
+ return -1;
+ }
}
/* return a string describing last occurred dl error */
char *dlerror()
{
- return dlerr;
+ return dlerr;
}