From dd665ec41f9dff4283b829a93d3b6ea5c0ef026e Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 21 Dec 2010 19:12:17 +0000 Subject: [PATCH] try to load libc from libc.so.6 on Linux (since this appears to work, but loading from libc.so fails) --- chrome/content/zotero/xpcom/integration.js | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index f769820f6..729d3b1b8 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -193,9 +193,32 @@ Zotero.Integration = new function() { } else { Components.utils.import("resource://gre/modules/ctypes.jsm"); - // initialize library - var libc = Zotero.isMac ? "/usr/lib/libc.dylib" : "libc.so"; - var lib = ctypes.open(libc); + // get possible names for libc + if(Zotero.isMac) { + var possibleLibcs = ["/usr/lib/libc.dylib"]; + } else { + var possibleLibcs = [ + "libc.so.6", + "libc.so.6.1", + "libc.so" + ]; + } + + // try all possibilities + while(possibleLibcs.length) { + var libc = possibleLibcs.shift(); + try { + var lib = ctypes.open(libc); + break; + } catch(e) {} + } + + // throw appropriate error on failure + if(!lib) { + throw "libc could not be loaded. Please post on the Zotero Forums so we can add "+ + "support for your operating system."; + } + // int mkfifo(const char *path, mode_t mode); var mkfifo = lib.declare("mkfifo", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.unsigned_int);