Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/openlaunchd
Path: blob/master/SystemStarter/StartupItems.h
374 views
1
/**
2
* StartupItems.h - Startup Item management routines
3
* Wilfredo Sanchez | [email protected]
4
* Kevin Van Vechten | [email protected]
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
*/
55
CFMutableArrayRef StartupItemListCreateWithMask (NSSearchPathDomainMask aMask);
56
57
/*
58
* Returns the item responsible for providing aService.
59
*/
60
CFMutableDictionaryRef StartupItemListGetProvider (CFArrayRef anItemList, CFStringRef aService);
61
62
/*
63
* Creates a list of items in anItemList which depend on anItem, given anAction.
64
*/
65
CFMutableArrayRef 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
*/
77
CFMutableDictionaryRef StartupItemListGetNext (CFArrayRef aWaitingList,
78
CFDictionaryRef aStatusDict ,
79
Action anAction );
80
81
CFMutableDictionaryRef StartupItemWithPID (CFArrayRef anItemList, pid_t aPID);
82
pid_t StartupItemGetPID(CFDictionaryRef anItem);
83
84
CFStringRef StartupItemCreateDescription(CFMutableDictionaryRef anItem);
85
86
/*
87
* Returns a list of currently executing startup items.
88
*/
89
CFArrayRef StartupItemListCreateFromRunning(CFArrayRef anItemList);
90
91
/*
92
* Returns the total number of "Provides" entries of all loaded items.
93
*/
94
CFIndex StartupItemListCountServices (CFArrayRef anItemList);
95
96
97
/*
98
* Utility functions
99
*/
100
void RemoveItemFromWaitingList(StartupContext aStartupContext, CFMutableDictionaryRef anItem);
101
void AddItemToFailedList(StartupContext aStartupContext, CFMutableDictionaryRef anItem);
102
103
/*
104
* Run the startup item.
105
*/
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);
109
110
/*
111
* Check whether file was created before boot and has proper permissions to run.
112
*/
113
bool StartupItemSecurityCheck(const char *aPath);
114
115
#endif /* _StartupItems_H_ */
116
117