Path: blob/next/external/cache/sources/wl/include/miniopt.h
18117 views
/*1* Command line options parser.2*3* $Copyright Open Broadcom Corporation$4* $Id: miniopt.h 241182 2011-02-17 21:50:03Z gmo $5*/678#ifndef MINI_OPT_H9#define MINI_OPT_H1011#ifdef __cplusplus12extern "C" {13#endif1415/* ---- Include Files ---------------------------------------------------- */16/* ---- Constants and Types ---------------------------------------------- */1718#define MINIOPT_MAXKEY 128 /* Max options */19typedef struct miniopt {2021/* These are persistent after miniopt_init() */22const char* name; /* name for prompt in error strings */23const char* flags; /* option chars that take no args */24bool longflags; /* long options may be flags */25bool opt_end; /* at end of options (passed a "--") */2627/* These are per-call to miniopt() */2829int consumed; /* number of argv entries cosumed in30* the most recent call to miniopt()31*/32bool positional;33bool good_int; /* 'val' member is the result of a sucessful34* strtol conversion of the option value35*/36char opt;37char key[MINIOPT_MAXKEY];38char* valstr; /* positional param, or value for the option,39* or null if the option had40* no accompanying value41*/42uint uval; /* strtol translation of valstr */43int val; /* strtol translation of valstr */44} miniopt_t;4546void miniopt_init(miniopt_t *t, const char* name, const char* flags, bool longflags);47int miniopt(miniopt_t *t, char **argv);484950/* ---- Variable Externs ------------------------------------------------- */51/* ---- Function Prototypes ---------------------------------------------- */525354#ifdef __cplusplus55}56#endif5758#endif /* MINI_OPT_H */596061