Better too long lines detection, added del key support in emacs mode.
[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  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <string.h>
23 #include <unistd.h>
24 #include <stdlib.h>
25 #include <errno.h>
26
27 #include "winnls.h"
28 #include "winbase.h"
29 #include "winerror.h"
30 #include "wine/exception.h"
31 #include "msvcrt/excpt.h"
32 #include "wine/debug.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(win32);
35
36 /* filter for page-fault exceptions */
37 static WINE_EXCEPTION_FILTER(page_fault)
38 {
39     if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
40         return EXCEPTION_EXECUTE_HANDLER;
41     return EXCEPTION_CONTINUE_SEARCH;
42 }
43
44 /***********************************************************************
45  *              GetComputerNameA         (KERNEL32.@)
46  */
47 BOOL WINAPI GetComputerNameA(LPSTR name,LPDWORD size)
48 {
49     /* At least Win95OSR2 survives if size is not a pointer (NT crashes though) */
50     BOOL ret;
51     __TRY
52     {
53         char host_name[256];
54         TRACE("*size = %ld\n", *size);
55         ret = (gethostname(host_name, sizeof(host_name)) != -1);
56         if (ret)
57         {
58             lstrcpynA(name, host_name, *size);
59             *size = strlen(name);
60         }
61         else
62             WARN("gethostname: %s\n", strerror(errno));
63     }
64     __EXCEPT(page_fault)
65     {
66       SetLastError( ERROR_INVALID_PARAMETER );
67       return FALSE;
68     }
69     __ENDTRY
70
71     TRACE("returning (%ld) %s\n", *size, debugstr_a(name));
72     return ret;
73 }
74
75 /***********************************************************************
76  *              GetComputerNameW         (KERNEL32.@)
77  */
78 BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
79 {
80     LPSTR nameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *size);
81     BOOL ret = GetComputerNameA(nameA,size);
82     /* FIXME: should set *size in Unicode chars */
83     if (ret) MultiByteToWideChar( CP_ACP, 0, nameA, -1, name, *size+1 );
84     HeapFree( GetProcessHeap(), 0, nameA );
85     return ret;
86 }
87
88 /***********************************************************************
89  *              GetComputerNameExA         (KERNEL32.@)
90  */
91 BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT type, LPSTR name, LPDWORD size)
92 {
93     FIXME("(%d, %p, %p) semi-stub!\n", type, name, size);
94     return GetComputerNameA(name, size);
95 }
96
97 /***********************************************************************
98  *              GetComputerNameExW         (KERNEL32.@)
99  */
100 BOOL WINAPI GetComputerNameExW(COMPUTER_NAME_FORMAT type, LPWSTR name, LPDWORD size)
101 {
102     FIXME("(%d, %p, %p) semi-stub!\n", type, name, size);
103     return GetComputerNameW(name, size);
104 }