irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

utils.hpp File Reference
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "objInfo.h"
#include "reHelpers1.hpp"
#include "rodsType.h"
#include "restructs.hpp"
#include "region.h"
#include "irods_hashtable.h"
#include "key.proto.hpp"
#include "proto.hpp"
#include "restruct.templates.hpp"
#include "end.instance.hpp"
#include "region.to.region.proto.hpp"
#include "to.region.proto.hpp"
#include "to.memory.proto.hpp"
#include "region.to.region2.proto.hpp"
Include dependency graph for utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CASCASE_NON_ZERO(x)   {int ret = x; if(ret != 0) { return ret;} }
 
#define CASCADE_NULL(x)   if((x)==NULL) return NULL;
 
#define CASCADE_N_ERROR(x)
 
#define IS_TVAR_NAME(x)   ((x)[0] == '?')
 
#define PRINT(p, s, f, d)   snprintf(*p, *s, f, d);*s -= strlen(*p); *p += strlen(*p);
 
#define cpRes(p, r)   regionRegionCpNode(p, r)
 
#define cpType(p, r)   regionRegionCpNode(p, r)
 
#define cpRes2(p, oldr, r)   regionRegion2CpNode(p, oldr, r)
 
#define cpType2(p, oldr, r)   regionRegion2CpNode(p, oldr, r)
 
#define INC_MOD(x, m)   (x) = (((x) == ((m) - 1)) ? 0 : ((x) + 1))
 
#define DEC_MOD(x, m)   (x) = (((x) == 0) ? ((m) - 1) : ((x) - 1))
 
#define FLOOR_MOD(x, m)   ((x) % (m) == 0? (x) : (x) / (m) * (m))
 
#define CEILING_MOD(x, m)   ((x) % (m) == 0? (x) : (x) / (m) * (m) + (m))
 
#define CONCAT2(a, b)   a##b
 
#define CONCAT(a, b)   CONCAT2(a,b)
 
#define KEY_PROTO
 

Functions

int newTVarId ()
 
char * getTVarName (int vid, char name[128])
 
char * getTVarNameRegion (int vid, Region *r)
 
char * getTVarNameRegionFromExprType (ExprType *tvar, Region *r)
 
ExprTypedupType (ExprType *ty, Region *r)
 
int typeEqSyntatic (ExprType *a, ExprType *b)
 
Node ** allocSubtrees (Region *r, int size)
 
void setStringPair (ExprType *ty, Region *r)
 
void replace (Hashtable *varTypes, int a, ExprType *b)
 
void replaceCons (ExprType *consType, int a, ExprType *b)
 
ExprTypedereference (ExprType *type, Hashtable *tt, Region *r)
 
ExprTypeinstantiate (ExprType *type, Hashtable *type_table, int replaceFreeVars, Region *r)
 
ExprTypedupTypeAux (ExprType *ty, Region *r, Hashtable *varTable)
 
char * cpString (char *res, Region *r)
 
char * cpStringExt (const char *str, Region *r)
 
void cpHashtable (Hashtable *env, Region *r)
 
void cpEnv (Env *env, Region *r)
 
char * cpString2 (char *res, Region *oldr, Region *newr)
 
void cpHashtable2 (Hashtable *env, Region *oldr, Region *newr)
 
void cpEnv2 (Env *env, Region *oldr, Region *newr)
 
int occursIn (ExprType *var, ExprType *type)
 
ExprTypeunifyWith (ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
 
ExprTypeunifyNonTvars (ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
 
ExprTypeunifyTVarL (ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
 
ExprTypeunifyTVarR (ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
 
void printType (ExprType *type, Hashtable *var_types)
 
char * typeToString (ExprType *type, Hashtable *var_types, char *buf, int bufsize)
 
void typingConstraintsToString (List *typingConstraints, char *buf, int bufsize)
 
const void * lookupFromEnv (Env *env, const char *key)
 
void updateInEnv (Env *env, char *varname, Res *res)
 
void freeEnvUninterpretedStructs (Env *e)
 
EnvglobalEnv (Env *env)
 
void listAppend (List *list, void *value, Region *r)
 
void listAppendToNode (List *list, ListNode *node, void *value, Region *r)
 
void listRemove (List *list, ListNode *node)
 
void listAppendNoRegion (List *list, void *value)
 
void listRemoveNoRegion (List *list, ListNode *node)
 
void logErrMsg (rError_t *errmsg, rError_t *system)
 
char * errMsgToString (rError_t *errmsg, char *buf, int buflen)
 
int isPattern (Node *pattern)
 
int isRecursive (Node *rule)
 
int invokedIn (char *fn, Node *expr)
 
NodelookupAVUFromMetadata (Node *metadata, char *a)
 
int isRuleGenSyntax (char *expr)
 
void keyBuf (unsigned char *buf, int size, char *keyBuf)
 
int writeToTmp (char *fileName, char *text)
 
void printMsParamArray (msParamArray_t *msParamArray, char *buf2)
 
void printHashtable (Hashtable *env, char *buf2)
 
void printVarTypeEnvToStdOut (Hashtable *env)
 

Macro Definition Documentation

◆ CASCADE_N_ERROR

#define CASCADE_N_ERROR (   x)
Value:
{Res *ret = x; if(getNodeType(ret) == N_ERROR) { \
return ret; \
}}

Definition at line 23 of file utils.hpp.

◆ CASCADE_NULL

#define CASCADE_NULL (   x)    if((x)==NULL) return NULL;

Definition at line 22 of file utils.hpp.

◆ CASCASE_NON_ZERO

#define CASCASE_NON_ZERO (   x)    {int ret = x; if(ret != 0) { return ret;} }

Definition at line 21 of file utils.hpp.

◆ CEILING_MOD

#define CEILING_MOD (   x,
 
)    ((x) % (m) == 0? (x) : (x) / (m) * (m) + (m))

Definition at line 100 of file utils.hpp.

◆ CONCAT

#define CONCAT (   a,
 
)    CONCAT2(a,b)

Definition at line 105 of file utils.hpp.

◆ CONCAT2

#define CONCAT2 (   a,
 
)    a##b

Definition at line 104 of file utils.hpp.

◆ cpRes

#define cpRes (   p,
 
)    regionRegionCpNode(p, r)

Definition at line 49 of file utils.hpp.

◆ cpRes2

#define cpRes2 (   p,
  oldr,
 
)    regionRegion2CpNode(p, oldr, r)

Definition at line 51 of file utils.hpp.

◆ cpType

#define cpType (   p,
 
)    regionRegionCpNode(p, r)

Definition at line 50 of file utils.hpp.

◆ cpType2

#define cpType2 (   p,
  oldr,
 
)    regionRegion2CpNode(p, oldr, r)

Definition at line 52 of file utils.hpp.

◆ DEC_MOD

#define DEC_MOD (   x,
 
)    (x) = (((x) == 0) ? ((m) - 1) : ((x) - 1))

Definition at line 98 of file utils.hpp.

◆ FLOOR_MOD

#define FLOOR_MOD (   x,
 
)    ((x) % (m) == 0? (x) : (x) / (m) * (m))

Definition at line 99 of file utils.hpp.

◆ INC_MOD

#define INC_MOD (   x,
 
)    (x) = (((x) == ((m) - 1)) ? 0 : ((x) + 1))

Definition at line 97 of file utils.hpp.

◆ IS_TVAR_NAME

#define IS_TVAR_NAME (   x)    ((x)[0] == '?')

Definition at line 27 of file utils.hpp.

◆ KEY_PROTO

#define KEY_PROTO

Definition at line 107 of file utils.hpp.

◆ PRINT

#define PRINT (   p,
  s,
  f,
 
)    snprintf(*p, *s, f, d);*s -= strlen(*p); *p += strlen(*p);

Definition at line 29 of file utils.hpp.

Function Documentation

◆ allocSubtrees()

Node** allocSubtrees ( Region r,
int  size 
)

Definition at line 34 of file restructs.cpp.

References region_alloc(), and size.

Referenced by typeFunction3().

Here is the call graph for this function:

◆ cpEnv()

void cpEnv ( Env env,
Region r 
)

Definition at line 396 of file utils.cpp.

References cpHashtable(), env::current, NULL, and env::previous.

Referenced by computeNode(), execRuleNodeRes(), smsi_forEach2Exec(), smsi_forExec(), and smsi_whileExec().

Here is the call graph for this function:

◆ cpEnv2()

void cpEnv2 ( Env env,
Region oldr,
Region newr 
)

Definition at line 479 of file utils.cpp.

References cpHashtable2(), env::current, NULL, and env::previous.

Referenced by evaluateFunction3(), and smsiCollectionSpider().

Here is the call graph for this function:

◆ cpHashtable()

void cpHashtable ( Hashtable env,
Region r 
)

Definition at line 384 of file utils.cpp.

References irods.six::b(), cpRes, and NULL.

Referenced by cpEnv().

Here is the call graph for this function:

◆ cpHashtable2()

void cpHashtable2 ( Hashtable env,
Region oldr,
Region newr 
)

Definition at line 467 of file utils.cpp.

References irods.six::b(), cpRes2, and NULL.

Referenced by cpEnv2().

Here is the call graph for this function:

◆ cpString()

char* cpString ( char *  res,
Region r 
)

Definition at line 350 of file utils.cpp.

References cpStringExt(), and IN_REGION.

Referenced by newConsType().

Here is the call graph for this function:

◆ cpString2()

char* cpString2 ( char *  res,
Region oldr,
Region newr 
)

Definition at line 438 of file utils.cpp.

References cpStringExt(), and IN_REGION.

Here is the call graph for this function:

◆ cpStringExt()

char* cpStringExt ( const char *  str,
Region r 
)

Definition at line 358 of file utils.cpp.

References region_alloc().

Referenced by construct(), cpString(), cpString2(), newCollType(), newFuncSymLink(), newFuncType(), newRuleIndexList(), newUnspecifiedRes(), and smsi_tuple().

Here is the call graph for this function:

◆ dereference()

ExprType* dereference ( ExprType type,
Hashtable tt,
Region r 
)

Definition at line 626 of file utils.cpp.

References getNodeType, getTVarName(), lookupFromHashTable(), generate_iadmin_commands_for_41_to_42_upgrade::name, NULL, T_VAR, T_VAR_ID, and type.

Referenced by instantiate(), isIterable(), simplifyLocally(), solveConstraints(), typeExpression3(), typeFunction3(), typeParameters(), typeToString(), unifyNonTvars(), unifyTVarL(), unifyTVarR(), and unifyWith().

Here is the call graph for this function:

◆ dupType()

ExprType* dupType ( ExprType ty,
Region r 
)

Definition at line 9 of file utils.cpp.

References dupTypeAux(), and newHashTable2().

Referenced by typeExpression3().

Here is the call graph for this function:

◆ dupTypeAux()

ExprType* dupTypeAux ( ExprType ty,
Region r,
Hashtable varTable 
)

Definition at line 46 of file utils.cpp.

References buf, getNodeType, getTVarName(), insertIntoHashTable(), lookupFromHashTable(), generate_iadmin_commands_for_41_to_42_upgrade::name, newConsType(), newExprType(), newTupleType(), newTVar2(), NULL, node::option, region_alloc(), node::subtrees, T_CONS, T_CONS_ARITY, T_CONS_TYPE_ARG, T_CONS_TYPE_NAME, T_FLEX, T_TUPLE, T_VAR, T_VAR_DISJUNCTS, T_VAR_ID, and T_VAR_NUM_DISJUNCTS.

Referenced by dupType().

Here is the call graph for this function:

◆ errMsgToString()

char* errMsgToString ( rError_t errmsg,
char *  buf,
int  buflen 
)

◆ freeEnvUninterpretedStructs()

void freeEnvUninterpretedStructs ( Env e)

Definition at line 837 of file utils.cpp.

References irods.six::b(), hashtable::buckets, terminate_irods_processes::e, NULL, RES_UNINTER_BUFFER, RES_UNINTER_STRUCT, hashtable::size, T_IRODS, and TYPE.

Here is the call graph for this function:

◆ getTVarName()

◆ getTVarNameRegion()

char* getTVarNameRegion ( int  vid,
Region r 
)

Definition at line 302 of file utils.cpp.

References generate_iadmin_commands_for_41_to_42_upgrade::name, and region_alloc().

Referenced by getTVarNameRegionFromExprType().

Here is the call graph for this function:

◆ getTVarNameRegionFromExprType()

char* getTVarNameRegionFromExprType ( ExprType tvar,
Region r 
)

Definition at line 307 of file utils.cpp.

References getTVarNameRegion(), and T_VAR_ID.

Here is the call graph for this function:

◆ globalEnv()

Env* globalEnv ( Env env)

replace type var a with type b in varTypes

Definition at line 754 of file utils.cpp.

References NULL, and env::previous.

Referenced by evaluateFunction3(), execRuleFromCondIndex(), execRuleNodeRes(), and parseAndComputeRuleAdapter().

◆ instantiate()

ExprType* instantiate ( ExprType type,
Hashtable type_table,
int  replaceFreeVars,
Region r 
)

Definition at line 642 of file utils.cpp.

References dereference(), getNodeType, newSimpType(), region_alloc(), node::subtrees, T_UNSPECED, T_VAR, and type.

Referenced by evaluateFunction3(), postProcessCoercion(), processCoercion(), and typeFunction3().

Here is the call graph for this function:

◆ invokedIn()

int invokedIn ( char *  fn,
Node expr 
)

◆ isPattern()

int isPattern ( Node pattern)

◆ isRecursive()

int isRecursive ( Node rule)

Definition at line 880 of file utils.cpp.

References invokedIn(), node::subtrees, and node::text.

Here is the call graph for this function:

◆ isRuleGenSyntax()

int isRuleGenSyntax ( char *  expr)

Definition at line 922 of file utils.cpp.

References mode, and pid_age::p.

Referenced by parseAndComputeExpression().

◆ keyBuf()

void keyBuf ( unsigned char *  buf,
int  size,
char *  keyBuf 
)

Definition at line 1003 of file utils.cpp.

References buf, KEY_SIZE, pid_age::p, and size.

Referenced by keyNode(), obfDecodeByKey(), obfEncodeByKey(), and obfGetMD5Hash().

◆ listAppend()

void listAppend ( List list,
void *  value,
Region r 
)

Definition at line 45 of file list.cpp.

References list::head, newListNode(), listNode::next, NULL, list::size, list::tail, and get_irods_version::value.

Here is the call graph for this function:

◆ listAppendNoRegion()

void listAppendNoRegion ( List list,
void *  value 
)

Definition at line 34 of file list.cpp.

References list::head, newListNodeNoRegion(), listNode::next, NULL, list::size, list::tail, and get_irods_version::value.

Here is the call graph for this function:

◆ listAppendToNode()

void listAppendToNode ( List list,
ListNode node,
void *  value,
Region r 
)

Definition at line 56 of file list.cpp.

References newListNode(), listNode::next, NULL, list::size, list::tail, and get_irods_version::value.

Here is the call graph for this function:

◆ listRemove()

void listRemove ( List list,
ListNode node 
)

Definition at line 68 of file list.cpp.

References list::head, listNode::next, NULL, list::size, and list::tail.

◆ listRemoveNoRegion()

void listRemoveNoRegion ( List list,
ListNode node 
)

Definition at line 100 of file list.cpp.

References list::head, listNode::next, NULL, list::size, and list::tail.

Referenced by clearListNoRegion(), and listRemoveNoRegion2().

◆ logErrMsg()

void logErrMsg ( rError_t errmsg,
rError_t system 
)

Definition at line 762 of file utils.cpp.

References ERR_MSG_LEN, errMsgToString(), LOG_ERROR, NULL, RE_UNKNOWN_ERROR, rodsLog(), rodsLogAndErrorMsg(), and writeToTmp().

Referenced by applyRuleArgPA(), parseAndComputeExpressionAdapter(), and parseAndComputeRuleAdapter().

Here is the call graph for this function:

◆ lookupAVUFromMetadata()

Node* lookupAVUFromMetadata ( Node metadata,
char *  a 
)

Definition at line 911 of file utils.cpp.

References node::degree, NULL, node::subtrees, and node::text.

Referenced by insertRulesIntoDBNew().

◆ lookupFromEnv()

const void* lookupFromEnv ( Env env,
const char *  key 
)

Definition at line 813 of file utils.cpp.

References env::current, bucket::key, lookupFromHashTable(), NULL, and env::previous.

Referenced by attemptToEvaluateVar3(), evaluateExpression3(), evaluateFunction3(), execAction3(), getSessionVar(), matchPattern(), rule_exists(), setVariableValue(), typeExpression3(), and typeRuleSet().

Here is the call graph for this function:

◆ newTVarId()

int newTVarId ( )

Definition at line 312 of file utils.cpp.

References ruleEngineConfig, and Cache::tvarNumber.

Referenced by newTVar(), newTVar2(), nextRuleGen_Type(), and replaceDynamicWithNewTVar().

◆ occursIn()

int occursIn ( ExprType var,
ExprType type 
)

Definition at line 126 of file typing.cpp.

References getNodeType, T_VAR, T_VAR_ID, and type.

Referenced by unifyTVarL(), and unifyTVarR().

◆ printHashtable()

void printHashtable ( Hashtable env,
char *  buf2 
)

Definition at line 736 of file conversion.cpp.

References irods.six::b(), convertResToString(), node::exprType, MAX_NAME_LEN, NULL, and typeToString().

Referenced by printEnvToStdOut(), and smsi_listvars().

Here is the call graph for this function:

◆ printMsParamArray()

void printMsParamArray ( msParamArray_t msParamArray,
char *  buf2 
)

◆ printType()

void printType ( ExprType type,
Hashtable var_types 
)

Definition at line 516 of file utils.cpp.

References buf, type, and typeToString().

Referenced by printTreeDeref(), and printVarTypeEnvToStdOut().

Here is the call graph for this function:

◆ printVarTypeEnvToStdOut()

void printVarTypeEnvToStdOut ( Hashtable env)

Definition at line 721 of file utils.cpp.

References irods.six::b(), NULL, and printType().

Here is the call graph for this function:

◆ replace()

void replace ( Hashtable varTypes,
int  a,
ExprType b 
)

◆ replaceCons()

void replaceCons ( ExprType consType,
int  a,
ExprType b 
)

◆ setStringPair()

void setStringPair ( ExprType ty,
Region r 
)

◆ typeEqSyntatic()

int typeEqSyntatic ( ExprType a,
ExprType b 
)

Definition at line 18 of file utils.cpp.

References irods.six::b(), getNodeType, getVararg, T_CONS, T_CONS_ARITY, T_CONS_TYPE_ARG, T_CONS_TYPE_NAME, T_IRODS, T_TUPLE, T_VAR, T_VAR_ID, and node::text.

Referenced by addToEquivalenceClass(), applyBaseTypeRule(), occursInEquiv(), postProcessCoercion(), processCoercion(), tautologyLt(), and tautologyLtBase().

Here is the call graph for this function:

◆ typeToString()

char* typeToString ( ExprType type,
Hashtable var_types,
char *  buf,
int  bufsize 
)

◆ typingConstraintsToString()

void typingConstraintsToString ( List typingConstraints,
char *  buf,
int  bufsize 
)

Definition at line 614 of file utils.cpp.

References buf, list::head, NULL, pid_age::p, TC_A, TC_B, and typeToString().

Here is the call graph for this function:

◆ unifyNonTvars()

ExprType* unifyNonTvars ( ExprType type,
ExprType expected,
Hashtable varTypes,
Region r 
)

Unify non tvar or union types. return The most general instance if unifiable NULL if not

Definition at line 248 of file utils.cpp.

References dereference(), getNodeType, newConsType(), newErrorType(), NULL, RE_TYPE_ERROR, region_alloc(), T_CONS, T_CONS_ARITY, T_CONS_TYPE_ARG, T_CONS_TYPE_NAME, T_IRODS, node::text, type, and unifyWith().

Referenced by unifyWith().

Here is the call graph for this function:

◆ unifyTVarL()

ExprType* unifyTVarL ( ExprType type,
ExprType expected,
Hashtable varTypes,
Region r 
)

Definition at line 115 of file utils.cpp.

References buf, dereference(), getNodeType, getTVarName(), insertIntoHashTable(), NULL, occursIn(), T_VAR_DISJUNCT, T_VAR_ID, T_VAR_NUM_DISJUNCTS, and type.

Referenced by isIterable(), and unifyWith().

Here is the call graph for this function:

◆ unifyTVarR()

ExprType* unifyTVarR ( ExprType type,
ExprType expected,
Hashtable varTypes,
Region r 
)

Definition at line 140 of file utils.cpp.

References buf, dereference(), getNodeType, getTVarName(), insertIntoHashTable(), NULL, occursIn(), T_VAR_DISJUNCT, T_VAR_ID, T_VAR_NUM_DISJUNCTS, and type.

Referenced by unifyWith().

Here is the call graph for this function:

◆ unifyWith()

ExprType* unifyWith ( ExprType type,
ExprType expected,
Hashtable varTypes,
Region r 
)

return The most general common instance of type and expected if unifiable NULL if false

Definition at line 169 of file utils.cpp.

References buf, dereference(), getNodeType, getTVarName(), getVararg, insertIntoHashTable(), newTVar2(), NULL, T_DYNAMIC, T_UNSPECED, T_VAR, T_VAR_DISJUNCT, T_VAR_ID, T_VAR_NUM_DISJUNCTS, type, unifyNonTvars(), unifyTVarL(), unifyTVarR(), and updateInHashTable().

Referenced by typeFunction3(), typeTypeAscription(), and unifyNonTvars().

Here is the call graph for this function:

◆ updateInEnv()

void updateInEnv ( Env env,
char *  varname,
Res res 
)

Definition at line 821 of file utils.cpp.

References env::current, insertIntoHashTable(), lookupFromHashTable(), NULL, env::previous, and updateInHashTable().

Referenced by matchPattern(), parseAndComputeMsParamArrayToEnv(), reIterable_collection_next(), setVariableValue(), smsi_forEach2Exec(), smsiCollectionSpider(), updateMsParamArrayToEnv(), and updateMsParamArrayToEnvAndFreeNonIRODSType().

Here is the call graph for this function:

◆ writeToTmp()

getNodeType
#define getNodeType(x)
Definition: restructs.hpp:69
node
Definition: restructs.hpp:244
N_ERROR
@ N_ERROR
Definition: restructs.hpp:111