1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
---|
2 | /* vim:set ts=4 sw=4 et cindent: */
|
---|
3 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
4 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
5 | *
|
---|
6 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
7 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
8 | * the License. You may obtain a copy of the License at
|
---|
9 | * http://www.mozilla.org/MPL/
|
---|
10 | *
|
---|
11 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
13 | * for the specific language governing rights and limitations under the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * The Original Code is mozilla.org code.
|
---|
17 | *
|
---|
18 | * The Initial Developer of the Original Code is
|
---|
19 | * Netscape Communications Corporation.
|
---|
20 | * Portions created by the Initial Developer are Copyright (C) 1998
|
---|
21 | * the Initial Developer. All Rights Reserved.
|
---|
22 | *
|
---|
23 | * Contributor(s):
|
---|
24 | *
|
---|
25 | * Alternatively, the contents of this file may be used under the terms of
|
---|
26 | * either of the GNU General Public License Version 2 or later (the "GPL"),
|
---|
27 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
28 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
29 | * of those above. If you wish to allow use of your version of this file only
|
---|
30 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
31 | * use your version of this file under the terms of the MPL, indicate your
|
---|
32 | * decision by deleting the provisions above and replace them with the notice
|
---|
33 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
34 | * the provisions above, a recipient may use your version of this file under
|
---|
35 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
36 | *
|
---|
37 | * ***** END LICENSE BLOCK ***** */
|
---|
38 |
|
---|
39 | #ifndef nsXPComPrivate_h__
|
---|
40 | #define nsXPComPrivate_h__
|
---|
41 |
|
---|
42 | #include "nscore.h"
|
---|
43 | #include "nsXPCOM.h"
|
---|
44 |
|
---|
45 | class nsStringContainer;
|
---|
46 | class nsCStringContainer;
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Private Method to register an exit routine. This method
|
---|
50 | * allows you to setup a callback that will be called from
|
---|
51 | * the NS_ShutdownXPCOM function after all services and
|
---|
52 | * components have gone away.
|
---|
53 | *
|
---|
54 | * This API is for the exclusive use of the xpcom glue library.
|
---|
55 | *
|
---|
56 | * Note that these APIs are NOT threadsafe and must be called on the
|
---|
57 | * main thread.
|
---|
58 | *
|
---|
59 | * @status FROZEN
|
---|
60 | * @param exitRoutine pointer to user defined callback function
|
---|
61 | * of type XPCOMExitRoutine.
|
---|
62 | * @param priority higher priorities are called before lower
|
---|
63 | * priorities.
|
---|
64 | *
|
---|
65 | * @return NS_OK for success;
|
---|
66 | * other error codes indicate a failure.
|
---|
67 | *
|
---|
68 | */
|
---|
69 | typedef NS_CALLBACK(XPCOMExitRoutine)(void);
|
---|
70 |
|
---|
71 | extern "C" NS_COM nsresult
|
---|
72 | NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority);
|
---|
73 |
|
---|
74 | extern "C" NS_COM nsresult
|
---|
75 | NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine);
|
---|
76 |
|
---|
77 |
|
---|
78 | // PUBLIC
|
---|
79 | typedef nsresult (* InitFunc)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider);
|
---|
80 | typedef nsresult (* ShutdownFunc)(nsIServiceManager* servMgr);
|
---|
81 | typedef nsresult (* GetServiceManagerFunc)(nsIServiceManager* *result);
|
---|
82 | typedef nsresult (* GetComponentManagerFunc)(nsIComponentManager* *result);
|
---|
83 | typedef nsresult (* GetComponentRegistrarFunc)(nsIComponentRegistrar* *result);
|
---|
84 | typedef nsresult (* GetMemoryManagerFunc)(nsIMemory* *result);
|
---|
85 | typedef nsresult (* NewLocalFileFunc)(const nsAString &path, PRBool followLinks, nsILocalFile* *result);
|
---|
86 | typedef nsresult (* NewNativeLocalFileFunc)(const nsACString &path, PRBool followLinks, nsILocalFile* *result);
|
---|
87 |
|
---|
88 | typedef nsresult (* GetDebugFunc)(nsIDebug* *result);
|
---|
89 | typedef nsresult (* GetTraceRefcntFunc)(nsITraceRefcnt* *result);
|
---|
90 |
|
---|
91 | typedef nsresult (* StringContainerInitFunc)(nsStringContainer&);
|
---|
92 | typedef void (* StringContainerFinishFunc)(nsStringContainer&);
|
---|
93 | typedef PRUint32 (* StringGetDataFunc)(const nsAString&, const PRUnichar**, PRBool*);
|
---|
94 | typedef PRUnichar* (* StringCloneDataFunc)(const nsAString&);
|
---|
95 | typedef nsresult (* StringSetDataFunc)(nsAString&, const PRUnichar*, PRUint32);
|
---|
96 | typedef nsresult (* StringSetDataRangeFunc)(nsAString&, PRUint32, PRUint32, const PRUnichar*, PRUint32);
|
---|
97 | typedef nsresult (* StringCopyFunc)(nsAString &, const nsAString &);
|
---|
98 |
|
---|
99 | typedef nsresult (* CStringContainerInitFunc)(nsCStringContainer&);
|
---|
100 | typedef void (* CStringContainerFinishFunc)(nsCStringContainer&);
|
---|
101 | typedef PRUint32 (* CStringGetDataFunc)(const nsACString&, const char**, PRBool*);
|
---|
102 | typedef char* (* CStringCloneDataFunc)(const nsACString&);
|
---|
103 | typedef nsresult (* CStringSetDataFunc)(nsACString&, const char*, PRUint32);
|
---|
104 | typedef nsresult (* CStringSetDataRangeFunc)(nsACString&, PRUint32, PRUint32, const char*, PRUint32);
|
---|
105 | typedef nsresult (* CStringCopyFunc)(nsACString &, const nsACString &);
|
---|
106 |
|
---|
107 | typedef nsresult (* CStringToUTF16)(const nsACString &, PRUint32, const nsAString &);
|
---|
108 | typedef nsresult (* UTF16ToCString)(const nsAString &, PRUint32, const nsACString &);
|
---|
109 |
|
---|
110 | // PRIVATE
|
---|
111 | typedef nsresult (* RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine, PRUint32 priority);
|
---|
112 | typedef nsresult (* UnregisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine);
|
---|
113 |
|
---|
114 | typedef struct XPCOMFunctions{
|
---|
115 | PRUint32 version;
|
---|
116 | PRUint32 size;
|
---|
117 |
|
---|
118 | InitFunc init;
|
---|
119 | ShutdownFunc shutdown;
|
---|
120 | GetServiceManagerFunc getServiceManager;
|
---|
121 | GetComponentManagerFunc getComponentManager;
|
---|
122 | GetComponentRegistrarFunc getComponentRegistrar;
|
---|
123 | GetMemoryManagerFunc getMemoryManager;
|
---|
124 | NewLocalFileFunc newLocalFile;
|
---|
125 | NewNativeLocalFileFunc newNativeLocalFile;
|
---|
126 |
|
---|
127 | RegisterXPCOMExitRoutineFunc registerExitRoutine;
|
---|
128 | UnregisterXPCOMExitRoutineFunc unregisterExitRoutine;
|
---|
129 |
|
---|
130 | // Added for Mozilla 1.5
|
---|
131 | GetDebugFunc getDebug;
|
---|
132 | GetTraceRefcntFunc getTraceRefcnt;
|
---|
133 |
|
---|
134 | // Added for Mozilla 1.7
|
---|
135 | StringContainerInitFunc stringContainerInit;
|
---|
136 | StringContainerFinishFunc stringContainerFinish;
|
---|
137 | StringGetDataFunc stringGetData;
|
---|
138 | StringSetDataFunc stringSetData;
|
---|
139 | StringSetDataRangeFunc stringSetDataRange;
|
---|
140 | StringCopyFunc stringCopy;
|
---|
141 | CStringContainerInitFunc cstringContainerInit;
|
---|
142 | CStringContainerFinishFunc cstringContainerFinish;
|
---|
143 | CStringGetDataFunc cstringGetData;
|
---|
144 | CStringSetDataFunc cstringSetData;
|
---|
145 | CStringSetDataRangeFunc cstringSetDataRange;
|
---|
146 | CStringCopyFunc cstringCopy;
|
---|
147 | CStringToUTF16 cstringToUTF16;
|
---|
148 | UTF16ToCString utf16ToCString;
|
---|
149 | StringCloneDataFunc stringCloneData;
|
---|
150 | CStringCloneDataFunc cstringCloneData;
|
---|
151 |
|
---|
152 | } XPCOMFunctions;
|
---|
153 |
|
---|
154 | typedef nsresult (PR_CALLBACK *GetFrozenFunctionsFunc)(XPCOMFunctions *entryPoints, const char* libraryPath);
|
---|
155 | extern "C" NS_COM nsresult
|
---|
156 | NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
|
---|
157 |
|
---|
158 | // think hard before changing this
|
---|
159 | #define XPCOM_GLUE_VERSION 1
|
---|
160 |
|
---|
161 |
|
---|
162 | /* XPCOM Specific Defines
|
---|
163 | *
|
---|
164 | * XPCOM_DLL - name of the loadable xpcom library on disk.
|
---|
165 | * XPCOM_SEARCH_KEY - name of the environment variable that can be
|
---|
166 | * modified to include additional search paths.
|
---|
167 | * GRE_CONF_NAME - Name of the GRE Configuration file
|
---|
168 | */
|
---|
169 |
|
---|
170 | #ifdef XPCOM_DLL_BASE
|
---|
171 | #define XPCOM_DLL XPCOM_DLL_BASE MOZ_DLL_SUFFIX
|
---|
172 | #endif
|
---|
173 |
|
---|
174 | #if defined(XP_WIN32) || defined(XP_OS2)
|
---|
175 |
|
---|
176 | #define XPCOM_SEARCH_KEY "PATH"
|
---|
177 | #define GRE_CONF_NAME "gre.config"
|
---|
178 | #define GRE_WIN_REG_LOC "Software\\mozilla.org\\GRE\\"
|
---|
179 | #ifndef XPCOM_DLL
|
---|
180 | #define XPCOM_DLL "xpcom"MOZ_DLL_SUFFIX
|
---|
181 | #endif
|
---|
182 |
|
---|
183 | #elif defined(XP_BEOS)
|
---|
184 |
|
---|
185 | #define XPCOM_SEARCH_KEY "ADDON_PATH"
|
---|
186 | #define GRE_CONF_NAME ".gre.config"
|
---|
187 | #define GRE_CONF_PATH "/boot/home/config/settings/GRE/gre.conf"
|
---|
188 | #ifndef XPCOM_DLL
|
---|
189 | #define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
---|
190 | #endif
|
---|
191 |
|
---|
192 | #else // Unix
|
---|
193 |
|
---|
194 | #ifndef XPCOM_DLL
|
---|
195 | #define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
---|
196 | #endif
|
---|
197 |
|
---|
198 | // you have to love apple..
|
---|
199 | #ifdef XP_MACOSX
|
---|
200 | #define XPCOM_SEARCH_KEY "DYLD_LIBRARY_PATH"
|
---|
201 | #else
|
---|
202 | #define XPCOM_SEARCH_KEY "LD_LIBRARY_PATH"
|
---|
203 | #endif
|
---|
204 |
|
---|
205 | #define GRE_CONF_NAME ".gre.config"
|
---|
206 | #define GRE_CONF_PATH "/etc/gre.conf"
|
---|
207 | #define GRE_CONF_DIR "/etc/gre.d/"
|
---|
208 | #endif
|
---|
209 |
|
---|
210 | #if defined(XP_WIN) || defined(XP_OS2)
|
---|
211 | #define XPCOM_FILE_PATH_SEPARATOR "\\"
|
---|
212 | #define XPCOM_ENV_PATH_SEPARATOR ";"
|
---|
213 | #elif defined(XP_UNIX) || defined(XP_BEOS)
|
---|
214 | #define XPCOM_FILE_PATH_SEPARATOR "/"
|
---|
215 | #define XPCOM_ENV_PATH_SEPARATOR ":"
|
---|
216 | #else
|
---|
217 | #error need_to_define_your_file_path_separator_and_illegal_characters
|
---|
218 | #endif
|
---|
219 |
|
---|
220 | #endif
|
---|
221 |
|
---|
222 |
|
---|