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)  

functions.cpp
Go to the documentation of this file.
1 /* For copyright information please refer to files in the COPYRIGHT directory
2  */
3 #include "index.hpp"
4 #include "functions.hpp"
5 #include "arithmetics.hpp"
6 #include "datetime.hpp"
7 #include "cache.hpp"
8 #include "configuration.hpp"
9 #include "rsExecMyRule.hpp"
10 #include "rsDataObjOpen.hpp"
11 #include "rsDataObjLseek.hpp"
12 #include "rsDataObjWrite.hpp"
13 #include "rsDataObjClose.hpp"
14 #ifndef DEBUG
15 #include "apiHeaderAll.h"
16 #include "rsApiHandler.hpp"
17 #include "dataObjOpr.hpp"
18 #else
19 int
20 getDataObjInfoIncSpecColl( rsComm_t *rsComm, dataObjInp_t *dataObjInp,
21  dataObjInfo_t **dataObjInfo );
22 #endif
23 
24 
25 #include <boost/regex.h>
26 
27 #ifndef DEBUG
28 #include "execMyRule.h"
29 #include "msParam.h"
30 #include "reFuncDefs.hpp"
31 #include "stringOpr.h"
32 #include "miscServerFunct.hpp"
33 #endif
34 
35 // =-=-=-=-=-=-=-
36 // irods includes
38 
39 #define GC_BEGIN Region *_rnew = make_region(0, NULL), *_rnew2 = NULL;
40 #define GC_REGION _rnew
41 #define GC_ON(env) \
42 if(region_size(_rnew) > DEFAULT_BLOCK_SIZE) {\
43 _rnew2 = make_region(0, NULL); \
44 cpEnv2((env), _rnew, _rnew2); \
45 region_free(_rnew); \
46 _rnew = _rnew2;}
47 #define GC_END region_free(_rnew);
48 
49 #define RE_BACKWARD_COMPATIBLE
50 
51 static char globalSessionId[MAX_NAME_LEN] = "Unspecified";
53 
54 /* todo include proper header files */
55 int rsOpenCollection( rsComm_t *rsComm, collInp_t *openCollInp );
56 int rsCloseCollection( rsComm_t *rsComm, int *handleInxInp );
57 int rsReadCollection( rsComm_t *rsComm, int *handleInxInp, collEnt_t **collEnt );
58 int msiExecGenQuery( msParam_t* genQueryInParam, msParam_t* genQueryOutParam, ruleExecInfo_t* rei );
59 int msiCloseGenQuery( msParam_t* genQueryInpParam, msParam_t* genQueryOutParam, ruleExecInfo_t* rei );
60 int msiGetMoreRows( msParam_t* genQueryInpParam, msParam_t* genQueryOutParam, msParam_t *contInxParam, ruleExecInfo_t* rei );
61 
62 
64  return newStringRes( r, globalSessionId );
65 }
66 
67 Res *smsi_setGlobalSessionId( Node**subtrees, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
68  char *sid = subtrees[0]->text;
70  return newIntRes( r, 0 );
71 }
72 
75 }
76 
77 
82 
83 void reIterable_list_init( ReIterableData *itrData, Region* r );
87 
88 void reIterable_irods_init( ReIterableData *itrData, Region* r );
92 
97 
98 #define NUM_RE_ITERABLE 7
107 };
108 
110  char *varName,
111  Res *res,
112  Node** subtrees,
113  Node* node,
114  ruleExecInfo_t* rei,
115  int reiSaveFlag,
116  Env* env,
117  rError_t* errmsg ) {
118  ReIterableData *itrData = ( ReIterableData * ) malloc( sizeof( ReIterableData ) );
119  itrData->varName = varName;
120  itrData->res = res;
121  itrData->itrSpecData = NULL;
122  itrData->errorRes = NULL;
123  itrData->subtrees = subtrees;
124  itrData->node = node;
125  itrData->rei = rei;
126  itrData->reiSaveFlag = reiSaveFlag;
127  itrData->env = env;
128  itrData->errmsg = errmsg;
129  return itrData;
130 
131 }
132 
134  free( itrData );
135 }
136 int fileConcatenate( const char *file1, const char *file2, const char *file3 );
137 
139  if ( getNodeType( node ) != N_ACTIONS ) {
140  Node *actions[1];
141  actions[0] = node;
142  Label expr;
143  expr.base = node->base;
144  expr.exprloc = NODE_EXPR_POS( node );
145  return createActionsNode( actions, 1, &expr, r );
146  }
147  return node;
148 }
149 Res *smsi_ifExec( Node** params, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
150  Res *res = evaluateExpression3( ( Node * )params[0], 0, 1, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, r );
151  if ( getNodeType( res ) == N_ERROR ) {
152  return res;
153  }
154  if ( RES_BOOL_VAL( res ) == 0 ) {
155  return evaluateActions( wrapToActions( params[2], r ), wrapToActions( params[4], r ), 0, rei, reiSaveFlag, env, errmsg, r );
156  }
157  else {
158  return evaluateActions( wrapToActions( params[1], r ), wrapToActions( params[3], r ), 0, rei, reiSaveFlag, env, errmsg, r );
159  }
160 }
161 
162 Res *smsi_if2Exec( Node** params, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
163  Res *res = evaluateExpression3( ( Node * )params[0], 0, 1, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, r );
164  if ( getNodeType( res ) == N_ERROR ) {
165  return res;
166  }
167  if ( RES_BOOL_VAL( res ) == 0 ) {
168  return evaluateExpression3( ( Node * )params[2], 0, 1, rei, reiSaveFlag, env, errmsg, r );
169  }
170  else {
171  return evaluateExpression3( ( Node * )params[1], 0, 1, rei, reiSaveFlag, env, errmsg, r );
172  }
173 }
174 
175 Res *smsi_do( Node** params, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
176  switch ( getNodeType( params[0] ) ) {
177  case N_ACTIONS:
178  return evaluateActions( ( Node * )params[0], NULL, 0, rei, reiSaveFlag, env, errmsg, r );
179  default:
180  return evaluateExpression3( ( Node * )params[0], 0, 1, rei, reiSaveFlag, env, errmsg, r );
181  }
182 
183 }
184 Res *smsi_letExec( Node** params, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
185  Res *res = evaluateExpression3( params[1], 0, 1, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, r );
186  if ( getNodeType( res ) == N_ERROR ) {
187  return res;
188  }
189  Env *nEnv = newEnv( newHashTable2( 100, r ), env, NULL, r );
190  Res *pres = matchPattern( params[0], res, nEnv, rei, reiSaveFlag, errmsg, r );
191  if ( getNodeType( pres ) == N_ERROR ) {
192  /*deleteEnv(nEnv, 1); */
193  return pres;
194  }
195  /* printTree(params[2], 0); */
196  res = evaluateExpression3( params[2], 0, 1, rei, reiSaveFlag, nEnv, errmsg, r );
197  /* deleteEnv(nEnv, 1); */
198  return res;
199 }
200 Res *smsi_matchExec( Node** params, int n, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
201  Res *res = evaluateExpression3( params[0], 0, 1, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, r );
202  if ( getNodeType( res ) == N_ERROR ) {
203  return res;
204  }
205  int i;
206  for ( i = 1; i < n; i++ ) {
207  Env *nEnv = newEnv( newHashTable2( 100, r ), env, NULL, r );
208  Res *pres = matchPattern( params[i]->subtrees[0], res, nEnv, rei, reiSaveFlag, errmsg, r );
209  if ( getNodeType( pres ) == N_ERROR ) {
210  /*deleteEnv(nEnv, 1); */
212  continue;
213  }
214  res = evaluateExpression3( params[i]->subtrees[1], 0, 0, rei, reiSaveFlag, nEnv, errmsg, r );
215  /*deleteEnv(nEnv, 1); */
216  return res;
217  }
218  generateAndAddErrMsg( "pattern not matched", node, RE_PATTERN_NOT_MATCHED, errmsg );
219  return newErrorRes( r, RE_PATTERN_NOT_MATCHED );
220 }
221 
222 
223 Res *smsi_whileExec( Node** params, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
224 
225  Res *cond, *res;
226  GC_BEGIN
227  while ( 1 ) {
228 
229  cond = evaluateExpression3( ( Node * )params[0], 0, 1, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, GC_REGION );
230  if ( getNodeType( cond ) == N_ERROR ) {
231  res = cond;
232  break;
233  }
234  if ( RES_BOOL_VAL( cond ) == 0 ) {
235  res = newIntRes( r, 0 );
236  break;
237  }
238  res = evaluateActions( ( Node * )params[1], ( Node * )params[2], 0, rei, reiSaveFlag, env, errmsg, GC_REGION );
239  if ( getNodeType( res ) == N_ERROR ) {
240  break;
241  }
242  else if ( TYPE( res ) == T_BREAK ) {
243  res = newIntRes( r, 0 );
244  break;
245  }
246  else if ( TYPE( res ) == T_SUCCESS ) {
247  break;
248  }
249  GC_ON( env );
250 
251  }
252  cpEnv( env, r );
253  res = cpRes( res, r );
254  GC_END
255  return res;
256 
257 }
258 
259 Res *smsi_forExec( Node** params, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
260 
261  Res *init, *cond, *res = NULL, *step;
262  Region* rnew = make_region( 0, NULL );
263  init = evaluateExpression3( ( Node * )params[0], 0, 1, rei, reiSaveFlag | DISCARD_EXPRESSION_RESULT, env, errmsg, rnew );
264  if ( getNodeType( init ) == N_ERROR ) {
265  res = init;
266  cpEnv( env, r );
267  res = cpRes2( res, rnew, r );
268  region_free( rnew );
269  return res;
270  }
271  GC_BEGIN
272  while ( 1 ) {
273 
274  cond = evaluateExpression3( ( Node * )params[1], 0, 1, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, GC_REGION );
275  if ( getNodeType( cond ) == N_ERROR ) {
276  res = cond;
277  break;
278  }
279  if ( RES_BOOL_VAL( cond ) == 0 ) {
280  res = newIntRes( r, 0 );
281  break;
282  }
283  res = evaluateActions( ( Node * )params[3], ( Node * )params[4], 0, rei, reiSaveFlag, env, errmsg, GC_REGION );
284  if ( getNodeType( res ) == N_ERROR ) {
285  break;
286  }
287  else if ( TYPE( res ) == T_BREAK ) {
288  res =
289  newIntRes( r, 0 );
290  break;
291  }
292  else if ( TYPE( res ) == T_SUCCESS ) {
293  break;
294  }
295  step = evaluateExpression3( ( Node * )params[2], 0, 1, rei, reiSaveFlag & DISCARD_EXPRESSION_RESULT, env, errmsg, GC_REGION );
296  if ( getNodeType( step ) == N_ERROR ) {
297  res = step;
298  break;
299  }
300  GC_ON( env );
301  }
302  cpEnv( env, r );
303  res = cpRes( res, r );
304  GC_END
305  region_free( rnew );
306  return res;
307 
308 }
309 
310 Res *smsi_split( Node** params, int, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r );
311 
312 Res *smsi_collection( Node** subtrees, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
313  char *collName = subtrees[0]->text;
314 
315  /* todo need to find a way to free this buffer */
316  collInp_t *collInpCache = ( collInp_t * )malloc( sizeof( collInp_t ) );
317  memset( collInpCache, 0, sizeof( collInp_t ) );
318  rstrcpy( collInpCache->collName, collName, MAX_NAME_LEN );
319 
320  return newUninterpretedRes( r, CollInp_MS_T, collInpCache, NULL );
321 }
322 
324  if ( TYPE( coll ) == T_STRING ) {
326  }
327  else if ( TYPE( coll ) == T_CONS && strcmp( coll->exprType->text, LIST ) == 0 ) {
328  return RE_ITERABLE_LIST;
329  }
330  else if ( TYPE( coll ) == T_TUPLE && coll->degree == 2 &&
331  TYPE( coll->subtrees[0] ) == T_IRODS && strcmp( coll->subtrees[0]->exprType->text, GenQueryInp_MS_T ) == 0 &&
332  TYPE( coll->subtrees[1] ) == T_IRODS && strcmp( coll->subtrees[1]->exprType->text, GenQueryOut_MS_T ) == 0 ) {
333  return RE_ITERABLE_GEN_QUERY;
334  }
335  else if ( TYPE( coll ) == T_PATH ) {
336  return RE_ITERABLE_COLLECTION;
337  }
338  else if ( TYPE( coll ) == T_IRODS ) {
339  if ( strcmp( coll->exprType->text, StrArray_MS_T ) == 0 ) {
341  }
342  else if ( strcmp( coll->exprType->text, IntArray_MS_T ) == 0 ) {
343  return RE_ITERABLE_INT_ARRAY;
344  }
345  else if ( strcmp( coll->exprType->text, GenQueryOut_MS_T ) == 0 ) {
347  }
348  else if ( strcmp( coll->exprType->text, CollInp_MS_T ) == 0 ) {
349  return RE_ITERABLE_COLLECTION;
350  }
351  else if ( strcmp( coll->exprType->text, KeyValPair_MS_T ) == 0 ) {
353  }
354  else {
355  return RE_NOT_ITERABLE;
356  }
357  }
358  else {
359  return RE_NOT_ITERABLE;
360  }
361 }
362 
363 /* genQuery iterable */
364 typedef struct reIterable_genQuery_data {
365  int i;
366  int cont;
367  int len;
372 
375 
376  itrData->itrSpecData = data;
377 
378  data->genQueryOut = ( genQueryOut_t* )RES_UNINTER_STRUCT( itrData->res->subtrees[1] );
379  data->cont = data->genQueryOut->continueInx > 0;
380  data->len = getCollectionSize( itrData->res->subtrees[1]->exprType->text, data->genQueryOut );
381  data->i = 0;
382 
383  convertResToMsParam( &( data->genQInpParam ), itrData->res->subtrees[0], itrData->errmsg );
384  convertResToMsParam( &( data->genQOutParam ), itrData->res->subtrees[1], itrData->errmsg );
385 
386 }
387 
390  if ( data->i < data->len ) {
391  return 1;
392  }
393  else if ( !data->cont ) {
394  return 0;
395  }
396  else {
397  data->i = 0;
398  msParam_t contInxParam;
399  memset( &contInxParam, 0, sizeof( msParam_t ) );
400  int status = msiGetMoreRows( &( data->genQInpParam ), &( data->genQOutParam ), &contInxParam, itrData->rei );
401  clearMsParam( &contInxParam, 1 );
402  if ( status < 0 ) {
403  if (status != CAT_NO_ROWS_FOUND) {
404  generateAndAddErrMsg( "msiGetMoreRows error", itrData->node, status, itrData->errmsg );
405  itrData->errorRes = newErrorRes( r, status );
406  }
407  return 0;
408  }
410  data->len = getCollectionSize( itrData->res->subtrees[1]->exprType->text, data->genQueryOut );
411  if ( data->len > 0 ) {
412  return 1;
413  }
414  else {
415  return 0;
416  }
417  }
418 }
421  Res *elem = getValueFromCollection( itrData->res->subtrees[1]->exprType->text, data->genQueryOut, data->i++, r );
422  setVariableValue( itrData->varName, elem, itrData->node, itrData->rei, itrData->env, itrData->errmsg, r );
423  Res *res = evaluateActions( itrData->subtrees[2], itrData->subtrees[3], 0, itrData->rei, itrData->reiSaveFlag, itrData->env, itrData->errmsg, r );
425  free( RES_UNINTER_STRUCT( elem ) );
426 
427  if ( getNodeType( res ) == N_ERROR ) {
428  itrData->errorRes = res;
429  return NULL;
430  }
431  return res;
432 
433 }
436  int status = msiCloseGenQuery( &( data->genQInpParam ), &( data->genQOutParam ), itrData->rei );
438  clearMsParam( &( data->genQInpParam ), 0 );
439  clearMsParam( &( data->genQOutParam ), 0 );
440  free( data );
441  if ( status < 0 ) {
442  generateAndAddErrMsg( "msiCloseGenQuery error", itrData->node, status, itrData->errmsg );
443  itrData->errorRes = newErrorRes( r, status );
444  }
445 
446 }
447 
448 /* list iterable */
449 typedef struct reIterable_list_data {
451  int i;
452  int n;
454 
456  ReIterable_list_data *data = ( ReIterable_list_data * ) malloc( sizeof( ReIterable_list_data ) );
457 
458  itrData->itrSpecData = data;
459  data->i = 0;
460  data->n = itrData->res->degree;
461  data->elems = itrData->res->subtrees;
462 }
463 
466  return data->i < data->n;
467 }
468 
471  Res *elem = data->elems[data->i++];
472  setVariableValue( itrData->varName, elem, itrData->node, itrData->rei, itrData->env, itrData->errmsg, r );
473  Res *res = evaluateActions( itrData->subtrees[2], itrData->subtrees[3], 0, itrData->rei, itrData->reiSaveFlag, itrData->env, itrData->errmsg, r );
474  return res;
475 }
476 
479  free( data );
480 }
481 
482 /* intArray strArray genQueryOut iterable */
483 typedef struct reIterable_irods_data {
484  int i;
485  int n;
487 
489  ReIterable_irods_data *data = ( ReIterable_irods_data * ) malloc( sizeof( ReIterable_irods_data ) );
490 
491  itrData->itrSpecData = data;
492  data->i = 0;
493  data->n = getCollectionSize( itrData->res->exprType->text, RES_UNINTER_STRUCT( itrData->res ) );
494 }
495 
498  return data->i < data->n;
499 }
500 
503  Res *elem = getValueFromCollection( itrData->res->exprType->text, RES_UNINTER_STRUCT( itrData->res ), data->i++, r );
504  setVariableValue( itrData->varName, elem, itrData->node, itrData->rei, itrData->env, itrData->errmsg, r );
505  Res *res = evaluateActions( itrData->subtrees[2], itrData->subtrees[3], 0, itrData->rei, itrData->reiSaveFlag, itrData->env, itrData->errmsg, r );
506  return res;
507 }
508 
511  free( data );
512 }
513 
514 /* path/collection iterable */
516  collInp_t *collInp; /* input for rsOpenCollection */
517  collEnt_t *collEnt; /* input for rsReadCollection */
518  int handleInx; /* collection handler */
519  dataObjInp_t *dataObjInp; /* will contain pathnames for each object (one at a time) */
521 
524 
525  itrData->itrSpecData = data;
526 
527  /* Sanity test */
528  if ( itrData->rei == NULL || itrData->rei->rsComm == NULL ) {
529  generateAndAddErrMsg( "msiCollectionSpider: input rei or rsComm is NULL.", itrData->node, SYS_INTERNAL_NULL_INPUT_ERR, itrData->errmsg );
531  return;
532  }
533 
534  Res *collRes;
535  if ( TYPE( itrData->subtrees[1] ) == T_PATH ) {
536  collRes = smsi_collection( &itrData->subtrees[1], 1, itrData->node->subtrees[1], itrData->rei, itrData->reiSaveFlag, itrData->env, itrData->errmsg, r );
537  if ( TYPE( collRes ) == T_ERROR ) {
538  itrData->errorRes = collRes;
539  return;
540  }
541  }
542  else {
543  collRes = itrData->subtrees[1];
544  }
545  data->collInp = ( collInp_t * ) RES_UNINTER_STRUCT( collRes );
546 
547  /* Allocate memory for dataObjInp. Needs to be persistent since will be freed later along with other msParams */
548  data->dataObjInp = ( dataObjInp_t * )malloc( sizeof( dataObjInp_t ) );
549 
550  /* Open collection in recursive mode */
551  data->collInp->flags = RECUR_QUERY_FG;
552  data->handleInx = rsOpenCollection( itrData->rei->rsComm, data->collInp );
553  if ( data->handleInx < 0 ) {
554  char buf[ERR_MSG_LEN];
555  snprintf( buf, ERR_MSG_LEN, "collectionSpider: rsOpenCollection of %s error. status = %d", data->collInp->collName, data->handleInx );
556  generateAndAddErrMsg( buf, itrData->node, data->handleInx, itrData->errmsg );
557  itrData->errorRes = newErrorRes( r, data->handleInx );
558  return;
559  }
560 }
561 
564 
565  collEnt_t *collEnt;
566  while ( ( itrData->rei->status = rsReadCollection( itrData->rei->rsComm, &data->handleInx, &collEnt ) ) >= 0 ) {
567  if ( collEnt != NULL ) {
568  if ( collEnt->objType == DATA_OBJ_T ) {
569  data->collEnt = collEnt;
570  return 1;
571  }
572  else {
573  /* Free collEnt only. Content will be freed by rsCloseCollection() */
574  free( collEnt );
575  }
576  }
577  }
578  return 0;
579 }
582 
583  /* Write our current object's path in dataObjInp, where the inOutStruct in 'objects' points to */
584 
585  memset( data->dataObjInp, 0, sizeof( dataObjInp_t ) );
586  snprintf( data->dataObjInp->objPath, MAX_NAME_LEN, "%s/%s", data->collEnt->collName, data->collEnt->dataName );
587 
588  /* Free collEnt only. Content will be freed by rsCloseCollection() */
589  free( data->collEnt );
590 
591  /* Set var with name varname in the current environment */
592  updateInEnv( itrData->env, itrData->varName, newUninterpretedRes( r, DataObjInp_MS_T, ( void * ) data->dataObjInp, NULL ) );
593 
594  /* Run actionStr on our object */
595  Res *ret = evaluateActions( itrData->subtrees[2], itrData->subtrees[3], 0, itrData->rei, itrData->reiSaveFlag, itrData->env, itrData->errmsg, r );
596 
597  return ret;
598 
599 }
602  free( data->dataObjInp );
603  itrData->rei->status = rsCloseCollection( itrData->rei->rsComm, &data->handleInx );
604  if ( itrData->rei->status < 0 ) {
605  itrData->errorRes = newErrorRes( r, itrData->rei->status );
606  }
607 
608  if ( TYPE( itrData->subtrees[1] ) == T_PATH ) {
609  /* free automatically generated collInp_t struct */
610  free( data->collInp );
611  }
612  else {
613  }
614 }
616  int i;
617  for ( i = 0; i < NUM_RE_ITERABLE; i++ ) {
618  if ( reIterableTable[i].nodeType == nodeType ) {
619  return &( reIterableTable[i].reIterable );
620  }
621  }
622  return NULL;
623 }
624 Res *smsi_forEach2Exec( Node** subtrees, int, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
625  Res *res;
626  ReIterableType ctype = collType( subtrees[1] );
627  ReIterableData *itrData;
628  Res *oldVal;
629  ReIterable* itr;
630  Node *subtreesNew[4];
631  char errbuf[ERR_MSG_LEN];
632 
633  switch ( ctype ) {
634  case RE_NOT_ITERABLE:
635  snprintf( errbuf, ERR_MSG_LEN, "%s is not a collection type.", typeName_Res( subtrees[1] ) );
636  generateAndAddErrMsg( errbuf, node, RE_DYNAMIC_TYPE_ERROR, errmsg );
637  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
639  /* backward compatible mode only */
640  subtreesNew[0] = subtrees[0];
641  Res *paramsr[2];
642  paramsr[0] = subtrees[1];
643  paramsr[1] = newStringRes( r, "," );
644  subtreesNew[1] = smsi_split( paramsr, 2, node, NULL, 0, NULL, errmsg, r );;
645  subtreesNew[2] = subtrees[2];
646  subtreesNew[3] = subtrees[3];
647  subtrees = subtreesNew;
648  ctype = RE_ITERABLE_LIST;
649  /* no break */
650 
657  case RE_ITERABLE_LIST: {
658  res = newIntRes( r, 0 );
659  itrData = newReIterableData( subtrees[0]->text, subtrees[1], subtrees, node, rei, reiSaveFlag, env, errmsg );
660  /* save the old value of variable in the current env */
661  oldVal = ( Res * ) lookupFromHashTable( env->current, itrData->varName );
662  GC_BEGIN
663  itr = getReIterable( ctype );
664  itr->init( itrData, GC_REGION );
665  if ( itrData->errorRes != NULL ) {
666  res = itrData->errorRes;
667  }
668  else {
669  while ( itr->hasNext( itrData, GC_REGION ) ) {
670  if ( itrData->errorRes != NULL ) {
671  res = itrData->errorRes;
672  break;
673  }
674  GC_ON( env );
675 
676  res = itr->next( itrData, GC_REGION );
677 
678  if ( itrData->errorRes != NULL ) {
679  res = itrData->errorRes;
680  break;
681  }
682  if ( getNodeType( res ) == N_ERROR ) {
683  break;
684  }
685  if ( TYPE( res ) == T_BREAK ) {
686  break;
687  }
688  }
689  }
690  itr->finalize( itrData, GC_REGION );
691  if ( itrData->errorRes != NULL ) {
692  res = itrData->errorRes;
693  }
694 
695  cpEnv( env, r );
696  res = cpRes( res, r );
697  GC_END
698  /* restore variable value */
699  if ( oldVal == NULL ) {
700  deleteFromHashTable( env->current, itrData-> varName );
701  }
702  else {
703  updateInEnv( env, itrData->varName, oldVal );
704  }
705  deleteReIterableData( itrData );
706  if ( getNodeType( res ) != N_ERROR ) {
707  res = newIntRes( r, 0 );
708  }
709  return res;
710  }
711  default:
712  snprintf( errbuf, ERR_MSG_LEN, "Error occurred when trying to determine if type %s is iterable.", typeName_Res( subtrees[1] ) );
713  generateAndAddErrMsg( errbuf, node, RE_RUNTIME_ERROR, errmsg );
714  return newErrorRes( r, RE_RUNTIME_ERROR );
715  }
716 
717 }
718 Res *smsi_forEachExec( Node** subtrees, int, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
719  Res *res;
720  char* varName = ( ( Node * )subtrees[0] )->text;
721  Res* orig = evaluateVar3( varName, ( ( Node * )subtrees[0] ), rei, env, errmsg, r );
722  if ( getNodeType( orig ) == N_ERROR || TYPE( orig ) == T_ERROR ) {
723  return orig;
724  }
725 
726  Node *subtreesNew[4];
727  subtreesNew[0] = subtrees[0];
728  subtreesNew[1] = orig;
729  subtreesNew[2] = subtrees[1];
730  subtreesNew[3] = subtrees[2];
731 
732  res = smsi_forEach2Exec( subtreesNew, 4, node, rei, reiSaveFlag, env, errmsg, r );
733  return res;
734 }
735 
736 void columnToString( Node *n, char **queryStr, int *size ) {
737  if ( strlen( n->text ) == 0 ) { /* no attribute function */
738  PRINT( queryStr, size, "%s", n->subtrees[0]->text );
739  }
740  else {
741  PRINT( queryStr, size, "%s", n->text );
742  PRINT( queryStr, size, "(%s)", n->subtrees[0]->text );
743  }
744 
745 
746 }
747 
748 Res *smsi_query( Node** subtrees, int, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
749 #ifdef DEBUG
751 #else
752  char condStr[MAX_NAME_LEN];
753  char errmsgBuf[ERR_MSG_LEN];
754  int i, k;
755  int column_inx, function_inx, att_inx;
756  Res *res0, *res1;
757  NodeType nodeType0, nodeType1;
758  char *value0, *value1;
759  char *attr;
760  char *p;
761  int size;
762 
763  genQueryInp_t *genQueryInp = ( genQueryInp_t* )malloc( sizeof( genQueryInp_t ) );
764  memset( genQueryInp, 0, sizeof( genQueryInp_t ) );
765  genQueryInp->maxRows = MAX_SQL_ROWS;
766 
767  msParam_t genQInpParam;
768  memset( &genQInpParam, 0, sizeof( msParam_t ) );
769  genQInpParam.inOutStruct = ( void* )genQueryInp;
770  genQInpParam.type = strdup( GenQueryInp_MS_T );
771 
772  Node *queNode = subtrees[0];
773  Node *subQueNode;
774 
775  Hashtable *queCondHashTable = newHashTable( 1024 );
776 
777  for ( i = 0; i < queNode->degree; i++ ) {
778  subQueNode = queNode->subtrees[i];
779 
780  switch ( getNodeType( subQueNode ) ) {
781  case N_ATTR:
782 
783  /* Parse function and convert to index directly, getSelVal() returns 1 if string is NULL or empty. */
784  function_inx = getSelVal( subQueNode->text );
785 
786  /* Get column index */
787  column_inx = getAttrIdFromAttrName( subQueNode->subtrees[0]->text );
788 
789  /* Error? */
790  if ( column_inx < 0 ) {
791  snprintf( errmsgBuf, ERR_MSG_LEN, "Unable to get valid ICAT column index for %s.", subQueNode->subtrees[0]->text );
792  generateAndAddErrMsg( errmsgBuf, subQueNode->subtrees[0], RE_DYNAMIC_TYPE_ERROR, errmsg );
793  deleteHashTable( queCondHashTable, nop );
794  freeGenQueryInp( &genQueryInp );
795  clearMsParam( &genQInpParam, 0 );
796  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
797  }
798 
799  /* Add column and function to genQueryInput */
800  addInxIval( &genQueryInp->selectInp, column_inx, function_inx );
801 
802  break;
804 
805  attr = subQueNode->subtrees[0]->subtrees[0]->text;
806  if ( lookupFromHashTable( queCondHashTable, attr ) != NULL ) {
807  deleteHashTable( queCondHashTable, nop );
808  snprintf( errmsgBuf, ERR_MSG_LEN, "Unsupported gen query format: multiple query conditions on one attribute %s.", attr );
809  generateAndAddErrMsg( errmsgBuf, subQueNode, RE_DYNAMIC_TYPE_ERROR, errmsg );
810  freeGenQueryInp( &genQueryInp );
811  clearMsParam( &genQInpParam, 0 );
812  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
813  }
814  insertIntoHashTable( queCondHashTable, attr, attr );
815 
816  /* Get attribute index */
817  att_inx = getAttrIdFromAttrName( attr );
818 
819  /* Error? */
820  if ( att_inx < 0 ) {
821  snprintf( errmsgBuf, ERR_MSG_LEN, "Unable to get valid ICAT column index for %s.", subQueNode->subtrees[0]->text );
822  generateAndAddErrMsg( errmsgBuf, subQueNode->subtrees[0], RE_DYNAMIC_TYPE_ERROR, errmsg );
823  deleteHashTable( queCondHashTable, nop );
824  freeGenQueryInp( &genQueryInp );
825  clearMsParam( &genQInpParam, 0 );
826  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
827  }
828 
829  p = condStr;
830  size = MAX_NAME_LEN;
831 
832  for ( k = 1; k < subQueNode->degree; k++ ) {
833 
834  Node* node = subQueNode->subtrees[k];
835 
836  /* Make the condition */
837  res0 = evaluateExpression3( node->subtrees[0], 0, 0, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, r );
838  if ( getNodeType( res0 ) == N_ERROR ) {
839  deleteHashTable( queCondHashTable, nop );
840  freeGenQueryInp( &genQueryInp );
841  clearMsParam( &genQInpParam, 0 );
842  return res0;
843  }
844  nodeType0 = ( NodeType ) TYPE( res0 );
845  if ( nodeType0 != T_DOUBLE && nodeType0 != T_INT && nodeType0 != T_STRING ) {
846  generateAndAddErrMsg( "dynamic type error", node->subtrees[0], RE_DYNAMIC_TYPE_ERROR, errmsg );
847  deleteHashTable( queCondHashTable, nop );
848  freeGenQueryInp( &genQueryInp );
849  clearMsParam( &genQInpParam, 0 );
850  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
851  }
852  value0 = convertResToString( res0 );
853  PRINT( &p, &size, "%s", node->text );
854  if ( nodeType0 == T_STRING ) {
855  PRINT( &p, &size, " '%s'", value0 );
856  }
857  else {
858  PRINT( &p, &size, " %s", value0 );
859  }
860  free( value0 );
861 
862  if ( strcmp( node->text, "between" ) == 0 ) {
863  res1 = evaluateExpression3( node->subtrees[1], 0, 0, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, r );
864  if ( getNodeType( res1 ) == N_ERROR ) {
865  deleteHashTable( queCondHashTable, nop );
866  freeGenQueryInp( &genQueryInp );
867  clearMsParam( &genQInpParam, 0 );
868  return res1;
869  }
870  nodeType1 = ( NodeType ) TYPE( res1 );
871  if ( ( ( nodeType0 == T_DOUBLE || nodeType0 == T_INT ) && nodeType1 != T_DOUBLE && nodeType1 != T_INT ) || ( nodeType0 == T_STRING && nodeType1 != T_STRING ) ) {
872  generateAndAddErrMsg( "dynamic type error", node->subtrees[1], RE_DYNAMIC_TYPE_ERROR, errmsg );
873  deleteHashTable( queCondHashTable, nop );
874  freeGenQueryInp( &genQueryInp );
875  clearMsParam( &genQInpParam, 0 );
876  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
877  }
878  value1 = convertResToString( res1 );
879  if ( nodeType0 == T_STRING ) {
880  PRINT( &p, &size, " '%s'", value1 );
881  }
882  else {
883  PRINT( &p, &size, " %s", value1 );
884  }
885  free( value1 );
886  }
887  if ( k < subQueNode->degree - 1 ) {
888  PRINT( &p, &size, " %s ", subQueNode->text );
889  }
890 
891  }
892  /* Add condition to genQueryInput */
893  addInxVal( &genQueryInp->sqlCondInp, att_inx, condStr ); /* condStr gets strdup'ed */
894  break;
895  default:
896  generateAndAddErrMsg( "unsupported node type", subQueNode, RE_DYNAMIC_TYPE_ERROR, errmsg );
897  deleteHashTable( queCondHashTable, nop );
898  freeGenQueryInp( &genQueryInp );
899  clearMsParam( &genQInpParam, 0 );
900  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
901  }
902  }
903 
904  deleteHashTable( queCondHashTable, nop );
905 
906  Region* rNew = make_region( 0, NULL );
907  msParam_t genQOutParam;
908  memset( &genQOutParam, 0, sizeof( msParam_t ) );
909  int status = msiExecGenQuery( &genQInpParam, &genQOutParam, rei );
910  if ( status < 0 ) {
911  region_free( rNew );
912  freeGenQueryInp(&genQueryInp);
913  clearMsParam(&genQInpParam, 0);
914  if (genQOutParam.inOutStruct) {
915  freeGenQueryOut((genQueryOut_t **) &genQOutParam.inOutStruct);
916  }
917  clearMsParam(&genQOutParam, 0);
918  generateAndAddErrMsg( "msiExecGenQuery error", node, status, errmsg );
919  return newErrorRes( r, status );
920  }
921  Res *res = newRes( r );
922  convertMsParamToResAndFreeNonIRODSType( &genQInpParam, res, r );
923  clearMsParam(&genQInpParam, 0);
924  Res *res2 = newRes( r );
925  convertMsParamToResAndFreeNonIRODSType( &genQOutParam, res2, r );
926  clearMsParam(&genQOutParam, 0);
927  region_free( rNew );
928 
929  Res **comps = ( Res ** ) region_alloc( r, sizeof( Res * ) * 2 );
930  comps[0] = res;
931  comps[1] = res2;
932 
933  return newTupleRes( 2, comps, r );
934 #endif
935 }
936 Res *smsi_break( Node**, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region * r ) {
937 
938  Res * res = newRes( r );
939  res->exprType = newSimpType( T_BREAK, r );
940  return res;
941 }
942 Res *smsi_succeed( Node**, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
943 
944  Res * res = newRes( r );
945  res->exprType = newSimpType( T_SUCCESS, r );
946  return res;
947 }
948 Res *smsi_fail( Node** subtrees, int n, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
949 
950  Res * res = newErrorRes( r, n == 0 ? FAIL_ACTION_ENCOUNTERED_ERR : RES_INT_VAL( subtrees[0] ) );
951  char *msg = ( n == 0 || n == 1 ) ? ( char * ) "fail action encountered" : subtrees[1]->text;
952  generateAndAddErrMsg( msg, node, RES_ERR_CODE( res ), errmsg );
953  return res;
954 }
955 
956 
957 Res *smsi_assign( Node** subtrees, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
958 
959  /* An smsi shares the same env as the enclosing rule. */
960  /* Therefore, our modification to the env is reflected to the enclosing rule automatically. */
961  Res *val = evaluateExpression3( ( Node * )subtrees[1], 0, 1, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, r );
962  if ( getNodeType( val ) == N_ERROR ) {
963  return val;
964  }
965  Res *ret = matchPattern( subtrees[0], val, env, rei, reiSaveFlag, errmsg, r );
966 
967  return ret;
968 }
969 
985 Res *smsi_getValByKey( Node** params, int, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
986  char errbuf[ERR_MSG_LEN];
987  keyValPair_t *kvp = ( keyValPair_t * ) RES_UNINTER_STRUCT( params[0] );
988  char *key = NULL;
989  Res *res;
990  if ( getNodeType( params[1] ) == N_APPLICATION && N_APP_ARITY( params[1] ) == 0 ) {
991  key = N_APP_FUNC( params[1] )->text;
992  }
993  else {
994  res = evaluateExpression3( params[1], 0, 1, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, r );
995  if ( TYPE( res ) != T_STRING ) {
996  snprintf( errbuf, ERR_MSG_LEN, "malformatted key" );
997  generateAndAddErrMsg( errbuf, params[1], UNMATCHED_KEY_OR_INDEX, errmsg );
998  return newErrorRes( r, UNMATCHED_KEY_OR_INDEX );
999  }
1000  else {
1001  key = res->text;
1002  }
1003  }
1004 
1005  int i;
1006  for ( i = 0; i < kvp->len; i++ ) {
1007  if ( strcmp( kvp->keyWord[i], key ) == 0 ) {
1008  return newStringRes( r, kvp->value[i] );
1009  }
1010  }
1011  snprintf( errbuf, ERR_MSG_LEN, "unmatched key %s", key );
1012  generateAndAddErrMsg( errbuf, node, UNMATCHED_KEY_OR_INDEX, errmsg );
1013  return newErrorRes( r, UNMATCHED_KEY_OR_INDEX );
1014 }
1016  char buf[1024];
1018  Res *res = newStringRes( r, buf );
1019  return res;
1020 }
1023  int i;
1024  for ( i = 0; i < ruleEngineConfig.coreRuleSet->len; i++ ) {
1026  }
1027  return coll;
1028 }
1031  int i;
1032  for ( i = 0; i < ruleEngineConfig.appRuleSet->len; i++ ) {
1034  }
1035  return coll;
1036 }
1039  int i;
1040  for ( i = 0; i < ruleEngineConfig.extRuleSet->len; i++ ) {
1042  }
1043  return coll;
1044 }
1045 Res *smsi_true( Node**, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1046  return newBoolRes( r, 1 );
1047 }
1048 Res *smsi_false( Node**, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1049  return newBoolRes( r, 0 );
1050 }
1051 
1052 Res *smsi_max( Node** params, int n, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1053  int init = 0;
1054  double max = 0;
1055  int i;
1056  for ( i = 0; i < n; i++ ) {
1057  double x = params[i]->dval;
1058  if ( init == 0 ) {
1059  max = x;
1060  init = 1;
1061  }
1062  else {
1063  max = x > max ? x : max;
1064  }
1065  }
1066  Res *res = newDoubleRes( r, max );
1067  return res;
1068 }
1069 Res *smsi_min( Node** params, int n, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1070  int init = 0;
1071  double min = 0;
1072  int i;
1073  for ( i = 0; i < n; i++ ) {
1074  double x = params[i]->dval;
1075  if ( init == 0 ) {
1076  min = x;
1077  init = 1;
1078  }
1079  else {
1080  min = x < min ? x : min;
1081  }
1082  }
1083  Res *res = newDoubleRes( r, min );
1084  return res;
1085 }
1086 Res *smsi_average( Node** params, int n, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1087  double sum = 0;
1088  int i;
1089  for ( i = 0; i < n; i++ ) {
1090  double x = params[i]->dval;
1091  sum += x;
1092  }
1093  Res *res = newDoubleRes( r, sum / n );
1094  return res;
1095 }
1096 Res *smsi_hd( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1097  if ( params[0]->degree > 0 ) {
1098  return params[0]->subtrees[0];
1099  }
1100  else {
1101  generateAndAddErrMsg( "error: hd: empty list", node, RE_RUNTIME_ERROR, errmsg );
1102  return newErrorRes( r, RE_RUNTIME_ERROR );
1103  }
1104 }
1105 Res *smsi_tl( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1106  if ( params[0]->degree > 0 ) {
1107  Res *res = newRes( r );
1108  ExprType *elemType = T_CONS_TYPE_ARG( ( ( Res * )params[0] )->exprType, 0 );
1109  /* allocate memory for elements */
1110  res->exprType = newCollType( elemType, r );
1111  res->degree = params[0]->degree - 1;
1112  res->subtrees = ( Res ** ) region_alloc( r, sizeof( Res * ) * res->degree );
1113  int i;
1114  for ( i = 0; i < res->degree; i++ ) {
1115  res->subtrees[i] = params[0]->subtrees[i + 1];
1116  }
1117  return res;
1118  }
1119  else {
1120  generateAndAddErrMsg( "error: tl: empty list", node, RE_RUNTIME_ERROR, errmsg );
1121  return newErrorRes( r, RE_RUNTIME_ERROR );
1122  }
1123 }
1124 Res *smsi_cons( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1125  Res *res = newRes( r );
1126  ExprType *elemType = params[0]->exprType;
1127  /* allocate memory for elements */
1128  res->exprType = newCollType( elemType, r );
1129  res->degree = params[1]->degree + 1;
1130  res->subtrees = ( Res ** ) region_alloc( r, sizeof( Res * ) * res->degree );
1131  int i;
1132  res->subtrees[0] = params[0];
1133  for ( i = 1; i < res->degree; i++ ) {
1134  res->subtrees[i] = params[1]->subtrees[i - 1];
1135  }
1136  return res;
1137 }
1138 Res *smsi_setelem( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1139  Res *res = newRes( r );
1140  Res *coll = params[0];
1141  Res *indexRes = params[1];
1142  Res *val = params[2];
1143  ExprType *elemType = coll->exprType->subtrees[0];
1144  int index = RES_INT_VAL( indexRes );
1145  if ( 0 > index || index >= coll->degree ) {
1146  char errbuf[ERR_MSG_LEN];
1147  snprintf( errbuf, ERR_MSG_LEN, "setelem: index out of bound %d", index );
1148  generateAndAddErrMsg( errbuf, node, RE_RUNTIME_ERROR, errmsg );
1149  return newErrorRes( r, RE_RUNTIME_ERROR );
1150  }
1151 
1152  /* allocate memory for elements */
1153  res->exprType = newCollType( elemType, r );
1154  res->degree = coll->degree;
1155  res->subtrees = ( Res ** ) region_alloc( r, sizeof( Res * ) * res->degree );
1156  memcpy( res->subtrees, coll->subtrees, sizeof( Res * )*res->degree );
1157  res->subtrees[index] = val;
1158  return res;
1159 }
1160 Res *smsi_list( Node** params, int n, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1161  Res *res = newRes( r );
1162  ExprType *elemType =
1163  n == 0 ? newSimpType( T_UNSPECED, r ) : params[0]->exprType;
1164  /* allocate memory for elements */
1165  res->exprType = newCollType( elemType, r );
1166  res->degree = n;
1167  res->subtrees = ( Res ** ) region_alloc( r, sizeof( Res * ) * n );
1168  int i;
1169  for ( i = 0; i < n; i++ ) {
1170  res->subtrees[i] = params[i];
1171  }
1172  return res;
1173 }
1174 Res *smsi_tuple( Node** params, int n, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1175  Res *res = newRes( r );
1176  /* allocate memory for element types */
1177  ExprType **elemTypes = ( ExprType ** )region_alloc( r, n * sizeof( ExprType * ) );
1178  int i;
1179  for ( i = 0; i < n; i++ ) {
1180  elemTypes[i] = params[i]->exprType;
1181  }
1182  res->exprType = newConsType( n, cpStringExt( TUPLE, r ), elemTypes, r );
1183  res->degree = n;
1184  res->text = cpStringExt( TUPLE, r );
1185  /* allocate memory for elements */
1186  res->subtrees = ( Res ** ) region_alloc( r, sizeof( Res * ) * n );
1187  for ( i = 0; i < n; i++ ) {
1188  res->subtrees[i] = params[i];
1189  }
1190  return res;
1191 }
1192 Res *smsi_elem( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1193  char errbuf[ERR_MSG_LEN];
1194  int index = RES_INT_VAL( params[1] );
1195  if ( TYPE( params[0] ) == T_CONS ) {
1196  if ( index < 0 || index >= params[0]->degree ) {
1197  snprintf( errbuf, ERR_MSG_LEN, "error: index out of range %d.", index );
1198  generateAndAddErrMsg( errbuf, node, RE_RUNTIME_ERROR, errmsg );
1199  return newErrorRes( r, RE_RUNTIME_ERROR );
1200  }
1201  Res *res = params[0]->subtrees[index];
1202  return res;
1203  }
1204  else {
1205  if ( index < 0 || index >= getCollectionSize( params[0]->exprType->text,
1206  RES_UNINTER_STRUCT( params[0] ) ) ) {
1207  snprintf( errbuf, ERR_MSG_LEN, "error: index out of range %d. %s", index, ( ( Res * )params[0] )->exprType->text );
1208  generateAndAddErrMsg( errbuf, node, RE_RUNTIME_ERROR, errmsg );
1209  return newErrorRes( r, RE_RUNTIME_ERROR );
1210  }
1211  Res *res2 = getValueFromCollection( params[0]->exprType->text,
1212  RES_UNINTER_STRUCT( params[0] ),
1213  index, r );
1214 
1215  return res2;
1216  }
1217 }
1218 Res *smsi_size( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1219  Res * res = newRes( r );
1220  res->exprType = newSimpType( T_INT, r );
1221  if ( TYPE( params[0] ) == T_CONS ) {
1222  RES_INT_VAL_LVAL( res ) = params[0]->degree;
1223  }
1224  else {
1225  RES_INT_VAL_LVAL( res ) = getCollectionSize( params[0]->exprType->text,
1226  RES_UNINTER_STRUCT( params[0] ) );
1227  }
1228  return res;
1229 }
1230 Res *smsi_datetime( Node** params, int n, Node*, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1231  char errbuf[ERR_MSG_LEN];
1232  Res *res = newRes( r );
1233  Res* timestr = params[0];
1234  char* format;
1235  if ( TYPE( params[0] ) == T_STRING && ( n == 1 ||
1236  ( n == 2 && TYPE( params[1] ) == T_STRING ) ) ) {
1237  if ( n == 2 ) {
1238  format = params[1]->text;
1239  }
1240  else {
1241  format = "";
1242  }
1243  strttime( timestr->text, format, &( RES_TIME_VAL( res ) ) );
1244  res->exprType = newSimpType( T_DATETIME, r );
1245  }
1246  else if ( n == 1 && ( TYPE( params[0] ) == T_DOUBLE || TYPE( params[0] ) == T_INT ) ) {
1247  if ( TYPE( params[0] ) == T_DOUBLE ) {
1248  RES_TIME_VAL( res ) = ( long ) RES_DOUBLE_VAL( timestr );
1249  }
1250  else {
1251  RES_TIME_VAL( res ) = ( long ) RES_INT_VAL( timestr );
1252  }
1253  res->exprType = newSimpType( T_DATETIME, r );
1254  }
1255  else { /* error not a string */
1257  snprintf( errbuf, ERR_MSG_LEN, "error: unsupported operator or type. can not apply datetime to type (%s[,%s]).", typeName_Res( ( Res * )params[0] ), n == 2 ? typeName_Res( ( Res * )params[1] ) : "null" );
1258  addRErrorMsg( errmsg, RE_UNSUPPORTED_OP_OR_TYPE, errbuf );
1259  }
1260  return res;
1261 }
1262 
1263 Res *smsi_time( Node**, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1264  time_t t;
1265  time( &t );
1266  Res*res = newDatetimeRes( r, t );
1267  return res;
1268 }
1269 Res *smsi_timestr( Node** params, int n, Node*, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1270  char errbuf[ERR_MSG_LEN];
1271  Res *res = newRes( r );
1272  Res* dtime = params[0];
1273  char* format;
1274  if ( TYPE( params[0] ) != T_DATETIME ||
1275  ( n == 2 && TYPE( params[1] ) != T_STRING ) ) {
1277  snprintf( errbuf, ERR_MSG_LEN, "error: unsupported operator or type. can not apply datetime to type (%s[,%s]).", typeName_Res( ( Res * )params[0] ), n == 2 ? typeName_Res( ( Res * )params[1] ) : "null" );
1278  addRErrorMsg( errmsg, RE_UNSUPPORTED_OP_OR_TYPE, errbuf );
1279  }
1280  else {
1281  if ( n == 2 ) {
1282  format = params[1]->text;
1283  }
1284  else {
1285  format = "";
1286  }
1287  char buf[1024];
1288  ttimestr( buf, 1024 - 1, format, &RES_TIME_VAL( dtime ) );
1289  res = newStringRes( r, buf );
1290  }
1291  return res;
1292 }
1293 Res *smsi_type( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1294  Res *val = params[0], *res;
1295  char typeName[128];
1296  typeToString( val->exprType, NULL, typeName, 128 );
1297  res = newStringRes( r, typeName );
1298  return res;
1299 }
1300 Res *smsi_arity( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1301  Res *val = params[0];
1302  RuleIndexListNode *ruleInxLstNode;
1303  if ( findNextRule2( val->text, 0, &ruleInxLstNode ) < 0 ) {
1304  return newErrorRes( r, RE_RUNTIME_ERROR );
1305  }
1306  int ri;
1307  if ( ruleInxLstNode->secondaryIndex ) {
1308  return newErrorRes( r, RE_RUNTIME_ERROR );
1309  }
1310  else {
1311  ri = ruleInxLstNode->ruleIndex;
1312  }
1313  RuleDesc *rd = getRuleDesc( ri );
1314  return newIntRes( r, RULE_NODE_NUM_PARAMS( rd->node ) );
1315 }
1316 Res *smsi_str( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1317  Res *val = params[0], *res;
1318  if ( TYPE( val ) == T_INT
1319  || TYPE( val ) == T_DOUBLE
1320  || TYPE( val ) == T_BOOL
1321  || TYPE( val ) == T_CONS
1322  || TYPE( val ) == T_STRING
1323  || TYPE( val ) == T_PATH
1324  || TYPE( val ) == T_DATETIME ) {
1325  char *buf = convertResToString( val );
1326  if ( buf != NULL ) {
1327  res = newStringRes( r, buf );
1328  free( buf );
1329  }
1330  else {
1332  char errbuf[ERR_MSG_LEN];
1333  snprintf( errbuf, ERR_MSG_LEN, "error: converting value of type %s to string.", typeName_Res( val ) );
1335 
1336  }
1337  }
1338  else if ( TYPE( val ) == T_IRODS && strcmp( val->exprType->text, BUF_LEN_MS_T ) == 0 ) {
1339  bytesBuf_t *buf = ( bytesBuf_t * ) RES_UNINTER_BUFFER( val );
1340  int len = buf->len;
1341  int i;
1342  for ( i = 0; i < len; i++ ) {
1343  if ( ( ( char * ) buf->buf )[i] == '\0' ) {
1344  return newStringRes( r, ( char * ) buf->buf );
1345  }
1346  }
1347  char *tmp = ( char * )malloc( len + 1 );
1348  memcpy( tmp, buf->buf, len );
1349  tmp[len] = '\0';
1350  res = newStringRes( r, tmp );
1351  free( tmp );
1352  }
1353  else if ( TYPE( val ) == T_IRODS && strcmp( val->exprType->text, KeyValPair_MS_T ) == 0 ) {
1354  int size = 1024;
1355  char *buf = ( char * ) malloc( size );
1356  buf[0] = '\0';
1357  keyValPair_t *kvp = ( keyValPair_t * ) RES_UNINTER_STRUCT( val );
1358  int i;
1359  int kl;
1360  int vl;
1361  for ( i = 0; i < kvp->len; i++ ) {
1362  kl = strlen( kvp->keyWord[i] );
1363  vl = strlen( kvp->value[i] );
1364  int diff = strlen( buf );
1365  if ( diff + kl + 1 + vl + ( i == 0 ? 0 : 4 ) >= size ) {
1366  size *= 2;
1367  if ( char * tmp = ( char * ) realloc( buf, size ) ) {
1368  buf = tmp;
1369  }
1370  else {
1371  break;
1372  }
1373  }
1374  snprintf( buf + diff, size - diff, "%s%s=%s", i == 0 ? "" : "++++", kvp->keyWord[i], kvp->value[i] );
1375  }
1376  res = newStringRes( r, buf );
1377  free( buf );
1378  }
1379  else {
1381  char errbuf[ERR_MSG_LEN];
1382  snprintf( errbuf, ERR_MSG_LEN, "error: unsupported type. can not convert %s to string.", typeName_Res( val ) );
1384  }
1385  return res;
1386 }
1387 
1388 Res *smsi_double( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1389  char errbuf[ERR_MSG_LEN];
1390  Res *val = params[0], *res = newRes( r );
1391  if ( TYPE( val ) == T_STRING ) {
1392  res->exprType = newSimpType( T_DOUBLE, r );
1393  RES_DOUBLE_VAL_LVAL( res ) = atof( val->text );
1394  }
1395  else if ( TYPE( val ) == T_DATETIME ) {
1396  res->exprType = newSimpType( T_DOUBLE, r );
1397  RES_DOUBLE_VAL_LVAL( res ) = ( double )RES_TIME_VAL( val );
1398  }
1399  else if ( TYPE( val ) == T_DOUBLE ) {
1400  res = val;
1401  }
1402  else {
1404  snprintf( errbuf, ERR_MSG_LEN, "error: unsupported operator or type. can not convert %s to double.", typeName_Res( val ) );
1406  }
1407  return res;
1408 }
1409 Res *smsi_int( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1410  char errbuf[ERR_MSG_LEN];
1411  Res *val = params[0], *res = newRes( r );
1412  if ( TYPE( val ) == T_STRING ) {
1413  res->exprType = newSimpType( T_INT, r );
1414  RES_INT_VAL_LVAL( res ) = atoi( val->text );
1415  }
1416  else if ( TYPE( val ) == T_DOUBLE ) {
1417  res->exprType = newSimpType( T_INT, r );
1418  RES_INT_VAL_LVAL( res ) = ( int )RES_DOUBLE_VAL( val );
1419  }
1420  else if ( TYPE( val ) == T_INT ) {
1421  res = val;
1422  }
1423  else {
1425  snprintf( errbuf, ERR_MSG_LEN, "error: unsupported operator or type. can not convert %s to integer.", typeName_Res( val ) );
1427  }
1428  return res;
1429 }
1430 Res *smsi_bool( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1431  char errbuf[ERR_MSG_LEN];
1432  Res *val = params[0], *res = newRes( r );
1433  res->exprType = newSimpType( T_BOOL, r );
1434  if ( TYPE( val ) == T_BOOL ) {
1435  res = val;
1436  }
1437  else if ( TYPE( val ) == T_STRING && ( strcmp( val->text, "true" ) == 0 || strcmp( val->text, "1" ) == 0 ) ) {
1438  RES_BOOL_VAL_LVAL( res ) = 1;
1439  }
1440  else if ( TYPE( val ) == T_STRING && ( strcmp( val->text, "false" ) == 0 || strcmp( val->text, "0" ) == 0 ) ) {
1441  RES_BOOL_VAL_LVAL( res ) = 0;
1442  }
1443  else if ( TYPE( val ) == T_DOUBLE ) {
1444  RES_BOOL_VAL_LVAL( res ) = ( int )RES_DOUBLE_VAL( val ) ? 1 : 0;
1445  }
1446  else if ( TYPE( val ) == T_INT ) {
1447  RES_BOOL_VAL_LVAL( res ) = ( int )RES_INT_VAL( val ) ? 1 : 0;
1448  }
1449  else {
1451  snprintf( errbuf, ERR_MSG_LEN, "error: unsupported operator or type. can not convert %s to boolean.", typeName_Res( val ) );
1453  }
1454  return res;
1455 }
1456 Res *smsi_lmsg( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1457  writeToTmp( "re.log", params[0]->text );
1458  Res *res = newIntRes( r, 0 );
1459  return res;
1460 }
1461 Res *smsi_not( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1462  return newBoolRes( r, !RES_BOOL_VAL( params[0] ) ? 1 : 0 );
1463 
1464 }
1465 Res *smsi_negate( Node** args, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1466  if ( TYPE( args[0] ) == T_INT ) {
1467  return newIntRes( r, -RES_INT_VAL( args[0] ) );
1468  }
1469  else {
1470  return newDoubleRes( r, -RES_DOUBLE_VAL( args[0] ) );
1471  }
1472 }
1473 Res *smsi_abs( Node** args, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1474  if ( TYPE( args[0] ) == T_INT ) {
1475  int val = RES_INT_VAL( args[0] );
1476  return newIntRes( r, ( int )( val < 0 ? -val : val ) );
1477  }
1478  else {
1479  double val = RES_DOUBLE_VAL( args[0] );
1480  return newDoubleRes( r, ( val < 0 ? -val : val ) );
1481  }
1482 }
1483 Res *smsi_exp( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1484  Res **args = ( Res ** )params;
1485  double val = RES_DOUBLE_VAL( args[0] );
1486  return newDoubleRes( r, exp( val ) );
1487 }
1488 Res *smsi_log( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1489  Res **args = ( Res ** )params;
1490  double val = RES_DOUBLE_VAL( args[0] );
1491  return newDoubleRes( r, log( val ) );
1492 
1493 }
1494 Res *smsi_floor( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1495  Res **args = ( Res ** )params;
1496  double val = RES_DOUBLE_VAL( args[0] );
1497  return newDoubleRes( r, floor( val ) );
1498 
1499 }
1500 Res *smsi_ceiling( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1501  Res **args = ( Res ** )params;
1502  double val = RES_DOUBLE_VAL( args[0] );
1503  return newDoubleRes( r, ceil( val ) );
1504 
1505 }
1506 
1507 Res *smsi_and( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1508  Res **args = ( Res ** )params;
1509  return newBoolRes( r, RES_BOOL_VAL( args[0] ) && RES_BOOL_VAL( args[1] ) ? 1 : 0 );
1510 
1511 }
1512 
1513 Res *smsi_or( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1514  Res **args = ( Res ** )params;
1515  return newBoolRes( r, RES_BOOL_VAL( args[0] ) || RES_BOOL_VAL( args[1] ) ? 1 : 0 );
1516 }
1517 
1518 Res *smsi_add( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1519  if ( TYPE( params[0] ) == T_INT ) {
1520  return newIntRes( r, RES_INT_VAL( params[0] ) + RES_INT_VAL( params[1] ) );
1521  }
1522  else {
1523  return newDoubleRes( r, RES_DOUBLE_VAL( params[0] ) + RES_DOUBLE_VAL( params[1] ) );
1524  }
1525 }
1526 Res *smsi_subtract( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1527  if ( TYPE( params[0] ) == T_INT ) {
1528  return newIntRes( r, RES_INT_VAL( params[0] ) - RES_INT_VAL( params[1] ) );
1529  }
1530  else {
1531  return newDoubleRes( r, RES_DOUBLE_VAL( params[0] ) - RES_DOUBLE_VAL( params[1] ) );
1532  }
1533 }
1534 Res *smsi_multiply( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1535  if ( TYPE( params[0] ) == T_INT ) {
1536  return newIntRes( r, RES_INT_VAL( params[0] ) * RES_INT_VAL( params[1] ) );
1537  }
1538  else {
1539  return newDoubleRes( r, RES_DOUBLE_VAL( params[0] ) * RES_DOUBLE_VAL( params[1] ) );
1540  }
1541 }
1542 Res *smsi_divide( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1543  if ( TYPE( params[0] ) == T_INT ) {
1544  if ( RES_INT_VAL( params[1] ) != 0 ) {
1545  return newDoubleRes( r, RES_INT_VAL( params[0] ) / ( double )RES_INT_VAL( params[1] ) );
1546  }
1547  }
1548  else {
1549  if ( RES_DOUBLE_VAL( params[1] ) != 0 ) {
1550  return newDoubleRes( r, RES_DOUBLE_VAL( params[0] ) / RES_DOUBLE_VAL( params[1] ) );
1551  }
1552  }
1553  generateAndAddErrMsg( "division by zero.", node, RE_DIVISION_BY_ZERO, errmsg );
1554  return newErrorRes( r, RE_DIVISION_BY_ZERO );
1555 }
1556 
1557 Res *smsi_modulo( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1558  if ( RES_INT_VAL( params[1] ) != 0 ) {
1559  return newDoubleRes( r, RES_INT_VAL( params[0] ) % RES_INT_VAL( params[1] ) );
1560  }
1561  generateAndAddErrMsg( "division by zero.", node, RE_DIVISION_BY_ZERO, errmsg );
1562  return newErrorRes( r, RE_DIVISION_BY_ZERO );
1563 }
1564 
1565 Res *smsi_power( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1566  return newDoubleRes( r, pow( RES_DOUBLE_VAL( params[0] ), RES_DOUBLE_VAL( params[1] ) ) );
1567 }
1568 Res *smsi_root( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1569  if ( RES_DOUBLE_VAL( params[1] ) != 0 ) {
1570  return newDoubleRes( r, pow( RES_DOUBLE_VAL( params[0] ), 1 / RES_DOUBLE_VAL( params[1] ) ) );
1571  }
1572  generateAndAddErrMsg( "division by zero.", node, RE_DIVISION_BY_ZERO, errmsg );
1573  return newErrorRes( r, RE_DIVISION_BY_ZERO );
1574 }
1575 
1576 Res *smsi_concat( Node** params, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1577  Res **args = ( Res ** )params;
1578  char *newbuf = ( char * )malloc( ( RES_STRING_STR_LEN( args[0] ) + RES_STRING_STR_LEN( args[1] ) + 1 ) * sizeof( char ) );
1579 
1580  strcpy( newbuf, args[0]->text );
1581  strcpy( newbuf + RES_STRING_STR_LEN( args[0] ), args[1]->text );
1582 
1583  Res *res = newStringRes( r, newbuf );
1584  free( newbuf );
1585  return res;
1586  /*}*/
1587 }
1588 
1589 Res *smsi_lt( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1590  switch ( TYPE( params[0] ) ) {
1591  case T_INT:
1592  return newBoolRes( r, RES_INT_VAL( params[0] ) < RES_INT_VAL( params[1] ) ? 1 : 0 );
1593  break;
1594  case T_DOUBLE:
1595  return newBoolRes( r, RES_DOUBLE_VAL( params[0] ) < RES_DOUBLE_VAL( params[1] ) ? 1 : 0 );
1596  break;
1597  case T_DATETIME:
1598  return newBoolRes( r, difftime( RES_TIME_VAL( params[0] ), RES_TIME_VAL( params[1] ) ) < 0 ? 1 : 0 );
1599  break;
1600  case T_STRING:
1601  return newBoolRes( r, strcmp( params[0]->text, params[1]->text ) < 0 ? 1 : 0 );
1602  break;
1603  default:
1604  break;
1605  }
1606  char errbuf[ERR_MSG_LEN], type0[128], type1[128];
1607  snprintf( errbuf, ERR_MSG_LEN, "type error: comparing between %s and %s", typeToString( params[0]->exprType, NULL, type0, 128 ), typeToString( params[1]->exprType, NULL, type1, 128 ) );
1608  generateAndAddErrMsg( errbuf, node, RE_DYNAMIC_TYPE_ERROR, errmsg );
1609  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
1610 
1611 }
1612 Res *smsi_le( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1613  switch ( TYPE( params[0] ) ) {
1614  case T_INT:
1615  return newBoolRes( r, RES_INT_VAL( params[0] ) <= RES_INT_VAL( params[1] ) ? 1 : 0 );
1616  break;
1617  case T_DOUBLE:
1618  return newBoolRes( r, RES_DOUBLE_VAL( params[0] ) <= RES_DOUBLE_VAL( params[1] ) ? 1 : 0 );
1619  break;
1620  case T_DATETIME:
1621  return newBoolRes( r, difftime( RES_TIME_VAL( params[0] ), RES_TIME_VAL( params[1] ) ) <= 0 ? 1 : 0 );
1622  break;
1623  case T_STRING:
1624  return newBoolRes( r, strcmp( params[0]->text, params[1]->text ) <= 0 ? 1 : 0 );
1625  break;
1626  default:
1627  break;
1628  }
1629  char errbuf[ERR_MSG_LEN], type0[128], type1[128];
1630  snprintf( errbuf, ERR_MSG_LEN, "type error: comparing between %s and %s", typeToString( params[0]->exprType, NULL, type0, 128 ), typeToString( params[1]->exprType, NULL, type1, 128 ) );
1631  generateAndAddErrMsg( errbuf, node, RE_DYNAMIC_TYPE_ERROR, errmsg );
1632  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
1633 
1634 }
1635 Res *smsi_gt( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1636  switch ( TYPE( params[0] ) ) {
1637  case T_INT:
1638  return newBoolRes( r, RES_INT_VAL( params[0] ) > RES_INT_VAL( params[1] ) ? 1 : 0 );
1639  break;
1640  case T_DOUBLE:
1641  return newBoolRes( r, RES_DOUBLE_VAL( params[0] ) > RES_DOUBLE_VAL( params[1] ) ? 1 : 0 );
1642  break;
1643  case T_DATETIME:
1644  return newBoolRes( r, difftime( RES_TIME_VAL( params[0] ), RES_TIME_VAL( params[1] ) ) > 0 ? 1 : 0 );
1645  break;
1646  case T_STRING:
1647  return newBoolRes( r, strcmp( params[0]->text, params[1]->text ) > 0 ? 1 : 0 );
1648  break;
1649  default:
1650  break;
1651  }
1652  char errbuf[ERR_MSG_LEN], type0[128], type1[128];
1653  snprintf( errbuf, ERR_MSG_LEN, "type error: comparing between %s and %s", typeToString( params[0]->exprType, NULL, type0, 128 ), typeToString( params[1]->exprType, NULL, type1, 128 ) );
1654  generateAndAddErrMsg( errbuf, node, RE_DYNAMIC_TYPE_ERROR, errmsg );
1655  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
1656 
1657 }
1658 Res *smsi_ge( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1659  switch ( TYPE( params[0] ) ) {
1660  case T_INT:
1661  return newBoolRes( r, RES_INT_VAL( params[0] ) >= RES_INT_VAL( params[1] ) ? 1 : 0 );
1662  break;
1663  case T_DOUBLE:
1664  return newBoolRes( r, RES_DOUBLE_VAL( params[0] ) >= RES_DOUBLE_VAL( params[1] ) ? 1 : 0 );
1665  break;
1666  case T_DATETIME:
1667  return newBoolRes( r, difftime( RES_TIME_VAL( params[0] ), RES_TIME_VAL( params[1] ) ) >= 0 ? 1 : 0 );
1668  break;
1669  case T_STRING:
1670  return newBoolRes( r, strcmp( params[0]->text, params[1]->text ) >= 0 ? 1 : 0 );
1671  break;
1672  default:
1673  break;
1674  }
1675  char errbuf[ERR_MSG_LEN], type0[128], type1[128];
1676  snprintf( errbuf, ERR_MSG_LEN, "type error: comparing between %s and %s", typeToString( params[0]->exprType, NULL, type0, 128 ), typeToString( params[1]->exprType, NULL, type1, 128 ) );
1677  generateAndAddErrMsg( errbuf, node, RE_DYNAMIC_TYPE_ERROR, errmsg );
1678  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
1679 }
1680 Res *smsi_eq( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1681  switch ( TYPE( params[0] ) ) {
1682  case T_BOOL:
1683  return newBoolRes( r, RES_BOOL_VAL( params[0] ) == RES_BOOL_VAL( params[1] ) ? 1 : 0 );
1684  break;
1685  case T_INT:
1686  return newBoolRes( r, RES_INT_VAL( params[0] ) == RES_INT_VAL( params[1] ) ? 1 : 0 );
1687  break;
1688  case T_DOUBLE:
1689  return newBoolRes( r, RES_DOUBLE_VAL( params[0] ) == RES_DOUBLE_VAL( params[1] ) ? 1 : 0 );
1690  break;
1691  case T_DATETIME:
1692  return newBoolRes( r, difftime( RES_TIME_VAL( params[0] ), RES_TIME_VAL( params[1] ) ) == 0 ? 1 : 0 );
1693  break;
1694  case T_STRING:
1695  return newBoolRes( r, strcmp( params[0]->text, params[1]->text ) == 0 ? 1 : 0 );
1696  break;
1697  case T_PATH:
1698  return newBoolRes( r, strcmp( params[0]->text, params[1]->text ) == 0 ? 1 : 0 );
1699  break;
1700  default:
1701  break;
1702  }
1703  char errbuf[ERR_MSG_LEN], type0[128], type1[128];
1704  snprintf( errbuf, ERR_MSG_LEN, "type error: comparing between %s and %s", typeToString( params[0]->exprType, NULL, type0, 128 ), typeToString( params[1]->exprType, NULL, type1, 128 ) );
1705  generateAndAddErrMsg( errbuf, node, RE_DYNAMIC_TYPE_ERROR, errmsg );
1706  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
1707 }
1708 Res *smsi_neq( Node** params, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
1709  switch ( TYPE( params[0] ) ) {
1710  case T_BOOL:
1711  return newBoolRes( r, RES_BOOL_VAL( params[0] ) != RES_BOOL_VAL( params[1] ) ? 1 : 0 );
1712  break;
1713  case T_INT:
1714  return newBoolRes( r, RES_INT_VAL( params[0] ) != RES_INT_VAL( params[1] ) ? 1 : 0 );
1715  break;
1716  case T_DOUBLE:
1717  return newBoolRes( r, RES_DOUBLE_VAL( params[0] ) != RES_DOUBLE_VAL( params[1] ) ? 1 : 0 );
1718  break;
1719  case T_DATETIME:
1720  return newBoolRes( r, difftime( RES_TIME_VAL( params[0] ), RES_TIME_VAL( params[1] ) ) != 0 ? 1 : 0 );
1721  break;
1722  case T_STRING:
1723  return newBoolRes( r, strcmp( params[0]->text, params[1]->text ) != 0 ? 1 : 0 );
1724  break;
1725  case T_PATH:
1726  return newBoolRes( r, strcmp( params[0]->text, params[1]->text ) != 0 ? 1 : 0 );
1727  break;
1728  default:
1729  break;
1730  }
1731  char errbuf[ERR_MSG_LEN], type0[128], type1[128];
1732  snprintf( errbuf, ERR_MSG_LEN, "type error: comparing between %s and %s", typeToString( params[0]->exprType, NULL, type0, 128 ), typeToString( params[1]->exprType, NULL, type1, 128 ) );
1733  generateAndAddErrMsg( errbuf, node, RE_DYNAMIC_TYPE_ERROR, errmsg );
1734  return newErrorRes( r, RE_DYNAMIC_TYPE_ERROR );
1735 }
1736 Res *smsi_like( Node** paramsr, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1737  Res **params = paramsr;
1738  char *pattern;
1739  char *bufstr;
1740  pattern = params[1]->text;
1741  Res *res;
1742 
1743  bufstr = strdup( params[0]->text );
1744  /* make the regexp match whole strings */
1745  char *buf2;
1746  buf2 = wildCardToRegex( pattern );
1747  regex_t regbuf;
1748  regcomp( &regbuf, buf2, REG_EXTENDED );
1749  res = newBoolRes( r, regexec( &regbuf, bufstr, 0, 0, 0 ) == 0 ? 1 : 0 );
1750  regfree( &regbuf );
1751  free( buf2 );
1752  free( bufstr );
1753  return res;
1754 }
1755 Res *smsi_not_like( Node** paramsr, int n, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
1756  Res *res = smsi_like( paramsr, n, node, rei, reiSaveFlag, env, errmsg, r );
1757  if ( TYPE( res ) != N_ERROR ) {
1758  return newBoolRes( r, RES_BOOL_VAL( res ) ? 0 : 1 );
1759  }
1760  return res;
1761 }
1762 Res *smsi_like_regex( Node** paramsr, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
1763  Res **params = paramsr;
1764  char *pattern;
1765  char *bufstr;
1766  pattern = params[1]->text;
1767  Res *res;
1768 
1769  bufstr = strdup( params[0]->text );
1770  /* make the regexp match whole strings */
1771  pattern = matchWholeString( params[1]->text );
1772  regex_t regbuf;
1773  regcomp( &regbuf, pattern, REG_EXTENDED );
1774  res = newBoolRes( r, regexec( &regbuf, bufstr, 0, 0, 0 ) == 0 ? 1 : 0 );
1775  regfree( &regbuf );
1776  free( bufstr );
1777  free( pattern );
1778  return res;
1779 }
1780 Res *smsi_not_like_regex( Node** paramsr, int n, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
1781  Res *res = smsi_like_regex( paramsr, n, node, rei, reiSaveFlag, env, errmsg, r );
1782  if ( TYPE( res ) != N_ERROR ) {
1783  return newBoolRes( r, RES_BOOL_VAL( res ) ? 0 : 1 );
1784  }
1785  return res;
1786 }
1787 
1788 Res *smsi_eval( Node** paramsr, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
1789  Res **params = ( Res ** )paramsr;
1790  /*printf("\neval: %s\n", params[0]->text); */
1791  return eval( params[0]->text, env, rei, reiSaveFlag, errmsg, r );
1792 }
1793 
1794 Res *smsi_evalrule( Node** paramsr, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
1795  Res **params = ( Res ** )paramsr;
1796  /*printf("\neval: %s\n", params[0]->text); */
1797  return newIntRes( r, parseAndComputeRule( params[0]->text, env, rei, reiSaveFlag, errmsg, r ) );
1798 }
1803 Res *smsi_errorcode( Node** paramsr, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
1804  Res *res;
1805  switch ( getNodeType( paramsr[0] ) ) {
1806  case N_ACTIONS:
1807  res = evaluateActions( ( Node * )paramsr[0], ( Node * )paramsr[1], 0, rei, reiSaveFlag, env, errmsg, r );
1808  break;
1809  default:
1810  res = evaluateExpression3( ( Node * )paramsr[0], 0, 1, rei, reiSaveFlag, env, errmsg, r );
1811  break;
1812  }
1813  switch ( getNodeType( res ) ) {
1814  case N_ERROR:
1815  return newIntRes( r, RES_ERR_CODE( res ) );
1816  default:
1817  return newIntRes( r, 0 );
1818  }
1819 }
1820 
1825 Res *smsi_errormsg( Node** paramsr, int, Node*, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
1826  char *errbuf = ( char * )malloc( ERR_MSG_LEN * 1024 * sizeof( char ) );
1827  Res *res;
1828  switch ( getNodeType( paramsr[0] ) ) {
1829  case N_ACTIONS:
1830  res = evaluateActions( ( Node * )paramsr[0], ( Node * )paramsr[1], 0, rei, reiSaveFlag, env, errmsg, r );
1831  paramsr[2] = newStringRes( r, errMsgToString( errmsg, errbuf, ERR_MSG_LEN * 1024 ) );
1832  break;
1833  default:
1834  res = evaluateExpression3( ( Node * )paramsr[0], 0, 1, rei, reiSaveFlag, env, errmsg, r );
1835  paramsr[1] = newStringRes( r, errMsgToString( errmsg, errbuf, ERR_MSG_LEN * 1024 ) );
1836  break;
1837  }
1838  freeRErrorContent( errmsg );
1839  free( errbuf );
1840  switch ( getNodeType( res ) ) {
1841  case N_ERROR:
1842  return newIntRes( r, RES_ERR_CODE( res ) );
1843  default:
1844  return newIntRes( r, 0 );
1845  }
1846 }
1847 
1848 Res *smsi_delayExec( Node** paramsr, int, Node* node, ruleExecInfo_t* rei, int, Env* env, rError_t* errmsg, Region* r ) {
1849  int i;
1850  char actionCall[MAX_ACTION_SIZE];
1851  char recoveryActionCall[MAX_ACTION_SIZE];
1852  char delayCondition[MAX_ACTION_SIZE];
1853 
1854  Res **params = ( Res ** )paramsr;
1855 
1856  rstrcpy( delayCondition, params[0]->text, MAX_ACTION_SIZE );
1857  rstrcpy( actionCall, params[1]->text, MAX_ACTION_SIZE );
1858  rstrcpy( recoveryActionCall, params[2]->text, MAX_ACTION_SIZE );
1859 
1860  msParamArray_t *tmp = rei->msParamArray;
1861  rei->msParamArray = newMsParamArray();
1862 
1863  int ret = convertEnvToMsParamArray( rei->msParamArray, env, errmsg, r );
1864  if ( ret != 0 ) {
1865  generateAndAddErrMsg( "error converting Env to MsParamArray", node, ret, errmsg );
1866  return newErrorRes( r, ret );
1867  }
1868 
1869  i = _delayExec( actionCall, recoveryActionCall, delayCondition, rei );
1870 
1872  rei->msParamArray = tmp;
1873 
1874  if ( i < 0 ) {
1875  return newErrorRes( r, i );
1876  }
1877  else {
1878  return newIntRes( r, i );
1879  }
1880 }
1881 
1882 Res *smsi_remoteExec( Node** paramsr, int, Node* node, ruleExecInfo_t* rei, int, Env* env, rError_t* errmsg, Region* r ) {
1883 #ifdef DEBUG
1885 #else
1886 
1887  int i;
1888  execMyRuleInp_t execMyRuleInp;
1889  msParamArray_t *outParamArray = NULL;
1890  char tmpStr[LONG_NAME_LEN];
1891 
1892  Res **params = ( Res ** )paramsr;
1893 
1894  memset( &execMyRuleInp, 0, sizeof( execMyRuleInp ) );
1895  execMyRuleInp.condInput.len = 0;
1897 
1898  rstrcpy( tmpStr, params[0]->text, LONG_NAME_LEN );
1899  parseHostAddrStr( tmpStr, &execMyRuleInp.addr );
1900 
1901  try {
1902  auto taggedValues = getTaggedValues(params[1]->text);
1903  auto it = taggedValues.find("ZONE");
1904  if ( it != taggedValues.end() ) {
1905  strncpy(execMyRuleInp.addr.zoneName, it->second.front().c_str(), NAME_LEN);
1906  taggedValues.erase(it);
1907  }
1908  } catch ( const irods::exception& e) {
1910  }
1911 
1912  if ( strlen( params[3]->text ) == 0 ) {
1913  snprintf( execMyRuleInp.myRule, META_STR_LEN, "remExec{%s}", params[2]->text );
1914  }
1915  else {
1916  snprintf( execMyRuleInp.myRule, META_STR_LEN, "remExec||%s|%s", params[2]->text, params[3]->text );
1917  }
1918  addKeyVal( &execMyRuleInp.condInput, "execCondition", params[1]->text );
1919 
1920  execMyRuleInp.inpParamArray = newMsParamArray();
1921  int ret = convertEnvToMsParamArray( execMyRuleInp.inpParamArray, env, errmsg, r );
1922  if ( ret != 0 ) {
1923  generateAndAddErrMsg( "error converting Env to MsParamArray", node, ret, errmsg );
1924  return newErrorRes( r, ret );
1925  }
1926 
1927  // Add ruleExecOut to input param and execute rule if the type is set
1928  // Use add here because ruleExecOut is specifically not stored in rei, not env
1929  msParam_t* rule_exec_out{getMsParamByLabel(rei->msParamArray, "ruleExecOut")};
1930  if (rule_exec_out && rule_exec_out->type) {
1931  addMsParamToArray(execMyRuleInp.inpParamArray, rule_exec_out->label, rule_exec_out->type, rule_exec_out->inOutStruct, rule_exec_out->inpOutBuf, 0);
1932  }
1933  i = rsExecMyRule( rei->rsComm, &execMyRuleInp, &outParamArray );
1934 
1935  if (outParamArray) {
1936  // Put ruleExecOut into rei->msParamArray if the type is set
1937  // Use fill rather than add because the label already exists in rei->msParamArray
1938  replMsParam(getMsParamByLabel(outParamArray, "ruleExecOut"), rule_exec_out);
1939  if (rule_exec_out && rule_exec_out->type) {
1940  fillMsParam(getMsParamByLabel(rei->msParamArray, "ruleExecOut"), rule_exec_out->label, rule_exec_out->type, rule_exec_out->inOutStruct, rule_exec_out->inpOutBuf);
1941  }
1942 
1943  // Remove ruleExecOut before storing param array to env
1944  rmMsParamByLabel(outParamArray, "ruleExecOut", 1);
1946  deleteMsParamArray(outParamArray);
1947  }
1948  else {
1949  deleteMsParamArray(execMyRuleInp.inpParamArray);
1950  }
1951 
1952  if ( i < 0 ) {
1953  return newErrorRes( r, i );
1954  }
1955  else {
1956  return newIntRes( r, i );
1957  }
1958 #endif
1959 }
1960 
1961 Res *smsi_writeLine( Node** paramsr, int, Node*, ruleExecInfo_t* rei, int, Env* env, rError_t*, Region* r ) {
1962  char *inString = convertResToString( paramsr[1] );
1963  Res *where = ( Res * )paramsr[0];
1964  char *whereId = where->text;
1965 
1966  if ( strcmp( whereId, "serverLog" ) == 0 ) {
1967  rodsLog( LOG_NOTICE, "writeLine: inString = %s\n", inString );
1968  free( inString );
1969  return newIntRes( r, 0 );
1970  }
1971  int i = _writeString( whereId, inString, rei );
1972 #ifdef DEBUG
1973  printf( "%s\n", inString );
1974 #endif
1975 
1976  free( inString );
1977  if ( i < 0 ) {
1978  return newErrorRes( r, i );
1979  }
1980  i = _writeString( whereId, "\n", rei );
1981 
1982  if ( i < 0 ) {
1983  return newErrorRes( r, i );
1984  }
1985  else {
1986  return newIntRes( r, i );
1987  }
1988 }
1989 Res *smsi_writeString( Node** paramsr, int, Node*, ruleExecInfo_t* rei, int, Env* env, rError_t*, Region* r ) {
1990 
1991  char *inString = convertResToString( paramsr[1] );
1992  Res *where = ( Res * )paramsr[0];
1993  char *whereId = where->text;
1994 
1995  int i = _writeString( whereId, inString, rei );
1996 
1997  free( inString );
1998  if ( i < 0 ) {
1999  return newErrorRes( r, i );
2000  }
2001  else {
2002  return newIntRes( r, i );
2003  }
2004 }
2005 
2006 Res *smsi_triml( Node** paramsr, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
2007  /* if the length of delim is 0, strstr should return str */
2008  Res *strres = ( Res * )paramsr[0];
2009  Res *delimres = ( Res * )paramsr[1];
2010 
2011  char *str = strres->text;
2012  char *delim = delimres->text;
2013 
2014  char *p = strstr( str, delim );
2015  if ( p != NULL ) {
2016  /* found */
2017  return newStringRes( r, p + strlen( delim ) );
2018  }
2019  else {
2020  /* not found return the original string */
2021  return strres;
2022  }
2023 }
2024 Res *smsi_strlen( Node** paramsr, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
2025  Res *strres = ( Res * )paramsr[0];
2026  return newIntRes( r, strlen( strres->text ) );
2027 }
2028 
2029 Res *smsi_substr( Node** paramsr, int, Node* node, ruleExecInfo_t*, int, Env*, rError_t* errmsg, Region* r ) {
2030  Res *strres = ( Res * )paramsr[0];
2031  Res *startres = ( Res * )paramsr[1];
2032  Res *finishres = ( Res * )paramsr[2];
2033 
2034  int len = strlen( strres->text );
2035  int start = RES_INT_VAL( startres );
2036  int finish = RES_INT_VAL( finishres );
2037  if ( start < 0 || start > len || finish < 0 || finish > len || start > finish ) {
2038  generateAndAddErrMsg( "invalid substr index error", node, RE_RUNTIME_ERROR, errmsg );
2039  return newErrorRes( r, RE_RUNTIME_ERROR );
2040 
2041  }
2042 
2043  char *buf = strdup( strres->text + start );
2044  buf[finish - start] = '\0';
2045 
2046  Res *retres = newStringRes( r, buf );
2047  free( buf );
2048  return retres;
2049 }
2050 
2051 Res *smsi_split( Node** paramsr, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
2052  Res *strres = ( Res * )paramsr[0];
2053  Res *delimres = ( Res * )paramsr[1];
2054 
2055  char *buf = strdup( strres->text );
2056  int len = strlen( buf );
2057  int count = 0;
2058  int trim = 1;
2059  int i;
2060  for ( i = 0; i < len; i++ ) {
2061  if ( strchr( delimres->text, buf[i] ) != NULL ) {
2062  i++;
2063  while ( i < len && strchr( delimres->text, buf[i] ) != NULL ) {
2064  i++;
2065  }
2066  if ( !trim && i < len ) {
2067  count++;
2068  }
2069  }
2070  else {
2071  trim = 0;
2072  }
2073  }
2074  if ( !trim ) {
2075  count ++;
2076  }
2077 
2078  Res *coll = newCollRes( count, newSimpType( T_STRING, r ), r );
2079 
2080  int j = 0;
2081  trim = 1;
2082  char *bufStart = buf;
2083  for ( i = 0; i < len; i++ ) {
2084  if ( strchr( delimres->text, buf[i] ) != NULL ) {
2085  buf[i] = '\0';
2086  if ( !trim ) {
2087  coll->subtrees[j++] = newStringRes( r, bufStart );
2088  }
2089  i++;
2090  while ( i < len && strchr( delimres->text, buf[i] ) != NULL ) {
2091  i++;
2092  }
2093  bufStart = buf + i;
2094  }
2095  else {
2096  trim = 0;
2097  }
2098  }
2099  if ( j != count ) {
2100  coll->subtrees[j++] = newStringRes( r, bufStart );
2101  }
2102 
2103  free( buf );
2104  return coll;
2105 
2106 }
2107 
2109  return newUnspecifiedRes( r );
2110 
2111 }
2112 Res *smsi_trimr( Node** paramsr, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
2113  Res *strres = ( Res * )paramsr[0];
2114  Res *delimres = ( Res * )paramsr[1];
2115 
2116  char *str = strres->text;
2117  char *delim = delimres->text;
2118 
2119  if ( strlen( delim ) == 0 ) {
2120  return strres;
2121  }
2122 
2123  char *p = strstr( str, delim );
2124  char *newp = NULL;
2125  while ( p != NULL ) {
2126  newp = p;
2127  p = strstr( p + 1, delim );
2128  }
2129  if ( newp == NULL ) {
2130  /* not found */
2131  return strres;
2132  }
2133  else {
2134  /* found set where newp points to to \0 */
2135  char temp = *newp;
2136  *newp = '\0';
2137 
2138  Res *res = newStringRes( r, str );
2139  /* restore */
2140  *newp = temp;
2141  return res;
2142  }
2143 
2144 }
2145 
2146 Res *smsi_getReLogging( Node** paramsr, int, Node* node, ruleExecInfo_t* rei, int, Env*, rError_t* errmsg, Region* r ) {
2147  int logging;
2148  char *userName = paramsr[0]->text;
2149  int i = readICatUserLogging( userName, &logging, rei->rsComm );
2150  if ( i < 0 ) {
2151  generateAndAddErrMsg( "error reading RE logging settings.", node, i, errmsg );
2152  return newErrorRes( r, i );
2153 
2154  }
2155  return newBoolRes( r, logging );
2156 }
2157 
2158 Res *smsi_setReLogging( Node** paramsr, int, Node* node, ruleExecInfo_t* rei, int, Env*, rError_t* errmsg, Region* r ) {
2159  char *userName = paramsr[0]->text;
2160  int logging = RES_BOOL_VAL( paramsr[1] );
2161 
2162  int i = writeICatUserLogging( userName, logging, rei->rsComm );
2163  if ( i < 0 ) {
2164  generateAndAddErrMsg( "error writing RE logging settings.", node, i, errmsg );
2165  return newErrorRes( r, i );
2166 
2167  }
2168  return newIntRes( r, 0 );
2169 }
2170 
2171 
2172 Res *smsi_getstdout( Node** paramsr, int, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
2173  msParam_t * mP = NULL;
2174  msParamArray_t * inMsParamArray = rei->msParamArray;
2175  execCmdOut_t *out;
2176  if ( ( ( mP = getMsParamByLabel( inMsParamArray, "ruleExecOut" ) ) != NULL ) &&
2177  ( mP->inOutStruct != NULL ) &&
2178  strcmp(mP->type, ExecCmdOut_MS_T) == 0 ) {
2179  out = ( execCmdOut_t* )mP->inOutStruct;
2180  } else {
2181  generateAndAddErrMsg( "ruleExecOut not set", node, RE_RUNTIME_ERROR, errmsg );
2182  return newErrorRes( r, RE_RUNTIME_ERROR );
2183  }
2184 
2185  int start = strlen( ( char * )out->stdoutBuf.buf );
2186  Res *ret = smsi_do( paramsr, 1, node, rei, reiSaveFlag, env, errmsg, r );
2187  /* int fin = strlen((char *)out->stdoutBuf.buf); */
2188  paramsr[1] = newStringRes( r, ( ( char * )out->stdoutBuf.buf + start ) );
2189  return ret;
2190 }
2191 
2192 Res *smsi_getstderr( Node** paramsr, int, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
2193  msParam_t * mP = NULL;
2194  msParamArray_t * inMsParamArray = rei->msParamArray;
2195  execCmdOut_t *out;
2196  if ( ( ( mP = getMsParamByLabel( inMsParamArray, "ruleExecOut" ) ) != NULL ) &&
2197  ( mP->inOutStruct != NULL ) &&
2198  strcmp(mP->type, ExecCmdOut_MS_T) == 0 ) {
2199  out = ( execCmdOut_t* )mP->inOutStruct;
2200  } else {
2201  generateAndAddErrMsg( "ruleExecOut not set", node, RE_RUNTIME_ERROR, errmsg );
2202  return newErrorRes( r, RE_RUNTIME_ERROR );
2203  }
2204 
2205  int start = strlen( ( char * )out->stderrBuf.buf );
2206  Res *ret = smsi_do( paramsr, 1, node, rei, reiSaveFlag, env, errmsg, r );
2207  paramsr[1] = newStringRes( r, ( ( char * )out->stderrBuf.buf + start ) );
2208  return ret;
2209 }
2210 
2211 Res *smsi_assignStr( Node** subtrees, int, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
2212  Res *val = evaluateExpression3( ( Node * )subtrees[1], 0, 1, rei, reiSaveFlag & ~DISCARD_EXPRESSION_RESULT, env, errmsg, r );
2213  if ( getNodeType( val ) == N_ERROR ) {
2214  return val;
2215  }
2216  if ( TYPE( val ) == T_INT || TYPE( val ) == T_DOUBLE || TYPE( val ) == T_BOOL ) {
2217  CASCADE_N_ERROR( val = smsi_str( &val, 1, node, rei, reiSaveFlag, env, errmsg, r ) );
2218  }
2219  Res *ret = matchPattern( subtrees[0], val, env, rei, reiSaveFlag, errmsg, r );
2220 
2221  return ret;
2222 
2223 }
2224 
2225 extern int GlobalAllRuleExecFlag;
2226 Res *smsi_applyAllRules( Node** subtrees, int, Node*, ruleExecInfo_t* rei, int, Env* env, rError_t* errmsg, Region* r ) {
2227  Res *res;
2228  Node *action;
2229  int reiSaveFlag2;
2230  int allRuleExecFlag;
2231 
2232  action = subtrees[0];
2233  reiSaveFlag2 = RES_INT_VAL( subtrees[1] );
2234  allRuleExecFlag = RES_INT_VAL( subtrees[2] );
2235 
2236  res = evaluateExpression3( action, allRuleExecFlag == 1 ? 2 : 1, 1, rei, reiSaveFlag2, env, errmsg, r );
2237 
2238  return res;
2239 
2240 }
2241 
2242 
2243 
2244 Res *smsi_path( Node** subtrees, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
2245  char *pathName = subtrees[0]->text;
2246  /* remove excessive slashes */
2247  while ( pathName[0] == '/' && pathName[1] == '/' ) {
2248  pathName ++;
2249  }
2250 
2251  Res *res = newPathRes( r, pathName );
2252  return res;
2253 }
2254 
2255 Res *smsi_execCmdArg( Node** subtrees, int, Node*, ruleExecInfo_t*, int, Env*, rError_t*, Region* r ) {
2256  char *arg = subtrees[0]->text;
2257  char *argNew = ( char * ) malloc( strlen( arg ) * 2 + 4 );
2258  char *p = arg, *q = argNew;
2259  /* this prevent invalid read:
2260  * when msiExecCmd sees a quote it tries to read the previous char to determine whether the quote is escaped
2261  * if the quote is the first char, there will be an invalid read
2262  * leave a space so that the first char is never a quote */
2263  *( q++ ) = ' ';
2264  *( q++ ) = '\"';
2265  while ( *p != '\0' ) {
2266  if ( *p == '\"' || *p == '\'' ) {
2267  *( q++ ) = '\\';
2268  }
2269  *( q++ ) = *( p++ );
2270  }
2271  *( q++ ) = '\"';
2272  *( q++ ) = '\0';
2273  Res *res = newStringRes( r, argNew );
2274  free( argNew );
2275  return res;
2276 
2277 }
2278 
2279 int checkStringForSystem( const char *s );
2281  char *s = paramsr[0]->text;
2282  int ret = checkStringForSystem( s );
2283  if ( ret < 0 ) {
2284  return newErrorRes( r, ret );
2285  }
2286  else {
2287  return newIntRes( r, ret );
2288  }
2289 }
2290 
2291 int
2292 parseResForCollInp( Node *inpParam, collInp_t *collInpCache,
2293  collInp_t **outCollInp, int outputToCache ) {
2294  *outCollInp = NULL;
2295 
2296  if ( inpParam == NULL ) {
2297  rodsLog( LOG_ERROR,
2298  "parseMspForCollInp: input inpParam is NULL" );
2300  }
2301 
2302  if ( TYPE( inpParam ) == T_STRING ) {
2303  /* str input */
2304  if ( collInpCache == NULL ) {
2305  collInpCache = ( collInp_t * )malloc( sizeof( collInp_t ) );
2306  }
2307  memset( collInpCache, 0, sizeof( collInp_t ) );
2308  *outCollInp = collInpCache;
2309  if ( strcmp( inpParam->text, "null" ) != 0 ) {
2310  rstrcpy( collInpCache->collName, ( char* )inpParam->text, MAX_NAME_LEN );
2311  }
2312  return 0;
2313  }
2314  else if ( TYPE( inpParam ) == T_IRODS && strcmp( RES_IRODS_TYPE( inpParam ), CollInp_MS_T ) == 0 ) {
2315  if ( outputToCache == 1 ) {
2316  collInp_t *tmpCollInp;
2317  tmpCollInp = ( collInp_t * ) RES_UNINTER_STRUCT( inpParam );
2318  if ( collInpCache == NULL ) {
2319  collInpCache = ( collInp_t * )malloc( sizeof( collInp_t ) );
2320  }
2321  *collInpCache = *tmpCollInp;
2322  /* zero out the condition of the original because it has been
2323  * moved */
2324  memset( &tmpCollInp->condInput, 0, sizeof( keyValPair_t ) );
2325  *outCollInp = collInpCache;
2326  }
2327  else {
2328  *outCollInp = ( collInp_t * ) RES_UNINTER_STRUCT( inpParam );
2329  }
2330  return 0;
2331  }
2332  else {
2333  char buf[ERR_MSG_LEN];
2334  Hashtable *varTypes = newHashTable( 10 );
2335  typeToString( inpParam->exprType, varTypes, buf, ERR_MSG_LEN );
2336  deleteHashTable( varTypes, NULL );
2337  rodsLog( LOG_ERROR,
2338  "parseMspForCollInp: Unsupported input Param1 type %s",
2339  buf );
2340  return USER_PARAM_TYPE_ERR;
2341  }
2342 }
2343 
2344 Res *smsiCollectionSpider( Node** subtrees, int, Node* node, ruleExecInfo_t* rei, int reiSaveFlag, Env* env, rError_t* errmsg, Region* r ) {
2345  collInp_t collInpCache, *collInp; /* input for rsOpenCollection */
2346  collEnt_t *collEnt; /* input for rsReadCollection */
2347  int handleInx; /* collection handler */
2348  dataObjInp_t *dataObjInp; /* will contain pathnames for each object (one at a time) */
2349 
2350  /* Sanity test */
2351  if ( rei == NULL || rei->rsComm == NULL ) {
2352  generateAndAddErrMsg( "msiCollectionSpider: input rei or rsComm is NULL.", node, SYS_INTERNAL_NULL_INPUT_ERR, errmsg );
2354  }
2355 
2356  /* Parse collection input */
2357  rei->status = parseResForCollInp( subtrees[1], &collInpCache, &collInp, 0 );
2358  if ( rei->status < 0 ) {
2359  char buf[ERR_MSG_LEN];
2360  snprintf( buf, ERR_MSG_LEN, "msiCollectionSpider: input collection error. status = %d", rei->status );
2361  generateAndAddErrMsg( buf, node, rei->status, errmsg );
2362  return newErrorRes( r, rei->status );
2363  }
2364 
2365  /* Check if "objects" input has proper form */
2366  if ( getNodeType( subtrees[0] ) != TK_VAR ) {
2367  char buf[ERR_MSG_LEN];
2368  snprintf( buf, ERR_MSG_LEN, "msiCollectionSpider: input objects error. status = %d", rei->status );
2369  generateAndAddErrMsg( buf, node, rei->status, errmsg );
2370  return newErrorRes( r, rei->status );
2371  }
2372  char* varname = subtrees[0]->text;
2373 
2374  /* Open collection in recursive mode */
2375  collInp->flags = RECUR_QUERY_FG;
2376  handleInx = rsOpenCollection( rei->rsComm, collInp );
2377  if ( handleInx < 0 ) {
2378  char buf[ERR_MSG_LEN];
2379  snprintf( buf, ERR_MSG_LEN, "msiCollectionSpider: rsOpenCollection of %s error. status = %d", collInp->collName, handleInx );
2380  generateAndAddErrMsg( buf, node, handleInx, errmsg );
2381  return newErrorRes( r, handleInx );
2382  }
2383 
2384  GC_BEGIN
2385  /* save the old value of variable with name varname in the current env only */
2386  Res *oldVal = ( Res * ) lookupFromHashTable( env->current, varname );
2387 
2388  /* Allocate memory for dataObjInp. Needs to be persistent since will be freed later along with other msParams */
2389  dataObjInp = ( dataObjInp_t * )malloc( sizeof( dataObjInp_t ) );
2390 
2391  /* Read our collection one object at a time */
2392  while ( ( rei->status = rsReadCollection( rei->rsComm, &handleInx, &collEnt ) ) >= 0 ) {
2393  GC_ON( env );
2394  /* Skip collection entries */
2395  if ( collEnt != NULL ) {
2396  if ( collEnt->objType == DATA_OBJ_T ) {
2397  /* Write our current object's path in dataObjInp, where the inOutStruct in 'objects' points to */
2398 
2399  memset( dataObjInp, 0, sizeof( dataObjInp_t ) );
2400  snprintf( dataObjInp->objPath, MAX_NAME_LEN, "%s/%s", collEnt->collName, collEnt->dataName );
2401 
2402  /* Free collEnt only. Content will be freed by rsCloseCollection() */
2403  free( collEnt );
2404 
2405  /* Set var with name varname in the current environment */
2406  updateInEnv( env, varname, newUninterpretedRes( GC_REGION, DataObjInp_MS_T, ( void * ) dataObjInp, NULL ) );
2407 
2408  /* Run actionStr on our object */
2409  Res *ret = evaluateActions( subtrees[2], subtrees[3], 0, rei, reiSaveFlag, env, errmsg, GC_REGION );
2410  if ( TYPE( ret ) == T_ERROR ) {
2411  /* If an error occurs, log incident but keep going */
2412  char buf[ERR_MSG_LEN];
2413  snprintf( buf, ERR_MSG_LEN, "msiCollectionSpider: execMyRule error. status = %d", RES_ERR_CODE( ret ) );
2414  generateAndAddErrMsg( buf, node, RES_ERR_CODE( ret ), errmsg );
2415  }
2416  else if ( TYPE( ret ) == T_BREAK ) {
2417  break;
2418  }
2419 
2420  }
2421  else {
2422  /* Free collEnt only. Content will be freed by rsCloseCollection() */
2423  free( collEnt );
2424  }
2425  }
2426 
2427  }
2428 
2429  if ( oldVal == NULL ) {
2430  deleteFromHashTable( env->current, varname );
2431  }
2432  else {
2433  updateInEnv( env, varname, oldVal );
2434  }
2435  cpEnv2( env, GC_REGION, r );
2436  GC_END
2437 
2438  free( dataObjInp );
2439 
2440  /* Close collection */
2441  rei->status = rsCloseCollection( rei->rsComm, &handleInx );
2442 
2443  /* Return operation status */
2444  if ( rei->status < 0 ) {
2445  return newErrorRes( r, rei->status );
2446  }
2447  else {
2448  return newIntRes( r, rei->status );
2449  }
2450 
2451 }
2452 
2453 /* utilities */
2454 int fileConcatenate( const char *file1, const char *file2, const char *file3 ) {
2455  char buf[1024];
2456  FILE *f1 = fopen( file1, "r" );
2457  if ( f1 == NULL ) {
2458  return USER_FILE_DOES_NOT_EXIST;
2459  }
2460  FILE *f2;
2461  if ( file2 == NULL ) {
2462  f2 = NULL;
2463  }
2464  else {
2465  f2 = fopen( file2, "r" );
2466  if ( f2 == NULL ) {
2467  fclose( f1 );
2468  return USER_FILE_DOES_NOT_EXIST;
2469  }
2470  }
2471  FILE *f3 = fopen( file3, "w" );
2472  if ( NULL == f3 ) {
2473  fclose( f1 );
2474  if ( NULL != f2 ) {
2475  fclose( f2 );
2476  }
2477  return UNIX_FILE_OPEN_ERR;
2478  }
2479 
2480  size_t len;
2481  int error = 0;
2482  while ( !feof( f1 ) && ferror( f1 ) == 0 ) {
2483  len = fread( buf, 1, 1024, f1 );
2484  fwrite( buf, 1, len, f3 );
2485  }
2486  error = ferror( f1 );
2487  if ( error == 0 && f2 != NULL ) {
2488  while ( !feof( f2 ) && ferror( f2 ) == 0 ) {
2489  len = fread( buf, 1, 1024, f2 );
2490  fwrite( buf, 1, len, f3 );
2491  }
2492  error = ferror( f2 );
2493  }
2494 
2495  fclose( f1 );
2496  if ( f2 != NULL ) {
2497  fclose( f2 );
2498  }
2499  fclose( f3 );
2500  return error;
2501 }
2502 
2503 Res* eval( char *expr, Env* env, ruleExecInfo_t* rei, int saveREI, rError_t* errmsg, Region* r ) {
2504  Res *res = parseAndComputeExpression( expr, env, rei, saveREI, errmsg, r );
2505  return res;
2506 }
2507 
2508 Node *construct( char *fn, Node** args, int argc, Node *constype, Region* r ) {
2509  Node *res = newRes( r );
2510  res->text = cpStringExt( fn, r );
2511  res->degree = argc;
2512  res->subtrees = ( Node** )region_alloc( r, sizeof( Node * ) * argc );
2513  memcpy( res->subtrees, args, sizeof( Node * )*argc );
2514  res->exprType = constype;
2515  return res;
2516 }
2517 
2518 Node *deconstruct( Node** args, int proj ) {
2519  Node *res = args[0]->subtrees[proj];
2520  return res;
2521 }
2522 
2523 char *matchWholeString( char *buf ) {
2524  char *buf2 = ( char * )malloc( sizeof( char ) * strlen( buf ) + 2 + 1 );
2525  buf2[0] = '^';
2526  strcpy( buf2 + 1, buf );
2527  buf2[strlen( buf ) + 1] = '$';
2528  buf2[strlen( buf ) + 2] = '\0';
2529  return buf2;
2530 }
2531 
2532 char *wildCardToRegex( char *buf ) {
2533  char *buf2 = ( char * )malloc( sizeof( char ) * strlen( buf ) * 3 + 2 + 1 );
2534  char *p = buf2;
2535  int i;
2536  *( p++ ) = '^';
2537  int n = strlen( buf );
2538  for ( i = 0; i < n; i++ ) {
2539  switch ( buf[i] ) {
2540  case '*':
2541  *( p++ ) = '.';
2542  *( p++ ) = buf[i];
2543  break;
2544  case ']':
2545  case '[':
2546  case '^':
2547  *( p++ ) = '\\';
2548  *( p++ ) = buf[i];
2549  break;
2550  default:
2551  *( p++ ) = '[';
2552  *( p++ ) = buf[i];
2553  *( p++ ) = ']';
2554  break;
2555  }
2556  }
2557  *( p++ ) = '$';
2558  *( p++ ) = '\0';
2559  return buf2;
2560 }
2561 
2562 Res *smsi_segfault(Node**, int, Node* node, ruleExecInfo_t* rei, int, Env*, rError_t* errmsg, Region* r) {
2564  char buf[ERR_MSG_LEN];
2565  snprintf(buf, ERR_MSG_LEN, "[%s]: permission denied", __FUNCTION__);
2568  }
2569  raise( SIGSEGV );
2570  return NULL;
2571 }
2572 
2574  insertIntoHashTable( ft, "do", newFunctionFD( "e ?->?", smsi_do, r ) );
2575  insertIntoHashTable( ft, "eval", newFunctionFD( "string->?", smsi_eval, r ) );
2576  insertIntoHashTable( ft, "evalrule", newFunctionFD( "string->?", smsi_evalrule, r ) );
2577  insertIntoHashTable( ft, "applyAllRules", newFunctionFD( "e ? * f 0{integer string } => integer * f 1{integer string} => integer->?", smsi_applyAllRules, r ) );
2578  insertIntoHashTable( ft, "errorcodea", newFunctionFD( "a ? * a ?->integer", smsi_errorcode, r ) );
2579  insertIntoHashTable( ft, "errorcode", newFunctionFD( "e ?->integer", smsi_errorcode, r ) );
2580  insertIntoHashTable( ft, "errormsga", newFunctionFD( "a ? * a ? * o string->integer", smsi_errormsg, r ) );
2581  insertIntoHashTable( ft, "errormsg", newFunctionFD( "e ? * o string->integer", smsi_errormsg, r ) );
2582  insertIntoHashTable( ft, "getstdout", newFunctionFD( "e ? * o string ->integer", smsi_getstdout, r ) );
2583  insertIntoHashTable( ft, "getstderr", newFunctionFD( "e ? * o string ->integer", smsi_getstderr, r ) );
2584  insertIntoHashTable( ft, "let", newFunctionFD( "e 0 * e f 0 * e 1->1", smsi_letExec, r ) );
2585  insertIntoHashTable( ft, "match", newFunctionFD( "e 0 * e (0 * 1)*->1", smsi_matchExec, r ) );
2586  insertIntoHashTable( ft, "if2", newFunctionFD( "e boolean * e 0 * e 0 * e ? * e ?->0", smsi_if2Exec, r ) );
2587  insertIntoHashTable( ft, "if", newFunctionFD( "e boolean * a ? * a ? * a ? * a ?->?", smsi_ifExec, r ) );
2588  insertIntoHashTable( ft, "for", newFunctionFD( "e ? * e boolean * e ? * a ? * a ?->?", smsi_forExec, r ) );
2589  insertIntoHashTable( ft, "while", newFunctionFD( "e boolean * a ? * a ?->?", smsi_whileExec, r ) );
2590  insertIntoHashTable( ft, "foreach", newFunctionFD( "e f list 0 * a ? * a ?->?", smsi_forEachExec, r ) );
2591  insertIntoHashTable( ft, "foreach2", newFunctionFD( "forall X, e X * f list X * a ? * a ?->?", smsi_forEach2Exec, r ) );
2592  insertIntoHashTable( ft, "break", newFunctionFD( "->integer", smsi_break, r ) );
2593  insertIntoHashTable( ft, "succeed", newFunctionFD( "->integer", smsi_succeed, r ) );
2594  insertIntoHashTable( ft, "fail", newFunctionFD( "integer ?->integer", smsi_fail, r ) );
2595  insertIntoHashTable( ft, "failmsg", newFunctionFD( "integer * string->integer", smsi_fail, r ) );
2596  insertIntoHashTable( ft, "assign", newFunctionFD( "e 0 * e f 0->integer", smsi_assign, r ) );
2597  insertIntoHashTable( ft, "lmsg", newFunctionFD( "string->integer", smsi_lmsg, r ) );
2598  insertIntoHashTable( ft, "listvars", newFunctionFD( "->string", smsi_listvars, r ) );
2599  insertIntoHashTable( ft, "listcorerules", newFunctionFD( "->list string", smsi_listcorerules, r ) );
2600  insertIntoHashTable( ft, "listapprules", newFunctionFD( "->list string", smsi_listapprules, r ) );
2601  insertIntoHashTable( ft, "listextrules", newFunctionFD( "->list string", smsi_listextrules, r ) );
2602  /*insertIntoHashTable(ft, "true", newFunctionFD("boolean", smsi_true, r));
2603  insertIntoHashTable(ft, "false", newFunctionFD("boolean", smsi_false, r));*/
2604  insertIntoHashTable( ft, "time", newFunctionFD( "->time", smsi_time, r ) );
2605  insertIntoHashTable( ft, "timestr", newFunctionFD( "time->string", smsi_timestr, r ) );
2606  insertIntoHashTable( ft, "str", newFunctionFD( "?->string", smsi_str, r ) );
2607  insertIntoHashTable( ft, "datetime", newFunctionFD( "0 { string integer double }->time", smsi_datetime, r ) );
2608  insertIntoHashTable( ft, "timestrf", newFunctionFD( "time * string->string", smsi_timestr, r ) );
2609  insertIntoHashTable( ft, "datetimef", newFunctionFD( "string * string->time", smsi_datetime, r ) );
2610  insertIntoHashTable( ft, "double", newFunctionFD( "f 0{string double time}->double", smsi_double, r ) );
2611  insertIntoHashTable( ft, "int", newFunctionFD( "0{integer string double}->integer", smsi_int, r ) );
2612  insertIntoHashTable( ft, "bool", newFunctionFD( "0{boolean integer string double}->boolean", smsi_bool, r ) );
2613  insertIntoHashTable( ft, "list", newFunctionFD( "forall X, X*->list X", smsi_list, r ) );
2614  /*insertIntoHashTable(ft, "tuple",
2615  newFunctionDescChain(newConstructorDesc("-> <>", r),
2616  newFunctionDescChain(newConstructorDesc("A-> <A>", r),
2617  newFunctionDescChain(newConstructorDesc("A * B-> <A * B>", r),
2618  newFunctionDescChain(newConstructorDesc("A * B * C-> <A * B * C>", r),
2619  newFunctionDescChain(newConstructorDesc("A * B * C * D-> <A * B * C * D>", r),
2620  newFunctionDescChain(newConstructorDesc("A * B * C * D * E-> <A * B * C * D * E>", r),
2621  newFunctionDescChain(newConstructorDesc("A * B * C * D * E * F * G-> <A * B * C * D * E * F * G>", r),
2622  newFunctionDescChain(newConstructorDesc("A * B * C * D * E * F * G * H-> <A * B * C * D * E * F * G * H>", r),
2623  newFunctionDescChain(newConstructorDesc("A * B * C * D * E * F * G * H * I-> <A * B * C * D * E * F * G * H * I>", r),
2624  newConstructorDesc("A * B * C * D * E * F * G * H * I * J-> <A * B * C * D * E * F * G * H * I * J>", r)
2625  ))))))))));*/
2626  insertIntoHashTable( ft, "elem", newFunctionFD( "forall X, list X * integer->X", smsi_elem, r ) );
2627  insertIntoHashTable( ft, "setelem", newFunctionFD( "forall X, list X * integer * X->list X", smsi_setelem, r ) );
2628  insertIntoHashTable( ft, "hd", newFunctionFD( "forall X, list X->X", smsi_hd, r ) );
2629  insertIntoHashTable( ft, "tl", newFunctionFD( "forall X, list X->list X", smsi_tl, r ) );
2630  insertIntoHashTable( ft, "cons", newFunctionFD( "forall X, X * list X->list X", smsi_cons, r ) );
2631  insertIntoHashTable( ft, "size", newFunctionFD( "forall X, list X->integer", smsi_size, r ) );
2632  insertIntoHashTable( ft, "type", newFunctionFD( "forall X, X->string", smsi_type, r ) );
2633  insertIntoHashTable( ft, "arity", newFunctionFD( "string->integer", smsi_arity, r ) );
2634  insertIntoHashTable( ft, "+", newFunctionFD( "forall X in {integer double}, f X * f X->X", smsi_add, r ) );
2635  insertIntoHashTable( ft, "++", newFunctionFD( "f string * f string->string", smsi_concat, r ) );
2636  insertIntoHashTable( ft, "-", newFunctionFD( "forall X in {integer double}, f X * f X->X", smsi_subtract, r ) );
2637  insertIntoHashTable( ft, "neg", newFunctionFD( "forall X in {integer double}, X-> X", smsi_negate, r ) );
2638  insertIntoHashTable( ft, "*", newFunctionFD( "forall X in {integer double}, f X * f X->X", smsi_multiply, r ) );
2639  insertIntoHashTable( ft, "/", newFunctionFD( "forall X in {integer double}, f X * f X->?", smsi_divide, r ) );
2640  insertIntoHashTable( ft, "%", newFunctionFD( "integer * integer->integer", smsi_modulo, r ) );
2641  insertIntoHashTable( ft, "^", newFunctionFD( "f double * f double->double", smsi_power, r ) );
2642  insertIntoHashTable( ft, "^^", newFunctionFD( "f double * f double->double", smsi_root, r ) );
2643  insertIntoHashTable( ft, ".", newFunctionFD( "forall X, `KeyValPair_PI` * expression X->string", smsi_getValByKey, r ) );
2644  insertIntoHashTable( ft, "log", newFunctionFD( "f double->double", smsi_log, r ) );
2645  insertIntoHashTable( ft, "exp", newFunctionFD( "f double->double", smsi_exp, r ) );
2646  insertIntoHashTable( ft, "!", newFunctionFD( "boolean->boolean", smsi_not, r ) );
2647  insertIntoHashTable( ft, "&&", newFunctionFD( "boolean * boolean->boolean", smsi_and, r ) );
2648  insertIntoHashTable( ft, "||", newFunctionFD( "boolean * boolean->boolean", smsi_or, r ) );
2649  insertIntoHashTable( ft, "%%", newFunctionFD( "boolean * boolean->boolean", smsi_or, r ) );
2650  insertIntoHashTable( ft, "==", newFunctionFD( "forall X in {integer double boolean string time path}, f X * f X->boolean", smsi_eq, r ) );
2651  insertIntoHashTable( ft, "!=", newFunctionFD( "forall X in {integer double boolean string time path}, f X * f X->boolean", smsi_neq, r ) );
2652  insertIntoHashTable( ft, ">", newFunctionFD( "forall X in {integer double string time}, f X * f X->boolean", smsi_gt, r ) );
2653  insertIntoHashTable( ft, "<", newFunctionFD( "forall X in {integer double string time}, f X * f X->boolean", smsi_lt, r ) );
2654  insertIntoHashTable( ft, ">=", newFunctionFD( "forall X in {integer double string time}, f X * f X->boolean", smsi_ge, r ) );
2655  insertIntoHashTable( ft, "<=", newFunctionFD( "forall X in {integer double string time}, f X * f X->boolean", smsi_le, r ) );
2656  insertIntoHashTable( ft, "floor", newFunctionFD( "f double->double", smsi_floor, r ) );
2657  insertIntoHashTable( ft, "ceiling", newFunctionFD( "f double->double", smsi_ceiling, r ) );
2658  insertIntoHashTable( ft, "abs", newFunctionFD( "f double->double", smsi_abs, r ) );
2659  insertIntoHashTable( ft, "max", newFunctionFD( "f double+->double", smsi_max, r ) );
2660  insertIntoHashTable( ft, "min", newFunctionFD( "f double+->double", smsi_min, r ) );
2661  insertIntoHashTable( ft, "average", newFunctionFD( "f double+->double", smsi_average, r ) );
2662  insertIntoHashTable( ft, "like", newFunctionFD( "string * string->boolean", smsi_like, r ) );
2663  insertIntoHashTable( ft, "not like", newFunctionFD( "string * string->boolean", smsi_not_like, r ) );
2664  insertIntoHashTable( ft, "like regex", newFunctionFD( "string * string->boolean", smsi_like_regex, r ) );
2665  insertIntoHashTable( ft, "not like regex", newFunctionFD( "string * string->boolean", smsi_not_like_regex, r ) );
2666  insertIntoHashTable( ft, "delayExec", newFunctionFD( "string * string * string->integer", smsi_delayExec, r ) );
2667  insertIntoHashTable( ft, "remoteExec", newFunctionFD( "string * string * string * string->integer", smsi_remoteExec, r ) );
2668  insertIntoHashTable( ft, "writeLine", newFunctionFD( "string * ?->integer", smsi_writeLine, r ) );
2669  insertIntoHashTable( ft, "writeString", newFunctionFD( "string * ?->integer", smsi_writeString, r ) );
2670  insertIntoHashTable( ft, "triml", newFunctionFD( "string * string->string", smsi_triml, r ) );
2671  insertIntoHashTable( ft, "trimr", newFunctionFD( "string * string->string", smsi_trimr, r ) );
2672  insertIntoHashTable( ft, "strlen", newFunctionFD( "string->integer", smsi_strlen, r ) );
2673  insertIntoHashTable( ft, "substr", newFunctionFD( "string * integer * integer->string", smsi_substr, r ) );
2674  insertIntoHashTable( ft, "split", newFunctionFD( "string * string -> list string", smsi_split, r ) );
2675  insertIntoHashTable( ft, "execCmdArg", newFunctionFD( "f string->string", smsi_execCmdArg, r ) );
2676  insertIntoHashTable( ft, "query", newFunctionFD( "expression ? -> `GenQueryInp_PI` * `GenQueryOut_PI`", smsi_query, r ) );
2677  insertIntoHashTable( ft, "unspeced", newFunctionFD( "-> ?", smsi_undefined, r ) );
2678  insertIntoHashTable( ft, "msiCheckStringForSystem", newFunctionFD( "f string->int", smsi_msiCheckStringForSystem, r ) );
2679 #ifdef DEBUG
2680 #else
2681 #endif
2682  /* insertIntoHashTable(ft, "getReLogging", newFunctionFD("string -> boolean", smsi_getReLogging, r));
2683  insertIntoHashTable(ft, "setReLogging", newFunctionFD("string * boolean -> integer", smsi_setReLogging, r));*/
2684  insertIntoHashTable( ft, "collectionSpider", newFunctionFD( "forall X in {string `CollInpNew_PI`}, expression ? * X * actions ? * actions ? -> integer", smsiCollectionSpider, r ) );
2685  insertIntoHashTable( ft, "path", newFunctionFD( "string -> path", smsi_path, r ) );
2686  insertIntoHashTable( ft, "collection", newFunctionFD( "path -> `CollInpNew_PI`", smsi_collection, r ) );
2687  insertIntoHashTable( ft, "getGlobalSessionId", newFunctionFD( "->string", smsi_getGlobalSessionId, r ) );
2688  insertIntoHashTable( ft, "setGlobalSessionId", newFunctionFD( "string->integer", smsi_setGlobalSessionId, r ) );
2689  insertIntoHashTable( ft, "temporaryStorage", newFunctionFD( "->KeyValPair_PI", smsi_properties, r ) );
2690  /* insertIntoHashTable(ft, "msiDataObjInfo", newFunctionFD("input `DataObjInp_PI` * output `DataObjInfo_PI` -> integer", smsi_msiDataObjInfo, r));*/
2691  insertIntoHashTable( ft, "rei->doi->dataSize", newFunctionFD( "double : 0 {string}", ( SmsiFuncTypePtr ) NULL, r ) );
2692  insertIntoHashTable( ft, "rei->doi->writeFlag", newFunctionFD( "integer : 0 {string}", ( SmsiFuncTypePtr ) NULL, r ) );
2693 
2694 #ifdef RE_BACKWARD_COMPATIBLE
2695  insertIntoHashTable( ft, "assignStr", newFunctionFD( "e ? * e ?->integer", smsi_assignStr, r ) );
2696  insertIntoHashTable( ft, "ifExec", newFunctionFD( "e boolean * a ? * a ? * a ? * a ?->?", smsi_ifExec, r ) );
2697  insertIntoHashTable( ft, "forExec", newFunctionFD( "e ? * e boolean * a ? * a ? * a ?->?", smsi_forExec, r ) );
2698  insertIntoHashTable( ft, "whileExec", newFunctionFD( "e boolean * a ? * a ?->?", smsi_whileExec, r ) );
2699  insertIntoHashTable( ft, "forEachExec", newFunctionFD( "e list 0 * a ? * a ?->?", smsi_forEachExec, r ) );
2700 #endif
2701  insertIntoHashTable( ft, "msiSegFault", newFunctionFD( " -> integer", smsi_segfault, r ) );
2702 
2703 
2704 }
reIterableTableRow::reIterable
ReIterable reIterable
Definition: functions.hpp:50
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
ruleSet::rules
RuleDesc * rules[50000]
Definition: restructs.hpp:284
MAX_SQL_ROWS
#define MAX_SQL_ROWS
Definition: rodsGenQuery.h:16
getValueFromCollection
Res * getValueFromCollection(char *typ, void *inPtr, int inx, Region *r)
Definition: conversion.cpp:61
NULL
#define NULL
Definition: rodsDef.h:70
rmMsParamByLabel
int rmMsParamByLabel(msParamArray_t *msParamArray, const char *label, int freeStruct)
Definition: msParam.cpp:424
rsComm_t
Definition: rcConnect.h:145
generateAndAddErrMsg
void generateAndAddErrMsg(char *msg, Node *node, int errcode, rError_t *errmsg)
Definition: parser.cpp:3550
smsi_setelem
Res * smsi_setelem(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1138
rsReadCollection
int rsReadCollection(rsComm_t *rsComm, int *handleInxInp, collEnt_t **collEnt)
Definition: rsReadCollection.cpp:15
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
convertResToString
char * convertResToString(Res *res0)
Definition: conversion.cpp:556
rsOpenCollection
int rsOpenCollection(rsComm_t *rsComm, collInp_t *openCollInp)
Definition: rsOpenCollection.cpp:16
reIterable_genQuery_data::cont
int cont
Definition: functions.cpp:366
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
RE_ITERABLE_LIST
@ RE_ITERABLE_LIST
Definition: functions.hpp:33
reIterable_collection_finalize
void reIterable_collection_finalize(ReIterableData *itrData, Region *r)
Definition: functions.cpp:600
reIterable_collection_init
void reIterable_collection_init(ReIterableData *itrData, Region *r)
Definition: functions.cpp:522
RE_PATTERN_NOT_MATCHED
@ RE_PATTERN_NOT_MATCHED
Definition: rodsErrorTable.h:710
getMsParamByLabel
msParam_t * getMsParamByLabel(msParamArray_t *msParamArray, const char *label)
Definition: msParam.cpp:376
smsi_setGlobalSessionId
Res * smsi_setGlobalSessionId(Node **subtrees, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:67
smsi_timestr
Res * smsi_timestr(Node **params, int n, Node *, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1269
RE_RUNTIME_ERROR
@ RE_RUNTIME_ERROR
Definition: rodsErrorTable.h:699
rsDataObjWrite.hpp
msiExecGenQuery
int msiExecGenQuery(msParam_t *genQueryInParam, msParam_t *genQueryOutParam, ruleExecInfo_t *rei)
Definition: genQueryMS.cpp:117
reIterable_irods_init
void reIterable_irods_init(ReIterableData *itrData, Region *r)
Definition: functions.cpp:488
writeICatUserLogging
int writeICatUserLogging(char *userName, int logging, rsComm_t *rsComm)
Definition: configuration.cpp:667
CollInp
Definition: dataObjInpOut.h:157
ExecCmdOut
Definition: execCmd.h:20
DataObjInp_MS_T
#define DataObjInp_MS_T
Definition: msParam.h:30
msParam.h
UNMATCHED_KEY_OR_INDEX
@ UNMATCHED_KEY_OR_INDEX
Definition: rodsErrorTable.h:244
smsi_msiCheckStringForSystem
Res * smsi_msiCheckStringForSystem(Node **paramsr, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:2280
smsi_subtract
Res * smsi_subtract(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1526
rsDataObjOpen.hpp
index.hpp
smsi_succeed
Res * smsi_succeed(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:942
GenQueryInp_MS_T
#define GenQueryInp_MS_T
Definition: msParam.h:46
N_ATTR
@ N_ATTR
Definition: restructs.hpp:130
fileConcatenate
int fileConcatenate(const char *file1, const char *file2, const char *file3)
Definition: functions.cpp:2454
NUM_RE_ITERABLE
#define NUM_RE_ITERABLE
Definition: functions.cpp:98
RE_ITERABLE_KEY_VALUE_PAIRS
@ RE_ITERABLE_KEY_VALUE_PAIRS
Definition: functions.hpp:37
reIterable_genQuery_data
Definition: functions.cpp:364
smsi_add
Res * smsi_add(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1518
smsi_writeString
Res * smsi_writeString(Node **paramsr, int, Node *, ruleExecInfo_t *rei, int, Env *env, rError_t *, Region *r)
Definition: functions.cpp:1989
smsi_and
Res * smsi_and(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1507
_writeString
int _writeString(char *writeId, char *writeStr, ruleExecInfo_t *rei)
Definition: irods_re_structs.cpp:278
irods_get_full_path_for_config_file.hpp
reIterableTableRow
Definition: functions.hpp:48
smsi_collection
Res * smsi_collection(Node **subtrees, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:312
RuleExecInfo::status
int status
Definition: irods_re_structs.hpp:19
region_alloc
void * region_alloc(Region *r, size_t s)
Definition: region.cpp:138
reIterable_list_data::i
int i
Definition: functions.cpp:451
node::dval
double dval
Definition: restructs.hpp:256
T_UNSPECED
@ T_UNSPECED
Definition: restructs.hpp:156
smsi_getGlobalSessionId
Res * smsi_getGlobalSessionId(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:63
RE_DYNAMIC_TYPE_ERROR
@ RE_DYNAMIC_TYPE_ERROR
Definition: rodsErrorTable.h:722
rsExecMyRule
int rsExecMyRule(rsComm_t *rsComm, execMyRuleInp_t *execMyRuleInp, msParamArray_t **outParamArray)
Definition: rsExecMyRule.cpp:9
reIterable_collection_data::collEnt
collEnt_t * collEnt
Definition: functions.cpp:517
reIterable_list_data::n
int n
Definition: functions.cpp:452
CollEnt::collName
char * collName
Definition: miscUtil.h:119
reIterable_genQuery_finalize
void reIterable_genQuery_finalize(ReIterableData *itrData, Region *r)
Definition: functions.cpp:434
getNodeType
#define getNodeType(x)
Definition: restructs.hpp:69
RES_TIME_VAL
#define RES_TIME_VAL(x)
Definition: restructs.hpp:60
convertMsParamToResAndFreeNonIRODSType
int convertMsParamToResAndFreeNonIRODSType(msParam_t *mP, Res *res, Region *r)
Definition: conversion.cpp:222
convertResToMsParam
int convertResToMsParam(msParam_t *var, Res *res, rError_t *errmsg)
Definition: conversion.cpp:350
smsi_fail
Res * smsi_fail(Node **subtrees, int n, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:948
reIterable_collection_data::collInp
collInp_t * collInp
Definition: functions.cpp:516
ExecMyRuleInp::outParamDesc
char outParamDesc[256]
Definition: execMyRule.h:13
env
Definition: restructs.hpp:226
GenQueryInp
Definition: rodsGenQuery.h:24
reIterable_collection_data
Definition: functions.cpp:515
configuration.hpp
reIterable_genQuery_init
void reIterable_genQuery_init(ReIterableData *itrData, Region *r)
Definition: functions.cpp:373
ExecMyRuleInp::condInput
keyValPair_t condInput
Definition: execMyRule.h:12
smsi_execCmdArg
Res * smsi_execCmdArg(Node **subtrees, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:2255
smsi_cons
Res * smsi_cons(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1124
convertEnvToMsParamArray
int convertEnvToMsParamArray(msParamArray_t *var, Env *env, rError_t *errmsg, Region *r)
Definition: conversion.cpp:460
evaluateVar3
Res * evaluateVar3(char *vn, Node *node, ruleExecInfo_t *rei, Env *env, rError_t *errmsg, Region *r)
Definition: arithmetics.cpp:879
smsi_true
Res * smsi_true(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1045
smsi_like_regex
Res * smsi_like_regex(Node **paramsr, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1762
typeToString
char * typeToString(ExprType *type, Hashtable *var_types, char *buf, int bufsize)
Definition: utils.cpp:522
smsi_substr
Res * smsi_substr(Node **paramsr, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:2029
N_APP_ARITY
#define N_APP_ARITY(x)
Definition: restructs.hpp:44
pid_age.p
p
Definition: pid_age.py:13
smsi_bool
Res * smsi_bool(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1430
reIterableData::errorRes
Res * errorRes
Definition: functions.hpp:20
BUF_LEN_MS_T
#define BUF_LEN_MS_T
Definition: msParam.h:25
ruleSet::len
int len
Definition: restructs.hpp:283
freeGenQueryInp
int freeGenQueryInp(genQueryInp_t **genQueryInp)
Definition: rcMisc.cpp:1101
LONG_NAME_LEN
#define LONG_NAME_LEN
Definition: rodsDef.h:57
T_DOUBLE
@ T_DOUBLE
Definition: restructs.hpp:159
T_PATH
@ T_PATH
Definition: restructs.hpp:168
getRuleDesc
RuleDesc * getRuleDesc(int ri)
Definition: rules.cpp:595
RULE_NODE_NUM_PARAMS
#define RULE_NODE_NUM_PARAMS(r)
Definition: restructs.hpp:45
USER_FILE_DOES_NOT_EXIST
@ USER_FILE_DOES_NOT_EXIST
Definition: rodsErrorTable.h:241
TUPLE
#define TUPLE
Definition: reconstants.hpp:15
N_APPLICATION
@ N_APPLICATION
Definition: restructs.hpp:128
smsi_assignStr
Res * smsi_assignStr(Node **subtrees, int, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:2211
make_region
Region * make_region(size_t is, jmp_buf *label)
Definition: region.cpp:85
RE_ITERABLE_COLLECTION
@ RE_ITERABLE_COLLECTION
Definition: functions.hpp:34
reIterable_list_finalize
void reIterable_list_finalize(ReIterableData *itrData, Region *r)
Definition: functions.cpp:477
RES_DOUBLE_VAL
#define RES_DOUBLE_VAL(x)
Definition: restructs.hpp:57
T_BREAK
@ T_BREAK
Definition: restructs.hpp:169
node
Definition: restructs.hpp:244
fillMsParam
int fillMsParam(msParam_t *msParam, const char *label, const char *type, void *inOutStruct, bytesBuf_t *inpOutBuf)
Definition: msParam.cpp:222
ReIterable_irods_data
struct reIterable_irods_data ReIterable_irods_data
reIterable_genQuery_data::genQInpParam
msParam_t genQInpParam
Definition: functions.cpp:368
ttimestr
int ttimestr(char *timestr, int n, char *timeformat, rodsLong_t *t)
Definition: datetime.cpp:37
readICatUserLogging
int readICatUserLogging(char *userName, int *logging, rsComm_t *rsComm)
Definition: configuration.cpp:650
reIterableData::itrSpecData
void * itrSpecData
Definition: functions.hpp:19
RE_ITERABLE_STRING_ARRAY
@ RE_ITERABLE_STRING_ARRAY
Definition: functions.hpp:31
reIterable
Definition: functions.hpp:41
datetime.hpp
execMyRule.h
smsi_multiply
Res * smsi_multiply(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1534
Cache::coreRuleSet
RuleSet * coreRuleSet
Definition: configuration.hpp:53
reIterable_genQuery_next
Res * reIterable_genQuery_next(ReIterableData *itrData, Region *r)
Definition: functions.cpp:419
getSystemFunctions
void getSystemFunctions(Hashtable *ft, Region *r)
Definition: functions.cpp:2573
parseResForCollInp
int parseResForCollInp(Node *inpParam, collInp_t *collInpCache, collInp_t **outCollInp, int outputToCache)
Definition: functions.cpp:2292
smsi_getstdout
Res * smsi_getstdout(Node **paramsr, int, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:2172
RE_NOT_ITERABLE
@ RE_NOT_ITERABLE
Definition: functions.hpp:38
TYPE
#define TYPE(x)
Definition: restructs.hpp:23
smsi_assign
Res * smsi_assign(Node **subtrees, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:957
ruleIndexListNode::ruleIndex
int ruleIndex
Definition: restructs.hpp:216
smsi_like
Res * smsi_like(Node **paramsr, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1736
smsi_not_like
Res * smsi_not_like(Node **paramsr, int n, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:1755
addInxVal
int addInxVal(inxValPair_t *inxValPair, int inx, const char *value)
Definition: rcMisc.cpp:921
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
ruleIndexListNode::secondaryIndex
int secondaryIndex
Definition: restructs.hpp:215
printHashtable
void printHashtable(Hashtable *env, char *buf2)
Definition: conversion.cpp:736
CollInp::flags
int flags
Definition: dataObjInpOut.h:159
CASCADE_N_ERROR
#define CASCADE_N_ERROR(x)
Definition: utils.hpp:22
label::exprloc
long exprloc
Definition: restructs.hpp:289
RES_UNINTER_BUFFER
#define RES_UNINTER_BUFFER(x)
Definition: restructs.hpp:66
run_tests.action
action
Definition: run_tests.py:114
trim
char * trim(char *str)
Definition: parser.cpp:1740
smsi_ge
Res * smsi_ge(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1658
smsi_root
Res * smsi_root(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1568
smsi_getReLogging
Res * smsi_getReLogging(Node **paramsr, int, Node *node, ruleExecInfo_t *rei, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:2146
ReIterable_collection_data
struct reIterable_collection_data ReIterable_collection_data
MsParam::type
char * type
Definition: msParam.h:78
reIterable_irods_finalize
void reIterable_irods_finalize(ReIterableData *itrData, Region *r)
Definition: functions.cpp:509
MAX_ACTION_SIZE
#define MAX_ACTION_SIZE
Definition: reDefines.h:22
GenQueryInp::selectInp
inxIvalPair_t selectInp
Definition: rodsGenQuery.h:53
smsi_split
Res * smsi_split(Node **params, int, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:2051
GenQueryInp::maxRows
int maxRows
Definition: rodsGenQuery.h:25
smsi_power
Res * smsi_power(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1565
T_CONS
@ T_CONS
Definition: restructs.hpp:167
GC_REGION
#define GC_REGION
Definition: functions.cpp:40
_delayExec
int _delayExec(const char *rule, const char *recov, const char *condition, ruleExecInfo_t *)
Definition: nre.systemMS.cpp:158
reIterableData::varName
char * varName
Definition: functions.hpp:17
smsi_not
Res * smsi_not(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1461
updateMsParamArrayToEnvAndFreeNonIRODSType
int updateMsParamArrayToEnvAndFreeNonIRODSType(msParamArray_t *var, Env *env, Region *r)
Definition: conversion.cpp:539
StrArray_MS_T
#define StrArray_MS_T
Definition: msParam.h:44
smsi_str
Res * smsi_str(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1316
getReIterable
ReIterable * getReIterable(ReIterableType nodeType)
Definition: functions.cpp:615
smsi_break
Res * smsi_break(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:936
smsi_triml
Res * smsi_triml(Node **paramsr, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:2006
Cache::appRuleSet
RuleSet * appRuleSet
Definition: configuration.hpp:54
newCollType
ExprType * newCollType(ExprType *elemType, Region *r)
Definition: restructs.cpp:110
reIterableData::rei
ruleExecInfo_t * rei
Definition: functions.hpp:23
deconstruct
Node * deconstruct(Node **args, int proj)
Definition: functions.cpp:2518
deleteFromHashTable
const void * deleteFromHashTable(Hashtable *h, const char *key)
Definition: hashtable.cpp:184
errMsgToString
char * errMsgToString(rError_t *errmsg, char *buf, int buflen)
Definition: utils.cpp:778
ReIterable_genQuery_data
struct reIterable_genQuery_data ReIterable_genQuery_data
RuleExecInfo::rsComm
rsComm_t * rsComm
Definition: irods_re_structs.hpp:22
rsCloseCollection
int rsCloseCollection(rsComm_t *rsComm, int *handleInxInp)
Definition: rsCloseCollection.cpp:14
smsi_trimr
Res * smsi_trimr(Node **paramsr, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:2112
smsi_modulo
Res * smsi_modulo(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1557
reIterable_genQuery_hasNext
int reIterable_genQuery_hasNext(ReIterableData *itrData, Region *r)
Definition: functions.cpp:388
KeyValPair::value
char ** value
Definition: objInfo.h:123
node::text
char * text
Definition: restructs.hpp:252
functions.hpp
GenQueryOut_MS_T
#define GenQueryOut_MS_T
Definition: msParam.h:47
smsi_or
Res * smsi_or(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1513
smsi_if2Exec
Res * smsi_if2Exec(Node **params, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:162
smsi_negate
Res * smsi_negate(Node **args, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1465
TK_VAR
@ TK_VAR
Definition: restructs.hpp:119
eval
Res * eval(char *expr, Env *env, ruleExecInfo_t *rei, int saveREI, rError_t *errmsg, Region *r)
Definition: functions.cpp:2503
smsi_double
Res * smsi_double(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1388
newIntRes
Res * newIntRes(Region *r, int n)
Definition: restructs.cpp:204
DISCARD_EXPRESSION_RESULT
#define DISCARD_EXPRESSION_RESULT
Definition: restructs.hpp:93
smsi_concat
Res * smsi_concat(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1576
smsi_log
Res * smsi_log(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1488
ExecMyRuleInp::myRule
char myRule[(1024 *20)]
Definition: execMyRule.h:10
UNIX_FILE_OPEN_ERR
@ UNIX_FILE_OPEN_ERR
Definition: rodsErrorTable.h:300
newHashTable2
Hashtable * newHashTable2(int size, Region *r)
Definition: hashtable.cpp:72
newUninterpretedRes
Res * newUninterpretedRes(Region *r, const char *typeName, void *ioStruct, bytesBuf_t *ioBuf)
Definition: restructs.cpp:183
GlobalAllRuleExecFlag
int GlobalAllRuleExecFlag
Definition: libirods_rule_engine_plugin-irods_rule_language.cpp:57
smsi_arity
Res * smsi_arity(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1300
ExecCmdOut_MS_T
#define ExecCmdOut_MS_T
Definition: msParam.h:41
rError_t
Definition: rodsError.h:24
cpEnv2
void cpEnv2(Env *env, Region *oldr, Region *newr)
Definition: utils.cpp:479
cpRes2
#define cpRes2(p, oldr, r)
Definition: utils.hpp:50
T_IRODS
@ T_IRODS
Definition: restructs.hpp:172
newErrorRes
Res * newErrorRes(Region *r, int errcode)
Definition: restructs.cpp:259
start
irods::error start(irods::default_re_ctx &_u, const std::string &_instance_name)
Definition: libirods_rule_engine_plugin-cpp_default_policy.cpp:796
reIterableData::errmsg
rError_t * errmsg
Definition: functions.hpp:26
columnToString
void columnToString(Node *n, char **queryStr, int *size)
Definition: functions.cpp:736
irods.pypyodbc.long
long
Definition: pypyodbc.py:43
reIterableData
Definition: functions.hpp:16
reIterable_irods_data
Definition: functions.cpp:483
parseAndComputeRule
int parseAndComputeRule(char *expr, Env *env, ruleExecInfo_t *rei, int reiSaveFlag, rError_t *errmsg, Region *r)
Definition: rules.cpp:187
N_ACTIONS
@ N_ACTIONS
Definition: restructs.hpp:134
wrapToActions
Node * wrapToActions(Node *node, Region *r)
Definition: functions.cpp:138
GC_BEGIN
#define GC_BEGIN
Definition: functions.cpp:39
N_APP_FUNC
#define N_APP_FUNC(x)
Definition: restructs.hpp:43
node::subtrees
struct node ** subtrees
Definition: restructs.hpp:254
RE_DIVISION_BY_ZERO
@ RE_DIVISION_BY_ZERO
Definition: rodsErrorTable.h:700
smsi_lmsg
Res * smsi_lmsg(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1456
smsi_listvars
Res * smsi_listvars(Node **, int, Node *, ruleExecInfo_t *, int, Env *env, rError_t *, Region *r)
Definition: functions.cpp:1015
GenQueryOut::continueInx
int continueInx
Definition: rodsGenQuery.h:70
GC_END
#define GC_END
Definition: functions.cpp:47
META_STR_LEN
#define META_STR_LEN
Definition: rodsDef.h:65
rsExecMyRule.hpp
checkStringForSystem
int checkStringForSystem(const char *s)
Definition: stringOpr.cpp:296
reIterable_irods_next
Res * reIterable_irods_next(ReIterableData *itrData, Region *r)
Definition: functions.cpp:501
newDoubleRes
Res * newDoubleRes(Region *r, double a)
Definition: restructs.cpp:210
CAT_INSUFFICIENT_PRIVILEGE_LEVEL
@ CAT_INSUFFICIENT_PRIVILEGE_LEVEL
Definition: rodsErrorTable.h:445
clearMsParam
int clearMsParam(msParam_t *msParam, int freeStruct)
Definition: msParam.cpp:468
reIterableData::subtrees
Node ** subtrees
Definition: functions.hpp:21
getDataObjInfoIncSpecColl
int getDataObjInfoIncSpecColl(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfo)
Definition: dataObjOpr.cpp:1767
deleteReIterableData
void deleteReIterableData(ReIterableData *itrData)
Definition: functions.cpp:133
PRINT
#define PRINT(p, s, f, d)
Definition: utils.hpp:28
smsi_path
Res * smsi_path(Node **subtrees, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:2244
msiCloseGenQuery
int msiCloseGenQuery(msParam_t *genQueryInpParam, msParam_t *genQueryOutParam, ruleExecInfo_t *rei)
Definition: genQueryMS.cpp:395
getSelVal
int getSelVal(char *c)
Definition: rcMisc.cpp:2792
RE_ITERABLE_GEN_QUERY_OUT
@ RE_ITERABLE_GEN_QUERY_OUT
Definition: functions.hpp:36
reIterableData::res
Res * res
Definition: functions.hpp:18
smsi_le
Res * smsi_le(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1612
evaluateExpression3
Res * evaluateExpression3(Node *expr, int applyAll, int force, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: arithmetics.cpp:50
smsi_evalrule
Res * smsi_evalrule(Node **paramsr, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:1794
T_DATETIME
@ T_DATETIME
Definition: restructs.hpp:162
node::degree
int degree
Definition: restructs.hpp:246
RE_ITERABLE_COMMA_STRING
@ RE_ITERABLE_COMMA_STRING
Definition: functions.hpp:30
smsi_not_like_regex
Res * smsi_not_like_regex(Node **paramsr, int n, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:1780
reIterable_list_init
void reIterable_list_init(ReIterableData *itrData, Region *r)
Definition: functions.cpp:455
KeyValPair::keyWord
char ** keyWord
Definition: objInfo.h:122
RES_STRING_STR_LEN
#define RES_STRING_STR_LEN(x)
Definition: restructs.hpp:53
updateInEnv
void updateInEnv(Env *env, char *varname, Res *res)
Definition: utils.cpp:821
CollEnt
Definition: miscUtil.h:113
N_QUERY_COND_JUNCTION
@ N_QUERY_COND_JUNCTION
Definition: restructs.hpp:132
GenQueryInp::sqlCondInp
inxValPair_t sqlCondInp
Definition: rodsGenQuery.h:56
DataObjInp
Definition: dataObjInpOut.h:65
rsDataObjClose.hpp
newPathRes
Res * newPathRes(Region *r, const char *s)
Definition: restructs.cpp:241
T_STRING
@ T_STRING
Definition: restructs.hpp:161
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
smsi_getValByKey
Res * smsi_getValByKey(Node **params, int, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:985
NODE_EXPR_POS
#define NODE_EXPR_POS(x)
Definition: restructs.hpp:68
smsi_hd
Res * smsi_hd(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1096
reIterable_collection_next
Res * reIterable_collection_next(ReIterableData *itrData, Region *r)
Definition: functions.cpp:580
cpRes
#define cpRes(p, r)
Definition: utils.hpp:48
getTaggedValues
std::map< std::string, std::vector< std::string > > getTaggedValues(const char *str)
Definition: irods_re_structs.cpp:462
addInxIval
int addInxIval(inxIvalPair_t *inxIvalPair, int inx, int value)
Definition: rcMisc.cpp:883
newSimpType
ExprType * newSimpType(NodeType t, Region *r)
Definition: restructs.cpp:70
insertIntoHashTable
int insertIntoHashTable(Hashtable *h, const char *key, const void *value)
Definition: hashtable.cpp:99
ruleIndexListNode
Definition: restructs.hpp:213
CollInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:161
smsi_properties
Res * smsi_properties(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:73
label::base
char * base
Definition: restructs.hpp:290
smsi_getstderr
Res * smsi_getstderr(Node **paramsr, int, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:2192
smsi_listextrules
Res * smsi_listextrules(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1037
GenQueryOut
Definition: rodsGenQuery.h:67
addRErrorMsg
int addRErrorMsg(rError_t *myError, int status, const char *msg)
Definition: rcMisc.cpp:121
collType
ReIterableType collType(Res *coll)
Definition: functions.cpp:323
LOCAL_PRIV_USER_AUTH
#define LOCAL_PRIV_USER_AUTH
Definition: rodsUser.h:36
strttime
int strttime(char *timestr, char *timeformat, rodsLong_t *t)
Definition: datetime.cpp:10
smsi_gt
Res * smsi_gt(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1635
msiGetMoreRows
int msiGetMoreRows(msParam_t *genQueryInpParam, msParam_t *genQueryOutParam, msParam_t *contInxParam, ruleExecInfo_t *rei)
Definition: genQueryMS.cpp:292
reIterable_irods_data::i
int i
Definition: functions.cpp:484
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
newDatetimeRes
Res * newDatetimeRes(Region *r, long dt)
Definition: restructs.cpp:253
MsParam
Definition: msParam.h:76
newReIterableData
ReIterableData * newReIterableData(char *varName, Res *res, Node **subtrees, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg)
Definition: functions.cpp:109
smsi_applyAllRules
Res * smsi_applyAllRules(Node **subtrees, int, Node *, ruleExecInfo_t *rei, int, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:2226
reIterable_collection_data::dataObjInp
dataObjInp_t * dataObjInp
Definition: functions.cpp:519
irods::log
void log(const error &)
Definition: irods_log.cpp:13
smsi_exp
Res * smsi_exp(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1483
smsiCollectionSpider
Res * smsiCollectionSpider(Node **subtrees, int, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:2344
reIterable_list_hasNext
int reIterable_list_hasNext(ReIterableData *itrData, Region *r)
Definition: functions.cpp:464
smsi_ceiling
Res * smsi_ceiling(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1500
smsi_list
Res * smsi_list(Node **params, int n, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1160
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
lookupFromHashTable
const void * lookupFromHashTable(Hashtable *h, const char *key)
Definition: hashtable.cpp:222
node::base
char * base
Definition: restructs.hpp:255
smsi_divide
Res * smsi_divide(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1542
RECUR_QUERY_FG
#define RECUR_QUERY_FG
Definition: miscUtil.h:92
reIterableData::env
Env * env
Definition: functions.hpp:25
BytesBuf
Definition: rodsDef.h:197
cpEnv
void cpEnv(Env *env, Region *r)
Definition: utils.cpp:396
region
Definition: region.h:45
T_BOOL
@ T_BOOL
Definition: restructs.hpp:163
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
DATA_OBJ_T
@ DATA_OBJ_T
Definition: rodsType.h:38
reIterable_list_data::elems
Res ** elems
Definition: functions.cpp:450
RES_UNINTER_STRUCT
#define RES_UNINTER_STRUCT(x)
Definition: restructs.hpp:65
int
typedef int((*funcPtr)())
globalHashtable
static keyValPair_t globalHashtable
Definition: functions.cpp:52
RES_INT_VAL
#define RES_INT_VAL(x)
Definition: restructs.hpp:58
CollInp_MS_T
#define CollInp_MS_T
Definition: msParam.h:39
arithmetics.hpp
GC_ON
#define GC_ON(env)
Definition: functions.cpp:41
CollEnt::dataName
char * dataName
Definition: miscUtil.h:120
smsi_max
Res * smsi_max(Node **params, int n, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1052
reIterable_collection_data::handleInx
int handleInx
Definition: functions.cpp:518
createActionsNode
Node * createActionsNode(Node **params, int paramsLen, Label *exprloc, Region *r)
Definition: restructs.cpp:443
addMsParamToArray
int addMsParamToArray(msParamArray_t *msParamArray, const char *label, const char *type, void *inOutStruct, bytesBuf_t *inpOutBuf, int replFlag)
Definition: msParam.cpp:47
smsi_size
Res * smsi_size(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1218
MsParam::label
char * label
Definition: msParam.h:77
RuleDesc
Definition: restructs.hpp:272
ExecMyRuleInp
Definition: execMyRule.h:9
smsi_forEachExec
Res * smsi_forEachExec(Node **subtrees, int, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:718
smsi_type
Res * smsi_type(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1293
USER_PARAM_TYPE_ERR
@ USER_PARAM_TYPE_ERR
Definition: rodsErrorTable.h:254
getCollectionSize
int getCollectionSize(char *typ, void *inPtr)
Definition: conversion.cpp:118
smsi_neq
Res * smsi_neq(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1708
newEnv
Env * newEnv(Hashtable *current, Env *previous, Env *lower, Region *r)
Definition: restructs.cpp:281
smsi_eq
Res * smsi_eq(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1680
smsi_errorcode
Res * smsi_errorcode(Node **paramsr, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:1803
node::exprType
ExprType * exprType
Definition: restructs.hpp:250
findNextRule2
int findNextRule2(const char *action, int i, RuleIndexListNode **node)
Definition: index.cpp:322
RE_ITERABLE_INT_ARRAY
@ RE_ITERABLE_INT_ARRAY
Definition: functions.hpp:32
RuleExecInfo::uoic
userInfo_t * uoic
Definition: irods_re_structs.hpp:30
wildCardToRegex
char * wildCardToRegex(char *buf)
Definition: functions.cpp:2532
newBoolRes
Res * newBoolRes(Region *r, int n)
Definition: restructs.cpp:216
NodeType
enum node_type NodeType
matchPattern
Res * matchPattern(Node *pattern, Node *val, Env *env, ruleExecInfo_t *rei, int reiSaveFlag, rError_t *errmsg, Region *r)
Definition: arithmetics.cpp:1516
newRes
Res * newRes(Region *r)
Definition: restructs.cpp:176
evaluateActions
Res * evaluateActions(Node *expr, Node *reco, int applyAll, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: arithmetics.cpp:473
smsi_strlen
Res * smsi_strlen(Node **paramsr, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:2024
smsi_writeLine
Res * smsi_writeLine(Node **paramsr, int, Node *, ruleExecInfo_t *rei, int, Env *env, rError_t *, Region *r)
Definition: functions.cpp:1961
RuleExecInfo::msParamArray
msParamArray_t * msParamArray
Definition: irods_re_structs.hpp:24
rsDataObjLseek.hpp
smsi_eval
Res * smsi_eval(Node **paramsr, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:1788
RES_DOUBLE_VAL_LVAL
#define RES_DOUBLE_VAL_LVAL(x)
Definition: restructs.hpp:54
smsi_time
Res * smsi_time(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1263
smsi_query
Res * smsi_query(Node **subtrees, int, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:748
apiHeaderAll.h
stringOpr.h
reIterable_genQuery_data::len
int len
Definition: functions.cpp:367
smsi_floor
Res * smsi_floor(Node **params, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1494
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
KeyValPair_MS_T
#define KeyValPair_MS_T
Definition: msParam.h:37
reIterable_genQuery_data::genQueryOut
genQueryOut_t * genQueryOut
Definition: functions.cpp:370
error
int error
Definition: filesystem.cpp:101
RuleDesc::node
Node * node
Definition: restructs.hpp:275
globalSessionId
static char globalSessionId[(1024+64)]
Definition: functions.cpp:51
smsi_do
Res * smsi_do(Node **params, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:175
reIterableData::node
Node * node
Definition: functions.hpp:22
RuleExecInfo
Definition: irods_re_structs.hpp:18
T_INT
@ T_INT
Definition: restructs.hpp:160
RES_IRODS_TYPE
#define RES_IRODS_TYPE(x)
Definition: restructs.hpp:67
reIterable_genQuery_data::i
int i
Definition: functions.cpp:365
smsi_min
Res * smsi_min(Node **params, int n, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1069
N_ERROR
@ N_ERROR
Definition: restructs.hpp:111
KeyValPair::len
int len
Definition: objInfo.h:121
T_TUPLE
@ T_TUPLE
Definition: restructs.hpp:166
newCollRes
Res * newCollRes(int size, ExprType *elemType, Region *r)
Definition: restructs.cpp:161
env::current
Hashtable * current
Definition: restructs.hpp:227
newHashTable
Hashtable * newHashTable(int size)
Definition: hashtable.cpp:46
region_free
void region_free(Region *r)
Definition: region.cpp:146
deleteMsParamArray
void deleteMsParamArray(msParamArray_t *msParamArray)
Definition: restructs.cpp:274
ALL_MS_PARAM_KW
#define ALL_MS_PARAM_KW
Definition: rodsKeyWdDef.h:73
newFunctionFD
FunctionDesc * newFunctionFD(char *type, SmsiFuncTypePtr func, Region *r)
Definition: restructs.cpp:323
reIterableTable
ReIterableTableRow reIterableTable[7]
Definition: functions.cpp:99
irods::exception
Definition: irods_exception.hpp:15
replMsParam
int replMsParam(msParam_t *msParam, msParam_t *outMsParam)
Definition: msParam.cpp:156
newConsType
ExprType * newConsType(int arity, char *cons, ExprType **paramTypes, Region *r)
Definition: restructs.cpp:88
construct
Node * construct(char *fn, Node **args, int argc, Node *constype, Region *r)
Definition: functions.cpp:2508
newUnspecifiedRes
Res * newUnspecifiedRes(Region *r)
Definition: restructs.cpp:247
smsi_tuple
Res * smsi_tuple(Node **params, int n, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1174
ruleEngineConfig
Cache ruleEngineConfig
Definition: configuration.cpp:68
parseAndComputeExpression
Res * parseAndComputeExpression(char *expr, Env *env, ruleExecInfo_t *rei, int reiSaveFlag, rError_t *errmsg, Region *r)
Definition: rules.cpp:497
CollEnt::objType
objType_t objType
Definition: miscUtil.h:114
CollInp::collName
char collName[(1024+64)]
Definition: dataObjInpOut.h:158
ReIterableType
enum reIterableType ReIterableType
smsi_errormsg
Res * smsi_errormsg(Node **paramsr, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:1825
newTupleRes
Res * newTupleRes(int arity, Res **compTypes, Region *r)
Definition: restructs.cpp:148
hashtable
Definition: irods_hashtable.h:16
smsi_datetime
Res * smsi_datetime(Node **params, int n, Node *, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1230
reIterable_genQuery_data::genQOutParam
msParam_t genQOutParam
Definition: functions.cpp:369
smsi_elem
Res * smsi_elem(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1192
smsi_remoteExec
Res * smsi_remoteExec(Node **paramsr, int, Node *node, ruleExecInfo_t *rei, int, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:1882
smsi_average
Res * smsi_average(Node **params, int n, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1086
writeToTmp
int writeToTmp(char *fileName, char *text)
Definition: utils.cpp:681
SmsiFuncTypePtr
SmsiFuncType * SmsiFuncTypePtr
Definition: restructs.hpp:233
smsi_forEach2Exec
Res * smsi_forEach2Exec(Node **subtrees, int, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:624
smsi_matchExec
Res * smsi_matchExec(Node **params, int n, Node *node, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:200
RES_ERR_CODE
#define RES_ERR_CODE(x)
Definition: restructs.hpp:50
size
long long size
Definition: filesystem.cpp:102
smsi_listapprules
Res * smsi_listapprules(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1029
smsi_forExec
Res * smsi_forExec(Node **params, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:259
smsi_setReLogging
Res * smsi_setReLogging(Node **paramsr, int, Node *node, ruleExecInfo_t *rei, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:2158
userInfo_t::authInfo
authInfo_t authInfo
Definition: rodsUser.h:70
label
Definition: restructs.hpp:288
smsi_delayExec
Res * smsi_delayExec(Node **paramsr, int, Node *node, ruleExecInfo_t *rei, int, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:1848
parseHostAddrStr
int parseHostAddrStr(char *hostAddr, rodsHostAddr_t *addr)
Definition: rcMisc.cpp:3552
smsi_abs
Res * smsi_abs(Node **args, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1473
MsParam::inOutStruct
void * inOutStruct
Definition: msParam.h:80
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
reIterable_list_next
Res * reIterable_list_next(ReIterableData *itrData, Region *r)
Definition: functions.cpp:469
dataObjOpr.hpp
rsApiHandler.hpp
MsParamArray
Definition: msParam.h:84
RES_INT_VAL_LVAL
#define RES_INT_VAL_LVAL(x)
Definition: restructs.hpp:55
smsi_ifExec
Res * smsi_ifExec(Node **params, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:149
getAttrIdFromAttrName
int getAttrIdFromAttrName(char *cname)
Definition: rcMisc.cpp:2751
smsi_tl
Res * smsi_tl(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1105
smsi_whileExec
Res * smsi_whileExec(Node **params, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:223
ExecMyRuleInp::addr
rodsHostAddr_t addr
Definition: execMyRule.h:11
freeGenQueryOut
int freeGenQueryOut(genQueryOut_t **genQueryOut)
Definition: rcMisc.cpp:1133
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
T_ERROR
@ T_ERROR
Definition: restructs.hpp:157
reIterable_irods_hasNext
int reIterable_irods_hasNext(ReIterableData *itrData, Region *r)
Definition: functions.cpp:496
KeyValPair
Definition: objInfo.h:120
smsi_segfault
Res * smsi_segfault(Node **, int, Node *node, ruleExecInfo_t *rei, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:2562
smsi_listcorerules
Res * smsi_listcorerules(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1021
newMsParamArray
msParamArray_t * newMsParamArray()
Definition: restructs.cpp:266
T_CONS_TYPE_ARG
#define T_CONS_TYPE_ARG(x, n)
Definition: restructs.hpp:26
reFuncDefs.hpp
matchWholeString
char * matchWholeString(char *buf)
Definition: functions.cpp:2523
authInfo_t::authFlag
int authFlag
Definition: rodsUser.h:42
RE_ITERABLE_GEN_QUERY
@ RE_ITERABLE_GEN_QUERY
Definition: functions.hpp:35
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
smsi_letExec
Res * smsi_letExec(Node **params, int, Node *, ruleExecInfo_t *rei, int reiSaveFlag, Env *env, rError_t *errmsg, Region *r)
Definition: functions.cpp:184
newStringRes
Res * newStringRes(Region *r, const char *s)
Definition: restructs.cpp:235
buf
static char buf[64+50+1]
Definition: rsAuthRequest.cpp:21
deleteHashTable
void deleteHashTable(Hashtable *h, void(*f)(const void *))
Definition: hashtable.cpp:260
manual_cleanup.out
out
Definition: manual_cleanup.py:29
DataObjInfo
Definition: objInfo.h:129
reIterableData::reiSaveFlag
int reiSaveFlag
Definition: functions.hpp:24
RES_BOOL_VAL
#define RES_BOOL_VAL(x)
Definition: restructs.hpp:59
smsi_lt
Res * smsi_lt(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1589
reIterable_collection_hasNext
int reIterable_collection_hasNext(ReIterableData *itrData, Region *r)
Definition: functions.cpp:562
reIterable_list_data
Definition: functions.cpp:449
T_SUCCESS
@ T_SUCCESS
Definition: restructs.hpp:170
cache.hpp
ERR_MSG_SEP
#define ERR_MSG_SEP
Definition: reconstants.hpp:21
nop
void nop(const void *a)
Definition: hashtable.cpp:284
RE_UNSUPPORTED_OP_OR_TYPE
@ RE_UNSUPPORTED_OP_OR_TYPE
Definition: rodsErrorTable.h:702
cpStringExt
char * cpStringExt(const char *str, Region *r)
Definition: utils.cpp:358
ExecMyRuleInp::inpParamArray
msParamArray_t * inpParamArray
Definition: execMyRule.h:14
rodsHostAddr_t::zoneName
char zoneName[64]
Definition: rodsDef.h:298
reIterable_irods_data::n
int n
Definition: functions.cpp:485
freeRErrorContent
int freeRErrorContent(rError_t *myError)
Definition: rcMisc.cpp:182
ReIterable_list_data
struct reIterable_list_data ReIterable_list_data
setVariableValue
Res * setVariableValue(char *varName, Res *val, Node *node, ruleExecInfo_t *rei, Env *env, rError_t *errmsg, Region *r)
Definition: arithmetics.cpp:1672
smsi_false
Res * smsi_false(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:1048
ERR_MSG_LEN
#define ERR_MSG_LEN
Definition: rodsError.h:16
IntArray_MS_T
#define IntArray_MS_T
Definition: msParam.h:45
LIST
#define LIST
Definition: reconstants.hpp:14
RES_BOOL_VAL_LVAL
#define RES_BOOL_VAL_LVAL(x)
Definition: restructs.hpp:56
smsi_undefined
Res * smsi_undefined(Node **, int, Node *, ruleExecInfo_t *, int, Env *, rError_t *, Region *r)
Definition: functions.cpp:2108
Cache::extRuleSet
RuleSet * extRuleSet
Definition: configuration.hpp:55
typeName_Res
char * typeName_Res(Res *s)
Definition: parser.cpp:3415
smsi_int
Res * smsi_int(Node **params, int, Node *node, ruleExecInfo_t *, int, Env *, rError_t *errmsg, Region *r)
Definition: functions.cpp:1409
FAIL_ACTION_ENCOUNTERED_ERR
@ FAIL_ACTION_ENCOUNTERED_ERR
Definition: rodsErrorTable.h:665