winpr: add a function to export timer file descriptor
The equivalent exist for Events, and it happens that sometime you also need to access the internal file descriptor associated with a timer.
This commit is contained in:
parent
a04021d38b
commit
ccffa8dfa2
@ -262,6 +262,8 @@ extern "C"
|
||||
#define OpenWaitableTimer OpenWaitableTimerA
|
||||
#endif
|
||||
|
||||
WINPR_API int GetTimerFileDescriptor(HANDLE hEvent);
|
||||
|
||||
/**
|
||||
* Timer-Queue Timer
|
||||
*/
|
||||
|
@ -658,6 +658,30 @@ BOOL CancelWaitableTimer(HANDLE hTimer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns inner file descriptor for usage with select()
|
||||
* This file descriptor is not usable on Windows
|
||||
*/
|
||||
|
||||
int GetTimerFileDescriptor(HANDLE hTimer)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
WINPR_HANDLE* hdl;
|
||||
ULONG type;
|
||||
|
||||
if (!winpr_Handle_GetInfo(hTimer, &type, &hdl) || type != HANDLE_TYPE_TIMER)
|
||||
{
|
||||
WLog_ERR(TAG, "GetTimerFileDescriptor: hTimer is not an timer");
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return winpr_Handle_getFd(hTimer);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Timer-Queue Timer
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user