1#include <string.h>23static int fsopt_matches(const char *opts_list, const char *opt, size_t optlen)4{5 int match = 1;67 if (optlen >= 2 && opt[0] == 'n' && opt[1] == 'o') {8 match--;9 opt += 2; optlen -= 2;10 }1112 if (optlen == 0)13 return 0;14 if (match && optlen > 1 && *opt == '+') {15 opt++; optlen--;16 }1718 while (1) {19 if (strncmp(opts_list, opt, optlen) == 0) {20 const char *after_opt = opts_list + optlen;21 if (*after_opt == '\0' || *after_opt == ',')22 return match;23 }2425 opts_list = strchr(opts_list, ',');26 if (!opts_list)27 break;28 opts_list++;29 }3031 return !match;32}3334int fsopts_matches(const char *opts_list, const char *reqopts_list)35{36 if (!reqopts_list)37 return 1; /* no options requested, match anything */3839 while (1) {40 size_t len;41 const char *comma = strchr(reqopts_list, ',');42 if (!comma)43 len = strlen(reqopts_list);44 else45 len = comma - reqopts_list;4647 if (len && !fsopt_matches(opts_list, reqopts_list, len))48 return 0;4950 if (!comma)51 break;52 reqopts_list = ++comma;53 }5455 return 1;56}