Rearranged PAINT_RedrawWindow() so that it first recursively updates
[wine] / win32 / newfns.c
1 /*
2  * Win32 miscellaneous functions
3  *
4  * Copyright 1995 Thomas Sandford (tdgsandf@prds-grn.demon.co.uk)
5  */
6
7 /* Misc. new functions - they should be moved into appropriate files
8 at a later date. */
9
10 #include <string.h>
11 #include <sys/time.h>
12 #include <unistd.h>
13 #include "windef.h"
14 #include "winerror.h"
15 #include "heap.h"
16 #include "debugtools.h"
17 #include "debugstr.h"
18
19 DECLARE_DEBUG_CHANNEL(debug)
20 DECLARE_DEBUG_CHANNEL(win32)
21
22
23 /****************************************************************************
24  *              QueryPerformanceCounter (KERNEL32.564)
25  */
26 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
27 {
28     struct timeval tv;
29
30     gettimeofday(&tv,NULL);
31     counter->LowPart = tv.tv_usec+tv.tv_sec*1000000;
32     counter->HighPart = 0;
33     return TRUE;
34 }
35
36 /****************************************************************************
37  *              QueryPerformanceFrequency (KERNEL32.565)
38  */
39 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
40 {
41         frequency->LowPart      = 1000000;
42         frequency->HighPart     = 0;
43         return TRUE;
44 }
45
46 /****************************************************************************
47  *              FlushInstructionCache (KERNEL32.261)
48  */
49 BOOL WINAPI FlushInstructionCache(DWORD x,DWORD y,DWORD z) {
50         FIXME_(debug)("(0x%08lx,0x%08lx,0x%08lx): stub\n",x,y,z);
51         return TRUE;
52 }
53
54 /***********************************************************************
55  *           CreateNamedPipeA   (KERNEL32.168)
56  */
57 HANDLE WINAPI CreateNamedPipeA (LPCSTR lpName, DWORD dwOpenMode,
58                                   DWORD dwPipeMode, DWORD nMaxInstances,
59                                   DWORD nOutBufferSize, DWORD nInBufferSize,
60                                   DWORD nDefaultTimeOut,
61                                   LPSECURITY_ATTRIBUTES lpSecurityAttributes)
62 {
63   FIXME_(win32)("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
64          debugstr_a(lpName), dwOpenMode, dwPipeMode, nMaxInstances,
65          nOutBufferSize, nInBufferSize, nDefaultTimeOut, 
66          lpSecurityAttributes);
67   /* if (nMaxInstances > PIPE_UNLIMITED_INSTANCES) {
68     SetLastError (ERROR_INVALID_PARAMETER);
69     return INVALID_HANDLE_VALUE;
70   } */
71
72   SetLastError (ERROR_UNKNOWN);
73   return INVALID_HANDLE_VALUE;
74 }
75
76 /***********************************************************************
77  *           CreateNamedPipeW   (KERNEL32.169)
78  */
79 HANDLE WINAPI CreateNamedPipeW (LPCWSTR lpName, DWORD dwOpenMode,
80                                   DWORD dwPipeMode, DWORD nMaxInstances,
81                                   DWORD nOutBufferSize, DWORD nInBufferSize,
82                                   DWORD nDefaultTimeOut,
83                                   LPSECURITY_ATTRIBUTES lpSecurityAttributes)
84 {
85   FIXME_(win32)("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
86          debugstr_w(lpName), dwOpenMode, dwPipeMode, nMaxInstances,
87          nOutBufferSize, nInBufferSize, nDefaultTimeOut, 
88          lpSecurityAttributes);
89
90   SetLastError (ERROR_UNKNOWN);
91   return INVALID_HANDLE_VALUE;
92 }
93
94 /***********************************************************************
95  *           GetSystemPowerStatus      (KERNEL32.621)
96  */
97 BOOL WINAPI GetSystemPowerStatus(LPSYSTEM_POWER_STATUS sps_ptr)
98 {
99     return FALSE;   /* no power management support */
100 }
101
102
103 /***********************************************************************
104  *           SetSystemPowerState      (KERNEL32.630)
105  */
106 BOOL WINAPI SetSystemPowerState(BOOL suspend_or_hibernate,
107                                   BOOL force_flag)
108 {
109     /* suspend_or_hibernate flag: w95 does not support
110        this feature anyway */
111
112     for ( ;0; )
113     {
114         if ( force_flag )
115         {
116         }
117         else
118         {
119         }
120     }
121     return TRUE;
122 }
123
124
125 /******************************************************************************
126  * CreateMailslot32A [KERNEL32.164]
127  */
128 HANDLE WINAPI CreateMailslotA( LPCSTR lpName, DWORD nMaxMessageSize,
129                                    DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa)
130 {
131     FIXME_(win32)("(%s,%ld,%ld,%p): stub\n", debugstr_a(lpName),
132           nMaxMessageSize, lReadTimeout, sa);
133     return 1;
134 }
135
136
137 /******************************************************************************
138  * CreateMailslot32W [KERNEL32.165]  Creates a mailslot with specified name
139  * 
140  * PARAMS
141  *    lpName          [I] Pointer to string for mailslot name
142  *    nMaxMessageSize [I] Maximum message size
143  *    lReadTimeout    [I] Milliseconds before read time-out
144  *    sa              [I] Pointer to security structure
145  *
146  * RETURNS
147  *    Success: Handle to mailslot
148  *    Failure: INVALID_HANDLE_VALUE
149  */
150 HANDLE WINAPI CreateMailslotW( LPCWSTR lpName, DWORD nMaxMessageSize,
151                                    DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa )
152 {
153     FIXME_(win32)("(%s,%ld,%ld,%p): stub\n", debugstr_w(lpName), 
154           nMaxMessageSize, lReadTimeout, sa);
155     return 1;
156 }
157
158
159 /******************************************************************************
160  * GetMailslotInfo [KERNEL32.347]  Retrieves info about specified mailslot
161  *
162  * PARAMS
163  *    hMailslot        [I] Mailslot handle
164  *    lpMaxMessageSize [O] Address of maximum message size
165  *    lpNextSize       [O] Address of size of next message
166  *    lpMessageCount   [O] Address of number of messages
167  *    lpReadTimeout    [O] Address of read time-out
168  * 
169  * RETURNS
170  *    Success: TRUE
171  *    Failure: FALSE
172  */
173 BOOL WINAPI GetMailslotInfo( HANDLE hMailslot, LPDWORD lpMaxMessageSize,
174                                LPDWORD lpNextSize, LPDWORD lpMessageCount,
175                                LPDWORD lpReadTimeout )
176 {
177     FIXME_(win32)("(%04x): stub\n",hMailslot);
178     if (lpMaxMessageSize) *lpMaxMessageSize = (DWORD)NULL;
179     if (lpNextSize) *lpNextSize = (DWORD)NULL;
180     if (lpMessageCount) *lpMessageCount = (DWORD)NULL;
181     if (lpReadTimeout) *lpReadTimeout = (DWORD)NULL;
182     return TRUE;
183 }
184
185
186 /******************************************************************************
187  * GetCompressedFileSize32A [KERNEL32.291]
188  *
189  * NOTES
190  *    This should call the W function below
191  */
192 DWORD WINAPI GetCompressedFileSizeA(
193     LPCSTR lpFileName,
194     LPDWORD lpFileSizeHigh)
195 {
196     FIXME_(win32)("(...): stub\n");
197     return 0xffffffff;
198 }
199
200
201 /******************************************************************************
202  * GetCompressedFileSize32W [KERNEL32.292]  
203  * 
204  * RETURNS
205  *    Success: Low-order doubleword of number of bytes
206  *    Failure: 0xffffffff
207  */
208 DWORD WINAPI GetCompressedFileSizeW(
209     LPCWSTR lpFileName,     /* [in]  Pointer to name of file */
210     LPDWORD lpFileSizeHigh) /* [out] Receives high-order doubleword of size */
211 {
212     FIXME_(win32)("(%s,%p): stub\n",debugstr_w(lpFileName),lpFileSizeHigh);
213     return 0xffffffff;
214 }
215
216
217 /******************************************************************************
218  * GetProcessWindowStation [USER32.280]  Returns handle of window station
219  *
220  * NOTES
221  *    Docs say the return value is HWINSTA
222  *
223  * RETURNS
224  *    Success: Handle to window station associated with calling process
225  *    Failure: NULL
226  */
227 DWORD WINAPI GetProcessWindowStation(void)
228 {
229     FIXME_(win32)("(void): stub\n");
230     return 1;
231 }
232
233
234 /******************************************************************************
235  * GetThreadDesktop [USER32.295]  Returns handle to desktop
236  *
237  * NOTES
238  *    Docs say the return value is HDESK
239  *
240  * PARAMS
241  *    dwThreadId [I] Thread identifier
242  *
243  * RETURNS
244  *    Success: Handle to desktop associated with specified thread
245  *    Failure: NULL
246  */
247 DWORD WINAPI GetThreadDesktop( DWORD dwThreadId )
248 {
249     FIXME_(win32)("(%lx): stub\n",dwThreadId);
250     return 1;
251 }
252
253
254 /******************************************************************************
255  * SetDebugErrorLevel [USER32.475]
256  * Sets the minimum error level for generating debugging events
257  *
258  * PARAMS
259  *    dwLevel [I] Debugging error level
260  */
261 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
262 {
263     FIXME_(win32)("(%ld): stub\n", dwLevel);
264 }
265
266
267 /******************************************************************************
268  * WaitForDebugEvent [KERNEL32.720]
269  * Waits for a debugging event to occur in a process being debugged
270  *
271  * PARAMS
272  *    lpDebugEvent   [I] Address of structure for event information
273  *    dwMilliseconds [I] Number of milliseconds to wait for event
274  *
275  * RETURNS STD
276  */
277 BOOL WINAPI WaitForDebugEvent( LPDEBUG_EVENT lpDebugEvent, 
278                                  DWORD dwMilliseconds )
279 {
280     FIXME_(win32)("(%p,%ld): stub\n", lpDebugEvent, dwMilliseconds);
281     return FALSE;
282 }
283
284
285 /******************************************************************************
286  * SetComputerName32A [KERNEL32.621]  
287  */
288 BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
289 {
290     LPWSTR lpComputerNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpComputerName);
291     BOOL ret = SetComputerNameW(lpComputerNameW);
292     HeapFree(GetProcessHeap(),0,lpComputerNameW);
293     return ret;
294 }
295
296
297 /******************************************************************************
298  * SetComputerName32W [KERNEL32.622]
299  *
300  * PARAMS
301  *    lpComputerName [I] Address of new computer name
302  * 
303  * RETURNS STD
304  */
305 BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
306 {
307     FIXME_(win32)("(%s): stub\n", debugstr_w(lpComputerName));
308     return TRUE;
309 }
310
311
312 BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE ports,DWORD bufsize,LPDWORD bufneeded,LPDWORD bufreturned) {
313         FIXME_(win32)("(%s,%ld,%p,%ld,%p,%p), stub!\n",name,level,ports,bufsize,bufneeded,bufreturned);
314         return FALSE;
315 }
316
317 /******************************************************************************
318  * IsDebuggerPresent [KERNEL32.827]
319  *
320  */
321 BOOL WINAPI IsDebuggerPresent() {
322         FIXME_(win32)(" ... no debuggers yet, returning FALSE.\n");
323         return FALSE; 
324 }
325
326 /******************************************************************************
327  * OpenDesktop32A [USER32.408]
328  *
329  * NOTES
330  *    Return type should be HDESK
331  */
332 HANDLE WINAPI OpenDesktopA( LPCSTR lpszDesktop, DWORD dwFlags, 
333                                 BOOL fInherit, DWORD dwDesiredAccess )
334 {
335     FIXME_(win32)("(%s,%lx,%i,%lx): stub\n",debugstr_a(lpszDesktop),dwFlags,
336           fInherit,dwDesiredAccess);
337     return 1;
338 }
339
340
341 BOOL WINAPI SetUserObjectInformationA( HANDLE hObj, int nIndex, 
342                                            LPVOID pvInfo, DWORD nLength )
343 {
344     FIXME_(win32)("(%x,%d,%p,%lx): stub\n",hObj,nIndex,pvInfo,nLength);
345     return TRUE;
346 }
347
348
349 BOOL WINAPI SetThreadDesktop( HANDLE hDesktop )
350 {
351     FIXME_(win32)("(%x): stub\n",hDesktop);
352     return TRUE;
353 }
354
355 HANDLE WINAPI CreateIoCompletionPort(HANDLE hFileHandle,
356 HANDLE hExistingCompletionPort, DWORD dwCompletionKey,
357 DWORD dwNumberOfConcurrentThreads)
358 {
359     FIXME_(win32)("(%04x, %04x, %08lx, %08lx): stub.\n", hFileHandle, hExistingCompletionPort, dwCompletionKey, dwNumberOfConcurrentThreads);
360     return (HANDLE)NULL;
361 }