merged tag ooo/OOO330_m14
[LibreOffice.git] / soldep / bootstrp / prj.cxx
blobdfb29fe74754d0e3027869d6dac883230a91675d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <bootstrp/sstring.hxx>
30 #include <vos/mutex.hxx>
32 #define ENABLE_BYTESTRING_STREAM_OPERATORS
33 #include <tools/stream.hxx>
34 #include <tools/geninfo.hxx>
35 #include <soldep/prj.hxx>
36 #include <bootstrp/inimgr.hxx>
38 #ifndef MACOSX
39 #pragma hdrstop
40 #endif
42 //#define TEST 1
44 #ifdef MAC
45 #define putenv(x)
46 #endif
48 #if defined(DOS) || defined(WNT) || defined(OS2)
49 #define LIST_DELIMETER ';'
50 #else
51 #ifdef UNX
52 #define LIST_DELIMETER ':'
53 #else
54 #ifdef MAC
55 #define LIST_DELIMETER ','
56 #endif
57 #endif
58 #endif
60 #if defined(DOS) || defined(WNT) || defined(OS2) || defined(WIN)
61 #define PATH_DELIMETER '\\'
62 #else
63 #ifdef UNX
64 #define PATH_DELIMETER '/'
65 #else
66 #ifdef MAC
67 #define PATH_DELIMETER ':'
68 #endif
69 #endif
70 #endif
72 //static const char * XML_ALL = "all";
75 // class SimpleConfig
78 /*****************************************************************************/
79 SimpleConfig::SimpleConfig( String aSimpleConfigFileName )
80 /*****************************************************************************/
82 nLine = 0;
83 aFileName = aSimpleConfigFileName;
84 aFileStream.Open ( aFileName, STREAM_READ );
87 /*****************************************************************************/
88 SimpleConfig::SimpleConfig( DirEntry& rDirEntry )
89 /*****************************************************************************/
91 nLine = 0;
92 aFileName = rDirEntry.GetFull();
93 aFileStream.Open ( aFileName, STREAM_READ );
96 /*****************************************************************************/
97 SimpleConfig::~SimpleConfig()
98 /*****************************************************************************/
100 aFileStream.Close ();
103 /*****************************************************************************/
104 ByteString SimpleConfig::GetNext()
105 /*****************************************************************************/
107 ByteString aString;
109 if ( aStringBuffer =="" )
110 while ((aStringBuffer = GetNextLine()) == "\t"); //solange bis != "\t"
111 if ( aStringBuffer =="" )
112 return ByteString();
114 aString = aStringBuffer.GetToken(0,'\t');
115 aStringBuffer.Erase(0, aString.Len()+1);
117 aStringBuffer.EraseLeadingChars( '\t' );
119 return aString;
122 /*****************************************************************************/
123 ByteString SimpleConfig::GetNextLine()
124 /*****************************************************************************/
126 ByteString aSecStr;
127 sal_Bool bStreamOk;
128 // USHORT iret = 0;
129 nLine++;
131 bStreamOk = aFileStream.ReadLine ( aTmpStr );
132 if ( (aTmpStr.Search( "#" ) == 0) )
133 return "\t";
134 aTmpStr = aTmpStr.EraseLeadingChars();
135 aTmpStr = aTmpStr.EraseTrailingChars();
136 while ( aTmpStr.SearchAndReplace(ByteString(' '),ByteString('\t') ) != STRING_NOTFOUND );
137 int nLength = aTmpStr.Len();
138 if ( bStreamOk && (nLength == 0) )
139 return "\t";
140 // USHORT nPos = 0;
141 BOOL bFound = FALSE;
142 ByteString aEraseString;
143 for ( USHORT i = 0; i<= nLength; i++)
145 #ifdef MAC
146 if ( aTmpStr.GetChar( i ) == '"')
148 if ( bFound) bFound = FALSE;
149 else bFound = TRUE;
150 aTmpStr.SetChar( i, '\t' );
152 #endif
153 if ( aTmpStr.GetChar( i ) == 0x20 && !bFound )
154 aTmpStr.SetChar( i, 0x09 );
156 return aTmpStr;
159 /*****************************************************************************/
160 ByteString SimpleConfig::GetCleanedNextLine( BOOL bReadComments )
161 /*****************************************************************************/
163 sal_Bool bStreamOk;
164 sal_Bool bReadNextLine = sal_True;
165 while (bReadNextLine)
167 bStreamOk = aFileStream.ReadLine ( aTmpStr );
168 if (!bStreamOk)
169 return ByteString();
171 ByteString sTab = "\t";
172 ByteString sDoubleTab = "\t\t";
173 ByteString sSpace = " ";
174 xub_StrLen nIndex = 0;
176 aTmpStr.SearchAndReplaceAll(sSpace, sTab);
177 while ( (nIndex = aTmpStr.SearchAndReplace(sDoubleTab, sTab, nIndex )) != STRING_NOTFOUND );
179 aTmpStr = aTmpStr.EraseLeadingAndTrailingChars('\t'); // remove tabs
181 if ( aTmpStr.Search( "#" ) == 0 )
183 if (bReadComments )
184 return aTmpStr;
186 else if (aTmpStr != ByteString::EmptyString())
187 bReadNextLine = sal_False;
190 return aTmpStr;
195 // class CommandData
198 /*****************************************************************************/
199 CommandData::CommandData()
200 /*****************************************************************************/
202 nOSType = 0;
203 nCommand = 0;
204 pDepList = 0;
205 pCommandList = 0;
208 /*****************************************************************************/
209 CommandData::~CommandData()
210 /*****************************************************************************/
212 if ( pDepList )
214 ByteString *pString = pDepList->First();
215 while ( pString )
217 delete pString;
218 pString = pDepList->Next();
220 delete pDepList;
222 pDepList = NULL;
224 if ( pCommandList )
226 ByteString *pString = pCommandList->First();
227 while ( pString )
229 delete pString;
230 pString = pCommandList->Next();
232 delete pCommandList;
234 pCommandList = NULL;
238 /*****************************************************************************/
239 ByteString CommandData::GetOSTypeString()
240 /*****************************************************************************/
242 ByteString aRetStr;
244 switch (nOSType)
246 case OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX | OS_MAC :
247 aRetStr = "all";
248 break;
249 case OS_WIN32 | OS_WIN16 :
250 aRetStr = "w";
251 break;
252 case OS_OS2 :
253 aRetStr = "p";
254 break;
255 case OS_UNX :
256 aRetStr = "u";
257 break;
258 case OS_WIN16 :
259 aRetStr = "d";
260 break;
261 case OS_WIN32 :
262 aRetStr = "n";
263 break;
264 case OS_MAC :
265 aRetStr = "m";
266 break;
267 default :
268 aRetStr = "none";
271 return aRetStr;
274 /*****************************************************************************/
275 ByteString CommandData::GetCommandTypeString()
276 /*****************************************************************************/
278 ByteString aRetStr;
280 switch (nCommand)
282 case COMMAND_NMAKE :
283 aRetStr = "nmake";
284 break;
285 case COMMAND_GET :
286 aRetStr = "get";
287 break;
288 default :
289 aRetStr = "usr";
290 aRetStr += ByteString::CreateFromInt64( nCommand + 1 - COMMAND_USER_START );
294 return aRetStr;
297 /*****************************************************************************/
298 void CommandData::AddCommand(ByteString* pCommand)
299 /*****************************************************************************/
301 if (!pCommandList)
302 pCommandList = new SByteStringList();
303 pCommandList->Insert(pCommand, LIST_APPEND);
306 /*****************************************************************************/
307 CommandData& CommandData::operator>> ( SvStream& rStream )
308 /*****************************************************************************/
310 rStream << aPrj;
311 rStream << aLogFileName;
312 rStream << aInpath;
313 rStream << aUpd;
314 rStream << aUpdMinor;
315 rStream << aProduct;
316 rStream << aCommand;
317 rStream << aPath;
318 rStream << aPrePath;
319 rStream << aPreFix;
320 rStream << aCommandPara;
321 rStream << aComment;
322 rStream << sClientRestriction;
324 rStream << nOSType;
325 rStream << nCommand;
326 rStream << nDepth;
328 if (pDepList)
330 rStream << sal_True;
331 *pDepList >> rStream;
333 else
334 rStream << sal_False;
336 if (pCommandList)
338 rStream << sal_True;
339 *pCommandList >> rStream;
341 else
342 rStream << sal_False;
344 return *this;
347 /*****************************************************************************/
348 CommandData& CommandData::operator<< ( SvStream& rStream )
349 /*****************************************************************************/
351 rStream >> aPrj;
352 rStream >> aLogFileName;
353 rStream >> aInpath;
354 rStream >> aUpd;
355 rStream >> aUpdMinor;
356 rStream >> aProduct;
357 rStream >> aCommand;
358 rStream >> aPath;
359 rStream >> aPrePath;
360 rStream >> aPreFix;
361 rStream >> aCommandPara;
362 rStream >> aComment;
363 rStream >> sClientRestriction;
365 rStream >> nOSType;
366 rStream >> nCommand;
367 rStream >> nDepth;
369 BOOL bDepList;
370 rStream >> bDepList;
371 if (pDepList)
372 pDepList->CleanUp();
373 if (bDepList)
375 if (!pDepList)
376 pDepList = new SByteStringList();
377 *pDepList << rStream;
379 else
381 if (pDepList)
382 DELETEZ (pDepList);
385 BOOL bCommandList;
386 rStream >> bCommandList;
387 if (pCommandList)
388 pCommandList->CleanUp();
389 if (bCommandList)
391 if (!pCommandList)
392 pCommandList = new SByteStringList();
393 *pCommandList << rStream;
395 else
397 if (pCommandList)
398 DELETEZ (pCommandList);
401 return *this;
407 // class DepInfo
410 /*****************************************************************************/
411 DepInfo::~DepInfo()
412 /*****************************************************************************/
414 RemoveProject();
416 if ( pModeList )
418 ByteString *pString = pModeList->First();
419 while ( pString )
421 delete pString;
422 pString = pModeList->Next();
424 delete pModeList;
426 pModeList = NULL;
430 /*****************************************************************************/
431 void DepInfo::SetProject (ByteString* pStr)
432 /*****************************************************************************/
434 RemoveProject();
435 pProject = pStr;
438 /*****************************************************************************/
439 void DepInfo::RemoveProject ()
440 /*****************************************************************************/
442 if (pProject)
444 delete pProject;
445 pProject = NULL;
449 /*****************************************************************************/
450 DepInfo& DepInfo::operator<< ( SvStream& rStream )
451 /*****************************************************************************/
453 RemoveProject();
454 pProject = new ByteString();
455 rStream >> *pProject;
457 BOOL bModeList;
458 rStream >> bModeList;
459 if (pModeList)
460 pModeList->CleanUp();
461 if (bModeList)
463 if (!pModeList)
464 pModeList = new SByteStringList();
465 *pModeList << rStream;
467 else
468 DELETEZ (pModeList);
470 rStream >> bAllModes;
471 return *this;
474 /*****************************************************************************/
475 DepInfo& DepInfo::operator>> ( SvStream& rStream )
476 /*****************************************************************************/
478 rStream << *pProject;
479 if (pModeList)
481 rStream << sal_True;
482 *pModeList >> rStream;
484 else
485 rStream << sal_False;
486 rStream << bAllModes;
488 return *this;
492 // class SDepInfoList
495 /*****************************************************************************/
496 SDepInfoList::SDepInfoList()
497 /*****************************************************************************/
498 : pAllModeList(0)
502 /*****************************************************************************/
503 SDepInfoList::~SDepInfoList()
504 /*****************************************************************************/
506 if (pAllModeList)
507 delete pAllModeList;
510 /*****************************************************************************/
511 ULONG SDepInfoList::IsString( ByteString* pStr )
512 /*****************************************************************************/
514 ULONG nRet = NOT_THERE;
515 if ( (nRet = GetPrevString( pStr )) != 0 )
517 ByteString* pString = GetObject( nRet )->GetProject();
518 if ( *pString == *pStr )
519 return nRet;
520 else
521 return NOT_THERE;
523 else
525 ByteString* pString = GetObject( 0 )->GetProject();
526 if ( pString && (*pString == *pStr) )
527 return 0;
528 else
529 return NOT_THERE;
531 return nRet;
534 /*****************************************************************************/
535 ULONG SDepInfoList::GetPrevString( ByteString* pStr )
536 /*****************************************************************************/
538 ULONG nRet = 0;
539 BOOL bFound = FALSE;
540 ULONG nCount_l = Count();
541 ULONG nUpper = nCount_l;
542 ULONG nLower = 0;
543 ULONG nCurrent = nUpper / 2;
544 ULONG nRem = 0;
545 ByteString* pString;
549 if ( (nCurrent == nLower) || (nCurrent == nUpper) )
550 return nLower;
551 pString = GetObject( nCurrent )->GetProject();
552 int nResult = pStr->CompareTo( *pString );
553 if ( nResult == COMPARE_LESS )
555 nUpper = nCurrent;
556 nCurrent = (nCurrent + nLower) /2;
558 else if ( nResult == COMPARE_GREATER )
560 nLower = nCurrent;
561 nCurrent = (nUpper + nCurrent) /2;
563 else if ( nResult == COMPARE_EQUAL )
564 return nCurrent;
565 if ( nRem == nCurrent )
566 return nCurrent;
567 nRem = nCurrent;
569 while ( !bFound );
570 return nRet;
573 /*****************************************************************************/
574 void SDepInfoList::PutModeString( DepInfo* pInfoList, ByteString* pStr )
575 /*****************************************************************************/
577 SByteStringList* pList = pInfoList->GetModeList();
578 if (!pList)
580 pList = new SByteStringList;
581 pInfoList->SetModeList(pList);
585 if (pList)
587 // check if string exists
588 ByteString *pString = pList->First();
589 while ( pString )
591 if (*pString == *pStr)
593 delete pStr;
594 return;
596 pString = pList->Next();
598 pList->PutString( pStr );
600 else
601 delete pStr;
604 /*****************************************************************************/
605 ULONG SDepInfoList::PutString( ByteString* pStr)
606 /*****************************************************************************/
608 return PutString( pStr, NULL);
611 /**************************************************************************
613 * Sortiert einen ByteString in die Liste ein und gibt die Position,
614 * an der einsortiert wurde, zurueck
616 **************************************************************************/
618 ULONG SDepInfoList::PutString( ByteString* pStr, ByteString* pModeStr)
620 if (pAllModeList)
622 delete pAllModeList;
623 pAllModeList = NULL;
626 ULONG nPos = GetPrevString ( pStr );
627 if ( Count() )
630 DepInfo* pInfo = GetObject( 0 );
631 ByteString* pString = pInfo->GetProject();
632 if ( pString->CompareTo( *pStr ) == COMPARE_GREATER )
634 pInfo = new DepInfo;
635 if (pInfo)
637 pInfo->SetProject(pStr);
638 if (pModeStr)
639 PutModeString(pInfo, pModeStr);
640 else
641 pInfo->SetAllModes();
642 Insert( pInfo, (ULONG)0 );
644 return (ULONG)0;
647 ByteString* pString = GetObject( nPos )->GetProject();
648 if ( *pStr != *pString )
650 DepInfo* pInfo = new DepInfo;
651 if (pInfo)
653 pInfo->SetProject(pStr);
654 if (pModeStr)
655 PutModeString(pInfo, pModeStr);
656 else
657 pInfo->SetAllModes();
658 Insert( pInfo, nPos+1 );
660 return ( nPos +1 );
662 else
664 delete pStr;
665 DepInfo* pInfo = GetObject( nPos );
666 if (pModeStr)
667 PutModeString(pInfo, pModeStr);
668 else
669 pInfo->SetAllModes();
670 return ( nPos +1 );
673 else
675 DepInfo* pInfo = new DepInfo;
676 if (pInfo)
678 pInfo->SetProject(pStr);
679 if (pModeStr)
680 PutModeString(pInfo, pModeStr);
681 else
682 pInfo->SetAllModes();
683 Insert( pInfo);
684 return (ULONG)0;
688 delete pStr;
689 if (pModeStr)
690 delete pModeStr;
691 return NOT_THERE;
694 /*****************************************************************************/
695 ByteString* SDepInfoList::RemoveString( const ByteString& rName )
696 /*****************************************************************************/
698 ULONG i;
699 ByteString* pReturn;
700 if (pAllModeList)
702 delete pAllModeList;
703 pAllModeList = NULL;
706 for( i = 0 ; i < Count(); i++ )
708 if ( rName == *(GetObject( i )->GetProject()) )
710 pReturn = new ByteString(*(GetObject(i)->GetProject()));
711 DepInfo* pInfo;
712 pInfo = GetObject(i);
713 delete pInfo;
714 Remove(i);
715 return pReturn;
719 return NULL;
722 /*****************************************************************************/
723 SByteStringList* SDepInfoList::GetAllDepModes()
724 /*****************************************************************************/
726 if (pAllModeList)
727 return pAllModeList;
729 DepInfo *pInfo = First();
730 while ( pInfo )
732 if (!pInfo->IsAllModes() && pInfo->GetModeList())
734 if (!pAllModeList)
735 pAllModeList = new SByteStringList();
736 ByteString* pStr = pInfo->GetModeList()->First();
737 while (pStr)
739 if (pAllModeList->IsString(pStr) == NOT_THERE)
740 pAllModeList->PutString(pStr);
741 pStr = pInfo->GetModeList()->Next();
744 pInfo = Next();
746 return pAllModeList;
749 /*****************************************************************************/
750 SDepInfoList& SDepInfoList::operator<< ( SvStream& rStream )
751 /*****************************************************************************/
753 ULONG nCount_l;
754 rStream >> nCount_l;
755 for ( USHORT i = 0; i < nCount_l; i++ ) {
756 DepInfo* pDepInfo = new DepInfo();
757 *pDepInfo << rStream;
758 Insert (pDepInfo, LIST_APPEND);
760 return *this;
763 /*****************************************************************************/
764 SDepInfoList& SDepInfoList::operator>> ( SvStream& rStream )
765 /*****************************************************************************/
767 ULONG nCount_l = Count();
768 rStream << nCount_l;
769 DepInfo* pDepInfo = First();
770 while (pDepInfo) {
771 *pDepInfo >> rStream;
772 pDepInfo = Next();
775 return *this;
778 /*****************************************************************************/
779 CommandData* Prj::GetDirectoryList ( USHORT nWhatOS, USHORT nCommand )
780 /*****************************************************************************/
782 return (CommandData *)NULL;
785 /*****************************************************************************/
786 CommandData* Prj::GetDirectoryData( ByteString aLogFileName )
787 /*****************************************************************************/
789 PrjList* pPrjList = GetCommandDataList ();
790 CommandData *pData = NULL;
791 ULONG nCount_l = pPrjList->Count();
792 for ( ULONG i=0; i<nCount_l; i++ )
794 pData = pPrjList->GetObject(i);
795 if ( pData->GetLogFile() == aLogFileName )
796 return pData;
798 return NULL;
802 // class Prj
805 /*****************************************************************************/
806 Prj::Prj() :
807 pPrjInitialDepList(0),
808 pPrjDepList(0),
809 pPrjDepInfoList(0),
810 bSorted( FALSE ),
811 bHardDependencies( FALSE ),
812 bFixedDependencies( FALSE ),
813 bVisited( FALSE ),
814 bIsAvailable( TRUE ),
815 pTempCommandDataList (0),
816 bTempCommandDataListPermanent (FALSE),
817 bError (FALSE)
818 /*****************************************************************************/
822 /*****************************************************************************/
823 Prj::Prj( ByteString aName ) :
824 aProjectName( aName ),
825 pPrjInitialDepList(0),
826 pPrjDepList(0),
827 pPrjDepInfoList(0),
828 bSorted( FALSE ),
829 bHardDependencies( FALSE ),
830 bFixedDependencies( FALSE ),
831 bVisited( FALSE ),
832 bIsAvailable( TRUE ),
833 pTempCommandDataList (0),
834 bTempCommandDataListPermanent (FALSE),
835 bError (FALSE)
836 /*****************************************************************************/
840 /*****************************************************************************/
841 Prj::~Prj()
842 /*****************************************************************************/
844 pPrjDepList = RemoveStringList (pPrjDepList);
845 pPrjInitialDepList = RemoveStringList (pPrjInitialDepList);
846 pPrjDepInfoList = RemoveDepInfoList (pPrjDepInfoList);
849 /*****************************************************************************/
850 SByteStringList* Prj::RemoveStringList(SByteStringList* pStringList )
851 /*****************************************************************************/
853 if ( pStringList )
855 ByteString *pString = pStringList->First();
856 while ( pString )
858 delete pString;
859 pString = pStringList->Next();
862 delete pStringList;
864 pStringList = NULL;
866 return pStringList;
869 /*****************************************************************************/
870 SDepInfoList* Prj::RemoveDepInfoList(SDepInfoList* pInfoList )
871 /*****************************************************************************/
873 if ( pInfoList )
875 DepInfo *pInfo = pInfoList->First();
876 while ( pInfo )
878 delete pInfo;
879 pInfo = pInfoList->Next();
882 delete pInfoList;
884 pInfoList = NULL;
886 return pInfoList;
889 /*****************************************************************************/
890 void Prj::AddDependencies( ByteString aStr )
891 /*****************************************************************************/
894 if ( !pPrjDepInfoList )
895 pPrjDepInfoList = new SDepInfoList;
897 pPrjDepInfoList->PutString( new ByteString(aStr) );
900 /*****************************************************************************/
901 void Prj::AddDependencies( ByteString aStr, ByteString aModeStr )
902 /*****************************************************************************/
905 // needs dirty flag - not expanded
906 if ( !pPrjDepInfoList )
907 pPrjDepInfoList = new SDepInfoList;
909 pPrjDepInfoList->PutString( new ByteString(aStr), new ByteString(aModeStr) );
912 /*****************************************************************************/
913 SByteStringList* Prj::GetDependencies( BOOL bExpanded )
914 /*****************************************************************************/
916 if ( bExpanded )
918 if (!pPrjDepList)
919 SetMode (NULL);
920 return pPrjDepList;
922 else
924 if (!pPrjInitialDepList)
925 SetMode (NULL);
926 return pPrjInitialDepList;
930 /*****************************************************************************/
931 void Prj::SetMode(SByteStringList* pModList)
932 /*****************************************************************************/
934 pPrjDepList = RemoveStringList (pPrjDepList);
935 pPrjInitialDepList = RemoveStringList (pPrjInitialDepList);
937 if (!pPrjDepInfoList)
938 return;
940 pPrjDepList = new SByteStringList;
941 pPrjInitialDepList = new SByteStringList;
943 DepInfo *pInfo = pPrjDepInfoList->First();
944 while ( pInfo )
946 if (pInfo->IsAllModes() || !pInfo->GetModeList() || !pModList)
948 pPrjDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
949 pPrjInitialDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
950 //pPrjDepList->PutString( pInfo->GetProject());
951 //pPrjInitialDepList->PutString( pInfo->GetProject());
953 else
955 BOOL bStringFound = FALSE;
956 SByteStringList * pDepList = pInfo->GetModeList();
957 ByteString *pModString = pDepList->First();
958 while ( pModString )
960 ByteString *pDefModString = pModList->First();
961 while ( pDefModString )
963 if (*pDefModString == *pModString)
965 pPrjDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
966 pPrjInitialDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
967 //pPrjDepList->PutString( pInfo->GetProject());
968 //pPrjInitialDepList->PutString( pInfo->GetProject());
969 bStringFound = TRUE;
970 break;
972 pDefModString = pModList->Next();
974 if (bStringFound)
975 break;
976 pModString = pDepList->Next();
981 pInfo = pPrjDepInfoList->Next();
985 /*****************************************************************************/
986 BOOL Prj::InsertDirectory ( ByteString aDirName, USHORT aWhat,
987 USHORT aWhatOS, ByteString aLogFileName,
988 const ByteString &rClientRestriction )
989 /*****************************************************************************/
991 CommandData* pData = new CommandData();
993 pData->SetPath( aDirName );
994 pData->SetCommandType( aWhat );
995 pData->SetOSType( aWhatOS );
996 pData->SetLogFile( aLogFileName );
997 pData->SetClientRestriction( rClientRestriction );
999 PrjList* pPrjList = GetCommandDataList ();
1000 pPrjList->Insert( pData );
1002 return FALSE;
1005 /*****************************************************************************/
1007 // removes directory and existing dependencies on it
1009 CommandData* Prj::RemoveDirectory ( ByteString aLogFileName )
1010 /*****************************************************************************/
1012 PrjList* pPrjList = GetCommandDataList ();
1013 ULONG nCount_l = pPrjList->Count();
1014 CommandData* pData;
1015 CommandData* pDataFound = NULL;
1016 SByteStringList* pDataDeps;
1018 for ( USHORT i = 0; i < nCount_l; i++ )
1020 pData = pPrjList->GetObject( i );
1021 if ( pData->GetLogFile() == aLogFileName )
1022 pDataFound = pData;
1023 else
1025 pDataDeps = pData->GetDependencies();
1026 if ( pDataDeps )
1028 ByteString* pString;
1029 ULONG nDataDepsCount = pDataDeps->Count();
1030 for ( ULONG j = nDataDepsCount; j > 0; j-- )
1032 pString = pDataDeps->GetObject( j - 1 );
1033 if ( pString->GetToken( 0, '.') == aLogFileName )
1034 pDataDeps->Remove( pString );
1040 Remove( pDataFound );
1042 return pDataFound;
1045 /*****************************************************************************/
1046 void Prj::ExtractDependencies()
1047 /*****************************************************************************/
1049 ULONG nPos = 0;
1050 CommandData* pData = GetObject(nPos);
1051 while (pData)
1053 SByteStringList* pDepList = pData->GetDependencies();
1054 if (pDepList)
1056 ByteString * pDepStr = pDepList->First();
1057 while (pDepStr)
1059 CommandData* pSearchData = First();
1060 while (pSearchData)
1062 if ((*pDepStr == pSearchData->GetPath()) && (pData->GetOSType() & pSearchData->GetOSType()))
1064 *pDepStr = pSearchData->GetLogFile();
1065 break;
1068 pSearchData = Next();
1071 pDepStr = pDepList->Next();
1074 nPos ++;
1075 pData = GetObject(nPos);
1079 /*****************************************************************************/
1080 PrjList* Prj::GetCommandDataList ()
1081 /*****************************************************************************/
1083 if (pTempCommandDataList)
1084 return pTempCommandDataList;
1085 else
1086 return (PrjList*)this;
1089 /*****************************************************************************/
1090 void Prj::RemoveTempCommandDataList()
1091 /*****************************************************************************/
1093 if (pTempCommandDataList)
1095 delete pTempCommandDataList; // this list remove the elements by itself
1096 pTempCommandDataList = NULL;
1100 /*****************************************************************************/
1101 void Prj::GenerateTempCommandDataList()
1102 /*****************************************************************************/
1104 if (pTempCommandDataList)
1105 RemoveTempCommandDataList();
1106 pTempCommandDataList = new PrjList();
1107 CommandData* pCommandData = First();
1108 while (pCommandData) {
1109 SvMemoryStream* pStream = new SvMemoryStream();
1110 *pCommandData >> *pStream;
1111 CommandData* pNewCommandData = new CommandData();
1112 pStream->Seek( STREAM_SEEK_TO_BEGIN );
1113 *pNewCommandData << *pStream;
1114 pTempCommandDataList->Insert(pNewCommandData, LIST_APPEND);
1115 delete pStream;
1116 pCommandData = Next();
1120 /*****************************************************************************/
1121 void Prj::GenerateEmptyTempCommandDataList()
1122 /*****************************************************************************/
1124 if (pTempCommandDataList)
1125 RemoveTempCommandDataList();
1126 pTempCommandDataList = new PrjList();
1129 /*****************************************************************************/
1130 Prj& Prj::operator>> ( SvStream& rStream )
1131 /*****************************************************************************/
1133 rStream << bVisited;
1134 rStream << aProjectName;
1135 rStream << aProjectPrefix;
1136 rStream << bHardDependencies;
1137 rStream << bFixedDependencies;
1138 rStream << bSorted;
1139 rStream << bIsAvailable;
1140 rStream << bError;
1142 if (pPrjDepInfoList)
1144 rStream << sal_True;
1145 *pPrjDepInfoList >> rStream;
1147 else
1148 rStream << sal_False;
1150 ULONG nCount_l = Count();
1151 rStream << nCount_l;
1153 CommandData* pData = First();
1154 while (pData) {
1155 *pData >> rStream;
1156 pData = Next();
1159 return *this;
1162 /*****************************************************************************/
1163 Prj& Prj::operator<< ( SvStream& rStream )
1164 /*****************************************************************************/
1166 rStream >> bVisited;
1167 rStream >> aProjectName;
1168 rStream >> aProjectPrefix;
1169 rStream >> bHardDependencies;
1170 rStream >> bFixedDependencies;
1171 rStream >> bSorted;
1172 rStream >> bIsAvailable;
1173 rStream >> bError;
1175 BOOL bDepList;
1176 rStream >> bDepList;
1177 DELETEZ (pPrjDepInfoList);
1178 if (bDepList)
1180 pPrjDepInfoList = new SDepInfoList();
1181 *pPrjDepInfoList << rStream;
1184 ULONG nCount_l;
1185 rStream >> nCount_l;
1187 for ( USHORT i = 0; i < nCount_l; i++ ) {
1188 CommandData* pData = new CommandData();
1189 *pData << rStream;
1190 Insert (pData, LIST_APPEND);
1193 return *this;
1198 // class Star
1201 /*****************************************************************************/
1202 Star::Star()
1203 /*****************************************************************************/
1204 : pDepMode (NULL),
1205 pAllDepMode (NULL)
1207 // this ctor is only used by StarWriter
1210 /*****************************************************************************/
1211 Star::Star(String aFileName, USHORT nMode )
1212 /*****************************************************************************/
1213 : nStarMode( nMode ),
1214 sFileName( aFileName ),
1215 pDepMode (NULL),
1216 pAllDepMode (NULL)
1218 Read( aFileName );
1221 /*****************************************************************************/
1222 Star::Star(SolarFileList *pSolarFiles )
1223 /*****************************************************************************/
1224 : nStarMode( STAR_MODE_MULTIPLE_PARSE ),
1225 pDepMode (NULL),
1226 pAllDepMode (NULL)
1228 // this ctor is used by StarBuilder to get the information for the whole workspace
1229 Read( pSolarFiles );
1232 /*****************************************************************************/
1233 Star::Star(GenericInformationList *pStandLst, ByteString &rVersion,
1234 BOOL bLocal, const char *pSourceRoot )
1235 /*****************************************************************************/
1236 : pDepMode (NULL),
1237 pAllDepMode (NULL)
1239 UpdateFileList (pStandLst, rVersion, TRUE, bLocal, pSourceRoot);
1242 /*****************************************************************************/
1243 void Star::UpdateFileList( GenericInformationList *pStandLst, ByteString &rVersion,
1244 BOOL bRead, BOOL bLocal, const char *pSourceRoot )
1245 /*****************************************************************************/
1247 sSourceRoot=String::CreateFromAscii(""); // clear old SourceRoot
1248 ByteString sPath( rVersion );
1249 if ( pSourceRoot )
1250 sSourceRoot = String::CreateFromAscii( pSourceRoot );
1252 #ifdef UNX
1253 sPath += "/settings/UNXSOLARLIST";
1254 #else
1255 sPath += "/settings/SOLARLIST";
1256 #endif
1257 GenericInformation *pInfo = pStandLst->GetInfo( sPath, TRUE );
1259 if( pInfo && pInfo->GetValue().Len()) {
1260 ByteString sFile( pInfo->GetValue());
1261 if ( bLocal ) {
1262 IniManager aIniManager;
1263 aIniManager.ToLocal( sFile );
1265 String sFileName_l( sFile, RTL_TEXTENCODING_ASCII_US );
1266 nStarMode = STAR_MODE_SINGLE_PARSE;
1267 if (bRead)
1268 Read( sFileName_l );
1270 else {
1271 SolarFileList *pFileList = new SolarFileList();
1273 sPath = rVersion;
1274 sPath += "/drives";
1276 GenericInformation *pInfo_l = pStandLst->GetInfo( sPath, TRUE );
1277 if ( pInfo_l && pInfo_l->GetSubList()) {
1278 GenericInformationList *pDrives = pInfo_l->GetSubList();
1279 for ( ULONG i = 0; i < pDrives->Count(); i++ ) {
1280 GenericInformation *pDrive = pDrives->GetObject( i );
1281 if ( pDrive ) {
1282 DirEntry aEntry;
1283 BOOL bOk = FALSE;
1284 if ( sSourceRoot.Len()) {
1285 aEntry = DirEntry( sSourceRoot );
1286 bOk = TRUE;
1288 else {
1289 #ifdef UNX
1290 sPath = "UnixVolume";
1291 GenericInformation *pUnixVolume = pDrive->GetSubInfo( sPath );
1292 if ( pUnixVolume ) {
1293 String sRoot( pUnixVolume->GetValue(), RTL_TEXTENCODING_ASCII_US );
1294 aEntry = DirEntry( sRoot );
1295 bOk = TRUE;
1297 #else
1298 bOk = TRUE;
1299 String sRoot( *pDrive, RTL_TEXTENCODING_ASCII_US );
1300 sRoot += String::CreateFromAscii( "\\" );
1301 aEntry = DirEntry( sRoot );
1302 #endif
1304 if ( bOk ) {
1305 sPath = "projects";
1306 GenericInformation *pProjectsKey = pDrive->GetSubInfo( sPath, TRUE );
1307 if ( pProjectsKey ) {
1308 if ( !sSourceRoot.Len()) {
1309 sPath = rVersion;
1310 sPath += "/settings/PATH";
1311 GenericInformation *pPath = pStandLst->GetInfo( sPath, TRUE );
1312 if( pPath ) {
1313 ByteString sAddPath( pPath->GetValue());
1314 #ifdef UNX
1315 sAddPath.SearchAndReplaceAll( "\\", "/" );
1316 #else
1317 sAddPath.SearchAndReplaceAll( "/", "\\" );
1318 #endif
1319 String ssAddPath( sAddPath, RTL_TEXTENCODING_ASCII_US );
1320 aEntry += DirEntry( ssAddPath );
1323 sPath = rVersion;
1324 sPath += "/settings/SHORTPATH";
1325 GenericInformation *pShortPath = pStandLst->GetInfo( sPath, TRUE );
1326 BOOL bShortPath = FALSE;
1327 if (pShortPath && (pShortPath->GetValue() == "_TRUE"))
1328 bShortPath = TRUE;
1329 sSourceRoot = aEntry.GetFull();
1330 GenericInformationList *pProjects = pProjectsKey->GetSubList();
1331 if ( pProjects ) {
1332 GenericInformation * pProject = pProjects->First();
1333 while (pProject) {
1334 String sLocalSourceRoot = sSourceRoot;
1335 ByteString sProject( *pProject );
1336 String ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
1338 ByteString aDirStr ("Directory");
1339 GenericInformation * pDir = pProject->GetSubInfo (aDirStr);
1340 if (pDir) {
1341 ByteString aDir = pDir->GetValue();
1342 DirEntry aRootEntry;
1343 if (bShortPath)
1344 aRootEntry = aEntry + DirEntry(aDir);
1345 else
1346 aRootEntry = aEntry.GetPath() + DirEntry(aDir);
1347 sLocalSourceRoot = aRootEntry.GetFull();
1350 String aBuildListPath = CreateFileName(ssProject, sLocalSourceRoot);
1352 pFileList->Insert( new String( aBuildListPath ), LIST_APPEND );
1353 ByteString sFile( aBuildListPath, RTL_TEXTENCODING_ASCII_US );
1354 pProject = pProjects->Next();
1363 if (!CheckFileLoadList(pFileList))
1365 ClearAvailableDeps();
1366 ClearCurrentDeps();
1367 ClearLoadedFilesList();
1368 RemoveAllPrj();
1369 bRead = TRUE; // read new list because old list is deleted
1372 if (bRead)
1373 Read( pFileList );
1374 else
1375 GenerateFileLoadList( pFileList );
1379 /*****************************************************************************/
1380 void Star::FullReload( GenericInformationList *pStandLst, ByteString &rVersion,
1381 BOOL bRead, BOOL bLocal, const char *pSourceRoot )
1382 /*****************************************************************************/
1384 ClearAvailableDeps();
1385 ClearCurrentDeps();
1386 ClearLoadedFilesList();
1387 RemoveAllPrj();
1388 UpdateFileList( pStandLst, rVersion, bRead, bLocal, pSourceRoot );
1391 /*****************************************************************************/
1392 BOOL Star::CheckFileLoadList(SolarFileList *pSolarFiles)
1393 /*****************************************************************************/
1395 BOOL bRet = TRUE;
1396 if (aLoadedFilesList.Count() == 0)
1397 return bRet;
1398 StarFile * pLoadFile = aLoadedFilesList.First();
1399 while (pLoadFile)
1401 BOOL bIsAvailable = FALSE;
1402 String * pFile = pSolarFiles->First();
1403 while (pFile)
1405 if (*pFile == pLoadFile->GetName())
1407 bIsAvailable = TRUE;
1408 break;
1410 pFile = pSolarFiles->Next();
1412 if (!bIsAvailable)
1414 bRet = FALSE;
1415 break;
1417 pLoadFile = aLoadedFilesList.Next();
1419 return bRet;
1422 /*****************************************************************************/
1423 Star::~Star()
1424 /*****************************************************************************/
1426 ClearAvailableDeps();
1427 ClearCurrentDeps();
1428 ClearLoadedFilesList();
1429 RemoveAllPrj();
1432 /*****************************************************************************/
1433 void Star::GenerateFileLoadList( SolarFileList *pSolarFiles )
1434 /*****************************************************************************/
1436 SolarFileList* pNewSolarFiles = NULL;
1437 while( pSolarFiles->Count()) {
1438 StarFile *pFile = new StarFile( *pSolarFiles->GetObject(( ULONG ) 0 ));
1439 aMutex.acquire();
1440 ULONG nPos = SearchFileEntry(&aLoadedFilesList, pFile);
1441 if ( nPos == LIST_ENTRY_NOTFOUND )
1443 if (!pNewSolarFiles)
1444 pNewSolarFiles = new SolarFileList();
1446 pNewSolarFiles->Insert(new String(pFile->GetName()), LIST_APPEND );
1448 aMutex.release();
1449 delete pSolarFiles->Remove(( ULONG ) 0 );
1450 delete pFile;
1452 delete pSolarFiles;
1453 if (pNewSolarFiles)
1454 Read (pNewSolarFiles);
1457 /*****************************************************************************/
1458 SolarFileList* Star::NeedsFilesForUpdate()
1459 /*****************************************************************************/
1461 aMutex.acquire();
1462 SolarFileList* pPrjList = NULL;
1463 for ( ULONG i = 0; i < aLoadedFilesList.Count(); i++ )
1464 if ( aLoadedFilesList.GetObject( i )->NeedsUpdate()) {
1465 if (!pPrjList)
1466 pPrjList = new SolarFileList();
1468 pPrjList->Insert(new String (aLoadedFilesList.GetObject( i )->GetName()), LIST_APPEND);
1471 aMutex.release();
1472 return pPrjList;
1475 /*****************************************************************************/
1476 BOOL Star::NeedsUpdate()
1477 /*****************************************************************************/
1479 aMutex.acquire();
1480 for ( ULONG i = 0; i < aLoadedFilesList.Count(); i++ )
1481 if ( aLoadedFilesList.GetObject( i )->NeedsUpdate()) {
1482 aMutex.release();
1483 return TRUE;
1486 aMutex.release();
1487 return FALSE;
1490 /*****************************************************************************/
1491 void Star::Read( String &rFileName )
1492 /*****************************************************************************/
1494 ClearAvailableDeps ();
1495 ByteString aString;
1496 aFileList.Insert( new String( rFileName ));
1498 DirEntry aEntry( rFileName );
1499 aEntry.ToAbs();
1500 aEntry = aEntry.GetPath().GetPath().GetPath();
1501 sSourceRoot = aEntry.GetFull();
1503 while( aFileList.Count()) {
1504 String ssFileName = *aFileList.GetObject(( ULONG ) 0 );
1505 StarFile* pFile = ReadBuildlist (ssFileName);
1506 aMutex.acquire();
1507 ReplaceFileEntry (&aLoadedFilesList, pFile);
1508 //aLoadedFilesList.Insert( pFile, LIST_APPEND );
1509 aMutex.release();
1510 aFileList.Remove(( ULONG ) 0 );
1512 // resolve all dependencies recursive
1513 Expand_Impl();
1516 /*****************************************************************************/
1517 ULONG Star::SearchFileEntry( StarFileList *pStarFiles, StarFile* pFile )
1518 /*****************************************************************************/
1520 StarFile *pSearchFile;
1521 ULONG nCount_l;
1523 nCount_l = pStarFiles->Count();
1525 for ( ULONG i=0; i<nCount_l; i++)
1527 pSearchFile = pStarFiles->GetObject(i);
1528 if ( pSearchFile->GetName() == pFile->GetName() )
1530 return i;
1533 return LIST_ENTRY_NOTFOUND;
1536 /*****************************************************************************/
1537 void Star::ReplaceFileEntry( StarFileList *pStarFiles, StarFile* pFile )
1538 /*****************************************************************************/
1540 ULONG nPos = SearchFileEntry(pStarFiles, pFile);
1541 if ( nPos != LIST_ENTRY_NOTFOUND )
1543 StarFile* pTmpStarFile = pStarFiles->GetObject(nPos);
1544 delete pTmpStarFile;
1545 pStarFiles->Replace(pFile, nPos);
1546 return;
1548 pStarFiles->Insert( pFile, LIST_APPEND );
1551 /*****************************************************************************/
1552 void Star::Read( SolarFileList *pSolarFiles )
1553 /*****************************************************************************/
1555 ClearAvailableDeps ();
1556 while( pSolarFiles->Count()) {
1557 ByteString aString;
1559 String ssFileName = *pSolarFiles->GetObject(( ULONG ) 0 );
1560 StarFile *pFile = ReadBuildlist ( ssFileName);
1562 if ( pFile->Exists()) {
1563 DirEntry aEntry( pFile->GetName() );
1564 DirEntry aEntryPrj = aEntry.GetPath().GetPath();
1565 if (aEntryPrj.GetExtension() != String::CreateFromAscii( "" ))
1567 aEntryPrj.CutExtension();
1568 ByteString aPrjName = ByteString( aEntryPrj.GetName(), gsl_getSystemTextEncoding());
1569 Prj* pPrj = GetPrj(aPrjName);
1570 if (pPrj)
1571 pPrj->IsAvailable (FALSE);
1576 aMutex.acquire();
1577 ReplaceFileEntry (&aLoadedFilesList, pFile);
1578 //aLoadedFilesList.Insert( pFile, LIST_APPEND );
1579 aMutex.release();
1580 delete pSolarFiles->Remove(( ULONG ) 0 );
1582 delete pSolarFiles;
1584 Expand_Impl();
1587 /*****************************************************************************/
1588 String Star::CreateFileName( String& rProject, String& rSourceRoot )
1589 /*****************************************************************************/
1591 // this method is used to find solarlist parts of nabours (other projects)
1592 String sPrjDir( String::CreateFromAscii( "prj" ));
1593 String sBuildList( String::CreateFromAscii( "build.lst" ));
1594 // String sXmlBuildList( String::CreateFromAscii( "build.xlist" ));
1596 DirEntry aEntry( rSourceRoot );
1597 aEntry += DirEntry( rProject );
1599 // if this project not exists, maybe it's a not added project of a CWS
1601 if ( !aEntry.Exists() ) {
1602 aEntry.SetExtension(String::CreateFromAscii( "lnk" ));
1603 if ( !aEntry.Exists() )
1604 aEntry.CutExtension();
1606 aEntry.SetExtension(String::CreateFromAscii( "link" ));
1607 if ( !aEntry.Exists() )
1608 aEntry.CutExtension();
1611 aEntry += DirEntry( sPrjDir );
1613 // DirEntry aPossibleEntry(aEntry);
1614 // aPossibleEntry += DirEntry( sXmlBuildList );
1616 aEntry += DirEntry( sBuildList );
1618 DirEntry& aActualEntry = aEntry;
1620 if (aPossibleEntry.Exists()) {
1621 aActualEntry = aPossibleEntry;
1622 } else */
1623 if ( !aActualEntry.Exists() && aDBNotFoundHdl.IsSet())
1624 aDBNotFoundHdl.Call( &rProject );
1625 return aActualEntry.GetFull();
1628 /*****************************************************************************/
1629 void Star::InsertSolarList( String sProject )
1630 /*****************************************************************************/
1632 // inserts a new solarlist part of another project
1633 String sFileName_l( CreateFileName( sProject, sSourceRoot ));
1635 for ( ULONG i = 0; i < aFileList.Count(); i++ ) {
1636 if (( *aFileList.GetObject( i )) == sFileName_l )
1637 return;
1640 ByteString ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
1641 if ( HasProject( ssProject ))
1642 return;
1644 aFileList.Insert( new String( sFileName_l ), LIST_APPEND );
1647 /*****************************************************************************/
1648 void Star::ExpandPrj_Impl( Prj *pPrj, Prj *pDepPrj )
1649 /*****************************************************************************/
1651 if ( pDepPrj->bVisited )
1652 return;
1654 pDepPrj->bVisited = TRUE;
1656 SByteStringList* pPrjLst = pPrj->GetDependencies();
1657 SByteStringList* pDepLst = NULL;
1658 ByteString* pDepend;
1659 ByteString* pPutStr;
1660 Prj *pNextPrj = NULL;
1661 ULONG i, nRetPos;
1663 if ( pPrjLst ) {
1664 pDepLst = pDepPrj->GetDependencies();
1665 if ( pDepLst ) {
1666 for ( i = 0; i < pDepLst->Count(); i++ ) {
1667 pDepend = pDepLst->GetObject( i );
1668 pPutStr = new ByteString( *pDepend );
1669 nRetPos = pPrjLst->PutString( pPutStr );
1670 if( nRetPos == NOT_THERE )
1671 delete pPutStr;
1672 pNextPrj = GetPrj( *pDepend );
1673 if ( pNextPrj ) {
1674 ExpandPrj_Impl( pPrj, pNextPrj );
1681 /*****************************************************************************/
1682 void Star::Expand_Impl()
1683 /*****************************************************************************/
1685 for ( ULONG i = 0; i < Count(); i++ ) {
1686 for ( ULONG j = 0; j < Count(); j++ )
1687 GetObject( j )->bVisited = FALSE;
1689 Prj* pPrj = GetObject( i );
1690 pPrj->SetMode(pDepMode); // DepList für Mode initialisieren
1691 ExpandPrj_Impl( pPrj, pPrj );
1695 /*****************************************************************************/
1696 StarFile* Star::ReadBuildlist (const String& rFilename, BOOL bReadComments, BOOL bExtendAlias)
1697 /*****************************************************************************/
1699 ByteString sFileName_l(rFilename, RTL_TEXTENCODING_ASCII_US);
1700 StarFile *pFile = new StarFile( rFilename );
1701 if ( pFile->Exists()) {
1702 SimpleConfig aSolarConfig( rFilename );
1703 DirEntry aEntry(rFilename);
1704 ByteString sProjectName (aEntry.GetPath().GetPath().GetName(), RTL_TEXTENCODING_ASCII_US);
1705 Prj* pPrj = GetPrj (sProjectName); // 0, if Prj not found
1706 if (pPrj)
1708 Remove(pPrj); // Project exist, remove old Project and read again
1709 DELETEZ (pPrj); // delete and set pPrj to 0
1711 ByteString aString;
1712 while (( aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != ByteString::EmptyString() )
1713 InsertTokenLine ( aString, &pPrj, sProjectName, bExtendAlias );
1715 return pFile;
1718 /*****************************************************************************/
1719 void Star::InsertTokenLine ( const ByteString& rTokenLine, Prj** ppPrj, const ByteString& rProjectName, const sal_Bool bExtendAlias )
1720 /*****************************************************************************/
1722 int i = 0;
1723 ByteString aWhat, aWhatOS,
1724 sClientRestriction, aLogFileName, aProjectName, aPrefix, aCommandPara;
1725 ByteString aDirName;
1726 BOOL bPrjDep = FALSE;
1727 BOOL bHardDep = FALSE;
1728 BOOL bFixedDep = FALSE;
1729 BOOL bNewProject = FALSE;
1730 int nCommandType=0, nOSType=0;
1731 Prj* pPrj = *ppPrj;
1732 CommandData* pCmdData;
1733 SByteStringList *pDepList = NULL;
1734 ByteString aCommentString;
1735 ByteString sToken;
1736 ByteString sStringBuffer = rTokenLine;
1738 while (sStringBuffer != ByteString::EmptyString())
1740 ByteString sToken = sStringBuffer.GetToken(0,'\t');
1741 sStringBuffer.Erase(0, sToken.Len()+1);
1743 switch (i)
1745 case 0:
1746 if ( sToken.Search( "#" ) == 0 )
1748 i = -1;
1749 aCommentString = sToken;
1750 sStringBuffer = ByteString::EmptyString();
1751 if ( Count() == 0 )
1752 aDirName = "null_entry" ; //comments at begin of file
1754 else
1756 aPrefix = sToken;
1757 pDepList = 0;
1759 break;
1760 case 1:
1761 aDirName = sToken;
1762 aProjectName = aDirName.GetToken ( 0, 0x5c);
1763 if (aProjectName != rProjectName)
1764 sStringBuffer = ByteString::EmptyString(); // something is wrong, ignore line
1765 break;
1766 case 2:
1767 if ( sToken.CompareTo(":") == COMPARE_EQUAL )
1769 bPrjDep = TRUE;
1770 bHardDep = FALSE;
1771 bFixedDep = FALSE;
1772 i = 9;
1774 else if ( sToken.CompareTo("::") == COMPARE_EQUAL )
1776 bPrjDep = TRUE;
1777 bHardDep = TRUE;
1778 bFixedDep = FALSE;
1779 i = 9;
1781 else if ( sToken.CompareTo(":::") == COMPARE_EQUAL )
1783 bPrjDep = TRUE;
1784 bHardDep = TRUE;
1785 bFixedDep = TRUE;
1786 i = 9;
1788 else
1790 bPrjDep = FALSE;
1791 bHardDep = FALSE;
1792 bFixedDep = FALSE;
1794 aWhat = sToken;
1795 nCommandType = GetJobType(aWhat);
1797 if (bPrjDep)
1799 if (pPrj)
1800 sStringBuffer = ByteString::EmptyString(); // definition more than once or not first line, ignore line
1802 break;
1803 case 3:
1804 if ( !bPrjDep )
1806 aWhat = sToken;
1807 if ( aWhat == "-" )
1809 aCommandPara = ByteString();
1811 else
1812 aCommandPara = aWhat;
1814 break;
1815 case 4:
1816 if ( !bPrjDep )
1818 aWhatOS = sToken;
1819 if ( aWhatOS.GetTokenCount( ',' ) > 1 ) {
1820 sClientRestriction = aWhatOS.Copy( aWhatOS.GetToken( 0, ',' ).Len() + 1 );
1821 aWhatOS = aWhatOS.GetToken( 0, ',' );
1823 nOSType = GetOSType (aWhatOS);
1825 break;
1826 case 5:
1827 if ( !bPrjDep )
1829 if (bExtendAlias)
1830 aLogFileName = (ByteString(aProjectName).Append("_")).Append(sToken);
1831 else
1832 aLogFileName = sToken;
1835 break;
1836 default:
1837 if ( !bPrjDep )
1839 ByteString aItem = sToken;
1840 if ( aItem == "NULL" )
1842 // Liste zu Ende
1843 i = -1;
1845 else
1847 // ggfs. Dependency liste anlegen und ergaenzen
1848 if ( !pDepList )
1849 pDepList = new SByteStringList;
1850 ByteString* pStr;
1851 if (bExtendAlias)
1852 pStr = new ByteString ((ByteString (aProjectName).Append("_")).Append(aItem));
1853 else
1854 pStr = new ByteString (aItem);
1855 pDepList->PutString( pStr );
1858 else
1860 ByteString aItem = sToken;
1861 if ( aItem == "NULL" )
1863 // Liste zu Ende
1864 i = -1;
1865 bPrjDep= FALSE;
1867 else
1869 ByteString sMode;
1870 BOOL bHasModes = FALSE;
1871 if (aItem.Search(":") != STRING_NOTFOUND)
1873 sMode = aItem.GetToken ( 0, ':');
1874 aItem = aItem.GetToken ( 1, ':');
1875 bHasModes = TRUE;
1877 if (!pPrj)
1879 // neues Project anlegen
1880 pPrj = new Prj ( aProjectName );
1881 pPrj->SetPreFix( aPrefix );
1882 bNewProject = TRUE;
1884 if (bHasModes)
1885 pPrj->AddDependencies( aItem, sMode );
1886 else
1887 pPrj->AddDependencies( aItem );
1888 pPrj->HasHardDependencies( bHardDep );
1889 pPrj->HasFixedDependencies( bFixedDep );
1892 break;
1894 if ( i == -1 )
1895 break;
1896 i++;
1898 /* Wenn dieses Project noch nicht vertreten ist, in die Liste
1899 der Solar-Projekte einfuegen */
1900 if ( i == -1 )
1902 if (!pPrj)
1904 // neues Project anlegen
1905 pPrj = new Prj ( aProjectName );
1906 pPrj->SetPreFix( aPrefix );
1907 bNewProject = TRUE;
1910 if (bNewProject)
1911 Insert(pPrj,LIST_APPEND);
1913 pCmdData = new CommandData;
1914 pCmdData->SetPath( aDirName );
1915 pCmdData->SetCommandType( nCommandType );
1916 pCmdData->SetCommandPara( aCommandPara );
1917 pCmdData->SetOSType( nOSType );
1918 pCmdData->SetLogFile( aLogFileName );
1919 pCmdData->SetComment( aCommentString );
1920 pCmdData->SetClientRestriction( sClientRestriction );
1921 if ( pDepList )
1922 pCmdData->SetDependencies( pDepList );
1924 pDepList = 0;
1925 pPrj->Insert ( pCmdData, LIST_APPEND );
1927 // und wer raeumt die depLst wieder ab ?
1928 // CommandData macht das
1930 else
1932 if (!pPrj)
1934 // new project to set the error flag
1935 pPrj = new Prj ( rProjectName );
1936 pPrj->SetPreFix( aPrefix );
1937 bNewProject = TRUE;
1939 if (pPrj)
1941 pPrj->SetError();
1942 if (bNewProject)
1943 Insert(pPrj,LIST_APPEND); // add project even if there is a buildlist error
1945 if ( pDepList )
1946 delete pDepList;
1948 *ppPrj = pPrj;
1951 /*****************************************************************************/
1952 BOOL Star::HasProject ( ByteString aProjectName )
1953 /*****************************************************************************/
1955 Prj *pPrj;
1956 int nCount_l;
1958 nCount_l = Count();
1960 for ( int i=0; i<nCount_l; i++)
1962 pPrj = GetObject(i);
1963 if ( pPrj->GetProjectName().ToLowerAscii() == aProjectName.ToLowerAscii() )
1964 return TRUE;
1966 return FALSE;
1969 /*****************************************************************************/
1970 Prj* Star::GetPrj ( ByteString aProjectName )
1971 /*****************************************************************************/
1973 Prj* pPrj;
1974 int nCount_l = Count();
1975 for ( int i=0;i<nCount_l;i++)
1977 pPrj = GetObject(i);
1978 if ( pPrj->GetProjectName().ToLowerAscii() == aProjectName.ToLowerAscii() )
1979 return pPrj;
1981 // return (Prj*)NULL;
1982 return 0L ;
1985 /*****************************************************************************/
1986 BOOL Star::RemovePrj ( Prj* pPrj )
1987 /*****************************************************************************/
1989 ULONG nPos = GetPos(pPrj);
1990 if (nPos != LIST_ENTRY_NOTFOUND) {
1991 delete pPrj;
1992 Remove(nPos);
1993 return TRUE;
1995 return FALSE;
1998 /*****************************************************************************/
1999 void Star::RemoveAllPrj ()
2000 /*****************************************************************************/
2002 Prj* pPrj = First();
2003 while (pPrj)
2005 delete pPrj;
2006 pPrj = Next();
2008 Clear();
2011 /*****************************************************************************/
2012 ByteString Star::GetPrjName( DirEntry &aPath )
2013 /*****************************************************************************/
2015 ByteString aRetPrj, aDirName;
2016 ByteString aFullPathName = ByteString( aPath.GetFull(), gsl_getSystemTextEncoding());
2018 USHORT nToken = aFullPathName.GetTokenCount(PATH_DELIMETER);
2019 for ( int i=0; i< nToken; i++ )
2021 aDirName = aFullPathName.GetToken( i, PATH_DELIMETER );
2022 if ( HasProject( aDirName ))
2024 aRetPrj = aDirName;
2025 break;
2029 return aRetPrj;
2032 /*****************************************************************************/
2033 void Star::ClearAvailableDeps ()
2034 /*****************************************************************************/
2036 if ( pAllDepMode )
2038 ByteString *pString = pAllDepMode->First();
2039 while ( pString )
2041 delete pString;
2042 pString = pAllDepMode->Next();
2044 delete pAllDepMode;
2045 pAllDepMode = NULL;
2049 /*****************************************************************************/
2050 void Star::ClearLoadedFilesList ()
2051 /*****************************************************************************/
2053 StarFile *pStarFile = aLoadedFilesList.First();
2054 while ( pStarFile )
2056 delete pStarFile;
2057 pStarFile = aLoadedFilesList.Next();
2059 aLoadedFilesList.Clear();
2062 /*****************************************************************************/
2063 void Star::ClearCurrentDeps ()
2064 /*****************************************************************************/
2066 if ( pDepMode )
2068 ByteString *pString = pDepMode->First();
2069 while ( pString )
2071 delete pString;
2072 pString = pDepMode->Next();
2074 delete pDepMode;
2075 pDepMode = NULL;
2079 /*****************************************************************************/
2080 SByteStringList* Star::GetAvailableDeps ()
2081 /*****************************************************************************/
2083 if ( pAllDepMode )
2084 return pAllDepMode;
2086 Prj *pPrj;
2087 ByteString* pStr;
2088 pPrj = First();
2089 while (pPrj)
2091 SByteStringList* pModeList = NULL;
2092 if (pPrj->GetModeAndDependencies() && (pModeList = pPrj->GetModeAndDependencies()->GetAllDepModes()))
2094 pStr = pModeList->First();
2095 while (pStr)
2097 if ( !pAllDepMode )
2098 pAllDepMode = new SByteStringList();
2100 if (pAllDepMode->IsString(pStr) == NOT_THERE)
2101 pAllDepMode->PutString(new ByteString(*pStr));
2103 pStr = pModeList->Next();
2106 pPrj = Next();
2108 return pAllDepMode;
2111 /*****************************************************************************/
2112 void Star::SetCurrentDeps (SByteStringList* pDepList)
2113 /*****************************************************************************/
2115 ClearCurrentDeps();
2117 if (pDepList)
2119 pDepMode = new SByteStringList();
2120 ByteString *pString = pDepList->First();
2121 while ( pString )
2123 ByteString* pStr = new ByteString (*pString);
2124 if (pDepMode->PutString(pStr) == NOT_THERE)
2125 delete pStr; // String is not in List
2126 pString = pDepList->Next();
2129 Expand_Impl();
2132 ///*****************************************************************************/
2133 //void Star::ReadXmlBuildList(const ByteString& sBuildLstPath) {
2134 ///*****************************************************************************/
2135 // if (mpXmlBuildList) {
2136 // Prj* pPrj = NULL;
2138 // try {
2139 // mpXmlBuildList->loadXMLFile(sBuildLstPath);
2140 // }
2141 // catch (XmlBuildListException) {
2142 // DirEntry aDirEntry (sBuildLstPath);
2143 // String ssPrjName = aDirEntry.GetPath().GetPath().GetBase();
2144 // ByteString sPrjName = ByteString(ssPrjName, RTL_TEXTENCODING_ASCII_US);
2145 // pPrj = GetPrj( sPrjName );
2146 // if (pPrj)
2147 // {
2148 // //remove old Project
2149 // RemovePrj (pPrj);
2150 // }
2151 // return;
2152 // }
2154 // try {
2155 // ByteString sProjectName = mpXmlBuildList->getModuleName();
2156 // pPrj = GetPrj( sProjectName );
2157 // if (pPrj)
2158 // {
2159 // //remove old Project
2160 // RemovePrj (pPrj);
2161 // }
2163 // // insert new Project
2164 // pPrj = new Prj ( sProjectName );
2165 // pPrj->SetPreFix( sProjectName ); // use ProjectName as Prefix
2166 // Insert(pPrj,LIST_APPEND);
2168 // // get global dependencies
2169 // FullByteStringListWrapper aProducts = mpXmlBuildList->getProducts();
2170 // ByteString aDepType = ByteString(DEP_MD_ALWAYS_STR);
2171 // if (mpXmlBuildList->hasModuleDepType(aProducts, aDepType))
2172 // pPrj->HasHardDependencies( TRUE );
2174 // aDepType = ByteString(DEP_MD_FORCE_STR);
2175 // if (mpXmlBuildList->hasModuleDepType(aProducts, aDepType))
2176 // {
2177 // pPrj->HasHardDependencies( TRUE );
2178 // pPrj->HasFixedDependencies( TRUE );
2179 // }
2181 // // modul dependencies
2182 // ByteString sModulDepType = ByteString();
2183 // FullByteStringListWrapper aModulDeps = mpXmlBuildList->getModuleDependencies(aProducts, sModulDepType);
2184 // ByteString * pModulDep = aModulDeps.First();
2185 // while (pModulDep)
2186 // {
2187 // FullByteStringListWrapper aModulProducts = mpXmlBuildList->getModuleProducts(*pModulDep);
2188 // ByteString *pModulePoduct = aModulProducts.First();
2189 // while (pModulePoduct)
2190 // {
2191 // if (*pModulePoduct == XML_ALL)
2192 // pPrj->AddDependencies( *pModulDep );
2193 // else
2194 // pPrj->AddDependencies( *pModulDep, *pModulePoduct);
2196 // pModulePoduct = aModulProducts.Next();
2197 // }
2198 // pModulDep = aModulDeps.Next();
2199 // }
2201 // // job dirs
2202 // ByteString sJobType = ByteString();
2203 // ByteString sJobPlatforms = ByteString();
2204 // FullByteStringListWrapper aJobDirs = mpXmlBuildList->getJobDirectories(sJobType, sJobPlatforms); // all dirs
2205 // ByteString* pJobDir = aJobDirs.First();
2206 // while (pJobDir)
2207 // {
2208 // FullByteStringListWrapper aJobPlatforms = mpXmlBuildList->getJobPlatforms (*pJobDir);
2209 // ByteString* pJobPlatform = aJobPlatforms.First();
2210 // while (pJobPlatform)
2211 // {
2212 // ByteString sJobRestriction = ByteString();
2213 // FullByteStringListWrapper aJobReq = mpXmlBuildList->getJobBuildReqs (*pJobDir, *pJobPlatform);
2214 // // nur ein Req pro Platform wird zur Zeit unterstützt
2215 // // mehr geht wegen der Struktur zur Zeit nicht!
2216 // // lese sie trotzdem kommasepariert ein, wenn nötig
2217 // if (aJobReq.Count() > 0)
2218 // {
2219 // ByteString* pRestriction = aJobReq.First();
2220 // sJobRestriction = ByteString (*pRestriction);
2221 // pRestriction = aJobReq.Next();
2222 // while (pRestriction)
2223 // {
2224 // sJobRestriction += ByteString (",");
2225 // sJobRestriction += ByteString (*pRestriction);
2226 // pRestriction = aJobReq.Next();
2227 // }
2228 // }
2230 // FullByteStringListWrapper aJobTypes = mpXmlBuildList->getJobTypes (*pJobDir);
2231 // ByteString * pJobType = aJobTypes.First();
2232 // while(pJobType)
2233 // {
2234 // FullByteStringListWrapper aDirDependencies = mpXmlBuildList->getDirDependencies(*pJobDir, *pJobType, *pJobPlatform);
2235 // SByteStringList *pDepList = NULL;
2236 // if (aDirDependencies.Count() > 0)
2237 // {
2238 // pDepList = new SByteStringList;
2239 // ByteString* pDirDep = aDirDependencies.First();
2240 // while (pDirDep)
2241 // {
2242 // ByteString sFullDir = sProjectName;
2243 // sFullDir += *pDirDep;
2244 // sFullDir.SearchAndReplaceAll('/', '\\');
2245 // *pDirDep = sFullDir;
2246 // pDepList->PutString(pDirDep); // String wird übergeben
2247 // aDirDependencies.Remove(); // Zeiger aus alter Liste löschen
2248 // pDirDep = aDirDependencies.First();
2249 // }
2250 // }
2251 // // insert CommandData
2252 // CommandData * pCmdData = new CommandData;
2253 // ByteString sRequiredPath = sProjectName;
2254 // sRequiredPath += *pJobDir;
2255 // sRequiredPath.SearchAndReplaceAll('/', '\\');
2256 // pCmdData->SetPath(sRequiredPath);
2257 // pCmdData->SetCommandType( GetJobType(*pJobType) );
2258 // pCmdData->SetCommandPara( ByteString() );
2259 // pCmdData->SetOSType( GetOSType(*pJobPlatform) );
2260 // ByteString sLogFileName = sProjectName;
2261 // sLogFileName += ByteString::CreateFromInt64( pPrj->Count() );
2262 // pCmdData->SetLogFile( sLogFileName );
2263 // pCmdData->SetClientRestriction( sJobRestriction );
2264 // if ( pDepList )
2265 // pCmdData->SetDependencies( pDepList );
2267 // pPrj->Insert ( pCmdData, LIST_APPEND );
2269 // pJobType = aJobTypes.Next();
2270 // }
2272 // pJobPlatform = aJobPlatforms.Next();
2273 // }
2275 // pJobDir = aJobDirs.Next();
2276 // }
2277 // pPrj->ExtractDependencies();
2278 // }
2279 // catch (XmlBuildListException) {
2280 // if (pPrj)
2281 // {
2282 // RemovePrj (pPrj);
2283 // delete pPrj;
2284 // }
2286 // }
2287 // }
2290 /*****************************************************************************/
2291 int Star::GetOSType ( ByteString& aWhatOS ) {
2292 /*****************************************************************************/
2293 int nOSType = OS_NONE;
2294 if ( aWhatOS == "all" )
2295 nOSType = ( OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX | OS_MAC );
2296 else if ( aWhatOS == "w" || aWhatOS == "wnt" )
2297 nOSType = ( OS_WIN16 | OS_WIN32 );
2298 else if ( aWhatOS == "p" )
2299 nOSType = OS_OS2;
2300 else if ( aWhatOS == "u" || aWhatOS == "unx" )
2301 nOSType = OS_UNX;
2302 else if ( aWhatOS == "d" )
2303 nOSType = OS_WIN16;
2304 else if ( aWhatOS == "n" )
2305 nOSType = OS_WIN32;
2306 else if ( aWhatOS == "m" || aWhatOS == "mac" )
2307 nOSType = OS_MAC;
2308 return nOSType;
2312 /*****************************************************************************/
2313 int Star::GetJobType ( ByteString& JobType ) {
2314 /*****************************************************************************/
2315 int nCommandType = 0;
2316 if ( JobType == "nmake" || JobType == "make")
2317 nCommandType = COMMAND_NMAKE;
2318 else if ( JobType == "get" )
2319 nCommandType = COMMAND_GET;
2320 else {
2321 ULONG nOffset = JobType.Copy( 3 ).ToInt32();
2322 nCommandType = COMMAND_USER_START + nOffset - 1;
2324 return nCommandType;
2327 /*****************************************************************************/
2328 void Star::PutPrjIntoStream (SByteStringList* pPrjNameList, SvStream* pStream)
2329 /*****************************************************************************/
2331 aMutex.acquire();
2332 *pStream << sal_False; // not full Star / only some Projects
2334 ULONG nCount_l = pPrjNameList->Count();
2335 *pStream << nCount_l;
2336 ByteString* pStr = pPrjNameList->First();
2337 while (pStr) {
2338 Prj* pPrj = GetPrj (*pStr);
2339 *pPrj >> *pStream;
2340 pStr = pPrjNameList->Next();
2342 aMutex.release();
2345 /*****************************************************************************/
2346 Star& Star::operator>> ( SvStream& rStream )
2347 /*****************************************************************************/
2349 aMutex.acquire();
2350 rStream << sal_True; // full Star
2351 rStream << nStarMode;
2352 if (pDepMode)
2354 rStream << sal_True;
2355 *pDepMode >> rStream;
2357 else
2358 rStream << sal_False;
2360 ULONG nCount_l = Count();
2361 rStream << nCount_l;
2362 Prj* pPrj = First();
2363 while (pPrj) {
2364 *pPrj >> rStream;
2365 pPrj = Next();
2367 aMutex.release();
2369 return *this;
2372 /*****************************************************************************/
2373 Star& Star::operator<< ( SvStream& rStream )
2374 /*****************************************************************************/
2376 aMutex.acquire();
2377 BOOL bFullList;
2378 rStream >> bFullList;
2379 if (bFullList)
2381 rStream >> nStarMode;
2382 BOOL bDepMode;
2383 rStream >> bDepMode;
2384 if (pDepMode)
2385 pDepMode->CleanUp();
2386 if (bDepMode)
2388 if (!pDepMode)
2389 pDepMode = new SByteStringList();
2390 *pDepMode << rStream;
2392 else
2393 DELETEZ (pDepMode);
2396 ULONG nCount_l;
2397 rStream >> nCount_l;
2398 for ( USHORT i = 0; i < nCount_l; i++ ) {
2399 Prj* pPrj = new Prj();
2400 *pPrj << rStream;
2401 pPrj->SetMode(pDepMode);
2402 if (HasProject (pPrj->GetProjectName())) {
2403 Prj* pTmpPrj = GetPrj( pPrj->GetProjectName() );
2404 Replace (pPrj, pTmpPrj);
2405 delete pTmpPrj;
2407 else
2408 Insert (pPrj, LIST_APPEND);
2410 Expand_Impl();
2411 aMutex.release();
2412 return *this;
2418 // class StarWriter
2421 /*****************************************************************************/
2422 StarWriter::StarWriter( String aFileName, BOOL bReadComments, USHORT nMode )
2423 /*****************************************************************************/
2424 : Star ()
2426 sFileName = aFileName;
2427 Read ( aFileName, bReadComments, nMode );
2430 /*****************************************************************************/
2431 StarWriter::StarWriter( SolarFileList *pSolarFiles, BOOL bReadComments )
2432 /*****************************************************************************/
2433 : Star ()
2435 Read( pSolarFiles, bReadComments );
2438 /*****************************************************************************/
2439 StarWriter::StarWriter( GenericInformationList *pStandLst, ByteString &rVersion,
2440 ByteString &rMinor, BOOL bReadComments, BOOL bLocal, const char *pSourceRoot )
2441 /*****************************************************************************/
2442 : Star ()
2444 ByteString sPath( rVersion );
2445 if ( pSourceRoot )
2446 sSourceRoot = String::CreateFromAscii( pSourceRoot );
2448 #ifdef UNX
2449 sPath += "/settings/UNXSOLARLIST";
2450 #else
2451 sPath += "/settings/SOLARLIST";
2452 #endif
2453 GenericInformation *pInfo_l = pStandLst->GetInfo( sPath, TRUE );
2455 if( pInfo_l && pInfo_l->GetValue().Len()) {
2456 ByteString sFile( pInfo_l->GetValue());
2457 if ( bLocal ) {
2458 IniManager aIniManager;
2459 aIniManager.ToLocal( sFile );
2461 String sFileName_l( sFile, RTL_TEXTENCODING_ASCII_US );
2462 nStarMode = STAR_MODE_SINGLE_PARSE;
2463 Read( sFileName_l, bReadComments );
2465 else {
2466 SolarFileList *pFileList = new SolarFileList();
2468 sPath = rVersion;
2469 sPath += "/drives";
2471 GenericInformation *pInfo_k = pStandLst->GetInfo( sPath, TRUE );
2472 if ( pInfo_k && pInfo_k->GetSubList()) {
2473 GenericInformationList *pDrives = pInfo_k->GetSubList();
2474 for ( ULONG i = 0; i < pDrives->Count(); i++ ) {
2475 GenericInformation *pDrive = pDrives->GetObject( i );
2476 if ( pDrive ) {
2477 DirEntry aEntry;
2478 BOOL bOk = FALSE;
2479 if ( sSourceRoot.Len()) {
2480 aEntry = DirEntry( sSourceRoot );
2481 bOk = TRUE;
2483 else {
2484 #ifdef UNX
2485 sPath = "UnixVolume";
2486 GenericInformation *pUnixVolume = pDrive->GetSubInfo( sPath );
2487 if ( pUnixVolume ) {
2488 String sRoot( pUnixVolume->GetValue(), RTL_TEXTENCODING_ASCII_US );
2489 aEntry = DirEntry( sRoot );
2490 bOk = TRUE;
2492 #else
2493 bOk = TRUE;
2494 String sRoot( *pDrive, RTL_TEXTENCODING_ASCII_US );
2495 sRoot += String::CreateFromAscii( "\\" );
2496 aEntry = DirEntry( sRoot );
2497 #endif
2499 if ( bOk ) {
2500 sPath = "projects";
2501 GenericInformation *pProjectsKey = pDrive->GetSubInfo( sPath, TRUE );
2502 if ( pProjectsKey ) {
2503 if ( !sSourceRoot.Len()) {
2504 sPath = rVersion;
2505 sPath += "/settings/PATH";
2506 GenericInformation *pPath = pStandLst->GetInfo( sPath, TRUE );
2507 if( pPath ) {
2508 ByteString sAddPath( pPath->GetValue());
2509 #ifdef UNX
2510 sAddPath.SearchAndReplaceAll( "\\", "/" );
2511 #else
2512 sAddPath.SearchAndReplaceAll( "/", "\\" );
2513 #endif
2514 //If Minor has been set add it to path
2515 if (rMinor.Len()>0) {
2516 sAddPath += ".";
2517 sAddPath += rMinor;
2519 String ssAddPath( sAddPath, RTL_TEXTENCODING_ASCII_US );
2521 aEntry += DirEntry( ssAddPath );
2524 sPath = rVersion;
2525 sPath += "/settings/SHORTPATH";
2526 GenericInformation *pShortPath = pStandLst->GetInfo( sPath, TRUE );
2527 BOOL bShortPath = FALSE;
2528 if (pShortPath && (pShortPath->GetValue() == "_TRUE"))
2529 bShortPath = TRUE;
2530 sSourceRoot = aEntry.GetFull();
2531 GenericInformationList *pProjects = pProjectsKey->GetSubList();
2532 if ( pProjects ) {
2533 String sPrjDir( String::CreateFromAscii( "prj" ));
2534 String sSolarFile( String::CreateFromAscii( "build.lst" ));
2536 GenericInformation * pProject = pProjects->First();
2537 while (pProject) {
2538 ByteString sProject( *pProject);
2539 String ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
2541 DirEntry aPrjEntry( aEntry );
2543 ByteString aDirStr ("Directory");
2544 GenericInformation * pDir = pProject->GetSubInfo (aDirStr);
2545 if (pDir) {
2546 ByteString aDir = pDir->GetValue();
2547 if (bShortPath)
2548 aPrjEntry = aEntry;
2549 else
2550 aPrjEntry = aEntry.GetPath();
2551 aPrjEntry += DirEntry(aDir);
2554 aPrjEntry += DirEntry( ssProject );
2555 aPrjEntry += DirEntry( sPrjDir );
2556 aPrjEntry += DirEntry( sSolarFile );
2558 pFileList->Insert( new String( aPrjEntry.GetFull()), LIST_APPEND );
2560 ByteString sFile( aPrjEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
2561 fprintf( stdout, "%s\n", sFile.GetBuffer());
2562 pProject = pProjects->Next();
2570 Read( pFileList, bReadComments );
2574 /*****************************************************************************/
2575 void StarWriter::CleanUp()
2576 /*****************************************************************************/
2578 Expand_Impl();
2581 /*****************************************************************************/
2582 USHORT StarWriter::Read( String aFileName, BOOL bReadComments, USHORT nMode )
2583 /*****************************************************************************/
2585 sFileName = aFileName;
2587 nStarMode = nMode;
2589 ByteString aString;
2590 aFileList.Insert( new String( aFileName ));
2592 DirEntry aEntry( aFileName );
2593 aEntry.ToAbs();
2594 aEntry = aEntry.GetPath().GetPath().GetPath();
2595 sSourceRoot = aEntry.GetFull();
2597 while( aFileList.Count()) {
2598 String ssFileName = *aFileList.GetObject(( ULONG ) 0 );
2599 StarFile* pFile = ReadBuildlist (ssFileName, bReadComments, FALSE);
2600 aMutex.acquire();
2601 aLoadedFilesList.Insert( pFile, LIST_APPEND );
2602 aMutex.release();
2603 delete aFileList.Remove(( ULONG ) 0 );
2605 // resolve all dependencies recursive
2606 Expand_Impl();
2608 // Die gefundenen Abhaengigkeiten rekursiv aufloesen
2609 Expand_Impl();
2610 return 0;
2613 /*****************************************************************************/
2614 USHORT StarWriter::Read( SolarFileList *pSolarFiles, BOOL bReadComments )
2615 /*****************************************************************************/
2617 nStarMode = STAR_MODE_MULTIPLE_PARSE;
2619 // this ctor is used by StarBuilder to get the information for the whole workspace
2620 while( pSolarFiles->Count()) {
2621 ByteString aString;
2622 String ssFileName = *pSolarFiles->GetObject(( ULONG ) 0 );
2623 StarFile* pFile = ReadBuildlist(ssFileName, bReadComments, FALSE);
2624 aMutex.acquire();
2625 aLoadedFilesList.Insert( pFile, LIST_APPEND );
2626 aMutex.release();
2627 delete pSolarFiles->Remove(( ULONG ) 0 );
2629 delete pSolarFiles;
2631 Expand_Impl();
2632 return 0;
2635 /*****************************************************************************/
2636 USHORT StarWriter::WritePrj( Prj *pPrj, SvFileStream& rStream )
2637 /*****************************************************************************/
2639 ByteString aDataString;
2640 ByteString aTab('\t');
2641 ByteString aSpace(' ');
2642 ByteString aEmptyString("");
2643 SByteStringList* pCmdDepList;
2644 SByteStringList* pPrjDepList;
2646 CommandData* pCmdData = NULL;
2647 if ( pPrj->Count() > 0 )
2649 pCmdData = pPrj->First();
2650 if ( (pPrjDepList = pPrj->GetDependencies( FALSE )) )
2652 aDataString = pPrj->GetPreFix();
2653 aDataString += aTab;
2654 aDataString += pPrj->GetProjectName();
2655 aDataString += aTab;
2656 if ( pPrj->HasFixedDependencies())
2657 aDataString+= ByteString(":::");
2658 else if ( pPrj->HasHardDependencies())
2659 aDataString+= ByteString("::");
2660 else
2661 aDataString+= ByteString(":");
2662 aDataString += aTab;
2663 for ( USHORT i = 0; i< pPrjDepList->Count(); i++ ) {
2664 aDataString += *pPrjDepList->GetObject( i );
2665 aDataString += aSpace;
2667 aDataString+= "NULL";
2669 rStream.WriteLine( aDataString );
2671 pCmdData = pPrj->Next();
2673 if ( pCmdData ) {
2676 if (( aDataString = pCmdData->GetComment()) == aEmptyString )
2678 aDataString = pPrj->GetPreFix();
2679 aDataString += aTab;
2681 aDataString+= pCmdData->GetPath();
2682 aDataString += aTab;
2683 USHORT nPathLen = pCmdData->GetPath().Len();
2684 if ( nPathLen < 40 )
2685 for ( int i = 0; i < 9 - pCmdData->GetPath().Len() / 4 ; i++ )
2686 aDataString += aTab;
2687 else
2688 for ( int i = 0; i < 12 - pCmdData->GetPath().Len() / 4 ; i++ )
2689 aDataString += aTab;
2690 aDataString += pCmdData->GetCommandTypeString();
2691 aDataString += aTab;
2692 if ( pCmdData->GetCommandType() == COMMAND_GET )
2693 aDataString += aTab;
2694 if ( pCmdData->GetCommandPara() == aEmptyString )
2695 aDataString+= ByteString("-");
2696 else
2697 aDataString+= pCmdData->GetCommandPara();
2698 aDataString += aTab;
2699 aDataString+= pCmdData->GetOSTypeString();
2700 if ( pCmdData->GetClientRestriction().Len()) {
2701 aDataString += ByteString( "," );
2702 aDataString += pCmdData->GetClientRestriction();
2704 aDataString += aTab;
2705 aDataString += pCmdData->GetLogFile();
2706 aDataString += aSpace;
2708 pCmdDepList = pCmdData->GetDependencies();
2709 if ( pCmdDepList )
2710 for ( USHORT i = 0; i< pCmdDepList->Count(); i++ ) {
2711 aDataString += *pCmdDepList->GetObject( i );
2712 aDataString += aSpace;
2714 aDataString += "NULL";
2717 rStream.WriteLine( aDataString );
2719 pCmdData = pPrj->Next();
2720 } while ( pCmdData );
2723 return 0;
2726 /*****************************************************************************/
2727 USHORT StarWriter::Write( String aFileName )
2728 /*****************************************************************************/
2730 sFileName = aFileName;
2732 FileStat::SetReadOnlyFlag( DirEntry( aFileName ), FALSE );
2734 SvFileStream aFileStream;
2736 aFileStream.Open( aFileName, STREAM_WRITE | STREAM_TRUNC);
2737 if ( !aFileStream.IsOpen() && aFileIOErrorHdl.IsSet()) {
2738 String sError( String::CreateFromAscii( "Error: Unable to open \"" ));
2739 sError += aFileName;
2740 sError += String::CreateFromAscii( "for writing!" );
2741 aFileIOErrorHdl.Call( &sError );
2744 if ( Count() > 0 )
2746 Prj* pPrj = First();
2749 WritePrj( pPrj, aFileStream );
2750 pPrj = Next();
2751 } while ( pPrj );
2754 aFileStream.Close();
2756 return 0;
2759 /*****************************************************************************/
2760 USHORT StarWriter::WriteMultiple( String rSourceRoot )
2761 /*****************************************************************************/
2763 sSourceRoot = rSourceRoot;
2765 if ( Count() > 0 )
2767 String sPrjDir( String::CreateFromAscii( "prj" ));
2768 String sSolarFile( String::CreateFromAscii( "build.lst" ));
2770 Prj* pPrj = First();
2773 String sName( pPrj->GetProjectName(), RTL_TEXTENCODING_ASCII_US );
2775 DirEntry aEntry( rSourceRoot );
2776 aEntry += DirEntry( sName );
2777 aEntry += DirEntry( sPrjDir );
2778 aEntry += DirEntry( sSolarFile );
2780 FileStat::SetReadOnlyFlag( aEntry, FALSE );
2782 SvFileStream aFileStream;
2783 aFileStream.Open( aEntry.GetFull(), STREAM_WRITE | STREAM_TRUNC);
2785 if ( !aFileStream.IsOpen() && aFileIOErrorHdl.IsSet()) {
2786 String sError( String::CreateFromAscii( "Error: Unable to open \"" ));
2787 sError += aEntry.GetFull();
2788 sError += String::CreateFromAscii( "for writing!" );
2789 aFileIOErrorHdl.Call( &sError );
2792 WritePrj( pPrj, aFileStream );
2794 aFileStream.Close();
2796 pPrj = Next();
2797 } while ( pPrj );
2800 return 0;
2803 /*****************************************************************************/
2804 void StarWriter::InsertTokenLine ( const ByteString& rTokenLine )
2805 /*****************************************************************************/
2807 ByteString sProjectName = rTokenLine.GetToken(1,'\t');
2808 Prj* pPrj = GetPrj (sProjectName); // 0, if Prj not found;
2809 Star::InsertTokenLine ( rTokenLine, &pPrj, sProjectName, sal_False );
2812 /*****************************************************************************/
2813 BOOL StarWriter::InsertProject ( Prj* /*pNewPrj*/ )
2814 /*****************************************************************************/
2816 return FALSE;
2819 /*****************************************************************************/
2820 Prj* StarWriter::RemoveProject ( ByteString aProjectName )
2821 /*****************************************************************************/
2823 ULONG nCount_l = Count();
2824 Prj* pPrj;
2825 Prj* pPrjFound = NULL;
2826 SByteStringList* pPrjDeps;
2828 for ( USHORT i = 0; i < nCount_l; i++ )
2830 pPrj = GetObject( i );
2831 if ( pPrj->GetProjectName() == aProjectName )
2832 pPrjFound = pPrj;
2833 else
2835 pPrjDeps = pPrj->GetDependencies( FALSE );
2836 if ( pPrjDeps )
2838 ByteString* pString;
2839 ULONG nPrjDepsCount = pPrjDeps->Count();
2840 for ( ULONG j = nPrjDepsCount; j > 0; j-- )
2842 pString = pPrjDeps->GetObject( j - 1 );
2843 if ( pString->GetToken( 0, '.') == aProjectName )
2844 pPrjDeps->Remove( pString );
2850 Remove( pPrjFound );
2852 return pPrjFound;
2856 // class StarFile
2859 /*****************************************************************************/
2860 StarFile::StarFile( const String &rFile )
2861 /*****************************************************************************/
2862 : aFileName( rFile )
2864 DirEntry aEntry( aFileName );
2865 if ( aEntry.Exists()) {
2866 bExists = TRUE;
2867 FileStat aStat( aEntry );
2868 aDate = aStat.DateModified();
2869 aTime = aStat.TimeModified();
2870 aDateCreated = aStat.DateCreated();
2871 aTimeCreated = aStat.TimeCreated();
2873 else
2874 bExists = FALSE;
2877 /*****************************************************************************/
2878 BOOL StarFile::NeedsUpdate()
2879 /*****************************************************************************/
2881 DirEntry aEntry( aFileName );
2882 if ( aEntry.Exists()) {
2883 if ( !bExists ) {
2884 bExists = TRUE;
2885 return TRUE;
2887 FileStat aStat( aEntry );
2888 if (( aStat.DateModified() != aDate ) || ( aStat.TimeModified() != aTime )
2889 || ( aStat.DateCreated() != aDateCreated ) || ( aStat.TimeCreated() != aTimeCreated ))
2890 return TRUE;
2892 return FALSE;