2008-10-18 10:27 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* include/hbapi.h
* source/common/hbgete.c
+ Added hb_getenv_buffer(). Similar to hb_getenv() but
this one needs a buffer+size to be passed, so no memory
allocation is done by the function. It also return
a BOOL to signal success. It doesn't signal if passed
buffer was too small to store the value.
This commit is contained in:
@@ -8,6 +8,15 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2008-10-18 10:27 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
|
||||
* include/hbapi.h
|
||||
* source/common/hbgete.c
|
||||
+ Added hb_getenv_buffer(). Similar to hb_getenv() but
|
||||
this one needs a buffer+size to be passed, so no memory
|
||||
allocation is done by the function. It also return
|
||||
a BOOL to signal success. It doesn't signal if passed
|
||||
buffer was too small to store the value.
|
||||
|
||||
2008-10-18 08:36 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/source/debug/dbgtwin.prg
|
||||
* harbour/source/debug/dbgbrwsr.prg
|
||||
|
||||
@@ -1010,6 +1010,7 @@ extern HB_EXPORT BOOL hb_iswince( void ); /* return .T. if OS is Windows CE or
|
||||
extern HB_EXPORT BOOL hb_printerIsReady( char * pszPrinterName );
|
||||
|
||||
/* environment variables access */
|
||||
extern BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize );
|
||||
/* WARNING: This returned pointer must be freed if not NULL using hb_xfree( ( void * ) ptr ); */
|
||||
extern char * hb_getenv( const char * name );
|
||||
extern char * hb_netname( void );
|
||||
|
||||
@@ -111,3 +111,52 @@ char * hb_getenv( const char * szName )
|
||||
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
|
||||
BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize )
|
||||
{
|
||||
BOOL bRetVal = FALSE;
|
||||
|
||||
if( szBuffer != NULL && nSize != 0 )
|
||||
{
|
||||
szBuffer[ 0 ] = '\0';
|
||||
|
||||
#if defined(HB_OS_WIN_32)
|
||||
|
||||
{
|
||||
bRetVal = GetEnvironmentVariableA( szName, szBuffer, nSize ) != 0;
|
||||
}
|
||||
|
||||
#elif defined(HB_OS_OS2)
|
||||
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
PSZ EnvValue = "";
|
||||
#else
|
||||
PCSZ EnvValue = "";
|
||||
#endif
|
||||
|
||||
if( DosScanEnv( szName, &EnvValue ) == NO_ERROR )
|
||||
{
|
||||
hb_strncpy( szBuffer, EnvValue, nSize - 1 );
|
||||
bRetVal = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
{
|
||||
char * pszTemp = getenv( szName );
|
||||
|
||||
if( pszTemp != NULL )
|
||||
{
|
||||
hb_strncpy( szBuffer, pszTemp, nSize - 1 );
|
||||
bRetVal = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
return bRetVal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user