dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libast / common / comp / getsubopt.c
blobe0817d91ba72dbf0a7bd8aef6300ae6c35ac5b2b
1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
20 * *
21 ***********************************************************************/
22 #pragma prototyped
24 * Xopen 4.2 compatibility
27 #include <ast.h>
29 #undef _lib_getsubopt /* we can satisfy the api */
31 #if _lib_getsubopt
33 NoN(getsubopt)
35 #else
37 #undef _BLD_ast /* enable ast imports since we're user static */
39 #include <error.h>
41 extern int
42 getsubopt(register char** op, char* const* tp, char** vp)
44 register char* b;
45 register char* s;
46 register char* v;
48 if (*(b = *op))
50 v = 0;
51 s = b;
52 for (;;)
54 switch (*s++)
56 case 0:
57 s--;
58 break;
59 case ',':
60 *(s - 1) = 0;
61 break;
62 case '=':
63 if (!v)
65 *(s - 1) = 0;
66 v = s;
68 continue;
69 default:
70 continue;
72 break;
74 *op = s;
75 *vp = v;
76 for (op = (char**)tp; *op; op++)
77 if (streq(b, *op))
78 return op - (char**)tp;
80 *vp = b;
81 return -1;
84 #endif