1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
37 #include "bootstrp/prj.hxx"
39 #include <rtl/strbuf.hxx>
40 #include <tools/string.hxx>
41 #include <tools/fsys.hxx>
42 #include <tools/stream.hxx>
48 #define __GNU_LIBRARY__
49 #include <external/glibc/getopt.h>
52 class RscHrcDep
: public CppDep
58 virtual void Execute();
61 RscHrcDep::RscHrcDep() :
66 RscHrcDep::~RscHrcDep()
70 void RscHrcDep::Execute()
75 int main( int argc
, char** argv
)
79 char pFileNamePrefix
[255];
80 char pOutputFileName
[255];
81 char pSrsFileName
[255];
83 sal_Bool bSource
= sal_False
;
84 rtl::OStringBuffer aRespArg
;
85 // who needs anything but '/' ?
86 sal_Char cDelim
= '/';
88 RscHrcDep
*pDep
= new RscHrcDep
;
90 pOutputFileName
[0] = 0;
93 for ( int i
=1; i
<argc
; i
++)
95 strcpy( aBuf
, (const char *)argv
[i
] );
96 if ( aBuf
[0] == '-' && aBuf
[1] == 'p' && aBuf
[2] == '=' )
98 strcpy(pFileNamePrefix
, &aBuf
[3]);
100 if ( aBuf
[0] == '-' && aBuf
[1] == 'f' && aBuf
[2] == 'o' && aBuf
[3] == '=' )
102 strcpy(pOutputFileName
, &aBuf
[4]);
104 if ( aBuf
[0] == '-' && aBuf
[1] == 'f' && aBuf
[2] == 'p' && aBuf
[3] == '=' )
106 strcpy(pSrsFileName
, &aBuf
[4]);
107 String
aName( pSrsFileName
, osl_getThreadTextEncoding());
108 DirEntry
aDest( aName
);
109 aSrsBaseName
= aDest
.GetBase();
111 if (aBuf
[0] == '-' && aBuf
[1] == 'i' )
113 pDep
->AddSearchPath( &aBuf
[2] );
115 if (aBuf
[0] == '-' && aBuf
[1] == 'I' )
117 pDep
->AddSearchPath( &aBuf
[2] );
122 String
aRespName( &aBuf
[1], osl_getThreadTextEncoding());
123 SimpleConfig
aConfig( aRespName
);
124 while (!(aToken
= aConfig
.getNext()).isEmpty())
127 strcpy( aBuf2
, aToken
.getStr());
128 if ( aBuf
[0] == '-' && aBuf
[1] == 'p' && aBuf
[2] == '=' )
130 strcpy(pFileNamePrefix
, &aBuf
[3]);
132 if ( aBuf2
[0] == '-' && aBuf2
[1] == 'f' && aBuf2
[2] == 'o' )
134 strcpy(pOutputFileName
, &aBuf2
[3]);
136 if ( aBuf2
[0] == '-' && aBuf2
[1] == 'f' && aBuf2
[2] == 'p' )
138 strcpy(pSrsFileName
, &aBuf2
[3]);
139 String
aName( pSrsFileName
, osl_getThreadTextEncoding());
140 DirEntry
aDest( aName
);
141 aSrsBaseName
= aDest
.GetBase();
143 if (aBuf2
[0] == '-' && aBuf2
[1] == 'i' )
145 pDep
->AddSearchPath( &aBuf2
[2] );
147 if (aBuf2
[0] == '-' && aBuf2
[1] == 'I' )
149 pDep
->AddSearchPath( &aBuf2
[2] );
151 if (( aBuf2
[0] != '-' ) && ( aBuf2
[0] != '@' ))
153 pDep
->AddSource( &aBuf2
[0] );
154 aRespArg
.append(' ').append(&aBuf2
[0]);
163 c
= getopt( argc
, argv
,
164 "_abcdefghi:jklmnopqrstuvwxyzABCDEFGHI:JKLMNOPQRSTUVWXYZ1234567890/-+=.\\()\"");
174 printf("option a\n");
180 printf("option l with Value %s\n", optarg
);
182 pDep
->AddSource( optarg
);
188 printf("RscDep 1.0\n");
193 printf("Unknown getopt error\n");
200 String
aCwd(pFileNamePrefix
, osl_getThreadTextEncoding());
201 SvFileStream aOutStream
;
202 String
aOutputFileName( pOutputFileName
, osl_getThreadTextEncoding());
203 DirEntry
aOutEntry( aOutputFileName
);
204 String aOutPath
= aOutEntry
.GetPath().GetFull();
206 String
aFileName( aOutPath
);
209 aFileName
+= String(".", osl_getThreadTextEncoding());
210 aFileName
+= aSrsBaseName
;
211 aFileName
+= String(".dprr", osl_getThreadTextEncoding());
212 aOutStream
.Open( aFileName
, STREAM_WRITE
);
214 rtl::OStringBuffer aString
;
218 printf("further arguments : ");
220 aString
.append(rtl::OString(pSrsFileName
).replace('\\', cDelim
));
221 aString
.append(RTL_CONSTASCII_STRINGPARAM(" : " ));
223 while ( optind
< argc
)
228 aString
.append(argv
[optind
]);
229 pDep
->AddSource( argv
[optind
++]);
237 aString
.append(aRespArg
.makeStringAndClear());
239 std::vector
<rtl::OString
>& rLst
= pDep
->GetDepList();
240 size_t nCount
= rLst
.size();
242 aString
.append('\\');
243 aOutStream
.WriteLine( aString
.makeStringAndClear() );
245 for ( size_t j
= 0; j
< nCount
; ++j
)
247 rtl::OStringBuffer
aStr(rLst
[j
].replace('\\', cDelim
));
248 if ( j
!= (nCount
-1) )
250 aOutStream
.WriteLine(aStr
.makeStringAndClear());
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */