Coverage Report

Created: 2026-08-31 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/FreeRDP/winpr/libwinpr/handle/nonehandle.c
Line
Count
Source
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(WINPR_ATTR_UNUSED HANDLE handle)
30
0
{
31
0
  return TRUE;
32
0
}
33
34
static BOOL NoneHandleIsHandle(HANDLE handle)
35
0
{
36
0
  return WINPR_HANDLE_IS_HANDLED(handle, HANDLE_TYPE_NONE, FALSE);
37
0
}
38
39
static int NoneHandleGetFd(HANDLE handle)
40
0
{
41
0
  if (!NoneHandleIsHandle(handle))
42
0
    return -1;
43
44
0
  return -1;
45
0
}
46
47
static HANDLE_OPS ops = { NoneHandleIsHandle,
48
                        NoneHandleCloseHandle,
49
                        NoneHandleGetFd,
50
                        nullptr, /* CleanupHandle */
51
                        nullptr,
52
                        nullptr,
53
                        nullptr,
54
                        nullptr,
55
                        nullptr,
56
                        nullptr,
57
                        nullptr,
58
                        nullptr,
59
                        nullptr,
60
                        nullptr,
61
                        nullptr,
62
                        nullptr,
63
                        nullptr,
64
                        nullptr,
65
                        nullptr,
66
                        nullptr,
67
                        nullptr };
68
69
HANDLE CreateNoneHandle(void)
70
0
{
71
0
  WINPR_NONE_HANDLE* none = (WINPR_NONE_HANDLE*)calloc(1, sizeof(WINPR_NONE_HANDLE));
72
73
0
  if (!none)
74
0
    return nullptr;
75
76
0
  none->common.ops = &ops;
77
0
  none->common.refCount = 1;
78
0
  return (HANDLE)none;
79
0
}
80
81
void winpr_Handle_ConvertToNone(HANDLE handle)
82
0
{
83
0
  WINPR_HANDLE* hdl = (WINPR_HANDLE*)handle;
84
85
0
  if (!hdl)
86
0
    return;
87
88
0
  hdl->Type = HANDLE_TYPE_NONE;
89
0
  hdl->Mode = 0;
90
0
  hdl->ops = &ops;
91
0
}
92
93
#endif