int omi_prc_set(omi_conn *cptr, char *xend, char *buff, char *bend) { int rv; omi_si replicate; omi_li li; mval v; /* Replicate flag */ OMI_SI_READ(&replicate, cptr->xptr); /* Global Ref */ OMI_LI_READ(&li, cptr->xptr); /* Condition handler for DBMS operations */ ESTABLISH_RET(omi_dbms_ch,0); rv = omi_gvextnam(cptr, li.value, cptr->xptr); /* If true, there was an error finding the global reference in the DBMS */ if (rv < 0) { REVERT; return rv; } cptr->xptr += li.value; /* Bounds checking */ if (cptr->xptr > xend) { REVERT; return -OMI_ER_PR_INVMSGFMT; } /* Global Data */ OMI_LI_READ(&li, cptr->xptr); v.mvtype = MV_STR; v.str.len = li.value; v.str.addr = cptr->xptr; op_gvput(&v); REVERT; cptr->xptr += li.value; /* Bounds checking */ if (cptr->xptr > xend) return -OMI_ER_PR_INVMSGFMT; /* The response contains only a header */ return 0; }
int omi_prc_rord(omi_conn *cptr, char *xend, char *buff, char *bend) { char *bptr; int rv; omi_li len; mval v; 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; } cptr->xptr += len.value; /* Bounds checking */ if (cptr->xptr > xend) { REVERT; return -OMI_ER_PR_INVMSGFMT; } op_zprevious(&v); REVERT; if (v.str.len > 255) return -OMI_ER_DB_UNRECOVER; OMI_SI_WRIT(v.str.len, bptr); if (v.str.len) { memcpy(bptr, v.str.addr, v.str.len); bptr += v.str.len; } return (int)(bptr - buff); }
int omi_prc_qry(omi_conn *cptr, char *xend, char *buff, char *bend) { char *bptr, *eptr; int rv; omi_li len; mval v; 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 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++; sbsp = gvsub2str((uchar_ptr_t)grp, (uchar_ptr_t)bptr, FALSE); grl = sbsp - (uns_char *)bptr; OMI_SI_WRIT(grl, bgn2); bptr += grl; sbsp += grl + 1; } /* Length of the global reference */ grl = (uns_char *)bptr - bgn1; OMI_LI_WRIT(grl - OMI_LI_SIZ, bgn1); return bptr - buff; }
int omi_prc_def(omi_conn *cptr, char *xend, char *buff, char *bend) { GBLREF bool undef_inhibit; char *bptr; omi_li len; int rv; mval vo, vd, vg; bptr = buff; /* Global Ref */ OMI_LI_READ(&len, cptr->xptr); /* Set up a condition handler */ 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; } cptr->xptr += len.value; /* Bounds checking */ if (cptr->xptr > xend) { REVERT; return -OMI_ER_PR_INVMSGFMT; } /* We want to make sure there is plenty of space in the string pool * for all three operations ($ORDER, $GET, $DATA) */ if (cptr->exts & OMI_XTF_NEWOP) stp_gcol(0); /* $DATA */ op_gvdata(&vd); if (!(vd.mvtype & MV_INT)) { REVERT; return -OMI_ER_DB_UNRECOVER; } if (cptr->exts & OMI_XTF_NEWOP) { /* $GET */ undef_inhibit = TRUE; rv = op_gvget(&vg); /* $ORDER */ op_gvorder(&vo); OMI_SI_WRIT(vo.str.len, bptr); if (vo.str.len) { memcpy(bptr, vo.str.addr, vo.str.len); bptr += vo.str.len; } } /* $DATA (buffer write) */ OMI_SI_WRIT(vd.m[1] / MV_BIAS, bptr); if (cptr->exts & OMI_XTF_NEWOP) { /* $GET (buffer write) */ OMI_SI_WRIT((rv ? 1 : 0), bptr); if (!rv || !vg.str.len) OMI_LI_WRIT(0, bptr); else { OMI_LI_WRIT(vg.str.len, bptr); memcpy(bptr, vg.str.addr, vg.str.len); bptr += vg.str.len; } } REVERT; return (int)(bptr - buff); }
int omi_prc_ordr(omi_conn *cptr, char *xend, char *buff, char *bend) { char *bptr; int rv; omi_li len; mval vo, vd, vg; DCL_THREADGBL_ACCESS; SETUP_THREADGBL_ACCESS; 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; } cptr->xptr += len.value; /* Bounds checking */ if (cptr->xptr > xend) { REVERT; return -OMI_ER_PR_INVMSGFMT; } /* We want to make sure there is plenty of space in the string pool for all three operations ($ORDER, $GET, $DATA) */ if (cptr->exts & OMI_XTF_NEWOP) INVOKE_STP_GCOL(0); /* $ORDER */ op_gvorder(&vo); /* $ORDER (buffer write) */ OMI_SI_WRIT(vo.str.len, bptr); if (vo.str.len) { memcpy(bptr, vo.str.addr, vo.str.len); bptr += vo.str.len; } /* Bunching */ if (cptr->exts & OMI_XTF_NEWOP) { if (vo.str.len) { if (!gv_currkey->prev) { if (*vo.str.addr != '^') { REVERT; return -OMI_ER_PR_INVGLOBREF; } vo.str.addr++; vo.str.len--; GV_BIND_NAME_AND_ROOT_SEARCH(cptr->ga, &vo.str); vo.str.addr--; vo.str.len++; TREF(gv_last_subsc_null) = FALSE; } else { if (gv_currkey->top != gv_altkey->top) { REVERT return -OMI_ER_DB_UNRECOVER; } memcpy(gv_currkey, gv_altkey, gv_altkey->end + SIZEOF(gv_key)); TREF(gv_last_subsc_null) = FALSE; } /* $DATA */ op_gvdata(&vd); if (!(vd.mvtype & MV_INT)) { REVERT; return -OMI_ER_DB_UNRECOVER; } /* $GET */ undef_inhibit = TRUE; rv = op_gvget(&vg); /* $DATA (buffer write) */ OMI_SI_WRIT(vd.m[1] / MV_BIAS, bptr); /* $GET (buffer write) */ OMI_SI_WRIT((rv ? 1 : 0), bptr); if (!rv || !vg.str.len) OMI_LI_WRIT(0, bptr); else { OMI_LI_WRIT(vg.str.len, bptr); memcpy(bptr, vg.str.addr, vg.str.len); bptr += vg.str.len; } } else { /* Otherwise $ORDER returned a null */