void Writer::beginStruct(const StructSig *sig) { _writeByte(trace::TYPE_STRUCT); _writeUInt(sig->id); if (!lookup(structs, sig->id)) { _writeString(sig->name); _writeUInt(sig->num_members); for (unsigned i = 0; i < sig->num_members; ++i) { _writeString(sig->member_names[i]); } structs[sig->id] = true; } }
/** * \fn msiAdmShowFNM (msParam_t *bufParam, ruleExecInfo_t *rei) * * \brief This is a microservice that reads the function-name-mapping data structure * in the Rule Engine and pretty-prints that structure to the stdout buffer. * * \module core * * \since pre-2.1 * * \author Arcot Rajasekar * \date 2007-08 * * \note This microservice has a dummy parameter. * * \note This microservice lists the currently loaded microServices and action * name mappings from the rule engine memory. The list is written to stdout in ruleExecOut. * * \usage See clients/icommands/test/rules3.0/ * * \param[in] bufParam - is a msParam (not used for anything, a dummy parameter) * \param[in,out] rei - The RuleExecInfo structure that is automatically * handled by the rule engine. The user does not include rei as a * parameter in the rule invocation. * * \DolVarDependence none * \DolVarModified - rei->MsParamArray->MsParam->ruleExecOut->stdout is modified * \iCatAttrDependence none * \iCatAttrModified none * \sideeffect none * * \return integer * \retval 0 on success * \pre none * \post none * \sa msiAdmShowDVM **/ int msiAdmShowFNM( msParam_t*, ruleExecInfo_t *rei ) { int i; _writeString( "stdout", "----------------------------- FNM -----------------------------\n", rei ); i = _admShowFNM( rei, &appRuleFuncMapDef, 0 ); if ( i != 0 ) { return i; } i = _admShowFNM( rei, &coreRuleFuncMapDef, 1000 ); _writeString( "stdout", "----------------------------- FNM -----------------------------\n", rei ); return i; }
int _admShowDVM( ruleExecInfo_t *rei, rulevardef_t *inRuleVarDef, int inx ) { int j; char outStr[MAX_RULE_LENGTH]; _writeString( "stdout", "---------------------------------------------------------------\n", rei ); for ( j = 0 ; j < inRuleVarDef->MaxNumOfDVars ; j++ ) { sprintf( outStr, " %-5i %-15.15s %s ===> %s\n", j + inx, inRuleVarDef->action[j], inRuleVarDef->varName[j], inRuleVarDef->var2CMap[j] ); _writeString( "stdout", outStr, rei ); } _writeString( "stdout", "---------------------------------------------------------------\n", rei ); return 0; }
int _admShowFNM( ruleExecInfo_t *rei, rulefmapdef_t *inRuleFuncMapDef, int inx ) { int j; char outStr[MAX_RULE_LENGTH]; _writeString( "stdout", "---------------------------------------------------------------\n", rei ); for ( j = 0 ; j < inRuleFuncMapDef->MaxNumOfFMaps ; j++ ) { sprintf( outStr, " %-5i %s ===> %s\n", j + inx, inRuleFuncMapDef->funcName[j], inRuleFuncMapDef->func2CMap[j] ); _writeString( "stdout", outStr, rei ); } _writeString( "stdout", "---------------------------------------------------------------\n", rei ); return 0; }
unsigned Writer::beginEnter(const FunctionSig *sig) { _writeByte(trace::EVENT_ENTER); _writeUInt(sig->id); if (!lookup(functions, sig->id)) { _writeString(sig->name); _writeUInt(sig->num_args); for (unsigned i = 0; i < sig->num_args; ++i) { _writeString(sig->arg_names[i]); } functions[sig->id] = true; } return call_no++; }
/** * \fn writeBytesBuf(msParam_t* where, msParam_t* inBuf, ruleExecInfo_t *rei) * * \brief This microservice writes the buffer in an inOutStruct to stdout or stderr. * * \module core * * \since pre-2.1 * * * \usage See clients/icommands/test/rules3.0/ * * \param[in] where - a msParam of type STR_MS_T which is the buffer name in ruleExecOut. It can be stdout or stderr. * \param[in] inBuf - a msParam of type BUF_LEN_MS_T. * \param[in,out] rei - The RuleExecInfo structure that is automatically * handled by the rule engine. The user does not include rei as a * parameter in the rule invocation. * * \DolVarDependence none * \DolVarModified none * \iCatAttrDependence none * \iCatAttrModified none * \sideeffect none * * \return integer * \retval 0 on success * \pre none * \post none * \sa none **/ int writeBytesBuf( msParam_t* where, msParam_t* inBuf, ruleExecInfo_t *rei ) { char *writeId; char *writeStr; int status; if ( where->inOutStruct != NULL ) { writeId = ( char* )where->inOutStruct; } else { writeId = where->label; } if ( inBuf->inpOutBuf ) { /* Buffer might no be null-terminated */ writeStr = ( char* )malloc( inBuf->inpOutBuf->len + 1 ); strncpy( writeStr, ( char* )inBuf->inpOutBuf->buf, inBuf->inpOutBuf->len ); writeStr[inBuf->inpOutBuf->len] = '\0'; } else { writeStr = strdup( inBuf->label ); } status = _writeString( writeId, writeStr, rei ); if ( writeStr != NULL ) { free( writeStr ); } return status; }
void Writer::writeWString(const wchar_t *str) { if (!str) { Writer::writeNull(); return; } _writeByte(trace::TYPE_STRING); _writeString("<wide-string>"); }
void Writer::writeString(const char *str) { if (!str) { Writer::writeNull(); return; } _writeByte(trace::TYPE_STRING); _writeString(str); }
void Writer::writeEnum(const EnumSig *sig) { _writeByte(trace::TYPE_ENUM); _writeUInt(sig->id); if (!lookup(enums, sig->id)) { _writeString(sig->name); Writer::writeSInt(sig->value); enums[sig->id] = true; } }
void Writer::writeEnum(const EnumSig *sig, signed long long value) { _writeByte(trace::TYPE_ENUM); _writeUInt(sig->id); if (!lookup(enums, sig->id)) { _writeUInt(sig->num_values); for (unsigned i = 0; i < sig->num_values; ++i) { _writeString(sig->values[i].name); writeSInt(sig->values[i].value); } enums[sig->id] = true; } writeSInt(value); }
void Writer::writeBitmask(const BitmaskSig *sig, unsigned long long value) { _writeByte(trace::TYPE_BITMASK); _writeUInt(sig->id); if (!lookup(bitmasks, sig->id)) { _writeUInt(sig->num_flags); for (unsigned i = 0; i < sig->num_flags; ++i) { if (i != 0 && sig->flags[i].value == 0) { os::log("apitrace: warning: sig %s is zero but is not first flag\n", sig->flags[i].name); } _writeString(sig->flags[i].name); _writeUInt(sig->flags[i].value); } bitmasks[sig->id] = true; } _writeUInt(value); }
/** * \fn writePosInt(msParam_t* where, msParam_t* inInt, ruleExecInfo_t *rei) * * \brief This microservice writes a positive integer into a buffer. * * \module core * * \since pre-2.1 * * * \usage See clients/icommands/test/rules3.0/ * * \param[in] where - a msParam of type STR_MS_T which is the buffer name in ruleExecOut. * \param[in] inInt - the integer to write * \param[in,out] rei - The RuleExecInfo structure that is automatically * handled by the rule engine. The user does not include rei as a * parameter in the rule invocation. * * \DolVarDependence none * \DolVarModified none * \iCatAttrDependence none * \iCatAttrModified none * \sideeffect none * * \return integer * \retval 0 on success * \pre none * \post none * \sa none **/ int writePosInt( msParam_t* where, msParam_t* inInt, ruleExecInfo_t *rei ) { char *writeId; char writeStr[LONG_NAME_LEN]; int status; if ( where->inOutStruct != NULL ) { writeId = ( char* )where->inOutStruct; } else { writeId = where->label; } if ( inInt->inOutStruct != NULL ) { sprintf( writeStr, "%d", parseMspForPosInt( inInt ) ); } else { snprintf( writeStr, LONG_NAME_LEN, "%s", inInt->label ); } status = _writeString( writeId, writeStr, rei ); return status; }
/** * \cond oldruleengine * \fn writeString(msParam_t* where, msParam_t* inString, ruleExecInfo_t *rei) * * \brief This microservice writes a given string into the target buffer * * \module core * * \since pre-2.1 * * * \note This microservice takes a given buffer string and appends it to the end of the buffer * (either stdout or stderr in ruleExecOut parameter). This may be extended later for writing into local log file * or into an iRODS file also. The ruleExecOut is a system MS-parameter (*variable) that is automatically available. * * \usage See clients/icommands/test/rules3.0/ * * \param[in] where - where is a msParam of type STR_MS_T which is the buffer name in ruleExecOut. * Currently stdout, stderr and an existing iRODS file. * \param[in] inString - inString is a msParam of type STR_MS_T which is a string to be written into buffer * \param[in,out] rei - The RuleExecInfo structure that is automatically * handled by the rule engine. The user does not include rei as a * parameter in the rule invocation. * * \DolVarDependence none * \DolVarModified none * \iCatAttrDependence none * \iCatAttrModified none * \sideeffect ruleExecOut structure in msParamArray gets modified. * * \return integer * \retval 0 on success * \pre none * \post none * \sa none * \endcond **/ int writeString( msParam_t* where, msParam_t* inString, ruleExecInfo_t *rei ) { int i; char *writeId; char *writeStr; if ( where->inOutStruct == NULL ) { writeId = where->label; } else { writeId = ( char* )where->inOutStruct; } if ( inString->inOutStruct == NULL ) { writeStr = strdup( ( char * ) inString->label ); } else { writeStr = strdup( ( char * ) inString->inOutStruct ); } i = _writeString( writeId, writeStr, rei ); free( writeStr ); return i; }
/** * \fn msiPrintGenQueryInp( msParam_t *where, msParam_t* genQueryInpParam, ruleExecInfo_t *rei) * * \brief This microservice prints the given GenQueryInp_MS_T to the given target buffer * * \module core * * \since pre-2.1 * * \author Arcot Rajasekar * \date 2008 * * \usage See clients/icommands/test/rules3.0/ * * \param[in] where - Required - a STR_MS_T containing the parameters. * \param[in] genQueryInpParam - Required - a GenQueryInp_MS_T containing the parameters and conditions. * \param[in,out] rei - The RuleExecInfo structure that is automatically * handled by the rule engine. The user does not include rei as a * parameter in the rule invocation. * * \DolVarDependence none * \DolVarModified none * \iCatAttrDependence none * \iCatAttrModified none * \sideeffect none * * \return integer * \retval 0 on success * \pre none * \post none * \sa writeString **/ int msiPrintGenQueryInp( msParam_t *where, msParam_t* genQueryInpParam, ruleExecInfo_t *rei ) { genQueryInp_t *genQueryInp; int i, j; char *writeId; char writeStr[MAX_NAME_LEN * 2]; int len; int *ip1, *ip2; char *cp; char **cpp; RE_TEST_MACRO( " Calling msiPrintGenQueryInp" ); if ( rei == NULL || rei->rsComm == NULL ) { rodsLog( LOG_ERROR, "msiPrintGenQueryInp: input rei or rsComm is NULL." ); return ( SYS_INTERNAL_NULL_INPUT_ERR ); } if ( !where ) { rodsLog( LOG_ERROR, "msiPrintGenQueryInp: No destination provided for writing." ); return ( USER__NULL_INPUT_ERR ); } /* where are we writing to? */ if ( where->inOutStruct != NULL ) { writeId = ( char* )where->inOutStruct; } else { writeId = where->label; } /* genQueryInp = (genQueryInp_t *) strtol((char *)genQueryInpParam->inOutStruct, (char **) NULL,0); */ genQueryInp = ( genQueryInp_t * ) genQueryInpParam->inOutStruct; /* print each selection pair to writeStr */ len = genQueryInp->selectInp.len; ip1 = genQueryInp->selectInp.inx; ip2 = genQueryInp->selectInp.value; for ( i = 0; i < len; i++ ) { sprintf( writeStr, "Selected Column %d With Option %d\n", *ip1, *ip2 ); j = _writeString( writeId, writeStr, rei ); if ( j < 0 ) { return( j ); } ip1++; ip2++; } len = genQueryInp->sqlCondInp.len; ip1 = genQueryInp->sqlCondInp.inx; cpp = genQueryInp->sqlCondInp.value; cp = *cpp; for ( i = 0; i < len; i++ ) { sprintf( writeStr, "Condition Column %d %s\n", *ip1, cp ); j = _writeString( writeId, writeStr, rei ); if ( j < 0 ) { return( j ); } ip1++; cpp++; cp = *cpp; } return( 0 ); }
/** * \fn writeKeyValPairs(msParam_t *where, msParam_t *inKVPair, msParam_t *separator, ruleExecInfo_t *rei) * * \brief This microservice writes keyword value pairs to stdout or stderr, using the given separator. * * \module core * * \since 2.1 * * * \usage See clients/icommands/test/rules3.0/ * * \param[in] where - a msParam of type STR_MS_T which is the buffer name in ruleExecOut. It can be stdout or stderr. * \param[in] inKVPair - a msParam of type KeyValPair_MS_T * \param[in] separator - Optional - a msParam of type STR_MS_T, the desired parameter * \param[in,out] rei - The RuleExecInfo structure that is automatically * handled by the rule engine. The user does not include rei as a * parameter in the rule invocation. * * \DolVarDependence none * \DolVarModified none * \iCatAttrDependence none * \iCatAttrModified none * \sideeffect none * * \return integer * \retval 0 on success * \pre none * \post none * \sa none **/ int writeKeyValPairs( msParam_t *where, msParam_t *inKVPair, msParam_t *separator, ruleExecInfo_t *rei ) { keyValPair_t *KVPairs; char *writeId; char *writeStr; char *sepStr; int i; size_t size; RE_TEST_MACRO( " Calling writeKeyValPairs" ) /* sanity checks */ if ( !rei ) { rodsLog( LOG_ERROR, "writeKeyValPairs: input rei is NULL." ); return SYS_INTERNAL_NULL_INPUT_ERR; } if ( !where ) { rodsLog( LOG_ERROR, "writeKeyValPairs: No destination provided for writing." ); return USER__NULL_INPUT_ERR; } /* empty? */ if ( !inKVPair || !inKVPair->inOutStruct ) { return 0; } /* check for proper input type and get keyValPair input */ if ( inKVPair->type && strcmp( inKVPair->type, KeyValPair_MS_T ) ) { rodsLog( LOG_ERROR, "writeKeyValPairs: input parameter is not of KeyValPair_MS_T type." ); return USER_PARAM_TYPE_ERR; } KVPairs = ( keyValPair_t * )inKVPair->inOutStruct; /* where are we writing to? */ if ( where->inOutStruct != NULL ) { writeId = ( char* )where->inOutStruct; } else { writeId = where->label; } /* get separator string or use default */ if ( ( sepStr = parseMspForStr( separator ) ) == NULL ) { sepStr = "\t|\t"; } /* find out how much memory is needed for writeStr */ size = 0; for ( i = 0; i < KVPairs->len; i++ ) { size += strlen( KVPairs->keyWord[i] ) + strlen( sepStr ) + strlen( KVPairs->value[i] ) + strlen( "\n" ); } /* allocate memory for writeStr and pad with null chars */ writeStr = ( char * )malloc( size + MAX_COND_LEN ); memset( writeStr, '\0', size + MAX_COND_LEN ); /* print each key-value pair to writeStr */ for ( i = 0; i < KVPairs->len; i++ ) { strcat( writeStr, KVPairs->keyWord[i] ); strcat( writeStr, sepStr ); strcat( writeStr, KVPairs->value[i] ); strcat( writeStr, "\n" ); } /* call _writeString() routine */ rei->status = _writeString( writeId, writeStr, rei ); /* free writeStr since its content has been copied somewhere else */ if ( writeStr != NULL ) { free( writeStr ); } return rei->status; }
/** * \fn msiDboExec(msParam_t *dbrName, msParam_t *dboName, msParam_t *dborName, * msParam_t *options, * msParam_t *inpParam1, msParam_t *inpParam2, * msParam_t *inpParam3, msParam_t *inpParam4, * msParam_t *inpParam5, msParam_t *inpParam6, * ruleExecInfo_t *rei) * * \brief Execute a database object on a DBR * * \module core * * \since 2.5 * * \author Wayne Schroeder * \date 2010-11-23 * * \usage See clients/icommands/test/rules3.0/ and https://www.irods.org/index.php/DBR * * \param[in] dbrName - a STR_MS_T, name of the DBR being used * \param[in] dboName - a STR_MS_T, name of the DBO being used * \param[in] dborName - a STR_MS_T, name of the DBOR being used * \param[in] options - a STR_MS_T, currently 'force' or not * \param[in] inpParam1 - Optional - STR_MS_T parameters to the DBO SQL. * \param[in] inpParam2 - Optional - STR_MS_T parameters to the DBO SQL. * \param[in] inpParam3 - Optional - STR_MS_T parameters to the DBO SQL. * \param[in] inpParam4 - Optional - STR_MS_T parameters to the DBO SQL. * \param[in] inpParam5 - Optional - STR_MS_T parameters to the DBO SQL. * \param[in] inpParam6 - Optional - STR_MS_T parameters to the DBO SQL. * \param[in,out] rei - The RuleExecInfo structure that is automatically * handled by the rule engine. The user does not include rei as a * parameter in the rule invocation. * * \DolVarDependence none * \DolVarModified none * \iCatAttrDependence none * \iCatAttrModified none * \sideeffect none * * \return integer * \retval 0 on success * \pre none * \post none * \sa none **/ int msiDboExec(msParam_t *dbrName, msParam_t *dboName, msParam_t *dborName, msParam_t *options, msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *inpParam5, msParam_t *inpParam6, ruleExecInfo_t *rei) { rsComm_t *rsComm; char *myDbrName; char *myDboName; char *myDborName; char *myOptions; char *p1; char *p2; char *p3; char *p4; char *p5; char *p6; databaseObjControlInp_t databaseObjControlInp; databaseObjControlOut_t *databaseObjControlOut; int status; RE_TEST_MACRO (" Calling msiDboExec") if (rei == NULL || rei->rsComm == NULL) { rodsLog (LOG_ERROR, "msiDboExec rei or rsComm is NULL"); return (SYS_INTERNAL_NULL_INPUT_ERR); } rsComm = rei->rsComm; myDbrName = parseMspForStr(dbrName); if (myDbrName == NULL) { rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, "msiDboExec: input dbrName is NULL"); return (USER__NULL_INPUT_ERR); } myDboName = parseMspForStr(dboName); if (myDboName == NULL) { rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, "msiDboExec: input dboName is NULL"); return (USER__NULL_INPUT_ERR); } myDborName = parseMspForStr(dborName); if (myDborName == NULL) { rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, "msiDboExec: input dborName is NULL"); return (USER__NULL_INPUT_ERR); } myOptions = parseMspForStr(options); p1 = parseMspForStr(inpParam1); p2 = parseMspForStr(inpParam2); p3 = parseMspForStr(inpParam3); p4 = parseMspForStr(inpParam4); p5 = parseMspForStr(inpParam5); p6 = parseMspForStr(inpParam6); if (rei->status < 0) { rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, "msiDboExec: input inpParam error. status = %d", rei->status); return (rei->status); } memset((void *)&databaseObjControlInp, 0, sizeof(databaseObjControlInp)); databaseObjControlInp.option = DBO_EXECUTE; databaseObjControlInp.dbrName = myDbrName; databaseObjControlInp.dboName = myDboName; databaseObjControlInp.dborName = myDborName; if (strcmp(myOptions, "force")==0) { databaseObjControlInp.subOption = 1; } databaseObjControlInp.args[0] = p1; databaseObjControlInp.args[1] = p2; databaseObjControlInp.args[2] = p3; databaseObjControlInp.args[3] = p4; databaseObjControlInp.args[4] = p5; databaseObjControlInp.args[5] = p6; status = rsDatabaseObjControl(rsComm, &databaseObjControlInp, &databaseObjControlOut); if (status) { return(status); } if (*databaseObjControlOut->outBuf != '\0') { int stat2; stat2 = _writeString("stdout",databaseObjControlOut->outBuf,rei); } return(status); }