1/** 2 * \file 3 * \brief Commandline parameter parsing. 4 */ 5 6/* 7 * Copyright (c) 2007, 2008, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#ifndef GETOPT_H 16#define GETOPT_H 17 18#include <sys/cdefs.h> 19 20__BEGIN_DECLS 21 22enum argtype { 23 ArgType_Int, 24 ArgType_UInt, 25 ArgType_Long, 26 ArgType_ULong, 27 ArgType_Bool, 28 ArgType_Custom 29}; 30 31typedef int (*cmdarg_handler)(const char *arg, const char *val); 32 33struct cmdarg { 34 const char *arg; 35 enum argtype type; 36 37 union { 38 int *integer; 39 unsigned *uinteger; 40 long *longinteger; 41 unsigned long *ulonginteger; 42 bool *boolean; 43 cmdarg_handler handler; 44 } var; 45}; 46 47extern void parse_commandline(const char *cmdline, struct cmdarg *cmdargs); 48 49__END_DECLS 50 51#endif // GETOPT_H 52