2 * Win32 waitable timers
4 * Copyright 1999 Alexandre Julliard
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
22 #include "wine/port.h"
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
31 #include "wine/unicode.h"
32 #include "wine/server.h"
33 #include "wine/debug.h"
34 #include "ntdll_misc.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(timer
);
39 /***********************************************************************
40 * CreateWaitableTimerA (KERNEL32.@)
42 HANDLE WINAPI
CreateWaitableTimerA( SECURITY_ATTRIBUTES
*sa
, BOOL manual
, LPCSTR name
)
44 WCHAR buffer
[MAX_PATH
];
46 if (!name
) return CreateWaitableTimerW( sa
, manual
, NULL
);
48 if (!MultiByteToWideChar( CP_ACP
, 0, name
, -1, buffer
, MAX_PATH
))
50 SetLastError( ERROR_FILENAME_EXCED_RANGE
);
53 return CreateWaitableTimerW( sa
, manual
, buffer
);
57 /***********************************************************************
58 * CreateWaitableTimerW (KERNEL32.@)
60 HANDLE WINAPI
CreateWaitableTimerW( SECURITY_ATTRIBUTES
*sa
, BOOL manual
, LPCWSTR name
)
63 DWORD len
= name
? strlenW(name
) : 0;
66 SetLastError( ERROR_FILENAME_EXCED_RANGE
);
69 SERVER_START_REQ( create_timer
)
72 req
->inherit
= (sa
&& (sa
->nLength
>=sizeof(*sa
)) && sa
->bInheritHandle
);
73 wine_server_add_data( req
, name
, len
* sizeof(WCHAR
) );
75 wine_server_call_err( req
);
83 /***********************************************************************
84 * OpenWaitableTimerA (KERNEL32.@)
86 HANDLE WINAPI
OpenWaitableTimerA( DWORD access
, BOOL inherit
, LPCSTR name
)
88 WCHAR buffer
[MAX_PATH
];
90 if (!name
) return OpenWaitableTimerW( access
, inherit
, NULL
);
92 if (!MultiByteToWideChar( CP_ACP
, 0, name
, -1, buffer
, MAX_PATH
))
94 SetLastError( ERROR_FILENAME_EXCED_RANGE
);
97 return OpenWaitableTimerW( access
, inherit
, buffer
);
101 /***********************************************************************
102 * OpenWaitableTimerW (KERNEL32.@)
104 HANDLE WINAPI
OpenWaitableTimerW( DWORD access
, BOOL inherit
, LPCWSTR name
)
107 DWORD len
= name
? strlenW(name
) : 0;
110 SetLastError( ERROR_FILENAME_EXCED_RANGE
);
113 SERVER_START_REQ( open_timer
)
115 req
->access
= access
;
116 req
->inherit
= inherit
;
117 wine_server_add_data( req
, name
, len
* sizeof(WCHAR
) );
118 wine_server_call_err( req
);
126 /***********************************************************************
127 * SetWaitableTimer (KERNEL32.@)
129 BOOL WINAPI
SetWaitableTimer( HANDLE handle
, const LARGE_INTEGER
*when
, LONG period
,
130 PTIMERAPCROUTINE callback
, LPVOID arg
, BOOL resume
)
134 SERVER_START_REQ( set_timer
)
136 if (!when
->s
.LowPart
&& !when
->s
.HighPart
)
138 /* special case to start timeout on now+period without too many calculations */
140 req
->expire
.usec
= 0;
142 else NTDLL_get_server_timeout( &req
->expire
, when
);
144 req
->handle
= handle
;
145 req
->period
= period
;
146 req
->callback
= callback
;
148 if (resume
) SetLastError( ERROR_NOT_SUPPORTED
); /* set error but can still succeed */
149 ret
= !wine_server_call_err( req
);
156 /***********************************************************************
157 * CancelWaitableTimer (KERNEL32.@)
159 BOOL WINAPI
CancelWaitableTimer( HANDLE handle
)
162 SERVER_START_REQ( cancel_timer
)
164 req
->handle
= handle
;
165 ret
= !wine_server_call_err( req
);
172 /***********************************************************************
173 * CreateTimerQueue (KERNEL32.@)
175 HANDLE WINAPI
CreateTimerQueue()
178 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
183 /***********************************************************************
184 * DeleteTimerQueueEx (KERNEL32.@)
186 BOOL WINAPI
DeleteTimerQueueEx(HANDLE TimerQueue
, HANDLE CompletionEvent
)
188 FIXME("(%p, %p): stub\n", TimerQueue
, CompletionEvent
);
189 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
193 /***********************************************************************
194 * CreateTimerQueueTimer (KERNEL32.@)
196 * Creates a timer-queue timer. This timer expires at the specified due
197 * time (in ms), then after every specified period (in ms). When the timer
198 * expires, the callback function is called.
201 * nonzero on success or zero on faillure
206 BOOL WINAPI
CreateTimerQueueTimer( PHANDLE phNewTimer
, HANDLE TimerQueue
,
207 WAITORTIMERCALLBACK Callback
, PVOID Parameter
,
208 DWORD DueTime
, DWORD Period
, ULONG Flags
)
211 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
215 /***********************************************************************
216 * DeleteTimerQueueTimer (KERNEL32.@)
218 * Cancels a timer-queue timer.
221 * nonzero on success or zero on faillure
226 BOOL WINAPI
DeleteTimerQueueTimer( HANDLE TimerQueue
, HANDLE Timer
,
227 HANDLE CompletionEvent
)
230 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);