Fixed quoting of KDE desktop entry.
[wine/multimedia.git] / win32 / newfns.c
blob53cc0df62d6c01c67940cfd01963c5885049abfb
1 /*
2 * Win32 miscellaneous functions
4 * Copyright 1995 Thomas Sandford (tdgsandf@prds-grn.demon.co.uk)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* Misc. new functions - they should be moved into appropriate files
22 at a later date. */
24 #include <stdio.h>
25 #include <string.h>
26 #include <sys/time.h>
27 #include <unistd.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
31 #include "winerror.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(win32);
35 WINE_DECLARE_DEBUG_CHANNEL(debug);
38 static BOOL QUERYPERF_Initialized = 0;
39 #if defined(__i386__) && defined(__GNUC__)
40 static BOOL QUERYPERF_RDTSC_Use = 0;
41 static LONGLONG QUERYPERF_RDTSC_Frequency = 0;
42 #endif
44 static void QUERYPERF_Init(void)
46 #if defined(__i386__) && defined(__GNUC__)
47 /* We are running on i386 and compiling on GCC.
48 * Do a runtime check to see if we have the rdtsc instruction available
50 FILE *fp;
51 char line[256], *s, *value;
52 double cpuMHz;
54 TRACE("()\n");
56 if (IsProcessorFeaturePresent( PF_RDTSC_INSTRUCTION_AVAILABLE ))
58 /* rdtsc is available. However, in order to use it
59 * we also need to be able to get the processor's
60 * speed. Currently we do this by reading /proc/cpuinfo
61 * which makes it Linux-specific.
64 TRACE("rdtsc available\n");
66 fp = fopen( "/proc/cpuinfo", "r" );
67 if (fp)
69 while(fgets( line, sizeof(line), fp ))
71 /* NOTE: the ':' is the only character we can rely on */
72 if (!(value = strchr( line, ':' )))
73 continue;
75 /* terminate the valuename */
76 *value++ = '\0';
77 /* skip any leading spaces */
78 while (*value == ' ') value++;
79 if ((s = strchr( value, '\n' )))
80 *s = '\0';
82 if (!strncasecmp( line, "cpu MHz", strlen( "cpu MHz" ) ))
84 if (sscanf( value, "%lf", &cpuMHz ) == 1)
86 QUERYPERF_RDTSC_Frequency = (LONGLONG)(cpuMHz * 1000000.0);
87 QUERYPERF_RDTSC_Use = TRUE;
88 TRACE("using frequency: %lldHz\n", QUERYPERF_RDTSC_Frequency);
89 break;
93 fclose(fp);
96 #endif
97 QUERYPERF_Initialized = TRUE;
101 /****************************************************************************
102 * QueryPerformanceCounter (KERNEL32.@)
104 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
106 struct timeval tv;
108 if (!QUERYPERF_Initialized)
109 QUERYPERF_Init();
111 #if defined(__i386__) && defined(__GNUC__)
112 if (QUERYPERF_RDTSC_Use)
114 /* i586 optimized version */
115 __asm__ __volatile__ ( "rdtsc"
116 : "=a" (counter->s.LowPart), "=d" (counter->s.HighPart) );
117 return TRUE;
119 /* fall back to generic routine (ie, for i386, i486) */
120 #endif
122 /* generic routine */
123 gettimeofday( &tv, NULL );
124 counter->QuadPart = (LONGLONG)tv.tv_usec + (LONGLONG)tv.tv_sec * 1000000LL;
125 return TRUE;
128 /****************************************************************************
129 * QueryPerformanceFrequency (KERNEL32.@)
131 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
133 if (!QUERYPERF_Initialized)
134 QUERYPERF_Init();
136 #if defined(__i386__) && defined(__GNUC__)
137 if (QUERYPERF_RDTSC_Use)
139 frequency->QuadPart = QUERYPERF_RDTSC_Frequency;
140 return TRUE;
142 #endif
144 frequency->s.LowPart = 1000000;
145 frequency->s.HighPart = 0;
146 return TRUE;
149 /****************************************************************************
150 * FlushInstructionCache (KERNEL32.@)
152 BOOL WINAPI FlushInstructionCache(DWORD x,DWORD y,DWORD z) {
153 if (GetVersion() & 0x80000000) return TRUE; /* not NT, always TRUE */
154 FIXME_(debug)("(0x%08lx,0x%08lx,0x%08lx): stub\n",x,y,z);
155 return TRUE;
158 /***********************************************************************
159 * GetSystemPowerStatus (KERNEL32.@)
161 BOOL WINAPI GetSystemPowerStatus(LPSYSTEM_POWER_STATUS sps_ptr)
163 return FALSE; /* no power management support */
167 /***********************************************************************
168 * SetSystemPowerState (KERNEL32.@)
170 BOOL WINAPI SetSystemPowerState(BOOL suspend_or_hibernate,
171 BOOL force_flag)
173 /* suspend_or_hibernate flag: w95 does not support
174 this feature anyway */
176 for ( ;0; )
178 if ( force_flag )
181 else
185 return TRUE;
189 /******************************************************************************
190 * CreateMailslotA [KERNEL32.@]
192 HANDLE WINAPI CreateMailslotA( LPCSTR lpName, DWORD nMaxMessageSize,
193 DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa)
195 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_a(lpName),
196 nMaxMessageSize, lReadTimeout, sa);
197 return 1;
201 /******************************************************************************
202 * CreateMailslotW [KERNEL32.@] Creates a mailslot with specified name
204 * PARAMS
205 * lpName [I] Pointer to string for mailslot name
206 * nMaxMessageSize [I] Maximum message size
207 * lReadTimeout [I] Milliseconds before read time-out
208 * sa [I] Pointer to security structure
210 * RETURNS
211 * Success: Handle to mailslot
212 * Failure: INVALID_HANDLE_VALUE
214 HANDLE WINAPI CreateMailslotW( LPCWSTR lpName, DWORD nMaxMessageSize,
215 DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa )
217 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_w(lpName),
218 nMaxMessageSize, lReadTimeout, sa);
219 return 1;
223 /******************************************************************************
224 * GetMailslotInfo [KERNEL32.@] Retrieves info about specified mailslot
226 * PARAMS
227 * hMailslot [I] Mailslot handle
228 * lpMaxMessageSize [O] Address of maximum message size
229 * lpNextSize [O] Address of size of next message
230 * lpMessageCount [O] Address of number of messages
231 * lpReadTimeout [O] Address of read time-out
233 * RETURNS
234 * Success: TRUE
235 * Failure: FALSE
237 BOOL WINAPI GetMailslotInfo( HANDLE hMailslot, LPDWORD lpMaxMessageSize,
238 LPDWORD lpNextSize, LPDWORD lpMessageCount,
239 LPDWORD lpReadTimeout )
241 FIXME("(%04x): stub\n",hMailslot);
242 if (lpMaxMessageSize) *lpMaxMessageSize = (DWORD)NULL;
243 if (lpNextSize) *lpNextSize = (DWORD)NULL;
244 if (lpMessageCount) *lpMessageCount = (DWORD)NULL;
245 if (lpReadTimeout) *lpReadTimeout = (DWORD)NULL;
246 return TRUE;
250 /******************************************************************************
251 * GetCompressedFileSizeA [KERNEL32.@]
253 * NOTES
254 * This should call the W function below
256 DWORD WINAPI GetCompressedFileSizeA(
257 LPCSTR lpFileName,
258 LPDWORD lpFileSizeHigh)
260 FIXME("(...): stub\n");
261 return 0xffffffff;
265 /******************************************************************************
266 * GetCompressedFileSizeW [KERNEL32.@]
268 * RETURNS
269 * Success: Low-order doubleword of number of bytes
270 * Failure: 0xffffffff
272 DWORD WINAPI GetCompressedFileSizeW(
273 LPCWSTR lpFileName, /* [in] Pointer to name of file */
274 LPDWORD lpFileSizeHigh) /* [out] Receives high-order doubleword of size */
276 FIXME("(%s,%p): stub\n",debugstr_w(lpFileName),lpFileSizeHigh);
277 return 0xffffffff;
281 /******************************************************************************
282 * SetComputerNameA [KERNEL32.@]
284 BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
286 BOOL ret;
287 DWORD len = MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, NULL, 0 );
288 LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
290 MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, nameW, len );
291 ret = SetComputerNameW( nameW );
292 HeapFree( GetProcessHeap(), 0, nameW );
293 return ret;
297 /******************************************************************************
298 * SetComputerNameW [KERNEL32.@]
300 * PARAMS
301 * lpComputerName [I] Address of new computer name
303 * RETURNS STD
305 BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
307 FIXME("(%s): stub\n", debugstr_w(lpComputerName));
308 return TRUE;
311 /******************************************************************************
312 * CreateIoCompletionPort (KERNEL32.@)
314 HANDLE WINAPI CreateIoCompletionPort(HANDLE hFileHandle,
315 HANDLE hExistingCompletionPort, DWORD dwCompletionKey,
316 DWORD dwNumberOfConcurrentThreads)
318 FIXME("(%04x, %04x, %08lx, %08lx): stub.\n", hFileHandle, hExistingCompletionPort, dwCompletionKey, dwNumberOfConcurrentThreads);
319 return (HANDLE)NULL;
322 /******************************************************************************
323 * GetQueuedCompletionStatus (KERNEL32.@)
325 BOOL WINAPI GetQueuedCompletionStatus(
326 HANDLE CompletionPort, LPDWORD lpNumberOfBytesTransferred,
327 LPDWORD lpCompletionKey, LPOVERLAPPED *lpOverlapped, DWORD dwMilliseconds
329 FIXME("(%x,%p,%p,%p,%ld), stub!\n",CompletionPort,lpNumberOfBytesTransferred,lpCompletionKey,lpOverlapped,dwMilliseconds);
330 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
331 return FALSE;