Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / buildopts.c
blob9b003f8b0e451b071253ad889ed7a280271adfaa
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2000-2002 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Id: buildopts.c,v 1.6.4.1 2006/06/16 17:20:56 darrenr Exp
9 */
11 #include "ipf.h"
14 u_32_t buildopts(cp, op, len)
15 char *cp, *op;
16 int len;
18 struct ipopt_names *io;
19 u_32_t msk = 0;
20 char *s, *t;
21 int inc;
23 for (s = strtok(cp, ","); s; s = strtok(NULL, ",")) {
24 if ((t = strchr(s, '=')))
25 *t++ = '\0';
26 for (io = ionames; io->on_name; io++) {
27 if (strcasecmp(s, io->on_name) || (msk & io->on_bit))
28 continue;
29 if ((inc = addipopt(op, io, len, t))) {
30 op += inc;
31 len += inc;
33 msk |= io->on_bit;
34 break;
36 if (!io->on_name) {
37 fprintf(stderr, "unknown IP option name %s\n", s);
38 return 0;
41 *op++ = IPOPT_EOL;
42 len++;
43 return len;