source: trunk/src/kernel32/network.cpp

Last change on this file was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

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