MQSeries
view release on metacpan or search on metacpan
MQClient/MQSeries.xs.in/32MQOPEN-v5 view on Meta::CPAN
# -*-c-*-
#
# $Id: 32MQOPEN-v5,v 33.5 2012/09/26 16:10:03 jettisu Exp $
#
# (c) 1999-2012 Morgan Stanley & Co. Incorporated
# See ..../src/LICENSE for terms of distribution.
#
void
MQOPEN(Hconn,ObjDesc,Options,CompCode,Reason)
MQHCONN Hconn
MQOD ObjDesc
MQLONG Options
MQLONG CompCode = NO_INIT
MQLONG Reason = NO_INIT
PREINIT:
MQHOBJ Hobj;
SV *Return, **svp;
AV *ObjectRecs, *ObjectRecsArrayEntry;
AV *ResponseRecArray;
HV *ObjectRecsHashEntry, *ResponseRecHash;
PMQRR pResponseRecPtr = NULL;
PMQOR pObjectRecPtr;
char *String;
STRLEN StringLength;
int index;
#ifdef MQOD_VERSION_4
MQCHAR resolved_object_string[MQ_TOPIC_STR_LENGTH];
#endif
PPCODE:
CompCode = MQCC_FAILED;
Reason = MQRC_UNEXPECTED_ERROR;
sv_setiv(ST(3),(IV)CompCode);
sv_setiv(ST(4),(IV)Reason);
/*
If there is a list of ObjectRecs, then we are dealing with a
distribution list.
*/
if ( hv_exists((HV*)SvRV(ST(1)),"ObjectRecs",10) ) {
svp = hv_fetch((HV*)SvRV(ST(1)),"ObjectRecs",10,FALSE);
if ( svp == NULL ) {
warn("Unable to fetch value for key ObjectRecs\n");
XSRETURN_EMPTY;
}
if (
!SvROK(*svp) ||
( SvROK(*svp) && SvTYPE(SvRV(*svp)) != SVt_PVAV )
) {
warn("Invalid data for 'ObjectRecs', not an ARRAY reference\n");
XSRETURN_EMPTY;
}
ObjectRecs = (AV*)SvRV(*svp);
/* Override this, even if it was provided by the user */
ObjDesc.RecsPresent = av_len(ObjectRecs) + 1;
/* If this is NOT set, then MQOPEN() will puke. One more
thing the user doesn't have to care about... */
ObjDesc.Version = MQOD_VERSION_2;
if ( (pResponseRecPtr = (PMQRR)malloc( ObjDesc.RecsPresent * sizeof(MQRR) ) ) == NULL ) {
perror("Unable to allocate memory");
XSRETURN_EMPTY;
}
memset(pResponseRecPtr,'\0',ObjDesc.RecsPresent * sizeof(MQRR));
if ( (pObjectRecPtr = (PMQOR)malloc( ObjDesc.RecsPresent * sizeof(MQOR) ) ) == NULL ) {
perror("Unable to allocate memory");
XSRETURN_EMPTY;
}
memset(pObjectRecPtr,'\0',ObjDesc.RecsPresent * sizeof(MQOR));
ObjDesc.ResponseRecPtr = pResponseRecPtr;
ObjDesc.ObjectRecPtr = pObjectRecPtr;
/*
Now we have to go through the list, and extract the
QName/QMgrName pairs. We'll allow this to be one of three
formats.
ObjectRecs => [qw( FOO BAR BAZ )],
ObjectRecs => [
( run in 0.642 second using v1.01-cache-2.11-cpan-5511b514fd6 )