libfuse
Data Structures | Macros | Typedefs | Functions
fuse_opt.h File Reference

Go to the source code of this file.

Data Structures

struct  fuse_opt
 
struct  fuse_args
 

Macros

#define FUSE_OPT_KEY(templ, key)   { templ, -1U, key }
 
#define FUSE_OPT_END   { NULL, 0, 0 }
 
#define FUSE_ARGS_INIT(argc, argv)   { argc, argv, 0 }
 
#define FUSE_OPT_KEY_OPT   -1
 
#define FUSE_OPT_KEY_NONOPT   -2
 
#define FUSE_OPT_KEY_KEEP   -3
 
#define FUSE_OPT_KEY_DISCARD   -4
 

Typedefs

typedef int(* fuse_opt_proc_t) (void *data, const char *arg, int key, struct fuse_args *outargs)
 

Functions

int fuse_opt_parse (struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc)
 
int fuse_opt_add_opt (char **opts, const char *opt)
 
int fuse_opt_add_opt_escaped (char **opts, const char *opt)
 
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 *arg)
 
void fuse_opt_free_args (struct fuse_args *args)
 
int fuse_opt_match (const struct fuse_opt opts[], const char *opt)
 

Detailed Description

This file defines the option parsing interface of FUSE

Definition in file fuse_opt.h.

Macro Definition Documentation

◆ FUSE_ARGS_INIT

#define FUSE_ARGS_INIT (   argc,
  argv 
)    { argc, argv, 0 }

Initializer for 'struct fuse_args'

Definition at line 123 of file fuse_opt.h.

◆ FUSE_OPT_END

#define FUSE_OPT_END   { NULL, 0, 0 }

Last option. An array of 'struct fuse_opt' must end with a NULL template value

Definition at line 104 of file fuse_opt.h.

◆ FUSE_OPT_KEY

#define FUSE_OPT_KEY (   templ,
  key 
)    { templ, -1U, key }

Key option. In case of a match, the processing function will be called with the specified key.

Definition at line 98 of file fuse_opt.h.

◆ FUSE_OPT_KEY_DISCARD

#define FUSE_OPT_KEY_DISCARD   -4

Special key value for options to discard

Argument is not passed to processing function, but behave as if the processing function returned zero

Definition at line 153 of file fuse_opt.h.

◆ FUSE_OPT_KEY_KEEP

#define FUSE_OPT_KEY_KEEP   -3

Special key value for options to keep

Argument is not passed to processing function, but behave as if the processing function returned 1

Definition at line 145 of file fuse_opt.h.

◆ FUSE_OPT_KEY_NONOPT

#define FUSE_OPT_KEY_NONOPT   -2

Key value passed to the processing function for all non-options

Non-options are the arguments beginning with a character other than '-' or all arguments after the special '–' option

Definition at line 137 of file fuse_opt.h.

◆ FUSE_OPT_KEY_OPT

#define FUSE_OPT_KEY_OPT   -1

Key value passed to the processing function if an option did not match any template

Definition at line 129 of file fuse_opt.h.

Typedef Documentation

◆ fuse_opt_proc_t

typedef int(* fuse_opt_proc_t) (void *data, const char *arg, int key, struct fuse_args *outargs)

Processing function

This function is called if

  • option did not match any 'struct fuse_opt'
  • argument is a non-option
  • option did match and offset was set to -1

The 'arg' parameter will always contain the whole argument or option including the parameter if exists. A two-argument option ("-x foo") is always converted to single argument option of the form "-xfoo" before this function is called.

Options of the form '-ofoo' are passed to this function without the '-o' prefix.

The return value of this function determines whether this argument is to be inserted into the output argument vector, or discarded.

Parameters
datais the user data passed to the fuse_opt_parse() function
argis the whole argument or option
keydetermines why the processing function was called
outargsthe current output argument list
Returns
-1 on error, 0 if arg is to be discarded, 1 if arg should be kept

Definition at line 180 of file fuse_opt.h.

Function Documentation

◆ fuse_opt_add_arg()

int fuse_opt_add_arg ( struct fuse_args args,
const char *  arg 
)

Add an argument to a NULL terminated argument vector

Parameters
argsis the structure containing the current argument list
argis the new argument to add
Returns
-1 on allocation error, 0 on success

Definition at line 55 of file fuse_opt.c.

◆ fuse_opt_add_opt()

int fuse_opt_add_opt ( char **  opts,
const char *  opt 
)

Add an option to a comma separated option list

Parameters
optsis a pointer to an option list, may point to a NULL value
optis the option to add
Returns
-1 on allocation error, 0 on success

Definition at line 139 of file fuse_opt.c.

◆ fuse_opt_add_opt_escaped()

int fuse_opt_add_opt_escaped ( char **  opts,
const char *  opt 
)

Add an option, escaping commas, to a comma separated option list

Parameters
optsis a pointer to an option list, may point to a NULL value
optis the option to add
Returns
-1 on allocation error, 0 on success

Definition at line 144 of file fuse_opt.c.

◆ fuse_opt_free_args()

void fuse_opt_free_args ( struct fuse_args args)

Free the contents of argument list

The structure itself is not freed

Parameters
argsis the structure containing the argument list

Definition at line 34 of file fuse_opt.c.

◆ fuse_opt_insert_arg()

int fuse_opt_insert_arg ( struct fuse_args args,
int  pos,
const char *  arg 
)

Add an argument at the specified position in a NULL terminated argument vector

Adds the argument to the N-th position. This is useful for adding options at the beginning of the array which must not come after the special '–' option.

Parameters
argsis the structure containing the current argument list
posis the position at which to add the argument
argis the new argument to add
Returns
-1 on allocation error, 0 on success

Definition at line 95 of file fuse_opt.c.

◆ fuse_opt_match()

int fuse_opt_match ( const struct fuse_opt  opts[],
const char *  opt 
)

Check if an option matches

Parameters
optsis the option description array
optis the option to match
Returns
1 if a match is found, 0 if not

◆ fuse_opt_parse()

int fuse_opt_parse ( struct fuse_args args,
void *  data,
const struct fuse_opt  opts[],
fuse_opt_proc_t  proc 
)

Option parsing function

If 'args' was returned from a previous call to fuse_opt_parse() or it was constructed from

A NULL 'args' is equivalent to an empty argument vector

A NULL 'opts' is equivalent to an 'opts' array containing a single end marker

A NULL 'proc' is equivalent to a processing function always returning '1'

Parameters
argsis the input and output argument list
datais the user data
optsis the option description array
procis the processing function
Returns
-1 on error, 0 on success

Definition at line 398 of file fuse_opt.c.