]> git.saurik.com Git - apple/launchd.git/blame_incremental - SystemStarter/StartupItems.h
launchd-842.92.1.tar.gz
[apple/launchd.git] / SystemStarter / StartupItems.h
... / ...
CommitLineData
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 *
9 * @APPLE_APACHE_LICENSE_HEADER_START@
10 *
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
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
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@
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")
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/*
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.
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
84CFStringRef StartupItemCreateDescription(CFMutableDictionaryRef anItem);
85
86/*
87 * Returns a list of currently executing startup items.
88 */
89CFArrayRef StartupItemListCreateFromRunning(CFArrayRef anItemList);
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
110/*
111 * Check whether file was created before boot and has proper permissions to run.
112 */
113bool StartupItemSecurityCheck(const char *aPath);
114
115#endif /* _StartupItems_H_ */