#ifndef _KEXTSTAT_MAIN_H
#define _KEXTSTAT_MAIN_H
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/kext/OSKext.h>
#include <getopt.h>
#include <sysexits.h>
#include <mach-o/arch.h>
#include "kext_tools_util.h"
#pragma mark Basic Types & Constants
enum {
kKextstatExitOK = EX_OK,
kKextstatExitError = 1,
kKextstatExitUnspecified = 11,
kKextstatExitHelp = 33
};
#pragma mark Command-line Option Definitions
#define kOptNameNoKernelComponents "no-kernel"
#define kOptNameListOnly "list-only"
#define kOptNameArchitecture "arch"
#define kOptNameSort "sort"
#define kOptNoKernelComponents 'k'
#define kOptListOnly 'l'
#define kOptArchitecture 'a'
#define kOptSort 's'
#if 0
CFBundleIdentifier
CFBundleVersion
kOSBundleCompatibleVersionKey
kOSKernelResourceKey
kOSBundleIsInterfaceKey
kOSBundlePathKey
kOSBundleUUIDKey
kOSBundleStartedKey
kOSBundlePrelinkedKey
kOSBundleLoadTagKey
kOSBundleLoadAddressKey
kOSBundleLoadSizeKey
kOSBundleWiredSizeKey
kOSBundleDependenciesKey
kOSBundleMetaClassesKey
#endif
#define kOptChars "b:hkla"
#define kLongOptLongindexHack (-2)
int longopt = 0;
struct option sOptInfo[] = {
{ kOptNameHelp, no_argument, NULL, kOptHelp },
{ kOptNameBundleIdentifier, required_argument, NULL, kOptBundleIdentifier },
{ kOptNameNoKernelComponents, no_argument, NULL, kOptNoKernelComponents },
{ kOptNameListOnly, no_argument, NULL, kOptListOnly },
{ kOptNameSort, no_argument, NULL, kOptSort },
{ kOptNameArch, no_argument, NULL, kOptArchitecture },
{ NULL, 0, NULL, 0 } };
#pragma mark Tool Args Structure
typedef struct {
Boolean flagNoKernelComponents;
Boolean flagListOnly;
Boolean flagShowArchitecture;
Boolean flagSortByLoadAddress;
CFMutableArrayRef bundleIDs;
CFDictionaryRef loadedKextInfo; const NXArchInfo * runningKernelArch; } KextstatArgs;
#pragma mark Function Prototypes
ExitStatus readArgs(int argc, char * const * argv, KextstatArgs * toolArgs);
void printKextInfo(CFDictionaryRef kextInfo, KextstatArgs * toolArgs);
Boolean getNumValue(CFNumberRef aNumber, CFNumberType type, void * valueOut);
int compareKextInfo(const void * vKextInfo1, const void * vKextInfo2);
int compareKextInfoLoadAddress(const void * vKextInfo1, const void * vKextInfo2);
CFComparisonResult compareNumbers(
const void * val1,
const void * val2,
void * context);
static void usage(UsageLevel usageLevel);
#endif