]> git.saurik.com Git - apple/launchd.git/blame - launchd/src/launch.h
launchd-152.tar.gz
[apple/launchd.git] / launchd / src / launch.h
CommitLineData
e91b9f68
A
1/*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 *
ed34e3c3 4 * @APPLE_APACHE_LICENSE_HEADER_START@
e91b9f68 5 *
ed34e3c3
A
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
e91b9f68 9 *
ed34e3c3
A
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
e91b9f68
A
16 * limitations under the License.
17 *
ed34e3c3 18 * @APPLE_APACHE_LICENSE_HEADER_END@
e91b9f68
A
19 */
20#ifndef _LAUNCH_H_
21#define _LAUNCH_H_
22
ed34e3c3
A
23#include <mach/mach.h>
24#include <sys/cdefs.h>
e91b9f68
A
25#include <stddef.h>
26#include <stdbool.h>
27
ed34e3c3
A
28__BEGIN_DECLS
29
30#ifdef __GNUC__
31#define __ld_normal __attribute__((__nothrow__))
32#define __ld_setter __attribute__((__nothrow__, __nonnull__))
33#define __ld_getter __attribute__((__nothrow__, __nonnull__, __pure__, __warn_unused_result__))
34#define __ld_iterator(x, y) __attribute__((__nonnull__(x, y)))
35#define __ld_allocator __attribute__((__nothrow__, __malloc__, __nonnull__, __warn_unused_result__))
36#else
37#define __ld_normal
38#define __ld_setter
39#define __ld_getter
40#define __ld_iterator(x, y)
41#define __ld_allocator
42#endif
43
e91b9f68
A
44
45#define LAUNCH_KEY_SUBMITJOB "SubmitJob"
46#define LAUNCH_KEY_REMOVEJOB "RemoveJob"
47#define LAUNCH_KEY_STARTJOB "StartJob"
48#define LAUNCH_KEY_STOPJOB "StopJob"
49#define LAUNCH_KEY_GETJOB "GetJob"
50#define LAUNCH_KEY_GETJOBWITHHANDLES "GetJobWithHandles"
51#define LAUNCH_KEY_GETJOBS "GetJobs"
52#define LAUNCH_KEY_CHECKIN "CheckIn"
53
54#define LAUNCH_JOBKEY_LABEL "Label"
55#define LAUNCH_JOBKEY_DISABLED "Disabled"
56#define LAUNCH_JOBKEY_USERNAME "UserName"
57#define LAUNCH_JOBKEY_GROUPNAME "GroupName"
58#define LAUNCH_JOBKEY_TIMEOUT "TimeOut"
59#define LAUNCH_JOBKEY_INITGROUPS "InitGroups"
60#define LAUNCH_JOBKEY_SOCKETS "Sockets"
ed34e3c3 61#define LAUNCH_JOBKEY_MACHSERVICES "MachServices"
e91b9f68 62#define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility"
ed34e3c3 63#define LAUNCH_JOBKEY_ENABLEGLOBBING "EnableGlobbing"
e91b9f68
A
64#define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments"
65#define LAUNCH_JOBKEY_PROGRAM "Program"
66#define LAUNCH_JOBKEY_ONDEMAND "OnDemand"
ed34e3c3
A
67#define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive"
68#define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts"
69#define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts"
70#define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType"
e91b9f68
A
71#define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad"
72#define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory"
73#define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory"
74#define LAUNCH_JOBKEY_SERVICEDESCRIPTION "ServiceDescription"
75#define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables"
76#define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables"
ed34e3c3 77#define LAUNCH_JOBKEY_FORCEPOWERPC "ForcePowerPC"
e91b9f68
A
78#define LAUNCH_JOBKEY_UMASK "Umask"
79#define LAUNCH_JOBKEY_NICE "Nice"
80#define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO"
81#define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate"
82#define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits"
83#define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits"
e91b9f68
A
84#define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath"
85#define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath"
86#define LAUNCH_JOBKEY_DEBUG "Debug"
ed34e3c3 87#define LAUNCH_JOBKEY_WAITFORDEBUGGER "WaitForDebugger"
e91b9f68
A
88#define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories"
89#define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths"
90#define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval"
91#define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval"
92#define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs"
ed34e3c3
A
93#define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus"
94#define LAUNCH_JOBKEY_PID "PID"
95#define LAUNCH_JOBKEY_SUBJOBS "SubJobs"
e91b9f68
A
96
97#define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait"
98
ed34e3c3
A
99#define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose"
100#define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn"
101
102#define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit"
103#define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState"
104#define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState"
105
e91b9f68
A
106#define LAUNCH_JOBKEY_CAL_MINUTE "Minute"
107#define LAUNCH_JOBKEY_CAL_HOUR "Hour"
108#define LAUNCH_JOBKEY_CAL_DAY "Day"
109#define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday"
110#define LAUNCH_JOBKEY_CAL_MONTH "Month"
111
112#define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core"
113#define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU"
114#define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data"
115#define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize"
116#define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock"
117#define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles"
118#define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses"
119#define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize"
120#define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack"
121
122#define LAUNCH_JOBSOCKETKEY_TYPE "SockType"
123#define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive"
124#define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour"
125#define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey"
126#define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName"
aa59983a 127#define LAUNCH_JOBSOCKETKEY_PATHMODE "SockPathMode"
e91b9f68
A
128#define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName"
129#define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName"
130#define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily"
131#define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol"
ab36757d 132#define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup"
e91b9f68
A
133
134typedef struct _launch_data *launch_data_t;
135
136typedef enum {
137 LAUNCH_DATA_DICTIONARY = 1,
138 LAUNCH_DATA_ARRAY,
139 LAUNCH_DATA_FD,
140 LAUNCH_DATA_INTEGER,
141 LAUNCH_DATA_REAL,
142 LAUNCH_DATA_BOOL,
143 LAUNCH_DATA_STRING,
144 LAUNCH_DATA_OPAQUE,
145 LAUNCH_DATA_ERRNO,
ed34e3c3 146 LAUNCH_DATA_MACHPORT,
e91b9f68
A
147} launch_data_type_t;
148
ed34e3c3
A
149launch_data_t launch_data_alloc(launch_data_type_t) __ld_allocator;
150launch_data_t launch_data_copy(launch_data_t) __ld_allocator;
151launch_data_type_t launch_data_get_type(const launch_data_t) __ld_getter;
152void launch_data_free(launch_data_t) __ld_setter;
e91b9f68
A
153
154/* Generic Dictionaries */
155/* the value should not be changed while iterating */
ed34e3c3
A
156bool launch_data_dict_insert(launch_data_t, const launch_data_t, const char *) __ld_setter;
157launch_data_t launch_data_dict_lookup(const launch_data_t, const char *) __ld_getter;
158bool launch_data_dict_remove(launch_data_t, const char *) __ld_setter;
159void launch_data_dict_iterate(const launch_data_t, void (*)(const launch_data_t, const char *, void *), void *) __ld_iterator(1, 2);
160size_t launch_data_dict_get_count(const launch_data_t) __ld_getter;
e91b9f68
A
161
162/* Generic Arrays */
ed34e3c3
A
163bool launch_data_array_set_index(launch_data_t, const launch_data_t, size_t) __ld_setter;
164launch_data_t launch_data_array_get_index(const launch_data_t, size_t) __ld_getter;
165size_t launch_data_array_get_count(const launch_data_t) __ld_getter;
166
167launch_data_t launch_data_new_fd(int) __ld_allocator;
168launch_data_t launch_data_new_machport(mach_port_t) __ld_allocator;
169launch_data_t launch_data_new_integer(long long) __ld_allocator;
170launch_data_t launch_data_new_bool(bool) __ld_allocator;
171launch_data_t launch_data_new_real(double) __ld_allocator;
172launch_data_t launch_data_new_string(const char *) __ld_allocator;
173launch_data_t launch_data_new_opaque(const void *, size_t) __ld_allocator;
174
175bool launch_data_set_fd(launch_data_t, int) __ld_setter;
176bool launch_data_set_machport(launch_data_t, mach_port_t) __ld_setter;
177bool launch_data_set_integer(launch_data_t, long long) __ld_setter;
178bool launch_data_set_bool(launch_data_t, bool) __ld_setter;
179bool launch_data_set_real(launch_data_t, double) __ld_setter;
180bool launch_data_set_string(launch_data_t, const char *) __ld_setter;
181bool launch_data_set_opaque(launch_data_t, const void *, size_t) __ld_setter;
182
183int launch_data_get_fd(const launch_data_t) __ld_getter;
184mach_port_t launch_data_get_machport(const launch_data_t) __ld_getter;
185long long launch_data_get_integer(const launch_data_t) __ld_getter;
186bool launch_data_get_bool(const launch_data_t) __ld_getter;
187double launch_data_get_real(const launch_data_t) __ld_getter;
188const char * launch_data_get_string(const launch_data_t) __ld_getter;
189void * launch_data_get_opaque(const launch_data_t) __ld_getter;
190size_t launch_data_get_opaque_size(const launch_data_t) __ld_getter;
191int launch_data_get_errno(const launch_data_t) __ld_getter;
e91b9f68
A
192
193
194/* launch_get_fd()
195 *
196 * Use this to get the FD if you're doing asynchronous I/O with select(),
197 * poll() or kevent().
198 */
ed34e3c3 199int launch_get_fd(void) __ld_normal;
e91b9f68
A
200
201/* launch_msg()
202 *
203 * Use this API to send and receive messages.
204 * Calling launch_msg() with no message to send is a valid way to get
205 * asynchronously received messages.
206 *
207 * If a message was to be sent, it returns NULL and errno on failure.
208 *
209 * If no messages were to be sent, it returns NULL and errno is set to zero if
210 * no more asynchronous messages are available.
211 */
ed34e3c3
A
212launch_data_t launch_msg(const launch_data_t) __ld_normal;
213
214__END_DECLS
e91b9f68
A
215
216#endif