xref: /openbsd-src/regress/lib/libfuse/fuse-opt-add-opt.c (revision f3de9d7dd81d004e964f4bd559c4dd6d7cb610e1)
1 /* $OpenBSD: fuse-opt-add-opt.c,v 1.3 2018/07/20 12:05:08 helg Exp $ */
2 /*
3  * Copyright (c) Sylvestre Gallon <ccna.syl@gmail.com>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #include <string.h>
19 #include <fuse_opt.h>
20 
21 int
main(int ac,char ** av)22 main(int ac, char **av)
23 {
24 	char *opt = NULL;
25 	char *opt2;
26 
27 	opt2 = strdup("-a,--bc,01234,-56789,-o test1");
28 	if (opt2 == NULL)
29 		return (0);
30 
31 	if (fuse_opt_add_opt(&opt2, "test") != 0)
32 		return (1);
33 
34 	if (fuse_opt_add_opt(&opt, "-a") != 0)
35 		return (2);
36 	if (fuse_opt_add_opt(&opt, "--bc") != 0)
37 		return (3);
38 	if (fuse_opt_add_opt(&opt, "01234") != 0)
39 		return (4);
40 	if (fuse_opt_add_opt(&opt, "-56789") != 0)
41 		return (5);
42 	if (fuse_opt_add_opt(&opt, "-o test1") != 0)
43 		return (6);
44 	if (fuse_opt_add_opt(&opt, "test") != 0)
45 		return (7);
46 
47 	if (fuse_opt_add_opt(&opt, NULL) != -1)
48 		return (8);
49 	if (fuse_opt_add_opt(&opt, "") != -1)
50 		return (9);
51 
52 	return (strcmp(opt, opt2));
53 }
54 
55