Ignore:
Timestamp:
Sep 8, 2000, 8:07:52 PM (25 years ago)
Author:
sandervl
Message:

exception changes, implemented enumresourcelanguages + put back some old code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/environ.cpp

    r4208 r4224  
    1 /* $Id: environ.cpp,v 1.5 2000-09-07 21:40:28 phaller Exp $ */
     1/* $Id: environ.cpp,v 1.6 2000-09-08 18:07:49 sandervl Exp $ */
    22
    33/*
     
    1717 *
    1818 */
    19 
    20 /*****************************************************************************
    21  * Includes                                                                  *
    22  *****************************************************************************/
    23 
    2419#include <odin.h>
    2520#include <odinwrap.h>
     
    3833#include "dbglocal.h"
    3934
    40 /*****************************************************************************
    41  * Defines                                                                   *
    42  *****************************************************************************/
    43 
    44 ODINDEBUGCHANNEL(KERNEL32-ENVIRONMENT)
    45 
    46 
    47 //******************************************************************************
    48 //******************************************************************************
    49 ODINFUNCTION0(LPSTR, GetEnvironmentStringsA)
    50 {
    51   return (LPSTR) O32_GetEnvironmentStrings();
    52 }
    53 //******************************************************************************
    54 //******************************************************************************
    55 ODINFUNCTION0(LPWSTR, GetEnvironmentStringsW)
     35//******************************************************************************
     36//******************************************************************************
     37LPSTR WIN32API GetEnvironmentStringsA(void)
     38{
     39    dprintf(("KERNEL32:  OS2GetEnvironmentStringsA\n"));
     40    return (LPSTR) O32_GetEnvironmentStrings();
     41}
     42//******************************************************************************
     43//******************************************************************************
     44LPWSTR WIN32API GetEnvironmentStringsW(VOID)
    5645{
    5746 char *envstrings = (char *)O32_GetEnvironmentStrings();
     
    5948 LPWSTR wenvstrings;
    6049 int len, i;
     50
     51  dprintf(("KERNEL32:  GetEnvironmentStringsW\n"));
    6152
    6253  if(envstrings == NULL)
     
    8273//******************************************************************************
    8374//******************************************************************************
    84 ODINFUNCTION1(BOOL, FreeEnvironmentStringsA,
    85               LPSTR, envstrings)
    86 {
    87   dprintf(("not correctly implemented.\n"));
    88   //free(envstrings);
     75BOOL WIN32API FreeEnvironmentStringsA(LPSTR envstrings)
     76{
     77  dprintf(("KERNEL32:  FreeEnvironmentStringsA\n"));
    8978  return(TRUE);
    9079}
    9180//******************************************************************************
    9281//******************************************************************************
    93 ODINFUNCTION1(BOOL,   FreeEnvironmentStringsW,
    94               LPWSTR, envstrings)
    95 {
    96   dprintf(("not correctly implemented.\n"));
    97   //free(envstrings);
     82BOOL WIN32API FreeEnvironmentStringsW(LPWSTR envstrings)
     83{
     84  dprintf(("KERNEL32:  FreeEnvironmentStringsW\n"));
     85  free(envstrings);
    9886  return(TRUE);
    9987}
    10088//******************************************************************************
    10189//******************************************************************************
    102 ODINFUNCTION2(BOOL,   SetEnvironmentVariableA,
    103               LPCSTR, lpszName,
    104               LPCSTR, lpszValue)
    105 {
    106   return O32_SetEnvironmentVariable(lpszName, lpszValue);
    107 }
    108 //******************************************************************************
    109 //******************************************************************************
    110 ODINFUNCTION2(BOOL,    SetEnvironmentVariableW,
    111               LPCWSTR, lpszName,
    112               LPCWSTR, lpszValue)
    113 {
    114   char *asciiname, *asciivalue;
    115   BOOL  rc;
    116 
    117   asciiname  = UnicodeToAsciiString((LPWSTR)lpszName);
    118   asciivalue = UnicodeToAsciiString((LPWSTR)lpszValue);
    119   rc = O32_SetEnvironmentVariable(asciiname, asciivalue);
    120   FreeAsciiString(asciivalue);
    121   FreeAsciiString(asciiname);
    122   return(rc);
    123 }
    124 //******************************************************************************
    125 //******************************************************************************
    126 ODINFUNCTION3(DWORD,  GetEnvironmentVariableA,
    127               LPCSTR, lpName,
    128               LPSTR,  lpBuffer,
    129               DWORD,  nSize)
    130 {
    131   return O32_GetEnvironmentVariable(lpName, lpBuffer, nSize);
    132 }
    133 //******************************************************************************
    134 //******************************************************************************
    135 ODINFUNCTION3(DWORD,   GetEnvironmentVariableW,
    136               LPCWSTR, lpName,
    137               LPWSTR,  lpBuffer,
    138               DWORD,   nSize)
     90BOOL WIN32API SetEnvironmentVariableA(LPCSTR arg1, LPCSTR arg2)
     91{
     92    dprintf(("KERNEL32:  SetEnvironmentVariable %s to %s\n", arg1, arg2));
     93    return O32_SetEnvironmentVariable(arg1, arg2);
     94}
     95//******************************************************************************
     96//******************************************************************************
     97BOOL WIN32API SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue)
     98{
     99 char *asciiname, *asciivalue;
     100 BOOL  rc;
     101
     102    dprintf(("KERNEL32:  OS2SetEnvironmentVariableW\n"));
     103    asciiname  = UnicodeToAsciiString((LPWSTR)lpName);
     104    asciivalue = UnicodeToAsciiString((LPWSTR)lpValue);
     105    rc = O32_SetEnvironmentVariable(asciiname, asciivalue);
     106    FreeAsciiString(asciivalue);
     107    FreeAsciiString(asciiname);
     108    return(rc);
     109}
     110//******************************************************************************
     111//******************************************************************************
     112DWORD WIN32API GetEnvironmentVariableA(LPCSTR arg1, LPSTR arg2, DWORD  arg3)
     113{
     114    dprintf(("KERNEL32:  GetEnvironmentVariable %s\n", arg1));
     115    return O32_GetEnvironmentVariable(arg1, arg2, arg3);
     116}
     117//******************************************************************************
     118//******************************************************************************
     119DWORD WIN32API GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer,
     120                                       DWORD nSize)
    139121{
    140122  char *astring, *asciibuffer;
    141123  DWORD rc;
    142124
    143   asciibuffer = (char *)malloc(nSize+1);
    144   *asciibuffer = 0;
    145   astring     = UnicodeToAsciiString((LPWSTR)lpName);
    146 
    147   rc = O32_GetEnvironmentVariable(astring, asciibuffer, nSize);
    148   AsciiToUnicode(asciibuffer, lpBuffer);
    149   FreeAsciiString(astring);
    150   free(asciibuffer);
    151   return(rc);
     125    dprintf(("KERNEL32:  OS2GetEnvironmentVariableW\n"));
     126    asciibuffer = (char *)malloc(nSize+1);
     127    *asciibuffer = 0;
     128    astring     = UnicodeToAsciiString((LPWSTR)lpName);
     129
     130    rc = O32_GetEnvironmentVariable(astring, asciibuffer, nSize);
     131    AsciiToUnicode(asciibuffer, lpBuffer);
     132    FreeAsciiString(astring);
     133    free(asciibuffer);
     134    return(rc);
    152135}
    153136/***********************************************************************
     
    186169 *****************************************************************************/
    187170
    188 ODINFUNCTION3(DWORD,  ExpandEnvironmentStringsA,
    189               LPCSTR, lpSrc,
    190               LPSTR,  lpDst,
    191               DWORD,  nSize)
     171DWORD WIN32API ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
    192172{
    193173    DWORD len, total_size = 1;  /* 1 for terminating '\0' */
    194174    LPCSTR p, var;
    195175
    196     if (!nSize) lpDst = NULL;
    197 
    198     while (*lpSrc)
    199     {
    200         if (*lpSrc != '%')
     176    dprintf(("KERNEL32:ExpandEnvironmentStringsA '%s', %08x, %08x",
     177              src, dst, count
     178              ));
     179
     180    if (!count) dst = NULL;
     181
     182    while (*src)
     183    {
     184        if (*src != '%')
    201185        {
    202             if ((p = strchr( lpSrc, '%' ))) len = p - lpSrc;
    203             else len = strlen(lpSrc);
    204             var = lpSrc;
    205             lpSrc += len;
     186            if ((p = strchr( src, '%' ))) len = p - src;
     187            else len = strlen(src);
     188            var = src;
     189            src += len;
    206190        }
    207191        else  /* we are at the start of a variable */
    208192        {
    209             if ((p = strchr( lpSrc + 1, '%' )))
     193            if ((p = strchr( src + 1, '%' )))
    210194            {
    211                 len = p - lpSrc - 1;  /* Length of the variable name */
     195                len = p - src - 1;  /* Length of the variable name */   
    212196                if ((var = ENV_FindVariable( GetEnvironmentStringsA(),
    213                                              lpSrc + 1, len )))
     197                                             src + 1, len )))
    214198                {
    215                     lpSrc += len + 2;  /* Skip the variable name */
     199                    src += len + 2;  /* Skip the variable name */
    216200                    len = strlen(var);
    217201                }
    218202                else
    219203                {
    220                     var = lpSrc;  /* Copy original name instead */
     204                    var = src;  /* Copy original name instead */
    221205                    len += 2;
    222                     lpSrc += len;
     206                    src += len;
    223207                }
    224208            }
    225209            else  /* unfinished variable name, ignore it */
    226210            {
    227                 var = lpSrc;
    228                 len = strlen(lpSrc);  /* Copy whole string */
    229                 lpSrc += len;
     211                var = src;
     212                len = strlen(src);  /* Copy whole string */
     213                src += len;
    230214            }
    231215        }
    232216        total_size += len;
    233         if (lpDst)
     217        if (dst)
    234218        {
    235             if (nSize < len) len = nSize;
    236             memcpy( lpDst, var, len );
    237             lpDst += len;
    238             nSize -= len;
     219            if (count < len) len = count;
     220            memcpy( dst, var, len );
     221            dst += len;
     222            count -= len;
    239223        }
    240224    }
    241225
    242226    /* Null-terminate the string */
    243     if (lpDst)
    244     {
    245         if (!nSize) lpDst--;
    246         *lpDst = '\0';
     227    if (dst)
     228    {
     229        if (!count) dst--;
     230        *dst = '\0';
    247231    }
    248232    dprintf(("KERNEL32:ExpandEnvironmentStringsA returned %s %d",
    249               lpDst, total_size));
     233              dst, total_size));
    250234    return total_size;
    251235}
     
    270254 *****************************************************************************/
    271255
    272 ODINFUNCTION3(DWORD,  ExpandEnvironmentStringsW,
    273               LPCWSTR,lpSrc,
    274               LPWSTR, lpDst,
    275               DWORD,  nSize)
     256DWORD WIN32API ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
    276257{
    277258    LPSTR srcA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpSrc );
    278259    LPSTR dstA = lpDst ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, nSize ) : NULL;
    279260
     261    dprintf(("KERNEL32:ExpandEnvironmentStringsW(%08x,%08x,%08x)", lpSrc, lpDst, nSize));
     262
    280263    DWORD ret  = ExpandEnvironmentStringsA( srcA, dstA, nSize );
    281264    if (dstA)
Note: See TracChangeset for help on using the changeset viewer.