/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include <shell.h>
static const char enum_usage[] =
"[-?@(#)$Id: enum (AT&T Research) 2008-01-08 $\n]"
"[+NAME?enum - create an enumeration type]"
"[+DESCRIPTION?\benum\b is a declaration command that creates an enumeration "
"type \atypename\a that can only store any one of the values in the indexed "
"array variable \atypename\a.]"
"[+?If the list of \avalue\as is omitted, then \atypename\a must name an "
"indexed array variable with at least two elements.]"
"[i:ignorecase?The values are case insensitive.]"
"\n"
"\n\atypename\a[\b=(\b \avalue\a ... \b)\b]\n"
"\n"
"[+EXIT STATUS]"
"{"
"[+0?Successful completion.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\bksh\b(1), \btypeset\b(1).]"
;
static const char enum_type[] =
"[-1c?\n@(#)$Id: type (AT&T Labs Research) 2008-01-08 $\n]"
"[+NAME?\f?\f - create an instance of type \b\f?\f\b]"
"[+DESCRIPTION?\b\f?\f\b creates a variable for each \aname\a with "
"enumeration type \b\f?\f\b where \b\f?\f\b is a type that has been "
"created with the \benum\b(1) command.]"
"[+?The variable can have one of the following values\fvalues\f. "
"The the values are \fcase\fcase sensitive.]"
"[+?If \b=\b\avalue\a is omitted, the default is \fdefault\f.]"
"[+?If no \aname\as are specified then the names and values of all "
"variables of this type are written to standard output.]"
"[+?\b\f?\f\b is built-in to the shell as a declaration command so that "
"field splitting and pathname expansion are not performed on "
"the arguments. Tilde expansion occurs on \avalue\a.]"
"[r?Enables readonly. Once enabled, the value cannot be changed or unset.]"
"[a?index array. Each \aname\a will converted to an index "
"array of type \b\f?\f\b. If a variable already exists, the current "
"value will become index \b0\b.]"
"[A?Associative array. Each \aname\a will converted to an associate "
"array of type \b\f?\f\b. If a variable already exists, the current "
"value will become subscript \b0\b.]"
"[h]:[string?Used within a type definition to provide a help string "
"for variable \aname\a. Otherwise, it is ignored.]"
"[S?Used with a type definition to indicate that the variable is shared by "
"each instance of the type. When used inside a function defined "
"with the \bfunction\b reserved word, the specified variables "
"will have function static scope. Otherwise, the variable is "
"unset prior to processing the assignment list.]"
#if 0
"[p?Causes the output to be in a form of \b\f?\f\b commands that can be "
"used as input to the shell to recreate the current type of "
"these variables.]"
#endif
"\n"
"\n[name[=value]...]\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Successful completion.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\benum\b(1), \btypeset\b(1)]"
;
struct Enum
{
short nelem;
short iflag;
};
{
int n=0;
const char *v;
#if 0
#else
#endif
{
}
{
}
return(0);
}
{
}
{
register const char *v;
unsigned short i=0, n;
if(!val)
{
return;
}
if(flags&NV_INTEGER)
{
return;
}
{
n = strcasecmp(v,val);
else
if(n==0)
{
return;
}
i++;
}
}
{
return(buff);
}
{
}
#ifdef STANDALONE
#else
#endif
{
struct {
} optdisc;
for (;;)
{
{
case 'i':
iflag = 'i';
continue;
case '?':
break;
case ':':
break;
}
break;
}
{
return 1;
}
{
if(!(np = nv_open(cp, (void*)0, NV_VARNAME|NV_NOADD)) || !(ap=nv_arrayptr(np)) || ap->fun || (sz=ap->nelem&(((1L<<ARRAY_BITS)-1))) < 2)
n = staktell();
stakseek(n);
n = sz;
i = 0;
do
{
}
while(nv_nextsub(np));
sz += n*sizeof(char*);
i = 0;
do
{
cp += n+1;
}
while(nv_nextsub(np));
}
return error_info.errors != 0;
}
#ifdef STANDALONE
{
if(flag)
return;
}
#endif