xref: /AOO41X/main/soldep/bootstrp/prj.cxx (revision d9e04f7d457e8d4292f3a8dc854ee7656a676fbb)
1*d9e04f7dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d9e04f7dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d9e04f7dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d9e04f7dSAndrew Rist  * distributed with this work for additional information
6*d9e04f7dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d9e04f7dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d9e04f7dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d9e04f7dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*d9e04f7dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*d9e04f7dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d9e04f7dSAndrew Rist  * software distributed under the License is distributed on an
15*d9e04f7dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d9e04f7dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d9e04f7dSAndrew Rist  * specific language governing permissions and limitations
18*d9e04f7dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*d9e04f7dSAndrew Rist  *************************************************************/
21*d9e04f7dSAndrew Rist 
22*d9e04f7dSAndrew Rist 
23cdf0e10cSrcweir #include <stdlib.h>
24cdf0e10cSrcweir #include <stdio.h>
25cdf0e10cSrcweir #include <soldep/sstring.hxx>
26cdf0e10cSrcweir #include <vos/mutex.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #define ENABLE_BYTESTRING_STREAM_OPERATORS
29cdf0e10cSrcweir #include <tools/stream.hxx>
30cdf0e10cSrcweir #include <tools/geninfo.hxx>
31cdf0e10cSrcweir #include <soldep/prj.hxx>
32cdf0e10cSrcweir //#include <bootstrp/inimgr.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #ifndef MACOSX
35cdf0e10cSrcweir #pragma hdrstop
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //#define TEST 	1
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #if defined(WNT) || defined(OS2)
41cdf0e10cSrcweir #define LIST_DELIMETER ';'
42cdf0e10cSrcweir #else
43cdf0e10cSrcweir #ifdef UNX
44cdf0e10cSrcweir #define LIST_DELIMETER ':'
45cdf0e10cSrcweir #else
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #if defined(WNT) || defined(OS2)
50cdf0e10cSrcweir #define PATH_DELIMETER '\\'
51cdf0e10cSrcweir #else
52cdf0e10cSrcweir #ifdef UNX
53cdf0e10cSrcweir #define PATH_DELIMETER '/'
54cdf0e10cSrcweir #else
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir 
58cdf0e10cSrcweir //static const char * XML_ALL  =	"all";
59cdf0e10cSrcweir 
60cdf0e10cSrcweir //
61cdf0e10cSrcweir //	class SimpleConfig
62cdf0e10cSrcweir //
63cdf0e10cSrcweir 
64cdf0e10cSrcweir /*****************************************************************************/
SimpleConfig(String aSimpleConfigFileName)65cdf0e10cSrcweir SimpleConfig::SimpleConfig( String aSimpleConfigFileName )
66cdf0e10cSrcweir /*****************************************************************************/
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	nLine = 0;
69cdf0e10cSrcweir 	aFileName = aSimpleConfigFileName;
70cdf0e10cSrcweir 	aFileStream.Open ( aFileName, STREAM_READ );
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir /*****************************************************************************/
SimpleConfig(DirEntry & rDirEntry)74cdf0e10cSrcweir SimpleConfig::SimpleConfig( DirEntry& rDirEntry )
75cdf0e10cSrcweir /*****************************************************************************/
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	nLine = 0;
78cdf0e10cSrcweir 	aFileName = rDirEntry.GetFull();
79cdf0e10cSrcweir 	aFileStream.Open ( aFileName, STREAM_READ );
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir /*****************************************************************************/
~SimpleConfig()83cdf0e10cSrcweir SimpleConfig::~SimpleConfig()
84cdf0e10cSrcweir /*****************************************************************************/
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	aFileStream.Close ();
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir /*****************************************************************************/
GetNext()90cdf0e10cSrcweir ByteString SimpleConfig::GetNext()
91cdf0e10cSrcweir /*****************************************************************************/
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	ByteString aString;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	if ( aStringBuffer =="" )
96cdf0e10cSrcweir 	  while ((aStringBuffer = GetNextLine()) == "\t"); //solange bis != "\t"
97cdf0e10cSrcweir 	if ( aStringBuffer =="" )
98cdf0e10cSrcweir 		return ByteString();
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	aString = aStringBuffer.GetToken(0,'\t');
101cdf0e10cSrcweir 	aStringBuffer.Erase(0, aString.Len()+1);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	aStringBuffer.EraseLeadingChars( '\t' );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	return aString;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir /*****************************************************************************/
GetNextLine()109cdf0e10cSrcweir ByteString	SimpleConfig::GetNextLine()
110cdf0e10cSrcweir /*****************************************************************************/
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	ByteString aSecStr;
113cdf0e10cSrcweir     sal_Bool bStreamOk;
114cdf0e10cSrcweir //	sal_uInt16 iret = 0;
115cdf0e10cSrcweir 	nLine++;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	bStreamOk = aFileStream.ReadLine ( aTmpStr );
118cdf0e10cSrcweir 	if ( (aTmpStr.Search( "#" ) == 0) )
119cdf0e10cSrcweir 		return "\t";
120cdf0e10cSrcweir 	aTmpStr = aTmpStr.EraseLeadingChars();
121cdf0e10cSrcweir 	aTmpStr = aTmpStr.EraseTrailingChars();
122cdf0e10cSrcweir 	while ( aTmpStr.SearchAndReplace(ByteString(' '),ByteString('\t') ) != STRING_NOTFOUND );
123cdf0e10cSrcweir 	int nLength = aTmpStr.Len();
124cdf0e10cSrcweir     if ( bStreamOk && (nLength == 0) )
125cdf0e10cSrcweir 		return "\t";
126cdf0e10cSrcweir //	sal_uInt16 nPos = 0;
127cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
128cdf0e10cSrcweir 	ByteString aEraseString;
129cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i<= nLength; i++)
130cdf0e10cSrcweir 	{
131cdf0e10cSrcweir 		if ( aTmpStr.GetChar( i ) == 0x20  && !bFound )
132cdf0e10cSrcweir 			aTmpStr.SetChar( i, 0x09 );
133cdf0e10cSrcweir 	}
134cdf0e10cSrcweir 	return aTmpStr;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir /*****************************************************************************/
GetCleanedNextLine(sal_Bool bReadComments)138cdf0e10cSrcweir ByteString SimpleConfig::GetCleanedNextLine( sal_Bool bReadComments )
139cdf0e10cSrcweir /*****************************************************************************/
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	sal_Bool bStreamOk;
142cdf0e10cSrcweir 	sal_Bool bReadNextLine = sal_True;
143cdf0e10cSrcweir 	while (bReadNextLine)
144cdf0e10cSrcweir 	{
145cdf0e10cSrcweir 		bStreamOk = aFileStream.ReadLine ( aTmpStr );
146cdf0e10cSrcweir 		if (!bStreamOk)
147cdf0e10cSrcweir 			return ByteString();
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 		ByteString sTab = "\t";
150cdf0e10cSrcweir 		ByteString sDoubleTab = "\t\t";
151cdf0e10cSrcweir 		ByteString sSpace = " ";
152cdf0e10cSrcweir 		xub_StrLen nIndex = 0;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 		aTmpStr.SearchAndReplaceAll(sSpace, sTab);
155cdf0e10cSrcweir 		while ( (nIndex = aTmpStr.SearchAndReplace(sDoubleTab, sTab, nIndex )) != STRING_NOTFOUND );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		aTmpStr = aTmpStr.EraseLeadingAndTrailingChars('\t'); // remove tabs
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		if ( aTmpStr.Search( "#" ) == 0 )
160cdf0e10cSrcweir 		{
161cdf0e10cSrcweir 			if (bReadComments )
162cdf0e10cSrcweir 				return aTmpStr;
163cdf0e10cSrcweir 		}
164cdf0e10cSrcweir         else if (aTmpStr != ByteString::EmptyString())
165cdf0e10cSrcweir 			bReadNextLine = sal_False;
166cdf0e10cSrcweir 	}
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	return aTmpStr;
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 
172cdf0e10cSrcweir //
173cdf0e10cSrcweir //	class CommandData
174cdf0e10cSrcweir //
175cdf0e10cSrcweir 
176cdf0e10cSrcweir /*****************************************************************************/
CommandData()177cdf0e10cSrcweir CommandData::CommandData()
178cdf0e10cSrcweir /*****************************************************************************/
179cdf0e10cSrcweir {
180cdf0e10cSrcweir 	nOSType = 0;
181cdf0e10cSrcweir 	nCommand = 0;
182cdf0e10cSrcweir 	pDepList = 0;
183cdf0e10cSrcweir 	pCommandList = 0;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir /*****************************************************************************/
~CommandData()187cdf0e10cSrcweir CommandData::~CommandData()
188cdf0e10cSrcweir /*****************************************************************************/
189cdf0e10cSrcweir {
190cdf0e10cSrcweir 	if ( pDepList )
191cdf0e10cSrcweir 	{
192cdf0e10cSrcweir 		ByteString *pString = pDepList->First();
193cdf0e10cSrcweir 		while ( pString )
194cdf0e10cSrcweir 		{
195cdf0e10cSrcweir 			delete pString;
196cdf0e10cSrcweir 			pString = pDepList->Next();
197cdf0e10cSrcweir 		}
198cdf0e10cSrcweir 		delete pDepList;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 		pDepList = NULL;
201cdf0e10cSrcweir 	}
202cdf0e10cSrcweir 	if ( pCommandList )
203cdf0e10cSrcweir 	{
204cdf0e10cSrcweir 		ByteString *pString = pCommandList->First();
205cdf0e10cSrcweir 		while ( pString )
206cdf0e10cSrcweir 		{
207cdf0e10cSrcweir 			delete pString;
208cdf0e10cSrcweir 			pString = pCommandList->Next();
209cdf0e10cSrcweir 		}
210cdf0e10cSrcweir 		delete pCommandList;
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 		pCommandList = NULL;
213cdf0e10cSrcweir 	}
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir /*****************************************************************************/
GetOSTypeString()217cdf0e10cSrcweir ByteString CommandData::GetOSTypeString()
218cdf0e10cSrcweir /*****************************************************************************/
219cdf0e10cSrcweir {
220cdf0e10cSrcweir 	ByteString aRetStr;
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	switch (nOSType)
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir 		case OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX | OS_MAC :
225cdf0e10cSrcweir 			aRetStr = "all";
226cdf0e10cSrcweir 			break;
227cdf0e10cSrcweir 		case OS_WIN32 | OS_WIN16 :
228cdf0e10cSrcweir 			aRetStr = "w";
229cdf0e10cSrcweir 			break;
230cdf0e10cSrcweir 		case OS_OS2 :
231cdf0e10cSrcweir 			aRetStr = "p";
232cdf0e10cSrcweir 			break;
233cdf0e10cSrcweir 		case OS_UNX :
234cdf0e10cSrcweir 			aRetStr = "u";
235cdf0e10cSrcweir 			break;
236cdf0e10cSrcweir 		case OS_WIN16 :
237cdf0e10cSrcweir 			aRetStr = "d";
238cdf0e10cSrcweir 			break;
239cdf0e10cSrcweir 		case OS_WIN32 :
240cdf0e10cSrcweir 			aRetStr = "n";
241cdf0e10cSrcweir 			break;
242cdf0e10cSrcweir 		case OS_MAC :
243cdf0e10cSrcweir 			aRetStr = "m";
244cdf0e10cSrcweir 			break;
245cdf0e10cSrcweir 		default :
246cdf0e10cSrcweir 			aRetStr = "none";
247cdf0e10cSrcweir 	}
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	return aRetStr;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir /*****************************************************************************/
GetCommandTypeString()253cdf0e10cSrcweir ByteString CommandData::GetCommandTypeString()
254cdf0e10cSrcweir /*****************************************************************************/
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	ByteString aRetStr;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	switch (nCommand)
259cdf0e10cSrcweir 	{
260cdf0e10cSrcweir 		case COMMAND_NMAKE :
261cdf0e10cSrcweir 			aRetStr = "nmake";
262cdf0e10cSrcweir 			break;
263cdf0e10cSrcweir 		case COMMAND_GET :
264cdf0e10cSrcweir 			aRetStr = "get";
265cdf0e10cSrcweir 			break;
266cdf0e10cSrcweir 		default :
267cdf0e10cSrcweir 			aRetStr = "usr";
268cdf0e10cSrcweir 			aRetStr += ByteString::CreateFromInt64( nCommand + 1 - COMMAND_USER_START );
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	}
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	return aRetStr;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir /*****************************************************************************/
AddCommand(ByteString * pCommand)276cdf0e10cSrcweir void CommandData::AddCommand(ByteString* pCommand)
277cdf0e10cSrcweir /*****************************************************************************/
278cdf0e10cSrcweir {
279cdf0e10cSrcweir 	if (!pCommandList)
280cdf0e10cSrcweir 		pCommandList = new SByteStringList();
281cdf0e10cSrcweir 	pCommandList->Insert(pCommand, LIST_APPEND);
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir /*****************************************************************************/
operator >>(SvStream & rStream)285cdf0e10cSrcweir CommandData& CommandData::operator>>  ( SvStream& rStream )
286cdf0e10cSrcweir /*****************************************************************************/
287cdf0e10cSrcweir {
288cdf0e10cSrcweir 	rStream << aPrj;
289cdf0e10cSrcweir 	rStream << aLogFileName;
290cdf0e10cSrcweir 	rStream << aInpath;
291cdf0e10cSrcweir 	rStream << aUpd;
292cdf0e10cSrcweir 	rStream << aUpdMinor;
293cdf0e10cSrcweir 	rStream << aProduct;
294cdf0e10cSrcweir 	rStream << aCommand;
295cdf0e10cSrcweir 	rStream << aPath;
296cdf0e10cSrcweir 	rStream << aPrePath;
297cdf0e10cSrcweir 	rStream << aPreFix;
298cdf0e10cSrcweir 	rStream << aCommandPara;
299cdf0e10cSrcweir 	rStream << aComment;
300cdf0e10cSrcweir 	rStream << sClientRestriction;
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	rStream << nOSType;
303cdf0e10cSrcweir 	rStream << nCommand;
304cdf0e10cSrcweir 	rStream << nDepth;
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	if (pDepList)
307cdf0e10cSrcweir 	{
308cdf0e10cSrcweir 		rStream << sal_True;
309cdf0e10cSrcweir 		*pDepList >> rStream;
310cdf0e10cSrcweir 	}
311cdf0e10cSrcweir 	else
312cdf0e10cSrcweir 		rStream << sal_False;
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 	if (pCommandList)
315cdf0e10cSrcweir 	{
316cdf0e10cSrcweir 		rStream << sal_True;
317cdf0e10cSrcweir 		*pCommandList >> rStream;
318cdf0e10cSrcweir 	}
319cdf0e10cSrcweir 	else
320cdf0e10cSrcweir 		rStream << sal_False;
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	return *this;
323cdf0e10cSrcweir }
324cdf0e10cSrcweir 
325cdf0e10cSrcweir /*****************************************************************************/
operator <<(SvStream & rStream)326cdf0e10cSrcweir CommandData& CommandData::operator<<  ( SvStream& rStream )
327cdf0e10cSrcweir /*****************************************************************************/
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	rStream >> aPrj;
330cdf0e10cSrcweir 	rStream >> aLogFileName;
331cdf0e10cSrcweir 	rStream >> aInpath;
332cdf0e10cSrcweir 	rStream >> aUpd;
333cdf0e10cSrcweir 	rStream >> aUpdMinor;
334cdf0e10cSrcweir 	rStream >> aProduct;
335cdf0e10cSrcweir 	rStream >> aCommand;
336cdf0e10cSrcweir 	rStream >> aPath;
337cdf0e10cSrcweir 	rStream >> aPrePath;
338cdf0e10cSrcweir 	rStream >> aPreFix;
339cdf0e10cSrcweir 	rStream >> aCommandPara;
340cdf0e10cSrcweir 	rStream >> aComment;
341cdf0e10cSrcweir 	rStream >> sClientRestriction;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	rStream >> nOSType;
344cdf0e10cSrcweir 	rStream >> nCommand;
345cdf0e10cSrcweir 	rStream >> nDepth;
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	sal_Bool bDepList;
348cdf0e10cSrcweir 	rStream >> bDepList;
349cdf0e10cSrcweir 	if (pDepList)
350cdf0e10cSrcweir 		pDepList->CleanUp();
351cdf0e10cSrcweir 	if (bDepList)
352cdf0e10cSrcweir 	{
353cdf0e10cSrcweir 		if (!pDepList)
354cdf0e10cSrcweir 			pDepList = new SByteStringList();
355cdf0e10cSrcweir 		*pDepList << rStream;
356cdf0e10cSrcweir 	}
357cdf0e10cSrcweir 	else
358cdf0e10cSrcweir 	{
359cdf0e10cSrcweir 		if (pDepList)
360cdf0e10cSrcweir 		DELETEZ (pDepList);
361cdf0e10cSrcweir 	}
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	sal_Bool bCommandList;
364cdf0e10cSrcweir 	rStream >> bCommandList;
365cdf0e10cSrcweir 	if (pCommandList)
366cdf0e10cSrcweir 		pCommandList->CleanUp();
367cdf0e10cSrcweir 	if (bCommandList)
368cdf0e10cSrcweir 	{
369cdf0e10cSrcweir 		if (!pCommandList)
370cdf0e10cSrcweir 			pCommandList = new SByteStringList();
371cdf0e10cSrcweir 		*pCommandList << rStream;
372cdf0e10cSrcweir 	}
373cdf0e10cSrcweir 	else
374cdf0e10cSrcweir 	{
375cdf0e10cSrcweir 		if (pCommandList)
376cdf0e10cSrcweir 			DELETEZ (pCommandList);
377cdf0e10cSrcweir 	}
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 	return *this;
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 
384cdf0e10cSrcweir //
385cdf0e10cSrcweir // class DepInfo
386cdf0e10cSrcweir //
387cdf0e10cSrcweir 
388cdf0e10cSrcweir /*****************************************************************************/
~DepInfo()389cdf0e10cSrcweir DepInfo::~DepInfo()
390cdf0e10cSrcweir /*****************************************************************************/
391cdf0e10cSrcweir {
392cdf0e10cSrcweir 	RemoveProject();
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 	if ( pModeList )
395cdf0e10cSrcweir 	{
396cdf0e10cSrcweir 		ByteString *pString = pModeList->First();
397cdf0e10cSrcweir 		while ( pString )
398cdf0e10cSrcweir 		{
399cdf0e10cSrcweir 			delete pString;
400cdf0e10cSrcweir 			pString = pModeList->Next();
401cdf0e10cSrcweir 		}
402cdf0e10cSrcweir 		delete pModeList;
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 		pModeList = NULL;
405cdf0e10cSrcweir 	}
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
408cdf0e10cSrcweir /*****************************************************************************/
SetProject(ByteString * pStr)409cdf0e10cSrcweir void DepInfo::SetProject (ByteString* pStr)
410cdf0e10cSrcweir /*****************************************************************************/
411cdf0e10cSrcweir {
412cdf0e10cSrcweir 	RemoveProject();
413cdf0e10cSrcweir 	pProject = pStr;
414cdf0e10cSrcweir }
415cdf0e10cSrcweir 
416cdf0e10cSrcweir /*****************************************************************************/
RemoveProject()417cdf0e10cSrcweir void DepInfo::RemoveProject ()
418cdf0e10cSrcweir /*****************************************************************************/
419cdf0e10cSrcweir {
420cdf0e10cSrcweir 	if (pProject)
421cdf0e10cSrcweir 	{
422cdf0e10cSrcweir 		delete pProject;
423cdf0e10cSrcweir 		pProject = NULL;
424cdf0e10cSrcweir 	}
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
427cdf0e10cSrcweir /*****************************************************************************/
operator <<(SvStream & rStream)428cdf0e10cSrcweir DepInfo& DepInfo::operator<<  ( SvStream& rStream )
429cdf0e10cSrcweir /*****************************************************************************/
430cdf0e10cSrcweir {
431cdf0e10cSrcweir 	RemoveProject();
432cdf0e10cSrcweir 	pProject = new ByteString();
433cdf0e10cSrcweir 	rStream >> *pProject;
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 	sal_Bool bModeList;
436cdf0e10cSrcweir 	rStream >> bModeList;
437cdf0e10cSrcweir 	if (pModeList)
438cdf0e10cSrcweir 		pModeList->CleanUp();
439cdf0e10cSrcweir 	if (bModeList)
440cdf0e10cSrcweir 	{
441cdf0e10cSrcweir 		if (!pModeList)
442cdf0e10cSrcweir 			pModeList = new SByteStringList();
443cdf0e10cSrcweir 		*pModeList << rStream;
444cdf0e10cSrcweir 	}
445cdf0e10cSrcweir 	else
446cdf0e10cSrcweir 		DELETEZ (pModeList);
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 	rStream >> bAllModes;
449cdf0e10cSrcweir 	return *this;
450cdf0e10cSrcweir }
451cdf0e10cSrcweir 
452cdf0e10cSrcweir /*****************************************************************************/
operator >>(SvStream & rStream)453cdf0e10cSrcweir DepInfo& DepInfo::operator>>  ( SvStream& rStream )
454cdf0e10cSrcweir /*****************************************************************************/
455cdf0e10cSrcweir {
456cdf0e10cSrcweir 	rStream << *pProject;
457cdf0e10cSrcweir 	if (pModeList)
458cdf0e10cSrcweir 	{
459cdf0e10cSrcweir 		rStream << sal_True;
460cdf0e10cSrcweir 		*pModeList >> rStream;
461cdf0e10cSrcweir 	}
462cdf0e10cSrcweir 	else
463cdf0e10cSrcweir 		rStream << sal_False;
464cdf0e10cSrcweir 	rStream << bAllModes;
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	return *this;
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir //
470cdf0e10cSrcweir // class SDepInfoList
471cdf0e10cSrcweir //
472cdf0e10cSrcweir 
473cdf0e10cSrcweir /*****************************************************************************/
SDepInfoList()474cdf0e10cSrcweir SDepInfoList::SDepInfoList()
475cdf0e10cSrcweir /*****************************************************************************/
476cdf0e10cSrcweir 								: pAllModeList(0)
477cdf0e10cSrcweir {
478cdf0e10cSrcweir }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir /*****************************************************************************/
~SDepInfoList()481cdf0e10cSrcweir SDepInfoList::~SDepInfoList()
482cdf0e10cSrcweir /*****************************************************************************/
483cdf0e10cSrcweir {
484cdf0e10cSrcweir 	if (pAllModeList)
485cdf0e10cSrcweir 		delete pAllModeList;
486cdf0e10cSrcweir }
487cdf0e10cSrcweir 
488cdf0e10cSrcweir /*****************************************************************************/
IsString(ByteString * pStr)489cdf0e10cSrcweir sal_uIntPtr SDepInfoList::IsString( ByteString* pStr )
490cdf0e10cSrcweir /*****************************************************************************/
491cdf0e10cSrcweir {
492cdf0e10cSrcweir 	sal_uIntPtr nRet = NOT_THERE;
493cdf0e10cSrcweir 	if ( (nRet = GetPrevString( pStr )) != 0 )
494cdf0e10cSrcweir 	{
495cdf0e10cSrcweir 		ByteString* pString = GetObject( nRet )->GetProject();
496cdf0e10cSrcweir 		if ( *pString == *pStr )
497cdf0e10cSrcweir 			return nRet;
498cdf0e10cSrcweir 		else
499cdf0e10cSrcweir 			return NOT_THERE;
500cdf0e10cSrcweir 	}
501cdf0e10cSrcweir 	else
502cdf0e10cSrcweir 	{
503cdf0e10cSrcweir 		ByteString* pString = GetObject( 0 )->GetProject();
504cdf0e10cSrcweir 		if ( pString && (*pString == *pStr) )
505cdf0e10cSrcweir 			return 0;
506cdf0e10cSrcweir 		else
507cdf0e10cSrcweir 			return NOT_THERE;
508cdf0e10cSrcweir 	}
509cdf0e10cSrcweir 	return nRet;
510cdf0e10cSrcweir }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir /*****************************************************************************/
GetPrevString(ByteString * pStr)513cdf0e10cSrcweir sal_uIntPtr SDepInfoList::GetPrevString( ByteString* pStr )
514cdf0e10cSrcweir /*****************************************************************************/
515cdf0e10cSrcweir {
516cdf0e10cSrcweir 	sal_uIntPtr nRet = 0;
517cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
518cdf0e10cSrcweir 	sal_uIntPtr nCount_l = Count();
519cdf0e10cSrcweir 	sal_uIntPtr nUpper = nCount_l;
520cdf0e10cSrcweir 	sal_uIntPtr nLower = 0;
521cdf0e10cSrcweir 	sal_uIntPtr nCurrent = nUpper / 2;
522cdf0e10cSrcweir 	sal_uIntPtr nRem = 0;
523cdf0e10cSrcweir 	ByteString* pString;
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 	do
526cdf0e10cSrcweir 	{
527cdf0e10cSrcweir 		if ( (nCurrent == nLower) || (nCurrent == nUpper) )
528cdf0e10cSrcweir 			return nLower;
529cdf0e10cSrcweir 		pString = GetObject( nCurrent )->GetProject();
530cdf0e10cSrcweir 		int nResult =  pStr->CompareTo( *pString );
531cdf0e10cSrcweir 		if ( nResult == COMPARE_LESS )
532cdf0e10cSrcweir 		{
533cdf0e10cSrcweir 			nUpper = nCurrent;
534cdf0e10cSrcweir 			nCurrent = (nCurrent + nLower) /2;
535cdf0e10cSrcweir 		}
536cdf0e10cSrcweir 		else if ( nResult == COMPARE_GREATER )
537cdf0e10cSrcweir 		{
538cdf0e10cSrcweir 			nLower = nCurrent;
539cdf0e10cSrcweir 			nCurrent = (nUpper + nCurrent) /2;
540cdf0e10cSrcweir 		}
541cdf0e10cSrcweir 		else if ( nResult == COMPARE_EQUAL )
542cdf0e10cSrcweir 			return nCurrent;
543cdf0e10cSrcweir 		if ( nRem == nCurrent )
544cdf0e10cSrcweir 			return nCurrent;
545cdf0e10cSrcweir 		nRem = nCurrent;
546cdf0e10cSrcweir 	}
547cdf0e10cSrcweir 	while ( !bFound );
548cdf0e10cSrcweir 	return nRet;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir /*****************************************************************************/
PutModeString(DepInfo * pInfoList,ByteString * pStr)552cdf0e10cSrcweir void SDepInfoList::PutModeString( DepInfo* pInfoList, ByteString* pStr )
553cdf0e10cSrcweir /*****************************************************************************/
554cdf0e10cSrcweir {
555cdf0e10cSrcweir 	SByteStringList* pList = pInfoList->GetModeList();
556cdf0e10cSrcweir 	if (!pList)
557cdf0e10cSrcweir 	{
558cdf0e10cSrcweir 		pList = new SByteStringList;
559cdf0e10cSrcweir 		pInfoList->SetModeList(pList);
560cdf0e10cSrcweir 
561cdf0e10cSrcweir 	}
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 	if (pList)
564cdf0e10cSrcweir 	{
565cdf0e10cSrcweir 		// check if string exists
566cdf0e10cSrcweir 		ByteString *pString = pList->First();
567cdf0e10cSrcweir 		while ( pString )
568cdf0e10cSrcweir 		{
569cdf0e10cSrcweir 			if (*pString == *pStr)
570cdf0e10cSrcweir 			{
571cdf0e10cSrcweir 				delete pStr;
572cdf0e10cSrcweir 				return;
573cdf0e10cSrcweir 			}
574cdf0e10cSrcweir 			pString = pList->Next();
575cdf0e10cSrcweir 		}
576cdf0e10cSrcweir 		pList->PutString( pStr );
577cdf0e10cSrcweir 	}
578cdf0e10cSrcweir 	else
579cdf0e10cSrcweir 		delete pStr;
580cdf0e10cSrcweir }
581cdf0e10cSrcweir 
582cdf0e10cSrcweir /*****************************************************************************/
PutString(ByteString * pStr)583cdf0e10cSrcweir sal_uIntPtr SDepInfoList::PutString( ByteString* pStr)
584cdf0e10cSrcweir /*****************************************************************************/
585cdf0e10cSrcweir {
586cdf0e10cSrcweir 	return PutString( pStr, NULL);
587cdf0e10cSrcweir }
588cdf0e10cSrcweir 
589cdf0e10cSrcweir /**************************************************************************
590cdf0e10cSrcweir *
591cdf0e10cSrcweir *	Sortiert einen ByteString in die Liste ein und gibt die Position,
592cdf0e10cSrcweir *	an der einsortiert wurde, zurueck
593cdf0e10cSrcweir *
594cdf0e10cSrcweir **************************************************************************/
595cdf0e10cSrcweir 
PutString(ByteString * pStr,ByteString * pModeStr)596cdf0e10cSrcweir sal_uIntPtr SDepInfoList::PutString( ByteString* pStr, ByteString* pModeStr)
597cdf0e10cSrcweir {
598cdf0e10cSrcweir 	if (pAllModeList)
599cdf0e10cSrcweir 	{
600cdf0e10cSrcweir 		delete pAllModeList;
601cdf0e10cSrcweir 		pAllModeList = NULL;
602cdf0e10cSrcweir 	}
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 	sal_uIntPtr nPos = GetPrevString ( pStr );
605cdf0e10cSrcweir 	if ( Count() )
606cdf0e10cSrcweir 	{
607cdf0e10cSrcweir 		{
608cdf0e10cSrcweir 			DepInfo* pInfo = GetObject( 0 );
609cdf0e10cSrcweir 			ByteString* pString = pInfo->GetProject();
610cdf0e10cSrcweir 			if ( pString->CompareTo( *pStr ) == COMPARE_GREATER )
611cdf0e10cSrcweir 			{
612cdf0e10cSrcweir 				pInfo = new DepInfo;
613cdf0e10cSrcweir 				if (pInfo)
614cdf0e10cSrcweir 				{
615cdf0e10cSrcweir 					pInfo->SetProject(pStr);
616cdf0e10cSrcweir 					if (pModeStr)
617cdf0e10cSrcweir 						PutModeString(pInfo, pModeStr);
618cdf0e10cSrcweir 					else
619cdf0e10cSrcweir 						pInfo->SetAllModes();
620cdf0e10cSrcweir 					Insert( pInfo, (sal_uIntPtr)0 );
621cdf0e10cSrcweir 				}
622cdf0e10cSrcweir 				return (sal_uIntPtr)0;
623cdf0e10cSrcweir 			}
624cdf0e10cSrcweir 		}
625cdf0e10cSrcweir 		ByteString* pString = GetObject( nPos )->GetProject();
626cdf0e10cSrcweir 		if ( *pStr != *pString )
627cdf0e10cSrcweir 		{
628cdf0e10cSrcweir 			DepInfo* pInfo = new DepInfo;
629cdf0e10cSrcweir 			if (pInfo)
630cdf0e10cSrcweir 			{
631cdf0e10cSrcweir 				pInfo->SetProject(pStr);
632cdf0e10cSrcweir 				if (pModeStr)
633cdf0e10cSrcweir 					PutModeString(pInfo, pModeStr);
634cdf0e10cSrcweir 				else
635cdf0e10cSrcweir 					pInfo->SetAllModes();
636cdf0e10cSrcweir 				Insert( pInfo, nPos+1 );
637cdf0e10cSrcweir 			}
638cdf0e10cSrcweir 			return ( nPos +1 );
639cdf0e10cSrcweir 		}
640cdf0e10cSrcweir 		else
641cdf0e10cSrcweir 		{
642cdf0e10cSrcweir 			delete pStr;
643cdf0e10cSrcweir 			DepInfo* pInfo = GetObject( nPos );
644cdf0e10cSrcweir 			if (pModeStr)
645cdf0e10cSrcweir 				PutModeString(pInfo, pModeStr);
646cdf0e10cSrcweir 			else
647cdf0e10cSrcweir 				pInfo->SetAllModes();
648cdf0e10cSrcweir 			return ( nPos +1 );
649cdf0e10cSrcweir 		}
650cdf0e10cSrcweir 	}
651cdf0e10cSrcweir 	else
652cdf0e10cSrcweir 	{
653cdf0e10cSrcweir 		DepInfo* pInfo = new DepInfo;
654cdf0e10cSrcweir 		if (pInfo)
655cdf0e10cSrcweir 		{
656cdf0e10cSrcweir 			pInfo->SetProject(pStr);
657cdf0e10cSrcweir 			if (pModeStr)
658cdf0e10cSrcweir 				PutModeString(pInfo, pModeStr);
659cdf0e10cSrcweir 			else
660cdf0e10cSrcweir 				pInfo->SetAllModes();
661cdf0e10cSrcweir 			Insert( pInfo);
662cdf0e10cSrcweir 			return (sal_uIntPtr)0;
663cdf0e10cSrcweir 		}
664cdf0e10cSrcweir 	}
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 	delete pStr;
667cdf0e10cSrcweir 	if (pModeStr)
668cdf0e10cSrcweir 		delete pModeStr;
669cdf0e10cSrcweir 	return NOT_THERE;
670cdf0e10cSrcweir }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir /*****************************************************************************/
RemoveString(const ByteString & rName)673cdf0e10cSrcweir ByteString* SDepInfoList::RemoveString( const ByteString& rName )
674cdf0e10cSrcweir /*****************************************************************************/
675cdf0e10cSrcweir {
676cdf0e10cSrcweir 	sal_uIntPtr i;
677cdf0e10cSrcweir 	ByteString* pReturn;
678cdf0e10cSrcweir 	if (pAllModeList)
679cdf0e10cSrcweir 	{
680cdf0e10cSrcweir 		delete pAllModeList;
681cdf0e10cSrcweir 		pAllModeList = NULL;
682cdf0e10cSrcweir 	}
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 	for( i = 0 ; i < Count(); i++ )
685cdf0e10cSrcweir 	{
686cdf0e10cSrcweir 		if ( rName == *(GetObject( i )->GetProject()) )
687cdf0e10cSrcweir 		{
688cdf0e10cSrcweir 			pReturn = new ByteString(*(GetObject(i)->GetProject()));
689cdf0e10cSrcweir 			DepInfo* pInfo;
690cdf0e10cSrcweir 			pInfo = GetObject(i);
691cdf0e10cSrcweir 			delete pInfo;
692cdf0e10cSrcweir 			Remove(i);
693cdf0e10cSrcweir 			return pReturn;
694cdf0e10cSrcweir 		}
695cdf0e10cSrcweir 	}
696cdf0e10cSrcweir 
697cdf0e10cSrcweir 	return NULL;
698cdf0e10cSrcweir }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir /*****************************************************************************/
GetAllDepModes()701cdf0e10cSrcweir SByteStringList* SDepInfoList::GetAllDepModes()
702cdf0e10cSrcweir /*****************************************************************************/
703cdf0e10cSrcweir {
704cdf0e10cSrcweir 	if (pAllModeList)
705cdf0e10cSrcweir 			return pAllModeList;
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 	DepInfo *pInfo = First();
708cdf0e10cSrcweir 	while ( pInfo )
709cdf0e10cSrcweir 	{
710cdf0e10cSrcweir 		if (!pInfo->IsAllModes() && pInfo->GetModeList())
711cdf0e10cSrcweir 		{
712cdf0e10cSrcweir 			if (!pAllModeList)
713cdf0e10cSrcweir 				pAllModeList = new SByteStringList();
714cdf0e10cSrcweir 			ByteString* pStr = pInfo->GetModeList()->First();
715cdf0e10cSrcweir 			while (pStr)
716cdf0e10cSrcweir 			{
717cdf0e10cSrcweir 				if (pAllModeList->IsString(pStr) == NOT_THERE)
718cdf0e10cSrcweir 					pAllModeList->PutString(pStr);
719cdf0e10cSrcweir 				pStr = pInfo->GetModeList()->Next();
720cdf0e10cSrcweir 			}
721cdf0e10cSrcweir 		}
722cdf0e10cSrcweir 		pInfo = Next();
723cdf0e10cSrcweir 	}
724cdf0e10cSrcweir 	return pAllModeList;
725cdf0e10cSrcweir }
726cdf0e10cSrcweir 
727cdf0e10cSrcweir /*****************************************************************************/
operator <<(SvStream & rStream)728cdf0e10cSrcweir SDepInfoList& SDepInfoList::operator<< ( SvStream& rStream )
729cdf0e10cSrcweir /*****************************************************************************/
730cdf0e10cSrcweir {
731cdf0e10cSrcweir 	sal_uIntPtr nCount_l;
732cdf0e10cSrcweir 	rStream >> nCount_l;
733cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount_l; i++ ) {
734cdf0e10cSrcweir         DepInfo* pDepInfo = new DepInfo();
735cdf0e10cSrcweir         *pDepInfo << rStream;
736cdf0e10cSrcweir         Insert (pDepInfo, LIST_APPEND);
737cdf0e10cSrcweir     }
738cdf0e10cSrcweir 	return *this;
739cdf0e10cSrcweir }
740cdf0e10cSrcweir 
741cdf0e10cSrcweir /*****************************************************************************/
operator >>(SvStream & rStream)742cdf0e10cSrcweir SDepInfoList& SDepInfoList::operator>> ( SvStream& rStream )
743cdf0e10cSrcweir /*****************************************************************************/
744cdf0e10cSrcweir {
745cdf0e10cSrcweir 	sal_uIntPtr nCount_l = Count();
746cdf0e10cSrcweir 	rStream << nCount_l;
747cdf0e10cSrcweir 	DepInfo* pDepInfo = First();
748cdf0e10cSrcweir 	while (pDepInfo) {
749cdf0e10cSrcweir 		*pDepInfo >> rStream;
750cdf0e10cSrcweir 		pDepInfo = Next();
751cdf0e10cSrcweir 	}
752cdf0e10cSrcweir 
753cdf0e10cSrcweir 	return *this;
754cdf0e10cSrcweir }
755cdf0e10cSrcweir 
756cdf0e10cSrcweir /*****************************************************************************/
GetDirectoryList(sal_uInt16 nWhatOS,sal_uInt16 nCommand)757cdf0e10cSrcweir CommandData* Prj::GetDirectoryList ( sal_uInt16 nWhatOS, sal_uInt16 nCommand )
758cdf0e10cSrcweir /*****************************************************************************/
759cdf0e10cSrcweir {
760cdf0e10cSrcweir 	return (CommandData *)NULL;
761cdf0e10cSrcweir }
762cdf0e10cSrcweir 
763cdf0e10cSrcweir /*****************************************************************************/
GetDirectoryData(ByteString aLogFileName)764cdf0e10cSrcweir CommandData* Prj::GetDirectoryData( ByteString aLogFileName )
765cdf0e10cSrcweir /*****************************************************************************/
766cdf0e10cSrcweir {
767cdf0e10cSrcweir 	PrjList* pPrjList = GetCommandDataList ();
768cdf0e10cSrcweir 	CommandData *pData = NULL;
769cdf0e10cSrcweir 	sal_uIntPtr nCount_l = pPrjList->Count();
770cdf0e10cSrcweir 	for ( sal_uIntPtr i=0; i<nCount_l; i++ )
771cdf0e10cSrcweir 	{
772cdf0e10cSrcweir 		pData = pPrjList->GetObject(i);
773cdf0e10cSrcweir 		if ( pData->GetLogFile() == aLogFileName )
774cdf0e10cSrcweir 			return pData;
775cdf0e10cSrcweir 	}
776cdf0e10cSrcweir 	return NULL;
777cdf0e10cSrcweir }
778cdf0e10cSrcweir 
779cdf0e10cSrcweir //
780cdf0e10cSrcweir //	class Prj
781cdf0e10cSrcweir //
782cdf0e10cSrcweir 
783cdf0e10cSrcweir /*****************************************************************************/
Prj()784cdf0e10cSrcweir Prj::Prj() :
785cdf0e10cSrcweir 	pPrjInitialDepList(0),
786cdf0e10cSrcweir 	pPrjDepList(0),
787cdf0e10cSrcweir 	pPrjDepInfoList(0),
788cdf0e10cSrcweir 	bSorted( sal_False ),
789cdf0e10cSrcweir 	bHardDependencies( sal_False ),
790cdf0e10cSrcweir 	bFixedDependencies( sal_False ),
791cdf0e10cSrcweir 	bVisited( sal_False ),
792cdf0e10cSrcweir 	bIsAvailable( sal_True ),
793cdf0e10cSrcweir 	pTempCommandDataList (0),
794cdf0e10cSrcweir 	bTempCommandDataListPermanent (sal_False),
795cdf0e10cSrcweir 	bError (sal_False)
796cdf0e10cSrcweir /*****************************************************************************/
797cdf0e10cSrcweir {
798cdf0e10cSrcweir }
799cdf0e10cSrcweir 
800cdf0e10cSrcweir /*****************************************************************************/
Prj(ByteString aName)801cdf0e10cSrcweir Prj::Prj( ByteString aName ) :
802cdf0e10cSrcweir 	aProjectName( aName ),
803cdf0e10cSrcweir 	pPrjInitialDepList(0),
804cdf0e10cSrcweir 	pPrjDepList(0),
805cdf0e10cSrcweir 	pPrjDepInfoList(0),
806cdf0e10cSrcweir 	bSorted( sal_False ),
807cdf0e10cSrcweir 	bHardDependencies( sal_False ),
808cdf0e10cSrcweir 	bFixedDependencies( sal_False ),
809cdf0e10cSrcweir 	bVisited( sal_False ),
810cdf0e10cSrcweir 	bIsAvailable( sal_True ),
811cdf0e10cSrcweir 	pTempCommandDataList (0),
812cdf0e10cSrcweir 	bTempCommandDataListPermanent (sal_False),
813cdf0e10cSrcweir 	bError (sal_False)
814cdf0e10cSrcweir /*****************************************************************************/
815cdf0e10cSrcweir {
816cdf0e10cSrcweir }
817cdf0e10cSrcweir 
818cdf0e10cSrcweir /*****************************************************************************/
~Prj()819cdf0e10cSrcweir Prj::~Prj()
820cdf0e10cSrcweir /*****************************************************************************/
821cdf0e10cSrcweir {
822cdf0e10cSrcweir 	pPrjDepList = RemoveStringList (pPrjDepList);
823cdf0e10cSrcweir 	pPrjInitialDepList = RemoveStringList (pPrjInitialDepList);
824cdf0e10cSrcweir 	pPrjDepInfoList = RemoveDepInfoList (pPrjDepInfoList);
825cdf0e10cSrcweir }
826cdf0e10cSrcweir 
827cdf0e10cSrcweir /*****************************************************************************/
RemoveStringList(SByteStringList * pStringList)828cdf0e10cSrcweir SByteStringList* Prj::RemoveStringList(SByteStringList* pStringList )
829cdf0e10cSrcweir /*****************************************************************************/
830cdf0e10cSrcweir {
831cdf0e10cSrcweir 	if ( pStringList )
832cdf0e10cSrcweir 	{
833cdf0e10cSrcweir 		ByteString *pString = pStringList->First();
834cdf0e10cSrcweir 		while ( pString )
835cdf0e10cSrcweir 		{
836cdf0e10cSrcweir 			delete pString;
837cdf0e10cSrcweir 			pString = pStringList->Next();
838cdf0e10cSrcweir 		}
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 		delete pStringList;
841cdf0e10cSrcweir 
842cdf0e10cSrcweir 		pStringList = NULL;
843cdf0e10cSrcweir 	}
844cdf0e10cSrcweir 	return pStringList;
845cdf0e10cSrcweir }
846cdf0e10cSrcweir 
847cdf0e10cSrcweir /*****************************************************************************/
RemoveDepInfoList(SDepInfoList * pInfoList)848cdf0e10cSrcweir SDepInfoList* Prj::RemoveDepInfoList(SDepInfoList* pInfoList )
849cdf0e10cSrcweir /*****************************************************************************/
850cdf0e10cSrcweir {
851cdf0e10cSrcweir 	if ( pInfoList )
852cdf0e10cSrcweir 	{
853cdf0e10cSrcweir 		DepInfo *pInfo = pInfoList->First();
854cdf0e10cSrcweir 		while ( pInfo )
855cdf0e10cSrcweir 		{
856cdf0e10cSrcweir 			delete pInfo;
857cdf0e10cSrcweir 			pInfo = pInfoList->Next();
858cdf0e10cSrcweir 		}
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 		delete pInfoList;
861cdf0e10cSrcweir 
862cdf0e10cSrcweir 		pInfoList = NULL;
863cdf0e10cSrcweir 	}
864cdf0e10cSrcweir 	return pInfoList;
865cdf0e10cSrcweir }
866cdf0e10cSrcweir 
867cdf0e10cSrcweir /*****************************************************************************/
AddDependencies(ByteString aStr)868cdf0e10cSrcweir void Prj::AddDependencies( ByteString aStr )
869cdf0e10cSrcweir /*****************************************************************************/
870cdf0e10cSrcweir {
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 	if ( !pPrjDepInfoList )
873cdf0e10cSrcweir 		pPrjDepInfoList = new SDepInfoList;
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 	pPrjDepInfoList->PutString( new ByteString(aStr) );
876cdf0e10cSrcweir }
877cdf0e10cSrcweir 
878cdf0e10cSrcweir /*****************************************************************************/
AddDependencies(ByteString aStr,ByteString aModeStr)879cdf0e10cSrcweir void Prj::AddDependencies( ByteString aStr, ByteString aModeStr )
880cdf0e10cSrcweir /*****************************************************************************/
881cdf0e10cSrcweir {
882cdf0e10cSrcweir 
883cdf0e10cSrcweir 	// needs dirty flag - not expanded
884cdf0e10cSrcweir 	if ( !pPrjDepInfoList )
885cdf0e10cSrcweir 		pPrjDepInfoList = new SDepInfoList;
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 	pPrjDepInfoList->PutString( new ByteString(aStr), new ByteString(aModeStr) );
888cdf0e10cSrcweir }
889cdf0e10cSrcweir 
890cdf0e10cSrcweir /*****************************************************************************/
GetDependencies(sal_Bool bExpanded)891cdf0e10cSrcweir SByteStringList* Prj::GetDependencies( sal_Bool bExpanded )
892cdf0e10cSrcweir /*****************************************************************************/
893cdf0e10cSrcweir {
894cdf0e10cSrcweir 	if ( bExpanded )
895cdf0e10cSrcweir 	{
896cdf0e10cSrcweir 		if (!pPrjDepList)
897cdf0e10cSrcweir 			SetMode (NULL);
898cdf0e10cSrcweir 		return pPrjDepList;
899cdf0e10cSrcweir 	}
900cdf0e10cSrcweir 	else
901cdf0e10cSrcweir 	{
902cdf0e10cSrcweir 		if (!pPrjInitialDepList)
903cdf0e10cSrcweir 			SetMode (NULL);
904cdf0e10cSrcweir 		return pPrjInitialDepList;
905cdf0e10cSrcweir 	}
906cdf0e10cSrcweir }
907cdf0e10cSrcweir 
908cdf0e10cSrcweir /*****************************************************************************/
SetMode(SByteStringList * pModList)909cdf0e10cSrcweir void Prj::SetMode(SByteStringList* pModList)
910cdf0e10cSrcweir /*****************************************************************************/
911cdf0e10cSrcweir {
912cdf0e10cSrcweir 	pPrjDepList = RemoveStringList (pPrjDepList);
913cdf0e10cSrcweir 	pPrjInitialDepList = RemoveStringList (pPrjInitialDepList);
914cdf0e10cSrcweir 
915cdf0e10cSrcweir 	if (!pPrjDepInfoList)
916cdf0e10cSrcweir 		return;
917cdf0e10cSrcweir 
918cdf0e10cSrcweir 	pPrjDepList = new SByteStringList;
919cdf0e10cSrcweir 	pPrjInitialDepList = new SByteStringList;
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 	DepInfo *pInfo = pPrjDepInfoList->First();
922cdf0e10cSrcweir 	while ( pInfo )
923cdf0e10cSrcweir 	{
924cdf0e10cSrcweir 		if (pInfo->IsAllModes() || !pInfo->GetModeList() || !pModList)
925cdf0e10cSrcweir 		{
926cdf0e10cSrcweir 			pPrjDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
927cdf0e10cSrcweir 			pPrjInitialDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
928cdf0e10cSrcweir 			//pPrjDepList->PutString( pInfo->GetProject());
929cdf0e10cSrcweir 			//pPrjInitialDepList->PutString( pInfo->GetProject());
930cdf0e10cSrcweir 		}
931cdf0e10cSrcweir 		else
932cdf0e10cSrcweir 		{
933cdf0e10cSrcweir 			sal_Bool bStringFound = sal_False;
934cdf0e10cSrcweir 			SByteStringList * pDepList = pInfo->GetModeList();
935cdf0e10cSrcweir 			ByteString *pModString = pDepList->First();
936cdf0e10cSrcweir 			while ( pModString )
937cdf0e10cSrcweir 			{
938cdf0e10cSrcweir 				ByteString *pDefModString = pModList->First();
939cdf0e10cSrcweir 				while ( pDefModString )
940cdf0e10cSrcweir 				{
941cdf0e10cSrcweir 					if (*pDefModString == *pModString)
942cdf0e10cSrcweir 					{
943cdf0e10cSrcweir 						pPrjDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
944cdf0e10cSrcweir 						pPrjInitialDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
945cdf0e10cSrcweir 						//pPrjDepList->PutString( pInfo->GetProject());
946cdf0e10cSrcweir 						//pPrjInitialDepList->PutString( pInfo->GetProject());
947cdf0e10cSrcweir 						bStringFound = sal_True;
948cdf0e10cSrcweir 						break;
949cdf0e10cSrcweir 					}
950cdf0e10cSrcweir 					pDefModString = pModList->Next();
951cdf0e10cSrcweir 				}
952cdf0e10cSrcweir 				if (bStringFound)
953cdf0e10cSrcweir 					break;
954cdf0e10cSrcweir 				pModString = pDepList->Next();
955cdf0e10cSrcweir 			}
956cdf0e10cSrcweir 
957cdf0e10cSrcweir 		}
958cdf0e10cSrcweir 
959cdf0e10cSrcweir 		pInfo = pPrjDepInfoList->Next();
960cdf0e10cSrcweir 	}
961cdf0e10cSrcweir }
962cdf0e10cSrcweir 
963cdf0e10cSrcweir /*****************************************************************************/
InsertDirectory(ByteString aDirName,sal_uInt16 aWhat,sal_uInt16 aWhatOS,ByteString aLogFileName,const ByteString & rClientRestriction)964cdf0e10cSrcweir sal_Bool Prj::InsertDirectory ( ByteString aDirName, sal_uInt16 aWhat,
965cdf0e10cSrcweir 								sal_uInt16 aWhatOS, ByteString aLogFileName,
966cdf0e10cSrcweir 								const ByteString &rClientRestriction )
967cdf0e10cSrcweir /*****************************************************************************/
968cdf0e10cSrcweir {
969cdf0e10cSrcweir 	CommandData* pData = new CommandData();
970cdf0e10cSrcweir 
971cdf0e10cSrcweir 	pData->SetPath( aDirName );
972cdf0e10cSrcweir 	pData->SetCommandType( aWhat );
973cdf0e10cSrcweir 	pData->SetOSType( aWhatOS );
974cdf0e10cSrcweir 	pData->SetLogFile( aLogFileName );
975cdf0e10cSrcweir 	pData->SetClientRestriction( rClientRestriction );
976cdf0e10cSrcweir 
977cdf0e10cSrcweir 	PrjList* pPrjList = GetCommandDataList ();
978cdf0e10cSrcweir 	pPrjList->Insert( pData );
979cdf0e10cSrcweir 
980cdf0e10cSrcweir 	return sal_False;
981cdf0e10cSrcweir }
982cdf0e10cSrcweir 
983cdf0e10cSrcweir /*****************************************************************************/
984cdf0e10cSrcweir //
985cdf0e10cSrcweir // removes directory and existing dependencies on it
986cdf0e10cSrcweir //
RemoveDirectory(ByteString aLogFileName)987cdf0e10cSrcweir CommandData* Prj::RemoveDirectory ( ByteString aLogFileName )
988cdf0e10cSrcweir /*****************************************************************************/
989cdf0e10cSrcweir {
990cdf0e10cSrcweir 	PrjList* pPrjList = GetCommandDataList ();
991cdf0e10cSrcweir 	sal_uIntPtr nCount_l = pPrjList->Count();
992cdf0e10cSrcweir 	CommandData* pData;
993cdf0e10cSrcweir 	CommandData* pDataFound = NULL;
994cdf0e10cSrcweir 	SByteStringList* pDataDeps;
995cdf0e10cSrcweir 
996cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount_l; i++ )
997cdf0e10cSrcweir 	{
998cdf0e10cSrcweir 		pData = pPrjList->GetObject( i );
999cdf0e10cSrcweir 		if ( pData->GetLogFile() == aLogFileName )
1000cdf0e10cSrcweir 			pDataFound = pData;
1001cdf0e10cSrcweir 		else
1002cdf0e10cSrcweir 		{
1003cdf0e10cSrcweir 			pDataDeps = pData->GetDependencies();
1004cdf0e10cSrcweir 			if ( pDataDeps )
1005cdf0e10cSrcweir 			{
1006cdf0e10cSrcweir 				ByteString* pString;
1007cdf0e10cSrcweir 				sal_uIntPtr nDataDepsCount = pDataDeps->Count();
1008cdf0e10cSrcweir 				for ( sal_uIntPtr j = nDataDepsCount; j > 0; j-- )
1009cdf0e10cSrcweir 				{
1010cdf0e10cSrcweir 					pString = pDataDeps->GetObject( j - 1 );
1011cdf0e10cSrcweir 					if ( pString->GetToken( 0, '.') == aLogFileName )
1012cdf0e10cSrcweir 						pDataDeps->Remove( pString );
1013cdf0e10cSrcweir 				}
1014cdf0e10cSrcweir 			}
1015cdf0e10cSrcweir 		}
1016cdf0e10cSrcweir 	}
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir 	Remove( pDataFound );
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 	return pDataFound;
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir /*****************************************************************************/
ExtractDependencies()1024cdf0e10cSrcweir void Prj::ExtractDependencies()
1025cdf0e10cSrcweir /*****************************************************************************/
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir 	sal_uIntPtr nPos = 0;
1028cdf0e10cSrcweir 	CommandData* pData = GetObject(nPos);
1029cdf0e10cSrcweir 	while (pData)
1030cdf0e10cSrcweir 	{
1031cdf0e10cSrcweir 		SByteStringList* pDepList = pData->GetDependencies();
1032cdf0e10cSrcweir 		if (pDepList)
1033cdf0e10cSrcweir 		{
1034cdf0e10cSrcweir 			ByteString * pDepStr = pDepList->First();
1035cdf0e10cSrcweir 			while (pDepStr)
1036cdf0e10cSrcweir 			{
1037cdf0e10cSrcweir 				CommandData* pSearchData = First();
1038cdf0e10cSrcweir 				while (pSearchData)
1039cdf0e10cSrcweir 				{
1040cdf0e10cSrcweir 					if ((*pDepStr == pSearchData->GetPath()) && (pData->GetOSType() & pSearchData->GetOSType()))
1041cdf0e10cSrcweir 					{
1042cdf0e10cSrcweir 						*pDepStr = pSearchData->GetLogFile();
1043cdf0e10cSrcweir 						break;
1044cdf0e10cSrcweir 					}
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir 					pSearchData = Next();
1047cdf0e10cSrcweir 				}
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir 				pDepStr = pDepList->Next();
1050cdf0e10cSrcweir 			}
1051cdf0e10cSrcweir 		}
1052cdf0e10cSrcweir 		nPos ++;
1053cdf0e10cSrcweir 		pData = GetObject(nPos);
1054cdf0e10cSrcweir 	}
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir /*****************************************************************************/
GetCommandDataList()1058cdf0e10cSrcweir PrjList* Prj::GetCommandDataList ()
1059cdf0e10cSrcweir /*****************************************************************************/
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir 	if (pTempCommandDataList)
1062cdf0e10cSrcweir 		return pTempCommandDataList;
1063cdf0e10cSrcweir 	else
1064cdf0e10cSrcweir 		return (PrjList*)this;
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir /*****************************************************************************/
RemoveTempCommandDataList()1068cdf0e10cSrcweir void Prj::RemoveTempCommandDataList()
1069cdf0e10cSrcweir /*****************************************************************************/
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir 	if (pTempCommandDataList)
1072cdf0e10cSrcweir 	{
1073cdf0e10cSrcweir 		delete pTempCommandDataList; // this list remove the elements by itself
1074cdf0e10cSrcweir 		pTempCommandDataList = NULL;
1075cdf0e10cSrcweir 	}
1076cdf0e10cSrcweir }
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir /*****************************************************************************/
GenerateTempCommandDataList()1079cdf0e10cSrcweir void Prj::GenerateTempCommandDataList()
1080cdf0e10cSrcweir /*****************************************************************************/
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir 	if (pTempCommandDataList)
1083cdf0e10cSrcweir 		RemoveTempCommandDataList();
1084cdf0e10cSrcweir 	pTempCommandDataList = new PrjList();
1085cdf0e10cSrcweir 	CommandData* pCommandData = First();
1086cdf0e10cSrcweir 	while (pCommandData) {
1087cdf0e10cSrcweir 		SvMemoryStream* pStream = new SvMemoryStream();
1088cdf0e10cSrcweir 		*pCommandData >> *pStream;
1089cdf0e10cSrcweir 		CommandData* pNewCommandData = new CommandData();
1090cdf0e10cSrcweir 		pStream->Seek( STREAM_SEEK_TO_BEGIN );
1091cdf0e10cSrcweir 		*pNewCommandData << *pStream;
1092cdf0e10cSrcweir 		pTempCommandDataList->Insert(pNewCommandData, LIST_APPEND);
1093cdf0e10cSrcweir 		delete pStream;
1094cdf0e10cSrcweir 		pCommandData = Next();
1095cdf0e10cSrcweir 	}
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir /*****************************************************************************/
GenerateEmptyTempCommandDataList()1099cdf0e10cSrcweir void Prj::GenerateEmptyTempCommandDataList()
1100cdf0e10cSrcweir /*****************************************************************************/
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir 	if (pTempCommandDataList)
1103cdf0e10cSrcweir 		RemoveTempCommandDataList();
1104cdf0e10cSrcweir 	pTempCommandDataList = new PrjList();
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir /*****************************************************************************/
operator >>(SvStream & rStream)1108cdf0e10cSrcweir Prj& Prj::operator>>  ( SvStream& rStream )
1109cdf0e10cSrcweir /*****************************************************************************/
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir 	rStream << bVisited;
1112cdf0e10cSrcweir     rStream << aProjectName;
1113cdf0e10cSrcweir     rStream << aProjectPrefix;
1114cdf0e10cSrcweir     rStream << bHardDependencies;
1115cdf0e10cSrcweir     rStream << bFixedDependencies;
1116cdf0e10cSrcweir     rStream << bSorted;
1117cdf0e10cSrcweir     rStream << bIsAvailable;
1118cdf0e10cSrcweir 	rStream << bError;
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir 	if (pPrjDepInfoList)
1121cdf0e10cSrcweir 	{
1122cdf0e10cSrcweir 		rStream << sal_True;
1123cdf0e10cSrcweir 		*pPrjDepInfoList >> rStream;
1124cdf0e10cSrcweir 	}
1125cdf0e10cSrcweir 	else
1126cdf0e10cSrcweir 		rStream << sal_False;
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir     sal_uIntPtr nCount_l = Count();
1129cdf0e10cSrcweir     rStream << nCount_l;
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir     CommandData* pData = First();
1132cdf0e10cSrcweir     while (pData) {
1133cdf0e10cSrcweir         *pData >> rStream;
1134cdf0e10cSrcweir         pData = Next();
1135cdf0e10cSrcweir     }
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir 	return *this;
1138cdf0e10cSrcweir }
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir /*****************************************************************************/
operator <<(SvStream & rStream)1141cdf0e10cSrcweir Prj& Prj::operator<<  ( SvStream& rStream )
1142cdf0e10cSrcweir /*****************************************************************************/
1143cdf0e10cSrcweir {
1144cdf0e10cSrcweir    	rStream >> bVisited;
1145cdf0e10cSrcweir     rStream >> aProjectName;
1146cdf0e10cSrcweir     rStream >> aProjectPrefix;
1147cdf0e10cSrcweir     rStream >> bHardDependencies;
1148cdf0e10cSrcweir     rStream >> bFixedDependencies;
1149cdf0e10cSrcweir     rStream >> bSorted;
1150cdf0e10cSrcweir     rStream >> bIsAvailable;
1151cdf0e10cSrcweir 	rStream >> bError;
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir 	sal_Bool bDepList;
1154cdf0e10cSrcweir 	rStream >> bDepList;
1155cdf0e10cSrcweir 	DELETEZ (pPrjDepInfoList);
1156cdf0e10cSrcweir 	if (bDepList)
1157cdf0e10cSrcweir 	{
1158cdf0e10cSrcweir 		pPrjDepInfoList = new SDepInfoList();
1159cdf0e10cSrcweir 		*pPrjDepInfoList << rStream;
1160cdf0e10cSrcweir 	}
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir     sal_uIntPtr nCount_l;
1163cdf0e10cSrcweir     rStream >> nCount_l;
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < nCount_l; i++ ) {
1166cdf0e10cSrcweir         CommandData* pData = new CommandData();
1167cdf0e10cSrcweir         *pData << rStream;
1168cdf0e10cSrcweir         Insert (pData, LIST_APPEND);
1169cdf0e10cSrcweir     }
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 	return *this;
1172cdf0e10cSrcweir }
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir //
1176cdf0e10cSrcweir //	class Star
1177cdf0e10cSrcweir //
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir /*****************************************************************************/
Star()1180cdf0e10cSrcweir Star::Star()
1181cdf0e10cSrcweir /*****************************************************************************/
1182cdf0e10cSrcweir 				: pDepMode (NULL),
1183cdf0e10cSrcweir 				pAllDepMode (NULL)
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir 	// this ctor is only used by StarWriter
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir /*****************************************************************************/
Star(String aFileName,sal_uInt16 nMode)1189cdf0e10cSrcweir Star::Star(String aFileName, sal_uInt16 nMode )
1190cdf0e10cSrcweir /*****************************************************************************/
1191cdf0e10cSrcweir 				: nStarMode( nMode ),
1192cdf0e10cSrcweir 				sFileName( aFileName ),
1193cdf0e10cSrcweir 				pDepMode (NULL),
1194cdf0e10cSrcweir 				pAllDepMode (NULL)
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir 	Read( aFileName );
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir /*****************************************************************************/
Star(SolarFileList * pSolarFiles)1200cdf0e10cSrcweir Star::Star(SolarFileList *pSolarFiles )
1201cdf0e10cSrcweir /*****************************************************************************/
1202cdf0e10cSrcweir 				: nStarMode( STAR_MODE_MULTIPLE_PARSE ),
1203cdf0e10cSrcweir 				pDepMode (NULL),
1204cdf0e10cSrcweir 				pAllDepMode (NULL)
1205cdf0e10cSrcweir {
1206cdf0e10cSrcweir 	// this ctor is used by StarBuilder to get the information for the whole workspace
1207cdf0e10cSrcweir 	Read( pSolarFiles );
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir /*****************************************************************************/
Star(GenericInformationList * pStandLst,ByteString & rVersion)1211cdf0e10cSrcweir Star::Star(GenericInformationList *pStandLst, ByteString &rVersion )
1212cdf0e10cSrcweir /*****************************************************************************/
1213cdf0e10cSrcweir 				: pDepMode (NULL),
1214cdf0e10cSrcweir 				pAllDepMode (NULL)
1215cdf0e10cSrcweir {
1216cdf0e10cSrcweir 	UpdateFileList (pStandLst, rVersion, sal_True );
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir /*****************************************************************************/
UpdateFileList(GenericInformationList * pStandLst,ByteString & rVersion,sal_Bool bRead)1220cdf0e10cSrcweir void Star::UpdateFileList( GenericInformationList *pStandLst, ByteString &rVersion,
1221cdf0e10cSrcweir 	sal_Bool bRead )
1222cdf0e10cSrcweir /*****************************************************************************/
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir 	sSourceRoot=String::CreateFromAscii(""); // clear old SourceRoot
1225cdf0e10cSrcweir 	ByteString sPath( rVersion );
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir #ifdef UNX
1228cdf0e10cSrcweir 	sPath += "/settings/UNXSOLARLIST";
1229cdf0e10cSrcweir #else
1230cdf0e10cSrcweir 	sPath += "/settings/SOLARLIST";
1231cdf0e10cSrcweir #endif
1232cdf0e10cSrcweir 	GenericInformation *pInfo = pStandLst->GetInfo( sPath, sal_True );
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir 	if( pInfo && pInfo->GetValue().Len()) {
1235cdf0e10cSrcweir 		ByteString sFile( pInfo->GetValue());
1236cdf0e10cSrcweir 		String sFileName_l( sFile, RTL_TEXTENCODING_ASCII_US );
1237cdf0e10cSrcweir 		nStarMode = STAR_MODE_SINGLE_PARSE;
1238cdf0e10cSrcweir 		if (bRead)
1239cdf0e10cSrcweir 			Read( sFileName_l );
1240cdf0e10cSrcweir 	}
1241cdf0e10cSrcweir 	else {
1242cdf0e10cSrcweir 		SolarFileList *pFileList = new SolarFileList();
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir 		sPath = rVersion;
1245cdf0e10cSrcweir 		sPath += "/drives";
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir 		GenericInformation *pInfo_l = pStandLst->GetInfo( sPath, sal_True );
1248cdf0e10cSrcweir 		if ( pInfo_l && pInfo_l->GetSubList())  {
1249cdf0e10cSrcweir 			GenericInformationList *pDrives = pInfo_l->GetSubList();
1250cdf0e10cSrcweir 			for ( sal_uIntPtr i = 0; i < pDrives->Count(); i++ ) {
1251cdf0e10cSrcweir 				GenericInformation *pDrive = pDrives->GetObject( i );
1252cdf0e10cSrcweir 				if ( pDrive ) {
1253cdf0e10cSrcweir 					DirEntry aEntry;
1254cdf0e10cSrcweir 					sal_Bool bOk = sal_False;
1255cdf0e10cSrcweir 					if ( sSourceRoot.Len()) {
1256cdf0e10cSrcweir 						aEntry = DirEntry( sSourceRoot );
1257cdf0e10cSrcweir 						bOk = sal_True;
1258cdf0e10cSrcweir 					}
1259cdf0e10cSrcweir 					else {
1260cdf0e10cSrcweir #ifdef UNX
1261cdf0e10cSrcweir 						sPath = "UnixVolume";
1262cdf0e10cSrcweir 						GenericInformation *pUnixVolume = pDrive->GetSubInfo( sPath );
1263cdf0e10cSrcweir 						if ( pUnixVolume ) {
1264cdf0e10cSrcweir 							String sRoot( pUnixVolume->GetValue(), RTL_TEXTENCODING_ASCII_US );
1265cdf0e10cSrcweir 							aEntry = DirEntry( sRoot );
1266cdf0e10cSrcweir 							bOk = sal_True;
1267cdf0e10cSrcweir 				 		}
1268cdf0e10cSrcweir #else
1269cdf0e10cSrcweir 						bOk = sal_True;
1270cdf0e10cSrcweir 						String sRoot( *pDrive, RTL_TEXTENCODING_ASCII_US );
1271cdf0e10cSrcweir 						sRoot += String::CreateFromAscii( "\\" );
1272cdf0e10cSrcweir 						aEntry = DirEntry( sRoot );
1273cdf0e10cSrcweir #endif
1274cdf0e10cSrcweir 					}
1275cdf0e10cSrcweir 					if ( bOk ) {
1276cdf0e10cSrcweir 						sPath = "projects";
1277cdf0e10cSrcweir 						GenericInformation *pProjectsKey = pDrive->GetSubInfo( sPath, sal_True );
1278cdf0e10cSrcweir 						if ( pProjectsKey ) {
1279cdf0e10cSrcweir 							if ( !sSourceRoot.Len()) {
1280cdf0e10cSrcweir 								sPath = rVersion;
1281cdf0e10cSrcweir 								sPath += "/settings/PATH";
1282cdf0e10cSrcweir 								GenericInformation *pPath = pStandLst->GetInfo( sPath, sal_True );
1283cdf0e10cSrcweir 								if( pPath ) {
1284cdf0e10cSrcweir 									ByteString sAddPath( pPath->GetValue());
1285cdf0e10cSrcweir #ifdef UNX
1286cdf0e10cSrcweir 									sAddPath.SearchAndReplaceAll( "\\", "/" );
1287cdf0e10cSrcweir #else
1288cdf0e10cSrcweir 									sAddPath.SearchAndReplaceAll( "/", "\\" );
1289cdf0e10cSrcweir #endif
1290cdf0e10cSrcweir 									String ssAddPath( sAddPath, RTL_TEXTENCODING_ASCII_US );
1291cdf0e10cSrcweir 									aEntry += DirEntry( ssAddPath );
1292cdf0e10cSrcweir 								}
1293cdf0e10cSrcweir 							}
1294cdf0e10cSrcweir 							sPath = rVersion;
1295cdf0e10cSrcweir 							sPath += "/settings/SHORTPATH";
1296cdf0e10cSrcweir 							GenericInformation *pShortPath = pStandLst->GetInfo( sPath, sal_True );
1297cdf0e10cSrcweir 							sal_Bool bShortPath = sal_False;
1298cdf0e10cSrcweir 							if (pShortPath && (pShortPath->GetValue() == "_TRUE"))
1299cdf0e10cSrcweir 								bShortPath = sal_True;
1300cdf0e10cSrcweir 							sSourceRoot = aEntry.GetFull();
1301cdf0e10cSrcweir 							GenericInformationList *pProjects = pProjectsKey->GetSubList();
1302cdf0e10cSrcweir 							if ( pProjects ) {
1303cdf0e10cSrcweir 								GenericInformation * pProject = pProjects->First();
1304cdf0e10cSrcweir 								while (pProject) {
1305cdf0e10cSrcweir 									String sLocalSourceRoot = sSourceRoot;
1306cdf0e10cSrcweir 									ByteString sProject( *pProject );
1307cdf0e10cSrcweir 									String ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir 									ByteString aDirStr ("Directory");
1310cdf0e10cSrcweir 									GenericInformation * pDir = pProject->GetSubInfo (aDirStr);
1311cdf0e10cSrcweir 									if (pDir) {
1312cdf0e10cSrcweir 										ByteString aDir = pDir->GetValue();
1313cdf0e10cSrcweir 										DirEntry aRootEntry;
1314cdf0e10cSrcweir 										if (bShortPath)
1315cdf0e10cSrcweir 											aRootEntry = aEntry + DirEntry(aDir);
1316cdf0e10cSrcweir 										else
1317cdf0e10cSrcweir 											aRootEntry = aEntry.GetPath() + DirEntry(aDir);
1318cdf0e10cSrcweir 										sLocalSourceRoot = aRootEntry.GetFull();
1319cdf0e10cSrcweir 									}
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir 									String aBuildListPath = CreateFileName(ssProject, sLocalSourceRoot);
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir 									pFileList->Insert( new String( aBuildListPath ), LIST_APPEND );
1324cdf0e10cSrcweir 									ByteString sFile( aBuildListPath, RTL_TEXTENCODING_ASCII_US );
1325cdf0e10cSrcweir 									pProject = pProjects->Next();
1326cdf0e10cSrcweir 								}
1327cdf0e10cSrcweir 							}
1328cdf0e10cSrcweir 						}
1329cdf0e10cSrcweir 					}
1330cdf0e10cSrcweir 				}
1331cdf0e10cSrcweir 			}
1332cdf0e10cSrcweir 		}
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir 		if (!CheckFileLoadList(pFileList))
1335cdf0e10cSrcweir 		{
1336cdf0e10cSrcweir 			ClearAvailableDeps();
1337cdf0e10cSrcweir 			ClearCurrentDeps();
1338cdf0e10cSrcweir 			ClearLoadedFilesList();
1339cdf0e10cSrcweir 			RemoveAllPrj();
1340cdf0e10cSrcweir 			bRead = sal_True; // read new list because old list is deleted
1341cdf0e10cSrcweir 		}
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir 		if (bRead)
1344cdf0e10cSrcweir 			Read( pFileList );
1345cdf0e10cSrcweir 		else
1346cdf0e10cSrcweir 			GenerateFileLoadList( pFileList );
1347cdf0e10cSrcweir 	}
1348cdf0e10cSrcweir }
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir /*****************************************************************************/
FullReload(GenericInformationList * pStandLst,ByteString & rVersion,sal_Bool bRead)1351cdf0e10cSrcweir void Star::FullReload( GenericInformationList *pStandLst, ByteString &rVersion,
1352cdf0e10cSrcweir 	sal_Bool bRead )
1353cdf0e10cSrcweir /*****************************************************************************/
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir 	ClearAvailableDeps();
1356cdf0e10cSrcweir 	ClearCurrentDeps();
1357cdf0e10cSrcweir 	ClearLoadedFilesList();
1358cdf0e10cSrcweir 	RemoveAllPrj();
1359cdf0e10cSrcweir 	UpdateFileList( pStandLst, rVersion, bRead );
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir /*****************************************************************************/
CheckFileLoadList(SolarFileList * pSolarFiles)1363cdf0e10cSrcweir sal_Bool Star::CheckFileLoadList(SolarFileList *pSolarFiles)
1364cdf0e10cSrcweir /*****************************************************************************/
1365cdf0e10cSrcweir {
1366cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
1367cdf0e10cSrcweir 	if (aLoadedFilesList.Count() == 0)
1368cdf0e10cSrcweir 		return bRet;
1369cdf0e10cSrcweir 	StarFile * pLoadFile = aLoadedFilesList.First();
1370cdf0e10cSrcweir 	while (pLoadFile)
1371cdf0e10cSrcweir 	{
1372cdf0e10cSrcweir 		sal_Bool bIsAvailable = sal_False;
1373cdf0e10cSrcweir 		String * pFile = pSolarFiles->First();
1374cdf0e10cSrcweir 		while (pFile)
1375cdf0e10cSrcweir 		{
1376cdf0e10cSrcweir 			if (*pFile == pLoadFile->GetName())
1377cdf0e10cSrcweir 			{
1378cdf0e10cSrcweir 				bIsAvailable = sal_True;
1379cdf0e10cSrcweir 				break;
1380cdf0e10cSrcweir 			}
1381cdf0e10cSrcweir 			pFile = pSolarFiles->Next();
1382cdf0e10cSrcweir 		}
1383cdf0e10cSrcweir 		if (!bIsAvailable)
1384cdf0e10cSrcweir 		{
1385cdf0e10cSrcweir 			bRet = sal_False;
1386cdf0e10cSrcweir 			break;
1387cdf0e10cSrcweir 		}
1388cdf0e10cSrcweir 		pLoadFile = aLoadedFilesList.Next();
1389cdf0e10cSrcweir 	}
1390cdf0e10cSrcweir    	return bRet;
1391cdf0e10cSrcweir }
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir /*****************************************************************************/
~Star()1394cdf0e10cSrcweir Star::~Star()
1395cdf0e10cSrcweir /*****************************************************************************/
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir 	ClearAvailableDeps();
1398cdf0e10cSrcweir 	ClearCurrentDeps();
1399cdf0e10cSrcweir 	ClearLoadedFilesList();
1400cdf0e10cSrcweir 	RemoveAllPrj();
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir /*****************************************************************************/
GenerateFileLoadList(SolarFileList * pSolarFiles)1404cdf0e10cSrcweir void Star::GenerateFileLoadList( SolarFileList *pSolarFiles )
1405cdf0e10cSrcweir /*****************************************************************************/
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir 	SolarFileList* pNewSolarFiles = NULL;
1408cdf0e10cSrcweir 	while(  pSolarFiles->Count()) {
1409cdf0e10cSrcweir 		StarFile *pFile = new StarFile( *pSolarFiles->GetObject(( sal_uIntPtr ) 0 ));
1410cdf0e10cSrcweir 		aMutex.acquire();
1411cdf0e10cSrcweir 		sal_uIntPtr nPos = SearchFileEntry(&aLoadedFilesList, pFile);
1412cdf0e10cSrcweir 		if ( nPos == LIST_ENTRY_NOTFOUND )
1413cdf0e10cSrcweir 		{
1414cdf0e10cSrcweir 			if (!pNewSolarFiles)
1415cdf0e10cSrcweir 				pNewSolarFiles = new SolarFileList();
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir 			pNewSolarFiles->Insert(new String(pFile->GetName()), LIST_APPEND );
1418cdf0e10cSrcweir 		}
1419cdf0e10cSrcweir 		aMutex.release();
1420cdf0e10cSrcweir 		delete pSolarFiles->Remove(( sal_uIntPtr ) 0 );
1421cdf0e10cSrcweir 		delete pFile;
1422cdf0e10cSrcweir 	}
1423cdf0e10cSrcweir 	delete pSolarFiles;
1424cdf0e10cSrcweir 	if (pNewSolarFiles)
1425cdf0e10cSrcweir 		Read (pNewSolarFiles);
1426cdf0e10cSrcweir }
1427cdf0e10cSrcweir 
1428cdf0e10cSrcweir /*****************************************************************************/
NeedsFilesForUpdate()1429cdf0e10cSrcweir SolarFileList* Star::NeedsFilesForUpdate()
1430cdf0e10cSrcweir /*****************************************************************************/
1431cdf0e10cSrcweir {
1432cdf0e10cSrcweir 	aMutex.acquire();
1433cdf0e10cSrcweir 	SolarFileList* pPrjList = NULL;
1434cdf0e10cSrcweir 	for ( sal_uIntPtr i = 0; i < aLoadedFilesList.Count(); i++ )
1435cdf0e10cSrcweir 		if ( aLoadedFilesList.GetObject( i )->NeedsUpdate()) {
1436cdf0e10cSrcweir 			if (!pPrjList)
1437cdf0e10cSrcweir 				pPrjList = new SolarFileList();
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir 			pPrjList->Insert(new String (aLoadedFilesList.GetObject( i )->GetName()), LIST_APPEND);
1440cdf0e10cSrcweir 		}
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir 	aMutex.release();
1443cdf0e10cSrcweir 	return pPrjList;
1444cdf0e10cSrcweir }
1445cdf0e10cSrcweir 
1446cdf0e10cSrcweir /*****************************************************************************/
NeedsUpdate()1447cdf0e10cSrcweir sal_Bool Star::NeedsUpdate()
1448cdf0e10cSrcweir /*****************************************************************************/
1449cdf0e10cSrcweir {
1450cdf0e10cSrcweir 	aMutex.acquire();
1451cdf0e10cSrcweir 	for ( sal_uIntPtr i = 0; i < aLoadedFilesList.Count(); i++ )
1452cdf0e10cSrcweir 		if ( aLoadedFilesList.GetObject( i )->NeedsUpdate()) {
1453cdf0e10cSrcweir 			aMutex.release();
1454cdf0e10cSrcweir 			return sal_True;
1455cdf0e10cSrcweir 		}
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir 	aMutex.release();
1458cdf0e10cSrcweir 	return sal_False;
1459cdf0e10cSrcweir }
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir /*****************************************************************************/
Read(String & rFileName)1462cdf0e10cSrcweir void Star::Read( String &rFileName )
1463cdf0e10cSrcweir /*****************************************************************************/
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir 	ClearAvailableDeps ();
1466cdf0e10cSrcweir 	ByteString aString;
1467cdf0e10cSrcweir 	aFileList.Insert( new String( rFileName ));
1468cdf0e10cSrcweir 
1469cdf0e10cSrcweir 	DirEntry aEntry( rFileName );
1470cdf0e10cSrcweir 	aEntry.ToAbs();
1471cdf0e10cSrcweir 	aEntry = aEntry.GetPath().GetPath().GetPath();
1472cdf0e10cSrcweir 	sSourceRoot = aEntry.GetFull();
1473cdf0e10cSrcweir 
1474cdf0e10cSrcweir 	while( aFileList.Count()) {
1475cdf0e10cSrcweir 		String ssFileName = *aFileList.GetObject(( sal_uIntPtr ) 0 );
1476cdf0e10cSrcweir 		StarFile* pFile = ReadBuildlist (ssFileName);
1477cdf0e10cSrcweir 		aMutex.acquire();
1478cdf0e10cSrcweir 		ReplaceFileEntry (&aLoadedFilesList, pFile);
1479cdf0e10cSrcweir 		//aLoadedFilesList.Insert( pFile, LIST_APPEND );
1480cdf0e10cSrcweir 		aMutex.release();
1481cdf0e10cSrcweir 		aFileList.Remove(( sal_uIntPtr ) 0 );
1482cdf0e10cSrcweir 	}
1483cdf0e10cSrcweir 	// resolve all dependencies recursive
1484cdf0e10cSrcweir 	Expand_Impl();
1485cdf0e10cSrcweir }
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir /*****************************************************************************/
SearchFileEntry(StarFileList * pStarFiles,StarFile * pFile)1488cdf0e10cSrcweir sal_uIntPtr Star::SearchFileEntry( StarFileList *pStarFiles, StarFile* pFile )
1489cdf0e10cSrcweir /*****************************************************************************/
1490cdf0e10cSrcweir {
1491cdf0e10cSrcweir 	StarFile *pSearchFile;
1492cdf0e10cSrcweir 	sal_uIntPtr nCount_l;
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir 	nCount_l = pStarFiles->Count();
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir 	for ( sal_uIntPtr i=0; i<nCount_l; i++)
1497cdf0e10cSrcweir 	{
1498cdf0e10cSrcweir 		pSearchFile = pStarFiles->GetObject(i);
1499cdf0e10cSrcweir 		if ( pSearchFile->GetName() == pFile->GetName() )
1500cdf0e10cSrcweir 		{
1501cdf0e10cSrcweir 			return i;
1502cdf0e10cSrcweir 		}
1503cdf0e10cSrcweir 	}
1504cdf0e10cSrcweir 	return LIST_ENTRY_NOTFOUND;
1505cdf0e10cSrcweir }
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir /*****************************************************************************/
ReplaceFileEntry(StarFileList * pStarFiles,StarFile * pFile)1508cdf0e10cSrcweir void Star::ReplaceFileEntry( StarFileList *pStarFiles, StarFile* pFile )
1509cdf0e10cSrcweir /*****************************************************************************/
1510cdf0e10cSrcweir {
1511cdf0e10cSrcweir 	sal_uIntPtr nPos = SearchFileEntry(pStarFiles, pFile);
1512cdf0e10cSrcweir 	if ( nPos != LIST_ENTRY_NOTFOUND )
1513cdf0e10cSrcweir 	{
1514cdf0e10cSrcweir 		StarFile* pTmpStarFile = pStarFiles->GetObject(nPos);
1515cdf0e10cSrcweir 		delete pTmpStarFile;
1516cdf0e10cSrcweir 		pStarFiles->Replace(pFile, nPos);
1517cdf0e10cSrcweir 		return;
1518cdf0e10cSrcweir 	}
1519cdf0e10cSrcweir 	pStarFiles->Insert( pFile,	LIST_APPEND );
1520cdf0e10cSrcweir }
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir /*****************************************************************************/
Read(SolarFileList * pSolarFiles)1523cdf0e10cSrcweir void Star::Read( SolarFileList *pSolarFiles )
1524cdf0e10cSrcweir /*****************************************************************************/
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir 	ClearAvailableDeps ();
1527cdf0e10cSrcweir 	while(  pSolarFiles->Count()) {
1528cdf0e10cSrcweir 		ByteString aString;
1529cdf0e10cSrcweir 
1530cdf0e10cSrcweir 		String ssFileName = *pSolarFiles->GetObject(( sal_uIntPtr ) 0 );
1531cdf0e10cSrcweir 		StarFile *pFile = ReadBuildlist ( ssFileName);
1532cdf0e10cSrcweir 
1533cdf0e10cSrcweir 		if ( pFile->Exists()) {
1534cdf0e10cSrcweir 			DirEntry aEntry( pFile->GetName() );
1535cdf0e10cSrcweir 			DirEntry aEntryPrj = aEntry.GetPath().GetPath();
1536cdf0e10cSrcweir 			if (aEntryPrj.GetExtension() != String::CreateFromAscii( "" ))
1537cdf0e10cSrcweir 			{
1538cdf0e10cSrcweir 				aEntryPrj.CutExtension();
1539cdf0e10cSrcweir 				ByteString aPrjName = ByteString( aEntryPrj.GetName(), gsl_getSystemTextEncoding());
1540cdf0e10cSrcweir 				Prj* pPrj = GetPrj(aPrjName);
1541cdf0e10cSrcweir 				if (pPrj)
1542cdf0e10cSrcweir 					pPrj->IsAvailable (sal_False);
1543cdf0e10cSrcweir 			}
1544cdf0e10cSrcweir 
1545cdf0e10cSrcweir 		}
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir 		aMutex.acquire();
1548cdf0e10cSrcweir 		ReplaceFileEntry (&aLoadedFilesList, pFile);
1549cdf0e10cSrcweir 		//aLoadedFilesList.Insert( pFile,	LIST_APPEND );
1550cdf0e10cSrcweir 		aMutex.release();
1551cdf0e10cSrcweir 		delete pSolarFiles->Remove(( sal_uIntPtr ) 0 );
1552cdf0e10cSrcweir 	}
1553cdf0e10cSrcweir 	delete pSolarFiles;
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir 	Expand_Impl();
1556cdf0e10cSrcweir }
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir /*****************************************************************************/
CreateFileName(String & rProject,String & rSourceRoot)1559cdf0e10cSrcweir String Star::CreateFileName( String& rProject, String& rSourceRoot )
1560cdf0e10cSrcweir /*****************************************************************************/
1561cdf0e10cSrcweir {
1562cdf0e10cSrcweir 	// this method is used to find solarlist parts of nabours (other projects)
1563cdf0e10cSrcweir 	String sPrjDir( String::CreateFromAscii( "prj" ));
1564cdf0e10cSrcweir 	String sBuildList( String::CreateFromAscii( "build.lst" ));
1565cdf0e10cSrcweir //	String sXmlBuildList( String::CreateFromAscii( "build.xlist" ));
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir 	DirEntry aEntry( rSourceRoot );
1568cdf0e10cSrcweir 	aEntry += DirEntry( rProject );
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir 	// if this project not exists, maybe it's a not added project of a CWS
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir 	if ( !aEntry.Exists() ) {
1573cdf0e10cSrcweir 		aEntry.SetExtension(String::CreateFromAscii( "lnk" ));
1574cdf0e10cSrcweir 		if ( !aEntry.Exists() )
1575cdf0e10cSrcweir 			aEntry.CutExtension();
1576cdf0e10cSrcweir 
1577cdf0e10cSrcweir 		aEntry.SetExtension(String::CreateFromAscii( "link" ));
1578cdf0e10cSrcweir 		if ( !aEntry.Exists() )
1579cdf0e10cSrcweir 			aEntry.CutExtension();
1580cdf0e10cSrcweir 	}
1581cdf0e10cSrcweir 
1582cdf0e10cSrcweir 	aEntry += DirEntry( sPrjDir );
1583cdf0e10cSrcweir 
1584cdf0e10cSrcweir //	DirEntry aPossibleEntry(aEntry);
1585cdf0e10cSrcweir //  aPossibleEntry += DirEntry( sXmlBuildList );
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir 	aEntry += DirEntry( sBuildList );
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir     DirEntry& aActualEntry = aEntry;
1590cdf0e10cSrcweir /*
1591cdf0e10cSrcweir     if (aPossibleEntry.Exists()) {
1592cdf0e10cSrcweir         aActualEntry = aPossibleEntry;
1593cdf0e10cSrcweir     } else */
1594cdf0e10cSrcweir 	if ( !aActualEntry.Exists() && aDBNotFoundHdl.IsSet())
1595cdf0e10cSrcweir 		aDBNotFoundHdl.Call( &rProject );
1596cdf0e10cSrcweir 	return aActualEntry.GetFull();
1597cdf0e10cSrcweir }
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir /*****************************************************************************/
InsertSolarList(String sProject)1600cdf0e10cSrcweir void Star::InsertSolarList( String sProject )
1601cdf0e10cSrcweir /*****************************************************************************/
1602cdf0e10cSrcweir {
1603cdf0e10cSrcweir 	// inserts a new solarlist part of another project
1604cdf0e10cSrcweir 	String sFileName_l( CreateFileName( sProject, sSourceRoot ));
1605cdf0e10cSrcweir 
1606cdf0e10cSrcweir 	for ( sal_uIntPtr i = 0; i < aFileList.Count(); i++ ) {
1607cdf0e10cSrcweir 		if (( *aFileList.GetObject( i )) == sFileName_l )
1608cdf0e10cSrcweir 			return;
1609cdf0e10cSrcweir 	}
1610cdf0e10cSrcweir 
1611cdf0e10cSrcweir 	ByteString ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
1612cdf0e10cSrcweir 	if ( HasProject( ssProject ))
1613cdf0e10cSrcweir 		return;
1614cdf0e10cSrcweir 
1615cdf0e10cSrcweir 	aFileList.Insert( new String( sFileName_l ), LIST_APPEND );
1616cdf0e10cSrcweir }
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir /*****************************************************************************/
ExpandPrj_Impl(Prj * pPrj,Prj * pDepPrj)1619cdf0e10cSrcweir void Star::ExpandPrj_Impl( Prj *pPrj, Prj *pDepPrj )
1620cdf0e10cSrcweir /*****************************************************************************/
1621cdf0e10cSrcweir {
1622cdf0e10cSrcweir 	if ( pDepPrj->bVisited )
1623cdf0e10cSrcweir 		return;
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir 	pDepPrj->bVisited = sal_True;
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir 	SByteStringList* pPrjLst = pPrj->GetDependencies();
1628cdf0e10cSrcweir 	SByteStringList* pDepLst = NULL;
1629cdf0e10cSrcweir 	ByteString* pDepend;
1630cdf0e10cSrcweir 	ByteString* pPutStr;
1631cdf0e10cSrcweir 	Prj *pNextPrj = NULL;
1632cdf0e10cSrcweir 	sal_uIntPtr i, nRetPos;
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir 	if ( pPrjLst ) {
1635cdf0e10cSrcweir 		pDepLst = pDepPrj->GetDependencies();
1636cdf0e10cSrcweir 		if ( pDepLst ) {
1637cdf0e10cSrcweir 			for ( i = 0; i < pDepLst->Count(); i++ ) {
1638cdf0e10cSrcweir 				pDepend = pDepLst->GetObject( i );
1639cdf0e10cSrcweir 				pPutStr = new ByteString( *pDepend );
1640cdf0e10cSrcweir 				nRetPos = pPrjLst->PutString( pPutStr );
1641cdf0e10cSrcweir 				if( nRetPos == NOT_THERE )
1642cdf0e10cSrcweir 					delete pPutStr;
1643cdf0e10cSrcweir 				pNextPrj = GetPrj( *pDepend );
1644cdf0e10cSrcweir 				if ( pNextPrj ) {
1645cdf0e10cSrcweir 					ExpandPrj_Impl( pPrj, pNextPrj );
1646cdf0e10cSrcweir 				}
1647cdf0e10cSrcweir 			}
1648cdf0e10cSrcweir 		}
1649cdf0e10cSrcweir 	}
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir /*****************************************************************************/
Expand_Impl()1653cdf0e10cSrcweir void Star::Expand_Impl()
1654cdf0e10cSrcweir /*****************************************************************************/
1655cdf0e10cSrcweir {
1656cdf0e10cSrcweir 	for ( sal_uIntPtr i = 0; i < Count(); i++ ) {
1657cdf0e10cSrcweir 		for ( sal_uIntPtr j = 0; j < Count(); j++ )
1658cdf0e10cSrcweir 			GetObject( j )->bVisited = sal_False;
1659cdf0e10cSrcweir 
1660cdf0e10cSrcweir 		Prj* pPrj = GetObject( i );
1661cdf0e10cSrcweir 		pPrj->SetMode(pDepMode); // DepList f�r Mode initialisieren
1662cdf0e10cSrcweir 		ExpandPrj_Impl( pPrj, pPrj );
1663cdf0e10cSrcweir 	}
1664cdf0e10cSrcweir }
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir /*****************************************************************************/
ReadBuildlist(const String & rFilename,sal_Bool bReadComments,sal_Bool bExtendAlias)1667cdf0e10cSrcweir StarFile* Star::ReadBuildlist (const String& rFilename, sal_Bool bReadComments, sal_Bool bExtendAlias)
1668cdf0e10cSrcweir /*****************************************************************************/
1669cdf0e10cSrcweir {
1670cdf0e10cSrcweir 	ByteString sFileName_l(rFilename, RTL_TEXTENCODING_ASCII_US);
1671cdf0e10cSrcweir 	StarFile *pFile = new StarFile( rFilename );
1672cdf0e10cSrcweir 	if ( pFile->Exists()) {
1673cdf0e10cSrcweir 		SimpleConfig aSolarConfig( rFilename );
1674cdf0e10cSrcweir 		DirEntry aEntry(rFilename);
1675cdf0e10cSrcweir 		ByteString sProjectName (aEntry.GetPath().GetPath().GetName(), RTL_TEXTENCODING_ASCII_US);
1676cdf0e10cSrcweir 		Prj* pPrj = GetPrj (sProjectName); // 0, if Prj not found
1677cdf0e10cSrcweir 		if (pPrj)
1678cdf0e10cSrcweir 		{
1679cdf0e10cSrcweir 			Remove(pPrj); // Project exist, remove old Project and read again
1680cdf0e10cSrcweir 			DELETEZ (pPrj); // delete and set pPrj to 0
1681cdf0e10cSrcweir 		}
1682cdf0e10cSrcweir 		ByteString aString;
1683cdf0e10cSrcweir 		while (( aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != ByteString::EmptyString() )
1684cdf0e10cSrcweir     		InsertTokenLine ( aString, &pPrj, sProjectName, bExtendAlias );
1685cdf0e10cSrcweir 	}
1686cdf0e10cSrcweir 	return pFile;
1687cdf0e10cSrcweir }
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir /*****************************************************************************/
InsertTokenLine(const ByteString & rTokenLine,Prj ** ppPrj,const ByteString & rProjectName,const sal_Bool bExtendAlias)1690cdf0e10cSrcweir void Star::InsertTokenLine ( const ByteString& rTokenLine, Prj** ppPrj, const ByteString& rProjectName, const sal_Bool bExtendAlias )
1691cdf0e10cSrcweir /*****************************************************************************/
1692cdf0e10cSrcweir {
1693cdf0e10cSrcweir 	int i = 0;
1694cdf0e10cSrcweir 	ByteString aWhat, aWhatOS,
1695cdf0e10cSrcweir 		sClientRestriction, aLogFileName, aProjectName, aPrefix, aCommandPara;
1696cdf0e10cSrcweir 	ByteString aDirName;
1697cdf0e10cSrcweir 	sal_Bool bPrjDep = sal_False;
1698cdf0e10cSrcweir 	sal_Bool bHardDep = sal_False;
1699cdf0e10cSrcweir 	sal_Bool bFixedDep = sal_False;
1700cdf0e10cSrcweir 	sal_Bool bNewProject = sal_False;
1701cdf0e10cSrcweir 	int nCommandType=0, nOSType=0;
1702cdf0e10cSrcweir 	Prj* pPrj = *ppPrj;
1703cdf0e10cSrcweir 	CommandData* pCmdData;
1704cdf0e10cSrcweir 	SByteStringList *pDepList = NULL;
1705cdf0e10cSrcweir 	ByteString aCommentString;
1706cdf0e10cSrcweir 	ByteString sToken;
1707cdf0e10cSrcweir 	ByteString sStringBuffer = rTokenLine;
1708cdf0e10cSrcweir 
1709cdf0e10cSrcweir 	while (sStringBuffer != ByteString::EmptyString())
1710cdf0e10cSrcweir 	{
1711cdf0e10cSrcweir 		ByteString sToken = sStringBuffer.GetToken(0,'\t');
1712cdf0e10cSrcweir 		sStringBuffer.Erase(0, sToken.Len()+1);
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir 		switch (i)
1715cdf0e10cSrcweir 		{
1716cdf0e10cSrcweir 			case 0:
1717cdf0e10cSrcweir 					if ( sToken.Search( "#" ) == 0 )
1718cdf0e10cSrcweir 					{
1719cdf0e10cSrcweir 						i = -1;
1720cdf0e10cSrcweir 						aCommentString = sToken;
1721cdf0e10cSrcweir 						sStringBuffer = ByteString::EmptyString();
1722cdf0e10cSrcweir 						if ( Count() == 0 )
1723cdf0e10cSrcweir 							aDirName = "null_entry" ; //comments at begin of file
1724cdf0e10cSrcweir 					}
1725cdf0e10cSrcweir 					else
1726cdf0e10cSrcweir 					{
1727cdf0e10cSrcweir 						aPrefix = sToken;
1728cdf0e10cSrcweir 						pDepList = 0;
1729cdf0e10cSrcweir 					}
1730cdf0e10cSrcweir 					break;
1731cdf0e10cSrcweir 			case 1:
1732cdf0e10cSrcweir 					aDirName = sToken;
1733cdf0e10cSrcweir 					aProjectName = aDirName.GetToken ( 0, 0x5c);
1734cdf0e10cSrcweir 					if (aProjectName != rProjectName)
1735cdf0e10cSrcweir 						sStringBuffer = ByteString::EmptyString(); // something is wrong, ignore line
1736cdf0e10cSrcweir 					break;
1737cdf0e10cSrcweir 			case 2:
1738cdf0e10cSrcweir 					if ( sToken.CompareTo(":") == COMPARE_EQUAL )
1739cdf0e10cSrcweir 					{
1740cdf0e10cSrcweir 						bPrjDep = sal_True;
1741cdf0e10cSrcweir 						bHardDep = sal_False;
1742cdf0e10cSrcweir 						bFixedDep = sal_False;
1743cdf0e10cSrcweir 						i = 9;
1744cdf0e10cSrcweir 					}
1745cdf0e10cSrcweir 					else if ( sToken.CompareTo("::") == COMPARE_EQUAL )
1746cdf0e10cSrcweir 					{
1747cdf0e10cSrcweir 						bPrjDep = sal_True;
1748cdf0e10cSrcweir 						bHardDep = sal_True;
1749cdf0e10cSrcweir 						bFixedDep = sal_False;
1750cdf0e10cSrcweir 						i = 9;
1751cdf0e10cSrcweir 					}
1752cdf0e10cSrcweir 					else if ( sToken.CompareTo(":::") == COMPARE_EQUAL )
1753cdf0e10cSrcweir 					{
1754cdf0e10cSrcweir 						bPrjDep = sal_True;
1755cdf0e10cSrcweir 						bHardDep = sal_True;
1756cdf0e10cSrcweir 						bFixedDep = sal_True;
1757cdf0e10cSrcweir 						i = 9;
1758cdf0e10cSrcweir 					}
1759cdf0e10cSrcweir 					else
1760cdf0e10cSrcweir 					{
1761cdf0e10cSrcweir 						bPrjDep = sal_False;
1762cdf0e10cSrcweir 						bHardDep = sal_False;
1763cdf0e10cSrcweir 						bFixedDep = sal_False;
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir 						aWhat = sToken;
1766cdf0e10cSrcweir 						nCommandType = GetJobType(aWhat);
1767cdf0e10cSrcweir 					}
1768cdf0e10cSrcweir 					if (bPrjDep)
1769cdf0e10cSrcweir 					{
1770cdf0e10cSrcweir 						if (pPrj)
1771cdf0e10cSrcweir 							sStringBuffer = ByteString::EmptyString(); // definition more than once or not first line, ignore line
1772cdf0e10cSrcweir 					}
1773cdf0e10cSrcweir 					break;
1774cdf0e10cSrcweir 			case 3:
1775cdf0e10cSrcweir 					if ( !bPrjDep )
1776cdf0e10cSrcweir 					{
1777cdf0e10cSrcweir 						aWhat = sToken;
1778cdf0e10cSrcweir 						if ( aWhat == "-" )
1779cdf0e10cSrcweir 						{
1780cdf0e10cSrcweir 							aCommandPara = ByteString();
1781cdf0e10cSrcweir 						}
1782cdf0e10cSrcweir 						else
1783cdf0e10cSrcweir 							aCommandPara = aWhat;
1784cdf0e10cSrcweir 					}
1785cdf0e10cSrcweir 					break;
1786cdf0e10cSrcweir 			case 4:
1787cdf0e10cSrcweir 					if ( !bPrjDep )
1788cdf0e10cSrcweir 					{
1789cdf0e10cSrcweir 						aWhatOS = sToken;
1790cdf0e10cSrcweir 						if ( aWhatOS.GetTokenCount( ',' ) > 1 ) {
1791cdf0e10cSrcweir 							sClientRestriction = aWhatOS.Copy( aWhatOS.GetToken( 0, ',' ).Len() + 1 );
1792cdf0e10cSrcweir 							aWhatOS = aWhatOS.GetToken( 0, ',' );
1793cdf0e10cSrcweir 						}
1794cdf0e10cSrcweir 						nOSType = GetOSType (aWhatOS);
1795cdf0e10cSrcweir 					}
1796cdf0e10cSrcweir 					break;
1797cdf0e10cSrcweir 			case 5:
1798cdf0e10cSrcweir 					if ( !bPrjDep )
1799cdf0e10cSrcweir 					{
1800cdf0e10cSrcweir 						if (bExtendAlias)
1801cdf0e10cSrcweir 							aLogFileName = (ByteString(aProjectName).Append("_")).Append(sToken);
1802cdf0e10cSrcweir 						else
1803cdf0e10cSrcweir 							aLogFileName = sToken;
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir 					}
1806cdf0e10cSrcweir 					break;
1807cdf0e10cSrcweir 			default:
1808cdf0e10cSrcweir 					if ( !bPrjDep )
1809cdf0e10cSrcweir 					{
1810cdf0e10cSrcweir 						ByteString aItem = sToken;
1811cdf0e10cSrcweir 						if ( aItem == "NULL" )
1812cdf0e10cSrcweir 						{
1813cdf0e10cSrcweir 							// Liste zu Ende
1814cdf0e10cSrcweir 							i = -1;
1815cdf0e10cSrcweir 						}
1816cdf0e10cSrcweir 						else
1817cdf0e10cSrcweir 						{
1818cdf0e10cSrcweir 							// ggfs. Dependency liste anlegen und ergaenzen
1819cdf0e10cSrcweir 							if ( !pDepList )
1820cdf0e10cSrcweir 								pDepList = new SByteStringList;
1821cdf0e10cSrcweir 							ByteString* pStr;
1822cdf0e10cSrcweir 							if (bExtendAlias)
1823cdf0e10cSrcweir 								pStr = new ByteString ((ByteString (aProjectName).Append("_")).Append(aItem));
1824cdf0e10cSrcweir 							else
1825cdf0e10cSrcweir 								pStr = new ByteString (aItem);
1826cdf0e10cSrcweir 							pDepList->PutString( pStr );
1827cdf0e10cSrcweir 						}
1828cdf0e10cSrcweir 					}
1829cdf0e10cSrcweir 					else
1830cdf0e10cSrcweir 					{
1831cdf0e10cSrcweir 						ByteString aItem = sToken;
1832cdf0e10cSrcweir 						if ( aItem == "NULL" )
1833cdf0e10cSrcweir 						{
1834cdf0e10cSrcweir 							// Liste zu Ende
1835cdf0e10cSrcweir 							i = -1;
1836cdf0e10cSrcweir 							bPrjDep= sal_False;
1837cdf0e10cSrcweir 						}
1838cdf0e10cSrcweir 						else
1839cdf0e10cSrcweir 						{
1840cdf0e10cSrcweir 							ByteString sMode;
1841cdf0e10cSrcweir 							sal_Bool bHasModes = sal_False;
1842cdf0e10cSrcweir 							if (aItem.Search(":") != STRING_NOTFOUND)
1843cdf0e10cSrcweir 							{
1844cdf0e10cSrcweir 								sMode = aItem.GetToken ( 0, ':');
1845cdf0e10cSrcweir 								aItem = aItem.GetToken ( 1, ':');
1846cdf0e10cSrcweir 								bHasModes = sal_True;
1847cdf0e10cSrcweir 							}
1848cdf0e10cSrcweir 							if (!pPrj)
1849cdf0e10cSrcweir 							{
1850cdf0e10cSrcweir 								// neues Project anlegen
1851cdf0e10cSrcweir 								pPrj = new Prj ( aProjectName );
1852cdf0e10cSrcweir 								pPrj->SetPreFix( aPrefix );
1853cdf0e10cSrcweir 								bNewProject = sal_True;
1854cdf0e10cSrcweir 							}
1855cdf0e10cSrcweir 							if (bHasModes)
1856cdf0e10cSrcweir 								pPrj->AddDependencies( aItem, sMode );
1857cdf0e10cSrcweir 							else
1858cdf0e10cSrcweir 								pPrj->AddDependencies( aItem );
1859cdf0e10cSrcweir 							pPrj->HasHardDependencies( bHardDep );
1860cdf0e10cSrcweir 							pPrj->HasFixedDependencies( bFixedDep );
1861cdf0e10cSrcweir 						}
1862cdf0e10cSrcweir 					}
1863cdf0e10cSrcweir 					break;
1864cdf0e10cSrcweir 		}
1865cdf0e10cSrcweir 		if ( i == -1 )
1866cdf0e10cSrcweir 			break;
1867cdf0e10cSrcweir 		i++;
1868cdf0e10cSrcweir 	}
1869cdf0e10cSrcweir 	/* Wenn dieses Project noch nicht vertreten ist, in die Liste
1870cdf0e10cSrcweir 	   der Solar-Projekte einfuegen */
1871cdf0e10cSrcweir 	if ( i == -1 )
1872cdf0e10cSrcweir 	{
1873cdf0e10cSrcweir 		if (!pPrj)
1874cdf0e10cSrcweir 		{
1875cdf0e10cSrcweir 			// neues Project anlegen
1876cdf0e10cSrcweir 			pPrj = new Prj ( aProjectName );
1877cdf0e10cSrcweir 			pPrj->SetPreFix( aPrefix );
1878cdf0e10cSrcweir 			bNewProject = sal_True;
1879cdf0e10cSrcweir 		}
1880cdf0e10cSrcweir 
1881cdf0e10cSrcweir 		if (bNewProject)
1882cdf0e10cSrcweir 			Insert(pPrj,LIST_APPEND);
1883cdf0e10cSrcweir 
1884cdf0e10cSrcweir 		pCmdData = new CommandData;
1885cdf0e10cSrcweir 		pCmdData->SetPath( aDirName );
1886cdf0e10cSrcweir 		pCmdData->SetCommandType( nCommandType );
1887cdf0e10cSrcweir 		pCmdData->SetCommandPara( aCommandPara );
1888cdf0e10cSrcweir 		pCmdData->SetOSType( nOSType );
1889cdf0e10cSrcweir 		pCmdData->SetLogFile( aLogFileName );
1890cdf0e10cSrcweir 		pCmdData->SetComment( aCommentString );
1891cdf0e10cSrcweir 		pCmdData->SetClientRestriction( sClientRestriction );
1892cdf0e10cSrcweir 		if ( pDepList )
1893cdf0e10cSrcweir 			pCmdData->SetDependencies( pDepList );
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir 		pDepList = 0;
1896cdf0e10cSrcweir 		pPrj->Insert ( pCmdData, LIST_APPEND );
1897cdf0e10cSrcweir 
1898cdf0e10cSrcweir 		// und wer raeumt die depLst wieder ab ?
1899cdf0e10cSrcweir 		// CommandData macht das
1900cdf0e10cSrcweir 	}
1901cdf0e10cSrcweir 	else
1902cdf0e10cSrcweir 	{
1903cdf0e10cSrcweir 		if (!pPrj)
1904cdf0e10cSrcweir 		{
1905cdf0e10cSrcweir 			// new project to set the error flag
1906cdf0e10cSrcweir 			pPrj = new Prj ( rProjectName );
1907cdf0e10cSrcweir 			pPrj->SetPreFix( aPrefix );
1908cdf0e10cSrcweir 			bNewProject = sal_True;
1909cdf0e10cSrcweir 		}
1910cdf0e10cSrcweir 		if (pPrj)
1911cdf0e10cSrcweir 		{
1912cdf0e10cSrcweir 			pPrj->SetError();
1913cdf0e10cSrcweir 			if (bNewProject)
1914cdf0e10cSrcweir 				Insert(pPrj,LIST_APPEND); // add project even if there is a buildlist error
1915cdf0e10cSrcweir 		}
1916cdf0e10cSrcweir 		if ( pDepList )
1917cdf0e10cSrcweir 			delete pDepList;
1918cdf0e10cSrcweir 	}
1919cdf0e10cSrcweir 	*ppPrj = pPrj;
1920cdf0e10cSrcweir }
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir /*****************************************************************************/
HasProject(ByteString aProjectName)1923cdf0e10cSrcweir sal_Bool Star::HasProject ( ByteString aProjectName )
1924cdf0e10cSrcweir /*****************************************************************************/
1925cdf0e10cSrcweir {
1926cdf0e10cSrcweir 	Prj *pPrj;
1927cdf0e10cSrcweir 	int nCount_l;
1928cdf0e10cSrcweir 
1929cdf0e10cSrcweir 	nCount_l = Count();
1930cdf0e10cSrcweir 
1931cdf0e10cSrcweir 	for ( int i=0; i<nCount_l; i++)
1932cdf0e10cSrcweir 	{
1933cdf0e10cSrcweir 		pPrj = GetObject(i);
1934cdf0e10cSrcweir 		if ( pPrj->GetProjectName().ToLowerAscii() == aProjectName.ToLowerAscii() )
1935cdf0e10cSrcweir 			return sal_True;
1936cdf0e10cSrcweir 	}
1937cdf0e10cSrcweir 	return sal_False;
1938cdf0e10cSrcweir }
1939cdf0e10cSrcweir 
1940cdf0e10cSrcweir /*****************************************************************************/
GetPrj(ByteString aProjectName)1941cdf0e10cSrcweir Prj* Star::GetPrj ( ByteString aProjectName )
1942cdf0e10cSrcweir /*****************************************************************************/
1943cdf0e10cSrcweir {
1944cdf0e10cSrcweir 	Prj* pPrj;
1945cdf0e10cSrcweir 	int nCount_l = Count();
1946cdf0e10cSrcweir 	for ( int i=0;i<nCount_l;i++)
1947cdf0e10cSrcweir 	{
1948cdf0e10cSrcweir 		pPrj = GetObject(i);
1949cdf0e10cSrcweir 		if ( pPrj->GetProjectName().ToLowerAscii() == aProjectName.ToLowerAscii() )
1950cdf0e10cSrcweir 			return pPrj;
1951cdf0e10cSrcweir 	}
1952cdf0e10cSrcweir //	return (Prj*)NULL;
1953cdf0e10cSrcweir 	return 0L ;
1954cdf0e10cSrcweir }
1955cdf0e10cSrcweir 
1956cdf0e10cSrcweir /*****************************************************************************/
RemovePrj(Prj * pPrj)1957cdf0e10cSrcweir sal_Bool Star::RemovePrj ( Prj* pPrj )
1958cdf0e10cSrcweir /*****************************************************************************/
1959cdf0e10cSrcweir {
1960cdf0e10cSrcweir 	sal_uIntPtr nPos = GetPos(pPrj);
1961cdf0e10cSrcweir 	if (nPos != LIST_ENTRY_NOTFOUND) {
1962cdf0e10cSrcweir 		delete pPrj;
1963cdf0e10cSrcweir 		Remove(nPos);
1964cdf0e10cSrcweir 		return sal_True;
1965cdf0e10cSrcweir 	}
1966cdf0e10cSrcweir 	return sal_False;
1967cdf0e10cSrcweir }
1968cdf0e10cSrcweir 
1969cdf0e10cSrcweir /*****************************************************************************/
RemoveAllPrj()1970cdf0e10cSrcweir void Star::RemoveAllPrj ()
1971cdf0e10cSrcweir /*****************************************************************************/
1972cdf0e10cSrcweir {
1973cdf0e10cSrcweir 	Prj* pPrj = First();
1974cdf0e10cSrcweir 	while (pPrj)
1975cdf0e10cSrcweir 	{
1976cdf0e10cSrcweir 		delete pPrj;
1977cdf0e10cSrcweir 		pPrj = Next();
1978cdf0e10cSrcweir 	}
1979cdf0e10cSrcweir 	Clear();
1980cdf0e10cSrcweir }
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir /*****************************************************************************/
GetPrjName(DirEntry & aPath)1983cdf0e10cSrcweir ByteString Star::GetPrjName( DirEntry &aPath )
1984cdf0e10cSrcweir /*****************************************************************************/
1985cdf0e10cSrcweir {
1986cdf0e10cSrcweir 	ByteString aRetPrj, aDirName;
1987cdf0e10cSrcweir 	ByteString aFullPathName = ByteString( aPath.GetFull(), gsl_getSystemTextEncoding());
1988cdf0e10cSrcweir 
1989cdf0e10cSrcweir 	sal_uInt16 nToken = aFullPathName.GetTokenCount(PATH_DELIMETER);
1990cdf0e10cSrcweir 	for ( int i=0; i< nToken; i++ )
1991cdf0e10cSrcweir 	{
1992cdf0e10cSrcweir 		aDirName = aFullPathName.GetToken( i, PATH_DELIMETER );
1993cdf0e10cSrcweir 		if ( HasProject( aDirName ))
1994cdf0e10cSrcweir 		{
1995cdf0e10cSrcweir 			aRetPrj = aDirName;
1996cdf0e10cSrcweir 			break;
1997cdf0e10cSrcweir 		}
1998cdf0e10cSrcweir 	}
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir 	return aRetPrj;
2001cdf0e10cSrcweir }
2002cdf0e10cSrcweir 
2003cdf0e10cSrcweir /*****************************************************************************/
ClearAvailableDeps()2004cdf0e10cSrcweir void Star::ClearAvailableDeps ()
2005cdf0e10cSrcweir /*****************************************************************************/
2006cdf0e10cSrcweir {
2007cdf0e10cSrcweir 	if ( pAllDepMode )
2008cdf0e10cSrcweir 	{
2009cdf0e10cSrcweir 		ByteString *pString = pAllDepMode->First();
2010cdf0e10cSrcweir 		while ( pString )
2011cdf0e10cSrcweir 		{
2012cdf0e10cSrcweir 			delete pString;
2013cdf0e10cSrcweir 			pString = pAllDepMode->Next();
2014cdf0e10cSrcweir 		}
2015cdf0e10cSrcweir 		delete pAllDepMode;
2016cdf0e10cSrcweir 		pAllDepMode = NULL;
2017cdf0e10cSrcweir 	}
2018cdf0e10cSrcweir }
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir /*****************************************************************************/
ClearLoadedFilesList()2021cdf0e10cSrcweir void Star::ClearLoadedFilesList ()
2022cdf0e10cSrcweir /*****************************************************************************/
2023cdf0e10cSrcweir {
2024cdf0e10cSrcweir 	StarFile *pStarFile = aLoadedFilesList.First();
2025cdf0e10cSrcweir 	while ( pStarFile )
2026cdf0e10cSrcweir 	{
2027cdf0e10cSrcweir 		delete pStarFile;
2028cdf0e10cSrcweir 		pStarFile = aLoadedFilesList.Next();
2029cdf0e10cSrcweir 	}
2030cdf0e10cSrcweir 	aLoadedFilesList.Clear();
2031cdf0e10cSrcweir }
2032cdf0e10cSrcweir 
2033cdf0e10cSrcweir /*****************************************************************************/
ClearCurrentDeps()2034cdf0e10cSrcweir void Star::ClearCurrentDeps ()
2035cdf0e10cSrcweir /*****************************************************************************/
2036cdf0e10cSrcweir {
2037cdf0e10cSrcweir 	if ( pDepMode )
2038cdf0e10cSrcweir 	{
2039cdf0e10cSrcweir 		ByteString *pString = pDepMode->First();
2040cdf0e10cSrcweir 		while ( pString )
2041cdf0e10cSrcweir 		{
2042cdf0e10cSrcweir 			delete pString;
2043cdf0e10cSrcweir 			pString = pDepMode->Next();
2044cdf0e10cSrcweir 		}
2045cdf0e10cSrcweir 		delete pDepMode;
2046cdf0e10cSrcweir 		pDepMode = NULL;
2047cdf0e10cSrcweir 	}
2048cdf0e10cSrcweir }
2049cdf0e10cSrcweir 
2050cdf0e10cSrcweir /*****************************************************************************/
GetAvailableDeps()2051cdf0e10cSrcweir SByteStringList* Star::GetAvailableDeps ()
2052cdf0e10cSrcweir /*****************************************************************************/
2053cdf0e10cSrcweir {
2054cdf0e10cSrcweir 	if ( pAllDepMode )
2055cdf0e10cSrcweir 		return pAllDepMode;
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir 	Prj *pPrj;
2058cdf0e10cSrcweir 	ByteString* pStr;
2059cdf0e10cSrcweir 	pPrj = First();
2060cdf0e10cSrcweir 	while (pPrj)
2061cdf0e10cSrcweir 	{
2062cdf0e10cSrcweir 		SByteStringList* pModeList = NULL;
2063cdf0e10cSrcweir 		if (pPrj->GetModeAndDependencies() && (pModeList = pPrj->GetModeAndDependencies()->GetAllDepModes()))
2064cdf0e10cSrcweir 		{
2065cdf0e10cSrcweir 			pStr = pModeList->First();
2066cdf0e10cSrcweir 			while (pStr)
2067cdf0e10cSrcweir 			{
2068cdf0e10cSrcweir 				if ( !pAllDepMode )
2069cdf0e10cSrcweir 					pAllDepMode = new SByteStringList();
2070cdf0e10cSrcweir 
2071cdf0e10cSrcweir 				if (pAllDepMode->IsString(pStr) == NOT_THERE)
2072cdf0e10cSrcweir 					pAllDepMode->PutString(new ByteString(*pStr));
2073cdf0e10cSrcweir 
2074cdf0e10cSrcweir 				pStr = pModeList->Next();
2075cdf0e10cSrcweir 			}
2076cdf0e10cSrcweir 		}
2077cdf0e10cSrcweir 		pPrj = Next();
2078cdf0e10cSrcweir 	}
2079cdf0e10cSrcweir 	return pAllDepMode;
2080cdf0e10cSrcweir }
2081cdf0e10cSrcweir 
2082cdf0e10cSrcweir /*****************************************************************************/
SetCurrentDeps(SByteStringList * pDepList)2083cdf0e10cSrcweir void Star::SetCurrentDeps (SByteStringList* pDepList)
2084cdf0e10cSrcweir /*****************************************************************************/
2085cdf0e10cSrcweir {
2086cdf0e10cSrcweir 	ClearCurrentDeps();
2087cdf0e10cSrcweir 
2088cdf0e10cSrcweir 	if (pDepList)
2089cdf0e10cSrcweir 	{
2090cdf0e10cSrcweir 		pDepMode = new SByteStringList();
2091cdf0e10cSrcweir 		ByteString *pString = pDepList->First();
2092cdf0e10cSrcweir 		while ( pString )
2093cdf0e10cSrcweir 		{
2094cdf0e10cSrcweir 			ByteString* pStr = new ByteString (*pString);
2095cdf0e10cSrcweir 			if (pDepMode->PutString(pStr) == NOT_THERE)
2096cdf0e10cSrcweir 				delete pStr; // String is not in List
2097cdf0e10cSrcweir 			pString = pDepList->Next();
2098cdf0e10cSrcweir 		}
2099cdf0e10cSrcweir 	}
2100cdf0e10cSrcweir 	Expand_Impl();
2101cdf0e10cSrcweir }
2102cdf0e10cSrcweir 
2103cdf0e10cSrcweir ///*****************************************************************************/
2104cdf0e10cSrcweir //void Star::ReadXmlBuildList(const ByteString& sBuildLstPath) {
2105cdf0e10cSrcweir ///*****************************************************************************/
2106cdf0e10cSrcweir //	if (mpXmlBuildList) {
2107cdf0e10cSrcweir //		Prj* pPrj = NULL;
2108cdf0e10cSrcweir //
2109cdf0e10cSrcweir //		try {
2110cdf0e10cSrcweir //			mpXmlBuildList->loadXMLFile(sBuildLstPath);
2111cdf0e10cSrcweir //		}
2112cdf0e10cSrcweir //		catch (XmlBuildListException) {
2113cdf0e10cSrcweir //			DirEntry aDirEntry (sBuildLstPath);
2114cdf0e10cSrcweir //			String ssPrjName = aDirEntry.GetPath().GetPath().GetBase();
2115cdf0e10cSrcweir //			ByteString sPrjName = ByteString(ssPrjName, RTL_TEXTENCODING_ASCII_US);
2116cdf0e10cSrcweir //			pPrj = GetPrj( sPrjName );
2117cdf0e10cSrcweir //			if (pPrj)
2118cdf0e10cSrcweir //			{
2119cdf0e10cSrcweir //				//remove old Project
2120cdf0e10cSrcweir //				RemovePrj (pPrj);
2121cdf0e10cSrcweir //			}
2122cdf0e10cSrcweir //			return;
2123cdf0e10cSrcweir //		}
2124cdf0e10cSrcweir //
2125cdf0e10cSrcweir //		try {
2126cdf0e10cSrcweir //			ByteString sProjectName = mpXmlBuildList->getModuleName();
2127cdf0e10cSrcweir //			pPrj = GetPrj( sProjectName );
2128cdf0e10cSrcweir //			if (pPrj)
2129cdf0e10cSrcweir //			{
2130cdf0e10cSrcweir //				//remove old Project
2131cdf0e10cSrcweir //				RemovePrj (pPrj);
2132cdf0e10cSrcweir //			}
2133cdf0e10cSrcweir //
2134cdf0e10cSrcweir //			// insert new Project
2135cdf0e10cSrcweir //			pPrj = new Prj ( sProjectName );
2136cdf0e10cSrcweir //			pPrj->SetPreFix( sProjectName ); // use ProjectName as Prefix
2137cdf0e10cSrcweir //			Insert(pPrj,LIST_APPEND);
2138cdf0e10cSrcweir //
2139cdf0e10cSrcweir //			// get global dependencies
2140cdf0e10cSrcweir //			FullByteStringListWrapper aProducts = mpXmlBuildList->getProducts();
2141cdf0e10cSrcweir //			ByteString aDepType = ByteString(DEP_MD_ALWAYS_STR);
2142cdf0e10cSrcweir //			if (mpXmlBuildList->hasModuleDepType(aProducts, aDepType))
2143cdf0e10cSrcweir //				pPrj->HasHardDependencies( sal_True );
2144cdf0e10cSrcweir //
2145cdf0e10cSrcweir //			aDepType = ByteString(DEP_MD_FORCE_STR);
2146cdf0e10cSrcweir //			if (mpXmlBuildList->hasModuleDepType(aProducts, aDepType))
2147cdf0e10cSrcweir //			{
2148cdf0e10cSrcweir //				pPrj->HasHardDependencies( sal_True );
2149cdf0e10cSrcweir //				pPrj->HasFixedDependencies( sal_True );
2150cdf0e10cSrcweir //			}
2151cdf0e10cSrcweir //
2152cdf0e10cSrcweir //			// modul dependencies
2153cdf0e10cSrcweir //			ByteString sModulDepType = ByteString();
2154cdf0e10cSrcweir //			FullByteStringListWrapper aModulDeps = mpXmlBuildList->getModuleDependencies(aProducts, sModulDepType);
2155cdf0e10cSrcweir //			ByteString * pModulDep = aModulDeps.First();
2156cdf0e10cSrcweir //			while (pModulDep)
2157cdf0e10cSrcweir //			{
2158cdf0e10cSrcweir //				FullByteStringListWrapper aModulProducts = mpXmlBuildList->getModuleProducts(*pModulDep);
2159cdf0e10cSrcweir //				ByteString *pModulePoduct = aModulProducts.First();
2160cdf0e10cSrcweir //				while (pModulePoduct)
2161cdf0e10cSrcweir //				{
2162cdf0e10cSrcweir //					if (*pModulePoduct == XML_ALL)
2163cdf0e10cSrcweir //						pPrj->AddDependencies( *pModulDep );
2164cdf0e10cSrcweir //					else
2165cdf0e10cSrcweir //						pPrj->AddDependencies( *pModulDep, *pModulePoduct);
2166cdf0e10cSrcweir //
2167cdf0e10cSrcweir //					pModulePoduct = aModulProducts.Next();
2168cdf0e10cSrcweir //				}
2169cdf0e10cSrcweir //				pModulDep = aModulDeps.Next();
2170cdf0e10cSrcweir //			}
2171cdf0e10cSrcweir //
2172cdf0e10cSrcweir //			// job dirs
2173cdf0e10cSrcweir //			ByteString sJobType = ByteString();
2174cdf0e10cSrcweir //			ByteString sJobPlatforms = ByteString();
2175cdf0e10cSrcweir //			FullByteStringListWrapper aJobDirs = mpXmlBuildList->getJobDirectories(sJobType, sJobPlatforms); // all dirs
2176cdf0e10cSrcweir //			ByteString* pJobDir = aJobDirs.First();
2177cdf0e10cSrcweir //			while (pJobDir)
2178cdf0e10cSrcweir //			{
2179cdf0e10cSrcweir //				FullByteStringListWrapper aJobPlatforms = mpXmlBuildList->getJobPlatforms (*pJobDir);
2180cdf0e10cSrcweir //				ByteString* pJobPlatform = aJobPlatforms.First();
2181cdf0e10cSrcweir //				while (pJobPlatform)
2182cdf0e10cSrcweir //				{
2183cdf0e10cSrcweir //					ByteString sJobRestriction = ByteString();
2184cdf0e10cSrcweir //					FullByteStringListWrapper aJobReq = mpXmlBuildList->getJobBuildReqs (*pJobDir, *pJobPlatform);
2185cdf0e10cSrcweir //					// nur ein Req pro Platform wird zur Zeit unterst�tzt
2186cdf0e10cSrcweir //					// mehr geht wegen der Struktur zur Zeit nicht!
2187cdf0e10cSrcweir //					// lese sie trotzdem kommasepariert ein, wenn n�tig
2188cdf0e10cSrcweir //					if (aJobReq.Count() > 0)
2189cdf0e10cSrcweir //					{
2190cdf0e10cSrcweir //						ByteString* pRestriction = aJobReq.First();
2191cdf0e10cSrcweir //						sJobRestriction = ByteString (*pRestriction);
2192cdf0e10cSrcweir //						pRestriction = aJobReq.Next();
2193cdf0e10cSrcweir //						while (pRestriction)
2194cdf0e10cSrcweir //						{
2195cdf0e10cSrcweir //							sJobRestriction += ByteString (",");
2196cdf0e10cSrcweir //							sJobRestriction += ByteString (*pRestriction);
2197cdf0e10cSrcweir //							pRestriction = aJobReq.Next();
2198cdf0e10cSrcweir //						}
2199cdf0e10cSrcweir //					}
2200cdf0e10cSrcweir //
2201cdf0e10cSrcweir //					FullByteStringListWrapper aJobTypes = mpXmlBuildList->getJobTypes (*pJobDir);
2202cdf0e10cSrcweir //					ByteString * pJobType = aJobTypes.First();
2203cdf0e10cSrcweir //					while(pJobType)
2204cdf0e10cSrcweir //					{
2205cdf0e10cSrcweir //						FullByteStringListWrapper aDirDependencies = mpXmlBuildList->getDirDependencies(*pJobDir, *pJobType, *pJobPlatform);
2206cdf0e10cSrcweir //						SByteStringList *pDepList = NULL;
2207cdf0e10cSrcweir //						if (aDirDependencies.Count() > 0)
2208cdf0e10cSrcweir //						{
2209cdf0e10cSrcweir //							pDepList = new SByteStringList;
2210cdf0e10cSrcweir //							ByteString* pDirDep = aDirDependencies.First();
2211cdf0e10cSrcweir //							while (pDirDep)
2212cdf0e10cSrcweir //							{
2213cdf0e10cSrcweir //								ByteString sFullDir = sProjectName;
2214cdf0e10cSrcweir //								sFullDir += *pDirDep;
2215cdf0e10cSrcweir //								sFullDir.SearchAndReplaceAll('/', '\\');
2216cdf0e10cSrcweir //								*pDirDep = sFullDir;
2217cdf0e10cSrcweir //								pDepList->PutString(pDirDep);	// String wird �bergeben
2218cdf0e10cSrcweir //								aDirDependencies.Remove();		// Zeiger aus alter Liste l�schen
2219cdf0e10cSrcweir //								pDirDep = aDirDependencies.First();
2220cdf0e10cSrcweir //							}
2221cdf0e10cSrcweir //						}
2222cdf0e10cSrcweir //						// insert CommandData
2223cdf0e10cSrcweir //						CommandData * pCmdData = new CommandData;
2224cdf0e10cSrcweir //						ByteString sRequiredPath = sProjectName;
2225cdf0e10cSrcweir //						sRequiredPath += *pJobDir;
2226cdf0e10cSrcweir //						sRequiredPath.SearchAndReplaceAll('/', '\\');
2227cdf0e10cSrcweir //						pCmdData->SetPath(sRequiredPath);
2228cdf0e10cSrcweir //						pCmdData->SetCommandType( GetJobType(*pJobType) );
2229cdf0e10cSrcweir //						pCmdData->SetCommandPara( ByteString() );
2230cdf0e10cSrcweir //						pCmdData->SetOSType( GetOSType(*pJobPlatform) );
2231cdf0e10cSrcweir //						ByteString sLogFileName = sProjectName;
2232cdf0e10cSrcweir //						sLogFileName += ByteString::CreateFromInt64( pPrj->Count() );
2233cdf0e10cSrcweir // 						pCmdData->SetLogFile( sLogFileName );
2234cdf0e10cSrcweir //						pCmdData->SetClientRestriction( sJobRestriction );
2235cdf0e10cSrcweir //						if ( pDepList )
2236cdf0e10cSrcweir //							pCmdData->SetDependencies( pDepList );
2237cdf0e10cSrcweir //
2238cdf0e10cSrcweir //						pPrj->Insert ( pCmdData, LIST_APPEND );
2239cdf0e10cSrcweir //
2240cdf0e10cSrcweir //						pJobType = aJobTypes.Next();
2241cdf0e10cSrcweir //					}
2242cdf0e10cSrcweir //
2243cdf0e10cSrcweir //					pJobPlatform = aJobPlatforms.Next();
2244cdf0e10cSrcweir //				}
2245cdf0e10cSrcweir //
2246cdf0e10cSrcweir //				pJobDir = aJobDirs.Next();
2247cdf0e10cSrcweir //			}
2248cdf0e10cSrcweir //			pPrj->ExtractDependencies();
2249cdf0e10cSrcweir //		}
2250cdf0e10cSrcweir //		catch (XmlBuildListException) {
2251cdf0e10cSrcweir //			if (pPrj)
2252cdf0e10cSrcweir //			{
2253cdf0e10cSrcweir //				RemovePrj (pPrj);
2254cdf0e10cSrcweir //				delete pPrj;
2255cdf0e10cSrcweir //			}
2256cdf0e10cSrcweir //
2257cdf0e10cSrcweir //		}
2258cdf0e10cSrcweir //	}
2259cdf0e10cSrcweir //}
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir /*****************************************************************************/
GetOSType(ByteString & aWhatOS)2262cdf0e10cSrcweir int Star::GetOSType ( ByteString& aWhatOS ) {
2263cdf0e10cSrcweir /*****************************************************************************/
2264cdf0e10cSrcweir     int nOSType = OS_NONE;
2265cdf0e10cSrcweir     if ( aWhatOS == "all" )
2266cdf0e10cSrcweir 	    nOSType = ( OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX | OS_MAC );
2267cdf0e10cSrcweir     else if ( aWhatOS == "w" || aWhatOS == "wnt" )
2268cdf0e10cSrcweir 	    nOSType = ( OS_WIN16 | OS_WIN32 );
2269cdf0e10cSrcweir     else if ( aWhatOS == "p" )
2270cdf0e10cSrcweir 	    nOSType = OS_OS2;
2271cdf0e10cSrcweir     else if ( aWhatOS == "u" || aWhatOS == "unx" )
2272cdf0e10cSrcweir 	    nOSType = OS_UNX;
2273cdf0e10cSrcweir     else if ( aWhatOS == "d" )
2274cdf0e10cSrcweir 	    nOSType = OS_WIN16;
2275cdf0e10cSrcweir     else if ( aWhatOS == "n" )
2276cdf0e10cSrcweir 	    nOSType = OS_WIN32;
2277cdf0e10cSrcweir     else if ( aWhatOS == "m" || aWhatOS == "mac" )
2278cdf0e10cSrcweir 	    nOSType = OS_MAC;
2279cdf0e10cSrcweir     return nOSType;
2280cdf0e10cSrcweir 
2281cdf0e10cSrcweir };
2282cdf0e10cSrcweir 
2283cdf0e10cSrcweir /*****************************************************************************/
GetJobType(ByteString & JobType)2284cdf0e10cSrcweir int Star::GetJobType ( ByteString& JobType ) {
2285cdf0e10cSrcweir /*****************************************************************************/
2286cdf0e10cSrcweir     int nCommandType = 0;
2287cdf0e10cSrcweir     if ( JobType == "nmake" || JobType == "make")
2288cdf0e10cSrcweir         nCommandType = COMMAND_NMAKE;
2289cdf0e10cSrcweir     else if ( JobType == "get" )
2290cdf0e10cSrcweir         nCommandType = COMMAND_GET;
2291cdf0e10cSrcweir     else {
2292cdf0e10cSrcweir         sal_uIntPtr nOffset = JobType.Copy( 3 ).ToInt32();
2293cdf0e10cSrcweir 	    nCommandType = COMMAND_USER_START + nOffset - 1;
2294cdf0e10cSrcweir     }
2295cdf0e10cSrcweir     return nCommandType;
2296cdf0e10cSrcweir };
2297cdf0e10cSrcweir 
2298cdf0e10cSrcweir /*****************************************************************************/
PutPrjIntoStream(SByteStringList * pPrjNameList,SvStream * pStream)2299cdf0e10cSrcweir void Star::PutPrjIntoStream (SByteStringList* pPrjNameList, SvStream* pStream)
2300cdf0e10cSrcweir /*****************************************************************************/
2301cdf0e10cSrcweir {
2302cdf0e10cSrcweir     aMutex.acquire();
2303cdf0e10cSrcweir     *pStream << sal_False; // not full Star / only some Projects
2304cdf0e10cSrcweir 
2305cdf0e10cSrcweir     sal_uIntPtr nCount_l = pPrjNameList->Count();
2306cdf0e10cSrcweir     *pStream << nCount_l;
2307cdf0e10cSrcweir     ByteString* pStr = pPrjNameList->First();
2308cdf0e10cSrcweir     while (pStr) {
2309cdf0e10cSrcweir         Prj* pPrj = GetPrj (*pStr);
2310cdf0e10cSrcweir         *pPrj >> *pStream;
2311cdf0e10cSrcweir         pStr = pPrjNameList->Next();
2312cdf0e10cSrcweir     }
2313cdf0e10cSrcweir     aMutex.release();
2314cdf0e10cSrcweir }
2315cdf0e10cSrcweir 
2316cdf0e10cSrcweir /*****************************************************************************/
operator >>(SvStream & rStream)2317cdf0e10cSrcweir Star& Star::operator>>  ( SvStream& rStream )
2318cdf0e10cSrcweir /*****************************************************************************/
2319cdf0e10cSrcweir {
2320cdf0e10cSrcweir     aMutex.acquire();
2321cdf0e10cSrcweir     rStream << sal_True; // full Star
2322cdf0e10cSrcweir     rStream << nStarMode;
2323cdf0e10cSrcweir 	if (pDepMode)
2324cdf0e10cSrcweir 	{
2325cdf0e10cSrcweir 		rStream << sal_True;
2326cdf0e10cSrcweir 		*pDepMode >> rStream;
2327cdf0e10cSrcweir 	}
2328cdf0e10cSrcweir 	else
2329cdf0e10cSrcweir 		rStream << sal_False;
2330cdf0e10cSrcweir 
2331cdf0e10cSrcweir     sal_uIntPtr nCount_l = Count();
2332cdf0e10cSrcweir     rStream << nCount_l;
2333cdf0e10cSrcweir     Prj* pPrj = First();
2334cdf0e10cSrcweir     while (pPrj) {
2335cdf0e10cSrcweir         *pPrj >> rStream;
2336cdf0e10cSrcweir         pPrj = Next();
2337cdf0e10cSrcweir     }
2338cdf0e10cSrcweir     aMutex.release();
2339cdf0e10cSrcweir 
2340cdf0e10cSrcweir 	return *this;
2341cdf0e10cSrcweir }
2342cdf0e10cSrcweir 
2343cdf0e10cSrcweir /*****************************************************************************/
operator <<(SvStream & rStream)2344cdf0e10cSrcweir Star& Star::operator<<  ( SvStream& rStream )
2345cdf0e10cSrcweir /*****************************************************************************/
2346cdf0e10cSrcweir {
2347cdf0e10cSrcweir     aMutex.acquire();
2348cdf0e10cSrcweir     sal_Bool bFullList;
2349cdf0e10cSrcweir     rStream >> bFullList;
2350cdf0e10cSrcweir     if (bFullList)
2351cdf0e10cSrcweir     {
2352cdf0e10cSrcweir         rStream >> nStarMode;
2353cdf0e10cSrcweir 	    sal_Bool bDepMode;
2354cdf0e10cSrcweir 	    rStream >> bDepMode;
2355cdf0e10cSrcweir 	    if (pDepMode)
2356cdf0e10cSrcweir 		    pDepMode->CleanUp();
2357cdf0e10cSrcweir 	    if (bDepMode)
2358cdf0e10cSrcweir 	    {
2359cdf0e10cSrcweir 		    if (!pDepMode)
2360cdf0e10cSrcweir 			    pDepMode = new SByteStringList();
2361cdf0e10cSrcweir 		    *pDepMode << rStream;
2362cdf0e10cSrcweir 	    }
2363cdf0e10cSrcweir 	    else
2364cdf0e10cSrcweir 		    DELETEZ (pDepMode);
2365cdf0e10cSrcweir 
2366cdf0e10cSrcweir     }
2367cdf0e10cSrcweir     sal_uIntPtr nCount_l;
2368cdf0e10cSrcweir     rStream >> nCount_l;
2369cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < nCount_l; i++ ) {
2370cdf0e10cSrcweir         Prj* pPrj = new Prj();
2371cdf0e10cSrcweir         *pPrj << rStream;
2372cdf0e10cSrcweir 		pPrj->SetMode(pDepMode);
2373cdf0e10cSrcweir         if (HasProject (pPrj->GetProjectName())) {
2374cdf0e10cSrcweir             Prj* pTmpPrj = GetPrj( pPrj->GetProjectName() );
2375cdf0e10cSrcweir             Replace (pPrj, pTmpPrj);
2376cdf0e10cSrcweir             delete pTmpPrj;
2377cdf0e10cSrcweir         }
2378cdf0e10cSrcweir         else
2379cdf0e10cSrcweir             Insert (pPrj, LIST_APPEND);
2380cdf0e10cSrcweir     }
2381cdf0e10cSrcweir 	Expand_Impl();
2382cdf0e10cSrcweir     aMutex.release();
2383cdf0e10cSrcweir 	return *this;
2384cdf0e10cSrcweir }
2385cdf0e10cSrcweir 
2386cdf0e10cSrcweir 
2387cdf0e10cSrcweir 
2388cdf0e10cSrcweir //
2389cdf0e10cSrcweir //	class StarWriter
2390cdf0e10cSrcweir //
2391cdf0e10cSrcweir 
2392cdf0e10cSrcweir /*****************************************************************************/
StarWriter(String aFileName,sal_Bool bReadComments,sal_uInt16 nMode)2393cdf0e10cSrcweir StarWriter::StarWriter( String aFileName, sal_Bool bReadComments, sal_uInt16 nMode )
2394cdf0e10cSrcweir /*****************************************************************************/
2395cdf0e10cSrcweir 				: Star ()
2396cdf0e10cSrcweir {
2397cdf0e10cSrcweir 	sFileName = aFileName;
2398cdf0e10cSrcweir 	Read ( aFileName, bReadComments, nMode );
2399cdf0e10cSrcweir }
2400cdf0e10cSrcweir 
2401cdf0e10cSrcweir /*****************************************************************************/
StarWriter(SolarFileList * pSolarFiles,sal_Bool bReadComments)2402cdf0e10cSrcweir StarWriter::StarWriter( SolarFileList *pSolarFiles, sal_Bool bReadComments )
2403cdf0e10cSrcweir /*****************************************************************************/
2404cdf0e10cSrcweir 				: Star ()
2405cdf0e10cSrcweir {
2406cdf0e10cSrcweir 	Read( pSolarFiles, bReadComments );
2407cdf0e10cSrcweir }
2408cdf0e10cSrcweir 
2409cdf0e10cSrcweir /*****************************************************************************/
StarWriter(GenericInformationList * pStandLst,ByteString & rVersion,ByteString & rMinor,sal_Bool bReadComments)2410cdf0e10cSrcweir StarWriter::StarWriter( GenericInformationList *pStandLst, ByteString &rVersion,
2411cdf0e10cSrcweir 	ByteString &rMinor, sal_Bool bReadComments )
2412cdf0e10cSrcweir /*****************************************************************************/
2413cdf0e10cSrcweir 				: Star ()
2414cdf0e10cSrcweir {
2415cdf0e10cSrcweir 	ByteString sPath( rVersion );
2416cdf0e10cSrcweir 
2417cdf0e10cSrcweir #ifdef UNX
2418cdf0e10cSrcweir 	sPath += "/settings/UNXSOLARLIST";
2419cdf0e10cSrcweir #else
2420cdf0e10cSrcweir 	sPath += "/settings/SOLARLIST";
2421cdf0e10cSrcweir #endif
2422cdf0e10cSrcweir 	GenericInformation *pInfo_l = pStandLst->GetInfo( sPath, sal_True );
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir 	if( pInfo_l && pInfo_l->GetValue().Len()) {
2425cdf0e10cSrcweir 		ByteString sFile( pInfo_l->GetValue());
2426cdf0e10cSrcweir 		String sFileName_l( sFile, RTL_TEXTENCODING_ASCII_US );
2427cdf0e10cSrcweir 		nStarMode = STAR_MODE_SINGLE_PARSE;
2428cdf0e10cSrcweir 		Read( sFileName_l, bReadComments );
2429cdf0e10cSrcweir 	}
2430cdf0e10cSrcweir 	else {
2431cdf0e10cSrcweir 		SolarFileList *pFileList = new SolarFileList();
2432cdf0e10cSrcweir 
2433cdf0e10cSrcweir 		sPath = rVersion;
2434cdf0e10cSrcweir 		sPath += "/drives";
2435cdf0e10cSrcweir 
2436cdf0e10cSrcweir 		GenericInformation *pInfo_k = pStandLst->GetInfo( sPath, sal_True );
2437cdf0e10cSrcweir 		if ( pInfo_k && pInfo_k->GetSubList())  {
2438cdf0e10cSrcweir 			GenericInformationList *pDrives = pInfo_k->GetSubList();
2439cdf0e10cSrcweir 			for ( sal_uIntPtr i = 0; i < pDrives->Count(); i++ ) {
2440cdf0e10cSrcweir 				GenericInformation *pDrive = pDrives->GetObject( i );
2441cdf0e10cSrcweir 				if ( pDrive ) {
2442cdf0e10cSrcweir 					DirEntry aEntry;
2443cdf0e10cSrcweir 					sal_Bool bOk = sal_False;
2444cdf0e10cSrcweir 					if ( sSourceRoot.Len()) {
2445cdf0e10cSrcweir 						aEntry = DirEntry( sSourceRoot );
2446cdf0e10cSrcweir 						bOk = sal_True;
2447cdf0e10cSrcweir 					}
2448cdf0e10cSrcweir 					else {
2449cdf0e10cSrcweir #ifdef UNX
2450cdf0e10cSrcweir 						sPath = "UnixVolume";
2451cdf0e10cSrcweir 						GenericInformation *pUnixVolume = pDrive->GetSubInfo( sPath );
2452cdf0e10cSrcweir 						if ( pUnixVolume ) {
2453cdf0e10cSrcweir 							String sRoot( pUnixVolume->GetValue(), RTL_TEXTENCODING_ASCII_US );
2454cdf0e10cSrcweir 							aEntry = DirEntry( sRoot );
2455cdf0e10cSrcweir 							bOk = sal_True;
2456cdf0e10cSrcweir 				 		}
2457cdf0e10cSrcweir #else
2458cdf0e10cSrcweir 						bOk = sal_True;
2459cdf0e10cSrcweir 						String sRoot( *pDrive, RTL_TEXTENCODING_ASCII_US );
2460cdf0e10cSrcweir 						sRoot += String::CreateFromAscii( "\\" );
2461cdf0e10cSrcweir 						aEntry = DirEntry( sRoot );
2462cdf0e10cSrcweir #endif
2463cdf0e10cSrcweir 					}
2464cdf0e10cSrcweir 					if ( bOk ) {
2465cdf0e10cSrcweir 						sPath = "projects";
2466cdf0e10cSrcweir 						GenericInformation *pProjectsKey = pDrive->GetSubInfo( sPath, sal_True );
2467cdf0e10cSrcweir 						if ( pProjectsKey ) {
2468cdf0e10cSrcweir 							if ( !sSourceRoot.Len()) {
2469cdf0e10cSrcweir 								sPath = rVersion;
2470cdf0e10cSrcweir 								sPath += "/settings/PATH";
2471cdf0e10cSrcweir 								GenericInformation *pPath = pStandLst->GetInfo( sPath, sal_True );
2472cdf0e10cSrcweir 								if( pPath ) {
2473cdf0e10cSrcweir 									ByteString sAddPath( pPath->GetValue());
2474cdf0e10cSrcweir #ifdef UNX
2475cdf0e10cSrcweir 									sAddPath.SearchAndReplaceAll( "\\", "/" );
2476cdf0e10cSrcweir #else
2477cdf0e10cSrcweir 									sAddPath.SearchAndReplaceAll( "/", "\\" );
2478cdf0e10cSrcweir #endif
2479cdf0e10cSrcweir                                      //If Minor has been set add it to path
2480cdf0e10cSrcweir                                     if (rMinor.Len()>0) {
2481cdf0e10cSrcweir                                         sAddPath += ".";
2482cdf0e10cSrcweir                                         sAddPath += rMinor;
2483cdf0e10cSrcweir                                     }
2484cdf0e10cSrcweir 									String ssAddPath( sAddPath, RTL_TEXTENCODING_ASCII_US );
2485cdf0e10cSrcweir 
2486cdf0e10cSrcweir 									aEntry += DirEntry( ssAddPath );
2487cdf0e10cSrcweir 								}
2488cdf0e10cSrcweir 							}
2489cdf0e10cSrcweir 							sPath = rVersion;
2490cdf0e10cSrcweir 							sPath += "/settings/SHORTPATH";
2491cdf0e10cSrcweir 							GenericInformation *pShortPath = pStandLst->GetInfo( sPath, sal_True );
2492cdf0e10cSrcweir 							sal_Bool bShortPath = sal_False;
2493cdf0e10cSrcweir 							if (pShortPath && (pShortPath->GetValue() == "_TRUE"))
2494cdf0e10cSrcweir 								bShortPath = sal_True;
2495cdf0e10cSrcweir 							sSourceRoot = aEntry.GetFull();
2496cdf0e10cSrcweir 							GenericInformationList *pProjects = pProjectsKey->GetSubList();
2497cdf0e10cSrcweir 							if ( pProjects ) {
2498cdf0e10cSrcweir 								String sPrjDir( String::CreateFromAscii( "prj" ));
2499cdf0e10cSrcweir 								String sSolarFile( String::CreateFromAscii( "build.lst" ));
2500cdf0e10cSrcweir 
2501cdf0e10cSrcweir 								GenericInformation * pProject = pProjects->First();
2502cdf0e10cSrcweir 								while (pProject) {
2503cdf0e10cSrcweir 									ByteString sProject( *pProject);
2504cdf0e10cSrcweir 									String ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
2505cdf0e10cSrcweir 
2506cdf0e10cSrcweir 									DirEntry aPrjEntry( aEntry );
2507cdf0e10cSrcweir 
2508cdf0e10cSrcweir 									ByteString aDirStr ("Directory");
2509cdf0e10cSrcweir 									GenericInformation * pDir = pProject->GetSubInfo (aDirStr);
2510cdf0e10cSrcweir 									if (pDir) {
2511cdf0e10cSrcweir 										ByteString aDir = pDir->GetValue();
2512cdf0e10cSrcweir 										if (bShortPath)
2513cdf0e10cSrcweir 											aPrjEntry = aEntry;
2514cdf0e10cSrcweir 										else
2515cdf0e10cSrcweir 											aPrjEntry = aEntry.GetPath();
2516cdf0e10cSrcweir 										aPrjEntry += DirEntry(aDir);
2517cdf0e10cSrcweir 									}
2518cdf0e10cSrcweir 
2519cdf0e10cSrcweir 									aPrjEntry += DirEntry( ssProject );
2520cdf0e10cSrcweir 									aPrjEntry += DirEntry( sPrjDir );
2521cdf0e10cSrcweir 									aPrjEntry += DirEntry( sSolarFile );
2522cdf0e10cSrcweir 
2523cdf0e10cSrcweir 									pFileList->Insert( new String( aPrjEntry.GetFull()), LIST_APPEND );
2524cdf0e10cSrcweir 
2525cdf0e10cSrcweir 									ByteString sFile( aPrjEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
2526cdf0e10cSrcweir 									fprintf( stdout, "%s\n", sFile.GetBuffer());
2527cdf0e10cSrcweir 									pProject = pProjects->Next();
2528cdf0e10cSrcweir 								}
2529cdf0e10cSrcweir 							}
2530cdf0e10cSrcweir 						}
2531cdf0e10cSrcweir 					}
2532cdf0e10cSrcweir 				}
2533cdf0e10cSrcweir 			}
2534cdf0e10cSrcweir 		}
2535cdf0e10cSrcweir 		Read( pFileList, bReadComments );
2536cdf0e10cSrcweir 	}
2537cdf0e10cSrcweir }
2538cdf0e10cSrcweir 
2539cdf0e10cSrcweir /*****************************************************************************/
CleanUp()2540cdf0e10cSrcweir void StarWriter::CleanUp()
2541cdf0e10cSrcweir /*****************************************************************************/
2542cdf0e10cSrcweir {
2543cdf0e10cSrcweir 	Expand_Impl();
2544cdf0e10cSrcweir }
2545cdf0e10cSrcweir 
2546cdf0e10cSrcweir /*****************************************************************************/
Read(String aFileName,sal_Bool bReadComments,sal_uInt16 nMode)2547cdf0e10cSrcweir sal_uInt16 StarWriter::Read( String aFileName, sal_Bool bReadComments, sal_uInt16 nMode  )
2548cdf0e10cSrcweir /*****************************************************************************/
2549cdf0e10cSrcweir {
2550cdf0e10cSrcweir 	sFileName = aFileName;
2551cdf0e10cSrcweir 
2552cdf0e10cSrcweir 	nStarMode = nMode;
2553cdf0e10cSrcweir 
2554cdf0e10cSrcweir 	ByteString aString;
2555cdf0e10cSrcweir 	aFileList.Insert( new String( aFileName ));
2556cdf0e10cSrcweir 
2557cdf0e10cSrcweir 	DirEntry aEntry( aFileName );
2558cdf0e10cSrcweir 	aEntry.ToAbs();
2559cdf0e10cSrcweir 	aEntry = aEntry.GetPath().GetPath().GetPath();
2560cdf0e10cSrcweir 	sSourceRoot = aEntry.GetFull();
2561cdf0e10cSrcweir 
2562cdf0e10cSrcweir 	while( aFileList.Count()) {
2563cdf0e10cSrcweir 		String ssFileName = *aFileList.GetObject(( sal_uIntPtr ) 0 );
2564cdf0e10cSrcweir 		StarFile* pFile = ReadBuildlist (ssFileName, bReadComments, sal_False);
2565cdf0e10cSrcweir 		aMutex.acquire();
2566cdf0e10cSrcweir 		aLoadedFilesList.Insert( pFile, LIST_APPEND );
2567cdf0e10cSrcweir 		aMutex.release();
2568cdf0e10cSrcweir 		delete aFileList.Remove(( sal_uIntPtr ) 0 );
2569cdf0e10cSrcweir 	}
2570cdf0e10cSrcweir 	// resolve all dependencies recursive
2571cdf0e10cSrcweir 	Expand_Impl();
2572cdf0e10cSrcweir 
2573cdf0e10cSrcweir 	// Die gefundenen Abhaengigkeiten rekursiv aufloesen
2574cdf0e10cSrcweir 	Expand_Impl();
2575cdf0e10cSrcweir 	return 0;
2576cdf0e10cSrcweir }
2577cdf0e10cSrcweir 
2578cdf0e10cSrcweir /*****************************************************************************/
Read(SolarFileList * pSolarFiles,sal_Bool bReadComments)2579cdf0e10cSrcweir sal_uInt16 StarWriter::Read( SolarFileList *pSolarFiles, sal_Bool bReadComments )
2580cdf0e10cSrcweir /*****************************************************************************/
2581cdf0e10cSrcweir {
2582cdf0e10cSrcweir 	nStarMode = STAR_MODE_MULTIPLE_PARSE;
2583cdf0e10cSrcweir 
2584cdf0e10cSrcweir 	// this ctor is used by StarBuilder to get the information for the whole workspace
2585cdf0e10cSrcweir 	while(  pSolarFiles->Count()) {
2586cdf0e10cSrcweir 		ByteString aString;
2587cdf0e10cSrcweir 		String ssFileName = *pSolarFiles->GetObject(( sal_uIntPtr ) 0 );
2588cdf0e10cSrcweir 		StarFile* pFile = ReadBuildlist(ssFileName, bReadComments, sal_False);
2589cdf0e10cSrcweir 		aMutex.acquire();
2590cdf0e10cSrcweir 		aLoadedFilesList.Insert( pFile,	LIST_APPEND );
2591cdf0e10cSrcweir 		aMutex.release();
2592cdf0e10cSrcweir 		delete pSolarFiles->Remove(( sal_uIntPtr ) 0 );
2593cdf0e10cSrcweir 	}
2594cdf0e10cSrcweir 	delete pSolarFiles;
2595cdf0e10cSrcweir 
2596cdf0e10cSrcweir 	Expand_Impl();
2597cdf0e10cSrcweir 	return 0;
2598cdf0e10cSrcweir }
2599cdf0e10cSrcweir 
2600cdf0e10cSrcweir /*****************************************************************************/
WritePrj(Prj * pPrj,SvFileStream & rStream)2601cdf0e10cSrcweir sal_uInt16 StarWriter::WritePrj( Prj *pPrj, SvFileStream& rStream )
2602cdf0e10cSrcweir /*****************************************************************************/
2603cdf0e10cSrcweir {
2604cdf0e10cSrcweir 	ByteString aDataString;
2605cdf0e10cSrcweir 	ByteString aTab('\t');
2606cdf0e10cSrcweir 	ByteString aSpace(' ');
2607cdf0e10cSrcweir 	ByteString aEmptyString("");
2608cdf0e10cSrcweir 	SByteStringList* pCmdDepList;
2609cdf0e10cSrcweir 	SByteStringList* pPrjDepList;
2610cdf0e10cSrcweir 
2611cdf0e10cSrcweir 	CommandData* pCmdData = NULL;
2612cdf0e10cSrcweir 	if ( pPrj->Count() > 0 )
2613cdf0e10cSrcweir 	{
2614cdf0e10cSrcweir 		pCmdData = pPrj->First();
2615cdf0e10cSrcweir 		if ( (pPrjDepList = pPrj->GetDependencies( sal_False )) )
2616cdf0e10cSrcweir 		{
2617cdf0e10cSrcweir 			aDataString = pPrj->GetPreFix();
2618cdf0e10cSrcweir 			aDataString += aTab;
2619cdf0e10cSrcweir 			aDataString += pPrj->GetProjectName();
2620cdf0e10cSrcweir 			aDataString += aTab;
2621cdf0e10cSrcweir 			if ( pPrj->HasFixedDependencies())
2622cdf0e10cSrcweir 				aDataString+= ByteString(":::");
2623cdf0e10cSrcweir 			else if ( pPrj->HasHardDependencies())
2624cdf0e10cSrcweir 				aDataString+= ByteString("::");
2625cdf0e10cSrcweir 			else
2626cdf0e10cSrcweir 				aDataString+= ByteString(":");
2627cdf0e10cSrcweir 			aDataString += aTab;
2628cdf0e10cSrcweir 			for ( sal_uInt16 i = 0; i< pPrjDepList->Count(); i++ ) {
2629cdf0e10cSrcweir 				aDataString += *pPrjDepList->GetObject( i );
2630cdf0e10cSrcweir 				aDataString += aSpace;
2631cdf0e10cSrcweir 			}
2632cdf0e10cSrcweir 			aDataString+= "NULL";
2633cdf0e10cSrcweir 
2634cdf0e10cSrcweir 			rStream.WriteLine( aDataString );
2635cdf0e10cSrcweir 
2636cdf0e10cSrcweir 			pCmdData = pPrj->Next();
2637cdf0e10cSrcweir 		}
2638cdf0e10cSrcweir 		if ( pCmdData ) {
2639cdf0e10cSrcweir 			do
2640cdf0e10cSrcweir 			{
2641cdf0e10cSrcweir 				if (( aDataString = pCmdData->GetComment()) == aEmptyString )
2642cdf0e10cSrcweir 				{
2643cdf0e10cSrcweir 					aDataString = pPrj->GetPreFix();
2644cdf0e10cSrcweir 					aDataString += aTab;
2645cdf0e10cSrcweir 
2646cdf0e10cSrcweir 					aDataString+= pCmdData->GetPath();
2647cdf0e10cSrcweir 					aDataString += aTab;
2648cdf0e10cSrcweir 					sal_uInt16 nPathLen = pCmdData->GetPath().Len();
2649cdf0e10cSrcweir 					if ( nPathLen < 40 )
2650cdf0e10cSrcweir 						for ( int i = 0; i < 9 - pCmdData->GetPath().Len() / 4 ; i++ )
2651cdf0e10cSrcweir 							aDataString += aTab;
2652cdf0e10cSrcweir 					else
2653cdf0e10cSrcweir 						for ( int i = 0; i < 12 - pCmdData->GetPath().Len() / 4 ; i++ )
2654cdf0e10cSrcweir 							aDataString += aTab;
2655cdf0e10cSrcweir 					aDataString += pCmdData->GetCommandTypeString();
2656cdf0e10cSrcweir 					aDataString += aTab;
2657cdf0e10cSrcweir 					if ( pCmdData->GetCommandType() == COMMAND_GET )
2658cdf0e10cSrcweir 						aDataString += aTab;
2659cdf0e10cSrcweir 					if ( pCmdData->GetCommandPara() == aEmptyString )
2660cdf0e10cSrcweir 						aDataString+= ByteString("-");
2661cdf0e10cSrcweir 					else
2662cdf0e10cSrcweir 						aDataString+= pCmdData->GetCommandPara();
2663cdf0e10cSrcweir 					aDataString += aTab;
2664cdf0e10cSrcweir 					aDataString+= pCmdData->GetOSTypeString();
2665cdf0e10cSrcweir 					if ( pCmdData->GetClientRestriction().Len()) {
2666cdf0e10cSrcweir 						aDataString += ByteString( "," );
2667cdf0e10cSrcweir 						aDataString += pCmdData->GetClientRestriction();
2668cdf0e10cSrcweir 					}
2669cdf0e10cSrcweir 					aDataString += aTab;
2670cdf0e10cSrcweir 					aDataString += pCmdData->GetLogFile();
2671cdf0e10cSrcweir 					aDataString += aSpace;
2672cdf0e10cSrcweir 
2673cdf0e10cSrcweir 					pCmdDepList = pCmdData->GetDependencies();
2674cdf0e10cSrcweir 					if ( pCmdDepList )
2675cdf0e10cSrcweir 						for ( sal_uInt16 i = 0; i< pCmdDepList->Count(); i++ ) {
2676cdf0e10cSrcweir 							aDataString += *pCmdDepList->GetObject( i );
2677cdf0e10cSrcweir 							aDataString += aSpace;
2678cdf0e10cSrcweir 					}
2679cdf0e10cSrcweir 					aDataString += "NULL";
2680cdf0e10cSrcweir 				}
2681cdf0e10cSrcweir 
2682cdf0e10cSrcweir 				rStream.WriteLine( aDataString );
2683cdf0e10cSrcweir 
2684cdf0e10cSrcweir 				pCmdData = pPrj->Next();
2685cdf0e10cSrcweir 			} while ( pCmdData );
2686cdf0e10cSrcweir 		}
2687cdf0e10cSrcweir 	}
2688cdf0e10cSrcweir 	return 0;
2689cdf0e10cSrcweir }
2690cdf0e10cSrcweir 
2691cdf0e10cSrcweir /*****************************************************************************/
Write(String aFileName)2692cdf0e10cSrcweir sal_uInt16 StarWriter::Write( String aFileName )
2693cdf0e10cSrcweir /*****************************************************************************/
2694cdf0e10cSrcweir {
2695cdf0e10cSrcweir 	sFileName = aFileName;
2696cdf0e10cSrcweir 
2697cdf0e10cSrcweir 	FileStat::SetReadOnlyFlag( DirEntry( aFileName ), sal_False );
2698cdf0e10cSrcweir 
2699cdf0e10cSrcweir 	SvFileStream aFileStream;
2700cdf0e10cSrcweir 
2701cdf0e10cSrcweir 	aFileStream.Open( aFileName, STREAM_WRITE | STREAM_TRUNC);
2702cdf0e10cSrcweir 	if ( !aFileStream.IsOpen() && aFileIOErrorHdl.IsSet()) {
2703cdf0e10cSrcweir 		String sError( String::CreateFromAscii( "Error: Unable to open \"" ));
2704cdf0e10cSrcweir 		sError += aFileName;
2705cdf0e10cSrcweir 		sError += String::CreateFromAscii( "for writing!" );
2706cdf0e10cSrcweir 		aFileIOErrorHdl.Call( &sError );
2707cdf0e10cSrcweir 	}
2708cdf0e10cSrcweir 
2709cdf0e10cSrcweir 	if ( Count() > 0 )
2710cdf0e10cSrcweir 	{
2711cdf0e10cSrcweir 		Prj* pPrj = First();
2712cdf0e10cSrcweir 		do
2713cdf0e10cSrcweir 		{
2714cdf0e10cSrcweir 			WritePrj( pPrj, aFileStream );
2715cdf0e10cSrcweir 			pPrj = Next();
2716cdf0e10cSrcweir 		} while ( pPrj );
2717cdf0e10cSrcweir 	}
2718cdf0e10cSrcweir 
2719cdf0e10cSrcweir 	aFileStream.Close();
2720cdf0e10cSrcweir 
2721cdf0e10cSrcweir 	return 0;
2722cdf0e10cSrcweir }
2723cdf0e10cSrcweir 
2724cdf0e10cSrcweir /*****************************************************************************/
WriteMultiple(String rSourceRoot)2725cdf0e10cSrcweir sal_uInt16 StarWriter::WriteMultiple( String rSourceRoot )
2726cdf0e10cSrcweir /*****************************************************************************/
2727cdf0e10cSrcweir {
2728cdf0e10cSrcweir 	sSourceRoot = rSourceRoot;
2729cdf0e10cSrcweir 
2730cdf0e10cSrcweir 	if ( Count() > 0 )
2731cdf0e10cSrcweir 	{
2732cdf0e10cSrcweir 		String sPrjDir( String::CreateFromAscii( "prj" ));
2733cdf0e10cSrcweir 		String sSolarFile( String::CreateFromAscii( "build.lst" ));
2734cdf0e10cSrcweir 
2735cdf0e10cSrcweir 		Prj* pPrj = First();
2736cdf0e10cSrcweir 		do
2737cdf0e10cSrcweir 		{
2738cdf0e10cSrcweir 			String sName( pPrj->GetProjectName(), RTL_TEXTENCODING_ASCII_US );
2739cdf0e10cSrcweir 
2740cdf0e10cSrcweir 			DirEntry aEntry( rSourceRoot );
2741cdf0e10cSrcweir 			aEntry += DirEntry( sName );
2742cdf0e10cSrcweir 			aEntry += DirEntry( sPrjDir );
2743cdf0e10cSrcweir 			aEntry += DirEntry( sSolarFile );
2744cdf0e10cSrcweir 
2745cdf0e10cSrcweir 			FileStat::SetReadOnlyFlag( aEntry, sal_False );
2746cdf0e10cSrcweir 
2747cdf0e10cSrcweir 			SvFileStream aFileStream;
2748cdf0e10cSrcweir 			aFileStream.Open( aEntry.GetFull(), STREAM_WRITE | STREAM_TRUNC);
2749cdf0e10cSrcweir 
2750cdf0e10cSrcweir 			if ( !aFileStream.IsOpen() && aFileIOErrorHdl.IsSet()) {
2751cdf0e10cSrcweir 				String sError( String::CreateFromAscii( "Error: Unable to open \"" ));
2752cdf0e10cSrcweir 				sError += aEntry.GetFull();
2753cdf0e10cSrcweir 				sError += String::CreateFromAscii( "for writing!" );
2754cdf0e10cSrcweir 				aFileIOErrorHdl.Call( &sError );
2755cdf0e10cSrcweir 			}
2756cdf0e10cSrcweir 
2757cdf0e10cSrcweir 	  		WritePrj( pPrj, aFileStream );
2758cdf0e10cSrcweir 
2759cdf0e10cSrcweir 			aFileStream.Close();
2760cdf0e10cSrcweir 
2761cdf0e10cSrcweir 			pPrj = Next();
2762cdf0e10cSrcweir 		} while ( pPrj );
2763cdf0e10cSrcweir 	}
2764cdf0e10cSrcweir 
2765cdf0e10cSrcweir 	return 0;
2766cdf0e10cSrcweir }
2767cdf0e10cSrcweir 
2768cdf0e10cSrcweir /*****************************************************************************/
InsertTokenLine(const ByteString & rTokenLine)2769cdf0e10cSrcweir void StarWriter::InsertTokenLine ( const ByteString& rTokenLine )
2770cdf0e10cSrcweir /*****************************************************************************/
2771cdf0e10cSrcweir {
2772cdf0e10cSrcweir 	ByteString sProjectName = rTokenLine.GetToken(1,'\t');
2773cdf0e10cSrcweir 	Prj* pPrj = GetPrj (sProjectName); // 0, if Prj not found;
2774cdf0e10cSrcweir 	Star::InsertTokenLine ( rTokenLine, &pPrj, sProjectName, sal_False );
2775cdf0e10cSrcweir }
2776cdf0e10cSrcweir 
2777cdf0e10cSrcweir /*****************************************************************************/
InsertProject(Prj *)2778cdf0e10cSrcweir sal_Bool StarWriter::InsertProject ( Prj* /*pNewPrj*/ )
2779cdf0e10cSrcweir /*****************************************************************************/
2780cdf0e10cSrcweir {
2781cdf0e10cSrcweir 	return sal_False;
2782cdf0e10cSrcweir }
2783cdf0e10cSrcweir 
2784cdf0e10cSrcweir /*****************************************************************************/
RemoveProject(ByteString aProjectName)2785cdf0e10cSrcweir Prj* StarWriter::RemoveProject ( ByteString aProjectName )
2786cdf0e10cSrcweir /*****************************************************************************/
2787cdf0e10cSrcweir {
2788cdf0e10cSrcweir 	sal_uIntPtr nCount_l = Count();
2789cdf0e10cSrcweir 	Prj* pPrj;
2790cdf0e10cSrcweir 	Prj* pPrjFound = NULL;
2791cdf0e10cSrcweir 	SByteStringList* pPrjDeps;
2792cdf0e10cSrcweir 
2793cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount_l; i++ )
2794cdf0e10cSrcweir 	{
2795cdf0e10cSrcweir 		pPrj = GetObject( i );
2796cdf0e10cSrcweir 		if ( pPrj->GetProjectName() == aProjectName )
2797cdf0e10cSrcweir 			pPrjFound = pPrj;
2798cdf0e10cSrcweir 		else
2799cdf0e10cSrcweir 		{
2800cdf0e10cSrcweir 			pPrjDeps = pPrj->GetDependencies( sal_False );
2801cdf0e10cSrcweir 			if ( pPrjDeps )
2802cdf0e10cSrcweir 			{
2803cdf0e10cSrcweir 				ByteString* pString;
2804cdf0e10cSrcweir 				sal_uIntPtr nPrjDepsCount = pPrjDeps->Count();
2805cdf0e10cSrcweir 				for ( sal_uIntPtr j = nPrjDepsCount; j > 0; j-- )
2806cdf0e10cSrcweir 				{
2807cdf0e10cSrcweir 					pString = pPrjDeps->GetObject( j - 1 );
2808cdf0e10cSrcweir 					if ( pString->GetToken( 0, '.') == aProjectName )
2809cdf0e10cSrcweir 						pPrjDeps->Remove( pString );
2810cdf0e10cSrcweir 				}
2811cdf0e10cSrcweir 			}
2812cdf0e10cSrcweir 		}
2813cdf0e10cSrcweir 	}
2814cdf0e10cSrcweir 
2815cdf0e10cSrcweir 	Remove( pPrjFound );
2816cdf0e10cSrcweir 
2817cdf0e10cSrcweir 	return pPrjFound;
2818cdf0e10cSrcweir }
2819cdf0e10cSrcweir 
2820cdf0e10cSrcweir //
2821cdf0e10cSrcweir // class StarFile
2822cdf0e10cSrcweir //
2823cdf0e10cSrcweir 
2824cdf0e10cSrcweir /*****************************************************************************/
StarFile(const String & rFile)2825cdf0e10cSrcweir StarFile::StarFile( const String &rFile )
2826cdf0e10cSrcweir /*****************************************************************************/
2827cdf0e10cSrcweir 				: aFileName( rFile )
2828cdf0e10cSrcweir {
2829cdf0e10cSrcweir 	DirEntry aEntry( aFileName );
2830cdf0e10cSrcweir 	if ( aEntry.Exists()) {
2831cdf0e10cSrcweir 		bExists = sal_True;
2832cdf0e10cSrcweir 		FileStat aStat( aEntry );
2833cdf0e10cSrcweir 		aDate = aStat.DateModified();
2834cdf0e10cSrcweir 		aTime = aStat.TimeModified();
2835cdf0e10cSrcweir 		aDateCreated = aStat.DateCreated();
2836cdf0e10cSrcweir 		aTimeCreated = aStat.TimeCreated();
2837cdf0e10cSrcweir 	}
2838cdf0e10cSrcweir 	else
2839cdf0e10cSrcweir 		bExists = sal_False;
2840cdf0e10cSrcweir }
2841cdf0e10cSrcweir 
2842cdf0e10cSrcweir /*****************************************************************************/
NeedsUpdate()2843cdf0e10cSrcweir sal_Bool StarFile::NeedsUpdate()
2844cdf0e10cSrcweir /*****************************************************************************/
2845cdf0e10cSrcweir {
2846cdf0e10cSrcweir 	DirEntry aEntry( aFileName );
2847cdf0e10cSrcweir 	if ( aEntry.Exists()) {
2848cdf0e10cSrcweir 		if ( !bExists ) {
2849cdf0e10cSrcweir 			bExists = sal_True;
2850cdf0e10cSrcweir 			return sal_True;
2851cdf0e10cSrcweir 		}
2852cdf0e10cSrcweir 		FileStat aStat( aEntry );
2853cdf0e10cSrcweir 		if (( aStat.DateModified() != aDate ) || ( aStat.TimeModified() != aTime )
2854cdf0e10cSrcweir 			|| ( aStat.DateCreated() != aDateCreated ) || ( aStat.TimeCreated() != aTimeCreated ))
2855cdf0e10cSrcweir 			return sal_True;
2856cdf0e10cSrcweir 	}
2857cdf0e10cSrcweir 	return sal_False;
2858cdf0e10cSrcweir }
2859