/***********************************************************************
* *
* 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 *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
static const char usage[] =
"[+DESCRIPTION?The fix query generates a fixed binary flat schema from the"
" input file schema on the standard output. If the input schema is"
" variable width then the input file is used to estimate average and"
" maximum field widths. The generated schema may be used as input for"
" the \bflat\b method conversion query.]"
"[s:stamp?The identification date stamp.]:[stamp:=YYYY-MM-DD]"
;
#include <dsslib.h>
#include <tm.h>
#define FIELD_string 0
struct Field_s
{
int representation;
int flags;
};
struct State_s
{
char* stamp;
};
static int
{
return -1;
return 1;
return 1;
return -1;
}
extern Dsslib_t dss_lib_fix;
static int
{
char* s;
{
if (vm)
return -1;
}
goto bad;
for (;;)
{
{
case 's':
{
return -1;
}
continue;
case '?':
else
goto bad;
continue;
case ':':
else
goto bad;
continue;
}
break;
}
goto bad;
{
goto bad;
}
for (variable = (Cxvariable_t*)dtfirst(cx->fields); variable; variable = (Cxvariable_t*)dtnext(cx->fields, variable))
{
{
goto bad;
}
{
case CX_buffer:
break;
case CX_string:
break;
default:
break;
}
{
}
{
}
else
{
}
}
return 0;
bad:
return -1;
}
static int
{
{
return -1;
{
{
}
}
{
error(-1, "AHA fix_act %s.width %d arg.size %d", field->variable->name, field->width, arg.value.buffer.size);
}
}
return 0;
}
static int
{
register size_t w;
register size_t x;
register size_t r;
register size_t b;
char* s;
b = 0;
{
{
{
}
else
{
else
}
}
else
{
w = 8;
else if (w < (1<<15))
for (x = w, w = 1; w < x; w <<= 1);
else
{
b += w;
}
}
}
r = 0;
for (field = (Field_t*)dtfirst(state->fields); field; field = (Field_t*)dtnext(state->fields, field))
x = r;
if ((r += 2 * b) < 16)
r = 16;
else if (r < (1<<15))
for (w = r, r = 1; r < w; r <<= 1);
w--;
if (isdigit(*s))
w = 0;
for (lib = (Dsslib_t*)dtfirst(cx->state->libraries); lib; lib = (Dsslib_t*)dtnext(cx->state->libraries, lib))
{
w = 1;
}
if (!w)
for (field = (Field_t*)dtfirst(state->fields); field; field = (Field_t*)dtnext(state->fields, field))
{
switch (field->representation)
{
case FIELD_buffer:
break;
case FIELD_number:
else
break;
}
}
if (r > x)
{
sfprintf(expr->op, " <DESCRIPTION>%s</>\n", b ? "Variable width data heap." : "Fixed size roundup pad.");
}
return 0;
}
{
{
"fix",
"generate fixed binary schema from input schema",
CXH,
0,
},
{0}
};
{
"fix",
"fix query"
"[-1lms5P?\n@(#)$Id: dss fix query (AT&T Research) 2003-01-30 $\n]"
CXH,
0,
0,
0,
0,
0,
0,
&queries[0]
};