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