1/*********************************************************************** 2* * 3* This software is part of the ast package * 4* Copyright (c) 1985-2011 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 23/* 24 * Xopen 4.2 compatibility 25 */ 26 27#include <ast.h> 28 29#undef _lib_getsubopt /* we can satisfy the api */ 30 31#if _lib_getsubopt 32 33NoN(getsubopt) 34 35#else 36 37#undef _BLD_ast /* enable ast imports since we're user static */ 38 39#include <error.h> 40 41extern int 42getsubopt(register char** op, char* const* tp, char** vp) 43{ 44 register char* b; 45 register char* s; 46 register char* v; 47 48 if (*(b = *op)) 49 { 50 v = 0; 51 s = b; 52 for (;;) 53 { 54 switch (*s++) 55 { 56 case 0: 57 s--; 58 break; 59 case ',': 60 *(s - 1) = 0; 61 break; 62 case '=': 63 if (!v) 64 { 65 *(s - 1) = 0; 66 v = s; 67 } 68 continue; 69 default: 70 continue; 71 } 72 break; 73 } 74 *op = s; 75 *vp = v; 76 for (op = (char**)tp; *op; op++) 77 if (streq(b, *op)) 78 return op - (char**)tp; 79 } 80 *vp = b; 81 return -1; 82} 83 84#endif 85