/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2003-2011 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 *
* *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "vchdr.h"
/* Managing lists of transforms.
**
** Written by Kiem-Phong Vo (kpv@research.att.com)
*/
#if _PACKAGE_ast
#include <dlldefs.h>
#include <ccode.h>
#endif
/* reconstitute declarations for the default public methods */
#ifdef __STDC__
#else
#endif
#include <vcmethods.h>
/* reconstitute the list of pointers to the default public methods */
{
#ifdef __STDC__
#define VCMETHOD(m) &_##m,
#else
#define VCMETHOD(m) &_/**/m,
#endif
#include <vcmethods.h>
};
struct _vcmtlist_s
};
static int _Doneinit;
/* add a list of methods - perhaps dynamically loaded */
#if __STD_C
#else
#endif
{
if(VCMTINIT() < 0) /* initialize with our own methods first */
return -1;
return 0;
return -1;
if(_Vcmtlist)
}
else
}
if(!size)
{
size = 1;
}
return 0;
}
#if _PACKAGE_ast
#if __STD_C
#else
char* path;
#endif
{
{
return meth;
}
return 0;
}
#endif
/* return a method matching an id */
#if __STD_C
static int vcmtinit(void)
#else
static int vcmtinit()
#endif
{
#if _PACKAGE_ast
#endif
#if _PACKAGE_ast
}
#endif
return 0;
}
/* return a method matching an id */
#if __STD_C
#else
char* name;
int portable; /* name is in portable format */
#endif
{
int i;
#if _PACKAGE_ast
unsigned char *map;
#endif
if(VCMTINIT() < 0) /* initialize with our own methods first */
return NIL(Vcmethod_t*);
if(!name)
return NIL(Vcmethod_t*);
return NIL(Vcmethod_t*);
return NIL(Vcmethod_t*);
}
}
#if _PACKAGE_ast
{ for (i = 0; i < sizeof(buf2) - 1; i++)
}
if (dll = dllplugin(VC_ID, name, NIL(char*), VCODEX_PLUGIN_VERSION, NiL, RTLD_LAZY, buf1, sizeof(buf1)))
#endif
return NIL(Vcmethod_t*);
}
/* return the method after 'meth' in the union of all methods */
#if __STD_C
#else
#endif
{
int i, rv;
if(VCMTINIT() < 0) /* initialize with our own methods first */
return -1;
if(!walkf)
return -1;
if(rv < 0)
return rv;
}
}
return 0;
}
/* set data for a particular transformation context for the method */
#if __STD_C
#else
char* name; /* name of the parameter to set */
int type; /* different coding types: */
/* 0: null-terminated string */
/* 1: 'char' in C-style */
/* >0: 'int' in decimal */
/* <0: no value */
#endif
{
int k;
return -1;
return 0;
for(k = 0; k < sizeof(data); ++k)
break;
}
return -1;
if(type == 0) /* string */
{ data[k++] = '=';
while(k < sizeof(data)-1)
{ if(*v == 0)
break;
data[k++] = *v++;
}
}
}
{ data[k++] = '=';
data[k++] = '\\';
if(type >= 64)
goto do_8;
}
else if(type >= 8)
{ data[k++] = '0';
goto do_0;
}
else
{ data[k++] = '0';
data[k++] = '0';
}
}
else if(type > 0) /* int, code in base 10 */
{ data[k++] = '=';
if(type == 0)
break;
}
*--v = '-';
data[k++] = *v++;
}
data[k] = 0;
}
/* from a string specification, find an argument and its value if any */
#if __STD_C
#else
char* data; /* data to be parsed, null-terminated */
char* val; /* buffer to return the value */
#endif
{
Vcmtarg_t *a;
ssize_t k;
int csep;
if(arg)
if(!data)
if(!val)
vlsz = 0;
if(!args) /* partitioning by separator, no internal character processing */
/* a real name must be alphanumeric */
break;
/* extract the name */
break;
}
if(k == sizeof(name))
k = 0;
name[k] = 0;
data += 1;
;
}
data += 1;
/* find the matching argument */
break;
if(arg)
*arg = a;
/* next name=value, if any */
}
/* Get a substring from a larger string. There are two cases:
** type == 0: Only search for the separator csep. In this case,
** we still allow escape via backslash or grouping with braces
** and brackets but we do not process such characters.
** type == 1: In this case, brackets and C-notation for
** characters are processed.
** Return the left-over data.
*/
#if __STD_C
#else
char* data; /* data to extract from */
int csep; /* separator character */
char* val; /* space for substring */
int type; /* see above */
#endif
{
if(!val)
vlsz = 0;
for(endbrace = -1;;)
{
{ end_string:
if(c == 0) /* point to the zero-byte */
data -= 1;
if(vlsz > 0)
return data;
}
if(c == '[' )
{ endbrace = ']';
if(type == 0) /* grab group as is */
{ do
{ if(vlsz > 1)
if(c == endbrace)
break;
{ c = *data++;
if(vlsz > 1)
}
if(c == 0)
goto end_string;
if(vlsz > 1)
endbrace = -1;
continue;
}
if((c = *data++) == 0) /* skip forward */
goto end_string;
}
if(c == endbrace)
{ endbrace = -1;
continue;
}
if(c == '\\')
{ if(type == 0) /* no processing, just keeping next letter */
{ if(vlsz > 1)
if((c = *data++) == 0)
goto end_string;
if(vlsz > 1)
continue;
}
if((c = *data++) == 0)
goto end_string; /* unexpected eos */
else if(c >= '0' && c <= '7') /* \ddd notation */
{ for(c -= '0', k = 0; k < 2; ++k)
break;
}
}
else switch(c)
{ case 't' : c = '\t'; break;
case 'b' : c = '\b'; break;
case 'r' : c = '\r'; break;
case 'n' : c = '\n'; break;
}
}
if(vlsz > 1)
}
}
/* get the identification string of a method */
#if __STD_C
#else
char* buf; /* buffer to store ID if needed */
sszie_t n; /* size of buffer */
#endif
{
char *ident = NIL(char*);
if(!meth) /* bad invocation */
return NIL(char*);
#ifdef VC_GETIDENT
return NIL(char*);
#endif
return ident;
}