2012-02-05 11:35:58 -05:00
|
|
|
/****************************************************************
|
|
|
|
* *
|
2012-10-29 18:54:31 -04:00
|
|
|
* Copyright 2001, 2012 Fidelity Information Services, Inc *
|
2012-02-05 11:35:58 -05:00
|
|
|
* *
|
|
|
|
* This source code contains the intellectual property *
|
|
|
|
* of its copyright holder(s), and is made available *
|
|
|
|
* under a license. If you do not know the terms of *
|
|
|
|
* the license, please stop and do not read further. *
|
|
|
|
* *
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include "mdef.h"
|
|
|
|
#include "gdsroot.h"
|
|
|
|
#include "gtm_facility.h"
|
|
|
|
#include "fileinfo.h"
|
|
|
|
#include "gdsbt.h"
|
|
|
|
#include "gdsfhead.h"
|
|
|
|
#include "stringpool.h"
|
|
|
|
#include "op.h"
|
|
|
|
#include "gvcst_protos.h" /* for gvcst_order prototype */
|
|
|
|
#include "gvsub2str.h"
|
|
|
|
#include "gvcmx.h"
|
|
|
|
#include "gvusr.h"
|
|
|
|
|
|
|
|
GBLREF gv_key *gv_altkey;
|
2012-10-29 18:54:31 -04:00
|
|
|
GBLREF gv_key *gv_currkey;
|
2012-02-05 11:35:58 -05:00
|
|
|
GBLREF gd_region *gv_cur_region;
|
2012-10-29 18:54:31 -04:00
|
|
|
GBLREF gv_namehead *gv_target;
|
|
|
|
GBLREF spdesc stringpool;
|
2012-02-05 11:35:58 -05:00
|
|
|
|
|
|
|
/****************** SHOULD BE IN .H FILES !!!!!!!! ***********************/
|
2012-10-29 18:54:31 -04:00
|
|
|
#define MAX_NUM_SLEN 128
|
2012-02-05 11:35:58 -05:00
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
void op_gvnext(mval *v)
|
|
|
|
{
|
|
|
|
boolean_t found;
|
|
|
|
enum db_acc_method acc_meth;
|
2012-10-29 18:54:31 -04:00
|
|
|
int4 n;
|
|
|
|
register char *c;
|
2012-02-05 11:35:58 -05:00
|
|
|
DCL_THREADGBL_ACCESS;
|
|
|
|
|
|
|
|
SETUP_THREADGBL_ACCESS;
|
|
|
|
acc_meth = gv_cur_region->dyn.addr->acc_meth;
|
|
|
|
/* if the lowest subscript is -1, then make it null */
|
2012-10-29 18:54:31 -04:00
|
|
|
if ((gv_currkey->end == gv_currkey->prev + 4)
|
|
|
|
&& *(gv_currkey->base + gv_currkey->prev) == 0x40
|
|
|
|
&& *(gv_currkey->base + gv_currkey->prev + 1) == 0xEE
|
|
|
|
&& *(gv_currkey->base + gv_currkey->prev + 2) == 0xFF)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
2012-10-29 18:54:31 -04:00
|
|
|
*(gv_currkey->base + gv_currkey->prev) = 01;
|
|
|
|
*(char *)(gv_currkey->base + gv_currkey->prev + 2) = KEY_DELIMITER;
|
2012-02-05 11:35:58 -05:00
|
|
|
if (0 == gv_cur_region->std_null_coll)
|
|
|
|
{
|
2012-10-29 18:54:31 -04:00
|
|
|
*(char *)(gv_currkey->base + gv_currkey->prev + 1) = KEY_DELIMITER;
|
2012-02-05 11:35:58 -05:00
|
|
|
gv_currkey->end -= 2;
|
|
|
|
} else
|
|
|
|
{
|
2012-10-29 18:54:31 -04:00
|
|
|
*(char *)(gv_currkey->base + gv_currkey->prev + 1) = 1;
|
|
|
|
*(char *)(gv_currkey->base + gv_currkey->prev + 3) = KEY_DELIMITER;
|
2012-02-05 11:35:58 -05:00
|
|
|
gv_currkey->end --;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
2012-10-29 18:54:31 -04:00
|
|
|
if (!TREF(gv_last_subsc_null) || gv_cur_region->std_null_coll)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
2012-10-29 18:54:31 -04:00
|
|
|
*(gv_currkey->base + gv_currkey->end - 1) = 1;
|
|
|
|
*(gv_currkey->base + gv_currkey->end + 1) = KEY_DELIMITER;
|
2012-02-05 11:35:58 -05:00
|
|
|
gv_currkey->end += 1;
|
|
|
|
} else
|
2012-10-29 18:54:31 -04:00
|
|
|
*(gv_currkey->base + gv_currkey->prev) = 01;
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
2012-10-29 18:54:31 -04:00
|
|
|
if ((acc_meth == dba_bg) || (acc_meth == dba_mm))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
if (gv_target->root)
|
|
|
|
found = gvcst_order();
|
|
|
|
else
|
|
|
|
found = FALSE; /* global does not exist */
|
|
|
|
} else if (acc_meth == dba_cm)
|
|
|
|
found = gvcmx_order();
|
|
|
|
else
|
|
|
|
found = gvusr_order();
|
2012-10-29 18:54:31 -04:00
|
|
|
v->mvtype = 0; /* so stp_gcol, if invoked below, can free up space currently occupied by this to-be-overwritten mval */
|
2012-02-05 11:35:58 -05:00
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
ENSURE_STP_FREE_SPACE(2);
|
|
|
|
c = v->str.addr = (char *) stringpool.free;
|
|
|
|
*c++ = '-';
|
|
|
|
*c = '1';
|
|
|
|
v->str.len = 2;
|
2012-10-29 18:54:31 -04:00
|
|
|
stringpool.free += 2;
|
|
|
|
|
2012-02-05 11:35:58 -05:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
gv_altkey->prev = gv_currkey->prev;
|
2012-10-29 18:54:31 -04:00
|
|
|
if (!IS_STP_SPACE_AVAILABLE(MAX_KEY_SZ + 1))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
if (*(&gv_altkey->base[0] + gv_altkey->prev) != 0xFF)
|
|
|
|
n = MAX_NUM_SLEN;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n = gv_altkey->top - gv_altkey->prev;
|
|
|
|
assert (n > 0);
|
|
|
|
}
|
|
|
|
ENSURE_STP_FREE_SPACE(n);
|
|
|
|
}
|
2012-10-29 18:54:31 -04:00
|
|
|
v->str.addr = (char *)stringpool.free;
|
2012-02-05 11:35:58 -05:00
|
|
|
c = (char *)(&gv_altkey->base[0] + gv_altkey->prev);
|
|
|
|
stringpool.free = gvsub2str ((uchar_ptr_t)c,stringpool.free, FALSE);
|
|
|
|
v->str.len = INTCAST(stringpool.free - (unsigned char *) v->str.addr);
|
|
|
|
assert (v->str.addr < (char *) stringpool.top && v->str.addr >= (char *) stringpool.base);
|
2012-10-29 18:54:31 -04:00
|
|
|
assert (v->str.addr + v->str.len <= (char *) stringpool.top
|
|
|
|
&& v->str.addr + v->str.len >= (char *) stringpool.base);
|
|
|
|
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
|
|
|
v->mvtype = MV_STR; /* initialize mvtype now that mval has been otherwise completely set up */
|
2012-10-29 18:54:31 -04:00
|
|
|
if ((2 == v->str.len) && ('-' == *v->str.addr) && ('1' == *(v->str.addr + 1)))
|
|
|
|
{ /* adjust so $REFERENCE would be correct */
|
|
|
|
gv_currkey->end = gv_currkey->prev;
|
|
|
|
*(gv_currkey->base + gv_currkey->end++) = 0x40;
|
|
|
|
*(gv_currkey->base + gv_currkey->end++) = 0xEE;
|
|
|
|
*(gv_currkey->base + gv_currkey->end++) = 0xFF;
|
|
|
|
*(gv_currkey->base + gv_currkey->end++) = KEY_DELIMITER;
|
|
|
|
*(gv_currkey->base + gv_currkey->end) = KEY_DELIMITER;
|
|
|
|
}
|
2012-02-05 11:35:58 -05:00
|
|
|
return;
|
|
|
|
}
|