Changeset 4208 for trunk/src


Ignore:
Timestamp:
Sep 7, 2000, 11:40:28 PM (25 years ago)
Author:
phaller
Message:

Fixed some FS: bugs

Location:
trunk/src/kernel32
Files:
2 edited

Legend:

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

    r3512 r4208  
    1 /* $Id: environ.cpp,v 1.4 2000-05-10 13:13:32 sandervl Exp $ */
     1/* $Id: environ.cpp,v 1.5 2000-09-07 21:40:28 phaller Exp $ */
    22
    33/*
     
    1717 *
    1818 */
     19
     20/*****************************************************************************
     21 * Includes                                                                  *
     22 *****************************************************************************/
     23
    1924#include <odin.h>
    2025#include <odinwrap.h>
     
    3338#include "dbglocal.h"
    3439
    35 //******************************************************************************
    36 //******************************************************************************
    37 LPSTR WIN32API GetEnvironmentStringsA(void)
    38 {
    39     dprintf(("KERNEL32:  OS2GetEnvironmentStringsA\n"));
    40     return (LPSTR) O32_GetEnvironmentStrings();
    41 }
    42 //******************************************************************************
    43 //******************************************************************************
    44 LPWSTR WIN32API GetEnvironmentStringsW(VOID)
     40/*****************************************************************************
     41 * Defines                                                                   *
     42 *****************************************************************************/
     43
     44ODINDEBUGCHANNEL(KERNEL32-ENVIRONMENT)
     45
     46
     47//******************************************************************************
     48//******************************************************************************
     49ODINFUNCTION0(LPSTR, GetEnvironmentStringsA)
     50{
     51  return (LPSTR) O32_GetEnvironmentStrings();
     52}
     53//******************************************************************************
     54//******************************************************************************
     55ODINFUNCTION0(LPWSTR, GetEnvironmentStringsW)
    4556{
    4657 char *envstrings = (char *)O32_GetEnvironmentStrings();
     
    4859 LPWSTR wenvstrings;
    4960 int len, i;
    50 
    51   dprintf(("KERNEL32:  GetEnvironmentStringsW\n"));
    5261
    5362  if(envstrings == NULL)
     
    7382//******************************************************************************
    7483//******************************************************************************
    75 BOOL WIN32API FreeEnvironmentStringsA(LPSTR envstrings)
    76 {
    77   dprintf(("KERNEL32:  FreeEnvironmentStringsA\n"));
     84ODINFUNCTION1(BOOL, FreeEnvironmentStringsA,
     85              LPSTR, envstrings)
     86{
     87  dprintf(("not correctly implemented.\n"));
     88  //free(envstrings);
    7889  return(TRUE);
    7990}
    8091//******************************************************************************
    8192//******************************************************************************
    82 BOOL WIN32API FreeEnvironmentStringsW(LPWSTR envstrings)
    83 {
    84   dprintf(("KERNEL32:  FreeEnvironmentStringsW\n"));
    85   free(envstrings);
     93ODINFUNCTION1(BOOL,   FreeEnvironmentStringsW,
     94              LPWSTR, envstrings)
     95{
     96  dprintf(("not correctly implemented.\n"));
     97  //free(envstrings);
    8698  return(TRUE);
    8799}
    88100//******************************************************************************
    89101//******************************************************************************
    90 BOOL 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 //******************************************************************************
    97 BOOL 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 //******************************************************************************
    112 DWORD 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 //******************************************************************************
    119 DWORD WIN32API GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer,
    120                                        DWORD nSize)
     102ODINFUNCTION2(BOOL,   SetEnvironmentVariableA,
     103              LPCSTR, lpszName,
     104              LPCSTR, lpszValue)
     105{
     106  return O32_SetEnvironmentVariable(lpszName, lpszValue);
     107}
     108//******************************************************************************
     109//******************************************************************************
     110ODINFUNCTION2(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//******************************************************************************
     126ODINFUNCTION3(DWORD,  GetEnvironmentVariableA,
     127              LPCSTR, lpName,
     128              LPSTR,  lpBuffer,
     129              DWORD,  nSize)
     130{
     131  return O32_GetEnvironmentVariable(lpName, lpBuffer, nSize);
     132}
     133//******************************************************************************
     134//******************************************************************************
     135ODINFUNCTION3(DWORD,   GetEnvironmentVariableW,
     136              LPCWSTR, lpName,
     137              LPWSTR,  lpBuffer,
     138              DWORD,   nSize)
    121139{
    122140  char *astring, *asciibuffer;
    123141  DWORD rc;
    124142
    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);
     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);
    135152}
    136153/***********************************************************************
     
    169186 *****************************************************************************/
    170187
    171 DWORD WIN32API ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
     188ODINFUNCTION3(DWORD,  ExpandEnvironmentStringsA,
     189              LPCSTR, lpSrc,
     190              LPSTR,  lpDst,
     191              DWORD,  nSize)
    172192{
    173193    DWORD len, total_size = 1;  /* 1 for terminating '\0' */
    174194    LPCSTR p, var;
    175195
    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 != '%')
     196    if (!nSize) lpDst = NULL;
     197
     198    while (*lpSrc)
     199    {
     200        if (*lpSrc != '%')
    185201        {
    186             if ((p = strchr( src, '%' ))) len = p - src;
    187             else len = strlen(src);
    188             var = src;
    189             src += len;
     202            if ((p = strchr( lpSrc, '%' ))) len = p - lpSrc;
     203            else len = strlen(lpSrc);
     204            var = lpSrc;
     205            lpSrc += len;
    190206        }
    191207        else  /* we are at the start of a variable */
    192208        {
    193             if ((p = strchr( src + 1, '%' )))
     209            if ((p = strchr( lpSrc + 1, '%' )))
    194210            {
    195                 len = p - src - 1;  /* Length of the variable name */   
     211                len = p - lpSrc - 1;  /* Length of the variable name */
    196212                if ((var = ENV_FindVariable( GetEnvironmentStringsA(),
    197                                              src + 1, len )))
     213                                             lpSrc + 1, len )))
    198214                {
    199                     src += len + 2;  /* Skip the variable name */
     215                    lpSrc += len + 2;  /* Skip the variable name */
    200216                    len = strlen(var);
    201217                }
    202218                else
    203219                {
    204                     var = src;  /* Copy original name instead */
     220                    var = lpSrc;  /* Copy original name instead */
    205221                    len += 2;
    206                     src += len;
     222                    lpSrc += len;
    207223                }
    208224            }
    209225            else  /* unfinished variable name, ignore it */
    210226            {
    211                 var = src;
    212                 len = strlen(src);  /* Copy whole string */
    213                 src += len;
     227                var = lpSrc;
     228                len = strlen(lpSrc);  /* Copy whole string */
     229                lpSrc += len;
    214230            }
    215231        }
    216232        total_size += len;
    217         if (dst)
     233        if (lpDst)
    218234        {
    219             if (count < len) len = count;
    220             memcpy( dst, var, len );
    221             dst += len;
    222             count -= len;
     235            if (nSize < len) len = nSize;
     236            memcpy( lpDst, var, len );
     237            lpDst += len;
     238            nSize -= len;
    223239        }
    224240    }
    225241
    226242    /* Null-terminate the string */
    227     if (dst)
    228     {
    229         if (!count) dst--;
    230         *dst = '\0';
     243    if (lpDst)
     244    {
     245        if (!nSize) lpDst--;
     246        *lpDst = '\0';
    231247    }
    232248    dprintf(("KERNEL32:ExpandEnvironmentStringsA returned %s %d",
    233               dst, total_size));
     249              lpDst, total_size));
    234250    return total_size;
    235251}
     
    254270 *****************************************************************************/
    255271
    256 DWORD WIN32API ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
     272ODINFUNCTION3(DWORD,  ExpandEnvironmentStringsW,
     273              LPCWSTR,lpSrc,
     274              LPWSTR, lpDst,
     275              DWORD,  nSize)
    257276{
    258277    LPSTR srcA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpSrc );
    259278    LPSTR dstA = lpDst ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, nSize ) : NULL;
    260279
    261     dprintf(("KERNEL32:ExpandEnvironmentStringsW(%08x,%08x,%08x)", lpSrc, lpDst, nSize));
    262 
    263280    DWORD ret  = ExpandEnvironmentStringsA( srcA, dstA, nSize );
    264281    if (dstA)
  • trunk/src/kernel32/time.cpp

    r4174 r4208  
    1 /* $Id: time.cpp,v 1.9 2000-09-03 18:04:56 phaller Exp $ */
     1/* $Id: time.cpp,v 1.10 2000-09-07 21:40:27 phaller Exp $ */
    22
    33/*
     
    1414 * Project Odin Software License can be found in LICENSE.TXT
    1515 */
     16
     17
     18/*****************************************************************************
     19 * Includes                                                                  *
     20 *****************************************************************************/
     21
     22#include <odin.h>
     23#include <odinwrap.h>
     24#include <os2sel.h>
     25
    1626#include <os2win.h>
     27
    1728#include <winnls.h>
    1829#include "winuser.h"
     
    2435#define DBG_LOCALLOG    DBG_time
    2536#include "dbglocal.h"
     37
     38/*****************************************************************************
     39 * Defines                                                                   *
     40 *****************************************************************************/
     41
     42ODINDEBUGCHANNEL(KERNEL32-TIME)
     43
     44
    2645
    2746#define lstrcpynAtoW(unicode,ascii,asciilen) AsciiToUnicodeN(ascii,unicode,asciilen);
     
    131150//******************************************************************************
    132151//******************************************************************************
    133 VOID WIN32API GetSystemTime( LPSYSTEMTIME arg1)
    134 {
    135     dprintf(("KERNEL32:  OS2GetSystemTime\n"));
     152ODINPROCEDURE1(GetSystemTime,
     153               LPSYSTEMTIME, arg1)
     154{
    136155    O32_GetSystemTime(arg1);
    137156}
Note: See TracChangeset for help on using the changeset viewer.