Adding upstream version 2.41.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
This commit is contained in:
parent
9586bb3c92
commit
c36e531662
3661 changed files with 2164106 additions and 0 deletions
53
lib/match.c
Normal file
53
lib/match.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Karel Zak <kzak@redhat.com>
|
||||
*
|
||||
* This file may be redistributed under the terms of the
|
||||
* GNU Lesser General Public License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "match.h"
|
||||
|
||||
/*
|
||||
* match_fstype:
|
||||
* @type: filesystem type
|
||||
* @pattern: filesystem name or comma delimited list of names
|
||||
*
|
||||
* The @pattern list of filesystem can be prefixed with a global
|
||||
* "no" prefix to invert matching of the whole list. The "no" could
|
||||
* also be used for individual items in the @pattern list. So,
|
||||
* "nofoo,bar" has the same meaning as "nofoo,nobar".
|
||||
*/
|
||||
int match_fstype(const char *type, const char *pattern)
|
||||
{
|
||||
int no = 0; /* negated types list */
|
||||
int len;
|
||||
const char *p;
|
||||
|
||||
if (!pattern && !type)
|
||||
return 1;
|
||||
if (!pattern)
|
||||
return 0;
|
||||
|
||||
if (!strncmp(pattern, "no", 2)) {
|
||||
no = 1;
|
||||
pattern += 2;
|
||||
}
|
||||
|
||||
/* Does type occur in types, separated by commas? */
|
||||
len = strlen(type);
|
||||
p = pattern;
|
||||
while(1) {
|
||||
if (!strncmp(p, "no", 2) && !strncasecmp(p+2, type, len) &&
|
||||
(p[len+2] == 0 || p[len+2] == ','))
|
||||
return 0;
|
||||
if (strncasecmp(p, type, len) == 0 && (p[len] == 0 || p[len] == ','))
|
||||
return !no;
|
||||
p = strchr(p,',');
|
||||
if (!p)
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
return no;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue