1/* 2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23#ifndef _KEXTFIND_H_ 24#define _KEXTFIND_H_ 25 26#include <CoreFoundation/CoreFoundation.h> 27#include <libc.h> 28#include <getopt.h> 29#include <mach-o/arch.h> 30#include <sysexits.h> 31 32#include <IOKit/IOTypes.h> 33#include <IOKit/kext/OSKext.h> 34#include <IOKit/kext/fat_util.h> 35 36 37#include "kext_tools_util.h" 38#include "QEQuery.h" 39 40#pragma mark Basic Types & Constants 41/******************************************************************************* 42* Constants 43*******************************************************************************/ 44 45enum { 46 kKextfindExitOK = EX_OK, 47 48 // don't actually exit with this, it's just a sentinel value 49 kKextfindExitHelp = 33, 50}; 51 52/******************************************************************************* 53* Data types. 54*******************************************************************************/ 55 56/* I originally thought this was a good idea, but changed my mind. I'm leaving 57 * the code in case someone hates it, but kextfind will just always be picky, 58 * now. 59 */ 60typedef enum { 61 kKextfindMeek = -1, 62 kKextfindQuibbling = 0, 63 kKextfindPicky = 1 64} KextfindAssertiveness; 65 66typedef enum { 67 kPathsFull = 0, 68 kPathsRelative, 69 kPathsNone 70} PathSpec; 71 72/* The query context is passed as user data to the query engine. 73 */ 74typedef struct { 75 76 /* These fields are set by command-line options and govern global behavior 77 * during the search. 78 */ 79 KextfindAssertiveness assertiveness; 80 const NXArchInfo * defaultArch; 81 82 Boolean caseInsensitive; 83 Boolean extraInfo; // currently unused, see EXTRA_INFO ifdefs 84 PathSpec pathSpec; 85 Boolean substrings; 86 87 CFMutableArrayRef searchURLs; 88 89 /* These fields are set by the parsing callbacks to determine what 90 * expensive operations the kext manager needs to perform before the 91 * query can be evaluated. 92 */ 93 Boolean checkLoaded; 94 95 /* Kext integrity is no longer used on SnowLeopard. We read the 96 * flags but no kext will ever match them now. 97 */ 98 Boolean checkIntegrity; 99 100 /* This field is set by the parsing callbacks. If no commands are given 101 * in the query, a default "print" will be executed for each matching 102 * kext. 103 */ 104 Boolean commandSpecified; 105 106 /* If false, the report logic will print the report header as needed. 107 */ 108 Boolean reportStarted; 109 110 /* If true, the report log will print a tab before the next value. 111 */ 112 Boolean reportRowStarted; 113 114} QueryContext; 115 116/******************************************************************************* 117* Function prototypes. 118*******************************************************************************/ 119ExitStatus readArgs( 120 int argc, 121 char * const * argv, 122 QueryContext * toolArgs); 123ExitStatus checkArgs(QueryContext * toolArgs); 124Boolean checkSearchItem(const char * pathname, Boolean logFlag); 125fat_iterator createFatIteratorForKext(OSKextRef aKext); 126void usage(UsageLevel level); 127 128 129#endif /* _KEXTFIND_H_ */ 130