xref: /AOO41X/main/soldep/inc/soldep/prj.hxx (revision 53a9af0a251b18e3c3b23eacf3a4922b098ea5c4)
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 
24 #ifndef _PRJ_HXX
25 #define _PRJ_HXX
26 
27 #include <tools/fsys.hxx>
28 #include <tools/stream.hxx>
29 #include <soldep/listmacr.hxx>
30 #include <vos/mutex.hxx>
31 #include <tools/string.hxx>
32 
33 #define XML_EXT "xlist"
34 
35 #define OS_NONE             0x0000
36 #define OS_WIN16            0x0001
37 #define OS_WIN32            0x0002
38 #define OS_OS2              0x0004
39 #define OS_UNX              0x0008
40 #define OS_MAC              0x0010
41 #define OS_ALL              ( OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX | OS_MAC )
42 
43 #define COMMAND_PROJECTROOT 0x0000
44 #define COMMAND_NMAKE       0x0001
45 #define COMMAND_GET         0x0002
46 #define COMMAND_USER_START  0x0003
47 #define COMMAND_USER_END    0xFFFE
48 #define COMMAND_ALLDIRS     0xFFFF
49 
50 class SByteStringList;
51 class GenericInformationList;
52 
53 /*
54 // Pfade auf Konfigurationsdateien des Build-Servers
55 
56 #define REQUEST_DIR         \\src\data4\source\b_server\server\newjob
57 */
58 /*********************************************************************
59 *
60 *   Die Klasse CommandData haelte alle Informationen, die fuer die
61 *   Abarbeitung eines Kommandos (nmake, get) noetig sind
62 *
63 *********************************************************************/
64 
65 class CommandData
66 {
67     ByteString      aPrj;
68     ByteString      aLogFileName;
69     ByteString      aInpath;
70     ByteString      aUpd;
71     ByteString      aUpdMinor;
72     ByteString      aProduct;
73     ByteString      aCommand;
74     ByteString      aPath;
75     ByteString      aPrePath;
76     ByteString      aPreFix;
77     ByteString      aCommandPara;
78     ByteString      aComment;
79     ByteString      sClientRestriction;
80     SByteStringList *pDepList;
81     SByteStringList *pCommandList;
82     sal_uInt16      nOSType;
83     sal_uInt16      nCommand;
84 
85     sal_uIntPtr     nDepth;             // Tiefe der Abhaenigkeit
86 
87 public:
88                 CommandData();
89                 ~CommandData();
GetProjectName()90     ByteString      GetProjectName(){return aPrj;}
SetProjectName(ByteString aName)91     void        SetProjectName( ByteString aName ){aPrj = aName;}
GetLogFile()92     ByteString      GetLogFile(){return aLogFileName;}
SetLogFile(ByteString aName)93     void        SetLogFile( ByteString aName ){aLogFileName = aName;}
GetInpath()94     ByteString      GetInpath(){return aInpath;}
SetInpath(ByteString aName)95     void        SetInpath( ByteString aName ){aInpath = aName;}
GetUpd()96     ByteString      GetUpd(){return aUpd;}
SetUpd(ByteString aName)97     void        SetUpd( ByteString aName ){aUpd = aName;}
GetUpdMinor()98     ByteString      GetUpdMinor(){return aUpdMinor;}
SetUpdMinor(ByteString aName)99     void        SetUpdMinor( ByteString aName ){aUpdMinor = aName;}
GetProduct()100     ByteString      GetProduct(){return aProduct;}
SetProduct(ByteString aName)101     void        SetProduct( ByteString aName ){aProduct = aName;}
GetCommand()102     ByteString      GetCommand(){return aCommand;}
SetCommand(ByteString aName)103     void        SetCommand ( ByteString aName ){aCommand = aName;}
GetCommandPara()104     ByteString      GetCommandPara(){return aCommandPara;}
SetCommandPara(ByteString aName)105     void        SetCommandPara ( ByteString aName ){aCommandPara = aName;}
GetComment()106     ByteString      GetComment(){return aComment;}
SetComment(ByteString aCommentString)107     void        SetComment ( ByteString aCommentString ){aComment = aCommentString;}
GetPath()108     ByteString      GetPath(){return aPath;}
SetPath(ByteString aName)109     void        SetPath( ByteString aName ){aPath = aName;}
GetPrePath()110     ByteString      GetPrePath(){return aPrePath;}
SetPrePath(ByteString aName)111     void        SetPrePath( ByteString aName ){aPrePath = aName;}
GetOSType()112     sal_uInt16      GetOSType(){return nOSType;}
113     ByteString      GetOSTypeString();
SetOSType(sal_uInt16 nType)114     void        SetOSType( sal_uInt16 nType ){nOSType = nType;}
GetCommandType()115     sal_uInt16      GetCommandType(){return nCommand;}
116     ByteString      GetCommandTypeString();
SetCommandType(sal_uInt16 nCommandType)117     void        SetCommandType( sal_uInt16 nCommandType ){nCommand = nCommandType;}
GetDependencies()118     SByteStringList* GetDependencies(){return pDepList;}
SetDependencies(SByteStringList * pList)119     void        SetDependencies( SByteStringList *pList ){pDepList = pList;}
GetClientRestriction()120     ByteString      GetClientRestriction() { return sClientRestriction; }
SetClientRestriction(ByteString sRestriction)121     void        SetClientRestriction( ByteString sRestriction ) { sClientRestriction = sRestriction; }
122 
AddDepth()123     void        AddDepth(){nDepth++;}
GetDepth()124     sal_uIntPtr     GetDepth(){return nDepth;}
125 
126     void AddCommand(ByteString* pCommand);
GetCommandList()127     SByteStringList* GetCommandList() {return pCommandList;}
128 
129     CommandData& operator<<  ( SvStream& rStream );
130     CommandData& operator>>  ( SvStream& rStream );
131 };
132 
133 /*********************************************************************
134 *
135 *   Die Klasse SimpleConfig kann benutzt werden, um aus einer Textdatei
136 *   alle Tokens zu lesen
137 *
138 *********************************************************************/
139 
140 class SimpleConfig
141 {
142     long            nLine;
143     String          aFileName;
144     SvFileStream    aFileStream;
145     ByteString          aTmpStr;
146     ByteString          aStringBuffer;
147 
148     ByteString          GetNextLine();
149 public:
150                     SimpleConfig(String aSimpleConfigFileName);
151                     SimpleConfig(DirEntry& rDirEntry);
152                     ~SimpleConfig();
153     ByteString          GetNext();
154     ByteString          GetCleanedNextLine( sal_Bool bReadComments = sal_False );
155 };
156 
157 #define ENV_GUI     0x00000000
158 #define ENV_OS      0x00000001
159 #define ENV_UPD     0x00000002
160 #define ENV_UPDMIN  0x00000004
161 #define ENV_INPATH  0x00000008
162 #define ENV_OUTPATH 0x00000010
163 #define ENV_GUIBASE 0x00000020
164 #define ENV_CVER    0x00000040
165 #define ENV_GVER    0x00000080
166 #define ENV_GUIENV  0x00000100
167 #define ENV_CPU     0x00000200
168 #define ENV_CPUNAME 0x00000400
169 #define ENV_DLLSUFF 0x00000800
170 #define ENV_COMEX   0x00001000
171 #define ENV_COMPATH 0x00002000
172 #define ENV_INCLUDE 0x00004000
173 #define ENV_LIB     0x00008000
174 #define ENV_PATH    0x00010000
175 #define ENV_SOLVER  0x00020000
176 #define ENV_SOLENV  0x00040000
177 #define ENV_SOLROOT 0x00080000
178 #define ENV_DEVROOT 0x00100000
179 #define ENV_EMERG   0x00200000
180 #define ENV_STAND   0x00400000
181 
182 DECL_DEST_LIST ( PrjList_tmp, PrjList, CommandData * )
183 
184 /*********************************************************************
185 *
186 *   class DepInfo
187 *   Struct mit Modeinfos
188 *
189 *********************************************************************/
190 
191 class DepInfo
192 {
193     private:
194         ByteString*         pProject;
195         SByteStringList*    pModeList;
196         sal_Bool                bAllModes;
197 
198         void                RemoveProject ();
199         void                RemoveModeList ();
200     public:
DepInfo()201                             DepInfo() : pProject(0), pModeList(0), bAllModes(sal_False) {}
DepInfo(ByteString * pString)202                             DepInfo(ByteString* pString) : pProject(0), pModeList(0), bAllModes(sal_False) {pProject = pString;}
DepInfo(ByteString * pString,SByteStringList * pList)203                             DepInfo(ByteString* pString, SByteStringList* pList) : pProject(0), pModeList(0), bAllModes(sal_False) {pProject = pString; pModeList = pList;}
204                             ~DepInfo();
205 
206         void                SetProject (ByteString* pStr);
GetProject()207         ByteString*         GetProject() {return pProject;}
208         void                PutModeString (ByteString* pStr);
GetModeList()209         SByteStringList*    GetModeList() {return pModeList;}
SetModeList(SByteStringList * pList)210         void                SetModeList (SByteStringList* pList) {pModeList = pList;}
IsAllModes()211         sal_Bool                IsAllModes() {return bAllModes;}
SetAllModes(sal_Bool bModes=sal_True)212         void                SetAllModes(sal_Bool bModes=sal_True) {bAllModes = bModes;}
213 
214         DepInfo&            operator<<  ( SvStream& rStream );
215         DepInfo&            operator>>  ( SvStream& rStream );
216 };
217 
218 DECLARE_LIST( DepInfoList, DepInfo* )
219 
220 /*********************************************************************
221 *
222 *   class SDepInfoList
223 *   Struct mit Modeinfos + Listen Methoden
224 *
225 *********************************************************************/
226 
227 class SDepInfoList : public DepInfoList
228 {
229     SByteStringList*    pAllModeList; // only pointer to strings
230 
231     public:
232                 SDepInfoList();
233                 ~SDepInfoList();
234 
235                 // neuen ByteString in Liste einfuegen
236     sal_uIntPtr     PutString( ByteString*, ByteString*);
237     sal_uIntPtr     PutString( ByteString*);
238     void        PutModeString( DepInfo* pInfoList, ByteString* pStr );
239 
240     ByteString*     RemoveString( const ByteString& rName );
241 
242                 // Position des ByteString in Liste, wenn nicht enthalten, dann
243                 // return = NOT_THERE
244     sal_uIntPtr     IsString( ByteString* );
245 
246                 // Vorgaenger ermitteln ( auch wenn selbst noch nicht in
247                 // Liste enthalten
248     sal_uIntPtr     GetPrevString( ByteString* );
249     SByteStringList*    GetAllDepModes();
250 
251     SDepInfoList& operator<< ( SvStream& rStream );
252     SDepInfoList& operator>> ( SvStream& rStream );
253 };
254 
255 
256 /*********************************************************************
257 *
258 *   class Prj
259 *   alle Daten eines Projektes werden hier gehalten
260 *
261 *********************************************************************/
262 
263 class Star;
264 class Prj : public PrjList
265 {
266 friend class Star;
267 private:
268 
269     ByteString          aPrjPath;
270     ByteString          aProjectName;
271     ByteString          aProjectPrefix;     // max. 2-buchstabige Abk.
272     SByteStringList*    pPrjInitialDepList;
273     SByteStringList*    pPrjDepList;
274     SDepInfoList*       pPrjDepInfoList;
275     sal_Bool            bSorted;
276     sal_Bool            bHardDependencies;
277     sal_Bool            bFixedDependencies;
278     sal_Bool            bVisited;
279     sal_Bool            bIsAvailable;
280     SByteStringList* RemoveStringList(SByteStringList* pStringList );
281     SDepInfoList*   RemoveDepInfoList(SDepInfoList* pInfoList );
282     PrjList*        pTempCommandDataList;
283     sal_Bool            bTempCommandDataListPermanent;
284     sal_Bool            bError;
285 public:
286                     Prj();
287                     Prj( ByteString aName );
288                     ~Prj();
SetPreFix(ByteString aPre)289     void            SetPreFix( ByteString aPre ){aProjectPrefix = aPre;}
GetPreFix()290     ByteString          GetPreFix(){return aProjectPrefix;}
GetProjectName()291     ByteString          GetProjectName()
292                             {return aProjectName;}
SetProjectName(ByteString aName)293     void            SetProjectName(ByteString aName)
294                             {aProjectName = aName;}
295     sal_Bool            InsertDirectory( ByteString aDirName , sal_uInt16 aWhat,
296                                     sal_uInt16 aWhatOS, ByteString aLogFileName,
297                                     const ByteString &rClientRestriction );
298     CommandData*    RemoveDirectory( ByteString aLogFileName );
299     CommandData*    GetDirectoryList ( sal_uInt16 nWhatOs, sal_uInt16 nCommand );
300     CommandData*    GetDirectoryData( ByteString aLogFileName );
GetData(ByteString aLogFileName)301     inline CommandData* GetData( ByteString aLogFileName )
302                             { return GetDirectoryData( aLogFileName ); };
303 
304     SByteStringList*    GetDependencies( sal_Bool bExpanded = sal_True );
GetModeAndDependencies()305     SDepInfoList*   GetModeAndDependencies() {return pPrjDepInfoList;}
306     void            AddDependencies( ByteString aStr );
307     void            AddDependencies( ByteString aStr, ByteString aModeStr );
308     void            SetMode(SByteStringList* pModeList);
HasHardDependencies(sal_Bool bHard)309     void            HasHardDependencies( sal_Bool bHard ) { bHardDependencies = bHard; }
HasHardDependencies()310     sal_Bool            HasHardDependencies() { return bHardDependencies; }
HasFixedDependencies(sal_Bool bFixed)311     void            HasFixedDependencies( sal_Bool bFixed ) { bFixedDependencies = bFixed; }
HasFixedDependencies()312     sal_Bool            HasFixedDependencies() { return bFixedDependencies; }
313 
IsAvailable()314     sal_Bool            IsAvailable() { return bIsAvailable; }
IsAvailable(sal_Bool bAvailable)315     void            IsAvailable( sal_Bool bAvailable ) { bIsAvailable=bAvailable; }
316 
317     void            ExtractDependencies();
318 
319     PrjList*        GetCommandDataList ();
320     void            RemoveTempCommandDataList();
321     void            GenerateTempCommandDataList();
322     void            GenerateEmptyTempCommandDataList();
HasTempCommandDataList()323     sal_Bool            HasTempCommandDataList() {return pTempCommandDataList != NULL;}
SetTempCommandDataListPermanent(sal_Bool bVar=sal_True)324     void            SetTempCommandDataListPermanent (sal_Bool bVar = sal_True) {bTempCommandDataListPermanent = bVar;}
IsTempCommandDataListPermanent()325     sal_Bool            IsTempCommandDataListPermanent() {return bTempCommandDataListPermanent;}
326 
SetError(sal_Bool bVar=sal_True)327     void            SetError (sal_Bool bVar = sal_True) {bError = bVar;}
HasError()328     sal_Bool            HasError () {return bError;}
329 
330     Prj&            operator<<  ( SvStream& rStream );
331     Prj&            operator>>  ( SvStream& rStream );
332 };
333 
334 /*********************************************************************
335 *
336 *   class Star
337 *   Diese Klasse liest die Projectstruktur aller StarDivision Projekte
338 *   aus \\dev\data1\upenv\data\config\solar.lst aus
339 *
340 *********************************************************************/
341 
342 DECL_DEST_LIST ( StarList_tmp, StarList, Prj* )
343 DECLARE_LIST ( SolarFileList, String* )
344 
345 class StarFile
346 {
347 private:
348     String aFileName;
349     Date aDate;
350     Time aTime;
351     Date aDateCreated;
352     Time aTimeCreated;
353 
354     sal_Bool bExists;
355 
356 public:
357     StarFile( const String &rFile );
GetName()358     const String &GetName() { return aFileName; }
GetDate()359     Date GetDate() { return aDate; }
GetTime()360     Time GetTime() { return aTime; }
361 
362     sal_Bool NeedsUpdate();
Exists()363     sal_Bool Exists() { return bExists; }
364 };
365 
366 DECLARE_LIST( StarFileList, StarFile * )
367 
368 #define STAR_MODE_SINGLE_PARSE          0x0000
369 //#define STAR_MODE_RECURSIVE_PARSE     0x0001      it dosen't work anymore
370 #define STAR_MODE_MULTIPLE_PARSE        0x0002
371 
372 class Star : public StarList
373 {
374 private:
375     Link aDBNotFoundHdl;
376     ByteString      aStarName; // no idee what this should be
377 
378 protected:
379     vos:: OMutex  aMutex;
380 
381     sal_uInt16          nStarMode;
382     SolarFileList   aFileList;
383     StarFileList    aLoadedFilesList;
384     String          sSourceRoot;
385     String          sFileName;
386     SByteStringList* pDepMode;
387     SByteStringList* pAllDepMode;
388 
389     Link aFileIOErrorHdl; // called with &String as parameter!!!
390 
391     void InsertSolarList( String sProject );
392     String CreateFileName( String& rProject, String& rSourceRoot );
393 
394     void            Expand_Impl();
395     void            ExpandPrj_Impl( Prj *pPrj, Prj *pDepPrj );
396     sal_uIntPtr         SearchFileEntry( StarFileList *pStarFiles, StarFile* pFile );
397     void            InsertTokenLine (const ByteString& rToken, Prj** ppPrj, const ByteString& rProjectName, const sal_Bool bExtendAlias = sal_True);
398 
399 public:
400                     Star();
401                     Star( String aFileName, sal_uInt16 nMode = STAR_MODE_SINGLE_PARSE );
402                     Star( SolarFileList *pSolarFiles );
403                     Star( GenericInformationList *pStandLst, ByteString &rVersion );
404 
405                     ~Star();
406 
SetDBNotFoundHdl(const Link & rLink)407     void            SetDBNotFoundHdl( const Link &rLink ) { aDBNotFoundHdl = rLink; }
SetFileIOErrorHdl(const Link & rLink)408     void            SetFileIOErrorHdl( const Link &rLink ) { aFileIOErrorHdl = rLink; }
409 
GetName()410     ByteString      GetName(){ return aStarName; }; // dummy function of VG
411     void            Read( String &rFileName );
412     void            Read( SolarFileList *pSOlarFiles );
413 //  void            ReadXmlBuildList(const ByteString& sBuildLstPath);
414 
415 
416     sal_Bool            HasProject( ByteString aProjectName );
417     Prj*            GetPrj( ByteString aProjectName );
418     ByteString          GetPrjName( DirEntry &rPath );
419     sal_Bool            RemovePrj ( Prj* pPrj );
420     void            RemoveAllPrj ();
421 
422     StarFile*       ReadBuildlist (const String& rFilename, sal_Bool bReadComments = sal_False, sal_Bool bExtendAlias = sal_True);
423     sal_Bool            NeedsUpdate();
424     SolarFileList*  NeedsFilesForUpdate();
425     void            ReplaceFileEntry( StarFileList *pStarFiles, StarFile* pFile );
426     void            UpdateFileList( GenericInformationList *pStandLst, ByteString &rVersion, sal_Bool bRead = sal_False );
427     void            FullReload( GenericInformationList *pStandLst, ByteString &rVersion, sal_Bool bRead = sal_False );
428     void            GenerateFileLoadList( SolarFileList *pSolarFiles );
429     sal_Bool            CheckFileLoadList(SolarFileList *pSolarFiles);
430 
GetMode()431     sal_uInt16          GetMode() { return nStarMode; }
GetFileName()432     String          GetFileName(){ return sFileName; };
GetSourceRoot()433     String          GetSourceRoot(){ return sSourceRoot; };
434     SByteStringList* GetAvailableDeps ();
435     void            ClearAvailableDeps ();
GetCurrentDeps()436     SByteStringList* GetCurrentDeps () {return pDepMode;}
437     void            SetCurrentDeps (SByteStringList* pDepList);
438     void            ClearCurrentDeps ();
439 
440     int             GetOSType ( ByteString& aWhatOS );
441     int             GetJobType ( ByteString& JobType );
442 
443     void            ClearLoadedFilesList ();
444 
445     void            PutPrjIntoStream (SByteStringList* pPrjNameList, SvStream* pStream);
446     Star&           operator<<  ( SvStream& rStream );
447     Star&           operator>>  ( SvStream& rStream );
448 };
449 
450 class StarWriter : public Star
451 {
452 private:
453     sal_uInt16          WritePrj( Prj *pPrj, SvFileStream& rStream );
454 
455 public:
456                     StarWriter( String aFileName, sal_Bool bReadComments = sal_False, sal_uInt16 nMode = STAR_MODE_SINGLE_PARSE );
457                     StarWriter( SolarFileList *pSolarFiles, sal_Bool bReadComments = sal_False );
458                     StarWriter( GenericInformationList *pStandLst, ByteString &rVersion, ByteString &rMinor,
459                         sal_Bool bReadComments = sal_False );
460 
461     void            CleanUp();
462 
463     sal_Bool            InsertProject ( Prj* pNewPrj );
464     Prj*            RemoveProject ( ByteString aProjectName );
465 
466     sal_uInt16          Read( String aFileName, sal_Bool bReadComments = sal_False, sal_uInt16 nMode = STAR_MODE_SINGLE_PARSE  );
467     sal_uInt16          Read( SolarFileList *pSolarFiles, sal_Bool bReadComments = sal_False );
468     sal_uInt16          Write( String aFileName );
469     sal_uInt16          WriteMultiple( String rSourceRoot );
470 
471     void            InsertTokenLine ( const ByteString& rTokenLine );
472 };
473 
474 #endif
475 
476 
477