FreeRDP
nonehandle.c
1 
21 #include <winpr/config.h>
22 
23 #include "nonehandle.h"
24 
25 #ifndef _WIN32
26 
27 #include <pthread.h>
28 
29 static BOOL NoneHandleCloseHandle(HANDLE handle)
30 {
31  WINPR_NONE_HANDLE* none = (WINPR_NONE_HANDLE*)handle;
32  free(none);
33  return TRUE;
34 }
35 
36 static BOOL NoneHandleIsHandle(HANDLE handle)
37 {
38  return WINPR_HANDLE_IS_HANDLED(handle, HANDLE_TYPE_NONE, FALSE);
39 }
40 
41 static int NoneHandleGetFd(HANDLE handle)
42 {
43  if (!NoneHandleIsHandle(handle))
44  return -1;
45 
46  return -1;
47 }
48 
49 static HANDLE_OPS ops = { NoneHandleIsHandle,
50  NoneHandleCloseHandle,
51  NoneHandleGetFd,
52  NULL, /* CleanupHandle */
53  NULL,
54  NULL,
55  NULL,
56  NULL,
57  NULL,
58  NULL,
59  NULL,
60  NULL,
61  NULL,
62  NULL,
63  NULL,
64  NULL,
65  NULL,
66  NULL,
67  NULL,
68  NULL,
69  NULL };
70 
71 HANDLE CreateNoneHandle(void)
72 {
73  WINPR_NONE_HANDLE* none = (WINPR_NONE_HANDLE*)calloc(1, sizeof(WINPR_NONE_HANDLE));
74 
75  if (!none)
76  return NULL;
77 
78  none->common.ops = &ops;
79  return (HANDLE)none;
80 }
81 
82 #endif