diff options
Diffstat (limited to 'tools/bootstrp')
-rw-r--r-- | tools/bootstrp/addexes/replace.cxx | 76 | ||||
-rw-r--r-- | tools/bootstrp/addexes2/mkfilt.cxx | 237 | ||||
-rw-r--r-- | tools/bootstrp/appdef.cxx | 168 | ||||
-rw-r--r-- | tools/bootstrp/cppdep.cxx | 246 | ||||
-rw-r--r-- | tools/bootstrp/cppdep.hxx | 58 | ||||
-rw-r--r-- | tools/bootstrp/inimgr.cxx | 210 | ||||
-rw-r--r-- | tools/bootstrp/iserver.cxx | 152 | ||||
-rw-r--r-- | tools/bootstrp/md5.cxx | 149 | ||||
-rw-r--r-- | tools/bootstrp/md5.hxx | 32 | ||||
-rw-r--r-- | tools/bootstrp/mkcreate.cxx | 945 | ||||
-rw-r--r-- | tools/bootstrp/prj.cxx | 171 | ||||
-rw-r--r-- | tools/bootstrp/rscdep.cxx | 299 | ||||
-rw-r--r-- | tools/bootstrp/so_checksum.cxx | 56 | ||||
-rw-r--r-- | tools/bootstrp/sspretty.cxx | 60 |
14 files changed, 2859 insertions, 0 deletions
diff --git a/tools/bootstrp/addexes/replace.cxx b/tools/bootstrp/addexes/replace.cxx new file mode 100644 index 000000000000..37304ab18870 --- /dev/null +++ b/tools/bootstrp/addexes/replace.cxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" + +#include <stdio.h> +#include <tools/string.hxx> + + +/****************************************************************************/ +#if defined UNX +int main( int argc, char *argv[] ) +#else +int _cdecl main( int argc, char *argv[] ) +#endif +/****************************************************************************/ +{ + if ( argc < 4 ) + { + fprintf( stderr, "ERROR: too few parameters. \n\n"); + fprintf( stderr, "usage: txtrep.exe EnvironmentVariable Searchstring replacestring\n"); + return 1; + } + ByteString aText( getenv( argv[ 1 ] )); + if ( aText.Len() == 0 ) + { + fprintf( stderr, "ERROR: Variable not set. \n\n"); + fprintf( stderr, "usage: txtrep.exe EnvironmentVariable Searchstring replacestring\n"); + return 2; + } + ByteString aSearch( argv[ 2 ] ); + ByteString aReplace( argv[ 3 ] ); + + ByteString aUpperText( aText ); + aUpperText.ToUpperAscii(); + + + sal_uIntPtr nIndex; + aSearch.ToUpperAscii(); + + nIndex = aUpperText.Search( aSearch.GetBuffer(), 0); + while ( nIndex != STRING_NOTFOUND ) + { + aText.Replace( nIndex, aSearch.Len(), aReplace.GetBuffer()); + aUpperText.Replace( nIndex, aSearch.Len(), aReplace.GetBuffer()); + nIndex = aUpperText.Search( aSearch.GetBuffer(), nIndex + aReplace.Len()); + } + + fprintf( stdout, "%s\n", aText.GetBuffer()); + return 0; +} diff --git a/tools/bootstrp/addexes2/mkfilt.cxx b/tools/bootstrp/addexes2/mkfilt.cxx new file mode 100644 index 000000000000..9dae100352c3 --- /dev/null +++ b/tools/bootstrp/addexes2/mkfilt.cxx @@ -0,0 +1,237 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" + +#include <stdio.h> + +#include <../../inc/tools/string.hxx> +#include <../../inc/tools/list.hxx> + +class TextFilter +{ +protected: + FILE *pIn, *pOut; + virtual void Filter(); +public: + TextFilter( ByteString aInFile = "stdin", + ByteString aOutFile = "stdout" ); + virtual ~TextFilter(); + + virtual void Execute(); +}; + +TextFilter::TextFilter( ByteString aInFile, ByteString aOutFile ) +{ + if ( aInFile == "stdin" ) + pIn = stdin; + else + if (( pIn = fopen( aInFile.GetBuffer(), "r" )) == NULL ) + printf( "Can't read %s\n", aInFile.GetBuffer() ); + + if ( aOutFile == "stdout" ) + pOut = stdout; + else + if (( pOut = fopen( aOutFile.GetBuffer(), "w" )) == NULL ) + printf( "Can't write %s\n", aOutFile.GetBuffer() ); +} + +TextFilter::~TextFilter() +{ + fclose( pOut ); + fclose( pIn ); +} + +void TextFilter::Execute() +{ + Filter(); +} + +void TextFilter::Filter() +{ + int c; + while ( (c = fgetc( pIn )) != EOF ) + fputc( c, pOut ); +} + +#define LINE_LEN 2048 + +class ByteStringList; + +class MkLine +{ +public: + ByteString aLine; + ByteStringList* pPrivateTnrLst; + sal_Bool bOut; + sal_Bool bHier; + + MkLine(); +}; + +MkLine::MkLine() +{ + bOut = sal_False; + bHier = sal_False; + pPrivateTnrLst = NULL; +} + +DECLARE_LIST( ByteStringList, MkLine * ) + +class MkFilter : public TextFilter +{ + static ByteString aTnr; + ByteStringList *pLst; + ByteStringList *pTnrLst; +protected: + virtual void Filter(); +public: + MkFilter( ByteString aInFile = "stdin", ByteString aOutFile = "stdout"); + ~MkFilter(); +}; + +MkFilter::MkFilter( ByteString aInFile, ByteString aOutFile ) : + TextFilter( aInFile, aOutFile ) +{ + pLst = new ByteStringList; + pTnrLst = new ByteStringList; +} + +MkFilter::~MkFilter() +{ + delete pTnrLst; + delete pLst; +} + +ByteString MkFilter::aTnr="$(TNR)"; + +void MkFilter::Filter() +{ + char aLineBuf[LINE_LEN]; + int nState = 0; + + while(( fgets(aLineBuf, LINE_LEN, pIn)) != NULL ) + { + ByteString aLine( aLineBuf ); + //fprintf(stderr, "aLine :%s\n", aLine.GetBuffer()); + if ( aLine.Search("mkfilter1" ) != STRING_NOTFOUND ) + { + // Zeilen unterdruecken + fprintf( stderr, "mkfilter1\n" ); + nState = 0; + } + else if ( aLine.Search("unroll begin" ) != STRING_NOTFOUND ) + { + // Zeilen raus schreiben mit ersetzen von $(TNR) nach int n + fprintf( stderr, "\nunroll begin\n" ); + nState = 1; + } + ; + + if ( nState == 0 ) + { + fprintf( stderr, "." ); + MkLine *pMkLine = new MkLine(); + ByteString *pStr = new ByteString( aLineBuf ); + pMkLine->aLine = *pStr; + pMkLine->bOut = sal_False; + + pLst->Insert( pMkLine, LIST_APPEND ); + } + else if ( nState == 1 ) + { + sal_Bool bInTnrList = sal_True; + fprintf( stderr, ":" ); + MkLine *pMkLine = new MkLine(); + if ( aLine.Search("unroll end") != STRING_NOTFOUND ) + { + fprintf( stderr, ";\nunroll end\n" ); + MkLine *p_MkLine = new MkLine(); + p_MkLine->bHier = sal_True; + ByteString *pByteString = new ByteString("# do not delete this line === mkfilter3i\n"); + p_MkLine->aLine = *pByteString; + p_MkLine->bOut = sal_False; + p_MkLine->pPrivateTnrLst = pTnrLst; + pTnrLst = new ByteStringList(); + pLst->Insert( p_MkLine, LIST_APPEND ); + nState = 0; + bInTnrList = sal_False; + } + ByteString *pStr = new ByteString( aLineBuf ); + pMkLine->aLine = *pStr; + pMkLine->bOut = sal_False; + + if ( bInTnrList ) + pTnrLst->Insert( pMkLine, LIST_APPEND ); + } + else { + /* Zeilen ignorieren */; + } + } // End Of File + fprintf( stderr, "\n" ); + + // das File wieder ausgegeben + sal_uIntPtr nLines = pLst->Count(); + for ( sal_uIntPtr j=0; j<nLines; j++ ) + { + MkLine *pLine = pLst->GetObject( j ); + if ( pLine->bHier ) + { + // die List n - Mal abarbeiten + for ( sal_uInt16 n=1; n<11; n++) + { + sal_uIntPtr nCount = pLine->pPrivateTnrLst->Count(); + for ( sal_uIntPtr i=0; i<nCount; i++ ) + { + MkLine *pMkLine = pLine->pPrivateTnrLst->GetObject(i); + ByteString aLine = pMkLine->aLine; + while( aLine.SearchAndReplace( aTnr, ByteString::CreateFromInt32( n )) != (sal_uInt16)-1 ) ; + fputs( aLine.GetBuffer(), pOut ); + fprintf( stderr, "o" ); + } + } + if ( pLine->pPrivateTnrLst != NULL ) + delete pLine->pPrivateTnrLst; + pLine->pPrivateTnrLst = NULL; + } + if ( pLine->bOut ) + fputs(pLine->aLine.GetBuffer(), pOut ); + } + fprintf( stderr, "\n" ); +} + +int main() +{ + int nRet = 0; + + TextFilter *pFlt = new MkFilter(); + pFlt->Execute(); + delete pFlt; + + return nRet; +} diff --git a/tools/bootstrp/appdef.cxx b/tools/bootstrp/appdef.cxx new file mode 100644 index 000000000000..ac6212724afc --- /dev/null +++ b/tools/bootstrp/appdef.cxx @@ -0,0 +1,168 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "bootstrp/appdef.hxx" + +const char* GetDefStandList() +{ + char* pRet; + char* pEnv = getenv("STAR_STANDLST"); + if ( pEnv ) + { + int nLen = strlen( pEnv ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, pEnv ); + } + else + { + int nLen = strlen( _DEF_STAND_LIST ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, _DEF_STAND_LIST ); + } + return pRet; +} + + +const char* GetIniRoot() +{ + char* pRet; + char* pEnv = getenv("STAR_INIROOT"); + if ( pEnv ) + { + int nLen = strlen( pEnv ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, pEnv ); + } + else + { + int nLen = strlen( _INIROOT ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, _INIROOT ); + } + return pRet; +} + +const char* GetIniRootOld() +{ + char* pRet; + char* pEnv = getenv("STAR_INIROOTOLD"); + if ( pEnv ) + { + int nLen = strlen( pEnv ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, pEnv ); + } + else + { + int nLen = strlen( _INIROOT_OLD ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, _INIROOT_OLD ); + } + return pRet; +} + +const char* GetSSolarIni() +{ + char* pRet; + char* pEnv = getenv("STAR_SSOLARINI"); + if ( pEnv ) + { + int nLen = strlen( pEnv ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, pEnv ); + } + else + { + int nLen = strlen( _DEF_SSOLARINI ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, _DEF_SSOLARINI ); + } + return pRet; +} + + +const char* GetSSCommon() +{ + char* pRet; + char* pEnv = getenv("STAR_SSCOMMON"); + if ( pEnv ) + { + int nLen = strlen( pEnv ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, pEnv ); + } + else + { + int nLen = strlen( _DEF_SSCOMMON ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, _DEF_SSCOMMON ); + } + return pRet; +} + + +const char* GetBServerRoot() +{ + char* pRet; + char* pEnv = getenv("STAR_BSERVERROOT"); + if ( pEnv ) + { + int nLen = strlen( pEnv ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, pEnv ); + } + else + { + int nLen = strlen( B_SERVER_ROOT ); + pRet = ( char *) malloc( nLen + 1 ); + (void) strcpy( pRet, B_SERVER_ROOT ); + } + return pRet; +} + +const char* GetEnv( const char *pVar ) +{ + char const *pRet = getenv( pVar ); + if ( !pRet ) + pRet = ""; + return pRet; +} + +const char* GetEnv( const char *pVar, const char *pDefault ) +{ + char *pRet = getenv( pVar ); + if ( !pRet ) + return pDefault; + return pRet; +} diff --git a/tools/bootstrp/cppdep.cxx b/tools/bootstrp/cppdep.cxx new file mode 100644 index 000000000000..28410a575b5a --- /dev/null +++ b/tools/bootstrp/cppdep.cxx @@ -0,0 +1,246 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" + +#include <stdio.h> +#include <string.h> + +#include <unistd.h> + +#include <sys/stat.h> +#include <tools/stream.hxx> +#include "cppdep.hxx" + +//#define TEST + +CppDep::CppDep( ByteString aFileName ) +{ + aSourceFile = aFileName; + + pSearchPath = new ByteStringList; + pFileList = new ByteStringList; +} + +CppDep::CppDep() +{ + pSources = new ByteStringList; + pSearchPath = new ByteStringList; + pFileList = new ByteStringList; +} + +CppDep::~CppDep() +{ + delete pSources; + delete pSearchPath; + delete pFileList; +} + +void CppDep::Execute() +{ + sal_uIntPtr nCount = pSources->Count(); + for ( sal_uIntPtr n=0; n<nCount;n++) + { + ByteString *pStr = pSources->GetObject(n); + Search( *pStr ); + } +} + +sal_Bool CppDep::AddSearchPath( const char* aPath ) +{ + ByteString *pStr = new ByteString( aPath ); + pSearchPath->Insert( pStr, LIST_APPEND ); + return sal_False; +} + +sal_Bool CppDep::AddSource( const char* aSource ) +{ + ByteString *pStr = new ByteString( aSource ); + pSources->Insert( pStr, LIST_APPEND ); + return sal_False; +} + +sal_Bool CppDep::Search( ByteString aFileName ) +{ +#ifdef DEBUG_VERBOSE + fprintf( stderr, "SEARCH : %s\n", aFileName.GetBuffer()); +#endif + sal_Bool bRet = sal_False; + + SvFileStream aFile; + ByteString aReadLine; + + UniString suFileName( aFileName, gsl_getSystemTextEncoding()); + + aFile.Open( suFileName, STREAM_READ ); + while ( aFile.ReadLine( aReadLine )) + { + sal_uInt16 nPos = aReadLine.Search( "include" ); + if ( nPos != STRING_NOTFOUND ) + { +#ifdef DEBUG_VERBOSE + fprintf( stderr, "found : %d %s\n", nPos, aReadLine.GetBuffer() ); +#endif + ByteString aResult = IsIncludeStatement( aReadLine ); +#ifdef DEBUG_VERBOSE + fprintf( stderr, "Result : %s\n", aResult.GetBuffer() ); +#endif + + ByteString aNewFile; + if ( aResult !="") + if ( (aNewFile = Exists( aResult )) != "" ) + { + sal_Bool bFound = sal_False; + sal_uIntPtr nCount = pFileList->Count(); + for ( sal_uIntPtr i=0; i<nCount; i++ ) + { + ByteString *pStr = pFileList->GetObject(i); + if ( *pStr == aNewFile ) + bFound = sal_True; + } +#ifdef DEBUG_VERBOSE + fprintf( stderr, "not in list : %d %s\n", nPos, aReadLine.GetBuffer() ); +#endif + if ( !bFound ) + { + pFileList->Insert( new ByteString( aNewFile ), LIST_APPEND ); +#ifdef DEBUG_VERBOSE + fprintf( stderr, " CppDep %s\\\n", aNewFile.GetBuffer() ); +#endif + Search(aNewFile); + } + } + } + } + aFile.Close(); + + return bRet; +} + +ByteString CppDep::Exists( ByteString aFileName ) +{ + char pFullName[1023]; + ByteString aString; + +#ifdef DEBUG_VERBOSE + fprintf( stderr, "Searching %s \n", aFileName.GetBuffer() ); +#endif + + sal_uIntPtr nCount = pSearchPath->Count(); + for ( sal_uIntPtr n=0; n<nCount; n++) + { + struct stat aBuf; + ByteString *pPathName = pSearchPath->GetObject(n); + + strcpy( pFullName, pPathName->GetBuffer()); + strcat( pFullName, DIR_SEP ); + strcat( pFullName, aFileName.GetBuffer()); + +#ifdef DEBUG_VERBOSE + fprintf( stderr, "looking for %s\t ", pFullName ); +#endif + if ( stat( pFullName, &aBuf ) == 0 ) + { +#ifdef DEBUG_VERBOSE + fprintf( stderr, "Got Dependency ", pFullName ); +#endif +#ifdef DEBUG_VERBOSE + fprintf( stderr, "%s \\\n", pFullName ); +#endif + + return ByteString(pFullName); + } + } + return aString; +} + +ByteString CppDep::IsIncludeStatement( ByteString aLine ) +{ + ByteString aRetStr; + if ( aLine.Search("/*",0) != STRING_NOTFOUND ) + { +#ifdef DEBUG_VERBOSE + fprintf( stderr, "found starting C comment : %s\n", aLine.GetBuffer() ); +#endif + aLine.Erase(aLine.Search("/*",0), aLine.Len() - 1); +#ifdef DEBUG_VERBOSE + fprintf( stderr, "cleaned string : %s\n", aLine.GetBuffer() ); +#endif + } + if ( aLine.Search("//",0) != STRING_NOTFOUND ) + { +#ifdef DEBUG_VERBOSE + fprintf( stderr, "found C++ comment : %s\n", aLine.GetBuffer() ); +#endif + aLine.Erase(aLine.Search("//",0), aLine.Len() - 1); +#ifdef DEBUG_VERBOSE + fprintf( stderr, "cleaned string : %s\n", aLine.GetBuffer() ); +#endif + } + // WhiteSpacesfressen + aLine.EraseAllChars(' '); + aLine.EraseAllChars('\t'); +#ifdef DEBUG_VERBOSE + fprintf( stderr, "now : %s\n", aLine.GetBuffer() ); +#endif + // ist der erste Teil ein #include ? + ByteString aTmpStr; + aTmpStr = aLine.Copy( 0, 8 ); +#ifdef DEBUG_VERBOSE + fprintf( stderr, "is include : %s\n", aTmpStr.GetBuffer() ); +#endif + if ( aTmpStr.Equals("#include") ) + { + aTmpStr = aLine.Erase( 0, 8 ); + sal_uInt16 nLen = aLine.Len(); + aLine.Erase( nLen-1, 1 ); + aLine.Erase( 0, 1 ); +#ifdef DEBUG_VERBOSE + fprintf( stderr, "Gotcha : %s\n", aLine.GetBuffer() ); +#endif + aRetStr = aLine; + } + return aRetStr; +} + +#ifdef TEST + +int main( int argc, char **argv ) +{ + CppDep *pDep = new CppDep( "cppdep.cxx" ); + pDep->AddSearchPath("."); + pDep->AddSearchPath("/usr/include"); + pDep->AddSearchPath("/usr/local/include"); + pDep->AddSearchPath("/usr/include/sys"); + pDep->AddSearchPath("/usr/include/X11"); + pDep->Execute(); + delete pDep; + return 0; +} + +#endif diff --git a/tools/bootstrp/cppdep.hxx b/tools/bootstrp/cppdep.hxx new file mode 100644 index 000000000000..0744a94d8964 --- /dev/null +++ b/tools/bootstrp/cppdep.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <tools/list.hxx> +#include <tools/string.hxx> +#define PATH_SEP ":" +#define DIR_SEP "/" + +DECLARE_LIST( ByteStringList, ByteString * ) + +class CppDep +{ + ByteString aSourceFile; + ByteStringList *pSearchPath; + +protected: + ByteStringList *pFileList; + ByteStringList *pSources; + + sal_Bool Search( ByteString aFileName ); + ByteString Exists( ByteString aFileName ); + + ByteString IsIncludeStatement( ByteString aLine ); +public: + CppDep( ByteString aFileName ); + CppDep(); + virtual ~CppDep(); + virtual void Execute(); + + ByteStringList* GetDepList(){return pFileList;} + sal_Bool AddSearchPath( const char* aPath ); + sal_Bool AddSource( const char * aSource ); +}; + diff --git a/tools/bootstrp/inimgr.cxx b/tools/bootstrp/inimgr.cxx new file mode 100644 index 000000000000..0907f8f9e102 --- /dev/null +++ b/tools/bootstrp/inimgr.cxx @@ -0,0 +1,210 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" +#if !defined( UNX ) +#include <direct.h> +#else +#include <sys/stat.h> +#endif +#include <stdlib.h> +#include <stdio.h> + + +#include "bootstrp/inimgr.hxx" +#include "bootstrp/appdef.hxx" + +/****************************************************************************/ +IniManager::IniManager( ByteString &rDir, ByteString &rLocalDir ) +/****************************************************************************/ + : bUpdate( sal_True ) +{ + sLocalPath = ByteString( getenv( "LOCALINI" )); + if ( !sLocalPath.Len()) + sLocalPath = rLocalDir; + + sGlobalDir = rDir; +#if !defined( UNX ) && !defined( OS2 ) + mkdir(( char * ) sLocalPath.GetBuffer()); +#else + mkdir( sLocalPath.GetBuffer() ,00777 ); +#endif +} + +/****************************************************************************/ +IniManager::IniManager( ByteString &rDir ) +/****************************************************************************/ + : bUpdate( sal_True ) +{ + sLocalPath = GetLocalIni(); + sGlobalDir = rDir; +#if !defined( UNX ) && !defined( OS2 ) + mkdir(( char * ) sLocalPath.GetBuffer()); +#else + mkdir( sLocalPath.GetBuffer() ,00777 ); +#endif +} + +/****************************************************************************/ +IniManager::IniManager() +/****************************************************************************/ + : bUpdate( sal_True ) +{ + sLocalPath = GetLocalIni(); + +#if !defined( UNX ) && !defined( OS2 ) + mkdir(( char * ) sLocalPath.GetBuffer()); +#else + mkdir( sLocalPath.GetBuffer(), 00777 ); +#endif + + sGlobalDir = GetGlobalIni(); +} + +/****************************************************************************/ +ByteString IniManager::ToLocal( ByteString &rPath ) +/****************************************************************************/ +{ + ByteString sTmp( rPath ); +#if !defined( UNX ) + ByteString sUnc( _INI_UNC ); + sUnc.ToUpperAscii(); + ByteString sOldUnc( _INI_UNC_OLD ); + sOldUnc.ToUpperAscii(); + sTmp.ToUpperAscii(); + + sTmp.SearchAndReplace( sUnc, _INI_DRV ); + sTmp.SearchAndReplace( sOldUnc, _INI_DRV ); + sTmp.ToUpperAscii(); + + ByteString sIni( sGlobalDir ); + sIni.ToUpperAscii(); + + sTmp.SearchAndReplace( sIni, sLocalPath ); + + while ( sTmp.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND ) ; +#else + sTmp.SearchAndReplace( sGlobalDir, sLocalPath ); + + ByteString sOldGlobalDir( GetIniRootOld() ); + sTmp.SearchAndReplace( sOldGlobalDir, sLocalPath ); + + while ( sTmp.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND ) ; +#endif + + return sTmp; +} + +/****************************************************************************/ +ByteString IniManager::GetLocalIni() +/****************************************************************************/ +{ + ByteString sLocalPath = ByteString( getenv( "LOCALINI" )); + + if ( !sLocalPath.Len()) { +#ifdef UNX + ByteString sLocal( getenv( "HOME" )); + sLocal += ByteString( "/localini" ); +#else + ByteString sLocal( getenv( "TMP" )); + sLocal += ByteString( "\\localini" ); +#endif + + sLocalPath = sLocal; + } + + return sLocalPath; +} + +/****************************************************************************/ +ByteString IniManager::GetGlobalIni() +/****************************************************************************/ +{ + ByteString sGlobalPath = ByteString( GetEnv( "GLOBALINI" )); + + if ( !sGlobalPath.Len()) + sGlobalPath = ByteString( _INIROOT ); + + return sGlobalPath; +} + +/****************************************************************************/ +void IniManager::ForceUpdate() +/****************************************************************************/ +{ + UniString sUniGlobalDir( sGlobalDir, gsl_getSystemTextEncoding()); + DirEntry aPath( UniString( sGlobalDir, gsl_getSystemTextEncoding())); + Dir aDir( aPath, FSYS_KIND_DIR | FSYS_KIND_FILE); + +#ifndef UNX + sLocalPath.EraseTrailingChars( '\\' ); + sLocalPath += "\\"; +#else + sLocalPath.EraseTrailingChars( '/' ); + sLocalPath += "/"; +#endif + + for ( sal_uInt16 i=0; i < aDir.Count(); i++ ) { + ByteString sEntry( aDir[i].GetName(), gsl_getSystemTextEncoding()); + if (( sEntry != "." ) && + ( sEntry != ".." )) + { + if ( !FileStat( aDir[i] ).IsKind( FSYS_KIND_DIR )) { + ByteString sSrc( aDir[i].GetFull(), gsl_getSystemTextEncoding()); + ByteString sDestination( sLocalPath ); + sDestination += sEntry; + + UniString sUniDestination( sDestination, gsl_getSystemTextEncoding()); + DirEntry aDestEntry( sUniDestination ); + FileStat aDestStat( aDestEntry ); + FileStat aSrcStat( aDir[i] ); + + if (( !aDestEntry.Exists() ) || + ( aSrcStat.IsYounger( aDestStat ))) + { + FileCopier aFileCopier( aDir[ i ], aDestEntry ); + aFileCopier.Execute(); + + while ( !aDestEntry.Exists()) + aFileCopier.Execute(); + } + } + } + } +} + +/****************************************************************************/ +void IniManager::Update() +/****************************************************************************/ +{ + if ( bUpdate ) + { + ForceUpdate(); + bUpdate = sal_False; + } +} diff --git a/tools/bootstrp/iserver.cxx b/tools/bootstrp/iserver.cxx new file mode 100644 index 000000000000..63b1b333b22f --- /dev/null +++ b/tools/bootstrp/iserver.cxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" +#include <tools/iparser.hxx> +#include <tools/geninfo.hxx> +#include "bootstrp/appdef.hxx" +#include <stdio.h> + + +/*****************************************************************************/ +#ifdef UNX +int main( int argc, char *argv[] ) +#else +int _cdecl main( int argc, char *argv[] ) +#endif +/*****************************************************************************/ +{ + if ( argc == 1 ) { + fprintf( stdout, "\ni_server.exe v2.0 (c) 2000\n\n" ); + fprintf( stdout, "Syntax: i_server -i accesspath [-l] [-d database] \n" ); + fprintf( stdout, "Example: - i_server -i vcl364/settings/now\n" ); + fprintf( stdout, " returns value of settings \"now\" of version \"vcl364\"\n" ); + fprintf( stdout, " - i_server -i vcl364/settings -l\n" ); + fprintf( stdout, " returns a list of all settings of version \"vcl364\"\n" ); + } + else { + sal_Bool bError = sal_False; + sal_Bool bList = sal_False; + ByteString sInfo( "" ); + ByteString sDataBase( GetDefStandList()); + + sal_Bool bGetNow = sal_False; + + int nCount = 1; + while (( nCount < argc ) && + ( !bError )) + { + if ( ByteString( argv[nCount] ).ToUpperAscii() == "-I" ) { + // requestet info path + nCount++; + if( nCount < argc ) { + sInfo = ByteString( argv[nCount] ); + nCount++; + } + else bError = sal_True; + } + else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-D" ) { + // requestet info path + nCount++; + if( nCount < argc ) { + sDataBase = ByteString( argv[nCount] ); + nCount++; + } + else bError = sal_True; + } + else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-L" ) { + // request list of childs + nCount++; + bList = sal_True; + } + else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-N" ) { + // request list of childs + nCount++; + bGetNow = sal_True; + } + else { + bError = sal_True; + } + } + + if ( !bError ) { + InformationParser aParser( REPLACE_VARIABLES ); + ByteString sStandList( sDataBase ); + String s = String( sStandList, gsl_getSystemTextEncoding()); + GenericInformationList *pList = aParser.Execute( s ); + if ( !pList ) + return 1; + + if ( sInfo.Len()) { + GenericInformation *pInfo = pList->GetInfo( sInfo, sal_True ); + + if ( pInfo ) { + ByteString sValue( pInfo->GetValue()); + // show the info and its value + fprintf( stdout, "%s %s\n", pInfo->GetBuffer(), sValue.GetBuffer()); + if ( bList ) { + GenericInformationList *pList = pInfo->GetSubList(); + if ( pList ) { + // show whole list of childs and their values + for( sal_uIntPtr i = 0; i < pList->Count(); i++ ) { + GenericInformation *pInfo = pList->GetObject( i ); + ByteString sValue( pInfo->GetValue()); + fprintf( stdout, " %s %s\n", pInfo->GetBuffer(), sValue.GetBuffer()); + } + } + } + return 0; + } + return 1; + } + else { + // show whole list of childs and their values + for( sal_uIntPtr i = 0; i < pList->Count(); i++ ) { + GenericInformation *pInfo = pList->GetObject( i ); + if ( bGetNow ) { + ByteString sPath( "settings/now" ); + GenericInformation *pSubInfo = pInfo->GetSubInfo( sPath, sal_True ); + if ( pSubInfo && pSubInfo->GetValue() == "_TRUE" ) + fprintf( stdout, "%s\n", pInfo->GetBuffer()); + } + else { + ByteString sValue( pInfo->GetValue()); + fprintf( stdout, " %s %s\n", pInfo->GetBuffer(), sValue.GetBuffer()); + } + } + return 0; + } + } + else + fprintf( stderr, "%s: Fehler in der Kommandozeile!", argv[0] ); + // command line arror !!! + } + + return 1; +} + diff --git a/tools/bootstrp/md5.cxx b/tools/bootstrp/md5.cxx new file mode 100644 index 000000000000..687441c5c511 --- /dev/null +++ b/tools/bootstrp/md5.cxx @@ -0,0 +1,149 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" + +#include "md5.hxx" + +#include <cstddef> +#include <stdio.h> + +#include <tools/string.hxx> + +#ifdef WNT +#define FILE_OPEN_READ "rb" +#else +#define FILE_OPEN_READ "r" +#endif + +// Extended calc_md5_checksum to recognize Windows executables and libraries. To +// create the same md5 checksum for a (code/data) identical file it ignores a different +// date and header checksum. Please see crashrep/source/win32/soreport.cpp +// where the same method is also used. The crash reporter uses the MD5 +// checksums to transfer them to the crash database. You have to make sure that both +// methods use the same algorithm otherwise there could be problems with stack reports. + +void normalize_pe_image(sal_uInt8* buffer, size_t nBufferSize) +{ + const int OFFSET_PE_OFFSET = 0x3c; + const int OFFSET_COFF_TIMEDATESTAMP = 4; + const int PE_SIGNATURE_SIZE = 4; + const int COFFHEADER_SIZE = 20; + const int OFFSET_PE_OPTIONALHEADER_CHECKSUM = 64; + + // Check the header part of the file buffer + if (buffer[0] == sal_uInt8('M') && buffer[1] == sal_uInt8('Z')) + { + unsigned long PEHeaderOffset = (long)buffer[OFFSET_PE_OFFSET]; + if (PEHeaderOffset < nBufferSize-4) + { + if ( buffer[PEHeaderOffset+0] == sal_uInt8('P') && + buffer[PEHeaderOffset+1] == sal_uInt8('E') && + buffer[PEHeaderOffset+2] == 0 && + buffer[PEHeaderOffset+3] == 0 ) + { + PEHeaderOffset += PE_SIGNATURE_SIZE; + if (PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP < nBufferSize-4) + { + // Set timedatestamp and checksum fields to a normalized + // value to enforce the same MD5 checksum for identical + // Windows executables/libraries. + buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+0] = 0; + buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+1] = 0; + buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+2] = 0; + buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+3] = 0; + } + + if (PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM < nBufferSize-4) + { + // Set checksum to a normalized value + buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM] = 0; + buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM+1] = 0; + buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM+2] = 0; + buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM+3] = 0; + } + } + } + } +} + +rtlDigestError calc_md5_checksum( const char *filename, ByteString &aChecksum ) +{ + const size_t BUFFER_SIZE = 0x1000; + const size_t MINIMAL_SIZE = 512; + + sal_uInt8 checksum[RTL_DIGEST_LENGTH_MD5]; + rtlDigestError error = rtl_Digest_E_None; + + FILE *fp = fopen( filename, FILE_OPEN_READ ); + + if ( fp ) + { + rtlDigest digest = rtl_digest_createMD5(); + + if ( digest ) + { + size_t nBytesRead; + sal_uInt8 buffer[BUFFER_SIZE]; + bool bHeader(true); + + while ( rtl_Digest_E_None == error && + 0 != (nBytesRead = fread( buffer, 1, sizeof(buffer), fp )) ) + { + if (bHeader) + { + bHeader = false; + if (nBytesRead >= MINIMAL_SIZE && buffer[0] == sal_uInt8('M') && buffer[1] == sal_uInt8('Z') ) + normalize_pe_image(buffer, nBytesRead); + } + + error = rtl_digest_updateMD5( digest, buffer, nBytesRead ); + } + + if ( rtl_Digest_E_None == error ) + { + error = rtl_digest_getMD5( digest, checksum, sizeof(checksum) ); + } + + rtl_digest_destroyMD5( digest ); + + for ( std::size_t i = 0; i < sizeof(checksum); i++ ) + { + if ( checksum[i] < 16 ) + aChecksum.Append( "0" ); + aChecksum += ByteString::CreateFromInt32( checksum[i], 16 ); + } + } + + fclose( fp ); + } + else + error = rtl_Digest_E_Unknown; + + return error; +} diff --git a/tools/bootstrp/md5.hxx b/tools/bootstrp/md5.hxx new file mode 100644 index 000000000000..55aa97e941c9 --- /dev/null +++ b/tools/bootstrp/md5.hxx @@ -0,0 +1,32 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <rtl/digest.h> +class ByteString; + +rtlDigestError calc_md5_checksum( const char *filename, ByteString &aChecksum ); + diff --git a/tools/bootstrp/mkcreate.cxx b/tools/bootstrp/mkcreate.cxx new file mode 100644 index 000000000000..adf9dde2ddaa --- /dev/null +++ b/tools/bootstrp/mkcreate.cxx @@ -0,0 +1,945 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" + +// global includes +#include <stdio.h> + +// local includes +#include "bootstrp/mkcreate.hxx" +#include "bootstrp/inimgr.hxx" +#include "bootstrp/appdef.hxx" +#include <tools/geninfo.hxx> +#include <tools/iparser.hxx> +#include "bootstrp/prj.hxx" + +char const *NoBuildProject[] = { + "solenv", + "EndOf_NoBuildProject" +}; + +char const *LimitedPath[] = { + "jurt\\com\\sun\\star", + "r_tools", + "ridljar", + "setup2", + "connectivity", + "EndOf_LimitedPath" +}; + +// +// class SourceDirectory +// + +/*****************************************************************************/ +SourceDirectory::SourceDirectory( const ByteString &rDirectoryName, + sal_uInt16 nOperatingSystem, SourceDirectory *pParentDirectory ) +/*****************************************************************************/ + : ByteString( rDirectoryName ), + pParent( pParentDirectory ), + pSubDirectories( NULL ), + nOSType( nOperatingSystem ), + nDepth( 0 ), + pDependencies( NULL ), + pCodedDependencies( NULL ), + pCodedIdentifier( NULL ) +{ + if ( pParent ) { + if ( !pParent->pSubDirectories ) + pParent->pSubDirectories = new SourceDirectoryList(); + pParent->pSubDirectories->InsertSorted( this ); + nDepth = pParent->nDepth + 1; + } +} + +/*****************************************************************************/ +SourceDirectory::~SourceDirectory() +/*****************************************************************************/ +{ + delete pSubDirectories; +} + +/*****************************************************************************/ +CodedDependency *SourceDirectory::AddCodedDependency( + const ByteString &rCodedIdentifier, sal_uInt16 nOperatingSystems ) +/*****************************************************************************/ +{ + CodedDependency *pReturn = NULL; + + if ( !pCodedDependencies ) { + pCodedDependencies = new SByteStringList(); + pReturn = new CodedDependency( rCodedIdentifier, nOperatingSystems ); + pCodedDependencies->PutString(( ByteString * ) pReturn ); + } + else { + sal_uIntPtr nPos = + pCodedDependencies->IsString( (ByteString *) (& rCodedIdentifier) ); + if ( nPos == NOT_THERE ) { + pReturn = + new CodedDependency( rCodedIdentifier, nOperatingSystems ); + pCodedDependencies->PutString(( ByteString * ) pReturn ); + } + else { + pReturn = + ( CodedDependency * ) pCodedDependencies->GetObject( nPos ); + pReturn->TryToMerge( rCodedIdentifier, nOperatingSystems ); + } + } + return pReturn; +} + +/*****************************************************************************/ +CodedDependency *SourceDirectory::AddCodedIdentifier( + const ByteString &rCodedIdentifier, sal_uInt16 nOperatingSystems ) +/*****************************************************************************/ +{ + CodedDependency *pReturn = NULL; + + if ( !pCodedIdentifier ) { + pCodedIdentifier = new SByteStringList(); + pReturn = new CodedDependency( rCodedIdentifier, nOperatingSystems ); + pCodedIdentifier->PutString(( ByteString * ) pReturn ); + } + else { + sal_uIntPtr nPos = + pCodedIdentifier->IsString( ( ByteString *) (& rCodedIdentifier) ); + if ( nPos == NOT_THERE ) { + pReturn = + new CodedDependency( rCodedIdentifier, nOperatingSystems ); + pCodedIdentifier->PutString(( ByteString * ) pReturn ); + } + else { + pReturn = + ( CodedDependency * ) pCodedIdentifier->GetObject( nPos ); + pReturn->TryToMerge( rCodedIdentifier, nOperatingSystems ); + } + } + if ( pParent && pParent->nDepth > 1 ) + pParent->AddCodedIdentifier( rCodedIdentifier, nOperatingSystems ); + + return pReturn; +} + +/*****************************************************************************/ +ByteString SourceDirectory::GetFullPath() +/*****************************************************************************/ +{ + ByteString sFullPath; + if ( pParent ) { + sFullPath = pParent->GetFullPath(); + sFullPath += ByteString( PATH_SEPARATOR ); + } + sFullPath += *this; + + return sFullPath; +} + +/*****************************************************************************/ +SourceDirectory *SourceDirectory::GetRootDirectory() +/*****************************************************************************/ +{ + if ( !pParent ) + return this; + + return pParent->GetRootDirectory(); +} + +/*****************************************************************************/ +SourceDirectory *SourceDirectory::GetSubDirectory( + const ByteString &rDirectoryPath, sal_uInt16 nOperatingSystem ) +/*****************************************************************************/ +{ + ByteString sSearch; + + sal_Bool bSubs = sal_True; + sal_uIntPtr nIndex = 0; + + while ( bSubs && ByteString( LimitedPath[ nIndex ]) != "EndOf_LimitedPath" ) { + SourceDirectory *pActDir = this; + ByteString sLimitation( LimitedPath[ nIndex ]); + + sal_Bool bBreak = sal_False; + for ( sal_uIntPtr i = sLimitation.GetTokenCount( '\\' ); i > 0 && !bBreak; i-- ) { + if (( !pActDir ) || ( *pActDir != sLimitation.GetToken(( sal_uInt16 )( i - 1 ), '\\' ))) + bBreak = sal_True; + else + pActDir = pActDir->pParent; + } + bSubs = bBreak; + nIndex++; + } + + if ( !bSubs ) + { + sSearch = rDirectoryPath; + } + else + sSearch = rDirectoryPath.GetToken( 0, PATH_SEPARATOR ); + + SourceDirectory *pSubDirectory = NULL; + + if ( pSubDirectories ) + pSubDirectory = pSubDirectories->Search( sSearch ); + + if ( !pSubDirectory ) + pSubDirectory = new SourceDirectory( + sSearch, nOperatingSystem, this ); + + pSubDirectory->nOSType |= nOperatingSystem; + + if ( sSearch.Len() == rDirectoryPath.Len()) + return pSubDirectory; + + ByteString sPath = rDirectoryPath.Copy( sSearch.Len() + 1 ); + + return pSubDirectory->GetSubDirectory( sPath, nOperatingSystem ); +} + +/*****************************************************************************/ +SourceDirectory *SourceDirectory::GetDirectory( + const ByteString &rDirectoryName, sal_uInt16 nOperatingSystem ) +/*****************************************************************************/ +{ + ByteString sDirectoryName( rDirectoryName ); +#ifdef UNX + sDirectoryName.SearchAndReplaceAll( "\\", "/" ); +#endif + + SourceDirectory *pRoot = GetRootDirectory(); + + if ( sDirectoryName.Search( *pRoot ) != 0 ) + return NULL; + + if ( sDirectoryName.Len() == pRoot->Len()) + return pRoot; + + if ( sDirectoryName.GetChar( pRoot->Len()) == PATH_SEPARATOR ) { + ByteString sSub = sDirectoryName.Copy( pRoot->Len() + 1 ); + return pRoot->GetSubDirectory( sSub, nOperatingSystem ); + } + + return NULL; +} + +/*****************************************************************************/ +SourceDirectory *SourceDirectory::Insert( const ByteString &rDirectoryName, + sal_uInt16 nOperatingSystem ) +/*****************************************************************************/ +{ + SourceDirectory *pSubDirectory = NULL; + if ( pSubDirectories ) + pSubDirectory = pSubDirectories->Search( rDirectoryName ); + + if ( !pSubDirectory ) + pSubDirectory = new SourceDirectory( + rDirectoryName, nOperatingSystem, this ); + + return pSubDirectory; +} + +/*****************************************************************************/ +Dependency *SourceDirectory::ResolvesDependency( + CodedDependency *pCodedDependency ) +/*****************************************************************************/ +{ + if ( !pCodedIdentifier ) + return NULL; + + sal_uIntPtr nPos = pCodedIdentifier->IsString( pCodedDependency ); + if ( nPos != NOT_THERE ) { + CodedDependency *pIdentifier = + ( CodedDependency * ) pCodedIdentifier->GetObject( nPos ); + sal_uInt16 nResult = + pIdentifier->GetOperatingSystem() & + pCodedDependency->GetOperatingSystem(); + Dependency *pReturn = new Dependency( *this, nResult ); + nResult ^= pCodedDependency->GetOperatingSystem(); + pCodedDependency->SetOperatingSystem( nResult ); + return pReturn; + } + return NULL; +} + + +/*****************************************************************************/ +void SourceDirectory::ResolveDependencies() +/*****************************************************************************/ +{ + if ( !pSubDirectories ) + return; + + for ( sal_uIntPtr i = 0; i < pSubDirectories->Count(); i++ ) { + SourceDirectory *pActDirectory = + ( SourceDirectory * ) pSubDirectories->GetObject( i ); + if ( pActDirectory->pSubDirectories ) + pActDirectory->ResolveDependencies(); + + if ( pActDirectory->pCodedDependencies ) { + while ( pActDirectory->pCodedDependencies->Count()) + { + CodedDependency *pCodedDependency = ( CodedDependency * ) + pActDirectory->pCodedDependencies->GetObject(( sal_uIntPtr ) 0 ); + + for ( + sal_uIntPtr k = 0; + ( k < pSubDirectories->Count()) && + ( pCodedDependency->GetOperatingSystem() != OS_NONE ); + k++ + ) { + Dependency *pDependency = + ((SourceDirectory *) pSubDirectories->GetObject( k ))-> + ResolvesDependency( pCodedDependency ); + if ( pDependency ) + { + if ( !pActDirectory->pDependencies ) + pActDirectory->pDependencies = new SByteStringList(); + pActDirectory->pDependencies->PutString( pDependency ); + } + } + if ( pCodedDependency->GetOperatingSystem()) { + if ( !pCodedDependencies ) + pCodedDependencies = new SByteStringList(); + pCodedDependencies->PutString( pCodedDependency ); + } + else + delete pCodedDependency; + pActDirectory->pCodedDependencies->Remove(( sal_uIntPtr ) 0 ); + } + } + } +} + +/*****************************************************************************/ +ByteString SourceDirectory::GetTarget() +/*****************************************************************************/ +{ + ByteString sReturn; + + if ( !pDependencies ) + return sReturn; + + sal_uIntPtr k = 0; + while ( k < pDependencies->Count()) { + if ( *this == *pDependencies->GetObject( k )) + delete pDependencies->Remove( k ); + else + k++; + } + + if ( !pDependencies->Count()) { + delete pDependencies; + pDependencies = NULL; + return sReturn; + } + + sal_Bool bDependsOnPlatform = sal_False; + for ( sal_uIntPtr i = 0; i < pDependencies->Count(); i++ ) + if ((( Dependency * ) pDependencies->GetObject( i ))-> + GetOperatingSystem() != OS_ALL ) + bDependsOnPlatform = sal_True; + + ByteString sTarget( *this ); + sTarget.SearchAndReplaceAll( "\\", "$/" ); + if ( !bDependsOnPlatform ) { + sReturn = sTarget; + sReturn += " :"; + for ( sal_uIntPtr i = 0; i < pDependencies->Count(); i++ ) { + ByteString sDependency( *pDependencies->GetObject( i )); + sDependency.SearchAndReplaceAll( "\\", "$/" ); + sReturn += " "; + sReturn += sDependency; + } + } + else { + ByteString sUNX( ".IF \"$(GUI)\" == \"UNX\"\n" ); + sUNX += sTarget; + sUNX += " :"; + sal_Bool bUNX = sal_False; + + ByteString sWNT( ".IF \"$(GUI)\" == \"WNT\"\n" ); + sWNT += sTarget; + sWNT += " :"; + sal_Bool bWNT = sal_False; + + ByteString sOS2( ".IF \"$(GUI)\" == \"OS2\"\n" ); + sOS2 += sTarget; + sOS2 += " :"; + sal_Bool bOS2 = sal_False; + + for ( sal_uIntPtr i = 0; i < pDependencies->Count(); i++ ) { + Dependency *pDependency = + ( Dependency * ) pDependencies->GetObject( i ); + ByteString sDependency( *pDependency ); + sDependency.SearchAndReplaceAll( "\\", "$/" ); + + if ( pDependency->GetOperatingSystem() & OS_UNX ) { + sUNX += " "; + sUNX += sDependency; + bUNX = sal_True; + } + if ( pDependency->GetOperatingSystem() & OS_WIN32 ) { + sWNT += " "; + sWNT += sDependency; + bWNT = sal_True; + } + if ( pDependency->GetOperatingSystem() & OS_OS2 ) { + sOS2 += " "; + sOS2 += sDependency; + bOS2 = sal_True; + } + } + + if ( bUNX ) { + sReturn += sUNX; + sReturn += "\n.ENDIF\n"; + } + if ( bWNT ) { + sReturn += sWNT; + sReturn += "\n.ENDIF\n"; + } + if ( bOS2 ) { + sReturn += sOS2; + sReturn += "\n.ENDIF\n"; + } + } + sReturn.EraseTrailingChars( '\n' ); + return sReturn; +} + +/*****************************************************************************/ +ByteString SourceDirectory::GetSubDirsTarget() +/*****************************************************************************/ +{ + ByteString sReturn; + + if ( pSubDirectories ) { + sal_Bool bDependsOnPlatform = sal_False; + for ( sal_uIntPtr i = 0; i < pSubDirectories->Count(); i++ ) + if ((( SourceDirectory * ) pSubDirectories->GetObject( i ))-> + GetOperatingSystems() != OS_ALL ) + bDependsOnPlatform = sal_True; + + if ( !bDependsOnPlatform ) { + sReturn = "RC_SUBDIRS = "; + + for ( sal_uIntPtr i = 0; i < pSubDirectories->Count(); i++ ) { + ByteString sSubDirectory( *pSubDirectories->GetObject( i )); + sSubDirectory.SearchAndReplaceAll( "\\", "$/" ); + sReturn += " \\\n\t"; + sReturn += sSubDirectory; + } + sReturn += "\n"; + } + else { + ByteString sUNX( ".IF \"$(GUI)\" == \"UNX\"\n" ); + sUNX += "RC_SUBDIRS = "; + sal_Bool bUNX = sal_False; + + ByteString sWNT( ".IF \"$(GUI)\" == \"WNT\"\n" ); + sWNT += "RC_SUBDIRS = "; + sal_Bool bWNT = sal_False; + + ByteString sOS2( ".IF \"$(GUI)\" == \"OS2\"\n" ); + sOS2 += "RC_SUBDIRS = "; + sal_Bool bOS2 = sal_False; + + for ( sal_uIntPtr i = 0; i < pSubDirectories->Count(); i++ ) { + SourceDirectory *pDirectory = + ( SourceDirectory * ) pSubDirectories->GetObject( i ); + ByteString sDirectory( *pDirectory ); + sDirectory.SearchAndReplaceAll( "\\", "$/" ); + + if ( pDirectory->GetOperatingSystems() & OS_UNX ) { + sUNX += " \\\n\t"; + sUNX += sDirectory; + bUNX = sal_True; + } + if ( pDirectory->GetOperatingSystems() & OS_WIN32 ) { + sWNT += " \\\n\t"; + sWNT += sDirectory; + bWNT = sal_True; + } + if ( pDirectory->GetOperatingSystems() & OS_OS2 ) { + sOS2 += " \\\n\t"; + sOS2 += sDirectory; + bOS2 = sal_True; + } + } + if ( bUNX ) { + sReturn += sUNX; + sReturn += "\n.ENDIF\n"; + } + if ( bWNT ) { + sReturn += sWNT; + sReturn += "\n.ENDIF\n"; + } + if ( bOS2 ) { + sReturn += sOS2; + sReturn += "\n.ENDIF\n"; + } + } + } + return sReturn; +} + +/*****************************************************************************/ +sal_uInt16 SourceDirectory::GetOSType( const ByteString &sDependExt ) +/*****************************************************************************/ +{ + sal_uInt16 nOSType = 0; + if ( sDependExt == "" ) + nOSType |= OS_ALL; + else if ( sDependExt == "N" || sDependExt == "W" ) + nOSType |= OS_WIN32; + else if ( sDependExt == "U" ) + nOSType |= OS_UNX; + else if ( sDependExt == "P" ) + nOSType |= OS_OS2; + return nOSType; +} + +/*****************************************************************************/ +SourceDirectory *SourceDirectory::CreateRootDirectory( + const ByteString &rRoot, const ByteString &rVersion, sal_Bool bAll ) +/*****************************************************************************/ +{ + IniManager aIniManager; + aIniManager.Update(); + + ByteString sDefLst( GetDefStandList()); + ByteString sStandLst( aIniManager.ToLocal( sDefLst )); + String s = String( sStandLst, gsl_getSystemTextEncoding()); + InformationParser aParser; +// fprintf( stderr, +// "Reading database %s ...\n", sStandLst.GetBuffer()); + GenericInformationList *pVerList = aParser.Execute( + s ); + +/* + ByteString sPath( rVersion ); +#ifndef UNX + sPath += ByteString( "/settings/solarlist" ); +#else + sPath += ByteString( "/settings/unxsolarlist" ); +#endif + ByteString sSolarList( _SOLARLIST ); + + GenericInformation *pInfo = pVerList->GetInfo( sPath, sal_True ); + if ( pInfo ) { + ByteString aIniRoot( GetIniRoot() ); + DirEntry aIniEntry( String( aIniRoot, RTL_TEXTENCODING_ASCII_US )); + aIniEntry += DirEntry( String( pInfo->GetValue(), RTL_TEXTENCODING_ASCII_US )).GetBase( PATH_SEPARATOR ); + sSolarList = ByteString( aIniEntry.GetFull(), RTL_TEXTENCODING_ASCII_US ); + } + + sSolarList = aIniManager.ToLocal( sSolarList ); + fprintf( stderr, + "Reading directory information %s ...\n", sSolarList.GetBuffer()); +*/ + + ByteString sVersion( rVersion ); + Star aStar( pVerList, sVersion, sal_True, rRoot.GetBuffer()); +// fprintf( stderr, +// "Creating virtual directory tree ...\n" ); + + + SourceDirectory *pSourceRoot = new SourceDirectory( rRoot, OS_ALL ); + + for ( sal_uIntPtr i = 0; i < aStar.Count(); i++ ) { + Prj *pPrj = aStar.GetObject( i ); + + sal_Bool bBuildable = sal_True; + sal_uIntPtr nIndex = 0; + + while ( bBuildable && ByteString( NoBuildProject[ nIndex ]) != "EndOf_NoBuildProject" ) { + bBuildable = ( ByteString( NoBuildProject[ nIndex ]) != pPrj->GetProjectName()); + nIndex ++; + } + + if ( bBuildable ) { + SourceDirectory *pProject = pSourceRoot->Insert( pPrj->GetProjectName(), OS_ALL ); + + SByteStringList *pPrjDependencies = pPrj->GetDependencies( sal_False ); + if ( pPrjDependencies ) + for ( sal_uIntPtr x = 0; x < pPrjDependencies->Count(); x++ ) + pProject->AddCodedDependency( *pPrjDependencies->GetObject( x ), OS_ALL ); + + pProject->AddCodedIdentifier( pPrj->GetProjectName(), OS_ALL ); + + for ( sal_uIntPtr j = 0; j < pPrj->Count(); j++ ) { + CommandData *pData = pPrj->GetObject( j ); + if ( bAll || ( pData->GetCommandType() == COMMAND_NMAKE )) { + ByteString sDirPath( rRoot ); + sDirPath += ByteString( PATH_SEPARATOR ); + sDirPath += pData->GetPath(); + SourceDirectory *pDirectory = + pSourceRoot->InsertFull( sDirPath, pData->GetOSType()); + SByteStringList *pDependencies = pData->GetDependencies(); + if ( pDependencies ) { + for ( sal_uIntPtr k = 0; k < pDependencies->Count(); k++ ) { + ByteString sDependency(*pDependencies->GetObject( k )); + ByteString sDependExt(sDependency.GetToken( 1, '.' )); + sDependExt.ToUpperAscii(); + pDirectory->AddCodedDependency( + sDependency.GetToken( 0, '.' ), GetOSType( sDependExt )); + } + } + ByteString sIdentifier = pData->GetLogFile(); + ByteString sIdExt = sIdentifier.GetToken( 1, '.' ); + sIdExt.ToUpperAscii(); + pDirectory->AddCodedIdentifier( sIdentifier.GetToken( 0, '.' ), GetOSType( sIdExt )); + } + } + } + } + delete pVerList; + return pSourceRoot; +} + +/*****************************************************************************/ +sal_Bool SourceDirectory::RemoveDirectoryTreeAndAllDependencies() +/*****************************************************************************/ +{ + if ( !pParent ) + return sal_False; + + SourceDirectoryList *pParentContent = pParent->pSubDirectories; + sal_uIntPtr i = 0; + while ( i < pParentContent->Count()) { + SourceDirectory *pCandidate = + ( SourceDirectory * )pParentContent->GetObject( i ); + if ( pCandidate == this ) { + pParentContent->Remove( i ); + } + else { + if ( pCandidate->pDependencies ) { + sal_uIntPtr nPos = pCandidate->pDependencies->IsString( this ); + if ( nPos != NOT_THERE ) + delete pCandidate->pDependencies->Remove( nPos ); + } + i++; + } + } + delete this; + return sal_True; +} + +/*****************************************************************************/ +sal_Bool SourceDirectory::CreateRecursiveMakefile( sal_Bool bAllChilds ) +/*****************************************************************************/ +{ + if ( !pSubDirectories ) + return sal_True; + + fprintf( stdout, "%s", GetFullPath().GetBuffer()); + + String aTmpStr( GetFullPath(), gsl_getSystemTextEncoding()); + DirEntry aEntry( aTmpStr ); + if ( !aEntry.Exists()) { + fprintf( stdout, " ... no directory!n" ); + return sal_False; + } + + sal_uIntPtr j = 0; + while( j < pSubDirectories->Count()) { + String sSubDirectory( + (( SourceDirectory * ) pSubDirectories->GetObject( j ))-> + GetFullPath(), + gsl_getSystemTextEncoding() + ); + DirEntry aSubDirectory( sSubDirectory ); + if ( !aSubDirectory.Exists()) + (( SourceDirectory * ) pSubDirectories->GetObject( j ))-> + RemoveDirectoryTreeAndAllDependencies(); + else + j++; + } + + DirEntry aRCFile( String( "makefile.rc", gsl_getSystemTextEncoding())); + DirEntry aRCEntry( aEntry ); + aRCEntry += aRCFile; + + DirEntry aMKFile( String( "makefile.mk", gsl_getSystemTextEncoding())); + DirEntry aMKEntry( aEntry ); + aMKEntry += aMKFile; + + sal_Bool bMakefileMk = sal_False; + if ( aMKEntry.Exists()) { + if ( nDepth == 1 && *this == ByteString( "api" )) + fprintf( stdout, " ... makefile.mk exists, ignoring (hack: prj == api)!" ); + else { + fprintf( stdout, " ... makefile.mk exists, including!" ); + bMakefileMk = sal_True; + } + } + + SvFileStream aMakefile( aRCEntry.GetFull(), STREAM_STD_WRITE | STREAM_TRUNC ); + if ( !aMakefile.IsOpen()) { + fprintf( stdout, " ... failed!\n" ); + return sal_False; + } + + ByteString sHeader( + "#*************************************************************************\n" + "#\n" + "# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n" + "#\n" + "# Copyright 2000, 2010 Oracle and/or its affiliates.\n" + "#\n" + "# OpenOffice.org - a multi-platform office productivity suite\n" + "#\n" + "# This file is part of OpenOffice.org.\n" + "#\n" + "# OpenOffice.org is free software: you can redistribute it and/or modify\n" + "# it under the terms of the GNU Lesser General Public License version 3\n" + "# only, as published by the Free Software Foundation.\n" + "#\n" + "# OpenOffice.org is distributed in the hope that it will be useful,\n" + "# but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "# GNU Lesser General Public License version 3 for more details\n" + "# (a copy is included in the LICENSE file that accompanied this code).\n" + "#\n" + "# You should have received a copy of the GNU Lesser General Public License\n" + "# version 3 along with OpenOffice.org. If not, see\n" + "# <http://www.openoffice.org/license.html>\n" + "# for a copy of the LGPLv3 License.\n" + "#\n" + "#*************************************************************************\n" + "\n" + ); + if ( !bMakefileMk ) { + if ( nDepth == 0 ) { + sHeader += ByteString( + "\n" + "# \n" + "# mark this makefile as a recursive one\n" + "# \n" + "\n" + "MAKEFILERC=yes\n" + "\n" + "# \n" + "# implementation of cvs checkout\n" + "# \n" + "\n" + ".IF \"$(checkout)\"==\"\"\n" + "all_target: ALLTAR\n" + ".ELSE\t# \"$(checkout)\"==\"\"\n" + ".IF \"$(checkout)\"==\"true\"\n" + "% : $(NULL)\n" + "\t_cvs co $@\n" + ".ELSE\t# \"$(checkout)\"==\"true\"\n" + "% : $(NULL)\n" + "\t_cvs co -r$(checkout) $@\n" + ".ENDIF\t# \"$(checkout)\"==\"true\"\n" + "all_subdirs : $(RC_SUBDIRS)\n" + ".ENDIF\t# \"$(checkout)\"==\"\"\n" + ); + } + else { + sHeader += ByteString( + "\n" + "# \n" + "# mark this makefile as a recursive one\n" + "# \n" + "\n" + "MAKEFILERC=yes\n" + ); + if ( nDepth == 1 ) + sHeader += ByteString( + ".IF \"$(build_deliver)\"==\"true\"\n" + "all_target:\t\t\\\n" + "\tTG_DELIVER\t\\\n" + "\tALLTAR\n" + ".ELSE # \"$(build_deliver)\"==\"true\"\n" + "all_target: ALLTAR\n" + ".ENDIF # \"$(build_deliver)\"==\"true\"\n" + ); + else + sHeader += ByteString( + "all_target: ALLTAR\n" + ); + } + } + else { + if ( nDepth == 1 ) + sHeader += ByteString( + ".IF \"$(build_deliver)\"==\"true\"\n" + "all_target:\t\t\\\n" + "\tTG_DELIVER\t\\\n" + "\tALLTAR\n" + ".ELSE # \"$(build_deliver)\"==\"true\"\n" + "all_target: ALLTAR\n" + ".ENDIF # \"$(build_deliver)\"==\"true\"\n" + ); + } + sHeader += ByteString( + "\n" + "# \n" + "# macro RC_SUBDIRS handles iteration over\n" + "# all mandatory sub directories\n" + "# \n" + ); + + aMakefile.WriteLine( sHeader ); + aMakefile.WriteLine( GetSubDirsTarget()); + + if ( nDepth == 0 ) { + ByteString sBootstrapTarget( + "# \n" + "# bootstrap target\n" + "# \n\n" + "bootstrap .PHONY :\n" + "\t@config_office/bootstrap\n\n" + ); + aMakefile.WriteLine( sBootstrapTarget ); + ByteString sConfigureTarget( + "# \n" + "# configure target\n" + "# \n\n" + "configure .PHONY SETDIR=config_office :\n" + "\t@configure\n" + ); + aMakefile.WriteLine( sConfigureTarget ); + } + else if ( nDepth == 1 ) { + ByteString sDeliverTarget( + "# \n" + "# deliver target to handle\n" + "# project dependencies\n" + "# \n\n" + "TG_DELIVER : $(RC_SUBDIRS)\n" + "\t$(DELIVER)\n" + ); + aMakefile.WriteLine( sDeliverTarget ); + } + + if ( bMakefileMk ) { + ByteString sInclude( + "# \n" + "# local makefile\n" + "# \n" + "\n" + ".INCLUDE : makefile.mk\n" + ); + + if ( nDepth != 1 ) + sInclude += ByteString( + "\n" + "all_rc_target: ALLTAR\n" + ); + + aMakefile.WriteLine( sInclude ); + } + + ByteString sComment( + "# \n" + "# single directory targets for\n" + "# dependency handling between directories\n" + "# \n" + ); + aMakefile.WriteLine( sComment ); + + for ( sal_uIntPtr i = 0; i < pSubDirectories->Count(); i++ ) { + ByteString sTarget( + (( SourceDirectory * )pSubDirectories->GetObject( i ))-> + GetTarget() + ); + if ( sTarget.Len()) + aMakefile.WriteLine( sTarget ); + } + + ByteString sFooter( + "\n" + ); + if ( !bMakefileMk ) { + sFooter += ByteString( + "# \n" + "# central target makefile\n" + "# \n" + "\n" + ); + if ( nDepth != 0 ) { + sFooter += ByteString( + ".INCLUDE : target.mk\n" + ); + } + else { + sFooter += ByteString( + ".IF \"$(checkout)\"==\"\"\n" + ".INCLUDE : target.mk\n" + ".ENDIF\t#\"$(checkout)\"==\"\"\n" + ); + } + } + sFooter += ByteString( + "\n" + "#*************************************************************************\n" + ); + aMakefile.WriteLine( sFooter ); + + aMakefile.Close(); + + fprintf( stdout, "\n" ); + + sal_Bool bSuccess = sal_True; + if ( bAllChilds ) + for ( sal_uIntPtr k = 0; k < pSubDirectories->Count(); k++ ) + if ( !(( SourceDirectory * ) pSubDirectories->GetObject( k ))-> + CreateRecursiveMakefile( sal_True )) + bSuccess = sal_False; + + return bSuccess; +} + +// +// class SourceDirectoryList +// + +/*****************************************************************************/ +SourceDirectoryList::~SourceDirectoryList() +/*****************************************************************************/ +{ + for ( sal_uIntPtr i = 0; i < Count(); i++ ) + delete GetObject( i ); +} + +/*****************************************************************************/ +SourceDirectory *SourceDirectoryList::Search( + const ByteString &rDirectoryName ) +/*****************************************************************************/ +{ + sal_uIntPtr nPos = IsString( ( ByteString * ) (&rDirectoryName) ); + if ( nPos != LIST_ENTRY_NOTFOUND ) + return ( SourceDirectory * ) GetObject( nPos ); + + return NULL; +} + + diff --git a/tools/bootstrp/prj.cxx b/tools/bootstrp/prj.cxx new file mode 100644 index 000000000000..b4dee65f9673 --- /dev/null +++ b/tools/bootstrp/prj.cxx @@ -0,0 +1,171 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" +#include <stdlib.h> +#include <stdio.h> +//#include "bootstrp/sstring.hxx" +#include <vos/mutex.hxx> + +#include <tools/stream.hxx> +#include <tools/geninfo.hxx> +#include "bootstrp/prj.hxx" +#include "bootstrp/inimgr.hxx" + +DECLARE_LIST( UniStringList, UniString* ) + +//#define TEST 1 + +#if defined(WNT) || defined(OS2) +#define LIST_DELIMETER ';' +#define PATH_DELIMETER '\\' +#elif defined UNX +#define LIST_DELIMETER ':' +#define PATH_DELIMETER '/' +#endif + +//Link Star::aDBNotFoundHdl; + +// +// class SimpleConfig +// + +/*****************************************************************************/ +SimpleConfig::SimpleConfig( String aSimpleConfigFileName ) +/*****************************************************************************/ +{ + nLine = 0; + aFileName = aSimpleConfigFileName; + aFileStream.Open ( aFileName, STREAM_READ ); +} + +/*****************************************************************************/ +SimpleConfig::SimpleConfig( DirEntry& rDirEntry ) +/*****************************************************************************/ +{ + nLine = 0; + aFileName = rDirEntry.GetFull(); + aFileStream.Open ( aFileName, STREAM_READ ); +} + +/*****************************************************************************/ +SimpleConfig::~SimpleConfig() +/*****************************************************************************/ +{ + aFileStream.Close (); +} + +/*****************************************************************************/ +ByteString SimpleConfig::GetNext() +/*****************************************************************************/ +{ + ByteString aString; + + if ( aStringBuffer =="" ) + while ((aStringBuffer = GetNextLine()) == "\t") ; //solange bis != "\t" + if ( aStringBuffer =="" ) + return ByteString(); + + aString = aStringBuffer.GetToken(0,'\t'); + aStringBuffer.Erase(0, aString.Len()+1); + + aStringBuffer.EraseLeadingChars( '\t' ); + + return aString; +} + +/*****************************************************************************/ +ByteString SimpleConfig::GetNextLine() +/*****************************************************************************/ +{ + ByteString aSecStr; + nLine++; + + aFileStream.ReadLine ( aTmpStr ); + if ( aTmpStr.Search( "#" ) == 0 ) + return "\t"; + aTmpStr = aTmpStr.EraseLeadingChars(); + aTmpStr = aTmpStr.EraseTrailingChars(); + while ( aTmpStr.SearchAndReplace(ByteString(' '),ByteString('\t') ) != STRING_NOTFOUND ) ; + int nLength = aTmpStr.Len(); + sal_Bool bFound = sal_False; + ByteString aEraseString; + for ( sal_uInt16 i = 0; i<= nLength; i++) + { + if ( aTmpStr.GetChar( i ) == 0x20 && !bFound ) + aTmpStr.SetChar( i, 0x09 ); + } + return aTmpStr; +} + +/*****************************************************************************/ +ByteString SimpleConfig::GetCleanedNextLine( sal_Bool bReadComments ) +/*****************************************************************************/ +{ + + aFileStream.ReadLine ( aTmpStr ); + if ( aTmpStr.Search( "#" ) == 0 ) + { + if (bReadComments ) + return aTmpStr; + else + while ( aTmpStr.Search( "#" ) == 0 ) + { + aFileStream.ReadLine ( aTmpStr ); + } + } + + aTmpStr = aTmpStr.EraseLeadingChars(); + aTmpStr = aTmpStr.EraseTrailingChars(); +// while ( aTmpStr.SearchAndReplace(String(' '),String('\t') ) != (sal_uInt16)-1 ); + int nLength = aTmpStr.Len(); + ByteString aEraseString; + sal_Bool bFirstTab = sal_True; + for ( sal_uInt16 i = 0; i<= nLength; i++) + { + if ( aTmpStr.GetChar( i ) == 0x20 ) + aTmpStr.SetChar( i, 0x09 ); + + if ( aTmpStr.GetChar( i ) == 0x09 ) + { + if ( bFirstTab ) + bFirstTab = sal_False; + else + { + aTmpStr.SetChar( i, 0x20 ); + } + } + else + bFirstTab = sal_True; + + } + aTmpStr.EraseAllChars(' '); + return aTmpStr; + +} + diff --git a/tools/bootstrp/rscdep.cxx b/tools/bootstrp/rscdep.cxx new file mode 100644 index 000000000000..7bcf036f6fa4 --- /dev/null +++ b/tools/bootstrp/rscdep.cxx @@ -0,0 +1,299 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" +#ifdef UNX +#include <unistd.h> +#endif + +#include <sys/stat.h> +#include <stdio.h> +#include <string.h> + +#include "bootstrp/prj.hxx" +#include "sal/main.h" + +#include <tools/string.hxx> +#include <tools/list.hxx> +#include <tools/fsys.hxx> +#include <tools/stream.hxx> + +#include "cppdep.hxx" + +#if defined WNT +#if !defined HAVE_GETOPT +#define __STDC__ 1 +#define __GNU_LIBRARY__ +#include <external/glibc/getopt.h> +#else +#include <getopt.h> +#endif +#endif + +class RscHrcDep : public CppDep +{ +public: + RscHrcDep(); + virtual ~RscHrcDep(); + + virtual void Execute(); +}; + +RscHrcDep::RscHrcDep() : + CppDep() +{ +} + +RscHrcDep::~RscHrcDep() +{ +} + +void RscHrcDep::Execute() +{ + CppDep::Execute(); +} + +//static String aDelim; + +int main( int argc, char** argv ) +{ + int c; + char aBuf[255]; + char pFileNamePrefix[255]; + char pOutputFileName[255]; + char pSrsFileName[255]; + String aSrsBaseName; + sal_Bool bSource = sal_False; + ByteString aRespArg; +// who needs anything but '/' ? +// String aDelim = String(DirEntry::GetAccessDelimiter()); + String aDelim = '/'; + + RscHrcDep *pDep = new RscHrcDep; + + pOutputFileName[0] = 0; + pSrsFileName[0] = 0; + + for ( int i=1; i<argc; i++) + { + strcpy( aBuf, (const char *)argv[i] ); + if ( aBuf[0] == '-' && aBuf[1] == 'p' && aBuf[2] == '=' ) + { + strcpy(pFileNamePrefix, &aBuf[3]); + //break; + } + if ( aBuf[0] == '-' && aBuf[1] == 'f' && aBuf[2] == 'o' && aBuf[3] == '=' ) + { + strcpy(pOutputFileName, &aBuf[4]); + //break; + } + if ( aBuf[0] == '-' && aBuf[1] == 'f' && aBuf[2] == 'p' && aBuf[3] == '=' ) + { + strcpy(pSrsFileName, &aBuf[4]); + String aName( pSrsFileName, gsl_getSystemTextEncoding()); + DirEntry aDest( aName ); + aSrsBaseName = aDest.GetBase(); + //break; + } + if (aBuf[0] == '-' && aBuf[1] == 'i' ) + { + //printf("Include : %s\n", &aBuf[2] ); + pDep->AddSearchPath( &aBuf[2] ); + } + if (aBuf[0] == '-' && aBuf[1] == 'I' ) + { + //printf("Include : %s\n", &aBuf[2] ); + pDep->AddSearchPath( &aBuf[2] ); + } + if (aBuf[0] == '@' ) + { + ByteString aToken; + String aRespName( &aBuf[1], gsl_getSystemTextEncoding()); + SimpleConfig aConfig( aRespName ); + while ( (aToken = aConfig.GetNext()) != "") + { + char aBuf2[255]; + (void) strcpy( aBuf2, aToken.GetBuffer()); + if ( aBuf[0] == '-' && aBuf[1] == 'p' && aBuf[2] == '=' ) + { + strcpy(pFileNamePrefix, &aBuf[3]); + //break; + } + if ( aBuf2[0] == '-' && aBuf2[1] == 'f' && aBuf2[2] == 'o' ) + { + strcpy(pOutputFileName, &aBuf2[3]); + //break; + } + if ( aBuf2[0] == '-' && aBuf2[1] == 'f' && aBuf2[2] == 'p' ) + { + strcpy(pSrsFileName, &aBuf2[3]); + String aName( pSrsFileName, gsl_getSystemTextEncoding()); + DirEntry aDest( aName ); + aSrsBaseName = aDest.GetBase(); + //break; + } + if (aBuf2[0] == '-' && aBuf2[1] == 'i' ) + { + //printf("Include : %s\n", &aBuf[2] ); + pDep->AddSearchPath( &aBuf2[2] ); + } + if (aBuf2[0] == '-' && aBuf2[1] == 'I' ) + { + //printf("Include : %s\n", &aBuf[2] ); + pDep->AddSearchPath( &aBuf2[2] ); + } + if (( aBuf2[0] != '-' ) && ( aBuf2[0] != '@' )) + { + pDep->AddSource( &aBuf2[0] ); + aRespArg += " "; + aRespArg += &aBuf2[0]; + bSource = sal_True; + } + } + } + } + + while( 1 ) + { + c = getopt( argc, argv, + "_abcdefghi:jklmnopqrstuvwxyzABCDEFGHI:JKLMNOPQRSTUVWXYZ1234567890/-+=.\\()\""); + if ( c == -1 ) + break; + + switch( c ) + { + case 0: + break; + case 'a' : +#ifdef DEBUG_VERBOSE + printf("option a\n"); +#endif + break; + + case 'l' : +#ifdef DEBUG_VERBOSE + printf("option l with Value %s\n", optarg ); +#endif + pDep->AddSource( optarg ); + break; + + case 'h' : + case 'H' : + case '?' : + printf("RscDep 1.0\n"); + break; + + default: +#ifdef DEBUG_VERBOSE + printf("Unknown getopt error\n"); +#endif + ; + } + } + + + DirEntry aEntry("."); + aEntry.ToAbs(); +// String aCwd = aEntry.GetName(); + String aCwd(pFileNamePrefix, gsl_getSystemTextEncoding()); +/* sal_uInt16 nPos; +#ifndef UNX + while ( (nPos = aCwd.Search('\\') != STRING_NOTFOUND )) +#else + while ( (nPos = aCwd.Search('/') != STRING_NOTFOUND )) +#endif + { + String attt = aCwd.Copy( 0, nPos ); + aCwd.Erase( 0, nPos ); + } */ + SvFileStream aOutStream; + String aOutputFileName( pOutputFileName, gsl_getSystemTextEncoding()); + DirEntry aOutEntry( aOutputFileName ); + String aOutPath = aOutEntry.GetPath().GetFull(); + + String aFileName( aOutPath ); + aFileName += aDelim; + aFileName += aCwd; + aFileName += String(".", gsl_getSystemTextEncoding()); + aFileName += aSrsBaseName; + aFileName += String(".dprr", gsl_getSystemTextEncoding()); + //fprintf( stderr, "OutFileName : %s \n",aFileName.GetStr()); + aOutStream.Open( aFileName, STREAM_WRITE ); + + ByteString aString; + if ( optind < argc ) + { +#ifdef DEBUG_VERBOSE + printf("further arguments : "); +#endif + aString = ByteString( pSrsFileName ); + aString.SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US )); + aString += ByteString(" : " ); + + while ( optind < argc ) + { + if (!bSource ) + { + aString += ByteString(" " ); + aString += ByteString( argv[optind]); + pDep->AddSource( argv[optind++]); + } + else + { + optind++; + } + } + } + aString += aRespArg; + pDep->Execute(); + ByteStringList *pLst = pDep->GetDepList(); + sal_uIntPtr nCount = pLst->Count(); + if ( nCount == 0 ) + { + aOutStream.WriteLine( aString ); + } + else + { + aString += ByteString( "\\" ); + aOutStream.WriteLine( aString ); + } + + for ( sal_uIntPtr j=0; j<nCount; j++ ) + { + ByteString *pStr = pLst->GetObject(j); + pStr->SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US )); + if ( j != (nCount-1) ) + *pStr += ByteString( "\\" ); + aOutStream.WriteLine( *pStr ); + } + delete pDep; + aOutStream.Close(); + + return 0; +} + diff --git a/tools/bootstrp/so_checksum.cxx b/tools/bootstrp/so_checksum.cxx new file mode 100644 index 000000000000..716e99eff9f1 --- /dev/null +++ b/tools/bootstrp/so_checksum.cxx @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" + +#include "md5.hxx" + +#include <stdio.h> + +#include <tools/string.hxx> + +int main( int argc, char * argv[] ) +{ + for ( int n = 1; n < argc; n++ ) + { + ByteString aChecksum; + rtlDigestError error = calc_md5_checksum( argv[n], aChecksum ); + + if ( rtl_Digest_E_None == error ) + { + printf( "%s %s\n", aChecksum.GetBuffer(), argv[n] ); + } + else + printf( "ERROR: Unable to calculate MD5 checksum for %s\n", argv[n] ); + } + + return 0; +} + + + diff --git a/tools/bootstrp/sspretty.cxx b/tools/bootstrp/sspretty.cxx new file mode 100644 index 000000000000..143705b6a2ea --- /dev/null +++ b/tools/bootstrp/sspretty.cxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_tools.hxx" +#include <tools/iparser.hxx> +#include <tools/geninfo.hxx> +#include <stdio.h> + + +/*****************************************************************************/ +#ifdef UNX +int main( int argc, char *argv[] ) +#else +int _cdecl main( int argc, char *argv[] ) +#endif +/*****************************************************************************/ +{ + if ( argc != 2 ) { + fprintf( stdout, "\nsspretty.exe v1.0 (c) 2001\n\n" ); + fprintf( stdout, "Syntax: sspretty filename\n" ); + } + else { + String aFileName( argv[ 1 ], RTL_TEXTENCODING_ASCII_US ); + InformationParser aParser; + GenericInformationList *pList = aParser.Execute( aFileName ); + if ( pList ) + aParser.Save( aFileName, pList ); + else { + fprintf( stderr, "Error reading input file!\n" ); + return 1; + } + } + return 0; +} + |