add UNLEASHED_OBJ to unleashed.mk
[unleashed/tickless.git] / usr / src / cmd / ipf / lib / common / buildopts.c
blob706e7b73b97f40143837c09adb0a3c1755badb4e
1 /*
2 * Copyright (C) 1993-2001 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: buildopts.c,v 1.6 2002/01/28 06:50:45 darrenr Exp $
7 */
9 #include "ipf.h"
12 u_32_t buildopts(cp, op, len)
13 char *cp, *op;
14 int len;
16 struct ipopt_names *io;
17 u_32_t msk = 0;
18 char *s, *t;
19 int inc;
21 for (s = strtok(cp, ","); s; s = strtok(NULL, ",")) {
22 if ((t = strchr(s, '=')))
23 *t++ = '\0';
24 for (io = ionames; io->on_name; io++) {
25 if (strcasecmp(s, io->on_name) || (msk & io->on_bit))
26 continue;
27 if ((inc = addipopt(op, io, len, t))) {
28 op += inc;
29 len += inc;
31 msk |= io->on_bit;
32 break;
34 if (!io->on_name) {
35 fprintf(stderr, "unknown IP option name %s\n", s);
36 return 0;
39 *op++ = IPOPT_EOL;
40 len++;
41 return len;