2 * StartupItems.h - Startup Item management routines
3 * Wilfredo Sanchez | wsanchez@opensource.apple.com
4 * Kevin Van Vechten | kevinvv@uclink4.berkeley.edu
7 * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.
9 * @APPLE_APACHE_LICENSE_HEADER_START@
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
15 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * @APPLE_APACHE_LICENSE_HEADER_END@
26 #ifndef _StartupItems_H_
27 #define _StartupItems_H_
29 #include <NSSystemDirectories.h>
31 #include <CoreFoundation/CFArray.h>
32 #include <CoreFoundation/CFDictionary.h>
34 #include "SystemStarter.h"
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")
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")
53 * Find all available startup items in NSDomains specified by aMask.
55 CFMutableArrayRef
StartupItemListCreateWithMask (NSSearchPathDomainMask aMask
);
58 * Returns the item responsible for providing aService.
60 CFMutableDictionaryRef
StartupItemListGetProvider (CFArrayRef anItemList
, CFStringRef aService
);
63 * Creates a list of items in anItemList which depend on anItem, given anAction.
65 CFMutableArrayRef
StartupItemListCreateDependentsList (CFMutableArrayRef anItemList
,
66 CFStringRef aService
,
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
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.
77 CFMutableDictionaryRef
StartupItemListGetNext (CFArrayRef aWaitingList
,
78 CFDictionaryRef aStatusDict
,
81 CFMutableDictionaryRef
StartupItemWithPID (CFArrayRef anItemList
, pid_t aPID
);
82 pid_t
StartupItemGetPID(CFDictionaryRef anItem
);
84 CFStringRef
StartupItemGetDescription(CFMutableDictionaryRef anItem
);
87 * Returns a list of currently executing startup items.
89 CFArrayRef
StartupItemListGetRunning(CFArrayRef anItemList
);
92 * Returns the total number of "Provides" entries of all loaded items.
94 CFIndex
StartupItemListCountServices (CFArrayRef anItemList
);
100 void RemoveItemFromWaitingList(StartupContext aStartupContext
, CFMutableDictionaryRef anItem
);
101 void AddItemToFailedList(StartupContext aStartupContext
, CFMutableDictionaryRef anItem
);
104 * Run the startup item.
106 int StartupItemRun (CFMutableDictionaryRef aStatusDict
, CFMutableDictionaryRef anItem
, Action anAction
);
107 void StartupItemExit (CFMutableDictionaryRef aStatusDict
, CFMutableDictionaryRef anItem
, Boolean aSuccess
);
108 void StartupItemSetStatus(CFMutableDictionaryRef aStatusDict
, CFMutableDictionaryRef anItem
, CFStringRef aServiceName
, Boolean aSuccess
, Boolean aReplaceFlag
);
110 #endif /* _StartupItems_H_ */