]> git.saurik.com Git - apple/launchd.git/blob - launchd/src/launch.h
0a8a1750928ce8f62412b063866c4b9c741f8f6e
[apple/launchd.git] / launchd / src / launch.h
1 /*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 #ifndef _LAUNCH_H_
24 #define _LAUNCH_H_
25
26 #include <stddef.h>
27 #include <stdbool.h>
28
29
30 #define LAUNCH_KEY_SUBMITJOB "SubmitJob"
31 #define LAUNCH_KEY_REMOVEJOB "RemoveJob"
32 #define LAUNCH_KEY_STARTJOB "StartJob"
33 #define LAUNCH_KEY_STOPJOB "StopJob"
34 #define LAUNCH_KEY_GETJOB "GetJob"
35 #define LAUNCH_KEY_GETJOBWITHHANDLES "GetJobWithHandles"
36 #define LAUNCH_KEY_GETJOBS "GetJobs"
37 #define LAUNCH_KEY_CHECKIN "CheckIn"
38
39 #define LAUNCH_JOBKEY_LABEL "Label"
40 #define LAUNCH_JOBKEY_DISABLED "Disabled"
41 #define LAUNCH_JOBKEY_USERNAME "UserName"
42 #define LAUNCH_JOBKEY_GROUPNAME "GroupName"
43 #define LAUNCH_JOBKEY_TIMEOUT "TimeOut"
44 #define LAUNCH_JOBKEY_INITGROUPS "InitGroups"
45 #define LAUNCH_JOBKEY_SOCKETS "Sockets"
46 #define LAUNCH_JOBKEY_EVENTSOURCES "EventSources"
47 #define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility"
48 #define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments"
49 #define LAUNCH_JOBKEY_PROGRAM "Program"
50 #define LAUNCH_JOBKEY_ONDEMAND "OnDemand"
51 #define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad"
52 #define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory"
53 #define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory"
54 #define LAUNCH_JOBKEY_SERVICEDESCRIPTION "ServiceDescription"
55 #define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables"
56 #define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables"
57 #define LAUNCH_JOBKEY_PID "PID"
58 #define LAUNCH_JOBKEY_UMASK "Umask"
59 #define LAUNCH_JOBKEY_NICE "Nice"
60 #define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO"
61 #define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate"
62 #define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits"
63 #define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits"
64 #define LAUNCH_JOBKEY_SERVICEIPC "ServiceIPC"
65 #define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath"
66 #define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath"
67 #define LAUNCH_JOBKEY_DEBUG "Debug"
68 #define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories"
69 #define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths"
70 #define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval"
71 #define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval"
72 #define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs"
73
74 #define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait"
75
76 #define LAUNCH_JOBKEY_CAL_MINUTE "Minute"
77 #define LAUNCH_JOBKEY_CAL_HOUR "Hour"
78 #define LAUNCH_JOBKEY_CAL_DAY "Day"
79 #define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday"
80 #define LAUNCH_JOBKEY_CAL_MONTH "Month"
81
82 #define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core"
83 #define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU"
84 #define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data"
85 #define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize"
86 #define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock"
87 #define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles"
88 #define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses"
89 #define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize"
90 #define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack"
91
92 #define LAUNCH_JOBSOCKETKEY_TYPE "SockType"
93 #define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive"
94 #define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour"
95 #define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey"
96 #define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName"
97 #define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName"
98 #define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName"
99 #define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily"
100 #define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol"
101 #define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup"
102
103 typedef struct _launch_data *launch_data_t;
104
105 typedef enum {
106 LAUNCH_DATA_DICTIONARY = 1,
107 LAUNCH_DATA_ARRAY,
108 LAUNCH_DATA_FD,
109 LAUNCH_DATA_INTEGER,
110 LAUNCH_DATA_REAL,
111 LAUNCH_DATA_BOOL,
112 LAUNCH_DATA_STRING,
113 LAUNCH_DATA_OPAQUE,
114 LAUNCH_DATA_ERRNO,
115 } launch_data_type_t;
116
117 launch_data_t launch_data_alloc(launch_data_type_t);
118 launch_data_t launch_data_copy(launch_data_t);
119 launch_data_type_t launch_data_get_type(launch_data_t);
120 void launch_data_free(launch_data_t);
121
122 /* Generic Dictionaries */
123 /* the value should not be changed while iterating */
124 bool launch_data_dict_insert(launch_data_t, launch_data_t, const char *);
125 launch_data_t launch_data_dict_lookup(launch_data_t, const char *);
126 bool launch_data_dict_remove(launch_data_t, const char *);
127 void launch_data_dict_iterate(launch_data_t, void (*)(launch_data_t, const char *, void *), void *);
128 size_t launch_data_dict_get_count(launch_data_t);
129
130 /* Generic Arrays */
131 bool launch_data_array_set_index(launch_data_t, launch_data_t, size_t);
132 launch_data_t launch_data_array_get_index(launch_data_t, size_t);
133 size_t launch_data_array_get_count(launch_data_t);
134
135 launch_data_t launch_data_new_fd(int);
136 launch_data_t launch_data_new_integer(long long);
137 launch_data_t launch_data_new_bool(bool);
138 launch_data_t launch_data_new_real(double);
139 launch_data_t launch_data_new_string(const char *);
140 launch_data_t launch_data_new_opaque(const void *, size_t);
141
142 bool launch_data_set_fd(launch_data_t, int);
143 bool launch_data_set_integer(launch_data_t, long long);
144 bool launch_data_set_bool(launch_data_t, bool);
145 bool launch_data_set_real(launch_data_t, double);
146 bool launch_data_set_string(launch_data_t, const char *);
147 bool launch_data_set_opaque(launch_data_t, const void *, size_t);
148
149 int launch_data_get_fd(launch_data_t);
150 long long launch_data_get_integer(launch_data_t);
151 bool launch_data_get_bool(launch_data_t);
152 double launch_data_get_real(launch_data_t);
153 const char * launch_data_get_string(launch_data_t);
154 void * launch_data_get_opaque(launch_data_t);
155 size_t launch_data_get_opaque_size(launch_data_t);
156 int launch_data_get_errno(launch_data_t);
157
158
159 /* launch_get_fd()
160 *
161 * Use this to get the FD if you're doing asynchronous I/O with select(),
162 * poll() or kevent().
163 */
164 int launch_get_fd(void);
165
166 /* launch_msg()
167 *
168 * Use this API to send and receive messages.
169 * Calling launch_msg() with no message to send is a valid way to get
170 * asynchronously received messages.
171 *
172 * If a message was to be sent, it returns NULL and errno on failure.
173 *
174 * If no messages were to be sent, it returns NULL and errno is set to zero if
175 * no more asynchronous messages are available.
176 */
177 launch_data_t launch_msg(launch_data_t);
178
179 #endif