ARSperl
view release on metacpan or search on metacpan
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);
ARCharMenuStruct menuDefn;
ARStatusList status;
int ret;
RETVAL = &PL_sv_undef;
(void) ARError_reset();
Zero(&menuDefn, 1, ARCharMenuStruct);
Zero(&status, 1,ARStatusList);
DBG( ("-> ARGetCharMenu\n") );
ret = ARGetCharMenu(ctrl, name, NULL, &menuDefn,
NULL, NULL, NULL, NULL, NULL,
#if AR_EXPORT_VERSION >= 5
NULL,
#endif
&status);
DBG( ("<- ARGetCharMenu\n") );
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (! ARError(ret, status)) {
DBG( ("-> perl_expandARCharMenuStruct\n") );
RETVAL = perl_expandARCharMenuStruct(ctrl,
&menuDefn);
DBG( ("<- perl_expandARCharMenuStruct\n") );
FreeARCharMenuStruct(&menuDefn, FALSE);
DBG( ("after Free\n") );
}
}
OUTPUT:
RETVAL
HV *
ars_GetSchema(ctrl,name)
ARControlStruct * ctrl
char * name
CODE:
{
ARStatusList status;
int ret = 0;
ARPermissionList assignedGroupList;
ARPermissionList groupList;
#if AR_EXPORT_VERSION >= 8L
ARSchemaInheritanceList inheritanceList;
ARArchiveInfoStruct infoStruct;
#endif
#if AR_EXPORT_VERSION >= 9L
ARAuditInfoStruct auditInfo;
#endif
ARInternalIdList adminGroupList;
AREntryListFieldList getListFields;
ARIndexList indexList;
char *helpText = CPNULL;
ARTimestamp timestamp;
ARAccessNameType owner;
ARAccessNameType lastChanged;
char *changeDiary = CPNULL;
ARDiaryList diaryList;
ARCompoundSchema schema;
ARSortList sortList;
ARPropList objPropList;
ARNameType defaultVui;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
Zero(&assignedGroupList, 1, ARPermissionList);
Zero(&groupList, 1, ARPermissionList);
Zero(&adminGroupList, 1, ARInternalIdList);
Zero(&getListFields, 1, AREntryListFieldList);
Zero(&indexList, 1, ARIndexList);
Zero(×tamp, 1, ARTimestamp);
Zero(owner, 1, ARAccessNameType);
Zero(lastChanged, 1, ARAccessNameType);
Zero(&diaryList, 1, ARDiaryList);
Zero(&schema, 1, ARCompoundSchema);
Zero(&sortList, 1, ARSortList);
Zero(&objPropList, 1, ARPropList);
Zero(&defaultVui, 1, ARNameType);
#if AR_EXPORT_VERSION >= 8L
Zero(&inheritanceList, 1, ARSchemaInheritanceList);
Zero(&infoStruct, 1, ARArchiveInfoStruct);
#endif
#if AR_EXPORT_VERSION >= 9L
Zero(&auditInfo, 1, ARAuditInfoStruct);
#endif
RETVAL = newHV();
sv_2mortal( (SV*) RETVAL );
ret = ARGetSchema(ctrl, name, &schema,
#if AR_EXPORT_VERSION >= 8L
&inheritanceList,
#endif
#if AR_CURRENT_API_VERSION >= 17
&assignedGroupList,
#endif
&groupList, &adminGroupList, &getListFields,
&sortList, &indexList,
#if AR_EXPORT_VERSION >= 8L
&infoStruct,
#endif
#if AR_EXPORT_VERSION >= 9L
&auditInfo,
#endif
defaultVui,
&helpText, ×tamp, owner,
lastChanged, &changeDiary,
&objPropList,
&status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (!ARError( ret,status)) {
#if AR_EXPORT_VERSION >= 5
hv_store(RETVAL, "objPropList", strlen("objPropList") ,
perl_ARPropList(ctrl, &objPropList), 0);
#endif
#if AR_EXPORT_VERSION >= 6
hv_store(RETVAL, "defaultVui", strlen("defaultVui"),
newSVpv(defaultVui, 0), 0);
#endif
#if AR_CURRENT_API_VERSION >= 17
hv_store(RETVAL, "assignedGroupList", strlen("assignedGroupList") ,
perl_ARPermissionList(ctrl, &assignedGroupList, PERMTYPE_SCHEMA), 0);
#endif
hv_store(RETVAL, "groupList", strlen("groupList") ,
perl_ARPermissionList(ctrl, &groupList, PERMTYPE_SCHEMA), 0);
hv_store(RETVAL, "adminList", strlen("adminList") ,
perl_ARList(ctrl, (ARList *)&adminGroupList,
(ARS_fn)perl_ARInternalId,
sizeof(ARInternalId)),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);
Zero(&assignedGroupList, 1, ARPermissionList);
Zero(&permissions, 1, ARPermissionList);
Zero(&limit, 1, ARFieldLimitStruct);
Zero(fieldName, 1, ARNameType);
Zero(&fieldMap, 1, ARFieldMappingStruct);
Zero(&displayList, 1, ARDisplayInstanceList);
Zero(×tamp, 1, ARTimestamp);
Zero(owner, 1, ARAccessNameType);
Zero(lastChanged, 1, ARAccessNameType);
Zero(&diaryList, 1, ARDiaryList);
Zero(&objPropList, 1, ARPropList);
#if AR_CURRENT_API_VERSION >= 17
ret = ARGetFieldCached(ctrl, schema, id, fieldName, &fieldMap, &dataType, &option, &createMode, &fieldOption, &defaultVal, &assignedGroupList, &permissions, &limit, &displayList, &helpText, ×tamp, owner, lastChanged, &changeDiary, &objPropLis...
#elif AR_CURRENT_API_VERSION >= 12
ret = ARGetFieldCached(ctrl, schema, id, fieldName, &fieldMap, &dataType, &option, &createMode, &fieldOption, &defaultVal, &permissions, &limit, &displayList, &helpText, ×tamp, owner, lastChanged, &changeDiary, &Status);
#else
ret = ARGetFieldCached(ctrl, schema, id, fieldName, &fieldMap, &dataType, &option, &createMode, &defaultVal, &permissions, &limit, &displayList, &helpText, ×tamp, owner, lastChanged, &changeDiary, &Status);
#endif
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (! ARError( ret, Status)) {
RETVAL = newHV();
sv_2mortal( (SV*) RETVAL );
/* store field id for convenience */
hv_store(RETVAL, "fieldId", strlen("fieldId") , newSViv(id), 0);
if (createMode == AR_FIELD_OPEN_AT_CREATE)
hv_store(RETVAL, "createMode", strlen("createMode") , newSVpv("open",0), 0);
else
hv_store(RETVAL, "createMode", strlen("createMode") ,
newSVpv("protected",0), 0);
hv_store(RETVAL, "option", strlen("option") , newSViv(option), 0);
#if AR_CURRENT_API_VERSION >= 12
hv_store(RETVAL, "fieldOption", strlen("fieldOption") , newSViv(fieldOption), 0);
#endif
hv_store(RETVAL, "dataType", strlen("dataType") ,
perl_dataType_names(ctrl, &dataType), 0);
hv_store(RETVAL, "defaultVal", strlen("defaultVal") ,
perl_ARValueStruct(ctrl, &defaultVal), 0);
#if AR_CURRENT_API_VERSION >= 17
hv_store(RETVAL, "assignedGroupList", strlen("assignedGroupList") ,
perl_ARPermissionList(ctrl, &assignedGroupList, PERMTYPE_FIELD), 0);
#endif
hv_store(RETVAL, "permissions", strlen("permissions") ,
perl_ARPermissionList(ctrl, &permissions, PERMTYPE_FIELD), 0);
hv_store(RETVAL, "limit", strlen("limit") ,
perl_ARFieldLimitStruct(ctrl, &limit), 0);
hv_store(RETVAL, "fieldName", strlen("fieldName") ,
newSVpv(fieldName, 0), 0);
hv_store(RETVAL, "fieldMap", strlen("fieldMap") ,
perl_ARFieldMappingStruct(ctrl, &fieldMap), 0);
hv_store(RETVAL, "displayInstanceList", strlen("displayInstanceList") ,
perl_ARDisplayInstanceList(ctrl, &displayList), 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);
}
}
FreeARFieldLimitStruct(&limit,FALSE);
FreeARDisplayInstanceList(&displayList,FALSE);
if(helpText) {
/* AP_FREE(helpText); */ /* TS 20060207 disabled bc of memory errors with 5.8.8 */
}
if(changeDiary) {
AP_FREE(changeDiary);
}
}else{
XSRETURN_UNDEF;
}
}
OUTPUT:
RETVAL
HV*
ars_GetImage(ctrl,name)
ARControlStruct * ctrl
ARNameType name
CODE:
{
ARStatusList status;
#if AR_CURRENT_API_VERSION >= 14
unsigned int enable = 0;
ARImageDataStruct content;
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,
&(serverInfo.serverInfoList[ui].value))));
}
}
FreeARServerInfoList(&serverInfo, FALSE);
}
}
HV *
ars_GetVUI(ctrl, schema, vuiId)
ARControlStruct * ctrl
char * schema
ARInternalId vuiId
CODE:
{
#if AR_EXPORT_VERSION >= 3
ARStatusList status;
ARNameType vuiName;
ARPropList dPropList;
char *helpText = CPNULL;
ARTimestamp timestamp;
ARAccessNameType owner;
ARAccessNameType lastChanged;
char *changeDiary = CPNULL;
int ret = 0;
ARDiaryList diaryList;
ARPropList objPropList;
# if AR_EXPORT_VERSION >= 6
unsigned int vuiType = 0;
ARLocaleType locale;
Zero(locale, 1, ARLocaleType);
# endif
helpText,
owner,
changeDiary,
objPropList,
#if AR_CURRENT_API_VERSION >= 17
objectModificationLogLabel,
#endif
&status );
RETVAL = ARError(ret,status) ? 0 : 1;
}else{
ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
RETVAL = 0;
}
if( helpText != NULL ){
AP_FREE( helpText );
}
if( changeDiary != NULL ){
AP_FREE( changeDiary );
}
if( arMenuDef != NULL ){
FreeARCharMenuStruct( arMenuDef, TRUE );
}
if( objPropList != NULL ){
FreeARPropList( objPropList, TRUE );
}
#else /* < 5.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ARSperl supports SetCharMenu() only for ARSystem >= 5.0");
RETVAL = AR_RETURN_ERROR;
#endif
}
OUTPUT:
RETVAL
#define STR_TEMP_SIZE 30
int
ars_CreateField( ctrl, schema, fieldDefRef, reservedIdOK=0 )
ARControlStruct * ctrl
ARNameType schema
SV * fieldDefRef
ARBoolean reservedIdOK
CODE:
{
#if AR_EXPORT_VERSION >= 6L
int ret = 0, rv = 0;
ARInternalId fieldId;
ARNameType fieldName;
ARFieldMappingStruct fieldMap;
unsigned int dataType;
unsigned int option;
unsigned int createMode = AR_FIELD_PROTECTED_AT_CREATE;
#if AR_EXPORT_VERSION >= 9L
unsigned int fieldOption;
#endif
ARValueStruct *defaultVal = NULL;
ARPermissionList permissions;
ARFieldLimitStruct *limit = NULL;
ARDisplayInstanceList dInstanceList;
char *helpText = NULL;
ARAccessNameType owner;
char *changeDiary = NULL;
ARPropList *objPropList = NULL;
ARStatusList status;
HV *fieldDef = NULL;
SV **pSvTemp;
char strTemp[STR_TEMP_SIZE+1];
RETVAL = 0; /* assume error */
(void) ARError_reset();
Zero(owner, 1,ARAccessNameType);
Zero(fieldName, 1,ARNameType);
Zero(&status, 1,ARStatusList);
Zero(&fieldMap, 1,ARFieldMappingStruct);
Zero(&permissions, 1,ARPermissionList);
Zero(&dInstanceList, 1, ARDisplayInstanceList);
if( SvROK(fieldDefRef) && SvTYPE(SvRV(fieldDefRef)) == SVt_PVHV ){
fieldDef = (HV*) SvRV(fieldDefRef);
}else{
croak("usage: ars_CreateField(...)");
}
rv += ulongcpyHVal( fieldDef, "fieldId", &fieldId );
rv += strcpyHVal( fieldDef, "fieldName", fieldName, AR_MAX_NAME_SIZE );
fieldMap.fieldType = AR_FIELD_REGULAR;
rv += rev_ARFieldMappingStruct( ctrl, fieldDef, "fieldMap", &fieldMap );
rv += strcpyHVal( fieldDef, "dataType", strTemp, STR_TEMP_SIZE );
dataType = caseLookUpTypeNumber( (TypeMapStruct*) DataTypeMap, strTemp );
rv += uintcpyHVal( fieldDef, "option", &option );
rv += strcpyHVal( fieldDef, "createMode", strTemp, STR_TEMP_SIZE );
if( !strncmp(strTemp,"open",STR_TEMP_SIZE) ){
createMode = AR_FIELD_OPEN_AT_CREATE;
}else if( !strncmp(strTemp,"protected",STR_TEMP_SIZE) ){
createMode = AR_FIELD_PROTECTED_AT_CREATE;
}else{
ARError_add(AR_RETURN_WARNING, AP_ERR_GENERAL,
"ars_CreateField: invalid createmode:");
ARError_add(AR_RETURN_WARNING, AP_ERR_CONTINUE,
strTemp ? strTemp : "n/a");
}
#if AR_EXPORT_VERSION >= 9L
rv += uintcpyHVal( fieldDef, "fieldOption", &fieldOption );
#endif
pSvTemp = hv_fetch( fieldDef, "defaultVal", strlen("defaultVal") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
defaultVal = (ARValueStruct*) MALLOCNN( sizeof(ARValueStruct) );
rv += rev_ARValueStruct( ctrl, fieldDef, "defaultVal", "dataType", defaultVal );
}
permissions.numItems = 0;
permissions.permissionList = NULL;
rv += rev_ARPermissionList( ctrl, fieldDef, "permissions", &permissions );
pSvTemp = hv_fetch( fieldDef, "limit", strlen("limit") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
limit = (ARFieldLimitStruct*) MALLOCNN( sizeof(ARFieldLimitStruct) );
/* rv += rev_ARFieldLimitStruct( ctrl, fieldDef, "limit", "dataType", limit ); */
rv += rev_ARFieldLimitStruct( ctrl, fieldDef, "limit", limit );
}
#if AR_CURRENT_API_VERSION >= 17
pSvTemp = hv_fetch( fieldDef, "objPropList", strlen("objPropList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
objPropList = (ARPropList*) MALLOCNN( sizeof(ARPropList) );
/* rv += rev_ARPropList( ctrl, fieldDef, "objPropList", "dataType", objPropList ); */
rv += rev_ARPropList( ctrl, fieldDef, "objPropList", objPropList );
}
#endif
rv += rev_ARDisplayInstanceList( ctrl, fieldDef, "displayInstanceList", &dInstanceList );
if( hv_exists(fieldDef,"helpText",8) ){
rv += strmakHVal( fieldDef, "helpText", &helpText );
}
if( hv_exists(fieldDef,"owner",5) ){
rv += strcpyHVal( fieldDef, "owner", owner, AR_MAX_ACCESS_NAME_SIZE );
}
if( hv_exists(fieldDef,"changeDiary",11) ){
rv += strmakHVal( fieldDef, "changeDiary", &changeDiary );
}
if( rv == 0 ){
ret = ARCreateField( ctrl,
schema,
&fieldId,
reservedIdOK,
fieldName,
&fieldMap,
dataType,
option,
createMode,
#if AR_EXPORT_VERSION >= 9L
fieldOption,
#endif
defaultVal,
&permissions,
limit,
&dInstanceList,
helpText,
owner,
changeDiary,
#if AR_CURRENT_API_VERSION >= 17
objPropList,
#endif
&status );
RETVAL = ARError(ret,status) ? 0 : fieldId;
}else{
ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
RETVAL = 0;
}
if( helpText != NULL ){
AP_FREE( helpText );
}
if( changeDiary != NULL ){
AP_FREE( changeDiary );
}
if( defaultVal != NULL ){
FreeARValueStruct( defaultVal, TRUE );
}
FreeARPermissionList( &permissions, FALSE );
if( limit != NULL ){
FreeARFieldLimitStruct( limit, TRUE );
}
FreeARDisplayInstanceList( &dInstanceList, FALSE );
/*
FreeARStatusList( &status, FALSE );
printf( "-- FreeARStatusList -- OK\n" ); // _DEBUG_
*/
#else /* < 5.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ARSperl supports CreateField() only for ARSystem >= 5.0");
RETVAL = AR_RETURN_ERROR;
#endif
}
OUTPUT:
RETVAL
int
ars_SetField( ctrl, schema, fieldId, fieldDefRef )
ARControlStruct * ctrl
ARNameType schema
ARInternalId fieldId
SV * fieldDefRef
CODE:
{
#if AR_EXPORT_VERSION >= 6L
int ret = 0, rv = 0;
ARNameType fieldName;
char *fieldNamePtr = NULL;
ARFieldMappingStruct *fieldMap = NULL;
unsigned int *option = NULL;
unsigned int *createMode = NULL;
#if AR_EXPORT_VERSION >= 9L
unsigned int *fieldOption = NULL;
#endif
ARValueStruct *defaultVal = NULL;
ARPermissionList *permissions = NULL;
ARFieldLimitStruct *limit = NULL;
ARDisplayInstanceList *dInstanceList = NULL;
char *helpText = NULL;
ARAccessNameType owner;
char *ownerPtr = NULL;
#if AR_EXPORT_VERSION >= 9L
unsigned int setFieldOptions = 0;
#endif
char *changeDiary = NULL;
ARPropList *objPropList = NULL;
ARStatusList status;
HV *fieldDef = NULL;
SV **pSvTemp;
char strTemp[STR_TEMP_SIZE+1];
RETVAL = 0; /* assume error */
(void) ARError_reset();
Zero(fieldName, 1,ARNameType);
Zero(owner, 1,ARAccessNameType);
Zero(&status, 1,ARStatusList);
if( SvROK(fieldDefRef) && SvTYPE(SvRV(fieldDefRef)) == SVt_PVHV ){
fieldDef = (HV*) SvRV(fieldDefRef);
}else{
croak("usage: ars_SetField(...)");
}
/* rv += ulongcpyHVal( fieldDef, "fieldId", &fieldId ); */
pSvTemp = hv_fetch( fieldDef, "fieldName", strlen("fieldName") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += strcpyHVal( fieldDef, "fieldName", fieldName, AR_MAX_NAME_SIZE );
fieldNamePtr = fieldName;
}
pSvTemp = hv_fetch( fieldDef, "fieldMap", strlen("fieldMap") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
fieldMap = (ARFieldMappingStruct*) MALLOCNN( sizeof(ARFieldMappingStruct) );
rv += rev_ARFieldMappingStruct( ctrl, fieldDef, "fieldMap", fieldMap );
}
pSvTemp = hv_fetch( fieldDef, "option", strlen("option") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
option = (unsigned int*) MALLOCNN( sizeof(unsigned int) );
rv += uintcpyHVal( fieldDef, "option", option );
}
pSvTemp = hv_fetch( fieldDef, "createMode", strlen("createMode") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
createMode = (unsigned int*) MALLOCNN( sizeof(unsigned int) );
rv += strcpyHVal( fieldDef, "createMode", strTemp, STR_TEMP_SIZE );
if( !strncmp(strTemp,"open",STR_TEMP_SIZE) ){
*createMode = AR_FIELD_OPEN_AT_CREATE;
}else if( !strncmp(strTemp,"protected",STR_TEMP_SIZE) ){
*createMode = AR_FIELD_PROTECTED_AT_CREATE;
}else{
ARError_add(AR_RETURN_WARNING, AP_ERR_GENERAL,
"ars_CreateField: invalid createmode:");
ARError_add(AR_RETURN_WARNING, AP_ERR_CONTINUE,
strTemp ? strTemp : "n/a");
}
}
#if AR_EXPORT_VERSION >= 9L
pSvTemp = hv_fetch( fieldDef, "fieldOption", strlen("fieldOption") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
fieldOption = (unsigned int*) MALLOCNN( sizeof(unsigned int) );
rv += uintcpyHVal( fieldDef, "fieldOption", fieldOption );
}
#endif
pSvTemp = hv_fetch( fieldDef, "defaultVal", strlen("defaultVal") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
defaultVal = (ARValueStruct*) MALLOCNN( sizeof(ARValueStruct) );
rv += rev_ARValueStruct( ctrl, fieldDef, "defaultVal", "dataType", defaultVal );
}
pSvTemp = hv_fetch( fieldDef, "permissions", strlen("permissions") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
permissions = (ARPermissionList*) MALLOCNN( sizeof(ARPermissionList) );
rv += rev_ARPermissionList( ctrl, fieldDef, "permissions", permissions );
}
pSvTemp = hv_fetch( fieldDef, "limit", strlen("limit") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
limit = (ARFieldLimitStruct*) MALLOCNN( sizeof(ARFieldLimitStruct) );
/* rv += rev_ARFieldLimitStruct( ctrl, fieldDef, "limit", "dataType", limit ); */
rv += rev_ARFieldLimitStruct( ctrl, fieldDef, "limit", limit );
}
#if AR_CURRENT_API_VERSION >= 17
pSvTemp = hv_fetch( fieldDef, "objPropList", strlen("objPropList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
objPropList = (ARPropList*) MALLOCNN( sizeof(ARPropList) );
/* rv += rev_ARPropList( ctrl, fieldDef, "objPropList", "dataType", objPropList ); */
rv += rev_ARPropList( ctrl, fieldDef, "objPropList", objPropList );
}
#endif
pSvTemp = hv_fetch( fieldDef, "displayInstanceList", strlen("displayInstanceList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
dInstanceList = (ARDisplayInstanceList*) MALLOCNN( sizeof(ARDisplayInstanceList) );
rv += rev_ARDisplayInstanceList( ctrl, fieldDef, "displayInstanceList", dInstanceList );
}
if( hv_exists(fieldDef,"helpText",8) ){
rv += strmakHVal( fieldDef, "helpText", &helpText );
}
if( hv_exists(fieldDef,"owner",5) ){
rv += strcpyHVal( fieldDef, "owner", owner, AR_MAX_ACCESS_NAME_SIZE );
ownerPtr = owner;
}
#if AR_EXPORT_VERSION >= 9L
pSvTemp = hv_fetch( fieldDef, "setFieldOptions", strlen("setFieldOptions") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += uintcpyHVal( fieldDef, "setFieldOptions", &setFieldOptions );
}
#endif
if( hv_exists(fieldDef,"changeDiary",11) ){
rv += strmakHVal( fieldDef, "changeDiary", &changeDiary );
}
if( rv == 0 ){
ret = ARSetField( ctrl,
schema,
fieldId,
fieldNamePtr,
fieldMap,
option,
createMode,
#if AR_EXPORT_VERSION >= 9L
fieldOption,
#endif
defaultVal,
permissions,
limit,
dInstanceList,
helpText,
ownerPtr,
changeDiary,
#if AR_EXPORT_VERSION >= 9L
setFieldOptions,
#endif
#if AR_CURRENT_API_VERSION >= 17
objPropList,
#endif
&status );
RETVAL = ARError(ret,status) ? 0 : fieldId;
}else{
ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
RETVAL = 0;
}
if( createMode != NULL ){
AP_FREE( createMode );
}
if( option != NULL ){
AP_FREE( option );
}
if( helpText != NULL ){
AP_FREE( helpText );
}
if( changeDiary != NULL ){
AP_FREE( changeDiary );
}
if( defaultVal != NULL ){
FreeARValueStruct( defaultVal, TRUE );
}
if( permissions != NULL ){
FreeARPermissionList( permissions, TRUE );
}
if( limit != NULL ){
FreeARFieldLimitStruct( limit, TRUE );
}
if( dInstanceList != NULL ){
FreeARDisplayInstanceList( dInstanceList, TRUE );
}
/*
FreeARStatusList( &status, FALSE );
printf( "-- FreeARStatusList -- OK\n" ); // _DEBUG_
*/
#else /* < 5.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ARSperl supports SetField() only for ARSystem >= 5.0");
RETVAL = AR_RETURN_ERROR;
#endif
}
OUTPUT:
RETVAL
int
ars_CreateSchema( ctrl, schemaDefRef )
ARControlStruct * ctrl
SV * schemaDefRef
CODE:
{
#if AR_EXPORT_VERSION >= 6L
int ret = 0, rv = 0;
ARNameType name;
ARCompoundSchema compoundSchema;
ARPermissionList groupList;
ARInternalIdList admingrpList;
AREntryListFieldList getListFields;
ARSortList sortList;
ARIndexList indexList;
#if AR_EXPORT_VERSION >= 8L
ARArchiveInfoStruct *archiveInfo = NULL;
#endif
#if AR_EXPORT_VERSION >= 9L
ARAuditInfoStruct *auditInfo = NULL;
#endif
ARNameType defaultVui;
char *helpText = NULL;
ARAccessNameType owner;
char *changeDiary = NULL;
ARPropList *objPropList = NULL;
char *objectModificationLogLabel = NULL;
ARStatusList status;
HV *schemaDef = NULL;
SV **pSvTemp;
/* char strTemp[STR_TEMP_SIZE+1]; */
RETVAL = 0; /* assume error */
(void) ARError_reset();
Zero(name, 1,ARNameType);
Zero(&compoundSchema, 1,ARCompoundSchema);
Zero(&groupList, 1,ARPermissionList);
Zero(&admingrpList, 1,ARInternalIdList);
Zero(&getListFields, 1,AREntryListFieldList);
Zero(&sortList, 1,ARSortList);
Zero(&indexList, 1,ARIndexList);
Zero(defaultVui, 1,ARNameType);
Zero(owner, 1,ARAccessNameType);
Zero(&status, 1,ARStatusList);
if( SvROK(schemaDefRef) && SvTYPE(SvRV(schemaDefRef)) == SVt_PVHV ){
schemaDef = (HV*) SvRV(schemaDefRef);
}else{
croak("usage: ars_CreateSchema(...)");
}
rv += strcpyHVal( schemaDef, "name", name, AR_MAX_NAME_SIZE );
compoundSchema.schemaType = AR_SCHEMA_REGULAR;
pSvTemp = hv_fetch( schemaDef, "schema", strlen("schema") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCompoundSchema( ctrl, schemaDef, "schema", &compoundSchema );
}
groupList.numItems = 0;
groupList.permissionList = NULL;
pSvTemp = hv_fetch( schemaDef, "groupList", strlen("groupList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARPermissionList( ctrl, schemaDef, "groupList", &groupList );
}
admingrpList.numItems = 0;
admingrpList.internalIdList = NULL;
pSvTemp = hv_fetch( schemaDef, "adminList", strlen("adminList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARInternalIdList( ctrl, schemaDef, "adminList", &admingrpList );
}
getListFields.numItems = 0;
getListFields.fieldsList = NULL;
pSvTemp = hv_fetch( schemaDef, "getListFields", strlen("getListFields") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_AREntryListFieldList( ctrl, schemaDef, "getListFields", &getListFields );
}
sortList.numItems = 0;
sortList.sortList = NULL;
pSvTemp = hv_fetch( schemaDef, "sortList", strlen("sortList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARSortList( ctrl, schemaDef, "sortList", &sortList );
}
indexList.numItems = 0;
indexList.indexList = NULL;
pSvTemp = hv_fetch( schemaDef, "indexList", strlen("indexList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARIndexList( ctrl, schemaDef, "indexList", &indexList );
}
#if AR_EXPORT_VERSION >= 8L
pSvTemp = hv_fetch( schemaDef, "archiveInfo", strlen("archiveInfo") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
archiveInfo = (ARArchiveInfoStruct*) MALLOCNN( sizeof(ARArchiveInfoStruct) );
rv += rev_ARArchiveInfoStruct( ctrl, schemaDef, "archiveInfo", archiveInfo );
}
#endif
#if AR_EXPORT_VERSION >= 9L
pSvTemp = hv_fetch( schemaDef, "auditInfo", strlen("auditInfo") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
auditInfo = (ARAuditInfoStruct*) MALLOCNN( sizeof(ARAuditInfoStruct) );
rv += rev_ARAuditInfoStruct( ctrl, schemaDef, "auditInfo", auditInfo );
}
#endif
rv += strcpyHVal( schemaDef, "defaultVui", defaultVui, AR_MAX_NAME_SIZE );
if( hv_exists(schemaDef,"helpText",8) ){
rv += strmakHVal( schemaDef, "helpText", &helpText );
}
if( hv_exists(schemaDef,"owner",5) ){
rv += strcpyHVal( schemaDef, "owner", owner, AR_MAX_ACCESS_NAME_SIZE );
}
if( hv_exists(schemaDef,"changeDiary",11) ){
rv += strmakHVal( schemaDef, "changeDiary", &changeDiary );
}
pSvTemp = hv_fetch( schemaDef, "objPropList", strlen("objPropList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
objPropList = (ARPropList*) MALLOCNN( sizeof(ARPropList) );
rv += rev_ARPropList( ctrl, schemaDef, "objPropList", objPropList );
}
if( rv == 0 ){
ret = ARCreateSchema( ctrl,
name,
&compoundSchema,
#if AR_EXPORT_VERSION >= 8L
NULL, /* schemaInheritanceList, reserved for future use */
#endif
&groupList,
&admingrpList,
&getListFields,
&sortList,
&indexList,
#if AR_EXPORT_VERSION >= 8L
archiveInfo,
#endif
#if AR_EXPORT_VERSION >= 9L
auditInfo,
#endif
defaultVui,
helpText,
owner,
changeDiary,
objPropList,
#if AR_CURRENT_API_VERSION >= 17
objectModificationLogLabel,
#endif
&status );
RETVAL = ARError(ret,status) ? 0 : 1;
}else{
ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
RETVAL = 0;
}
if( helpText != NULL ){
AP_FREE( helpText );
}
if( changeDiary != NULL ){
AP_FREE( changeDiary );
}
FreeARCompoundSchema( &compoundSchema, FALSE ); // TODO: we need our own free routine
AP_FREE(groupList.permissionList);
AP_FREE(admingrpList.internalIdList);
AP_FREE(getListFields.fieldsList);
AP_FREE(sortList.sortList);
AP_FREE(indexList.indexList);
#if AR_EXPORT_VERSION >= 8L
if( archiveInfo != NULL ){
FreeARArchiveInfoStruct( archiveInfo, TRUE ); // TODO: we need our own free routine
}
#endif
if( objPropList != NULL ){
FreeARPropList( objPropList, TRUE ); // TODO: we need our own free routine
}
#else /* < 5.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ARSperl supports CreateSchema() only for ARSystem >= 5.0");
RETVAL = AR_RETURN_ERROR;
#endif
}
OUTPUT:
RETVAL
int
ars_SetSchema( ctrl, name, schemaDefRef )
ARControlStruct * ctrl
ARNameType name
SV * schemaDefRef
CODE:
{
#if AR_EXPORT_VERSION >= 6L
int ret = 0, rv = 0;
ARNameType newName;
char *newNamePtr = NULL;
ARCompoundSchema *compoundSchema = NULL;
ARPermissionList *groupList = NULL;
ARInternalIdList *admingrpList = NULL;
AREntryListFieldList *getListFields = NULL;
ARSortList *sortList = NULL;
ARIndexList *indexList = NULL;
#if AR_EXPORT_VERSION >= 8L
ARArchiveInfoStruct *archiveInfo = NULL;
#endif
#if AR_EXPORT_VERSION >= 9L
ARAuditInfoStruct *auditInfo = NULL;
#endif
ARNameType defaultVui;
char *defaultVuiPtr = NULL;
char *helpText = NULL;
ARAccessNameType owner;
char *ownerPtr = NULL;
char *changeDiary = NULL;
ARPropList *objPropList = NULL;
char *objectModificationLogLabel = NULL;
ARStatusList status;
HV *schemaDef = NULL;
SV **pSvTemp;
/* char strTemp[STR_TEMP_SIZE+1]; */
RETVAL = 0; /* assume error */
(void) ARError_reset();
Zero(newName, 1,ARNameType);
Zero(defaultVui, 1,ARNameType);
Zero(owner, 1,ARAccessNameType);
Zero(&status, 1,ARStatusList);
if( SvROK(schemaDefRef) && SvTYPE(SvRV(schemaDefRef)) == SVt_PVHV ){
schemaDef = (HV*) SvRV(schemaDefRef);
}else{
croak("usage: ars_SetSchema(...)");
}
if( hv_exists(schemaDef,"name",4) ){
rv += strcpyHVal( schemaDef, "name", newName, AR_MAX_NAME_SIZE );
newNamePtr = newName;
}
pSvTemp = hv_fetch( schemaDef, "schema", strlen("schema") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
compoundSchema = (ARCompoundSchema*) MALLOCNN( sizeof(ARCompoundSchema) );
rv += rev_ARCompoundSchema( ctrl, schemaDef, "schema", compoundSchema );
}
pSvTemp = hv_fetch( schemaDef, "groupList", strlen("groupList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
groupList = (ARPermissionList*) MALLOCNN( sizeof(ARPermissionList) );
rv += rev_ARPermissionList( ctrl, schemaDef, "groupList", groupList );
}
pSvTemp = hv_fetch( schemaDef, "adminList", strlen("adminList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
admingrpList = (ARInternalIdList*) MALLOCNN( sizeof(ARInternalIdList) );
rv += rev_ARInternalIdList( ctrl, schemaDef, "adminList", admingrpList );
}
pSvTemp = hv_fetch( schemaDef, "getListFields", strlen("getListFields") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
getListFields = (AREntryListFieldList*) MALLOCNN( sizeof(AREntryListFieldList) );
rv += rev_AREntryListFieldList( ctrl, schemaDef, "getListFields", getListFields );
}
pSvTemp = hv_fetch( schemaDef, "sortList", strlen("sortList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
sortList = (ARSortList*) MALLOCNN( sizeof(ARSortList) );
rv += rev_ARSortList( ctrl, schemaDef, "sortList", sortList );
}
pSvTemp = hv_fetch( schemaDef, "indexList", strlen("indexList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
indexList = (ARIndexList*) MALLOCNN( sizeof(ARIndexList) );
rv += rev_ARIndexList( ctrl, schemaDef, "indexList", indexList );
}
#if AR_EXPORT_VERSION >= 8L
pSvTemp = hv_fetch( schemaDef, "archiveInfo", strlen("archiveInfo") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
archiveInfo = (ARArchiveInfoStruct*) MALLOCNN( sizeof(ARArchiveInfoStruct) );
rv += rev_ARArchiveInfoStruct( ctrl, schemaDef, "archiveInfo", archiveInfo );
}
#endif
#if AR_EXPORT_VERSION >= 9L
pSvTemp = hv_fetch( schemaDef, "auditInfo", strlen("auditInfo") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
auditInfo = (ARAuditInfoStruct*) MALLOCNN( sizeof(ARAuditInfoStruct) );
rv += rev_ARAuditInfoStruct( ctrl, schemaDef, "auditInfo", auditInfo );
}
#endif
if( hv_exists(schemaDef,"defaultVui",10) ){
rv += strcpyHVal( schemaDef, "defaultVui", defaultVui, AR_MAX_NAME_SIZE );
defaultVuiPtr = defaultVui;
}
if( hv_exists(schemaDef,"helpText",8) ){
rv += strmakHVal( schemaDef, "helpText", &helpText );
}
if( hv_exists(schemaDef,"owner",5) ){
rv += strcpyHVal( schemaDef, "owner", owner, AR_MAX_ACCESS_NAME_SIZE );
ownerPtr = owner;
}
if( hv_exists(schemaDef,"changeDiary",11) ){
rv += strmakHVal( schemaDef, "changeDiary", &changeDiary );
}
pSvTemp = hv_fetch( schemaDef, "objPropList", strlen("objPropList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
objPropList = (ARPropList*) MALLOCNN( sizeof(ARPropList) );
rv += rev_ARPropList( ctrl, schemaDef, "objPropList", objPropList );
}
if( rv == 0 ){
ret = ARSetSchema( ctrl,
name,
newNamePtr,
compoundSchema,
#if AR_EXPORT_VERSION >= 8L
NULL, /* schemaInheritanceList, reserved for future use */
#endif
groupList,
admingrpList,
getListFields,
sortList,
indexList,
#if AR_EXPORT_VERSION >= 8L
archiveInfo,
#endif
#if AR_EXPORT_VERSION >= 9L
auditInfo,
#endif
defaultVuiPtr,
helpText,
ownerPtr,
changeDiary,
objPropList,
#if AR_EXPORT_VERSION >= 8L
0, /* setOption, reserved for future use */
#endif
#if AR_CURRENT_API_VERSION >= 17
objectModificationLogLabel,
#endif
&status );
RETVAL = ARError(ret,status) ? 0 : 1;
}else{
ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
RETVAL = 0;
}
if( helpText != NULL ){
AP_FREE( helpText );
}
if( changeDiary != NULL ){
AP_FREE( changeDiary );
}
if( compoundSchema != NULL ){
FreeARCompoundSchema( compoundSchema, TRUE );
}
if( groupList != NULL ){
FreeARPermissionList( groupList, TRUE );
}
if( admingrpList != NULL ){
FreeARInternalIdList( admingrpList, TRUE );
}
if( getListFields != NULL ){
FreeAREntryListFieldList( getListFields, TRUE );
}
if( sortList != NULL ){
FreeARSortList( sortList, TRUE );
}
if( indexList != NULL ){
FreeARIndexList( indexList, TRUE );
}
#if AR_EXPORT_VERSION >= 8L
if( archiveInfo != NULL ){
FreeARArchiveInfoStruct( archiveInfo, TRUE );
}
#endif
if( objPropList != NULL ){
FreeARPropList( objPropList, TRUE );
}
#else /* < 5.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ARSperl supports SetSchema() only for ARSystem >= 5.0");
RETVAL = AR_RETURN_ERROR;
#endif
}
OUTPUT:
RETVAL
char *helpText = CPNULL;
ARAccessNameType owner;
char *changeDiary = CPNULL;
char *objectModificationLogLabel = NULL;
ARStatusList status;
ARNameList schemaNameList;
ARWorkflowConnectStruct schemaList;
ARPropList objPropList;
RETVAL = 0; /* assume error */
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(name, 1, ARNameType);
Zero(&actionList, 1,ARFilterActionList);
Zero(&elseList, 1,ARFilterActionList);
Zero(owner, 1, ARAccessNameType);
Zero(&objPropList, 1, ARPropList);
Zero(&schemaList, 1, ARWorkflowConnectStruct);
Zero(&schemaNameList, 1, ARNameList);
Zero(&escalationTm, 1, AREscalationTmStruct);
schemaList.type = AR_WORKFLOW_CONN_SCHEMA_LIST;
schemaList.u.schemaList = &schemaNameList;
if(SvTYPE((SV *)SvRV(objDefRef)) != SVt_PVHV) {
ARError_add( AR_RETURN_ERROR, AP_ERR_EXPECT_PVHV);
} else {
HV *objDef = (HV *)SvRV(objDefRef);
SV **qhv = hv_fetch(objDef, "query", strlen("query") , 0);
/* dereference the qual pointer */
if(qhv && *qhv && SvROK(*qhv)) {
query = (ARQualifierStruct *)SvIV((SV *)SvRV(*qhv));
/* query = (ARQualifierStruct*) MALLOCNN( sizeof(ARQualifierStruct) );
rv += rev_ARQualifierStruct( ctrl, objDef, "query", query ); */
} else {
query = (ARQualifierStruct *)NULL;
}
/* copy the various hash entries into the appropriate
* data structure. if any are missing, we fail.
*/
rv = 0;
rv += strcpyHVal( objDef, "name", name, AR_MAX_NAME_SIZE);
rv += rev_ARNameList( ctrl, objDef, "schemaList", schemaList.u.schemaList );
rv += uintcpyHVal( objDef, "enable", &enable);
/* rv += rev_AREscalationTmStruct( ctrl, objDef, "escalationTm", &escalationTm ); */
rv += uintcpyHVal( objDef, "TmType", &(escalationTm.escalationTmType) );
switch( escalationTm.escalationTmType ){
case AR_ESCALATION_TYPE_INTERVAL:
rv += longcpyHVal( objDef, "TmInterval", &(escalationTm.u.interval) );
break;
case AR_ESCALATION_TYPE_TIMEMARK:
rv += longcpyHVal( objDef, "TmMonthDayMask", &(escalationTm.u.date.monthday) );
rv += longcpyHVal( objDef, "TmWeekDayMask", &(escalationTm.u.date.weekday) );
rv += longcpyHVal( objDef, "TmHourMask", &(escalationTm.u.date.hourmask) );
rv += uintcpyHVal( objDef, "TmMinute", &(escalationTm.u.date.minute) );
break;
default:
rv += (-1);
}
if(hv_exists(objDef, "owner", strlen("owner") ))
rv += strcpyHVal( objDef, "owner", owner, AR_MAX_ACCESS_NAME_SIZE);
else
strncpy(owner, ctrl->user, sizeof(ARAccessNameType));
/* these two are optional, so if the calls return warnings
* it probably indicates that the hash keys don't exist and
* we'll ignore it unless an actual failure code is returned.
*/
if(hv_exists(objDef, "changeDiary", strlen("changeDiary") ))
rv += strmakHVal( objDef, "changeDiary", &changeDiary);
if(hv_exists(objDef, "helpText", strlen("helpText") ))
rv += strmakHVal( objDef, "helpText", &helpText);
/* now handle the action & else (3.x) lists */
rv += rev_ARFilterActionList(ctrl, objDef, "actionList",
&actionList);
rv += rev_ARFilterActionList(ctrl, objDef, "elseList",
&elseList);
if(hv_exists(objDef, "objPropList", strlen("objPropList") ))
rv += rev_ARPropList(ctrl, objDef, "objPropList",
&objPropList);
/* at this point all datastructures (hopefully) are
* built. we can call the api routine to create the
* escalation.
*/
if(rv == 0) {
ret = ARCreateEscalation(ctrl, name,
&escalationTm,
&schemaList,
enable, query,
&actionList, &elseList,
helpText, owner, changeDiary,
&objPropList,
#if AR_CURRENT_API_VERSION >= 17
objectModificationLogLabel,
#endif
&status);
if(!ARError( ret, status))
RETVAL = 1;
} else
ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
}
if (helpText) {
AP_FREE(helpText);
}
if (changeDiary) {
AP_FREE(changeDiary);
}
FreeARFilterActionList(&actionList, FALSE);
FreeARFilterActionList(&elseList, FALSE);
FreeARPropList(&objPropList, FALSE);
( run in 0.715 second using v1.01-cache-2.11-cpan-39bf76dae61 )