23 #ifndef _POSIX_C_SOURCE 24 #define _POSIX_C_SOURCE 2 31 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LIB 56 fprintf(stderr,
"Usage: %s options...\n\nwhere valid options are\n\n",
59 for (
i = 0;
i <
nr; ++
i) {
63 fprintf(stderr,
"\t -%c %10s: %s\n", o->
go_opt,
74 static int getnum(
const char *arg,
const char *desc, int64_t *
out)
78 *
out = strtoll(arg, &end, 0);
80 fprintf(stderr,
"Failed conversion of \"%s\" to %s\n",
93 fprintf(stderr,
"Failed conversion of \"%s\" to %s\n",
108 if (optstring ==
NULL)
117 optstring[
scan++] =
':';
130 while (result == 0 && (
ch = getopt(argc, argv, optstring)) != -1) {
131 for (
i = 0;
i <
nr; ++
i) {
133 const union m0_getopts_union *
u;
164 result = sscanf(
optarg,
u->got_fmt.f_string,
166 result = result == 1 ? 0 :
M0_ERR(-EINVAL);
168 fprintf(stderr,
"Cannot scan \"%s\" " 169 "as \"%s\" in \"%s\"\n",
188 fprintf(stderr,
"Unknown option '%c'\n",
optopt);
198 #undef M0_TRACE_SUBSYSTEM
#define M0_ALLOC_ARR(arr, nr)
static int getnum(const char *arg, const char *desc, int64_t *out)
return M0_ERR(-EOPNOTSUPP)
enum m0_getopts_opt_type go_type
static int getscaled(const char *arg, const char *desc, m0_bcount_t *out)
struct m0_getopts_opt::m0_getopts_union::@271 got_fmt
union m0_getopts_opt::m0_getopts_union go_u
static const char * progname
static void usage(const char *progname, const struct m0_getopts_opt *opts, unsigned nr)
M0_INTERNAL int m0_bcount_get(const char *arg, m0_bcount_t *out)
static int scan(struct scanner *s)
int m0_getopts(const char *progname, int argc, char *const *argv, const struct m0_getopts_opt *opts, unsigned nr)
#define M0_IMPOSSIBLE(fmt,...)