1 /*
2 * lookupany.c --
3 *
4 * *********************************************************************
5 * * Copyright (C) 1985, 1990 Regents of the University of California. *
6 * * Permission to use, copy, modify, and distribute this *
7 * * software and its documentation for any purpose and without *
8 * * fee is hereby granted, provided that the above copyright *
9 * * notice appear in all copies. The University of California *
10 * * makes no representations about the suitability of this *
11 * * software for any purpose. It is provided "as is" without *
12 * * express or implied warranty. Export of this software outside *
13 * * of the United States of America may require an export license. *
14 * *********************************************************************
15 * Full rights reserved.
16 *
17 * This file contains a single routine used to find a string in a
18 * table which contains the supplied character.
19 */
20
21 #include <string.h>
22
23 #ifndef lint
24 static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/utils/lookupany.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
25 #endif /* not lint */
26
27
28 /*
29 * ----------------------------------------------------------------------------
30 * LookupAny --
31 *
32 * Look up a single character in a table of pointers to strings. The last
33 * entry in the string table must be a NULL pointer.
34 * The index of the first string in the table containing the indicated
35 * character is returned.
36 *
37 * Results:
38 * Index of the name supplied in the table, or -1 if the name
39 * is not found.
40 *
41 * Side effects:
42 * None.
43 *
44 * ----------------------------------------------------------------------------
45 */
46
47 int
LookupAny(c,table)48 LookupAny(c, table)
49 char c;
50 char **table;
51 {
52 char **tp;
53
54 for (tp = table; *tp; tp++)
55 if (strchr(*tp, c) != (char *) 0)
56 return (tp - table);
57
58 return (-1);
59 }
60