- Timestamp:
- Jul 27, 1999, 8:57:52 AM (26 years ago)
- 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.TXT6 *7 */8 1 /* 9 2 * Win32 Network apis 10 3 * 11 4 * Copyright 1998 Peter Fitzsimmons 5 * 1999 Przemyslaw Dobrowolski 12 6 * 13 7 */ … … 15 9 #define INCL_DOSMEMMGR 16 10 #include <os2wrap.h> //Odin32 OS/2 api wrappers 17 //#include <pmwsock.h>18 11 #include <stdlib.h> 19 12 #include <stdio.h> … … 26 19 BOOL WIN32API GetComputerNameA(LPSTR name, LPDWORD size) 27 20 { 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"); 35 26 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 37 35 return TRUE; 38 #endif39 36 } 40 37 //****************************************************************************** 41 38 //****************************************************************************** 42 BOOL WIN32API GetComputerNameW(LP STR name, LPDWORD size)39 BOOL WIN32API GetComputerNameW(LPWSTR name, LPDWORD size) 43 40 { 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; 52 43 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; 56 53 } 57 54 //****************************************************************************** … … 59 56 BOOL WIN32API GetComputerName32W(LPWSTR name, LPDWORD size) 60 57 { 61 LPSTR nameA = (LPSTR)malloc(*size);62 BOOL ret = GetComputerNameA(nameA,size);58 LPSTR nameA = NULL; 59 BOOL ret; 63 60 64 if (ret) 65 AsciiToUnicode(nameA, name); 61 if (name) nameA=(LPSTR)malloc(2**size); 66 62 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; 70 70 } 71 71 //****************************************************************************** 72 72 //****************************************************************************** 73
Note:
See TracChangeset
for help on using the changeset viewer.