ARSperl
view release on metacpan or search on metacpan
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;
}
fieldList.numItems = c;
AMALLOCNN(fieldList.fieldValueList,c,ARFieldValueStruct);
getFieldIds.numItems = 0;
getFieldIds.internalIdList = NULL;
/* try to get data type from field cache, collect fieldIds which are not cached */
for (i=0; i<c; ++i) {
ARInternalId fieldId;
a = i*2+2;
fieldId = fieldList.fieldValueList[i].fieldId = SvIV(ST(a));
dataType = fieldcache_get_data_type( cacheFields, fieldId );
if (dataType <= AR_DATA_TYPE_MAX_TYPE) {
/* printf( "%s [%d] found in cache\n", schema, fieldId ); fflush(stdout); */ /* _DEBUG_ */
if (sv_to_ARValue(ctrl, ST(a+1), dataType, &fieldList.fieldValueList[i].value) < 0) {
goto create_entry_end;
}
}else{
if( getFieldIds.numItems == 0 ){
AMALLOCNN(getFieldIds.internalIdList,c,ARInternalId);
}
/* printf( "%s [%d] collect for loading\n", schema, fieldId ); fflush(stdout); */ /* _DEBUG_ */
getFieldIds.internalIdList[getFieldIds.numItems] = fieldId;
++getFieldIds.numItems;
}
}
/* load missing fields into cache */
if( getFieldIds.numItems > 0 ){
/* printf( "--- load missing fields ---\n" ); fflush(stdout); */ /* _DEBUG_ */
/* if( fieldcache_load_schema(ctrl,schema,&getFieldIds,NULL) != AR_RETURN_OK ){ */
if( fieldcache_load_schema(ctrl,schema,&getFieldIds,NULL) > AR_RETURN_WARNING ){
goto create_entry_end;
}
}
/* now get data type from the freshly cached fields */
i = 0;
for (j=0; j<getFieldIds.numItems; ++j) {
ARInternalId fieldId = getFieldIds.internalIdList[j];
while(fieldId != fieldList.fieldValueList[i].fieldId) ++i;
a = i*2+2;
dataType = fieldcache_get_data_type( cacheFields, fieldId );
if (dataType <= AR_DATA_TYPE_MAX_TYPE) {
/* printf( "%s [%d] freshly loaded\n", schema, fieldId ); fflush(stdout); */ /* _DEBUG_ */
if (sv_to_ARValue(ctrl, ST(a+1), dataType, &fieldList.fieldValueList[i].value) < 0) {
goto create_entry_end;
}
}else{
char errTxt[256];
sprintf( errTxt, "Failed to fetch field %d from hash", fieldId );
ARError_add(AR_RETURN_ERROR, AP_ERR_FIELD_TYPE);
ARError_add(AR_RETURN_ERROR, AP_ERR_CONTINUE, errTxt );
goto create_entry_end;
}
}
/* printf( "--------------------\n" ); fflush(stdout); */ /* _DEBUG_ */
ret = ARCreateEntry(ctrl, schema, &fieldList, entryId, &status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (! ARError( ret, status)) rv = 1;
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
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;
ARCharMenuStruct menuDefn;
char *helpText = CPNULL;
ARTimestamp timestamp;
ARAccessNameType owner;
ARAccessNameType lastChanged;
char *changeDiary = CPNULL;
ARStatusList status;
int ret = 0, i = 0;
HV *menuDef = newHV();
/* SV *ref; */
ARDiaryList diaryList;
ARPropList objPropList;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&objPropList, 1, ARPropList);
Zero(&menuDefn, 1, ARCharMenuStruct);
Zero(×tamp, 1, ARTimestamp);
Zero(owner, 1, ARAccessNameType);
Zero(lastChanged, 1, ARAccessNameType);
Zero(&diaryList, 1, ARDiaryList);
RETVAL = newHV();
sv_2mortal( (SV*) RETVAL );
ret = ARGetCharMenu(ctrl, name, &refreshCode, &menuDefn, &helpText,
×tamp, owner, lastChanged, &changeDiary,
&objPropList,
&status);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if(!ARError( ret, status)) {
hv_store(RETVAL, "name", strlen("name") , newSVpv(name, 0), 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) {
AV *a = newAV();
av_push(a, newSViv(menuDefn.u.menuQuery.labelField));
hv_store(menuDef, "labelField", strlen("labelField"),
newRV_noinc((SV *)a), 0);
}
#endif
hv_store(menuDef, "valueField", strlen("valueField") ,
newSViv(menuDefn.u.menuQuery.valueField), 0);
hv_store(menuDef, "sortOnLabel", strlen("sortOnLabel") ,
newSViv(menuDefn.u.menuQuery.sortOnLabel), 0);
/* ref = newSViv(0);
sv_setref_pv(ref, "ARQualifierStructPtr",
dup_qualifier(ctrl,
(void *)&(menuDefn.u.menuQuery.qualifier)));
hv_store(menuDef, "qualifier", strlen("qualifier") , ref, 0); */
hv_store( menuDef, "qualifier", strlen("qualifier"),
newRV_inc((SV*) perl_qualifier(ctrl,&(menuDefn.u.menuQuery.qualifier))), 0 );
hv_store(RETVAL, "menuQuery", strlen("menuQuery") ,
newRV_noinc((SV *)menuDef), 0);
break;
case AR_CHAR_MENU_FILE:
hv_store(menuDef, "fileLocation", strlen("fileLocation") ,
newSViv(menuDefn.u.menuFile.fileLocation), 0);
hv_store(menuDef, "filename", strlen("filename") ,
newSVpv(menuDefn.u.menuFile.filename, 0), 0);
hv_store(RETVAL, "menuFile", strlen("menuFile") ,
newRV_noinc((SV *)menuDef), 0);
break;
#ifndef ARS20
case AR_CHAR_MENU_SQL:
hv_store(menuDef, "server", strlen("server") ,
newSVpv(menuDefn.u.menuSQL.server, 0), 0);
hv_store(menuDef, "sqlCommand", strlen("sqlCommand") ,
newSVpv(menuDefn.u.menuSQL.sqlCommand, 0), 0);
#if AR_EXPORT_VERSION >= 6
{
int lfn = 0;
AV *a = newAV();
while (lfn < AR_MAX_LEVELS_DYNAMIC_MENU) {
if ( menuDefn.u.menuSQL.labelIndex[lfn] ) {
av_push(a, newSViv(menuDefn.u.menuSQL.labelIndex[lfn]));
} else {
av_push(a, newSVsv(&PL_sv_undef));
}
lfn++;
}
hv_store(menuDef, "labelIndex", strlen("labelIndex"),
newRV_noinc((SV *) a), 0);
}
#else
hv_store(menuDef, "labelIndex", strlen("labelIndex") ,
newSViv(menuDefn.u.menuSQL.labelIndex), 0);
#endif
hv_store(menuDef, "valueIndex", strlen("valueIndex") ,
newSViv(menuDefn.u.menuSQL.valueIndex), 0);
hv_store(RETVAL, "menuSQL", strlen("menuSQL") ,
newRV_noinc((SV *)menuDef), 0);
break;
# if AR_EXPORT_VERSION >= 6
case AR_CHAR_MENU_DATA_DICTIONARY:
hv_store(menuDef, "server", strlen("server") ,
newSVpv(menuDefn.u.menuDD.server, 0), 0);
hv_store(menuDef, "nameType", strlen("nameType") ,
newSViv(menuDefn.u.menuDD.nameType), 0);
hv_store(menuDef, "valueFormat", strlen("valueFormat") ,
newSViv(menuDefn.u.menuDD.valueFormat), 0);
hv_store(menuDef, "structType", strlen("structType") ,
newSViv(menuDefn.u.menuDD.structType), 0);
switch(menuDefn.u.menuDD.structType) {
case AR_CHAR_MENU_DD_FORM:
hv_store(menuDef, "schemaType", strlen("schemaType") ,
newSViv(menuDefn.u.menuDD.u.formDefn.schemaType), 0);
if(menuDefn.u.menuDD.u.formDefn.includeHidden)
hv_store(menuDef, "includeHidden", strlen("includeHidden") ,
newSVpv("true", 0), 0);
else
hv_store(menuDef, "includeHidden", strlen("includeHidden") ,
newSVpv("false", 0), 0);
break;
case AR_CHAR_MENU_DD_FIELD:
hv_store(menuDef, "fieldType", strlen("fieldType") ,
newSViv(menuDefn.u.menuDD.u.fieldDefn.fieldType), 0);
hv_store(menuDef, "schema", strlen("schema") ,
newSVpv(menuDefn.u.menuDD.u.fieldDefn.schema, 0), 0);
break;
}
hv_store(RETVAL, "menuDD", strlen("menuDD") ,
newRV_noinc((SV *)menuDef), 0);
break;
# endif
#endif
}
FreeARPropList(&objPropList, FALSE);
FreeARCharMenuStruct(&menuDefn, FALSE);
if (helpText) {
AP_FREE(helpText);
}
if (changeDiary) {
AP_FREE(changeDiary);
}
}else{
XSRETURN_UNDEF;
}
}
OUTPUT:
RETVAL
SV *
ars_ExpandCharMenu2(ctrl,name,qual=NULL)
ARControlStruct * ctrl
char * name
ARQualifierStruct * qual
CODE:
{
ARCharMenuStruct menuDefn;
ARStatusList status;
int ret;
RETVAL = &PL_sv_undef;
(void) ARError_reset();
XSRETURN_UNDEF;
#endif
}
OUTPUT:
RETVAL
int
ars_SetEntry(ctrl,schema,entry_id,getTime,...)
ARControlStruct * ctrl
char * schema
char * entry_id
unsigned long getTime
CODE:
{
int a = 0, i = 0, c = (items - 4) / 2;
int offset = 4;
ARFieldValueList fieldList;
ARInternalIdList getFieldIds;
ARStatusList status;
int ret = 0;
unsigned int dataType = 0, j = 0;
unsigned int option = AR_JOIN_SETOPTION_NONE;
AREntryIdList entryList;
HV *cacheFields;
(void) ARError_reset();
Zero(&status, 1,ARStatusList);
Zero(&fieldList, 1, ARFieldValueList);
Zero(&getFieldIds, 1, ARInternalIdList);
Zero(&entryList, 1,AREntryIdList);
RETVAL = 0; /* assume error */
if ((items - 4) % 2) {
option = SvIV(ST(offset));
offset ++;
}
if (c < 1) {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
goto set_entry_exit;
}
cacheFields = fieldcache_get_schema_fields( ctrl, schema, FALSE );
if( ! cacheFields ){
goto set_entry_exit;
}
fieldList.numItems = c;
AMALLOCNN(fieldList.fieldValueList,c,ARFieldValueStruct);
getFieldIds.numItems = 0;
getFieldIds.internalIdList = NULL;
for (i=0; i<c; i++) {
ARInternalId fieldId;
a = i*2+offset;
fieldId = fieldList.fieldValueList[i].fieldId = SvIV(ST(a));
if (! SvOK(ST(a+1))) {
/* pass a NULL */
fieldList.fieldValueList[i].value.dataType = AR_DATA_TYPE_NULL;
}else{
/* determine data type and pass value */
dataType = fieldcache_get_data_type( cacheFields, fieldId );
if (dataType <= AR_DATA_TYPE_MAX_TYPE) {
if (sv_to_ARValue(ctrl, ST(a+1), dataType, &fieldList.fieldValueList[i].value) < 0) {
goto set_entry_end;
}
}else{
if( getFieldIds.numItems == 0 ){
AMALLOCNN(getFieldIds.internalIdList,c,ARInternalId);
}
/* printf( "%s [%d] collect for loading\n", schema, fieldId ); fflush(stdout); */ /* _DEBUG_ */
getFieldIds.internalIdList[getFieldIds.numItems] = fieldId;
++getFieldIds.numItems;
}
}
}
/* load missing fields into cache */
if( getFieldIds.numItems > 0 ){
/* printf( "--- load missing fields ---\n" ); fflush(stdout); */ /* _DEBUG_ */
/* if( fieldcache_load_schema(ctrl,schema,&getFieldIds,NULL) != AR_RETURN_OK ){ */
if( fieldcache_load_schema(ctrl,schema,&getFieldIds,NULL) > AR_RETURN_WARNING ){
goto set_entry_end;
}
}
/* now get data type from the freshly cached fields */
i = 0;
for (j=0; j<getFieldIds.numItems; ++j) {
ARInternalId fieldId = getFieldIds.internalIdList[j];
while(fieldId != fieldList.fieldValueList[i].fieldId) ++i;
a = i*2+offset;
dataType = fieldcache_get_data_type( cacheFields, fieldId );
if (dataType <= AR_DATA_TYPE_MAX_TYPE) {
/* printf( "%s [%d] freshly loaded\n", schema, fieldId ); fflush(stdout); */ /* _DEBUG_ */
if (sv_to_ARValue(ctrl, ST(a+1), dataType, &fieldList.fieldValueList[i].value) < 0) {
goto set_entry_end;
}
}else{
char errTxt[256];
sprintf( errTxt, "Failed to fetch field %d from hash", fieldId );
ARError_add(AR_RETURN_ERROR, AP_ERR_FIELD_TYPE);
ARError_add(AR_RETURN_ERROR, AP_ERR_CONTINUE, errTxt );
goto set_entry_end;
}
}
/* printf( "--------------------\n" ); fflush(stdout); */ /* _DEBUG_ */
/* build entryList */
if(perl_BuildEntryList(ctrl, &entryList, entry_id) != 0){
goto set_entry_end;
}
ret = ARSetEntry(ctrl, schema, &entryList, &fieldList, getTime, option, &status);
if (entryList.entryIdList) AP_FREE(entryList.entryIdList);
#ifdef PROFILE
((ars_ctrl *)ctrl)->queries++;
#endif
if (! ARError( ret, status)) {
RETVAL = 1;
}
set_entry_end:;
if (fieldList.fieldValueList) AP_FREE(fieldList.fieldValueList);
set_entry_exit:;
}
OUTPUT:
RETVAL
SV *
ars_Export(ctrl,displayTag,vuiType,...)
ARControlStruct * ctrl
char * displayTag
unsigned int vuiType
CODE:
{
int ret = 0, i = 0, a = 0, c = (items - 3) / 2, ok = 1;
ARStructItemList structItems;
char *buf = CPNULL;
ARStatusList status;
#if AR_CURRENT_API_VERSION >= 17
unsigned int exportOption = AR_EXPORT_DEFAULT; /* TODO: support this as ars_Export() argument */
#endif
#if AR_EXPORT_VERSION >= 8L
ARWorkflowLockStruct workflowLockStruct;
#endif
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
Zero(&structItems, 1, ARStructItemList);
#if AR_EXPORT_VERSION >= 8L
Zero(&workflowLockStruct, 1, ARWorkflowLockStruct);
#endif
RETVAL = &PL_sv_undef;
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;
}
}
if( SvROK(menuDefRef) && SvTYPE(SvRV(menuDefRef)) == SVt_PVHV ){
menuDef = (HV*) SvRV(menuDefRef);
}else{
croak("usage: ars_CreateCharMenu(...)");
}
rv += strcpyHVal( menuDef, "name", name, AR_MAX_NAME_SIZE );
/* rv += uintcpyHVal( menuDef, "refreshCode", &type ); */
rv += strmakHVal( menuDef, "refreshCode", &refreshCodeStr );
refreshCode = revTypeName( (TypeMapStruct*)CharMenuRefreshCodeTypeMap, refreshCodeStr );
if( refreshCode == TYPEMAP_LAST ){
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"ars_CreateCharMenu: refreshCode key invalid. key follows:");
ARError_add(AR_RETURN_WARNING, AP_ERR_CONTINUE,
refreshCodeStr ? refreshCodeStr : "[key null]" );
}
if( refreshCodeStr != NULL ){ AP_FREE(refreshCodeStr); }
rv += strmakHVal( menuDef, "menuType", &menuTypeStr );
arMenuDef.menuType = revTypeName( (TypeMapStruct*)CharMenuTypeMap, menuTypeStr );
if( arMenuDef.menuType == TYPEMAP_LAST ){
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"ars_CreateCharMenu: menuType key invalid. key follows:");
ARError_add(AR_RETURN_WARNING, AP_ERR_CONTINUE,
menuTypeStr ? menuTypeStr : "[key null]" );
}
if( menuTypeStr != NULL ){ AP_FREE(menuTypeStr); }
switch( arMenuDef.menuType ){
case AR_CHAR_MENU_LIST:
pSvTemp = hv_fetch( menuDef, "menuList", strlen("menuList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuList( ctrl, menuDef, "menuList", &(arMenuDef.u.menuList) );
}
break;
case AR_CHAR_MENU_QUERY:
pSvTemp = hv_fetch( menuDef, "menuQuery", strlen("menuQuery") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuQueryStruct( ctrl, menuDef, "menuQuery", &(arMenuDef.u.menuQuery) );
}
break;
case AR_CHAR_MENU_FILE:
pSvTemp = hv_fetch( menuDef, "menuFile", strlen("menuFile") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuFileStruct( ctrl, menuDef, "menuFile", &(arMenuDef.u.menuFile) );
}
break;
case AR_CHAR_MENU_SQL:
pSvTemp = hv_fetch( menuDef, "menuSQL", strlen("menuSQL") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuSQLStruct( ctrl, menuDef, "menuSQL", &(arMenuDef.u.menuSQL) );
}
break;
case AR_CHAR_MENU_SS:
pSvTemp = hv_fetch( menuDef, "menuSS", strlen("menuSS") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuSSStruct( ctrl, menuDef, "menuSS", &(arMenuDef.u.menuSS) );
}
break;
case AR_CHAR_MENU_DATA_DICTIONARY:
pSvTemp = hv_fetch( menuDef, "menuDD", strlen("menuDD") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuDDStruct( ctrl, menuDef, "menuDD", &(arMenuDef.u.menuDD) );
}
break;
}
objPropList.numItems = 0;
objPropList.props = NULL;
pSvTemp = hv_fetch( menuDef, "objPropList", strlen("objPropList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARPropList( ctrl, menuDef, "objPropList", &objPropList );
}
if( hv_exists(menuDef,"helpText",8) ){
rv += strmakHVal( menuDef, "helpText", &helpText );
}
if( hv_exists(menuDef,"owner",5) ){
rv += strcpyHVal( menuDef, "owner", owner, AR_MAX_ACCESS_NAME_SIZE );
}
if( hv_exists(menuDef,"changeDiary",11) ){
rv += strmakHVal( menuDef, "changeDiary", &changeDiary );
}
if( rv == 0 ){
ret = ARCreateCharMenu( ctrl,
name,
refreshCode,
&arMenuDef,
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 );
}
FreeARCharMenuStruct( &arMenuDef, FALSE );
FreeARPropList( &objPropList, FALSE );
#else /* < 5.0 */
XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ARSperl supports CreateCharMenu() only for ARSystem >= 5.0");
RETVAL = AR_RETURN_ERROR;
#endif
}
OUTPUT:
/* rv += uintcpyHVal( menuDef, "refreshCode", &refreshCode ); */
rv += strmakHVal( menuDef, "refreshCode", &refreshCodeStr );
refreshCode = revTypeName( (TypeMapStruct*)CharMenuRefreshCodeTypeMap, refreshCodeStr );
if( refreshCode == TYPEMAP_LAST ){
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"ars_CreateCharMenu: refreshCode key invalid. key follows:");
ARError_add(AR_RETURN_WARNING, AP_ERR_CONTINUE,
refreshCodeStr ? refreshCodeStr : "[key null]" );
}
if( refreshCodeStr != NULL ){ AP_FREE(refreshCodeStr); }
refreshCodePtr = &refreshCode;
}
if( hv_exists(menuDef,"menuType",4) ){
/* rv += uintcpyHVal( menuDef, "menuType", &menuType ); */
arMenuDef = (ARCharMenuStruct*) MALLOCNN( sizeof(ARCharMenuStruct) );
rv += strmakHVal( menuDef, "menuType", &menuTypeStr );
arMenuDef->menuType = revTypeName( (TypeMapStruct*)CharMenuTypeMap, menuTypeStr );
if( arMenuDef->menuType == TYPEMAP_LAST ){
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"ars_CreateCharMenu: menuType key invalid. key follows:");
ARError_add(AR_RETURN_WARNING, AP_ERR_CONTINUE,
menuTypeStr ? menuTypeStr : "[key null]" );
}
if( menuTypeStr != NULL ){ AP_FREE(menuTypeStr); }
switch( arMenuDef->menuType ){
case AR_CHAR_MENU_LIST:
pSvTemp = hv_fetch( menuDef, "menuList", strlen("menuList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuList( ctrl, menuDef, "menuList", &(arMenuDef->u.menuList) );
}
break;
case AR_CHAR_MENU_QUERY:
pSvTemp = hv_fetch( menuDef, "menuQuery", strlen("menuQuery") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuQueryStruct( ctrl, menuDef, "menuQuery", &(arMenuDef->u.menuQuery) );
}
break;
case AR_CHAR_MENU_FILE:
pSvTemp = hv_fetch( menuDef, "menuFile", strlen("menuFile") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuFileStruct( ctrl, menuDef, "menuFile", &(arMenuDef->u.menuFile) );
}
break;
case AR_CHAR_MENU_SQL:
pSvTemp = hv_fetch( menuDef, "menuSQL", strlen("menuSQL") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuSQLStruct( ctrl, menuDef, "menuSQL", &(arMenuDef->u.menuSQL) );
}
break;
case AR_CHAR_MENU_SS:
pSvTemp = hv_fetch( menuDef, "menuSS", strlen("menuSS") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuSSStruct( ctrl, menuDef, "menuSS", &(arMenuDef->u.menuSS) );
}
break;
case AR_CHAR_MENU_DATA_DICTIONARY:
pSvTemp = hv_fetch( menuDef, "menuDD", strlen("menuDD") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
rv += rev_ARCharMenuDDStruct( ctrl, menuDef, "menuDD", &(arMenuDef->u.menuDD) );
}
break;
}
}
pSvTemp = hv_fetch( menuDef, "objPropList", strlen("objPropList") , 0 );
if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
objPropList = (ARPropList*) MALLOCNN( sizeof(ARPropList) );
rv += rev_ARPropList( ctrl, menuDef, "objPropList", objPropList );
}
if( hv_exists(menuDef,"helpText",8) ){
rv += strmakHVal( menuDef, "helpText", &helpText );
}
if( hv_exists(menuDef,"owner",5) ){
rv += strcpyHVal( menuDef, "owner", owner, AR_MAX_ACCESS_NAME_SIZE );
}
if( hv_exists(menuDef,"changeDiary",11) ){
rv += strmakHVal( menuDef, "changeDiary", &changeDiary );
}
if( rv == 0 ){
ret = ARSetCharMenu( ctrl,
name,
newNamePtr,
refreshCodePtr,
arMenuDef,
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,
}
if (changeDiary) {
AP_FREE(changeDiary);
}
if (description) {
AP_FREE(description);
}
if (imageType) {
AP_FREE(description);
}
if( imageBuf != NULL ) { FreeARImageDataStruct(imageBuf, TRUE); }
if( objPropList != NULL ) { FreeARPropList(objPropList, TRUE); }
#else /* prior to ARS 7.5 */
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED,
"ars_SetImage() is only available in ARS >= 7.5");
XSRETURN_UNDEF;
#endif
}
OUTPUT:
RETVAL
char *
ars_MergeEntry(ctrl, schema, mergeType, ...)
ARControlStruct * ctrl
char * schema
unsigned int mergeType
CODE:
{
int a, i, c = (items - 3) / 2;
ARFieldValueList fieldList;
ARStatusList status;
int ret = 0;
unsigned int dataType = 0;
AREntryIdType entryId;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
Zero(&fieldList, 1, ARFieldValueList);
Zero(&entryId, 1, AREntryIdType);
RETVAL = "";
if ((items - 3) % 2 || c < 1) {
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
goto merge_entry_exit;
}
fieldList.numItems = c;
AMALLOCNN(fieldList.fieldValueList, c, ARFieldValueStruct);
for (i = 0; i < c; i++) {
a = i*2 + 3;
fieldList.fieldValueList[i].fieldId = SvIV(ST(a));
if (! SvOK(ST(a+1))) {
/* pass a NULL */
fieldList.fieldValueList[i].value.dataType =
AR_DATA_TYPE_NULL;
} 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
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;
( run in 0.631 second using v1.01-cache-2.11-cpan-140bd7fdf52 )