VirtualBox

Ignore:
Timestamp:
Nov 8, 2023 12:01:00 PM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom: Convert PR_GetEnv/PR_SetEnv to IPRT RTEnv* API, bugref:10545

Location:
trunk/src/libs/xpcom18a4/ipc/ipcd/shared/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcConfig.cpp

    r16561 r101962  
    4747#include "ipcConfig.h"
    4848#include "ipcLog.h"
    49 #include "prenv.h"
    5049#include "plstr.h"
     50
     51#include <iprt/env.h>
    5152
    5253#if defined(XP_OS2) && !defined(XP_OS2_NATIVEIPC)
     
    7576    bufLen -= (sizeof(kDefaultSocketPrefix) - 1);
    7677
    77     logName = PR_GetEnv("VBOX_IPC_SOCKETID");
     78    logName = RTEnvGet("VBOX_IPC_SOCKETID");
    7879#if defined(VBOX) && defined(XP_UNIX)
    7980    if (!logName || !logName[0]) {
     
    8485#endif
    8586    if (!logName || !logName[0]) {
    86         logName = PR_GetEnv("LOGNAME");
     87        logName = RTEnvGet("LOGNAME");
    8788        if (!logName || !logName[0]) {
    88             logName = PR_GetEnv("USER");
     89            logName = RTEnvGet("USER");
    8990            if (!logName || !logName[0]) {
    9091                LOG(("could not determine username from environment\n"));
  • trunk/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.cpp

    r46593 r101962  
    4848#include "plstr.h"
    4949
    50 #ifdef VBOX
    51 # if defined(__OS2__) && defined(PAGE_SIZE)
    52 #  undef PAGE_SIZE
    53 # endif
    54 # include <iprt/initterm.h> // for RTR3InitDll
    55 #else // !VBOX
    56 PRBool ipcLogEnabled = PR_FALSE;
    57 #endif // !VBOX
     50#include <iprt/initterm.h> // for RTR3InitDll
    5851
    5952char ipcLogPrefix[10] = {0};
    60 
    61 #ifndef VBOX
    62 
    63 //-----------------------------------------------------------------------------
    64 // UNIX
    65 //-----------------------------------------------------------------------------
    66 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
    67 
    68 #include <sys/types.h>
    69 #include <unistd.h>
    70 
    71 static inline PRUint32
    72 WritePrefix(char *buf, PRUint32 bufLen)
    73 {
    74     return PR_snprintf(buf, bufLen, "[%u:%p] %s ",
    75                        (unsigned) getpid(),
    76                        PR_GetCurrentThread(),
    77                        ipcLogPrefix);
    78 }
    79 #endif
    80 
    81 //-----------------------------------------------------------------------------
    82 // WIN32
    83 //-----------------------------------------------------------------------------
    84 #ifdef XP_WIN
    85 #include <windows.h>
    86 
    87 static inline PRUint32
    88 WritePrefix(char *buf, PRUint32 bufLen)
    89 {
    90     return PR_snprintf(buf, bufLen, "[%u:%p] %s ",
    91                        GetCurrentProcessId(),
    92                        PR_GetCurrentThread(),
    93                        ipcLogPrefix);
    94 }
    95 #endif
    96 
    97 #endif // !VBOX
    9853
    9954//-----------------------------------------------------------------------------
     
    10459IPC_InitLog(const char *prefix)
    10560{
    106 #ifdef VBOX
    10761    // initialize VBox Runtime
    10862    RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    10963
    11064    PL_strncpyz(ipcLogPrefix, prefix, sizeof(ipcLogPrefix));
    111 #else
    112     if (PR_GetEnv("IPC_LOG_ENABLE")) {
    113         ipcLogEnabled = PR_TRUE;
    114         PL_strncpyz(ipcLogPrefix, prefix, sizeof(ipcLogPrefix));
    115     }
    116 #endif
    11765}
    11866
     
    12573    char buf[512];
    12674
    127 #ifdef VBOX
    12875    if (ipcLogPrefix[0]) {
    12976        nb = strlen(ipcLogPrefix);
     
    13380        buf[nb++] = ' ';
    13481    }
    135 #else
    136     if (ipcLogPrefix[0])
    137         nb = WritePrefix(buf, sizeof(buf));
    138 #endif
    13982
    14083    PR_vsnprintf(buf + nb, sizeof(buf) - nb, fmt, ap);
    14184    buf[sizeof(buf) - 1] = '\0';
    14285
    143 #ifdef VBOX
    14486    LogFlow(("%s", buf));
    145 #else
    146     fwrite(buf, strlen(buf), 1, stdout);
    147 #endif
    148 
    14987    va_end(ap);
    15088}
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