Tang Cheng | 37650ea | 2014-10-20 16:14:41 +0800 | [diff] [blame^] | 1 | /* Copyright (c) 2003, 2011, Oracle and/or its affiliates. |
| 2 | All rights reserved. */ |
| 3 | |
| 4 | /* |
| 5 | NAME |
| 6 | ocixmldb.h - XDB public functions |
| 7 | |
| 8 | DESCRIPTION |
| 9 | This file contains XDB specific public functions required for DOM C-API. |
| 10 | |
| 11 | RELATED DOCUMENTS |
| 12 | |
| 13 | |
| 14 | EXPORT FUNCTION(S) |
| 15 | struct xmlctx *OCIXmlDbInitXmlCtx(OCIEnv *, OCISvcCtx *, OCIError *, |
| 16 | ocixmldbparam *params, int num_params); |
| 17 | |
| 18 | void OCIXmlDbFreeXmlCtx(struct xmlctx *xctx); |
| 19 | |
| 20 | |
| 21 | ------------------------------------------------------------------------ |
| 22 | EXAMPLES |
| 23 | |
| 24 | NOTES |
| 25 | |
| 26 | MODIFIED (MM/DD/YY) |
| 27 | srirkris 06/15/11 - Add OCIXmlDr_DEF |
| 28 | srirkris 06/07/11 - Backport srirkris_bug-12613945 from main |
| 29 | srirkris 04/26/11 - Backport srirkris_xmlop_bnd from main |
| 30 | srirkris 04/14/11 - Backport srirkris_xqupd_repl from main |
| 31 | yifeng 02/15/11 - Backport yifeng_bug-10236275 from main |
| 32 | srirkris 03/01/11 - OCIXmlDbRewriteXMLDiff definition change |
| 33 | vmedi 01/14/11 - OCIXmlDbGetFullyQualifiedSchemaUrl |
| 34 | sipatel 03/08/10 - add lob arg to OCIXmlDbRewriteXMLDiff |
| 35 | samane 01/20/10 - Bug 9302227 |
| 36 | yifeng 11/05/09 - add OCIXmlDbRewriteXMLDiff |
| 37 | samane 08/05/09 - Bug 8661204 |
| 38 | ataracha 12/11/03 - remove redundant definitions |
| 39 | ataracha 05/28/03 - change names |
| 40 | ataracha 02/18/03 - add oratypes, remove XMLERR_* |
| 41 | imacky 02/01/03 - remove xml.h; xdbs fix |
| 42 | ataracha 01/24/03 - use "struct xmlctx" instead of xmlctx |
| 43 | imacky 01/28/03 - fix XMLERR defs |
| 44 | ataracha 01/21/03 - ataracha_uni_capi_cleanup |
| 45 | ataracha 01/09/03 - Creation |
| 46 | |
| 47 | */ |
| 48 | |
| 49 | #ifndef ORATYPES |
| 50 | #include <oratypes.h> |
| 51 | #endif |
| 52 | |
| 53 | #ifndef OCI_ORACLE |
| 54 | # include <oci.h> |
| 55 | #endif |
| 56 | |
| 57 | #ifndef OCIXMLDB_ORACLE |
| 58 | # define OCIXMLDB_ORACLE |
| 59 | |
| 60 | /*--------------------------------------------------------------------------- |
| 61 | PUBLIC TYPES AND CONSTANTS |
| 62 | ---------------------------------------------------------------------------*/ |
| 63 | |
| 64 | #ifndef XMLCTX_DEFINED |
| 65 | # define XMLCTX_DEFINED |
| 66 | /* DATATYPE xmlctx - XML top-level context |
| 67 | */ |
| 68 | struct xmlctx; typedef struct xmlctx xmlctx; |
| 69 | #endif |
| 70 | |
| 71 | |
| 72 | typedef struct OCIXmlDiffBnd { |
| 73 | oratext *bndnmp; |
| 74 | ub1 bndnml; |
| 75 | ub2 bndpos; |
| 76 | ub2 bndnum; |
| 77 | ub2 bnddty; |
| 78 | void *bndvalp; |
| 79 | ub4 bndvallen; |
| 80 | } OCIXmlDiffBnd; |
| 81 | |
| 82 | struct xmldrctx; typedef struct xmldrctx xmldrctx; |
| 83 | |
| 84 | typedef enum |
| 85 | { |
| 86 | XCTXINIT_OCIDUR = 1, |
| 87 | XCTXINIT_ERRHDL = 2 |
| 88 | } ocixmldbpname; |
| 89 | |
| 90 | typedef struct ocixmldbparam |
| 91 | { |
| 92 | ocixmldbpname name_ocixmldbparam; |
| 93 | void *value_ocixmldbparam; |
| 94 | } ocixmldbparam; |
| 95 | |
| 96 | #define NUM_OCIXMLDBPARAMS 2 |
| 97 | |
| 98 | #define OCIXMLDB_BINDBYNAME 1 |
| 99 | #define OCIXMLDB_BINDBYNUM 2 |
| 100 | |
| 101 | #define OCIMAXXQUBNDLMT 1000 |
| 102 | |
| 103 | #define OCIXmlDr_DEF 1 |
| 104 | |
| 105 | |
| 106 | /*--------------------------------------------------------------------------- |
| 107 | PRIVATE TYPES AND CONSTANTS |
| 108 | ---------------------------------------------------------------------------*/ |
| 109 | |
| 110 | |
| 111 | /*--------------------------------------------------------------------------- |
| 112 | EXPORT FUNCTIONS |
| 113 | ---------------------------------------------------------------------------*/ |
| 114 | /***************************************************************************** |
| 115 | DESCRIPTION |
| 116 | |
| 117 | -----------------------------OCIXmlDbInitXmlCtx--------------------------------- |
| 118 | Name |
| 119 | OCIXmlDbInitXmlCtx |
| 120 | Purpose |
| 121 | To get a xmlctx structure initialized with error-handler and XDB callbacks. |
| 122 | Syntax |
| 123 | struct xmlctx *OCIXmlDbInitXmlCtx (OCIEnv *envhp, |
| 124 | OCISvcCtx *svchp, |
| 125 | OCIError *err, |
| 126 | params_ocixmldb *params, |
| 127 | int num_params); |
| 128 | Parameters |
| 129 | envhp (IN) - The OCI environment handle |
| 130 | svchp (IN) - The OCI service handle |
| 131 | errhp (IN) - The OCI error handle |
| 132 | params (IN)- This contains the following optional parameters : |
| 133 | (a) OCIDuration dur (IN - The OCI Duration (Default: OCI_DURATION_SESSION) |
| 134 | (b) void (*err_handler) (sword, (const oratext *) (IN) - |
| 135 | Pointer to the error handling function (Default: null) |
| 136 | num_params (IN) - Number of parameters to be read from parameter params. |
| 137 | If the value of num_params exceeds the size of array |
| 138 | "params", unexpected behavior will result. |
| 139 | |
| 140 | Returns |
| 141 | A pointer to xmlctx structure, with xdb context, error handler and callbacks |
| 142 | populated with appropriate values. This is later used for all API calls. NULL |
| 143 | if no database connection available. |
| 144 | |
| 145 | -----------------------------OCIXmlDbFreeXmlCtx---------------------------- |
| 146 | Name |
| 147 | OCIXmlDbFreeXmlCtx |
| 148 | Pupose |
| 149 | To free any allocations done during OCIXmlDbInitXmlCtx. |
| 150 | Syntax |
| 151 | void OCIXmlDbFreeXmlCtx (struct xmlctx *xctx) |
| 152 | Parameters |
| 153 | xctx (IN) - The xmlctx to terminate |
| 154 | Returns |
| 155 | - |
| 156 | ------------------------OCIXmlDbOrastreamFromLob--------------------------- |
| 157 | Name |
| 158 | OCIXmlDbOrastreamFromLob |
| 159 | Pupose |
| 160 | To create an orastream from a lob. This orastream can be used by functions like XMLLoadDom(). |
| 161 | Syntax |
| 162 | sword OCIXmlDbOrastreamFromLob(OCIError *errhp, xmlctx *xctx, |
| 163 | void **stream, OCILobLocator *lobloc) |
| 164 | Parameters |
| 165 | envhp (IN) - The OCI environment handle |
| 166 | xctx (IN) - XML context |
| 167 | stream (IN/OUT) - A pointer to orastream |
| 168 | lobloc (IN) - The OCI lob locator |
| 169 | Returns |
| 170 | The orastream created on top of the lob is returned in the parameter 'stream'. |
| 171 | ******************************************************************************/ |
| 172 | |
| 173 | struct xmlctx *OCIXmlDbInitXmlCtx(OCIEnv *, OCISvcCtx *, OCIError *, |
| 174 | ocixmldbparam *, int); |
| 175 | |
| 176 | void OCIXmlDbFreeXmlCtx(struct xmlctx *xctx); |
| 177 | sword OCIXmlDbStreamFromXMLType(OCIError *errhp, void **stream, |
| 178 | OCIXMLType *doc, ub4 mode); |
| 179 | sword OCIXmlDbOrastreamFromLob(OCIError *errhp, xmlctx *xctx, |
| 180 | void **stream, OCILobLocator *lobloc); |
| 181 | sword OCIXmlDbStreamRead(OCIError *errhp, void *stream, |
| 182 | void *bufp, sb8 *len, ub4 mode); |
| 183 | sword OCIXmlDbStreamClose(OCIError *errhp, void *stream); |
| 184 | |
| 185 | /*--------------------------------------------------------------------------- |
| 186 | INTERNAL FUNCTIONS |
| 187 | ---------------------------------------------------------------------------*/ |
| 188 | /* This function is for internal usage only */ |
| 189 | sword OCIXmlDbRewriteXMLDiff(OCIEnv *envhp, OCIError *errhp, OCISvcCtx *svchp, |
| 190 | xmldrctx *xctx , oratext* colname, ub4 colnamelen, |
| 191 | const void* xmldiff, ub4 xmldifflen, |
| 192 | OCILobLocator *xdiff_locator, oratext** updstmt, |
| 193 | ub2 binditerator, ub2 *colvalbndcount, |
| 194 | OCIXmlDiffBnd **bindlist); |
| 195 | |
| 196 | struct xmldrctx *OCIXmlInitDRCtx(OCIEnv *env, OCISvcCtx *svc, OCIError *err, |
| 197 | ub1 bindtyp); |
| 198 | |
| 199 | void OCIXmlFreeDRCtx(xmldrctx *xctx); |
| 200 | |
| 201 | sword OCIXmlDbGetFullyQualifiedSchemaUrl(OCIError *errhp, |
| 202 | oratext *schema_url, |
| 203 | ub2 schema_url_len, |
| 204 | oratext *schema_owner, |
| 205 | ub2 schema_owner_len, |
| 206 | oratext **fq_schema_url, |
| 207 | ub4 *fs_schema_url_len); |
| 208 | |
| 209 | void *OCIXmlDbMemCallback(void *ctx, size_t size); |
| 210 | |
| 211 | #endif /* OCIXMLDB_ORACLE */ |