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