/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2003-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* dss type library
*
* David Korn
* AT&T Labs
*
*/
#include <shell.h>
#include <dsslib.h>
#ifndef SH_DICT
#endif
struct Optdisc
{
};
typedef struct Namchld
{
} Namchld_t;
struct type
{
};
struct Namtype
{
char *nodes;
char *data;
int numnodes;
char **names;
};
struct dsstype
{
char **names;
int nnames;
};
struct dssfile
{
char *dp;
};
struct query
{
int index;
};
struct parent
{
char *name;
};
/*
* the following function is added as a builtin for each query
* function that a variable can have
*/
{
char *savedata;
{
if(!pp)
{
}
{
if(xp)
return(0);
}
{
{
return(2);
}
}
return(0);
}
return(1);
{
return(n<0?2:1);
}
return(0);
}
{
static char *buf;
{
if(buflen==0)
else
}
return(buf);
}
{
if(cxisnumber(tp))
{
}
else if(cxisbuffer(tp))
}
{
#if 0
{
/* create reference variable name to NV_CLASS.dss.name */
}
#endif
return(mp);
}
{
{
}
return(0);
}
{
{
{
return(sp);
}
}
return(0);
}
{
return(0);
{
}
else
{
{
}
}
else
if(savedata)
{
}
return(value);
}
{
{
else
{
return(ld);
}
}
return(0);
}
{
#if 1
#else
#endif
return(0.0);
}
{
}
{
}
{
char *cp;
{
else
}
}
{
return(0);
}
/* for child variables of compound variables */
{
sizeof(Namchld_t),
0,
0,
0,
0,
};
/* for child variables of methods */
{
sizeof(Namchld_t),
0,
0,
0,
0,
};
{
{
return(0);
if(tp)
else
else if(tp)
else
mp = 0;
}
if(!vp)
{
if(!dp->dss && vp->type->base && (mp=typenode(vp->type->name,0)) && (fp = nv_hasdisc(mp, &type_disc)))
{
{
}
if(nfp)
}
}
return(np);
}
{
}
{
{
{
{
}
}
}
}
{
int c;
if(!name)
last++;
if(c)
*last = 0;
{
if(c)
*last = c;
return(np);
}
if(c)
*last = c;
if(vp)
{
if(c=='.')
{
{
}
if(rp)
}
return(np);
}
return(0);
}
{
{
else
}
}
{
if(!val)
{
}
{
{
return;
}
}
}
{
if(event==SF_CLOSING)
{
{
if(nfp)
}
}
return(0);
return(1);
}
{
if(!iop)
{
{
return(1);
}
}
{
if(!iop)
else
{
}
}
if(iop)
{
return(1);
if(ap)
{
}
else
}
return(0);
}
{
{
{
return(1);
}
}
}
{
{
}
if(!fp)
return(0);
do
{
if(root)
{
}
else
{
if(!vp)
}
#if 0
if(vp)
#endif
}
else
{
return (np);
#if 0
if(vp)
#endif
}
}
if(!vp)
return((Namval_t*)0);
return(np);
}
{
sizeof(struct parent),
0,
0,
0,
0,
0,
};
/*
* should only get here when requesting raw binary data
* This must come after the nv_tree discipline
*/
{
#if 1
#else
#if 1
#else
#endif
#endif
char *cp;
#if 1
if(size>0)
{
#else
{
#endif
nv_setsize(np,m);
return(cp);
}
return(0);
}
{
0,0,get_parent
};
/*
* add discipline builtin given by name to type
*/
static Namval_t *add_discipline(const char *typename, const char *name, int (*fun)(int, char*[],Shbltin_t*), void* context)
{
return(mp);
}
{
{
{
return;
}
}
{
else
{
}
}
else
if(!val)
{
else
{
int i;
{
{
}
}
}
}
}
{
int i,n;
else
{
}
for(i=0; i < 2; i++)
{
if(n<buflen)
break;
}
return(buf);
}
/*
* They can all share one instance of the discipline
*/
{
{
}
return(fp);
}
{
{
}
return(0);
}
*fp)
{
int n = -1;
if(name)
{
n = 0;
}
if(!event)
{
return("match");
n = -1;
}
if(n<0)
{
/* clone the discipline for variable specific function */
{
}
}
else if(action)
else
{
}
}
{
{
}
{
return(np);
}
if(memcmp(name,NV_DATA,sizeof(NV_DATA)-1)==0 && (name[sizeof(NV_DATA)-1]==0 || strchr("+=[",name[sizeof(NV_DATA)-1])))
{
}
return(0);
}
{
0,
0,
0,
};
static const char sh_opttype[] =
"[-1c?\n@(#)$Id: type (AT&T Research) 2008-06-09 $\n]"
"[+NAME?\f?\f - set the type of variables to \b\f?\f\b]"
"[+DESCRIPTION?\b\f?\f\b sets the type of each of the variables specified "
"by \aname\a to \b\f?\f\b. If \b=\b\avalue\a is specified, "
"the variable \aname\a is set to \avalue\a before the variable "
"is converted to \b\f?\f\b.]"
"[+?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.]"
"[+?The types are:]{\ftypes\f}"
"[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.]"
"[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.]"
"\n"
"\n[name[=value]...]\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Successful completion.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\breadonly\b(1), \btypeset\b(1)]"
;
{
{
}
{
}
}
{
long n;
char *cp=0;
if(cp)
{
*cp = '.';
if(!mp)
return(0);
if(!fq)
return(0);
return(np);
}
if(mp)
return(mp);
{
}
else
{
}
if(dss)
else
{
{
return(mp);
}
}
{
continue;
#if 0
#endif
continue;
{
{
}
}
}
return(0);
#if 0
#endif
if(dss)
{
for(i=0; i < n; i++)
}
if(dss)
return(mp);
}
{
return(name);
}
{
0,
0,
0,
0,
0,
0,
};
static const char optlist[] =
"[-1c?\n@(#)$Id: dss.list (AT&T Research) 2007-05-09 $\n]"
"[+NAME?\f?\f - list the known dss entities]"
"[+DESCRIPTION?\b\f?\f\b causes each of the specified dss entities "
"specified as options to be written to standard output. If no "
"options are specified, all entities are written.]"
"[+?If multiple entities types are written, then the entity type is written "
"before each of the names.]"
"[l?List the names of library entities.]"
"[m?List the names of method entities.]"
"[q?List the names of query entities.]"
"[t?List the names of type entities.]"
"[v?A description of each entity will be listed along with the name.]"
"\n"
"\n\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Successful completion.]"
"[+>0?An error occurred.]"
"}"
;
{
char *name;
{
case 'm': case 'l': case 't': case 'q':
break;
case 'v':
delim = '\t';
break;
case ':':
case '?':
return(2);
}
if(flags==0)
{
else
continue;
{
if(n)
if(delim!='\n')
}
}
return(error_info.errors);
}
static const char optload[] =
"[-1c?\n@(#)$Id: dss.load (AT&T Research) 2003-01-10 $\n]"
"[+NAME?\f?\f - load a dss format library]"
"[+DESCRIPTION?\b\f?\f\b causes each of the specified dss libraries \alib\a "
"to be loaded into the shell and its contents merged with other "
"dss libraries.]"
"\n"
"\nlib ...\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Successful completion.]"
"[+>0?An error occurred.]"
"}"
;
{
char *name;
int n;
{
case ':':
case '?':
return(2);
}
return(error_info.errors);
}
{
{
#if 1
#else
#endif
}
else
{
else
{
}
}
}
static const char optmatch[] =
"[-1c?\n@(#)$Id: dss.match (AT&T Research) 2003-01-15 $\n]"
"[+NAME?\f?\f - match a dss type variable to a pattern]"
"[+DESCRIPTION?\b\f?\f\b causes the value of the variable whose name "
"precedes \b.match\b in the callers name to be matched against "
"the specified pattern \apattern\a. The interpretation of "
"\apattern\a depends on the type of this variable.]"
"[+?\fmatch\f]"
"[v?\apattern\a is a variable name that contains the pattern.]"
"\n"
"\npattern\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?The value of the variable matched \apattern\a.]"
"[+1?The value of the variable did not match \apattern\a.]"
"[+2?A usage error was found or a help request was made.]"
"[+>2?An error occurred.]"
"}"
"[+SEE ALSO?\bdss\b(3)]"
;
{
char *cp;
void *comp;
int n, flag=0;
{
goto exec;
if(argc<=0)
return(0);
}
{
case 'v':
flag = 'v';
break;
case ':':
case '?':
return(2);
}
if(flag)
{
{
if(mp)
if(!tptr)
fp = 0;
}
}
else
{
}
if(!tptr)
if(!comp)
return(3);
exec:
return(n<0?4:!n);
}
{
const char *name;
/* create reference variable dss to NV_CLASS.dss */
{
char *cp;
n = 0;
for (lib = dsslib(NiL, DSS_VERBOSE, &Dssdisc); lib; lib = (Dsslib_t*)dtnext(state->cx->libraries, lib))
{
int m;
continue;
{
continue;
continue;
continue;
if(level==0)
{
n++;
len += m;
}
else
{
cp += m;
}
}
if(level==0)
{
}
}
}
}