diff options
author | Daniel Boelzle <dbo@openoffice.org> | 2002-10-21 14:07:37 +0000 |
---|---|---|
committer | Daniel Boelzle <dbo@openoffice.org> | 2002-10-21 14:07:37 +0000 |
commit | 04207901c0efb0bcb492ad30a4beca222455c068 (patch) | |
tree | c100977a6df76c11a855fee33a640da1e342c256 /sal | |
parent | 4d9c6c4cc2cb7a638744c033b472a2456b2345af (diff) |
#104367# added rtl_bootstrap_set()
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/source/bootstrap.cxx | 65 | ||||
-rwxr-xr-x | sal/util/sal.map | 1 |
2 files changed, 56 insertions, 10 deletions
diff --git a/sal/rtl/source/bootstrap.cxx b/sal/rtl/source/bootstrap.cxx index 497a333de7fa..a007356f3735 100644 --- a/sal/rtl/source/bootstrap.cxx +++ b/sal/rtl/source/bootstrap.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bootstrap.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: dbo $ $Date: 2002-08-19 07:59:31 $ + * last change: $Author: dbo $ $Date: 2002-10-21 15:06:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -206,6 +206,14 @@ struct rtl_bootstrap_NameValue { rtl::OUString sName; rtl::OUString sValue; + + inline rtl_bootstrap_NameValue() SAL_THROW( () ) + {} + inline rtl_bootstrap_NameValue( + OUString const & name, OUString const & value ) SAL_THROW( () ) + : sName( name ), + sValue( value ) + {} }; typedef std::list< @@ -362,6 +370,9 @@ static void getFromList(NameValueList *pNameValueList, rtl_uString **ppValue, rt } } +static NameValueList s_rtl_bootstrap_set_list; + + static sal_Bool getValue(NameValueList *pNameValueList, rtl_uString * pName, rtl_uString ** ppValue, rtl_uString * pDefault) { static const OUString sysUserConfig(RTL_CONSTASCII_USTRINGPARAM("SYSUSERCONFIG")); @@ -388,19 +399,23 @@ static sal_Bool getValue(NameValueList *pNameValueList, rtl_uString * pName, rtl else { - getFromCommandLineArgs(ppValue, pName); - if(!*ppValue) + getFromList( &s_rtl_bootstrap_set_list, ppValue, pName ); + if (! *ppValue) { - getFromList(pNameValueList, ppValue, pName); - if( ! *ppValue ) + getFromCommandLineArgs(ppValue, pName); + if(!*ppValue) { - getFromEnvironment( ppValue, pName ); + getFromList(pNameValueList, ppValue, pName); if( ! *ppValue ) { - result = sal_False; + getFromEnvironment( ppValue, pName ); + if( ! *ppValue ) + { + result = sal_False; - if(pDefault) - rtl_uString_assign( ppValue , pDefault ); + if(pDefault) + rtl_uString_assign( ppValue , pDefault ); + } } } } @@ -600,6 +615,36 @@ sal_Bool SAL_CALL rtl_bootstrap_get( rtl_uString *pName, rtl_uString **ppValue , get_static_bootstrap_handle(), pName, ppValue, pDefault); } +void SAL_CALL rtl_bootstrap_set( rtl_uString * pName, rtl_uString * pValue ) + SAL_THROW_EXTERN_C() +{ + OUString const & name = *reinterpret_cast< OUString const * >( &pName ); + OUString const & value = *reinterpret_cast< OUString const * >( &pValue ); + + ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); + + NameValueList::iterator iPos( s_rtl_bootstrap_set_list.begin() ); + NameValueList::iterator iEnd( s_rtl_bootstrap_set_list.end() ); + for ( ; iPos != iEnd; ++iPos ) + { + if (iPos->sName.equals( name )) + { + iPos->sValue = value; + return; + } + } + +#ifdef DEBUG + OString cstr_name( OUStringToOString( name, RTL_TEXTENCODING_ASCII_US ) ); + OString cstr_value( OUStringToOString( value, RTL_TEXTENCODING_ASCII_US ) ); + OSL_TRACE( + "bootstrap.cxx: explicitly setting: name=%s value=%s\n", + cstr_name.getStr(), cstr_value.getStr() ); +#endif + + s_rtl_bootstrap_set_list.push_back( rtl_bootstrap_NameValue( name, value ) ); +} + void SAL_CALL rtl_bootstrap_expandMacros_from_handle( rtlBootstrapHandle handle, rtl_uString ** macro ) SAL_THROW_EXTERN_C() diff --git a/sal/util/sal.map b/sal/util/sal.map index 77ff3fa7a2ac..c14858aec6d5 100755 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -460,6 +460,7 @@ UDK_3_0_0 { rtl_uriDecode; rtl_bootstrap_get; + rtl_bootstrap_set; rtl_bootstrap_setIniFileName; rtl_bootstrap_args_open; rtl_bootstrap_args_close; |