1/* 2 * kextstat_main.h 3 * kext_tools 4 * 5 * Created by Nik Gervae on 5/03/08. 6 * Copyright 2008, 2014 Apple Inc. All rights reserved. 7 * 8 */ 9#ifndef _KEXTSTAT_MAIN_H 10#define _KEXTSTAT_MAIN_H 11 12#include <CoreFoundation/CoreFoundation.h> 13#include <IOKit/kext/OSKext.h> 14 15#include <getopt.h> 16#include <sysexits.h> 17 18#include <mach-o/arch.h> 19 20#include "kext_tools_util.h" 21 22#pragma mark Basic Types & Constants 23/******************************************************************************* 24* Constants 25*******************************************************************************/ 26enum { 27 kKextstatExitOK = EX_OK, 28 kKextstatExitError = 1, 29 30 // don't think we use it 31 kKextstatExitUnspecified = 11, 32 33 // don't actually exit with this, it's just a sentinel value 34 kKextstatExitHelp = 33 35}; 36 37#pragma mark Command-line Option Definitions 38/******************************************************************************* 39* Command-line options. This data is used by getopt_long_only(). 40* 41* Options common to all kext tools are in kext_tools_util.h. 42*******************************************************************************/ 43 44#define kOptNameNoKernelComponents "no-kernel" 45#define kOptNameListOnly "list-only" 46#define kOptNameArchitecture "arch" 47 48#define kOptNoKernelComponents 'k' 49#define kOptListOnly 'l' 50#define kOptArchitecture 'a' 51 52#if 0 53// bundle-id,version,compatible-version,is-kernel,is-interface,retaincount,path,uuid,started,prelinked,index,address,size,wired,dependencies,classes,cputype,cpusubtype 54CFBundleIdentifier 55CFBundleVersion 56kOSBundleCompatibleVersionKey 57kOSKernelResourceKey 58kOSBundleIsInterfaceKey 59kOSBundlePathKey 60kOSBundleUUIDKey 61kOSBundleStartedKey 62kOSBundlePrelinkedKey 63kOSBundleLoadTagKey 64kOSBundleLoadAddressKey 65kOSBundleLoadSizeKey 66kOSBundleWiredSizeKey 67kOSBundleDependenciesKey 68kOSBundleMetaClassesKey 69#endif 70 71#define kOptChars "b:hkla" 72 73/* Options with no single-letter variant. */ 74// Do not use -1, that's getopt() end-of-args return value 75// and can cause confusion 76#define kLongOptLongindexHack (-2) 77 78int longopt = 0; 79 80struct option sOptInfo[] = { 81 { kOptNameHelp, no_argument, NULL, kOptHelp }, 82 { kOptNameBundleIdentifier, required_argument, NULL, kOptBundleIdentifier }, 83 { kOptNameNoKernelComponents, no_argument, NULL, kOptNoKernelComponents }, 84 { kOptNameListOnly, no_argument, NULL, kOptListOnly }, 85 { kOptNameArch, no_argument, NULL, kOptArchitecture }, 86 87 { NULL, 0, NULL, 0 } // sentinel to terminate list 88}; 89 90#pragma mark Tool Args Structure 91/******************************************************************************* 92* Tool Args Structure 93*******************************************************************************/ 94typedef struct { 95 Boolean flagNoKernelComponents; 96 Boolean flagListOnly; 97 Boolean flagShowArchitecture; 98 CFMutableArrayRef bundleIDs; // must release 99 100 CFDictionaryRef loadedKextInfo; // must release 101 const NXArchInfo * runningKernelArch; // do not free 102} KextstatArgs; 103 104#pragma mark Function Prototypes 105/******************************************************************************* 106* Function Prototypes 107*******************************************************************************/ 108ExitStatus readArgs(int argc, char * const * argv, KextstatArgs * toolArgs); 109void printKextInfo(CFDictionaryRef kextInfo, KextstatArgs * toolArgs); 110 111Boolean getNumValue(CFNumberRef aNumber, CFNumberType type, void * valueOut); 112int compareKextInfo(const void * vKextInfo1, const void * vKextInfo2); 113CFComparisonResult compareNumbers( 114 const void * val1, 115 const void * val2, 116 void * context); 117 118static void usage(UsageLevel usageLevel); 119 120#endif /* _KEXTSTAT_MAIN_H */ 121