xref: /netbsd/lib/librefuse/fuse_opt.h (revision 77429898)
1*77429898Spho /*	$NetBSD: fuse_opt.h,v 1.10 2022/01/22 08:01:50 pho Exp $	*/
2942dafa6Sxtraeme 
3c7b91b59Sxtraeme /*
4c7b91b59Sxtraeme  * Copyright (c) 2007 Alistair Crooks.  All rights reserved.
5c7b91b59Sxtraeme  *
6c7b91b59Sxtraeme  * Redistribution and use in source and binary forms, with or without
7c7b91b59Sxtraeme  * modification, are permitted provided that the following conditions
8c7b91b59Sxtraeme  * are met:
9c7b91b59Sxtraeme  * 1. Redistributions of source code must retain the above copyright
10c7b91b59Sxtraeme  *    notice, this list of conditions and the following disclaimer.
11c7b91b59Sxtraeme  * 2. Redistributions in binary form must reproduce the above copyright
12c7b91b59Sxtraeme  *    notice, this list of conditions and the following disclaimer in the
13c7b91b59Sxtraeme  *    documentation and/or other materials provided with the distribution.
14c7b91b59Sxtraeme  * 3. The name of the author may not be used to endorse or promote
15c7b91b59Sxtraeme  *    products derived from this software without specific prior written
16c7b91b59Sxtraeme  *    permission.
17c7b91b59Sxtraeme  *
18c7b91b59Sxtraeme  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19c7b91b59Sxtraeme  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20c7b91b59Sxtraeme  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21c7b91b59Sxtraeme  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22c7b91b59Sxtraeme  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23c7b91b59Sxtraeme  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24c7b91b59Sxtraeme  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25c7b91b59Sxtraeme  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26c7b91b59Sxtraeme  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27c7b91b59Sxtraeme  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28c7b91b59Sxtraeme  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29c7b91b59Sxtraeme  */
30c7b91b59Sxtraeme 
31c7b91b59Sxtraeme #ifndef _FUSE_OPT_H_
32c7b91b59Sxtraeme #define _FUSE_OPT_H_
33c7b91b59Sxtraeme 
3499dd5f63Sdholland #include <stdint.h>
3599dd5f63Sdholland 
3608522514Schristos #ifdef __cplusplus
3708522514Schristos extern "C" {
3808522514Schristos #endif
3908522514Schristos 
40c7b91b59Sxtraeme enum {
41c7b91b59Sxtraeme 	FUSE_OPT_KEY_OPT = -1,
42c7b91b59Sxtraeme 	FUSE_OPT_KEY_NONOPT = -2,
43c7b91b59Sxtraeme 	FUSE_OPT_KEY_KEEP = -3,
44c7b91b59Sxtraeme 	FUSE_OPT_KEY_DISCARD = -4
45c7b91b59Sxtraeme };
46c7b91b59Sxtraeme 
47*77429898Spho struct fuse_args;
48*77429898Spho 
49c7b91b59Sxtraeme struct fuse_opt {
50c7b91b59Sxtraeme 	const char	*templ;
510e878a83Spho 	int32_t		offset;
520e878a83Spho 	int32_t		value;
53c7b91b59Sxtraeme };
54c7b91b59Sxtraeme 
550e878a83Spho #define FUSE_OPT_KEY(templ, key) { templ, -1, key }
56c7b91b59Sxtraeme #define FUSE_OPT_END { .templ = NULL }
57c7b91b59Sxtraeme 
58c7b91b59Sxtraeme typedef int (*fuse_opt_proc_t)(void *, const char *, int, struct fuse_args *);
59c7b91b59Sxtraeme 
60c7b91b59Sxtraeme 
61c7b91b59Sxtraeme int fuse_opt_add_arg(struct fuse_args *, const char *);
6219468d62Schristos struct fuse_args *fuse_opt_deep_copy_args(int, char **);
63c7b91b59Sxtraeme void fuse_opt_free_args(struct fuse_args *);
64c7b91b59Sxtraeme int fuse_opt_insert_arg(struct fuse_args *, int, const char *);
65c7b91b59Sxtraeme int fuse_opt_add_opt(char **, const char *);
665a307a76Spho int fuse_opt_add_opt_escaped(char **, const char *);
67c7b91b59Sxtraeme int fuse_opt_parse(struct fuse_args *, void *,
68c7b91b59Sxtraeme 		   const struct fuse_opt *, fuse_opt_proc_t);
69c7b91b59Sxtraeme int fuse_opt_match(const struct fuse_opt *, const char *);
70c7b91b59Sxtraeme 
7108522514Schristos #ifdef __cplusplus
7208522514Schristos }
7308522514Schristos #endif
7408522514Schristos 
75c7b91b59Sxtraeme #endif /* _FUSE_OPT_H_ */
76