diff options
-rw-r--r-- | sal/inc/rtl/bootstrap.h | 36 | ||||
-rw-r--r-- | sal/inc/rtl/bootstrap.hxx | 60 | ||||
-rw-r--r-- | sal/rtl/source/bootstrap.cxx | 333 | ||||
-rw-r--r-- | sal/rtl/source/cmdargs.cxx | 6 | ||||
-rw-r--r-- | sal/rtl/source/macro.hxx | 7 | ||||
-rw-r--r-- | sal/test/makefile.mk | 44 | ||||
-rw-r--r-- | sal/test/testbootstrap.cxx | 40 | ||||
-rwxr-xr-x | sal/util/sal.map | 6 |
8 files changed, 355 insertions, 177 deletions
diff --git a/sal/inc/rtl/bootstrap.h b/sal/inc/rtl/bootstrap.h index a9aeb6b32ec2..1cf92dff1251 100644 --- a/sal/inc/rtl/bootstrap.h +++ b/sal/inc/rtl/bootstrap.h @@ -2,9 +2,9 @@ * * $RCSfile: bootstrap.h,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jbu $ $Date: 2001-05-17 08:55:01 $ + * last change: $Author: kr $ $Date: 2001-08-30 11:51:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -164,6 +164,38 @@ void SAL_CALL rtl_bootstrap_setIniFileName( rtl_uString *pName ); sal_True. */ sal_Bool SAL_CALL rtl_bootstrap_get( rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault ); + + +typedef void * rtlBootstrapHandle; + +/** + Opens a bootstrap argument container. + @param pIniName [in] The name of the ini-file to use, if <code>NULL</code> defaults + to the excutables name + @return Handle for a boostrap argument container +*/ +rtlBootstrapHandle SAL_CALL rtl_bootstrap_args_open(rtl_uString * pIniName); + +/** + Closes a boostrap agument container. + @ param handle [in] The handle got by <code>rtl_bootstrap_args_open</code> +*/ +void SAL_CALL rtl_bootstrap_args_close(rtlBootstrapHandle handle); + +/** + @param handle [in] The handle got by <code>rtl_bootstrap_args_open</code> + @param pName [in] The name of the variable to be retrieved + @param ppValue [out] The result of the retrieval + @param pDefault [in] The default value for the retrieval, may be <code>NULL</code> + + @return The status of the retrieval, <code>sal_True</code> on success. +*/ +sal_Bool SAL_CALL rtl_bootstrap_get_from_handle(rtlBootstrapHandle handle, rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault); + + +void SAL_CALL rtl_bootstrap_get_iniName_from_handle(rtlBootstrapHandle handle, rtl_uString ** ppIniName); + + #ifdef __cplusplus } #endif diff --git a/sal/inc/rtl/bootstrap.hxx b/sal/inc/rtl/bootstrap.hxx index ec234f726f12..27d72c324cd4 100644 --- a/sal/inc/rtl/bootstrap.hxx +++ b/sal/inc/rtl/bootstrap.hxx @@ -2,9 +2,9 @@ * * $RCSfile: bootstrap.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jbu $ $Date: 2001-05-17 08:55:02 $ + * last change: $Author: kr $ $Date: 2001-08-30 11:51:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,6 +67,7 @@ namespace rtl { class Bootstrap { + void * _handle; public: /** @see rtl_bootstrap_setIniFileName @@ -96,6 +97,22 @@ namespace rtl const ::rtl::OUString &sName, ::rtl::OUString &outValue, const ::rtl::OUString &aDefault ); + + + inline Bootstrap(); + inline Bootstrap(const OUString & iniName); + inline ~Bootstrap(); + + inline sal_Bool getFrom(const ::rtl::OUString &sName, + ::rtl::OUString &outValue) const; + + + inline void getFrom(const ::rtl::OUString &sName, + ::rtl::OUString &outValue, + const ::rtl::OUString &aDefault) const; + + inline void getIniName(::rtl::OUString & iniName) const; + }; //---------------------------------------------------------------------------- @@ -118,5 +135,44 @@ namespace rtl { rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData ); } + + inline Bootstrap::Bootstrap() + { + _handle = 0; + } + + inline Bootstrap::Bootstrap(const OUString & iniName) + { + if(iniName.getLength()) + _handle = rtl_bootstrap_args_open(iniName.pData); + + else + _handle = 0; + } + + inline Bootstrap::~Bootstrap() + { + rtl_bootstrap_args_close(_handle); + } + + + inline sal_Bool Bootstrap::getFrom(const ::rtl::OUString &sName, + ::rtl::OUString &outValue) const + { + return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0); + } + + inline void Bootstrap::getFrom(const ::rtl::OUString &sName, + ::rtl::OUString &outValue, + const ::rtl::OUString &aDefault) const + { + rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData); + } + + inline void Bootstrap::getIniName(::rtl::OUString & iniName) const + { + rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData); + } + } #endif diff --git a/sal/rtl/source/bootstrap.cxx b/sal/rtl/source/bootstrap.cxx index 8dec2bcdb973..fde08b768760 100644 --- a/sal/rtl/source/bootstrap.cxx +++ b/sal/rtl/source/bootstrap.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bootstrap.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: rt $ $Date: 2001-07-26 10:01:41 $ + * last change: $Author: kr $ $Date: 2001-08-30 11:51:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,6 +65,7 @@ #include <osl/file.h> #include <osl/diagnose.h> #include <osl/mutex.hxx> +#include <osl/file.hxx> #include <rtl/bootstrap.h> #include <rtl/ustring.hxx> @@ -86,15 +87,15 @@ struct rtl_bootstrap_NameValue typedef ::std::list< struct rtl_bootstrap_NameValue > NameValueList; -static void getFromCommandLineArgs( rtl_uString **ppValue , rtl_uString *pName ) +static sal_Bool getFromCommandLineArgs( rtl_uString **ppValue , rtl_uString *pName ) { static NameValueList *pNameValueList = 0; if( ! pNameValueList ) { static NameValueList nameValueList; - sal_Int32 i = 0; + sal_Int32 nArgCount = osl_getCommandArgCount(); - for( ; i < nArgCount && ! *ppValue ; i ++ ) + for(sal_Int32 i = 0; i < nArgCount; ++ i) { rtl_uString *pArg = 0; osl_getCommandArg( i, &pArg ); @@ -128,6 +129,8 @@ static void getFromCommandLineArgs( rtl_uString **ppValue , rtl_uString *pName ) pNameValueList = &nameValueList; } + sal_Bool found = sal_False; + OUString name( pName ); for( NameValueList::iterator ii = pNameValueList->begin() ; ii != pNameValueList->end() ; @@ -136,9 +139,12 @@ static void getFromCommandLineArgs( rtl_uString **ppValue , rtl_uString *pName ) if( (*ii).sName.equals(name) ) { rtl_uString_assign( ppValue, (*ii).sValue.pData ); + found = sal_True; break; } } + + return found; } static ::rtl::OUString &getIniFileNameImpl() @@ -146,58 +152,35 @@ static ::rtl::OUString &getIniFileNameImpl() static OUString *pStaticName = 0; if( ! pStaticName ) { - rtl_uString *pFileName = 0; - ::rtl::OUString sVarName( RTL_CONSTASCII_USTRINGPARAM( "INIFILENAME")); - getFromCommandLineArgs( &pFileName , sVarName.pData ); - if( !pFileName ) + OUString fileName; + + OUString sVarName(RTL_CONSTASCII_USTRINGPARAM("INIFILENAME")); + if(!getFromCommandLineArgs(&fileName.pData, sVarName.pData)) { - rtl_uString *pExeName = 0; - osl_getExecutableFile( &pExeName ); + osl_getExecutableFile(&fileName.pData); - sal_Int32 n = pExeName->length; + // get rid of a potential executable extension + OUString progExt = OUString::createFromAscii(".bin"); + if(fileName.getLength() > progExt.getLength() + && fileName.copy(fileName.getLength() - progExt.getLength()).equalsIgnoreAsciiCase(progExt)) + fileName = fileName.copy(0, fileName.getLength() - progExt.getLength()); - if( n ) - { - sal_Int32 nCapacity = - rtl_uStringbuffer_newFromStringBuffer( - &pFileName, pExeName->length + 4, pExeName ); - - const sal_Char *pNewSuffix = SAL_CONFIGFILE(""); - OUString sOldSuffix( RTL_CONSTASCII_USTRINGPARAM( ".exe" ) ); - - if(pFileName->length > sOldSuffix.getLength() - && 0 == rtl_ustr_compareIgnoreAsciiCase_WithLength(pFileName->buffer + n - sOldSuffix.getLength(), - sOldSuffix.getLength(), - sOldSuffix.pData->buffer, - sOldSuffix.getLength())) - pFileName->length = pFileName->length - sOldSuffix.getLength(); - - sOldSuffix = OUString(RTL_CONSTASCII_USTRINGPARAM( ".bin" ) ); - if(pFileName->length > sOldSuffix.getLength() - && 0 == rtl_ustr_compareIgnoreAsciiCase_WithLength(pFileName->buffer + n - sOldSuffix.getLength(), - sOldSuffix.getLength(), - sOldSuffix.pData->buffer, - sOldSuffix.getLength())) - pFileName->length = pFileName->length - sOldSuffix.getLength(); - - - rtl_uStringbuffer_insert_ascii( - &pFileName, - &nCapacity, - pFileName->length, - pNewSuffix, - strlen(pNewSuffix) ); - } - rtl_uString_release( pExeName ); + progExt = OUString::createFromAscii(".exe"); + if(fileName.getLength() > progExt.getLength() + && fileName.copy(fileName.getLength() - progExt.getLength()).equalsIgnoreAsciiCase(progExt)) + fileName = fileName.copy(0, fileName.getLength() - progExt.getLength()); + + // append config file suffix + fileName += OUString(RTL_CONSTASCII_USTRINGPARAM(SAL_CONFIGFILE(""))); } static OUString theFileName; - if( pFileName ) - theFileName = pFileName; + if(fileName.getLength()) + theFileName = fileName; - rtl_uString_release( pFileName ); pStaticName = &theFileName; } + return *pStaticName; } @@ -210,66 +193,6 @@ static void getFileSize( oslFileHandle handle, sal_uInt64 *pSize ) osl_File_E_None == osl_setFilePos( handle, osl_Pos_Absolut, nOldPos ) ); } -static void getFromIniFile( rtl_uString **ppValue, rtl_uString *pName ) -{ - static NameValueList *pNameValueList = 0; - - if( !pNameValueList ) - { - static NameValueList nameValueList; - OUString &file = getIniFileNameImpl(); - oslFileHandle handle; - if( file.getLength() && - osl_File_E_None == osl_openFile( file.pData, &handle , osl_File_OpenFlag_Read ) ) - { - ByteSequence seq; - sal_uInt64 nSize = 0; - - getFileSize( handle, &nSize ); - while( sal_True ) - { - sal_uInt64 nPos; - if( osl_File_E_None != osl_getFilePos( handle, &nPos ) || - nPos >= nSize ) - { - break; - } - if(osl_File_E_None != osl_readLine( handle , (sal_Sequence ** ) &seq )) - { - break; - } - OString line( (const sal_Char * ) seq.getConstArray() , seq.getLength() ); - sal_Int32 nIndex = line.indexOf( '=' ); - struct rtl_bootstrap_NameValue nameValue; - if( nIndex >= 1 && nIndex +1 < line.getLength()) - { - nameValue.sName = - OStringToOUString( - line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US ); - nameValue.sValue = - OStringToOUString( - line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 ); - nameValueList.push_back( nameValue ); - } - } - osl_closeFile( handle ); - } - pNameValueList = &nameValueList; - } - - OUString name( pName ); - for( NameValueList::iterator ii = pNameValueList->begin() ; - ii != pNameValueList->end() ; - ++ii ) - { - if( (*ii).sName.equals(name) ) - { - rtl_uString_assign( ppValue, (*ii).sValue.pData ); - break; - } - } -} - static void getFromEnvironment( rtl_uString **ppValue, rtl_uString *pName ) { if( osl_Process_E_None != osl_getEnvironment( pName , ppValue ) ) @@ -285,20 +208,13 @@ static void getFromEnvironment( rtl_uString **ppValue, rtl_uString *pName ) } -static void getFromDefault( rtl_uString **ppValue, rtl_uString *pName, rtl_uString *pDefault ) +static void getFromList(NameValueList *pNameValueList, rtl_uString **ppValue, rtl_uString *pName) { - static NameValueList *pNameValueList = 0; + OUString name(pName); - if( !pNameValueList ) - { - static NameValueList nameValueList; - pNameValueList = &nameValueList; - } - - OUString name( pName ); - for( NameValueList::iterator ii = pNameValueList->begin() ; - ii != pNameValueList->end() ; - ++ii ) + for(NameValueList::iterator ii = pNameValueList->begin(); + ii != pNameValueList->end(); + ++ii) { if( (*ii).sName.equals(name) ) { @@ -306,13 +222,9 @@ static void getFromDefault( rtl_uString **ppValue, rtl_uString *pName, rtl_uStri break; } } - if( ! *ppValue ) - { - rtl_uString_assign( ppValue , pDefault ); - } } -static void getFlatArg(rtl_uString * pName, rtl_uString ** ppValue, rtl_uString * pDefault) +static void getValue(NameValueList *pNameValueList, rtl_uString * pName, rtl_uString ** ppValue, rtl_uString * pDefault) { static const OUString sysUserConfig(RTL_CONSTASCII_USTRINGPARAM("SYSUSERCONFIG")); static const OUString sysUserHome(RTL_CONSTASCII_USTRINGPARAM("SYSUSERHOME")); @@ -332,10 +244,10 @@ static void getFlatArg(rtl_uString * pName, rtl_uString ** ppValue, rtl_uString } else { - getFromCommandLineArgs( ppValue, pName ); - if( ! *ppValue ) + getFromCommandLineArgs(ppValue, pName); + if(!*ppValue) { - getFromIniFile( ppValue, pName ); + getFromList(pNameValueList, ppValue, pName); if( ! *ppValue ) { getFromEnvironment( ppValue, pName ); @@ -346,11 +258,151 @@ static void getFlatArg(rtl_uString * pName, rtl_uString ** ppValue, rtl_uString } } } + +#ifdef DEBUG + OString sName = OUStringToOString(OUString(pName), RTL_TEXTENCODING_ASCII_US); + OString sValue; + if(*ppValue) + sValue = OUStringToOString(OUString(*ppValue), RTL_TEXTENCODING_ASCII_US); + OSL_TRACE("bootstrap.cxx::getValue - name:%s value:%s\n", sName.getStr(), sValue.getStr()); +#endif } +typedef struct Bootstrap_Impl { + NameValueList _nameValueList; + OUString _iniName; +} Bootstrap_Impl; + +static void fillFromIniFile(Bootstrap_Impl * pBootstrap_Impl) +{ + OUString iniName = pBootstrap_Impl->_iniName; + +#ifdef DEBUG + OString sFile = OUStringToOString(iniName, RTL_TEXTENCODING_ASCII_US); + OSL_TRACE("bootstrap.cxx::fillFromIniFile - %s\n", sFile.getStr()); +#endif + + + oslFileHandle handle; + if(iniName.getLength() + && osl_File_E_None == osl_openFile(iniName.pData, &handle, osl_File_OpenFlag_Read)) + { + ByteSequence seq; + sal_uInt64 nSize = 0; + + getFileSize(handle, &nSize); + while( sal_True ) + { + sal_uInt64 nPos; + if(osl_File_E_None != osl_getFilePos(handle, &nPos) + || nPos >= nSize) + break; + + if(osl_File_E_None != osl_readLine(handle , (sal_Sequence ** ) &seq)) + break; + + OString line((const sal_Char *)seq.getConstArray(), seq.getLength()); + sal_Int32 nIndex = line.indexOf('='); + struct rtl_bootstrap_NameValue nameValue; + if(nIndex >= 1 && nIndex +1 < line.getLength()) + { + nameValue.sName = OStringToOUString(line.copy(0,nIndex).trim(), + RTL_TEXTENCODING_ASCII_US); + nameValue.sValue = OStringToOUString(line.copy(nIndex+1).trim(), + RTL_TEXTENCODING_UTF8); + + OString name_tmp = OUStringToOString(nameValue.sName, RTL_TEXTENCODING_ASCII_US); + OString value_tmp = OUStringToOString(nameValue.sValue, RTL_TEXTENCODING_UTF8); + OSL_TRACE("bootstrap.cxx: pushing: name=%s value=%s\n", name_tmp.getStr(), value_tmp.getStr()); + + pBootstrap_Impl->_nameValueList.push_back(nameValue); + } + } + osl_closeFile(handle); + } +#ifdef DEBUG + else + { + OString file_tmp = OUStringToOString(iniName, RTL_TEXTENCODING_ASCII_US); + OSL_TRACE("bootstrap.cxx: couldn't open file: %s", file_tmp.getStr()); + } +#endif +} extern "C" { + + +rtlBootstrapHandle SAL_CALL rtl_bootstrap_args_open(rtl_uString * pIniName) +{ + OUString workDir; + OUString iniName = OUString(pIniName); + + osl_getProcessWorkingDir(&workDir.pData); + FileBase::getAbsoluteFileURL(workDir, iniName, iniName); + + Bootstrap_Impl * pBootstrap_Impl = new Bootstrap_Impl; + + pBootstrap_Impl->_iniName = iniName; + fillFromIniFile(pBootstrap_Impl); + + return pBootstrap_Impl; +} + + +void SAL_CALL rtl_bootstrap_args_close(rtlBootstrapHandle handle) +{ + delete (Bootstrap_Impl *)handle; +} + +sal_Bool SAL_CALL rtl_bootstrap_get_from_handle(rtlBootstrapHandle handle, rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault) +{ + MutexGuard guard(Mutex::getGlobalMutex()); + + sal_Bool result = sal_False; + if(ppValue && pName) + { + if(handle) { + rtl_uString_release(*ppValue); + *ppValue = 0; + + getValue(&((Bootstrap_Impl *)handle)->_nameValueList, pName, ppValue, pDefault); + + + if(*ppValue) + { + OUString result = expandMacros(&((Bootstrap_Impl *)handle)->_nameValueList, OUString(*ppValue)); + + rtl_uString_assign(ppValue, result.pData ); + } + + if(!*ppValue) + rtl_uString_new(ppValue); + + else + result = sal_True; + } + else + result = rtl_bootstrap_get(pName, ppValue, pDefault); + } + + + return result; +} + +void SAL_CALL rtl_bootstrap_get_iniName_from_handle(rtlBootstrapHandle handle, rtl_uString ** ppIniName) +{ + if(ppIniName) + if(handle) + rtl_uString_assign(ppIniName, ((Bootstrap_Impl *)handle)->_iniName.pData); + + else { + const OUString & iniName = getIniFileNameImpl(); + + rtl_uString_assign(ppIniName, iniName.pData); + } +} + void SAL_CALL rtl_bootstrap_setIniFileName( rtl_uString *pName ) { MutexGuard guard( Mutex::getGlobalMutex() ); @@ -361,27 +413,20 @@ void SAL_CALL rtl_bootstrap_setIniFileName( rtl_uString *pName ) sal_Bool SAL_CALL rtl_bootstrap_get( rtl_uString *pName, rtl_uString **ppValue , rtl_uString *pDefault ) { MutexGuard guard( Mutex::getGlobalMutex() ); - OSL_ASSERT( ppValue ); - if( *ppValue ) - { - rtl_uString_release( *ppValue ); - *ppValue = 0; - } - getFlatArg(pName, ppValue, pDefault); + static Bootstrap_Impl * pBootstrap_Impl = 0; - if(*ppValue) { - OUString result = expandMacros(OUString(*ppValue)); + if(!pBootstrap_Impl) + { + static Bootstrap_Impl bootstrap_Impl; - rtl_uString_assign(ppValue, result.pData ); - } + bootstrap_Impl._iniName = getIniFileNameImpl(); + fillFromIniFile(&bootstrap_Impl); - if( ! *ppValue ) - { - rtl_uString_new( ppValue ); - return sal_False; + pBootstrap_Impl = &bootstrap_Impl; } - return sal_True; + + return rtl_bootstrap_get_from_handle(pBootstrap_Impl, pName, ppValue, pDefault); } } diff --git a/sal/rtl/source/cmdargs.cxx b/sal/rtl/source/cmdargs.cxx index 84aac80631af..ac09e62eaab0 100644 --- a/sal/rtl/source/cmdargs.cxx +++ b/sal/rtl/source/cmdargs.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cmdargs.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: kr $ $Date: 2001-06-15 13:53:53 $ + * last change: $Author: kr $ $Date: 2001-08-30 11:51:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -125,7 +125,7 @@ extern "C" oslProcessError err = osl_Process_E_None; if( nArg < g_nCommandArgCount ) { - OUString expandedArg = expandMacros(g_pCommandArgs[nArg]); + OUString expandedArg = expandMacros(NULL, g_pCommandArgs[nArg]); rtl_uString_assign( strCommandArg, expandedArg.pData ); } diff --git a/sal/rtl/source/macro.hxx b/sal/rtl/source/macro.hxx index 1502e22d5c42..feac06036565 100644 --- a/sal/rtl/source/macro.hxx +++ b/sal/rtl/source/macro.hxx @@ -2,9 +2,9 @@ * * $RCSfile: macro.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: kr $ $Date: 2001-06-15 13:53:53 $ + * last change: $Author: kr $ $Date: 2001-08-30 11:51:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,7 @@ #ifndef _RTL_MACRO_HXX #define _RTL_MACRO_HXX +#include <rtl/bootstrap.h> #include <rtl/ustring.hxx> /* @@ -70,7 +71,7 @@ http://udk.openoffice.org/common/man/spec/uno_default_bootstrapping.html for details. */ -::rtl::OUString SAL_CALL expandMacros(const ::rtl::OUString & argstr); +::rtl::OUString SAL_CALL expandMacros(rtlBootstrapHandle handle, const ::rtl::OUString & argstr); #endif diff --git a/sal/test/makefile.mk b/sal/test/makefile.mk index aa4de097ec84..9b5cd3b6b343 100644 --- a/sal/test/makefile.mk +++ b/sal/test/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: jbu $ $Date: 2001-08-17 12:52:47 $ +# last change: $Author: kr $ $Date: 2001-08-30 11:51:36 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -94,9 +94,7 @@ APP1OBJS= \ $(OBJ)$/testbyteseq.obj \ $(OBJ)$/testuri.obj \ $(OBJ)$/test.obj \ - $(OBJ)$/testlogfile.obj \ - $(OBJ)$/test_file.obj - + $(OBJ)$/testlogfile.obj OBJFILES= \ $(APP1OBJS) \ $(APP2OBJS) @@ -114,25 +112,41 @@ ALL : ALLTAR \ $(BIN)$/$(BOOTSTRAPSCRIPT) \ $(BIN)$/$(BOOTSTRAPINI) \ $(BIN)$/bootstraptest.ini \ - $(BIN)$/testbootstrap.bin \ - $(BIN)$/testbootstrap.Bin \ - $(BIN)$/testbootstrap.Exe + $(BIN)$/$(APP2TARGET).bin \ + $(BIN)$/$(APP2TARGET).Bin \ + $(BIN)$/$(APP2TARGET).Exe \ + $(BIN)$/bootstrap.pl + .IF "$(GUI)"=="UNX" -ALL: $(BIN)$/testbootstrap.exe +ALL: $(BIN)$/$(APP2TARGET).exe \ + $(BIN)$/inirc -$(BIN)$/testbootstrap.exe : $(APP2TARGETN) +$(BIN)$/$(APP2TARGET).exe : $(APP2TARGETN) cp $(APP2TARGETN) $@ +$(BIN)$/inirc: + echo "MYBOOTSTRAPTESTVALUE=auxaux" > $@ + +.ELSE + +ALL: $(BIN)$/ini.ini + +$(BIN)$/ini.ini: + echo MYBOOTSTRAPTESTVALUE=auxaux > $@ + .ENDIF -$(BIN)$/testbootstrap.bin : $(APP2TARGETN) +$(BIN)$/bootstrap.pl: + cp bootstrap.pl $@ + +$(BIN)$/$(APP2TARGET).bin : $(APP2TARGETN) cp $(APP2TARGETN) $@ -$(BIN)$/testbootstrap.Bin : $(APP2TARGETN) +$(BIN)$/$(APP2TARGET).Bin : $(APP2TARGETN) cp $(APP2TARGETN) $@ -$(BIN)$/testbootstrap.Exe : $(APP2TARGETN) +$(BIN)$/$(APP2TARGET).Exe : $(APP2TARGETN) cp $(APP2TARGETN) $@ .ELSE @@ -148,8 +162,8 @@ $(BIN)$/$(BOOTSTRAPSCRIPT) : $(BOOTSTRAPSCRIPT) chmod ug+x $@ .ENDIF -$(BIN)$/$(BOOTSTRAPINI) : testbootstrap.ini - $(MY_SCRIPTCAT) testbootstrap.ini > $@ +$(BIN)$/$(BOOTSTRAPINI) : $(APP2TARGET).ini + $(MY_SCRIPTCAT) $(APP2TARGET).ini > $@ $(BIN)$/bootstraptest.ini : bootstraptest.ini $(MY_SCRIPTCAT) bootstraptest.ini > $@ diff --git a/sal/test/testbootstrap.cxx b/sal/test/testbootstrap.cxx index c8d899f434c8..e36a89d4f238 100644 --- a/sal/test/testbootstrap.cxx +++ b/sal/test/testbootstrap.cxx @@ -10,7 +10,7 @@ using namespace ::rtl; -void main( int argc, char *argv[] ) +int main( int argc, char *argv[] ) { sal_Int32 nCount = rtl_getAppCommandArgCount(); fprintf( stdout, "rtl-commandargs (%d) real args:%i ", nCount, argc); @@ -26,14 +26,30 @@ void main( int argc, char *argv[] ) if( nCount == 0 ) { printf( "usage : testbootstrap <checkedValueOfMyBootstrapValue>\n" ); - exit( 1 ); + exit( 1 ); } + + OUString iniName; + Bootstrap::get(OUString(RTL_CONSTASCII_USTRINGPARAM("iniName")), iniName, OUString()); + + if(iniName.getLength()) + { + OString tmp_iniName = OUStringToOString(iniName, RTL_TEXTENCODING_ASCII_US); + fprintf(stderr, "using ini: %s\n", tmp_iniName.getStr()); + } + + Bootstrap bootstrap(iniName); + + OUString name( RTL_CONSTASCII_USTRINGPARAM( "MYBOOTSTRAPTESTVALUE" )); OUString myDefault( RTL_CONSTASCII_USTRINGPARAM( "default" )); OUString value; - Bootstrap::get( name, value, myDefault ); + + bootstrap.getFrom( name, value, myDefault ); + + sal_Bool result = sal_True; OUString para(OUString::createFromAscii( argv[1] )); if(para != value) @@ -42,17 +58,25 @@ void main( int argc, char *argv[] ) OString value_tmp = OUStringToOString(value, RTL_TEXTENCODING_ASCII_US); fprintf(stderr, "para(%s) != value(%s)\n", para_tmp.getStr(), value_tmp.getStr()); + + result = sal_False; } // test the default case name = OUString( RTL_CONSTASCII_USTRINGPARAM( "no_one_has_set_this_name" ) ); - OSL_ASSERT( ! Bootstrap::get( name, value ) ); + OSL_ASSERT( ! bootstrap.getFrom( name, value ) ); + result = result && !bootstrap.getFrom( name, value ); myDefault = OUString( RTL_CONSTASCII_USTRINGPARAM( "1" ) ); OUString myDefault2 = OUString( RTL_CONSTASCII_USTRINGPARAM( "2" ) ); - Bootstrap::get( name, value, myDefault ); - OSL_ASSERT( value == myDefault ); - Bootstrap::get( name, value, myDefault2 ); - OSL_ASSERT( value == myDefault2 ); + bootstrap.getFrom( name, value, myDefault ); + OSL_ASSERT( value == myDefault ); + result = result && (value == myDefault); + + bootstrap.getFrom( name, value, myDefault2 ); + OSL_ASSERT( value == myDefault2 ); + result = result && (value == myDefault2); + + return result; } diff --git a/sal/util/sal.map b/sal/util/sal.map index dccf1cf4fcf4..7a0bb8ba8be4 100755 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -456,6 +456,10 @@ UDK_3_0_0 { rtl_bootstrap_get; rtl_bootstrap_setIniFileName; + rtl_bootstrap_args_open; + rtl_bootstrap_args_close; + rtl_bootstrap_get_from_handle; + rtl_bootstrap_get_iniName_from_handle; rtl_getAppCommandArgCount; rtl_getAppCommandArg; @@ -469,6 +473,8 @@ UDK_3_0_0 { rtl_removeUnloadingListener; rtl_logfile_trace; + + local: *; }; |