00001 /** 00002 * @file ruleAdminMS.c 00003 * 00004 */ 00005 00006 /*** Copyright (c), The Regents of the University of California *** 00007 *** For more information please refer to files in the COPYRIGHT directory ***/ 00008 00009 #include "reGlobalsExtern.h" 00010 #include "rsGlobalExtern.h" 00011 #include "dataObjCreate.h" 00012 #include "objMetaOpr.h" 00013 #include "regDataObj.h" 00014 /* #include "reAction.h" */ 00015 #include "miscServerFunct.h" 00016 00017 00018 00019 00020 /** 00021 * \fn msiAdmChangeCoreIRB (msParam_t *newFileNameParam, ruleExecInfo_t *rei) 00022 * 00023 * \brief This microservice copies the specified file in the configuration 00024 * directory 'server/config/reConfigs' onto the core.irb file in the same directory. 00025 * 00026 * \module core 00027 * 00028 * \since pre-2.1 00029 * 00030 * \author Arcot Rajasekar 00031 * \date 2007-04 00032 * 00033 * \note This microservice expects the alternate file to be of the form *.irb and to be 00034 * located in the configuration directory. 00035 * 00036 * \note This microservice requires iRODS administration privilege. 00037 * 00038 * \note This microservice changes the core.irb file currently in the configuration 00039 * directory. It can be invoked through an irule. When the server is re-started, the 00040 * new core file will be used by the rule engine. 00041 * 00042 * \usage See clients/icommands/test/rules3.0/ 00043 * 00044 * \param[in] newFileNameParam - is a msParam of type STR_MS_T, which is a new core file name without the .irb extension. 00045 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00046 * handled by the rule engine. The user does not include rei as a 00047 * parameter in the rule invocation. 00048 * 00049 * \DolVarDependence none 00050 * \DolVarModified none 00051 * \iCatAttrDependence none 00052 * \iCatAttrModified none 00053 * \sideeffect The core.irb file is replaced by the alternate core file. 00054 * 00055 * \return integer 00056 * \retval 0 on success 00057 * \pre none 00058 * \post none 00059 * \sa none 00060 **/ 00061 int msiAdmChangeCoreIRB(msParam_t *newFileNameParam, ruleExecInfo_t *rei) 00062 { 00063 /* newFileNameParam contains the file name of the new core. 00064 The file should be in reConfigs directory */ 00065 00066 char sysString[1000]; 00067 int i; 00068 00069 RE_TEST_MACRO ("Loopback on admChangeCoreIRB"); 00070 00071 if (strcmp (newFileNameParam->type,STR_MS_T) != 0) 00072 return(USER_PARAM_TYPE_ERR); 00073 00074 if ((i = isUserPrivileged(rei->rsComm)) != 0) 00075 return (i); 00076 00077 snprintf(sysString, 999, "cp %s/reConfigs/%s %s/reConfigs/core.irb", 00078 (char *) getConfigDir (), (char *) newFileNameParam->inOutStruct, 00079 (char *) getConfigDir ()); 00080 system(sysString); 00081 00082 00083 return(0); 00084 } 00085 00086 /** 00087 * \fn msiAdmAppendToTopOfCoreIRB (msParam_t *newFileNameParam, ruleExecInfo_t *rei) 00088 * 00089 * \brief This is a microservice that changes the core.irb file currently in 00090 * the configuration directory 'server/config/reConfigs' by prepending the given 00091 * rules file to it. When the server is started next time, 00092 * then the new core file will be used by the rule engine. 00093 * 00094 * \module core 00095 * 00096 * \since pre-2.1 00097 * 00098 * \author Arcot Rajasekar 00099 * \date 2007-04 00100 * 00101 * \note This microservice requires iRODS administration privileges. 00102 * 00103 * \note This microservice expects the prepended file to be of the form *.irb and to be 00104 * located in the configuration directory. 00105 * 00106 * \usage See clients/icommands/test/rules3.0/ 00107 * 00108 * \param[in] newFileNameParam - is a msParam of type STR_MS_T, which is a prepended core file name without the .irb extension. 00109 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00110 * handled by the rule engine. The user does not include rei as a 00111 * parameter in the rule invocation. 00112 * 00113 * \DolVarDependence none 00114 * \DolVarModified none 00115 * \iCatAttrDependence none 00116 * \iCatAttrModified none 00117 * \sideeffect core.irb file is prepended by the alternate new core file. 00118 * 00119 * \return integer 00120 * \retval 0 on success 00121 * \pre none 00122 * \post none 00123 * \sa msiAdmShowIRB, msiAdmChangeCoreIRB 00124 **/ 00125 int msiAdmAppendToTopOfCoreIRB(msParam_t *newFileNameParam, ruleExecInfo_t *rei) 00126 { 00127 /* newFileNameParam contains the file name to be added to top of core.irb 00128 The file should be in reConfigs directory */ 00129 00130 char sysString[1000]; 00131 int i; 00132 char *conDir; 00133 00134 RE_TEST_MACRO ("Loopback on admAppendToTopOfCoreIRB"); 00135 00136 if (strcmp (newFileNameParam->type,STR_MS_T) != 0) 00137 return(USER_PARAM_TYPE_ERR); 00138 00139 if ((i = isUserPrivileged(rei->rsComm)) != 0) 00140 return (i); 00141 conDir = getConfigDir (); 00142 snprintf(sysString, 999, "cat %s/reConfigs/%s %s/reConfigs/core.irb > %s/reConfigs/admtmpcore.irb", 00143 conDir, (char *) newFileNameParam->inOutStruct, 00144 conDir, conDir); 00145 system(sysString); 00146 snprintf(sysString, 999, "mv %s/reConfigs/admtmpcore.irb %s/reConfigs/core.irb", 00147 conDir,conDir); 00148 system(sysString); 00149 return(0); 00150 00151 00152 } 00153 00154 /** 00155 * \fn msiAdmShowDVM (msParam_t *bufParam, ruleExecInfo_t *rei) 00156 * 00157 * \brief This is a microservice that reads the data-value-mapping data structure 00158 * in the Rule Engine and pretty-prints that structure to the stdout buffer. 00159 * 00160 * \module core 00161 * 00162 * \since pre-2.1 00163 * 00164 * \author Arcot Rajasekar 00165 * \date 2007-08 00166 * 00167 * \note This microservice uses a dummy parameter. 00168 * 00169 * \note Lists the currently loaded dollar variable mappings from the rule 00170 * engine memory. The list is written to stdout in ruleExecOut. 00171 * 00172 * \usage See clients/icommands/test/rules3.0/ 00173 * 00174 * \param[in] bufParam - is a msParam (not used for anything, a dummy parameter) 00175 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00176 * handled by the rule engine. The user does not include rei as a 00177 * parameter in the rule invocation. 00178 * 00179 * \DolVarDependence none 00180 * \DolVarModified - rei->MsParamArray->MsParam->ruleExecOut->stdout is modified 00181 * \iCatAttrDependence none 00182 * \iCatAttrModified none 00183 * \sideeffect none 00184 * 00185 * \return integer 00186 * \retval 0 on success 00187 * \pre none 00188 * \post none 00189 * \sa msiAdmShowIRB, msiAdmShowFNM 00190 **/ 00191 int msiAdmShowDVM(msParam_t *bufParam, ruleExecInfo_t *rei) 00192 { 00193 int i; 00194 00195 _writeString("stdout","----------------------------- DVM -----------------------------\n",rei); 00196 00197 i = _admShowDVM(bufParam, rei, &appRuleVarDef,0); 00198 if (i != 0) 00199 return(i); 00200 i = _admShowDVM(bufParam, rei, &coreRuleVarDef,1000); 00201 _writeString("stdout","----------------------------- DVM -----------------------------\n",rei); 00202 return(i); 00203 } 00204 00205 int _admShowDVM(msParam_t *bufParam, ruleExecInfo_t *rei, rulevardef_t *inRuleVarDef, int inx) 00206 { 00207 int j; 00208 char outStr[MAX_RULE_LENGTH]; 00209 00210 _writeString("stdout","---------------------------------------------------------------\n",rei); 00211 for( j = 0 ; j < inRuleVarDef->MaxNumOfDVars ; j++) { 00212 sprintf(outStr," %-5i %-15.15s %s ===> %s\n",j+inx,inRuleVarDef->action[j], 00213 inRuleVarDef->varName[j], inRuleVarDef->var2CMap[j]); 00214 _writeString("stdout",outStr,rei); 00215 } 00216 _writeString("stdout","---------------------------------------------------------------\n",rei); 00217 return(0); 00218 } 00219 00220 /** 00221 * \fn msiAdmShowFNM (msParam_t *bufParam, ruleExecInfo_t *rei) 00222 * 00223 * \brief This is a microservice that reads the function-name-mapping data structure 00224 * in the Rule Engine and pretty-prints that structure to the stdout buffer. 00225 * 00226 * \module core 00227 * 00228 * \since pre-2.1 00229 * 00230 * \author Arcot Rajasekar 00231 * \date 2007-08 00232 * 00233 * \note This microservice has a dummy parameter. 00234 * 00235 * \note This microservice lists the currently loaded microServices and action 00236 * name mappings from the rule engine memory. The list is written to stdout in ruleExecOut. 00237 * 00238 * \usage See clients/icommands/test/rules3.0/ 00239 * 00240 * \param[in] bufParam - is a msParam (not used for anything, a dummy parameter) 00241 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00242 * handled by the rule engine. The user does not include rei as a 00243 * parameter in the rule invocation. 00244 * 00245 * \DolVarDependence none 00246 * \DolVarModified - rei->MsParamArray->MsParam->ruleExecOut->stdout is modified 00247 * \iCatAttrDependence none 00248 * \iCatAttrModified none 00249 * \sideeffect none 00250 * 00251 * \return integer 00252 * \retval 0 on success 00253 * \pre none 00254 * \post none 00255 * \sa msiAdmShowIRB, msiAdmShowDVM 00256 **/ 00257 int msiAdmShowFNM(msParam_t *bufParam, ruleExecInfo_t *rei) 00258 { 00259 int i; 00260 00261 _writeString("stdout","----------------------------- FNM -----------------------------\n",rei); 00262 i = _admShowFNM(bufParam, rei, &appRuleFuncMapDef,0); 00263 if (i != 0) 00264 return(i); 00265 i = _admShowFNM(bufParam, rei, &coreRuleFuncMapDef,1000); 00266 _writeString("stdout","----------------------------- FNM -----------------------------\n",rei); 00267 return(i); 00268 } 00269 00270 int _admShowFNM(msParam_t *bufParam, ruleExecInfo_t *rei, rulefmapdef_t *inRuleFuncMapDef, int inx) 00271 { 00272 00273 int j; 00274 char outStr[MAX_RULE_LENGTH]; 00275 00276 _writeString("stdout","---------------------------------------------------------------\n",rei); 00277 for( j = 0 ; j < inRuleFuncMapDef->MaxNumOfFMaps ; j++) { 00278 sprintf(outStr," %-5i %s ===> %s\n",j+inx, inRuleFuncMapDef->funcName[j], inRuleFuncMapDef->func2CMap[j]); 00279 _writeString("stdout",outStr,rei); 00280 } 00281 _writeString("stdout","---------------------------------------------------------------\n",rei); 00282 return(0); 00283 00284 } 00285 00286 /** 00287 * \fn msiAdmShowIRB (msParam_t *bufParam, ruleExecInfo_t *rei) 00288 * 00289 * \brief This is a microservice that reads the data structure in the Rule Engine, which holds the 00290 * current set of Rules, and pretty-prints that structure to the stdout buffer. 00291 * 00292 * \module core 00293 * 00294 * \since pre-2.1 00295 * 00296 * \author Arcot Rajasekar 00297 * \date 2007-06 00298 * 00299 * \note This microservice has a dummy parameter. 00300 * 00301 * \usage See clients/icommands/test/rules3.0/ 00302 * 00303 * \param[in] bufParam - is a msParam (not used for anything, a dummy parameter) 00304 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00305 * handled by the rule engine. The user does not include rei as a 00306 * parameter in the rule invocation. 00307 * 00308 * \DolVarDependence none 00309 * \DolVarModified - rei->MsParamArray->MsParam->ruleExecOut->stdout is modified 00310 * \iCatAttrDependence none 00311 * \iCatAttrModified none 00312 * \sideeffect none 00313 * 00314 * \return integer 00315 * \retval 0 on success 00316 * \pre none 00317 * \post none 00318 * \sa msiAdmShowDVM, msiAdmShowFNM 00319 **/ 00320 00321 /** 00322 * \fn msiAdmClearAppRuleStruct (ruleExecInfo_t *rei) 00323 * 00324 * \brief This is a microservice that clears the application level IRB Rules and DVM 00325 * and FNM mappings that were loaded into the Rule engine's working memory. 00326 * 00327 * \module core 00328 * 00329 * \since pre-2.1 00330 * 00331 * \author Arcot Rajasekar 00332 * \date 2007-09 00333 * 00334 * \note This microservice needs iRODS administration privileges to perform 00335 * this function. 00336 * 00337 * \note Clears the application structures in the working memory of the rule engine 00338 * holding the rules, $-variable mappings and microService name mappings. 00339 * 00340 * \usage See clients/icommands/test/rules3.0/ 00341 * 00342 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00343 * handled by the rule engine. The user does not include rei as a 00344 * parameter in the rule invocation. 00345 * 00346 * \DolVarDependence none 00347 * \DolVarModified none 00348 * \iCatAttrDependence none 00349 * \iCatAttrModified none 00350 * \sideeffect The rule engine's application-level ruleset and mappings get cleared. 00351 * 00352 * \return integer 00353 * \retval 0 on success 00354 * \pre none 00355 * \post none 00356 * \sa msiAdmAddAppRuleStruct, msiAdmShowIRB, msiAdmShowDVM, msiAdmShowFNM 00357 **/ 00358 00359 /** 00360 * \fn msiAdmAddAppRuleStruct(msParam_t *irbFilesParam, msParam_t *dvmFilesParam, 00361 * msParam_t *fnmFilesParam, ruleExecInfo_t *rei) 00362 * 00363 * \brief This is a microservice that reads the given file in the configuration directory 00364 * 'server/config/reConfigs' and adds them to the Rule list being used by the Rule 00365 * Engine. These Rules are loaded at the beginning of the core.irb file, and hence can 00366 * be used to override the core Rules from the core.irb file (i.e., it adds application level 00367 * IRB Rules and DVM and FNM mappings to the Rule engine). 00368 * 00369 * \module core 00370 * 00371 * \since pre-2.1 00372 * 00373 * \author Arcot Rajasekar 00374 * \date 2007-09 00375 * 00376 * \note This microservice requires iRODS administration privileges. 00377 * 00378 * \note Adds the given rules (irb) file and $-variable mapping (dvm) and microService 00379 * logical microService logical name mapping (fnm) files to the working memory 00380 * of the rule engine. Any subsequent rule or microServices will also use the newly 00381 * prepended rules and mappings 00382 * 00383 * \usage See clients/icommands/test/rules3.0/ 00384 * 00385 * \param[in] irbFilesParam - a msParam of type STR_MS_T, which is an application Rules file name without the .irb extension. 00386 * \param[in] dvmFilesParam - a msParam of type STR_MS_T, which is a variable file name mapping without the .dvm extension. 00387 * \param[in] fnmFilesParam - a msParam of type STR_MS_T, which is an application microService mapping file name without the .fnm extension. 00388 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00389 * handled by the rule engine. The user does not include rei as a 00390 * parameter in the rule invocation. 00391 * 00392 * \DolVarDependence none 00393 * \DolVarModified none 00394 * \iCatAttrDependence none 00395 * \iCatAttrModified none 00396 * \sideeffect The rule engine's application ruleset and mappings get modified. 00397 * 00398 * \return integer 00399 * \retval 0 on success 00400 * \pre none 00401 * \post none 00402 * \sa msiAdmClearAppRuleStruct, msiAdmShowIRB, msiAdmShowDVM, msiAdmShowFNM 00403 **/ 00404 00405 /** 00406 * \fn msiAdmReadRulesFromFileIntoStruct(msParam_t *inIrbFileNameParam, msParam_t *outCoreRuleStruct, ruleExecInfo_t *rei) 00407 * 00408 * \brief This is a microservice that reads the given file in the configuration directory 00409 * 'server/config/reConfigs' or any file in the server local file system and 00410 * reads them into a rule structure. 00411 * 00412 * \module core 00413 * 00414 * \since 2.5 00415 * 00416 * \author Arcot Rajasekar 00417 * \date 2010 00418 * 00419 * \note This microservice requires iRODS administration privileges. 00420 * 00421 * \note Adds the given rules from an irb-file to a given rule structure. 00422 * 00423 * \usage See clients/icommands/test/rules3.0/ 00424 * 00425 * \param[in] inIrbFileNameParam - a msParam of type STR_MS_T, a Rules file in irb format, 00426 * either in 'server/config/reConfigs/' and without the .irb extension, 00427 * or a full file path in another directory on the server. 00428 * \param[out] outCoreRuleStruct - a msParam of type RuleStruct_MS_T (can be NULL in which case it is allocated) 00429 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00430 * handled by the rule engine. The user does not include rei as a 00431 * parameter in the rule invocation. 00432 * 00433 * \DolVarDependence none 00434 * \DolVarModified none 00435 * \iCatAttrDependence none 00436 * \iCatAttrModified none 00437 * \sideeffect none 00438 * 00439 * \return integer 00440 * \retval 0 on success 00441 * \pre none 00442 * \post none 00443 * \sa msiAdmInsertRulesFromStructIntoDB, msiGetRulesFromDBIntoStruct, msiAdmWriteRulesFromStructIntoFile 00444 **/ 00445 00446 /** 00447 * \fn msiAdmInsertRulesFromStructIntoDB(msParam_t *inIrbBaseNameParam, msParam_t *inCoreRuleStruct, ruleExecInfo_t *rei) 00448 * 00449 * \brief This is a microservice that reads the contents of a rule structure and writes them as 00450 * a new rule base set by populating the core rule tables of the iCAT. 00451 * It also maintains versioning of the rule base in the iCAT by giving an older version number to the existing base set of rules. 00452 * 00453 * \module core 00454 * 00455 * \since 2.5 00456 * 00457 * \author Arcot Rajasekar 00458 * \date 2010 00459 * 00460 * \note This microservice requires iRODS administration privileges. 00461 * 00462 * \note Adds rules to the iCAT rule base. 00463 * 00464 * \usage See clients/icommands/test/rules3.0/ 00465 * 00466 * \param[in] inIrbBaseNameParam - a msParam of type STR_MS_T, which is name of the base that is being added. 00467 * \param[in] inCoreRuleStruct - a msParam of type RuleStruct_MS_T containing the rules. 00468 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00469 * handled by the rule engine. The user does not include rei as a 00470 * parameter in the rule invocation. 00471 * 00472 * \DolVarDependence none 00473 * \DolVarModified none 00474 * \iCatAttrDependence none 00475 * \iCatAttrModified icat rule-tables get modified 00476 * \sideeffect none 00477 * 00478 * \return integer 00479 * \retval 0 on success 00480 * \pre none 00481 * \post none 00482 * \sa msiAdmReadRulesFromFileIntoStruct, msiGetRulesFromDBIntoStruct, msiAdmWriteRulesFromStructIntoFile 00483 **/ 00484 00485 00486 00487 /** 00488 * \fn msiGetRulesFromDBIntoStruct(msParam_t *inIrbBaseNameParam, msParam_t *inVersionParam, 00489 * msParam_t *outCoreRuleStruct, ruleExecInfo_t *rei) 00490 * 00491 * \brief This is a microservice that queries the iCAT for rules with a given base name and 00492 * version number and populates a rule structure with those rules. 00493 * 00494 * \module core 00495 * 00496 * \since 2.5 00497 * 00498 * \author Arcot Rajasekar 00499 * \date 2010 00500 * 00501 * \note This microservice requires iRODS administration privileges. 00502 * 00503 * \note Queries rules from the iCAT rule base. 00504 * 00505 * \usage See clients/icommands/test/rules3.0/ 00506 * 00507 * \param[in] inIrbBaseNameParam - a msParam of type STR_MS_T, which is the name of the base that is being queried. 00508 * \param[in] inVersionParam - a msParam of type STR_MS_T, which is the version string of the base being queried (use 0 for current version) 00509 * \param[out] outCoreRuleStruct - a msParam of type RuleStruct_MS_T (can be NULL in which case it is allocated) 00510 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00511 * handled by the rule engine. The user does not include rei as a 00512 * parameter in the rule invocation. 00513 * 00514 * \DolVarDependence none 00515 * \DolVarModified none 00516 * \iCatAttrDependence none 00517 * \iCatAttrModified none 00518 * \sideeffect none 00519 * 00520 * \return integer 00521 * \retval 0 on success 00522 * \pre none 00523 * \post none 00524 * \sa msiAdmReadRulesFromFileIntoStruct, msiAdmInsertRulesFromStructIntoDB, msiAdmWriteRulesFromStructIntoFile 00525 **/ 00526 00527 00528 /** 00529 * \fn msiAdmWriteRulesFromStructIntoFile(msParam_t *inIrbFileNameParam, msParam_t *inCoreRuleStruct, ruleExecInfo_t *rei) 00530 * 00531 * \brief This is a microservice that writes into a given file the contents of a given rule structure. 00532 * The file can be in 'server/config/reConfigs/' or any path on the server local file system. 00533 * 00534 * \module core 00535 * 00536 * \since 2.5 00537 * 00538 * \author Arcot Rajasekar 00539 * \date 2010 00540 * 00541 * \note This microservice requires iRODS administration privileges. 00542 * 00543 * \note Writes a file (in irb format) with rules from a rule structure. 00544 * 00545 * \usage See clients/icommands/test/rules3.0/ 00546 * 00547 * \param[in] inIrbFileNameParam - a msParam of type STR_MS_T, which is either a base-name in which case the file will 00548 * be written into the 'server/config/reConfigs/' directory with an .irb extension, 00549 * or a full file path in another directory on the server. 00550 * \param[in] inCoreRuleStruct - a msParam of type RuleStruct_MS_T 00551 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00552 * handled by the rule engine. The user does not include rei as a 00553 * parameter in the rule invocation. 00554 * 00555 * \DolVarDependence none 00556 * \DolVarModified none 00557 * \iCatAttrDependence none 00558 * \iCatAttrModified none 00559 * \sideeffect A new rule file is created 00560 * 00561 * \return integer 00562 * \retval 0 on success 00563 * \pre none 00564 * \post none 00565 * \sa msiAdmReadRulesFromFileIntoStruct, msiAdmInsertRulesFromStructIntoDB, msiGetRulesFromDBIntoStruct 00566 **/ 00567 00568 00569 /** 00570 * \fn msiAdmReadDVMapsFromFileIntoStruct(msParam_t *inDvmFileNameParam, msParam_t *outCoreDVMapStruct, ruleExecInfo_t *rei) 00571 * 00572 * \brief Reads a DVM configuration file into a DVM structure 00573 * 00574 * \module core 00575 * 00576 * \since after 2.5 00577 * 00578 * \author Arcot Rajasekar 00579 * \date 2011 00580 * 00581 * \note This microservice requires iRODS administration privileges. 00582 * 00583 * \note Reads the given file in the configuration directory 00584 * 'server/config/reConfigs' or any file in the server local file system and 00585 * puts them into a DVM structure. 00586 * 00587 * \usage See clients/icommands/test/rules3.0/ 00588 * 00589 * \param[in] inDvmFileNameParam - a msParam of type STR_MS_T 00590 * \param[in] outCoreDVMapStruct - a msParam of type RuleStruct_MS_T 00591 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00592 * handled by the rule engine. The user does not include rei as a 00593 * parameter in the rule invocation. 00594 * 00595 * \DolVarDependence none 00596 * \DolVarModified none 00597 * \iCatAttrDependence none 00598 * \iCatAttrModified none 00599 * \sideeffect none 00600 * 00601 * \return integer 00602 * \retval 0 on success 00603 * \pre none 00604 * \post none 00605 * \sa msiAdmInsertDVMapsFromStructIntoDB, msiGetDVMapsFromDBIntoStruct, msiAdmWriteDVMapsFromStructIntoFile 00606 **/ 00607 int msiAdmReadDVMapsFromFileIntoStruct(msParam_t *inDvmFileNameParam, msParam_t *outCoreDVMapStruct, ruleExecInfo_t *rei) 00608 { 00609 00610 int i; 00611 dvmStruct_t *coreDVMapStrct; 00612 00613 if ((i = isUserPrivileged(rei->rsComm)) != 0) 00614 return (i); 00615 00616 RE_TEST_MACRO ("Loopback on msiAdmReadDVMapsFromFileIntoStruct"); 00617 00618 00619 if (inDvmFileNameParam == NULL || 00620 strcmp (inDvmFileNameParam->type,STR_MS_T) != 0 || 00621 inDvmFileNameParam->inOutStruct == NULL || 00622 strlen((char *) inDvmFileNameParam->inOutStruct) == 0 ) 00623 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 00624 if (outCoreDVMapStruct->type != NULL && 00625 strcmp (outCoreDVMapStruct->type,DVMapStruct_MS_T) == 0 && 00626 outCoreDVMapStruct->inOutStruct != NULL) { 00627 coreDVMapStrct = (dvmStruct_t *) outCoreDVMapStruct->inOutStruct; 00628 } 00629 else { 00630 coreDVMapStrct = (dvmStruct_t *) malloc (sizeof(dvmStruct_t)); 00631 coreDVMapStrct->MaxNumOfDVars = 0; 00632 } 00633 i = readDVarStructFromFile((char*) inDvmFileNameParam->inOutStruct, coreDVMapStrct); 00634 if (i != 0) { 00635 if (strcmp (outCoreDVMapStruct->type,DVMapStruct_MS_T) != 0 ) 00636 free(coreDVMapStrct); 00637 return(i); 00638 } 00639 00640 outCoreDVMapStruct->inOutStruct = (void *) coreDVMapStrct; 00641 if (outCoreDVMapStruct->type == NULL || 00642 strcmp (outCoreDVMapStruct->type,DVMapStruct_MS_T) != 0) 00643 outCoreDVMapStruct->type = (char *) strdup(DVMapStruct_MS_T); 00644 return(0); 00645 } 00646 00647 /** 00648 * \fn msiAdmInsertDVMapsFromStructIntoDB(msParam_t *inDvmBaseNameParam, msParam_t *inCoreDVMapStruct, ruleExecInfo_t *rei) 00649 * 00650 * \brief Writes a DVM structure into the current DVM base 00651 * 00652 * \module core 00653 * 00654 * \since after 2.5 00655 * 00656 * \author Arcot Rajasekar 00657 * \date 2011 00658 * 00659 * \note This microservice requires iRODS administration privileges. 00660 * 00661 * \note This is a microservice that reads the contents of a DVM structure and writes them as 00662 * a new DVM base set in the iCAT. 00663 * 00664 * \usage See clients/icommands/test/rules3.0/ 00665 * 00666 * \param[in] inDvmBaseNameParam - a msParam of type STR_MS_T, the name of the target database 00667 * \param[in] inCoreDVMapStruct - a msParam of type RuleStruct_MS_T 00668 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00669 * handled by the rule engine. The user does not include rei as a 00670 * parameter in the rule invocation. 00671 * 00672 * \DolVarDependence none 00673 * \DolVarModified none 00674 * \iCatAttrDependence none 00675 * \iCatAttrModified iCAT tables are modified 00676 * \sideeffect none 00677 * 00678 * \return integer 00679 * \retval 0 on success 00680 * \pre none 00681 * \post none 00682 * \sa msiAdmReadDVMapsFromFileIntoStruct, msiGetDVMapsFromDBIntoStruct, msiAdmWriteDVMapsFromStructIntoFile 00683 **/ 00684 int msiAdmInsertDVMapsFromStructIntoDB(msParam_t *inDvmBaseNameParam, msParam_t *inCoreDVMapStruct, ruleExecInfo_t *rei) 00685 { 00686 00687 dvmStruct_t *coreDVMapStruct; 00688 int i; 00689 00690 if ((i = isUserPrivileged(rei->rsComm)) != 0) 00691 return (i); 00692 00693 RE_TEST_MACRO ("Loopback on msiAdmInsertDVMapsFromStructIntoDB"); 00694 00695 if (inDvmBaseNameParam == NULL || inCoreDVMapStruct == NULL || 00696 strcmp (inDvmBaseNameParam->type,STR_MS_T) != 0 || 00697 strcmp (inCoreDVMapStruct->type,DVMapStruct_MS_T) != 0 || 00698 inDvmBaseNameParam->inOutStruct == NULL || 00699 inCoreDVMapStruct->inOutStruct == NULL || 00700 strlen((char *) inDvmBaseNameParam->inOutStruct) == 0 ) 00701 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 00702 00703 coreDVMapStruct = (dvmStruct_t *) inCoreDVMapStruct->inOutStruct; 00704 i = insertDVMapsIntoDB((char *) inDvmBaseNameParam->inOutStruct, coreDVMapStruct, rei); 00705 return(i); 00706 00707 } 00708 00709 00710 /** 00711 * \fn msiGetDVMapsFromDBIntoStruct(msParam_t *inDvmBaseNameParam, msParam_t *inVersionParam, msParam_t *outCoreDVMapStruct, ruleExecInfo_t *rei) 00712 * 00713 * \brief Populates a DVM structure with DVMs from the given base name 00714 * 00715 * \module core 00716 * 00717 * \since after 2.5 00718 * 00719 * \author Arcot Rajasekar 00720 * \date 2011 00721 * 00722 * \note This microservice requires iRODS administration privileges. 00723 * 00724 * \note This is a microservice that queries the iCAT for DVM with a given base name and version number and populates a DVM rule structure. 00725 * 00726 * \usage See clients/icommands/test/rules3.0/ 00727 * 00728 * \param[in] inDvmBaseNameParam - a msParam of type STR_MS_T, the name of the base being queried 00729 * \param[in] inVersionParam - a msParam of type STR_MS_T, which is the version string of the base being queried (use 0 for current version) 00730 * \param[in] outCoreDVMapStruct - a msParam of type RuleStruct_MS_T 00731 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00732 * handled by the rule engine. The user does not include rei as a 00733 * parameter in the rule invocation. 00734 * 00735 * \DolVarDependence none 00736 * \DolVarModified none 00737 * \iCatAttrDependence none 00738 * \iCatAttrModified none 00739 * \sideeffect none 00740 * 00741 * \return integer 00742 * \retval 0 on success 00743 * \pre none 00744 * \post none 00745 * \sa msiAdmReadDVMapsFromFileIntoStruct, msiAdmInsertDVMapsFromStructIntoDB, msiAdmWriteDVMapsFromStructIntoFile 00746 **/ 00747 int 00748 msiGetDVMapsFromDBIntoStruct(msParam_t *inDvmBaseNameParam, msParam_t *inVersionParam, msParam_t *outCoreDVMapStruct, ruleExecInfo_t *rei) 00749 { 00750 00751 int i; 00752 dvmStruct_t *coreDVMapStrct; 00753 00754 RE_TEST_MACRO ("Loopback on msiGetDVMapsFromDBIntoStruct"); 00755 00756 if (inDvmBaseNameParam == NULL || 00757 strcmp (inDvmBaseNameParam->type,STR_MS_T) != 0 || 00758 inDvmBaseNameParam->inOutStruct == NULL || 00759 strlen((char *) inDvmBaseNameParam->inOutStruct) == 0 ) 00760 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 00761 if (inVersionParam == NULL || 00762 strcmp (inVersionParam->type,STR_MS_T) != 0 || 00763 inVersionParam->inOutStruct == NULL || 00764 strlen((char *) inVersionParam->inOutStruct) == 0 ) 00765 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 00766 if (outCoreDVMapStruct->type != NULL && 00767 strcmp (outCoreDVMapStruct->type,DVMapStruct_MS_T) == 0 && 00768 outCoreDVMapStruct->inOutStruct != NULL) { 00769 coreDVMapStrct = (dvmStruct_t *) outCoreDVMapStruct->inOutStruct; 00770 } 00771 else { 00772 coreDVMapStrct = (dvmStruct_t *) malloc (sizeof(dvmStruct_t)); 00773 coreDVMapStrct->MaxNumOfDVars = 0; 00774 } 00775 i = readDVMapStructFromDB((char*) inDvmBaseNameParam->inOutStruct, (char*) inVersionParam->inOutStruct, coreDVMapStrct, rei); 00776 if (i != 0) { 00777 if (strcmp (outCoreDVMapStruct->type,DVMapStruct_MS_T) != 0 ) 00778 free(coreDVMapStrct); 00779 return(i); 00780 } 00781 00782 outCoreDVMapStruct->inOutStruct = (void *) coreDVMapStrct; 00783 if (outCoreDVMapStruct->type == NULL || 00784 strcmp (outCoreDVMapStruct->type,DVMapStruct_MS_T) != 0) 00785 outCoreDVMapStruct->type = (char *) strdup(DVMapStruct_MS_T); 00786 return(0); 00787 } 00788 00789 /** 00790 * \fn msiAdmWriteDVMapsFromStructIntoFile(msParam_t *inDvmFileNameParam, msParam_t *inCoreDVMapStruct, ruleExecInfo_t *rei) 00791 * 00792 * \brief Writes to file the DVMs within a given DVM structure 00793 * 00794 * \module core 00795 * 00796 * \since after 2.5 00797 * 00798 * \author Arcot Rajasekar 00799 * \date 2011 00800 * 00801 * \note This microservice requires iRODS administration privileges. 00802 * 00803 * \note This is a microservice that writes into a given file the contents of a given DVM structure. 00804 * The file can be in 'server/config/reConfigs/' or any path on the server local file system. 00805 * 00806 * \usage See clients/icommands/test/rules3.0/ 00807 * 00808 * \param[in] inDvmFileNameParam - a msParam of type STR_MS_T, the name of the file to be written 00809 * \param[in] inCoreDVMapStruct - a msParam of type RuleStruct_MS_T 00810 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00811 * handled by the rule engine. The user does not include rei as a 00812 * parameter in the rule invocation. 00813 * 00814 * \DolVarDependence none 00815 * \DolVarModified none 00816 * \iCatAttrDependence none 00817 * \iCatAttrModified none 00818 * \sideeffect A new DVM file is created 00819 * 00820 * \return integer 00821 * \retval 0 on success 00822 * \pre none 00823 * \post none 00824 * \sa msiAdmReadDVMapsFromFileIntoStruct, msiAdmInsertDVMapsFromStructIntoDB, msiGetDVMapsFromDBIntoStruct 00825 **/ 00826 int 00827 msiAdmWriteDVMapsFromStructIntoFile(msParam_t *inDvmFileNameParam, msParam_t *inCoreDVMapStruct, ruleExecInfo_t *rei) 00828 { 00829 int i; 00830 dvmStruct_t *myDVMapStruct; 00831 00832 if ((i = isUserPrivileged(rei->rsComm)) != 0) 00833 return (i); 00834 00835 RE_TEST_MACRO ("Loopback on msiAdmWriteDVMapsFromStructIntoFile"); 00836 00837 if (inDvmFileNameParam == NULL || inCoreDVMapStruct == NULL || 00838 strcmp (inDvmFileNameParam->type,STR_MS_T) != 0 || 00839 strcmp (inCoreDVMapStruct->type,DVMapStruct_MS_T) != 0 || 00840 inDvmFileNameParam->inOutStruct == NULL || 00841 strlen((char *) inDvmFileNameParam->inOutStruct) == 0 ) 00842 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 00843 00844 myDVMapStruct = (dvmStruct_t *) inCoreDVMapStruct->inOutStruct; 00845 i = writeDVMapsIntoFile((char *) inDvmFileNameParam->inOutStruct, myDVMapStruct, rei); 00846 return(i); 00847 00848 } 00849 00850 00851 /** 00852 * \fn msiAdmReadFNMapsFromFileIntoStruct(msParam_t *inFnmFileNameParam, msParam_t *outCoreFNMapStruct, ruleExecInfo_t *rei) 00853 * 00854 * \brief Reads a FNM configuration file into a FNM structure 00855 * 00856 * \module core 00857 * 00858 * \since after 2.5 00859 * 00860 * \author Arcot Rajasekar 00861 * \date 2011 00862 * 00863 * \note This microservice requires iRODS administration privileges. 00864 * 00865 * \note Reads the given file in the configuration directory 00866 * 'server/config/reConfigs' or any file in the server local file system and 00867 * puts them into a FNM structure. 00868 * 00869 * \usage See clients/icommands/test/rules3.0/ 00870 * 00871 * \param[in] inFnmFileNameParam - a msParam of type STR_MS_T 00872 * \param[in] outCoreFNMapStruct - a msParam of type RuleStruct_MS_T 00873 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00874 * handled by the rule engine. The user does not include rei as a 00875 * parameter in the rule invocation. 00876 * 00877 * \DolVarDependence none 00878 * \DolVarModified none 00879 * \iCatAttrDependence none 00880 * \iCatAttrModified none 00881 * \sideeffect none 00882 * 00883 * \return integer 00884 * \retval 0 on success 00885 * \pre none 00886 * \post none 00887 * \sa msiAdmInsertFNMapsFromStructIntoDB, msiGetFNMapsFromDBIntoStruct, msiAdmWriteFNMapsFromStructIntoFile 00888 **/ 00889 int msiAdmReadFNMapsFromFileIntoStruct(msParam_t *inFnmFileNameParam, msParam_t *outCoreFNMapStruct, ruleExecInfo_t *rei) 00890 { 00891 00892 int i; 00893 fnmapStruct_t *coreFNMapStrct; 00894 00895 if ((i = isUserPrivileged(rei->rsComm)) != 0) 00896 return (i); 00897 00898 RE_TEST_MACRO ("Loopback on msiAdmReadFNMapsFromFileIntoStruct"); 00899 00900 00901 if (inFnmFileNameParam == NULL || 00902 strcmp (inFnmFileNameParam->type,STR_MS_T) != 0 || 00903 inFnmFileNameParam->inOutStruct == NULL || 00904 strlen((char *) inFnmFileNameParam->inOutStruct) == 0 ) 00905 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 00906 if (outCoreFNMapStruct->type != NULL && 00907 strcmp (outCoreFNMapStruct->type,FNMapStruct_MS_T) == 0 && 00908 outCoreFNMapStruct->inOutStruct != NULL) { 00909 coreFNMapStrct = (fnmapStruct_t *) outCoreFNMapStruct->inOutStruct; 00910 } 00911 else { 00912 coreFNMapStrct = (fnmapStruct_t *) malloc (sizeof(fnmapStruct_t)); 00913 coreFNMapStrct->MaxNumOfFMaps = 0; 00914 } 00915 i = readFuncMapStructFromFile((char*) inFnmFileNameParam->inOutStruct, coreFNMapStrct); 00916 if (i != 0) { 00917 if (strcmp (outCoreFNMapStruct->type,FNMapStruct_MS_T) != 0 ) 00918 free(coreFNMapStrct); 00919 return(i); 00920 } 00921 00922 outCoreFNMapStruct->inOutStruct = (void *) coreFNMapStrct; 00923 if (outCoreFNMapStruct->type == NULL || 00924 strcmp (outCoreFNMapStruct->type,FNMapStruct_MS_T) != 0) 00925 outCoreFNMapStruct->type = (char *) strdup(FNMapStruct_MS_T); 00926 return(0); 00927 } 00928 00929 00930 /** 00931 * \fn msiAdmInsertFNMapsFromStructIntoDB(msParam_t *inFnmBaseNameParam, msParam_t *inCoreFNMapStruct, ruleExecInfo_t *rei) 00932 * 00933 * \brief Writes a FNM structure into the current FNM base 00934 * 00935 * \module core 00936 * 00937 * \since after 2.5 00938 * 00939 * \author Arcot Rajasekar 00940 * \date 2011 00941 * 00942 * \note This microservice requires iRODS administration privileges. 00943 * 00944 * \note This is a microservice that reads the contents of a FNM structure and writes them as 00945 * a new FNM base set in the iCAT. 00946 * 00947 * \usage See clients/icommands/test/rules3.0/ 00948 * 00949 * \param[in] inFnmBaseNameParam - a msParam of type STR_MS_T, the name of the target database 00950 * \param[in] inCoreFNMapStruct - a msParam of type RuleStruct_MS_T 00951 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00952 * handled by the rule engine. The user does not include rei as a 00953 * parameter in the rule invocation. 00954 * 00955 * \DolVarDependence none 00956 * \DolVarModified none 00957 * \iCatAttrDependence none 00958 * \iCatAttrModified iCAT tables are modified 00959 * \sideeffect none 00960 * 00961 * \return integer 00962 * \retval 0 on success 00963 * \pre none 00964 * \post none 00965 * \sa msiAdmReadFNMapsFromFileIntoStruct, msiGetFNMapsFromDBIntoStruct, msiAdmWriteFNMapsFromStructIntoFile 00966 **/ 00967 int msiAdmInsertFNMapsFromStructIntoDB(msParam_t *inFnmBaseNameParam, msParam_t *inCoreFNMapStruct, ruleExecInfo_t *rei) 00968 { 00969 00970 fnmapStruct_t *coreFNMapStruct; 00971 int i; 00972 00973 if ((i = isUserPrivileged(rei->rsComm)) != 0) 00974 return (i); 00975 00976 RE_TEST_MACRO ("Loopback on msiAdmInsertFNMapsFromStructIntoDB"); 00977 00978 if (inFnmBaseNameParam == NULL || inCoreFNMapStruct == NULL || 00979 strcmp (inFnmBaseNameParam->type,STR_MS_T) != 0 || 00980 strcmp (inCoreFNMapStruct->type,FNMapStruct_MS_T) != 0 || 00981 inFnmBaseNameParam->inOutStruct == NULL || 00982 inCoreFNMapStruct->inOutStruct == NULL || 00983 strlen((char *) inFnmBaseNameParam->inOutStruct) == 0 ) 00984 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 00985 00986 coreFNMapStruct = (fnmapStruct_t *) inCoreFNMapStruct->inOutStruct; 00987 i = insertFNMapsIntoDB((char *) inFnmBaseNameParam->inOutStruct, coreFNMapStruct, rei); 00988 return(i); 00989 00990 } 00991 00992 00993 /** 00994 * \fn msiGetFNMapsFromDBIntoStruct(msParam_t *inFnmBaseNameParam, msParam_t *inVersionParam, msParam_t *outCoreFNMapStruct, ruleExecInfo_t *rei) 00995 * 00996 * \brief Populates a FNM structure with FNMs from the given base name 00997 * 00998 * \module core 00999 * 01000 * \since after 2.5 01001 * 01002 * \author Arcot Rajasekar 01003 * \date 2011 01004 * 01005 * \note This microservice requires iRODS administration privileges. 01006 * 01007 * \note This is a microservice that queries the iCAT for FNM with a given base name and version number and populates a FNM rule structure. 01008 * 01009 * \usage See clients/icommands/test/rules3.0/ 01010 * 01011 * \param[in] inFnmBaseNameParam - a msParam of type STR_MS_T, the name of the base being queried 01012 * \param[in] inVersionParam - a msParam of type STR_MS_T, which is the version string of the base being queried (use 0 for current version) 01013 * \param[in] outCoreFNMapStruct - a msParam of type RuleStruct_MS_T 01014 * \param[in,out] rei - The RuleExecInfo structure that is automatically 01015 * handled by the rule engine. The user does not include rei as a 01016 * parameter in the rule invocation. 01017 * 01018 * \DolVarDependence none 01019 * \DolVarModified none 01020 * \iCatAttrDependence none 01021 * \iCatAttrModified none 01022 * \sideeffect none 01023 * 01024 * \return integer 01025 * \retval 0 on success 01026 * \pre none 01027 * \post none 01028 * \sa msiAdmReadFNMapsFromFileIntoStruct, msiAdmInsertFNMapsFromStructIntoDB, msiAdmWriteFNMapsFromStructIntoFile 01029 **/ 01030 int 01031 msiGetFNMapsFromDBIntoStruct(msParam_t *inFnmBaseNameParam, msParam_t *inVersionParam, msParam_t *outCoreFNMapStruct, ruleExecInfo_t *rei) 01032 { 01033 01034 int i; 01035 fnmapStruct_t *coreFNMapStrct; 01036 01037 RE_TEST_MACRO ("Loopback on msiGetFNMapsFromDBIntoStruct"); 01038 01039 if (inFnmBaseNameParam == NULL || 01040 strcmp (inFnmBaseNameParam->type,STR_MS_T) != 0 || 01041 inFnmBaseNameParam->inOutStruct == NULL || 01042 strlen((char *) inFnmBaseNameParam->inOutStruct) == 0 ) 01043 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 01044 if (inVersionParam == NULL || 01045 strcmp (inVersionParam->type,STR_MS_T) != 0 || 01046 inVersionParam->inOutStruct == NULL || 01047 strlen((char *) inVersionParam->inOutStruct) == 0 ) 01048 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 01049 if (outCoreFNMapStruct->type != NULL && 01050 strcmp (outCoreFNMapStruct->type,FNMapStruct_MS_T) == 0 && 01051 outCoreFNMapStruct->inOutStruct != NULL) { 01052 coreFNMapStrct = (fnmapStruct_t *) outCoreFNMapStruct->inOutStruct; 01053 } 01054 else { 01055 coreFNMapStrct = (fnmapStruct_t *) malloc (sizeof(fnmapStruct_t)); 01056 coreFNMapStrct->MaxNumOfFMaps = 0; 01057 } 01058 i = readFNMapStructFromDB((char*) inFnmBaseNameParam->inOutStruct, (char*) inVersionParam->inOutStruct, coreFNMapStrct, rei); 01059 if (i != 0) { 01060 if (strcmp (outCoreFNMapStruct->type,FNMapStruct_MS_T) != 0 ) 01061 free(coreFNMapStrct); 01062 return(i); 01063 } 01064 01065 outCoreFNMapStruct->inOutStruct = (void *) coreFNMapStrct; 01066 if (outCoreFNMapStruct->type == NULL || 01067 strcmp (outCoreFNMapStruct->type,FNMapStruct_MS_T) != 0) 01068 outCoreFNMapStruct->type = (char *) strdup(FNMapStruct_MS_T); 01069 return(0); 01070 } 01071 01072 01073 /** 01074 * \fn msiAdmWriteFNMapsFromStructIntoFile(msParam_t *inFnmFileNameParam, msParam_t *inCoreFNMapStruct, ruleExecInfo_t *rei) 01075 * 01076 * \brief Writes to file the FNMs within a given FNM structure 01077 * 01078 * \module core 01079 * 01080 * \since after 2.5 01081 * 01082 * \author Arcot Rajasekar 01083 * \date 2011 01084 * 01085 * \note This microservice requires iRODS administration privileges. 01086 * 01087 * \note This is a microservice that writes into a given file the contents of a given FNM structure. 01088 * The file can be in 'server/config/reConfigs/' or any path on the server local file system. 01089 * 01090 * \usage See clients/icommands/test/rules3.0/ 01091 * 01092 * \param[in] inFnmFileNameParam - a msParam of type STR_MS_T, the name of the file to be written 01093 * \param[in] inCoreFNMapStruct - a msParam of type RuleStruct_MS_T 01094 * \param[in,out] rei - The RuleExecInfo structure that is automatically 01095 * handled by the rule engine. The user does not include rei as a 01096 * parameter in the rule invocation. 01097 * 01098 * \DolVarDependence none 01099 * \DolVarModified none 01100 * \iCatAttrDependence none 01101 * \iCatAttrModified none 01102 * \sideeffect A new FNM file is created 01103 * 01104 * \return integer 01105 * \retval 0 on success 01106 * \pre none 01107 * \post none 01108 * \sa msiAdmReadFNMapsFromFileIntoStruct, msiAdmInsertFNMapsFromStructIntoDB, msiGetFNMapsFromDBIntoStruct 01109 **/ 01110 int 01111 msiAdmWriteFNMapsFromStructIntoFile(msParam_t *inFnmFileNameParam, msParam_t *inCoreFNMapStruct, ruleExecInfo_t *rei) 01112 { 01113 int i; 01114 fnmapStruct_t *myFNMapStruct; 01115 01116 if ((i = isUserPrivileged(rei->rsComm)) != 0) 01117 return (i); 01118 01119 RE_TEST_MACRO ("Loopback on msiAdmWriteFNMapsFromStructIntoFile"); 01120 01121 if (inFnmFileNameParam == NULL || inCoreFNMapStruct == NULL || 01122 strcmp (inFnmFileNameParam->type,STR_MS_T) != 0 || 01123 strcmp (inCoreFNMapStruct->type,FNMapStruct_MS_T) != 0 || 01124 inFnmFileNameParam->inOutStruct == NULL || 01125 strlen((char *) inFnmFileNameParam->inOutStruct) == 0 ) 01126 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 01127 01128 myFNMapStruct = (fnmapStruct_t *) inCoreFNMapStruct->inOutStruct; 01129 i = writeFNMapsIntoFile((char *) inFnmFileNameParam->inOutStruct, myFNMapStruct, rei); 01130 return(i); 01131 01132 } 01133 01134 01135 /** 01136 * \fn msiAdmReadMSrvcsFromFileIntoStruct(msParam_t *inMsrvcFileNameParam, msParam_t *outCoreMsrvcStruct, ruleExecInfo_t *rei) 01137 * 01138 * \brief Reads a microservice configuration file into a microservice structure 01139 * 01140 * \module core 01141 * 01142 * \since after 2.5 01143 * 01144 * \author Arcot Rajasekar 01145 * \date 2011 01146 * 01147 * \note This microservice requires iRODS administration privileges. 01148 * 01149 * \note Reads the given file in the configuration directory 01150 * 'server/config/reConfigs' or any file in the server local file system and 01151 * puts them into a microservice structure. 01152 * 01153 * \usage See clients/icommands/test/rules3.0/ 01154 * 01155 * \param[in] inMsrvcFileNameParam - a msParam of type STR_MS_T 01156 * \param[in] outCoreMsrvcStruct - a msParam of type RuleStruct_MS_T 01157 * \param[in,out] rei - The RuleExecInfo structure that is automatically 01158 * handled by the rule engine. The user does not include rei as a 01159 * parameter in the rule invocation. 01160 * 01161 * \DolVarDependence none 01162 * \DolVarModified none 01163 * \iCatAttrDependence none 01164 * \iCatAttrModified none 01165 * \sideeffect none 01166 * 01167 * \return integer 01168 * \retval 0 on success 01169 * \pre none 01170 * \post none 01171 * \sa msiAdmInsertMSrvcsFromStructIntoDB, msiGetMSrvcsFromDBIntoStruct, msiAdmWriteMSrvcsFromStructIntoFile 01172 **/ 01173 int msiAdmReadMSrvcsFromFileIntoStruct(msParam_t *inMsrvcFileNameParam, msParam_t *outCoreMsrvcStruct, ruleExecInfo_t *rei) 01174 { 01175 01176 int i; 01177 msrvcStruct_t *coreMsrvcStrct; 01178 01179 if ((i = isUserPrivileged(rei->rsComm)) != 0) 01180 return (i); 01181 01182 RE_TEST_MACRO ("Loopback on msiAdmReadMSrvcsFromFileIntoStruct"); 01183 01184 01185 if (inMsrvcFileNameParam == NULL || 01186 strcmp (inMsrvcFileNameParam->type,STR_MS_T) != 0 || 01187 inMsrvcFileNameParam->inOutStruct == NULL || 01188 strlen((char *) inMsrvcFileNameParam->inOutStruct) == 0 ) 01189 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 01190 if (outCoreMsrvcStruct->type != NULL && 01191 strcmp (outCoreMsrvcStruct->type,MsrvcStruct_MS_T) == 0 && 01192 outCoreMsrvcStruct->inOutStruct != NULL) { 01193 coreMsrvcStrct = (msrvcStruct_t *) outCoreMsrvcStruct->inOutStruct; 01194 } 01195 else { 01196 coreMsrvcStrct = (msrvcStruct_t *) malloc (sizeof(msrvcStruct_t)); 01197 coreMsrvcStrct->MaxNumOfMsrvcs = 0; 01198 } 01199 i = readMsrvcStructFromFile((char*) inMsrvcFileNameParam->inOutStruct, coreMsrvcStrct); 01200 if (i != 0) { 01201 if (strcmp (outCoreMsrvcStruct->type,MsrvcStruct_MS_T) != 0 ) 01202 free(coreMsrvcStrct); 01203 return(i); 01204 } 01205 01206 outCoreMsrvcStruct->inOutStruct = (void *) coreMsrvcStrct; 01207 if (outCoreMsrvcStruct->type == NULL || 01208 strcmp (outCoreMsrvcStruct->type,MsrvcStruct_MS_T) != 0) 01209 outCoreMsrvcStruct->type = (char *) strdup(MsrvcStruct_MS_T); 01210 return(0); 01211 } 01212 01213 01214 /** 01215 * \fn msiAdmInsertMSrvcsFromStructIntoDB(msParam_t *inMsrvcBaseNameParam, msParam_t *inCoreMsrvcStruct, ruleExecInfo_t *rei) 01216 * 01217 * \brief Writes a microservice structure into the current microservice base 01218 * 01219 * \module core 01220 * 01221 * \since after 2.5 01222 * 01223 * \author Arcot Rajasekar 01224 * \date 2011 01225 * 01226 * \note This microservice requires iRODS administration privileges. 01227 * 01228 * \note This is a microservice that reads the contents of a microservice structure and writes them as 01229 * a new microservice base set in the iCAT. 01230 * 01231 * \usage See clients/icommands/test/rules3.0/ 01232 * 01233 * \param[in] inMsrvcBaseNameParam - a msParam of type STR_MS_T, the name of the target database 01234 * \param[in] inCoreMsrvcStruct - a msParam of type RuleStruct_MS_T 01235 * \param[in,out] rei - The RuleExecInfo structure that is automatically 01236 * handled by the rule engine. The user does not include rei as a 01237 * parameter in the rule invocation. 01238 * 01239 * \DolVarDependence none 01240 * \DolVarModified none 01241 * \iCatAttrDependence none 01242 * \iCatAttrModified iCAT tables are modified 01243 * \sideeffect none 01244 * 01245 * \return integer 01246 * \retval 0 on success 01247 * \pre none 01248 * \post none 01249 * \sa msiAdmReadMSrvcsFromFileIntoStruct, msiGetMSrvcsFromDBIntoStruct, msiAdmWriteMSrvcsFromStructIntoFile 01250 **/ 01251 int msiAdmInsertMSrvcsFromStructIntoDB(msParam_t *inMsrvcBaseNameParam, msParam_t *inCoreMsrvcStruct, ruleExecInfo_t *rei) 01252 01253 { 01254 01255 msrvcStruct_t *coreMsrvcStruct; 01256 int i; 01257 01258 if ((i = isUserPrivileged(rei->rsComm)) != 0) 01259 return (i); 01260 01261 RE_TEST_MACRO ("Loopback on msiAdmInsertMSrvcsFromStructIntoDB"); 01262 01263 if ( inCoreMsrvcStruct == NULL || 01264 strcmp (inCoreMsrvcStruct->type,MsrvcStruct_MS_T) != 0 || 01265 inCoreMsrvcStruct->inOutStruct == NULL) 01266 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 01267 01268 coreMsrvcStruct = (msrvcStruct_t *) inCoreMsrvcStruct->inOutStruct; 01269 i = insertMSrvcsIntoDB( coreMsrvcStruct, rei); 01270 return(i); 01271 01272 } 01273 01274 01275 /** 01276 * \fn msiGetMSrvcsFromDBIntoStruct(msParam_t *inStatus, msParam_t *outCoreMsrvcStruct, ruleExecInfo_t *rei) 01277 * 01278 * \brief Populates a microservice structure with microservices from the given base name 01279 * 01280 * \module core 01281 * 01282 * \since after 2.5 01283 * 01284 * \author Arcot Rajasekar 01285 * \date 2011 01286 * 01287 * \note This microservice requires iRODS administration privileges. 01288 * 01289 * \note This is a microservice that queries the iCAT for microservices with a given base name and version number and populates a microservice rule structure. 01290 * 01291 * \usage See clients/icommands/test/rules3.0/ 01292 * 01293 * \param[in] inStatus - a msParam of type INT_MS_T or an integer stored in STR_MS_T, normally 1 if microservice is available, 0 otherwise. 01294 * \param[out] outCoreMsrvcStruct - a msParam of type MsrvcStruct_MS_T 01295 * \param[in,out] rei - The RuleExecInfo structure that is automatically 01296 * handled by the rule engine. The user does not include rei as a 01297 * parameter in the rule invocation. 01298 * 01299 * \DolVarDependence none 01300 * \DolVarModified none 01301 * \iCatAttrDependence none 01302 * \iCatAttrModified none 01303 * \sideeffect none 01304 * 01305 * \return integer 01306 * \retval 0 on success 01307 * \pre none 01308 * \post none 01309 * \sa msiAdmReadMSrvcsFromFileIntoStruct, msiAdmInsertMSrvcsFromStructIntoDB, msiAdmWriteMSrvcsFromStructIntoFile 01310 **/ 01311 int 01312 msiGetMSrvcsFromDBIntoStruct(msParam_t *inStatus, msParam_t *outCoreMsrvcStruct, ruleExecInfo_t *rei) 01313 { 01314 01315 int i, stat; 01316 msrvcStruct_t *coreMsrvcStrct; 01317 01318 RE_TEST_MACRO ("Loopback on msiGetMSrvcsFromDBIntoStruct"); 01319 01320 if (outCoreMsrvcStruct->type != NULL && 01321 strcmp (outCoreMsrvcStruct->type,MsrvcStruct_MS_T) == 0 && 01322 outCoreMsrvcStruct->inOutStruct != NULL) { 01323 coreMsrvcStrct = (msrvcStruct_t *) outCoreMsrvcStruct->inOutStruct; 01324 } 01325 else { 01326 coreMsrvcStrct = (msrvcStruct_t *) malloc (sizeof(msrvcStruct_t)); 01327 coreMsrvcStrct->MaxNumOfMsrvcs = 0; 01328 } 01329 if (inStatus != NULL && inStatus->type != NULL && inStatus->inOutStruct != NULL) { 01330 if (strcmp (inStatus->type, INT_MS_T) == 0) { 01331 stat = *(int *)inStatus->inOutStruct; 01332 } 01333 else if (strcmp (inStatus->type, STR_MS_T) == 0) { 01334 stat = atoi((char *) inStatus->inOutStruct); 01335 } 01336 else { 01337 free(coreMsrvcStrct); // cppcheck - Memory leak: coreMsrvcStrct 01338 return(USER_PARAM_TYPE_ERR); 01339 } 01340 } 01341 else { 01342 free(coreMsrvcStrct); // cppcheck - Memory leak: coreMsrvcStrct 01343 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 01344 } 01345 i = readMsrvcStructFromDB( stat, coreMsrvcStrct, rei); 01346 if (i != 0) { 01347 if (strcmp (outCoreMsrvcStruct->type,MsrvcStruct_MS_T) != 0 ) 01348 free(coreMsrvcStrct); 01349 return(i); 01350 } 01351 01352 outCoreMsrvcStruct->inOutStruct = (void *) coreMsrvcStrct; 01353 if (outCoreMsrvcStruct->type == NULL || 01354 strcmp (outCoreMsrvcStruct->type,MsrvcStruct_MS_T) != 0) 01355 outCoreMsrvcStruct->type = (char *) strdup(MsrvcStruct_MS_T); 01356 return(0); 01357 } 01358 01359 /** 01360 * \fn msiAdmWriteMSrvcsFromStructIntoFile(msParam_t *inMsrvcFileNameParam, msParam_t *inCoreMsrvcStruct, ruleExecInfo_t *rei) 01361 * 01362 * \brief Writes to file the microservices within a given microservice structure 01363 * 01364 * \module core 01365 * 01366 * \since after 2.5 01367 * 01368 * \author Arcot Rajasekar 01369 * \date 2011 01370 * 01371 * \note This microservice requires iRODS administration privileges. 01372 * 01373 * \note This is a microservice that writes into a given file the contents of a given microservice structure. 01374 * The file can be in 'server/config/reConfigs/' or any path on the server local file system. 01375 * 01376 * \usage See clients/icommands/test/rules3.0/ 01377 * 01378 * \param[in] inMsrvcFileNameParam - a msParam of type STR_MS_T, the name of the file to be written 01379 * \param[in] inCoreMsrvcStruct - a msParam of type MsrvcStruct_MS_T 01380 * \param[in,out] rei - The RuleExecInfo structure that is automatically 01381 * handled by the rule engine. The user does not include rei as a 01382 * parameter in the rule invocation. 01383 * 01384 * \DolVarDependence none 01385 * \DolVarModified none 01386 * \iCatAttrDependence none 01387 * \iCatAttrModified none 01388 * \sideeffect A new microservice file is created 01389 * 01390 * \return integer 01391 * \retval 0 on success 01392 * \pre none 01393 * \post none 01394 * \sa msiAdmReadMSrvcsFromFileIntoStruct, msiAdmInsertMSrvcsFromStructIntoDB, msiGetMSrvcsFromDBIntoStruct 01395 **/ 01396 int 01397 msiAdmWriteMSrvcsFromStructIntoFile(msParam_t *inMsrvcFileNameParam, msParam_t *inCoreMsrvcStruct, ruleExecInfo_t *rei) 01398 { 01399 int i; 01400 msrvcStruct_t *myMsrvcStruct; 01401 01402 if ((i = isUserPrivileged(rei->rsComm)) != 0) 01403 return (i); 01404 01405 RE_TEST_MACRO ("Loopback on msiAdmWriteMSrvcsFromStructIntoFile"); 01406 01407 if (inMsrvcFileNameParam == NULL || inCoreMsrvcStruct == NULL || 01408 strcmp (inMsrvcFileNameParam->type,STR_MS_T) != 0 || 01409 strcmp (inCoreMsrvcStruct->type,MsrvcStruct_MS_T) != 0 || 01410 inMsrvcFileNameParam->inOutStruct == NULL || 01411 strlen((char *) inMsrvcFileNameParam->inOutStruct) == 0 ) 01412 return(PARAOPR_EMPTY_IN_STRUCT_ERR); 01413 01414 myMsrvcStruct = (msrvcStruct_t *) inCoreMsrvcStruct->inOutStruct; 01415 i = writeMSrvcsIntoFile((char *) inMsrvcFileNameParam->inOutStruct, myMsrvcStruct, rei); 01416 return(i); 01417 01418 } 01419