/***********************************************************************
* *
* 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
/*
*
* Glenn Fowler
* AT&T Research
*/
#include "cxlib.h"
#include <ccode.h>
typedef struct Type_s
{
} Type_t;
static void*
{
if (!cxisstring(pt))
{
return 0;
}
{
return 0;
}
{
return 0;
}
return re;
}
static int
{
int i;
if ((i = regnexec((regex_t*)data, sv->string.data, sv->string.size, 0, NiL, 0)) && i != REG_NOMATCH)
i = -1;
return i == 0;
}
static int
{
if (data)
{
}
return 0;
}
{
"regex",
"Matches on this type treat the pattern as a regex(3) pattern string.",
CXH,
};
/*
* default void externalf
*/
static ssize_t
void_external(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
{
ssize_t i;
if (!format)
return 0;
buf[i] = 0;
return i;
}
/*
* default void internalf
*/
static ssize_t
void_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
{
}
/*
* default number externalf
*/
static ssize_t
number_external(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
{
ssize_t n;
char* f;
{
f = fmt;
*f++ = '%';
if (format)
{
{
}
*f++ = 'l';
*f++ = 'l';
}
else
{
*f++ = 'l';
*f++ = 'l';
*f++ = 'd';
}
*f = 0;
}
{
int w;
if (n != w)
{
w += w - n;
}
}
else
if (n < 0)
return -1;
if (n > size)
return n;
}
/*
* default number internalf
*/
static ssize_t
number_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
{
Cxunsigned_t m;
char* e;
if (size == 0)
{
return 0;
}
else
{
{
return size;
}
(*disc->errorf)(cx, disc, 1, "%s: invalid number [(buf+size)=%p e=%p%s base=%d size=%d]", fmtquote(buf, NiL, NiL, size, 0), (char*)buf+size, e, (format && (format->flags & CX_UNSIGNED)) ? " unsigned" : "", format ? format->base : 0, size);
}
return e - (char*)buf;
}
/*
* default string externalf
*/
static ssize_t
string_external(Cx_t* cx, Cxtype_t* type, const char* details, register Cxformat_t* format, register Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
{
{
else
{
memset(buf + value->string.size, format->fill >= 0 ? format->fill : 0, format->width - value->string.size);
}
}
else
{
}
}
/*
* default string internalf
*/
static ssize_t
string_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
{
char* s;
}
/*
* default buffer externalf -- mime base64 encode
*/
static ssize_t
buffer_external(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
{
register unsigned char* t;
register unsigned char* f;
register unsigned char* e;
register int v;
int z;
{
case 0:
case 'b':
case 'm':
case 'h':
case 'x':
e = f + z;
z *= 2;
if (size < z)
return z;
t = (unsigned char*)buf;
while (f < e)
{
v = *f++;
*t++ = hex[v >> 4];
*t++ = hex[v & 0xf];
}
return z;
}
(*cx->disc->errorf)(cx, cx->disc, ERROR_SYSTEM|2, "%s: unknown buffer representation details", details);
return -1;
}
/*
* default buffer internalf -- mime base64 decode
*/
static ssize_t
buffer_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
{
void* t;
size_t n;
ssize_t r;
if (!vm)
{
return -1;
}
else
{
}
return r;
}
/*
* type externalf
*/
static ssize_t
type_external(Cx_t* cx, Cxtype_t* type, const char* details, register Cxformat_t* format, register Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
{
size_t n;
return n;
}
/*
* default string internalf
*/
static ssize_t
type_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
{
return -1;
}
/*
* NOTE: void must be first
*/
{
BT(CX_void, &name_void[0], &state.type_void, "No value. May be used for padding.", void_external, void_internal, 0)
BT(CX_number, &name_number[0], &state.type_number, "An integral or floating point number.", number_external, number_internal, 0)
BT(CX_string, &name_string[0], &state.type_string, "A string. The format details string specifies quoting and C style character escape processing: \bquote\b[=\achar\a] quotes string with \achar\a (\b\"\b) as the begin and end quote; \bendquote\b=\achar\a changes the \bquote\b end to \achar\a; \bshell\b[=\abeg\a] quotes using shell conventions and \abeg\a (\b$'\b) as the quote begin; \bopt\b performs \bquote\b and \bshell\b quoting only when necessary; \bescape\b assumes that escape processing has already been performed; \bwide\b does not escape characters with the bit 8 set; \bexpand\b=\amask\a expands escaped characters according to \amask\a which may be a \b,\b or \b|\b separated list of \ball\b: expand all escaped chars, \bchar\b expands 7 bit character escapes, \bline\b expands \b\\r\b and \b\\n\b escapes, \bwide\b expands wide character escapes, \bnocr\b eliminates \b\\r\b, and \bnonl\b eliminates \b\\n\b.", string_external, string_internal, &match_string)
BT(CX_buffer, &name_buffer[0], &state.type_buffer, "A separately allocated sized buffer. The external representation is a newline separated base64 mime encoding.", buffer_external, buffer_internal, 0)
};
static int
op_call_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return (*pc->data.variable->function)(cx, pc->data.variable, r, b + (pc->pp + 1), -pc->pp, data, disc);
}
static int
op_nop_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_end_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
/*
* NOTE: this special case error return breaks out of the
* cxeval() execute() inner loop and is not recorded
* as an error
*/
return -1;
}
static int
op_ref_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
}
static int
op_sc_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
{
return 1;
}
return 0;
}
static int
op_const_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_tst_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return -1;
}
static int
op_add_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_sub_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_mpy_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_div_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
{
return -1;
}
return 0;
}
static int
op_mod_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
{
return -1;
}
return 0;
}
static int
op_and_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_or_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_xor_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_andand_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_oror_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_lsh_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_rsh_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_inv_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_log_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_not_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_uplus_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_uminus_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_lt_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_le_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_eq_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_ne_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_ge_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_gt_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_log_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_lt_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int c;
r->value.number = (c = strncmp(a->value.string.data, b->value.string.data, CXMIN(a->value.string.size, b->value.string.size))) < 0 || c == 0 && a->value.string.size < b->value.string.size;
return 0;
}
static int
op_le_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int c;
r->value.number = (c = strncmp(a->value.string.data, b->value.string.data, CXMIN(a->value.string.size, b->value.string.size))) < 0 || c == 0 && a->value.string.size == b->value.string.size;
return 0;
}
static int
op_eq_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
r->value.number = a->value.string.size == b->value.string.size && strncmp(a->value.string.data, b->value.string.data, a->value.string.size) == 0;
return 0;
}
static int
op_ne_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
r->value.number = a->value.string.size != b->value.string.size || strncmp(a->value.string.data, b->value.string.data, a->value.string.size) != 0;
return 0;
}
static int
op_ge_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int c;
r->value.number = (c = strncmp(a->value.string.data, b->value.string.data, CXMIN(a->value.string.size, b->value.string.size))) > 0 || c == 0 && a->value.string.size > b->value.string.size;
return 0;
}
static int
op_gt_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int c;
r->value.number = (c = strncmp(a->value.string.data, b->value.string.data, CXMIN(a->value.string.size, b->value.string.size))) > 0 || c == 0 && a->value.string.size > b->value.string.size;
return 0;
}
static int
op_not_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_lt_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int c;
r->value.number = (c = memcmp(a->value.buffer.data, b->value.buffer.data, CXMIN(a->value.buffer.size, b->value.buffer.size))) < 0 || c == 0 && a->value.buffer.size < b->value.buffer.size;
return 0;
}
static int
op_le_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int c;
r->value.number = (c = memcmp(a->value.buffer.data, b->value.buffer.data, CXMIN(a->value.buffer.size, b->value.buffer.size))) < 0 || c == 0 && a->value.buffer.size == b->value.buffer.size;
return 0;
}
static int
op_eq_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
r->value.number = a->value.buffer.size == b->value.buffer.size && memcmp(a->value.buffer.data, b->value.buffer.data, a->value.buffer.size) == 0;
return 0;
}
static int
op_ne_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
r->value.number = a->value.buffer.size != b->value.buffer.size || memcmp(a->value.buffer.data, b->value.buffer.data, a->value.buffer.size) != 0;
return 0;
}
static int
op_ge_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int c;
r->value.number = (c = memcmp(a->value.buffer.data, b->value.buffer.data, CXMIN(a->value.buffer.size, b->value.buffer.size))) > 0 || c == 0 && a->value.buffer.size > b->value.buffer.size;
return 0;
}
static int
op_gt_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int c;
r->value.number = (c = memcmp(a->value.buffer.data, b->value.buffer.data, CXMIN(a->value.buffer.size, b->value.buffer.size))) > 0 || c == 0 && a->value.buffer.size > b->value.buffer.size;
return 0;
}
static int
op_not_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_eq_T(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_ne_T(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
op_cast_SN(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
char* e;
return 0;
}
static int
op_match(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int i;
return i;
return 0;
}
static int
op_nomatch(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
int i;
return i;
return 0;
}
static int
re_match(Cx_t* cx, Cxexpr_t* expr, Cxinstruction_t* x, Cxinstruction_t* a, Cxinstruction_t* b, void* data, Cxdisc_t* disc)
{
return -1;
{
return -1;
}
return 0;
}
{
};
{
else
do
{
break;
switch (type->representation)
{
case CX_buffer:
{
}
break;
case CX_number:
case CX_pointer:
size = 8;
break;
case CX_string:
break;
default:
continue;
}
break;
return size;
}
static int
cx_edit_B(Cx_t* cx, Cxvariable_t* var, Cxoperand_t* ret, Cxoperand_t* arg, int n, void* data, Cxdisc_t* disc)
{
return -1;
}
static int
cx_sizeof_B(Cx_t* cx, Cxvariable_t* var, Cxoperand_t* ret, Cxoperand_t* arg, int n, void* data, Cxdisc_t* disc)
{
return 0;
}
static int
cx_typeof_B(Cx_t* cx, Cxvariable_t* var, Cxoperand_t* ret, Cxoperand_t* arg, int n, void* data, Cxdisc_t* disc)
{
return 0;
}
{
"Returns the result of applying the ed(1) style substitute expression"
" in the first argument to the second argument.")
"Returns the size of the \avariable\a argument;"
" the size of an array variable is the number of elements,"
" otherwise the size is in bytes.")
"Returns the type of the \avariable\a argument"
" for comparison with other types.")
};
/*
* open a cx session
*/
Cx_t*
{
if (!(vm = vmopen(Vmdcheap, Vmbest, 0)) || !(em = vmopen(Vmdcheap, Vmlast, 0)) || !(rm = vmopen(Vmdcheap, Vmlast, 0)))
{
if (vm)
{
if (em)
}
return 0;
}
{
goto bad;
}
{
return 0;
}
{
if (!(cx->fields = dtnew(cx->vm, &state.listdisc, Dtqueue)) || !(cx->buf = sfstropen()) || !(cx->tp = sfstropen()))
{
return 0;
}
}
return cx;
bad:
return 0;
}
/*
* scope control
*/
Cx_t*
{
if (!top)
{
return 0;
}
{
return 0;
}
if (bot)
{
/*
* scope top on bot
*/
{
return 0;
}
else
else
else
else
else
else
else
else
else
}
{
/*
* pop the scope
*/
}
else
return bot;
}
/*
* close a cx session
*/
int
{
if (!cx)
return -1;
{
}
return 0;
}
/*
* add a type
*/
int
{
char* base;
Cxvariable_t* v;
int i;
if (cx)
{
{
return -1;
}
else
{
}
{
return -1;
}
}
else
{
return -1;
}
{
{
return -1;
}
{
return -1;
}
{
{
return -1;
}
{
return -1;
}
else if (!(type->member->members = cx ? dtnew(cx->vm, &state.namedisc, Dtoset) : dtopen(&state.namedisc, Dtoset)))
{
return -1;
}
else
{
v = member;
{
{
return -1;
}
}
}
}
{
return -1;
}
}
{
if (type->fundamental)
{
}
else
{
}
{
{
return -1;
}
return -1;
}
return -1;
}
return 0;
}
/*
* return type given name
*/
{
register char* s;
register char* lib;
Cxtype_t* t;
size_t n;
{
n = s - (char*)name;
lib[n] = 0;
name = (const char*)s + 1;
}
else
if (!(t = (Cxtype_t*)dtmatch(cx ? cx->types : state.types, name)) && disc->loadf && (*disc->loadf)(lib, disc))
return t;
}
/*
* add an op callout
*/
int
{
char* name;
if (cx)
{
{
return -1;
}
else
{
}
{
return -1;
}
}
else if (callout->op.code == CX_GET || callout->op.code == CX_SET || callout->op.code == CX_DEL || callout->op.code == CX_RET)
{
return -1;
}
else
{
{
return -1;
}
{
return -1;
}
}
{
return -1;
}
return 0;
}
/*
* return callout given <code,type1,type2>
*/
{
{
return 0;
else
}
}
/*
* add a query
*/
int
{
if (cx)
{
{
return -1;
}
else
{
}
{
return -1;
}
}
else
{
return -1;
}
return 0;
}
/*
* return query given name
*/
{
register char* s;
register char* lib;
Cxquery_t* q;
size_t n;
{
n = s - (char*)name;
lib[n] = 0;
name = (const char*)s + 1;
}
else
if (!(q = (Cxquery_t*)dtmatch(cx ? cx->queries : state.queries, name)) && disc->loadf && (*disc->loadf)(lib, disc))
return q;
}
/*
* return function given name
*/
{
register char* s;
register char* p;
Cxvariable_t* f;
int i;
if (!cx)
{
return 0;
}
{
if (f->function)
return f;
return 0;
}
{
return 0;
}
i = s - (char*)name;
p = fmtbuf(i);
p[i] = 0;
return 0;
return 0;
{
if (f->function)
return f;
}
else
{
return 0;
}
return 0;
}
/*
* add a map
*/
int
{
if (cx)
{
{
return -1;
}
else
{
}
{
return -1;
}
}
else
{
return -1;
}
return -1;
return 0;
}
/*
* return map given name
*/
{
}
/*
* add an op recode
*/
int
{
Cxrecode_t* o;
char* name;
if (cx)
{
{
return -1;
}
else
{
}
{
return -1;
}
}
else if (recode->op.code == CX_GET || recode->op.code == CX_SET || recode->op.code == CX_DEL || recode->op.code == CX_RET)
{
return -1;
}
else
{
{
return -1;
}
{
return -1;
}
}
return 0;
}
/*
* return recode given <code,type1,type2>
*/
{
switch (code)
{
case CX_NOMATCH:
/*FALLTHROUGH*/
case CX_MATCH:
type2 = 0;
break;
}
return (recode = (Cxrecode_t*)dtmatch(cx ? cx->recodes : state.recodes, &op)) ? recode->recode : (Cxrecode_f)0;
}
/*
* add an edit
*/
int
{
if (cx)
{
{
return -1;
}
else
{
}
{
return -1;
}
}
else
{
return -1;
}
{
return -1;
}
return 0;
}
/*
* return edit given name
* optional substitute expression instantiated
*/
{
Cxedit_t* e;
Cxedit_t* o;
char* s;
{
if (!e)
{
return 0;
}
o = e;
{
return 0;
}
e->description = o->description;
}
else if (e)
return e;
else
{
if (!(e = cx ? vmnewof(cx->vm, 0, Cxedit_t, 1, strlen(data) + 1) : newof(0, Cxedit_t, 1, strlen(data) + 1)))
{
return 0;
}
if (cx)
{
}
s = (char*)data;
return 0;
return 0;
return 0;
}
return e;
}
/*
* add a constraint
*/
int
{
if (cx)
{
{
return -1;
}
else
{
}
{
return -1;
}
*copy = *constraint;
constraint = copy;
}
else
{
return -1;
}
{
return -1;
}
return 0;
}
/*
* return constraint given name
*/
{
}
/*
* mark type CX_REFERENCED
*/
static void
{
{
for (mp = (Cxvariable_t*)dtfirst(type->member->members); mp; mp = (Cxvariable_t*)dtnext(type->member->members, mp))
}
}
/*
* add a variable
*/
int
{
char* name;
if (cx)
{
{
return -1;
}
else
{
}
}
else
if (!variable)
return 0;
{
return -1;
}
{
{
return -1;
}
}
if (cx)
{
{
}
else
}
{
if (cx)
}
return 0;
}
/*
* return variable given name
*/
{
register char* s;
register char* t;
Cxvariable_t* v;
if (!cx)
{
return 0;
}
if (!m || !m->member)
{
{
{
return 0;
}
/*
* cxparse() never gets here
*/
t = s + (t - (char*)name);
m = 0;
head = 0;
for (;;)
{
if (t)
*t++ = 0;
if (!v)
{
{
if (m)
else
}
return 0;
}
{
return 0;
}
if (m)
if (head)
else
if (!(s = t))
break;
{
return 0;
}
t = strchr(t, '.');
}
{
return 0;
}
}
}
{
return 0;
}
return v;
}
/*
* cast var value to type
* if var==0 or data==0 then the value is already in ret
*/
int
cxcast(Cx_t* cx, Cxoperand_t* ret, Cxvariable_t* var, Cxtype_t* type, void* data, const char* format)
{
unsigned char* map;
char* s;
ssize_t n;
Cxunsigned_t m;
int c;
Cxoperand_t a;
Cxoperand_t b;
x.callout = 0;
{
if (!type)
if (data)
{
{
return -1;
}
a.refs = 0;
{
b.refs = 0;
return -1;
{
return -1;
}
}
return -1;
return 0;
}
}
else
from = 0;
c != CC_NATIVE &&
{
{
{
return -1;
}
}
ret->value.string.data = (char*)ccmapcpy(map, cx->ccbuf, ret->value.string.data, ret->value.string.size);
}
{
if (cxisstring(type))
{
if (!var || !cxisnumber(from) || !var->format.map || format || cxnum2str(cx, &var->format, (Cxinteger_t)ret->value.number, &s))
{
{
while ((n = (*ret->type->externalf)(cx, ret->type, format, var ? &var->format : (Cxformat_t*)0, &ret->value, cx->cvtbuf, cx->cvtsiz, cx->disc)) > cx->cvtsiz)
{
{
return -1;
}
}
if (n < 0)
return -1;
}
goto bad;
else
}
else
}
else if (cxisnumber(type) && var && cxisstring(from) && var->format.map && !cxstr2num(cx, &var->format, val.value.string.data, val.value.string.size, &m))
#if 0
goto bad;
#endif
else if (!type->internalf || (*type->internalf)(cx, type, format, var ? &var->format : (Cxformat_t*)0, ret, val.value.string.data, val.value.string.size, cx->em, cx->disc) < 0)
goto bad;
}
return 0;
bad:
if ((x.callout = cxcallout(cx, CX_CAST, ret->type, type, cx->disc)) && !(*x.callout)(cx, &x, ret, NiL, &val, NiL, cx->disc))
return 0;
return -1;
}
/*
* initialize the global state
*/
static void
{
register int i;
if (!state.initialized++)
{
{
goto panic;
}
for (i = 0; i < elementsof(types); i++)
{
goto panic;
}
for (i = 0; i < elementsof(callouts); i++)
goto panic;
for (i = 0; i < elementsof(builtins); i++)
goto panic;
for (i = 0; i < (sizeof(cx_alpha) - 1); i++)
for (i = 0; i < (sizeof(cx_digit) - 1); i++)
for (i = 0; i < (sizeof(cx_float) - 1); i++)
for (i = 0; i < (sizeof(cx_space) - 1); i++)
}
return;
}
/*
* return initialized global state pointer
*/
{
if (!state.initialized)
return &state;
}
/*
* return the input location (path,record,offset) or the empty string
*/
char*
{
char* s;
}
/*
* for when only a 0-terminated string will do
* copy n bytes of s to cvt buffer and 0-terminate it
* pointer to cvt buf returned
* data ok until the next cvtbuf() call
*/
char*
{
{
{
return (char*)s;
}
}
}