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_LICENSE_HEADER_START@
11 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
12 * Reserved. This file contains Original Code and/or Modifications of
13 * Original Code as defined in and that are subject to the Apple Public
14 * Source License Version 1.1 (the "License"). You may not use this file
15 * except in compliance with the License. Please obtain a copy of the
16 * License at http://www.apple.com/publicsource and read it before using
19 * The Original Code and all software distributed under the License are
20 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
21 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
22 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
24 * License for the specific language governing rights and limitations
27 * @APPLE_LICENSE_HEADER_END@
30 #ifndef _StartupItems_H_
31 #define _StartupItems_H_
33 #include <NSSystemDirectories.h>
35 #include <CoreFoundation/CFArray.h>
36 #include <CoreFoundation/CFDictionary.h>
38 #include "SystemStarter.h"
40 #define kProvidesKey CFSTR("Provides")
41 #define kRequiresKey CFSTR("Requires")
42 #define kDescriptionKey CFSTR("Description")
43 #define kUsesKey CFSTR("Uses")
44 #define kErrorKey CFSTR("Error")
45 #define kPriorityKey CFSTR("OrderPreference")
46 #define kBundlePathKey CFSTR("PathToBundle")
47 #define kPIDKey CFSTR("ProcessID")
48 #define kDomainKey CFSTR("Domain")
51 #define kErrorPermissions CFSTR("incorrect permissions")
52 #define kErrorInternal CFSTR("SystemStarter internal error")
53 #define kErrorReturnNonZero CFSTR("execution of Startup script failed")
54 #define kErrorFork CFSTR("could not fork() StartupItem")
58 * Find all available startup items in NSDomains specified by aMask.
60 CFMutableArrayRef
StartupItemListCreateWithMask (NSSearchPathDomainMask aMask
);
63 * Returns the item responsible for providing aService.
65 CFMutableDictionaryRef
StartupItemListGetProvider (CFArrayRef anItemList
, CFStringRef aService
);
68 * Creates a list of items in anItemList which depend on anItem, given anAction.
70 CFMutableArrayRef
StartupItemListCreateDependentsList (CFMutableArrayRef anItemList
,
71 CFStringRef aService
,
75 * Given aWaitingList of startup items, and aStatusDict describing the
76 * current startup state, returns the next startup item to run, if any.
77 * Returns nil if none is available.
78 * The startup order depends on the dependancies between items and the
79 * priorities of the items.
80 * Note that this is not necessarily deterministic; if more than one
81 * startup item with the same priority is ready to run, which item gets
82 * returned is not specified.
84 CFMutableDictionaryRef
StartupItemListGetNext (CFArrayRef aWaitingList
,
85 CFDictionaryRef aStatusDict
,
88 CFMutableDictionaryRef
StartupItemWithPID (CFArrayRef anItemList
, pid_t aPID
);
89 pid_t
StartupItemGetPID(CFDictionaryRef anItem
);
91 CFStringRef
StartupItemGetDescription(CFMutableDictionaryRef anItem
);
94 * Returns a list of currently executing startup items.
96 CFArrayRef
StartupItemListGetRunning(CFArrayRef anItemList
);
99 * Returns the total number of "Provides" entries of all loaded items.
101 CFIndex
StartupItemListCountServices (CFArrayRef anItemList
);
107 void RemoveItemFromWaitingList(StartupContext aStartupContext
, CFMutableDictionaryRef anItem
);
108 void AddItemToFailedList(StartupContext aStartupContext
, CFMutableDictionaryRef anItem
);
111 * Run the startup item.
113 int StartupItemRun (CFMutableDictionaryRef aStatusDict
, CFMutableDictionaryRef anItem
, Action anAction
);
114 void StartupItemExit (CFMutableDictionaryRef aStatusDict
, CFMutableDictionaryRef anItem
, Boolean aSuccess
);
115 void StartupItemSetStatus(CFMutableDictionaryRef aStatusDict
, CFMutableDictionaryRef anItem
, CFStringRef aServiceName
, Boolean aSuccess
, Boolean aReplaceFlag
);
117 #endif /* _StartupItems_H_ */