File: omi_prc_qry.c

package info (click to toggle)
fis-gtm 6.3-007-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 36,284 kB
  • sloc: ansic: 328,861; asm: 5,182; csh: 5,102; sh: 1,918; awk: 291; makefile: 69; sed: 13
file content (118 lines) | stat: -rwxr-xr-x 2,674 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/****************************************************************
 *								*
 * Copyright (c) 2001-2015 Fidelity National Information	*
 * Services, Inc. and/or its subsidiaries. All rights reserved.	*
 *								*
 *	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.	*
 *								*
 ****************************************************************/

/*
 *  omi_prc_qry.c ---
 *
 *	Process a QUERY request.
 *
 */

#ifndef lint
static char rcsid[] = "$Header:$";
#endif

#include "mdef.h"

#include "gtm_string.h"

#include "omi.h"
#include "error.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsroot.h"
#include "gdsbt.h"
#include "gdsfhead.h"
#include "op.h"
#include "gvsub2str.h"

GBLREF gv_key		*gv_altkey;

int
omi_prc_qry(omi_conn *cptr, char *xend, char *buff, char *bend)
{
    char	*bptr, *eptr;
    int		rv;
    omi_li	len;
    mval	v;
    mstr	opstr;
    uns_char	*bgn1, *bgn2, *sbsp;
    char	*grp;
    int		grl;

    bptr = buff;

/*  Global Ref */
    OMI_LI_READ(&len, cptr->xptr);
/*  Condition handler for DBMS operations */
    ESTABLISH_RET(omi_dbms_ch,0);
    rv = omi_gvextnam(cptr, len.value, cptr->xptr);
/*  If true, there was an error finding the global reference in the DBMS */
    if (rv < 0) {
	REVERT;
	return rv;
    }
    eptr        = cptr->xptr;
    cptr->xptr += len.value;

/*  Bounds checking */
    if (cptr->xptr > xend) {
	REVERT;
	return -OMI_ER_PR_INVMSGFMT;
    }

    op_gvquery(&v);

    REVERT;

    if (v.str.len == 0) {
	OMI_LI_WRIT(0, bptr);
	return (int)(bptr - buff);
    }

/*  Put a global reference into the reply */
    bgn1    = (uns_char *)bptr;
    bptr   += OMI_LI_SIZ;

/*  Environment (we give back the request environment) */
    OMI_LI_READ(&len, eptr);
    OMI_LI_WRIT(len.value, bptr);
    (void) memcpy(bptr, eptr, len.value);
    bptr   += len.value;

/*  Global name */
    bgn2    = (uns_char *)bptr++;
    *bptr++ = '^';
    grp     = (char *)gv_altkey->base;
    grl     = STRLEN(grp);
    OMI_SI_WRIT(grl + 1, bgn2);
    (void) strcpy(bptr, grp);
    bptr   += grl;

/*  Subscripts */
    for (grp += grl + 1; *grp; grp += strlen(grp) + 1) {
	bgn2   = (uns_char *)bptr++;
	opstr.addr = bptr;
	opstr.len = MAX_ZWR_KEY_SZ;
	sbsp   = gvsub2str((uchar_ptr_t)grp, &opstr, FALSE);
	grl    = (int)(sbsp - (uns_char *)bptr);
	OMI_SI_WRIT(grl, bgn2);
	bptr  += grl;
    }

/*  Length of the global reference */
    grl = (int)((uns_char *)bptr - bgn1);
    OMI_LI_WRIT(grl - OMI_LI_SIZ, bgn1);

    return (int)(bptr - buff);

}