MQSeries
view release on metacpan or search on metacpan
MQClient/MQSeries.xs.in/34MQPUT-v5 view on Meta::CPAN
# -*-c-*-
#
# $Id: 34MQPUT-v5,v 33.5 2012/09/26 16:10:04 jettisu Exp $
#
# (c) 1999-2012 Morgan Stanley & Co. Incorporated
# See ..../src/LICENSE for terms of distribution.
#
void
MQPUT(Hconn,Hobj,MsgDesc,PutMsgOpts,Msg,CompCode,Reason)
MQHCONN Hconn
MQHOBJ Hobj
MQMD MsgDesc
MQPMO PutMsgOpts
SV *Msg
MQLONG CompCode = NO_INIT
MQLONG Reason = NO_INIT
PREINIT:
char *Key, *pPutMsgRecPtr = NULL, *String;
STRLEN KeyLength, StringLength;
int index, subindex;
size_t FieldSize;
int PutMsgRecSize = 0;
PMQRR pResponseRecPtr = NULL;
PMQCHAR Buffer;
SV **svp;
AV *PutMsgRecs, *ValidPutMsgRecFieldsArray;
AV *ResponseRecArray;
HV *PutMsgRecFields = NULL, *PutMsgRecHash;
HV *ValidPutMsgRecFieldsHash;
HV *ValidPutMsgRecFieldsSubHash, *ResponseRecHash;
PPCODE:
CompCode = MQCC_FAILED;
Reason = MQRC_UNEXPECTED_ERROR;
sv_setiv(ST(5),(IV)CompCode);
sv_setiv(ST(6),(IV)Reason);
/*
* We set the MQMD version to 2, so users of segmentation or
* grouping won't have to do this manually.
*/
if (MsgDesc.Version < MQMD_VERSION_2) {
MsgDesc.Version = MQMD_VERSION_2;
}
if ( hv_exists((HV*)SvRV(ST(3)),"PutMsgRecs",10) ) {
/*
* Using the put-msg records (distribution list features)
* requires MQPMO version 2. We enable that automatically
* if distribution lists are used.
*/
if (PutMsgOpts.Version < MQPMO_VERSION_2) {
PutMsgOpts.Version = MQPMO_VERSION_2;
}
/*
We will need this configuration hash, but only
when handling dist lists.
*/
if ( (ValidPutMsgRecFieldsHash =
perl_get_hv("MQSeries::Constants::ValidPutMsgRecFields",FALSE)) == NULL ) {
warn("Unable to see %%MQSeries::Constants::ValidPutMsgRecFields\n");
XSRETURN_EMPTY;
}
if ( (ValidPutMsgRecFieldsArray =
perl_get_av("MQSeries::Constants::ValidPutMsgRecFields",FALSE)) == NULL ) {
warn("Unable to see @MQSeries::Constants::ValidPutMsgRecFields\n");
XSRETURN_EMPTY;
}
svp = hv_fetch((HV*)SvRV(ST(3)),"PutMsgRecs",10,FALSE);
if ( svp == NULL ) {
warn("Unable to fetch value for key PutMsgRecs\n");
XSRETURN_EMPTY;
}
if ( !SvROK(*svp) || ( SvROK(*svp) && SvTYPE(SvRV(*svp)) != SVt_PVAV ) ) {
warn("Invalid data for 'PutMsgRecs', not an ARRAY reference\n");
XSRETURN_EMPTY;
}
PutMsgRecs = (AV*)SvRV(*svp);
PutMsgOpts.RecsPresent = av_len(PutMsgRecs) + 1;
/*
OK, here we go...
First, look at the *first* PutMsgRecs hash, and from
that set the PutMsgOpts.PutMsgRecFields value, and
malloc() the necessary memory for the MQMPR and MQRR
( run in 1.036 second using v1.01-cache-2.11-cpan-5511b514fd6 )