]> git.saurik.com Git - apple/launchd.git/blame - launchd/src/StartupItems.h
launchd-106.tar.gz
[apple/launchd.git] / launchd / src / 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 *
9 * @APPLE_LICENSE_HEADER_START@
10 *
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
17 * this file.
18 *
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
25 * under the License.
26 *
27 * @APPLE_LICENSE_HEADER_END@
28 **/
29
30#ifndef _StartupItems_H_
31#define _StartupItems_H_
32
33#include <NSSystemDirectories.h>
34
35#include <CoreFoundation/CFArray.h>
36#include <CoreFoundation/CFDictionary.h>
37
38#include "SystemStarter.h"
39
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")
49
50
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")
55
56
57/*
58 * Find all available startup items in NSDomains specified by aMask.
59 */
60CFMutableArrayRef StartupItemListCreateWithMask (NSSearchPathDomainMask aMask);
61
62/*
63 * Returns the item responsible for providing aService.
64 */
65CFMutableDictionaryRef StartupItemListGetProvider (CFArrayRef anItemList, CFStringRef aService);
66
67/*
68 * Creates a list of items in anItemList which depend on anItem, given anAction.
69 */
70CFMutableArrayRef StartupItemListCreateDependentsList (CFMutableArrayRef anItemList,
71 CFStringRef aService ,
72 Action anAction );
73
74/*
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.
83 */
84CFMutableDictionaryRef StartupItemListGetNext (CFArrayRef aWaitingList,
85 CFDictionaryRef aStatusDict ,
86 Action anAction );
87
88CFMutableDictionaryRef StartupItemWithPID (CFArrayRef anItemList, pid_t aPID);
89pid_t StartupItemGetPID(CFDictionaryRef anItem);
90
91CFStringRef StartupItemGetDescription(CFMutableDictionaryRef anItem);
92
93/*
94 * Returns a list of currently executing startup items.
95 */
96CFArrayRef StartupItemListGetRunning(CFArrayRef anItemList);
97
98/*
99 * Returns the total number of "Provides" entries of all loaded items.
100 */
101CFIndex StartupItemListCountServices (CFArrayRef anItemList);
102
103
104/*
105 * Utility functions
106 */
107void RemoveItemFromWaitingList(StartupContext aStartupContext, CFMutableDictionaryRef anItem);
108void AddItemToFailedList(StartupContext aStartupContext, CFMutableDictionaryRef anItem);
109
110/*
111 * Run the startup item.
112 */
113int StartupItemRun (CFMutableDictionaryRef aStatusDict, CFMutableDictionaryRef anItem, Action anAction);
114void StartupItemExit (CFMutableDictionaryRef aStatusDict, CFMutableDictionaryRef anItem, Boolean aSuccess);
115void StartupItemSetStatus(CFMutableDictionaryRef aStatusDict, CFMutableDictionaryRef anItem, CFStringRef aServiceName, Boolean aSuccess, Boolean aReplaceFlag);
116
117#endif /* _StartupItems_H_ */