source: trunk/src/kernel32/network.cpp@ 2802

Last change on this file since 2802 was 2802, checked in by sandervl, 26 years ago

Added new logging feature

File size: 2.5 KB
Line 
1/*
2 * Win32 Network apis
3 *
4 * Copyright 1998 Peter Fitzsimmons
5 * 1999 Przemyslaw Dobrowolski
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 */
9#define INCL_DOSEXCEPTIONS
10#define INCL_DOSMEMMGR
11#include <os2wrap.h> //Odin32 OS/2 api wrappers
12#include <stdlib.h>
13#include <stdio.h>
14#include <string.h>
15#include "misc.h"
16#include "unicode.h"
17
18#define DBG_LOCALLOG DBG_network
19#include "dbglocal.h"
20
21//******************************************************************************
22// GetComputerName
23//
24// Retrieve the NetBIOS name of the computer
25//******************************************************************************
26BOOL WIN32API GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize)
27{
28 char szDefault[] = "NONAME";
29 char * szHostname = getenv("HOSTNAME"); // This is wrong;
30 // We should use NETBIOS computername
31
32 if (!szHostname) // Hostname not set; assume a default
33 szHostname = szDefault;
34
35 *nSize = min(strlen(szHostname) + 1, *nSize); // Truncate name as reqd.
36 // NB W95/98 would generate a
37 // BUFFER_OVERFLOW error here
38
39 if (lpBuffer)
40 {
41 strncpy(lpBuffer, szHostname, *nSize - 1); // Copy back name.
42 lpBuffer[*nSize - 1] = 0; // Ensure terminated.
43 }
44
45 dprintf(("KERNEL32: GetComputerNameA (Name: %.*s, nSize: %d)", *nSize, lpBuffer, *nSize));
46
47 return TRUE;
48}
49//******************************************************************************
50//******************************************************************************
51BOOL WIN32API GetComputerNameW(LPWSTR name, LPDWORD size)
52{
53 LPSTR nameA = NULL;
54 BOOL ret;
55
56 if (name) nameA=(LPSTR)malloc(2**size);
57
58 ret = GetComputerNameA(nameA,size);
59
60 if (ret) AsciiToUnicode(nameA,name);
61
62 free(nameA);
63
64 return ret;
65}
66//******************************************************************************
67//******************************************************************************
68BOOL WIN32API GetComputerName32W(LPWSTR name, LPDWORD size)
69{
70 LPSTR nameA = NULL;
71 BOOL ret;
72
73 if (name) nameA=(LPSTR)malloc(2**size);
74
75 ret = GetComputerNameA(nameA,size);
76
77 if (ret) AsciiToUnicode(nameA, name);
78
79 free(nameA);
80
81 return ret;
82}
83//******************************************************************************
84//******************************************************************************
Note: See TracBrowser for help on using the repository browser.