summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2002-12-14 11:57:16 +0000
committerTino Rachui <tra@openoffice.org>2002-12-14 11:57:16 +0000
commita76c3dd1bcffe6850b480c75e30194a49d3d1ba2 (patch)
tree5106ff7178c8a29fe75318d4da5f8d09eec3be07 /sal
parent78f348644b60627583f6a17da4a2f52be28bd1f0 (diff)
#104563#switch to unicode, no more working on byte string
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/process.c480
1 files changed, 231 insertions, 249 deletions
diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.c
index 8933a79db..d872e3f7e 100644
--- a/sal/osl/unx/process.c
+++ b/sal/osl/unx/process.c
@@ -2,9 +2,9 @@
*
* $RCSfile: process.c,v $
*
- * $Revision: 1.26 $
+ * $Revision: 1.27 $
*
- * last change: $Author: tra $ $Date: 2002-11-13 10:55:49 $
+ * last change: $Author: tra $ $Date: 2002-12-14 12:57:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -18,7 +18,7 @@
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
- *
+ *osl_getExecut
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
@@ -79,13 +79,33 @@
#include "system.h"
+#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
+#endif
+
+#ifndef _OSL_MUTEX_H_
#include <osl/mutex.h>
+#endif
+
+#ifndef _OSL_CONDITN_H_
#include <osl/conditn.h>
+#endif
+
+#ifndef _OSL_THREAD_H_
#include <osl/thread.h>
+#endif
+
+#ifndef _OSL_FILE_H_
#include <osl/file.h>
+#endif
+
+#ifndef _OSL_SIGNAL_H_
#include <osl/signal.h>
+#endif
+
+#ifndef _RTL_ALLOC_H_
#include <rtl/alloc.h>
+#endif
#include <grp.h>
@@ -148,7 +168,7 @@ typedef struct _oslPipeImpl {
*
*****************************************************************************/
-static sal_Char *getCmdLine();
+extern sal_Char *getCmdLine();
oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
sal_Char *pszArguments[],
@@ -160,8 +180,15 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
oslFileHandle *pInputWrite,
oslFileHandle *pOutputRead,
oslFileHandle *pErrorRead );
-oslProcessError SAL_CALL osl_searchPath(const sal_Char* pszName, const sal_Char* pszPath,
- sal_Char Separator, sal_Char *pszBuffer, sal_uInt32 Max);
+
+
+oslProcessError SAL_CALL osl_searchPath_impl(
+ const sal_Char* pszName,
+ const sal_Char* pszPath,
+ sal_Char Separator,
+ sal_Char *pszBuffer,
+ sal_uInt32 Max);
+
oslProcessError SAL_CALL osl_psz_getExecutableFile(sal_Char* pszBuffer, sal_uInt32 Max);
sal_Bool osl_getFullPath(const sal_Char* pszFilename, sal_Char* pszPath, sal_uInt32 MaxLen);
@@ -184,7 +211,7 @@ static int nArgCount = -1;
#if defined(MACOSX)
/* Can't access environ and __progname directly when linking two-level. */
-static sal_Char *getCmdLine()
+sal_Char *getCmdLine()
{
int i;
int len = 0;
@@ -217,7 +244,7 @@ static sal_Char *getCmdLine()
* mfe: used by FreeBSD, NetBSD, HP-UX, IRIX
* (and which other Unix flavours?)
*/
-static sal_Char *getCmdLine()
+sal_Char *getCmdLine()
{
/* Memory layout of CMD_ARG_PRG:
progname\0arg1\0...argn[\0]\0environ\0env2\0...envn\0[\0] */
@@ -260,7 +287,7 @@ static void saveEnviron(void)
pEnviron = CMD_ARG_ENV;
}
-static sal_Char *getCmdLine()
+sal_Char *getCmdLine()
{
sal_Char **pArgs = pEnviron;
sal_Char *pChr;
@@ -286,7 +313,7 @@ static sal_Char *getCmdLine()
* mfe: this is for Linux
* (and which other Unix flavours?)
*/
-static sal_Char *getCmdLine()
+sal_Char *getCmdLine()
{
FILE *fp;
sal_Char name[PATH_MAX + 1];
@@ -326,7 +353,7 @@ static sal_Char *getCmdLine()
* (and which other Unix flavours?)
*/
-static sal_Char *getCmdLine()
+sal_Char *getCmdLine()
{
int fd;
sal_Char name[PATH_MAX + 1];
@@ -379,7 +406,7 @@ static sal_Char *getCmdLine()
* (and which other Unix flavours?)
*/
-static sal_Char *getCmdLine()
+sal_Char *getCmdLine()
{
FILE *fp;
sal_Char cmd[CMD_ARG_MAX + 1];
@@ -425,7 +452,14 @@ static sal_Char *getCmdLine()
}
#endif
-oslProcessError SAL_CALL osl_getExecutableFile( rtl_uString** pustrFile )
+/*******************************************************************
+ !!! Working on byte strings is dangerous because of MBCS see
+ #104563.
+ Don't fix this function because it is only used in profile.c and
+ profiles are deprecated
+ ******************************************************************/
+
+oslProcessError SAL_CALL osl_psz_getExecutableFile(sal_Char* pszBuffer, sal_uInt32 Max)
{
const char * pszCmdLine = getCmdLine();
const char * pszRealPathSrc = pszCmdLine;
@@ -444,14 +478,14 @@ oslProcessError SAL_CALL osl_getExecutableFile( rtl_uString** pustrFile )
{
if( NULL != getcwd(szAbsolutePath, sizeof(szAbsolutePath)) )
{
- size_t n = strlen(szAbsolutePath);
+ size_t n = PATH_MAX - strlen(szAbsolutePath);
size_t n2 = strlen(pszCmdLine);
/* check remaining size and append '/' and argument #0 is possible */
if( n + n2 + 1 < PATH_MAX )
{
szAbsolutePath[n] = '/';
- strncpy(szAbsolutePath + n + 1, pszCmdLine, n2 + 1);
+ strncpy(szAbsolutePath+n+1, pszCmdLine, n2+1);
/* replace the original pszRealPathSrc pointer */
pszRealPathSrc = szAbsolutePath;
@@ -461,7 +495,7 @@ oslProcessError SAL_CALL osl_getExecutableFile( rtl_uString** pustrFile )
/* this program must be in the PATH variable */
else
{
- ret = osl_searchPath(pszCmdLine, NULL, '\0', szAbsolutePath, sizeof(szAbsolutePath));
+ ret = osl_searchPath_impl(pszCmdLine, NULL, '\0', szAbsolutePath, sizeof(szAbsolutePath));
if( osl_Process_E_None == ret )
{
/* replace the original pszRealPathSrc pointer */
@@ -483,125 +517,91 @@ oslProcessError SAL_CALL osl_getExecutableFile( rtl_uString** pustrFile )
}
/* get the realpath of the resulting file and convert it to a file URL */
- if( NULL != realpath(pszRealPathSrc, szRealPathBuf) )
+ if( NULL != realpath(pszRealPathSrc, szRealPathBuf) && strlen(szRealPathBuf) < Max )
{
- rtl_uString *ustrTmp = NULL;
-
- rtl_string2UString(&ustrTmp, szRealPathBuf, strlen(szRealPathBuf),
- osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS);
-
- osl_getFileURLFromSystemPath(ustrTmp, pustrFile);
- rtl_uString_release(ustrTmp);
-
- free((void *) pszCmdLine);
- return osl_Process_E_None;
+ strcpy(pszBuffer, szRealPathBuf);
}
else
{
free((void *)pszCmdLine);
return osl_Process_E_Unknown;
}
+
+ free((void *) pszCmdLine);
+ return osl_Process_E_None;
}
+/******************************************************************************
+ Deprecated
+ Old and buggy implementation of osl_searchPath used only by the deprected
+ osl_psz_getExecutableName.
+ A new implemenation is in process_impl.cxx
+ *****************************************************************************/
-/* a copy of the above, hopefully no longer used by referenced in profile.c, which is deprecated .. */
-oslProcessError SAL_CALL osl_psz_getExecutableFile(sal_Char* pszBuffer, sal_uInt32 Max)
+oslProcessError SAL_CALL osl_searchPath_impl(const sal_Char* pszName, const sal_Char* pszPath,
+ sal_Char Separator, sal_Char *pszBuffer, sal_uInt32 Max)
{
- const char * pszCmdLine = getCmdLine();
- const char * pszRealPathSrc = pszCmdLine;
- char szAbsolutePath[PATH_MAX] = "";
- char szRealPathBuf[PATH_MAX] = "";
+ sal_Char path[PATH_MAX + 1];
+ sal_Char *pchr;
- /* if the command line argument #0 starts with a '/', this program has been */
- /* invoked using a full qualified path */
- if( '/' != pszCmdLine[0] )
+ path[0] = '\0';
+
+ OSL_ASSERT(pszName != NULL);
+
+ if ( pszName == 0 )
{
- oslProcessError ret = osl_Process_E_None;
+ return osl_Process_E_NotFound;
+ }
- /* if the command line argument #0 contains a '/' somewhere else, it has */
- /* been probably invoked relatively to the current working directory */
- if( strchr(pszCmdLine, '/') )
- {
- if( NULL != getcwd(szAbsolutePath, sizeof(szAbsolutePath)) )
- {
- size_t n = PATH_MAX - strlen(szAbsolutePath);
- size_t n2 = strlen(pszCmdLine);
+ if (pszPath == NULL)
+ pszPath = "PATH";
- /* check remaining size and append '/' and argument #0 is possible */
- if( n + n2 + 1 < PATH_MAX )
- {
- szAbsolutePath[n] = '/';
- strncpy(szAbsolutePath+n+1, pszCmdLine, n2+1);
+ if (Separator == '\0')
+ Separator = ':';
- /* replace the original pszRealPathSrc pointer */
- pszRealPathSrc = szAbsolutePath;
- }
- }
- }
- /* this program must be in the PATH variable */
- else
- {
- ret = osl_searchPath(pszCmdLine, NULL, '\0', szAbsolutePath, sizeof(szAbsolutePath));
- if( osl_Process_E_None == ret )
- {
- /* replace the original pszRealPathSrc pointer */
- pszRealPathSrc = szAbsolutePath;
- }
- }
- /* if szAbsolutePath has not been filled, return with an error */
- if( '\0' == szAbsolutePath[0] )
- {
- ret = osl_Process_E_Unknown;
- }
+ if ( (pchr = getenv(pszPath)) != 0 )
+ {
+ sal_Char *pstr;
- if( osl_Process_E_None != ret )
+ while (*pchr != '\0')
{
- free((void *) pszCmdLine);
- return ret;
- }
- }
+ pstr = path;
- /* get the realpath of the resulting file and convert it to a file URL */
- if( NULL != realpath(pszRealPathSrc, szRealPathBuf) && strlen(szRealPathBuf) < Max )
- {
- strcpy(pszBuffer, szRealPathBuf);
- }
- else
- {
- free((void *)pszCmdLine);
- return osl_Process_E_Unknown;
- }
+ while ((*pchr != '\0') && (*pchr != Separator))
+ *pstr++ = *pchr++;
- free((void *) pszCmdLine);
- return osl_Process_E_None;
-}
+ if ((pstr > path) && ((*(pstr - 1) != '/')))
+ *pstr++ = '/';
+ *pstr = '\0';
-/* return the executable name without path - used in signal.c */
-char * osl_impl_getExecutableName(char * buffer, size_t n)
-{
- const char * pszCmdLine = getCmdLine();
- const char * pc = strrchr(pszCmdLine, '/');
- size_t len;
-
- /* cut of the path */
- if( NULL != pc )
- ++pc;
- else
- pc = pszCmdLine;
-
- if( n > strlen(pc) )
- {
- strcpy(buffer, pc);
- free((void *) pszCmdLine);
- return buffer;
+ strcat(path, pszName);
+
+ if (access(path, 0) == 0)
+ {
+ char szRealPathBuf[PATH_MAX] = "";
+
+ if( NULL == realpath(path, szRealPathBuf) || (strlen(szRealPathBuf) >= (sal_uInt32)Max))
+ return osl_Process_E_Unknown;
+
+ strcpy(pszBuffer, path);
+
+ return osl_Process_E_None;
+ }
+
+ if (*pchr == Separator)
+ pchr++;
+ }
}
-
- free((void *) pszCmdLine);
- return NULL;
+
+ return osl_Process_E_NotFound;
}
+/**********************************************
+ osl_getCommandArgCount
+ *********************************************/
+
sal_uInt32 SAL_CALL osl_getCommandArgCount()
{
sal_Char pszBuffer[CMD_ARG_MAX+1];
@@ -625,6 +625,10 @@ sal_uInt32 SAL_CALL osl_getCommandArgCount()
return nArgCount;
}
+/**********************************************
+ osl_getCommandArg
+ *********************************************/
+
oslProcessError SAL_CALL osl_getCommandArg( sal_uInt32 nArg, rtl_uString **strCommandArg)
{
oslProcessError tErr = osl_Process_E_Unknown;
@@ -675,6 +679,10 @@ oslProcessError SAL_CALL osl_getCommandArg( sal_uInt32 nArg, rtl_uString **strCo
return tErr;
}
+/**********************************************
+ osl_getCommandArgs
+ *********************************************/
+
oslProcessError SAL_CALL osl_getCommandArgs(sal_Char* pszBuffer, sal_uInt32 Max)
{
static int CmdLen = -1;
@@ -737,6 +745,10 @@ oslProcessError SAL_CALL osl_getCommandArgs(sal_Char* pszBuffer, sal_uInt32 Max)
*****************************************************************************/
+/**********************************************
+ sendFdPipe
+ *********************************************/
+
static sal_Bool sendFdPipe(int PipeFD, int SocketFD)
{
sal_Bool bRet = sal_False;
@@ -816,7 +828,10 @@ static sal_Bool sendFdPipe(int PipeFD, int SocketFD)
return bRet;
}
-
+/**********************************************
+ receiveFdPipe
+ *********************************************/
+
static oslSocket receiveFdPipe(int PipeFD)
{
oslSocket pSocket = 0;
@@ -896,6 +911,10 @@ static oslSocket receiveFdPipe(int PipeFD)
return pSocket;
}
+/**********************************************
+ osl_sendResourcePipe
+ *********************************************/
+
sal_Bool osl_sendResourcePipe(oslPipe pPipe, oslSocket pSocket)
{
sal_Bool bRet = sal_False;
@@ -910,7 +929,10 @@ sal_Bool osl_sendResourcePipe(oslPipe pPipe, oslSocket pSocket)
return bRet;
}
-
+/**********************************************
+ osl_receiveResourcePipe
+ *********************************************/
+
oslSocket osl_receiveResourcePipe(oslPipe pPipe)
{
oslSocket pSocket=0;
@@ -1145,7 +1167,10 @@ static void ChildStatusProc(void *pData)
}
}
-
+/**********************************************
+ osl_executeProcess_WithRedirectedIO
+ *********************************************/
+
oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
rtl_uString *ustrImageName,
rtl_uString *ustrArguments[],
@@ -1264,7 +1289,10 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
return Error;
}
-
+/**********************************************
+ osl_executeProcess
+ *********************************************/
+
oslProcessError SAL_CALL osl_executeProcess(
rtl_uString *ustrImageName,
rtl_uString *ustrArguments[],
@@ -1293,7 +1321,10 @@ oslProcessError SAL_CALL osl_executeProcess(
);
}
-
+/**********************************************
+ osl_psz_executeProcess
+ *********************************************/
+
oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
sal_Char *pszArguments[],
oslProcessOption Options,
@@ -1329,7 +1360,7 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
}
if ((Options & osl_Process_SEARCHPATH) &&
- (osl_searchPath(pszImageName, NULL, '\0', path, sizeof(path)) == osl_Process_E_None))
+ (osl_searchPath_impl(pszImageName, NULL, '\0', path, sizeof(path)) == osl_Process_E_None))
pszImageName = path;
Data.m_pszArgs[0] = strdup(pszImageName);
@@ -1414,6 +1445,11 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
*
*****************************************************************************/
+
+/**********************************************
+ osl_terminateProcess
+ *********************************************/
+
oslProcessError SAL_CALL osl_terminateProcess(oslProcess Process)
{
if (Process == NULL)
@@ -1437,6 +1473,10 @@ oslProcessError SAL_CALL osl_terminateProcess(oslProcess Process)
return osl_Process_E_None;
}
+/**********************************************
+ osl_getProcess
+ *********************************************/
+
oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident)
{
oslProcessImpl *pProcImpl;
@@ -1487,6 +1527,10 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident)
return (pProcImpl);
}
+/**********************************************
+ osl_freeProcessHandle
+ *********************************************/
+
void SAL_CALL osl_freeProcessHandle(oslProcess Process)
{
if (Process != NULL)
@@ -1606,9 +1650,11 @@ struct osl_procStat
unsigned long vm_lib; /* library size */
};
-
-void
-osl_getProcStat(pid_t pid, struct osl_procStat* procstat)
+/**********************************************
+ osl_getProcStat
+ *********************************************/
+
+void osl_getProcStat(pid_t pid, struct osl_procStat* procstat)
{
int fd = 0;
char name[PATH_MAX + 1];
@@ -1653,8 +1699,11 @@ osl_getProcStat(pid_t pid, struct osl_procStat* procstat)
}
}
-void
-osl_getProcStatm(pid_t pid, struct osl_procStat* procstat)
+/**********************************************
+ osl_getProcStatm
+ *********************************************/
+
+void osl_getProcStatm(pid_t pid, struct osl_procStat* procstat)
{
int fd = 0;
char name[PATH_MAX + 1];
@@ -1678,8 +1727,11 @@ osl_getProcStatm(pid_t pid, struct osl_procStat* procstat)
}
}
-void
-osl_getProcStatus(pid_t pid, struct osl_procStat* procstat)
+/**********************************************
+ osl_getProcStatus
+ *********************************************/
+
+void osl_getProcStatus(pid_t pid, struct osl_procStat* procstat)
{
int fd = 0;
char name[PATH_MAX + 1];
@@ -1741,6 +1793,10 @@ osl_getProcStatus(pid_t pid, struct osl_procStat* procstat)
#endif
+/**********************************************
+ osl_getProcessInfo
+ *********************************************/
+
oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData Fields, oslProcessInfo* pInfo)
{
pid_t pid;
@@ -1931,6 +1987,10 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F
return (pInfo->Fields == Fields) ? osl_Process_E_None : osl_Process_E_Unknown;
}
+/**********************************************
+ osl_joinProcess
+ *********************************************/
+
oslProcessError SAL_CALL osl_joinProcess(oslProcess Process)
{
/* int status;*/
@@ -1985,155 +2045,70 @@ oslProcessError SAL_CALL osl_joinProcess(oslProcess Process)
*
*****************************************************************************/
-oslProcessError SAL_CALL osl_getEnvironment(rtl_uString *ustrVar, rtl_uString **ustrValue)
+oslProcessError SAL_CALL osl_getEnvironment(rtl_uString* pustrEnvVar, rtl_uString** ppustrValue)
{
- oslProcessError Error;
- sal_Char pszValue[PATH_MAX];
- rtl_String* strVar=0;
- sal_Char* pszVar=0;
-
- pszValue[0] = '\0';
+ rtl_String* pstr_env_var = 0;
+ char* p_env_var;
+ oslProcessError osl_error = osl_Process_E_NotFound;
- if ( ustrVar != 0 )
- {
- rtl_uString2String( &strVar,
- rtl_uString_getStr(ustrVar),
- rtl_uString_getLength(ustrVar),
- osl_getThreadTextEncoding(),
- OUSTRING_TO_OSTRING_CVTFLAGS );
- pszVar = rtl_string_getStr(strVar);
- }
-
-
- Error=osl_psz_getEnvironment(pszVar,pszValue,sizeof(pszValue));
-
- if( osl_Process_E_None == Error )
+ OSL_PRECOND(pustrEnvVar, "osl_getEnvironment: Invalid parameter");
+ OSL_PRECOND(ppustrValue, "osl_getEnvironment: Invalid parameter");
+
+ rtl_uString2String(
+ &pstr_env_var,
+ rtl_uString_getStr(pustrEnvVar),
+ rtl_uString_getLength(pustrEnvVar),
+ osl_getThreadTextEncoding(),
+ OUSTRING_TO_OSTRING_CVTFLAGS);
+
+ if ((p_env_var = getenv(rtl_string_getStr(pstr_env_var))))
{
rtl_string2UString(
- ustrValue,
- pszValue,
- rtl_str_getLength( pszValue ),
+ ppustrValue,
+ p_env_var,
+ strlen(p_env_var),
osl_getThreadTextEncoding(),
- OUSTRING_TO_OSTRING_CVTFLAGS );
- }
-
- if ( strVar != 0 )
- {
- rtl_string_release(strVar);
- }
-
-
- return Error;
-}
-
-
-oslProcessError SAL_CALL osl_psz_getEnvironment(const sal_Char* pszName, sal_Char *pszBuffer, sal_uInt32 Max)
-{
- sal_Char *pStr;
-
- if ( (pStr = getenv(pszName)) != 0 )
- {
- strncpy(pszBuffer, pStr, Max);
- pszBuffer[Max-1] = '\0';
-
- return osl_Process_E_None;
+ OSTRING_TO_OUSTRING_CVTFLAGS);
+
+ osl_error = osl_Process_E_None;
}
-
- return osl_Process_E_NotFound;
-}
-
-
-/******************************************************************************
- *
- * Utilities
- *
- *****************************************************************************/
-
-oslProcessError SAL_CALL osl_searchPath(const sal_Char* pszName, const sal_Char* pszPath,
- sal_Char Separator, sal_Char *pszBuffer, sal_uInt32 Max)
-{
- sal_Char path[PATH_MAX + 1];
- sal_Char *pchr;
-
- path[0] = '\0';
- OSL_ASSERT(pszName != NULL);
-
- if ( pszName == 0 )
- {
- return osl_Process_E_NotFound;
- }
-
- if (pszPath == NULL)
- pszPath = "PATH";
-
- if (Separator == '\0')
- Separator = ':';
-
-
- if ( (pchr = getenv(pszPath)) != 0 )
- {
- sal_Char *pstr;
-
- while (*pchr != '\0')
- {
- pstr = path;
-
- while ((*pchr != '\0') && (*pchr != Separator))
- *pstr++ = *pchr++;
-
- if ((pstr > path) && ((*(pstr - 1) != '/')))
- *pstr++ = '/';
-
- *pstr = '\0';
-
- strcat(path, pszName);
-
- if (access(path, 0) == 0)
- {
- char szRealPathBuf[PATH_MAX] = "";
-
- if( NULL == realpath(path, szRealPathBuf) || (strlen(szRealPathBuf) >= (sal_uInt32)Max))
- return osl_Process_E_Unknown;
-
- strcpy(pszBuffer, path);
-
- return osl_Process_E_None;
- }
-
- if (*pchr == Separator)
- pchr++;
- }
- }
-
- return osl_Process_E_NotFound;
+ rtl_string_release(pstr_env_var);
+
+ return osl_error;
}
+
/******************************************************************************
*
* new function to return the process working dir
*
*****************************************************************************/
-oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir )
+oslProcessError SAL_CALL osl_getProcessWorkingDir(rtl_uString **ppustrWorkingDir)
{
- char buffer[PATH_MAX];
+ oslProcessError osl_error = osl_Process_E_None;
+ char buffer[PATH_MAX];
- if( getcwd( buffer, PATH_MAX ) )
+ OSL_PRECOND(ppustrWorkingDir, "osl_getProcessWorkingDir: invalid parameter");
+
+ if (getcwd(buffer, PATH_MAX))
{
rtl_uString* ustrTmp = NULL;
- /* convert file path to unicode */
- rtl_string2UString( &ustrTmp, buffer, strlen( buffer ), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
+ rtl_string2UString(
+ &ustrTmp,
+ buffer,
+ strlen(buffer),
+ osl_getThreadTextEncoding(),
+ OSTRING_TO_OUSTRING_CVTFLAGS);
- /* convert file path to file URL */
- osl_getFileURLFromSystemPath( ustrTmp, pustrWorkingDir );
-
- rtl_uString_release( ustrTmp );
- return osl_Process_E_None;
+ osl_error = osl_getFileURLFromSystemPath(ustrTmp, ppustrWorkingDir);
+
+ rtl_uString_release(ustrTmp);
}
- return osl_Process_E_Unknown;
+ return osl_error;
}
/******************************************************************************
@@ -2145,6 +2120,10 @@ oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir
static rtl_Locale * theProcessLocale = NULL;
static pthread_mutex_t aLocalMutex = PTHREAD_MUTEX_INITIALIZER;
+/**********************************************
+ osl_getProcessLocale
+ *********************************************/
+
oslProcessError SAL_CALL osl_getProcessLocale( rtl_Locale ** ppLocale )
{
OSL_ASSERT( ppLocale );
@@ -2162,7 +2141,10 @@ oslProcessError SAL_CALL osl_getProcessLocale( rtl_Locale ** ppLocale )
return osl_Process_E_None;
}
-
+/**********************************************
+ osl_setProcessLocale
+ *********************************************/
+
oslProcessError SAL_CALL osl_setProcessLocale( rtl_Locale * pLocale )
{
oslProcessError ret = osl_Process_E_Unknown;