From f3fd9f0a49e3b11680a3c639bfac43346589a9cf Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Fri, 1 Apr 2016 08:22:13 -0700 Subject: [PATCH 1/5] Initial AROS commit, such that it compiles & links now, but doesn't run properly yet. --- src/core/msystem.cpp | 7 ++++--- src/core/timeconvert.cpp | 4 ++++ src/core/tw_signal.cpp | 5 +++++ src/core/twlocale.cpp | 4 +++- src/tripwire/smtpmailmessage.cpp | 7 ++++++- src/tripwire/syslog_trip.cpp | 8 ++++++-- src/tw/twinit.cpp | 33 ++++++++++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 7 deletions(-) diff --git a/src/core/msystem.cpp b/src/core/msystem.cpp index 7fe2052..39e3e21 100644 --- a/src/core/msystem.cpp +++ b/src/core/msystem.cpp @@ -740,7 +740,6 @@ FILE *fp; return(-1); } - /* * like popen but A LOT safer * uses file descriptors for all three files @@ -867,6 +866,10 @@ FILE *fp[]; return(mfpclose(indx, fp)); } +#ifdef __AROS__ + #define fork() vfork() +#endif + /* * signal values */ @@ -893,7 +896,6 @@ int mask; register int i; /* counter in for loop */ register int ch_pid; /* child PID */ register int euid, egid; /* in case reset[gu]id is -1 */ - /* * create 1 pipe for each of standard input, output, error */ @@ -989,7 +991,6 @@ int mask; (void) close(p[2][0]); } } - /* * return child's PID */ diff --git a/src/core/timeconvert.cpp b/src/core/timeconvert.cpp index 5508a79..3eb59e1 100644 --- a/src/core/timeconvert.cpp +++ b/src/core/timeconvert.cpp @@ -54,6 +54,10 @@ #define TIME_MAX 2147483647L // largest signed 32 bit number +#ifdef __AROS__ + #define tzset() +#endif + struct tm* cTimeUtil::TimeToDateGMT( const int64& seconds ) { ASSERT( seconds < TIME_MAX );// this assumes time_t size is 32 bit. Yikes! diff --git a/src/core/tw_signal.cpp b/src/core/tw_signal.cpp index 6e03c7d..9277653 100644 --- a/src/core/tw_signal.cpp +++ b/src/core/tw_signal.cpp @@ -77,6 +77,11 @@ void util_SignalHandler( int sig ) } #if IS_UNIX + +#ifndef NSIG + #define NSIG 32 +#endif + void tw_psignal(int sig, const TCHAR *str) { const TCHAR *siglist[NSIG] = { diff --git a/src/core/twlocale.cpp b/src/core/twlocale.cpp index b528eca..549502f 100644 --- a/src/core/twlocale.cpp +++ b/src/core/twlocale.cpp @@ -66,6 +66,9 @@ static TSTRING& util_FormatTime( struct tm* ptm, TSTRING& strBuf ); // PUBLIC METHOD CODE //========================================================================= +#ifdef __AROS__ + #define tzset() +#endif void cTWLocale::InitGlobalLocale() { @@ -243,7 +246,6 @@ TSTRING& cTWLocale::FormatTime( int64 t, TSTRING& strBuf ) { // clear return string strBuf.erase(); - tzset(); time_t tmpTime = t; struct tm * ptm = localtime( &tmpTime ); diff --git a/src/tripwire/smtpmailmessage.cpp b/src/tripwire/smtpmailmessage.cpp index 84ec72c..86adc1a 100644 --- a/src/tripwire/smtpmailmessage.cpp +++ b/src/tripwire/smtpmailmessage.cpp @@ -66,6 +66,12 @@ #define INVALID_SOCKET -1 +#ifdef __AROS__ + #ifndef HAVE_GETHOSTNAME + #define HAVE_GETHOSTNAME 1 + #endif +#endif + #ifndef HAVE_GETHOSTNAME static int gethostname( char* name, int namelen ) { @@ -87,7 +93,6 @@ static int gethostname( char* name, int namelen ) } } #endif - // Unix does not require us to go though any silly DLL hoops, so we'll // just #define the pointers to functions needed by Windows to be the // berkely functions. diff --git a/src/tripwire/syslog_trip.cpp b/src/tripwire/syslog_trip.cpp index dab273a..44fc0fb 100644 --- a/src/tripwire/syslog_trip.cpp +++ b/src/tripwire/syslog_trip.cpp @@ -54,6 +54,12 @@ #include "tw/twerrors.h" #include "tw/twstrings.h" +#ifdef __AROS__ + #include + #define openlog(a,b,c) + #define closelog() +#endif + /////////////////////////////////////////////////////////////////////////////// // Syslog /////////////////////////////////////////////////////////////////////////////// @@ -91,11 +97,9 @@ void cSyslog::Log(const TCHAR* programName, cSyslog::LogType logType, const TCHA const char* msg = message; #endif -#ifndef SKYOS // Handle an oddball OS that has syslog.h but doesn't implement the calls. openlog(ident, LOG_PID, LOG_USER); syslog(LOG_NOTICE, "%s", msg); closelog(); -#endif #elif SUPPORTS_EVENTLOG diff --git a/src/tw/twinit.cpp b/src/tw/twinit.cpp index 5e1af78..8747f7e 100644 --- a/src/tw/twinit.cpp +++ b/src/tw/twinit.cpp @@ -79,6 +79,13 @@ #include "core/tw_signal.h" // to ignore SIGPIPE #endif +#ifdef __AROS__ +#include +#include +#include + +static bool aros_socketbase_init(); +#endif //============================================================================= // cTWInit_i @@ -238,6 +245,9 @@ void cTWInit::Init( const TSTRING& strArgv0 ) // END:RAD // ------------------------------------------------------------ +#ifdef __AROS__ + aros_socketbase_init(); +#endif // // set up the file system services // @@ -305,4 +315,27 @@ void cTWInit::Init( const TSTRING& strArgv0 ) } +#ifdef __AROS__ +struct Library* SocketBase=0; + +bool aros_socketbase_init() +{ + if (!(SocketBase = OpenLibrary("bsdsocket.library", 4))) + { + printf("Failed to load socket library"); + return 0; + } + + if (SocketBaseTags( + SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (IPTR)&errno, + SBTM_SETVAL(SBTC_HERRNOLONGPTR), (IPTR)&errno, + TAG_DONE)) + { + printf("Failed to init socket library"); + return 0; + } + return 1; +} +#endif + From ec90cdc0a54c80ded9eac95c4c0fa817d3238165 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Fri, 1 Apr 2016 09:36:29 -0700 Subject: [PATCH 2/5] Duplicate separator fix, AROS seems to need this. --- src/fco/fcodatasourceiterimpl.cpp | 5 +--- src/fco/fconame.cpp | 47 +++++++++++++++++-------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/fco/fcodatasourceiterimpl.cpp b/src/fco/fcodatasourceiterimpl.cpp index a9846db..7c8b9ec 100644 --- a/src/fco/fcodatasourceiterimpl.cpp +++ b/src/fco/fcodatasourceiterimpl.cpp @@ -200,10 +200,7 @@ void cFCODataSourceIterImpl::Next() iFCO* cFCODataSourceIterImpl::CreateFCO() //throw (eError) { ASSERT( ! Done() ); - - if( ! InitializeTypeInfo( *mCurPos ) ) - return 0; - + InitializeTypeInfo( *mCurPos ); (*mCurPos)->AddRef(); return *mCurPos; } diff --git a/src/fco/fconame.cpp b/src/fco/fconame.cpp index 312c94b..a11d72a 100644 --- a/src/fco/fconame.cpp +++ b/src/fco/fconame.cpp @@ -265,31 +265,36 @@ void cFCOName::ParseString(const TCHAR* str) void cFCOName::ParseString( const TCHAR* pszin ) { - ASSERT( mpPathName != 0); - - mpPathName->ClearList(); - - TSTRING ats = const_cast(pszin + 0); - TSTRING::const_iterator at = ats.begin(); - TSTRING::const_iterator end = at; - while ( *end ) ++end; // NOTE: Find end + ASSERT(mpPathName != 0); + ASSERT(pszin != 0); + + mpPathName->ClearList(); + + const TCHAR* at = (pszin + 0); + const TCHAR* begin = at; + const TCHAR* end = at; + int components = 0; - TSTRING::const_iterator beg = at; - while ( at < end ) - { - while ( !(*at == mDelimiter) && at < end ) - at = *at ? at + 1 : at; + while (*end) + ++end; - if ( at == beg && (*at ? at + 1 : at) >= end && at != ats.begin() ) - break; + while (at < end) + { + while (!(*at == mDelimiter) && (at < end)) + at++; - cFCONameTblNode* pNode = - cFCOName_i::msNameTbl.CreateNode( TSTRING( beg, at ) ); + TSTRING name(begin, at); + if (name.length() > 0 || components == 0) + { + cFCONameTblNode* pNode = + cFCOName_i::msNameTbl.CreateNode(name); + + mpPathName->mNames.push_back(pNode); + } - mpPathName->mNames.push_back( pNode ); - - beg = ( at = (*at ? at + 1 : at) ); - } + components++; + begin = (at = tss::strinc(at)); + } } #endif//RADS_NTMBS_VER From e71023730e61115af49180e9ddb1c67c98ffce42 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Fri, 1 Apr 2016 18:01:59 -0700 Subject: [PATCH 3/5] Add Posix<-->Native path conversion, and handle absence of Unix unlinked-but-open tempfile trick on AROS --- src/core/file.h | 14 +++++++++++-- src/core/file_unix.cpp | 41 ++++++++++++++++++++++++++++++++++++- src/core/unixfsservices.cpp | 15 +++++++++++++- src/fs/fsparserutil.cpp | 5 +++++ src/tripwire/twcmdline.cpp | 6 ++++++ 5 files changed, 77 insertions(+), 4 deletions(-) diff --git a/src/core/file.h b/src/core/file.h index 29f0630..3289660 100644 --- a/src/core/file.h +++ b/src/core/file.h @@ -73,8 +73,7 @@ class cFile { public: #if IS_UNIX - typedef off_t File_t; - + typedef off_t File_t; #else //WIN32 typedef int64 File_t; @@ -140,5 +139,16 @@ public: bool isWritable; }; + +#ifdef __AROS__ +class cArosPath +{ +public: + static TSTRING AsPosix(const TSTRING& in); + static TSTRING AsNative(const TSTRING& in); +}; +#endif + + #endif //__FILE_H diff --git a/src/core/file_unix.cpp b/src/core/file_unix.cpp index d63ed5f..94b92db 100644 --- a/src/core/file_unix.cpp +++ b/src/core/file_unix.cpp @@ -119,8 +119,15 @@ cFile::~cFile() /////////////////////////////////////////////////////////////////////////////// // Open /////////////////////////////////////////////////////////////////////////////// + +#ifndef __AROS void cFile::Open( const TSTRING& sFileName, uint32 flags ) { +#else +void cFile::Open( const TSTRING& sFileNameC, uint32 flags ) +{ + TSTRING sFileName = cArosPath::AsNative(sFileNameC); +#endif mode_t openmode = 0664; if ( mpData->mpCurrStream != NULL ) Close(); @@ -161,6 +168,7 @@ void cFile::Open( const TSTRING& sFileName, uint32 flags ) if ( flags & OPEN_CREATE ) perm |= O_CREAT; + // // actually open the file // @@ -169,6 +177,8 @@ void cFile::Open( const TSTRING& sFileName, uint32 flags ) { throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) ); } + +#ifndef __AROS__ if( flags & OPEN_LOCKED_TEMP ) { // unlink this file @@ -176,9 +186,10 @@ void cFile::Open( const TSTRING& sFileName, uint32 flags ) { // we weren't able to unlink file, so close handle and fail close( fh ); - throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) ); + throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) ); } } +#endif // // turn the file handle into a FILE* @@ -369,3 +380,31 @@ void cFile::Truncate( File_t offset ) // throw(eFile) throw( eFileTrunc( mpData->mFileName, iFSServices::GetInstance()->GetErrString() ) ); } + +#ifdef __AROS__ +TSTRING cArosPath::AsPosix( const TSTRING& in ) +{ + if (in[0] == '/') + return in; + + TSTRING out = '/' + in; + std::replace(out.begin(), out.end(), ':', '/'); + + return out; +} + +TSTRING cArosPath::AsNative( const TSTRING& in ) +{ + if (in[0] != '/') + return in; + + int x; + for (x=1; in[x] == '/' && x &v, bool bFullPaths) const throw(eFSServices) { +#else +void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector& v, bool bFullPaths) const throw(eFSServices) +{ + TSTRING strFilename = cArosPath::AsNative(strFilenameC); +#endif + //Get all the filenames DIR* dp; dp = opendir( strFilename.c_str() ); @@ -326,8 +333,14 @@ void cUnixFSServices::SetTempDirName(TSTRING& tmpPath) { } +#ifndef __AROS__ void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices) { +#else +void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const throw(eFSServices) +{ + TSTRING strName = cArosPath::AsNative(strNameC); +#endif //local variable for obtaining info on file. struct stat statbuf; diff --git a/src/fs/fsparserutil.cpp b/src/fs/fsparserutil.cpp index 0c08e50..163fc76 100644 --- a/src/fs/fsparserutil.cpp +++ b/src/fs/fsparserutil.cpp @@ -41,6 +41,7 @@ #include "fsparserutil.h" #include "core/fsservices.h" +#include "core/file.h" #include "fspropset.h" #include "fsstrings.h" #include "fco/fcopropvector.h" @@ -136,6 +137,10 @@ void cFSParserUtil::InterpretFCOName( const std::list& l, cFCOName& nam for( std::list::const_iterator i = l.begin(); i != l.end(); i++ ) strT += *i; +#ifdef __AROS__ + strT = cArosPath::AsPosix(strT); +#endif + // let cFCOName handle interpretation nameOut = strT; } diff --git a/src/tripwire/twcmdline.cpp b/src/tripwire/twcmdline.cpp index 6d50bf3..cfccb72 100644 --- a/src/tripwire/twcmdline.cpp +++ b/src/tripwire/twcmdline.cpp @@ -304,6 +304,12 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf) // make sure it exists... // + + +#ifdef __AROS__ + str = cArosPath::AsNative(str); +#endif + if (access(str.c_str(), F_OK) != 0) { TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY ); TSTRING tmpStr = _T("Directory: "); From f666409d8f8e0ca8280b2bacdd687227bc201b17 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Sat, 2 Apr 2016 10:38:21 -0700 Subject: [PATCH 4/5] String handling tweaks (string <--> dbchar) so AROS build works properly. --- src/core/stringutil.cpp | 14 ++- src/db/hierdbnode.h | 7 +- src/fco/fconame.cpp | 86 +++------------ src/fco/fconame.h~ | 231 ---------------------------------------- src/fco/fcosetimpl.h~ | 128 ---------------------- 5 files changed, 34 insertions(+), 432 deletions(-) delete mode 100644 src/fco/fconame.h~ delete mode 100644 src/fco/fcosetimpl.h~ diff --git a/src/core/stringutil.cpp b/src/core/stringutil.cpp index 5d8a0c5..8c10b3e 100644 --- a/src/core/stringutil.cpp +++ b/src/core/stringutil.cpp @@ -150,6 +150,11 @@ inline void tss_insert_in_hash( const wc16_string& lhs, const std::string& rhs ) std::string::const_iterator cStringUtil::Convert( std::string& nbs, const wc16_string& dbs ) { +#ifdef __AROS__ + nbs.resize(dbs.length()); + for (int x=0; xClearList(); - int len = _tcslen(str); - - TSTRING name; - const TCHAR* pEnd = str + len; - const TCHAR* pChar = str; - - // break off the next word to add.. - const TCHAR* pBegin = pChar; - while(pChar < pEnd) - { - while((*pChar != mDelimiter) && (pChar < pEnd)) - pChar++; - // if pChar == pBegin, then we have an extra delimiter; add it. - // TODO -- right now, I will suppress the final delimiter; I don't know if this is the - // right thing to do - if(pChar == pBegin) - { - // NOTE -- there is a special case here -- "/" (the root directory); it will be represented - // as a single empty node. This is handled by the (pChar != str) below. - if((pChar + 1 >= pEnd) && (pChar != str)) - // don't add the trailing slash - break; - name = _T(""); - } - else - name.assign(pBegin, (pChar - pBegin)); - cFCONameTblNode* pNode = cFCOName_i::msNameTbl.CreateNode(name); - mpPathName->mNames.push_back(pNode); - pBegin = ++pChar; - } -} - -#else//RADS_NTMBS_VER - - void cFCOName::ParseString( const TCHAR* pszin ) { ASSERT(mpPathName != 0); @@ -280,10 +228,11 @@ void cFCOName::ParseString( const TCHAR* pszin ) while (at < end) { - while (!(*at == mDelimiter) && (at < end)) + while (*at && !(*at == mDelimiter) && (at < end)) at++; TSTRING name(begin, at); + if (name.length() > 0 || components == 0) { cFCONameTblNode* pNode = @@ -292,12 +241,13 @@ void cFCOName::ParseString( const TCHAR* pszin ) mpPathName->mNames.push_back(pNode); } - components++; - begin = (at = tss::strinc(at)); + components++; + at++; + begin=at; + //begin = (at = tss::strinc(at)); } } -#endif//RADS_NTMBS_VER /////////////////////////////////////////////////////////////////////////////// // AsString @@ -322,14 +272,15 @@ TSTRING cFCOName::AsString() const return str; } // end ugly root dir hacks ... - ListType::iterator i = mpPathName->mNames.begin(); while(i != mpPathName->mNames.end()) { + TSTRING current = (*i)->GetString(); // the loop is constructed in this odd fashion because I don't want a trailing mDelimiter - str += (*i)->GetString(); + str += current; i++; - if(i != mpPathName->mNames.end()) + + if(i != mpPathName->mNames.end() && current != "/") str += mDelimiter; } @@ -416,17 +367,15 @@ void cFCOName::Read(iSerializer* pSerializer, int32 version) TSTRING str; pSerializer->ReadString(str); + int16 dummy = 0; // serialize the delimiter #ifdef _UNICODE pSerializer->ReadInt16( (int16&)mDelimiter ); #else - pSerializer->ReadInt16( dummy ); - const wchar_t wc = dummy; - size_t N = ::wcstombs( &mDelimiter, &wc, 1 ); - if ( N == (size_t)-1 ) - throw eCharacterEncoding(); + pSerializer->ReadInt16( dummy ); // delimiter, but it's always '/' anyway in OST. + mDelimiter = '/'; #endif // read the case-sensitiveness @@ -455,8 +404,7 @@ void cFCOName::Write(iSerializer* pSerializer) const #ifdef _UNICODE pSerializer->WriteInt16(mDelimiter); #else - wchar_t wc; - mbtowc(&wc, &mDelimiter, 1); + unsigned short wc = (unsigned short)'/'; pSerializer->WriteInt16(wc); #endif diff --git a/src/fco/fconame.h~ b/src/fco/fconame.h~ deleted file mode 100644 index 3e07ad0..0000000 --- a/src/fco/fconame.h~ +++ /dev/null @@ -1,231 +0,0 @@ -// -// The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, -// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights -// reserved. -// -// This program is free software. The contents of this file are subject -// to the terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2 of the License, or (at your -// option) any later version. You may redistribute it and/or modify it -// only in compliance with the GNU General Public License. -// -// This program is distributed in the hope that it will be useful. -// However, this program is distributed AS-IS WITHOUT ANY -// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS -// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. -// -// Nothing in the GNU General Public License or any other license to use -// the code or files shall permit you to use Tripwire's trademarks, -// service marks, or other intellectual property without Tripwire's -// prior written consent. -// -// If you have any questions, please contact Tripwire, Inc. at either -// info@tripwire.org or www.tripwire.org. -// -/////////////////////////////////////////////////////////////////////////////// -// fconame.h -// -// cFCOName -- represents the name of an FCO -#ifndef __FCONAME_H -#define __FCONAME_H - -#ifndef __SERIALIZABLE_H -#include "core/serializable.h" -#endif -#ifndef __FCONAMEINFO_H -#include "fconameinfo.h" -#endif - -/////////////////////////////////////////////////////////////////////////////// -// class cFCOName -- How we name a FCO. The implementation has ended up being -// a wrapper around a standard string. -/////////////////////////////////////////////////////////////////////////////// -class cFCONameTblNode; -class cFCONameIter; - -class cFCOName : public iTypedSerializable -{ - DECLARE_TYPEDSERIALIZABLE() - -public: - typedef cFCONameIter iterator; - - cFCOName(iFCONameInfo* iNI = NULL); - cFCOName(const cFCOName& rhs); - - explicit cFCOName(const TSTRING& rhs, iFCONameInfo* iNI = NULL); - explicit cFCOName(const TCHAR* rhs, iFCONameInfo* iNI = NULL); - // these ctors are explicit because it is expensive to create these things, so we don't want to - // do it unexpectedly - virtual ~cFCOName(); - - void operator = (const cFCOName& rhs); - void operator = (const TSTRING& rhs); - void operator = (const TCHAR* rhs); - - bool operator < (const cFCOName& rhs) const; - // defines an arbitrary order for cFCONames. This is so that names can - // be stored in trees and other ordered data structures in order to facilitate - // fast lookups. - - bool operator == (const cFCOName& rhs) const; - bool operator != (const cFCOName& rhs) const; - bool IsEqual (const cFCOName& rhs) const; - // both of these are synonyms for (GetRelationship(rhs) == REL_EQUAL) - - TSTRING AsString() const; - // return a string representation of the string - - bool IsCaseSensitive() const; - void SetCaseSensitive(bool val); - // determines how name comparisons are done. If two cFCONames are compared who are - // both case insensitive, a case insensitive compare is done. If both are case sensitive, - // a case sensitive compare is done. If one is and one isn't case sensitive (? TODO: what - // is the right thing to do in this case? ASSERT(0)? do a case sensitive compare??) - TCHAR GetDelimiter() const; - void SetDelimiter(TCHAR delimiter); - // defines what the path-delimiting character is - - void Push(const TSTRING& str); - // pushes the named string onto the end of the path. A delimiter is implicitely placed between the old end - // and the new string. if debug is defined, it is asserted that the new string does not contain the - // delimiting character - const TCHAR* Pop(); - // removes the last part of the path from the name and returns it. ASSERTS and returns an undefined value if - // the path is empty - const TCHAR* PopFront(); - // removes the first part of the path from the name and returns it. ASSERTS and returns an undefined value if - // the path is empty - void Clear(); - // removes all elements from the name; after this, GetSize() == 0. - const TCHAR* GetShortName() const; - // this will return the final string in the vector. It will assert that the name is not empty. - int GetSize() const; - // returns the number of path items (strings between delimiters) that are in the fco name. It is always equal - // to the number of delimiters in the path plus one. - - enum Relationship - { - REL_BELOW, // an fco is below another (/etc/passwd is below /etc) - REL_ABOVE, // an fco is above another (/etc is above /etc/passwd) - REL_EQUAL, // the fcos are equal (/etc/passwd is equal to /etc/passwd) - REL_UNRELATED // the fcos are unrelated (/var/spool/mail is unrelated to /var/log/pig.log) - }; - Relationship GetRelationship(const cFCOName& rhs) const; - // returns the relationship of _this_ name to the one passed in (ie -- if REL_BELOW is returned, - // this fco name is below the one passed in) - - virtual void Read (iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive) - virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive) - - ////////////////////////////////// - // Debugging method - ////////////////////////////////// - static void ClearNameTable(); - // this method should _only_ be called when the program is exiting, and you are positively sure you - // will not be using or creating any more cFCONames. Violating this rule will result in unpredictable - // results. This clears out the cFCOName internal name table, making memory leaks easier to find. -protected: - friend class cFCOName_i; - friend class cFCONameIter; - - void ParseString(const TCHAR* str); - // helper function that takes the pathname pointer to by str and fills out mpPathName - void CopyOnModify(); - // if the fconame is modified and mpPathName is shared by more than one object, this will - // release mpPathName and create a new one, so we don't change any other object's data - void SetNameInfo(iFCONameInfo* pNI); - // sets the delimiter and case sensitiveness to the name info's - - cFCOName_i* mpPathName; - TCHAR mDelimiter; // the delimiting character in names (ie -- in file systems, it is '/') - bool mbCaseSensitive; // determines whether name compares are case sensitive of not - - // this is what type of structure holds the elements of the name - // - typedef std::vector ListType; - -#ifdef _DEBUG - TSTRING mDebugStrName; // so we can see this guy's value in the debug window -#endif -}; - -//----------------------------------------------------------------------------- -// cFCONameIter -//----------------------------------------------------------------------------- -class cFCONameIter_i; -class cFCONameIter -{ -public: - cFCONameIter(const cFCOName& name); - ~cFCONameIter(); - - int GetSize() const; // returns the number of entries in the fco name - void SeekBegin(); - void Next(); - void Prev(); - bool Done() const; - - int Index() const; - // return the current offset from the beginning of the short name list - void SeekTo( int index ); - // seeks to the given index. asserts that the index is appropriate for the - // current fco name. - - const TCHAR* GetName() const; -private: - void operator=(const cFCONameIter& rhs); // not impl - cFCONameIter(const cFCONameIter& rhs); // not impl - - // the data... - // - const cFCOName& mName; - cFCOName::ListType::const_iterator mIter; -}; - -//############################################################################# -// inline implementation -inline bool cFCOName::IsCaseSensitive() const -{ - return mbCaseSensitive; -} -inline void cFCOName::SetCaseSensitive(bool val) -{ - mbCaseSensitive = val; -} -inline TCHAR cFCOName::GetDelimiter() const -{ - return mDelimiter; -} -inline void cFCOName::SetDelimiter(TCHAR delimiter) -{ - mDelimiter = delimiter; -} - -/////////////////////////////////////////////////////////////////////////////// -// IsEqual -/////////////////////////////////////////////////////////////////////////////// -inline bool cFCOName::IsEqual(const cFCOName& rhs) const -{ - return (GetRelationship(rhs) == cFCOName::REL_EQUAL); -} - -inline bool cFCOName::operator==(const cFCOName& rhs) const -{ - return IsEqual(rhs); -} -inline bool cFCOName::operator!=(const cFCOName& rhs) const -{ - return (! IsEqual(rhs)); -} - - -#endif //__FCONAME_H - diff --git a/src/fco/fcosetimpl.h~ b/src/fco/fcosetimpl.h~ deleted file mode 100644 index 90d7c19..0000000 --- a/src/fco/fcosetimpl.h~ +++ /dev/null @@ -1,128 +0,0 @@ -// -// The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, -// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights -// reserved. -// -// This program is free software. The contents of this file are subject -// to the terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2 of the License, or (at your -// option) any later version. You may redistribute it and/or modify it -// only in compliance with the GNU General Public License. -// -// This program is distributed in the hope that it will be useful. -// However, this program is distributed AS-IS WITHOUT ANY -// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS -// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. -// -// Nothing in the GNU General Public License or any other license to use -// the code or files shall permit you to use Tripwire's trademarks, -// service marks, or other intellectual property without Tripwire's -// prior written consent. -// -// If you have any questions, please contact Tripwire, Inc. at either -// info@tripwire.org or www.tripwire.org. -// -/////////////////////////////////////////////////////////////////////////////// -// fcosetimpl.h -// -// class cFCOSetImpl -- concrete implementation of an FCO set -// class cFCOIterImpl -- the iterator over the set -#ifndef __FCOSETIMPL_H -#define __FCOSETIMPL_H - -#ifndef __FCO_H -#include "fco.h" -#endif -#include "fconame.h" - -#ifndef __FCONAME_H -#include "fconame.h" -#endif - -class cFCOSetImpl : public iFCOSet -{ - friend class cFCOIterImpl; - DECLARE_TYPEDSERIALIZABLE() - -public: - cFCOSetImpl(); - cFCOSetImpl(const cFCOSetImpl& rhs); - virtual ~cFCOSetImpl(); - void operator=(const cFCOSetImpl& rhs); - - virtual const iFCOIter* Lookup(const cFCOName& name) const; - virtual iFCOIter* Lookup(const cFCOName& name); - virtual const iFCOIter* GetIter() const; - virtual iFCOIter* GetIter(); - virtual void Insert(iFCO* pFCO); - virtual void Clear(); - virtual bool IsEmpty() const; - virtual int Size() const { return mFCOSet.size(); }; - virtual void TraceContents(int dl = -1) const; - - // iSerializable interface - virtual void Read (iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive) - virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive) -private: - void ReturnIter(const cFCOIterImpl* pIter) const; - // returns the iterator to its owner; the reciprocal action - // to Lookup() or GetIter(); called by the iterator when it is destroyed - - // class we store in the set below; it is a hack that allows us to - // look up iFCOs using cFCONames in a std::set - class cFCONode - { - public: - iFCO* mpFCO; - const cFCOName* mpFCOName; - - cFCONode() : mpFCO(0), mpFCOName(0) {} - cFCONode(iFCO* pFCO) : mpFCO(pFCO), mpFCOName(&pFCO->GetName()) {} - cFCONode(const cFCOName& name) : mpFCO(0), mpFCOName(&name) {} - cFCONode(const cFCONode& rhs) : mpFCO(rhs.mpFCO), mpFCOName(rhs.mpFCOName) {} - bool operator < (const cFCONode& rhs) const { if(mpFCOName) return (*mpFCOName < *rhs.mpFCOName); else return false; } - bool operator ==(const cFCONode& rhs) const { if(mpFCOName) return (*mpFCOName == *rhs.mpFCOName); else return false; } - }; - - std::set mFCOSet; - // this is what actually stores the iFCOs. -}; - -class cFCOIterImpl : public iFCOIter -{ - friend class cFCOSetImpl; - -public: - cFCOIterImpl(cFCOSetImpl* pSet); - cFCOIterImpl(const cFCOSetImpl* pSet); - - virtual void SeekBegin() const; - virtual bool Done() const; - virtual bool IsEmpty() const; - virtual void Next() const; - virtual const iFCO* FCO() const; - virtual iFCO* FCO(); - virtual bool SeekToFCO(const cFCOName& name) const; - - virtual void Remove(); - virtual void Remove() const; - virtual void DestroyIter() const; -private: - virtual ~cFCOIterImpl() ; - - cFCOSetImpl* mpSet; - mutable std::set::iterator mIter; - // the definition of a const iterator is not that its position cannot change, - // but that it cannot modify the set it is iterating over, hence the "mutable" -}; - - -#endif //__FCOSETIMPL_H - From 943d17ceb8a85b249027231d22a47a0d729654d3 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Sun, 3 Apr 2016 20:54:44 -0700 Subject: [PATCH 5/5] Add SkyOS syslog fix to this branch so merge doesn't clobber it --- src/tripwire/syslog_trip.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tripwire/syslog_trip.cpp b/src/tripwire/syslog_trip.cpp index 44fc0fb..c70681d 100644 --- a/src/tripwire/syslog_trip.cpp +++ b/src/tripwire/syslog_trip.cpp @@ -97,9 +97,11 @@ void cSyslog::Log(const TCHAR* programName, cSyslog::LogType logType, const TCHA const char* msg = message; #endif +#ifndef SKYOS // Handle an oddball OS that has syslog.h but doesn't implement the calls. openlog(ident, LOG_PID, LOG_USER); syslog(LOG_NOTICE, "%s", msg); closelog(); +#endif #elif SUPPORTS_EVENTLOG