12fe1ca3dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
32fe1ca3dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42fe1ca3dSAndrew Rist * or more contributor license agreements. See the NOTICE file
52fe1ca3dSAndrew Rist * distributed with this work for additional information
62fe1ca3dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
72fe1ca3dSAndrew Rist * to you under the Apache License, Version 2.0 (the
82fe1ca3dSAndrew Rist * "License"); you may not use this file except in compliance
92fe1ca3dSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
112fe1ca3dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
132fe1ca3dSAndrew Rist * Unless required by applicable law or agreed to in writing,
142fe1ca3dSAndrew Rist * software distributed under the License is distributed on an
152fe1ca3dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162fe1ca3dSAndrew Rist * KIND, either express or implied. See the License for the
172fe1ca3dSAndrew Rist * specific language governing permissions and limitations
182fe1ca3dSAndrew Rist * under the License.
19cdf0e10cSrcweir *
202fe1ca3dSAndrew Rist *************************************************************/
212fe1ca3dSAndrew Rist
222fe1ca3dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_idlc.hxx"
26cdf0e10cSrcweir #include <idlc/idlc.hxx>
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir #include <rtl/strbuf.hxx>
29cdf0e10cSrcweir #include <osl/process.h>
30cdf0e10cSrcweir #include <osl/diagnose.h>
31cdf0e10cSrcweir #include <osl/thread.h>
32cdf0e10cSrcweir #include <osl/file.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #if defined(SAL_W32) || defined(SAL_OS2)
35cdf0e10cSrcweir #include <io.h>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir
38cdf0e10cSrcweir #ifdef SAL_UNX
39cdf0e10cSrcweir #include <unistd.h>
40cdf0e10cSrcweir #if defined(MACOSX) || defined(FREEBSD) || defined(NETBSD)
41cdf0e10cSrcweir #include <sys/wait.h>
42cdf0e10cSrcweir #else
43cdf0e10cSrcweir #include <wait.h>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir
47cdf0e10cSrcweir #include <string.h>
48cdf0e10cSrcweir
49cdf0e10cSrcweir using namespace ::rtl;
50cdf0e10cSrcweir using namespace ::osl;
51cdf0e10cSrcweir
52cdf0e10cSrcweir extern int yyparse();
53cdf0e10cSrcweir extern FILE* yyin;
54cdf0e10cSrcweir extern int yydebug;
55cdf0e10cSrcweir
56cdf0e10cSrcweir sal_Int32 lineNumber = 1;
57cdf0e10cSrcweir
58cdf0e10cSrcweir
59cdf0e10cSrcweir static OUString TMP(RTL_CONSTASCII_USTRINGPARAM("TMP"));
60cdf0e10cSrcweir static OUString TEMP(RTL_CONSTASCII_USTRINGPARAM("TEMP"));
61cdf0e10cSrcweir static sal_Char tmpFilePattern[512];
62cdf0e10cSrcweir
isFileUrl(const OString & fileName)63cdf0e10cSrcweir sal_Bool isFileUrl(const OString& fileName)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir if (fileName.indexOf("file://") == 0 )
66cdf0e10cSrcweir return sal_True;
67cdf0e10cSrcweir return sal_False;
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
convertToAbsoluteSystemPath(const OString & fileName)70cdf0e10cSrcweir OString convertToAbsoluteSystemPath(const OString& fileName)
71cdf0e10cSrcweir {
72cdf0e10cSrcweir OUString uSysFileName;
73cdf0e10cSrcweir OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
74cdf0e10cSrcweir if ( isFileUrl(fileName) )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir if (FileBase::getSystemPathFromFileURL(uFileName, uSysFileName)
77cdf0e10cSrcweir != FileBase::E_None)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir OSL_ASSERT(false);
80cdf0e10cSrcweir }
81cdf0e10cSrcweir } else
82cdf0e10cSrcweir {
83cdf0e10cSrcweir OUString uWorkingDir, uUrlFileName, uTmp;
84cdf0e10cSrcweir if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir OSL_ASSERT(false);
87cdf0e10cSrcweir }
88cdf0e10cSrcweir if (FileBase::getFileURLFromSystemPath(uFileName, uTmp)
89cdf0e10cSrcweir != FileBase::E_None)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir OSL_ASSERT(false);
92cdf0e10cSrcweir }
93cdf0e10cSrcweir if (FileBase::getAbsoluteFileURL(uWorkingDir, uTmp, uUrlFileName)
94cdf0e10cSrcweir != FileBase::E_None)
95cdf0e10cSrcweir {
96cdf0e10cSrcweir OSL_ASSERT(false);
97cdf0e10cSrcweir }
98cdf0e10cSrcweir if (FileBase::getSystemPathFromFileURL(uUrlFileName, uSysFileName)
99cdf0e10cSrcweir != FileBase::E_None)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir OSL_ASSERT(false);
102cdf0e10cSrcweir }
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir return OUStringToOString(uSysFileName, osl_getThreadTextEncoding());
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
convertToFileUrl(const OString & fileName)108cdf0e10cSrcweir OString convertToFileUrl(const OString& fileName)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir if ( !isFileUrl(fileName) )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir OString tmp = convertToAbsoluteSystemPath(fileName);
113cdf0e10cSrcweir OUString uFileName(tmp.getStr(), tmp.getLength(), osl_getThreadTextEncoding());
114cdf0e10cSrcweir OUString uUrlFileName;
115cdf0e10cSrcweir if (FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName)
116cdf0e10cSrcweir != FileBase::E_None)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir OSL_ASSERT(false);
119cdf0e10cSrcweir }
120cdf0e10cSrcweir return OUStringToOString(uUrlFileName, osl_getThreadTextEncoding());
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
123cdf0e10cSrcweir return fileName;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
makeTempName(const OString & prefix)126cdf0e10cSrcweir OString makeTempName(const OString& prefix)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir OUString uTmpPath;
129cdf0e10cSrcweir OString tmpPath;
130cdf0e10cSrcweir
131cdf0e10cSrcweir if ( osl_getEnvironment(TMP.pData, &uTmpPath.pData) != osl_Process_E_None )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir if ( osl_getEnvironment(TEMP.pData, &uTmpPath.pData) != osl_Process_E_None )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir #if defined(SAL_W32)
136cdf0e10cSrcweir tmpPath = OString("c:\\temp");
137cdf0e10cSrcweir #else
138cdf0e10cSrcweir tmpPath = OString("/tmp");
139cdf0e10cSrcweir #endif
140cdf0e10cSrcweir }
141cdf0e10cSrcweir }
142cdf0e10cSrcweir
143cdf0e10cSrcweir if ( uTmpPath.getLength() )
144cdf0e10cSrcweir tmpPath = OUStringToOString(uTmpPath, RTL_TEXTENCODING_UTF8);
145cdf0e10cSrcweir
146cdf0e10cSrcweir #if defined(SAL_W32) || defined(SAL_UNX) || defined(SAL_OS2)
147cdf0e10cSrcweir
148*24c56ab9SHerbert Dürr OSL_ASSERT( sizeof(tmpFilePattern) > ( tmpPath.getLength()
149cdf0e10cSrcweir + RTL_CONSTASCII_LENGTH(
150cdf0e10cSrcweir PATH_SEPARATOR )
151cdf0e10cSrcweir + prefix.getLength()
152cdf0e10cSrcweir + RTL_CONSTASCII_LENGTH(
153cdf0e10cSrcweir "XXXXXX") ) );
154cdf0e10cSrcweir
155cdf0e10cSrcweir tmpFilePattern[ sizeof(tmpFilePattern)-1 ] = '\0';
156*24c56ab9SHerbert Dürr strncpy(tmpFilePattern, tmpPath.getStr(), sizeof(tmpFilePattern)-1);
157cdf0e10cSrcweir strncat(tmpFilePattern, PATH_SEPARATOR, sizeof(tmpFilePattern)-1-strlen(tmpFilePattern));
158cdf0e10cSrcweir strncat(tmpFilePattern, prefix.getStr(), sizeof(tmpFilePattern)-1-strlen(tmpFilePattern));
159cdf0e10cSrcweir strncat(tmpFilePattern, "XXXXXX", sizeof(tmpFilePattern)-1-strlen(tmpFilePattern));
160cdf0e10cSrcweir
161cdf0e10cSrcweir #ifdef SAL_UNX
162cdf0e10cSrcweir int nDescriptor = mkstemp(tmpFilePattern);
163cdf0e10cSrcweir if( -1 == nDescriptor )
164cdf0e10cSrcweir {
1655979ef3cSJürgen Schmidt fprintf( stderr,"idlc: couldn't create temporary file %s\n", tmpFilePattern );
166cdf0e10cSrcweir exit( 1 );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir // the file shall later be reopened by stdio functions
169cdf0e10cSrcweir close( nDescriptor );
170cdf0e10cSrcweir #else
171cdf0e10cSrcweir (void) mktemp(tmpFilePattern);
172cdf0e10cSrcweir #endif
173cdf0e10cSrcweir #endif
174cdf0e10cSrcweir
175cdf0e10cSrcweir return OString(tmpFilePattern);
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
copyFile(const OString * source,const OString & target)178cdf0e10cSrcweir sal_Bool copyFile(const OString* source, const OString& target)
179cdf0e10cSrcweir {
180cdf0e10cSrcweir sal_Bool bRet = sal_True;
181cdf0e10cSrcweir
182cdf0e10cSrcweir FILE* pSource = source == 0 ? stdin : fopen(source->getStr(), "rb");
183cdf0e10cSrcweir if ( !pSource )
184cdf0e10cSrcweir return sal_False;
185cdf0e10cSrcweir
186cdf0e10cSrcweir FILE* pTarget = fopen(target.getStr(), "wb");
187cdf0e10cSrcweir if ( !pTarget )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir fclose(pSource);
190cdf0e10cSrcweir return sal_False;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
193cdf0e10cSrcweir size_t totalSize = 512;
194cdf0e10cSrcweir size_t readSize = 0;
195cdf0e10cSrcweir size_t writeSize = 0;
196cdf0e10cSrcweir char pBuffer[513];
197cdf0e10cSrcweir
198cdf0e10cSrcweir while ( !feof(pSource) )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir if ( (readSize = fread(pBuffer, 1, totalSize, pSource)) > 0 && !ferror(pSource) )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir if ( (writeSize = fwrite(pBuffer, 1, readSize, pTarget)) != readSize || ferror(pTarget) )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir if (source != 0) {
205cdf0e10cSrcweir fclose(pSource);
206cdf0e10cSrcweir }
207cdf0e10cSrcweir fclose(pTarget);
208cdf0e10cSrcweir return sal_False;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir }
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
213cdf0e10cSrcweir if (source != 0) {
214cdf0e10cSrcweir fclose(pSource);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir if ( fflush(pTarget) )
217cdf0e10cSrcweir bRet = sal_False;
218cdf0e10cSrcweir fclose(pTarget);
219cdf0e10cSrcweir
220cdf0e10cSrcweir return bRet;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir
compileFile(const OString * pathname)223cdf0e10cSrcweir sal_Int32 compileFile(const OString * pathname)
224cdf0e10cSrcweir {
225cdf0e10cSrcweir // preprocess input file
226cdf0e10cSrcweir OString tmpFile = makeTempName(OString("idli_"));
227cdf0e10cSrcweir OString preprocFile = makeTempName(OString("idlf_"));
228cdf0e10cSrcweir
229cdf0e10cSrcweir OString fileName;
230cdf0e10cSrcweir if (pathname == 0) {
231cdf0e10cSrcweir fileName = "stdin";
232cdf0e10cSrcweir } else {
233cdf0e10cSrcweir fileName = *pathname;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir if ( !copyFile(pathname, tmpFile) )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir fprintf(stderr, "%s: could not copy %s%s to %s\n",
239cdf0e10cSrcweir idlc()->getOptions()->getProgramName().getStr(),
240cdf0e10cSrcweir pathname == 0 ? "" : "file ", fileName.getStr(),
241cdf0e10cSrcweir tmpFile.getStr());
242cdf0e10cSrcweir exit(99);
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
245cdf0e10cSrcweir idlc()->setFileName(fileName);
246cdf0e10cSrcweir idlc()->setMainFileName(fileName);
247cdf0e10cSrcweir idlc()->setRealFileName(tmpFile);
248cdf0e10cSrcweir
2495979ef3cSJürgen Schmidt ::std::vector< ::rtl::OUString > lCppArgs;
2505979ef3cSJürgen Schmidt lCppArgs.push_back(OUString(RTL_CONSTASCII_USTRINGPARAM("-DIDL")));
2515979ef3cSJürgen Schmidt lCppArgs.push_back(OUString(RTL_CONSTASCII_USTRINGPARAM("-C")));
2525979ef3cSJürgen Schmidt lCppArgs.push_back(OUString(RTL_CONSTASCII_USTRINGPARAM("-zI")));
2535979ef3cSJürgen Schmidt lCppArgs.push_back(OUString(RTL_CONSTASCII_USTRINGPARAM("-I.")));
2545979ef3cSJürgen Schmidt
2555979ef3cSJürgen Schmidt OStringBuffer cppArgs(256);
256cdf0e10cSrcweir Options* pOptions = idlc()->getOptions();
257cdf0e10cSrcweir
258cdf0e10cSrcweir OString filePath;
259cdf0e10cSrcweir sal_Int32 index = fileName.lastIndexOf(SEPARATOR);
260cdf0e10cSrcweir
261cdf0e10cSrcweir if ( index > 0)
262cdf0e10cSrcweir {
263cdf0e10cSrcweir filePath = fileName.copy(0, index);
264cdf0e10cSrcweir
265cdf0e10cSrcweir if ( filePath.getLength() )
266cdf0e10cSrcweir {
2675979ef3cSJürgen Schmidt cppArgs.append("-I");
268cdf0e10cSrcweir cppArgs.append(filePath);
2695979ef3cSJürgen Schmidt lCppArgs.push_back(OStringToOUString(cppArgs.makeStringAndClear().replace('\\', '/'), RTL_TEXTENCODING_UTF8));
270cdf0e10cSrcweir }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir if ( pOptions->isValid("-D") )
274cdf0e10cSrcweir {
2755979ef3cSJürgen Schmidt OString dOpt = pOptions->getOption("-D");
2765979ef3cSJürgen Schmidt OString token;
2775979ef3cSJürgen Schmidt sal_Int32 nIndex = 0;
2785979ef3cSJürgen Schmidt do
2795979ef3cSJürgen Schmidt {
2805979ef3cSJürgen Schmidt token = dOpt.getToken( 0, ' ', nIndex );
2815979ef3cSJürgen Schmidt if (token.getLength())
2825979ef3cSJürgen Schmidt {
2835979ef3cSJürgen Schmidt lCppArgs.push_back(OStringToOUString(token, RTL_TEXTENCODING_UTF8));
284cdf0e10cSrcweir }
2855979ef3cSJürgen Schmidt } while( nIndex != -1 );
2865979ef3cSJürgen Schmidt }
2875979ef3cSJürgen Schmidt
288cdf0e10cSrcweir if ( pOptions->isValid("-I") )
289cdf0e10cSrcweir {
2905979ef3cSJürgen Schmidt OString incOpt = pOptions->getOption("-I");
2915979ef3cSJürgen Schmidt OString token;
2925979ef3cSJürgen Schmidt sal_Int32 nIndex = 0;
2935979ef3cSJürgen Schmidt do
294cdf0e10cSrcweir {
2955979ef3cSJürgen Schmidt token = incOpt.getToken( 0, ' ', nIndex );
2965979ef3cSJürgen Schmidt if (token.getLength())
2975979ef3cSJürgen Schmidt {
2985979ef3cSJürgen Schmidt lCppArgs.push_back(OStringToOUString(token, RTL_TEXTENCODING_UTF8));
299cdf0e10cSrcweir }
3005979ef3cSJürgen Schmidt } while( nIndex != -1 );
301cdf0e10cSrcweir }
302cdf0e10cSrcweir
3035979ef3cSJürgen Schmidt lCppArgs.push_back(OUString(RTL_CONSTASCII_USTRINGPARAM("-o")));
3045979ef3cSJürgen Schmidt
3055979ef3cSJürgen Schmidt cppArgs.append(preprocFile);
3065979ef3cSJürgen Schmidt lCppArgs.push_back(OStringToOUString(cppArgs.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
3075979ef3cSJürgen Schmidt
3085979ef3cSJürgen Schmidt cppArgs.append(tmpFile);
3095979ef3cSJürgen Schmidt lCppArgs.push_back(OStringToOUString(cppArgs.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
310cdf0e10cSrcweir
311cdf0e10cSrcweir OUString cpp;
312cdf0e10cSrcweir OUString startDir;
313cdf0e10cSrcweir if (osl_getExecutableFile(&cpp.pData) != osl_Process_E_None) {
314cdf0e10cSrcweir OSL_ASSERT(false);
315cdf0e10cSrcweir }
316cdf0e10cSrcweir
317cdf0e10cSrcweir sal_Int32 idx= cpp.lastIndexOf(OUString( RTL_CONSTASCII_USTRINGPARAM("idlc")) );
318cdf0e10cSrcweir cpp = cpp.copy(0, idx);
319cdf0e10cSrcweir
320cdf0e10cSrcweir #if defined(SAL_W32) || defined(SAL_OS2)
3215979ef3cSJürgen Schmidt cpp += OUString( RTL_CONSTASCII_USTRINGPARAM("ucpp.exe"));
322cdf0e10cSrcweir #else
3235979ef3cSJürgen Schmidt cpp += OUString( RTL_CONSTASCII_USTRINGPARAM("ucpp"));
324cdf0e10cSrcweir #endif
325cdf0e10cSrcweir
326cdf0e10cSrcweir oslProcess hProcess = NULL;
327cdf0e10cSrcweir oslProcessError procError = osl_Process_E_None;
328cdf0e10cSrcweir
3295979ef3cSJürgen Schmidt const int nCmdArgs = lCppArgs.size();
3305979ef3cSJürgen Schmidt rtl_uString** pCmdArgs = 0;
3315979ef3cSJürgen Schmidt pCmdArgs = (rtl_uString**)rtl_allocateZeroMemory(nCmdArgs * sizeof(rtl_uString*));
3325979ef3cSJürgen Schmidt
3335979ef3cSJürgen Schmidt ::std::vector< ::rtl::OUString >::iterator iter = lCppArgs.begin();
3345979ef3cSJürgen Schmidt ::std::vector< ::rtl::OUString >::iterator end = lCppArgs.end();
3355979ef3cSJürgen Schmidt int i = 0;
3365979ef3cSJürgen Schmidt while ( iter != end ) {
3375979ef3cSJürgen Schmidt pCmdArgs[i++] = (*iter).pData;
3385979ef3cSJürgen Schmidt ++iter;
3395979ef3cSJürgen Schmidt }
3405979ef3cSJürgen Schmidt
3415979ef3cSJürgen Schmidt procError = osl_executeProcess(cpp.pData, pCmdArgs, nCmdArgs, osl_Process_WAIT,
342cdf0e10cSrcweir 0, startDir.pData, 0, 0, &hProcess);
343cdf0e10cSrcweir
344cdf0e10cSrcweir oslProcessInfo hInfo;
345cdf0e10cSrcweir hInfo.Size = (sal_uInt32)(sizeof(oslProcessInfo));
346cdf0e10cSrcweir if (osl_getProcessInfo(hProcess, osl_Process_EXITCODE, &hInfo)
347cdf0e10cSrcweir != osl_Process_E_None)
348cdf0e10cSrcweir {
349cdf0e10cSrcweir OSL_ASSERT(false);
350cdf0e10cSrcweir }
351cdf0e10cSrcweir
352cdf0e10cSrcweir if ( procError || (hInfo.Code != 0) )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir if ( procError != osl_Process_E_None )
355cdf0e10cSrcweir fprintf(stderr, "%s: starting preprocessor failed\n", pOptions->getProgramName().getStr());
356cdf0e10cSrcweir else
357cdf0e10cSrcweir fprintf(stderr, "%s: preprocessing %s%s failed\n",
358cdf0e10cSrcweir pOptions->getProgramName().getStr(),
359cdf0e10cSrcweir pathname == 0 ? "" : "file ", fileName.getStr());
360cdf0e10cSrcweir
3615979ef3cSJürgen Schmidt // unlink(tmpFile.getStr());
3625979ef3cSJürgen Schmidt // unlink(preprocFile.getStr());
3635979ef3cSJürgen Schmidt // unlink(cmdFileName.getStr());
364cdf0e10cSrcweir osl_freeProcessHandle(hProcess);
3655979ef3cSJürgen Schmidt rtl_freeMemory(pCmdArgs);
366cdf0e10cSrcweir exit(hInfo.Code ? hInfo.Code : 99);
367cdf0e10cSrcweir }
368cdf0e10cSrcweir osl_freeProcessHandle(hProcess);
3695979ef3cSJürgen Schmidt rtl_freeMemory(pCmdArgs);
370cdf0e10cSrcweir
371cdf0e10cSrcweir if (unlink(tmpFile.getStr()) != 0)
372cdf0e10cSrcweir {
373cdf0e10cSrcweir fprintf(stderr, "%s: Could not remove cpp input file %s\n",
374cdf0e10cSrcweir pOptions->getProgramName().getStr(), tmpFile.getStr());
375cdf0e10cSrcweir exit(99);
376cdf0e10cSrcweir }
377cdf0e10cSrcweir
378cdf0e10cSrcweir if ( pOptions->isValid("-E") )
379cdf0e10cSrcweir {
380*24c56ab9SHerbert Dürr if( unlink( preprocFile.getStr()) != 0)
381cdf0e10cSrcweir {
382cdf0e10cSrcweir fprintf(stderr, "%s: Could not remove parser input file %s\n",
383cdf0e10cSrcweir pOptions->getProgramName().getStr(), preprocFile.getStr());
384cdf0e10cSrcweir exit(99);
385cdf0e10cSrcweir }
386cdf0e10cSrcweir exit(0);
387cdf0e10cSrcweir }
388cdf0e10cSrcweir
389cdf0e10cSrcweir // parse file
390cdf0e10cSrcweir yyin = fopen(preprocFile.getStr(), "r");
391cdf0e10cSrcweir if (yyin == NULL)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir fprintf(stderr, "%s: Could not open cpp output file %s\n",
394cdf0e10cSrcweir pOptions->getProgramName().getStr(), preprocFile.getStr());
395cdf0e10cSrcweir exit(99);
396cdf0e10cSrcweir }
397cdf0e10cSrcweir
398cdf0e10cSrcweir //yydebug = 0 no trace information
399cdf0e10cSrcweir //yydebug = 1 parser produce trace information
400cdf0e10cSrcweir yydebug = 0;
401cdf0e10cSrcweir
402cdf0e10cSrcweir sal_Int32 nErrors = yyparse();
403cdf0e10cSrcweir nErrors = idlc()->getErrorCount();
404cdf0e10cSrcweir
405cdf0e10cSrcweir fclose(yyin);
406cdf0e10cSrcweir if (unlink(preprocFile.getStr()) != 0)
407cdf0e10cSrcweir {
408cdf0e10cSrcweir fprintf(stderr, "%s: Could not remove parser input file %s\n",
409cdf0e10cSrcweir pOptions->getProgramName().getStr(), preprocFile.getStr());
410cdf0e10cSrcweir exit(99);
411cdf0e10cSrcweir }
412cdf0e10cSrcweir
413cdf0e10cSrcweir return nErrors;
414cdf0e10cSrcweir }
415