11 #include <drift/dslcore.h>
12 #include <drift/WhereIs.h>
13 #include <drift/Directory.h>
14 #include <drift/GenLib.h>
16 void WhereIs_Search(
WHEREIS_RESULTS * ret,
const char * sDir,
const char * fn) {
17 char buf[MAX_PATH],buf2[MAX_PATH];
18 memset(&buf, 0,
sizeof(buf));
19 memset(&buf2, 0,
sizeof(buf2));
22 while (dir.Read(buf,
sizeof(buf), &is_dir)) {
25 sprintf(buf2,
"%s%s", sDir, buf);
26 ret->sResults[ret->nCount] = dsl_strdup(buf2);
37 memset(&dir, 0,
sizeof(dir));
38 if (getcwd(dir,
sizeof(dir))) {
39 if (dir[strlen(dir) - 1] != PATH_SEP) {
40 strcat(dir, PATH_SEPS);
42 WhereIs_Search(ret, dir, fn);
45 if (SHGetSpecialFolderPathA(NULL, dir, CSIDL_SYSTEM, FALSE)) {
46 if (dir[strlen(dir) - 1] != PATH_SEP) {
47 strcat(dir, PATH_SEPS);
49 WhereIs_Search(ret, dir, fn);
51 if (SHGetSpecialFolderPathA(NULL, dir, CSIDL_WINDOWS, FALSE)) {
52 if (dir[strlen(dir) - 1] != PATH_SEP) {
53 strcat(dir, PATH_SEPS);
55 WhereIs_Search(ret, dir, fn);
58 #if defined(__x86_64__)
59 WhereIs_Search(ret,
"/usr/lib64/", fn);
60 WhereIs_Search(ret,
"/usr/local/lib64/", fn);
61 WhereIs_Search(ret,
"/lib64/", fn);
62 WhereIs_Search(ret,
"/usr/lib/x86_64-linux-gnu/", fn);
64 WhereIs_Search(ret,
"/usr/lib/", fn);
65 WhereIs_Search(ret,
"/usr/local/lib/", fn);
66 WhereIs_Search(ret,
"/lib/", fn);
67 WhereIs_Search(ret,
"/usr/lib/i386-linux-gnu/", fn);
69 const char * ld = getenv(
"LD_LIBRARY_PATH");
70 if (ld && strlen(ld)) {
71 char * tmp = dsl_strdup(ld);
73 char * p = strtok_r(tmp,
":", &p2);
76 if (dir[strlen(dir) - 1] != PATH_SEP) {
77 strcat(dir, PATH_SEPS);
79 WhereIs_Search(ret, dir, fn);
80 p = strtok_r(NULL,
":", &p2);
89 if (ptr == NULL) {
return; }
91 for (
int i=0; i < ptr->nCount; i++) {
DSL_API void DSL_CC dsl_free(void *ptr)
DSL_API int DSL_CC wildicmp(const char *wild, const char *string)