/***********************************************************************
* *
* 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
/*
* ibm dfsort control file parser and library support
*/
#include <ast.h>
#include <error.h>
#include <ccode.h>
#include <ctype.h>
#include <dlldefs.h>
#include <ls.h>
#ifndef DEBUG_TRACE
#define DEBUG_TRACE 0
#endif
#define _SS_PRIVATE_ \
char* xsum; \
unsigned char* n2a; \
unsigned char* n2e; \
char* data; \
char* peek; \
char* peekpeek; \
int ch; \
int item; \
int part; \
char acex[16]; \
char chex[16]; \
#define _SS_FILE_PRIVATE_ \
#define _SS_GROUP_PRIVATE_ \
unsigned char* beg; \
unsigned char* cur; \
unsigned char* end;
#include <ss.h>
struct Dd_s
{
char* id;
char* alt;
char* name;
};
static struct State_s
{
} state;
/*
* bcd_pack[x] is bcd byte for 0<=x<=99
*/
static const unsigned char bcd_pack[] =
{
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,
0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,
0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,
};
/*
* bcd_unit[x] is bcd units (last byte with no sign) byte for 0<=x<=9
*/
static const unsigned char bcd_unit[] =
{
0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,
};
/*
* bcd_unpack[x] is the binary value for bcd byte x
* invalid codes convert to 0
*/
static const unsigned char bcd_unpack[] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
10,11,12,13,14,15,16,17,18,19, 0, 0, 1, 1, 0, 0,
20,21,22,23,24,25,26,27,28,29, 0, 0, 2, 2, 0, 0,
30,31,32,33,34,35,36,37,38,39, 0, 0, 3, 3, 0, 0,
40,41,42,43,44,45,46,47,48,49, 0, 0, 4, 4, 0, 0,
50,51,52,53,54,55,56,57,58,59, 0, 0, 5, 5, 0, 0,
60,61,62,63,64,65,66,67,68,69, 0, 0, 6, 6, 0, 0,
70,71,72,73,74,75,76,77,78,79, 0, 0, 7, 7, 0, 0,
80,81,82,83,84,85,86,87,88,89, 0, 0, 8, 8, 0, 0,
90,91,92,93,94,95,96,97,98,99, 0, 0, 9, 9, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
/*
* bcd_negative[x]!=0 if bcd sign is negative
*/
static const unsigned char bcd_negative[] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
};
/*
* common syntax error message
*/
static void
{
{
if (s)
else
}
}
/*
* push back one token
*/
/*
* return the next token
*/
static char*
{
register char* s;
register char* t;
register int q;
{
#if DEBUG_TRACE
#endif
return s;
}
for (;;)
{
{
case ',':
continue;
case ' ':
case '\t':
case '\r':
{
continue;
}
/*FALLTHROUGH*/
case '*':
case 0:
{
#if DEBUG_TRACE
#endif
return SC;
}
do
{
{
return 0;
}
error_info.line++;
if (q > 72)
#if DEBUG_TRACE
#endif
continue;
}
break;
}
q = 0;
for (;;)
{
{
case 0:
return s;
case '=':
if (!q)
{
{
return EQ;
}
break;
}
continue;
case ':':
if (!q)
{
{
return CO;
}
break;
}
continue;
case '(':
if (!q)
{
{
return OP;
}
break;
}
continue;
case ')':
if (!q)
{
{
return CP;
}
break;
}
continue;
case ',':
if (!q)
{
break;
}
continue;
case ' ':
case '\t':
case '\r':
if (!q)
break;
continue;
case '\'':
{
*t = *(t - 1);
}
else
q = !q;
continue;
default:
continue;
}
break;
}
#if DEBUG_TRACE
#endif
return s;
}
/*
* return the first variable value token
* '=' and '(' if (flags&LEX_GROUP) are eaten
*/
static char*
{
register char* s;
{
return 0;
}
/* apparently accepted by dfsort */;
{
{
if (s)
(*ss->disc->errorf)(NiL, ss->disc, 2, "%s: %svalue expected", s, (flags & LEX_GROUP) ? "group " : null);
else
}
return 0;
}
return s;
}
/*
* return the type in s
*/
static int
{
int n;
{
n = SS_ascii;
break;
n = SS_AC_dec;
break;
n = SS_AC_hex;
break;
n = SS_AC_oct;
break;
n = SS_AC_alt;
break;
n = SS_bit;
break;
break;
break;
n = SS_zd;
break;
break;
break;
n = SS_be;
break;
n = SS_le;
break;
n = SS_bcd;
break;
n = SS_ss;
break;
default:
if (silent)
n = 0;
break;
}
return n;
}
/*
* set the ch codeset to n
*/
static void
{
register char* s;
register int c;
if (!n)
n = CC_EBCDIC_O;
for (n = 0, s = "0123456789"; *s; s++, n++)
{
}
for (n = 10, s = "abcdef"; *s; s++, n++)
{
}
for (n = 10, s = "ABCDEF"; *s; s++, n++)
{
}
}
/*
* eat the remainder of a =(...) value
*/
static int
{
register char* s;
{
if (s == CP)
return 0;
if (s == SC)
{
return 0;
}
}
return -1;
}
/*
* parse a field tuple list
* (flags & LEX_JOIN) collapses adjacent fields
* zp!=0 is set to the total size
*/
static Ssfield_t*
{
register char* s;
register char* v;
char* e;
unsigned char* map;
size_t n;
size_t z;
int a;
int c;
int x;
return 0;
{
return 0;
}
z = 0;
if (s == OP)
{
goto msg;
if (isdigit(*s))
{
a = tuple;
do
{
if (s == CO)
a = 0;
else
{
{
if (!bp)
{
dp = 0;
}
else if ((flags & LEX_JOIN) && (ep->offset + ep->size) == dp->offset && !dp->value && !ep->value && dp->reverse == ep->reverse)
else
{
dp = 0;
}
{
return 0;
}
a = 1;
}
switch (a)
{
case 1:
case 2:
{
return 0;
}
{
return 0;
}
{
return 0;
}
else
{
n = strtoul(s, &e, 10);
if (((x = toupper(*e)) == 'A' || x == 'B' || x == 'C' || x == 'X') && *(e + 1) == '\'' && *(v = e + strlen(e) - 1) == '\'')
{
s = e + 2;
e = v;
c = e - s;
if (!n)
n = 1;
{
return 0;
}
if (x == 'B')
{
}
else if (x == 'X')
{
}
else
{
}
while (--n)
a = 2;
}
else if ((x == 'X' || x == 'Z') && !*(e + 1))
{
if (x == 'X')
c = ' ';
else
c = 0;
if (!n)
n = 1;
{
return 0;
}
while (n--)
a = 2;
}
else
{
switch (a)
{
case 1:
break;
case 2:
break;
}
if (*e)
{
return 0;
}
}
}
break;
case 3:
if (tuple != 3)
{
tuple = 3;
break;
else
return 0;
tuple = 3;
}
/*FALLTHROUGH*/
case 4:
switch (*s)
{
case 'a':
case 'A':
break;
case 'd':
case 'D':
break;
default:
return 0;
}
}
}
goto msg;
} while (s != CP);
}
{
goto msg;
return 0;
}
else
}
if (!bp)
else if ((flags & LEX_JOIN) && (ep->offset + ep->size) == dp->offset && !dp->value && !ep->value && dp->reverse == ep->reverse)
else
if (zp)
*zp = z;
return bp;
msg:
return 0;
}
/*
* parse a field option list
*/
static int
{
register char* s;
char* e;
int n;
if (dp)
*dp = 0;
{
if (s == SC)
break;
;
{
return -1;
if ((n = ccmapid(s)) < 0)
{
return -1;
}
}
else if (streq(s, "COPY"))
{
if (!fp)
goto msg;
}
else if (streq(s, "EQUALS"))
else if (streq(s, "NOEQUALS"))
else if (streq(s, "FIELDS"))
{
return -1;
}
else if (streq(s, "FORMAT"))
{
return -1;
}
else if (streq(s, "FTOV"))
{
if (!fp)
goto msg;
}
else if (streq(s, "LENGTH"))
{
return -1;
goto msg;
if (*e)
{
return -1;
}
return -1;
}
else if (streq(s, "TYPE"))
{
return -1;
switch (*(e = s))
{
case 'd':
case 'D':
e++;
break;
case 'f':
case 'F':
e++;
break;
case 'v':
case 'V':
if (*++e == 'b' || *e == 'B')
{
e++;
}
else
break;
}
if (*e)
{
return -1;
}
}
else if (streq(s, "SIZE"))
{
return -1;
}
else if (streq(s, "SKIPREC"))
{
return -1;
if (*e)
{
return -1;
}
}
else if (streq(s, "STOPAFT"))
{
return -1;
if (*e)
{
return -1;
}
}
}
return 0;
msg:
return -1;
}
/*
* return the next expression operand
*/
static Ssexpr_t*
{
register char* s;
register char* v;
char* e;
unsigned char* map;
int c;
{
return 0;
}
else if (s == OP)
{
return 0;
{
return 0;
}
}
{
return 0;
}
else if (streq(s, "NOT"))
{
return 0;
}
{
return 0;
}
else
{
if (isdigit(*s))
{
if (*e)
{
{
if (lp)
else
}
return 0;
}
{
return 0;
}
if (isdigit(*s))
{
if (*e)
{
return 0;
}
{
return 0;
}
}
else
{
if (lp)
{
}
}
}
{
e = s + strlen(s) - 1;
if (*e != '\'' || *(e + 1))
{
return 0;
}
s += 2;
{
return 0;
}
}
else if (c == 'X' && *(s + 1) == '\'')
{
e = s + strlen(s) - 1;
if (*e != '\'')
{
return 0;
}
s += 2;
{
return 0;
}
}
else if (c == 'B' && *(s + 1) == '\'')
{
e = s + strlen(s) - 1;
if (*e != '\'')
{
return 0;
}
s += 2;
{
return 0;
}
}
else
{
return 0;
}
}
return xp;
}
/*
* compile an expression or subexpression
*/
static Ssexpr_t*
{
register char* s;
int op;
int pr;
return 0;
for (;;)
{
#if DEBUG_TRACE
sfprintf(sfstderr, "compile(%d) ", precedence); listexpr(ss, sfstderr, xp); sfprintf(sfstderr, "\n");
#endif
{
if (precedence)
break;
}
else if (s == CP)
{
break;
}
else
{
if (streq(s, "AND"))
{
pr = 4;
}
else if (streq(s, "OR"))
{
pr = 3;
}
else if (streq(s, "EQ"))
{
pr = 8;
}
else if (streq(s, "NE"))
{
pr = 8;
}
else if (streq(s, "LT"))
{
pr = 8;
}
else if (streq(s, "LE"))
{
pr = 8;
}
else if (streq(s, "GE"))
{
pr = 8;
}
else if (streq(s, "GT"))
{
pr = 8;
}
else
{
return 0;
}
if (precedence >= pr)
{
break;
}
{
return 0;
{
return 0;
}
}
{
return 0;
}
return 0;
{
return 0;
}
{
return 0;
}
}
}
return xp;
}
/*
* finalize constant values
* set default operand types
* migrate easy operands left
*/
static int
{
register char* s;
register char* v;
register long n;
{
case SS_OP_false:
case SS_OP_true:
return 0;
case SS_OP_and:
case SS_OP_or:
{
}
return -1;
/*FALLTHROUGH*/
case SS_OP_not:
}
{
{
return -1;
}
{
case SS_bcd:
if (n < 0)
{
n = -n;
*s = 0x0D;
}
else
*s = 0x0C;
*s |= bcd_unit[n % 10];
n /= 10;
while (s-- > v)
{
*s = bcd_pack[n % 100];
n /= 100;
}
break;
case SS_be:
do
{
*s = n & 0xFF;
n >>= 8;
} while (s-- > v);
break;
case SS_le:
do
{
*v = n & 0xFF;
n >>= 8;
} while (v++ < s);
break;
case SS_zd:
if (n < 0)
{
n = -n;
*s = 0xD0;
}
else
*s = 0xC0;
*s |= n % 10;
n /= 10;
while (s-- > v)
{
*s = n % 10;
n /= 10;
}
break;
case 0:
/*FALLTHROUGH*/
default:
return -1;
}
}
return 0;
}
/*
* parse a conditional expression
*/
static Ssexpr_t*
{
register char* s;
int n;
return 0;
else if (streq(s, "ALL"))
{
{
return 0;
}
}
else if (streq(s, "NONE"))
{
{
return 0;
}
}
else if (s != OP)
{
return 0;
}
return 0;
{
return 0;
}
{
if (!streq(s, "FORMAT"))
{
n = SS_be;
}
return 0;
return 0;
}
return xp;
}
/*
* add a file group member to the circular group list
*/
static int
{
{
return -1;
}
else
return 0;
}
/*
* load user exit usr function fun from library lib
*/
static int
{
int i;
char* e;
char* s;
char* t;
void* dll;
for (i = 0; i < elementsof(sys); i++)
break;
if (!dll)
{
{
s = e;
while (*s)
{
while (isspace(*s))
s++;
t = s;
while (*s && !isspace(*s))
s++;
if (*s)
*s++ = 0;
if (*t)
{
for (i = 0; i < elementsof(sys); i++)
break;
if (dll)
break;
}
}
free(e);
}
if (!dll)
{
return -1;
}
}
{
return -1;
}
if ((interceptf = (Ssintercept_f)dlllook(dll, "rs_intercept")) || (interceptf = (Ssintercept_f)dlllook(NiL, "rs_intercept")))
{
case 11:
case 21:
case 31:
break;
case 14:
case 15:
case 16:
break;
case 25:
case 32:
case 35:
break;
case 17:
case 27:
case 37:
case 38:
case 39:
break;
default:
return -1;
}
return 0;
}
/*
* open a handle to the control file and parse it
*/
Ss_t*
{
register char* s;
char* ofile;
int oline;
int n;
{
return 0;
}
{
return 0;
}
{
goto bad;
}
{
file = 0;
}
{
goto bad;
}
error_info.line = 0;
{
if (s == SC)
;
else if (streq(s, "ALTSEQ"))
{
{
if (s == SC)
break;
else if (streq(s, "CODE"))
{
goto bad;
{
if (s == SC)
goto msg;
else if (s == CP)
break;
}
}
else
goto msg;
}
}
else if (streq(s, "END"))
break;
{
goto bad;
}
else if (streq(s, "INREC"))
{
goto bad;
}
else if (streq(s, "MODS"))
{
{
if (s == SC)
break;
{
usr[0] = s;
goto bad;
n = 1;
{
if (s == SC)
goto msg;
else if (s == CP)
break;
else if (n < elementsof(usr))
usr[n++] = s;
}
if (n != 4)
goto msg;
goto bad;
}
else
goto msg;
}
}
else if (streq(s, "OPTION"))
{
{
if (s == SC)
break;
else if (streq(s, "EQUALS"))
else if (streq(s, "NOEQUALS"))
else
goto msg;
}
}
else if (streq(s, "OUTFIL"))
{
{
goto bad;
}
{
if (s == SC)
break;
{
goto bad;
if (s == OP)
{
goto bad;
if (s != CP)
goto msg;
}
goto bad;
}
{
goto bad;
}
else if (streq(s, "OUTREC"))
{
goto bad;
}
else if (streq(s, "SAVE"))
else
goto msg;
}
{
goto bad;
}
}
else if (streq(s, "OUTREC"))
{
goto bad;
}
else if (streq(s, "RECORD"))
{
goto bad;
}
{
goto bad;
}
else if (streq(s, "SUM"))
{
{
if (s == SC)
break;
else if (streq(s, "FIELDS"))
{
}
else if (streq(s, "FORMAT"))
{
goto bad;
}
else if (streq(s, "XSUM"))
{
if ((s = getenv(SS_DD_XSUM)) && *s)
}
else
goto msg;
}
}
else if (s[0] == '/' && (s[1] == '*' || s[1] == '/' && s[2] == '*'))
{
/*
* kosher comment?
*/
}
else
goto msg;
}
goto bad;
return ss;
msg:
bad:
return 0;
}
/*
* return sort(1) key for dp
* dp==0 returns the fixed record key
* 0 return means no key, no error
*/
char*
{
char* s;
if (dp)
{
{
case SS_bcd:
break;
case SS_zd:
break;
case SS_AC_dec:
case SS_AC_oct:
case SS_AC_hex:
case SS_CH_dec:
case SS_CH_oct:
case SS_CH_hex:
break;
case SS_AC_flt:
case SS_CH_flt:
break;
}
}
else
return 0;
return s;
}
static const char* opname[] =
{
"FALSE",
"TRUE",
"FIELD",
"VALUE",
"<",
"<=",
"==",
"!=",
">=",
">",
"&&",
"||",
"!",
};
/*
* list an expression
*/
static void
{
register unsigned char* s;
register unsigned char* e;
if (xp)
{
case SS_OP_field:
break;
case SS_OP_value:
break;
case SS_OP_not:
break;
default:
break;
}
}
/*
* list a field list
*/
static void
{
register unsigned char* v;
register unsigned char* e;
if (dp)
{
do
{
{
}
}
}
/*
* list file info
*/
static void
{
do
{
{
}
}
/*
* list all control file info
*/
int
{
char* s;
{
}
{
}
{
}
}
/*
* copy <buf,bsize> to <out,osize> according to fp->out
* if return value > osize then copy not done but
* subsequent call with osize >= return value will work
*/
{
register unsigned char* s;
register unsigned char* t;
int v;
{
v = 0;
return rsize;
}
return rsize;
else
{
t = (unsigned char*)out + v;
do
{
{
case 7: *t++ = *s++;
case 6: *t++ = *s++;
case 5: *t++ = *s++;
case 4: *t++ = *s++;
case 3: *t++ = *s++;
case 2: *t++ = *s++;
case 1: *t++ = *s++;
break;
default:
break;
}
}
if (v)
{
t = (unsigned char*)out;
*t++ = rsize&0xff;
*t++ = 0;
*t = 0;
}
return rsize;
}
/*
* write buf according to <fp->out,fp->size>
*/
{
register unsigned char* s;
register unsigned char* t;
size_t v;
size_t r;
ssize_t z;
else if (fp->format == SS_V_IBM && (size < 4 || (t = (unsigned char*)buf)[2] == 0 && t[3] == 0 && ((t[0]<<8)|t[1]) == size))
v = 0;
r = size + v;
{
{
return -1;
}
{
z = r;
{
return -1;
}
}
}
if (dp)
{
do
{
{
case 7: *t++ = *s++;
case 6: *t++ = *s++;
case 5: *t++ = *s++;
case 4: *t++ = *s++;
case 3: *t++ = *s++;
case 2: *t++ = *s++;
case 1: *t++ = *s++;
break;
default:
break;
}
}
else
{
t += size;
}
if (v)
{
r = t - s;
*s++ = (r>>8)&0xff;
*s++ = (r)&0xff;
*s++ = 0;
*s = 0;
}
return size;
}
/*
* sum buf into out according to field list dp
*/
int
{
register unsigned char* s;
register unsigned char* se;
register unsigned char* t;
register unsigned char* te;
register intmax_t n;
register int i;
register int j;
do
{
{
case SS_bcd:
{
{
j -= 10;
i = 1;
}
else
i = 0;
while (te-- > t)
{
se--;
{
j -= 100;
i = 1;
}
else
i = 0;
}
}
else
{
{
j += 10;
i = 1;
}
else
i = 0;
while (se-- > s)
{
te--;
{
j += 100;
i = 1;
}
else
i = 0;
}
if (i)
{
if ((j = (int)0 - (int)bcd_unpack[*te]) < 0)
{
j += 10;
i = 1;
}
else
i = 0;
while (te-- > t)
{
if ((j = (int)0 - (int)bcd_unpack[*te] - i) < 0)
{
j += 100;
i = 1;
}
else
i = 0;
}
}
}
break;
case SS_be:
n = 0;
n = (n << 8) + s[i] + t[i];
{
t[i] = (n & 0xFF);
n >>= 8;
}
break;
case SS_le:
n = 0;
n = (n << 8) + s[i] + t[i];
{
t[i] = (n & 0xFF);
n >>= 8;
}
break;
case SS_zd:
{
{
j += 10;
i = 1;
}
else
i = 0;
while (se-- > s)
{
te--;
{
j += 10;
i = 1;
}
else
i = 0;
*te = 0xF0 | j;
}
if (i)
{
if ((j = (int)0 - (int)(*te & 0x0F)) < 0)
{
j += 10;
i = 1;
}
else
i = 0;
while (te-- > t)
{
if ((j = (int)0 - (int)(*te & 0x0F) - i) < 0)
{
j += 10;
i = 1;
}
else
i = 0;
*te = 0xF0 | j;
}
}
}
else
{
{
j -= 10;
i = 1;
}
else
i = 0;
while (te-- > t)
{
se--;
{
j -= 10;
i = 1;
}
else
i = 0;
*te = 0xF0 | j;
}
}
break;
case SS_AC_dec:
n = 0;
while (i-- > 0)
{
n /= 10;
}
break;
case SS_AC_oct:
n = 0;
while (i-- > 0)
{
n >>= 3;
}
break;
case SS_AC_hex:
n = 0;
while (i-- > 0)
{
n >>= 4;
}
break;
case SS_CH_dec:
n = 0;
while (i-- > 0)
{
n /= 10;
}
break;
case SS_CH_oct:
n = 0;
while (i-- > 0)
{
n >>= 3;
}
break;
case SS_CH_hex:
n = 0;
while (i-- > 0)
{
n >>= 4;
}
break;
default:
return -1;
}
{
return -1;
}
return 0;
}
/*
* evaluate expression xp on buf
*/
int
{
register unsigned char* a;
register unsigned char* b;
register unsigned char* e;
register int r;
{
case SS_OP_false:
return 0;
case SS_OP_true:
return 1;
case SS_OP_not:
case SS_OP_and:
case SS_OP_or:
}
a = xp->left.expr->left.field->value ? (unsigned char*)xp->left.expr->left.field->value : ((unsigned char*)buf + xp->left.expr->left.field->offset);
b = xp->right.expr->left.field->value ? (unsigned char*)xp->right.expr->left.field->value : ((unsigned char*)buf + xp->right.expr->left.field->offset);
while (a < e && !(r = (int)*a++ - (int)*b++));
{
case SS_OP_lt:
return r < 0;
case SS_OP_le:
return r <= 0;
case SS_OP_eq:
return r == 0;
case SS_OP_ne:
return r != 0;
case SS_OP_ge:
return r >= 0;
case SS_OP_gt:
return r > 0;
}
return 0;
}
int
{
{
return -1;
}
return 0;
}
/*
* initialize io to active files
*/
int
{
register char* s;
register int n;
char* e;
{
}
{
do
{
{
{
{
(*ss->disc->errorf)(NiL, ss->disc, 2, "%s: auxiliary file %s already named %s", dd->name, gp->id, gp->name);
return -1;
}
break;
}
{
{
{
else
}
{
else
}
}
{
return -1;
}
{
(*ss->disc->errorf)(NiL, ss->disc, ERROR_SYSTEM|2, "%s: cannot write auxiliary file %s", gp->name, gp->id);
return -1;
}
}
if (dd)
{
if (pd)
else
}
}
{
}
{
n++;
if (pg)
else
}
if (pg)
}
{
n = -1;
do
{
} while (dd);
}
{
n = -1;
}
return n;
}
/*
* announce ss io to recsort
*/
int
{
{
do
{
{
return -1;
if (pg)
else
}
if (pg)
}
return -1;
return 0;
}
/*
* close handle ss
*/
int
{
ssize_t z;
int r;
if (!ss)
return -1;
r = 0;
do
{
if (gp->io && ((z = gp->cur - gp->beg) >= 0 && sfwrite(gp->io, gp->beg, z) != z || ((fp == ss->file || gp->io == sfstdout) ? sfsync(gp->io) : sfclose(gp->io))))
{
r = -1;
}
{
return -1;
}
return r;
}