ARSperl
view release on metacpan or search on metacpan
supportrev.c view on Meta::CPAN
* allocate space for action
* structure list
*/
al->numItems = av_len(ar) + 1;
if (al->numItems == 0)
return 0; /* nothing to do */
al->actionList = MALLOCNN(sizeof(ARActiveLinkActionStruct) * al->numItems);
/*
* iterate over the array, grabbing
* each hash reference out of it and
* passing that to a helper routine
* to fill in the ActionList
* structure. one action per array
* item.
*/
for (i = 0; i <= av_len(ar); i++) {
SV **av_hv = av_fetch(ar, i, 0);
if (av_hv && *av_hv && (SvTYPE(SvRV(*av_hv)) == SVt_PVHV)) {
if (rev_ARActiveLinkActionList_helper(ctrl,
(HV *) SvRV(*av_hv), al, i) != 0)
return -1;
} else
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"rev_ARActiveLinkActionList: inner array value is not a hash reference");
}
return 0;
} else
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"rev_ARActiveLinkActionList: hash value is not an array reference");
} else {
ARError_add(AR_RETURN_WARNING, AP_ERR_GENERAL,
"rev_ARActiveLinkActionList: hv_fetch returned null");
return -2;
}
} else {
ARError_add(AR_RETURN_WARNING, AP_ERR_GENERAL,
"rev_ARActiveLinkActionList: key doesn't exist");
return -2;
}
} else
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"rev_ARActiveLinkActionList: first argument is not a hash");
return -1;
}
/* helper routine to above routine. does the actual data copying once
* main routine has verified that everything is OK.
*/
static int
rev_ARActiveLinkActionList_helper(ARControlStruct * ctrl, HV * h, ARActiveLinkActionList * al, int idx)
{
int rv = 0;
/*
* test each has value in turn, first one that is defined, copy in
* and return. DDE: not implemented.
*/
if (hv_exists(h, "process", strlen("process") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_PROCESS;
rv += strmakHVal(h, "process", &(al->actionList[idx].u.process));
} else if (hv_exists(h, "macro", strlen("macro") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_MACRO;
rv += rev_ARActiveLinkMacroStruct(ctrl, h, "macro",
&(al->actionList[idx].u.macro));
} else if (hv_exists(h, "assign_fields", strlen("assign_fields") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_FIELDS;
#if AR_EXPORT_VERSION >= 8L
rv += rev_ARSetFieldsActionStruct(ctrl, h, "assign_fields",
&(al->actionList[idx].u.setFields));
#else
rv += rev_ARFieldAssignList(ctrl, h, "assign_fields",
&(al->actionList[idx].u.fieldList));
#endif
} else if (hv_exists(h, "message", strlen("message") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_MESSAGE;
#if AR_EXPORT_VERSION >= 4
rv += rev_ARMessageStruct(ctrl, h, "message",
&(al->actionList[idx].u.message));
#else
rv += rev_ARStatusStruct(ctrl, h, "message",
&(al->actionList[idx].u.message));
#endif
} else if (hv_exists(h, "characteristics", strlen("characteristics") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_SET_CHAR;
rv += rev_ARFieldCharacteristics(ctrl, h, "characteristics",
&(al->actionList[idx].u.characteristics));
} else if (hv_exists(h, "fieldp", strlen("fieldp") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_FIELDP;
#if AR_EXPORT_VERSION >= 8L
rv += rev_ARPushFieldsActionStruct(ctrl, h, "fieldp",
&(al->actionList[idx].u.pushFields));
#else
rv += rev_ARPushFieldsList(ctrl, h, "fieldp",
&(al->actionList[idx].u.pushFieldsList));
#endif
} else if (hv_exists(h, "openDlg", strlen("openDlg") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_OPENDLG;
rv += rev_AROpenDlgStruct(ctrl, h, "openDlg",
&(al->actionList[idx].u.openDlg));
} else if (hv_exists(h, "closeWnd", strlen("closeWnd") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_CLOSEWND;
rv += rev_ARCloseWndStruct(ctrl, h, "closeWnd",
&(al->actionList[idx].u.closeWnd));
} else if (hv_exists(h, "commitChanges", strlen("commitChanges") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_COMMITC;
rv += rev_ARCommitChangesStruct(ctrl, h, "commitChanges",
&(al->actionList[idx].u.commitChanges));
} else if (hv_exists(h, "callGuide", strlen("callGuide") )) {
al->actionList[idx].action = AR_ACTIVE_LINK_ACTION_CALLGUIDE;
supportrev.c view on Meta::CPAN
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"rev_ARFieldAssignList: first argument is not a hash");
return -1;
}
static int
rev_ARAssignList_helper(ARControlStruct * ctrl, HV * h, ARFieldAssignList * m, int i)
{
int rv = 0;
rv += ulongcpyHVal(h, "fieldId", &(m->fieldAssignList[i].fieldId));
rv += rev_ARAssignStruct(ctrl, h, "assignment",
&(m->fieldAssignList[i].assignment));
return rv;
}
int
rev_ARAssignStruct(ARControlStruct * ctrl, HV * h, char *k, ARAssignStruct * m)
{
if (!m || !h || !k) {
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"rev_ARAssignStruct: invalid (NULL) parameter");
return -1;
}
if (SvTYPE((SV *) h) == SVt_PVHV) {
if (hv_exists(h, k, strlen(k) )) {
SV **val = hv_fetch(h, k, strlen(k) , 0);
if (val && *val) {
/* hash value should be a hash reference */
if (SvTYPE(SvRV(*val)) == SVt_PVHV) {
HV *a = (HV *) SvRV((SV *) * val);
return rev_ARAssignStruct_helper(ctrl, a, m);
} else
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"rev_ARAssignStruct: hash value is not an array reference");
} else {
ARError_add(AR_RETURN_WARNING, AP_ERR_GENERAL,
"rev_ARAssignStruct: hv_fetch returned null");
return -2;
}
} else {
ARError_add(AR_RETURN_WARNING, AP_ERR_GENERAL,
"rev_ARAssignStruct: key doesn't exist");
return -2;
}
} else
ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
"rev_ARAssignStruct: first argument is not a hash");
return -1;
}
static int
rev_ARAssignStruct_helper(ARControlStruct * ctrl, HV * h, ARAssignStruct * m)
{
int rv = 0;
/*
* test each key in turn, first one that is defined, copy in and
* return. DDE: not implemented.
*/
if (hv_exists(h, "process", strlen("process") )) {
m->assignType = AR_ASSIGN_TYPE_PROCESS;
rv += strmakHVal(h, "process", &(m->u.process));
} else if (hv_exists(h, "value", strlen("value") )) {
m->assignType = AR_ASSIGN_TYPE_VALUE;
rv += rev_ARValueStruct(ctrl, h, "value", "valueType", &(m->u.value));
}
/*
* note. the below union members are pointers. so we will allocate
* space for them and then call the subroutine to populate them with
* data. (with the exception of 'process' whose subroutine will do
* the allocating for us)
*/
else if (hv_exists(h, "field", strlen("field") )) {
m->assignType = AR_ASSIGN_TYPE_FIELD;
m->u.field = MALLOCNN(sizeof(ARAssignFieldStruct));
rv += rev_ARAssignFieldStruct(ctrl, h, "field", m->u.field);
} else if (hv_exists(h, "arith", strlen("arith") )) {
m->assignType = AR_ASSIGN_TYPE_ARITH;
m->u.arithOp = MALLOCNN(sizeof(ARArithOpAssignStruct));
rv += rev_ARArithOpAssignStruct(ctrl, h, "arith", m->u.arithOp);
} else if (hv_exists(h, "function", strlen("function") )) {
m->assignType = AR_ASSIGN_TYPE_FUNCTION;
m->u.function = MALLOCNN(sizeof(ARFunctionAssignStruct));
rv += rev_ARFunctionAssignStruct(ctrl, h, "function", m->u.function);
}
#if AR_EXPORT_VERSION >= 3
else if (hv_exists(h, "sql", strlen("sql") )) {
m->assignType = AR_ASSIGN_TYPE_SQL;
m->u.sql = (ARAssignSQLStruct*) MALLOCNN(sizeof(ARAssignSQLStruct));
rv += rev_ARAssignSQLStruct(ctrl, h, "sql", m->u.sql);
}
#endif
else if (hv_exists(h, "none", strlen("none") )) {
m->assignType = AR_ASSIGN_TYPE_NONE;
} else {
rv = -1;
}
return rv;
}
#if AR_EXPORT_VERSION >= 3
int
rev_ARAssignSQLStruct(ARControlStruct * ctrl, HV * h, char *k, ARAssignSQLStruct * s)
{
SV **h_sv = hv_fetch(h, k, strlen(k) , 0);
SV **svp;
HV *hr;
int rv = 0;
/* STRLEN len; */
/* dereference the hash key and extract it */
if (SvROK(*h_sv) && SvTYPE(SvRV(*h_sv)) == SVt_PVHV) {
( run in 0.611 second using v1.01-cache-2.11-cpan-39bf76dae61 )