FUSE_OPT(3) | Library Functions Manual | FUSE_OPT(3) |
FUSE_ARGS_INIT
,
FUSE_OPT_IS_OPT_KEY
,
FUSE_OPT_KEY
,
fuse_opt_add_arg
,
fuse_opt_insert_arg
,
fuse_opt_add_opt
,
fuse_opt_add_opt_escaped
,
fuse_opt_free_args
,
fuse_opt_match
,
fuse_opt_parse
— FUSE
argument and option parser
#include
<fuse_opt.h>
struct fuse_args
FUSE_ARGS_INIT
(int argc,
char argv**);
int
FUSE_OPT_IS_OPT_KEY
(fuse_opt
*t);
struct fuse_opt
FUSE_OPT_KEY
(const char *templ,
int key);
int
fuse_opt_add_arg
(struct fuse_args
*args, const char *arg);
int
fuse_opt_insert_arg
(struct fuse_args
*args, int pos, const char
*opt);
int
fuse_opt_add_opt
(char **opts,
const char *opt);
int
fuse_opt_add_opt_escaped
(char
**opts, const char *opt);
void
fuse_opt_free_args
(struct fuse_args
*args);
int
fuse_opt_match
(const struct fuse_opt
*opts, const char *opt);
int
fuse_opt_parse
(struct fuse_args
*args, void *data, const struct
fuse_opt *opts, fuse_opt_proc_t proc);
These FUSE library functions and macros provide support for complex argument and option parsing. These are typically entered on the command line but may also be passed by file systems to the fuse_mount(3) and fuse_new(3) functions. struct fuse_args holds string options in an array:
struct fuse_args { int argc; /* argument count */ char **argv; /* NULL-terminated array of arguments */ int allocated; /* argv was allocated and must be freed */ };
FUSE_OPT_KEY
(templ,
key)FUSE_OPT_IS_OPT_KEY
(templ)The last element of the opts
struct fuse_opt option array must be
FUSE_OPT_END
.
proc points to a function with
the following signature: int (*fuse_opt_proc_t)
proc
(void
*data, const char *arg, int
key, struct fuse_args *outargs);
Special key values:
FUSE_OPT_KEY_OPT /* no match */ FUSE_OPT_KEY_NONOPT /* non-option */ FUSE_OPT_KEY_KEEP /* don't process; return 1 */ FUSE_OPT_KEY_DISCARD /* don't process; return 0 */
FUSE_ARGS_INIT
()main
().
argv is NULL-terminated, and is suitable for use
with execvp(3).
argv is used directly and
allocated is set to 0.
fuse_opt_add_arg
()fuse_opt_insert_arg
()fuse_opt_add_opt
()fuse_opt_add_opt_escaped
()fuse_opt_free_args
()fuse_opt_match
()fuse_opt_parse
()struct fuse_opt { const char *templ; /* template for option */ unsigned long off; /* data offset */ int val; /* key value */ };
The following templates are supported. foo=
foo=%u %u can be any format that can be parsed by
sscanf
(3).
If this is %s then a copy of the string is allocated. foo=bar matches
the option exactly (treated the same as if it didn't have an =).
foo matches exactly
-b or --bar matches the argument "-b " or "--bar " (trailing space) argument expects a value, that is passed to proc
-b %u or:w
--bar %u Treated the same as foo=%u above
Each argument or option is matched against every template. This allows more than one member of data to be set by a single argument or option (see example for gid below).
fuse_opt_add_arg
(),
fuse_opt_insert_arg
(),
fuse_opt_add_opt
(),
fuse_opt_add_opt_escaped
(), and
fuse_opt_parse
() return 0 on success, -1 on
error.
fuse_opt_match
() returns 1 on match, 0 if
no match.
fuse_opt_add_arg
(),
fuse_opt_insert_arg
(),
fuse_opt_add_opt
(), and
fuse_opt_add_opt_escaped
() can run out of memory and
set errno.
These library functions conform to FUSE 2.6.
These functions first appeared in OpenBSD 5.4.
Sylvestre Gallon
<ccna.syl@gmail.com>
Helg Bredow
<xx404@msn.com>
This manual was written by
Ray Lai
<ray@raylai.com> and
updated by
Helg Bredow
<xx404@msn.com>
November 30, 2018 | OpenBSD-6.7 |