00001 #include "reGlobalsExtern.h"
00002 #include "execMyRule.h"
00003 #include "miscServerFunct.h"
00004
00005 int
00006 rsExecMyRule (rsComm_t *rsComm, execMyRuleInp_t *execMyRuleInp,
00007 msParamArray_t **outParamArray)
00008 {
00009 int status;
00010 ruleExecInfo_t rei;
00011 char *iFlag;
00012 int oldReTestFlag, oldReLoopBackFlag;
00013 rodsServerHost_t *rodsServerHost;
00014 int remoteFlag;
00015
00016 if (execMyRuleInp == NULL) {
00017 rodsLog(LOG_NOTICE,
00018 "rsExecMyRule error. NULL input");
00019 return (SYS_INTERNAL_NULL_INPUT_ERR);
00020 }
00021
00022 remoteFlag = resolveHost (&execMyRuleInp->addr, &rodsServerHost);
00023
00024 if (remoteFlag == REMOTE_HOST) {
00025 status = remoteExecMyRule (rsComm, execMyRuleInp,
00026 outParamArray, rodsServerHost);
00027 return status;
00028 }
00029
00030 initReiWithDataObjInp (&rei, rsComm, NULL);
00031 rei.condInputData = &execMyRuleInp->condInput;
00032
00033 if (execMyRuleInp->inpParamArray == NULL) {
00034 execMyRuleInp->inpParamArray =
00035 (msParamArray_t *) malloc (sizeof (msParamArray_t));
00036 memset (execMyRuleInp->inpParamArray, 0, sizeof (msParamArray_t));
00037 }
00038 rei.msParamArray = execMyRuleInp->inpParamArray;
00039
00040 if ((iFlag = getValByKey (rei.condInputData,"looptest")) != NULL &&
00041 !strcmp(iFlag,"true")) {
00042 oldReTestFlag = reTestFlag;
00043 oldReLoopBackFlag = reLoopBackFlag;
00044 reTestFlag = LOG_TEST_2;
00045 reLoopBackFlag = LOOP_BACK_1;
00046 }
00047
00048 rstrcpy (rei.ruleName, EXEC_MY_RULE_KW, NAME_LEN);
00049
00050 #if defined(RULE_ENGINE_N)
00051 status = execMyRule (execMyRuleInp->myRule, execMyRuleInp->inpParamArray, execMyRuleInp->outParamDesc,
00052 &rei);
00053 #else
00054 status = execMyRule (execMyRuleInp->myRule, execMyRuleInp->inpParamArray,
00055 &rei);
00056 #endif
00057
00058
00059 if (iFlag != NULL) {
00060 reTestFlag = oldReTestFlag;
00061 reLoopBackFlag = oldReLoopBackFlag;
00062 }
00063
00064 trimMsParamArray (rei.msParamArray, execMyRuleInp->outParamDesc);
00065
00066 *outParamArray = rei.msParamArray;
00067 rei.msParamArray = NULL;
00068
00069 if (status < 0) {
00070 rodsLog (LOG_ERROR,
00071 "rsExecMyRule : execMyRule error for %s, status = %d",
00072 execMyRuleInp->myRule, status);
00073 return (status);
00074 }
00075
00076 return (status);
00077 }
00078
00079 int
00080 remoteExecMyRule (rsComm_t *rsComm, execMyRuleInp_t *execMyRuleInp,
00081 msParamArray_t **outParamArray, rodsServerHost_t *rodsServerHost)
00082 {
00083 int status;
00084
00085 if (rodsServerHost == NULL) {
00086 rodsLog (LOG_ERROR,
00087 "remoteExecMyRule: Invalid rodsServerHost");
00088 return SYS_INVALID_SERVER_HOST;
00089 }
00090
00091 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00092 return status;
00093 }
00094
00095 status = rcExecMyRule (rodsServerHost->conn, execMyRuleInp, outParamArray);
00096
00097 return (status);
00098 }
00099