merge one more triplicated function

This commit is contained in:
christos 2011-03-06 23:26:05 +00:00
parent 6a453cd117
commit 1c901e8c26
2 changed files with 18 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: quotautil.c,v 1.1 2011/03/06 22:36:07 christos Exp $ */
/* $NetBSD: quotautil.c,v 1.2 2011/03/06 23:26:05 christos Exp $ */
/*
* Copyright (c) 1980, 1990, 1993
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1990, 1993\
#if 0
static char sccsid[] = "@(#)quota.c 8.4 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: quotautil.c,v 1.1 2011/03/06 22:36:07 christos Exp $");
__RCSID("$NetBSD: quotautil.c,v 1.2 2011/03/06 23:26:05 christos Exp $");
#endif
#endif /* not lint */
@ -117,3 +117,17 @@ alldigits(const char *s)
} while ((c = *s++) != 0);
return 1;
}
/*
* Check to see if target appears in list of size cnt.
*/
int
oneof(const char *target, char *list[], int cnt)
{
int i;
for (i = 0; i < cnt; i++)
if (strcmp(target, list[i]) == 0)
return i;
return -1;
}

View File

@ -1,7 +1,8 @@
/* $NetBSD: quotautil.h,v 1.1 2011/03/06 22:36:07 christos Exp $ */
/* $NetBSD: quotautil.h,v 1.2 2011/03/06 23:26:16 christos Exp $ */
const char *qfextension[MAXQUOTAS];
const char *qfname;
struct fstab;
int hasquota(char *, size_t, struct fstab *, int);
int alldigits(const char *);
int oneof(const char *, char *[], int);