kernel32/tests/pipe: Enable compilation with long types.
[wine.git] / dlls / kernel32 / console.c
blobda8171dcccf96b3789e9d18bfe5352a1b0113911
1 /*
2 * Win32 console functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
5 * Copyright 1997 Karl Garrison
6 * Copyright 1998 John Richardson
7 * Copyright 1998 Marcus Meissner
8 * Copyright 2001,2002,2004,2005,2010 Eric Pouech
9 * Copyright 2001 Alexandre Julliard
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <limits.h>
31 #define NONAMELESSUNION
32 #include "ntstatus.h"
33 #define WIN32_NO_STATUS
34 #include "windef.h"
35 #include "winbase.h"
36 #include "winternl.h"
37 #include "winnls.h"
38 #include "winerror.h"
39 #include "wincon.h"
40 #include "wine/condrv.h"
41 #include "wine/debug.h"
42 #include "kernel_private.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(console);
46 /******************************************************************
47 * OpenConsoleW (KERNEL32.@)
49 * Undocumented
50 * Open a handle to the current process console.
51 * Returns INVALID_HANDLE_VALUE on failure.
53 HANDLE WINAPI OpenConsoleW(LPCWSTR name, DWORD access, BOOL inherit, DWORD creation)
55 SECURITY_ATTRIBUTES sa;
57 TRACE("(%s, 0x%08lx, %d, %lu)\n", debugstr_w(name), access, inherit, creation);
59 if (!name || (wcsicmp( L"CONIN$", name ) && wcsicmp( L"CONOUT$", name )) || creation != OPEN_EXISTING)
61 SetLastError( ERROR_INVALID_PARAMETER );
62 return INVALID_HANDLE_VALUE;
65 sa.nLength = sizeof(sa);
66 sa.lpSecurityDescriptor = NULL;
67 sa.bInheritHandle = inherit;
69 return CreateFileW( name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, creation, 0, NULL );
72 /******************************************************************
73 * VerifyConsoleIoHandle (KERNEL32.@)
75 * Undocumented
77 BOOL WINAPI VerifyConsoleIoHandle(HANDLE handle)
79 IO_STATUS_BLOCK io;
80 DWORD mode;
81 return !NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io, IOCTL_CONDRV_GET_MODE,
82 NULL, 0, &mode, sizeof(mode) );
85 /******************************************************************
86 * DuplicateConsoleHandle (KERNEL32.@)
88 * Undocumented
90 HANDLE WINAPI DuplicateConsoleHandle(HANDLE handle, DWORD access, BOOL inherit,
91 DWORD options)
93 HANDLE ret;
94 return DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(), &ret,
95 access, inherit, options) ? ret : INVALID_HANDLE_VALUE;
98 /******************************************************************
99 * CloseConsoleHandle (KERNEL32.@)
101 * Undocumented
103 BOOL WINAPI CloseConsoleHandle(HANDLE handle)
105 return CloseHandle(handle);
108 /******************************************************************
109 * GetConsoleInputWaitHandle (KERNEL32.@)
111 * Undocumented
113 HANDLE WINAPI GetConsoleInputWaitHandle(void)
115 return GetStdHandle( STD_INPUT_HANDLE );
119 /***********************************************************************
120 * GetConsoleKeyboardLayoutNameA (KERNEL32.@)
122 BOOL WINAPI GetConsoleKeyboardLayoutNameA(LPSTR layoutName)
124 FIXME( "stub %p\n", layoutName);
125 return TRUE;
128 /***********************************************************************
129 * GetConsoleKeyboardLayoutNameW (KERNEL32.@)
131 BOOL WINAPI GetConsoleKeyboardLayoutNameW(LPWSTR layoutName)
133 static int once;
134 if (!once++)
135 FIXME( "stub %p\n", layoutName);
136 return TRUE;
139 BOOL WINAPI SetConsoleIcon(HICON icon)
141 FIXME(": (%p) stub!\n", icon);
142 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
143 return FALSE;
146 DWORD WINAPI GetNumberOfConsoleFonts(void)
148 return 1;
151 BOOL WINAPI SetConsoleFont(HANDLE hConsole, DWORD index)
153 FIXME("(%p, %lu): stub!\n", hConsole, index);
154 SetLastError(LOWORD(E_NOTIMPL) /* win10 1709+ */);
155 return FALSE;
158 BOOL WINAPI SetConsoleKeyShortcuts(BOOL set, BYTE keys, VOID *a, DWORD b)
160 FIXME(": (%u %u %p %lu) stub!\n", set, keys, a, b);
161 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
162 return FALSE;
166 BOOL WINAPI GetConsoleFontInfo(HANDLE hConsole, BOOL maximize, DWORD numfonts, CONSOLE_FONT_INFO *info)
168 FIXME("(%p %d %lu %p): stub!\n", hConsole, maximize, numfonts, info);
169 SetLastError(LOWORD(E_NOTIMPL) /* win10 1709+ */);
170 return FALSE;