[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6157 - in Extractor/src: include main
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6157 - in Extractor/src: include main |
Date: |
Tue, 5 Feb 2008 10:35:48 -0700 (MST) |
Author: holindho
Date: 2008-02-05 10:35:48 -0700 (Tue, 05 Feb 2008)
New Revision: 6157
Modified:
Extractor/src/include/platform.h
Extractor/src/main/extractor.c
Log:
add OS X specific installation path discovery
Modified: Extractor/src/include/platform.h
===================================================================
--- Extractor/src/include/platform.h 2008-02-05 07:09:27 UTC (rev 6156)
+++ Extractor/src/include/platform.h 2008-02-05 17:35:48 UTC (rev 6157)
@@ -60,4 +60,9 @@
#include <iconv.h>
#include <langinfo.h>
+#if DARWIN
+#include <mach-o/dyld.h>
+#include <mach-o/ldsyms.h>
#endif
+
+#endif
Modified: Extractor/src/main/extractor.c
===================================================================
--- Extractor/src/main/extractor.c 2008-02-05 07:09:27 UTC (rev 6156)
+++ Extractor/src/main/extractor.c 2008-02-05 17:35:48 UTC (rev 6157)
@@ -386,6 +386,32 @@
}
#endif
+#if DARWIN
+static char * get_path_from_dyld_image() {
+ const char * path;
+ char * p, * s;
+ int i;
+ int c;
+
+ p = NULL;
+ c = _dyld_image_count();
+ for (i = 0; i < c; i++) {
+ if (_dyld_get_image_header(i) == &_mh_dylib_header) {
+ path = _dyld_get_image_name(i);
+ if (path != NULL) {
+ p = strdup(path);
+ s = p + strlen(p);
+ while ( (s > p) && (*s != '/') )
+ s--;
+ *s = '\0';
+ }
+ break;
+ }
+ }
+ return p;
+}
+#endif
+
/**
* This may also fail -- for example, if extract
* is not also installed.
@@ -451,6 +477,7 @@
char * lpref;
char * pexe;
char * modu;
+ char * dima;
char * path;
lpref = get_path_from_ENV_PREFIX();
@@ -464,6 +491,11 @@
#else
modu = NULL;
#endif
+#if DARWIN
+ dima = get_path_from_dyld_image();
+#else
+ dima = NULL;
+#endif
path = get_path_from_PATH();
n = 1;
if (lpref != NULL)
@@ -472,6 +504,8 @@
n += strlen(pexe) + strlen("/lib/libextractor/:");
if (modu != NULL)
n += strlen(modu) + strlen("/lib/libextractor/:");
+ if (dima != NULL)
+ n += strlen(dima) + strlen("/libextractor/:");
if (path != NULL)
n += strlen(path) + strlen("/lib/libextractor/:");
tmp = malloc(n);
@@ -491,6 +525,11 @@
strcat(tmp, "/lib/libextractor/:");
free(modu);
}
+ if (dima != NULL) {
+ strcat(tmp, dima);
+ strcat(tmp, "/libextractor/:");
+ free(dima);
+ }
if (path != NULL) {
strcat(tmp, path);
strcat(tmp, "/lib/libextractor/:");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6157 - in Extractor/src: include main,
gnunet <=