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