1 --- extensions/source/nsplugin/source/so_env.cxx.old 2009-04-02 10:51:19.000000000 +0000
2 +++ extensions/source/nsplugin/source/so_env.cxx 2009-04-06 16:41:44.000000000 +0000
10 #define NSP_vsnprintf vsnprintf
11 @@ -122,6 +123,96 @@ restoreUTF8(char *pPath)
16 +extern int nspluginOOoModuleHook (void** aResult);
17 +int nspluginOOoModuleHook (void** aResult)
22 + dl_handle = dlopen(NULL, RTLD_NOW);
25 + fprintf (stderr, "Can't open myself '%s'\n", dlerror());
29 + Dl_info dl_info = { 0, };
30 + if(!dladdr((void *)nspluginOOoModuleHook, &dl_info))
32 + fprintf (stderr, "Can't find my own address '%s'\n", dlerror());
36 + if (!dl_info.dli_fname)
38 + fprintf (stderr, "Can't find my own file name\n");
42 + char cwdstr[NPP_PATH_MAX];
43 + if (!getcwd (cwdstr, sizeof(cwdstr)))
45 + fprintf (stderr, "Can't get cwd\n");
49 + char libFileName[NPP_PATH_MAX];
51 + if (dl_info.dli_fname[0] != '/')
53 + if ((strlen(cwdstr) + 1 + strlen(dl_info.dli_fname)) >= NPP_PATH_MAX)
55 + fprintf (stderr, "Plugin path too long\n");
58 + strcpy (libFileName, cwdstr);
59 + strcat (libFileName, "/");
60 + strcat (libFileName, dl_info.dli_fname);
64 + if (strlen(dl_info.dli_fname) >= NPP_PATH_MAX)
66 + fprintf (stderr, "Plugin path too long\n");
69 + strcpy (libFileName, dl_info.dli_fname);
73 + static char realFileName[NPP_PATH_MAX] = {0};
74 +# define SEARCH_SUFFIX "/program/libnpsoplug"
76 + if (!(clobber = strstr (libFileName, SEARCH_SUFFIX)))
78 + ssize_t len = readlink(libFileName, realFileName, NPP_PATH_MAX-1);
81 + fprintf (stderr, "Couldn't read link '%s'\n", libFileName);
84 + realFileName[len] = '\0';
85 + if (!(clobber = strstr (realFileName, SEARCH_SUFFIX)))
87 + fprintf (stderr, "Couldn't find suffix in '%s'\n", realFileName);
95 + strcpy (realFileName, libFileName);
97 + *aResult = realFileName;
99 + fprintf (stderr, "OpenOffice path is '%s'\n", realFileName);
105 // *aResult points the static string holding "/opt/staroffice8"
106 int findReadSversion(void** aResult, int /*bWnt*/, const char* /*tag*/, const char* /*entry*/)
108 @@ -134,9 +225,22 @@ int findReadSversion(void** aResult, int
109 // Filename of lnk file, eg. "soffice"
110 char lnkFileName[NPP_PATH_MAX] = {0};
111 char* pTempZero = NULL;
113 + /* try to fetch a 'self' pointer */
114 + if (!nspluginOOoModuleHook (aResult))
117 + /* .. now in $HOME */
118 sprintf(lnkFileName, "%s/.mozilla/plugins/libnpsoplugin%s", getenv("HOME"), SAL_DLLEXTENSION);
119 - if ((0 > readlink(lnkFileName, realFileName, NPP_PATH_MAX)) ||
120 - (NULL == (pTempZero = strstr(realFileName, "/program/libnpsoplugin" SAL_DLLEXTENSION))))
121 + ssize_t len = readlink(lnkFileName, realFileName, NPP_PATH_MAX-1);
127 + realFileName[len] = '\0';
129 + if (NULL == (pTempZero = strstr(realFileName, "/program/libnpsoplugin" SAL_DLLEXTENSION)))