VirtualBox

Changeset 936 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
Feb 15, 2007 8:58:51 PM (18 years ago)
Author:
vboxsync
Message:

RTEnv (incomplete).

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/env-posix.cpp

    r935 r936  
    11/* $Id$ */
    22/** @file
    3  * InnoTek Portable Runtime - Assertions, generic RTAssertDoBreakpoint.
     3 * InnoTek Portable Runtime - Environment, Posix.
    44 */
    55
     
    2424*   Header Files                                                               *
    2525*******************************************************************************/
    26 #include <iprt/assert.h>
     26#include <iprt/env.h>
     27#include <iprt/string.h>
     28
     29#include <stdlib.h>
     30#include <errno.h>
    2731
    2832
    2933/**
    30  * Overridable function that decides whether assertions executes the breakpoint or not.
     34 * Gets an environment variable (getenv).
    3135 *
    32  * The generic implementation will return true.
     36 * The caller is responsible for ensuring that nobody changes the environment
     37 * while it's using the returned string pointer!
    3338 *
    34  * @returns true if the breakpoint should be hit, false if it should be ignored.
    35  * @remark  The RTDECL() makes this a bit difficult to override on windows. Sorry.
     39 * @returns Pointer to read only string on success, NULL if the variable wasn't found.
     40 *
     41 * @param   pszVar      The environment variable name.
    3642 */
    37 RTDECL(bool)    RTAssertDoBreakpoint(void)
     43RTDECL(const char *) RTEnvGet(const char *pszVar)
    3844{
    39     return true;
     45    return getenv(pszVar);
    4046}
    4147
     48
     49/**
     50 * Puts an variable=value string into the environment (putenv).
     51 *
     52 * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
     53 *
     54 * @param   pszVarEqualValue    The variable '=' value string. If the value and '=' is
     55 *                              omitted, the variable is removed from the environment.
     56 */
     57RTDECL(int) RTEnvPut(const char *pszVarEqualValue)
     58{
     59    /** @todo putenv is a memory leak. deal with this on a per system basis. */
     60    if (!putenv((char *)pszVarEqualValue))
     61        return 0;
     62    return RTErrConvertFromErrno(errno);
     63}
     64
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette