| 1 | /*
|
|---|
| 2 | * Win32 Network apis
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright 1998 Peter Fitzsimmons
|
|---|
| 5 | * 1999 Przemyslaw Dobrowolski
|
|---|
| 6 | *
|
|---|
| 7 | */
|
|---|
| 8 | #define INCL_DOSEXCEPTIONS
|
|---|
| 9 | #define INCL_DOSMEMMGR
|
|---|
| 10 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
|---|
| 11 | #include <stdlib.h>
|
|---|
| 12 | #include <stdio.h>
|
|---|
| 13 | #include <string.h>
|
|---|
| 14 | #include "misc.h"
|
|---|
| 15 | #include "unicode.h"
|
|---|
| 16 |
|
|---|
| 17 | //******************************************************************************
|
|---|
| 18 | //******************************************************************************
|
|---|
| 19 | BOOL WIN32API GetComputerNameA(LPSTR name, LPDWORD size)
|
|---|
| 20 | {
|
|---|
| 21 | char *szHostname;
|
|---|
| 22 | char szDefault[]="NONAME";
|
|---|
| 23 | int cbSize;
|
|---|
| 24 |
|
|---|
| 25 | szHostname=getenv("HOSTNAME");
|
|---|
| 26 |
|
|---|
| 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 |
|
|---|
| 35 | return TRUE;
|
|---|
| 36 | }
|
|---|
| 37 | //******************************************************************************
|
|---|
| 38 | //******************************************************************************
|
|---|
| 39 | BOOL WIN32API GetComputerNameW(LPWSTR name, LPDWORD size)
|
|---|
| 40 | {
|
|---|
| 41 | LPSTR nameA = NULL;
|
|---|
| 42 | BOOL ret;
|
|---|
| 43 |
|
|---|
| 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;
|
|---|
| 53 | }
|
|---|
| 54 | //******************************************************************************
|
|---|
| 55 | //******************************************************************************
|
|---|
| 56 | BOOL WIN32API GetComputerName32W(LPWSTR name, LPDWORD size)
|
|---|
| 57 | {
|
|---|
| 58 | LPSTR nameA = NULL;
|
|---|
| 59 | BOOL ret;
|
|---|
| 60 |
|
|---|
| 61 | if (name) nameA=(LPSTR)malloc(2**size);
|
|---|
| 62 |
|
|---|
| 63 | ret = GetComputerNameA(nameA,size);
|
|---|
| 64 |
|
|---|
| 65 | if (ret) AsciiToUnicode(nameA, name);
|
|---|
| 66 |
|
|---|
| 67 | free(nameA);
|
|---|
| 68 |
|
|---|
| 69 | return ret;
|
|---|
| 70 | }
|
|---|
| 71 | //******************************************************************************
|
|---|
| 72 | //******************************************************************************
|
|---|