]> git.saurik.com Git - apple/launchd.git/blame - SystemStarter/StartupItems.h
launchd-842.92.1.tar.gz
[apple/launchd.git] / SystemStarter / StartupItems.h
CommitLineData
e91b9f68
A
1/**
2 * StartupItems.h - Startup Item management routines
3 * Wilfredo Sanchez | wsanchez@opensource.apple.com
4 * Kevin Van Vechten | kevinvv@uclink4.berkeley.edu
5 * $Apple$
6 **
7 * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.
8 *
ed34e3c3 9 * @APPLE_APACHE_LICENSE_HEADER_START@
e91b9f68 10 *
ed34e3c3
A
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
e91b9f68 14 *
ed34e3c3 15 * http://www.apache.org/licenses/LICENSE-2.0
e91b9f68 16 *
ed34e3c3
A
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
22 *
23 * @APPLE_APACHE_LICENSE_HEADER_END@
e91b9f68
A
24 **/
25
26#ifndef _StartupItems_H_
27#define _StartupItems_H_
28
29#include <NSSystemDirectories.h>
30
31#include <CoreFoundation/CFArray.h>
32#include <CoreFoundation/CFDictionary.h>
33
34#include "SystemStarter.h"
35
36#define kProvidesKey CFSTR("Provides")
37#define kRequiresKey CFSTR("Requires")
38#define kDescriptionKey CFSTR("Description")
39#define kUsesKey CFSTR("Uses")
40#define kErrorKey CFSTR("Error")
e91b9f68
A
41#define kBundlePathKey CFSTR("PathToBundle")
42#define kPIDKey CFSTR("ProcessID")
43#define kDomainKey CFSTR("Domain")
44
45
46#define kErrorPermissions CFSTR("incorrect permissions")
47#define kErrorInternal CFSTR("SystemStarter internal error")
48#define kErrorReturnNonZero CFSTR("execution of Startup script failed")
49#define kErrorFork CFSTR("could not fork() StartupItem")
50
51
52/*
53 * Find all available startup items in NSDomains specified by aMask.
54 */
55CFMutableArrayRef StartupItemListCreateWithMask (NSSearchPathDomainMask aMask);
56
57/*
58 * Returns the item responsible for providing aService.
59 */
60CFMutableDictionaryRef StartupItemListGetProvider (CFArrayRef anItemList, CFStringRef aService);
61
62/*
63 * Creates a list of items in anItemList which depend on anItem, given anAction.
64 */
65CFMutableArrayRef StartupItemListCreateDependentsList (CFMutableArrayRef anItemList,
66 CFStringRef aService ,
67 Action anAction );
68
69/*
ed34e3c3
A
70 * Given aWaitingList of startup items, and aStatusDict describing the current
71 * startup state, returns the next startup item to run, if any. Returns nil if
72 * none is available.
73 * Note that this is not necessarily deterministic; if more than one startup
74 * item is ready to run, which item gets returned is not specified. An item is
75 * not ready to run if the specified dependencies are not satisfied yet.
e91b9f68
A
76 */
77CFMutableDictionaryRef StartupItemListGetNext (CFArrayRef aWaitingList,
78 CFDictionaryRef aStatusDict ,
79 Action anAction );
80
81CFMutableDictionaryRef StartupItemWithPID (CFArrayRef anItemList, pid_t aPID);
82pid_t StartupItemGetPID(CFDictionaryRef anItem);
83
dcace88f 84CFStringRef StartupItemCreateDescription(CFMutableDictionaryRef anItem);
e91b9f68
A
85
86/*
87 * Returns a list of currently executing startup items.
88 */
dcace88f 89CFArrayRef StartupItemListCreateFromRunning(CFArrayRef anItemList);
e91b9f68
A
90
91/*
92 * Returns the total number of "Provides" entries of all loaded items.
93 */
94CFIndex StartupItemListCountServices (CFArrayRef anItemList);
95
96
97/*
98 * Utility functions
99 */
100void RemoveItemFromWaitingList(StartupContext aStartupContext, CFMutableDictionaryRef anItem);
101void AddItemToFailedList(StartupContext aStartupContext, CFMutableDictionaryRef anItem);
102
103/*
104 * Run the startup item.
105 */
106int StartupItemRun (CFMutableDictionaryRef aStatusDict, CFMutableDictionaryRef anItem, Action anAction);
107void StartupItemExit (CFMutableDictionaryRef aStatusDict, CFMutableDictionaryRef anItem, Boolean aSuccess);
108void StartupItemSetStatus(CFMutableDictionaryRef aStatusDict, CFMutableDictionaryRef anItem, CFStringRef aServiceName, Boolean aSuccess, Boolean aReplaceFlag);
109
ddbbfbc1
A
110/*
111 * Check whether file was created before boot and has proper permissions to run.
112 */
113bool StartupItemSecurityCheck(const char *aPath);
114
5c88273d 115#endif /* _StartupItems_H_ */