Changeset 400 for trunk/src


Ignore:
Timestamp:
Jul 27, 1999, 8:57:52 AM (26 years ago)
Author:
sandervl
Message:

Przemyslaw Dobrowolski's GetComputerNameA/W changes

File:
1 edited

Legend:

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

    r152 r400  
    1 /* $Id: network.cpp,v 1.5 1999-06-22 08:09:29 sandervl Exp $ */
    2 
    3 /*
    4  *
    5  * Project Odin Software License can be found in LICENSE.TXT
    6  *
    7  */
    81/*
    92 * Win32 Network apis
    103 *
    114 * Copyright 1998 Peter Fitzsimmons
     5 *           1999 Przemyslaw Dobrowolski
    126 *
    137 */
     
    159#define INCL_DOSMEMMGR
    1610#include <os2wrap.h>    //Odin32 OS/2 api wrappers
    17 //#include <pmwsock.h>
    1811#include <stdlib.h>
    1912#include <stdio.h>
     
    2619BOOL WIN32API GetComputerNameA(LPSTR name, LPDWORD size)
    2720{
    28 #if 1   /*PLF Wed  98-03-18 23:38:28*/
    29 //*plf removing need for wsock32 call.
    30 // This should be done with UPM anyway.
    31 return FALSE;
    32 #else
    33   if (-1==gethostname(name,*size))
    34     return FALSE;
     21  char *szHostname;
     22  char szDefault[]="NONAME";
     23  int  cbSize;
     24 
     25  szHostname=getenv("HOSTNAME");
    3526
    36   *size = strlen(name);
     27  if (!szHostname) szHostname=szDefault;
     28     
     29  if (name) strncpy(name,szHostname,*size);
     30
     31  *size=strlen(name); 
     32
     33  dprintf(("KERNEL32 GetComputerNameA: %s (size %d)",name,*size));
     34
    3735  return TRUE;
    38 #endif
    3936}
    4037//******************************************************************************
    4138//******************************************************************************
    42 BOOL WIN32API GetComputerNameW(LPSTR name, LPDWORD size)
     39BOOL WIN32API GetComputerNameW(LPWSTR name, LPDWORD size)
    4340{
    44 #if 1   /*PLF Wed  98-03-18 23:38:28*/
    45 //*plf removing need for wsock32 call.
    46 // This should be done with UPM anyway.
    47 return FALSE;
    48 #else
    49   if (-1==OS2gethostname(name,*size))
    50     return FALSE;
    51   @@@PH do unicode conversion
     41  LPSTR nameA = NULL;
     42  BOOL  ret;
    5243
    53   *size = strlen(name);
    54   return TRUE;
    55 #endif
     44  if (name) nameA=(LPSTR)malloc(2**size);
     45
     46  ret = GetComputerNameA(nameA,size);
     47
     48  if (ret) AsciiToUnicode(nameA,name);
     49
     50  free(nameA);
     51
     52  return ret;
    5653}
    5754//******************************************************************************
     
    5956BOOL WIN32API GetComputerName32W(LPWSTR name, LPDWORD size)
    6057{
    61  LPSTR nameA = (LPSTR)malloc(*size);
    62  BOOL  ret = GetComputerNameA(nameA,size);
     58  LPSTR nameA = NULL;
     59  BOOL  ret;
    6360
    64     if (ret)
    65       AsciiToUnicode(nameA, name);
     61  if (name) nameA=(LPSTR)malloc(2**size);
    6662
    67     free(nameA);
    68     /* FIXME : size correct? */
    69     return ret;
     63  ret = GetComputerNameA(nameA,size);
     64
     65  if (ret) AsciiToUnicode(nameA, name);
     66
     67  free(nameA);
     68
     69  return ret;
    7070}
    7171//******************************************************************************
    7272//******************************************************************************
    73 
Note: See TracChangeset for help on using the changeset viewer.