1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_l10ntools.hxx" 30*cdf0e10cSrcweir #include <stdio.h> 31*cdf0e10cSrcweir #include <tools/fsys.hxx> 32*cdf0e10cSrcweir #include <tools/stream.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir // local includes 35*cdf0e10cSrcweir #include "utf8conv.hxx" 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #define GSI_FILE_UNKNOWN 0x0000 38*cdf0e10cSrcweir #define GSI_FILE_OLDSTYLE 0x0001 39*cdf0e10cSrcweir #define GSI_FILE_L10NFRAMEWORK 0x0002 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir /*****************************************************************************/ 42*cdf0e10cSrcweir sal_uInt16 GetGSIFileType( SvStream &rStream ) 43*cdf0e10cSrcweir /*****************************************************************************/ 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir sal_uInt16 nFileType = GSI_FILE_UNKNOWN; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir sal_uLong nPos( rStream.Tell()); 48*cdf0e10cSrcweir rStream.Seek( STREAM_SEEK_TO_BEGIN ); 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir ByteString sLine; 51*cdf0e10cSrcweir while( !rStream.IsEof() && !sLine.Len()) 52*cdf0e10cSrcweir rStream.ReadLine( sLine ); 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir if( sLine.Len()) { 55*cdf0e10cSrcweir if( sLine.Search( "($$)" ) != STRING_NOTFOUND ) 56*cdf0e10cSrcweir nFileType = GSI_FILE_OLDSTYLE; 57*cdf0e10cSrcweir else 58*cdf0e10cSrcweir nFileType = GSI_FILE_L10NFRAMEWORK; 59*cdf0e10cSrcweir } 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir rStream.Seek( nPos ); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir return nFileType; 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir /*****************************************************************************/ 67*cdf0e10cSrcweir ByteString GetGSILineId( const ByteString &rLine, sal_uInt16 nFileType ) 68*cdf0e10cSrcweir /*****************************************************************************/ 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir ByteString sId; 71*cdf0e10cSrcweir switch ( nFileType ) { 72*cdf0e10cSrcweir case GSI_FILE_OLDSTYLE: 73*cdf0e10cSrcweir sId = rLine; 74*cdf0e10cSrcweir sId.SearchAndReplaceAll( "($$)", "\t" ); 75*cdf0e10cSrcweir sId = sId.GetToken( 0, '\t' ); 76*cdf0e10cSrcweir break; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir case GSI_FILE_L10NFRAMEWORK: 79*cdf0e10cSrcweir sId = rLine.GetToken( 0, '\t' ); 80*cdf0e10cSrcweir sId += "\t"; 81*cdf0e10cSrcweir sId += rLine.GetToken( 1, '\t' ); 82*cdf0e10cSrcweir sId += "\t"; 83*cdf0e10cSrcweir sId += rLine.GetToken( 4, '\t' ); 84*cdf0e10cSrcweir sId += "\t"; 85*cdf0e10cSrcweir sId += rLine.GetToken( 5, '\t' ); 86*cdf0e10cSrcweir break; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir return sId; 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir /*****************************************************************************/ 92*cdf0e10cSrcweir ByteString GetGSILineLangId( const ByteString &rLine, sal_uInt16 nFileType ) 93*cdf0e10cSrcweir /*****************************************************************************/ 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir ByteString sLangId; 96*cdf0e10cSrcweir switch ( nFileType ) { 97*cdf0e10cSrcweir case GSI_FILE_OLDSTYLE: 98*cdf0e10cSrcweir sLangId = rLine; 99*cdf0e10cSrcweir sLangId.SearchAndReplaceAll( "($$)", "\t" ); 100*cdf0e10cSrcweir sLangId = sLangId.GetToken( 2, '\t' ); 101*cdf0e10cSrcweir break; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir case GSI_FILE_L10NFRAMEWORK: 104*cdf0e10cSrcweir sLangId = rLine.GetToken( 9, '\t' ); 105*cdf0e10cSrcweir break; 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir return sLangId; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir /*****************************************************************************/ 111*cdf0e10cSrcweir void ConvertGSILine( sal_Bool bToUTF8, ByteString &rLine, 112*cdf0e10cSrcweir rtl_TextEncoding nEncoding, sal_uInt16 nFileType ) 113*cdf0e10cSrcweir /*****************************************************************************/ 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir switch ( nFileType ) { 116*cdf0e10cSrcweir case GSI_FILE_OLDSTYLE: 117*cdf0e10cSrcweir if ( bToUTF8 ) 118*cdf0e10cSrcweir rLine = UTF8Converter::ConvertToUTF8( rLine, nEncoding ); 119*cdf0e10cSrcweir else 120*cdf0e10cSrcweir rLine = UTF8Converter::ConvertFromUTF8( rLine, nEncoding ); 121*cdf0e10cSrcweir break; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir case GSI_FILE_L10NFRAMEWORK: { 124*cdf0e10cSrcweir ByteString sConverted; 125*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < rLine.GetTokenCount( '\t' ); i++ ) { 126*cdf0e10cSrcweir ByteString sToken = rLine.GetToken( i, '\t' ); 127*cdf0e10cSrcweir if (( i > 9 ) && ( i < 14 )) { 128*cdf0e10cSrcweir if( bToUTF8 ) 129*cdf0e10cSrcweir sToken = UTF8Converter::ConvertToUTF8( sToken, nEncoding ); 130*cdf0e10cSrcweir else 131*cdf0e10cSrcweir sToken = UTF8Converter::ConvertFromUTF8( sToken, nEncoding ); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir if ( i ) 134*cdf0e10cSrcweir sConverted += "\t"; 135*cdf0e10cSrcweir sConverted += sToken; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir rLine = sConverted; 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir break; 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir /*****************************************************************************/ 144*cdf0e10cSrcweir void Help() 145*cdf0e10cSrcweir /*****************************************************************************/ 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir fprintf( stdout, "\n" ); 148*cdf0e10cSrcweir fprintf( stdout, "gsiconv (c)1999 by StarOffice Entwicklungs GmbH\n" ); 149*cdf0e10cSrcweir fprintf( stdout, "===============================================\n" ); 150*cdf0e10cSrcweir fprintf( stdout, "\n" ); 151*cdf0e10cSrcweir fprintf( stdout, "gsiconv converts strings in GSI-Files (Gutschmitt Interface) from or to UTF-8\n" ); 152*cdf0e10cSrcweir fprintf( stdout, "\n" ); 153*cdf0e10cSrcweir fprintf( stdout, "Syntax: gsiconv (-t|-f langid charset)|(-p n) filename\n" ); 154*cdf0e10cSrcweir fprintf( stdout, "Switches: -t => conversion from charset to UTF-8\n" ); 155*cdf0e10cSrcweir fprintf( stdout, " -f => conversion from UTF-8 to charset\n" ); 156*cdf0e10cSrcweir fprintf( stdout, " -p n => creates several files with ca. n lines\n" ); 157*cdf0e10cSrcweir fprintf( stdout, "\n" ); 158*cdf0e10cSrcweir fprintf( stdout, "Allowed charsets:\n" ); 159*cdf0e10cSrcweir fprintf( stdout, " MS_932 => Japanese\n" ); 160*cdf0e10cSrcweir fprintf( stdout, " MS_936 => Chinese Simplified\n" ); 161*cdf0e10cSrcweir fprintf( stdout, " MS_949 => Korean\n" ); 162*cdf0e10cSrcweir fprintf( stdout, " MS_950 => Chinese Traditional\n" ); 163*cdf0e10cSrcweir fprintf( stdout, " MS_1250 => East Europe\n" ); 164*cdf0e10cSrcweir fprintf( stdout, " MS_1251 => Cyrillic\n" ); 165*cdf0e10cSrcweir fprintf( stdout, " MS_1252 => West Europe\n" ); 166*cdf0e10cSrcweir fprintf( stdout, " MS_1253 => Greek\n" ); 167*cdf0e10cSrcweir fprintf( stdout, " MS_1254 => Turkish\n" ); 168*cdf0e10cSrcweir fprintf( stdout, " MS_1255 => Hebrew\n" ); 169*cdf0e10cSrcweir fprintf( stdout, " MS_1256 => Arabic\n" ); 170*cdf0e10cSrcweir fprintf( stdout, "\n" ); 171*cdf0e10cSrcweir fprintf( stdout, "Allowed langids:\n" ); 172*cdf0e10cSrcweir fprintf( stdout, " 1 => ENGLISH_US\n" ); 173*cdf0e10cSrcweir fprintf( stdout, " 3 => PORTUGUESE \n" ); 174*cdf0e10cSrcweir fprintf( stdout, " 4 => GERMAN_DE (new german style)\n" ); 175*cdf0e10cSrcweir fprintf( stdout, " 7 => RUSSIAN\n" ); 176*cdf0e10cSrcweir fprintf( stdout, " 30 => GREEK\n" ); 177*cdf0e10cSrcweir fprintf( stdout, " 31 => DUTCH\n" ); 178*cdf0e10cSrcweir fprintf( stdout, " 33 => FRENCH\n" ); 179*cdf0e10cSrcweir fprintf( stdout, " 34 => SPANISH\n" ); 180*cdf0e10cSrcweir fprintf( stdout, " 35 => FINNISH\n" ); 181*cdf0e10cSrcweir fprintf( stdout, " 36 => HUNGARIAN\n" ); 182*cdf0e10cSrcweir fprintf( stdout, " 39 => ITALIAN\n" ); 183*cdf0e10cSrcweir fprintf( stdout, " 42 => CZECH\n" ); 184*cdf0e10cSrcweir fprintf( stdout, " 44 => ENGLISH (UK)\n" ); 185*cdf0e10cSrcweir fprintf( stdout, " 45 => DANISH\n" ); 186*cdf0e10cSrcweir fprintf( stdout, " 46 => SWEDISH\n" ); 187*cdf0e10cSrcweir fprintf( stdout, " 47 => NORWEGIAN\n" ); 188*cdf0e10cSrcweir fprintf( stdout, " 49 => GERMAN (old german style)\n" ); 189*cdf0e10cSrcweir fprintf( stdout, " 55 => PORTUGUESE_BRAZILIAN\n" ); 190*cdf0e10cSrcweir fprintf( stdout, " 81 => JAPANESE\n" ); 191*cdf0e10cSrcweir fprintf( stdout, " 82 => KOREAN\n" ); 192*cdf0e10cSrcweir fprintf( stdout, " 86 => CHINESE_SIMPLIFIED\n" ); 193*cdf0e10cSrcweir fprintf( stdout, " 88 => CHINESE_TRADITIONAL\n" ); 194*cdf0e10cSrcweir fprintf( stdout, " 90 => TURKISH\n" ); 195*cdf0e10cSrcweir fprintf( stdout, " 96 => ARABIC\n" ); 196*cdf0e10cSrcweir fprintf( stdout, " 97 => HEBREW\n" ); 197*cdf0e10cSrcweir fprintf( stdout, "\n" ); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir /*****************************************************************************/ 201*cdf0e10cSrcweir #if defined(UNX) || defined(OS2) 202*cdf0e10cSrcweir int main( int argc, char *argv[] ) 203*cdf0e10cSrcweir #else 204*cdf0e10cSrcweir int _cdecl main( int argc, char *argv[] ) 205*cdf0e10cSrcweir #endif 206*cdf0e10cSrcweir /*****************************************************************************/ 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir if (( argc != 5 ) && ( argc != 4 )) { 209*cdf0e10cSrcweir Help(); 210*cdf0e10cSrcweir exit ( 0 ); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir if ( argc == 4 ) { 214*cdf0e10cSrcweir if ( ByteString( argv[ 1 ] ) == "-p" ) { 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir DirEntry aSource = DirEntry( String( argv[ 3 ], RTL_TEXTENCODING_ASCII_US )); 217*cdf0e10cSrcweir if ( !aSource.Exists()) { 218*cdf0e10cSrcweir fprintf( stderr, "\nERROR: GSI-File %s not found!\n\n", ByteString( argv[ 3 ] ).GetBuffer()); 219*cdf0e10cSrcweir exit ( 2 ); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir DirEntry aOutput( aSource ); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir String sBase = aOutput.GetBase(); 225*cdf0e10cSrcweir String sExt = aOutput.GetExtension(); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir String sGSI( argv[ 3 ], RTL_TEXTENCODING_ASCII_US ); 228*cdf0e10cSrcweir SvFileStream aGSI( sGSI, STREAM_STD_READ ); 229*cdf0e10cSrcweir if ( !aGSI.IsOpen()) { 230*cdf0e10cSrcweir fprintf( stderr, "\nERROR: Could not open GSI-File %s!\n\n", ByteString( argv[ 3 ] ).GetBuffer()); 231*cdf0e10cSrcweir exit ( 3 ); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir sal_uInt16 nFileType( GetGSIFileType( aGSI )); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir sal_uLong nMaxLines = (sal_uLong) ByteString( argv[ 2 ] ).ToInt64(); 237*cdf0e10cSrcweir if ( !nMaxLines ) { 238*cdf0e10cSrcweir fprintf( stderr, "\nERROR: Linecount must be at least 1!\n\n" ); 239*cdf0e10cSrcweir exit ( 3 ); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir ByteString sGSILine; 243*cdf0e10cSrcweir ByteString sOldId; 244*cdf0e10cSrcweir sal_uLong nLine = 0; 245*cdf0e10cSrcweir sal_uLong nOutputFile = 1; 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir String sOutput( sBase ); 248*cdf0e10cSrcweir sOutput += String( "_", RTL_TEXTENCODING_ASCII_US ); 249*cdf0e10cSrcweir sOutput += String::CreateFromInt64( nOutputFile ); 250*cdf0e10cSrcweir if ( sExt.Len()) { 251*cdf0e10cSrcweir sOutput += String( ".", RTL_TEXTENCODING_ASCII_US ); 252*cdf0e10cSrcweir sOutput += sExt; 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir nOutputFile ++; 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir aOutput.SetName( sOutput ); 257*cdf0e10cSrcweir SvFileStream aOutputStream( aOutput.GetFull(), STREAM_STD_WRITE | STREAM_TRUNC ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir while ( !aGSI.IsEof()) { 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir aGSI.ReadLine( sGSILine ); 262*cdf0e10cSrcweir ByteString sId( GetGSILineId( sGSILine, nFileType )); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir nLine++; 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir if (( nLine >= nMaxLines ) && ( sId != sOldId )) { 267*cdf0e10cSrcweir aOutputStream.Close(); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir ByteString sText( aOutput.GetFull(), gsl_getSystemTextEncoding()); 270*cdf0e10cSrcweir sText += " with "; 271*cdf0e10cSrcweir sText += ByteString::CreateFromInt64( nLine ); 272*cdf0e10cSrcweir sText += " lines written."; 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir fprintf( stdout, "%s\n", sText.GetBuffer()); 275*cdf0e10cSrcweir String sOutput1( sBase ); 276*cdf0e10cSrcweir sOutput1 += String( "_", RTL_TEXTENCODING_ASCII_US ); 277*cdf0e10cSrcweir sOutput1 += String::CreateFromInt64( nOutputFile ); 278*cdf0e10cSrcweir if ( sExt.Len()) { 279*cdf0e10cSrcweir sOutput1 += String( ".", RTL_TEXTENCODING_ASCII_US ); 280*cdf0e10cSrcweir sOutput1 += sExt; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir nOutputFile ++; 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir aOutput.SetName( sOutput1 ); 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir aOutputStream.Open( aOutput.GetFull(), STREAM_STD_WRITE | STREAM_TRUNC ); 287*cdf0e10cSrcweir nLine = 0; 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir aOutputStream.WriteLine( sGSILine ); 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir sOldId = sId; 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir aGSI.Close(); 296*cdf0e10cSrcweir aOutputStream.Close(); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir ByteString sText( aOutput.GetFull(), RTL_TEXTENCODING_ASCII_US ); 299*cdf0e10cSrcweir sText += " with "; 300*cdf0e10cSrcweir sText += ByteString::CreateFromInt64( nLine ); 301*cdf0e10cSrcweir sText += " lines written."; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir else { 304*cdf0e10cSrcweir Help(); 305*cdf0e10cSrcweir exit( 1 ); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir else { 309*cdf0e10cSrcweir if ( ByteString( argv[ 1 ] ) == "-t" || ByteString( argv[ 1 ] ) == "-f" ) { 310*cdf0e10cSrcweir rtl_TextEncoding nEncoding; 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir ByteString sCurLangId( argv[ 2 ] ); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir ByteString sCharset( argv[ 3 ] ); 315*cdf0e10cSrcweir sCharset.ToUpperAscii(); 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir if ( sCharset == "MS_932" ) nEncoding = RTL_TEXTENCODING_MS_932; 318*cdf0e10cSrcweir else if ( sCharset == "MS_936" ) nEncoding = RTL_TEXTENCODING_MS_936; 319*cdf0e10cSrcweir else if ( sCharset == "MS_949" ) nEncoding = RTL_TEXTENCODING_MS_949; 320*cdf0e10cSrcweir else if ( sCharset == "MS_950" ) nEncoding = RTL_TEXTENCODING_MS_950; 321*cdf0e10cSrcweir else if ( sCharset == "MS_1250" ) nEncoding = RTL_TEXTENCODING_MS_1250; 322*cdf0e10cSrcweir else if ( sCharset == "MS_1251" ) nEncoding = RTL_TEXTENCODING_MS_1251; 323*cdf0e10cSrcweir else if ( sCharset == "MS_1252" ) nEncoding = RTL_TEXTENCODING_MS_1252; 324*cdf0e10cSrcweir else if ( sCharset == "MS_1253" ) nEncoding = RTL_TEXTENCODING_MS_1253; 325*cdf0e10cSrcweir else if ( sCharset == "MS_1254" ) nEncoding = RTL_TEXTENCODING_MS_1254; 326*cdf0e10cSrcweir else if ( sCharset == "MS_1255" ) nEncoding = RTL_TEXTENCODING_MS_1255; 327*cdf0e10cSrcweir else if ( sCharset == "MS_1256" ) nEncoding = RTL_TEXTENCODING_MS_1256; 328*cdf0e10cSrcweir else if ( sCharset == "MS_1257" ) nEncoding = RTL_TEXTENCODING_MS_1257; 329*cdf0e10cSrcweir else if ( sCharset == "UTF8" ) nEncoding = RTL_TEXTENCODING_UTF8; 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir else { 332*cdf0e10cSrcweir Help(); 333*cdf0e10cSrcweir exit ( 1 ); 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir DirEntry aSource = DirEntry( String( argv[ 4 ], RTL_TEXTENCODING_ASCII_US )); 337*cdf0e10cSrcweir if ( !aSource.Exists()) { 338*cdf0e10cSrcweir fprintf( stderr, "\nERROR: GSI-File %s not found!\n\n", ByteString( argv[ 3 ] ).GetBuffer()); 339*cdf0e10cSrcweir exit ( 2 ); 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir String sGSI( argv[ 4 ], RTL_TEXTENCODING_ASCII_US ); 343*cdf0e10cSrcweir SvFileStream aGSI( sGSI, STREAM_STD_READ ); 344*cdf0e10cSrcweir if ( !aGSI.IsOpen()) { 345*cdf0e10cSrcweir fprintf( stderr, "\nERROR: Could not open GSI-File %s!\n\n", ByteString( argv[ 3 ] ).GetBuffer()); 346*cdf0e10cSrcweir exit ( 3 ); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir sal_uInt16 nFileType( GetGSIFileType( aGSI )); 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir ByteString sGSILine; 351*cdf0e10cSrcweir while ( !aGSI.IsEof()) { 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir aGSI.ReadLine( sGSILine ); 354*cdf0e10cSrcweir ByteString sLangId( GetGSILineLangId( sGSILine, nFileType )); 355*cdf0e10cSrcweir if ( sLangId == sCurLangId ) 356*cdf0e10cSrcweir ConvertGSILine(( ByteString( argv[ 1 ] ) == "-t" ), sGSILine, nEncoding, nFileType ); 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir fprintf( stdout, "%s\n", sGSILine.GetBuffer()); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir aGSI.Close(); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir else { 364*cdf0e10cSrcweir Help(); 365*cdf0e10cSrcweir exit( 1 ); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir return 0; 369*cdf0e10cSrcweir } 370