]> git.pld-linux.org Git - packages/libreoffice.git/blob - openoffice.org-nsplugin-path.diff
- spaces -> tab
[packages/libreoffice.git] / openoffice.org-nsplugin-path.diff
1 --- extensions/source/nsplugin/source/so_env.cxx.orig   2007-03-18 18:43:48.259831000 +0200
2 +++ extensions/source/nsplugin/source/so_env.cxx        2007-03-18 18:44:09.670316347 +0200
3 @@ -39,6 +39,7 @@
4  #ifdef UNIX
5  #include <sys/types.h>
6  #include <strings.h>
7 +#include <dlfcn.h>
8  #if defined(SOLARIS) && !defined(__GNUC__)
9  #include <varargs.h>
10  #else
11 @@ -125,6 +126,82 @@
12      return 0;
13  }
14  
15 +#ifdef UNIX
16 +extern int nspluginOOoModuleHook (void** aResult);
17 +int nspluginOOoModuleHook (void** aResult)
18 +{
19 +       void *dl_handle;
20 +       void *thisp;
21 +
22 +       dl_handle = dlopen(NULL, RTLD_NOW);
23 +       if (!dl_handle)
24 +       {
25 +               fprintf (stderr, "Can't open myself '%s'\n", dlerror());
26 +               return 1;
27 +       }
28 +
29 +       Dl_info dl_info = { 0, };
30 +       if(!dladdr((const void *)nspluginOOoModuleHook, &dl_info))
31 +       {
32 +               fprintf (stderr, "Can't find my own address '%s'\n", dlerror());
33 +               return 1;
34 +       }
35 +
36 +       if (!dl_info.dli_fname)
37 +       {
38 +               fprintf (stderr, "Can't find my own file name\n");
39 +               return 1;
40 +       }
41 +
42 +       char cwdstr[NPP_PATH_MAX];
43 +    if (!getcwd (cwdstr, sizeof(cwdstr)))
44 +       {
45 +               fprintf (stderr, "Can't get cwd\n");
46 +               return 1;
47 +       }
48 +
49 +    char libFileName[NPP_PATH_MAX];
50 +
51 +       if (dl_info.dli_fname[0] != '/')
52 +       {
53 +               strcpy (libFileName, cwdstr);
54 +               strcat (libFileName, "/");
55 +       }
56 +       strcat (libFileName, dl_info.dli_fname);
57 +
58 +       char *clobber;
59 +       static char realFileName[NPP_PATH_MAX] = {0};
60 +#   define SEARCH_SUFFIX "/program/libnpsoplug"
61 +
62 +       if (!(clobber = strstr (libFileName, SEARCH_SUFFIX)))
63 +       {
64 +               ssize_t len = readlink(libFileName, realFileName, NPP_PATH_MAX);
65 +               if (len == -1)
66 +               {
67 +                   fprintf (stderr, "Couldn't read link '%s'\n", libFileName);
68 +                       return 1;
69 +               }
70 +               realFileName[len] = '\0';
71 +               if (!(clobber = strstr (realFileName, "/program/libnpsoplug")))
72 +               {
73 +                    fprintf (stderr, "Couldn't find suffix in '%s'\n", realFileName);
74 +                        return 1;
75 +               }
76 +               *clobber = '\0';
77 +       }
78 +       else
79 +       {
80 +               *clobber = '\0';
81 +               strcpy (realFileName, libFileName);
82 +       }
83 +       *aResult = realFileName;
84 +
85 +       fprintf (stderr, "OpenOffice path is '%s'\n", realFileName);
86 +   
87 +       return 0;
88 +}
89 +#endif
90 +
91  // *aResult points the static string holding "/opt/staroffice8"
92  int findReadSversion(void** aResult, int bWnt, const char* tag, const char* entry)
93  {
94 @@ -137,9 +214,22 @@
95      // Filename of lnk file, eg. "soffice"
96      char lnkFileName[NPP_PATH_MAX] = {0};
97      char* pTempZero = NULL;
98 +
99 +    /* try to fetch a 'self' pointer */
100 +       if (!nspluginOOoModuleHook (aResult))
101 +         return 0;
102 +
103 +    /* .. now in $HOME */
104      sprintf(lnkFileName, "%s/.mozilla/plugins/libnpsoplugin%s", getenv("HOME"), SAL_DLLEXTENSION);
105 -    if ((0 > readlink(lnkFileName, realFileName, NPP_PATH_MAX)) ||
106 -       (NULL == (pTempZero = strstr(realFileName, "/program/libnpsoplugin" SAL_DLLEXTENSION))))
107 +       ssize_t len = readlink(lnkFileName, realFileName, NPP_PATH_MAX);
108 +       if (-1 == len)
109 +       {
110 +        *realFileName = 0;
111 +        return -1;
112 +       }
113 +       realFileName[len] = '\0';
114 +
115 +       if (NULL == (pTempZero = strstr(realFileName, "/program/libnpsoplugin" SAL_DLLEXTENSION)))
116      {
117          *realFileName = 0;
118          return -1;
This page took 0.061558 seconds and 3 git commands to generate.