Back to index

lightning-sunbird  0.9+nobinonly
nsXPCOMPrivate.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* vim:set ts=4 sw=4 et cindent: */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef nsXPComPrivate_h__
00040 #define nsXPComPrivate_h__
00041 
00042 // Map frozen functions to private symbol names if not using strict API.
00043 #ifdef MOZILLA_INTERNAL_API
00044 # define NS_RegisterXPCOMExitRoutine        NS_RegisterXPCOMExitRoutine_P
00045 # define NS_UnregisterXPCOMExitRoutine      NS_UnregisterXPCOMExitRoutine_P
00046 #endif
00047 
00048 #include "nscore.h"
00049 #include "nsXPCOM.h"
00050 #include "nsStringAPI.h"
00051 
00052 class nsStringContainer;
00053 class nsCStringContainer;
00054 class nsIComponentLoader;
00055 
00077 typedef NS_CALLBACK(XPCOMExitRoutine)(void);
00078 
00079 extern "C" NS_COM nsresult
00080 NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority);
00081 
00082 extern "C" NS_COM nsresult
00083 NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine);
00084 
00085 
00086 // PUBLIC
00087 typedef nsresult   (* InitFunc)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider);
00088 typedef nsresult   (* Init3Func)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider, nsStaticModuleInfo const *staticComponents, PRUint32 componentCount);
00089 typedef nsresult   (* ShutdownFunc)(nsIServiceManager* servMgr);
00090 typedef nsresult   (* GetServiceManagerFunc)(nsIServiceManager* *result);
00091 typedef nsresult   (* GetComponentManagerFunc)(nsIComponentManager* *result);
00092 typedef nsresult   (* GetComponentRegistrarFunc)(nsIComponentRegistrar* *result);
00093 typedef nsresult   (* GetMemoryManagerFunc)(nsIMemory* *result);
00094 typedef nsresult   (* NewLocalFileFunc)(const nsAString &path, PRBool followLinks, nsILocalFile* *result);
00095 typedef nsresult   (* NewNativeLocalFileFunc)(const nsACString &path, PRBool followLinks, nsILocalFile* *result);
00096 
00097 typedef nsresult   (* GetDebugFunc)(nsIDebug* *result);
00098 typedef nsresult   (* GetTraceRefcntFunc)(nsITraceRefcnt* *result);
00099 
00100 typedef nsresult   (* StringContainerInitFunc)(nsStringContainer&);
00101 typedef nsresult   (* StringContainerInit2Func)(nsStringContainer&, const PRUnichar *, PRUint32, PRUint32);
00102 typedef void       (* StringContainerFinishFunc)(nsStringContainer&);
00103 typedef PRUint32   (* StringGetDataFunc)(const nsAString&, const PRUnichar**, PRBool*);
00104 typedef PRUint32   (* StringGetMutableDataFunc)(nsAString&, PRUint32, PRUnichar**);
00105 typedef PRUnichar* (* StringCloneDataFunc)(const nsAString&);
00106 typedef nsresult   (* StringSetDataFunc)(nsAString&, const PRUnichar*, PRUint32);
00107 typedef nsresult   (* StringSetDataRangeFunc)(nsAString&, PRUint32, PRUint32, const PRUnichar*, PRUint32);
00108 typedef nsresult   (* StringCopyFunc)(nsAString &, const nsAString &);
00109 
00110 typedef nsresult   (* CStringContainerInitFunc)(nsCStringContainer&);
00111 typedef nsresult   (* CStringContainerInit2Func)(nsCStringContainer&, const char *, PRUint32, PRUint32);
00112 typedef void       (* CStringContainerFinishFunc)(nsCStringContainer&);
00113 typedef PRUint32   (* CStringGetDataFunc)(const nsACString&, const char**, PRBool*);
00114 typedef PRUint32   (* CStringGetMutableDataFunc)(nsACString&, PRUint32, char**);
00115 typedef char*      (* CStringCloneDataFunc)(const nsACString&);
00116 typedef nsresult   (* CStringSetDataFunc)(nsACString&, const char*, PRUint32);
00117 typedef nsresult   (* CStringSetDataRangeFunc)(nsACString&, PRUint32, PRUint32, const char*, PRUint32);
00118 typedef nsresult   (* CStringCopyFunc)(nsACString &, const nsACString &);
00119 
00120 typedef nsresult   (* CStringToUTF16)(const nsACString &, nsCStringEncoding, nsAString &);
00121 typedef nsresult   (* UTF16ToCString)(const nsAString &, nsCStringEncoding, nsACString &);
00122 
00123 typedef void*      (* AllocFunc)(PRSize size);
00124 typedef void*      (* ReallocFunc)(void* ptr, PRSize size);
00125 typedef void       (* FreeFunc)(void* ptr);
00126 
00127 // PRIVATE
00128 typedef nsresult   (* RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine, PRUint32 priority);
00129 typedef nsresult   (* UnregisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine);
00130 
00131 typedef struct XPCOMFunctions{
00132     PRUint32 version;
00133     PRUint32 size;
00134 
00135     InitFunc init;
00136     ShutdownFunc shutdown;
00137     GetServiceManagerFunc getServiceManager;
00138     GetComponentManagerFunc getComponentManager;
00139     GetComponentRegistrarFunc getComponentRegistrar;
00140     GetMemoryManagerFunc getMemoryManager;
00141     NewLocalFileFunc newLocalFile;
00142     NewNativeLocalFileFunc newNativeLocalFile;
00143 
00144     RegisterXPCOMExitRoutineFunc registerExitRoutine;
00145     UnregisterXPCOMExitRoutineFunc unregisterExitRoutine;
00146 
00147     // Added for Mozilla 1.5
00148     GetDebugFunc getDebug;
00149     GetTraceRefcntFunc getTraceRefcnt;
00150 
00151     // Added for Mozilla 1.7
00152     StringContainerInitFunc stringContainerInit;
00153     StringContainerFinishFunc stringContainerFinish;
00154     StringGetDataFunc stringGetData;
00155     StringSetDataFunc stringSetData;
00156     StringSetDataRangeFunc stringSetDataRange;
00157     StringCopyFunc stringCopy;
00158     CStringContainerInitFunc cstringContainerInit;
00159     CStringContainerFinishFunc cstringContainerFinish;
00160     CStringGetDataFunc cstringGetData;
00161     CStringSetDataFunc cstringSetData;
00162     CStringSetDataRangeFunc cstringSetDataRange;
00163     CStringCopyFunc cstringCopy;
00164     CStringToUTF16 cstringToUTF16;
00165     UTF16ToCString utf16ToCString;
00166     StringCloneDataFunc stringCloneData;
00167     CStringCloneDataFunc cstringCloneData;
00168 
00169     // Added for Mozilla 1.8
00170     AllocFunc allocFunc;
00171     ReallocFunc reallocFunc;
00172     FreeFunc freeFunc;
00173     StringContainerInit2Func stringContainerInit2;
00174     CStringContainerInit2Func cstringContainerInit2;
00175     StringGetMutableDataFunc stringGetMutableData;
00176     CStringGetMutableDataFunc cstringGetMutableData;
00177     Init3Func init3;
00178 } XPCOMFunctions;
00179 
00180 typedef nsresult (PR_CALLBACK *GetFrozenFunctionsFunc)(XPCOMFunctions *entryPoints, const char* libraryPath);
00181 extern "C" NS_COM nsresult
00182 NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
00183 
00184 // think hard before changing this
00185 #define XPCOM_GLUE_VERSION 1
00186 
00187 
00188 /* XPCOM Specific Defines
00189  *
00190  * XPCOM_DLL              - name of the loadable xpcom library on disk. 
00191  * XUL_DLL                - name of the loadable XUL library on disk
00192  * XPCOM_SEARCH_KEY       - name of the environment variable that can be 
00193  *                          modified to include additional search paths.
00194  * GRE_CONF_NAME          - Name of the GRE Configuration file
00195  */
00196 
00197 #if defined(XP_WIN32) || defined(XP_OS2) || defined(WINCE)
00198 
00199 #define XPCOM_SEARCH_KEY  "PATH"
00200 #define GRE_CONF_NAME     "gre.config"
00201 #define GRE_WIN_REG_LOC   "Software\\mozilla.org\\GRE"
00202 #define XPCOM_DLL         "xpcom.dll"
00203 #define XUL_DLL           "xul.dll"
00204 
00205 #elif defined(XP_BEOS)
00206 
00207 #define XPCOM_SEARCH_KEY  "ADDON_PATH"
00208 #define GRE_CONF_NAME ".gre.config"
00209 #define GRE_CONF_PATH "/boot/home/config/settings/GRE/gre.conf"
00210 #define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
00211 #define XUL_DLL   "libxul"MOZ_DLL_SUFFIX
00212 
00213 #else // Unix
00214 
00215 #define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
00216 
00217 // you have to love apple..
00218 #ifdef XP_MACOSX  
00219 #define XPCOM_SEARCH_KEY  "DYLD_LIBRARY_PATH"
00220 #define GRE_FRAMEWORK_NAME "XUL.framework"
00221 #define XUL_DLL            "XUL"
00222 #else
00223 #define XPCOM_SEARCH_KEY  "LD_LIBRARY_PATH"
00224 #define XUL_DLL   "libxul"MOZ_DLL_SUFFIX
00225 #endif
00226 
00227 #define GRE_CONF_NAME ".gre.config"
00228 #define GRE_CONF_PATH "/etc/gre.conf"
00229 #define GRE_CONF_DIR  "/etc/gre.d"
00230 #define GRE_USER_CONF_DIR ".gre.d"
00231 #endif
00232 
00233 #if defined(XP_WIN) || defined(XP_OS2)
00234   #define XPCOM_FILE_PATH_SEPARATOR       "\\"
00235   #define XPCOM_ENV_PATH_SEPARATOR        ";"
00236 #elif defined(XP_UNIX) || defined(XP_BEOS)
00237   #define XPCOM_FILE_PATH_SEPARATOR       "/"
00238   #define XPCOM_ENV_PATH_SEPARATOR        ":"
00239 #else
00240   #error need_to_define_your_file_path_separator_and_illegal_characters
00241 #endif
00242 
00243 #ifdef AIX
00244 #include <sys/param.h>
00245 #endif
00246 
00247 #ifndef MAXPATHLEN
00248 #ifdef PATH_MAX
00249 #define MAXPATHLEN PATH_MAX
00250 #elif defined(_MAX_PATH)
00251 #define MAXPATHLEN _MAX_PATH
00252 #elif defined(CCHMAXPATH)
00253 #define MAXPATHLEN CCHMAXPATH
00254 #else
00255 #define MAXPATHLEN 1024
00256 #endif
00257 #endif
00258 
00259 nsresult
00260 NewStaticComponentLoader(nsStaticModuleInfo const *aStaticModules,
00261                          PRUint32 aStaticModuleCount,
00262                          nsIComponentLoader **retval);
00263 
00264 #endif