]> git.saurik.com Git - apple/launchd.git/blob - liblaunch/launch.h
launchd-842.92.1.tar.gz
[apple/launchd.git] / liblaunch / launch.h
1 /*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
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
9 *
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
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21 #ifndef __LAUNCH_H__
22 #define __LAUNCH_H__
23
24 #include <mach/mach.h>
25 #include <sys/cdefs.h>
26 #include <stddef.h>
27 #include <stdbool.h>
28
29 #pragma GCC visibility push(default)
30
31 __BEGIN_DECLS
32
33 #ifdef __GNUC__
34 #define __ld_normal __attribute__((__nothrow__))
35 #define __ld_setter __attribute__((__nothrow__, __nonnull__))
36 #define __ld_getter __attribute__((__nothrow__, __nonnull__, __pure__, __warn_unused_result__))
37 #define __ld_iterator(x, y) __attribute__((__nonnull__(x, y)))
38 #define __ld_allocator __attribute__((__nothrow__, __malloc__, __nonnull__, __warn_unused_result__))
39 #else
40 #define __ld_normal
41 #define __ld_setter
42 #define __ld_getter
43 #define __ld_iterator(x, y)
44 #define __ld_allocator
45 #endif
46
47 #define LAUNCH_KEY_SUBMITJOB "SubmitJob"
48 #define LAUNCH_KEY_REMOVEJOB "RemoveJob"
49 #define LAUNCH_KEY_STARTJOB "StartJob"
50 #define LAUNCH_KEY_STOPJOB "StopJob"
51 #define LAUNCH_KEY_GETJOB "GetJob"
52 #define LAUNCH_KEY_GETJOBS "GetJobs"
53 #define LAUNCH_KEY_CHECKIN "CheckIn"
54
55 #define LAUNCH_JOBKEY_DEFAULTS "__Defaults"
56
57 #define LAUNCH_JOBKEY_LABEL "Label"
58 #define LAUNCH_JOBKEY_DISABLED "Disabled"
59 #define LAUNCH_JOBKEY_USERNAME "UserName"
60 #define LAUNCH_JOBKEY_GROUPNAME "GroupName"
61 #define LAUNCH_JOBKEY_TIMEOUT "TimeOut"
62 #define LAUNCH_JOBKEY_EXITTIMEOUT "ExitTimeOut"
63 #define LAUNCH_JOBKEY_INITGROUPS "InitGroups"
64 #define LAUNCH_JOBKEY_SOCKETS "Sockets"
65 #define LAUNCH_JOBKEY_MACHSERVICES "MachServices"
66 #define LAUNCH_JOBKEY_MACHSERVICELOOKUPPOLICIES "MachServiceLookupPolicies"
67 #define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility"
68 #define LAUNCH_JOBKEY_ENABLEGLOBBING "EnableGlobbing"
69 #define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments"
70 #define LAUNCH_JOBKEY_PROGRAM "Program"
71 #define LAUNCH_JOBKEY_ONDEMAND "OnDemand"
72 #define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive"
73 #define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts"
74 #define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts"
75 #define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType"
76 #define LAUNCH_JOBKEY_LIMITLOADTOHARDWARE "LimitLoadToHardware"
77 #define LAUNCH_JOBKEY_LIMITLOADFROMHARDWARE "LimitLoadFromHardware"
78 #define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad"
79 #define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory"
80 #define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory"
81 #define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables"
82 #define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables"
83 #define LAUNCH_JOBKEY_UMASK "Umask"
84 #define LAUNCH_JOBKEY_NICE "Nice"
85 #define LAUNCH_JOBKEY_HOPEFULLYEXITSFIRST "HopefullyExitsFirst"
86 #define LAUNCH_JOBKEY_HOPEFULLYEXITSLAST "HopefullyExitsLast"
87 #define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO"
88 #define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate"
89 #define LAUNCH_JOBKEY_STARTONMOUNT "StartOnMount"
90 #define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits"
91 #define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits"
92 #define LAUNCH_JOBKEY_STANDARDINPATH "StandardInPath"
93 #define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath"
94 #define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath"
95 #define LAUNCH_JOBKEY_DEBUG "Debug"
96 #define LAUNCH_JOBKEY_WAITFORDEBUGGER "WaitForDebugger"
97 #define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories"
98 #define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths"
99 #define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval"
100 #define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval"
101 #define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs"
102 #define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus"
103 #define LAUNCH_JOBKEY_PID "PID"
104 #define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval"
105 #define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce"
106 #define LAUNCH_JOBKEY_ABANDONPROCESSGROUP "AbandonProcessGroup"
107 #define LAUNCH_JOBKEY_IGNOREPROCESSGROUPATSHUTDOWN "IgnoreProcessGroupAtShutdown"
108 #define LAUNCH_JOBKEY_POLICIES "Policies"
109 #define LAUNCH_JOBKEY_ENABLETRANSACTIONS "EnableTransactions"
110 #define LAUNCH_JOBKEY_CFBUNDLEIDENTIFIER "CFBundleIdentifier"
111 #define LAUNCH_JOBKEY_PROCESSTYPE "ProcessType"
112 #define LAUNCH_KEY_PROCESSTYPE_APP "App"
113 #define LAUNCH_KEY_PROCESSTYPE_STANDARD "Standard"
114 #define LAUNCH_KEY_PROCESSTYPE_BACKGROUND "Background"
115 #define LAUNCH_KEY_PROCESSTYPE_INTERACTIVE "Interactive"
116 #define LAUNCH_KEY_PROCESSTYPE_ADAPTIVE "Adaptive"
117
118 #define LAUNCH_JOBPOLICY_DENYCREATINGOTHERJOBS "DenyCreatingOtherJobs"
119
120 #define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait"
121
122 #define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose"
123 #define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn"
124 #define LAUNCH_JOBKEY_MACH_DRAINMESSAGESONCRASH "DrainMessagesOnCrash"
125 #define LAUNCH_JOBKEY_MACH_PINGEVENTUPDATES "PingEventUpdates"
126
127 #define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit"
128 #define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState"
129 #define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState"
130 #define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBACTIVE "OtherJobActive"
131 #define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBENABLED "OtherJobEnabled"
132 #define LAUNCH_JOBKEY_KEEPALIVE_AFTERINITIALDEMAND "AfterInitialDemand"
133 #define LAUNCH_JOBKEY_KEEPALIVE_CRASHED "Crashed"
134
135 #define LAUNCH_JOBKEY_LAUNCHEVENTS "LaunchEvents"
136
137 #define LAUNCH_JOBKEY_CAL_MINUTE "Minute"
138 #define LAUNCH_JOBKEY_CAL_HOUR "Hour"
139 #define LAUNCH_JOBKEY_CAL_DAY "Day"
140 #define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday"
141 #define LAUNCH_JOBKEY_CAL_MONTH "Month"
142
143 #define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core"
144 #define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU"
145 #define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data"
146 #define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize"
147 #define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock"
148 #define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles"
149 #define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses"
150 #define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize"
151 #define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack"
152
153 #define LAUNCH_JOBKEY_DISABLED_MACHINETYPE "MachineType"
154 #define LAUNCH_JOBKEY_DISABLED_MODELNAME "ModelName"
155
156 #define LAUNCH_JOBSOCKETKEY_TYPE "SockType"
157 #define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive"
158 #define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour"
159 #define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey"
160 #define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName"
161 #define LAUNCH_JOBSOCKETKEY_PATHMODE "SockPathMode"
162 #define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName"
163 #define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName"
164 #define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily"
165 #define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol"
166 #define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup"
167
168 /* These APIs are NOT suitable for general use. Their use should be constrained
169 * to checking into launchd to obtain socket file descriptors using the
170 * LAUNCH_CHECK_IN message type.
171 */
172 typedef struct _launch_data *launch_data_t;
173
174 typedef enum {
175 LAUNCH_DATA_DICTIONARY = 1,
176 LAUNCH_DATA_ARRAY,
177 LAUNCH_DATA_FD,
178 LAUNCH_DATA_INTEGER,
179 LAUNCH_DATA_REAL,
180 LAUNCH_DATA_BOOL,
181 LAUNCH_DATA_STRING,
182 LAUNCH_DATA_OPAQUE,
183 LAUNCH_DATA_ERRNO,
184 LAUNCH_DATA_MACHPORT,
185 } launch_data_type_t;
186
187 __ld_allocator
188 launch_data_t
189 launch_data_alloc(launch_data_type_t);
190
191 __ld_allocator
192 launch_data_t
193 launch_data_copy(launch_data_t);
194
195 __ld_getter
196 launch_data_type_t
197 launch_data_get_type(const launch_data_t);
198
199 __ld_setter
200 void
201 launch_data_free(launch_data_t);
202
203 __ld_setter
204 bool
205 launch_data_dict_insert(launch_data_t, const launch_data_t, const char *);
206
207 __ld_getter
208 launch_data_t
209 launch_data_dict_lookup(const launch_data_t, const char *);
210
211 __ld_setter
212 bool
213 launch_data_dict_remove(launch_data_t, const char *);
214
215 __ld_iterator(1, 2)
216 void
217 launch_data_dict_iterate(const launch_data_t,
218 void (*)(const launch_data_t, const char *, void *), void *);
219
220 __ld_getter
221 size_t
222 launch_data_dict_get_count(const launch_data_t);
223
224 __ld_setter
225 bool
226 launch_data_array_set_index(launch_data_t, const launch_data_t, size_t);
227
228 __ld_getter
229 launch_data_t
230 launch_data_array_get_index(const launch_data_t, size_t);
231
232 __ld_getter
233 size_t
234 launch_data_array_get_count(const launch_data_t);
235
236 __ld_allocator
237 launch_data_t
238 launch_data_new_fd(int);
239
240 __ld_allocator
241 launch_data_t
242 launch_data_new_machport(mach_port_t);
243
244 __ld_allocator
245 launch_data_t
246 launch_data_new_integer(long long);
247
248 __ld_allocator
249 launch_data_t
250 launch_data_new_bool(bool);
251
252 __ld_allocator
253 launch_data_t
254 launch_data_new_real(double);
255
256 __ld_allocator
257 launch_data_t
258 launch_data_new_string(const char *);
259
260 __ld_allocator
261 launch_data_t
262 launch_data_new_opaque(const void *, size_t);
263
264 __ld_setter
265 bool
266 launch_data_set_fd(launch_data_t, int);
267
268 __ld_setter
269 bool
270 launch_data_set_machport(launch_data_t, mach_port_t);
271
272 __ld_setter
273 bool
274 launch_data_set_integer(launch_data_t, long long);
275
276 __ld_setter
277 bool
278 launch_data_set_bool(launch_data_t, bool);
279
280 __ld_setter
281 bool
282 launch_data_set_real(launch_data_t, double);
283
284 __ld_setter
285 bool
286 launch_data_set_string(launch_data_t, const char *);
287
288 __ld_setter
289 bool
290 launch_data_set_opaque(launch_data_t, const void *, size_t);
291
292 __ld_getter
293 int
294 launch_data_get_fd(const launch_data_t);
295
296 __ld_getter
297 mach_port_t
298 launch_data_get_machport(const launch_data_t);
299
300 __ld_getter
301 long long
302 launch_data_get_integer(const launch_data_t);
303
304 __ld_getter
305 bool
306 launch_data_get_bool(const launch_data_t);
307
308 __ld_getter
309 double
310 launch_data_get_real(const launch_data_t);
311
312 __ld_getter
313 const char *
314 launch_data_get_string(const launch_data_t);
315
316 __ld_getter
317 void *
318 launch_data_get_opaque(const launch_data_t);
319
320 __ld_getter
321 size_t
322 launch_data_get_opaque_size(const launch_data_t);
323
324 __ld_getter
325 int
326 launch_data_get_errno(const launch_data_t);
327
328
329 /* launch_get_fd()
330 *
331 * Use this to get the FD if you're doing asynchronous I/O with select(),
332 * poll() or kevent().
333 */
334 __ld_normal
335 int
336 launch_get_fd(void);
337
338 /* launch_msg()
339 *
340 * Use this API to check in. Nothing else.
341 */
342 __ld_normal
343 launch_data_t
344 launch_msg(const launch_data_t);
345
346 __END_DECLS
347
348 #pragma GCC visibility pop
349
350 #endif /* __LAUNCH_H__ */