From d83eb4b9ff792080f3c0012f7e0b59ed3c8639ce Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 23 Jan 2012 21:09:48 +0000 Subject: android: get osl_Pipe creation sorted out, before we kill it. use new OSL_SOCKET_PATH bootstrap variable to customise this. --- sal/osl/unx/pipe.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'sal/osl/unx') diff --git a/sal/osl/unx/pipe.c b/sal/osl/unx/pipe.c index 6deac995123a..fd472fa18e43 100644 --- a/sal/osl/unx/pipe.c +++ b/sal/osl/unx/pipe.c @@ -32,6 +32,9 @@ #include #include #include +#include +#include +#include #include "sockimpl.h" @@ -158,8 +161,38 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *ustrPipeName, oslPipeOptions Option } +static sal_Bool +cpyBootstrapSocketPath(sal_Char *name, size_t len) +{ + sal_Bool bRet = sal_False; + rtl_uString *pName = 0, *pValue = 0; + + rtl_uString_newFromAscii(&pName, "OSL_SOCKET_PATH"); + + if (rtl_bootstrap_get(pName, &pValue, NULL)) + { + rtl_String *pStrValue = 0; + if (pValue && pValue->length > 0) + { + rtl_uString2String(&pStrValue, pValue->buffer, + pValue->length, RTL_TEXTENCODING_UTF8, + OUSTRING_TO_OSTRING_CVTFLAGS); + if (pStrValue && pStrValue->length > 0) + { + size_t nCopy = SAL_MIN (len-1, (size_t)pStrValue->length); + strncpy (name, pStrValue->buffer, nCopy); + name[nCopy] = '\0'; + bRet = (size_t)pStrValue->length < len; + } + rtl_string_release(pStrValue); + } + rtl_uString_release(pName); + } + return bRet; +} + oslPipe SAL_CALL osl_psz_createPipe(const sal_Char *pszPipeName, oslPipeOptions Options, - oslSecurity Security) + oslSecurity Security) { int Flags; size_t len; @@ -174,10 +207,14 @@ oslPipe SAL_CALL osl_psz_createPipe(const sal_Char *pszPipeName, oslPipeOptions { strncpy(name, PIPEDEFAULTPATH, sizeof(name)); } - else + else if (access(PIPEALTERNATEPATH, R_OK|W_OK) == 0) { strncpy(name, PIPEALTERNATEPATH, sizeof(name)); } + else if (!cpyBootstrapSocketPath (name, sizeof (name))) + { + return NULL; + } name[sizeof(name) - 1] = '\0'; // ensure the string is NULL-terminated nNameLength = strlen(name); bNameTooLong = nNameLength > sizeof(name) - 2; @@ -600,5 +637,4 @@ sal_Int32 SAL_CALL osl_readPipe( oslPipe pPipe, void *pBuffer , sal_Int32 n ) return BytesRead; } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit