/src/FreeRDP/winpr/libwinpr/handle/nonehandle.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /**  | 
2  |  |  * WinPR: Windows Portable Runtime  | 
3  |  |  * NoneHandle a.k.a. brathandle should be used where a handle is needed, but  | 
4  |  |  * functionality is not implemented yet or not implementable.  | 
5  |  |  *  | 
6  |  |  * Copyright 2014 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>  | 
7  |  |  *  | 
8  |  |  * Licensed under the Apache License, Version 2.0 (the "License");  | 
9  |  |  * you may not use this file except in compliance with the License.  | 
10  |  |  * You may obtain a copy of the License at  | 
11  |  |  *  | 
12  |  |  *     http://www.apache.org/licenses/LICENSE-2.0  | 
13  |  |  *  | 
14  |  |  * Unless required by applicable law or agreed to in writing, software  | 
15  |  |  * distributed under the License is distributed on an "AS IS" BASIS,  | 
16  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  | 
17  |  |  * See the License for the specific language governing permissions and  | 
18  |  |  * limitations under the License.  | 
19  |  |  */  | 
20  |  |  | 
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  | 0  | { | 
31  | 0  |   WINPR_NONE_HANDLE* none = (WINPR_NONE_HANDLE*)handle;  | 
32  | 0  |   free(none);  | 
33  | 0  |   return TRUE;  | 
34  | 0  | }  | 
35  |  |  | 
36  |  | static BOOL NoneHandleIsHandle(HANDLE handle)  | 
37  | 0  | { | 
38  | 0  |   return WINPR_HANDLE_IS_HANDLED(handle, HANDLE_TYPE_NONE, FALSE);  | 
39  | 0  | }  | 
40  |  |  | 
41  |  | static int NoneHandleGetFd(HANDLE handle)  | 
42  | 0  | { | 
43  | 0  |   if (!NoneHandleIsHandle(handle))  | 
44  | 0  |     return -1;  | 
45  |  |  | 
46  | 0  |   return -1;  | 
47  | 0  | }  | 
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  | 0  | { | 
73  | 0  |   WINPR_NONE_HANDLE* none = (WINPR_NONE_HANDLE*)calloc(1, sizeof(WINPR_NONE_HANDLE));  | 
74  |  | 
  | 
75  | 0  |   if (!none)  | 
76  | 0  |     return NULL;  | 
77  |  |  | 
78  | 0  |   none->common.ops = &ops;  | 
79  | 0  |   return (HANDLE)none;  | 
80  | 0  | }  | 
81  |  |  | 
82  |  | #endif  |