• Main Page
  • Modules
  • Data Structures
  • Files
  • File List

D:/Perso/dev/ocilib/ocilib/src/msg.c

00001 /*
00002     +-----------------------------------------------------------------------------------------+
00003     |                                                                                         |
00004     |                               OCILIB - C Driver for Oracle                              |
00005     |                                                                                         |
00006     |                                (C Wrapper for Oracle OCI)                               |
00007     |                                                                                         |
00008     |                              Website : http://www.ocilib.net                            |
00009     |                                                                                         |
00010     |             Copyright (c) 2007-2010 Vincent ROGIER <vince.rogier@ocilib.net>            |
00011     |                                                                                         |
00012     +-----------------------------------------------------------------------------------------+
00013     |                                                                                         |
00014     |             This library is free software; you can redistribute it and/or               |
00015     |             modify it under the terms of the GNU Lesser General Public                  |
00016     |             License as published by the Free Software Foundation; either                |
00017     |             version 2 of the License, or (at your option) any later version.            |
00018     |                                                                                         |
00019     |             This library is distributed in the hope that it will be useful,             |
00020     |             but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00021     |             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           |
00022     |             Lesser General Public License for more details.                             |
00023     |                                                                                         |
00024     |             You should have received a copy of the GNU Lesser General Public            |
00025     |             License along with this library; if not, write to the Free                  |
00026     |             Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.          |
00027     |                                                                                         |
00028     +-----------------------------------------------------------------------------------------+
00029 */
00030 
00031 /* --------------------------------------------------------------------------------------------- *
00032  * $Id: msg.c, v 3.8.0 2010-10-24 21:53 Vincent Rogier $
00033  * --------------------------------------------------------------------------------------------- */
00034 
00035 #include "ocilib_internal.h"
00036 
00037 /* ********************************************************************************************* *
00038  *                            PUBLIC FUNCTIONS
00039  * ********************************************************************************************* */
00040 
00041 /* --------------------------------------------------------------------------------------------- *
00042  * OCI_MsgCreate
00043  * --------------------------------------------------------------------------------------------- */
00044 
00045 OCI_Msg * OCI_API OCI_MsgCreate
00046 (
00047     OCI_TypeInfo *typinf
00048 )
00049 {
00050     OCI_Msg *msg = NULL;
00051     boolean res  = TRUE;
00052 
00053     OCI_CHECK_INITIALIZED(NULL);
00054 
00055     OCI_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf, NULL);
00056 
00057     /* allocate message structure */
00058 
00059     msg = (OCI_Msg *) OCI_MemAlloc(OCI_IPC_MSG, sizeof(*msg), (size_t) 1, TRUE);
00060 
00061     if (msg != NULL)
00062     {
00063         msg->typinf       = typinf;
00064         msg->ind          = OCI_IND_NULL;
00065         msg->payload_ind  = &msg->ind;
00066 
00067         /* get payload type */
00068 
00069         if (mtscmp(msg->typinf->name, OCI_RAW_OBJECT_TYPE) == 0)
00070         {
00071             msg->payload_type = OCI_CDT_RAW;
00072         }
00073         else
00074         {
00075             msg->payload_type = OCI_CDT_OBJECT;
00076         }
00077 
00078         /* allocate message properties descriptor */
00079 
00080         res = (OCI_SUCCESS == OCI_DescriptorAlloc((dvoid * ) OCILib.env,
00081                                                   (dvoid **) &msg->proph,
00082                                                   OCI_DTYPE_AQMSG_PROPERTIES,
00083                                                   (size_t) 0, (dvoid **) NULL));
00084 
00085         if (res == TRUE)
00086         {
00087             /* allocate internal OCI_Object handle if payload is not RAW */
00088 
00089             if (msg->payload_type == OCI_CDT_OBJECT)
00090             {
00091                 msg->payload = (void *) OCI_ObjectCreate(typinf->con, typinf);
00092 
00093                 res = (msg->payload != NULL);
00094             }
00095         }
00096     }
00097     else
00098         res = FALSE;
00099 
00100     /* check for failure */
00101 
00102     if (res == FALSE)
00103     {
00104         OCI_MsgFree(msg);
00105         msg = NULL;
00106     }
00107 
00108     return msg;
00109 }
00110 
00111 /* --------------------------------------------------------------------------------------------- *
00112  * OCI_MsgFree
00113  * --------------------------------------------------------------------------------------------- */
00114 
00115 boolean OCI_API OCI_MsgFree
00116 (
00117     OCI_Msg *msg
00118 )
00119 {
00120     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00121 
00122     /* free local OCI_Agent object */
00123 
00124     if (msg->sender != NULL)
00125     {
00126         OCI_AgentFree(msg->sender);
00127     }
00128 
00129     /* free OCI descriptor */
00130 
00131     OCI_DescriptorFree((dvoid *) msg->proph, OCI_DTYPE_AQMSG_PROPERTIES);
00132 
00133     /* free internal OCI_Object handle if payload is not RAW */
00134 
00135     if ((msg->payload_type == OCI_CDT_OBJECT) && (msg->payload != NULL))
00136     {
00137         OCI_Object * obj = (OCI_Object *) msg->payload;
00138 
00139         obj->hstate =  OCI_OBJECT_ALLOCATED;
00140 
00141         OCI_ObjectFree(obj);
00142 
00143         msg->payload = NULL;
00144     }
00145 
00146     OCI_FREE(msg);
00147 
00148     return TRUE;
00149 }
00150 
00151 /* --------------------------------------------------------------------------------------------- *
00152  * OCI_MsgReset
00153  * --------------------------------------------------------------------------------------------- */
00154 
00155 boolean OCI_API OCI_MsgReset
00156 (
00157     OCI_Msg *msg
00158 )
00159 {
00160     boolean res = TRUE;
00161 
00162     unsigned int len = 0;
00163     void  *null_ptr  = NULL;
00164 
00165     res =   (
00166                 OCI_MsgSetExpiration(msg, -1)            &&
00167                 OCI_MsgSetEnqueueDelay(msg, 0)           &&
00168                 OCI_MsgSetPriority(msg,0)                &&
00169                 OCI_MsgSetOriginalID(msg, null_ptr, len) &&
00170                 OCI_MsgSetSender(msg, NULL)              &&
00171                 OCI_MsgSetConsumers(msg, null_ptr, len)  &&
00172                 OCI_MsgSetCorrelation(msg, NULL)         &&
00173                 OCI_MsgSetExceptionQueue(msg, NULL)
00174             );
00175 
00176     if (res == TRUE)
00177     {
00178         if (msg->payload_type == OCI_CDT_RAW)
00179         {
00180             res = OCI_MsgSetRaw(msg, null_ptr, len);
00181         }
00182         else
00183         {
00184             res = OCI_MsgSetObject(msg, null_ptr);
00185         }
00186     }
00187 
00188     return res;
00189 }
00190 
00191 /* --------------------------------------------------------------------------------------------- *
00192  * OCI_MsgGetObject
00193  * --------------------------------------------------------------------------------------------- */
00194 
00195 OCI_Object * OCI_API OCI_MsgGetObject
00196 (
00197     OCI_Msg *msg
00198 )
00199 {
00200     OCI_Object *obj = NULL;
00201 
00202     OCI_CHECK_PTR(OCI_IPC_MSG, msg, NULL);
00203     OCI_CHECK_COMPAT(msg->typinf->con, msg->payload_type == OCI_CDT_OBJECT, NULL);
00204 
00205     if (msg->ind != OCI_IND_NULL)
00206     {
00207         obj = (OCI_Object *) msg->payload;
00208     }
00209 
00210     OCI_RESULT(TRUE);
00211 
00212     return obj;
00213 }
00214 
00215 /* --------------------------------------------------------------------------------------------- *
00216  * OCI_MsgGetObject
00217  * --------------------------------------------------------------------------------------------- */
00218 
00219 boolean OCI_API OCI_MsgSetObject
00220 (
00221     OCI_Msg    *msg,
00222     OCI_Object *obj
00223 )
00224 {
00225     boolean res = TRUE;
00226 
00227     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00228 
00229     OCI_CHECK_COMPAT(msg->typinf->con, msg->payload_type == OCI_CDT_OBJECT, FALSE);
00230 
00231     if (obj != NULL)
00232     {
00233         /* assign the given object to the message internal object */
00234 
00235         res = OCI_ObjectAssign((OCI_Object *) msg->payload, obj);
00236 
00237         if (res == TRUE)
00238         {
00239             msg->ind = OCI_IND_NOTNULL;
00240         }
00241     }
00242     else
00243     {
00244         msg->ind = OCI_IND_NULL;
00245     }
00246 
00247     OCI_RESULT(res);
00248 
00249     return res;
00250 }
00251 
00252 /* --------------------------------------------------------------------------------------------- *
00253  * OCI_MsgGetRaw
00254  * --------------------------------------------------------------------------------------------- */
00255 
00256 boolean OCI_API OCI_MsgGetRaw
00257 (
00258     OCI_Msg      *msg,
00259     void         *raw,
00260     unsigned int *size
00261 )
00262 {
00263     unsigned int raw_size = 0;
00264 
00265     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00266     OCI_CHECK_PTR(OCI_IPC_VOID, raw, FALSE);
00267     OCI_CHECK_PTR(OCI_IPC_VOID, size, FALSE);
00268 
00269     OCI_CHECK_COMPAT(msg->typinf->con, msg->payload_type == OCI_CDT_RAW, FALSE);
00270 
00271     if ((msg->payload != NULL) && (msg->ind != OCI_IND_NULL))
00272     {
00273         raw_size = OCIRawSize(OCILib.env, (OCIRaw *) msg->payload);
00274 
00275         if (*size > raw_size)
00276             *size = raw_size;
00277 
00278         memcpy(raw, OCIRawPtr(OCILib.env, msg->payload), (size_t) (*size));
00279     }
00280     else
00281     {
00282         *size = 0;
00283     }
00284 
00285     OCI_RESULT(TRUE);
00286 
00287     return TRUE;
00288 }
00289 
00290 /* --------------------------------------------------------------------------------------------- *
00291  * OCI_MsgSetRaw
00292  * --------------------------------------------------------------------------------------------- */
00293 
00294 boolean OCI_API OCI_MsgSetRaw
00295 (
00296     OCI_Msg      *msg,
00297     const void   *raw,
00298     unsigned int  size
00299 )
00300 {
00301     boolean res = TRUE;
00302 
00303     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00304  
00305     OCI_CHECK_COMPAT(msg->typinf->con, msg->payload_type == OCI_CDT_RAW, FALSE);
00306 
00307     OCI_CALL2
00308     (
00309         res, msg->typinf->con,
00310 
00311         OCIRawAssignBytes(OCILib.env, msg->typinf->con->err, (ub1*) raw,
00312                           (ub4) size, (OCIRaw **) &msg->payload)
00313     )
00314 
00315     if ((res == TRUE) && (msg->payload != NULL) && (size > 0))
00316     {
00317         msg->ind = OCI_IND_NOTNULL;
00318     }
00319     else
00320     {
00321         msg->ind = OCI_IND_NULL;
00322     }
00323 
00324     OCI_RESULT(res);
00325 
00326     return res;
00327 }
00328 
00329 /* --------------------------------------------------------------------------------------------- *
00330  * OCI_MsgGetAttemptCount
00331  * --------------------------------------------------------------------------------------------- */
00332 
00333 int OCI_API OCI_MsgGetAttemptCount
00334 (
00335     OCI_Msg *msg
00336 )
00337 {
00338     boolean res = TRUE;
00339     sb4 ret     = 0;
00340 
00341     OCI_CHECK_PTR(OCI_IPC_MSG, msg, 0);
00342 
00343     OCI_CALL2
00344     (
00345         res, msg->typinf->con,
00346 
00347         OCIAttrGet((dvoid *) msg->proph,
00348                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00349                    (dvoid *) &ret,
00350                    (ub4   *) NULL,
00351                    (ub4    ) OCI_ATTR_ATTEMPTS,
00352                    msg->typinf->con->err)
00353     )
00354 
00355     OCI_RESULT(res);
00356 
00357     return (int) ret;
00358 }
00359 
00360 /* --------------------------------------------------------------------------------------------- *
00361  * OCI_MsgGetEnqueueDelay
00362  * --------------------------------------------------------------------------------------------- */
00363 
00364 int OCI_API OCI_MsgGetEnqueueDelay
00365 (
00366     OCI_Msg *msg
00367 )
00368 {
00369     boolean res = TRUE;
00370     sb4 ret     = 0;
00371 
00372     OCI_CHECK_PTR(OCI_IPC_MSG, msg, 0);
00373 
00374     OCI_CALL2
00375     (
00376         res, msg->typinf->con,
00377 
00378         OCIAttrGet((dvoid *) msg->proph,
00379                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00380                    (dvoid *) &ret,
00381                    (ub4   *) NULL,
00382                    (ub4    ) OCI_ATTR_DELAY,
00383                    msg->typinf->con->err)
00384     )
00385 
00386     OCI_RESULT(res);
00387 
00388     return (int) ret;
00389 }
00390 
00391 /* --------------------------------------------------------------------------------------------- *
00392  * OCI_MsgSetEnqueueDelay
00393  * --------------------------------------------------------------------------------------------- */
00394 
00395 boolean OCI_API OCI_MsgSetEnqueueDelay
00396 (
00397     OCI_Msg *msg,
00398     int      value
00399 )
00400 {
00401     boolean res = TRUE;
00402     sb4 sval    = (sb4) value;
00403 
00404     OCI_CHECK_PTR(OCI_IPC_MSG, msg, 0);
00405 
00406     OCI_CALL2
00407     (
00408         res, msg->typinf->con,
00409 
00410         OCIAttrSet((dvoid *) msg->proph,
00411                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00412                    (dvoid *) &sval,
00413                    (ub4    ) sizeof(sval),
00414                    (ub4    ) OCI_ATTR_DELAY,
00415                    msg->typinf->con->err)
00416     )
00417 
00418     OCI_RESULT(res);
00419 
00420     return res;
00421 }
00422 
00423 /* --------------------------------------------------------------------------------------------- *
00424  * OCI_MsgGetEnqueueTime
00425  * --------------------------------------------------------------------------------------------- */
00426 
00427 OCI_Date * OCI_API OCI_MsgGetEnqueueTime
00428 (
00429     OCI_Msg *msg
00430 )
00431 {
00432     boolean res    = TRUE;
00433     OCI_Date *date = NULL;
00434     OCIDate oci_date;
00435 
00436     OCI_CHECK_PTR(OCI_IPC_MSG, msg, NULL);
00437 
00438     OCI_CALL2
00439     (
00440         res, msg->typinf->con,
00441 
00442         OCIAttrGet((dvoid *) msg->proph,
00443                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00444                    (dvoid *) &oci_date,
00445                    (ub4   *) NULL,
00446                    (ub4    ) OCI_ATTR_ENQ_TIME,
00447                    msg->typinf->con->err)
00448     )
00449 
00450     if (res == TRUE)
00451     {
00452         date = OCI_DateInit(msg->typinf->con, &msg->date, &oci_date,
00453                             FALSE, FALSE);
00454 
00455         res = (date != NULL);
00456     }
00457 
00458     OCI_RESULT(res);
00459 
00460     return date;
00461 }
00462 
00463 /* --------------------------------------------------------------------------------------------- *
00464  * OCI_MsgGetExpiration
00465  * --------------------------------------------------------------------------------------------- */
00466 
00467 int OCI_API OCI_MsgGetExpiration
00468 (
00469     OCI_Msg *msg
00470 )
00471 {
00472     boolean res = TRUE;
00473     sb4 ret     = 0;
00474 
00475     OCI_CHECK_PTR(OCI_IPC_MSG, msg, 0);
00476 
00477     OCI_CALL2
00478     (
00479         res, msg->typinf->con,
00480 
00481         OCIAttrGet((dvoid *) msg->proph,
00482                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00483                    (dvoid *) &ret,
00484                    (ub4   *) NULL,
00485                    (ub4    ) OCI_ATTR_EXPIRATION,
00486                    msg->typinf->con->err)
00487     )
00488 
00489     OCI_RESULT(res);
00490 
00491     return (int) ret;
00492 }
00493 
00494 /* --------------------------------------------------------------------------------------------- *
00495  * OCI_MsgSetExpiration
00496  * --------------------------------------------------------------------------------------------- */
00497 
00498 boolean OCI_API OCI_MsgSetExpiration
00499 (
00500     OCI_Msg *msg,
00501     int      value
00502 )
00503 {
00504     boolean res = TRUE;
00505     sb4 sval    = (sb4) value;
00506 
00507     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00508 
00509     OCI_CALL2
00510     (
00511         res, msg->typinf->con,
00512 
00513         OCIAttrSet((dvoid *) msg->proph,
00514                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00515                    (dvoid *) &sval,
00516                    (ub4    ) sizeof(sval),
00517                    (ub4    ) OCI_ATTR_EXPIRATION,
00518                    msg->typinf->con->err)
00519     )
00520 
00521     OCI_RESULT(res);
00522 
00523     return res;
00524 }
00525 
00526 /* --------------------------------------------------------------------------------------------- *
00527  * OCI_MsgGetState
00528  * --------------------------------------------------------------------------------------------- */
00529 
00530 unsigned int OCI_API OCI_MsgGetState
00531 (
00532     OCI_Msg *msg
00533 )
00534 {
00535     boolean res = TRUE;
00536     sb4 ret     = 0;
00537 
00538     OCI_CHECK_PTR(OCI_IPC_MSG, msg, OCI_UNKNOWN);
00539 
00540     OCI_CALL2
00541     (
00542         res, msg->typinf->con,
00543 
00544         OCIAttrGet((dvoid *) msg->proph,
00545                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00546                    (dvoid *) &ret,
00547                    (ub4   *) NULL,
00548                    (ub4    ) OCI_ATTR_MSG_STATE,
00549                    msg->typinf->con->err)
00550     )
00551 
00552     /* increment value to handle return code OCI_UNKNOWN on failure */
00553 
00554     if (res == TRUE)
00555     {
00556         ret++;
00557     }
00558     else
00559     {
00560         ret = OCI_UNKNOWN;
00561     }
00562     
00563     OCI_RESULT(res);
00564     
00565     return (int) ret;
00566 }
00567 
00568 /* --------------------------------------------------------------------------------------------- *
00569  * OCI_MsgGetPriority
00570  * --------------------------------------------------------------------------------------------- */
00571 
00572 int OCI_API OCI_MsgGetPriority
00573 (
00574     OCI_Msg *msg
00575 )
00576 {
00577     boolean res = TRUE;
00578     sb4 ret     = 0;
00579 
00580     OCI_CHECK_PTR(OCI_IPC_MSG, msg, 0);
00581 
00582     OCI_CALL2
00583     (
00584         res, msg->typinf->con,
00585 
00586         OCIAttrGet((dvoid *) msg->proph,
00587                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00588                    (dvoid *) &ret,
00589                    (ub4   *) NULL,
00590                    (ub4    ) OCI_ATTR_PRIORITY,
00591                    msg->typinf->con->err)
00592     )
00593 
00594     OCI_RESULT(res);
00595 
00596     return (int) ret;
00597 }
00598 
00599 /* --------------------------------------------------------------------------------------------- *
00600  * OCI_MsgSetPriority
00601  * --------------------------------------------------------------------------------------------- */
00602 
00603 boolean OCI_API OCI_MsgSetPriority
00604 (
00605     OCI_Msg *msg,
00606     int      value
00607 )
00608 {
00609     boolean res = TRUE;
00610     sb4 sval    = (sb4) value;
00611 
00612     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00613 
00614     OCI_CALL2
00615     (
00616         res, msg->typinf->con,
00617 
00618         OCIAttrSet((dvoid *) msg->proph,
00619                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00620                    (dvoid *) &sval,
00621                    (ub4    ) sizeof(sval),
00622                    (ub4    ) OCI_ATTR_PRIORITY,
00623                    msg->typinf->con->err)
00624     )
00625 
00626     OCI_RESULT(res);
00627 
00628     return res;
00629 }
00630 
00631 
00632 /* --------------------------------------------------------------------------------------------- *
00633  * OCI_MsgGetID
00634  * --------------------------------------------------------------------------------------------- */
00635 
00636 boolean OCI_API OCI_MsgGetID
00637 (
00638     OCI_Msg      *msg,
00639     void         *id,
00640     unsigned int *len
00641 )
00642 {
00643     boolean res   = TRUE;
00644 
00645     OCI_CHECK_PTR(OCI_IPC_MSG,  msg, FALSE);
00646     OCI_CHECK_PTR(OCI_IPC_VOID, id,  FALSE);
00647     OCI_CHECK_PTR(OCI_IPC_VOID, len, FALSE);
00648 
00649     if (msg->id != NULL)
00650     {
00651         ub4 raw_len = 0;
00652 
00653         raw_len = OCIRawSize(OCILib.env, msg->id);
00654 
00655         if (*len > raw_len)
00656             *len = raw_len;
00657 
00658         memcpy(id, OCIRawPtr(OCILib.env, msg->id), (size_t) (*len));
00659     }
00660     else
00661     {
00662         *len = 0;
00663     }
00664 
00665     OCI_RESULT(res);
00666 
00667     return res;
00668 }
00669 
00670 /* --------------------------------------------------------------------------------------------- *
00671  * OCI_MsgGetOriginalID
00672  * --------------------------------------------------------------------------------------------- */
00673 
00674 boolean OCI_API OCI_MsgGetOriginalID
00675 (
00676     OCI_Msg      *msg,
00677     void         *id,
00678     unsigned int *len
00679 )
00680 {
00681     boolean res   = TRUE;
00682     OCIRaw *value = NULL;
00683 
00684     OCI_CHECK_PTR(OCI_IPC_MSG,  msg, FALSE);
00685     OCI_CHECK_PTR(OCI_IPC_VOID, id,  FALSE);
00686     OCI_CHECK_PTR(OCI_IPC_VOID, len, FALSE);
00687 
00688     OCI_CALL2
00689     (
00690         res, msg->typinf->con,
00691 
00692         OCIAttrGet((dvoid *) msg->proph,
00693                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00694                    (dvoid *) &value,
00695                    (ub4   *) NULL,
00696                    (ub4    ) OCI_ATTR_ORIGINAL_MSGID,
00697                    msg->typinf->con->err)
00698     )
00699 
00700     if (value != NULL)
00701     {
00702         ub4 raw_len = 0;
00703 
00704         raw_len = OCIRawSize(OCILib.env, value);
00705 
00706         if (*len > raw_len)
00707             *len = raw_len;
00708 
00709         memcpy(id, OCIRawPtr(OCILib.env, value), (size_t) (*len));
00710     }
00711     else
00712     {
00713         *len = 0;
00714     }
00715 
00716     OCI_RESULT(res);
00717 
00718     return res;
00719 }
00720 
00721 /* --------------------------------------------------------------------------------------------- *
00722  * OCI_MsgSetOriginalID
00723  * --------------------------------------------------------------------------------------------- */
00724 
00725 boolean OCI_API OCI_MsgSetOriginalID
00726 (
00727     OCI_Msg      *msg,
00728     const void   *id,
00729     unsigned int len
00730 )
00731 {
00732     boolean res   = TRUE;
00733     OCIRaw *value = NULL;
00734 
00735     OCI_CHECK_PTR(OCI_IPC_MSG,  msg, FALSE);
00736 
00737     OCI_CALL2
00738     (
00739         res, msg->typinf->con,
00740 
00741         OCIRawAssignBytes(OCILib.env, msg->typinf->con->err,
00742                           (ub1*) id, (ub4) len, (OCIRaw **) &value)
00743     )
00744 
00745     OCI_CALL2
00746     (
00747         res, msg->typinf->con,
00748 
00749         OCIAttrSet((dvoid *) msg->proph,
00750                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00751                    (dvoid *) &value,
00752                    (ub4    ) 0,
00753                    (ub4    ) OCI_ATTR_ORIGINAL_MSGID,
00754                    msg->typinf->con->err)
00755     )
00756 
00757     OCI_RESULT(res);
00758 
00759     return res;
00760 }
00761 
00762 /* --------------------------------------------------------------------------------------------- *
00763  * OCI_MsgGetCorrelation
00764  * --------------------------------------------------------------------------------------------- */
00765 
00766 const mtext * OCI_API OCI_MsgGetCorrelation
00767 (
00768     OCI_Msg *msg
00769 )
00770 {
00771     boolean res = TRUE;
00772 
00773     OCI_CHECK_PTR(OCI_IPC_MSG, msg, NULL);
00774 
00775     if (msg->correlation == NULL)
00776     {
00777         res = OCI_StringGetFromAttrHandle(msg->typinf->con,
00778                                           msg->proph,
00779                                           OCI_DTYPE_AQMSG_PROPERTIES,
00780                                           OCI_ATTR_CORRELATION,
00781                                           &msg->correlation);
00782     }
00783 
00784     OCI_RESULT(res);
00785 
00786     return msg->correlation;
00787 }
00788 
00789 /* --------------------------------------------------------------------------------------------- *
00790  * OCI_MsgSetCorrelation
00791  * --------------------------------------------------------------------------------------------- */
00792 
00793 boolean OCI_API OCI_MsgSetCorrelation
00794 (
00795     OCI_Msg     *msg,
00796     const mtext *correlation
00797 )
00798 {
00799     boolean res = TRUE;
00800 
00801     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00802 
00803     res =  OCI_StringSetToAttrHandle(msg->typinf->con,
00804                                      msg->proph,
00805                                      OCI_DTYPE_AQMSG_PROPERTIES,
00806                                      OCI_ATTR_CORRELATION,
00807                                      &msg->correlation,
00808                                      correlation);
00809 
00810     OCI_RESULT(res);
00811 
00812     return res;
00813 }
00814 
00815 /* --------------------------------------------------------------------------------------------- *
00816  * OCI_MsgGetExceptionQueue
00817  * --------------------------------------------------------------------------------------------- */
00818 
00819 const mtext * OCI_API OCI_MsgGetExceptionQueue
00820 (
00821     OCI_Msg *msg
00822 )
00823 {
00824     boolean res = TRUE;
00825 
00826     OCI_CHECK_PTR(OCI_IPC_MSG, msg, NULL);
00827 
00828     if (msg->except_queue == NULL)
00829     {
00830         res = OCI_StringGetFromAttrHandle(msg->typinf->con,
00831                                           msg->proph,
00832                                           OCI_DTYPE_AQMSG_PROPERTIES,
00833                                           OCI_ATTR_EXCEPTION_QUEUE,
00834                                           &msg->except_queue);
00835     }
00836 
00837     OCI_RESULT(res);
00838 
00839     return msg->except_queue;
00840 }
00841 
00842 /* --------------------------------------------------------------------------------------------- *
00843  * OCI_MsgSetExceptionQueue
00844  * --------------------------------------------------------------------------------------------- */
00845 
00846 boolean OCI_API OCI_MsgSetExceptionQueue
00847 (
00848     OCI_Msg     *msg,
00849     const mtext *queue
00850 )
00851 {
00852     boolean res = TRUE;
00853 
00854     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00855 
00856     res =  OCI_StringSetToAttrHandle(msg->typinf->con,
00857                                      msg->proph,
00858                                      OCI_DTYPE_AQMSG_PROPERTIES,
00859                                      OCI_ATTR_EXCEPTION_QUEUE,
00860                                      &msg->except_queue,
00861                                      queue);
00862 
00863     OCI_RESULT(res);
00864 
00865     return res;
00866 }
00867 
00868 /* --------------------------------------------------------------------------------------------- *
00869  * OCI_MsgGetSender
00870  * --------------------------------------------------------------------------------------------- */
00871 
00872 OCI_Agent * OCI_API OCI_MsgGetSender
00873 (
00874     OCI_Msg   *msg
00875 )
00876 {
00877     boolean res = TRUE;
00878     OCIAQAgent *handle = NULL;
00879     OCI_Agent  *sender = NULL;
00880 
00881     OCI_CHECK_PTR(OCI_IPC_MSG, msg, NULL);
00882 
00883     OCI_CALL2
00884     (
00885         res, msg->typinf->con,
00886 
00887         OCIAttrGet((dvoid *) msg->proph,
00888                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00889                    (dvoid *) &handle,
00890                    (ub4    ) 0,
00891                    (ub4    ) OCI_ATTR_SENDER_ID,
00892                    msg->typinf->con->err)
00893     )
00894 
00895     if ((res == TRUE) && (handle != NULL))
00896     {
00897         sender = OCI_AgentInit(msg->typinf->con, &msg->sender, handle, NULL, NULL);
00898     }
00899 
00900     OCI_RESULT(res);
00901 
00902     return sender;
00903 }
00904 
00905 /* --------------------------------------------------------------------------------------------- *
00906  * OCI_MsgSetSender
00907  * --------------------------------------------------------------------------------------------- */
00908 
00909 boolean OCI_API OCI_MsgSetSender
00910 (
00911     OCI_Msg   *msg,
00912     OCI_Agent *sender
00913 )
00914 {
00915     boolean res = TRUE;
00916 
00917     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00918 
00919     OCI_CALL2
00920     (
00921         res, msg->typinf->con,
00922 
00923         OCIAttrSet((dvoid *) msg->proph,
00924                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00925                    (dvoid *) (sender ? sender->handle : NULL),
00926                    (ub4    ) 0,
00927                    (ub4    ) OCI_ATTR_SENDER_ID,
00928                    msg->typinf->con->err)
00929     )
00930 
00931     OCI_RESULT(res);
00932 
00933     return res;
00934 }
00935 
00936 /* --------------------------------------------------------------------------------------------- *
00937  * OCI_MsgSetConsumers
00938  * --------------------------------------------------------------------------------------------- */
00939 
00940 boolean OCI_API OCI_MsgSetConsumers
00941 (
00942     OCI_Msg     *msg,
00943     OCI_Agent  **consumers,
00944     unsigned int count
00945 )
00946 {
00947     boolean res          = TRUE;
00948     OCIAQAgent **handles = NULL;
00949 
00950     OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);
00951 
00952     /* allocate local array of OCIAQAgent handles if needed */
00953 
00954     if ((consumers != NULL) && (count > 0))
00955     {
00956         handles = (OCIAQAgent **) OCI_MemAlloc(OCI_IPC_ARRAY,sizeof(OCIAQAgent *),
00957                                                count, FALSE);
00958 
00959         if (handles != NULL)
00960         {
00961             unsigned int i;
00962 
00963             for(i = 0; i < count; i++)
00964             {
00965                 handles[i] = consumers[i]->handle;
00966             }
00967         }
00968     }
00969     else
00970     {
00971         count = 0;
00972     }
00973 
00974     OCI_CALL2
00975     (
00976         res, msg->typinf->con,
00977 
00978         OCIAttrSet((dvoid *) msg->proph,
00979                    (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
00980                    (dvoid *) handles,
00981                    (ub4    ) count,
00982                    (ub4    ) OCI_ATTR_RECIPIENT_LIST,
00983                    msg->typinf->con->err)
00984     )
00985 
00986 
00987     /* free local array of OCIAQAgent handles if needed */
00988 
00989     if (handles != NULL)
00990     {
00991         OCI_FREE(handles);
00992     }
00993 
00994     OCI_RESULT(res);
00995 
00996     return res;
00997 }

Generated on Sun Oct 24 2010 22:02:54 for OCILIB (C Driver for Oracle) by  doxygen 1.7.1