From 7f42e390e5f96bc8454fc42cbbfa0ed6bc45df47 Mon Sep 17 00:00:00 2001 From: "mcafee%netscape.com" Date: Tue, 29 Jun 1999 10:27:58 +0000 Subject: [PATCH] BeOS changes --- xpcom/base/nsDebug.cpp | 17 +++++++ xpcom/build/Makefile.in | 4 ++ xpcom/components/nsComponentManager.cpp | 25 ++++++++- xpcom/components/nsComponentManager.h | 5 ++ xpcom/ds/nsCRT.h | 2 +- xpcom/ds/nsPageMgr.cpp | 40 ++++++++++++++- xpcom/ds/nsPageMgr.h | 9 ++++ xpcom/glue/nsDebug.cpp | 17 +++++++ xpcom/io/nsFileSpec.cpp | 22 ++++---- xpcom/io/nsFileSpec.h | 4 +- xpcom/io/nsSpecialSystemDirectory.cpp | 68 ++++++++++++++++++++++++- xpcom/io/nsSpecialSystemDirectory.h | 4 ++ xpcom/io/nsStdFileStream.h | 2 +- 13 files changed, 201 insertions(+), 18 deletions(-) diff --git a/xpcom/base/nsDebug.cpp b/xpcom/base/nsDebug.cpp index 0c0fe7428490..17dfa34979d9 100644 --- a/xpcom/base/nsDebug.cpp +++ b/xpcom/base/nsDebug.cpp @@ -20,6 +20,11 @@ #include "prlog.h" #include "prinit.h" +#if defined(XP_BEOS) +/* For DEBUGGER macros */ +#include +#endif + #if defined(XP_UNIX) /* for abort() */ #include @@ -96,6 +101,12 @@ NS_COM void nsDebug::Abort(const char* aFile, PRIntn aLine) ExitToShell(); #elif defined(XP_UNIX) PR_Abort(); +#elif defined(XP_BEOS) + { + char buf[2000]; + sprintf(buf, "Abort: at file %s, line %d", aFile, aLine); + DEBUGGER(buf); + } #endif } @@ -110,6 +121,12 @@ NS_COM void nsDebug::Break(const char* aFile, PRIntn aLine) ::DebugBreak(); #elif defined(XP_UNIX) && !defined(UNIX_CRASH_ON_ASSERT) fprintf(stderr, "\07"); fflush(stderr); +#elif defined(XP_BEOS) + { + char buf[2000]; + sprintf(buf, "Break: at file %s, line %d", aFile, aLine); + DEBUGGER(buf); + } #else Abort(aFile, aLine); #endif diff --git a/xpcom/build/Makefile.in b/xpcom/build/Makefile.in index e6de245ed9d9..0fbee7c874fd 100644 --- a/xpcom/build/Makefile.in +++ b/xpcom/build/Makefile.in @@ -65,6 +65,10 @@ EXTRA_DSO_LDOPTS = \ $(MKSHLIB_UNFORCE_ALL) endif +ifeq ($(OS_ARCH),BeOS) +EXTRA_DSO_LDOPTS += -lbe +endif + include $(topsrcdir)/config/rules.mk ifeq ($(OS_ARCH),HP-UX) diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 3e55dc00a5e7..98617e9ddf99 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -33,6 +33,11 @@ #include "prcmon.h" #include "prthread.h" /* XXX: only used for the NSPR initialization hack (rick) */ +#ifdef XP_BEOS +#include +#include +#endif + // Logging of debug output #define FORCE_PR_LOG /* Allow logging in the release build */ #include "prlog.h" @@ -255,7 +260,23 @@ nsComponentManagerImpl::PlatformInit(void) } } #endif /* XP_UNIX */ - + +#ifdef XP_BEOS + BPath p; + const char *settings = "/boot/home/config/settings"; + if(find_directory(B_USER_SETTINGS_DIRECTORY, &p) == B_OK) + settings = p.Path(); + char settingsMozillaDir[1024]; + PR_snprintf(settingsMozillaDir, sizeof(settingsMozillaDir), + "%s/" NS_MOZILLA_DIR_NAME, settings); + if (PR_Access(settingsMozillaDir, PR_ACCESS_EXISTS) != PR_SUCCESS) { + PR_MkDir(settingsMozillaDir, NS_MOZILLA_DIR_PERMISSION); + printf("nsComponentManager: Creating Directory %s\n", settingsMozillaDir); + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Creating Directory %s", settingsMozillaDir)); + } +#endif + // Open the App Components registry. We will keep it open forever! rv = mRegistry->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry); if (NS_FAILED(rv)) return rv; @@ -1534,7 +1555,7 @@ nsComponentManagerImpl::UnregisterComponent(const nsCID &aClass, if (old != NULL && old->dll != NULL) { if (old->dll->GetPersistentDescriptorString() != NULL && -#ifdef XP_UNIX +#if defined(XP_UNIX) || defined(XP_BEOS) PL_strcasecmp(old->dll->GetPersistentDescriptorString(), aLibrary) #else PL_strcmp(old->dll->GetPersistentDescriptorString(), aLibrary) diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h index 875083dc00c1..d959078642e6 100644 --- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -201,6 +201,11 @@ protected: #define NS_MOZILLA_DIR_PERMISSION 00700 #endif /* XP_UNIX */ +#ifdef XP_BEOS +#define NS_MOZILLA_DIR_NAME "mozilla" +#define NS_MOZILLA_DIR_PERMISSION 00700 +#endif /* XP_BEOS */ + /** * When using the registry we put a version number in it. * If the version number that is in the registry doesn't match diff --git a/xpcom/ds/nsCRT.h b/xpcom/ds/nsCRT.h index 412e068130c1..c44a5665f83f 100644 --- a/xpcom/ds/nsCRT.h +++ b/xpcom/ds/nsCRT.h @@ -39,7 +39,7 @@ # define NS_LINEBREAK "\015\012" # define NS_LINEBREAK_LEN 2 # else -# ifdef XP_UNIX +# if defined(XP_UNIX) || defined(XP_BEOS) # define NS_LINEBREAK "\012" # define NS_LINEBREAK_LEN 1 # endif /* XP_UNIX */ diff --git a/xpcom/ds/nsPageMgr.cpp b/xpcom/ds/nsPageMgr.cpp index 64f8f423bc2a..1982ec0309e0 100644 --- a/xpcom/ds/nsPageMgr.cpp +++ b/xpcom/ds/nsPageMgr.cpp @@ -23,6 +23,8 @@ #include #elif defined(XP_MAC) #include +#elif defined(XP_BEOS) +#include #elif defined(XP_UNIX) #include #include @@ -278,7 +280,36 @@ nsPageMgr::InitPages(nsPageCount minPages, nsPageCount maxPages) TempDisposeHandle(h, &err); } return PR_FAILURE; - + +#elif defined(XP_BEOS) + + nsPage* addr = NULL; + nsPageCount size = maxPages; + +#if (1L< #include #endif +#if defined(XP_BEOS) +#include +#endif + /******************************************************************************* * Configuration/Debugging parameters: ******************************************************************************/ @@ -182,6 +187,10 @@ class nsPageMgr : public nsIPageManager, public nsIAllocator { nsSegmentDesc* mSegTable; PRWord mSegTableCount; #endif + +#if defined(XP_BEOS) + area_id mAid; +#endif }; /******************************************************************************/ diff --git a/xpcom/glue/nsDebug.cpp b/xpcom/glue/nsDebug.cpp index 0c0fe7428490..17dfa34979d9 100644 --- a/xpcom/glue/nsDebug.cpp +++ b/xpcom/glue/nsDebug.cpp @@ -20,6 +20,11 @@ #include "prlog.h" #include "prinit.h" +#if defined(XP_BEOS) +/* For DEBUGGER macros */ +#include +#endif + #if defined(XP_UNIX) /* for abort() */ #include @@ -96,6 +101,12 @@ NS_COM void nsDebug::Abort(const char* aFile, PRIntn aLine) ExitToShell(); #elif defined(XP_UNIX) PR_Abort(); +#elif defined(XP_BEOS) + { + char buf[2000]; + sprintf(buf, "Abort: at file %s, line %d", aFile, aLine); + DEBUGGER(buf); + } #endif } @@ -110,6 +121,12 @@ NS_COM void nsDebug::Break(const char* aFile, PRIntn aLine) ::DebugBreak(); #elif defined(XP_UNIX) && !defined(UNIX_CRASH_ON_ASSERT) fprintf(stderr, "\07"); fflush(stderr); +#elif defined(XP_BEOS) + { + char buf[2000]; + sprintf(buf, "Break: at file %s, line %d", aFile, aLine); + DEBUGGER(buf); + } #else Abort(aFile, aLine); #endif diff --git a/xpcom/io/nsFileSpec.cpp b/xpcom/io/nsFileSpec.cpp index 9a68f73ee8c4..78768faf9d88 100644 --- a/xpcom/io/nsFileSpec.cpp +++ b/xpcom/io/nsFileSpec.cpp @@ -361,7 +361,7 @@ char* nsSimpleCharString::GetLeaf(char inSeparator) const return result; } // nsSimpleCharString::GetLeaf -#if defined(XP_UNIX) || defined(XP_PC) +#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS) //---------------------------------------------------------------------------------------- void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode) @@ -440,6 +440,8 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode) #include "nsFileSpecWin.cpp" // Windows-specific implementations #elif defined(XP_MAC) #include "nsFileSpecMac.cpp" // Macintosh-specific implementations +#elif defined(XP_BEOS) +#include "nsFileSpecBeOS.cpp" // BeOS-specific implementations #elif defined(XP_UNIX) #include "nsFileSpecUnix.cpp" // Unix-specific implementations #endif @@ -664,7 +666,7 @@ nsFilePath::nsFilePath(const nsFileURL& inOther) } #endif -#ifdef XP_UNIX +#if defined XP_UNIX || defined XP_BEOS //---------------------------------------------------------------------------------------- nsFilePath::nsFilePath(const nsFileSpec& inOther) //---------------------------------------------------------------------------------------- @@ -679,7 +681,7 @@ nsFilePath::~nsFilePath() { } -#ifdef XP_UNIX +#if defined XP_UNIX || defined XP_BEOS //---------------------------------------------------------------------------------------- void nsFilePath::operator = (const nsFileSpec& inOther) //---------------------------------------------------------------------------------------- @@ -859,7 +861,7 @@ void nsFileSpec::operator = (const nsPersistentFileDescriptor& inDescriptor) // UNIX & WIN nsFileSpec implementation //======================================================================================== -#ifdef XP_UNIX +#if defined XP_UNIX || defined XP_BEOS //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const nsFilePath& inPath) //---------------------------------------------------------------------------------------- @@ -869,7 +871,7 @@ nsFileSpec::nsFileSpec(const nsFilePath& inPath) } #endif // XP_UNIX -#ifdef XP_UNIX +#if defined XP_UNIX || defined XP_BEOS //---------------------------------------------------------------------------------------- void nsFileSpec::operator = (const nsFilePath& inPath) //---------------------------------------------------------------------------------------- @@ -879,7 +881,7 @@ void nsFileSpec::operator = (const nsFilePath& inPath) } #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_PC) +#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS) //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const nsFileSpec& inSpec) //---------------------------------------------------------------------------------------- @@ -889,7 +891,7 @@ nsFileSpec::nsFileSpec(const nsFileSpec& inSpec) } #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_PC) +#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS) //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs) //---------------------------------------------------------------------------------------- @@ -901,7 +903,7 @@ nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs) } #endif //XP_UNIX,PC -#if defined(XP_UNIX) || defined(XP_PC) +#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS) //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs) //---------------------------------------------------------------------------------------- @@ -919,7 +921,7 @@ nsFileSpec::~nsFileSpec() { } -#if defined(XP_UNIX) || defined(XP_PC) +#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS) //---------------------------------------------------------------------------------------- void nsFileSpec::operator = (const nsFileSpec& inSpec) //---------------------------------------------------------------------------------------- @@ -930,7 +932,7 @@ void nsFileSpec::operator = (const nsFileSpec& inSpec) #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_PC) +#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS) //---------------------------------------------------------------------------------------- void nsFileSpec::operator = (const char* inString) //---------------------------------------------------------------------------------------- diff --git a/xpcom/io/nsFileSpec.h b/xpcom/io/nsFileSpec.h index 92f99f6f21f5..d231648877e6 100644 --- a/xpcom/io/nsFileSpec.h +++ b/xpcom/io/nsFileSpec.h @@ -138,7 +138,7 @@ #ifdef XP_MAC #include -#elif defined(XP_UNIX) || defined (XP_OS2) +#elif defined(XP_UNIX) || defined (XP_OS2) || defined(XP_BEOS) #include #elif defined(XP_PC) #include "prio.h" @@ -709,7 +709,7 @@ class NS_COM nsDirectoryIterator nsFileSpec mCurrent; PRBool mExists; -#if defined(XP_UNIX) +#if defined(XP_UNIX) || defined(XP_BEOS) DIR* mDir; #elif defined(XP_PC) PRDir* mDir; // XXX why not use PRDir for Unix too? diff --git a/xpcom/io/nsSpecialSystemDirectory.cpp b/xpcom/io/nsSpecialSystemDirectory.cpp index ee0e93164e5a..c83fcd1c732c 100644 --- a/xpcom/io/nsSpecialSystemDirectory.cpp +++ b/xpcom/io/nsSpecialSystemDirectory.cpp @@ -40,6 +40,14 @@ #include #include #include "prenv.h" +#elif defined(XP_BEOS) +#include +#include +#include +#include +#include +#include +#include #endif #include "plstr.h" @@ -194,6 +202,33 @@ static void GetCurrentProcessDirectory(nsFileSpec& aFileSpec) } } +#elif defined(XP_BEOS) + + char *moz5 = getenv("MOZILLA_FIVE_HOME"); + if (moz5) + { + aFileSpec = moz5; + return; + } + else + { + static char buf[MAXPATHLEN]; + int32 cookie = 0; + image_info info; + char *p; + *buf = 0; + if(get_next_image_info(0, &cookie, &info) == B_OK) + { + strcpy(buf, info.name); + if((p = strrchr(buf, '/')) != 0) + { + *p = 0; + aFileSpec = buf; + return; + } + } + } + #endif NS_ERROR("unable to get current process directory"); @@ -258,7 +293,7 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect #elif defined(XP_MAC) *this = kTemporaryFolderType; -#elif defined(XP_UNIX) +#elif defined(XP_UNIX) || defined(XP_BEOS) *this = "/tmp/"; #endif break; @@ -529,6 +564,37 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect #endif +#ifdef XP_BEOS + case BeOS_SettingsDirectory: + { + BPath p; + if(find_directory(B_USER_SETTINGS_DIRECTORY, &p) == B_OK) + *this = p.Path(); + else + *this = "/boot/home/config/settings"; + break; + } + + case BeOS_HomeDirectory: + { + BPath p; + if(find_directory(B_USER_DIRECTORY, &p) == B_OK) + *this = p.Path(); + else + *this = "/boot/home"; + break; + } + + case BeOS_DesktopDirectory: + { + BPath p; + if(find_directory(B_DESKTOP_DIRECTORY, &p) == B_OK) + *this = p.Path(); + else + *this = "/boot/home/Desktop"; + } +#endif + default: break; } diff --git a/xpcom/io/nsSpecialSystemDirectory.h b/xpcom/io/nsSpecialSystemDirectory.h index 9d499a94d755..5dfcaec66d96 100644 --- a/xpcom/io/nsSpecialSystemDirectory.h +++ b/xpcom/io/nsSpecialSystemDirectory.h @@ -93,6 +93,10 @@ class NS_COM nsSpecialSystemDirectory : public nsFileSpec , Unix_LocalDirectory = 301 , Unix_LibDirectory = 302 , Unix_HomeDirectory = 303 + + , BeOS_SettingsDirectory = 401 + , BeOS_HomeDirectory = 402 + , BeOS_DesktopDirectory = 403 }; //nsSpecialSystemDirectory(); diff --git a/xpcom/io/nsStdFileStream.h b/xpcom/io/nsStdFileStream.h index 2459987d92fa..603c5841e786 100644 --- a/xpcom/io/nsStdFileStream.h +++ b/xpcom/io/nsStdFileStream.h @@ -641,7 +641,7 @@ POS_TYPE FILE_BUFFER_TYPE::seekpos(pos_type sp, IOS_BASE::openmode) { if (!mFileDesc || sp==pos_type(-1)) return -1; -#if defined(XP_PC) || defined(XP_UNIX) +#if defined(XP_PC) || defined(XP_UNIX) || defined(XP_BEOS) PRInt32 position = sp; #else PRInt32 position = sp.offset();