1*89b56da7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*89b56da7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*89b56da7SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*89b56da7SAndrew Rist * distributed with this work for additional information
6*89b56da7SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*89b56da7SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*89b56da7SAndrew Rist * "License"); you may not use this file except in compliance
9*89b56da7SAndrew Rist * with the License. You may obtain a copy of the License at
10*89b56da7SAndrew Rist *
11*89b56da7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*89b56da7SAndrew Rist *
13*89b56da7SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*89b56da7SAndrew Rist * software distributed under the License is distributed on an
15*89b56da7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*89b56da7SAndrew Rist * KIND, either express or implied. See the License for the
17*89b56da7SAndrew Rist * specific language governing permissions and limitations
18*89b56da7SAndrew Rist * under the License.
19*89b56da7SAndrew Rist *
20*89b56da7SAndrew Rist *************************************************************/
21*89b56da7SAndrew Rist
22*89b56da7SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_tools.hxx"
26cdf0e10cSrcweir #include <stdlib.h>
27cdf0e10cSrcweir #include <stdio.h>
28cdf0e10cSrcweir //#include "bootstrp/sstring.hxx"
29cdf0e10cSrcweir #include <vos/mutex.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <tools/stream.hxx>
32cdf0e10cSrcweir #include <tools/geninfo.hxx>
33cdf0e10cSrcweir #include "bootstrp/prj.hxx"
34cdf0e10cSrcweir #include "bootstrp/inimgr.hxx"
35cdf0e10cSrcweir
DECLARE_LIST(UniStringList,UniString *)36cdf0e10cSrcweir DECLARE_LIST( UniStringList, UniString* )
37cdf0e10cSrcweir
38cdf0e10cSrcweir //#define TEST 1
39cdf0e10cSrcweir
40cdf0e10cSrcweir #if defined(WNT) || defined(OS2)
41cdf0e10cSrcweir #define LIST_DELIMETER ';'
42cdf0e10cSrcweir #define PATH_DELIMETER '\\'
43cdf0e10cSrcweir #elif defined UNX
44cdf0e10cSrcweir #define LIST_DELIMETER ':'
45cdf0e10cSrcweir #define PATH_DELIMETER '/'
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir
48cdf0e10cSrcweir //Link Star::aDBNotFoundHdl;
49cdf0e10cSrcweir
50cdf0e10cSrcweir //
51cdf0e10cSrcweir // class SimpleConfig
52cdf0e10cSrcweir //
53cdf0e10cSrcweir
54cdf0e10cSrcweir /*****************************************************************************/
55cdf0e10cSrcweir SimpleConfig::SimpleConfig( String aSimpleConfigFileName )
56cdf0e10cSrcweir /*****************************************************************************/
57cdf0e10cSrcweir {
58cdf0e10cSrcweir nLine = 0;
59cdf0e10cSrcweir aFileName = aSimpleConfigFileName;
60cdf0e10cSrcweir aFileStream.Open ( aFileName, STREAM_READ );
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
63cdf0e10cSrcweir /*****************************************************************************/
SimpleConfig(DirEntry & rDirEntry)64cdf0e10cSrcweir SimpleConfig::SimpleConfig( DirEntry& rDirEntry )
65cdf0e10cSrcweir /*****************************************************************************/
66cdf0e10cSrcweir {
67cdf0e10cSrcweir nLine = 0;
68cdf0e10cSrcweir aFileName = rDirEntry.GetFull();
69cdf0e10cSrcweir aFileStream.Open ( aFileName, STREAM_READ );
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
72cdf0e10cSrcweir /*****************************************************************************/
~SimpleConfig()73cdf0e10cSrcweir SimpleConfig::~SimpleConfig()
74cdf0e10cSrcweir /*****************************************************************************/
75cdf0e10cSrcweir {
76cdf0e10cSrcweir aFileStream.Close ();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir /*****************************************************************************/
GetNext()80cdf0e10cSrcweir ByteString SimpleConfig::GetNext()
81cdf0e10cSrcweir /*****************************************************************************/
82cdf0e10cSrcweir {
83cdf0e10cSrcweir ByteString aString;
84cdf0e10cSrcweir
85cdf0e10cSrcweir if ( aStringBuffer =="" )
86cdf0e10cSrcweir while ((aStringBuffer = GetNextLine()) == "\t") ; //solange bis != "\t"
87cdf0e10cSrcweir if ( aStringBuffer =="" )
88cdf0e10cSrcweir return ByteString();
89cdf0e10cSrcweir
90cdf0e10cSrcweir aString = aStringBuffer.GetToken(0,'\t');
91cdf0e10cSrcweir aStringBuffer.Erase(0, aString.Len()+1);
92cdf0e10cSrcweir
93cdf0e10cSrcweir aStringBuffer.EraseLeadingChars( '\t' );
94cdf0e10cSrcweir
95cdf0e10cSrcweir return aString;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir /*****************************************************************************/
GetNextLine()99cdf0e10cSrcweir ByteString SimpleConfig::GetNextLine()
100cdf0e10cSrcweir /*****************************************************************************/
101cdf0e10cSrcweir {
102cdf0e10cSrcweir ByteString aSecStr;
103cdf0e10cSrcweir nLine++;
104cdf0e10cSrcweir
105cdf0e10cSrcweir aFileStream.ReadLine ( aTmpStr );
106cdf0e10cSrcweir if ( aTmpStr.Search( "#" ) == 0 )
107cdf0e10cSrcweir return "\t";
108cdf0e10cSrcweir aTmpStr = aTmpStr.EraseLeadingChars();
109cdf0e10cSrcweir aTmpStr = aTmpStr.EraseTrailingChars();
110cdf0e10cSrcweir while ( aTmpStr.SearchAndReplace(ByteString(' '),ByteString('\t') ) != STRING_NOTFOUND ) ;
111cdf0e10cSrcweir int nLength = aTmpStr.Len();
112cdf0e10cSrcweir sal_Bool bFound = sal_False;
113cdf0e10cSrcweir ByteString aEraseString;
114cdf0e10cSrcweir for ( sal_uInt16 i = 0; i<= nLength; i++)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir if ( aTmpStr.GetChar( i ) == 0x20 && !bFound )
117cdf0e10cSrcweir aTmpStr.SetChar( i, 0x09 );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir return aTmpStr;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir /*****************************************************************************/
GetCleanedNextLine(sal_Bool bReadComments)123cdf0e10cSrcweir ByteString SimpleConfig::GetCleanedNextLine( sal_Bool bReadComments )
124cdf0e10cSrcweir /*****************************************************************************/
125cdf0e10cSrcweir {
126cdf0e10cSrcweir
127cdf0e10cSrcweir aFileStream.ReadLine ( aTmpStr );
128cdf0e10cSrcweir if ( aTmpStr.Search( "#" ) == 0 )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir if (bReadComments )
131cdf0e10cSrcweir return aTmpStr;
132cdf0e10cSrcweir else
133cdf0e10cSrcweir while ( aTmpStr.Search( "#" ) == 0 )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir aFileStream.ReadLine ( aTmpStr );
136cdf0e10cSrcweir }
137cdf0e10cSrcweir }
138cdf0e10cSrcweir
139cdf0e10cSrcweir aTmpStr = aTmpStr.EraseLeadingChars();
140cdf0e10cSrcweir aTmpStr = aTmpStr.EraseTrailingChars();
141cdf0e10cSrcweir // while ( aTmpStr.SearchAndReplace(String(' '),String('\t') ) != (sal_uInt16)-1 );
142cdf0e10cSrcweir int nLength = aTmpStr.Len();
143cdf0e10cSrcweir ByteString aEraseString;
144cdf0e10cSrcweir sal_Bool bFirstTab = sal_True;
145cdf0e10cSrcweir for ( sal_uInt16 i = 0; i<= nLength; i++)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir if ( aTmpStr.GetChar( i ) == 0x20 )
148cdf0e10cSrcweir aTmpStr.SetChar( i, 0x09 );
149cdf0e10cSrcweir
150cdf0e10cSrcweir if ( aTmpStr.GetChar( i ) == 0x09 )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir if ( bFirstTab )
153cdf0e10cSrcweir bFirstTab = sal_False;
154cdf0e10cSrcweir else
155cdf0e10cSrcweir {
156cdf0e10cSrcweir aTmpStr.SetChar( i, 0x20 );
157cdf0e10cSrcweir }
158cdf0e10cSrcweir }
159cdf0e10cSrcweir else
160cdf0e10cSrcweir bFirstTab = sal_True;
161cdf0e10cSrcweir
162cdf0e10cSrcweir }
163cdf0e10cSrcweir aTmpStr.EraseAllChars(' ');
164cdf0e10cSrcweir return aTmpStr;
165cdf0e10cSrcweir
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
168