1 /* $OpenBSD: fuse-opt-add-opt-escaped.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 22 main(int ac, char **av) 23 { 24 char *opt = NULL; 25 char *opt2; 26 27 opt2 = strdup("-a,\\,a\\,b\\,c,\\\\\\,\\\\\\,\\,\\,\\,\\\\\\\\\\,"); 28 if (opt2 == NULL) 29 return (0); 30 31 if (fuse_opt_add_opt_escaped(&opt2, "test") != 0) 32 return (1); 33 34 if (fuse_opt_add_opt_escaped(&opt, "-a") != 0) 35 return (2); 36 if (fuse_opt_add_opt_escaped(&opt, ",a,b,c") != 0) 37 return (3); 38 if (fuse_opt_add_opt_escaped(&opt, "\\,\\,,,,\\\\,") != 0) 39 return (4); 40 if (fuse_opt_add_opt_escaped(&opt, "test") != 0) 41 return (5); 42 43 if (fuse_opt_add_opt_escaped(&opt, NULL) != -1) 44 return (6); 45 if (fuse_opt_add_opt_escaped(&opt, "") != -1) 46 return (7); 47 48 return (strcmp(opt, opt2)); 49 } 50 51