Make Home, End and Enter on the keypad work in the debugger.
[wine] / win32 / init.c
1 /*
2  * Win32 kernel functions
3  *
4  * Copyright 1995 Martin von Loewis and Cameron Heide
5  * 1999 Peter Ganten
6  */
7
8 #include <string.h>
9 #include <unistd.h>
10 #include <stdlib.h>
11 #include <errno.h>
12
13 #include "winnls.h"
14 #include "winbase.h"
15 #include "winerror.h"
16 #include "wine/exception.h"
17 #include "debugtools.h"
18
19 DEFAULT_DEBUG_CHANNEL(win32);
20   
21 /* filter for page-fault exceptions */
22 static WINE_EXCEPTION_FILTER(page_fault)
23 {
24     if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
25         return EXCEPTION_EXECUTE_HANDLER;
26     return EXCEPTION_CONTINUE_SEARCH;
27 }
28
29 /***********************************************************************
30  *              GetComputerNameA         (KERNEL32.@)
31  */
32 BOOL WINAPI GetComputerNameA(LPSTR name,LPDWORD size)
33 {
34     /* At least Win95OSR2 survives if size is not a pointer (NT crashes though) */
35     BOOL ret;
36     __TRY
37     {
38         char host_name[256];
39         TRACE("*size = %ld\n", *size);
40         ret = (gethostname(host_name, sizeof(host_name)) != -1);
41         if (ret)
42         {
43             lstrcpynA(name, host_name, *size);
44             *size = strlen(name);
45         }
46         else
47             WARN("gethostname: %s\n", strerror(errno));
48     }
49     __EXCEPT(page_fault)
50     {
51       SetLastError( ERROR_INVALID_PARAMETER );
52       return FALSE;
53     }
54     __ENDTRY
55
56     TRACE("returning (%ld) %s\n", *size, debugstr_a(name));
57     return ret;
58 }
59
60 /***********************************************************************
61  *              GetComputerNameW         (KERNEL32.@)
62  */
63 BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
64 {
65     LPSTR nameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *size);
66     BOOL ret = GetComputerNameA(nameA,size);
67     /* FIXME: should set *size in Unicode chars */
68     if (ret) MultiByteToWideChar( CP_ACP, 0, nameA, -1, name, *size+1 );
69     HeapFree( GetProcessHeap(), 0, nameA );
70     return ret;
71 }
72
73 /***********************************************************************
74  *              GetComputerNameExA         (KERNEL32.@)
75  */
76 BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT type, LPSTR name, LPDWORD size)
77 {
78     FIXME("(%d, %p, %p) semi-stub!\n", type, name, size);
79     return GetComputerNameA(name, size);
80 }
81
82 /***********************************************************************
83  *              GetComputerNameExW         (KERNEL32.@)
84  */
85 BOOL WINAPI GetComputerNameExW(COMPUTER_NAME_FORMAT type, LPWSTR name, LPDWORD size)
86 {
87     FIXME("(%d, %p, %p) semi-stub!\n", type, name, size);
88     return GetComputerNameW(name, size);
89 }