Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/openlaunchd
Path: blob/master/liblaunch/launch_getters.c
374 views
1
/*
2
* Copyright (c) 2013 Apple, Inc, R. Tyler Croy, All rights reserved.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
#include "launch.h"
18
#include "launch_priv.h"
19
#include "launch_internal.h"
20
21
int
22
launch_data_get_errno(launch_data_t d)
23
{
24
if (NULL == d) {
25
return 0;
26
}
27
return d->err;
28
}
29
30
int
31
launch_data_get_fd(launch_data_t d)
32
{
33
if (NULL == d) {
34
return 0;
35
}
36
return d->fd;
37
}
38
39
long long
40
launch_data_get_integer(launch_data_t d)
41
{
42
if (NULL == d) {
43
return 0;
44
}
45
return d->number;
46
}
47
48
bool
49
launch_data_get_bool(launch_data_t d)
50
{
51
return d->boolean;
52
}
53
54
double
55
launch_data_get_real(launch_data_t d)
56
{
57
return d->float_num;
58
}
59
60
const char *
61
launch_data_get_string(launch_data_t d)
62
{
63
if (LAUNCH_DATA_STRING != d->type)
64
return NULL;
65
return d->string;
66
}
67
68
void *
69
launch_data_get_opaque(launch_data_t d)
70
{
71
if (LAUNCH_DATA_OPAQUE != d->type)
72
return NULL;
73
return d->opaque;
74
}
75
76
size_t
77
launch_data_get_opaque_size(launch_data_t d)
78
{
79
return d->opaque_size;
80
}
81
82
int
83
launchd_getfd(launch_t l)
84
{
85
return (l->which == LAUNCHD_USE_CHECKIN_FD) ? l->cifd : l->fd;
86
}
87
88
#if HAS_MACH
89
mach_port_t
90
launch_data_get_machport(launch_data_t d)
91
{
92
return d->mp;
93
}
94
#endif
95
96