951 lines
24 KiB
C
951 lines
24 KiB
C
|
#ifndef h_getput
|
||
|
#define h_getput
|
||
|
/******************************************************************************
|
||
|
*
|
||
|
* Macro's used by the Run Machine to get & put DATUM's
|
||
|
*
|
||
|
* Module %M% Version %I% Date %H%
|
||
|
*
|
||
|
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
|
||
|
* This is unpublished proprietary source code of Ardent Software Inc.
|
||
|
* The copyright notice above does not evidence any actual or intented
|
||
|
* publication of such source code.
|
||
|
*
|
||
|
*******************************************************************************
|
||
|
*
|
||
|
* Maintenence log - insert most recent change descriptions at top
|
||
|
*
|
||
|
* Date.... GTAR# WHO Description.........................................
|
||
|
* 10/14/98 23801 SAP Change copyrights.
|
||
|
* 06/23/95 16666 MJC finish the job
|
||
|
* 06/22/95 16666 MJC replace fatal error number with define (for readability)
|
||
|
* 01/23/95 15607 WLG Re-worked SHM_DATUM_CHECK macro to allocate
|
||
|
* DATUMs in new structure contained in the Domain.
|
||
|
* 01/09/95 15607 DPB Fixed typo in SHM_DATUM_CHECK macro.
|
||
|
* 01/06/95 15607 WLG Added new macros for copying a datum from
|
||
|
* shared memory to local space for use in RM
|
||
|
* routines that use scd.
|
||
|
* 11/10/93 12531 TMC when returning an 0 set integer flag
|
||
|
* 08/02/93 10978 SHK Port to DEC AXP
|
||
|
* 07/13/93 11417 CSM Force casting on macro datum * arguments
|
||
|
* 06/25/93 11417 CSM Add new macros operating on datum addrs, for ODBC
|
||
|
* 06/17/93 11392 TMC Add RPC for uniVerse
|
||
|
* 01/04/93 10795 JWT add dynamic array caching primatives
|
||
|
* 01/02/93 10795 JWT Optimize out some relvar call overhead
|
||
|
* 12/05/91 8657 JSM changes for Tnull data type
|
||
|
* 12/04/91 7388 TMC change a select assignment to SELcpy
|
||
|
* 09/19/90 7472 JWT fix erro in G_math handling of non-numeric data
|
||
|
* 09/21/90 7312 JWT add proper integer support
|
||
|
* 10/24/89 6389 JWT allow Tsubrs to be referenced
|
||
|
* 08/18/89 5793 JWT basic SELECT to process one group at a time
|
||
|
* 07/08/89 6089 JWT fix COMMON core loss
|
||
|
*
|
||
|
*****************************************************************************/
|
||
|
|
||
|
#include "PROGRAM.h"
|
||
|
|
||
|
EXTERN STRING dtoa();
|
||
|
EXTERN int RAIDsymbol();
|
||
|
EXTERN void DATUMstore();
|
||
|
|
||
|
|
||
|
/*
|
||
|
|
||
|
SHM_DATUM_CHECK - handle the case where we have a DATUM
|
||
|
which is in shared memory and we are going to try to modify it.
|
||
|
|
||
|
We also check, on non-aligned machines to see if the string
|
||
|
pointed to by the DATUM is in shared memory. If it is, we copy
|
||
|
that to local user space too.
|
||
|
|
||
|
This macro is defined 4 times due to the conditional compilation
|
||
|
of OURMALLOC and ALIGN_OK. If OURMALLOC is available, then we
|
||
|
set Mnabort to trap an error during the malloc call. If
|
||
|
ALIGN_OK is set, then we don't have to worry about the string
|
||
|
the datum is pointing to because in that case, scd won't be
|
||
|
modifying the string. Otherwise, if ALIGN_OK is not set,
|
||
|
scd will be modifying the string, hence we make a copy of it.
|
||
|
|
||
|
*/
|
||
|
#if OURMALLOC
|
||
|
#if ALIGN_OK
|
||
|
|
||
|
#define SHM_DATUM_CHECK(check_datum, target, pc) \
|
||
|
if (prog->shmaddr && (check_datum > (DATUM *)Cshmseg) && \
|
||
|
(check_datum < (DATUM *)(Cshmseg + Cmemsize)))\
|
||
|
{\
|
||
|
SHMDATA *new;\
|
||
|
Mnabort = 1;\
|
||
|
new = (SHMDATA*)Rmalloc(sizeof(SHMDATA));\
|
||
|
Mnabort = 0;\
|
||
|
if (!new)\
|
||
|
{\
|
||
|
mwarning(AVAIL_MEM_EXCEEDED);\
|
||
|
RMreturn();\
|
||
|
}\
|
||
|
(void) memcpy((char *) &(new->localdatum), (char *)check_datum, sizeof(DATUM));\
|
||
|
new->next = Domain.datumlist;\
|
||
|
Domain.datumlist = new;\
|
||
|
Vartab[pc] = check_datum = &(new->localdatum);\
|
||
|
}
|
||
|
#else
|
||
|
|
||
|
#define SHM_DATUM_CHECK(check_datum, target, pc) \
|
||
|
if (prog->shmaddr && (check_datum > (DATUM *)Cshmseg) && \
|
||
|
(check_datum < (DATUM *)(Cshmseg + Cmemsize)))\
|
||
|
{\
|
||
|
SHMDATA *new;\
|
||
|
Mnabort = 1;\
|
||
|
new = (SHMDATA*)Rmalloc(sizeof(SHMDATA) + target.len);\
|
||
|
Mnabort = 0;\
|
||
|
if (!new)\
|
||
|
{\
|
||
|
mwarning(AVAIL_MEM_EXCEEDED);\
|
||
|
RMreturn();\
|
||
|
}\
|
||
|
(void) memcpy((char *) &(new->localdatum), (char *)check_datum, sizeof(DATUM));\
|
||
|
new->next = Domain.datumlist;\
|
||
|
Domain.datumlist = new;\
|
||
|
target.text = (char *)&(new->strloc);\
|
||
|
(void) memcpy((char *)target.text, \
|
||
|
(char *)check_datum->td_string.text, target.len);\
|
||
|
new->localdatum.td_string.text = target.text;\
|
||
|
Vartab[pc] = check_datum = &(new->localdatum);\
|
||
|
}
|
||
|
#endif
|
||
|
#else
|
||
|
#if ALIGN_OK
|
||
|
|
||
|
#define SHM_DATUM_CHECK(check_datum, target, pc) \
|
||
|
if (prog->shmaddr && (check_datum > (DATUM *)Cshmseg) && \
|
||
|
(check_datum < (DATUM *)(Cshmseg + Cmemsize)))\
|
||
|
{\
|
||
|
SHMDATA *new;\
|
||
|
new = (SHMDATA*)Rmalloc(sizeof(SHMDATA));\
|
||
|
if (!new)\
|
||
|
{\
|
||
|
mwarning(AVAIL_MEM_EXCEEDED);\
|
||
|
RMreturn();\
|
||
|
}\
|
||
|
(void) memcpy((char *) &(new->localdatum), (char *)check_datum, sizeof(DATUM));\
|
||
|
new->next = Domain.datumlist;\
|
||
|
Domain.datumlist = new;\
|
||
|
Vartab[pc] = check_datum = &(new->localdatum);\
|
||
|
}
|
||
|
|
||
|
#else
|
||
|
|
||
|
#define SHM_DATUM_CHECK(check_datum, target, pc) \
|
||
|
if (prog->shmaddr && (check_datum > (DATUM *)Cshmseg) && \
|
||
|
(check_datum < (DATUM *)(Cshmseg + Cmemsize)))\
|
||
|
{\
|
||
|
SHMDATA *new;\
|
||
|
new = (SHMDATA*)Rmalloc(sizeof(SHMDATA) + target.len);\
|
||
|
if (!new)\
|
||
|
{\
|
||
|
mwarning(AVAIL_MEM_EXCEEDED);\
|
||
|
RMreturn();\
|
||
|
}\
|
||
|
(void) memcpy((char *) &(new->localdatum), (char *)check_datum, sizeof(DATUM));\
|
||
|
new->next = Domain.datumlist;\
|
||
|
Domain.datumlist = new;\
|
||
|
target.text = (char *)&(new->strloc);\
|
||
|
(void) memcpy((char *)target.text, \
|
||
|
(char *)check_datum->td_string.text, target.len);\
|
||
|
new->localdatum.td_string.text = target.text;\
|
||
|
Vartab[pc] = check_datum = &(new->localdatum);\
|
||
|
}
|
||
|
#endif
|
||
|
#endif
|
||
|
|
||
|
#define G_DATUM(dest, addres) dest = Vartab[addres]
|
||
|
|
||
|
#define DATUM_GET(d, a) G_DATUM (d, (UVADDR)a)
|
||
|
|
||
|
#if gpflag
|
||
|
|
||
|
#define G_pint(dest, GPwrk)\
|
||
|
{ auto uchar *GPc;\
|
||
|
reg int GPt;\
|
||
|
auto STRING GPtstr;\
|
||
|
auto int ires;\
|
||
|
auto double fres;\
|
||
|
GPt = ((DATUM *)GPwrk)->td_type;\
|
||
|
if(GPt == Tint)\
|
||
|
dest = ((DATUM *)GPwrk)->td_integer;\
|
||
|
else\
|
||
|
if(GPt == Tnumber)\
|
||
|
dest = (int) ((DATUM *)GPwrk)->td_number;\
|
||
|
else\
|
||
|
if(GPt == Tstring)\
|
||
|
{ if(((DATUM *)GPwrk)->td_string.len)\
|
||
|
{ GPt = stfori(((DATUM *)GPwrk)->td_string, &ires, &fres, &GPc);\
|
||
|
if(GPc)\
|
||
|
{ warning(40025);\
|
||
|
dest = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if (GPt)\
|
||
|
dest = ires;\
|
||
|
else\
|
||
|
dest = (int) fres;\
|
||
|
}\
|
||
|
else\
|
||
|
dest = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tundef)\
|
||
|
{ undef_var(GPwrk, 0);\
|
||
|
dest = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tsubr)\
|
||
|
{ GPtstr = strtSTR(((DATUM *)GPwrk)->td_subr.prog->name);\
|
||
|
GPt = stfori(GPtstr, &ires, &fres, &GPc);\
|
||
|
if(GPc)\
|
||
|
{ warning(40025);\
|
||
|
dest = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if (GPt)\
|
||
|
dest = ires;\
|
||
|
else\
|
||
|
dest = (int) fres;\
|
||
|
}\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}
|
||
|
|
||
|
#define G_int(dest, addres)\
|
||
|
{ reg DATUM *DATUMptr;\
|
||
|
G_DATUM(DATUMptr, addres);\
|
||
|
G_pint(dest, DATUMptr);\
|
||
|
}
|
||
|
|
||
|
#define G_pnum(dest, GPwrk)\
|
||
|
{ auto uchar *GPc;\
|
||
|
reg int GPt;\
|
||
|
auto STRING GPtstr;\
|
||
|
auto int ires;\
|
||
|
GPt = ((DATUM *)GPwrk)->td_type;\
|
||
|
if(GPt == Tnumber)\
|
||
|
dest = ((DATUM *)GPwrk)->td_number;\
|
||
|
else\
|
||
|
if(GPt == Tint)\
|
||
|
dest = (double) ((DATUM *)GPwrk)->td_integer;\
|
||
|
else\
|
||
|
if(GPt == Tstring)\
|
||
|
{ if(((DATUM *)GPwrk)->td_string.len)\
|
||
|
{ GPt = stfori(((DATUM *)GPwrk)->td_string, &ires, &dest, &GPc);\
|
||
|
if(GPc)\
|
||
|
{ warning(40025);\
|
||
|
dest = 0.0;\
|
||
|
}\
|
||
|
else\
|
||
|
if (GPt)\
|
||
|
dest = (double) ires;\
|
||
|
}\
|
||
|
else\
|
||
|
dest = 0.0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tundef)\
|
||
|
{ undef_var(GPwrk, 0);\
|
||
|
dest = 0.0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tsubr)\
|
||
|
{ GPtstr = strtSTR(((DATUM *)GPwrk)->td_subr.prog->name);\
|
||
|
GPt = stfori(GPtstr, &ires, &dest, &GPc);\
|
||
|
if(GPc)\
|
||
|
{ warning(40025);\
|
||
|
dest = 0.0;\
|
||
|
}\
|
||
|
else\
|
||
|
if (GPt)\
|
||
|
dest = (double) ires;\
|
||
|
}\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}
|
||
|
|
||
|
#define G_num(dest, addres)\
|
||
|
{ reg DATUM *DATUMptr;\
|
||
|
G_DATUM(DATUMptr, addres);\
|
||
|
G_pnum(dest, DATUMptr);\
|
||
|
}
|
||
|
|
||
|
#define G_math(int_res_flag, int_val, flt_val, addres, nulflg)\
|
||
|
{ auto uchar *GPc;\
|
||
|
reg int GPt;\
|
||
|
reg DATUM *GPwrk;\
|
||
|
auto int ival;\
|
||
|
auto STRING GPtstr;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
nulflg = 0;\
|
||
|
GPt = GPwrk->td_type;\
|
||
|
if(GPt == Tint)\
|
||
|
{ int_res_flag = 1;\
|
||
|
int_val = GPwrk->td_integer;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tnumber)\
|
||
|
{ int_res_flag = 0;\
|
||
|
flt_val = GPwrk->td_number;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tstring)\
|
||
|
{ if(GPwrk->td_string.len)\
|
||
|
{ int_res_flag = stfori(GPwrk->td_string,\
|
||
|
&ival, &flt_val, &GPc);\
|
||
|
if(GPc)\
|
||
|
{ int_res_flag = 1;\
|
||
|
int_val = 0;\
|
||
|
warning(40025);\
|
||
|
}\
|
||
|
else\
|
||
|
int_val = ival;\
|
||
|
}\
|
||
|
else\
|
||
|
{ int_res_flag = 1;\
|
||
|
int_val = 0;\
|
||
|
}\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tundef)\
|
||
|
{ undef_var(GPwrk, 0);\
|
||
|
int_res_flag = 1;\
|
||
|
int_val = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tnull)\
|
||
|
{ nulflg = 1;\
|
||
|
int_res_flag = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tsubr)\
|
||
|
{ GPtstr = strtSTR(GPwrk->td_subr.prog->name);\
|
||
|
int_res_flag = stfori(GPtstr, &ival, &flt_val, &GPc);\
|
||
|
if(GPc)\
|
||
|
{ int_res_flag = 1;\
|
||
|
int_val = 0;\
|
||
|
warning(40025);\
|
||
|
}\
|
||
|
else\
|
||
|
int_val = ival;\
|
||
|
}\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}
|
||
|
|
||
|
#define G_bool(dest, addres, nulflg)\
|
||
|
{ auto uchar *GPstfd;\
|
||
|
reg int GPt;\
|
||
|
reg DATUM *GPwrk;\
|
||
|
auto STRING GPtstr;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
nulflg = 0;\
|
||
|
GPt = GPwrk->td_type;\
|
||
|
if(GPt == Tint)\
|
||
|
dest = GPwrk->td_integer;\
|
||
|
else\
|
||
|
if(GPt == Tnumber)\
|
||
|
{ if(GPwrk->td_number==0.0)\
|
||
|
dest = 0;\
|
||
|
else\
|
||
|
dest = 1;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tstring)\
|
||
|
{ double GPn;\
|
||
|
GPn = stf(GPwrk->td_string, &GPstfd);\
|
||
|
dest = (GPwrk->td_string.len&&((GPstfd!=0)||GPn));\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tundef)\
|
||
|
{ undef_var(GPwrk, 0);\
|
||
|
dest = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tnull)\
|
||
|
{ nulflg = 1;\
|
||
|
dest = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tsubr)\
|
||
|
{ GPtstr = strtSTR(GPwrk->td_subr.prog->name);\
|
||
|
dest = stf(GPtstr, &GPstfd);\
|
||
|
if(GPstfd)\
|
||
|
{ warning(40025);\
|
||
|
dest = 1;\
|
||
|
}\
|
||
|
}\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}
|
||
|
|
||
|
#define G_rstr(dest, addres, flag, reuseflg, nulflg)\
|
||
|
{ reg int GPt;\
|
||
|
reg DATUM *GPwrk;\
|
||
|
auto STRING GPtstr;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
nulflg = 0;\
|
||
|
GPt = GPwrk->td_type;\
|
||
|
if(GPt == Tstring)\
|
||
|
{ dest.text = GPwrk->td_string.text;\
|
||
|
dest.len = GPwrk->td_string.len;\
|
||
|
flag = 0;\
|
||
|
reuseflg = GPwrk->td_reuse;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tnumber)\
|
||
|
{ GPtstr = dtoa(GPwrk->td_number, Precision, 1, 1);\
|
||
|
dest.text = Rmalloc(GPtstr.len);\
|
||
|
(void) memcpy(dest.text, GPtstr.text, dest.len = GPtstr.len);\
|
||
|
flag = 1;\
|
||
|
reuseflg = GPwrk->td_reuse;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tint)\
|
||
|
{ GPtstr = itoa(GPwrk->td_integer);\
|
||
|
dest.text = Rmalloc(GPtstr.len);\
|
||
|
(void) memcpy(dest.text, GPtstr.text, dest.len = GPtstr.len);\
|
||
|
flag = 1;\
|
||
|
reuseflg = GPwrk->td_reuse;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tundef)\
|
||
|
{ undef_var(GPwrk, 1);\
|
||
|
dest.text = 0;\
|
||
|
dest.len = 0;\
|
||
|
flag = 0;\
|
||
|
reuseflg = GPwrk->td_reuse;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tnull)\
|
||
|
{ nulflg = 1;\
|
||
|
flag = 0;\
|
||
|
reuseflg = GPwrk->td_reuse;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tsubr)\
|
||
|
{ dest = strtSTR(GPwrk->td_subr.prog->name);\
|
||
|
flag = 1;\
|
||
|
reuseflg = GPwrk->td_reuse;\
|
||
|
}\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}
|
||
|
|
||
|
#define G_pstr(dest, GPwrk, flag, nulflg)\
|
||
|
{ reg int GPt;\
|
||
|
nulflg = 0;\
|
||
|
GPt = ((DATUM *)GPwrk)->td_type;\
|
||
|
if(GPt == Tstring)\
|
||
|
{ dest.text = ((DATUM *)GPwrk)->td_string.text;\
|
||
|
dest.len = ((DATUM *)GPwrk)->td_string.len;\
|
||
|
flag = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tnumber)\
|
||
|
{ STRING GPtemp;\
|
||
|
GPtemp = dtoa(((DATUM *)GPwrk)->td_number, Precision, 1, 1);\
|
||
|
dest.text = Rmalloc(GPtemp.len);\
|
||
|
(void) memcpy(dest.text, GPtemp.text, dest.len = GPtemp.len);\
|
||
|
flag = 1;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tint)\
|
||
|
{ STRING GPtemp;\
|
||
|
GPtemp = itoa(((DATUM *)GPwrk)->td_integer);\
|
||
|
dest.text = Rmalloc(GPtemp.len);\
|
||
|
(void) memcpy(dest.text, GPtemp.text, dest.len = GPtemp.len);\
|
||
|
flag = 1;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tundef)\
|
||
|
{ undef_var(GPwrk, 1);\
|
||
|
dest.text = 0;\
|
||
|
dest.len = 0;\
|
||
|
flag = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tnull)\
|
||
|
{ nulflg = 1;\
|
||
|
flag = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tsubr)\
|
||
|
{ dest = strtSTR(((DATUM *)GPwrk)->td_subr.prog->name);\
|
||
|
flag = 1;\
|
||
|
}\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}
|
||
|
|
||
|
#define G_str(dest, addres, flag, nulflg)\
|
||
|
{ reg DATUM *DATUMptr;\
|
||
|
G_DATUM(DATUMptr, addres);\
|
||
|
G_pstr(dest, DATUMptr, flag, nulflg);\
|
||
|
}
|
||
|
|
||
|
#define G_ptstr(dest, datump, nulflg)\
|
||
|
{ reg int GPt;\
|
||
|
reg DATUM *GPwrk=datump;\
|
||
|
nulflg = 0;\
|
||
|
GPt = GPwrk->td_type;\
|
||
|
if(GPt == Tstring)\
|
||
|
{ dest.text = Rmalloc(GPwrk->td_string.len);\
|
||
|
(void) memcpy(dest.text, GPwrk->td_string.text, dest.len = GPwrk->td_string.len);\
|
||
|
}\
|
||
|
else\
|
||
|
{ if(GPt == Tnumber)\
|
||
|
{ STRING GPtemp;\
|
||
|
GPtemp = dtoa(GPwrk->td_number, Precision, 1, 1);\
|
||
|
dest.text = Rmalloc(GPtemp.len);\
|
||
|
(void) memcpy(dest.text, GPtemp.text, dest.len = GPtemp.len);\
|
||
|
}else\
|
||
|
if(GPt == Tint)\
|
||
|
{ STRING GPtemp;\
|
||
|
GPtemp = itoa(GPwrk->td_integer);\
|
||
|
dest.text = Rmalloc(GPtemp.len);\
|
||
|
(void) memcpy(dest.text, GPtemp.text, dest.len = GPtemp.len);\
|
||
|
}else\
|
||
|
{ if(GPt == Tundef)\
|
||
|
{ undef_var(GPwrk, 1);\
|
||
|
dest.text = Rmalloc(1);\
|
||
|
dest.len = 0;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tnull)\
|
||
|
{ nulflg = 1;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPt == Tsubr)\
|
||
|
dest = strtSTR(GPwrk->td_subr.prog->name);\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}\
|
||
|
}\
|
||
|
}
|
||
|
|
||
|
#define G_tstr(dest, addres, nulflg)\
|
||
|
{ reg DATUM *DATUMptr;\
|
||
|
G_DATUM(DATUMptr, addres);\
|
||
|
G_ptstr(dest, DATUMptr, nulflg);\
|
||
|
}
|
||
|
|
||
|
|
||
|
#define G_file(dest, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
if(GPwrk->td_type == Tfile)\
|
||
|
dest = GPwrk->td_dbfile;\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}
|
||
|
|
||
|
#define G_seq(dest, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
if(GPwrk->td_type == Tsfile)\
|
||
|
dest = GPwrk->td_seqfile;\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}
|
||
|
|
||
|
#define G_odbc(dest, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
if(GPwrk->td_type == Todbc)\
|
||
|
dest = GPwrk->td_odbc;\
|
||
|
else\
|
||
|
fatal(40022);\
|
||
|
}
|
||
|
|
||
|
/************************************************************************
|
||
|
* *
|
||
|
************************************************************************/
|
||
|
|
||
|
#define P_pint(srce, GPwrk)\
|
||
|
{ reg int GPtemp = srce;\
|
||
|
if (((DATUM *)GPwrk)->td_type != Tint)\
|
||
|
{ rel_var(GPwrk);\
|
||
|
((DATUM *)GPwrk)->td_type = Tint;\
|
||
|
}\
|
||
|
((DATUM *)GPwrk)->td_integer = GPtemp;\
|
||
|
}
|
||
|
|
||
|
#define P_int(srce, addres)\
|
||
|
{ reg DATUM *DATUMptr;\
|
||
|
G_DATUM(DATUMptr, addres);\
|
||
|
P_pint(srce, DATUMptr);\
|
||
|
}
|
||
|
|
||
|
#define P_tDATUM(srce, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
reg DATUM *GPtemp = srce;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
rel_var(GPwrk);\
|
||
|
*GPwrk = *GPtemp;\
|
||
|
MMAP_DATUM(GPwrk, prog->name);\
|
||
|
}
|
||
|
|
||
|
#define P_pDATUM(srce, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
reg DATUM *GPtemp = srce;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
rel_var(GPwrk);\
|
||
|
DATUMstore(GPtemp, GPwrk);\
|
||
|
MMAP_DATUM(GPwrk, prog->name);\
|
||
|
}
|
||
|
|
||
|
#define P_rDATUM(srce, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
reg DATUM *GPtemp = srce;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
if (GPwrk != GPtemp)\
|
||
|
{ rel_var(GPwrk);\
|
||
|
switch (GPtemp->td_type)\
|
||
|
{\
|
||
|
case Tnumber:\
|
||
|
case Tint:\
|
||
|
*GPwrk = *GPtemp;\
|
||
|
break;\
|
||
|
case Tstring: \
|
||
|
if( !GPtemp->td_temp)\
|
||
|
{ GPwrk->td_string =\
|
||
|
GPtemp->td_string;\
|
||
|
GPwrk->td_lastfield =\
|
||
|
GPtemp->td_lastfield;\
|
||
|
GPwrk->td_lastfptr =\
|
||
|
GPtemp->td_lastfptr;\
|
||
|
GPwrk->td_temp = 0;\
|
||
|
GPwrk->td_remove=0;\
|
||
|
}\
|
||
|
else\
|
||
|
{ GPwrk->td_string.text =\
|
||
|
Rmalloc(GPtemp->td_string.len);\
|
||
|
(void) memcpy(GPwrk->td_string.text,\
|
||
|
GPtemp->td_string.text,\
|
||
|
GPwrk->td_string.len =\
|
||
|
GPtemp->td_string.len);\
|
||
|
GPwrk->td_lastfield =\
|
||
|
GPtemp->td_lastfield;\
|
||
|
if (GPtemp->td_lastfptr != (uchar*)0)\
|
||
|
GPwrk->td_lastfptr = \
|
||
|
GPwrk->td_string.text +\
|
||
|
(GPtemp->td_lastfptr -\
|
||
|
GPtemp->td_string.text);\
|
||
|
else\
|
||
|
GPwrk->td_lastfptr = 0;\
|
||
|
GPwrk->td_temp = 1;\
|
||
|
GPwrk->td_remove=0;\
|
||
|
}\
|
||
|
GPwrk->td_type = Tstring;\
|
||
|
break;\
|
||
|
case Tfile:\
|
||
|
*GPwrk = *GPtemp;\
|
||
|
GPwrk->td_dbfile->refs++;\
|
||
|
break;\
|
||
|
case Tundef:\
|
||
|
GPwrk->td_type = Tundef;\
|
||
|
break;\
|
||
|
case Tnull:\
|
||
|
GPwrk->td_type = Tnull;\
|
||
|
break;\
|
||
|
case Todbc:\
|
||
|
*GPwrk = *GPtemp;\
|
||
|
ODaddsyn(GPwrk->td_odbc,GPwrk);\
|
||
|
break;\
|
||
|
default:\
|
||
|
fatal(40014);\
|
||
|
}\
|
||
|
}\
|
||
|
GPwrk->td_reuse = 1;\
|
||
|
MMAP_DATUM(GPwrk, prog->name);\
|
||
|
};
|
||
|
|
||
|
#define P_pstr(srce, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
auto uchar *GPtstr;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
if (GPwrk->td_type != Tstring)\
|
||
|
{ GPtstr = Rmalloc(srce.len);\
|
||
|
(void) memcpy(GPtstr,srce.text,srce.len);\
|
||
|
rel_var(GPwrk);\
|
||
|
GPwrk->td_type = Tstring;\
|
||
|
}\
|
||
|
else\
|
||
|
{ if (GPwrk->td_temp)\
|
||
|
{ if (srce.len <= GPwrk->td_string.len)\
|
||
|
{ GPtstr = GPwrk->td_string.text;\
|
||
|
(void) memcpy(GPtstr,srce.text,srce.len);\
|
||
|
GPtstr = Rrealloc(GPtstr, srce.len);\
|
||
|
}\
|
||
|
else\
|
||
|
{ GPtstr = Rrealloc(GPwrk->td_string.text,\
|
||
|
srce.len);\
|
||
|
(void) memcpy(GPtstr,srce.text,srce.len);\
|
||
|
}\
|
||
|
}\
|
||
|
else\
|
||
|
{ GPtstr = Rmalloc(srce.len);\
|
||
|
(void) memcpy(GPtstr,srce.text,srce.len);\
|
||
|
}\
|
||
|
}\
|
||
|
GPwrk->td_string.text = GPtstr;\
|
||
|
GPwrk->td_string.len = srce.len;\
|
||
|
GPwrk->td_reuse = 0;\
|
||
|
GPwrk->td_temp = 1;\
|
||
|
GPwrk->td_remove = 0;\
|
||
|
GPwrk->td_lastfield = 0;\
|
||
|
GPwrk->td_lastfptr = (uchar *)0;\
|
||
|
MMAP_STRING(&GPwrk->td_string, prog->name);\
|
||
|
}
|
||
|
|
||
|
#define P_ptstr(srce, datump)\
|
||
|
{ STRING GPans;\
|
||
|
reg DATUM *GPwrk=datump;\
|
||
|
GPans = srce;\
|
||
|
if (GPwrk->td_type != Tstring)\
|
||
|
{ rel_var(GPwrk);\
|
||
|
GPwrk->td_type = Tstring;\
|
||
|
}\
|
||
|
else\
|
||
|
if(GPwrk->td_temp)\
|
||
|
Rfree(GPwrk->td_string.text);\
|
||
|
GPwrk->td_string = GPans;\
|
||
|
GPwrk->td_temp = 1;\
|
||
|
GPwrk->td_reuse = 0;\
|
||
|
GPwrk->td_remove = 0;\
|
||
|
GPwrk->td_lastfield = 0;\
|
||
|
GPwrk->td_lastfptr = (uchar *)0;\
|
||
|
MMAP_STRING(&GPans, prog->name);\
|
||
|
}
|
||
|
|
||
|
#define P_tstr(srce, addres)\
|
||
|
{ reg DATUM *DATUMptr;\
|
||
|
G_DATUM(DATUMptr, addres);\
|
||
|
P_ptstr(srce, DATUMptr);\
|
||
|
}
|
||
|
|
||
|
#define P_xstr(srce, GPwrk)\
|
||
|
{ auto uchar *GPtstr;\
|
||
|
if (((DATUM*)GPwrk)->td_type != Tstring)\
|
||
|
{ GPtstr = Rmalloc(srce.len);\
|
||
|
(void) memcpy(GPtstr,srce.text,srce.len);\
|
||
|
rel_var((DATUM*)GPwrk);\
|
||
|
((DATUM*)GPwrk)->td_type = Tstring;\
|
||
|
}\
|
||
|
else\
|
||
|
{ if (((DATUM*)GPwrk)->td_temp)\
|
||
|
{ if (srce.len <= ((DATUM*)GPwrk)->td_string.len)\
|
||
|
{ GPtstr = ((DATUM*)GPwrk)->td_string.text;\
|
||
|
(void) memcpy(GPtstr,srce.text,srce.len);\
|
||
|
GPtstr = Rrealloc(GPtstr, srce.len);\
|
||
|
}\
|
||
|
else\
|
||
|
{ GPtstr = Rrealloc(((DATUM*)GPwrk)->td_string.text,\
|
||
|
srce.len);\
|
||
|
(void) memcpy(GPtstr,srce.text,srce.len);\
|
||
|
}\
|
||
|
}\
|
||
|
else\
|
||
|
{ GPtstr = Rmalloc(srce.len);\
|
||
|
(void) memcpy(GPtstr,srce.text,srce.len);\
|
||
|
}\
|
||
|
}\
|
||
|
((DATUM*)GPwrk)->td_string.text = GPtstr;\
|
||
|
((DATUM*)GPwrk)->td_string.len = srce.len;\
|
||
|
((DATUM*)GPwrk)->td_reuse = 0;\
|
||
|
((DATUM*)GPwrk)->td_temp = 1;\
|
||
|
((DATUM*)GPwrk)->td_remove = 0;\
|
||
|
((DATUM*)GPwrk)->td_lastfield = 0;\
|
||
|
((DATUM*)GPwrk)->td_lastfptr = (uchar *)0;\
|
||
|
MMAP_STRING(&((DATUM*)GPwrk)->td_string, prog->name);\
|
||
|
}
|
||
|
|
||
|
#define P_pnum(srce, GPwrk)\
|
||
|
{ auto double GPtemp = srce;\
|
||
|
if (GPwrk->td_type != Tnumber)\
|
||
|
{ rel_var(GPwrk);\
|
||
|
GPwrk->td_type = Tnumber;\
|
||
|
}\
|
||
|
GPwrk->td_number = GPtemp;\
|
||
|
GPwrk->td_reuse = 0;\
|
||
|
}
|
||
|
|
||
|
#define P_num(srce, addres)\
|
||
|
{ reg DATUM *DATUMptr;\
|
||
|
G_DATUM(DATUMptr, addres);\
|
||
|
P_pnum(srce, DATUMptr);\
|
||
|
}
|
||
|
|
||
|
#define P_file(srce, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
reg DBFILE *GPtemp = srce;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
rel_var(GPwrk);\
|
||
|
GPwrk->td_type = Tfile;\
|
||
|
GPwrk->td_dbfile = GPtemp;\
|
||
|
GPwrk->td_reuse = 0;\
|
||
|
MMAP_DBFILE(GPtemp, prog->name);\
|
||
|
}
|
||
|
|
||
|
#define P_seq(srce, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
reg SEQFILE *GPtemp = srce;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
rel_var(GPwrk);\
|
||
|
GPwrk->td_type = Tsfile;\
|
||
|
GPwrk->td_seqfile = GPtemp;\
|
||
|
GPwrk->td_reuse = 0;\
|
||
|
MMAP_SEQFILE(GPtemp, prog->name);\
|
||
|
}
|
||
|
|
||
|
/* Above needs:
|
||
|
MMAP(GPtemp, MM_SEQFILE, prog->name);\
|
||
|
*/
|
||
|
#define P_sel( srce, addres )\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
reg SELFILE *GPtemp = srce;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
rel_var(GPwrk);\
|
||
|
GPwrk->td_type = Tselect;\
|
||
|
GPwrk->td_selfile = (SELFILE*)Rmalloc(sizeof(SELFILE));\
|
||
|
SELcpy(GPwrk->td_selfile, GPtemp);\
|
||
|
GPwrk->td_reuse = 0;\
|
||
|
MMAP_SELFILE(GPtemp, prog->name);\
|
||
|
}
|
||
|
|
||
|
#define P_pnul(srce, GPwrk)\
|
||
|
{ if ((GPwrk)->td_type != Tnull)\
|
||
|
{ rel_var(GPwrk);\
|
||
|
(GPwrk)->td_type = Tnull;\
|
||
|
}\
|
||
|
}
|
||
|
|
||
|
#define P_nul(srce, addres)\
|
||
|
{ reg DATUM *DATUMptr;\
|
||
|
srce = srce;\
|
||
|
G_DATUM(DATUMptr, addres);\
|
||
|
P_pnul(srce, DATUMptr);\
|
||
|
}
|
||
|
|
||
|
#define P_odbc(srce, addres)\
|
||
|
{ reg DATUM *GPwrk;\
|
||
|
reg char *GPtemp = srce;\
|
||
|
G_DATUM(GPwrk, addres);\
|
||
|
rel_var(GPwrk);\
|
||
|
GPwrk->td_type = Todbc;\
|
||
|
GPwrk->td_odbc = GPtemp;\
|
||
|
GPwrk->td_reuse = 0;\
|
||
|
}
|
||
|
|
||
|
|
||
|
/************************************************************************
|
||
|
* *
|
||
|
* *_PGET(), *_PPUT and XSTR_PUT macros operate on datum addresses *
|
||
|
* *
|
||
|
************************************************************************/
|
||
|
|
||
|
#define BOOL_GET(d, a ,n) G_bool (d, (UVADDR)a, n)
|
||
|
#define FILE_GET(d, a) G_file (d, (UVADDR)a)
|
||
|
#define FILE_PUT(s, a) P_file (s, (UVADDR)a)
|
||
|
#define INT_GET(d, a) G_int (d, (UVADDR)a)
|
||
|
#define INT_PUT(s, a) P_int (s, (UVADDR)a)
|
||
|
#define NUM_GET(d, a) G_num (d, (UVADDR)a)
|
||
|
#define NUM_PUT(s, a) P_num (s, (UVADDR)a)
|
||
|
#define MATH_GET(f, i, d, a, n) G_math (f, i, d, (UVADDR)a, n)
|
||
|
#define PDATUM_PUT(s, a) P_pDATUM(s, (UVADDR)a)
|
||
|
#define PSTR_PUT(s, a) P_pstr (s, (UVADDR)a)
|
||
|
#define RDATUM_PUT(s, a) P_rDATUM(s, (UVADDR)a)
|
||
|
#define RSTR_GET(d, a, f, r, n) G_rstr (d, (UVADDR)a, f, r, n)
|
||
|
#define SEL_PUT(s, a) P_sel (s, (UVADDR)a)
|
||
|
#define SEQ_GET(d, a) G_seq (d, (UVADDR)a)
|
||
|
#define SEQ_PUT(s, a) P_seq (s, (UVADDR)a)
|
||
|
#define STR_GET(d, a, f, n) G_str (d, (UVADDR)a, f, n)
|
||
|
#define TDATUM_PUT(s, a) P_tDATUM(s, (UVADDR)a)
|
||
|
#define TSTR_GET(d, a, n) G_tstr (d, (UVADDR)a, n)
|
||
|
#define TSTR_PUT(s, a) P_tstr (s, (UVADDR)a)
|
||
|
#define XSTR_PUT(s, a) P_xstr (s, (UVADDR)a)
|
||
|
#define NUL_PUT(x, a) P_nul (x, (UVADDR)a)
|
||
|
#define INT_PGET(d, p) G_pint (d, p)
|
||
|
#define INT_PPUT(s, p) P_pint (s, p)
|
||
|
#define NUM_PGET(d, p) G_pnum (d, p)
|
||
|
#define NUM_PPUT(s, p) P_pnum (s, p)
|
||
|
#define STR_PGET(d, p, f, n) G_pstr (d, p, f, n)
|
||
|
#define TSTR_PGET(d, p, n) G_ptstr (d, (DATUM *)p, n)
|
||
|
#define TSTR_PPUT(s, p) P_ptstr (s, (DATUM *)p)
|
||
|
#define NUL_PPUT(x, p) P_pnul (x, (DATUM *)p)
|
||
|
#define ODBC_GET(d, a) G_odbc (d, (UVADDR)a)
|
||
|
#define ODBC_PUT(s, a) P_odbc (s, (UVADDR)a)
|
||
|
|
||
|
#else
|
||
|
#define BOOL_GET(d, a, n) d = FG_bool ((UVADDR)a, &n)
|
||
|
#define FILE_GET(d, a) d = FG_file ((UVADDR)a)
|
||
|
#define FILE_PUT(s, a) FP_file (s, (UVADDR)a)
|
||
|
#define INT_GET(d, a) d = FG_int ((UVADDR)a)
|
||
|
#define INT_PUT(s, a) FP_int (s, (UVADDR)a)
|
||
|
#define NUM_GET(d, a) d = FG_num ((UVADDR)a)
|
||
|
#define NUM_PUT(s, a) FP_num (s, (UVADDR)a)
|
||
|
#define MATH_GET(f, i, d, a, n) f = FG_math(&i, &d, (UVADDR)a, &n)
|
||
|
#define PDATUM_PUT(s, a) FP_pDATUM (s, (UVADDR)a)
|
||
|
#define PSTR_PUT(s, a) FP_pstr (s, (UVADDR)a)
|
||
|
#define RDATUM_PUT(s, a) FP_rDATUM (s, (UVADDR)a)
|
||
|
#define RSTR_GET(d, a, f, r, n) d = FG_rstr ((UVADDR)a, &f, &r, &n)
|
||
|
#define SEL_PUT(s, a) FP_sel (s, (UVADDR)a)
|
||
|
#define SEQ_GET(d, a) d = FG_seq ((UVADDR)a)
|
||
|
#define SEQ_PUT(s, a) FP_seq (s, (UVADDR)a)
|
||
|
#define STR_GET(d, a, f, n) d = FG_str ((UVADDR)a, &f, &n)
|
||
|
#define TDATUM_PUT(s, a) FP_tDATUM (s, (UVADDR)a)
|
||
|
#define TSTR_GET(d, a, n) d = FG_tstr ((UVADDR)a, &n)
|
||
|
#define TSTR_PUT(s, a) FP_tstr (s, (UVADDR)a)
|
||
|
#define XSTR_PUT(s, a) FP_xstr (s, (UVADDR)a)
|
||
|
#define NUL_PUT(x, a) FP_nul (x, (UVADDR)a)
|
||
|
#define INT_PGET(d, p) d = FG_pint (p)
|
||
|
#define INT_PPUT(s, p) FP_pint (s, p)
|
||
|
#define NUM_PGET(d, p) d = FG_pnum (p)
|
||
|
#define NUM_PPUT(s, p) FP_pnum (s, p)
|
||
|
#define STR_PGET(d, p, f, n) d = FG_pstr (p, &f, &n)
|
||
|
#define TSTR_PGET(d, p, n) d = FG_ptstr ((DATUM *)p, &n)
|
||
|
#define TSTR_PPUT(s, p) FP_ptstr (s, (DATUM *)p)
|
||
|
#define NUL_PPUT(x, p) FP_pnul (x, (DATUM *)p)
|
||
|
#define ODBC_GET(d, a) d = FG_odbc ((UVADDR)a)
|
||
|
#define ODBC_PUT(s, a) FP_odbc (s, (UVADDR)a)
|
||
|
|
||
|
#endif
|
||
|
EXTERN DATUM *FG_DATUM();
|
||
|
EXTERN DBFILE *FG_file();
|
||
|
EXTERN SEQFILE *FG_seq();
|
||
|
EXTERN STRING FG_rstr(),
|
||
|
FG_str(),
|
||
|
FG_tstr(),
|
||
|
FG_ptstr(),
|
||
|
FG_pstr();
|
||
|
EXTERN double FG_num(), FG_pnum();
|
||
|
EXTERN int FG_bool(),
|
||
|
FG_pint(),
|
||
|
FG_int();
|
||
|
EXTERN char *FG_odbc();
|
||
|
EXTERN void FP_file(),
|
||
|
FP_int(),
|
||
|
FP_num(),
|
||
|
FP_pDATUM(),
|
||
|
FP_pstr(),
|
||
|
FP_rDATUM(),
|
||
|
FP_sel(),
|
||
|
FP_seq(),
|
||
|
FP_tDATUM(),
|
||
|
FP_tstr(),
|
||
|
FP_xstr(),
|
||
|
FP_nul(),
|
||
|
FP_pint(),
|
||
|
FP_pnum(),
|
||
|
FP_ptstr(),
|
||
|
FP_pnul(),
|
||
|
FP_odbc();
|
||
|
|
||
|
#endif /* end of getput.h */
|