summaryrefslogtreecommitdiff
path: root/tools/bootstrp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bootstrp')
-rw-r--r--tools/bootstrp/addexes/makefile.mk49
-rw-r--r--tools/bootstrp/addexes/replace.cxx76
-rw-r--r--tools/bootstrp/addexes2/makefile.mk56
-rw-r--r--tools/bootstrp/addexes2/mkfilt.cxx237
-rw-r--r--tools/bootstrp/appdef.cxx168
-rw-r--r--tools/bootstrp/command.cxx690
-rw-r--r--tools/bootstrp/cppdep.cxx246
-rw-r--r--tools/bootstrp/cppdep.hxx58
-rw-r--r--tools/bootstrp/inimgr.cxx210
-rw-r--r--tools/bootstrp/iserver.cxx152
-rw-r--r--tools/bootstrp/makefile.mk108
-rw-r--r--tools/bootstrp/md5.cxx149
-rw-r--r--tools/bootstrp/md5.hxx32
-rw-r--r--tools/bootstrp/mkcreate.cxx945
-rw-r--r--tools/bootstrp/prj.cxx1600
-rw-r--r--tools/bootstrp/rscdep.cxx299
-rw-r--r--tools/bootstrp/so_checksum.cxx56
-rw-r--r--tools/bootstrp/sspretty.cxx60
-rw-r--r--tools/bootstrp/sstring.cxx317
19 files changed, 5508 insertions, 0 deletions
diff --git a/tools/bootstrp/addexes/makefile.mk b/tools/bootstrp/addexes/makefile.mk
new file mode 100644
index 000000000000..324de9479502
--- /dev/null
+++ b/tools/bootstrp/addexes/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=tools
+TARGET=addexes
+TARGETTYPE=CUI
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CDEFS+=-D_TOOLS_STRINGLIST
+
+# --- Files --------------------------------------------------------
+
+APP1TARGET= txtrepl
+APP1OBJS= $(OBJ)$/replace.obj
+APP1STDLIBS=$(TOOLSLIB)
+
+DEPOBJFILES = $(APP1OBJS)
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/tools/bootstrp/addexes/replace.cxx b/tools/bootstrp/addexes/replace.cxx
new file mode 100644
index 000000000000..3c451ae54be0
--- /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();
+
+
+ ULONG 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/makefile.mk b/tools/bootstrp/addexes2/makefile.mk
new file mode 100644
index 000000000000..492d6f3105ed
--- /dev/null
+++ b/tools/bootstrp/addexes2/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=tools
+TARGET=addexes2
+TARGETTYPE=CUI
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+APP1TARGET= mkunroll
+APP1OBJS= $(OBJ)$/mkfilt.obj
+APP1STDLIBS= $(SALLIB) $(VOSLIB) $(TOOLSLIB)
+.IF "$(OS)"=="LINUX"
+APP1STDLIBS+=-lpthread
+.ENDIF
+.IF "$(OS)"=="NETBSD"
+APP1STDLIBS+=-lpthread
+.ENDIF
+APP1LIBS= $(LB)$/btstrp.lib $(LB)$/bootstrp2.lib
+APP1DEPN= $(LB)$/atools.lib $(LB)$/btstrp.lib $(LB)$/bootstrp2.lib
+
+
+DEPOBJFILES = $(APP1OBJS)
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/tools/bootstrp/addexes2/mkfilt.cxx b/tools/bootstrp/addexes2/mkfilt.cxx
new file mode 100644
index 000000000000..2d03aaa153e5
--- /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;
+ BOOL bOut;
+ BOOL bHier;
+
+ MkLine();
+};
+
+MkLine::MkLine()
+{
+ bOut = FALSE;
+ bHier = 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 = FALSE;
+
+ pLst->Insert( pMkLine, LIST_APPEND );
+ }
+ else if ( nState == 1 )
+ {
+ BOOL bInTnrList = 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 = TRUE;
+ ByteString *pByteString = new ByteString("# do not delete this line === mkfilter3i\n");
+ p_MkLine->aLine = *pByteString;
+ p_MkLine->bOut = FALSE;
+ p_MkLine->pPrivateTnrLst = pTnrLst;
+ pTnrLst = new ByteStringList();
+ pLst->Insert( p_MkLine, LIST_APPEND );
+ nState = 0;
+ bInTnrList = FALSE;
+ }
+ ByteString *pStr = new ByteString( aLineBuf );
+ pMkLine->aLine = *pStr;
+ pMkLine->bOut = FALSE;
+
+ if ( bInTnrList )
+ pTnrLst->Insert( pMkLine, LIST_APPEND );
+ }
+ else {
+ /* Zeilen ignorieren */;
+ }
+ } // End Of File
+ fprintf( stderr, "\n" );
+
+ // das File wieder ausgegeben
+ ULONG nLines = pLst->Count();
+ for ( ULONG j=0; j<nLines; j++ )
+ {
+ MkLine *pLine = pLst->GetObject( j );
+ if ( pLine->bHier )
+ {
+ // die List n - Mal abarbeiten
+ for ( USHORT n=1; n<11; n++)
+ {
+ ULONG nCount = pLine->pPrivateTnrLst->Count();
+ for ( ULONG i=0; i<nCount; i++ )
+ {
+ MkLine *pMkLine = pLine->pPrivateTnrLst->GetObject(i);
+ ByteString aLine = pMkLine->aLine;
+ while( aLine.SearchAndReplace( aTnr, ByteString::CreateFromInt32( n )) != (USHORT)-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/command.cxx b/tools/bootstrp/command.cxx
new file mode 100644
index 000000000000..2ab0cc8dc4a6
--- /dev/null
+++ b/tools/bootstrp/command.cxx
@@ -0,0 +1,690 @@
+/*************************************************************************
+ *
+ * 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 SCO
+#define _IOSTREAM_H
+#endif
+
+#ifdef PRECOMPILED
+#include "first.hxx"
+#endif
+
+#include <tools/fsys.hxx>
+#include <tools/stream.hxx>
+#include "bootstrp/command.hxx"
+#include <tools/debug.hxx>
+#include "bootstrp/appdef.hxx"
+
+#ifdef _MSC_VER
+#pragma warning (push,1)
+#endif
+
+#include <iostream>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+
+#ifdef _MSC_VER
+#pragma warning (pop)
+#endif
+
+//#define MH_TEST2 1 // fuers direkte Testen
+
+#if defined(WNT) || defined(OS2)
+#ifdef _MSC_VER
+#pragma warning (push,1)
+#endif
+#include <process.h> // for _SPAWN
+#ifdef _MSC_VER
+#pragma warning (pop)
+#endif
+#endif
+#ifdef UNX
+#include <sys/types.h>
+#include <unistd.h>
+#if ( defined NETBSD ) || defined (FREEBSD) || defined (AIX) \
+ || defined (HPUX) || defined (MACOSX)
+#include <sys/wait.h>
+#else
+#include <wait.h>
+#endif
+#define P_WAIT 1 // erstmal einen dummz
+#endif
+
+#if defined WNT
+#include <tools/svwin.h>
+#endif
+
+#if defined(WNT) || defined(OS2)
+#define cPathSeperator ';'
+#endif
+#ifdef UNX
+#define cPathSeperator ':'
+#endif
+
+/*****************************************************************************/
+CommandLine::CommandLine(BOOL bWrite)
+/*****************************************************************************/
+ : bTmpWrite(bWrite)
+{
+ CommandBuffer = new char [1];
+ if (CommandBuffer == NULL) {
+ //cout << "Error: nospace" << endl;
+ exit(0);
+ }
+ CommandBuffer[0] = '\0';
+ nArgc = 0;
+ ppArgv = new char * [1];
+ ppArgv[0] = NULL;
+
+ ComShell = new char [128];
+ char* pTemp = getenv("COMMAND_SHELL");
+ if(!pTemp)
+ strcpy(ComShell,COMMAND_SHELL);
+ else
+ strcpy(ComShell,pTemp);
+
+ strcpy(&ComShell[strlen(ComShell)]," -C ");
+}
+
+/*****************************************************************************/
+CommandLine::CommandLine(const char *CommandString, BOOL bWrite)
+/*****************************************************************************/
+ : bTmpWrite(bWrite)
+{
+ CommandBuffer = new char [1];
+ if (CommandBuffer == NULL) {
+ //cout << "Error: nospace" << endl;
+ exit(0);
+ }
+ nArgc = 0;
+ ppArgv = new char * [1];
+ ppArgv[0] = NULL;
+
+ ComShell = new char [128];
+ char* pTemp = getenv("COMMAND_SHELL");
+ if(!pTemp)
+ strcpy(ComShell,COMMAND_SHELL);
+ else
+ strcpy(ComShell,pTemp);
+
+ strcpy(&ComShell[strlen(ComShell)]," -C ");
+
+ BuildCommand(CommandString);
+}
+
+/*****************************************************************************/
+CommandLine::CommandLine(const CommandLine& CCommandLine, BOOL bWrite)
+/*****************************************************************************/
+ : bTmpWrite(bWrite)
+{
+ CommandBuffer = new char [1];
+ if (CommandBuffer == NULL) {
+ //cout << "Error: nospace" << endl;
+ exit(0);
+ }
+ nArgc = 0;
+ ppArgv = new char * [1];
+ ppArgv[0] = NULL;
+
+ ComShell = new char [128];
+ char* pTemp = getenv("COMMAND_SHELL");
+ if(!pTemp)
+ strcpy(ComShell,COMMAND_SHELL);
+ else
+ strcpy(ComShell,pTemp);
+
+ strcpy(&ComShell[strlen(ComShell)]," -C ");
+
+ BuildCommand(CCommandLine.CommandBuffer);
+}
+
+/*****************************************************************************/
+CommandLine::~CommandLine()
+/*****************************************************************************/
+{
+ delete [] CommandBuffer;
+ delete [] ComShell;
+ //for (int i = 0; ppArgv[i] != '\0'; i++) {
+ for (int i = 0; ppArgv[i] != 0; i++) {
+ delete [] ppArgv[i];
+ }
+ delete [] ppArgv;
+
+}
+
+/*****************************************************************************/
+CommandLine& CommandLine::operator=(const CommandLine& CCommandLine)
+/*****************************************************************************/
+{
+ strcpy (CommandBuffer, CCommandLine.CommandBuffer);
+ for (int i = 0; i != nArgc; i++) {
+ delete [] ppArgv[i];
+ }
+ delete [] ppArgv;
+ ppArgv = new char * [1];
+ ppArgv[0] = NULL;
+ BuildCommand(CommandBuffer);
+ return *this;
+}
+
+/*****************************************************************************/
+CommandLine& CommandLine::operator=(const char *CommandString)
+/*****************************************************************************/
+{
+ strcpy (CommandBuffer, CommandString);
+ for (int i = 0; i != nArgc; i++) {
+ delete [] ppArgv[i];
+ }
+ delete [] ppArgv;
+ ppArgv = new char * [1];
+ ppArgv[0] = NULL;
+ BuildCommand(CommandBuffer);
+
+ return *this;
+}
+
+/*****************************************************************************/
+void CommandLine::Print()
+/*****************************************************************************/
+{
+ //cout << "******* start print *******" << endl;
+ //cout << "nArgc = " << nArgc << endl;
+ //cout << "CommandBuffer = " << CommandBuffer << endl;
+ for (int i = 0; ppArgv[i] != NULL; i++) {
+ //cout << "ppArgv[" << i << "] = " << ppArgv[i] << endl;
+ }
+ //cout << "******** end print ********" << endl;
+}
+
+/*****************************************************************************/
+void CommandLine::BuildCommand(const char *CommandString)
+/*****************************************************************************/
+{
+ int index = 0, pos=0;
+ char buffer[1024];
+ char WorkString[1024];
+
+ strcpy(WorkString,CommandString);
+
+ //falls LogWindow -> in tmpfile schreiben
+ if(bTmpWrite)
+ {
+ strcpy(&WorkString[strlen(WorkString)]," >&");
+ strcpy(&WorkString[strlen(WorkString)],getenv("TMP"));
+ strcpy(&WorkString[strlen(WorkString)],TMPNAME);
+ }
+
+ // delete old memory and get some new memory for CommandBuffer
+
+ delete [] CommandBuffer;
+ CommandBuffer = new char [strlen(ComShell)+strlen(WorkString)+1];
+ if (CommandBuffer == NULL) {
+ //cout << "Error: nospace" << endl;
+ exit(0);
+ }
+ strcpy (CommandBuffer, ComShell);
+ strcpy (&CommandBuffer[strlen(ComShell)], WorkString);
+
+ CommandString = CommandBuffer;
+
+ // get the number of tokens
+ Strtokens(CommandString);
+
+ // delete the space for the old CommandLine
+
+ for (int i = 0; ppArgv[i] != 0; i++) {
+ delete [] ppArgv[i];
+ }
+ delete [] ppArgv;
+
+ /* get space for the new command line */
+
+ ppArgv = (char **) new char * [nArgc+1];
+ if (ppArgv == NULL) {
+ //cout << "Error: no space" << endl;
+ exit(0);
+ }
+
+ // flush the white space
+
+ while ( isspace(*CommandString) )
+ CommandString++;
+
+ index = 0;
+
+ // start the loop to build all the individual tokens
+
+ while (*CommandString != '\0') {
+
+ pos = 0;
+
+ // copy the token until white space is found
+
+ while ( !isspace(*CommandString) && *CommandString != '\0') {
+
+ buffer[pos++] = *CommandString++;
+
+ }
+
+ buffer[pos] = '\0';
+
+ // get space for the individual tokens
+
+ ppArgv[index] = (char *) new char [strlen(buffer)+1];
+ if (ppArgv[index] == NULL) {
+ //cout << "Error: nospace" << endl;
+ exit(0);
+ }
+
+ // copy the token
+
+ strcpy (ppArgv[index++], buffer);
+
+ // flush while space
+
+ while ( isspace(*CommandString) )
+ CommandString++;
+
+ }
+
+ // finish by setting the las pointer to NULL
+ ppArgv[nArgc]= NULL;
+
+}
+
+/*****************************************************************************/
+void CommandLine::Strtokens(const char *CommandString)
+/*****************************************************************************/
+{
+ int count = 0;
+ const char *temp;
+
+ temp = CommandString;
+
+ /* bypass white space */
+
+ while (isspace(*temp)) temp++;
+
+ for (count=0; *temp != '\0'; count++) {
+
+ /* continue until white space of string terminator is found */
+
+ while ((!isspace(*temp)) && (*temp != '\0')) temp++;
+
+ /* bypass white space */
+
+ while (isspace(*temp)) temp++;
+
+ }
+ nArgc = count;
+}
+
+/*****************************************************************************/
+CCommand::CCommand( ByteString &rString )
+/*****************************************************************************/
+{
+ rString.SearchAndReplace( '\t', ' ' );
+ aCommand = rString.GetToken( 0, ' ' );
+ aCommandLine = Search( "PATH" );
+#ifndef UNX
+ aCommandLine += " /c ";
+#else
+ aCommandLine += " -c ";
+#endif
+
+ ByteString sCmd( rString.GetToken( 0, ' ' ));
+ ByteString sParam( rString.Copy( sCmd.Len()));
+
+ aCommandLine += Search( "PATH", sCmd );
+ aCommandLine += sParam;
+
+ ImplInit();
+}
+
+/*****************************************************************************/
+CCommand::CCommand( const char *pChar )
+/*****************************************************************************/
+{
+ ByteString aString = pChar;
+ aString.SearchAndReplace( '\t', ' ' );
+ aCommand = aString.GetToken( 0, ' ' );
+
+ aCommandLine = Search( "PATH" );
+#ifndef UNX
+ aCommandLine += " /c ";
+#else
+ aCommandLine += " -c ";
+#endif
+ ByteString rString( pChar );
+
+ ByteString sCmd( rString.GetToken( 0, ' ' ));
+ ByteString sParam( rString.Copy( sCmd.Len()));
+
+ aCommandLine += Search( "PATH", sCmd );
+ aCommandLine += sParam;
+
+ ImplInit();
+}
+
+/*****************************************************************************/
+void CCommand::ImplInit()
+/*****************************************************************************/
+{
+ char pTmpStr[255];
+ size_t *pPtr;
+ char *pChar;
+ int nVoid = sizeof( size_t * );
+ nArgc = aCommandLine.GetTokenCount(' ');
+ ULONG nLen = aCommandLine.Len();
+
+ ppArgv = (char **) new char[ (ULONG)(nLen + nVoid * (nArgc +2) + nArgc ) ];
+ pChar = (char *) ppArgv + ( (1+nArgc) * nVoid );
+ pPtr = (size_t *) ppArgv;
+ for ( xub_StrLen i=0; i<nArgc; i++ )
+ {
+ (void) strcpy( pTmpStr, aCommandLine.GetToken(i, ' ' ).GetBuffer() );
+ size_t nStrLen = strlen( pTmpStr ) + 1;
+ strcpy( pChar, pTmpStr );
+ *pPtr = (sal_uIntPtr) pChar;
+ pChar += nStrLen;
+ pPtr += 1;
+#ifdef UNX
+ if ( i == 1 )
+ {
+ USHORT nWo = aCommandLine.Search("csh -c ");
+ if (nWo != STRING_NOTFOUND)
+ aCommandLine.Erase(0, nWo + 7);
+ else
+ aCommandLine.Erase(0, 16);
+ i = nArgc;
+ strcpy( pChar, aCommandLine.GetBuffer() );
+ *pPtr = (sal_uIntPtr) pChar;
+ pPtr += 1;
+ }
+#endif
+ }
+ *pPtr = 0;
+}
+
+/*****************************************************************************/
+CCommand::operator int()
+/*****************************************************************************/
+{
+ int nRet;
+#if defined WNT
+ nRet = _spawnv( P_WAIT, ppArgv[0], (const char **) ppArgv );
+#elif defined OS2
+ nRet = _spawnv( P_WAIT, ppArgv[0], ppArgv );
+#elif defined UNX
+ //fprintf( stderr, "CComand : operator (int) not implemented\n");
+ // **** Unix Implementierung ***************
+ pid_t pid;
+
+ if (( pid = fork()) < 0 )
+ {
+ DBG_ASSERT( FALSE, "fork error" );
+ }
+ else if ( pid == 0 )
+ {
+ if ( execv( ppArgv[0], (char * const *) ppArgv ) < 0 )
+ {
+ DBG_ASSERT( FALSE, "execv failed" );
+ }
+ }
+ //fprintf( stderr, "parent: %s %s\n", ppArgv[0] , ppArgv[1] );
+ if ( (nRet = waitpid( pid, NULL, 0 ) < 0) )
+ {
+ DBG_ASSERT( FALSE, "wait error" );
+ }
+#endif
+
+ switch ( errno )
+ {
+ case E2BIG :
+ nError = COMMAND_TOOBIG;
+ break;
+ case EINVAL :
+ nError = COMMAND_INVALID;
+ break;
+ case ENOENT:
+ nError = COMMAND_NOTFOUND;
+ break;
+ case ENOEXEC :
+ nError = COMMAND_NOEXEC;
+ break;
+ case ENOMEM :
+ nError = COMMAND_NOMEM;
+ break;
+ default:
+ nError = COMMAND_UNKNOWN;
+ }
+
+ if ( nRet )
+ fprintf( stderr, "Program returned with errros\n");
+ return nRet;
+}
+
+/*****************************************************************************/
+ByteString CCommand::Search(ByteString aEnv, ByteString sItem)
+/*****************************************************************************/
+{
+ // default wird eine Shell im Path gesucht,
+ // wenn aber compsec gestzt ist holen wir uns die
+ // Shell von dort
+ if ( sItem.Equals( COMMAND_SHELL ))
+ {
+ ByteString aComspec = GetEnv( "COMSPEC" );
+ if ( !aComspec.Equals(""))
+ return aComspec;
+ }
+
+ DirEntry aItem( String( sItem, RTL_TEXTENCODING_ASCII_US ));
+ if ( aItem.Exists())
+ return sItem;
+
+ ByteString aEntry, sReturn;
+ ByteString sEnv( aEnv );
+ ByteString sEnvironment = GetEnv( sEnv.GetBuffer());
+ xub_StrLen nCount = sEnvironment.GetTokenCount( cPathSeperator );
+
+ BOOL bFound = FALSE;
+
+ for ( xub_StrLen i=0; i<nCount && !bFound; i++ )
+ {
+ aEntry = sEnvironment.GetToken(i, cPathSeperator );
+#ifndef UNX
+ aEntry += '\\';
+#else
+ aEntry += '/';
+#endif
+ aEntry += sItem;
+
+ String sEntry( aEntry, RTL_TEXTENCODING_ASCII_US );
+ DirEntry aDirEntry( sEntry );
+ aDirEntry.ToAbs();
+ if ( aDirEntry.Exists()) {
+ sReturn = aEntry;
+ bFound = TRUE;
+ }
+ }
+ if ( !bFound )
+ {
+ sEnv = sEnv.ToUpperAscii();
+ ByteString sEnvironment2 = GetEnv(sEnv.GetBuffer() );
+ xub_StrLen nCount2 = sEnvironment2.GetTokenCount( cPathSeperator );
+ for ( xub_StrLen i=0; i<nCount2 && !bFound; i++ )
+ {
+ aEntry = sEnvironment2.GetToken(i, cPathSeperator );
+#ifndef UNX
+ aEntry += '\\';
+#else
+ aEntry += '/';
+#endif
+ aEntry += sItem;
+
+ String sEntry( aEntry, RTL_TEXTENCODING_ASCII_US );
+ DirEntry aDirEntry( sEntry );
+ aDirEntry.ToAbs();
+ if ( aDirEntry.Exists()) {
+ sReturn = aEntry;
+ bFound = TRUE;
+ }
+ }
+ }
+
+ if ( sReturn.Equals( "" ))
+ sReturn = sItem;
+
+ return sReturn;
+}
+
+/*****************************************************************************/
+CCommandd::CCommandd( ByteString &rString, CommandBits nBits )
+/*****************************************************************************/
+ : CCommand( rString ),
+ nFlag( nBits )
+{
+}
+
+
+/*****************************************************************************/
+CCommandd::CCommandd( const char *pChar, CommandBits nBits )
+/*****************************************************************************/
+ : CCommand( pChar ),
+ nFlag( nBits )
+{
+}
+
+/*****************************************************************************/
+CCommandd::operator int()
+/*****************************************************************************/
+{
+ int nRet = 0;
+
+#ifdef WNT
+ LPCTSTR lpApplicationName = NULL;
+ LPTSTR lpCommandLine = (char *) GetCommandLine_().GetBuffer();
+ LPSECURITY_ATTRIBUTES lpProcessAttributes = NULL;
+ LPSECURITY_ATTRIBUTES lpThreadAttributes = NULL;
+ BOOL bInheritHandles = TRUE;
+
+ // wie wuenschen wir denn gestartet zu werden ??
+ DWORD dwCreationFlags;
+
+ if ( nFlag & COMMAND_EXECUTE_START )
+ dwCreationFlags = DETACHED_PROCESS;
+ else
+ dwCreationFlags = CREATE_NEW_CONSOLE;
+
+ // wir erben vom Vaterprozess
+ LPVOID lpEnvironment = NULL;
+
+ // das exe im Pfad suchen
+ LPCTSTR lpCurrentDirectory = NULL;
+
+ // in dieser Struktur bekommen wir die erzeugte Processinfo
+ // zurueck
+ PROCESS_INFORMATION aProcessInformation;
+
+ // weiteres Startupinfo anlegen
+ STARTUPINFO aStartupInfo;
+
+ aStartupInfo.cb = sizeof( STARTUPINFO );
+ aStartupInfo.lpReserved = NULL;
+ aStartupInfo.lpDesktop = NULL;
+
+ // das Fenster bekommt den Namen des Exes
+ aStartupInfo.lpTitle = NULL;
+ aStartupInfo.dwX = 100;
+ aStartupInfo.dwY = 100;
+ //aStartupInfo.dwXSize = 400;
+ //aStartupInfo.dwYSize = 400;
+ aStartupInfo.dwXCountChars = 40;
+ aStartupInfo.dwYCountChars = 40;
+
+ // Farben setzen
+ aStartupInfo.dwFillAttribute = FOREGROUND_RED | BACKGROUND_RED |
+ BACKGROUND_BLUE | BACKGROUND_GREEN;
+
+// aStartupInfo.dwFlags = STARTF_USESTDHANDLES;
+ //aStartupInfo.wShowWindow = SW_NORMAL; //SW_SHOWDEFAULT;
+ //aStartupInfo.wShowWindow = SW_HIDE; //SW_SHOWNOACTIVATE;
+ aStartupInfo.wShowWindow = SW_SHOWNOACTIVATE;
+ aStartupInfo.cbReserved2 = NULL;
+ aStartupInfo.lpReserved2 = NULL;
+ //aStartupInfo.hStdInput = stdin;
+ //aStartupInfo.hStdOutput = stdout;
+ //aStartupInfo.hStdError = stderr;
+
+ if ( nFlag & COMMAND_EXECUTE_HIDDEN )
+ {
+ aStartupInfo.wShowWindow = SW_HIDE;
+ aStartupInfo.dwFlags = aStartupInfo.dwFlags | STARTF_USESHOWWINDOW;
+ }
+
+ bool bProcess = CreateProcess( lpApplicationName,
+ lpCommandLine, lpProcessAttributes,
+ lpThreadAttributes, bInheritHandles,
+ dwCreationFlags, lpEnvironment, lpCurrentDirectory,
+ &aStartupInfo, &aProcessInformation );
+
+ LPVOID lpMsgBuf;
+
+ if ( bProcess )
+ {
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL );
+
+ ByteString aErrorString = (char *) lpMsgBuf;
+
+ if ( nFlag & COMMAND_EXECUTE_WAIT )
+ {
+ DWORD aProcessState = STILL_ACTIVE;
+ while(aProcessState == STILL_ACTIVE)
+ {
+ GetExitCodeProcess(aProcessInformation.hProcess,&aProcessState);
+ }
+ }
+ }
+ else
+ fprintf( stderr, "Can not start Process !" );
+
+#endif
+ return nRet;
+}
diff --git a/tools/bootstrp/cppdep.cxx b/tools/bootstrp/cppdep.cxx
new file mode 100644
index 000000000000..6263c719df51
--- /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()
+{
+ ULONG nCount = pSources->Count();
+ for ( ULONG n=0; n<nCount;n++)
+ {
+ ByteString *pStr = pSources->GetObject(n);
+ Search( *pStr );
+ }
+}
+
+BOOL CppDep::AddSearchPath( const char* aPath )
+{
+ ByteString *pStr = new ByteString( aPath );
+ pSearchPath->Insert( pStr, LIST_APPEND );
+ return FALSE;
+}
+
+BOOL CppDep::AddSource( const char* aSource )
+{
+ ByteString *pStr = new ByteString( aSource );
+ pSources->Insert( pStr, LIST_APPEND );
+ return FALSE;
+}
+
+BOOL CppDep::Search( ByteString aFileName )
+{
+#ifdef DEBUG_VERBOSE
+ fprintf( stderr, "SEARCH : %s\n", aFileName.GetBuffer());
+#endif
+ BOOL bRet = FALSE;
+
+ SvFileStream aFile;
+ ByteString aReadLine;
+
+ UniString suFileName( aFileName, gsl_getSystemTextEncoding());
+
+ aFile.Open( suFileName, STREAM_READ );
+ while ( aFile.ReadLine( aReadLine ))
+ {
+ USHORT 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 )) != "" )
+ {
+ BOOL bFound = FALSE;
+ ULONG nCount = pFileList->Count();
+ for ( ULONG i=0; i<nCount; i++ )
+ {
+ ByteString *pStr = pFileList->GetObject(i);
+ if ( *pStr == aNewFile )
+ bFound = 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
+
+ ULONG nCount = pSearchPath->Count();
+ for ( ULONG 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 );
+ USHORT 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..cdc3ac2e9758
--- /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;
+
+ 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;}
+ BOOL AddSearchPath( const char* aPath );
+ BOOL AddSource( const char * aSource );
+};
+
diff --git a/tools/bootstrp/inimgr.cxx b/tools/bootstrp/inimgr.cxx
new file mode 100644
index 000000000000..a0a69f06f7af
--- /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( 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( TRUE )
+{
+ sLocalPath = GetLocalIni();
+ sGlobalDir = rDir;
+#if !defined( UNX ) && !defined( OS2 )
+ mkdir(( char * ) sLocalPath.GetBuffer());
+#else
+ mkdir( sLocalPath.GetBuffer() ,00777 );
+#endif
+}
+
+/****************************************************************************/
+IniManager::IniManager()
+/****************************************************************************/
+ : bUpdate( 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 ( USHORT 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 = FALSE;
+ }
+}
diff --git a/tools/bootstrp/iserver.cxx b/tools/bootstrp/iserver.cxx
new file mode 100644
index 000000000000..0b2c1df15203
--- /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 {
+ BOOL bError = FALSE;
+ BOOL bList = FALSE;
+ ByteString sInfo( "" );
+ ByteString sDataBase( GetDefStandList());
+
+ BOOL bGetNow = 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 = TRUE;
+ }
+ else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-D" ) {
+ // requestet info path
+ nCount++;
+ if( nCount < argc ) {
+ sDataBase = ByteString( argv[nCount] );
+ nCount++;
+ }
+ else bError = TRUE;
+ }
+ else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-L" ) {
+ // request list of childs
+ nCount++;
+ bList = TRUE;
+ }
+ else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-N" ) {
+ // request list of childs
+ nCount++;
+ bGetNow = TRUE;
+ }
+ else {
+ bError = 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, 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( ULONG 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( ULONG i = 0; i < pList->Count(); i++ ) {
+ GenericInformation *pInfo = pList->GetObject( i );
+ if ( bGetNow ) {
+ ByteString sPath( "settings/now" );
+ GenericInformation *pSubInfo = pInfo->GetSubInfo( sPath, 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/makefile.mk b/tools/bootstrp/makefile.mk
new file mode 100644
index 000000000000..41188d2117d0
--- /dev/null
+++ b/tools/bootstrp/makefile.mk
@@ -0,0 +1,108 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=tools
+TARGET=btstrp
+TARGET1=bootstrp2
+TARGETTYPE=CUI
+LIBTARGET=NO
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CDEFS+=-D_TOOLS_STRINGLIST
+
+.IF "$(HAVE_GETOPT)" == "YES"
+CDEFS += -DHAVE_GETOPT
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+OBJFILES= \
+ $(OBJ)$/appdef.obj \
+ $(OBJ)$/command.obj \
+ $(OBJ)$/cppdep.obj\
+ $(OBJ)$/inimgr.obj\
+ $(OBJ)$/mkcreate.obj \
+ $(OBJ)$/sstring.obj \
+ $(OBJ)$/prj.obj
+
+SLOFILES= \
+ $(SLO)$/appdef.obj \
+ $(SLO)$/command.obj \
+ $(SLO)$/cppdep.obj \
+ $(SLO)$/inimgr.obj \
+ $(SLO)$/mkcreate.obj \
+ $(SLO)$/sstring.obj \
+ $(SLO)$/prj.obj
+
+
+LIB1TARGET= $(LB)$/$(TARGET).lib
+LIB1ARCHIV= $(LB)$/lib$(TARGET).a
+LIB1OBJFILES=\
+ $(OBJ)$/appdef.obj \
+ $(OBJ)$/command.obj \
+ $(OBJ)$/cppdep.obj \
+ $(OBJ)$/inimgr.obj \
+ $(OBJ)$/mkcreate.obj \
+ $(OBJ)$/sstring.obj
+
+LIB2TARGET= $(LB)$/$(TARGET1).lib
+LIB2ARCHIV= $(LB)$/lib$(TARGET1).a
+LIB2OBJFILES=\
+ $(OBJ)$/prj.obj
+
+APP1TARGET= sspretty
+APP1OBJS= $(OBJ)$/sspretty.obj
+APP1LIBS= $(LB)$/$(TARGET).lib $(LB)$/$(TARGET1).lib
+APP1STDLIBS=$(SALLIB) $(VOSLIB) $(TOOLSLIB) $(BASEGFXLIB) $(UCBHELPERLIB) $(CPPULIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(SALHELPERLIB) $(I18NISOLANGLIB)
+
+APP2TARGET= rscdep
+APP2OBJS= $(OBJ)$/rscdep.obj
+APP2LIBS= $(LB)$/$(TARGET).lib $(LB)$/$(TARGET1).lib
+APP2STDLIBS= $(SALLIB) $(VOSLIB) $(TOOLSLIB) $(BASEGFXLIB) $(UCBHELPERLIB) $(CPPULIB) $(COMPHELPERLIB) $(I18NISOLANGLIB) $(CPPUHELPERLIB) $(SALHELPERLIB)
+.IF "$(HAVE_GETOPT)" != "YES"
+.IF "$(OS)"=="WNT"
+APP2STDLIBS+=gnu_getopt.lib
+.ENDIF
+.ENDIF
+APP2RPATH= NONE
+APP2RPATH= NONE
+APP2RPATH= NONE
+
+APP3TARGET= so_checksum
+APP3OBJS= $(OBJ)$/md5.obj \
+ $(OBJ)$/so_checksum.obj
+APP3STDLIBS= $(TOOLSLIB) $(SALLIB) $(VOSLIB) $(BASEGFXLIB) $(UCBHELPERLIB) $(CPPULIB) $(COMPHELPERLIB) $(I18NISOLANGLIB) $(CPPUHELPERLIB) $(SALHELPERLIB)
+
+DEPOBJFILES = $(APP1OBJS) $(APP2OBJS) $(APP3OBJS)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
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..398a3a4c4143
--- /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,
+ USHORT 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, USHORT nOperatingSystems )
+/*****************************************************************************/
+{
+ CodedDependency *pReturn = NULL;
+
+ if ( !pCodedDependencies ) {
+ pCodedDependencies = new SByteStringList();
+ pReturn = new CodedDependency( rCodedIdentifier, nOperatingSystems );
+ pCodedDependencies->PutString(( ByteString * ) pReturn );
+ }
+ else {
+ ULONG 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, USHORT nOperatingSystems )
+/*****************************************************************************/
+{
+ CodedDependency *pReturn = NULL;
+
+ if ( !pCodedIdentifier ) {
+ pCodedIdentifier = new SByteStringList();
+ pReturn = new CodedDependency( rCodedIdentifier, nOperatingSystems );
+ pCodedIdentifier->PutString(( ByteString * ) pReturn );
+ }
+ else {
+ ULONG 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, USHORT nOperatingSystem )
+/*****************************************************************************/
+{
+ ByteString sSearch;
+
+ BOOL bSubs = TRUE;
+ ULONG nIndex = 0;
+
+ while ( bSubs && ByteString( LimitedPath[ nIndex ]) != "EndOf_LimitedPath" ) {
+ SourceDirectory *pActDir = this;
+ ByteString sLimitation( LimitedPath[ nIndex ]);
+
+ BOOL bBreak = FALSE;
+ for ( ULONG i = sLimitation.GetTokenCount( '\\' ); i > 0 && !bBreak; i-- ) {
+ if (( !pActDir ) || ( *pActDir != sLimitation.GetToken(( USHORT )( i - 1 ), '\\' )))
+ bBreak = 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, USHORT 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,
+ USHORT 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;
+
+ ULONG nPos = pCodedIdentifier->IsString( pCodedDependency );
+ if ( nPos != NOT_THERE ) {
+ CodedDependency *pIdentifier =
+ ( CodedDependency * ) pCodedIdentifier->GetObject( nPos );
+ USHORT 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 ( ULONG 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(( ULONG ) 0 );
+
+ for (
+ ULONG 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(( ULONG ) 0 );
+ }
+ }
+ }
+}
+
+/*****************************************************************************/
+ByteString SourceDirectory::GetTarget()
+/*****************************************************************************/
+{
+ ByteString sReturn;
+
+ if ( !pDependencies )
+ return sReturn;
+
+ ULONG 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;
+ }
+
+ BOOL bDependsOnPlatform = FALSE;
+ for ( ULONG i = 0; i < pDependencies->Count(); i++ )
+ if ((( Dependency * ) pDependencies->GetObject( i ))->
+ GetOperatingSystem() != OS_ALL )
+ bDependsOnPlatform = TRUE;
+
+ ByteString sTarget( *this );
+ sTarget.SearchAndReplaceAll( "\\", "$/" );
+ if ( !bDependsOnPlatform ) {
+ sReturn = sTarget;
+ sReturn += " :";
+ for ( ULONG 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 += " :";
+ BOOL bUNX = FALSE;
+
+ ByteString sWNT( ".IF \"$(GUI)\" == \"WNT\"\n" );
+ sWNT += sTarget;
+ sWNT += " :";
+ BOOL bWNT = FALSE;
+
+ ByteString sOS2( ".IF \"$(GUI)\" == \"OS2\"\n" );
+ sOS2 += sTarget;
+ sOS2 += " :";
+ BOOL bOS2 = FALSE;
+
+ for ( ULONG 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 = TRUE;
+ }
+ if ( pDependency->GetOperatingSystem() & OS_WIN32 ) {
+ sWNT += " ";
+ sWNT += sDependency;
+ bWNT = TRUE;
+ }
+ if ( pDependency->GetOperatingSystem() & OS_OS2 ) {
+ sOS2 += " ";
+ sOS2 += sDependency;
+ bOS2 = 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 ) {
+ BOOL bDependsOnPlatform = FALSE;
+ for ( ULONG i = 0; i < pSubDirectories->Count(); i++ )
+ if ((( SourceDirectory * ) pSubDirectories->GetObject( i ))->
+ GetOperatingSystems() != OS_ALL )
+ bDependsOnPlatform = TRUE;
+
+ if ( !bDependsOnPlatform ) {
+ sReturn = "RC_SUBDIRS = ";
+
+ for ( ULONG 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 = ";
+ BOOL bUNX = FALSE;
+
+ ByteString sWNT( ".IF \"$(GUI)\" == \"WNT\"\n" );
+ sWNT += "RC_SUBDIRS = ";
+ BOOL bWNT = FALSE;
+
+ ByteString sOS2( ".IF \"$(GUI)\" == \"OS2\"\n" );
+ sOS2 += "RC_SUBDIRS = ";
+ BOOL bOS2 = FALSE;
+
+ for ( ULONG 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 = TRUE;
+ }
+ if ( pDirectory->GetOperatingSystems() & OS_WIN32 ) {
+ sWNT += " \\\n\t";
+ sWNT += sDirectory;
+ bWNT = TRUE;
+ }
+ if ( pDirectory->GetOperatingSystems() & OS_OS2 ) {
+ sOS2 += " \\\n\t";
+ sOS2 += sDirectory;
+ bOS2 = 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;
+}
+
+/*****************************************************************************/
+USHORT SourceDirectory::GetOSType( const ByteString &sDependExt )
+/*****************************************************************************/
+{
+ USHORT 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, 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, 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, TRUE, rRoot.GetBuffer());
+// fprintf( stderr,
+// "Creating virtual directory tree ...\n" );
+
+
+ SourceDirectory *pSourceRoot = new SourceDirectory( rRoot, OS_ALL );
+
+ for ( ULONG i = 0; i < aStar.Count(); i++ ) {
+ Prj *pPrj = aStar.GetObject( i );
+
+ BOOL bBuildable = TRUE;
+ ULONG 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( FALSE );
+ if ( pPrjDependencies )
+ for ( ULONG x = 0; x < pPrjDependencies->Count(); x++ )
+ pProject->AddCodedDependency( *pPrjDependencies->GetObject( x ), OS_ALL );
+
+ pProject->AddCodedIdentifier( pPrj->GetProjectName(), OS_ALL );
+
+ for ( ULONG 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 ( ULONG 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;
+}
+
+/*****************************************************************************/
+BOOL SourceDirectory::RemoveDirectoryTreeAndAllDependencies()
+/*****************************************************************************/
+{
+ if ( !pParent )
+ return FALSE;
+
+ SourceDirectoryList *pParentContent = pParent->pSubDirectories;
+ ULONG i = 0;
+ while ( i < pParentContent->Count()) {
+ SourceDirectory *pCandidate =
+ ( SourceDirectory * )pParentContent->GetObject( i );
+ if ( pCandidate == this ) {
+ pParentContent->Remove( i );
+ }
+ else {
+ if ( pCandidate->pDependencies ) {
+ ULONG nPos = pCandidate->pDependencies->IsString( this );
+ if ( nPos != NOT_THERE )
+ delete pCandidate->pDependencies->Remove( nPos );
+ }
+ i++;
+ }
+ }
+ delete this;
+ return TRUE;
+}
+
+/*****************************************************************************/
+BOOL SourceDirectory::CreateRecursiveMakefile( BOOL bAllChilds )
+/*****************************************************************************/
+{
+ if ( !pSubDirectories )
+ return TRUE;
+
+ fprintf( stdout, "%s", GetFullPath().GetBuffer());
+
+ String aTmpStr( GetFullPath(), gsl_getSystemTextEncoding());
+ DirEntry aEntry( aTmpStr );
+ if ( !aEntry.Exists()) {
+ fprintf( stdout, " ... no directory!n" );
+ return FALSE;
+ }
+
+ ULONG 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;
+
+ BOOL bMakefileMk = 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 = TRUE;
+ }
+ }
+
+ SvFileStream aMakefile( aRCEntry.GetFull(), STREAM_STD_WRITE | STREAM_TRUNC );
+ if ( !aMakefile.IsOpen()) {
+ fprintf( stdout, " ... failed!\n" );
+ return 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 ( ULONG 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" );
+
+ BOOL bSuccess = TRUE;
+ if ( bAllChilds )
+ for ( ULONG k = 0; k < pSubDirectories->Count(); k++ )
+ if ( !(( SourceDirectory * ) pSubDirectories->GetObject( k ))->
+ CreateRecursiveMakefile( TRUE ))
+ bSuccess = FALSE;
+
+ return bSuccess;
+}
+
+//
+// class SourceDirectoryList
+//
+
+/*****************************************************************************/
+SourceDirectoryList::~SourceDirectoryList()
+/*****************************************************************************/
+{
+ for ( ULONG i = 0; i < Count(); i++ )
+ delete GetObject( i );
+}
+
+/*****************************************************************************/
+SourceDirectory *SourceDirectoryList::Search(
+ const ByteString &rDirectoryName )
+/*****************************************************************************/
+{
+ ULONG 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..4f4d44a33536
--- /dev/null
+++ b/tools/bootstrp/prj.cxx
@@ -0,0 +1,1600 @@
+/*************************************************************************
+ *
+ * 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"
+
+//#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();
+ BOOL bFound = FALSE;
+ ByteString aEraseString;
+ for ( USHORT i = 0; i<= nLength; i++)
+ {
+ if ( aTmpStr.GetChar( i ) == 0x20 && !bFound )
+ aTmpStr.SetChar( i, 0x09 );
+ }
+ return aTmpStr;
+}
+
+/*****************************************************************************/
+ByteString SimpleConfig::GetCleanedNextLine( 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') ) != (USHORT)-1 );
+ int nLength = aTmpStr.Len();
+ ByteString aEraseString;
+ BOOL bFirstTab = TRUE;
+ for ( USHORT i = 0; i<= nLength; i++)
+ {
+ if ( aTmpStr.GetChar( i ) == 0x20 )
+ aTmpStr.SetChar( i, 0x09 );
+
+ if ( aTmpStr.GetChar( i ) == 0x09 )
+ {
+ if ( bFirstTab )
+ bFirstTab = FALSE;
+ else
+ {
+ aTmpStr.SetChar( i, 0x20 );
+ }
+ }
+ else
+ bFirstTab = TRUE;
+
+ }
+ aTmpStr.EraseAllChars(' ');
+ return aTmpStr;
+
+}
+
+
+//
+// class CommandData
+//
+
+/*****************************************************************************/
+CommandData::CommandData()
+/*****************************************************************************/
+{
+ nOSType = 0;
+ nCommand = 0;
+ pDepList = 0;
+}
+
+/*****************************************************************************/
+CommandData::~CommandData()
+/*****************************************************************************/
+{
+ if ( pDepList )
+ {
+ ByteString *pString = pDepList->First();
+ while ( pString )
+ {
+ delete pString;
+ pString = pDepList->Next();
+ }
+ delete pDepList;
+
+ pDepList = NULL;
+ }
+}
+
+/*****************************************************************************/
+ByteString CommandData::GetOSTypeString()
+/*****************************************************************************/
+{
+ ByteString aRetStr;
+
+ switch (nOSType)
+ {
+ case OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX :
+ aRetStr = "all";
+ break;
+ case OS_WIN32 | OS_WIN16 :
+ aRetStr = "w";
+ break;
+ case OS_OS2 :
+ aRetStr = "p";
+ break;
+ case OS_UNX :
+ aRetStr = "u";
+ break;
+ case OS_WIN16 :
+ aRetStr = "d";
+ break;
+ case OS_WIN32 :
+ aRetStr = "n";
+ break;
+ default :
+ aRetStr = "none";
+ }
+
+ return aRetStr;
+}
+
+/*****************************************************************************/
+ByteString CommandData::GetCommandTypeString()
+/*****************************************************************************/
+{
+ ByteString aRetStr;
+
+ switch (nCommand)
+ {
+ case COMMAND_NMAKE :
+ aRetStr = "nmake";
+ break;
+ case COMMAND_GET :
+ aRetStr = "get";
+ break;
+ default :
+ aRetStr = "usr";
+ aRetStr += ByteString::CreateFromInt64( nCommand + 1 - COMMAND_USER_START );
+
+ }
+
+ return aRetStr;
+}
+
+/*****************************************************************************/
+CommandData* Prj::GetDirectoryList ( USHORT, USHORT )
+/*****************************************************************************/
+{
+ return (CommandData *)NULL;
+}
+
+/*****************************************************************************/
+CommandData* Prj::GetDirectoryData( ByteString aLogFileName )
+/*****************************************************************************/
+{
+ CommandData *pData = NULL;
+ ULONG nObjCount = Count();
+ for ( ULONG i=0; i<nObjCount; i++ )
+ {
+ pData = GetObject(i);
+ if ( pData->GetLogFile() == aLogFileName )
+ return pData;
+ }
+ return NULL;
+}
+
+//
+// class Prj
+//
+
+/*****************************************************************************/
+Prj::Prj() :
+ bVisited( FALSE ),
+ pPrjInitialDepList(0),
+ pPrjDepList(0),
+ bHardDependencies( FALSE ),
+ bSorted( FALSE )
+/*****************************************************************************/
+{
+}
+
+/*****************************************************************************/
+Prj::Prj( ByteString aName ) :
+ bVisited( FALSE ),
+ aProjectName( aName ),
+ pPrjInitialDepList(0),
+ pPrjDepList(0),
+ bHardDependencies( FALSE ),
+ bSorted( FALSE )
+/*****************************************************************************/
+{
+}
+
+/*****************************************************************************/
+Prj::~Prj()
+/*****************************************************************************/
+{
+ if ( pPrjDepList )
+ {
+ ByteString *pString = pPrjDepList->First();
+ while ( pString )
+ {
+ delete pString;
+ pString = pPrjDepList->Next();
+ }
+ delete pPrjDepList;
+
+ pPrjDepList = NULL;
+ }
+
+ if ( pPrjInitialDepList )
+ {
+ ByteString *pString = pPrjInitialDepList->First();
+ while ( pString )
+ {
+ delete pString;
+ pString = pPrjInitialDepList->Next();
+ }
+ delete pPrjInitialDepList;
+
+ pPrjInitialDepList = NULL;
+ }
+}
+
+/*****************************************************************************/
+void Prj::AddDependencies( ByteString aStr )
+/*****************************************************************************/
+{
+
+ // needs dirty flag - not expanded
+ if ( !pPrjDepList )
+ pPrjDepList = new SByteStringList;
+
+ pPrjDepList->PutString( new ByteString(aStr) );
+
+ if ( !pPrjInitialDepList )
+ pPrjInitialDepList = new SByteStringList;
+
+ pPrjInitialDepList->PutString( new ByteString(aStr) );
+}
+
+/*****************************************************************************/
+SByteStringList* Prj::GetDependencies( BOOL bExpanded )
+/*****************************************************************************/
+{
+ if ( bExpanded )
+ return pPrjDepList;
+ else
+ return pPrjInitialDepList;
+}
+
+
+
+/*****************************************************************************/
+BOOL Prj::InsertDirectory ( ByteString aDirName, USHORT aWhat,
+ USHORT aWhatOS, ByteString aLogFileName,
+ const ByteString &rClientRestriction )
+/*****************************************************************************/
+{
+ CommandData* pData = new CommandData();
+
+ pData->SetPath( aDirName );
+ pData->SetCommandType( aWhat );
+ pData->SetOSType( aWhatOS );
+ pData->SetLogFile( aLogFileName );
+ pData->SetClientRestriction( rClientRestriction );
+
+ Insert( pData );
+
+ return FALSE;
+}
+
+/*****************************************************************************/
+//
+// removes directory and existing dependencies on it
+//
+CommandData* Prj::RemoveDirectory ( ByteString aLogFileName )
+/*****************************************************************************/
+{
+ ULONG nCountMember = Count();
+ CommandData* pData;
+ CommandData* pDataFound = NULL;
+ SByteStringList* pDataDeps;
+
+ for ( USHORT i = 0; i < nCountMember; i++ )
+ {
+ pData = GetObject( i );
+ if ( pData->GetLogFile() == aLogFileName )
+ pDataFound = pData;
+ else
+ {
+ pDataDeps = pData->GetDependencies();
+ if ( pDataDeps )
+ {
+ ByteString* pString;
+ ULONG nDataDepsCount = pDataDeps->Count();
+ for ( ULONG j = nDataDepsCount; j > 0; j-- )
+ {
+ pString = pDataDeps->GetObject( j - 1 );
+ if ( pString->GetToken( 0, '.') == aLogFileName )
+ pDataDeps->Remove( pString );
+ }
+ }
+ }
+ }
+
+ Remove( pDataFound );
+
+ return pDataFound;
+}
+
+//
+// class Star
+//
+
+/*****************************************************************************/
+Star::Star()
+/*****************************************************************************/
+{
+ // this ctor is only used by StarWriter
+}
+
+/*****************************************************************************/
+Star::Star(String aFileName, USHORT nMode )
+/*****************************************************************************/
+ : nStarMode( nMode )
+{
+ Read( aFileName );
+}
+
+/*****************************************************************************/
+Star::Star( SolarFileList *pSolarFiles )
+/*****************************************************************************/
+ : nStarMode( STAR_MODE_MULTIPLE_PARSE )
+{
+ // this ctor is used by StarBuilder to get the information for the whole workspace
+ Read( pSolarFiles );
+}
+
+/*****************************************************************************/
+Star::Star( GenericInformationList *pStandLst, ByteString &rVersion,
+ BOOL bLocal, const char *pSourceRoot )
+/*****************************************************************************/
+{
+ ByteString sPath( rVersion );
+ String sSrcRoot;
+ if ( pSourceRoot )
+ sSrcRoot = String::CreateFromAscii( pSourceRoot );
+
+#ifdef UNX
+ sPath += "/settings/UNXSOLARLIST";
+#else
+ sPath += "/settings/SOLARLIST";
+#endif
+ GenericInformation *pInfo = pStandLst->GetInfo( sPath, TRUE );
+
+ if( pInfo && pInfo->GetValue().Len()) {
+ ByteString sFile( pInfo->GetValue());
+ if ( bLocal ) {
+ IniManager aIniManager;
+ aIniManager.ToLocal( sFile );
+ }
+ String sFileName( sFile, RTL_TEXTENCODING_ASCII_US );
+ nStarMode = STAR_MODE_SINGLE_PARSE;
+ Read( sFileName );
+ }
+ else {
+ SolarFileList *pFileList = new SolarFileList();
+
+ sPath = rVersion;
+ sPath += "/drives";
+
+ GenericInformation *pInfo2 = pStandLst->GetInfo( sPath, TRUE );
+ if ( pInfo2 && pInfo2->GetSubList()) {
+ GenericInformationList *pDrives = pInfo2->GetSubList();
+ for ( ULONG i = 0; i < pDrives->Count(); i++ ) {
+ GenericInformation *pDrive = pDrives->GetObject( i );
+ if ( pDrive ) {
+ DirEntry aEntry;
+ BOOL bOk = FALSE;
+ if ( sSrcRoot.Len()) {
+ aEntry = DirEntry( sSrcRoot );
+ bOk = TRUE;
+ }
+ else {
+#ifdef UNX
+ sPath = "UnixVolume";
+ GenericInformation *pUnixVolume = pDrive->GetSubInfo( sPath );
+ if ( pUnixVolume ) {
+ String sRoot( pUnixVolume->GetValue(), RTL_TEXTENCODING_ASCII_US );
+ aEntry = DirEntry( sRoot );
+ bOk = TRUE;
+ }
+#else
+ bOk = TRUE;
+ String sRoot( *pDrive, RTL_TEXTENCODING_ASCII_US );
+ sRoot += String::CreateFromAscii( "\\" );
+ aEntry = DirEntry( sRoot );
+#endif
+ }
+ if ( bOk ) {
+ sPath = "projects";
+ GenericInformation *pProjectsKey = pDrive->GetSubInfo( sPath, TRUE );
+ if ( pProjectsKey ) {
+ if ( !sSrcRoot.Len()) {
+ sPath = rVersion;
+ sPath += "/settings/PATH";
+ GenericInformation *pPath = pStandLst->GetInfo( sPath, TRUE );
+ if( pPath ) {
+ ByteString sAddPath( pPath->GetValue());
+#ifdef UNX
+ sAddPath.SearchAndReplaceAll( "\\", "/" );
+#else
+ sAddPath.SearchAndReplaceAll( "/", "\\" );
+#endif
+ String ssAddPath( sAddPath, RTL_TEXTENCODING_ASCII_US );
+ aEntry += DirEntry( ssAddPath );
+ }
+ }
+ GenericInformationList *pProjects = pProjectsKey->GetSubList();
+ if ( pProjects ) {
+ String sPrjDir( String::CreateFromAscii( "prj" ));
+ String sSolarFile( String::CreateFromAscii( "build.lst" ));
+
+ for ( ULONG j = 0; j < pProjects->Count(); j++ ) {
+ ByteString sProject( *pProjects->GetObject( j ));
+ String ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
+
+ DirEntry aPrjEntry( aEntry );
+
+ aPrjEntry += DirEntry( ssProject );
+ aPrjEntry += DirEntry( sPrjDir );
+ aPrjEntry += DirEntry( sSolarFile );
+
+ pFileList->Insert( new String( aPrjEntry.GetFull()), LIST_APPEND );
+
+ ByteString sFile( aPrjEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ Read( pFileList );
+ }
+}
+
+/*****************************************************************************/
+Star::~Star()
+/*****************************************************************************/
+{
+}
+
+/*****************************************************************************/
+BOOL Star::NeedsUpdate()
+/*****************************************************************************/
+{
+ aMutex.acquire();
+ for ( ULONG i = 0; i < aLoadedFilesList.Count(); i++ )
+ if ( aLoadedFilesList.GetObject( i )->NeedsUpdate()) {
+ aMutex.release();
+ return TRUE;
+ }
+
+ aMutex.release();
+ return FALSE;
+}
+
+/*****************************************************************************/
+void Star::Read( String &rFileName )
+/*****************************************************************************/
+{
+ ByteString aString;
+ aFileList.Insert( new String( rFileName ));
+
+ DirEntry aEntry( rFileName );
+ aEntry.ToAbs();
+ aEntry = aEntry.GetPath().GetPath().GetPath();
+ sSourceRoot = aEntry.GetFull();
+
+ while( aFileList.Count()) {
+ StarFile *pFile = new StarFile( *aFileList.GetObject(( ULONG ) 0 ));
+ if ( pFile->Exists()) {
+ SimpleConfig aSolarConfig( *aFileList.GetObject(( ULONG ) 0 ));
+ while (( aString = aSolarConfig.GetNext()) != "" )
+ InsertToken (( char * ) aString.GetBuffer());
+ }
+ aMutex.acquire();
+ aLoadedFilesList.Insert( pFile, LIST_APPEND );
+ aMutex.release();
+ aFileList.Remove(( ULONG ) 0 );
+ }
+ // resolve all dependencies recursive
+ Expand_Impl();
+}
+
+/*****************************************************************************/
+void Star::Read( SolarFileList *pSolarFiles )
+/*****************************************************************************/
+{
+ while( pSolarFiles->Count()) {
+ ByteString aString;
+
+ StarFile *pFile = new StarFile( *pSolarFiles->GetObject(( ULONG ) 0 ));
+ if ( pFile->Exists()) {
+ SimpleConfig aSolarConfig( *pSolarFiles->GetObject(( ULONG ) 0 ));
+ while (( aString = aSolarConfig.GetNext()) != "" )
+ InsertToken (( char * ) aString.GetBuffer());
+ }
+
+ aMutex.acquire();
+ aLoadedFilesList.Insert( pFile, LIST_APPEND );
+ aMutex.release();
+ delete pSolarFiles->Remove(( ULONG ) 0 );
+ }
+ delete pSolarFiles;
+
+ Expand_Impl();
+}
+
+/*****************************************************************************/
+String Star::CreateFileName( String sProject )
+/*****************************************************************************/
+{
+ // this method is used to find solarlist parts of nabours (other projects)
+ String sPrjDir( String::CreateFromAscii( "prj" ));
+ String sSolarFile( String::CreateFromAscii( "build.lst" ));
+
+ DirEntry aEntry( sSourceRoot );
+ aEntry += DirEntry( sProject );
+ aEntry += DirEntry( sPrjDir );
+ aEntry += DirEntry( sSolarFile );
+
+ if ( !aEntry.Exists() && aDBNotFoundHdl.IsSet())
+ aDBNotFoundHdl.Call( &sProject );
+
+ return aEntry.GetFull();
+}
+
+/*****************************************************************************/
+void Star::InsertSolarList( String sProject )
+/*****************************************************************************/
+{
+ // inserts a new solarlist part of another project
+ String sFileName( CreateFileName( sProject ));
+
+ for ( ULONG i = 0; i < aFileList.Count(); i++ ) {
+ if (( *aFileList.GetObject( i )) == sFileName )
+ return;
+ }
+
+ ByteString ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
+ if ( HasProject( ssProject ))
+ return;
+
+ aFileList.Insert( new String( sFileName ), LIST_APPEND );
+}
+
+/*****************************************************************************/
+void Star::ExpandPrj_Impl( Prj *pPrj, Prj *pDepPrj )
+/*****************************************************************************/
+{
+ if ( pDepPrj->bVisited )
+ return;
+
+ pDepPrj->bVisited = TRUE;
+
+ SByteStringList* pPrjLst = pPrj->GetDependencies();
+ SByteStringList* pDepLst = NULL;
+ ByteString* pDepend;
+ ByteString* pPutStr;
+ Prj *pNextPrj = NULL;
+ ULONG i, nRetPos;
+
+ if ( pPrjLst ) {
+ pDepLst = pDepPrj->GetDependencies();
+ if ( pDepLst ) {
+ for ( i = 0; i < pDepLst->Count(); i++ ) {
+ pDepend = pDepLst->GetObject( i );
+ pPutStr = new ByteString( *pDepend );
+ nRetPos = pPrjLst->PutString( pPutStr );
+ if( nRetPos == NOT_THERE )
+ delete pPutStr;
+ pNextPrj = GetPrj( *pDepend );
+ if ( pNextPrj ) {
+ ExpandPrj_Impl( pPrj, pNextPrj );
+ }
+ }
+ }
+ }
+}
+
+/*****************************************************************************/
+void Star::Expand_Impl()
+/*****************************************************************************/
+{
+ for ( ULONG i = 0; i < Count(); i++ ) {
+ for ( ULONG j = 0; j < Count(); j++ )
+ GetObject( j )->bVisited = FALSE;
+
+ Prj* pPrj = GetObject( i );
+ ExpandPrj_Impl( pPrj, pPrj );
+ }
+}
+
+/*****************************************************************************/
+void Star::InsertToken ( char *yytext )
+/*****************************************************************************/
+{
+ static int i = 0;
+ static ByteString aDirName, aWhat, aWhatOS,
+ sClientRestriction, aLogFileName, aProjectName, aPrefix, aCommandPara;
+ static BOOL bPrjDep = FALSE;
+ static BOOL bHardDep = FALSE;
+ static USHORT nCommandType, nOSType;
+ CommandData* pCmdData;
+ static SByteStringList *pStaticDepList;
+ Prj* pPrj;
+
+ switch (i)
+ {
+ case 0:
+ aPrefix = yytext;
+ pStaticDepList = 0;
+ break;
+ case 1:
+ aDirName = yytext;
+ break;
+ case 2:
+ if ( !strcmp( yytext, ":" ))
+ {
+ bPrjDep = TRUE;
+ bHardDep = FALSE;
+ i = 9;
+ }
+ else if ( !strcmp( yytext, "::" ))
+ {
+ bPrjDep = TRUE;
+ bHardDep = TRUE;
+ i = 9;
+ }
+ else
+ {
+ bPrjDep = FALSE;
+ bHardDep = FALSE;
+
+ aWhat = yytext;
+ if ( aWhat == "nmake" )
+ nCommandType = COMMAND_NMAKE;
+ else if ( aWhat == "get" )
+ nCommandType = COMMAND_GET;
+ else {
+ ULONG nOffset = aWhat.Copy( 3 ).ToInt32();
+ nCommandType = sal::static_int_cast< USHORT >(
+ COMMAND_USER_START + nOffset - 1);
+ }
+ }
+ break;
+ case 3:
+ if ( !bPrjDep )
+ {
+ aWhat = yytext;
+ if ( aWhat == "-" )
+ {
+ aCommandPara = ByteString();
+ }
+ else
+ aCommandPara = aWhat;
+ }
+ break;
+ case 4:
+ if ( !bPrjDep )
+ {
+ aWhatOS = yytext;
+ if ( aWhatOS.GetTokenCount( ',' ) > 1 ) {
+ sClientRestriction = aWhatOS.Copy( aWhatOS.GetToken( 0, ',' ).Len() + 1 );
+ aWhatOS = aWhatOS.GetToken( 0, ',' );
+ }
+ if ( aWhatOS == "all" )
+ nOSType = ( OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX );
+ else if ( aWhatOS == "w" )
+ nOSType = ( OS_WIN16 | OS_WIN32 );
+ else if ( aWhatOS == "p" )
+ nOSType = OS_OS2;
+ else if ( aWhatOS == "u" )
+ nOSType = OS_UNX;
+ else if ( aWhatOS == "d" )
+ nOSType = OS_WIN16;
+ else if ( aWhatOS == "n" )
+ nOSType = OS_WIN32;
+ else
+ nOSType = OS_NONE;
+ }
+ break;
+ case 5:
+ if ( !bPrjDep )
+ {
+ aLogFileName = yytext;
+ }
+ break;
+ default:
+ if ( !bPrjDep )
+ {
+ ByteString aItem = yytext;
+ if ( aItem == "NULL" )
+ {
+ // Liste zu Ende
+ i = -1;
+ }
+ else
+ {
+ // ggfs. Dependency liste anlegen und ergaenzen
+ if ( !pStaticDepList )
+ pStaticDepList = new SByteStringList;
+ pStaticDepList->PutString( new ByteString( aItem ));
+ }
+ }
+ else
+ {
+ ByteString aItem = yytext;
+ if ( aItem == "NULL" )
+ {
+ // Liste zu Ende
+ i = -1;
+ bPrjDep= FALSE;
+ }
+ else
+ {
+ aProjectName = aDirName.GetToken ( 0, '\\');
+ if ( HasProject( aProjectName ))
+ {
+ pPrj = GetPrj( aProjectName );
+ // Projekt exist. schon, neue Eintraege anhaengen
+ }
+ else
+ {
+ // neues Project anlegen
+ pPrj = new Prj ( aProjectName );
+ pPrj->SetPreFix( aPrefix );
+ Insert(pPrj,LIST_APPEND);
+ }
+ pPrj->AddDependencies( aItem );
+ pPrj->HasHardDependencies( bHardDep );
+
+ if ( nStarMode == STAR_MODE_RECURSIVE_PARSE ) {
+ String sItem( aItem, RTL_TEXTENCODING_ASCII_US );
+ InsertSolarList( sItem );
+ }
+ }
+ }
+ break;
+ }
+ /* Wenn dieses Project noch nicht vertreten ist, in die Liste
+ der Solar-Projekte einfuegen */
+ if ( i == -1 )
+ {
+ aProjectName = aDirName.GetToken ( 0, '\\');
+ if ( HasProject( aProjectName ))
+ {
+ pPrj = GetPrj( aProjectName );
+ // Projekt exist. schon, neue Eintraege anhaengen
+ }
+ else
+ {
+ // neues Project anlegen
+ pPrj = new Prj ( aProjectName );
+ pPrj->SetPreFix( aPrefix );
+ Insert(pPrj,LIST_APPEND);
+ }
+
+ pCmdData = new CommandData;
+ pCmdData->SetPath( aDirName );
+ pCmdData->SetCommandType( nCommandType );
+ pCmdData->SetCommandPara( aCommandPara );
+ pCmdData->SetOSType( nOSType );
+ pCmdData->SetLogFile( aLogFileName );
+ pCmdData->SetClientRestriction( sClientRestriction );
+ if ( pStaticDepList )
+ pCmdData->SetDependencies( pStaticDepList );
+
+ pStaticDepList = 0;
+ pPrj->Insert ( pCmdData, LIST_APPEND );
+ aDirName ="";
+ aWhat ="";
+ aWhatOS = "";
+ sClientRestriction = "";
+ aLogFileName = "";
+ nCommandType = 0;
+ nOSType = 0;
+ }
+ i++;
+
+ // und wer raeumt die depLst wieder ab ?
+}
+
+/*****************************************************************************/
+BOOL Star::HasProject ( ByteString aProjectName )
+/*****************************************************************************/
+{
+ Prj *pPrj;
+ int nCountMember;
+
+ nCountMember = Count();
+
+ for ( int i=0; i<nCountMember; i++)
+ {
+ pPrj = GetObject(i);
+ if ( pPrj->GetProjectName().EqualsIgnoreCaseAscii(aProjectName) )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*****************************************************************************/
+Prj* Star::GetPrj ( ByteString aProjectName )
+/*****************************************************************************/
+{
+ Prj* pPrj;
+ int nCountMember = Count();
+ for ( int i=0;i<nCountMember;i++)
+ {
+ pPrj = GetObject(i);
+ if ( pPrj->GetProjectName().EqualsIgnoreCaseAscii(aProjectName) )
+ return pPrj;
+ }
+// return (Prj*)NULL;
+ return 0L ;
+}
+
+/*****************************************************************************/
+ByteString Star::GetPrjName( DirEntry &aPath )
+/*****************************************************************************/
+{
+ ByteString aRetPrj, aDirName;
+ ByteString aFullPathName = ByteString( aPath.GetFull(), gsl_getSystemTextEncoding());
+
+ xub_StrLen nToken = aFullPathName.GetTokenCount(PATH_DELIMETER);
+ for ( xub_StrLen i=0; i< nToken; i++ )
+ {
+ aDirName = aFullPathName.GetToken( i, PATH_DELIMETER );
+ if ( HasProject( aDirName ))
+ {
+ aRetPrj = aDirName;
+ break;
+ }
+ }
+
+ return aRetPrj;
+}
+
+
+//
+// class StarWriter
+//
+
+/*****************************************************************************/
+StarWriter::StarWriter( String aFileName, BOOL bReadComments, USHORT nMode )
+/*****************************************************************************/
+{
+ Read ( aFileName, bReadComments, nMode );
+}
+
+/*****************************************************************************/
+StarWriter::StarWriter( SolarFileList *pSolarFiles, BOOL bReadComments )
+/*****************************************************************************/
+{
+ Read( pSolarFiles, bReadComments );
+}
+
+/*****************************************************************************/
+StarWriter::StarWriter( GenericInformationList *pStandLst, ByteString &rVersion,
+ BOOL bLocal, const char *pSourceRoot )
+/*****************************************************************************/
+{
+ ByteString sPath( rVersion );
+ String sSrcRoot;
+ if ( pSourceRoot )
+ sSrcRoot = String::CreateFromAscii( pSourceRoot );
+
+#ifdef UNX
+ sPath += "/settings/UNXSOLARLIST";
+#else
+ sPath += "/settings/SOLARLIST";
+#endif
+ GenericInformation *pInfo = pStandLst->GetInfo( sPath, TRUE );
+
+ if( pInfo && pInfo->GetValue().Len()) {
+ ByteString sFile( pInfo->GetValue());
+ if ( bLocal ) {
+ IniManager aIniManager;
+ aIniManager.ToLocal( sFile );
+ }
+ String sFileName( sFile, RTL_TEXTENCODING_ASCII_US );
+ nStarMode = STAR_MODE_SINGLE_PARSE;
+ Read( sFileName );
+ }
+ else {
+ SolarFileList *pFileList = new SolarFileList();
+
+ sPath = rVersion;
+ sPath += "/drives";
+
+ GenericInformation *pInfo2 = pStandLst->GetInfo( sPath, TRUE );
+ if ( pInfo2 && pInfo2->GetSubList()) {
+ GenericInformationList *pDrives = pInfo2->GetSubList();
+ for ( ULONG i = 0; i < pDrives->Count(); i++ ) {
+ GenericInformation *pDrive = pDrives->GetObject( i );
+ if ( pDrive ) {
+ DirEntry aEntry;
+ BOOL bOk = FALSE;
+ if ( sSrcRoot.Len()) {
+ aEntry = DirEntry( sSrcRoot );
+ bOk = TRUE;
+ }
+ else {
+#ifdef UNX
+ sPath = "UnixVolume";
+ GenericInformation *pUnixVolume = pDrive->GetSubInfo( sPath );
+ if ( pUnixVolume ) {
+ String sRoot( pUnixVolume->GetValue(), RTL_TEXTENCODING_ASCII_US );
+ aEntry = DirEntry( sRoot );
+ bOk = TRUE;
+ }
+#else
+ bOk = TRUE;
+ String sRoot( *pDrive, RTL_TEXTENCODING_ASCII_US );
+ sRoot += String::CreateFromAscii( "\\" );
+ aEntry = DirEntry( sRoot );
+#endif
+ }
+ if ( bOk ) {
+ sPath = "projects";
+ GenericInformation *pProjectsKey = pDrive->GetSubInfo( sPath, TRUE );
+ if ( pProjectsKey ) {
+ if ( !sSrcRoot.Len()) {
+ sPath = rVersion;
+ sPath += "/settings/PATH";
+ GenericInformation *pPath = pStandLst->GetInfo( sPath, TRUE );
+ if( pPath ) {
+ ByteString sAddPath( pPath->GetValue());
+#ifdef UNX
+ sAddPath.SearchAndReplaceAll( "\\", "/" );
+#else
+ sAddPath.SearchAndReplaceAll( "/", "\\" );
+#endif
+ String ssAddPath( sAddPath, RTL_TEXTENCODING_ASCII_US );
+ aEntry += DirEntry( ssAddPath );
+ }
+ }
+ GenericInformationList *pProjects = pProjectsKey->GetSubList();
+ if ( pProjects ) {
+ String sPrjDir( String::CreateFromAscii( "prj" ));
+ String sSolarFile( String::CreateFromAscii( "build.lst" ));
+
+ for ( ULONG j = 0; j < pProjects->Count(); j++ ) {
+ ByteString sProject( *pProjects->GetObject( j ));
+ String ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
+
+ DirEntry aPrjEntry( aEntry );
+
+ aPrjEntry += DirEntry( ssProject );
+ aPrjEntry += DirEntry( sPrjDir );
+ aPrjEntry += DirEntry( sSolarFile );
+
+ pFileList->Insert( new String( aPrjEntry.GetFull()), LIST_APPEND );
+
+ ByteString sFile( aPrjEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
+ fprintf( stdout, "%s\n", sFile.GetBuffer());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ Read( pFileList );
+ }
+}
+
+/*****************************************************************************/
+void StarWriter::CleanUp()
+/*****************************************************************************/
+{
+ Expand_Impl();
+}
+
+/*****************************************************************************/
+USHORT StarWriter::Read( String aFileName, BOOL bReadComments, USHORT nMode )
+/*****************************************************************************/
+{
+ nStarMode = nMode;
+
+ ByteString aString;
+ aFileList.Insert( new String( aFileName ));
+
+ DirEntry aEntry( aFileName );
+ aEntry.ToAbs();
+ aEntry = aEntry.GetPath().GetPath().GetPath();
+ sSourceRoot = aEntry.GetFull();
+
+ while( aFileList.Count()) {
+
+ StarFile *pFile = new StarFile( *aFileList.GetObject(( ULONG ) 0 ));
+ if ( pFile->Exists()) {
+ SimpleConfig aSolarConfig( *aFileList.GetObject(( ULONG ) 0 ));
+ while (( aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != "" )
+ InsertTokenLine ( aString );
+ }
+
+ aMutex.acquire();
+ aLoadedFilesList.Insert( pFile, LIST_APPEND );
+ aMutex.release();
+ delete aFileList.Remove(( ULONG ) 0 );
+ }
+ // resolve all dependencies recursive
+ Expand_Impl();
+
+ // Die gefundenen Abhaengigkeiten rekursiv aufloesen
+ Expand_Impl();
+ return 0;
+}
+
+/*****************************************************************************/
+USHORT StarWriter::Read( SolarFileList *pSolarFiles, BOOL bReadComments )
+/*****************************************************************************/
+{
+ nStarMode = STAR_MODE_MULTIPLE_PARSE;
+
+ // this ctor is used by StarBuilder to get the information for the whole workspace
+ while( pSolarFiles->Count()) {
+ ByteString aString;
+
+ StarFile *pFile = new StarFile( *pSolarFiles->GetObject(( ULONG ) 0 ));
+ if ( pFile->Exists()) {
+ SimpleConfig aSolarConfig( *pSolarFiles->GetObject(( ULONG ) 0 ));
+ while (( aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != "" )
+ InsertTokenLine ( aString );
+ }
+
+ aMutex.acquire();
+ aLoadedFilesList.Insert( pFile, LIST_APPEND );
+ aMutex.release();
+ delete pSolarFiles->Remove(( ULONG ) 0 );
+ }
+ delete pSolarFiles;
+
+ Expand_Impl();
+ return 0;
+}
+
+/*****************************************************************************/
+USHORT StarWriter::WritePrj( Prj *pPrj, SvFileStream& rStream )
+/*****************************************************************************/
+{
+ ByteString aDataString;
+ ByteString aTab('\t');
+ ByteString aSpace(' ');
+ ByteString aEmptyString("");
+ SByteStringList* pCmdDepList;
+
+ CommandData* pCmdData = NULL;
+ if ( pPrj->Count() > 0 )
+ {
+ pCmdData = pPrj->First();
+ SByteStringList* pPrjDepList = pPrj->GetDependencies( FALSE );
+ if ( pPrjDepList != 0 )
+ {
+ aDataString = pPrj->GetPreFix();
+ aDataString += aTab;
+ aDataString += pPrj->GetProjectName();
+ aDataString += aTab;
+ if ( pPrj->HasHardDependencies())
+ aDataString+= ByteString("::");
+ else
+ aDataString+= ByteString(":");
+ aDataString += aTab;
+ for ( USHORT i = 0; i< pPrjDepList->Count(); i++ ) {
+ aDataString += *pPrjDepList->GetObject( i );
+ aDataString += aSpace;
+ }
+ aDataString+= "NULL";
+
+ rStream.WriteLine( aDataString );
+
+ pCmdData = pPrj->Next();
+ }
+ if ( pCmdData ) {
+ do
+ {
+ if (( aDataString = pCmdData->GetComment()) == aEmptyString )
+ {
+ aDataString = pPrj->GetPreFix();
+ aDataString += aTab;
+
+ aDataString+= pCmdData->GetPath();
+ aDataString += aTab;
+ USHORT nPathLen = pCmdData->GetPath().Len();
+ if ( nPathLen < 40 )
+ for ( int i = 0; i < 9 - pCmdData->GetPath().Len() / 4 ; i++ )
+ aDataString += aTab;
+ else
+ for ( int i = 0; i < 12 - pCmdData->GetPath().Len() / 4 ; i++ )
+ aDataString += aTab;
+ aDataString += pCmdData->GetCommandTypeString();
+ aDataString += aTab;
+ if ( pCmdData->GetCommandType() == COMMAND_GET )
+ aDataString += aTab;
+ if ( pCmdData->GetCommandPara() == aEmptyString )
+ aDataString+= ByteString("-");
+ else
+ aDataString+= pCmdData->GetCommandPara();
+ aDataString += aTab;
+ aDataString+= pCmdData->GetOSTypeString();
+ if ( pCmdData->GetClientRestriction().Len()) {
+ aDataString += ByteString( "," );
+ aDataString += pCmdData->GetClientRestriction();
+ }
+ aDataString += aTab;
+ aDataString += pCmdData->GetLogFile();
+ aDataString += aSpace;
+
+ pCmdDepList = pCmdData->GetDependencies();
+ if ( pCmdDepList )
+ for ( USHORT i = 0; i< pCmdDepList->Count(); i++ ) {
+ aDataString += *pCmdDepList->GetObject( i );
+ aDataString += aSpace;
+ }
+ aDataString += "NULL";
+ }
+
+ rStream.WriteLine( aDataString );
+
+ pCmdData = pPrj->Next();
+ } while ( pCmdData );
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+USHORT StarWriter::Write( String aFileName )
+/*****************************************************************************/
+{
+ SvFileStream aFileStream;
+
+ aFileStream.Open( aFileName, STREAM_WRITE | STREAM_TRUNC);
+
+ if ( Count() > 0 )
+ {
+ Prj* pPrj = First();
+ do
+ {
+ WritePrj( pPrj, aFileStream );
+ pPrj = Next();
+ } while ( pPrj );
+ }
+
+ aFileStream.Close();
+
+ return 0;
+}
+
+/*****************************************************************************/
+USHORT StarWriter::WriteMultiple( String rSourceRoot )
+/*****************************************************************************/
+{
+ if ( Count() > 0 )
+ {
+ String sPrjDir( String::CreateFromAscii( "prj" ));
+ String sSolarFile( String::CreateFromAscii( "build.lst" ));
+
+ Prj* pPrj = First();
+ do
+ {
+ String sName( pPrj->GetProjectName(), RTL_TEXTENCODING_ASCII_US );
+
+ DirEntry aEntry( rSourceRoot );
+ aEntry += DirEntry( sName );
+ aEntry += DirEntry( sPrjDir );
+ aEntry += DirEntry( sSolarFile );
+
+ SvFileStream aFileStream;
+ aFileStream.Open( aEntry.GetFull(), STREAM_WRITE | STREAM_TRUNC);
+
+ WritePrj( pPrj, aFileStream );
+
+ aFileStream.Close();
+
+ pPrj = Next();
+ } while ( pPrj );
+ }
+
+ return 0;
+}
+
+/*****************************************************************************/
+void StarWriter::InsertTokenLine ( ByteString& rString )
+/*****************************************************************************/
+{
+ int i = 0;
+ ByteString aWhat, aWhatOS,
+ sClientRestriction, aLogFileName, aProjectName, aPrefix, aCommandPara;
+ static ByteString aDirName;
+ BOOL bPrjDep = FALSE;
+ BOOL bHardDep = FALSE;
+ USHORT nCommandType = 0;
+ USHORT nOSType = 0;
+ CommandData* pCmdData;
+ SByteStringList *pDepList2 = NULL;
+ Prj* pPrj;
+
+ ByteString aEmptyString;
+ ByteString aToken = rString.GetToken( 0, '\t' );
+ ByteString aCommentString;
+
+ const char* yytext = aToken.GetBuffer();
+
+ while ( !( aToken == aEmptyString ) )
+ {
+ switch (i)
+ {
+ case 0:
+ if ( rString.Search( "#" ) == 0 )
+ {
+ i = -1;
+ aCommentString = rString;
+ rString = aEmptyString;
+ if ( Count() == 0 )
+ aDirName = "null_entry" ; //comments at begin of file
+ break;
+ }
+ aPrefix = yytext;
+ pDepList2 = NULL;
+ break;
+ case 1:
+ aDirName = yytext;
+ break;
+ case 2:
+ if ( !strcmp( yytext, ":" ))
+ {
+ bPrjDep = TRUE;
+ bHardDep = FALSE;
+ i = 9;
+ }
+ else if ( !strcmp( yytext, "::" ))
+ {
+ bPrjDep = TRUE;
+ bHardDep = TRUE;
+ i = 9;
+ }
+ else
+ {
+ bPrjDep = FALSE;
+ bHardDep = FALSE;
+
+ aWhat = yytext;
+ if ( aWhat == "nmake" )
+ nCommandType = COMMAND_NMAKE;
+ else if ( aWhat == "get" )
+ nCommandType = COMMAND_GET;
+ else {
+ ULONG nOffset = aWhat.Copy( 3 ).ToInt32();
+ nCommandType = sal::static_int_cast< USHORT >(
+ COMMAND_USER_START + nOffset - 1);
+ }
+ }
+ break;
+ case 3:
+ if ( !bPrjDep )
+ {
+ aWhat = yytext;
+ if ( aWhat == "-" )
+ {
+ aCommandPara = ByteString();
+ }
+ else
+ aCommandPara = aWhat;
+ }
+ break;
+ case 4:
+ if ( !bPrjDep )
+ {
+ aWhatOS = yytext;
+ if ( aWhatOS.GetTokenCount( ',' ) > 1 ) {
+ sClientRestriction = aWhatOS.Copy( aWhatOS.GetToken( 0, ',' ).Len() + 1 );
+ aWhatOS = aWhatOS.GetToken( 0, ',' );
+ }
+ aWhatOS = aWhatOS.GetToken( 0, ',' );
+ if ( aWhatOS == "all" )
+ nOSType = ( OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX );
+ else if ( aWhatOS == "w" )
+ nOSType = ( OS_WIN16 | OS_WIN32 );
+ else if ( aWhatOS == "p" )
+ nOSType = OS_OS2;
+ else if ( aWhatOS == "u" )
+ nOSType = OS_UNX;
+ else if ( aWhatOS == "d" )
+ nOSType = OS_WIN16;
+ else if ( aWhatOS == "n" )
+ nOSType = OS_WIN32;
+ else
+ nOSType = OS_NONE;
+ }
+ break;
+ case 5:
+ if ( !bPrjDep )
+ {
+ aLogFileName = yytext;
+ }
+ break;
+ default:
+ if ( !bPrjDep )
+ {
+ ByteString aItem = yytext;
+ if ( aItem == "NULL" )
+ {
+ // Liste zu Ende
+ i = -1;
+ }
+ else
+ {
+ // ggfs. Dependency liste anlegen und ergaenzen
+ if ( !pDepList2 )
+ pDepList2 = new SByteStringList;
+ pDepList2->PutString( new ByteString( aItem ));
+ }
+ }
+ else
+ {
+ ByteString aItem = yytext;
+ if ( aItem == "NULL" )
+ {
+ // Liste zu Ende
+ i = -1;
+ bPrjDep= FALSE;
+ }
+ else
+ {
+ aProjectName = aDirName.GetToken ( 0, '\\');
+ if ( HasProject( aProjectName ))
+ {
+ pPrj = GetPrj( aProjectName );
+ // Projekt exist. schon, neue Eintraege anhaengen
+ }
+ else
+ {
+ // neues Project anlegen
+ pPrj = new Prj ( aProjectName );
+ pPrj->SetPreFix( aPrefix );
+ Insert(pPrj,LIST_APPEND);
+ }
+ pPrj->AddDependencies( aItem );
+ pPrj->HasHardDependencies( bHardDep );
+
+ if ( nStarMode == STAR_MODE_RECURSIVE_PARSE ) {
+ String sItem( aItem, RTL_TEXTENCODING_ASCII_US );
+ InsertSolarList( sItem );
+ }
+ }
+
+ }
+ break;
+ }
+ /* Wenn dieses Project noch nicht vertreten ist, in die Liste
+ der Solar-Projekte einfuegen */
+ if ( i == -1 )
+ {
+ aProjectName = aDirName.GetToken ( 0, '\\');
+ if ( HasProject( aProjectName ))
+ {
+ pPrj = GetPrj( aProjectName );
+ // Projekt exist. schon, neue Eintraege anhaengen
+ }
+ else
+ {
+ // neues Project anlegen
+ pPrj = new Prj ( aProjectName );
+ pPrj->SetPreFix( aPrefix );
+ Insert(pPrj,LIST_APPEND);
+ }
+
+ pCmdData = new CommandData;
+ pCmdData->SetPath( aDirName );
+ pCmdData->SetCommandType( nCommandType );
+ pCmdData->SetCommandPara( aCommandPara );
+ pCmdData->SetOSType( nOSType );
+ pCmdData->SetLogFile( aLogFileName );
+ pCmdData->SetComment( aCommentString );
+ pCmdData->SetClientRestriction( sClientRestriction );
+ if ( pDepList2 )
+ pCmdData->SetDependencies( pDepList2 );
+
+ pPrj->Insert ( pCmdData, LIST_APPEND );
+
+ }
+ i++;
+
+ rString.Erase(0, aToken.Len()+1);
+ aToken = rString.GetToken( 0, '\t' );
+ yytext = aToken.GetBuffer();
+
+ }
+ // und wer raeumt die depLst wieder ab ?
+}
+
+/*****************************************************************************/
+BOOL StarWriter::InsertProject ( Prj* )
+/*****************************************************************************/
+{
+ return FALSE;
+}
+
+/*****************************************************************************/
+Prj* StarWriter::RemoveProject ( ByteString aProjectName )
+/*****************************************************************************/
+{
+ ULONG nCountMember = Count();
+ Prj* pPrj;
+ Prj* pPrjFound = NULL;
+ SByteStringList* pPrjDeps;
+
+ for ( USHORT i = 0; i < nCountMember; i++ )
+ {
+ pPrj = GetObject( i );
+ if ( pPrj->GetProjectName() == aProjectName )
+ pPrjFound = pPrj;
+ else
+ {
+ pPrjDeps = pPrj->GetDependencies( FALSE );
+ if ( pPrjDeps )
+ {
+ ByteString* pString;
+ ULONG nPrjDepsCount = pPrjDeps->Count();
+ for ( ULONG j = nPrjDepsCount; j > 0; j-- )
+ {
+ pString = pPrjDeps->GetObject( j - 1 );
+ if ( pString->GetToken( 0, '.') == aProjectName )
+ pPrjDeps->Remove( pString );
+ }
+ }
+ }
+ }
+
+ Remove( pPrjFound );
+
+ return pPrjFound;
+}
+
+//
+// class StarFile
+//
+
+/*****************************************************************************/
+StarFile::StarFile( const String &rFile )
+/*****************************************************************************/
+ : aFileName( rFile )
+{
+ DirEntry aEntry( aFileName );
+ if ( aEntry.Exists()) {
+ bExists = TRUE;
+ FileStat aStat( aEntry );
+ aDate = aStat.DateModified();
+ aTime = aStat.TimeModified();
+ }
+ else
+ bExists = FALSE;
+}
+
+/*****************************************************************************/
+BOOL StarFile::NeedsUpdate()
+/*****************************************************************************/
+{
+ DirEntry aEntry( aFileName );
+ if ( aEntry.Exists()) {
+ if ( !bExists ) {
+ bExists = TRUE;
+ return TRUE;
+ }
+ FileStat aStat( aEntry );
+ if (( aStat.DateModified() > aDate ) ||
+ (( aStat.DateModified() == aDate ) && ( aStat.TimeModified() > aTime )))
+ return TRUE;
+ }
+ return FALSE;
+}
+
diff --git a/tools/bootstrp/rscdep.cxx b/tools/bootstrp/rscdep.cxx
new file mode 100644
index 000000000000..37edfc6a8c18
--- /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;
+
+SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
+{
+ int c;
+ char aBuf[255];
+ char pFileNamePrefix[255];
+ char pOutputFileName[255];
+ char pSrsFileName[255];
+ String aSrsBaseName;
+ BOOL bSource = 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 = 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 (c)2000 StarOffice\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());
+/* USHORT 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();
+ ULONG nCount = pLst->Count();
+ if ( nCount == 0 )
+ {
+ aOutStream.WriteLine( aString );
+ }
+ else
+ {
+ aString += ByteString( "\\" );
+ aOutStream.WriteLine( aString );
+ }
+
+ for ( ULONG 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;
+}
+
diff --git a/tools/bootstrp/sstring.cxx b/tools/bootstrp/sstring.cxx
new file mode 100644
index 000000000000..8c83dedf72ec
--- /dev/null
+++ b/tools/bootstrp/sstring.cxx
@@ -0,0 +1,317 @@
+/*************************************************************************
+ *
+ * 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"
+
+#ifndef _TOOLS_STRINGLIST
+# define _TOOLS_STRINGLIST
+#endif
+
+#define ENABLE_BYTESTRING_STREAM_OPERATORS
+#include <tools/stream.hxx>
+#include "bootstrp/sstring.hxx"
+
+SByteStringList::SByteStringList()
+{
+}
+
+SByteStringList::~SByteStringList()
+{
+}
+
+ULONG SByteStringList::IsString( ByteString* pStr )
+{
+ ULONG nRet = NOT_THERE;
+ if ( (nRet = GetPrevString( pStr )) != 0 )
+ {
+ ByteString* pString = GetObject( nRet );
+ if ( *pString == *pStr )
+ return nRet;
+ else
+ return NOT_THERE;
+ }
+ else
+ {
+ ByteString* pString = GetObject( 0 );
+ if ( pString && (*pString == *pStr) )
+ return 0;
+ else
+ return NOT_THERE;
+ }
+}
+
+ULONG SByteStringList::GetPrevString( ByteString* pStr )
+{
+ ULONG nRet = 0;
+ BOOL bFound = FALSE;
+ ULONG nCountMember = Count();
+ ULONG nUpper = nCountMember;
+ ULONG nLower = 0;
+ ULONG nCurrent = nUpper / 2;
+ ULONG nRem = 0;
+ ByteString* pString;
+
+ do
+ {
+ if ( (nCurrent == nLower) || (nCurrent == nUpper) )
+ return nLower;
+ pString = GetObject( nCurrent );
+ StringCompare nResult = pStr->CompareTo( *pString );
+ if ( nResult == COMPARE_LESS )
+ {
+ nUpper = nCurrent;
+ nCurrent = (nCurrent + nLower) /2;
+ }
+ else if ( nResult == COMPARE_GREATER )
+ {
+ nLower = nCurrent;
+ nCurrent = (nUpper + nCurrent) /2;
+ }
+ else if ( nResult == COMPARE_EQUAL )
+ return nCurrent;
+ if ( nRem == nCurrent )
+ return nCurrent;
+ nRem = nCurrent;
+ }
+ while ( !bFound );
+ return nRet;
+}
+
+/**************************************************************************
+*
+* Sortiert einen ByteString in die Liste ein und gibt die Position,
+* an der einsortiert wurde, zurueck
+*
+**************************************************************************/
+
+ULONG SByteStringList::PutString( ByteString* pStr )
+{
+ ULONG nPos = GetPrevString ( pStr );
+ if ( Count() )
+ {
+ {
+ ByteString* pString = GetObject( 0 );
+ if ( pString->CompareTo( *pStr ) == COMPARE_GREATER )
+ {
+ Insert( pStr, (ULONG)0 );
+ return (ULONG)0;
+ }
+ }
+ ByteString* pString = GetObject( nPos );
+ if ( *pStr != *pString )
+ {
+ Insert( pStr, nPos+1 );
+ return ( nPos +1 );
+ }
+ }
+ else
+ {
+ Insert( pStr );
+ return (ULONG)0;
+ }
+
+ return NOT_THERE;
+}
+
+ByteString* SByteStringList::RemoveString( const ByteString& rName )
+{
+ ULONG i;
+ ByteString* pReturn;
+
+ for( i = 0 ; i < Count(); i++ )
+ {
+ if ( rName == *GetObject( i ) )
+ {
+ pReturn = GetObject(i);
+ Remove(i);
+ return pReturn;
+ }
+ }
+
+ return NULL;
+}
+
+void SByteStringList::CleanUp()
+{
+ ByteString* pByteString = First();
+ while (pByteString) {
+ delete pByteString;
+ pByteString = Next();
+ }
+ Clear();
+}
+
+SByteStringList& SByteStringList::operator<< ( SvStream& rStream )
+{
+ sal_uInt32 nListCount;
+ rStream >> nListCount;
+ for ( USHORT i = 0; i < nListCount; i++ ) {
+ ByteString* pByteString = new ByteString();
+ rStream >> *pByteString;
+ Insert (pByteString, LIST_APPEND);
+ }
+ return *this;
+}
+
+SByteStringList& SByteStringList::operator>> ( SvStream& rStream )
+{
+ sal_uInt32 nListCount = Count();
+ rStream << nListCount;
+ ByteString* pByteString = First();
+ while (pByteString) {
+ rStream << *pByteString;
+ pByteString = Next();
+ }
+ return *this;
+}
+
+
+
+
+
+
+
+SUniStringList::SUniStringList()
+{
+}
+
+SUniStringList::~SUniStringList()
+{
+}
+
+ULONG SUniStringList::IsString( UniString* pStr )
+{
+ ULONG nRet = NOT_THERE;
+ if ( (nRet = GetPrevString( pStr )) != 0 )
+ {
+ UniString* pString = GetObject( nRet );
+ if ( *pString == *pStr )
+ return nRet;
+ else
+ return NOT_THERE;
+ }
+ else
+ {
+ UniString* pString = GetObject( 0 );
+ if ( pString && (*pString == *pStr) )
+ return 0;
+ else
+ return NOT_THERE;
+ }
+}
+
+ULONG SUniStringList::GetPrevString( UniString* pStr )
+{
+ ULONG nRet = 0;
+ BOOL bFound = FALSE;
+ ULONG nCountMember = Count();
+ ULONG nUpper = nCountMember;
+ ULONG nLower = 0;
+ ULONG nCurrent = nUpper / 2;
+ ULONG nRem = 0;
+ UniString* pString;
+
+ do
+ {
+ if ( (nCurrent == nLower) || (nCurrent == nUpper) )
+ return nLower;
+ pString = GetObject( nCurrent );
+ StringCompare nResult = pStr->CompareTo( *pString );
+ if ( nResult == COMPARE_LESS )
+ {
+ nUpper = nCurrent;
+ nCurrent = (nCurrent + nLower) /2;
+ }
+ else if ( nResult == COMPARE_GREATER )
+ {
+ nLower = nCurrent;
+ nCurrent = (nUpper + nCurrent) /2;
+ }
+ else if ( nResult == COMPARE_EQUAL )
+ return nCurrent;
+ if ( nRem == nCurrent )
+ return nCurrent;
+ nRem = nCurrent;
+ }
+ while ( !bFound );
+ return nRet;
+}
+
+/**************************************************************************
+*
+* Sortiert einen UniString in die Liste ein und gibt die Position,
+* an der einsortiert wurde, zurueck
+*
+**************************************************************************/
+
+ULONG SUniStringList::PutString( UniString* pStr )
+{
+ ULONG nPos = GetPrevString ( pStr );
+ if ( Count() )
+ {
+ {
+ UniString* pString = GetObject( 0 );
+ if ( pString->CompareTo( *pStr ) == COMPARE_GREATER )
+ {
+ Insert( pStr, (ULONG)0);
+ return (ULONG)0;
+ }
+ }
+ UniString* pString = GetObject( nPos );
+ if ( *pStr != *pString )
+ {
+ Insert( pStr, nPos+1 );
+ return ( nPos +1 );
+ }
+ }
+ else
+ {
+ Insert( pStr );
+ return (ULONG)0;
+ }
+
+ return NOT_THERE;
+}
+
+UniString* SUniStringList::RemoveString( const UniString& rName )
+{
+ ULONG i;
+ UniString* pReturn;
+
+ for( i = 0 ; i < Count(); i++ )
+ {
+ if ( rName == *GetObject( i ) )
+ {
+ pReturn = GetObject(i);
+ Remove(i);
+ return pReturn;
+ }
+ }
+
+ return NULL;
+}