xref: /netbsd-src/external/bsd/ipf/dist/lib/optvalue.c (revision 13885a665959c62f13a82b3caedf986eaa17aa31)
1*13885a66Sdarrenr /*	$NetBSD: optvalue.c,v 1.2 2012/07/22 14:27:36 darrenr Exp $	*/
2bc4097aaSchristos 
3bc4097aaSchristos /*
4c9d5dc6cSdarrenr  * Copyright (C) 2012 by Darren Reed.
5bc4097aaSchristos  *
6bc4097aaSchristos  * See the IPFILTER.LICENCE file for details on licencing.
7bc4097aaSchristos  *
8*13885a66Sdarrenr  * Id: optvalue.c,v 1.1.1.2 2012/07/22 13:44:39 darrenr Exp $
9bc4097aaSchristos  */
10bc4097aaSchristos #include "ipf.h"
11bc4097aaSchristos 
12bc4097aaSchristos 
getoptbyname(optname)13bc4097aaSchristos u_32_t getoptbyname(optname)
14bc4097aaSchristos 	char *optname;
15bc4097aaSchristos {
16bc4097aaSchristos 	struct ipopt_names *io;
17bc4097aaSchristos 
18bc4097aaSchristos 	for (io = ionames; io->on_name; io++)
19bc4097aaSchristos 		if (!strcasecmp(optname, io->on_name))
20bc4097aaSchristos 			return io->on_bit;
21bc4097aaSchristos 	return -1;
22bc4097aaSchristos }
23bc4097aaSchristos 
24bc4097aaSchristos 
getoptbyvalue(optval)25bc4097aaSchristos u_32_t getoptbyvalue(optval)
26bc4097aaSchristos 	int optval;
27bc4097aaSchristos {
28bc4097aaSchristos 	struct ipopt_names *io;
29bc4097aaSchristos 
30bc4097aaSchristos 	for (io = ionames; io->on_name; io++)
31bc4097aaSchristos 		if (io->on_value == optval)
32bc4097aaSchristos 			return io->on_bit;
33bc4097aaSchristos 	return -1;
34bc4097aaSchristos }
35