ARSperl
view release on metacpan or search on metacpan
if(ARError( ret, status)) {
DBG( ("ARVerifyUser failed %d\n", ret) );
ARTermination(ctrl, &status);
ARError(ret, status);
#ifdef PROFILE
AP_FREE(ctrl); /* invalid, cleanup */
#else
safefree(ctrl);
#endif
RETVAL = NULL;
} else {
RETVAL = ctrl; /* valid, return ctrl struct */
}
if(s_ok == 0) {
DBG( ("s_ok == 0, cleaning ServerNameList\n") );
FreeARServerNameList(&serverList, FALSE);
}
ar_login_end:;
DBG( ("finished.\n") );
}
OUTPUT:
RETVAL
HV*
ars_VerifyUser(ctrl)
ARControlStruct * ctrl
CODE:
{
int ret = 0;
ARBoolean adminFlag = 0,
subAdminFlag = 0,
customFlag = 0;
ARStatusList status;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
ret = ARVerifyUser( ctrl, &adminFlag, &subAdminFlag, &customFlag, &status );
/* printf( "ret = %d, adminFlag = %d, subAdminFlag = %d, customFlag = %d\n",
ret, adminFlag, subAdminFlag, customFlag ); */
if(! ARError(ret, status)) {
RETVAL = newHV();
sv_2mortal( (SV*) RETVAL );
hv_store( RETVAL, "adminFlag", strlen("adminFlag"), newSViv(adminFlag), 0);
hv_store( RETVAL, "subAdminFlag", strlen("subAdminFlag"), newSViv(subAdminFlag), 0);
hv_store( RETVAL, "customFlag", strlen("customFlag"), newSViv(customFlag), 0);
}else{
XSRETURN_UNDEF;
}
}
OUTPUT:
RETVAL
void
ars_GetControlStructFields(ctrl)
ARControlStruct * ctrl
PPCODE:
{
(void) ARError_reset();
if(!ctrl) return;
XPUSHs(sv_2mortal(newSViv(ctrl->cacheId)));
XPUSHs(sv_2mortal(newSViv(ctrl->operationTime)));
XPUSHs(sv_2mortal(newSVpv(ctrl->user, 0)));
XPUSHs(sv_2mortal(newSVpv(ctrl->password, 0)));
#ifndef AR_MAX_LOCALE_SIZE
XPUSHs(sv_2mortal(newSVpv(ctrl->language, 0)));
#else
XPUSHs(sv_2mortal(newSVpv(ctrl->localeInfo.locale, 0)));
#endif
XPUSHs(sv_2mortal(newSVpv(ctrl->server, 0)));
XPUSHs(sv_2mortal(newSViv(ctrl->sessionId)));
#if AR_EXPORT_VERSION >= 7
XPUSHs(sv_2mortal(newSVpv(ctrl->authString, 0)));
#endif
}
SV *
ars_GetCurrentServer(ctrl)
ARControlStruct * ctrl
CODE:
{
RETVAL = NULL;
(void) ARError_reset();
if(ctrl && ctrl->server) {
RETVAL = newSVpv( ctrl->server, strlen(ctrl->server) );
}
}
OUTPUT:
RETVAL
HV *
ars_GetProfileInfo(ctrl)
ARControlStruct * ctrl
CODE:
{
RETVAL = newHV();
sv_2mortal( (SV*) RETVAL );
(void) ARError_reset();
#ifdef PROFILE
hv_store(RETVAL, "queries", strlen("queries") ,
newSViv(((ars_ctrl *)ctrl)->queries), 0);
hv_store(RETVAL, "startTime", strlen("startTime") ,
newSViv(((ars_ctrl *)ctrl)->startTime), 0);
#else /* profiling not compiled in */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_OPT_NA,
"Optional profiling code not compiled into this build of ARSperl");
#endif
}
OUTPUT:
RETVAL
void
ars_Logoff(ctrl)
ARControlStruct * ctrl
CODE:
{
int ret = 0;
ARStatusList status;
Zero(&status, 1, ARStatusList);
(void) ARError_reset();
if (!ctrl) return;
#if AR_EXPORT_VERSION >= 4
ret = ARTermination(ctrl, &status);
#else
ret = ARTermination(&status);
#endif
(void) ARError( ret, status);
/*AP_FREE(ctrl); let DESTROY free it*/
}
void
ars_GetListField(control,schema,changedsince=0,fieldType=AR_FIELD_TYPE_ALL)
ARControlStruct * control
char * schema
unsigned long changedsince
unsigned long fieldType
PPCODE:
{
ARInternalIdList idlist;
ARStatusList status;
int ret = 0;
unsigned int i = 0;
(void) ARError_reset();
Zero(&idlist, 1, ARInternalIdList);
Zero(&status, 1, ARStatusList);
#if AR_EXPORT_VERSION >= 3
ret = ARGetListField(control,schema,
fieldType,
changedsince,
#if AR_CURRENT_API_VERSION >= 17
NULL, /* &objPropList (undocumented by BMC) */
#endif
&idlist,
&status);
#else
ret = ARGetListField(control,schema,changedsince,&idlist,&status);
#endif
#ifdef PROFILE
((ars_ctrl *)control)->queries++;
#endif
if (!ARError( ret,status)) {
for (i=0; i<idlist.numItems; i++)
XPUSHs(sv_2mortal(newSViv(idlist.internalIdList[i])));
FreeARInternalIdList(&idlist,FALSE);
}
}
void
ars_GetFieldByName(control,schema,field_name)
ARControlStruct * control
char * schema
char * field_name
PPCODE:
{
int ret = 0;
unsigned int loop = 0;
ARInternalIdList idList;
ARStatusList status;
ARNameType fieldName;
(void) ARError_reset();
Zero(&idList, 1, ARInternalIdList);
Zero(&status, 1, ARStatusList);
ret = ARGetListField(control, schema,
AR_FIELD_TYPE_ALL,
(ARTimestamp)0,
#if AR_CURRENT_API_VERSION >= 17
NULL, /* &objPropList (undocumented by BMC) */
#endif
&idList,
&status);
#ifdef PROFILE
((ars_ctrl *)control)->queries++;
#endif
if (! ARError( ret, status)) {
for (loop=0; loop<idList.numItems; loop++) {
#if AR_CURRENT_API_VERSION >= 17
ret = ARGetFieldCached(control, schema, idList.internalIdList[loop], fieldName, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
#elif AR_CURRENT_API_VERSION >= 12
ret = ARGetFieldCached(control, schema, idList.internalIdList[loop], fieldName, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
#else
ret = ARGetFieldCached(control, schema, idList.internalIdList[loop], fieldName, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
#endif
if (ARError( ret, status))
break;
if (strcmp(field_name, fieldName) == 0){
XPUSHs(sv_2mortal(newSViv(idList.internalIdList[loop])));
break;
}
}
FreeARInternalIdList(&idList, FALSE);
}
}
void
ars_GetFieldTable(ctrl,schema)
ARControlStruct * ctrl
char * schema
PPCODE:
{
int ret = 0;
unsigned int loop = 0;
HV *fields, *h;
char *hkey;
SV *hval, **hvalName;
I32 klen;
(void) ARError_reset();
fields = fieldcache_get_schema_fields( ctrl, schema, TRUE );
if( ! fields ){
goto get_fieldtable_end;
}
hv_iterinit( fields );
while( (hval = hv_iternextsv(fields,&hkey,&klen)) ){
if( strcmp(hkey,"0") == 0 ) continue;
h = (HV* ) SvRV(hval);
hvalName = hv_fetch( h, "name", 4, 0 );
XPUSHs( sv_2mortal(newSVsv(*hvalName)) );
XPUSHs( sv_2mortal(newSVpv(hkey,0)) );
}
get_fieldtable_end:;
if( ! fields ){
XSRETURN_UNDEF;
}
}
SV *
ars_CreateEntry(ctrl,schema,...)
ARControlStruct * ctrl
char * schema
CODE:
{
int a = 0,
i = 0,
c = (items - 2) / 2;
AREntryIdType entryId;
ARFieldValueList fieldList;
ARInternalIdList getFieldIds;
ARStatusList status;
int ret = 0, rv = 0;
unsigned int dataType = 0, j = 0;
HV *cacheFields;
RETVAL=NULL;
(void) ARError_reset();
Zero(&entryId, 1, AREntryIdType);
Zero(&fieldList, 1, ARFieldValueList);
Zero(&getFieldIds, 1, ARInternalIdList);
Zero(&status, 1, ARStatusList);
if (((items - 2) % 2) || c < 1) {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
} else {
cacheFields = fieldcache_get_schema_fields( ctrl, schema, FALSE );
if( ! cacheFields ){
goto create_entry_end;
create_entry_end:;
if(rv == 0) {
RETVAL = newSVsv(&PL_sv_undef);
} else {
RETVAL = newSVpv( entryId, strlen(entryId) );
}
AP_FREE(fieldList.fieldValueList);
if( getFieldIds.internalIdList != NULL ) AP_FREE(getFieldIds.internalIdList);
}
}
OUTPUT:
RETVAL
int
ars_DeleteEntry(ctrl,schema,entry_id)
ARControlStruct * ctrl
char * schema
char * entry_id
CODE:
{
int ret = 0;
ARStatusList status;
#if AR_EXPORT_VERSION >= 3
AREntryIdList entryList;
RETVAL = 0; /* assume error */
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
if(perl_BuildEntryList(ctrl, &entryList, entry_id) != 0)
goto delete_fail;
ret = ARDeleteEntry(ctrl, schema, &entryList, 0, &status);
if (entryList.entryIdList) AP_FREE(entryList.entryIdList);
#else /* ARS 2 */
RETVAL = 0; /* assume error */
if(!entry_id || !*entry_id) {
ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_EID);
goto delete_fail;
}
ret = ARDeleteEntry(ctrl, schema, entry_id, &status);
#endif
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (ARError(ret, status))
RETVAL = 0;
else
RETVAL = 1;
delete_fail:;
}
OUTPUT:
RETVAL
void
ars_GetEntryBLOB(ctrl,schema,entry_id,field_id,locType,locFile=NULL)
ARControlStruct * ctrl
char * schema
char * entry_id
ARInternalId field_id
int locType
char * locFile
PPCODE:
{
ARStatusList status;
AREntryIdList entryList;
#if AR_EXPORT_VERSION >= 4
ARLocStruct loc;
#endif
int ret = 0;
(void) ARError_reset();
Zero(&entryList, 1, AREntryIdList);
Zero(&status, 1, ARStatusList);
#if AR_EXPORT_VERSION >= 4
/* build entryList */
ret = perl_BuildEntryList(ctrl, &entryList, entry_id);
if(ret)
goto get_entryblob_end;
switch(locType) {
case AR_LOC_FILENAME:
if(locFile == NULL) {
ARError_add(AR_RETURN_ERROR,
AP_ERR_USAGE,
"locFile parameter required when specifying AR_LOC_FILENAME");
goto get_entryblob_end;
}
loc.locType = AR_LOC_FILENAME;
loc.u.filename = strdup(locFile); /* strdup(locFile) ? i'm not completely sure
which to use. will FreeARLocStruct call
free(loc.locType)? i'm assuming it will.
Purify doesnt complain, so i'm going
to leave this alone. */
break;
case AR_LOC_BUFFER:
loc.locType = AR_LOC_BUFFER;
loc.u.buf.bufSize = 0;
break;
default:
ARError_add(AR_RETURN_ERROR,
AP_ERR_USAGE,
"locType parameter is required.");
goto get_entryblob_end;
break;
}
ret = ARGetEntryBLOB(ctrl, schema, &entryList, field_id,
&loc, &status);
if(!ARError(ret, status)) {
if(locType == AR_LOC_BUFFER)
#if PERL_PATCHLEVEL_IS >= 6
XPUSHs(sv_2mortal(newSVpvn((const char *)
loc.u.buf.buffer,
loc.u.buf.bufSize)));
#else
XPUSHs(sv_2mortal(newSVpvn(
loc.u.buf.buffer,
loc.u.buf.bufSize)));
#endif
else
XPUSHs(sv_2mortal(newSViv(1)));
} else
XPUSHs(&PL_sv_undef);
if (entryList.entryIdList) AP_FREE(entryList.entryIdList);
switch (loc.locType)
{
case AR_LOC_FILENAME:
AP_FREE(loc.u.filename);
break;
case AR_LOC_BUFFER:
FreeARLocStruct(&loc, FALSE);
break;
}
#else /* pre ARS-4.0 */
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ars_GetEntryBLOB() is only available > ARS4.x");
XPUSHs(&PL_sv_undef);
#endif
get_entryblob_end:;
}
void
ars_GetEntry(ctrl,schema,entry_id,...)
ARControlStruct * ctrl
char * schema
char * entry_id
PPCODE:
{
int ret = 0;
unsigned int c = items - 3, i;
ARInternalIdList idList;
ARFieldValueList fieldList;
ARStatusList status;
#if AR_EXPORT_VERSION >= 3
AREntryIdList entryList;
#endif
(void) ARError_reset();
Zero(&idList, 1, ARInternalIdList);
Zero(&fieldList, 1, ARFieldValueList);
Zero(&status, 1, ARStatusList);
if (c < 1) {
idList.numItems = 0; /* get all fields */
} else {
idList.numItems = c;
idList.internalIdList = MALLOCNN(sizeof(ARInternalId) * c);
if (!idList.internalIdList)
goto get_entry_end;
for (i=0; i<c; i++)
idList.internalIdList[i] = SvIV(ST(i+3));
}
#if AR_EXPORT_VERSION >= 3
/* build entryList */
if(perl_BuildEntryList(ctrl, &entryList, entry_id) != 0)
goto get_entry_end;
ret = ARGetEntry(ctrl, schema, &entryList, &idList, &fieldList, &status);
if (entryList.entryIdList) AP_FREE(entryList.entryIdList);
#else /* ARS 2 */
if(!entry_id || !*entry_id) {
ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_EID);
goto get_entry_cleanup;
}
ret = ARGetEntry(ctrl, schema, entry_id, &idList, &fieldList, &status);
#endif
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (ARError( ret, status)) {
goto get_entry_cleanup;
}
if(fieldList.numItems < 1) {
goto get_entry_cleanup;
}
for (i=0; i<fieldList.numItems; i++) {
XPUSHs(sv_2mortal(newSViv(fieldList.fieldValueList[i].fieldId)));
XPUSHs(sv_2mortal(perl_ARValueStruct(ctrl,
&fieldList.fieldValueList[i].value)));
}
FreeARFieldValueList(&fieldList,FALSE);
get_entry_cleanup:;
if (idList.internalIdList) AP_FREE(idList.internalIdList);
get_entry_end:;
}
void
ars_GetListEntry(ctrl,schema,qualifier,maxRetrieve=0,firstRetrieve=0,...)
ARControlStruct * ctrl
char * schema
ARQualifierStruct * qualifier
int maxRetrieve
int firstRetrieve
PPCODE:
{
unsigned int c = (items - 5) / 2;
unsigned int i = 0;
int field_off = 5;
int staticParams = field_off;
ARSortList sortList;
AREntryListList entryList;
ARStatusList status;
int ret = 0;
#if AR_EXPORT_VERSION >= 3
AREntryListFieldList getListFields, *getList = NULL;
AV *getListFields_array;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
Zero(&entryList, 1, AREntryListList);
Zero(&sortList, 1, ARSortList);
if ((items - staticParams) % 2) {
/* odd number of arguments, so argument after maxRetrieve is
optional getListFields (an array of hash refs) */
if (SvROK(ST(field_off)) &&
(getListFields_array = (AV *)SvRV(ST(field_off))) &&
SvTYPE(getListFields_array) == SVt_PVAV) {
getList = &getListFields;
getListFields.numItems = av_len(getListFields_array) + 1;
AMALLOCNN(getListFields.fieldsList, getListFields.numItems,
AREntryListFieldStruct);
/* set query field list */
for (i = 0 ; i < getListFields.numItems ; i++) {
SV **array_entry, **hash_entry;
HV *field_hash;
/* get hash from array */
if ((array_entry = av_fetch(getListFields_array, i, 0)) &&
SvROK(*array_entry) &&
SvTYPE(field_hash = (HV*)SvRV(*array_entry)) == SVt_PVHV) {
/* get fieldId, columnWidth and separator from hash */
if (! (hash_entry = hv_fetch(field_hash, "fieldId", strlen("fieldId"), 0))) {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_LFLDS);
FreeAREntryListFieldList(&getListFields, FALSE);
goto getlistentry_end;
}
getListFields.fieldsList[i].fieldId = SvIV(*hash_entry);
if (! (hash_entry = hv_fetch(field_hash, "columnWidth",
strlen("columnWidth"), 0))) {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_LFLDS);
FreeAREntryListFieldList(&getListFields, FALSE);
goto getlistentry_end;
}
getListFields.fieldsList[i].columnWidth = SvIV(*hash_entry);
if (! (hash_entry = hv_fetch(field_hash, "separator",
strlen("separator"), 0))) {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_LFLDS);
NULL, &status);
#elif AR_EXPORT_VERSION >= 6
ret = ARGetListEntry(ctrl, schema, qualifier, getList, &sortList,
firstRetrieve, maxRetrieve, &entryList,
NULL, &status);
#elif AR_EXPORT_VERSION >= 3
ret = ARGetListEntry(ctrl, schema, qualifier, getList, &sortList,
maxRetrieve, &entryList, NULL, &status);
#else
ret = ARGetListEntry(ctrl, schema, qualifier, &sortList,
maxRetrieve, &entryList, NULL, &status);
#endif
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (ARError( ret, status)) {
goto getlistentry_end;
}
for (i = 0 ; i < entryList.numItems ; i++) {
#if AR_EXPORT_VERSION >= 3
if (entryList.entryList[i].entryId.numItems == 1) {
/* only one entryId -- so just return its value to be compatible
with ars 2 */
XPUSHs(sv_2mortal(newSVpv(entryList.entryList[i].entryId.entryIdList[0], 0)));
} else {
/* more than one entry -- this must be a join schema. merge
* the list into a single entry-id to keep things
* consistent.
*/
unsigned int entry = 0;
char *joinId = (char *)NULL;
char joinSep[2] = {AR_ENTRY_ID_SEPARATOR, 0};
for ( entry = 0 ; entry < entryList.entryList[i].entryId.numItems ; entry++) {
joinId = strappend(joinId,
entryList.entryList[i].entryId.entryIdList[entry]);
if(entry < entryList.entryList[i].entryId.numItems-1)
joinId = strappend(joinId, joinSep);
}
XPUSHs(sv_2mortal(newSVpv(joinId, 0)));
AP_FREE(joinId);
}
#else /* ARS 2 */
XPUSHs(sv_2mortal(newSVpv(entryList.entryList[i].entryId, 0)));
#endif
XPUSHs(sv_2mortal(newSVpv(entryList.entryList[i].shortDesc, 0)));
}
getlistentry_end:;
FreeARSortList(&sortList, FALSE);
FreeAREntryListList(&entryList,FALSE);
}
void
ars_GetListSchema(ctrl,changedsince=0,schemaType=AR_LIST_SCHEMA_ALL,fieldPropList=NULL,name=NULL,fieldIdList=NULL)
ARControlStruct * ctrl
unsigned int changedsince
unsigned int schemaType
char * name
AV * fieldIdList
ARPropList * fieldPropList
PPCODE:
{
ARNameList nameList;
ARStatusList status;
unsigned int i = 0;
int ret = 0;
#if AR_EXPORT_VERSION >= 8L
ARPropList propList;
#endif
#if AR_EXPORT_VERSION >= 6
ARInternalIdList idList;
Zero(&idList, 1, ARInternalIdList);
#endif
#if AR_EXPORT_VERSION >= 8L
Zero(&propList, 1, ARPropList);
#endif
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
#if AR_EXPORT_VERSION >= 6
if (fieldIdList && (SvTYPE(fieldIdList) == SVt_PVAV)) {
idList.numItems = av_len(fieldIdList) + 1;
AMALLOCNN(idList.internalIdList, idList.numItems, ARInternalId);
for (i = 0 ; i < idList.numItems ; i++ ) {
SV **array_entry;
if ((array_entry = av_fetch(fieldIdList, i, 0)) &&
SvROK(*array_entry) &&
(SvTYPE(*array_entry) == SVt_PVIV) ) {
idList.internalIdList[i] = (unsigned long) (SvIV(*array_entry));
}
}
}
#endif
#if AR_EXPORT_VERSION >= 3
ret = ARGetListSchema(ctrl, changedsince, schemaType, name,
# if AR_EXPORT_VERSION >= 8L
&idList, &propList,
# elif AR_EXPORT_VERSION >= 6 && AR_EXPORT_VERSION < 8L
&idList,
# endif
&nameList, &status);
#else
ret = ARGetListSchema(ctrl, changedsince,
&nameList, &status);
#endif
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (! ARError( ret, status)) {
for (i=0; i<nameList.numItems; i++) {
XPUSHs(sv_2mortal(newSVpv(nameList.nameList[i], 0)));
}
FreeARNameList(&nameList,FALSE);
}
}
void
ars_GetListContainer(ctrl,changedSince=0,attributes=0,...)
ARControlStruct * ctrl
ARTimestamp changedSince
unsigned int attributes
PPCODE:
{
ARStatusList status;
int i, ret, rv = 0;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
if(items < 1 || items > 200){ /* don't overflow clist[] */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
}else{
ARContainerTypeList containerTypes;
int count;
int clist[256];
ARContainerOwnerObjList ownerObjList;
# if AR_EXPORT_VERSION >= 8L
ARPropList propList;
# endif
ARContainerInfoList conList;
Zero(&containerTypes, 1, ARContainerTypeList);
Zero(&ownerObjList, 1, ARContainerOwnerObjList);
# if AR_EXPORT_VERSION >= 8L
Zero(&propList, 1, ARPropList);
# endif
Zero(&conList, 1, ARContainerInfoList);
count = 0;
if( items >= 4 ){
SV* st3 = ST(3);
if( SvROK(st3) && SvTYPE(SvRV(st3)) == SVt_PVAV ){
HV *h_dummy = newHV();
SvREFCNT_inc( st3 );
hv_store( h_dummy, "_", 1, st3, 0 );
rv += rev_ARContainerOwnerObjList( ctrl, h_dummy, "_", &ownerObjList );
hv_undef( h_dummy );
}else{
clist[count++] = SvIV(st3);
}
}
for(i = 4 ; i < items ; ++i){
clist[count++] = SvIV(ST(i));
}
containerTypes.numItems = count;
containerTypes.type = clist;
if( rv == 0 ){
ret = ARGetListContainer(ctrl, changedSince,
&containerTypes,
attributes,
&ownerObjList,
# if AR_EXPORT_VERSION >= 8L
&propList,
# endif
&conList, &status);
}else{
ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
}
#if AR_CURRENT_API_VERSION >= 17
hv_store(RETVAL, "assignedGroupList", strlen("assignedGroupList") ,
perl_ARPermissionList(control, &assignedGroupList, PERMTYPE_SCHEMA), 0);
#endif
hv_store(RETVAL, "groupList", strlen("groupList") ,
perl_ARPermissionList(control, &groupList, PERMTYPE_SCHEMA), 0);
hv_store(RETVAL, "adminList", strlen("adminList") ,
perl_ARList(control, (ARList *)&adminGroupList,
(ARS_fn)perl_ARInternalId,
sizeof(ARInternalId)),0);
hv_store(RETVAL, "ownerObjList", strlen("ownerObjList") ,
perl_AROwnerObjList(control, &ownerObjList), 0);
if (helpText)
hv_store(RETVAL, "helpText", strlen("helpText") , newSVpv(helpText, 0), 0);
hv_store(RETVAL, "timestamp", strlen("timestamp") , newSViv(timestamp), 0);
hv_store(RETVAL, "type", strlen("type") ,
newSVpv( ContainerTypeMap[type].name, strlen(ContainerTypeMap[type].name) ) ,
0);
hv_store(RETVAL, "name", strlen("name") , newSVpv(name, 0), 0);
hv_store(RETVAL, "owner", strlen("owner") , newSVpv(owner, 0), 0);
hv_store(RETVAL, "lastChanged", strlen("lastChanged") ,
newSVpv(lastChanged, 0), 0);
if (changeDiary) {
ret = ARDecodeDiary(control, changeDiary, &diaryList, &status);
if (!ARError(ret, status)) {
hv_store(RETVAL, "changeDiary", strlen("changeDiary") ,
perl_ARList(control, (ARList *)&diaryList,
(ARS_fn)perl_diary,
sizeof(ARDiaryStruct)), 0);
FreeARDiaryList(&diaryList, FALSE);
}
}
hv_store(RETVAL, "referenceList", strlen("referenceList") ,
perl_ARReferenceList(control, &references), 0);
if (label)
hv_store(RETVAL, "label", strlen("label") , newSVpv(label, 0), 0);
if (description)
hv_store(RETVAL, "description", strlen("description") , newSVpv(description, 0), 0);
hv_store(RETVAL, "numReferences", strlen("numReferences") , newSViv(references.numItems), 0);
FreeARPermissionList(&groupList,FALSE);
FreeARInternalIdList(&adminGroupList,FALSE);
FreeARContainerOwnerObjList(&ownerObjList,FALSE);
FreeARReferenceList(&references,FALSE);
FreeARPropList(&objPropList, FALSE);
if(helpText)
arsperl_FreeARTextString(helpText);
if(changeDiary)
arsperl_FreeARTextString(changeDiary);
if(label)
arsperl_FreeARTextString(label);
if(description)
arsperl_FreeARTextString(description);
}
}
OUTPUT:
RETVAL
void
ars_GetListServer()
PPCODE:
{
ARServerNameList serverList;
ARStatusList status;
int ret = 0;
unsigned int i = 0;
ARControlStruct ctrl;
(void) ARError_reset();
Zero(&serverList, 1, ARServerNameList);
Zero(&status, 1, ARStatusList);
Zero(&ctrl, 1, ARControlStruct);
#if AR_EXPORT_VERSION >= 4
/* this function can be called without a control struct
* (or even before a control struct is available).
* we will create a bogus control struct, initialize it
* and execute the function. this seems to work fine.
*/
ARInitialization(&ctrl, &status);
ret = ARGetListServer(&ctrl, &serverList, &status);
#else
ret = ARGetListServer(&serverList, &status);
#endif
if (! ARError( ret, status)) {
for (i=0; i<serverList.numItems; i++) {
XPUSHs(sv_2mortal(newSVpv(serverList.nameList[i], 0)));
}
FreeARServerNameList(&serverList,FALSE);
}
}
HV *
ars_GetActiveLink(ctrl,name)
ARControlStruct * ctrl
char * name
CODE:
{
int ret = 0;
unsigned int order = 0;
ARInternalIdList assignedGroupList;
ARInternalIdList groupList;
unsigned int executeMask = 0;
ARInternalId controlField;
ARInternalId focusField;
unsigned int enable = 0;
ARActiveLinkActionList actionList;
ARActiveLinkActionList elseList;
ARWorkflowConnectStruct schemaList;
ARPropList objPropList;
char *helpText = CPNULL;
ARTimestamp timestamp;
ARAccessNameType owner;
ARAccessNameType lastChanged;
char *changeDiary = CPNULL;
ARStatusList status;
SV *ref;
ARQualifierStruct *query;
ARDiaryList diaryList;
AMALLOCNN(query,1,ARQualifierStruct);
hv_store(RETVAL, "order", strlen("order") , newSViv(order), 0);
hv_store(RETVAL, "schemaList", strlen("schemaList") , /* WorkflowConnectStruct */
perl_ARNameList(ctrl, schemaList.u.schemaList), 0);
hv_store(RETVAL, "objPropList", strlen("objPropList") ,
perl_ARPropList(ctrl, &objPropList), 0);
hv_store(RETVAL, "opSet", strlen("opSet") , newSViv(opSet), 0);
hv_store(RETVAL, "enable", strlen("enable") , newSViv(enable), 0);
/* a bit of a hack -- makes blessed reference to qualifier */
ref = newSViv(0);
sv_setref_pv(ref, "ARQualifierStructPtr", (void *)query);
hv_store(RETVAL, "query", strlen("query") , ref, 0);
hv_store(RETVAL, "actionList", strlen("actionList") ,
perl_ARList(ctrl,
(ARList *)&actionList,
(ARS_fn)perl_ARFilterActionStruct,
sizeof(ARFilterActionStruct)), 0);
hv_store(RETVAL, "elseList", strlen("elseList") ,
perl_ARList(ctrl,
(ARList *)&elseList,
(ARS_fn)perl_ARFilterActionStruct,
sizeof(ARFilterActionStruct)), 0);
if(helpText)
hv_store(RETVAL, "helpText", strlen("helpText") , newSVpv(helpText, 0), 0);
hv_store(RETVAL, "timestamp", strlen("timestamp") , newSViv(timestamp), 0);
hv_store(RETVAL, "owner", strlen("owner") , newSVpv(owner, 0), 0);
hv_store(RETVAL, "lastChanged", strlen("lastChanged") , newSVpv(lastChanged, 0), 0);
if (changeDiary) {
ret = ARDecodeDiary(ctrl, changeDiary, &diaryList, &status);
if (!ARError(ret, status)) {
hv_store(RETVAL, "changeDiary", strlen("changeDiary") ,
perl_ARList(ctrl, (ARList *)&diaryList,
(ARS_fn)perl_diary,
sizeof(ARDiaryStruct)), 0);
FreeARDiaryList(&diaryList, FALSE);
}
}
#if AR_CURRENT_API_VERSION >= 13
hv_store(RETVAL, "errorFilterOptions", strlen("errorFilterOptions") , newSViv(errorFilterOptions), 0);
hv_store(RETVAL, "errorFilterName", strlen("errorFilterName") , newSVpv(errorFilterName, 0), 0);
#endif
FreeARFilterActionList(&actionList,FALSE);
FreeARFilterActionList(&elseList,FALSE);
FreeARWorkflowConnectStruct(&schemaList, FALSE);
FreeARPropList(&objPropList, FALSE);
if(helpText) {
AP_FREE(helpText);
}
if(changeDiary) {
AP_FREE(changeDiary);
}
}else{
XSRETURN_UNDEF;
}
}
OUTPUT:
RETVAL
void
ars_GetServerStatistics(ctrl,...)
ARControlStruct * ctrl
PPCODE:
{
ARServerInfoRequestList requestList;
ARServerInfoList serverInfo;
int i = 0, ret = 0;
unsigned int ui = 0;
ARStatusList status;
(void) ARError_reset();
Zero(&requestList, 1, ARServerInfoRequestList);
Zero(&serverInfo, 1, ARServerInfoList);
Zero(&status, 1, ARStatusList);
if(items < 1) {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
} else {
requestList.numItems = items - 1;
AMALLOCNN(requestList.requestList,(items-1),unsigned int);
if(requestList.requestList) {
for(i=1; i<items; i++) {
requestList.requestList[i-1] = SvIV(ST(i));
}
ret = ARGetServerStatistics(ctrl, &requestList, &serverInfo, &status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (!ARError(ret, status)) {
for(ui=0; ui<serverInfo.numItems; ui++) {
XPUSHs(sv_2mortal(newSViv(serverInfo.serverInfoList[ui].operation)));
switch(serverInfo.serverInfoList[ui].value.dataType) {
case AR_DATA_TYPE_ENUM:
case AR_DATA_TYPE_TIME:
case AR_DATA_TYPE_BITMASK:
case AR_DATA_TYPE_INTEGER:
XPUSHs(sv_2mortal(newSViv(serverInfo.serverInfoList[ui].value.u.intVal)));
break;
case AR_DATA_TYPE_REAL:
XPUSHs(sv_2mortal(newSVnv(serverInfo.serverInfoList[ui].value.u.realVal)));
break;
case AR_DATA_TYPE_CHAR:
XPUSHs(sv_2mortal(newSVpv(serverInfo.serverInfoList[ui].value.u.charVal,
strlen(serverInfo.serverInfoList[ui].value.u.charVal))));
break;
}
}
}
FreeARServerInfoList(&serverInfo, FALSE);
FreeARServerInfoRequestList(&requestList, FALSE);
} else {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_MALLOC);
}
}
}
HV *
ars_GetCharMenu(ctrl,name)
ARControlStruct * ctrl
char * name
CODE:
{
unsigned int refreshCode = 0;
hv_store(RETVAL, "getListFields", strlen("getListFields") ,
perl_ARList(ctrl, (ARList *)&getListFields,
(ARS_fn)perl_AREntryListFieldStruct,
sizeof(AREntryListFieldStruct)),0);
hv_store(RETVAL, "indexList", strlen("indexList") ,
perl_ARList(ctrl, (ARList *)&indexList,
(ARS_fn)perl_ARIndexStruct,
sizeof(ARIndexStruct)), 0);
if (helpText)
hv_store(RETVAL, "helpText", strlen("helpText") , newSVpv(helpText, 0), 0);
hv_store(RETVAL, "timestamp", strlen("timestamp") , newSViv(timestamp), 0);
hv_store(RETVAL, "owner", strlen("owner") , newSVpv(owner, 0), 0);
hv_store(RETVAL, "lastChanged", strlen("lastChanged") ,
newSVpv(lastChanged, 0), 0);
hv_store(RETVAL, "name", strlen("name") , newSVpv(name, 0), 0);
if (changeDiary) {
ret = ARDecodeDiary(ctrl, changeDiary, &diaryList, &status);
if (!ARError(ret, status)) {
hv_store(RETVAL, "changeDiary", strlen("changeDiary") ,
perl_ARList(ctrl, (ARList *)&diaryList,
(ARS_fn)perl_diary,
sizeof(ARDiaryStruct)), 0);
FreeARDiaryList(&diaryList, FALSE);
}
}
hv_store(RETVAL, "schema", strlen("schema") ,
perl_ARCompoundSchema(ctrl, &schema), 0);
hv_store(RETVAL, "sortList", strlen("sortList") ,
perl_ARSortList(ctrl, &sortList), 0);
#if AR_EXPORT_VERSION >= 8L
hv_store(RETVAL, "archiveInfo", strlen("archiveInfo") ,
perl_ARArchiveInfoStruct(ctrl, &infoStruct), 0);
#endif
#if AR_EXPORT_VERSION >= 9L
hv_store(RETVAL, "auditInfo", strlen("auditInfo") ,
perl_ARAuditInfoStruct(ctrl, &auditInfo), 0);
#endif
FreeARPermissionList(&groupList,FALSE);
FreeARInternalIdList(&adminGroupList,FALSE);
FreeAREntryListFieldList(&getListFields,FALSE);
FreeARIndexList(&indexList,FALSE);
if(helpText) {
AP_FREE(helpText);
}
if(changeDiary) {
AP_FREE(changeDiary);
}
FreeARCompoundSchema(&schema,FALSE);
FreeARSortList(&sortList,FALSE);
}
}
OUTPUT:
RETVAL
void
ars_GetListActiveLink(ctrl,schema=NULL,changedSince=0)
ARControlStruct * ctrl
char * schema
int changedSince
PPCODE:
{
ARNameList nameList;
ARStatusList status;
ARPropList propList;
int ret = 0;
unsigned int i = 0;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&nameList, 1, ARNameList);
Zero(&propList, 1, ARPropList);
#if AR_EXPORT_VERSION >= 8L
Zero(&propList, 1, ARPropList);
#endif
ret=ARGetListActiveLink(ctrl,schema,changedSince,
#if AR_EXPORT_VERSION >= 8L
&propList,
#endif
&nameList,&status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (! ARError( ret,status)) {
for (i=0; i<nameList.numItems; i++)
XPUSHs(sv_2mortal(newSVpv(nameList.nameList[i],0)));
FreeARNameList(&nameList,FALSE);
}
}
HV *
ars_GetField(ctrl,schema,id)
ARControlStruct * ctrl
char * schema
unsigned long id
CODE:
{
int ret;
ARStatusList Status;
unsigned int dataType, option, createMode;
#if AR_CURRENT_API_VERSION >= 12
unsigned int fieldOption;
#endif
ARValueStruct defaultVal;
ARPermissionList assignedGroupList;
ARPermissionList permissions;
ARFieldLimitStruct limit;
ARNameType fieldName;
ARFieldMappingStruct fieldMap;
ARDisplayInstanceList displayList;
char *helpText = CPNULL;
ARTimestamp timestamp;
ARAccessNameType owner;
ARAccessNameType lastChanged;
char *changeDiary = CPNULL;
ARDiaryList diaryList;
ARPropList objPropList;
(void) ARError_reset();
Zero(&Status, 1, ARStatusList);
Zero(&defaultVal, 1, ARValueStruct);
structItems->numItems = c;
AMALLOCNN(structItems->structItemList, c,
ARStructItemStruct);
for (i = 0; i < c; i++) {
unsigned int et = 0;
a = i*2+3;
et = caseLookUpTypeNumber((TypeMapStruct *)
StructItemTypeMap,
SvPV(ST(a), PL_na)
);
if(et == TYPEMAP_LAST) {
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_BAD_IMP);
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_CONTINUE,
SvPV(ST(a), PL_na) );
ok = 0;
} else {
structItems->structItemList[i].type = et;
strncpy(structItems->structItemList[i].name,
SvPV(ST(a+1), PL_na),
sizeof(ARNameType) );
structItems->structItemList[i].name[sizeof(ARNameType)-1] = '\0';
}
}
}
}
if(ok) {
ret = ARImport(ctrl, structItems, importBuf,
#if AR_EXPORT_VERSION >= 5
importOption,
#endif
#if AR_CURRENT_API_VERSION >= 17
objectModificationLogLabel,
#endif
&status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (ARError(ret, status)) {
RETVAL = 0;
} else {
RETVAL = 1;
}
} else {
RETVAL = 0;
}
if (structItems != NULL)
{
AP_FREE(structItems->structItemList);
AP_FREE(structItems);
}
}
OUTPUT:
RETVAL
void
ars_GetListFilter(control,schema=NULL,changedsince=0)
ARControlStruct * control
char * schema
unsigned long changedsince
PPCODE:
{
ARNameList nameList;
ARStatusList status;
#if AR_EXPORT_VERSION >= 8L
ARPropList propList;
#endif
int ret = 0;
unsigned int i = 0;
(void) ARError_reset();
#if AR_EXPORT_VERSION >= 8L
Zero(&propList, 1, ARPropList);
#endif
Zero(&nameList, 1, ARNameList);
Zero(&status, 1,ARStatusList);
ret = ARGetListFilter(control,schema,changedsince,
#if AR_EXPORT_VERSION >= 8L
&propList,
#endif
&nameList,&status);
#ifdef PROFILE
((ars_ctrl *)control)->queries++;
#endif
if (!ARError( ret,status)) {
for (i=0; i < nameList.numItems; i++)
XPUSHs(sv_2mortal(newSVpv(nameList.nameList[i], 0)));
FreeARNameList(&nameList,FALSE);
}
}
void
ars_GetListEscalation(control,schema=NULL,changedsince=0)
ARControlStruct * control
char * schema
unsigned long changedsince
PPCODE:
{
ARNameList nameList;
ARStatusList status;
ARPropList propList;
int ret = 0;
unsigned int i = 0;
(void) ARError_reset();
#if AR_EXPORT_VERSION >= 8L
Zero(&propList, 1,ARPropList);
#endif
Zero(&nameList, 1, ARNameList);
Zero(&status, 1,ARStatusList);
ret = ARGetListEscalation(control,schema,changedsince,
#if AR_EXPORT_VERSION >= 8L
&propList,
#endif
&nameList,&status);
#ifdef PROFILE
((ars_ctrl *)control)->queries++;
#endif
if (!ARError( ret,status)) {
for (i=0; i<nameList.numItems; i++)
XPUSHs(sv_2mortal(newSVpv(nameList.nameList[i], 0)));
FreeARNameList(&nameList,FALSE);
}
}
void
ars_GetListCharMenu(control,changedsince=0)
ARControlStruct * control
unsigned long changedsince
PPCODE:
{
ARNameList nameList;
ARStatusList status;
#if AR_EXPORT_VERSION >= 8L
ARPropList propList;
#endif
ARNameList schemaNameList;
ARNameList actLinkNameList;
int ret = 0;
unsigned int i = 0;
(void) ARError_reset();
#if AR_EXPORT_VERSION >= 8L
Zero(&propList, 1, ARPropList);
#endif
Zero(&status, 1, ARStatusList);
Zero(&schemaNameList, 1, ARNameList);
Zero(&actLinkNameList, 1, ARNameList);
Zero(&nameList, 1, ARNameList);
ret = ARGetListCharMenu(control,changedsince,
#if AR_EXPORT_VERSION >= 8L
&schemaNameList, &actLinkNameList, &propList,
#endif
&nameList,&status);
#ifdef PROFILE
((ars_ctrl *)control)->queries++;
#endif
if (!ARError( ret,status)) {
for (i=0; i<nameList.numItems; i++)
XPUSHs(sv_2mortal(newSVpv(nameList.nameList[i], 0)));
FreeARNameList(&nameList,FALSE);
}
}
void
ars_GetListImage(ctrl,schema=NULL,changedSince=0,imageType=NULL)
ARControlStruct * ctrl
SV * schema
ARTimestamp changedSince
char * imageType
PPCODE:
{
ARStatusList status;
#if AR_CURRENT_API_VERSION >= 14
ARNameList schemaList;
ARNameList *schemaListPtr = NULL;
ARNameList nameList;
ARPropList propList;
int ret = 0, rv = 0;
unsigned int i = 0;
(void) ARError_reset();
Zero(&propList, 1, ARPropList);
Zero(&schemaList, 1, ARNameList);
Zero(&nameList, 1, ARNameList);
Zero(&status, 1,ARStatusList);
if( schema == NULL ){
/* do nothing */
}else if( SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVAV ){
HV *h_dummy = newHV();
SvREFCNT_inc( schema );
hv_store( h_dummy, "_", 1, schema, 0 );
rv += rev_ARNameList( ctrl, h_dummy, "_", &schemaList );
hv_undef( h_dummy );
schemaListPtr = &schemaList;
}else if( SvPOK(schema) ){
STRLEN len = 0;
char *str = SvPV( schema, len );
if( len > 0 ){
schemaList.numItems = 1;
schemaList.nameList = (ARNameType*) MALLOCNN(sizeof(ARNameType) * 1);
strncpy( schemaList.nameList[0], str, AR_MAX_NAME_SIZE );
}
schemaListPtr = &schemaList;
}
if( rv == 0 ){
ret = ARGetListImage( ctrl,
schemaListPtr,
changedSince,
imageType,
#if AR_CURRENT_API_VERSION >= 19
&propList, // at the moment we don't want to search for specific properties
#endif
&nameList,
&status );
}else{
ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
}
if (rv == 0 && !ARError( ret,status)) {
for (i=0; i < nameList.numItems; i++){
XPUSHs(sv_2mortal(newSVpv(nameList.nameList[i], 0)));
}
FreeARNameList(&nameList,FALSE);
}
FreeARNameList(&schemaList,FALSE);
#else /* prior to ARS 7.5 */
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
#endif
if(!ARError( ret, status))
RETVAL = 1;
FreeARInternalIdList(&fieldList, FALSE);
}
#else /* 2.x */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED, "Not available in 2.x");
#endif
}
OUTPUT:
RETVAL
int
ars_DeleteImage(ctrl, name, updateRef=FALSE)
ARControlStruct * ctrl
char * name
ARBoolean updateRef
CODE:
{
char *objectModificationLogLabel = NULL;
ARStatusList status;
#if AR_CURRENT_API_VERSION >= 14
int ret = 0;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
RETVAL = 0;
if(ctrl && name && *name) {
ret = ARDeleteImage(ctrl, name,
updateRef,
#if AR_CURRENT_API_VERSION >= 17
objectModificationLogLabel,
#endif
&status);
if( !ARError( ret, status) ){
RETVAL = 1;
}
}else{
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
}
#else /* prior to ARS 7.5 */
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ars_DeleteImage() is only available in ARS >= 7.5");
XSRETURN_UNDEF;
#endif
}
OUTPUT:
RETVAL
void
ars_ExecuteProcess(ctrl, command, runOption=0)
ARControlStruct * ctrl
char * command
int runOption
PPCODE:
{
ARStatusList status;
int returnStatus = 0;
char *returnString;
int ret = 0;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
#if AR_EXPORT_VERSION >= 3
if(ctrl && CVLD(command)) {
if(runOption == 0)
ret = ARExecuteProcess(ctrl, command, &returnStatus, &returnString, &status);
else
ret = ARExecuteProcess(ctrl, command, NULL, NULL, &status);
}
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
/* if all went well, and user requested synchronous processing
* then we push the returnStatus and returnString back out to them.
* if they requested async, then we just push a 1 to indicate that the
* command to the API was successfully handled (and foo || die constructs
* will work correctly).
*/
if(!ARError( ret, status)) {
if(runOption == 0) {
XPUSHs(sv_2mortal(newSViv(returnStatus)));
XPUSHs(sv_2mortal(newSVpv(returnString, 0)));
if(returnString) AP_FREE(returnString);
} else {
XPUSHs(sv_2mortal(newSViv(1)));
}
}
#else /* 2.x */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED, "Not available in 2.x");
#endif
}
HV *
ars_GetEscalation(ctrl, name)
ARControlStruct * ctrl
char * name
CODE:
{
ARStatusList status;
AREscalationTmStruct escalationTm;
unsigned int enable = 0;
ARFilterActionList actionList;
ARFilterActionList elseList;
char *helpText = CPNULL;
ARTimestamp timestamp;
ARAccessNameType owner;
ARAccessNameType lastChanged;
char *changeDiary = CPNULL;
SV *ref;
int ret;
ARQualifierStruct *query = MALLOCNN(sizeof(ARQualifierStruct));
ARDiaryList diaryList;
ARWorkflowConnectStruct schemaList;
#ifdef GETLISTGROUP_OLD_STYLE
HV *
ars_GetListGroup(ctrl, userName=NULL,password=NULL)
ARControlStruct * ctrl
char * userName
char * password
CODE:
{
ARStatusList status;
ARGroupInfoList groupList;
int ret = 0;
unsigned int i = 0, v = 0;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&groupList, 1, ARGroupInfoList);
RETVAL = newHV();
sv_2mortal( (SV*) RETVAL );
ret = ARGetListGroup(ctrl, userName,
#if AR_EXPORT_VERSION >= 6
password,
#endif
&groupList, &status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if(!ARError( ret, status)) {
AV *gidList = newAV(), *gtypeList = newAV(),
*gnameListList = newAV(), *gnameList;
for(i = 0; i < groupList.numItems; i++) {
av_push(gidList, newSViv(groupList.groupList[i].groupId));
av_push(gtypeList, newSViv(groupList.groupList[i].groupType));
gnameList = newAV();
for(v = 0; v < groupList.groupList[i].groupName.numItems ; v++) {
av_push(gnameList, newSVpv(groupList.groupList[i].groupName.nameList[v], 0));
}
av_push(gnameListList, newRV_noinc((SV *)gnameList));
}
hv_store(RETVAL, "groupId", strlen("groupId") , newRV_noinc((SV *)gidList), 0);
hv_store(RETVAL, "groupType", strlen("groupType") , newRV_noinc((SV *)gtypeList), 0);
hv_store(RETVAL, "groupName", strlen("groupName") , newRV_noinc((SV *)gnameListList), 0);
FreeARGroupInfoList(&groupList, FALSE);
}
}
OUTPUT:
RETVAL
#else
void
ars_GetListGroup(ctrl, userName=NULL,password=NULL)
ARControlStruct * ctrl
char * userName
char * password
PPCODE:
{
ARStatusList status;
ARGroupInfoList groupList;
int ret = 0;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&groupList, 1, ARGroupInfoList);
ret = ARGetListGroup(ctrl, userName,
#if AR_EXPORT_VERSION >= 6
password,
#endif
&groupList, &status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if(!ARError( ret, status)) {
unsigned int i;
for(i = 0; i < groupList.numItems; i++) {
unsigned int v;
HV *groupInfo = newHV();
AV *gnameList = newAV();
for(v = 0; v < groupList.groupList[i].groupName.numItems ; v++) {
av_push(gnameList, newSVpv(groupList.groupList[i].groupName.nameList[v], 0));
}
hv_store(groupInfo, "groupId", 7, newSViv(groupList.groupList[i].groupId), 0);
hv_store(groupInfo, "groupType", 9, newSViv(groupList.groupList[i].groupType), 0);
hv_store(groupInfo, "groupName", 9, newRV_noinc((SV *)gnameList), 0);
#if AR_CURRENT_API_VERSION >= 10
hv_store(groupInfo, "groupCategory", 13, newSViv(groupList.groupList[i].groupCategory), 0);
#endif
XPUSHs(sv_2mortal(newRV_noinc((SV *)groupInfo)));
}
}
FreeARGroupInfoList(&groupList, FALSE);
}
#endif
void
ars_GetListRole(ctrl, applicationName, userName=NULL,password=NULL)
ARControlStruct * ctrl
ARNameType applicationName
char * userName
char * password
PPCODE:
{
#if AR_EXPORT_VERSION >= 8L
ARStatusList status;
ARRoleInfoList roleList;
int ret = 0;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&roleList, 1, ARRoleInfoList);
ret = ARGetListRole(ctrl,
applicationName,
userName,
password,
&roleList, &status);
if(!ARError( ret, status)) {
unsigned int i;
for(i = 0; i < roleList.numItems; i++) {
HV *roleInfo = newHV();
hv_store(roleInfo, "roleId", 6, newSViv(roleList.roleList[i].roleId), 0);
hv_store(roleInfo, "roleType", 8, newSViv(roleList.roleList[i].roleType), 0);
hv_store(roleInfo, "roleName", 8, newSVpv(roleList.roleList[i].roleName,0), 0);
XPUSHs(sv_2mortal(newRV_noinc((SV *)roleInfo)));
}
}
FreeARRoleInfoList(&roleList, FALSE);
#else /* < 6.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ars_GetListRole() is only available in ARS >= 6.0");
#endif
}
void
ars_GetListLicense(ctrl, licenseType=NULL)
ARControlStruct * ctrl
char * licenseType
PPCODE:
{
#if AR_EXPORT_VERSION >= 6L
ARStatusList status;
ARLicenseInfoList licList;
int ret = 0;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&licList, 1, ARLicenseInfoList);
ret = ARGetListLicense(ctrl,
licenseType,
&licList, &status);
if(!ARError( ret, status)) {
unsigned int i;
for(i = 0; i < licList.numItems; i++) {
HV *licInfo = newHV();
hv_store(licInfo, "licKey", 6, newSVpv(licList.licenseInfoList[i].licKey,0), 0);
hv_store(licInfo, "licType", 8, newSVpv(licList.licenseInfoList[i].licType,0), 0);
hv_store(licInfo, "licSubtype", 10, newSVpv(licList.licenseInfoList[i].licSubtype,0), 0);
hv_store(licInfo, "issuedDate", 10,
perl_ARLicenseDateStruct(ctrl, &(licList.licenseInfoList[i].issuedDate)), 0);
hv_store(licInfo, "expireDate", 10,
perl_ARLicenseDateStruct(ctrl, &(licList.licenseInfoList[i].expireDate)), 0);
hv_store(licInfo, "hostId", 6, newSVpv(licList.licenseInfoList[i].hostId,0), 0);
hv_store(licInfo, "numLicenses", 11, newSViv(licList.licenseInfoList[i].numLicenses), 0);
hv_store(licInfo, "tokenList", 9, newSVpv(licList.licenseInfoList[i].tokenList,0), 0);
hv_store(licInfo, "comment", 7, newSVpv(licList.licenseInfoList[i].comment,0), 0);
XPUSHs(sv_2mortal(newRV_noinc((SV *)licInfo)));
}
}
FreeARLicenseInfoList(&licList, FALSE);
#else /* < 6.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ars_GetListLicense() is only available in ARS >= 5.0");
#endif
}
HV *
ars_GetListSQL(ctrl, sqlCommand, maxRetrieve=AR_NO_MAX_LIST_RETRIEVE)
ARControlStruct * ctrl
char * sqlCommand
unsigned int maxRetrieve
PPCODE:
{
ARStatusList status;
ARValueListList valueListList;
unsigned int numMatches = 0;
int ret = 0;
(void) ARError_reset();
RETVAL = NULL;
Zero(&status, 1, ARStatusList);
Zero(&valueListList, 1, ARValueListList);
#ifndef ARS20
ret = ARGetListSQL(ctrl, sqlCommand, maxRetrieve, &valueListList,
&numMatches, &status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if(!ARError( ret, status)) {
unsigned int row, col;
AV *ra = newAV(), *ca;
RETVAL = newHV();
hv_store(RETVAL, "numMatches", strlen("numMatches") , newSViv(numMatches), 0);
for(row = 0; row < valueListList.numItems ; row++) {
ca = newAV();
for(col = 0; col < valueListList.valueListList[row].numItems;
col++)
{
av_push(ca, perl_ARValueStruct(ctrl,
&(valueListList.valueListList[row].valueList[col])));
}
av_push(ra, newRV_noinc((SV *)ca));
}
hv_store(RETVAL, "rows", strlen("rows") , newRV_noinc((SV *)ra), 0);
FreeARValueListList(&valueListList, FALSE);
}
#else
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED, "Not available in pre-2.1 ARS");
#endif
if(RETVAL != NULL) {
XPUSHs(sv_2mortal(newRV_noinc((SV *)RETVAL)));
} else {
XPUSHs(sv_2mortal(newSViv(0)));
}
}
void
ars_GetListUser(ctrl, userListType=AR_USER_LIST_MYSELF,changedSince=0)
ARControlStruct * ctrl
unsigned int userListType
ARTimestamp changedSince
PPCODE:
{
ARStatusList status;
ARUserInfoList userList;
int ret = 0;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&userList, 1, ARUserInfoList);
ret = ARGetListUser(ctrl, userListType,
#if AR_EXPORT_VERSION >= 6
changedSince,
#endif
&userList, &status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if(!ARError( ret, status)) {
unsigned int i, j;
for(i = 0; i < userList.numItems; i++) {
HV *userInfo = newHV();
AV *licenseTag = newAV(),
*licenseType = newAV(),
*currentLicenseType = newAV();
hv_store(userInfo, "userName", strlen("userName") ,
newSVpv(userList.userList[i].userName, 0), 0);
hv_store(userInfo, "connectTime", strlen("connectTime") ,
newSViv(userList.userList[i].connectTime), 0);
hv_store(userInfo, "lastAccess", strlen("lastAccess") ,
newSViv(userList.userList[i].lastAccess), 0);
hv_store(userInfo, "defaultNotifyMech", strlen("defaultNotifyMech") ,
newSViv(userList.userList[i].defaultNotifyMech), 0);
hv_store(userInfo, "emailAddr", strlen("emailAddr") ,
newSVpv(userList.userList[i].emailAddr, 0), 0);
for(j = 0; j < userList.userList[i].licenseInfo.numItems; j++) {
av_push(licenseTag, newSViv(userList.userList[i].licenseInfo.licenseList[j].licenseTag));
av_push(licenseType, newSViv(userList.userList[i].licenseInfo.licenseList[j].licenseType));
av_push(currentLicenseType, newSViv(userList.userList[i].licenseInfo.licenseList[j].currentLicenseType));
}
hv_store(userInfo, "licenseTag", strlen("licenseTag") , newRV_noinc((SV *)licenseTag), 0);
hv_store(userInfo, "licenseType", strlen("licenseType") , newRV_noinc((SV *)licenseType), 0);
hv_store(userInfo, "currentLicenseType", strlen("currentLicenseType") , newRV_noinc((SV *)currentLicenseType), 0);
XPUSHs(sv_2mortal(newRV_noinc((SV *)userInfo)));
}
FreeARUserInfoList(&userList, FALSE);
}
}
void
ars_GetListVUI(ctrl, schema, changedSince=0)
ARControlStruct * ctrl
char * schema
unsigned int changedSince
PPCODE:
{
#if AR_EXPORT_VERSION >= 3
ARStatusList status;
ARInternalIdList idList;
int ret = 0;
unsigned int i = 0;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&idList, 1, ARInternalIdList);
ret = ARGetListVUI(ctrl, schema,
changedSince,
#if AR_CURRENT_API_VERSION >= 17
NULL, /* &objPropList (undocumented by BMC) */
#endif
&idList,
&status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if(!ARError( ret, status)) {
for(i = 0 ; i < idList.numItems ; i++) {
XPUSHs(sv_2mortal(newSViv(idList.internalIdList[i])));
}
}
FreeARInternalIdList(&idList, FALSE);
#else /* ars 2.x */
(void) ARError_reset();
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED, "Not available in 2.x");
#endif
}
void
ars_SetServerInfo(ctrl, ...)
ARControlStruct * ctrl
PPCODE:
{
ARStatusList status;
ARServerInfoList serverInfo;
int ret = 0, i = 0, count = 0;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
Zero(&serverInfo, 1, ARServerInfoList);
if((items == 1) || ((items % 2) == 0)) {
(void) ARError_add(AR_RETURN_ERROR,
AP_ERR_BAD_ARGS);
} else {
unsigned int infoType, j = 0;
char buf[256];
serverInfo.numItems = (items - 1) / 2;
serverInfo.serverInfoList = MALLOCNN(serverInfo.numItems * sizeof(ARServerInfoStruct));
/* Zero(serverInfo.serverInfoList, 1, ARServerInfoStruct); # happens already in MALLOCNN */
for(j = 0 ; j < serverInfo.numItems ; ++j) {
i = 2 * j + 1;
infoType = lookUpServerInfoTypeHint(SvIV(ST(i)));
serverInfo.serverInfoList[j].operation = SvIV(ST(i));
serverInfo.serverInfoList[j].value.dataType = infoType;
switch(infoType) {
case AR_DATA_TYPE_CHAR:
serverInfo.serverInfoList[j].value.u.charVal = strdup(SvPV(ST(i+1), PL_na));
break;
case AR_DATA_TYPE_INTEGER:
serverInfo.serverInfoList[j].value.u.intVal = SvIV(ST(i+1));
break;
default:
sprintf( buf, "(%d) type = %d", serverInfo.serverInfoList[j].operation, serverInfo.serverInfoList[j].value.dataType );
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_INV_ARGS,
buf);
FreeARServerInfoList(&serverInfo, FALSE);
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
goto SetServerInfo_fail;
}
}
ret = ARSetServerInfo(ctrl, &serverInfo, &status);
FreeARServerInfoList(&serverInfo, FALSE);
if(ARError(ret, status)) {
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
} else {
XPUSHs(sv_2mortal(newSViv(1))); /* OK */
}
}
SetServerInfo_fail:;
}
void
ars_GetServerInfo(ctrl, ...)
ARControlStruct * ctrl
PPCODE:
{
ARStatusList status;
ARServerInfoRequestList requestList;
ARServerInfoList serverInfo;
int ret = 0;
int i = 0;
unsigned int ui = 0, count = 0;
unsigned int rlist[AR_MAX_SERVER_INFO_USED];
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&requestList, 1, ARServerInfoRequestList);
Zero(&serverInfo, 1, ARServerInfoList);
count = 0;
if(items == 1) { /* none specified.. fetch all */
for(i = 0; i < AR_MAX_SERVER_INFO_USED ; i++) {
/* we'll exclude ones that can't be retrieved to avoid errors */
switch(i+1) {
case AR_SERVER_INFO_DB_PASSWORD:
#if AR_CURRENT_API_VERSION < 17
case 332:
case 331:
case 330:
case 329:
case 328:
case 327:
case 326:
case 325:
#endif
break;
default:
rlist[count++] = i+1;
}
}
}else if(items > AR_MAX_SERVER_INFO_USED + 1) {
ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
}else { /* user has asked for specific ones */
for(i = 1 ; i < items ; i++) {
rlist[count++] = SvIV(ST(i));
}
}
if(count > 0) {
requestList.numItems = count;
requestList.requestList = rlist;
ret = ARGetServerInfo(ctrl, &requestList, &serverInfo, &status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if(!ARError( ret, status)) {
for(ui = 0 ; ui < serverInfo.numItems ; ui++) {
/* provided we have a mapping for the operation code,
* push out it's translation. else push out the code itself
*/
if(serverInfo.serverInfoList[ui].operation <= AR_MAX_SERVER_INFO_USED) {
/* printf( "%d %s: data type = %d\n", serverInfo.serverInfoList[ui].operation, ServerInfoMap[serverInfo.serverInfoList[ui].operation].name, serverInfo.serverInfoList[ui].value.dataType ); */
XPUSHs(sv_2mortal(newSVpv(ServerInfoMap[serverInfo.serverInfoList[ui].operation].name, 0)));
} else {
XPUSHs(sv_2mortal(newSViv(serverInfo.serverInfoList[ui].operation)));
}
XPUSHs(sv_2mortal(perl_ARValueStruct(ctrl,
} else {
#if AR_CURRENT_API_VERSION >= 17
ret = ARGetFieldCached(ctrl, schema,
fieldList.fieldValueList[i].fieldId,
NULL, NULL, &dataType, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
#elif AR_EXPORT_VERSION >= 9
ret = ARGetFieldCached(ctrl, schema,
fieldList.fieldValueList[i].fieldId,
NULL, NULL, &dataType, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
#elif AR_EXPORT_VERSION >= 3
ret = ARGetFieldCached(ctrl, schema,
fieldList.fieldValueList[i].fieldId,
NULL, NULL, &dataType, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
#else
ret = ARGetFieldCached(ctrl, schema,
fieldList.fieldValueList[i].fieldId, &dataType,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, &status);
#endif
if (ARError( ret, status)) {
DBG( ("GetFieldCached failed %d\n", ret) );
goto merge_entry_end;
}
if (sv_to_ARValue(ctrl, ST(a+1), dataType,
&fieldList.fieldValueList[i].value) < 0) {
DBG( ("failed to convert to ARValue struct stack %d\n", a+1) );
goto merge_entry_end;
}
}
}
ret = ARMergeEntry(ctrl, schema, &fieldList, mergeType,
#if AR_CURRENT_API_VERSION >= 18
NULL, /* ARQualifier *query */
0, /* unsigned int multimatchOption */
#endif
entryId, &status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (! ARError( ret, status)) {
DBG( ("MergeEntry returned %d\n", ret) );
DBG( ("entryId %s\n", SAFEPRT(entryId)) );
RETVAL = entryId;
}
merge_entry_end:;
if (fieldList.fieldValueList) AP_FREE(fieldList.fieldValueList);
merge_entry_exit:;
}
OUTPUT:
RETVAL
void
ars_GetMultipleEntries(ctrl,schema,...)
ARControlStruct * ctrl
char * schema
PPCODE:
{
int ret = 0;
unsigned int c = items - 3, i;
AREntryIdListList entryList;
ARInternalIdList idList;
ARFieldValueListList fieldList;
ARBooleanList existList;
ARStatusList status;
AV *entryList_array;
entryList.entryIdList = NULL;
idList.internalIdList = NULL;
fieldList.valueListList = NULL;
existList.booleanList = NULL;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
Zero(&entryList, 1, AREntryIdListList);
Zero(&idList, 1, ARInternalIdList);
Zero(&fieldList, 1, ARFieldValueListList);
Zero(&existList, 1, ARBooleanList);
/*
* build list of field Id's
*/
if (c < 1) {
idList.numItems = 0; /* get all fields */
} else {
idList.numItems = c;
idList.internalIdList = MALLOCNN(sizeof(ARInternalId) * c);
for (i=0; i<c; i++)
idList.internalIdList[i] = SvIV(ST(i+3));
}
/*
* build list of entry Id's
*/
if ( SvROK(ST(2)) &&
(entryList_array = (AV *)SvRV(ST(2))) &&
(SvTYPE(entryList_array) == SVt_PVAV) ) {
entryList.numItems = av_len(entryList_array) + 1;
/* Newz(777,entryList.entryIdList,entryList.numItems,AREntryIdList); */
entryList.entryIdList =
MALLOCNN( entryList.numItems * sizeof(AREntryIdList) );
for (i=0; i<entryList.numItems; i++) {
SV **array_entry;
if (! (array_entry = av_fetch(entryList_array, i, 0))) {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_EID);
FreeAREntryIdListList(&entryList,FALSE);
goto get_mentry_cleanup;
}
if( perl_BuildEntryList(ctrl,
&entryList.entryIdList[i],
SvPV(*array_entry, PL_na)) != 0 ) {
FreeAREntryIdListList(&entryList,FALSE);
goto get_mentry_cleanup;
}
}
} else {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_EID );
* build PERL copy of returned entries
*/
for (i=0; i < entryList.numItems; i++) {
HV * fieldValue_hash;
unsigned int field;
char intstr[12];
/*
* push entryID onto list
*/
if (entryList.entryIdList[i].numItems == 1) {
/* only one entryId -- so just return its value to be compatible
with ars 2 */
XPUSHs(sv_2mortal(newSVpv(entryList.entryIdList[i].entryIdList[0], 0)));
} else {
/* more than one entry -- this must be a join schema. merge
* the list into a single entry-id to keep things
* consistent. */
unsigned int entry;
char *joinId = (char *)NULL;
char joinSep[2] = {AR_ENTRY_ID_SEPARATOR, 0};
for (entry=0; entry < entryList.entryIdList[i].numItems; entry++) {
joinId = strappend(joinId, entryList.entryIdList[i].entryIdList[entry]);
if(entry < entryList.entryIdList[i].numItems-1)
joinId = strappend(joinId, joinSep);
}
XPUSHs(sv_2mortal(newSVpv(joinId, 0)));
}
/*
* push field/value hash reference onto list
*/
if ( existList.booleanList[i] ) {
fieldValue_hash = newHV();
/* sv_2mortal( (SV *)fieldValue_hash ); */
for (field=0; field < fieldList.valueListList[i].numItems; field++) {
sprintf(intstr,"%ld",fieldList.valueListList[i].fieldValueList[field].fieldId);
hv_store( fieldValue_hash,
intstr, strlen(intstr),
perl_ARValueStruct(ctrl,&fieldList.valueListList[i].fieldValueList[field].value),
0 );
}
XPUSHs( sv_2mortal( newRV_noinc((SV *)fieldValue_hash) ) );
} else {
XPUSHs(&PL_sv_undef);
}
}
get_mentry_cleanup:;
FreeARInternalIdList(&idList, FALSE);
FreeAREntryIdListList(&entryList, FALSE);
FreeARFieldValueListList(&fieldList, FALSE);
FreeARBooleanList(&existList, FALSE);
}
void
ars_GetListEntryWithFields(ctrl,schema,qualifier,maxRetrieve=0,firstRetrieve=0,...)
ARControlStruct * ctrl
char * schema
ARQualifierStruct * qualifier
unsigned int firstRetrieve
unsigned int maxRetrieve
PPCODE:
{
ARStatusList status;
unsigned int c = (items - 5) / 2, i;
int field_off = 5;
ARSortList sortList;
AREntryListFieldValueList entryFieldValueList;
int ret = 0;
AREntryListFieldList getListFields, *getList = NULL;
AV *getListFields_array;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
Zero(&sortList, 1, ARSortList);
Zero(&entryFieldValueList, 1, AREntryListFieldValueList);
Zero(&getListFields, 1, AREntryListFieldList);
sortList.sortList = NULL;
getListFields.fieldsList = NULL;
entryFieldValueList.entryList = NULL;
if ((items - 5) % 2) {
/* odd number of arguments, so argument after maxRetrieve is
optional getListFields (an array of hash refs) */
if ( SvROK(ST(field_off)) &&
(getListFields_array = (AV *)SvRV(ST(field_off))) &&
(SvTYPE(getListFields_array) == SVt_PVAV) ) {
getList = &getListFields;
getListFields.numItems = av_len(getListFields_array) + 1;
DBG( ("getListFields.numItems=%d\n", getListFields.numItems) );
/* Newz(777,getListFields.fieldsList, getListFields.numItems,AREntryListFieldStruct); */
getListFields.fieldsList = MALLOCNN( sizeof(AREntryListFieldStruct) * getListFields.numItems );
/* set query field list */
for (i=0; i<getListFields.numItems; i++) {
SV **array_entry;
/* get fieldID from array */
if (! (array_entry = av_fetch(getListFields_array, i, 0))) {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_LFLDS);
goto getlistentry_end;
}
getListFields.fieldsList[i].fieldId = SvIV(*array_entry);
getListFields.fieldsList[i].columnWidth = 1;
strncpy(getListFields.fieldsList[i].separator, " ", 2 );
DBG( ("i=%d, fieldId=%d, columnWidth=%d, separator=\"%s\"\n", i,
getListFields.fieldsList[i].fieldId,
getListFields.fieldsList[i].columnWidth,
getListFields.fieldsList[i].separator) );
}
} else {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_LFLDS_TYPE);
goto getlistentry_end;
}
/* increase the offset of the first sortList field by one */
field_off ++;
}
/* build sortList */
sortList.numItems = c;
/* Newz(777,sortList.sortList, c, ARSortStruct); */
sortList.sortList = MALLOCNN( sizeof(ARSortStruct) * c );
for (i=0; i<c; i++) {
sortList.sortList[i].fieldId = SvIV(ST(i*2+field_off));
sortList.sortList[i].sortOrder = SvIV(ST(i*2+field_off+1));
#if AR_EXPORT_VERSION >= 6
firstRetrieve,
#endif
maxRetrieve,
#if AR_EXPORT_VERSION >= 8L
FALSE,
#endif
&entryFieldValueList, NULL, &status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (ARError( ret, status)) {
goto getlistentry_end;
}
for (i=0; i < entryFieldValueList.numItems; i++) {
HV * fieldValue_hash = newHV();
unsigned int field;
char intstr[12];
if (entryFieldValueList.entryList[i].entryId.numItems == 1) {
/* only one entryId -- so just return its value to be compatible
with ars 2 */
XPUSHs(sv_2mortal(newSVpv(entryFieldValueList.entryList[i].entryId.entryIdList[0], 0)));
} else {
/* more than one entry -- this must be a join schema. merge
* the list into a single entry-id to keep things
* consistent. */
unsigned int entry;
char *joinId = (char *)NULL;
char joinSep[2] = {AR_ENTRY_ID_SEPARATOR, 0};
for (entry=0; entry < entryFieldValueList.entryList[i].entryId.numItems; entry++) {
joinId = strappend(joinId, entryFieldValueList.entryList[i].entryId.entryIdList[entry]);
if(entry < entryFieldValueList.entryList[i].entryId.numItems-1)
joinId = strappend(joinId, joinSep);
}
XPUSHs(sv_2mortal(newSVpv(joinId, 0)));
}
for (field=0; field < entryFieldValueList.entryList[i].entryValues->numItems; field++) {
sprintf(intstr,"%ld",entryFieldValueList.entryList[i].entryValues->fieldValueList[field].fieldId);
hv_store( fieldValue_hash,
intstr, strlen(intstr),
perl_ARValueStruct(ctrl,&entryFieldValueList.entryList[i].entryValues->fieldValueList[field].value),
0 );
}
XPUSHs( sv_2mortal( newRV_noinc((SV *)fieldValue_hash) ) );
}
getlistentry_end:
FreeAREntryListFieldValueList( &entryFieldValueList,FALSE );
FreeARSortList( &sortList, FALSE );
FreeAREntryListFieldList( &getListFields, FALSE );
}
void
ars_GetListEntryWithMultiSchemaFields(ctrl,schema,qualifier=NULL,maxRetrieve=0,firstRetrieve=0,fields=NULL,...)
ARControlStruct * ctrl
SV * schema
SV * qualifier
unsigned int firstRetrieve
unsigned int maxRetrieve
SV * fields
PPCODE:
{
ARStatusList status;
#if AR_CURRENT_API_VERSION >= 14
#if AR_CURRENT_API_VERSION >= 17
ARMultiSchemaFuncQueryFromList queryFromList;
ARMultiSchemaFieldFuncList getListFields;
ARMultiSchemaFieldFuncValueListList entryFieldValueList;
ARMultiSchemaFieldIdList *groupBy = NULL; /* TODO: support as function argument */
ARMultiSchemaFuncQualifierStruct *having = NULL; /* TODO: support as function argument */
#else
ARMultiSchemaQueryFromList queryFromList;
ARMultiSchemaFieldIdList getListFields;
ARMultiSchemaFieldValueListList entryFieldValueList;
#endif
ARMultiSchemaQualifierStruct qualifierStruct;
ARMultiSchemaSortList sortList;
unsigned int i;
int i2, field_off = 6;
int ret = 0, rv = 0;
HV *hDummy;
/* printf( "\n\n!!!! ars_GetListEntryWithMultiSchemaFields(): experimental implementation, not really working yet !!!!\n\n" ); */
(void) ARError_reset();
#if AR_CURRENT_API_VERSION >= 17
Zero( &queryFromList, 1, ARMultiSchemaFuncQueryFromList );
Zero( &getListFields, 1, ARMultiSchemaFieldFuncList );
Zero( &entryFieldValueList, 1, ARMultiSchemaFieldFuncValueListList );
#else
Zero( &queryFromList, 1, ARMultiSchemaQueryFromList );
Zero( &getListFields, 1, ARMultiSchemaFieldIdList );
Zero( &entryFieldValueList, 1, ARMultiSchemaFieldValueListList );
#endif
Zero( &qualifierStruct, 1, ARMultiSchemaQualifierStruct );
Zero( &sortList, 1, ARMultiSchemaSortList );
Zero( &status, 1, ARStatusList );
hDummy = newHV();
if( !( SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVAV ) ){
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_GENERAL, "QueryFromList must be an ARRAY reference" );
goto getlistentry_multischema_end;
}
hv_store( hDummy, "queryFromList", 13, newSVsv(schema), 0 );
#if AR_CURRENT_API_VERSION >= 17
rv += rev_ARMultiSchemaFuncQueryFromList( ctrl, hDummy, "queryFromList", &queryFromList );
#else
rv += rev_ARMultiSchemaQueryFromList( ctrl, hDummy, "queryFromList", &queryFromList );
#endif
if( qualifier && SvOK(qualifier) ){
if( !( SvROK(qualifier) && SvTYPE(SvRV(qualifier)) == SVt_PVHV ) ){
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_GENERAL, "Qualifier must be a HASH reference" );
goto getlistentry_multischema_end;
}
hv_store( hDummy, "qualifierStruct", 15, newSVsv(qualifier), 0 );
rv += rev_ARMultiSchemaQualifierStruct( ctrl, hDummy, "qualifierStruct", &qualifierStruct );
}
if( fields && SvOK(fields) ){
if( !( SvROK(fields) && SvTYPE(SvRV(fields)) == SVt_PVAV ) ){
goto getlistentry_multischema_end;
}
#if AR_CURRENT_API_VERSION >= 17
for( i = 0; i < entryFieldValueList.numItems; ++i ){
HV * fieldValue_hash = newHV();
unsigned int field;
char keyStr[AR_MAX_NAME_SIZE + 1 + 12 + 1 + 12 + 1];
for( field = 0; field < entryFieldValueList.listPtr[i].numItems; ++field ){
ARMultiSchemaFieldFuncValueStruct *valPtr = &(entryFieldValueList.listPtr[i].listPtr[field]);
sprintf( keyStr, "%s.%ld.%ld", valPtr->fieldId.queryFromAlias, valPtr->fieldId.fieldId, valPtr->fieldId.funcId );
hv_store( fieldValue_hash,
keyStr, strlen(keyStr),
perl_ARValueStruct(ctrl, &(valPtr->value)),
0 );
}
XPUSHs( sv_2mortal( newRV_noinc((SV *)fieldValue_hash) ) );
}
#else
for( i = 0; i < entryFieldValueList.numItems; ++i ){
HV * fieldValue_hash = newHV();
unsigned int field;
char keyStr[AR_MAX_NAME_SIZE + 1 + 12 + 1];
for( field = 0; field < entryFieldValueList.listPtr[i].numItems; ++field ){
ARMultiSchemaFieldValueStruct *valPtr = &(entryFieldValueList.listPtr[i].listPtr[field]);
sprintf( keyStr, "%s.%ld", valPtr->fieldId.queryFromAlias, valPtr->fieldId.fieldId );
hv_store( fieldValue_hash,
keyStr, strlen(keyStr),
perl_ARValueStruct(ctrl, &(valPtr->value)),
0 );
}
XPUSHs( sv_2mortal( newRV_noinc((SV *)fieldValue_hash) ) );
}
#endif
getlistentry_multischema_end:
hv_undef( hDummy );
#if AR_CURRENT_API_VERSION >= 17
FreeARMultiSchemaFieldFuncList( &getListFields, FALSE );
FreeARMultiSchemaFieldFuncValueListList( &entryFieldValueList, FALSE );
#else
FreeARMultiSchemaFieldIdList( &getListFields, FALSE );
FreeARMultiSchemaFieldValueListList( &entryFieldValueList, FALSE );
#endif
FreeARMultiSchemaSortList( &sortList, FALSE );
#else /* prior to ARS 7.5 */
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ars_GetListEntryWithMultiSchemaFields() is only available in ARS >= 7.5");
#endif
}
void
ars_SetLogging( ctrl, logTypeMask_arg, ...)
ARControlStruct * ctrl
unsigned long logTypeMask_arg
PPCODE:
{
#if AR_EXPORT_VERSION >= 5
ARStatusList status;
#if AR_CURRENT_API_VERSION >= 14
ARULong32 whereToWriteMask = AR_WRITE_TO_STATUS_LIST;
ARULong32 logTypeMask = logTypeMask_arg;
#else
unsigned long whereToWriteMask = AR_WRITE_TO_STATUS_LIST;
unsigned long logTypeMask = logTypeMask_arg;
#endif
int ret;
FILE *logFilePtr = NULL;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
logFilePtr = get_logging_file_ptr();
/* printf( "GET logging_file_ptr = %p\n", logFilePtr ); */
if( items > 2 && logTypeMask != 0 ){
char *fileName;
STRLEN len;
fileName = SvPV(ST(2),len);
if( logFilePtr != NULL ){
fclose( logFilePtr );
logFilePtr = NULL;
}
whereToWriteMask = AR_WRITE_TO_FILE;
logFilePtr = fopen( fileName, "a" );
if( logFilePtr == NULL ){
char buf[2048];
sprintf( buf, "Cannot open file: %s", fileName );
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_INV_ARGS, buf);
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
goto SetLogging_fail;
}
set_logging_file_ptr( logFilePtr );
/* printf( "SET logging_file_ptr = %p\n", logFilePtr ); */
}
ret = ARSetLogging( ctrl, logTypeMask, whereToWriteMask, logFilePtr, &status );
if( logTypeMask == 0 && logFilePtr != NULL ){
fclose( logFilePtr );
set_logging_file_ptr( NULL );
}
if(ARError(ret, status)) {
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
} else {
XPUSHs(sv_2mortal(newSViv(1))); /* OK */
}
SetLogging_fail:;
#else /* < 4.5 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"SetLogging() is only available in ARSystem >= 4.5");
#endif
}
void
ars_SetSessionConfiguration( ctrl, variableId, value )
ARControlStruct * ctrl
unsigned int variableId
long value
PPCODE:
{
#if AR_EXPORT_VERSION >= 6
ARStatusList status;
ARValueStruct variableValue;
int ret;
char numToCharBuf[32];
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
variableValue.dataType = AR_DATA_TYPE_INTEGER;
variableValue.u.intVal = value;
if (variableId == 12 || variableId == 13)
{
// just a quick and dirty solution because those variables need to be characters
sprintf(numToCharBuf, "%ld", value);
variableValue.dataType = AR_DATA_TYPE_CHAR;
variableValue.u.charVal = numToCharBuf;
}
ret = ARSetSessionConfiguration( ctrl, variableId, &variableValue, &status );
if(ARError(ret, status)) {
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
} else {
XPUSHs(sv_2mortal(newSViv(1))); /* OK */
}
#else /* < 5.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"SetSessionConfiguration() is only available in ARSystem >= 5.0");
#endif
}
void
ars_SetImpersonatedUser( ctrl, impersonatedUser )
ARControlStruct * ctrl
ARAccessNameType impersonatedUser
PPCODE:
{
#if AR_EXPORT_VERSION >= 9
ARStatusList status;
int ret;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
if( strcmp("",impersonatedUser) == 0 ){
ret = ARSetImpersonatedUser( ctrl, NULL, &status );
}else{
ret = ARSetImpersonatedUser( ctrl, impersonatedUser, &status );
}
if(ARError(ret, status)) {
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
} else {
XPUSHs(sv_2mortal(newSViv(1))); /* OK */
}
#else /* < 7.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"SetImpersonatedUser() is only available in ARSystem >= 7.0");
#endif
}
void
ars_BeginBulkEntryTransaction( ctrl )
ARControlStruct * ctrl
PPCODE:
{
#if AR_CURRENT_API_VERSION >= 11
ARStatusList status;
int ret;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
ret = ARBeginBulkEntryTransaction( ctrl, &status );
if( ARError(ret, status) ){
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
}else{
XPUSHs(sv_2mortal(newSViv(1))); /* OK */
}
#else /* < 6.3 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"BeginBulkEntryTransaction() is only available in ARSystem >= 6.3");
#endif
}
void
ars_EndBulkEntryTransaction( ctrl, actionType )
ARControlStruct * ctrl
unsigned int actionType
PPCODE:
{
#if AR_CURRENT_API_VERSION >= 11
int ret;
ARStatusList status;
ARBulkEntryReturnList returnList;
unsigned int i;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
Zero(&returnList, 1, ARBulkEntryReturnList);
ret = AREndBulkEntryTransaction( ctrl, actionType, &returnList, &status );
ARError( ret, status );
for( i = 0; i < returnList.numItems; i++ ){
XPUSHs( sv_2mortal( perl_ARBulkEntryReturn(ctrl,&(returnList.entryReturnList[i])) ) );
}
FreeARBulkEntryReturnList(&returnList, FALSE);
#else /* < 6.3 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"BeginBulkEntryTransaction() is only available in ARSystem >= 6.3");
#endif
}
void
ars_Signal( ctrl, ...)
ARControlStruct * ctrl
PPCODE:
{
#if AR_CURRENT_API_VERSION >= 9
int ret;
ARSignalList signalList;
ARStatusList status;
unsigned int c = (items - 1) / 2, i = 0, a = 0, ok = 1;
(void) ARError_reset();
Zero(&signalList, 1, ARSignalList);
Zero(&status, 1, ARStatusList);
if( ((items - 1) % 2) || c < 1 ){
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
}else{
signalList.numItems = c;
AMALLOCNN(signalList.signalList,c,ARSignalStruct);
for( i = 0; i < c; ++i ){
int st;
a = i * 2 + 1;
st = caseLookUpTypeNumber((TypeMapStruct *)
SignalTypeMap,
SvPV(ST(a), PL_na)
);
if( st == TYPEMAP_LAST ){
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_TYPEMAP);
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_CONTINUE,
SvPV(ST(a), PL_na) );
ok = 0;
}else{
signalList.signalList[i].signalType = st;
signalList.signalList[i].sigArgument = SvPV(ST(a+1),PL_na);
}
}
}
if( ok ){
ret = ARSignal( ctrl, &signalList, &status );
}
if( !ok || ARError(ret, status) ){
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
}else{
XPUSHs(sv_2mortal(newSViv(1))); /* OK */
}
FreeARSignalList(&signalList, FALSE);
#else /* < 5.1 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ars_Signal() is only supported for ARSystem >= 5.1");
#endif
}
SV *
ars_GetTextForErrorMessage(msgId)
int msgId
CODE:
{
char *msgTxt = NULL;
(void) ARError_reset();
msgTxt = ARGetTextForErrorMessage( msgId );
if( msgTxt != NULL ){
RETVAL = newSVpv( msgTxt, 0 );
free( msgTxt );
}else{
XSRETURN_UNDEF;
}
}
OUTPUT:
RETVAL
void
ars_ValidateMultipleLicenses(ctrl, ...)
ARControlStruct * ctrl
PPCODE:
{
ARStatusList status;
ARLicenseNameList licNameList;
ARLicenseValidList licValidList;
int ret = 0;
unsigned int ui = 0, count = 0;
unsigned int c = items - 1, i = 0, a = 0, ok = 1;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&licNameList, 1, ARLicenseNameList);
Zero(&licValidList, 1, ARLicenseValidList);
if( items > 1){
licNameList.numItems = c;
AMALLOCNN(licNameList.nameList,c,ARLicenseNameType);
for( i = 0; i < c; ++i ){
a = i + 1;
strncpy( licNameList.nameList[i], SvPV(ST(a),PL_na), AR_MAX_LICENSE_NAME_SIZE );
}
}else{
ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
ok = 0;
}
if( ok ){
ret = ARValidateMultipleLicenses(ctrl, &licNameList, &licValidList, &status);
if( !ARError(ret,status) ){
if( licNameList.numItems != licValidList.numItems ){
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_INV_RETURN);
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_CONTINUE, "licNameList.numItems != licValidList.numItems");
}
for( ui = 0; ui < licValidList.numItems; ++ui ){
XPUSHs( sv_2mortal( newSVpv(licNameList.nameList[ui],0) ) );
XPUSHs( sv_2mortal( perl_ARLicenseValidStruct(ctrl,&(licValidList.licenseValidateInfoList[ui])) ) );
}
}
}
FreeARLicenseNameList(&licNameList, FALSE);
FreeARLicenseValidList(&licValidList, FALSE);
}
int
ars_DateToJulianDate(ctrl, year, month, day)
ARControlStruct * ctrl
int year;
int month;
int day;
CODE:
{
#if AR_CURRENT_API_VERSION >= 9
int ret = 0;
int jd = 0;
ARDateStruct date;
ARStatusList status;
(void) ARError_reset();
Zero(&date, 1, ARDateStruct);
###################################################
# ALERT ROUTINES
int
ars_RegisterForAlerts(ctrl, clientPort, registrationFlags=0)
ARControlStruct * ctrl
int clientPort
unsigned int registrationFlags
CODE:
{
ARStatusList status;
int ret = 0;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
RETVAL = 0;
#if AR_EXPORT_VERSION >= 6
ret = ARRegisterForAlerts(ctrl, clientPort,
registrationFlags, &status);
if( !ARError(ret, status) ) {
RETVAL = 1;
}
#else
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"RegisterForAlerts() is only available in ARSystem >= 5.0");
#endif
}
OUTPUT:
RETVAL
int
ars_DeregisterForAlerts(ctrl,clientPort)
ARControlStruct * ctrl
int clientPort
CODE:
{
ARStatusList status;
int ret = 0;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
RETVAL = 0;
#if AR_EXPORT_VERSION >= 6
ret = ARDeregisterForAlerts(ctrl, clientPort,
&status);
if( !ARError(ret, status) ) {
RETVAL = 1;
}
#else
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"DeregisterForAlerts() is only available in ARSystem >= 5.0");
#endif
}
OUTPUT:
RETVAL
void
ars_GetListAlertUser(ctrl)
ARControlStruct * ctrl
PPCODE:
{
#if AR_EXPORT_VERSION >= 6
ARStatusList status;
ARAccessNameList userList;
int ret = 0;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
Zero(&userList, 1, ARAccessNameList);
ret = ARGetListAlertUser(ctrl, &userList,
&status);
if( !ARError(ret, status) ) {
if (userList.numItems > 0) {
unsigned int i = 0;
while(i < userList.numItems) {
XPUSHs(sv_2mortal(newSVpvn(userList.nameList[i++],
AR_MAX_NAME_SIZE)));
}
}
}
#else
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"GetListAlertUser() is only available in ARSystem >= 5.0");
XPUSHs(sv_2mortal(&PL_sv_undef));
#endif
}
SV *
ars_GetAlertCount(ctrl,qualifier=NULL)
ARControlStruct * ctrl
ARQualifierStruct * qualifier
CODE:
{
ARStatusList status;
int ret = 0;
unsigned int count = 0;
RETVAL=newSVsv(&PL_sv_undef);
#if AR_EXPORT_VERSION >= 6
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
ret = ARGetAlertCount(ctrl, qualifier, &count,
&status);
if( !ARError(ret, status) ) {
/* RETVAL=sv_2mortal(newSViv(count)); */
RETVAL = newSViv(count);
}
#else
(void) ARError_add(AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"GetAlertCount() is only available in ARSystem >= 5.0");
#endif
}
OUTPUT:
RETVAL
HV *
ars_DecodeAlertMessage(ctrl,message,messageLen)
ARControlStruct * ctrl
unsigned char * message
unsigned int messageLen
( run in 0.629 second using v1.01-cache-2.11-cpan-71847e10f99 )