Enlightenment CVS committal Author : doursse Project : e17 Module : proto/evil
Dir : e17/proto/evil/src/lib/dlfcn Modified Files: dlfcn.c dlfcn.h Log Message: * src/lib/Evil.h: * src/lib/evil.c: (evil_getcwd): add getgwd-like function * src/lib/dlfcn/dlfcn.c: (dladdr): * src/lib/dlfcn/dlfcn.h: add dladdr-like function. Formatting Remove unused define * src/lib/mman/sys/mman.h: remove unused define =================================================================== RCS file: /cvs/e/e17/proto/evil/src/lib/dlfcn/dlfcn.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- dlfcn.c 26 Apr 2008 16:27:46 -0000 1.6 +++ dlfcn.c 28 Apr 2008 14:34:54 -0000 1.7 @@ -156,6 +156,46 @@ return fp; } +int +dladdr (void *addr __UNUSED__, Dl_info *info) +{ + TCHAR tpath[PATH_MAX]; + char *path; + int length; + int ret = 0; + + if (!info) + return 0; + + ret = GetModuleFileName(GetModuleHandle(NULL), (LPTSTR)&tpath, PATH_MAX); + if (!ret) + return 0; + +#if defined(__CEGCC__) || defined(__MINGW32CE__) + path = evil_wchar_to_char(tpath); +#else + path = tpath; +#endif /* ! __CEGCC__ && ! __MINGW32CE__ */ + + length = strlen (path); + if (length >= PATH_MAX) + { + length = PATH_MAX - 1; + path[PATH_MAX - 1] = '\0'; + } + + memcpy (info->dli_fname, path, length + 1); + info->dli_fbase = NULL; + info->dli_sname = NULL; + info->dli_saddr = NULL; + +#if defined(__CEGCC__) || defined(__MINGW32CE__) + free (path); +#endif /* __CEGCC__ || __MINGW32CE__ */ + + return 1; +} + char * dlerror (void) { =================================================================== RCS file: /cvs/e/e17/proto/evil/src/lib/dlfcn/dlfcn.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- dlfcn.h 5 Mar 2008 09:19:38 -0000 1.4 +++ dlfcn.h 28 Apr 2008 14:34:54 -0000 1.5 @@ -1,6 +1,12 @@ #ifndef __EVIL_DLFCN_H__ #define __EVIL_DLFCN_H__ + +#if defined(__CEGCC__) || defined(__MINGW32CE__) +# include <sys/syslimits.h> +#endif /* __MINGW32CE__ */ + + #ifdef EAPI # undef EAPI #endif /* EAPI */ @@ -17,12 +23,25 @@ # endif /* ! EFL_EVIL_BUILD */ #endif /* _WIN32 */ + #ifdef __cplusplus extern "C" { #endif /** + * @file dlfcn.h + * @brief The file that provides functions to manage dynamic-link libraries + * @defgroup Dlfcn Functions that manage dynamic-link libraries. + * + * This header provides functions to load and unload dynamic-link + * libaries, to get the address of a symbol, and to get diagnostic + * information. + * + */ + + +/** * @def RTLD_LAZY * Lazy function call binding */ @@ -42,16 +61,24 @@ # define RTLD_GLOBAL 4 /* symbols in this dlopen'ed obj are visible to other dlopen'ed objs */ + /** - * @file dlfcn.h - * @brief The file that provides functions to manage dynamic-link libraries - * @defgroup Dlfcn Functions that manage dynamic-link libraries. - * - * This header provides functions to load and unload dynamic-link - * libaries, to get the address of a symbol, and to get diagnostic - * information. - * + * @typedef Dl_info + * @brief A structure that stores infomation of a calling process. */ +typedef struct Dl_info Dl_info; + +/** + * @struct Dl_info + * @brief A structure that stores infomation of a calling process. + */ +struct Dl_info +{ + char *dli_fname[PATH_MAX]; /**< Filename of defining object */ + void *dli_fbase; /**< Load address of that object */ + const char *dli_sname; /**< Name of nearest lower symbol */ + void *dli_saddr; /**< Exact value of nearest symbol */ +}; /** * Map a specified executable module (either a .dll or .exe file) @@ -163,6 +190,30 @@ EAPI void *dlsym(void* handle, const char* symbol); /** + * Get the location of the current process (.exe) + * + * @param addr Unused. + * @param info Pointer to the Dl_info to fill. + * @return 1 on success, 0 otherwise. + * + * Fill the dli_fname member of @p info with the absolute name + * of the current calling process (.exe file that is executed). + * All other members are set to @c NULL. + * + * Contrary to the unix function, the full name of the shared + * library is not returned, but insted the full name of the current + * calling process (.exe file). + * + * Conformity: None. + * + * Supported OS: Windows Vista, Windows XP or Windows 2000 + * Professional. + * + * @ingroup Dlfcn + */ +EAPI int dladdr (void *addr, Dl_info *info); + +/** * Get diagnostic information * * @return A @c NULL-terminated string if an error occured, @c NULL @@ -190,9 +241,5 @@ } #endif -#ifdef _WIN32 -# undef EAPI -# define EAPI -#endif /* _WIN32 */ #endif /* __EVIL_DLFCN_H__ */ ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs