summaryrefslogtreecommitdiff
path: root/tools/bootstrp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bootstrp')
-rw-r--r--tools/bootstrp/addexes/makefile.mk128
-rw-r--r--tools/bootstrp/addexes2/makefile.mk100
-rw-r--r--tools/bootstrp/addexes2/mkfilt.cxx271
-rw-r--r--tools/bootstrp/appdef.cxx192
-rw-r--r--tools/bootstrp/command.cxx716
-rw-r--r--tools/bootstrp/cppdep.cxx251
-rw-r--r--tools/bootstrp/cppdep.hxx96
-rw-r--r--tools/bootstrp/inimgr.cxx253
-rw-r--r--tools/bootstrp/iserver.cxx182
-rw-r--r--tools/bootstrp/makefile.mk205
-rw-r--r--tools/bootstrp/mkcreate.cxx1017
-rw-r--r--tools/bootstrp/prj.cxx1185
-rw-r--r--tools/bootstrp/rscdep.cxx371
-rw-r--r--tools/bootstrp/sstring.cxx319
14 files changed, 5286 insertions, 0 deletions
diff --git a/tools/bootstrp/addexes/makefile.mk b/tools/bootstrp/addexes/makefile.mk
new file mode 100644
index 000000000000..5dfc14eda202
--- /dev/null
+++ b/tools/bootstrp/addexes/makefile.mk
@@ -0,0 +1,128 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:03:00 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=tools
+TARGET=addexes
+TARGETTYPE=CUI
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+.INCLUDE : static.mk
+
+CDEFS+=-D_TOOLS_STRINGLIST
+
+# --- Files --------------------------------------------------------
+
+LIB1TARGET= $(LB)$/btstrp.lib
+LIB1ARCHIV= $(LB)$/libbtstrp.a
+LIB1FILES= $(LB)$/bootstrp.lib
+
+APP1TARGET= dirsync
+APP1STACK= 16000
+APP1OBJS= $(OBJ)$/dirsync.obj
+APP1STDLIBS=$(STATIC_LIBS)
+APP1LIBS= $(LB)$/bootstrp.lib
+APP1DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP2TARGET= include
+APP2STACK= 16000
+APP2OBJS= $(OBJ)$/include.obj
+APP2STDLIBS=$(STATIC_LIBS)
+APP2LIBS= $(LB)$/bootstrp.lib
+APP2DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP3TARGET= ldump
+APP3STACK= 16000
+APP3OBJS= $(OBJ)$/ldump.obj
+APP3STDLIBS=$(STATIC_LIBS) $(LIBCIMT)
+APP3LIBS= $(LB)$/bootstrp.lib
+APP3DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP4TARGET= readmap
+APP4STACK= 16000
+APP4OBJS= $(OBJ)$/readmap.obj $(OBJ)$/deco.obj
+APP4STDLIBS=$(STATIC_LIBS) $(LIBCIMT)
+APP4LIBS= $(LB)$/bootstrp.lib
+APP4DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP5TARGET= deco
+APP5STACK= 16000
+APP5OBJS= $(OBJ)$/deco.obj $(OBJ)$/deco2.obj
+APP5STDLIBS=$(STATIC_LIBS) $(LIBCIMT)
+APP5LIBS= $(LB)$/bootstrp.lib
+APP5DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP6TARGET= urlconv
+APP6OBJS= $(OBJ)$/urlconv.obj
+APP6STDLIBS=\
+ $(TOOLSLIB) \
+ $(SALLIB)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/tools/bootstrp/addexes2/makefile.mk b/tools/bootstrp/addexes2/makefile.mk
new file mode 100644
index 000000000000..6da12f8ad4f6
--- /dev/null
+++ b/tools/bootstrp/addexes2/makefile.mk
@@ -0,0 +1,100 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:03:01 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=tools
+TARGET=addexes2
+TARGETTYPE=CUI
+TARGETTHREAD=MT
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+.INCLUDE : ../static.mk
+
+# --- Files --------------------------------------------------------
+
+APP1TARGET= javadep
+APP1OBJS= $(OBJ)$/javadep.obj
+APP1STDLIBS=$(STATIC_LIBS)
+
+.IF "$(GUI)"=="UNX"
+APP2TARGET= checkdll
+APP2OBJS= $(OBJ)$/checkdll.obj
+.ENDIF
+
+APP3TARGET= mkunroll
+APP3OBJS= $(OBJ)$/mkfilt.obj
+APP3STDLIBS=$(STATIC_LIBS)
+.IF "$(OS)"=="LINUX"
+APP3STDLIBS+=-lpthread
+.ENDIF
+APP3LIBS= $(LB)$/bootstrp.lib
+APP3DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+DEPOBJFILES = $(APP1OBJS) $(APP2OBJS) $(APP3OBJS) $(APP4OBJS) $(APP5OBJS) $(APP6OBJS) $(APP7OBJS) $(APP8OBJS) $(APP9OBJS)
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/tools/bootstrp/addexes2/mkfilt.cxx b/tools/bootstrp/addexes2/mkfilt.cxx
new file mode 100644
index 000000000000..c6642d9fdca8
--- /dev/null
+++ b/tools/bootstrp/addexes2/mkfilt.cxx
@@ -0,0 +1,271 @@
+/*************************************************************************
+ *
+ * $RCSfile: mkfilt.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:03:01 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#include <tools/string.hxx>
+#include <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()
+{
+ char 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;
+ BOOL bNew = TRUE;
+
+ 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;
+ if ( pMkLine->bOut );
+ {
+ 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 argc, char **argv )
+{
+ 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..417b0f8f8a8f
--- /dev/null
+++ b/tools/bootstrp/appdef.cxx
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * $RCSfile: appdef.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:02:58 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <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 *pRet = getenv( pVar );
+ if ( !pRet )
+ pRet = "";
+ return pRet;
+}
+
diff --git a/tools/bootstrp/command.cxx b/tools/bootstrp/command.cxx
new file mode 100644
index 000000000000..abd9d38daa24
--- /dev/null
+++ b/tools/bootstrp/command.cxx
@@ -0,0 +1,716 @@
+/*************************************************************************
+ *
+ * $RCSfile: command.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:02:58 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef SCO
+#define _IOSTREAM_H
+#endif
+
+#ifdef PRECOMPILED
+#include "first.hxx"
+#endif
+
+#pragma hdrstop
+
+#include "fsys.hxx"
+#include "stream.hxx"
+#include "command.hxx"
+#include "debug.hxx"
+
+#include <iostream.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+
+//#define MH_TEST2 1 // fuers direkte Testen
+
+#if defined (DOS) || defined (WNT) || defined (WIN) || defined(OS2)
+#include <process.h> // for _SPAWN
+#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
+#ifdef MAC
+#define P_WAIT 1 // erstmal einen dummz
+#endif
+#ifdef WTC
+#define _spawnv spawnv
+#endif
+
+#ifdef OS2
+#include <svpm.h>
+#define _spawnv spawnv
+#endif
+#if defined (WIN) || defined (WNT)
+#include <svwin.h>
+#endif
+
+#if defined( WNT ) || defined ( OS2 ) || defined ( WIN ) || defined (DOS )
+#define cPathSeperator ';'
+#endif
+#ifdef UNX
+#define cPathSeperator ':'
+#endif
+#ifdef MAC
+#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;
+ 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;
+ 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();
+#ifndef UNX
+ aCommandLine += " /c ";
+#else
+ aCommandLine += " -c ";
+#endif
+ aCommandLine += rString;
+ ImplInit();
+}
+
+/*****************************************************************************/
+CCommand::CCommand( const char *pChar )
+/*****************************************************************************/
+{
+ ByteString aString = pChar;
+ aString.SearchAndReplace( '\t', ' ' );
+ aCommand = aString.GetToken( 0, ' ' );
+
+ aCommandLine = Search();
+#ifndef UNX
+ aCommandLine += " /c ";
+#else
+ aCommandLine += " -c ";
+#endif
+ aCommandLine += pChar;
+
+
+ ImplInit();
+}
+
+/*****************************************************************************/
+void CCommand::ImplInit()
+/*****************************************************************************/
+{
+ char pTmpStr[255];
+ size_t *pPtr;
+ char *pChar;
+ int nVoid = sizeof( size_t * );
+ ULONG nPos = 0;
+ 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 ( ULONG i=0; i<nArgc; i++ )
+ {
+ (void) strcpy( pTmpStr, aCommandLine.GetToken(i, ' ' ).GetBuffer() );
+ USHORT nStrLen = strlen( pTmpStr ) + 1;
+ strcpy( pChar, pTmpStr );
+ *pPtr = (unsigned int) 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 = ( unsigned int ) pChar;
+ pPtr += 1;
+ }
+#endif
+ }
+ *pPtr = 0;
+}
+
+/*****************************************************************************/
+CCommand::operator const int()
+/*****************************************************************************/
+{
+ int nRet;
+#ifndef UNX
+#if defined( WNT ) || defined( DOS ) || defined( WIN )
+ nRet = _spawnv( P_WAIT, ppArgv[0], (const char **) ppArgv );
+#else
+#if defined( UNX ) || defined( OS2 )
+ nRet = _spawnv( P_WAIT, ppArgv[0], ppArgv );
+#endif
+#ifdef MAC
+//Mac-Implem.
+#endif
+#endif
+#else
+#ifdef 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
+
+#ifdef MAC
+//Mac_impl
+=======
+#endif
+
+#endif
+
+#ifndef MAC
+ 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;
+ }
+#endif
+
+ if ( nRet )
+ fprintf( stderr, "Program returned with errros\n");
+ return nRet;
+}
+
+/*****************************************************************************/
+ByteString CCommand::Search(ByteString sEnv, ByteString sItem)
+/*****************************************************************************/
+{
+ FILE *fp;
+ ByteString aEntry, sReturn;
+
+ // default wird eine Shell im Path gesucht,
+ // wenn aber compsec gestzt ist holen wir uns die
+ // Shell von dort
+
+ if ( sItem == COMMAND_SHELL )
+ {
+ ByteString aComspec = getenv( "COMSPEC" );
+ if ( aComspec != "" )
+ return aComspec;
+ }
+
+ ByteString sEnvironment = getenv(sEnv.GetBuffer() );
+ ULONG nCount = sEnvironment.GetTokenCount( cPathSeperator );
+ for ( ULONG i=0; i<nCount; i++ )
+ {
+ aEntry = sEnvironment.GetToken(i, cPathSeperator );
+#ifndef UNX
+ aEntry += '\\';
+#else
+ aEntry += '/';
+#endif
+ aEntry += sItem;
+ if (( fp = fopen( aEntry.GetBuffer(), "r" )) != NULL )
+ {
+ sReturn = aEntry;
+ fclose(fp);
+ break;
+ }
+ }
+ if ( sReturn == "" )
+ {
+ sEnv = sEnv.ToUpperAscii();
+ ByteString sEnvironment = getenv(sEnv.GetBuffer() );
+ ULONG nCount = sEnvironment.GetTokenCount( cPathSeperator );
+ for ( ULONG i=0; i<nCount; i++ )
+ {
+ aEntry = sEnvironment.GetToken(i, cPathSeperator );
+#ifndef UNX
+ aEntry += '\\';
+#else
+ aEntry += '/';
+#endif
+ aEntry += sItem;
+ if (( fp = fopen( aEntry.GetBuffer(), "r" )) != NULL )
+ {
+ sReturn = aEntry;
+ fclose(fp);
+ break;
+ }
+ }
+ }
+ if ( sReturn == "" )
+ fprintf(stderr, "WARNING: %s not found in %s\n",
+ sItem.GetBuffer(), sEnv.GetBuffer() );
+ 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 const 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 )
+ DWORD 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;
+ BOOL bTest;
+
+ while(aProcessState == STILL_ACTIVE)
+ {
+ bTest = 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..9040917ae393
--- /dev/null
+++ b/tools/bootstrp/cppdep.cxx
@@ -0,0 +1,251 @@
+/*************************************************************************
+ *
+ * $RCSfile: cppdep.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:02:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+#ifdef WNT
+#ifdef BOOTSTRAPPER
+#include <glibc/posix/getopt.h>
+#else
+#include <glibc/getopt.h>
+#endif
+#endif
+#ifdef UNX
+#ifdef BOOTSTRAPPER
+#include <glibc/posix/getopt.h>
+#include <glibc/posix/config.h>
+#else
+#ifdef MAC
+#include <glibc/getopt.h>
+#endif
+#include <glibc/config.h>
+#endif
+#include <unistd.h>
+#endif
+#ifndef MAC
+#include <sys/stat.h>
+#else
+#include <stat.h>
+#endif
+
+#include <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 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 )
+{
+ //fprintf( stderr, "SEARCH : %s\n", aFileName.GetStr());
+ BOOL bRet = FALSE;
+
+ SvFileStream aFile;
+ ByteString aReadLine;
+
+ UniString suFileName( aFileName, gsl_getSystemTextEncoding());
+
+ aFile.Open( suFileName, STREAM_READ );
+ while ( aFile.ReadLine( aReadLine ))
+ {
+ USHORT nPos;
+ if ( nPos = aReadLine.Search( "include" ) != STRING_NOTFOUND )
+ {
+ //fprintf( stderr, "found : %d %s\n", nPos, aReadLine.GetStr() );
+ ByteString aResult = IsIncludeStatement( aReadLine );
+ //fprintf( stderr, "Result : %x\n", aResult.GetStr() );
+
+ 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;
+ }
+ if ( !bFound )
+ {
+ pFileList->Insert( new ByteString( aNewFile ), LIST_APPEND );
+ //fprintf( stderr, " CppDep %s\\\n", aNewFile.GetStr() );
+ Search(aNewFile);
+ }
+ }
+ }
+ }
+ aFile.Close();
+
+ return bRet;
+}
+
+ByteString CppDep::Exists( ByteString aFileName )
+{
+ //fprintf( stderr, "Searching %s \n", aFileName.GetStr() );
+ ByteString aString;
+ ULONG nCount = pSearchPath->Count();
+ for ( ULONG n=0; n<nCount; n++)
+ {
+ struct stat aBuf;
+ ByteString *pPathName = pSearchPath->GetObject(n);
+
+ char *pFullName = new char[1023];
+ strcpy( pFullName, pPathName->GetBuffer());
+ strcat( pFullName, DIR_SEP );
+ strcat( pFullName, aFileName.GetBuffer());
+
+ //fprintf( stderr, "looking for %s\t ", pFullName );
+ if ( stat( pFullName, &aBuf ) == 0 )
+ {
+#ifdef DEBUG_VERBOSE
+ fprintf( stderr, "Got Dependency ", pFullName );
+#endif
+ //fprintf( stderr, "%s \\\n", pFullName );
+
+ return ByteString(pFullName);
+ }
+ delete pFullName;
+ }
+ return aString;
+}
+
+ByteString CppDep::IsIncludeStatement( ByteString aLine )
+{
+ ByteString aRetStr;
+ // WhiteSpacesfressen
+ aLine.EraseAllChars(' ');
+ aLine.EraseAllChars('\t');
+ //fprintf( stderr, "now : %s\n", aLine.GetStr() );
+ // ist der erste Teil ein #include ?
+ ByteString aTmpStr;
+ if ( (aTmpStr = aLine.Erase( 0, 8 )) == "#include" )
+ {
+ USHORT nLen = aLine.Len();
+ aLine.Erase( nLen-1, 1 );
+ aLine.Erase( 0, 1 );
+ //fprintf( stderr, "Gotcha : %s\n", aLine.GetStr() );
+ 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..4cc92c3da06f
--- /dev/null
+++ b/tools/bootstrp/cppdep.hxx
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * $RCSfile: cppdep.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:02:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#if SUPD < 356
+#include <tools.hxx>
+#else
+#include <list.hxx>
+#include <string.hxx>
+#endif
+
+#define PATH_SEP ":"
+#define DIR_SEP "/"
+
+DECLARE_LIST( ByteStringList, ByteString * );
+
+class CppDep
+{
+ ByteString aSourceFile;
+ ByteStringList *pSources;
+ ByteStringList *pSearchPath;
+ ByteStringList *pFileList;
+
+protected:
+ BOOL Search( ByteString aFileName );
+ ByteString Exists( ByteString aFileName );
+
+ ByteString IsIncludeStatement( ByteString aLine );
+public:
+ CppDep( ByteString aFileName );
+ CppDep();
+ ~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..f2d75d03e258
--- /dev/null
+++ b/tools/bootstrp/inimgr.cxx
@@ -0,0 +1,253 @@
+/*************************************************************************
+ *
+ * $RCSfile: inimgr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:02:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#if !defined( UNX ) && !defined( MAC )
+#include <direct.h>
+#else
+#ifndef MAC
+#include <sys/stat.h>
+#else
+#include <stat.h>
+#endif
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+
+
+#include "inimgr.hxx"
+#include "appdef.hxx"
+#include "fattr.hxx"
+
+/****************************************************************************/
+IniManager::IniManager( ByteString &rDir, ByteString &rLocalDir )
+/****************************************************************************/
+ : bUpdate( TRUE )
+{
+ sLocalPath = ByteString( getenv( "LOCALINI" ));
+ if ( !sLocalPath.Len())
+ sLocalPath = rLocalDir;
+
+ sGlobalDir = rDir;
+#if !defined( UNX ) && !defined( MAC )
+ mkdir(( char * ) sLocalPath.GetBuffer());
+#else
+ mkdir( sLocalPath.GetBuffer() ,00777 );
+#endif
+}
+
+/****************************************************************************/
+IniManager::IniManager( ByteString &rDir )
+/****************************************************************************/
+ : bUpdate( TRUE )
+{
+ sLocalPath = GetLocalIni();
+ sGlobalDir = rDir;
+#if !defined( UNX ) && !defined( MAC )
+ mkdir(( char * ) sLocalPath.GetBuffer());
+#else
+ mkdir( sLocalPath.GetBuffer() ,00777 );
+#endif
+}
+
+/****************************************************************************/
+IniManager::IniManager()
+/****************************************************************************/
+ : bUpdate( TRUE )
+{
+ sLocalPath = GetLocalIni();
+
+#if !defined( UNX ) && !defined( MAC )
+ mkdir(( char * ) sLocalPath.GetBuffer());
+#else
+ mkdir( sLocalPath.GetBuffer(), 00777 );
+#endif
+
+ sGlobalDir = ByteString( _INIROOT );
+}
+
+/****************************************************************************/
+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();
+
+#ifndef MAC
+ sTmp.SearchAndReplace( sIni, sLocalPath );
+#else
+ sTmp.SearchAndReplace( sIni, GetIniRootOld() );
+#endif
+
+ while ( sTmp.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND );
+#ifdef MAC
+ while ( sTmp.SearchAndReplace( "\\", ":" ) != STRING_NOTFOUND );
+ while ( sTmp.SearchAndReplace( "::", ":" ) != STRING_NOTFOUND );
+#endif
+#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
+#ifdef MAC
+ ByteString sLocal( getenv( "TEMP" ));
+ sLocal += ByteString( ":localini" );
+#else
+ ByteString sLocal( getenv( "TMP" ));
+ sLocal += ByteString( "\\localini" );
+#endif
+#endif
+
+ sLocalPath = sLocal;
+ }
+
+ return sLocalPath;
+}
+
+/****************************************************************************/
+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
+#ifndef MAC
+ sLocalPath.EraseTrailingChars( '\\' );
+ sLocalPath += "\\";
+#else
+ sLocalPath.EraseTrailingChars( ':' );
+ sLocalPath += ":";
+#endif
+#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();
+ BOOL bWorkaround = FALSE;
+
+ 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..7a8f12c1adba
--- /dev/null
+++ b/tools/bootstrp/iserver.cxx
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * $RCSfile: iserver.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:02:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "iparser.hxx"
+#include "geninfo.hxx"
+#include "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 );
+ GenericInformationList *pList = aParser.Execute( String( sStandList, gsl_getSystemTextEncoding()));
+ 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..f49b01b11bd2
--- /dev/null
+++ b/tools/bootstrp/makefile.mk
@@ -0,0 +1,205 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:02:59 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=tools
+TARGET=bootstrp
+TARGETTYPE=CUI
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+.INCLUDE : static.mk
+
+CDEFS+=-D_TOOLS_STRINGLIST
+
+# --- Files --------------------------------------------------------
+
+.IF "$(OS)"=="MACOS"
+dummy:
+ @echo No bootstrp for Mac OS
+.ELSE # "$(OS)"=="MACOS"
+
+OBJFILES= \
+ $(OBJ)$/sstring.obj \
+ $(OBJ)$/appdef.obj \
+ $(OBJ)$/cppdep.obj \
+ $(OBJ)$/command.obj \
+ $(OBJ)$/prj.obj \
+ $(OBJ)$/dlvclass.obj \
+ $(OBJ)$/hashtbl.obj \
+ $(OBJ)$/errdumm.obj \
+ $(OBJ)$/errhdl.obj \
+ $(OBJ)$/hedabu.obj \
+ $(OBJ)$/inimgr.obj \
+ $(OBJ)$/revision.obj \
+ $(OBJ)$/shellprp.obj \
+ $(OBJ)$/minormk.obj \
+ $(OBJ)$/fattr.obj
+
+.IF "$(UPD)" < "590"
+OBJFILES += \
+ $(OBJ)$/geninfo.obj \
+ $(OBJ)$/parser.obj
+.ENDIF
+
+SLOFILES= \
+ $(SLO)$/sstring.obj \
+ $(SLO)$/appdef.obj \
+ $(SLO)$/cppdep.obj \
+ $(SLO)$/command.obj \
+ $(SLO)$/prj.obj \
+ $(SLO)$/dlvclass.obj \
+ $(SLO)$/hashtbl.obj \
+ $(SLO)$/errdumm.obj \
+ $(SLO)$/errhdl.obj \
+ $(SLO)$/hedabu.obj \
+ $(SLO)$/inimgr.obj \
+ $(SLO)$/revision.obj \
+ $(SLO)$/shellprp.obj \
+ $(SLO)$/minormk.obj \
+ $(SLO)$/fattr.obj
+
+.IF "$(UPD)" < "590"
+SLOFILES += \
+ $(SLO)$/geninfo.obj \
+ $(SLO)$/parser.obj
+.ENDIF
+
+LIB1TARGET= $(LB)$/btstrp.lib
+LIB1ARCHIV= $(LB)$/libbtstrp.a
+LIB1FILES= $(LB)$/bootstrp.lib
+
+LIB2TARGET= $(SLB)$/btstrpsh.lib
+LIB2ARCHIV= $(SLB)$/libbtstrpsh.a
+LIB2FILES= $(SLB)$/bootstrp.lib
+
+LIB3TARGET=$(LB)$/bsvermap.lib
+LIB3ARCHIV= $(LB)$/libbsvermap.a
+LIB3OBJFILES=\
+ $(OBJ)$/vermap.obj
+
+APP1TARGET= i_server
+APP1STACK= 16000
+APP1OBJS= $(OBJ)$/iserver.obj
+APP1STDLIBS=$(STATIC_LIBS)
+APP1LIBS= $(LB)$/bootstrp.lib
+APP1DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP2TARGET= copyprj
+APP2OBJS= $(OBJ)$/cprjexe.obj $(OBJ)$/copyprj.obj
+APP2STDLIBS=$(STATIC_LIBS)
+APP2LIBS= $(LB)$/bootstrp.lib
+APP2DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP3TARGET=rscdep
+APP3OBJS= $(OBJ)$/rscdep.obj
+APP3STDLIBS=$(STATIC_LIBS)
+APP3LIBS= $(LB)$/bootstrp.lib
+APP3DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP4TARGET=mkcreate
+APP4OBJS= $(OBJ)$/mkcrexe.obj $(OBJ)$/mkcreate.obj
+APP4STDLIBS=$(STATIC_LIBS)
+APP4LIBS= $(LB)$/bootstrp.lib
+APP4DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP5TARGET= setsolar
+APP5OBJS= $(OBJ)$/setsolar.obj $(OBJ)$/envset.obj $(OBJ)$/vermap.obj
+APP5STDLIBS=$(STATIC_LIBS)
+APP5LIBS= $(LB)$/bootstrp.lib
+APP5DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP6TARGET= build
+APP6OBJS= $(OBJ)$/make.obj $(OBJ)$/updmake.obj $(OBJ)$/allmake.obj
+APP6STDLIBS=$(STATIC_LIBS)
+APP6LIBS= $(LB)$/bootstrp.lib
+APP6DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+APP7TARGET= deliver
+APP7OBJS= $(OBJ)$/deliver.obj
+APP7STDLIBS=$(STATIC_LIBS)
+APP7LIBS= $(LB)$/bootstrp.lib
+APP7DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+APP7STACK= 16384
+
+APP8TARGET= makedepn
+APP8OBJS= $(OBJ)$/makedepn.obj
+APP8STDLIBS=$(STATIC_LIBS)
+APP8DEPN= $(LB)$/atools.lib
+
+APP9TARGET= _mkout
+APP9LINKTYPE=STATIC
+APP9OBJS= $(OBJ)$/mkout.obj
+APP9STDLIBS=$(STATIC_LIBS)
+APP9LIBS= $(LB)$/bootstrp.lib
+APP9DEPN= $(LB)$/atools.lib $(LB)$/bootstrp.lib
+
+DEPOBJFILES = $(APP1OBJS) $(APP2OBJS) $(APP3OBJS) $(APP4OBJS) $(APP5OBJS) $(APP6OBJS) $(APP7OBJS) $(APP8OBJS) $(APP9OBJS)
+
+.ENDIF # "$(OS)"=="MACOS"
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/tools/bootstrp/mkcreate.cxx b/tools/bootstrp/mkcreate.cxx
new file mode 100644
index 000000000000..f6bd8addb1fc
--- /dev/null
+++ b/tools/bootstrp/mkcreate.cxx
@@ -0,0 +1,1017 @@
+/*************************************************************************
+ *
+ * $RCSfile: mkcreate.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:02:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+// global includes
+#include <stdio.h>
+
+// local includes
+#include "mkcreate.hxx"
+#include "inimgr.hxx"
+#include "appdef.hxx"
+#include "geninfo.hxx"
+#include "iparser.hxx"
+#include "prj.hxx"
+
+char *NoBuildProject[] = {
+ "solenv",
+ "EndOf_NoBuildProject"
+};
+
+char *LimitedPath[] = {
+ "jurt\\com\\sun\\star",
+ "r_tools",
+ "setup2",
+ "EndOf_LimitedPath"
+};
+
+//
+// class SourceDirectory
+//
+
+/*****************************************************************************/
+SourceDirectory::SourceDirectory( const ByteString &rDirectoryName,
+ USHORT nOperatingSystem, SourceDirectory *pParentDirectory )
+/*****************************************************************************/
+ : ByteString( rDirectoryName ),
+ pParent( pParentDirectory ),
+ nOSType( nOperatingSystem ),
+ pSubDirectories( NULL ),
+ 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( 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 = NULL;
+ if ( pDependency =
+ (( SourceDirectory * ) pSubDirectories->GetObject( k ))->
+ ResolvesDependency( pCodedDependency ))
+ {
+ 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 sWIN( ".IF \"$(GUI)\" == \"WIN\"\n" );
+// sWIN += sTarget;
+// sWIN += " :";
+// BOOL bWIN = FALSE;
+
+ ByteString sMAC( ".IF \"$(GUI)\" == \"MAC\"\n" );
+ sMAC += sTarget;
+ sMAC += " :";
+ BOOL bMAC = 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_WIN16 ) {
+// sWIN += " ";
+// sWIN += sDependency;
+// bWIN = TRUE;
+// }
+ if ( pDependency->GetOperatingSystem() & OS_MAC ) {
+ sMAC += " ";
+ sMAC += sDependency;
+ bMAC = 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 ( bWIN ) {
+// sReturn += sWIN;
+// sReturn += "\n.ENDIF\n";
+// }
+ if ( bMAC ) {
+ sReturn += sMAC;
+ 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 sWIN( ".IF \"$(GUI)\" == \"WIN\"\n" );
+ // sWIN += "RC_SUBDIRS = ";
+ // BOOL bWIN = FALSE;
+
+ ByteString sMAC( ".IF \"$(GUI)\" == \"MAC\"\n" );
+ sMAC += "RC_SUBDIRS = ";
+ BOOL bMAC = 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_WIN16 ) {
+ // sWIN += " \\\n\t";
+ // sWIN += sDirectory;
+ // bWIN = TRUE;
+ // }
+ if ( pDirectory->GetOperatingSystems() & OS_MAC ) {
+ sMAC += " \\\n\t";
+ sMAC += sDirectory;
+ bMAC = 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 ( bWIN ) {
+ // sReturn += sWIN;
+ // sReturn += "\n.ENDIF\n";
+ // }
+ if ( bMAC ) {
+ sReturn += sMAC;
+ 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 == "D" )
+ /* nOSType |= OS_WIN16 */;
+ else if ( sDependExt == "W" )
+ nOSType |= OS_WIN32 /* | OS_WIN16 */;
+ else if ( sDependExt == "N" )
+ nOSType |= OS_WIN32;
+ else if ( sDependExt == "U" )
+ nOSType |= OS_UNX;
+ else if ( sDependExt == "P" )
+ nOSType |= OS_OS2;
+ else if ( sDependExt == "M" )
+ nOSType |= OS_MAC;
+ return nOSType;
+}
+
+/*****************************************************************************/
+SourceDirectory *SourceDirectory::CreateRootDirectory(
+ const ByteString &rRoot, const ByteString &rVersion )
+/*****************************************************************************/
+{
+ IniManager aIniManager;
+ aIniManager.Update();
+
+ ByteString sDefLst( GetDefStandList());
+ ByteString sStandLst( aIniManager.ToLocal( sDefLst ));
+ InformationParser aParser;
+ fprintf( stderr,
+ "Reading database %s ...\n", sStandLst.GetBuffer());
+ GenericInformationList *pVerList = aParser.Execute(
+ String( sStandLst, gsl_getSystemTextEncoding()));
+
+ 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());
+
+ Star aStar( String( sSolarList, gsl_getSystemTextEncoding()));
+ 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 ( 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"
+ "#* $Workfile:$\n"
+ "#*\n"
+ "#* generated recursive makefile\n"
+ "#* last change $Author: hr $ $Date: 2000-09-18 17:02:59 $\n"
+ "#* $Revision: 1.1.1.1 $\n"
+ "#*\n"
+ "#* $Logfile:$\n"
+ "#*\n"
+ "#* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.\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 \"$(deliver)\"==\"true\"\n"
+ "all_target:\t\t\\\n"
+ "\tTG_DELIVER\t\\\n"
+ "\tALLTAR\n"
+ ".ELSE # \"$(deliver)\"==\"true\"\n"
+ "all_target: ALLTAR\n"
+ ".ENDIF # \"$(deliver)\"==\"true\"\n"
+ );
+ else
+ sHeader += ByteString(
+ "all_target: ALLTAR\n"
+ );
+ }
+ }
+ else {
+ if ( nDepth == 1 )
+ sHeader += ByteString(
+ ".IF \"$(deliver)\"==\"true\"\n"
+ "all_target:\t\t\\\n"
+ "\tTG_DELIVER\t\\\n"
+ "\tALLTAR\n"
+ ".ELSE # \"$(deliver)\"==\"true\"\n"
+ "all_target: ALLTAR\n"
+ ".ENDIF # \"$(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"
+ "\tdeliver\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 j = 0; j < pSubDirectories->Count(); j++ )
+ if ( !(( SourceDirectory * ) pSubDirectories->GetObject( j ))->
+ 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..7f1bc3603c22
--- /dev/null
+++ b/tools/bootstrp/prj.cxx
@@ -0,0 +1,1185 @@
+/*************************************************************************
+ *
+ * $RCSfile: prj.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:03:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdlib.h>
+#include <sstring.hxx>
+
+#include "stream.hxx"
+#include "prj.hxx"
+
+#pragma hdrstop
+
+//#define TEST 1
+
+#ifdef MAC
+#define putenv(x)
+#endif
+
+#if defined(DOS) || defined(WNT) || defined(OS2)
+#define LIST_DELIMETER ';'
+#else
+#ifdef UNX
+#define LIST_DELIMETER ':'
+#else
+#ifdef MAC
+#define LIST_DELIMETER ','
+#endif
+#endif
+#endif
+
+#if defined(DOS) || defined(WNT) || defined(OS2) || defined(WIN)
+#define PATH_DELIMETER '\\'
+#else
+#ifdef UNX
+#define PATH_DELIMETER '/'
+#else
+#ifdef MAC
+#define PATH_DELIMETER ':'
+#endif
+#endif
+#endif
+
+//
+// class SimpleConfig
+//
+
+/*****************************************************************************/
+SimpleConfig::SimpleConfig( UniString 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;
+ USHORT iret = 0;
+ 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();
+ USHORT nPos = 0;
+ BOOL bFound = FALSE;
+ ByteString aEraseString;
+ for ( USHORT i = 0; i<= nLength; i++)
+ {
+#ifdef MAC
+ if ( aTmpStr.GetChar( i ) == '"')
+ {
+ if ( bFound) bFound = FALSE;
+ else bFound = TRUE;
+ aTmpStr.SetChar( i, '\t' );
+ }
+#endif
+ 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();
+ USHORT nPos = 0;
+ 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 | OS_MAC :
+ 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;
+ case OS_MAC :
+ aRetStr = "m";
+ 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( nCommand + 1 - COMMAND_USER_START );
+
+ }
+
+ return aRetStr;
+}
+
+/*****************************************************************************/
+CommandData* Prj::GetDirectoryList ( USHORT nWhatOS, USHORT nCommand )
+/*****************************************************************************/
+{
+ return (CommandData *)NULL;
+}
+
+/*****************************************************************************/
+CommandData* Prj::GetDirectoryData( ByteString aLogFileName )
+/*****************************************************************************/
+{
+ CommandData *pData = NULL;
+ ULONG nCount = Count();
+ for ( ULONG i=0; i<nCount; i++ )
+ {
+ pData = GetObject(i);
+ if ( pData->GetLogFile() == aLogFileName )
+ return pData;
+ }
+ return NULL;
+}
+
+//
+// class Prj
+//
+
+/*****************************************************************************/
+Prj::Prj() :
+ pPrjDepList(0),
+ pPrjInitialDepList(0),
+ bSorted( FALSE ),
+ bHardDependencies( FALSE ),
+ bVisited( FALSE )
+/*****************************************************************************/
+{
+}
+
+/*****************************************************************************/
+Prj::Prj( ByteString aName ) :
+ aProjectName( aName ),
+ pPrjDepList(0),
+ pPrjInitialDepList(0),
+ bSorted( FALSE ),
+ bHardDependencies( FALSE ),
+ bVisited( 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 nCount = Count();
+ CommandData* pData;
+ CommandData* pDataFound = NULL;
+ SByteStringList* pDataDeps;
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ pData = GetObject( i );
+ if ( pData->GetLogFile() == aLogFileName )
+ pDataFound = pData;
+ else
+ {
+ pDataDeps = pData->GetDependencies();
+ if ( pDataDeps )
+ {
+ ByteString* pString;
+ USHORT nDataDepsCount = pDataDeps->Count();
+ for ( USHORT 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()
+/*****************************************************************************/
+{}
+/*****************************************************************************/
+Star::Star(UniString aFileName)
+/*****************************************************************************/
+{
+ ByteString aString;
+
+ SimpleConfig aSolarConfig ( aFileName );
+ while ( (aString = aSolarConfig.GetNext()) != "")
+ InsertToken ( (char *) aString.GetBuffer() );
+
+ // Die gefundenen Abhaengigkeiten rekursiv aufloesen
+ Expand_Impl();
+}
+
+/*****************************************************************************/
+Star::~Star()
+/*****************************************************************************/
+{
+}
+
+/*****************************************************************************/
+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 int 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 {
+ USHORT nOffset = aWhat.Copy( 3 ).ToInt32();
+ nCommandType = 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 | OS_MAC );
+ 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 if ( aWhatOS == "m" )
+ nOSType = OS_MAC;
+ 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, 0x5c);
+ 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 );
+ }
+
+ }
+ break;
+ }
+ /* Wenn dieses Project noch nicht vertreten ist, in die Liste
+ der Solar-Projekte einfuegen */
+ if ( i == -1 )
+ {
+ aProjectName = aDirName.GetToken ( 0, 0x5c);
+ 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 nCount;
+
+ nCount = Count();
+
+ for ( int i=0; i<nCount; i++)
+ {
+ pPrj = GetObject(i);
+ if ( pPrj->GetProjectName().ToLowerAscii() == aProjectName.ToLowerAscii() )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*****************************************************************************/
+Prj* Star::GetPrj ( ByteString aProjectName )
+/*****************************************************************************/
+{
+ Prj* pPrj;
+ int nCount = Count();
+ for ( int i=0;i<nCount;i++)
+ {
+ pPrj = GetObject(i);
+ if ( pPrj->GetProjectName().ToLowerAscii() == aProjectName.ToLowerAscii() )
+ return pPrj;
+ }
+// return (Prj*)NULL;
+ return 0L ;
+}
+
+/*****************************************************************************/
+ByteString Star::GetPrjName( DirEntry &aPath )
+/*****************************************************************************/
+{
+ ByteString aRetPrj, aDirName;
+ ByteString aFullPathName = ByteString( aPath.GetFull(), gsl_getSystemTextEncoding());
+
+ USHORT nToken = aFullPathName.GetTokenCount(PATH_DELIMETER);
+ for ( int i=0; i< nToken; i++ )
+ {
+ aDirName = aFullPathName.GetToken( i, PATH_DELIMETER );
+ if ( HasProject( aDirName ))
+ {
+ aRetPrj = aDirName;
+ break;
+ }
+ }
+
+ return aRetPrj;
+}
+
+
+//
+// class StarWriter
+//
+
+/*****************************************************************************/
+StarWriter::StarWriter( UniString aFileName, BOOL bReadComments )
+/*****************************************************************************/
+{
+ Read ( aFileName, bReadComments );
+}
+
+
+/*****************************************************************************/
+void StarWriter::CleanUp()
+{
+ Expand_Impl();
+}
+/*****************************************************************************/
+/*****************************************************************************/
+USHORT StarWriter::Read( UniString aFileName, BOOL bReadComments )
+/*****************************************************************************/
+{
+ ByteString aString;
+
+ SimpleConfig aSolarConfig ( aFileName );
+ while ( (aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != "")
+ InsertTokenLine ( aString );
+
+ // Die gefundenen Abhaengigkeiten rekursiv aufloesen
+ Expand_Impl();
+ return 0;
+}
+
+/*****************************************************************************/
+USHORT StarWriter::Write( UniString aFileName )
+/*****************************************************************************/
+{
+ Prj* pPrj = NULL;
+ ByteString aDataString;
+ ByteString aTab('\t');
+ ByteString aSpace(' ');
+ ByteString aEmptyString("");
+
+ CommandData* pCmdData = NULL;
+ SvFileStream aFileStream;
+ SByteStringList* pCmdDepList;
+ SByteStringList* pPrjDepList;
+
+ aFileStream.Open( aFileName, STREAM_WRITE | STREAM_TRUNC);
+
+ if ( Count() > 0 )
+ {
+ pPrj = First();
+ do
+ {
+ if ( pPrj->Count() > 0 )
+ {
+ pCmdData = pPrj->First();
+ if ( pPrjDepList = pPrj->GetDependencies( FALSE ))
+ {
+ 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";
+
+ aFileStream.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";
+ }
+
+ aFileStream.WriteLine( aDataString );
+
+ pCmdData = pPrj->Next();
+ } while ( pCmdData );
+
+ }
+ pPrj = Next();
+ } while ( pPrj );
+ }
+
+ aFileStream.Close();
+ 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;
+ int nCommandType, nOSType;
+ 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 {
+ USHORT nOffset = aWhat.Copy( 3 ).ToInt32();
+ nCommandType = 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 | OS_MAC );
+ 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 if ( aWhatOS == "m" )
+ nOSType = OS_MAC;
+ 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, 0x5c);
+ 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 );
+ }
+
+ }
+ break;
+ }
+ /* Wenn dieses Project noch nicht vertreten ist, in die Liste
+ der Solar-Projekte einfuegen */
+ if ( i == -1 )
+ {
+ aProjectName = aDirName.GetToken ( 0, 0x5c);
+ 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* pNewPrj )
+/*****************************************************************************/
+{
+ return FALSE;
+}
+
+/*****************************************************************************/
+Prj* StarWriter::RemoveProject ( ByteString aProjectName )
+/*****************************************************************************/
+{
+ ULONG nCount = Count();
+ Prj* pPrj;
+ Prj* pPrjFound = NULL;
+ SByteStringList* pPrjDeps;
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ pPrj = GetObject( i );
+ if ( pPrj->GetProjectName() == aProjectName )
+ pPrjFound = pPrj;
+ else
+ {
+ pPrjDeps = pPrj->GetDependencies( FALSE );
+ if ( pPrjDeps )
+ {
+ ByteString* pString;
+ USHORT nPrjDepsCount = pPrjDeps->Count();
+ for ( USHORT j = nPrjDepsCount; j > 0; j-- )
+ {
+ pString = pPrjDeps->GetObject( j - 1 );
+ if ( pString->GetToken( 0, '.') == aProjectName )
+ pPrjDeps->Remove( pString );
+ }
+ }
+ }
+ }
+
+ Remove( pPrjFound );
+
+ return pPrjFound;
+}
+
diff --git a/tools/bootstrp/rscdep.cxx b/tools/bootstrp/rscdep.cxx
new file mode 100644
index 000000000000..1dd7feac98cd
--- /dev/null
+++ b/tools/bootstrp/rscdep.cxx
@@ -0,0 +1,371 @@
+/*************************************************************************
+ *
+ * $RCSfile: rscdep.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:03:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/***************************************************************
+*
+* rscdep.cxx
+*
+* (c) Martin Hollmichel 1998
+*
+***************************************************************/
+
+#ifdef WNT
+#define __STDC__ 1
+#ifdef BOOTSTRAPPER
+#include <glibc/posix/getopt.h>
+#else
+#include <glibc/getopt.h>
+#endif
+#endif
+#ifdef UNX
+#ifdef BOOTSTRAPPER
+#include <glibc/posix/config.h>
+#ifdef MAC
+#include <glibc/posix/getopt.h>
+#endif
+#else
+#include <glibc/config.h>
+#ifdef MAC
+#include <glibc/getopt.h>
+#endif
+#endif
+#endif
+
+#if defined(SOLARIS)
+extern "C" {
+struct option
+{
+ char* name;
+ int has_arg;
+ int* flagl;
+ int val;
+};
+extern int getopt_long( int, char* const*, const char *, const struct option*, int *);
+}
+#endif
+
+#ifdef UNX
+#include <unistd.h>
+#endif
+
+#include <sys/stat.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "prj.hxx"
+
+#if SUPD < 356
+#include <tools.hxx>
+#else
+#include <string.hxx>
+#include <list.hxx>
+#include <fsys.hxx>
+#include <stream.hxx>
+#endif
+
+#include "cppdep.hxx"
+
+class RscHrcDep : public CppDep
+{
+public:
+ RscHrcDep();
+ virtual ~RscHrcDep();
+
+ virtual void Execute();
+};
+
+RscHrcDep::RscHrcDep() :
+ CppDep()
+{
+}
+
+RscHrcDep::~RscHrcDep()
+{
+}
+
+void RscHrcDep::Execute()
+{
+ CppDep::Execute();
+}
+
+static String aDelim = DirEntry::GetAccessDelimiter();
+
+int
+#ifdef WNT
+_cdecl
+#endif
+main( int argc, char **argv )
+{
+ int c;
+ int digit_optind = 0;
+ char aBuf[255];
+ char pOutputFileName[255];
+ String aSrsBaseName;
+ BOOL bSource = FALSE;
+ ByteString aRespArg;
+
+ RscHrcDep *pDep = new RscHrcDep;
+
+ for ( int i=1; i<argc; i++)
+ {
+ strcpy( aBuf, (const char *)argv[i] );
+ if ( aBuf[0] == '-' && aBuf[1] == 'f' && aBuf[2] == 'o' )
+ {
+ strcpy(pOutputFileName, &aBuf[3]);
+ //break;
+ }
+ if ( aBuf[0] == '-' && aBuf[1] == 'f' && aBuf[2] == 'p' )
+ {
+ strcpy(pOutputFileName, &aBuf[3]);
+ String aName( pOutputFileName, gsl_getSystemTextEncoding());
+ USHORT nPos = 0;
+ 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 ( aBuf2[0] == '-' && aBuf2[1] == 'f' && aBuf2[2] == 'o' )
+ {
+ strcpy(pOutputFileName, &aBuf2[3]);
+ //break;
+ }
+ if ( aBuf2[0] == '-' && aBuf2[1] == 'f' && aBuf2[2] == 'p' )
+ {
+ strcpy(pOutputFileName, &aBuf2[3]);
+ String aName( pOutputFileName, gsl_getSystemTextEncoding());
+ USHORT nPos = 0;
+ 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 )
+ {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+
+ static struct option long_options[] =
+ {
+ {"add",1,0,0},
+ {0,0,0,0}
+ };
+
+ c = getopt_long( argc, argv,
+ "_abcdefghi:jklmnopqrstuvwxyzABCDEFGHI:JKLMNOPQRSTUVWXYZ1234567890/-+=.\\()\"",
+ long_options, &option_index );
+ if ( c == -1 )
+ break;
+
+ switch( c )
+ {
+ case 0:
+#ifdef DEBUG_VERBOSE
+ printf("option %s", long_options[option_index].name);
+ if ( optarg)
+ printf(" with arg %s", optarg );
+ printf("\n");
+#endif
+ 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();
+/* 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(".dpr", 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( pOutputFileName );
+ 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);
+ if ( j != (nCount-1) )
+ *pStr += ByteString( "\\" );
+ aOutStream.WriteLine( *pStr );
+ }
+ delete pDep;
+ aOutStream.Close();
+
+ return 0;
+}
+
+
+
+
diff --git a/tools/bootstrp/sstring.cxx b/tools/bootstrp/sstring.cxx
new file mode 100644
index 000000000000..4341446629d4
--- /dev/null
+++ b/tools/bootstrp/sstring.cxx
@@ -0,0 +1,319 @@
+/*************************************************************************
+ *
+ * $RCSfile: sstring.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:03:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef WTC
+#ifdef _TOOLS_STRINGLIST
+#undef _TOOLS_STRINGLIST
+#endif
+#endif
+
+#define _TOOLS_STRINGLIST
+#include "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;
+ }
+ return nRet;
+}
+
+ULONG SByteStringList::GetPrevString( ByteString* pStr )
+{
+ ULONG nRet = 0;
+ BOOL bFound = FALSE;
+ ULONG nCount = Count();
+ ULONG nUpper = nCount;
+ ULONG nLower = 0;
+ ULONG nCurrent = nUpper / 2;
+ ULONG nRem = 0;
+ ByteString* pString;
+
+ do
+ {
+ if ( (nCurrent == nLower) || (nCurrent == nUpper) )
+ return nLower;
+ pString = GetObject( nCurrent );
+ ULONG 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;
+}
+
+
+
+
+
+
+
+
+
+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;
+ }
+ return nRet;
+}
+
+ULONG SUniStringList::GetPrevString( UniString* pStr )
+{
+ ULONG nRet = 0;
+ BOOL bFound = FALSE;
+ ULONG nCount = Count();
+ ULONG nUpper = nCount;
+ ULONG nLower = 0;
+ ULONG nCurrent = nUpper / 2;
+ ULONG nRem = 0;
+ UniString* pString;
+
+ do
+ {
+ if ( (nCurrent == nLower) || (nCurrent == nUpper) )
+ return nLower;
+ pString = GetObject( nCurrent );
+ ULONG 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;
+}