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