/**1* StartupItems.h - Startup Item management routines2* Wilfredo Sanchez | [email protected]3* Kevin Van Vechten | [email protected]4* $Apple$5**6* Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.7*8* @APPLE_APACHE_LICENSE_HEADER_START@9*10* Licensed under the Apache License, Version 2.0 (the "License");11* you may not use this file except in compliance with the License.12* You may obtain a copy of the License at13*14* http://www.apache.org/licenses/LICENSE-2.015*16* Unless required by applicable law or agreed to in writing, software17* distributed under the License is distributed on an "AS IS" BASIS,18* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.19* See the License for the specific language governing permissions and20* limitations under the License.21*22* @APPLE_APACHE_LICENSE_HEADER_END@23**/2425#ifndef _StartupItems_H_26#define _StartupItems_H_2728#include <NSSystemDirectories.h>2930#include <CoreFoundation/CFArray.h>31#include <CoreFoundation/CFDictionary.h>3233#include "SystemStarter.h"3435#define kProvidesKey CFSTR("Provides")36#define kRequiresKey CFSTR("Requires")37#define kDescriptionKey CFSTR("Description")38#define kUsesKey CFSTR("Uses")39#define kErrorKey CFSTR("Error")40#define kBundlePathKey CFSTR("PathToBundle")41#define kPIDKey CFSTR("ProcessID")42#define kDomainKey CFSTR("Domain")434445#define kErrorPermissions CFSTR("incorrect permissions")46#define kErrorInternal CFSTR("SystemStarter internal error")47#define kErrorReturnNonZero CFSTR("execution of Startup script failed")48#define kErrorFork CFSTR("could not fork() StartupItem")495051/*52* Find all available startup items in NSDomains specified by aMask.53*/54CFMutableArrayRef StartupItemListCreateWithMask (NSSearchPathDomainMask aMask);5556/*57* Returns the item responsible for providing aService.58*/59CFMutableDictionaryRef StartupItemListGetProvider (CFArrayRef anItemList, CFStringRef aService);6061/*62* Creates a list of items in anItemList which depend on anItem, given anAction.63*/64CFMutableArrayRef StartupItemListCreateDependentsList (CFMutableArrayRef anItemList,65CFStringRef aService ,66Action anAction );6768/*69* Given aWaitingList of startup items, and aStatusDict describing the current70* startup state, returns the next startup item to run, if any. Returns nil if71* none is available.72* Note that this is not necessarily deterministic; if more than one startup73* item is ready to run, which item gets returned is not specified. An item is74* not ready to run if the specified dependencies are not satisfied yet.75*/76CFMutableDictionaryRef StartupItemListGetNext (CFArrayRef aWaitingList,77CFDictionaryRef aStatusDict ,78Action anAction );7980CFMutableDictionaryRef StartupItemWithPID (CFArrayRef anItemList, pid_t aPID);81pid_t StartupItemGetPID(CFDictionaryRef anItem);8283CFStringRef StartupItemCreateDescription(CFMutableDictionaryRef anItem);8485/*86* Returns a list of currently executing startup items.87*/88CFArrayRef StartupItemListCreateFromRunning(CFArrayRef anItemList);8990/*91* Returns the total number of "Provides" entries of all loaded items.92*/93CFIndex StartupItemListCountServices (CFArrayRef anItemList);949596/*97* Utility functions98*/99void RemoveItemFromWaitingList(StartupContext aStartupContext, CFMutableDictionaryRef anItem);100void AddItemToFailedList(StartupContext aStartupContext, CFMutableDictionaryRef anItem);101102/*103* Run the startup item.104*/105int StartupItemRun (CFMutableDictionaryRef aStatusDict, CFMutableDictionaryRef anItem, Action anAction);106void StartupItemExit (CFMutableDictionaryRef aStatusDict, CFMutableDictionaryRef anItem, Boolean aSuccess);107void StartupItemSetStatus(CFMutableDictionaryRef aStatusDict, CFMutableDictionaryRef anItem, CFStringRef aServiceName, Boolean aSuccess, Boolean aReplaceFlag);108109/*110* Check whether file was created before boot and has proper permissions to run.111*/112bool StartupItemSecurityCheck(const char *aPath);113114#endif /* _StartupItems_H_ */115116117