dssopt.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2002-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 *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* dss optget() support
*/
#include "dsshdr.h"
/*
* format optget(3) description item on sp given plain text and item name
* you're in unless you optout
*/
static int
optout(register Sfio_t* sp, const char* name, const char* type, const char* map, const char* ret, const char* s, const char* x)
{
register const char* t;
register int c;
if (name)
{
if (ret)
for (t = name; c = *t++;)
{
if (c == ':')
}
}
if (type)
{
if (map)
}
if (s)
{
if (*s == '[')
return -1;
if (x)
{
return -1;
}
}
else
if (!s || *s != '[')
return 0;
}
/*
* structure type info output
*/
static int
{
register Cxvariable_t* mp;
for (mp = (Cxvariable_t*)dtfirst(type->member->members); mp; mp = (Cxvariable_t*)dtnext(type->member->members, mp))
{
if (optout(sp, mp->name, mp->type->name, NiL, NiL, mp->description, mp->type->member ? "This structure type has the following members:" : (char*)0))
return -1;
return -1;
}
return 0;
}
/*
* type info output
*/
static int
{
register const char* x;
register const char* b;
register const char* d;
register int i;
x = "This structure type has the following members:";
else
x = 0;
{
b = !x ? "" : x[0] == '[' && x[1] == '+' && x[2] == '?' ? (x + 3) : x;
else if (x)
else
}
{
}
if (tmp)
if (i)
return -1;
return -1;
else if (tp->base && tp->base->member && !(tp->base->header.flags & CX_REFERENCED) && opttype(sp, tp->base, 0))
return -1;
return -1;
return 0;
}
/*
* data map output
*/
static int
{
size_t n;
{
else
else
}
else
{
{
else
return -1;
}
}
return 0;
}
/*
* optget() info discipline function
*/
int
{
long pos;
int all;
int head;
char name[64];
switch (*s)
{
case 'd':
if (*(s + 1) == 'e' && *(s + 2) == 't')
{
/* details */
return -1;
}
else
{
/* description */
}
return 0;
case 'i':
/* ident|index */
else
return 0;
case 'm':
if (*(s + 1) == 'a')
{
/* match */
return -1;
}
else
{
/* methods */
return -1;
}
return 0;
case 'n':
/* name */
return 0;
case 'p':
/* default print format */
else
return 0;
case 't':
/* type */
return -1;
return 0;
}
{
return 0;
}
head = 0;
switch (*s)
{
case 'f':
if (*(s + 1) != 'i')
{
/* formats */
if ((head = !!strchr(s, ' ')) && meth->description && optout(sp, meth->name, NiL, NiL, NiL, meth->description, NiL))
return -1;
{
return -1;
for (format = (Dssformat_t*)dtfirst(meth->formats); format; format = (Dssformat_t*)dtnext(meth->formats, format))
return -1;
}
if (!head)
break;
}
/*FALLTHROUGH*/
case 'v':
/* fields|variables */
if (head)
head = 0;
return -1;
{
if (!head)
{
return -1;
head = 1;
}
return -1;
}
head = 0;
{
if (!head)
{
return -1;
head = 1;
}
return -1;
return -1;
}
{
head = 0;
for (vp = (Cxvariable_t*)dtfirst(meth->cx->variables); vp; vp = (Cxvariable_t*)dtnext(meth->cx->variables, vp))
{
if (!head)
{
return -1;
head = 1;
}
return -1;
}
}
head = 0;
if (!all)
for (vp = (Cxvariable_t*)dtfirst(meth->cx->fields); vp; vp = (Cxvariable_t*)dtnext(meth->cx->fields, vp))
{
if (!head)
{
return -1;
head = 1;
}
if (optout(sp, vp->name, vp->type->name, vp->format.map ? vp->format.map->name : (char*)0, NiL, vp->description, NiL))
return -1;
}
{
if (!head)
{
return -1;
head = 1;
}
if (optout(sp, name, (char*)vp->type, vp->format.map ? vp->format.map->name : (char*)0, NiL, vp->description, NiL))
return -1;
}
break;
}
return 0;
}
/*
* generate lib info usage
*/
int
{
register int i;
register char* s;
return -1;
return -1;
{
}
else
sfprintf(sp, "[-1ls5Pp0?][+PLUGIN?%s - %s]\n", lib->name, lib->description ? lib->description : "support library");
if (usage)
{
sfprintf(sp, "[+DESCRIPTION?The %s method handles %s.]\n", lib->meth->name, lib->meth->description);
}
{
return -1;
}
{
return -1;
return -1;
}
{
if (optout(sp, cxopname(lib->callouts[i].op.code, lib->callouts[i].op.type1, lib->callouts[i].op.type2), NiL, NiL, NiL, lib->callouts[i].description, NiL))
return -1;
}
{
if (optout(sp, cxopname(lib->recodes[i].op.code, lib->recodes[i].op.type1, lib->recodes[i].op.type2), NiL, NiL, NiL, lib->recodes[i].description, NiL))
return -1;
}
{
if (optout(sp, lib->queries[i].name, NiL, NiL, NiL, lib->queries[i].description, lib->queries[i].method ? sfprints("Limited to methods matching \"%s\".", lib->queries[i].method) : (char*)0))
return -1;
}
if (lib->constraints)
{
return -1;
}
{
return -1;
}
{
if (optout(sp, lib->functions[i].name, lib->functions[i].prototype, NiL, (lib->functions[i].header.flags & CX_INITIALIZED) ? lib->functions[i].type->name : (char*)lib->functions[i].type, lib->functions[i].description, NiL))
return -1;
}
return 0;
}