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)  

rcMisc.cpp
Go to the documentation of this file.
1 
4 /* rcMisc.c - misc client routines
5  */
6 #ifndef windows_platform
7 #include <sys/time.h>
8 #include <sys/wait.h>
9 #else
10 #include "Unix2Nt.hpp"
11 #endif
12 #include "rcMisc.h"
13 #include "apiHeaderAll.h"
14 #include "modDataObjMeta.h"
15 #include "rcGlobalExtern.h"
16 #include "rodsGenQueryNames.h"
17 #include "rodsType.h"
18 #include "dataObjPut.h"
19 
20 #include "bulkDataObjPut.h"
21 #include "putUtil.h"
22 #include "sockComm.h"
23 
24 #include "json.hpp"
25 
26 #include <cstdlib>
27 #include <iostream>
28 #include <iomanip>
29 #include <algorithm>
30 #include <string>
31 #include <map>
32 #include <random>
33 #include <openssl/md5.h>
34 
35 // =-=-=-=-=-=-=-
36 #include "irods_virtual_path.hpp"
38 #include "irods_stacktrace.hpp"
39 #include "irods_exception.hpp"
40 #include "irods_log.hpp"
41 #include "irods_random.hpp"
42 #include "irods_path_recursion.hpp"
44 
45 // =-=-=-=-=-=-=-
46 // boost includes
47 #include <boost/filesystem.hpp>
48 #include <boost/lexical_cast.hpp>
49 #include <boost/filesystem/operations.hpp>
50 #include <boost/filesystem/convenience.hpp>
51 #include <boost/format.hpp>
52 #include <boost/generator_iterator.hpp>
53 
54 /* check with the input path is a valid path -
55  * 1 - valid
56  * 0 - not valid
57  */
58 
59 int
60 isPath( char *myPath ) {
61  namespace fs = boost::filesystem;
62 
63  fs::path p( myPath );
64 
65  if ( exists( p ) ) {
66  return 1;
67  }
68  else {
69  return 0;
70  }
71 }
72 
74 getFileSize( char *myPath ) {
75  namespace fs = boost::filesystem;
76 
77  fs::path p( myPath );
78 
79  if ( exists( p ) && is_regular_file( p ) ) {
80  return file_size( p );
81  }
82  else {
83  return -1;
84  }
85 }
86 
87 
88 int freeBBuf( bytesBuf_t *myBBuf ) {
89  if ( myBBuf == NULL ) {
90  return 0;
91  }
92 
93  if ( myBBuf->buf != NULL ) {
94  free( myBBuf->buf );
95  }
96  free( myBBuf );
97  return 0;
98 }
99 
100 int
101 clearBBuf( bytesBuf_t *myBBuf ) {
102  if ( myBBuf == NULL ) {
103  return 0;
104  }
105 
106  if ( myBBuf->buf != NULL ) {
107  free( myBBuf->buf );
108  }
109 
110  memset( myBBuf, 0, sizeof( bytesBuf_t ) );
111  return 0;
112 }
113 
114 /* addRErrorMsg - Add an error msg to the rError_t struct.
115  * rError_t *myError - the rError_t struct for the error msg.
116  * int status - the input error status.
117  * char *msg - the error msg string. This string will be copied to myError.
118  */
119 
120 int
121 addRErrorMsg( rError_t *myError, int status, const char *msg ) {
122  rErrMsg_t **newErrMsg;
123  int newLen;
124  int i;
125 
126  if ( myError == NULL ) {
128  }
129 
130  if ( ( myError->len % PTR_ARRAY_MALLOC_LEN ) == 0 ) {
131  newLen = myError->len + PTR_ARRAY_MALLOC_LEN;
132  newErrMsg = ( rErrMsg_t ** ) malloc( newLen * sizeof( *newErrMsg ) );
133  memset( newErrMsg, 0, newLen * sizeof( *newErrMsg ) );
134  for ( i = 0; i < myError->len; i++ ) {
135  newErrMsg[i] = myError->errMsg[i];
136  }
137  if ( myError->errMsg != NULL ) {
138  free( myError->errMsg );
139  }
140  myError->errMsg = newErrMsg;
141  }
142 
143  myError->errMsg[myError->len] = ( rErrMsg_t* )malloc( sizeof( rErrMsg_t ) );
144  strncpy( myError->errMsg[myError->len]->msg, msg, ERR_MSG_LEN - 1 );
145  myError->errMsg[myError->len]->status = status;
146  myError->len++;
147 
148  return 0;
149 }
150 
151 int
152 replErrorStack( rError_t *srcRError, rError_t *destRError ) {
153  int i, len;
154  rErrMsg_t *errMsg;
155 
156  if ( srcRError == NULL || destRError == NULL ) {
157  return USER__NULL_INPUT_ERR;
158  }
159 
160  len = srcRError->len;
161 
162  for ( i = 0; i < len; i++ ) {
163  errMsg = srcRError->errMsg[i];
164  addRErrorMsg( destRError, errMsg->status, errMsg->msg );
165  }
166  return 0;
167 }
168 
169 int
170 freeRError( rError_t *myError ) {
171 
172  if ( myError == NULL ) {
173  return 0;
174  }
175 
176  freeRErrorContent( myError );
177  free( myError );
178  return 0;
179 }
180 
181 int
183  int i;
184 
185  if ( myError == NULL ) {
186  return 0;
187  }
188 
189  if ( myError->len > 0 ) {
190  for ( i = 0; i < myError->len; i++ ) {
191  free( myError->errMsg[i] );
192  }
193  free( myError->errMsg );
194  }
195 
196  memset( myError, 0, sizeof( rError_t ) );
197 
198  return 0;
199 }
200 
201 //Only split the username from the zone name, based on the first occurence of '#'
202 //Further parsing of the username is the responsibility of the database plugin.
203 int
204 parseUserName( const char * fullUserNameIn, char * userName, char * userZone ) {
205  const char * octothorpePointer = strchr( fullUserNameIn, '#' );
206  const std::string userNameString = octothorpePointer ?
207  std::string( fullUserNameIn, octothorpePointer - fullUserNameIn ) :
208  std::string( fullUserNameIn );
209  const std::string zoneNameString = octothorpePointer ?
210  std::string( octothorpePointer + 1 ) :
211  std::string();
212  if ( zoneNameString.find( '#' ) != std::string::npos || userNameString.size() >= NAME_LEN || zoneNameString.size() >= NAME_LEN ) {
213  if ( userName != NULL ) {
214  userName[0] = '\0';
215  }
216  if ( userZone != NULL ) {
217  userZone[0] = '\0';
218  }
220  }
221 
222  if ( userName != NULL ) {
223  snprintf( userName, NAME_LEN, "%s", userNameString.c_str() );
224  }
225  if ( userZone != NULL ) {
226  snprintf( userZone, NAME_LEN, "%s", zoneNameString.c_str() );
227  }
228  return 0;
229 }
230 
231 int
232 myHtonll( rodsLong_t inlonglong, rodsLong_t *outlonglong ) {
233  char *inPtr, *outPtr;
234 
235  if ( outlonglong == NULL ) {
237  }
238 
239  if ( ntohl( 1 ) == 1 ) {
240  *outlonglong = inlonglong;
241  return 0;
242  }
243 
244  inPtr = ( char * )( static_cast< void * >( &inlonglong ) );
245  outPtr = ( char * )( static_cast<void *>( outlonglong ) );
246 
247  int i;
248  int byte_length = sizeof( rodsLong_t );
249  for ( i = 0; i < byte_length; i++ ) {
250  outPtr[i] = inPtr[byte_length - 1 - i];
251  }
252  return 0;
253 }
254 
255 int
256 myNtohll( rodsLong_t inlonglong, rodsLong_t *outlonglong ) {
257  char *inPtr, *outPtr;
258 
259  if ( outlonglong == NULL ) {
261  }
262 
263  if ( ntohl( 1 ) == 1 ) {
264  *outlonglong = inlonglong;
265  return 0;
266  }
267 
268  inPtr = ( char * )( static_cast< void * >( &inlonglong ) );
269  outPtr = ( char * )( static_cast<void *>( outlonglong ) );
270 
271  int i;
272  int byte_length = sizeof( rodsLong_t );
273  for ( i = 0; i < byte_length; i++ ) {
274  outPtr[i] = inPtr[byte_length - 1 - i];
275  }
276  return 0;
277 }
278 
279 int
280 statToRodsStat( rodsStat_t *rodsStat, struct stat *myFileStat ) {
281  if ( rodsStat == NULL || myFileStat == NULL ) {
283  }
284 
285  rodsStat->st_size = myFileStat->st_size;
286  rodsStat->st_dev = myFileStat->st_dev;
287  rodsStat->st_ino = myFileStat->st_ino;
288  rodsStat->st_mode = myFileStat->st_mode;
289  rodsStat->st_nlink = myFileStat->st_nlink;
290  rodsStat->st_uid = myFileStat->st_uid;
291  rodsStat->st_gid = myFileStat->st_gid;
292  rodsStat->st_rdev = myFileStat->st_rdev;
293  rodsStat->st_atim = myFileStat->st_atime;
294  rodsStat->st_mtim = myFileStat->st_mtime;
295  rodsStat->st_ctim = myFileStat->st_ctime;
296 #ifndef _WIN32
297  rodsStat->st_blksize = myFileStat->st_blksize;
298  rodsStat->st_blocks = myFileStat->st_blocks;
299 #endif
300 
301  return 0;
302 }
303 
304 int
305 rodsStatToStat( struct stat *myFileStat, rodsStat_t *rodsStat ) {
306  if ( myFileStat == NULL || rodsStat == NULL ) {
308  }
309 
310  myFileStat->st_size = rodsStat->st_size;
311  myFileStat->st_dev = rodsStat->st_dev;
312  myFileStat->st_ino = rodsStat->st_ino;
313  myFileStat->st_mode = rodsStat->st_mode;
314  myFileStat->st_nlink = rodsStat->st_nlink;
315  myFileStat->st_uid = rodsStat->st_uid;
316  myFileStat->st_gid = rodsStat->st_gid;
317  myFileStat->st_rdev = rodsStat->st_rdev;
318  myFileStat->st_atime = rodsStat->st_atim;
319  myFileStat->st_mtime = rodsStat->st_mtim;
320  myFileStat->st_ctime = rodsStat->st_ctim;
321 #ifndef _WIN32
322  myFileStat->st_blksize = rodsStat->st_blksize;
323  myFileStat->st_blocks = rodsStat->st_blocks;
324 #endif
325 
326  return 0;
327 }
328 
329 int
330 direntToRodsDirent( struct rodsDirent *dirent, struct dirent *fileDirent ) {
331  if ( dirent == NULL || fileDirent == NULL ) {
333  }
334 
335  strcpy( dirent->d_name, fileDirent->d_name );
336 
337 #if defined(linux_platform)
338  dirent->d_ino = fileDirent->d_ino;
339  dirent->d_offset = 0;
340  dirent->d_reclen = fileDirent->d_reclen;
341  dirent->d_namlen = _D_EXACT_NAMLEN( fileDirent );
342 #elif defined(solaris_platform)
343  dirent->d_ino = fileDirent->d_ino;
344  dirent->d_offset = fileDirent->d_off;
345  dirent->d_reclen = fileDirent->d_reclen;
346  dirent->d_namlen = 0;
347 #elif defined(aix_platform)
348  dirent->d_ino = fileDirent->d_ino;
349  dirent->d_offset = fileDirent->d_offset;
350  dirent->d_reclen = fileDirent->d_reclen;
351  dirent->d_namlen = fileDirent->d_namlen;
352 #elif defined(sgi_platform)
353  dirent->d_ino = fileDirent->d_ino;
354  dirent->d_offset = fileDirent->d_off;
355  dirent->d_reclen = fileDirent->d_reclen;
356  dirent->d_namlen = 0;
357 #elif defined(sunos_platform)
358  dirent->d_ino = fileDirent->d_fileno;
359  dirent->d_offset = fileDirent->d_off;
360  dirent->d_reclen = fileDirent->d_reclen;
361  dirent->d_namlen = fileDirent->d_namlen;
362 #elif defined(alpha_platform)
363  dirent->d_ino = fileDirent->d_ino;
364  dirent->d_offset = 0;
365  dirent->d_reclen = fileDirent->d_reclen;
366  dirent->d_namlen = fileDirent->d_namlen;
367 #elif defined(osx_platform)
368  dirent->d_ino = fileDirent->d_ino;
369  dirent->d_offset = 0;
370  dirent->d_reclen = fileDirent->d_reclen;
371  dirent->d_namlen = fileDirent->d_namlen;
372 #elif defined(windows_platform)
373  dirent->d_ino = fileDirent->d_ino;
374  dirent->d_offset = 0;
375  dirent->d_reclen = 0;
376  dirent->d_namlen = 0;
377 #else /* unknown. use linux */
378  dirent->d_ino = fileDirent->d_ino;
379  dirent->d_offset = 0;
380  dirent->d_reclen = fileDirent->d_reclen;
381  dirent->d_namlen = _D_EXACT_NAMLEN( fileDirent );
382 #endif
383  return 0;
384 }
385 
386 /* getStrInBuf get the next str in buf.
387  * treat # as comment. ignore any leading white space.
388  * Return the length of str copied, not including NULL.
389  * bufSize is the remaining len in inbuf to be processed
390  */
391 
392 int
393 getStrInBuf( char **inbuf, char *outbuf, int *inbufLen, int outbufLen ) {
394  char *inPtr, *outPtr;
395  int bytesCopied = 0;
396  int c;
397 
398  inPtr = *inbuf;
399  outPtr = outbuf;
400 
401  while ( ( c = *inPtr ) != '\0' && *inbufLen > 0 ) {
402  ( *inbufLen )--;
403  inPtr ++;
404  if ( isspace( c ) ) {
405  if ( bytesCopied > 0 ) {
406  break;
407  }
408  else {
409  continue;
410  }
411  }
412  else if ( c == '#' ) {
413  break;
414  }
415  else {
416  if ( bytesCopied >= outbufLen - 1 ) {
418  "getStrInBuf: outbuf overflow buf len %d", bytesCopied );
419  break;
420  }
421  *outPtr = c;
422  bytesCopied ++;
423  outPtr++;
424  }
425  }
426  *outPtr = '\0';
427  *inbuf = inPtr;
428  return bytesCopied;
429 }
430 
431 /* getNextEleInStr - same as getStrInBuf except it did not check for # */
432 int
433 getNextEleInStr( char **inbuf, char *outbuf, int *inbufLen, int maxOutLen ) {
434  char *inPtr, *outPtr;
435  int bytesCopied = 0;
436  int c;
437  int hasQuote;
438 
439  inPtr = *inbuf;
440  outPtr = outbuf;
441 
442  hasQuote = 0;
443  while ( ( c = *inPtr ) != '\0' && *inbufLen > 0 ) {
444  ( *inbufLen )--;
445  inPtr ++;
446  if ( isspace( c ) && hasQuote == False ) {
447  if ( bytesCopied > 0 ) {
448  break;
449  }
450  else {
451  continue;
452  }
453  }
454  else if ( c == '\'' ) {
455  if ( hasQuote == True ) {
456  inPtr ++;
457  break;
458  }
459  else {
460  hasQuote = True;
461  }
462  }
463  else {
464  if ( bytesCopied >= maxOutLen - 1 ) {
466  "getNextEleInStr: outbuf overflow buf len %d", bytesCopied );
467  break;
468  }
469  *outPtr = c;
470  bytesCopied ++;
471  outPtr++;
472  }
473  }
474  *outPtr = '\0';
475  *inbuf = inPtr;
476  return bytesCopied;
477 }
478 
479 /* getLine - Read the next line. Add a NULL char at the end.
480  * return the length of the line including the terminating NULL.
481  */
482 
483 int
484 getLine( FILE *fp, char *buf, int bufSize ) {
485  int c;
486  int len = 0;
487  char *cptr = buf;
488 
489  while ( ( c = getc( fp ) ) != EOF ) {
490  if ( c == '\n' ) {
491  break;
492  }
493  *cptr ++ = c;
494  len ++;
495 
496  /* overflow buf ? */
497  if ( len >= bufSize - 1 ) {
498  rodsLog( LOG_ERROR, "getLine: buffer overflow bufSize %d",
499  bufSize );
500  break;
501  }
502 
503  }
504  if ( c == EOF && len == 0 ) {
505  return EOF;
506  }
507  else {
508  *cptr ++ = '\0';
509  len ++;
510  return len;
511  }
512 }
513 
515  const char* _hint,
516  char* _zone_name,
517  int _len ) {
518  if ( !_hint ) {
519  _zone_name[0] = '\0';
520  return 0;
521  }
522 
523  const std::string sep = irods::get_virtual_path_separator();
524 
525  std::string hint( _hint );
526  if ( sep[0] == hint[0] ) {
527  std::string::size_type pos = hint.find( sep, 1 );
528  if ( std::string::npos != pos ) {
529  hint = hint.substr( 1, pos - 1 );
530 
531  }
532  else {
533  hint = hint.substr( 1 );
534 
535  }
536  }
537 
538  snprintf( _zone_name, _len, "%s", hint.c_str() );
539 
540  return 0;
541 }
542 
543 int
545  if ( dataObjInfo == NULL ) {
546  return 0;
547  }
548 
549  clearKeyVal( &dataObjInfo->condInput );
550  /* separate specColl */
551  if ( dataObjInfo->specColl != NULL ) {
552  free( dataObjInfo->specColl );
553  }
554 
555  free( dataObjInfo );
556  dataObjInfo = 0;
557  return 0;
558 }
559 
560 int
561 freeAllDataObjInfo( dataObjInfo_t *dataObjInfoHead ) {
562  dataObjInfo_t *tmpDataObjInfo, *nextDataObjInfo;
563 
564  tmpDataObjInfo = dataObjInfoHead;
565  while ( tmpDataObjInfo != NULL ) {
566  nextDataObjInfo = tmpDataObjInfo->next;
567  freeDataObjInfo( tmpDataObjInfo );
568  tmpDataObjInfo = nextDataObjInfo;
569  }
570  return 0;
571 }
572 
573 /* queDataObjInfo - queue the input dataObjInfo in dataObjInfoHead queue.
574  * Input
575  * int singleInfoFlag - 1 - the input dataObjInfo is a single dataObjInfo.
576  * 0 - the input dataObjInfo is a link list
577  * int topFlag - 1 - queue the input dataObjInfo at the head of the queue
578  * 0 - queue the input dataObjInfo at the bottom of the
579  * queue.
580  */
582  dataObjInfo_t** dataObjInfoHead,
583  dataObjInfo_t* dataObjInfo,
584  int singleInfoFlag,
585  int topFlag ) {
586 
587  dataObjInfo_t *tmpDataObjInfo;
588 
589  if ( dataObjInfo == NULL ) {
590  return -1;
591  }
592 
593  if ( *dataObjInfoHead == NULL ) {
594  *dataObjInfoHead = dataObjInfo;
595  if ( singleInfoFlag > 0 ) {
596  dataObjInfo->next = NULL;
597  }
598  }
599  else {
600  if ( topFlag > 0 ) {
601  dataObjInfo_t *savedDataObjInfo;
602 
603  savedDataObjInfo = *dataObjInfoHead;
604  *dataObjInfoHead = dataObjInfo;
605  if ( singleInfoFlag > 0 ) {
606  ( *dataObjInfoHead )->next = savedDataObjInfo;
607  }
608  else {
609  /* have to drill down to find the last DataObjInfo */
610  tmpDataObjInfo = *dataObjInfoHead;
611  while ( tmpDataObjInfo->next != NULL ) {
612  tmpDataObjInfo = tmpDataObjInfo->next;
613  }
614  tmpDataObjInfo->next = savedDataObjInfo;
615  }
616  }
617  else {
618  tmpDataObjInfo = *dataObjInfoHead;
619  while ( tmpDataObjInfo->next != NULL ) {
620  tmpDataObjInfo = tmpDataObjInfo->next;
621  }
622  tmpDataObjInfo->next = dataObjInfo;
623 
624  if ( singleInfoFlag > 0 ) {
625  dataObjInfo->next = NULL;
626  }
627  }
628  }
629 
630  return 0;
631 }
632 // =-=-=-=-=-=-=-
633 // JMC - backport 4590
634 int
635 dequeDataObjInfo( dataObjInfo_t **dataObjInfoHead, dataObjInfo_t *dataObjInfo ) {
636  dataObjInfo_t *tmpDataObjInfo;
637  dataObjInfo_t *prevDataObjInfo = NULL;
638 
639  if ( dataObjInfo == NULL || dataObjInfoHead == NULL ) {
640  return -1;
641  }
642 
643  tmpDataObjInfo = *dataObjInfoHead;
644  while ( tmpDataObjInfo != NULL ) {
645  if ( tmpDataObjInfo == dataObjInfo ) {
646  if ( prevDataObjInfo == NULL ) {
647  *dataObjInfoHead = tmpDataObjInfo->next;
648  }
649  else {
650  prevDataObjInfo->next = tmpDataObjInfo->next;
651  }
652  return 0;
653  }
654  prevDataObjInfo = tmpDataObjInfo;
655  tmpDataObjInfo = tmpDataObjInfo->next;
656  }
657  return -1;
658 }
659 // =-=-=-=-=-=-=-
660 int
661 getDataObjInfoCnt( dataObjInfo_t *dataObjInfoHead ) {
662  dataObjInfo_t *tmpDataObjInfo;
663  int cnt = 0;
664  tmpDataObjInfo = dataObjInfoHead;
665 
666  while ( tmpDataObjInfo != NULL ) {
667  cnt++;
668  tmpDataObjInfo = tmpDataObjInfo->next;
669  }
670 
671  return cnt;
672 }
673 
674 char *
675 getValByKey( const keyValPair_t *condInput, const char *keyWord ) {
676  int i;
677 
678  if ( condInput == NULL ) {
679  return NULL;
680  }
681 
682  for ( i = 0; i < condInput->len; i++ ) {
683  if ( strcmp( condInput->keyWord[i], keyWord ) == 0 ) {
684  return condInput->value[i];
685  }
686  }
687 
688  return NULL;
689 }
690 
691 int
692 getIvalByInx( inxIvalPair_t *inxIvalPair, int inx, int *outValue ) {
693  int i;
694 
695  if ( inxIvalPair == NULL ) {
696  return UNMATCHED_KEY_OR_INDEX;
697  }
698 
699  for ( i = 0; i < inxIvalPair->len; i++ ) {
700  if ( inxIvalPair->inx[i] == inx ) {
701  *outValue = inxIvalPair->value[i];
702  return 0;
703  }
704  }
705 
706  return UNMATCHED_KEY_OR_INDEX;
707 }
708 
709 int
710 rmKeyVal( keyValPair_t *condInput, const char *keyWord ) {
711  int i, j;
712 
713  if ( condInput == NULL ) {
714  return 0;
715  }
716 
717  for ( i = 0; i < condInput->len; i++ ) {
718  if ( condInput->keyWord[i] != NULL &&
719  strcmp( condInput->keyWord[i], keyWord ) == 0 ) {
720  free( condInput->keyWord[i] );
721  free( condInput->value[i] );
722  condInput->len--;
723  for ( j = i; j < condInput->len; j++ ) {
724  condInput->keyWord[j] = condInput->keyWord[j + 1];
725  condInput->value[j] = condInput->value[j + 1];
726  }
727  if ( condInput->len <= 0 ) {
728  free( condInput->keyWord );
729  free( condInput->value );
730  condInput->value = condInput->keyWord = NULL;
731  }
732  break;
733  }
734  }
735  return 0;
736 }
737 
738 int
739 replKeyVal( const keyValPair_t *srcCondInput, keyValPair_t *destCondInput ) {
740  int i;
741 
742  memset( destCondInput, 0, sizeof( keyValPair_t ) );
743 
744  for ( i = 0; i < srcCondInput->len; i++ ) {
745  addKeyVal( destCondInput, srcCondInput->keyWord[i],
746  srcCondInput->value[i] );
747  }
748  return 0;
749 }
750 
752  const keyValPair_t* _src,
753  keyValPair_t* _dst ) {
754  // =-=-=-=-=-=-=-
755  // blatantly copy the src kvp to the dst
756  for ( int i = 0; i < _src->len; ++i ) {
757  addKeyVal( _dst, _src->keyWord[i], _src->value[i] );
758 
759  }
760 
761  return 0;
762 }
763 
764 int
765 replDataObjInp( dataObjInp_t *srcDataObjInp, dataObjInp_t *destDataObjInp ) {
766  *destDataObjInp = *srcDataObjInp;
767 
768  destDataObjInp->condInput.len = 0;
769  destDataObjInp->condInput.keyWord = NULL;
770  destDataObjInp->condInput.value = NULL;
771 
772  replKeyVal( &srcDataObjInp->condInput, &destDataObjInp->condInput );
773  replSpecColl( srcDataObjInp->specColl, &destDataObjInp->specColl );
774  return 0;
775 }
776 
777 int
778 replSpecColl( specColl_t *inSpecColl, specColl_t **outSpecColl ) {
779  if ( inSpecColl == NULL || outSpecColl == NULL ) {
780  return USER__NULL_INPUT_ERR;
781  }
782  *outSpecColl = ( specColl_t * )malloc( sizeof( specColl_t ) );
783  *( *outSpecColl ) = *inSpecColl;
784 
785  return 0;
786 }
787 
788 int
789 addKeyVal( keyValPair_t *condInput, const char *keyWord, const char *value ) {
790  if ( condInput == NULL ) {
792  }
793  if ( condInput->keyWord == NULL || condInput->value == NULL ) {
794  condInput->len = 0;
795  }
796 
797  /* check if the keyword exists */
798  for ( int i = 0; i < condInput->len; i++ ) {
799  if ( condInput->keyWord[i] == NULL || strlen( condInput->keyWord[i] ) == 0 ) {
800  free( condInput->keyWord[i] );
801  free( condInput->value[i] );
802  condInput->keyWord[i] = strdup( keyWord );
803  condInput->value[i] = value ? strdup( value ) : NULL;
804  return 0;
805  }
806  else if ( strcmp( keyWord, condInput->keyWord[i] ) == 0 ) {
807  free( condInput->value[i] );
808  condInput->value[i] = value ? strdup( value ) : NULL;
809  return 0;
810  }
811  }
812 
813  if ( ( condInput->len % PTR_ARRAY_MALLOC_LEN ) == 0 ) {
814  condInput->keyWord = ( char ** )realloc( condInput->keyWord,
815  ( condInput->len + PTR_ARRAY_MALLOC_LEN ) * sizeof( *condInput->keyWord ) );
816  condInput->value = ( char ** )realloc( condInput->value,
817  ( condInput->len + PTR_ARRAY_MALLOC_LEN ) * sizeof( *condInput->value ) );
818  memset( condInput->keyWord + condInput->len, 0, PTR_ARRAY_MALLOC_LEN * sizeof( *condInput->keyWord ) );
819  memset( condInput->value + condInput->len, 0, PTR_ARRAY_MALLOC_LEN * sizeof( *condInput->value ) );
820  }
821 
822  condInput->keyWord[condInput->len] = strdup( keyWord );
823  condInput->value[condInput->len] = value ? strdup( value ) : NULL;
824  condInput->len++;
825 
826  return 0;
827 }
828 
829 
830 int
831 addTagStruct( tagStruct_t *condInput, char *preTag, char *postTag, char *keyWord ) {
832  char **newKeyWord;
833  char **newPreTag;
834  char **newPostTag;
835  int newLen;
836  int i;
837 
838  if ( condInput == NULL ) {
840  }
841 
842 
843 
844  if ( ( condInput->len % PTR_ARRAY_MALLOC_LEN ) == 0 ) {
845  newLen = condInput->len + PTR_ARRAY_MALLOC_LEN;
846  newKeyWord = ( char ** ) malloc( newLen * sizeof( *newKeyWord ) );
847  newPreTag = ( char ** ) malloc( newLen * sizeof( *newPreTag ) );
848  newPostTag = ( char ** ) malloc( newLen * sizeof( *newPostTag ) );
849  memset( newKeyWord, 0, newLen * sizeof( *newKeyWord ) );
850  memset( newPreTag, 0, newLen * sizeof( *newPreTag ) );
851  memset( newPostTag, 0, newLen * sizeof( *newPostTag ) );
852  for ( i = 0; i < condInput->len; i++ ) {
853  newKeyWord[i] = condInput->keyWord[i];
854  newPreTag[i] = condInput->preTag[i];
855  newPostTag[i] = condInput->postTag[i];
856  }
857  if ( condInput->keyWord != NULL ) {
858  free( condInput->keyWord );
859  }
860  if ( condInput->preTag != NULL ) {
861  free( condInput->preTag );
862  }
863  if ( condInput->postTag != NULL ) {
864  free( condInput->postTag );
865  }
866  condInput->keyWord = newKeyWord;
867  condInput->preTag = newPreTag;
868  condInput->postTag = newPostTag;
869  }
870 
871  condInput->keyWord[condInput->len] = strdup( keyWord );
872  condInput->preTag[condInput->len] = strdup( preTag );
873  condInput->postTag[condInput->len] = strdup( postTag );
874  condInput->len++;
875 
876  return 0;
877 }
878 
879 
880 
881 
882 int
883 addInxIval( inxIvalPair_t *inxIvalPair, int inx, int value ) {
884  int *newInx;
885  int *newValue;
886  int newLen;
887  int i;
888 
889  if ( inxIvalPair == NULL ) {
891  }
892 
893  if ( ( inxIvalPair->len % PTR_ARRAY_MALLOC_LEN ) == 0 ) {
894  newLen = inxIvalPair->len + PTR_ARRAY_MALLOC_LEN;
895  newInx = ( int * ) malloc( newLen * sizeof( int ) );
896  newValue = ( int * ) malloc( newLen * sizeof( int ) );
897  memset( newInx, 0, newLen * sizeof( int ) );
898  memset( newValue, 0, newLen * sizeof( int ) );
899  for ( i = 0; i < inxIvalPair->len; i++ ) {
900  newInx[i] = inxIvalPair->inx[i];
901  newValue[i] = inxIvalPair->value[i];
902  }
903  if ( inxIvalPair->inx != NULL ) {
904  free( inxIvalPair->inx );
905  }
906  if ( inxIvalPair->value != NULL ) {
907  free( inxIvalPair->value );
908  }
909  inxIvalPair->inx = newInx;
910  inxIvalPair->value = newValue;
911  }
912 
913  inxIvalPair->inx[inxIvalPair->len] = inx;
914  inxIvalPair->value[inxIvalPair->len] = value;
915  inxIvalPair->len++;
916 
917  return 0;
918 }
919 
920 int
921 addInxVal( inxValPair_t *inxValPair, int inx, const char *value ) {
922  int *newInx;
923  char **newValue;
924  int newLen;
925  int i;
926 
927  if ( inxValPair == NULL ) {
929  }
930 
931  if ( ( inxValPair->len % PTR_ARRAY_MALLOC_LEN ) == 0 ) {
932  newLen = inxValPair->len + PTR_ARRAY_MALLOC_LEN;
933  newInx = ( int * ) malloc( newLen * sizeof( *newInx ) );
934  newValue = ( char ** ) malloc( newLen * sizeof( *newValue ) );
935  memset( newInx, 0, newLen * sizeof( *newInx ) );
936  memset( newValue, 0, newLen * sizeof( *newValue ) );
937  for ( i = 0; i < inxValPair->len; i++ ) {
938  newInx[i] = inxValPair->inx[i];
939  newValue[i] = inxValPair->value[i];
940  }
941  if ( inxValPair->inx != NULL ) {
942  free( inxValPair->inx );
943  }
944  if ( inxValPair->value != NULL ) {
945  free( inxValPair->value );
946  }
947  inxValPair->inx = newInx;
948  inxValPair->value = newValue;
949  }
950 
951  inxValPair->inx[inxValPair->len] = inx;
952  inxValPair->value[inxValPair->len] = strdup( value );
953  inxValPair->len++;
954 
955  return 0;
956 }
957 
958 int
959 addStrArray( strArray_t *strArray, char *value ) {
960  char *newValue;
961  int newLen;
962  int i;
963  int size;
964  int myLen;
965 
966  if ( strArray == NULL ) {
968  }
969 
970  if ( strArray->size <= 0 ) {
971  if ( strArray->len == 0 ) {
972  /* default to NAME_LEN */
973 
974  strArray->size = NAME_LEN;
975  }
976  else {
978  "addStrArray: invalid size %d, len %d",
979  strArray->size, strArray->len );
981  }
982  }
983 
984  myLen = strlen( value );
985 
986  size = strArray->size;
987  while ( size < myLen + 1 ) {
988  size = size * 2;
989  }
990 
991 
992  /* XXXXXXX should be replaced by resizeStrArray after 2.3 release */
993  if ( size != strArray->size ||
994  ( strArray->len % PTR_ARRAY_MALLOC_LEN ) == 0 ) {
995  int oldSize = strArray->size;
996  /* have to redo it */
997  strArray->size = size;
998  newLen = strArray->len + PTR_ARRAY_MALLOC_LEN;
999  newValue = ( char * ) malloc( newLen * size );
1000  memset( newValue, 0, newLen * size );
1001  for ( i = 0; i < strArray->len; i++ ) {
1002  rstrcpy( &newValue[i * size], &strArray->value[i * oldSize], size );
1003  }
1004  if ( strArray->value != NULL ) {
1005  free( strArray->value );
1006  }
1007  strArray->value = newValue;
1008  }
1009 
1010  rstrcpy( &strArray->value[strArray->len * size], value, size );
1011  strArray->len++;
1012 
1013  return 0;
1014 }
1015 
1016 int
1017 resizeStrArray( strArray_t *strArray, int newSize ) {
1018  int i, newLen;
1019  char *newValue;
1020 
1021  if ( newSize > strArray->size ||
1022  ( strArray->len % PTR_ARRAY_MALLOC_LEN ) == 0 ) {
1023  int oldSize = strArray->size;
1024  /* have to redo it */
1025  if ( strArray->size > newSize ) {
1026  newSize = strArray->size;
1027  }
1028  else {
1029  strArray->size = newSize;
1030  }
1031  newLen = strArray->len + PTR_ARRAY_MALLOC_LEN;
1032  newValue = ( char * ) malloc( newLen * newSize );
1033  memset( newValue, 0, newLen * newSize );
1034  for ( i = 0; i < strArray->len; i++ ) {
1035  rstrcpy( &newValue[i * newSize], &strArray->value[i * oldSize],
1036  newSize );
1037  }
1038  if ( strArray->value != NULL ) {
1039  free( strArray->value );
1040  }
1041  strArray->value = newValue;
1042  }
1043  return 0;
1044 }
1045 
1046 int
1047 clearKeyVal( keyValPair_t *condInput ) {
1048 
1049  if ( condInput == NULL || condInput->len < 1 ) {
1050  return 0;
1051  }
1052 
1053  for ( int i = 0; i < condInput->len; i++ ) {
1054  if ( condInput->keyWord != NULL ) {
1055  free( condInput->keyWord[i] );
1056  }
1057  if ( condInput->value != NULL ) {
1058  free( condInput->value[i] );
1059  }
1060  }
1061 
1062  free( condInput->keyWord );
1063  free( condInput->value );
1064  memset( condInput, 0, sizeof( keyValPair_t ) );
1065  return 0;
1066 }
1067 
1068 int
1069 clearInxIval( inxIvalPair_t *inxIvalPair ) {
1070  if ( inxIvalPair == NULL || inxIvalPair->len <= 0 ) {
1071  return 0;
1072  }
1073 
1074  free( inxIvalPair->inx );
1075  free( inxIvalPair->value );
1076  memset( inxIvalPair, 0, sizeof( inxIvalPair_t ) );
1077 
1078  return 0;
1079 }
1080 
1081 int
1082 clearInxVal( inxValPair_t *inxValPair ) {
1083  int i;
1084 
1085  if ( inxValPair == NULL || inxValPair->len <= 0 ) {
1086  return 0;
1087  }
1088 
1089  for ( i = 0; i < inxValPair->len; i++ ) {
1090  free( inxValPair->value[i] );
1091  }
1092 
1093  free( inxValPair->inx );
1094  free( inxValPair->value );
1095  memset( inxValPair, 0, sizeof( inxValPair_t ) );
1096 
1097  return 0;
1098 }
1099 
1100 int
1101 freeGenQueryInp( genQueryInp_t **genQueryInp ) {
1102  if ( genQueryInp == NULL ) {
1103  return 0;
1104  }
1105 
1106  if ( *genQueryInp == NULL ) {
1107  return 0;
1108  }
1109 
1110  clearGenQueryInp( *genQueryInp );
1111  free( *genQueryInp );
1112  *genQueryInp = NULL;
1113 
1114  return 0;
1115 }
1116 
1117 void
1118 clearGenQueryInp( void* voidInp ) {
1119 
1120  if ( voidInp == NULL ) {
1121  return;
1122  }
1123 
1124  genQueryInp_t *genQueryInp = ( genQueryInp_t* ) voidInp;
1125  clearInxIval( &genQueryInp->selectInp );
1126  clearInxVal( &genQueryInp->sqlCondInp );
1127  clearKeyVal( &genQueryInp->condInput );
1128 
1129  return;
1130 }
1131 
1132 int
1133 freeGenQueryOut( genQueryOut_t **genQueryOut ) {
1134  if ( genQueryOut == NULL ) {
1135  return 0;
1136  }
1137 
1138  if ( *genQueryOut == NULL ) {
1139  return 0;
1140  }
1141 
1142  clearGenQueryOut( *genQueryOut );
1143  free( *genQueryOut );
1144  *genQueryOut = NULL;
1145 
1146  return 0;
1147 }
1148 
1149 void
1150 clearGenQueryOut( void* voidInp ) {
1151  genQueryOut_t *genQueryOut = ( genQueryOut_t* ) voidInp;
1152  int i;
1153 
1154  if ( genQueryOut == NULL ) {
1155  return;
1156  }
1157 
1158  for ( i = 0; i < genQueryOut->attriCnt; i++ ) {
1159  if ( genQueryOut->sqlResult[i].value != NULL ) {
1160  free( genQueryOut->sqlResult[i].value );
1161  }
1162  }
1163  return;
1164 }
1165 
1166 /* catGenQueryOut - Concatenate genQueryOut to targGenQueryOut up to maxRowCnt.
1167  * It is assumed that the two genQueryOut have the same attriInx and
1168  * len for each attri.
1169  *
1170  */
1171 int
1172 catGenQueryOut( genQueryOut_t *targGenQueryOut, genQueryOut_t *genQueryOut,
1173  int maxRowCnt ) {
1174  int i;
1175  int totalRowCnt;
1176 
1177  /* do some sanity checks */
1178 
1179 
1180  if ( targGenQueryOut == NULL || genQueryOut == NULL ) {
1181  return USER__NULL_INPUT_ERR;
1182  }
1183 
1184  if ( genQueryOut->rowCnt == 0 ) {
1185  return 0;
1186  }
1187 
1188  if ( ( totalRowCnt = targGenQueryOut->rowCnt + genQueryOut->rowCnt ) >
1189  maxRowCnt ) {
1190  rodsLog( LOG_ERROR,
1191  "catGenQueryOut: total rowCnt %d > %d",
1192  targGenQueryOut->rowCnt + genQueryOut->rowCnt, maxRowCnt );
1194  }
1195 
1196 
1197  if ( targGenQueryOut->attriCnt != genQueryOut->attriCnt ) {
1198  rodsLog( LOG_ERROR,
1199  "catGenQueryOut: attriCnt mismatch %d != %d",
1200  targGenQueryOut->attriCnt, genQueryOut->attriCnt );
1202  }
1203 
1204  for ( i = 0; i < genQueryOut->attriCnt; i++ ) {
1205  if ( targGenQueryOut->sqlResult[i].attriInx !=
1206  genQueryOut->sqlResult[i].attriInx ) {
1207  rodsLog( LOG_ERROR,
1208  "catGenQueryOut: attriInx mismatch %d != %d",
1209  targGenQueryOut->sqlResult[i].attriInx,
1210  genQueryOut->sqlResult[i].attriInx );
1212  }
1213  if ( targGenQueryOut->sqlResult[i].len !=
1214  genQueryOut->sqlResult[i].len ) {
1215  rodsLog( LOG_ERROR,
1216  "catGenQueryOut: len mismatch %d != %d",
1217  targGenQueryOut->sqlResult[i].len, genQueryOut->sqlResult[i].len );
1219  }
1220  }
1221 
1222  for ( i = 0; i < genQueryOut->attriCnt; i++ ) {
1223  char *tmpValue;
1224  int len;
1225 
1226  if ( ( len = genQueryOut->sqlResult[i].len ) <= 0 ) {
1227  continue;
1228  }
1229  if ( ( tmpValue = ( char * )malloc( totalRowCnt * len ) ) == 0 ) {
1230  return SYS_MALLOC_ERR - errno;
1231  }
1232  if ( targGenQueryOut->sqlResult[i].value != NULL ) {
1233  memcpy( tmpValue, targGenQueryOut->sqlResult[i].value,
1234  len * targGenQueryOut->rowCnt );
1235  free( targGenQueryOut->sqlResult[i].value );
1236  }
1237  targGenQueryOut->sqlResult[i].value = tmpValue;
1238  tmpValue += len * targGenQueryOut->rowCnt;
1239  memcpy( tmpValue, genQueryOut->sqlResult[i].value,
1240  len * genQueryOut->rowCnt );
1241  }
1242  targGenQueryOut->rowCnt = totalRowCnt;
1243 
1244  return 0;
1245 }
1246 
1247 void
1248 clearBulkOprInp( void* voidInp ) {
1249  bulkOprInp_t *bulkOprInp = ( bulkOprInp_t* ) voidInp;
1250  if ( bulkOprInp == NULL ) {
1251  return;
1252  }
1253  clearGenQueryOut( &bulkOprInp->attriArray );
1254  clearKeyVal( &bulkOprInp->condInput );
1255  return;
1256 }
1257 
1258 int
1259 moveKeyVal( keyValPair_t *destKeyVal, keyValPair_t *srcKeyVal ) {
1260  if ( destKeyVal == NULL || srcKeyVal == NULL ) {
1261  return 0;
1262  }
1263 
1264  *destKeyVal = *srcKeyVal;
1265  memset( srcKeyVal, 0, sizeof( keyValPair_t ) );
1266  return 0;
1267 }
1268 
1269 int
1270 getUnixUid( char *userName ) {
1271 #ifndef _WIN32
1272  struct passwd *pw = 0;
1273  int myuid = 0;
1274  char* splitPos = 0;
1275 
1276  if ( ( splitPos = strchr( userName, '@' ) ) != NULL ) {
1277  *splitPos = '\0'; /* skip @ */
1278  }
1279 
1280  if ( !( pw = getpwnam( userName ) ) ) {
1281  myuid = -1;
1282  }
1283  else {
1284  myuid = ( int ) pw->pw_uid;
1285  }
1286  if ( splitPos != NULL ) {
1287  *splitPos = '@';
1288  }
1289  return myuid;
1290 #else
1291  return -1;
1292 #endif
1293 }
1294 
1295 int
1296 getUnixUsername( int uid, char *username, int username_len ) {
1297 #ifndef _WIN32
1298  struct passwd *pwent;
1299 
1300  if ( uid < 0 || username == NULL ) {
1301  return USER__NULL_INPUT_ERR;
1302  }
1303 
1304  /* if getpwuid returns NULL and errno is zero, it
1305  means the user doesn't exist in the user db */
1306  errno = 0;
1307  pwent = getpwuid( uid );
1308  if ( pwent == NULL ) {
1309  if ( errno ) {
1310  rodsLog( LOG_ERROR,
1311  "getUnixUsername: error calling getpwuid for uid %d. errno = %d",
1312  uid, errno );
1313  }
1314  else {
1315  rodsLog( LOG_ERROR, "getUnixUsername: no user with uid %d", uid );
1316  }
1317  return SYS_USER_RETRIEVE_ERR - errno;
1318  }
1319  if ( ( unsigned int )username_len <= strlen( pwent->pw_name ) ) {
1320  rodsLog( LOG_ERROR, "getUnixUsername: username input buffer too small (%d <= %d)",
1321  username_len, strlen( pwent->pw_name ) );
1322  return USER_STRLEN_TOOLONG;
1323  }
1324  strcpy( username, pwent->pw_name );
1325 
1326  return 0;
1327 #else
1328  return -1;
1329 #endif
1330 }
1331 
1332 int
1333 getUnixGroupname( int gid, char *groupname, int groupname_len ) {
1334 #ifndef _WIN32
1335  struct group *grent;
1336 
1337  if ( gid < 0 || groupname == NULL ) {
1338  return USER__NULL_INPUT_ERR;
1339  }
1340 
1341  errno = 0;
1342  grent = getgrgid( gid );
1343  if ( grent == NULL ) {
1344  if ( errno ) {
1345  rodsLog( LOG_ERROR,
1346  "getUnixGroupname: error calling getgrgid for gid %d. errno = %d",
1347  gid, errno );
1348  }
1349  else {
1350  rodsLog( LOG_ERROR, "getUnixGroupname: no group with gid %d", gid );
1351  }
1352  return SYS_GROUP_RETRIEVE_ERR - errno;
1353  }
1354  if ( ( unsigned int )groupname_len <= strlen( grent->gr_name ) ) {
1355  rodsLog( LOG_ERROR, "getUnixGroupname: groupname input buffer too small (%d <= %d)",
1356  groupname_len, strlen( grent->gr_name ) );
1357  return USER_STRLEN_TOOLONG;
1358  }
1359  strcpy( groupname, grent->gr_name );
1360 
1361  return 0;
1362 #else
1363  return -1;
1364 #endif
1365 }
1366 
1367 /*
1368  Return 64 semi-random bytes terminated by a null.
1369  hex encodes 32 random bytes to prevent troublesome values
1370  */
1371 int get64RandomBytes( char *buf ) {
1372  const int num_random_bytes = 32;
1373  const int num_hex_bytes = 2 * num_random_bytes;
1374  unsigned char random_bytes[num_random_bytes];
1375  irods::getRandomBytes( random_bytes, sizeof(random_bytes) );
1376 
1377  std::stringstream ss;
1378  for ( size_t i = 0; i < sizeof(random_bytes); ++i ) {
1379  ss << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)( random_bytes[i] );
1380  }
1381 
1382  snprintf( buf, num_hex_bytes+1, "%s", ss.str().c_str() );
1383  return 0;
1384 }
1385 
1386 sqlResult_t *
1387 getSqlResultByInx( genQueryOut_t *genQueryOut, int attriInx ) {
1388  int i;
1389 
1390  if ( genQueryOut == NULL ) {
1391  return NULL;
1392  }
1393 
1394  for ( i = 0; i < genQueryOut->attriCnt; i++ ) {
1395  if ( genQueryOut->sqlResult[i].attriInx == attriInx ) {
1396  return &genQueryOut->sqlResult[i];
1397  }
1398  }
1399  return NULL;
1400 }
1401 
1402 void
1403 clearModDataObjMetaInp( void* voidInp ) {
1404  modDataObjMeta_t *modDataObjMetaInp = ( modDataObjMeta_t* ) voidInp;
1405  if ( modDataObjMetaInp == NULL ) {
1406  return;
1407  }
1408 
1409  if ( modDataObjMetaInp->regParam != NULL ) {
1410  clearKeyVal( modDataObjMetaInp->regParam );
1411  free( modDataObjMetaInp->regParam );
1412  }
1413 
1414  if ( modDataObjMetaInp->dataObjInfo != NULL ) {
1415  freeDataObjInfo( modDataObjMetaInp->dataObjInfo );
1416  }
1417 
1418  return;
1419 }
1420 
1421 void
1422 clearUnregDataObj( void* voidInp ) {
1423  unregDataObj_t *unregDataObjInp = ( unregDataObj_t* ) voidInp;
1424  if ( unregDataObjInp == NULL ) {
1425  return;
1426  }
1427 
1428  if ( unregDataObjInp->condInput != NULL ) {
1429  clearKeyVal( unregDataObjInp->condInput );
1430  free( unregDataObjInp->condInput );
1431  }
1432 
1433  if ( unregDataObjInp->dataObjInfo != NULL ) {
1434  freeDataObjInfo( unregDataObjInp->dataObjInfo );
1435  }
1436 
1437  return ;
1438 }
1439 
1440 void
1441 clearRegReplicaInp( void* voidInp ) {
1442  regReplica_t *regReplicaInp = ( regReplica_t* ) voidInp;
1443  if ( regReplicaInp == NULL ) {
1444  return;
1445  }
1446 
1447  clearKeyVal( &regReplicaInp->condInput );
1448 
1449  if ( regReplicaInp->srcDataObjInfo != NULL ) {
1450  freeDataObjInfo( regReplicaInp->srcDataObjInfo );
1451  }
1452 
1453  if ( regReplicaInp->destDataObjInfo != NULL ) {
1454  freeDataObjInfo( regReplicaInp->destDataObjInfo );
1455  }
1456 
1457  memset( regReplicaInp, 0, sizeof( regReplica_t ) );
1458 
1459  return;
1460 }
1461 
1462 void
1463 clearFileOpenInp( void* voidInp ) {
1464  fileOpenInp_t *fileOpenInp = ( fileOpenInp_t* ) voidInp;
1465  if ( fileOpenInp == NULL ) {
1466  return;
1467  }
1468  clearKeyVal( &fileOpenInp->condInput );
1469  memset( fileOpenInp, 0, sizeof( fileOpenInp_t ) );
1470 
1471  return;
1472 }
1473 
1474 void
1475 clearDataObjInp( void* voidInp ) {
1476  dataObjInp_t *dataObjInp = ( dataObjInp_t* ) voidInp;
1477  if ( dataObjInp == NULL ) {
1478  return;
1479  }
1480 
1481  clearKeyVal( &dataObjInp->condInput );
1482  if ( dataObjInp->specColl != NULL ) {
1483  free( dataObjInp->specColl );
1484  }
1485 
1486  memset( dataObjInp, 0, sizeof( dataObjInp_t ) );
1487 
1488  return;
1489 }
1490 
1491 void
1492 clearCollInp( void* voidInp ) {
1493 
1494  collInp_t *collInp = ( collInp_t* ) voidInp;
1495  if ( collInp == NULL ) {
1496  return;
1497  }
1498 
1499  clearKeyVal( &collInp->condInput );
1500 
1501  memset( collInp, 0, sizeof( collInp_t ) );
1502 
1503  return;
1504 }
1505 
1506 void
1507 clearDataObjCopyInp( void* voidInp ) {
1508  dataObjCopyInp_t *dataObjCopyInp = ( dataObjCopyInp_t* ) voidInp;
1509  if ( dataObjCopyInp == NULL ) {
1510  return;
1511  }
1512 
1513  clearKeyVal( &dataObjCopyInp->destDataObjInp.condInput );
1514  clearKeyVal( &dataObjCopyInp->srcDataObjInp.condInput );
1515 
1516  if ( dataObjCopyInp->srcDataObjInp.specColl != NULL ) {
1517  free( dataObjCopyInp->srcDataObjInp.specColl );
1518  }
1519 
1520  memset( dataObjCopyInp, 0, sizeof( dataObjCopyInp_t ) );
1521 
1522  return;
1523 }
1524 
1525 int
1526 freeAllRescQuota( rescQuota_t *rescQuotaHead ) {
1527  rescQuota_t *tmpRescQuota, *nextRescQuota;
1528 
1529  tmpRescQuota = rescQuotaHead;
1530  while ( tmpRescQuota != NULL ) {
1531  nextRescQuota = tmpRescQuota->next;
1532  free( tmpRescQuota );
1533  tmpRescQuota = nextRescQuota;
1534  }
1535  return 0;
1536 }
1537 
1538 int
1539 parseMultiStr( char *strInput, strArray_t *strArray ) {
1540  char *startPtr, *endPtr;
1541  int endReached = 0;
1542 
1543  if ( strInput == NULL || strArray == NULL ) {
1545  }
1546 
1547  startPtr = endPtr = strInput;
1548 
1549  while ( 1 ) {
1550  // two %% will be taken as an input instead of as a delimiter
1551  while ( *endPtr != '%' && *endPtr != '\0' ) {
1552  endPtr ++;
1553  }
1554  if ( *endPtr == '%' ) {
1555  if ( *( endPtr + 1 ) == '%' ) {
1556  endPtr ++;
1557  endPtr ++;
1558  continue;
1559  }
1560  *endPtr = '\0';
1561  }
1562  else {
1563  endReached = 1;
1564  }
1565 
1566  addStrArray( strArray, startPtr );
1567 
1568  if ( endReached == 1 ) {
1569  break;
1570  }
1571 
1572  endPtr++;
1573  startPtr = endPtr;
1574  }
1575 
1576  return strArray->len;
1577 }
1578 
1579 /* Get the current time, in the form: 2006-10-25-10.52.43 */
1580 /* 0123456789012345678 */
1581 extern char *tzname[2];
1582 
1583 /*
1584  Return an integer string of the current time in the Unix Time
1585  format (integer seconds since 1970). This is the same
1586  in all timezones (sort of CUT) and is converted to local time
1587  for display.
1588  */
1589 void
1590 getNowStr( char *timeStr ) {
1591  time_t myTime;
1592 
1593  myTime = time( NULL );
1594  snprintf( timeStr, 15, "%011d", ( uint ) myTime );
1595 }
1596 
1597 /*
1598  Convert a Unix time value (as from getNowStr) to a local
1599  time format.
1600  */
1601 int
1602 getLocalTimeFromRodsTime( const char *timeStrIn, char *timeStr ) {
1603  time_t myTime;
1604  struct tm *mytm;
1605 
1606  // This is 1 because they actually capture a leading space
1607  if ( strlen( timeStrIn ) <= 1 ) {
1608  strcpy( timeStr, "Never" );
1609  }
1610  else {
1611  if ( sizeof( time_t ) == 4 ) {
1612  myTime = atol( timeStrIn );
1613  }
1614  else {
1615 #ifdef _WIN32
1616  myTime = _atoi64( timeStrIn );
1617 #else
1618  myTime = atoll( timeStrIn );
1619 #endif
1620  }
1621 
1622  mytm = localtime( &myTime );
1623 
1624  getLocalTimeStr( mytm, timeStr );
1625  }
1626  return 0;
1627 }
1628 
1629 int
1630 getLocalTimeStr( struct tm *mytm, char *timeStr ) {
1631  snprintf( timeStr, TIME_LEN, "%4d-%2d-%2d.%2d:%2d:%2d",
1632  mytm->tm_year + 1900, mytm->tm_mon + 1, mytm->tm_mday,
1633  mytm->tm_hour, mytm->tm_min, mytm->tm_sec );
1634 
1635  if ( timeStr[5] == ' ' ) {
1636  timeStr[5] = '0';
1637  }
1638  if ( timeStr[8] == ' ' ) {
1639  timeStr[8] = '0';
1640  }
1641  if ( timeStr[11] == ' ' ) {
1642  timeStr[11] = '0';
1643  }
1644  if ( timeStr[14] == ' ' ) {
1645  timeStr[14] = '0';
1646  }
1647  if ( timeStr[17] == ' ' ) {
1648  timeStr[17] = '0';
1649  }
1650 
1651  return 0;
1652 }
1653 
1654 
1655 /* Get the current time + offset , in the form: 2006-10-25-10.52.43 */
1656 /* offset is a string of the same form */
1657 /* 0123456789012345678 */
1658 void
1659 getOffsetTimeStr( char *timeStr, const char *offSet ) {
1660  time_t myTime;
1661 
1662  myTime = time( NULL );
1663  myTime += atoi( offSet );
1664 
1665  snprintf( timeStr, TIME_LEN, "%d", ( uint ) myTime );
1666 }
1667 
1668 /* Update the input time string to be offset minutes ahead of the
1669  input value. timeStr is input and ouput, in the form:
1670  2006-10-25-10.52.43
1671  0123456789012345678
1672  Offset the number of minutes to add.
1673  This is based on getOffsetTimeStr.
1674  */
1675 void
1676 updateOffsetTimeStr( char *timeStr, int offset ) {
1677  time_t myTime;
1678  struct tm *mytm;
1679  time_t newTime;
1680  char s[50];
1681 
1682  myTime = time( NULL );
1683  mytm = localtime( &myTime );
1684 
1685  rstrcpy( s, timeStr, 49 );
1686 
1687  s[19] = '\0';
1688  mytm->tm_sec = atoi( &s[17] );
1689  s[16] = '\0';
1690  mytm->tm_min = atoi( &s[14] );
1691  s[13] = '\0';
1692  mytm->tm_hour = atoi( &s[11] );
1693  s[10] = '\0';
1694  mytm->tm_mday = atoi( &s[8] );
1695  s[7] = '\0';
1696  mytm->tm_mon = atoi( &s[5] ) - 1;
1697  s[4] = '\0';
1698  mytm->tm_year = atoi( &s[0] ) - 1900;
1699 
1700  mytm->tm_min += offset; /* offset by the input minutes */
1701 
1702  newTime = mktime( mytm );
1703  mytm = localtime( &newTime );
1704 
1705  snprintf( timeStr, TIME_LEN, "%4d-%2d-%2d-%2d.%2d.%2d",
1706  mytm->tm_year + 1900, mytm->tm_mon + 1, mytm->tm_mday,
1707  mytm->tm_hour, mytm->tm_min, mytm->tm_sec );
1708 
1709  if ( timeStr[5] == ' ' ) {
1710  timeStr[5] = '0';
1711  }
1712  if ( timeStr[8] == ' ' ) {
1713  timeStr[8] = '0';
1714  }
1715  if ( timeStr[11] == ' ' ) {
1716  timeStr[11] = '0';
1717  }
1718  if ( timeStr[14] == ' ' ) {
1719  timeStr[14] = '0';
1720  }
1721  if ( timeStr[17] == ' ' ) {
1722  timeStr[17] = '0';
1723  }
1724 }
1725 
1726 /* getNextRepeatTime - analyze the string given in delayStr to output the time
1727  * in sec of unix time in string nextTime for the next repetition based on
1728  * the current time given in string currTime.
1729  * Strings currTime and nextTime will be in sec of unix time.
1730  * The delayStr is of the format:
1731  * nnnnU <directive> where
1732  * nnnn is a number, and
1733  * U is the unit of the number (s-sec,m-min,h-hour,d-day,y-year),
1734  * The <directive> can be for the form:
1735  * <empty-directive> - equal to REPEAT FOR EVER
1736  * REPEAT FOR EVER
1737  * REPEAT UNTIL SUCCESS
1738  * REPEAT nnnn TIMES - where nnnn is an integer
1739  * REPEAT UNTIL <time> - where <time> is of the time format
1740  * supported by checkDateFormat function below.
1741  * REPEAT UNTIL SUCCESS OR UNTIL <time>
1742  * REPEAT UNTIL SUCCESS OR nnnn TIMES
1743  *
1744  * DOUBLE FOR EVER
1745  * DOUBLE UNTIL SUCCESS - delay is doubled every time.
1746  * DOUBLE nnnn TIMES
1747  * DOUBLE UNTIL <time>
1748  * DOUBLE UNTIL SUCCESS OR UNTIL <time>
1749  * DOUBLE UNTIL SUCCESS OR nnnn TIMES
1750  * DOUBLE UNTIL SUCCESS UPTO <time>
1751  *
1752  * Return Values contain some semantics for followup actions:
1753  * 0 = continue with given delay
1754  * that is, update the delayExec entry with nextExec time.
1755  * 1 = if the first operation was successful no more repeats.
1756  * that is, remove the delayExec entry if execOp was successful.
1757  * otherwise update the delayExec entry with nextExec time.
1758  * 2 = no more repeats whether the operation was successful or not.
1759  * that is, remove the delayExec entry.
1760  * 3 = change the delayExec entry with new delayStr.
1761  * that is, change both delayStr as well as nextExec time.
1762  * 4 = if the first operation was successful no more repeats.
1763  * that is, remove the delayExec entry if execOp was successful.
1764  * otherwise change both delayStr as well as nextExec time.
1765  *
1766  */
1767 int
1768 getNextRepeatTime( char *currTime, char *delayStr, char *nextTime ) {
1769 
1770  rodsLong_t it, dt;
1771  char *t, *s;
1772  char u;
1773  char tstr[200];
1774  int n;
1775 
1776  t = delayStr;
1777  while ( isdigit( *t ) ) {
1778  t++;
1779  }
1780  u = *t;
1781  *t = '\0';
1782  dt = atol( delayStr );
1783  it = dt;
1784  *t = u;
1785  t++;
1786  switch ( u ) {
1787  case 's':
1788  break;
1789  case 'm':
1790  dt = dt * 60;
1791  break;
1792  case 'h':
1793  dt = dt * 3600;
1794  break;
1795  case 'd':
1796  dt = dt * 3600 * 24;
1797  break;
1798  case 'y':
1799  dt = dt * 3600 * 24 * 365;
1800  break;
1801  default:
1802  break;
1803  }
1804 
1805  while ( isspace( *t ) ) {
1806  t++;
1807  }
1808  if ( strlen( t ) == 0 || !strcmp( t, "REPEAT FOR EVER" ) ) {
1809  dt = dt + atol( currTime );
1810  sprintf( nextTime, "%lld", dt );
1811  return 0;
1812  }
1813  if ( !strcmp( t, "DOUBLE FOR EVER" ) ) {
1814  dt = dt + atol( currTime );
1815  sprintf( nextTime, "%lld", dt );
1816  sprintf( delayStr, "%lld%c DOUBLE FOR EVER", it * 2, u );
1817  return 3;
1818  }
1819  if ( ( s = strstr( t, "REPEAT UNTIL SUCCESS OR UNTIL " ) ) != NULL ) {
1820  s = s + strlen( "REPEAT UNTIL SUCCESS OR UNTIL " );
1821  while ( isspace( *s ) ) {
1822  s++;
1823  }
1824  snprintf( tstr, sizeof( tstr ), "%s", s );
1825  convertDateFormat( tstr, currTime );
1826  dt = dt + atol( currTime );
1827  sprintf( nextTime, "%lld", dt );
1828  if ( atol( tstr ) < dt ) {
1829  return 2;
1830  }
1831  else {
1832  return 1;
1833  }
1834  }
1835  if ( ( s = strstr( t, "DOUBLE UNTIL SUCCESS OR UNTIL " ) ) != NULL ) {
1836  s = s + strlen( "DOUBLE UNTIL SUCCESS OR UNTIL " );
1837  while ( isspace( *s ) ) {
1838  s++;
1839  }
1840  snprintf( tstr, sizeof( tstr ), "%s", s );
1841  convertDateFormat( tstr, currTime );
1842  dt = dt + atol( currTime );
1843  sprintf( nextTime, "%lld", dt );
1844  sprintf( delayStr, "%lld%c DOUBLE UNTIL SUCCESS OR UNTIL %s", it * 2, u, s );
1845  if ( atol( tstr ) < dt ) {
1846  return 2;
1847  }
1848  else {
1849  return 4;
1850  }
1851  }
1852  if ( ( s = strstr( t, "REPEAT UNTIL SUCCESS OR " ) ) != NULL ) {
1853  s = s + strlen( "REPEAT UNTIL SUCCESS OR " );
1854  while ( isspace( *s ) ) {
1855  s++;
1856  }
1857  snprintf( tstr, sizeof( tstr ), "%s", s );
1858  s = tstr;
1859  while ( isdigit( *s ) ) {
1860  s++;
1861  }
1862  *s = '\0';
1863  n = atoi( tstr );
1864  n--;
1865  dt = dt + atol( currTime );
1866  sprintf( nextTime, "%lld", dt );
1867  if ( strstr( s + 1, "ORIGINAL TIMES" ) != NULL ) {
1868  sprintf( delayStr, "%lld%c REPEAT UNTIL SUCCESS OR %i %s", it, u, n, s + 1 );
1869  }
1870  else {
1871  sprintf( delayStr, "%lld%c REPEAT UNTIL SUCCESS OR %i TIMES. ORIGINAL TIMES=%i", it, u, n, n + 1 );
1872  }
1873  if ( n <= 0 ) {
1874  return 2;
1875  }
1876  else {
1877  return 4;
1878  }
1879  }
1880  if ( ( s = strstr( t, "DOUBLE UNTIL SUCCESS OR " ) ) != NULL ) {
1881  s = s + strlen( "DOUBLE UNTIL SUCCESS OR " );
1882  while ( isspace( *s ) ) {
1883  s++;
1884  }
1885  snprintf( tstr, sizeof( tstr ), "%s", s );
1886  s = tstr;
1887  while ( isdigit( *s ) ) {
1888  s++;
1889  }
1890  *s = '\0';
1891  n = atoi( tstr );
1892  n--;
1893  dt = dt + atol( currTime );
1894  sprintf( nextTime, "%lld", dt );
1895  if ( strstr( s + 1, "ORIGINAL TIMES" ) != NULL ) {
1896  sprintf( delayStr, "%lld%c DOUBLE UNTIL SUCCESS OR %i %s", it * 2, u, n, s + 1 );
1897  }
1898  else {
1899  sprintf( delayStr, "%lld%c DOUBLE UNTIL SUCCESS OR %i TIMES. ORIGINAL TIMES=%i", it * 2, u, n, n + 1 );
1900  }
1901  if ( n <= 0 ) {
1902  return 2;
1903  }
1904  else {
1905  return 4;
1906  }
1907  }
1908  if ( ( s = strstr( t, "DOUBLE UNTIL SUCCESS UPTO " ) ) != NULL ) {
1909  s = s + strlen( "DOUBLE UNTIL SUCCESS UPTO " );
1910  while ( isspace( *s ) ) {
1911  s++;
1912  }
1913  snprintf( tstr, sizeof( tstr ), "%s", s );
1914  convertDateFormat( tstr, currTime );
1915  dt = dt + atol( currTime );
1916  sprintf( nextTime, "%lld", dt );
1917  sprintf( delayStr, "%lld%c DOUBLE UNTIL SUCCESS UPTO %s", it * 2, u, s );
1918  if ( atol( tstr ) > dt ) {
1919  sprintf( delayStr, "%lld%c DOUBLE UNTIL SUCCESS UPTO %s", it * 2 , u, s );
1920  }
1921  else {
1922  sprintf( delayStr, "%lld%c DOUBLE UNTIL SUCCESS UPTO %s", it , u, s );
1923  }
1924  return 4;
1925  }
1926  if ( strstr( t, "REPEAT UNTIL SUCCESS" ) != NULL ) {
1927  dt = dt + atol( currTime );
1928  sprintf( nextTime, "%lld", dt );
1929  return 1;
1930  }
1931  if ( strstr( t, "DOUBLE UNTIL SUCCESS" ) != NULL ) {
1932  dt = dt + atol( currTime );
1933  sprintf( nextTime, "%lld", dt );
1934  sprintf( delayStr, "%lld%c DOUBLE UNTIL SUCCESS", it * 2, u );
1935  return 4;
1936  }
1937  if ( ( s = strstr( t, "REPEAT UNTIL " ) ) != NULL ) {
1938  s = s + strlen( "REPEAT UNTIL " );
1939  while ( isspace( *s ) ) {
1940  s++;
1941  }
1942  snprintf( tstr, sizeof( tstr ), "%s", s );
1943  convertDateFormat( tstr, currTime );
1944  dt = dt + atol( currTime );
1945  sprintf( nextTime, "%lld", dt );
1946  if ( atol( tstr ) < dt ) {
1947  return 2;
1948  }
1949  else {
1950  return 0;
1951  }
1952  }
1953 
1954  if ( ( s = strstr( t, "DOUBLE UNTIL " ) ) != NULL ) {
1955  s = s + strlen( "DOUBLE UNTIL " );
1956  while ( isspace( *s ) ) {
1957  s++;
1958  }
1959  snprintf( tstr, sizeof( tstr ), "%s", s );
1960  convertDateFormat( tstr, currTime );
1961  dt = dt + atol( currTime );
1962  sprintf( nextTime, "%lld", dt );
1963  /* sprintf(delayStr,"%lld%c DOUBLE UNTIL %s", it * 2, u,s); */
1964  sprintf( delayStr, "%lld%c DOUBLE UNTIL %s", it * 2, u, tstr );
1965  if ( atol( tstr ) < dt ) {
1966  return 2;
1967  }
1968  else {
1969  return 3;
1970  }
1971 
1972  }
1973  if ( ( s = strstr( t, "REPEAT " ) ) != NULL ) {
1974  s = s + strlen( "REPEAT " );
1975  while ( isspace( *s ) ) {
1976  s++;
1977  }
1978  snprintf( tstr, sizeof( tstr ), "%s", s );
1979  s = tstr;
1980  while ( isdigit( *s ) ) {
1981  s++;
1982  }
1983  *s = '\0';
1984  n = atoi( tstr );
1985  n--;
1986 
1987  dt = dt + atol( currTime );
1988  sprintf( nextTime, "%lld", dt );
1989  if ( strstr( s + 1, "ORIGINAL TIMES" ) != NULL ) {
1990  sprintf( delayStr, "%lld%c REPEAT %i %s", it, u, n, s + 1 );
1991  }
1992  else {
1993  sprintf( delayStr, "%lld%c REPEAT %i TIMES. ORIGINAL TIMES=%i", it, u, n, n + 1 );
1994  }
1995  if ( n <= 0 ) {
1996  return 2;
1997  }
1998  else {
1999  return 3;
2000  }
2001  }
2002  if ( ( s = strstr( t, "DOUBLE " ) ) != NULL ) {
2003  s = s + strlen( "DOUBLE " );
2004  while ( isspace( *s ) ) {
2005  s++;
2006  }
2007  snprintf( tstr, sizeof( tstr ), "%s", s );
2008  s = tstr;
2009  while ( isdigit( *s ) ) {
2010  s++;
2011  }
2012  *s = '\0';
2013  n = atoi( tstr );
2014  n--;
2015  dt = dt + atol( currTime );
2016  sprintf( nextTime, "%lld", dt );
2017  if ( strstr( s + 1, "ORIGINAL TIMES" ) != NULL ) {
2018  sprintf( delayStr, "%lld%c DOUBLE %i %s", it * 2, u, n, s + 1 );
2019  }
2020  else {
2021  sprintf( delayStr, "%lld%c DOUBLE %i TIMES. ORIGINAL TIMES=%i", it * 2, u, n, n + 1 );
2022  }
2023  if ( n <= 0 ) {
2024  return 2;
2025  }
2026  else {
2027  return 3;
2028  }
2029  }
2030 
2031  return 0;
2032 }
2033 
2034 int
2035 localToUnixTime( char * localTime, char * unixTime ) {
2036  time_t myTime;
2037  struct tm *mytm;
2038  time_t newTime;
2039  char s[TIME_LEN];
2040 
2041  myTime = time( NULL );
2042  mytm = localtime( &myTime );
2043 
2044  rstrcpy( s, localTime, TIME_LEN );
2045 
2046  s[19] = '\0';
2047  mytm->tm_sec = atoi( &s[17] );
2048  s[16] = '\0';
2049  mytm->tm_min = atoi( &s[14] );
2050  s[13] = '\0';
2051  mytm->tm_hour = atoi( &s[11] );
2052  s[10] = '\0';
2053  mytm->tm_mday = atoi( &s[8] );
2054  s[7] = '\0';
2055  mytm->tm_mon = atoi( &s[5] ) - 1;
2056  s[4] = '\0';
2057  mytm->tm_year = atoi( &s[0] ) - 1900;
2058 
2059  newTime = mktime( mytm );
2060  if ( sizeof( newTime ) == 64 ) {
2061  snprintf( unixTime, TIME_LEN, "%lld", ( rodsLong_t ) newTime );
2062  }
2063  else {
2064  snprintf( unixTime, TIME_LEN, "%d", ( uint ) newTime );
2065  }
2066  return 0;
2067 }
2068 
2069 int
2070 isInteger( const char * inStr ) {
2071  int i;
2072  int len;
2073 
2074  len = strlen( inStr );
2075  /* see if it is all digit */
2076  for ( i = 0; i < len; i++ ) {
2077  if ( !isdigit( inStr[i] ) ) {
2078  return 0;
2079  }
2080  }
2081  return 1;
2082 }
2083 
2084 
2085 /* convertDateFormat - uses the checkDateFormat to convert string 's'
2086  * into sec of unix time. But if the time is in the YYYY-*** format
2087  * adds the current date (in unix seconds format) to forma full date
2088  */
2089 
2090 int
2091 convertDateFormat( char * s, char * currTime ) {
2092  rodsLong_t it;
2093  char tstr[200];
2094  int i;
2095  rstrcpy( tstr, s, 199 );
2096  i = checkDateFormat( tstr );
2097  if ( i != 0 ) {
2098  return i;
2099  }
2100  if ( !isInteger( s ) && strchr( s, '-' ) == NULL && strchr( s, ':' ) == NULL ) {
2101  it = atol( tstr ) + atol( currTime );
2102  sprintf( s, "%lld", it );
2103  }
2104  else {
2105  strcpy( s, tstr );
2106  }
2107  return 0;
2108 }
2109 
2110 /* checkDateFormat - convert the string given in s and output the time
2111  * in sec of unix time in the same string s
2112  * The input can be incremental time given in :
2113  * nnnn - an integer. assumed to be in sec
2114  * nnnns - an integer followed by 's' ==> in sec
2115  * nnnnm - an integer followed by 'm' ==> in min
2116  * nnnnh - an integer followed by 'h' ==> in hours
2117  * nnnnd - an integer followed by 'd' ==> in days
2118  * nnnny - an integer followed by 'y' ==> in years
2119  * dd.hh:mm:ss - where dd, hh, mm and ss are 2 digits integers representing
2120  * days, hours minutes and seconds, repectively. Truncation from the
2121  * end is allowed. e.g. 20:40 means mm:ss
2122  * The input can also be full calendar time in the form:
2123  * YYYY-MM-DD.hh:mm:ss - Truncation from the beginning is allowed.
2124  * e.g., 2007-07-29.12 means noon of July 29, 2007.
2125  *
2126  */
2127 
2128 int
2129 checkDateFormat( char * s ) {
2130  /* Note. The input *s is assumed to be TIME_LEN long */
2131  int len;
2132  char t[] = "0000-00-00.00:00:00";
2133  char outUnixTime[TIME_LEN];
2134  int status;
2135  int offset = 0;
2136 
2137  if ( isInteger( s ) ) {
2138  return 0;
2139  }
2140 
2141  len = strlen( s );
2142 
2143  if ( s[len - 1] == 's' ) {
2144  /* in sec */
2145  s[len - 1] = '\0';
2146  offset = atoi( s );
2147  snprintf( s, 19, "%d", offset );
2148  return 0;
2149  }
2150  else if ( s[len - 1] == 'm' ) {
2151  /* in min */
2152  s[len - 1] = '\0';
2153  offset = atoi( s ) * 60;
2154  snprintf( s, 19, "%d", offset );
2155  return 0;
2156  }
2157  else if ( s[len - 1] == 'h' ) {
2158  /* in hours */
2159  s[len - 1] = '\0';
2160  offset = atoi( s ) * 3600;
2161  snprintf( s, 19, "%d", offset );
2162  return 0;
2163  }
2164  else if ( s[len - 1] == 'd' ) {
2165  /* in days */
2166  s[len - 1] = '\0';
2167  offset = atoi( s ) * 3600 * 24;
2168  snprintf( s, 19, "%d", offset );
2169  return 0;
2170  }
2171  else if ( s[len - 1] == 'y' ) {
2172  /* in days */
2173  s[len - 1] = '\0';
2174  offset = atoi( s ) * 3600 * 24 * 365;
2175  snprintf( s, 19, "%d", offset );
2176  return 0;
2177  }
2178  else if ( len < 19 ) {
2179  /* not a full date. */
2180  if ( isdigit( s[0] ) && isdigit( s[1] ) && isdigit( s[2] ) && isdigit( s[3] ) ) {
2181  /* start with year, fill in the rest */
2182  strcat( s, ( char * )&t[len] );
2183  }
2184  else {
2185  /* must be offset */
2186  int mypos;
2187 
2188  /* sec */
2189  mypos = len - 1;
2190  while ( mypos >= 0 ) {
2191  if ( isdigit( s[mypos] ) ) {
2192  offset += s[mypos] - 48;
2193  }
2194  else {
2195  return DATE_FORMAT_ERR;
2196  }
2197 
2198  mypos--;
2199  if ( mypos >= 0 )
2200  if ( isdigit( s[mypos] ) ) {
2201  offset += 10 * ( s[mypos] - 48 );
2202  }
2203  else {
2204  return DATE_FORMAT_ERR;
2205  }
2206  else {
2207  break;
2208  }
2209 
2210  mypos--;
2211  if ( mypos >= 0 )
2212  if ( s[mypos] != ':' ) {
2213  return DATE_FORMAT_ERR;
2214  }
2215 
2216  /* min */
2217  mypos--;
2218  if ( mypos >= 0 )
2219  if ( isdigit( s[mypos] ) ) {
2220  offset += 60 * ( s[mypos] - 48 );
2221  }
2222  else {
2223  return DATE_FORMAT_ERR;
2224  }
2225  else {
2226  break;
2227  }
2228 
2229  mypos--;
2230  if ( mypos >= 0 )
2231  if ( isdigit( s[mypos] ) ) {
2232  offset += 10 * 60 * ( s[mypos] - 48 );
2233  }
2234  else {
2235  return DATE_FORMAT_ERR;
2236  }
2237  else {
2238  break;
2239  }
2240 
2241  mypos--;
2242  if ( mypos >= 0 )
2243  if ( s[mypos] != ':' ) {
2244  return DATE_FORMAT_ERR;
2245  }
2246 
2247  /* hour */
2248  mypos--;
2249  if ( mypos >= 0 )
2250  if ( isdigit( s[mypos] ) ) {
2251  offset += 3600 * ( s[mypos] - 48 );
2252  }
2253  else {
2254  return DATE_FORMAT_ERR;
2255  }
2256  else {
2257  break;
2258  }
2259 
2260  mypos--;
2261  if ( mypos >= 0 )
2262  if ( isdigit( s[mypos] ) ) {
2263  offset += 10 * 3600 * ( s[mypos] - 48 );
2264  }
2265  else {
2266  return DATE_FORMAT_ERR;
2267  }
2268  else {
2269  break;
2270  }
2271 
2272  mypos--;
2273  if ( mypos >= 0 )
2274  if ( s[mypos] != '.' ) {
2275  return DATE_FORMAT_ERR;
2276  }
2277 
2278  /* day */
2279 
2280  mypos--;
2281  if ( mypos >= 0 )
2282  if ( isdigit( s[mypos] ) ) {
2283  offset += 24 * 3600 * ( s[mypos] - 48 );
2284  }
2285  else {
2286  return DATE_FORMAT_ERR;
2287  }
2288  else {
2289  break;
2290  }
2291 
2292  mypos--;
2293  if ( mypos >= 0 )
2294  if ( isdigit( s[mypos] ) ) {
2295  offset += 10 * 24 * 3600 * ( s[mypos] - 48 );
2296  }
2297  else {
2298  return DATE_FORMAT_ERR;
2299  }
2300  else {
2301  break;
2302  }
2303  }
2304  snprintf( s, 19, "%d", offset );
2305  return 0;
2306  }
2307  }
2308 
2309  if ( isdigit( s[0] ) && isdigit( s[1] ) && isdigit( s[2] ) && isdigit( s[3] ) &&
2310  isdigit( s[5] ) && isdigit( s[6] ) && isdigit( s[8] ) && isdigit( s[9] ) &&
2311  isdigit( s[11] ) && isdigit( s[12] ) && isdigit( s[14] ) && isdigit( s[15] ) &&
2312  isdigit( s[17] ) && isdigit( s[18] ) &&
2313  s[4] == '-' && s[7] == '-' && s[10] == '.' &&
2314  s[13] == ':' && s[16] == ':' ) {
2315  status = localToUnixTime( s, outUnixTime );
2316  if ( status >= 0 ) {
2317  rstrcpy( s, outUnixTime, TIME_LEN );
2318  }
2319  return status;
2320  }
2321  else {
2322  return DATE_FORMAT_ERR;
2323  }
2324 }
2325 
2326 int
2328  int i, len;
2329  rErrMsg_t *errMsg;
2330 
2331  if ( rError == NULL ) {
2332  return 0;
2333  }
2334 
2335  len = rError->len;
2336 
2337  for ( i = 0; i < len; i++ ) {
2338  errMsg = rError->errMsg[i];
2339  if ( errMsg->status != STDOUT_STATUS ) {
2340  printf( "Level %d: ", i );
2341  }
2342  printf( "%s\n", errMsg->msg );
2343  }
2344  return 0;
2345 }
2346 
2347 int
2348 appendRandomToPath( char * trashPath ) {
2349  int len;
2350  char *tmpPtr;
2351 
2352  len = strlen( trashPath );
2353 
2354  /* assume there is enough space for MAX_NAME_LEN char */
2355 
2356  if ( len >= MAX_NAME_LEN + 12 ) {
2357  return SYS_INVALID_FILE_PATH;
2358  }
2359  tmpPtr = trashPath + len;
2360  sprintf( tmpPtr, ".%u", irods::getRandom<unsigned int>() );
2361 
2362  return 0;
2363 }
2364 
2365 // =-=-=-=-=-=-=-
2366 // JMC - backport 4552
2367 int
2368 isBundlePath( char * myPath ) {
2369  char *tmpPtr, *tmpPtr1;
2370 
2371  tmpPtr = myPath;
2372 
2373  /* start with a '/' */
2374  if ( *tmpPtr != '/' ) {
2375  return False;
2376  }
2377 
2378  tmpPtr++;
2379  if ( ( tmpPtr1 = strchr( tmpPtr, '/' ) ) == NULL ) {
2380  return False;
2381  }
2382 
2383  tmpPtr = tmpPtr1 + 1;
2384 
2385  if ( strncmp( tmpPtr, "bundle/", 7 ) == 0 ) {
2386  return True;
2387  }
2388  else {
2389  return False;
2390  }
2391 }
2392 // =-=-=-=-=-=-=-
2393 
2394 int
2395 isTrashPath( char * myPath ) {
2396  char *tmpPtr, *tmpPtr1;
2397 
2398  tmpPtr = myPath;
2399 
2400  /* start with a '/' */
2401  if ( *tmpPtr != '/' ) {
2402  return False;
2403  }
2404 
2405  tmpPtr++;
2406  if ( ( tmpPtr1 = strchr( tmpPtr, '/' ) ) == NULL ) {
2407  return False;
2408  }
2409 
2410  tmpPtr = tmpPtr1 + 1;
2411 
2412  if ( strncmp( tmpPtr, "trash/", 6 ) == 0 ) {
2413  return True;
2414  }
2415  else {
2416  return False;
2417  }
2418 }
2419 
2420 /* isTrashHome - see if the path is /myZone/trash/home or
2421  * /myZone/trash/home/myName.
2422  * return 0 if it is not
2423  * return 1 if it is.
2424  */
2425 
2426 int
2427 isTrashHome( char * myPath ) {
2428  char *tmpPtr, *tmpPtr1;
2429 
2430  tmpPtr = myPath;
2431 
2432  /* start with a '/' */
2433  if ( *tmpPtr != '/' ) {
2434  return 0;
2435  }
2436 
2437  tmpPtr++;
2438  if ( ( tmpPtr1 = strchr( tmpPtr, '/' ) ) == NULL ) {
2439  return 0;
2440  }
2441 
2442  tmpPtr = tmpPtr1 + 1;
2443 
2444  if ( strncmp( tmpPtr, "trash/home", 10 ) != 0 ) {
2445  return 0;
2446  }
2447 
2448  tmpPtr += 10;
2449 
2450  if ( *tmpPtr == '\0' ) {
2451  /* /myZone/trash/home */
2452  return 1;
2453  }
2454  else if ( *tmpPtr != '/' ) {
2455  return 0;
2456  }
2457 
2458  tmpPtr++;
2459 
2460  if ( strchr( tmpPtr, '/' ) == NULL ) {
2461  /* /myZone/trash/home/myName */
2462  return 1;
2463  }
2464  else {
2465  /* /myZone/trash/home/myName/... Not a trash home */
2466  return 0;
2467  }
2468 }
2469 
2470 /* isOrphanPath - check if path is a orphan path - /myZone/trash/orphan
2471  */
2473 isOrphanPath( char * myPath ) {
2474  char *tmpPtr, *tmpPtr1;
2475 
2476  tmpPtr = myPath;
2477 
2478  /* start with a '/' */
2479  if ( *tmpPtr != '/' ) {
2480  return NOT_ORPHAN_PATH;
2481  }
2482 
2483  tmpPtr++;
2484  if ( ( tmpPtr1 = strchr( tmpPtr, '/' ) ) == NULL ) {
2485  return NOT_ORPHAN_PATH;
2486  }
2487 
2488  tmpPtr = tmpPtr1 + 1;
2489 
2490  if ( strncmp( tmpPtr, "trash/orphan", 12 ) != 0 ) {
2491  return NOT_ORPHAN_PATH;
2492  }
2493  else if ( strcmp( tmpPtr, "trash/orphan" ) == 0 ) {
2494  return is_ORPHAN_HOME;
2495  }
2496  else {
2497  return IS_ORPHAN_PATH;
2498  }
2499 }
2500 
2501 /* isHomeColl - see if the path is /myZone/home or
2502  * /myZone/home/myName.
2503  * return 0 if it is not
2504  * return 1 if it is.
2505  */
2506 
2507 int
2508 isHomeColl( char * myPath ) {
2509  char *tmpPtr, *tmpPtr1;
2510 
2511  tmpPtr = myPath;
2512 
2513  /* start with a '/' */
2514  if ( *tmpPtr != '/' ) {
2515  return 0;
2516  }
2517 
2518  tmpPtr++;
2519  if ( ( tmpPtr1 = strchr( tmpPtr, '/' ) ) == NULL ) {
2520  return 0;
2521  }
2522 
2523  tmpPtr = tmpPtr1 + 1;
2524 
2525  if ( strncmp( tmpPtr, "home", 4 ) != 0 ) {
2526  return 0;
2527  }
2528 
2529  tmpPtr += 4;
2530 
2531  if ( *tmpPtr == '\0' ) {
2532  /* /myZone/home */
2533  return 1;
2534  }
2535  else if ( *tmpPtr != '/' ) {
2536  return 0;
2537  }
2538 
2539  tmpPtr++;
2540 
2541  if ( strchr( tmpPtr, '/' ) == NULL ) {
2542  /* /myZone/home/myName */
2543  return 1;
2544  }
2545  else {
2546  /* /myZone/home/myName/... Not a trash home */
2547  return 0;
2548  }
2549 }
2550 
2551 int
2552 openRestartFile( char * restartFile, rodsRestart_t * rodsRestart ) {
2553  namespace fs = boost::filesystem;
2554 
2555  fs::path p( restartFile );
2556  char buf[MAX_NAME_LEN * 3];
2557  char *inptr;
2558  char tmpStr[MAX_NAME_LEN];
2559  int status;
2560 
2561  if ( !exists( p ) || file_size( p ) == 0 ) {
2562 #ifndef windows_platform
2563  rodsRestart->fd = open( restartFile, O_RDWR | O_CREAT, 0644 );
2564 #else
2565  rodsRestart->fd = iRODSNt_bopen( restartFile, O_RDWR | O_CREAT, 0644 );
2566 #endif
2567  if ( rodsRestart->fd < 0 ) {
2568  status = UNIX_FILE_OPEN_ERR - errno;
2570  "openRestartFile: open error for %s", restartFile );
2571  return status;
2572  }
2573  rodsRestart->restartState = 0;
2574  printf( "New restartFile %s opened\n", restartFile );
2575  }
2576  else if ( !is_regular_file( p ) ) {
2577  close( rodsRestart->fd );
2578  rodsRestart->fd = -1;
2581  "openRestartFile: %s is not a file", restartFile );
2582  return UNIX_FILE_OPEN_ERR;
2583  }
2584  else {
2585 #ifndef windows_platform
2586  rodsRestart->fd = open( restartFile, O_RDWR, 0644 );
2587 #else
2588  rodsRestart->fd = iRODSNt_bopen( restartFile, O_RDWR, 0644 );
2589 #endif
2590  if ( rodsRestart->fd < 0 ) {
2591  status = UNIX_FILE_OPEN_ERR - errno;
2593  "openRestartFile: open error for %s", restartFile );
2594  return status;
2595  }
2596  status = read( rodsRestart->fd, ( void * ) buf, MAX_NAME_LEN * 3 );
2597  if ( status <= 0 ) {
2598  close( rodsRestart->fd );
2599  status = UNIX_FILE_READ_ERR - errno;
2601  "openRestartFile: read error for %s", restartFile );
2602  return status;
2603  }
2604 
2605  inptr = buf;
2606  if ( getLineInBuf( &inptr, rodsRestart->collection, MAX_NAME_LEN ) < 0 ) {
2607  rodsLog( LOG_ERROR,
2608  "openRestartFile: restartFile %s is empty", restartFile );
2610  }
2611  if ( getLineInBuf( &inptr, tmpStr, MAX_NAME_LEN ) < 0 ) {
2612  rodsLog( LOG_ERROR,
2613  "openRestartFile: restartFile %s has 1 only line", restartFile );
2615  }
2616  rodsRestart->doneCnt = atoi( tmpStr );
2617 
2618  if ( getLineInBuf( &inptr, rodsRestart->lastDonePath,
2619  MAX_NAME_LEN ) < 0 ) {
2620  rodsLog( LOG_ERROR,
2621  "openRestartFile: restartFile %s has only 2 lines", restartFile );
2623  }
2624 
2625  if ( getLineInBuf( &inptr, rodsRestart->oprType,
2626  NAME_LEN ) < 0 ) {
2627  rodsLog( LOG_ERROR,
2628  "openRestartFile: restartFile %s has only 3 lines", restartFile );
2630  }
2631 
2632  rodsRestart->restartState = PATH_MATCHING;
2633  printf( "RestartFile %s opened\n", restartFile );
2634  printf( "Restarting collection/directory = %s File count %d\n",
2635  rodsRestart->collection, rodsRestart->doneCnt );
2636  printf( "File last completed = %s\n", rodsRestart->lastDonePath );
2637  }
2638  return 0;
2639 }
2640 
2641 int
2642 getLineInBuf( char **inbuf, char * outbuf, int bufLen ) {
2643  char *inPtr, *outPtr;
2644  int bytesCopied = 0;
2645  int c;
2646 
2647  inPtr = *inbuf;
2648  outPtr = outbuf;
2649 
2650  while ( ( c = *inPtr ) != '\n' && c != EOF && bytesCopied < bufLen ) {
2651  c = *inPtr;
2652  if ( c == '\n' || c == EOF ) {
2653  break;
2654  }
2655  *outPtr = c;
2656  inPtr++;
2657  outPtr++;
2658  bytesCopied++;
2659  }
2660  *outPtr = '\0';
2661  *inbuf = inPtr + 1;
2662  return bytesCopied;
2663 }
2664 
2665 
2666 
2667 
2668 
2669 /* writeRestartFile - the restart file contain 4 lines:
2670  * line 1 - collection.
2671  * line 2 - doneCnt.
2672  * line 3 - lastDonePath
2673  * line 4 - oprType (BULK_OPR_KW or NON_BULK_OPR_KW);
2674  */
2675 
2676 int
2677 writeRestartFile( rodsRestart_t * rodsRestart, char * lastDonePath ) {
2678  char buf[MAX_NAME_LEN * 3];
2679  int status;
2680 
2681  rodsRestart->doneCnt = rodsRestart->curCnt;
2682  rstrcpy( rodsRestart->lastDonePath, lastDonePath, MAX_NAME_LEN );
2683  memset( buf, 0, MAX_NAME_LEN * 3 );
2684  snprintf( buf, MAX_NAME_LEN * 3, "%s\n%d\n%s\n%s\n",
2685  rodsRestart->collection, rodsRestart->doneCnt,
2686  rodsRestart->lastDonePath, rodsRestart->oprType );
2687 
2688  lseek( rodsRestart->fd, 0, SEEK_SET );
2689  status = write( rodsRestart->fd, buf, MAX_NAME_LEN * 3 );
2690  if ( status != MAX_NAME_LEN * 3 ) {
2691  rodsLog( LOG_ERROR,
2692  "writeRestartFile: write error, errno = %d",
2693  errno );
2694  return SYS_COPY_LEN_ERR - errno;
2695  }
2696  return 0;
2697 }
2698 
2699 int
2700 procAndWriteRestartFile( rodsRestart_t * rodsRestart, char * donePath ) {
2701  int status;
2702 
2703  if ( rodsRestart->fd <= 0 ) {
2704  return 0;
2705  }
2706 
2707  rodsRestart->curCnt ++;
2708  status = writeRestartFile( rodsRestart, donePath );
2709 
2710  return status;
2711 }
2712 
2713 int
2714 setStateForRestart( rodsRestart_t * rodsRestart, rodsPath_t * targPath,
2715  rodsArguments_t * rodsArgs ) {
2716  if ( rodsRestart->restartState & PATH_MATCHING ) {
2717  /* check the restart collection */
2718  if ( strstr( targPath->outPath, rodsRestart->collection ) != NULL ) {
2719  /* just use the rodsRestart->collection because the
2720  * targPath may be resolved into a different path */
2721  rstrcpy( targPath->outPath, rodsRestart->collection, MAX_NAME_LEN );
2722  rodsRestart->restartState |= MATCHED_RESTART_COLL;
2723  rodsRestart->curCnt = 0;
2724  if ( rodsArgs->verbose == True ) {
2725  printf( "**** Scanning to Restart Operation in %s ****\n",
2726  targPath->outPath );
2727  }
2728  }
2729  else {
2730  /* take out MATCHED_RESTART_COLL */
2731  if ( rodsArgs->verbose == True ) {
2732  printf( "**** Skip Coll/dir %s ****\n",
2733  targPath->outPath );
2734  }
2735  rodsRestart->restartState = rodsRestart->restartState &
2736  ( ~MATCHED_RESTART_COLL );
2737  }
2738  }
2739  else if ( rodsRestart->fd > 0 ) {
2740  /* just writing restart file */
2741  rstrcpy( rodsRestart->collection, targPath->outPath,
2742  MAX_NAME_LEN );
2743  rodsRestart->doneCnt = rodsRestart->curCnt = 0;
2744  }
2745  return 0;
2746 }
2747 
2748 
2749 
2750 int
2751 getAttrIdFromAttrName( char * cname ) {
2752 
2753  int i;
2754  for ( i = 0; i < NumOfColumnNames ; i++ ) {
2755  if ( !strcmp( columnNames[i].columnName, cname ) ) {
2756  return columnNames[i].columnId;
2757  }
2758  }
2759  return NO_COLUMN_NAME_FOUND;
2760 }
2761 
2762 int
2764  int i;
2765  for ( i = 0; i < NumOfColumnNames ; i++ ) {
2766  printf( "%s\n", columnNames[i].columnName );
2767  }
2768  return 0;
2769 }
2770 
2771 int
2772 separateSelFuncFromAttr( char * t, char **aggOp, char **colNm ) {
2773  char *s;
2774 
2775  if ( ( s = strchr( t, '(' ) ) == NULL ) {
2776  *colNm = t;
2777  *aggOp = NULL;
2778  return 0;
2779  }
2780  *aggOp = t;
2781  *s = '\0';
2782  s++;
2783  *colNm = s;
2784  if ( ( s = strchr( *colNm, ')' ) ) == NULL ) {
2785  return NO_COLUMN_NAME_FOUND;
2786  }
2787  *s = '\0';
2788  return 0;
2789 }
2790 
2791 int
2792 getSelVal( char * c ) {
2793  if ( c == NULL ) {
2794  return 1;
2795  }
2796  if ( !strcmp( c, "sum" ) || !strcmp( c, "SUM" ) ) {
2797  return SELECT_SUM;
2798  }
2799  if ( !strcmp( c, "min" ) || !strcmp( c, "MIN" ) ) {
2800  return SELECT_MIN;
2801  }
2802  if ( !strcmp( c, "max" ) || !strcmp( c, "MAX" ) ) {
2803  return SELECT_MAX;
2804  }
2805  if ( !strcmp( c, "avg" ) || !strcmp( c, "AVG" ) ) {
2806  return SELECT_AVG;
2807  }
2808  if ( !strcmp( c, "count" ) || !strcmp( c, "COUNT" ) ) {
2809  return SELECT_COUNT;
2810  }
2811  // =-=-=-=-=-=-=-
2812  // JMC - backport 4795
2813  if ( !strcmp( c, "order" ) || !strcmp( c, "ORDER" ) ) {
2814  return ORDER_BY;
2815  }
2816  if ( !strcmp( c, "order_desc" ) || !strcmp( c, "ORDER_DESC" ) ) {
2817  return ORDER_BY_DESC;
2818  }
2819  // =-=-=-=-=-=-=-
2820 
2821  return 1;
2822 }
2823 
2824 
2825 char *
2827 
2828  int i;
2829  for ( i = 0; i < NumOfColumnNames ; i++ ) {
2830  if ( columnNames[i].columnId == cid ) {
2831  return columnNames[i].columnName;
2832  }
2833  }
2834  return NULL;
2835 }
2836 
2837 int
2838 goodStrExpr( char * expr ) {
2839  int qcnt = 0;
2840  int qqcnt = 0;
2841  int bcnt = 0;
2842  int i = 0;
2843  int inq = 0;
2844  int inqq = 0;
2845  while ( expr[i] != '\0' ) {
2846  if ( inq ) {
2847  if ( expr[i] == '\'' ) {
2848  inq--;
2849  qcnt++;
2850  }
2851  }
2852  else if ( inqq ) {
2853  if ( expr[i] == '"' ) {
2854  inqq--;
2855  qqcnt++;
2856  }
2857  }
2858  else if ( expr[i] == '\'' ) {
2859  inq++;
2860  qcnt++;
2861  }
2862  else if ( expr[i] == '"' ) {
2863  inqq++;
2864  qqcnt++;
2865  }
2866  else if ( expr[i] == '(' ) {
2867  bcnt++;
2868  }
2869  else if ( expr[i] == ')' )
2870  if ( bcnt > 0 ) {
2871  bcnt--;
2872  }
2873  i++;
2874  }
2875  if ( bcnt != 0 || qcnt % 2 != 0 || qqcnt % 2 != 0 ) {
2876  return -1;
2877  }
2878  return 0;
2879 
2880 }
2881 
2882 
2883 char *getCondFromString( char * t ) {
2884  char *u;
2885  char *u1, *u2;
2886  char *s;
2887 
2888  s = t;
2889  for ( ;; ) {
2890  /* Search for an 'and' string, either case, and use the one
2891  that appears first. */
2892  u1 = strstr( s, " and " );
2893  u2 = strstr( s, " AND " );
2894  u = u1;
2895  if ( u1 == NULL ) {
2896  u = u2;
2897  }
2898  if ( u1 != NULL && u2 != NULL ) {
2899  if ( strlen( u2 ) > strlen( u1 ) ) {
2900  u = u2; /* both are present, use the first */
2901  }
2902  }
2903 
2904  if ( u != NULL ) {
2905  *u = '\0';
2906  if ( goodStrExpr( t ) == 0 ) {
2907  *u = ' ';
2908  return u;
2909  }
2910  *u = ' ';
2911  s = u + 1;
2912  }
2913  else {
2914  break;
2915  }
2916  }
2917  return NULL;
2918 }
2919 
2920 int
2921 fillGenQueryInpFromStrCond( char * str, genQueryInp_t * genQueryInp ) {
2922 
2923  int n, m;
2924  char *p, *t, *f, *u, *a, *c;
2925  char *s;
2926  s = strdup( str );
2927  if ( ( t = strstr( s, "select" ) ) != NULL ||
2928  ( t = strstr( s, "SELECT" ) ) != NULL ) {
2929 
2930  if ( ( f = strstr( t, "where" ) ) != NULL ||
2931  ( f = strstr( t, "WHERE" ) ) != NULL ) {
2932  /* Where Condition Found*/
2933  *f = '\0';
2934  }
2935  t = t + 7;
2936  while ( ( u = strchr( t, ',' ) ) != NULL ) {
2937  *u = '\0';
2938  trimWS( t );
2939  separateSelFuncFromAttr( t, &a, &c );
2940  m = getSelVal( a );
2941  n = getAttrIdFromAttrName( c );
2942  if ( n < 0 ) {
2943  free( s );
2944  return n;
2945  }
2946  addInxIval( &genQueryInp->selectInp, n, m );
2947  t = u + 1;
2948  }
2949  trimWS( t );
2950  separateSelFuncFromAttr( t, &a, &c );
2951  m = getSelVal( a );
2952  n = getAttrIdFromAttrName( c );
2953  if ( n < 0 ) {
2954  free( s );
2955  return n;
2956  }
2957  addInxIval( &genQueryInp->selectInp, n, m );
2958  if ( f == NULL ) {
2959  free( s );
2960  return 0;
2961  }
2962  }
2963  else {
2964  free( s );
2966  }
2967  t = f + 6;
2968  while ( ( u = getCondFromString( t ) ) != NULL ) {
2969  *u = '\0';
2970  trimWS( t );
2971  if ( ( p = strchr( t, ' ' ) ) == NULL ) {
2972  free( s );
2974  }
2975  *p = '\0';
2976  n = getAttrIdFromAttrName( t );
2977  if ( n < 0 ) {
2978  free( s );
2979  return n;
2980  }
2981  addInxVal( &genQueryInp->sqlCondInp, n, p + 1 );
2982  t = u + 5;
2983  }
2984  trimWS( t );
2985  if ( ( p = strchr( t, ' ' ) ) == NULL ) {
2986  free( s );
2988  }
2989  *p = '\0';
2990  n = getAttrIdFromAttrName( t );
2991  if ( n < 0 ) {
2992  free( s );
2993  return n;
2994  }
2995  addInxVal( &genQueryInp->sqlCondInp, n, p + 1 );
2996  free( s );
2997  return 0;
2998 }
2999 
3000 int
3001 printGenQueryOut( FILE * fd, char * format, char * hint, genQueryOut_t * genQueryOut ) {
3002  int i = 0, n = 0, j = 0;
3004  char * cname[MAX_SQL_ATTR];
3005 
3006  if ( hint != NULL && strlen( hint ) > 0 ) {
3007  //i = printHintedGenQueryOut(fd,format,hint, genQueryOut);
3008  return i;
3009  }
3010 
3011  n = genQueryOut->attriCnt;
3012 
3013  for ( i = 0; i < n; i++ ) {
3014  v[i] = &genQueryOut->sqlResult[i];
3015  cname[i] = getAttrNameFromAttrId( v[i]->attriInx );
3016  if ( cname[i] == NULL ) {
3017  return NO_COLUMN_NAME_FOUND;
3018  }
3019  }
3020 
3021  try {
3022  for ( i = 0; i < genQueryOut->rowCnt; i++ ) {
3023  if ( format == NULL || strlen( format ) == 0 ) {
3024  for ( j = 0; j < n; j++ ) {
3025  fprintf( fd, "%s = %s\n", cname[j], &v[j]->value[v[j]->len * i] );
3026  }
3027  fprintf( fd, "------------------------------------------------------------\n" );
3028  }
3029  else {
3030  boost::format formatter( format );
3031  for ( int j = 0; j < n; j++ ) {
3032  formatter % &v[j]->value[v[j]->len * i];
3033  }
3034  std::stringstream ss; ss << formatter;
3035  fprintf( fd, "%s\n", ss.str().c_str() );
3036  }
3037  }
3038  }
3039  catch ( const boost::io::format_error& _e ) {
3040  std::cerr << _e.what() << std::endl;
3041  }
3042 
3043  return 0;
3044 }
3045 
3046 
3047 int
3048 appendToByteBuf( bytesBuf_t * bytesBuf, char * str ) {
3049  const int i = strlen( str );
3050  const int num_new_bytes = i + 1 + MAX_NAME_LEN * 5;
3051  if ( bytesBuf->buf == NULL ) {
3052  bytesBuf->buf = malloc( num_new_bytes );
3053  memset( bytesBuf->buf, 0, num_new_bytes );
3054  strcpy( ( char * )bytesBuf->buf, str );
3055  bytesBuf->len = num_new_bytes;
3056  }
3057  else {
3058  const int j = strlen( ( char * )bytesBuf->buf );
3059  if ( ( i + j ) < bytesBuf->len ) {
3060  strcat( ( char * )bytesBuf->buf, str );
3061  }
3062  else { /* needs more space */
3063  const int num_total_bytes = j + num_new_bytes;
3064  char *tBuf = (char*)malloc( num_total_bytes );
3065  memset( tBuf, 0, num_total_bytes );
3066  strcpy( tBuf, (char*)bytesBuf->buf );
3067  strcat( tBuf, str );
3068  free( bytesBuf->buf );
3069  bytesBuf->len = num_total_bytes;
3070  bytesBuf->buf = tBuf;
3071  }
3072  }
3073  return 0;
3074 }
3075 
3076 
3077 int
3078 getMountedSubPhyPath( char * logMountPoint, char * phyMountPoint,
3079  char * logSubPath, char * phySubPathOut ) {
3080  char *tmpPtr;
3081  int len = strlen( logMountPoint );
3082 
3083  if ( strncmp( logSubPath, logMountPoint, len ) != 0 ) {
3084  rodsLog( LOG_ERROR,
3085  "getMountedSubPhyPath: sub path %s not in mount point %s",
3086  logSubPath, logMountPoint );
3088  }
3089  /* skip over the mount point */
3090  tmpPtr = logSubPath + len;
3091  /* compose the physical path */
3092  snprintf( phySubPathOut, MAX_NAME_LEN, "%s%s", phyMountPoint,
3093  tmpPtr );
3094  return 0;
3095 
3096 }
3097 
3098 int
3099 getSpecCollTypeStr( specColl_t * specColl, char * outStr ) {
3100  int i;
3101 
3102  if ( specColl->collClass == NO_SPEC_COLL ) {
3104  }
3105  else if ( specColl->collClass == MOUNTED_COLL ) {
3106  rstrcpy( outStr, MOUNT_POINT_STR, NAME_LEN );
3107  return 0;
3108  }
3109  else if ( specColl->collClass == LINKED_COLL ) {
3110  rstrcpy( outStr, LINK_POINT_STR, NAME_LEN );
3111  return 0;
3112  }
3113  else {
3114  for ( i = 0; i < NumStructFileType; i++ ) {
3115  if ( specColl->type == StructFileTypeDef[i].type ) {
3116  rstrcpy( outStr, StructFileTypeDef[i].typeName, NAME_LEN );
3117  return 0;
3118  }
3119  }
3120  rodsLog( LOG_ERROR,
3121  "getSpecCollTypeStr: unmatch specColl type %d", specColl->type );
3123  }
3124 }
3125 
3126 int
3127 resolveSpecCollType( char * type, char * collection, char * collInfo1,
3128  char * collInfo2, specColl_t * specColl ) {
3129  int i;
3130 
3131  if ( specColl == NULL ) {
3132  return USER__NULL_INPUT_ERR;
3133  }
3134 
3135  if ( *type == '\0' ) {
3136  specColl->collClass = NO_SPEC_COLL;
3138  }
3139 
3140  rstrcpy( specColl->collection, collection,
3141  MAX_NAME_LEN );
3142 
3143  if ( strcmp( type, MOUNT_POINT_STR ) == 0 ) {
3144  specColl->collClass = MOUNTED_COLL;
3145  rstrcpy( specColl->phyPath, collInfo1, MAX_NAME_LEN );
3146 
3148  parse.set_string( collInfo2 );
3149 
3150  std::string first_resc;
3151  parse.first_resc( first_resc );
3152 
3153  rstrcpy( specColl->resource, first_resc.c_str(), NAME_LEN );
3154  rstrcpy( specColl->rescHier, collInfo2, NAME_LEN );
3155 
3156  return 0;
3157  }
3158  else if ( strcmp( type, LINK_POINT_STR ) == 0 ) {
3159  specColl->collClass = LINKED_COLL;
3160  rstrcpy( specColl->phyPath, collInfo1, MAX_NAME_LEN );
3161 
3162  return 0;
3163  }
3164  else {
3165  for ( i = 0; i < NumStructFileType; i++ ) {
3166  if ( strcmp( type, StructFileTypeDef[i].typeName ) == 0 ) {
3167  specColl->collClass = STRUCT_FILE_COLL;
3168  specColl->type = StructFileTypeDef[i].type;
3169  rstrcpy( specColl->objPath, collInfo1,
3170  MAX_NAME_LEN );
3171  parseCachedStructFileStr( collInfo2, specColl );
3172  return 0;
3173  }
3174  }
3175 
3176  specColl->collClass = NO_SPEC_COLL;
3177  rodsLog( LOG_ERROR,
3178  "resolveSpecCollType: unmatch specColl type %s", type );
3180  }
3181 }
3182 
3183 int
3184 parseCachedStructFileStr( char * collInfo2, specColl_t * specColl ) {
3185  char *tmpPtr1, *tmpPtr2;
3186  int len;
3187 
3188  if ( collInfo2 == NULL || specColl == NULL ) {
3189  rodsLog( LOG_ERROR,
3190  "parseCachedStructFileStr: NULL input" );
3192  }
3193 
3194  if ( strlen( collInfo2 ) == 0 ) {
3195  /* empty */
3196  specColl->cacheDir[0] = specColl->resource[0] = '\0';
3197  return 0;
3198  }
3199 
3200  tmpPtr1 = strstr( collInfo2, ";;;" );
3201 
3202  if ( tmpPtr1 == NULL ) {
3204  "parseCachedStructFileStr: collInfo2 %s format error 1", collInfo2 );
3206  }
3207 
3208  len = ( int )( tmpPtr1 - collInfo2 );
3209  strncpy( specColl->cacheDir, collInfo2, len );
3210 
3211  tmpPtr1 += 3;
3212 
3213  tmpPtr2 = strstr( tmpPtr1, ";;;" );
3214 
3215  if ( tmpPtr2 == NULL ) {
3217  "parseCachedStructFileStr: collInfo2 %s format error 2", collInfo2 );
3219  }
3220 
3221  len = ( int )( tmpPtr2 - tmpPtr1 );
3222  *tmpPtr2 = '\0';
3223 
3225  parse.set_string( tmpPtr1 );
3226 
3227  std::string first_resc;
3228  parse.first_resc( first_resc );
3229 
3230  snprintf( specColl->resource, sizeof( specColl->resource ),
3231  "%s", first_resc.c_str() );
3232  snprintf( specColl->rescHier, sizeof( specColl->rescHier ),
3233  "%s", tmpPtr1 );
3234  tmpPtr2 += 3;
3235 
3236  specColl->cacheDirty = atoi( tmpPtr2 );
3237 
3238  return 0;
3239 }
3240 
3241 int
3242 makeCachedStructFileStr( char * collInfo2, specColl_t * specColl ) {
3243  if ( collInfo2 == NULL || specColl == NULL ) {
3244  rodsLog( LOG_ERROR,
3245  "makeCachedStructFileStr: NULL input" );
3247  }
3248 
3249  if ( strlen( specColl->resource ) == 0 || strlen( specColl->cacheDir ) == 0 ) {
3250  return 0;
3251  }
3252 
3253  snprintf( collInfo2, MAX_NAME_LEN, "%s;;;%s;;;%d",
3254  //specColl->cacheDir, specColl->resource, specColl->cacheDirty);
3255  specColl->cacheDir, specColl->rescHier, specColl->cacheDirty );
3256 
3257  return 0;
3258 }
3259 
3260 int
3261 getErrno( int irodError ) {
3262  int unixErrno = irodError % 1000;
3263 
3264  if ( unixErrno < 0 ) {
3265  unixErrno = -1 * unixErrno;
3266  }
3267 
3268  return unixErrno;
3269 }
3270 
3271 int
3272 getIrodsErrno( int irodError ) {
3273  int irodsErrno = irodError / 1000 * 1000;
3274  return irodsErrno;
3275 }
3276 
3278 getSpecCollOpr( keyValPair_t * condInput, specColl_t * specColl ) {
3279  if ( specColl == NULL ) {
3280  return NOT_SPEC_COLL_OPR;
3281  }
3282 
3283  if ( specColl->collClass != STRUCT_FILE_COLL ) {
3285  }
3286 
3287  if ( getValByKey( condInput, STRUCT_FILE_OPR_KW ) == NULL ) {
3289  }
3290  else {
3292  }
3293 }
3294 
3295 
3303 int
3304 keyValToString( keyValPair_t * list, char** string ) {
3305  if ( NULL == list || NULL == string ) { // JMC cppcheck - nullptr
3306  rodsLog( LOG_ERROR, "keyValToString :: null input parameter" );
3308  }
3309  int nBytes = 0;
3310  int nKeys = list->len;
3311  int i;
3312 
3313  //if ( list == NULL ) // JMC cppcheck - nullptr
3314  //return SYS_INTERNAL_NULL_INPUT_ERR;
3315 
3316  /* Scan the list to figure out how much space we need. */
3317  for ( i = 0; i < nKeys; i++ ) {
3318  int nk, nv;
3319  if ( list->keyWord[i] == NULL || list->keyWord[i][0] == '\0' ) {
3320  continue; /* Null keyword means empty entry */
3321  }
3322  if ( list->value[i] == NULL ) {
3323  continue; /* Null value is not legal */
3324  }
3325  nk = strlen( list->keyWord[i] );
3326  nv = strlen( list->value[i] );
3327 
3328  /* <keyword>value</keyword> */
3329  nBytes += 1 + nk + 1 + nv + 2 + nk + 1 + 1;
3330  }
3331  nBytes++;
3332 
3333  /* Allocate the space. */
3334  *string = ( char* )malloc( nBytes );
3335  memset( *string, 0, nBytes );
3336 
3337  /* Write the string. */
3338  for ( i = 0; i < nKeys; i++ ) {
3339  if ( list->keyWord[i] == NULL || list->keyWord[i][0] == '\0' ) {
3340  continue; /* Null keyword means empty entry */
3341  }
3342  if ( list->value[i] == NULL ) {
3343  continue; /* Null value is not legal */
3344  }
3345 
3346  strcat( *string, "<" );
3347  strcat( *string, list->keyWord[i] );
3348  strcat( *string, ">" );
3349  strcat( *string, list->value[i] );
3350  strcat( *string, "</" );
3351  strcat( *string, list->keyWord[i] );
3352  strcat( *string, ">\n" );
3353  }
3354 
3355  return 0;
3356 }
3357 
3358 
3359 
3360 
3369 int
3370 keyValFromString( char * string, keyValPair_t** list ) {
3371  int index = 0;
3372  int len = strlen( string );
3373 
3374  /* Create and clear the list. */
3375  *list = ( keyValPair_t* )malloc( sizeof( keyValPair_t ) );
3376  memset( *list, 0, sizeof( keyValPair_t ) );
3377 
3378  /* Parse the string. Extract out the tag and value */
3379  /* without doing any memory allocations (to save time). */
3380  while ( 1 ) {
3381  int startTag = -1;
3382  int endTag = -1;
3383  char* tag = NULL;
3384 
3385  int startCloseTag = -1;
3386  int endCloseTag = -1;
3387  char* closeTag = NULL;
3388 
3389  int startValue = -1;
3390  int endValue = -1;
3391  char* value = NULL;
3392 
3393  /* Skip over everything until the start */
3394  /* of the next tag. */
3395  while ( index < len && string[index] != '<' ) {
3396  ++index;
3397  }
3398  if ( index == len ) {
3399  break; /* Done */
3400  }
3401 
3402 
3403  /* Get the tag. */
3404  index++; /* Skip '<' */
3405  startTag = index;
3406  while ( index < len && string[index] != '>' ) {
3407  ++index;
3408  }
3409  if ( index == len ) {
3410  break; /* Done */
3411  }
3412  endTag = index;
3413  index++; /* Skip '>' */
3414  startValue = index;
3415 
3416 
3417  /* Skip to the end of the value. */
3418  while ( index < len && string[index] != '<' ) {
3419  ++index;
3420  }
3421  if ( index == len ) {
3422  break; /* Done */
3423  }
3424  endValue = index;
3425 
3426 
3427  /* Get the close tag.Y */
3428  index += 2; /* Skip '</' */
3429  startCloseTag = index;
3430  while ( index < len && string[index] != '>' ) {
3431  ++index;
3432  }
3433  if ( index == len ) {
3434  break; /* Done */
3435  }
3436  endCloseTag = index;
3437 
3438 
3439  /* Compare the opening and closing tags */
3440  /* and make sure they match. */
3441  if ( ( endTag - startTag ) != ( endCloseTag - startCloseTag ) )
3442  /* Find a better error code! */
3443  {
3444  return UNMATCHED_KEY_OR_INDEX;
3445  }
3446  tag = string + startTag;
3447  closeTag = string + startCloseTag;
3448  value = string + startValue;
3449  if ( strncmp( tag, closeTag, ( endTag - startTag ) ) != 0 )
3450  /* Find a better error code! */
3451  {
3452  return UNMATCHED_KEY_OR_INDEX;
3453  }
3454 
3455  /* Temporarily add a NULL at the end of the tag */
3456  /* and the value. This gives us two NULL-terminated */
3457  /* strings to pass in to the addKeyVal. */
3458  string[endTag] = '\0'; /* was '>' */
3459  string[endValue] = '\0'; /* was '<' */
3460 
3461  /* Add the key-value pair. */
3462  addKeyVal( *list, tag, value );
3463 
3464  /* Remove the NULLs added above. */
3465  string[endTag] = '>';
3466  string[endValue] = '<';
3467  }
3468 
3469  return 0;
3470 }
3471 
3472 int
3474  if ( sendXmsgInfo == NULL ) {
3475  return 0;
3476  }
3477 
3478  if ( sendXmsgInfo->msg != NULL ) {
3479  free( sendXmsgInfo->msg );
3480  }
3481 
3482  if ( sendXmsgInfo->deliPort != NULL ) {
3483  free( sendXmsgInfo->deliPort );
3484  }
3485 
3486  if ( sendXmsgInfo->miscInfo != NULL ) {
3487  free( sendXmsgInfo->miscInfo );
3488  }
3489 
3490  if ( sendXmsgInfo->deliAddress != NULL &&
3491  *sendXmsgInfo->deliAddress != NULL ) {
3492  int i;
3493 
3494  for ( i = 0; i < sendXmsgInfo->numDeli; i++ ) {
3495  free( sendXmsgInfo->deliAddress[i] );
3496  }
3497  free( sendXmsgInfo->deliAddress );
3498  }
3499  memset( sendXmsgInfo, 0, sizeof( sendXmsgInfo_t ) );
3500 
3501  return 0;
3502 }
3503 
3504 void
3505 clearModAccessControlInp( void* voidInp ) {
3506  modAccessControlInp_t * modAccessControlInp = ( modAccessControlInp_t* )voidInp;
3507  free( modAccessControlInp->accessLevel );
3508  free( modAccessControlInp->userName );
3509  free( modAccessControlInp->zone );
3510  free( modAccessControlInp->path );
3511  memset( modAccessControlInp, 0, sizeof( modAccessControlInp_t ) );
3512  return;
3513 }
3514 
3515 void
3516 clearModAVUMetadataInp( void* voidInp ) {
3517  modAVUMetadataInp_t * modAVUMetadataInp = ( modAVUMetadataInp_t* )voidInp;
3518  free( modAVUMetadataInp->arg0 );
3519  free( modAVUMetadataInp->arg1 );
3520  free( modAVUMetadataInp->arg2 );
3521  free( modAVUMetadataInp->arg3 );
3522  free( modAVUMetadataInp->arg4 );
3523  free( modAVUMetadataInp->arg5 );
3524  free( modAVUMetadataInp->arg6 );
3525  free( modAVUMetadataInp->arg7 );
3526  free( modAVUMetadataInp->arg8 );
3527  free( modAVUMetadataInp->arg9 );
3528  memset( modAVUMetadataInp, 0, sizeof( modAVUMetadataInp_t ) );
3529  return;
3530 }
3531 
3532 /* freeRodsObjStat - free a rodsObjStat_t. Note that this should only
3533  * be used by the client because specColl also is freed which is cached
3534  * on the server
3535  */
3536 int
3538  if ( rodsObjStat == NULL ) {
3539  return 0;
3540  }
3541 
3542  if ( rodsObjStat->specColl != NULL ) {
3543  free( rodsObjStat->specColl );
3544  }
3545 
3546  free( rodsObjStat );
3547 
3548  return 0;
3549 }
3550 
3551 int
3552 parseHostAddrStr( char * hostAddr, rodsHostAddr_t * addr ) {
3553  char port[LONG_NAME_LEN];
3554  char buffer[LONG_NAME_LEN];
3555 
3556  if ( hostAddr == NULL || addr == NULL ) {
3558  }
3559  if ( splitPathByKey( hostAddr, buffer, LONG_NAME_LEN, port, SHORT_STR_LEN, ':' ) < 0 ) {
3560  rstrcpy( addr->hostAddr, hostAddr, LONG_NAME_LEN );
3561  addr->portNum = 0;
3562  }
3563  else {
3564  rstrcpy( addr->hostAddr, buffer, LONG_NAME_LEN );
3565  addr->portNum = atoi( port );
3566  }
3567  return 0;
3568 }
3569 
3570 /*
3571  Print some release information.
3572  Used by the iCommands when printting the help text.
3573  */
3574 void
3575 printReleaseInfo( char * cmdName ) {
3576  char tmp[40];
3577  strncpy( tmp, RODS_REL_VERSION, 40 ); /* to skip over the 'rods' part
3578  of the string */
3579  tmp[39] = '\0';
3580  printf( "\niRODS Version %s %s\n",
3581  ( char* )&tmp[4], cmdName );
3582  return;
3583 }
3584 
3585 unsigned int
3587  unsigned int seed;
3588  const int random_fd = open( "/dev/urandom", O_RDONLY );
3589  if ( random_fd == -1 ) {
3590  rodsLog( LOG_ERROR, "seedRandom: failed to open /dev/urandom" );
3591  return FILE_OPEN_ERR;
3592  }
3593  char buf[sizeof( seed )];
3594  const ssize_t count = read( random_fd, &buf, sizeof( buf ) );
3595  close( random_fd );
3596  if ( count != sizeof( seed ) ) {
3597  rodsLog( LOG_ERROR, "seedRandom: failed to read enough bytes from /dev/urandom" );
3598  return FILE_READ_ERR;
3599  }
3600  memcpy( &seed, buf, sizeof( seed ) );
3601 
3602 #ifdef windows_platform
3603  srand( seed );
3604 #else
3605  srandom( seed );
3606 #endif
3607 
3608  return 0;
3609 }
3610 
3611 int
3612 initBulkDataObjRegInp( genQueryOut_t * bulkDataObjRegInp ) {
3613  if ( bulkDataObjRegInp == NULL ) {
3614  return USER__NULL_INPUT_ERR;
3615  }
3616 
3617  memset( bulkDataObjRegInp, 0, sizeof( genQueryOut_t ) );
3618 
3619  bulkDataObjRegInp->attriCnt = 10;
3620 
3621  bulkDataObjRegInp->sqlResult[0].attriInx = COL_DATA_NAME;
3622  bulkDataObjRegInp->sqlResult[0].len = MAX_NAME_LEN;
3623  bulkDataObjRegInp->sqlResult[0].value =
3624  ( char * )malloc( MAX_NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3625  bzero( bulkDataObjRegInp->sqlResult[0].value,
3627  bulkDataObjRegInp->sqlResult[1].attriInx = COL_DATA_TYPE_NAME;
3628  bulkDataObjRegInp->sqlResult[1].len = NAME_LEN;
3629  bulkDataObjRegInp->sqlResult[1].value =
3630  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3631  bzero( bulkDataObjRegInp->sqlResult[1].value,
3633  bulkDataObjRegInp->sqlResult[2].attriInx = COL_DATA_SIZE;
3634  bulkDataObjRegInp->sqlResult[2].len = NAME_LEN;
3635  bulkDataObjRegInp->sqlResult[2].value =
3636  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3637  bzero( bulkDataObjRegInp->sqlResult[2].value,
3639  bulkDataObjRegInp->sqlResult[3].attriInx = COL_D_RESC_NAME;
3640  bulkDataObjRegInp->sqlResult[3].len = NAME_LEN;
3641  bulkDataObjRegInp->sqlResult[3].value =
3642  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3643  bzero( bulkDataObjRegInp->sqlResult[3].value,
3645  bulkDataObjRegInp->sqlResult[4].attriInx = COL_D_DATA_PATH;
3646  bulkDataObjRegInp->sqlResult[4].len = MAX_NAME_LEN;
3647  bulkDataObjRegInp->sqlResult[4].value =
3648  ( char * )malloc( MAX_NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3649  bzero( bulkDataObjRegInp->sqlResult[4].value,
3651  bulkDataObjRegInp->sqlResult[5].attriInx = COL_DATA_MODE;
3652  bulkDataObjRegInp->sqlResult[5].len = NAME_LEN;
3653  bulkDataObjRegInp->sqlResult[5].value =
3654  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3655  bzero( bulkDataObjRegInp->sqlResult[5].value,
3657  bulkDataObjRegInp->sqlResult[6].attriInx = OPR_TYPE_INX;
3658  bulkDataObjRegInp->sqlResult[6].len = NAME_LEN;
3659  bulkDataObjRegInp->sqlResult[6].value =
3660  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3661  bzero( bulkDataObjRegInp->sqlResult[6].value,
3663  bulkDataObjRegInp->sqlResult[7].attriInx = COL_DATA_REPL_NUM;
3664  bulkDataObjRegInp->sqlResult[7].len = NAME_LEN;
3665  bulkDataObjRegInp->sqlResult[7].value =
3666  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3667  bzero( bulkDataObjRegInp->sqlResult[7].value,
3669  bulkDataObjRegInp->sqlResult[8].attriInx = COL_D_DATA_CHECKSUM;
3670  bulkDataObjRegInp->sqlResult[8].len = NAME_LEN;
3671  bulkDataObjRegInp->sqlResult[8].value =
3672  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3673  bzero( bulkDataObjRegInp->sqlResult[8].value,
3675  bulkDataObjRegInp->sqlResult[9].attriInx = COL_D_RESC_ID;
3676  bulkDataObjRegInp->sqlResult[9].len = MAX_NAME_LEN;
3677  bulkDataObjRegInp->sqlResult[9].value =
3678  ( char * )malloc( MAX_NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3679  bzero( bulkDataObjRegInp->sqlResult[9].value,
3681 
3682  bulkDataObjRegInp->continueInx = -1;
3683 
3684  return 0;
3685 }
3686 
3687 int
3688 initBulkDataObjRegOut( genQueryOut_t **bulkDataObjRegOut ) {
3689  genQueryOut_t *myBulkDataObjRegOut;
3690 
3691  if ( bulkDataObjRegOut == NULL ) {
3692  return USER__NULL_INPUT_ERR;
3693  }
3694 
3695  myBulkDataObjRegOut = *bulkDataObjRegOut = ( genQueryOut_t* )malloc( sizeof( genQueryOut_t ) );
3696  if ( myBulkDataObjRegOut == NULL ) {
3697  return SYS_MALLOC_ERR;
3698  }
3699 
3700  memset( myBulkDataObjRegOut, 0, sizeof( genQueryOut_t ) );
3701 
3702  myBulkDataObjRegOut->attriCnt = 1;
3703 
3704  myBulkDataObjRegOut->sqlResult[0].attriInx = COL_D_DATA_ID;
3705  myBulkDataObjRegOut->sqlResult[0].len = NAME_LEN;
3706  myBulkDataObjRegOut->sqlResult[0].value =
3707  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3708  bzero( myBulkDataObjRegOut->sqlResult[0].value,
3710 
3711  myBulkDataObjRegOut->continueInx = -1;
3712  return 0;
3713 }
3714 
3715 int
3717  genQueryOut_t *attriArray;
3718  int i;
3719 
3720  if ( bulkOprInp == NULL ) {
3721  return USER__NULL_INPUT_ERR;
3722  }
3723 
3724  attriArray = &bulkOprInp->attriArray;
3725 
3726  attriArray->attriCnt = 3;
3727 
3728  attriArray->sqlResult[0].attriInx = COL_DATA_NAME;
3729  attriArray->sqlResult[0].len = MAX_NAME_LEN;
3730  attriArray->sqlResult[0].value =
3731  ( char * )malloc( MAX_NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3732  bzero( attriArray->sqlResult[0].value,
3734  attriArray->sqlResult[1].attriInx = COL_DATA_MODE;
3735  attriArray->sqlResult[1].len = NAME_LEN;
3736  attriArray->sqlResult[1].value =
3737  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3738  bzero( attriArray->sqlResult[1].value,
3740  attriArray->sqlResult[2].attriInx = OFFSET_INX;
3741  attriArray->sqlResult[2].len = NAME_LEN;
3742  attriArray->sqlResult[2].value =
3743  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3744  bzero( attriArray->sqlResult[2].value,
3746 
3747  if ( getValByKey( &bulkOprInp->condInput, REG_CHKSUM_KW ) != NULL ||
3748  getValByKey( &bulkOprInp->condInput, VERIFY_CHKSUM_KW ) != NULL ) {
3749  i = attriArray->attriCnt;
3750  attriArray->sqlResult[i].attriInx = COL_D_DATA_CHECKSUM;
3751  attriArray->sqlResult[i].len = NAME_LEN;
3752  attriArray->sqlResult[i].value =
3753  ( char * )malloc( NAME_LEN * MAX_NUM_BULK_OPR_FILES );
3754  bzero( attriArray->sqlResult[i].value,
3756  attriArray->attriCnt++;
3757  }
3758  attriArray->continueInx = -1;
3759  return 0;
3760 }
3761 
3762 int
3763 fillAttriArrayOfBulkOprInp( char * objPath, int dataMode, char * inpChksum,
3764  int offset, bulkOprInp_t * bulkOprInp ) {
3765  genQueryOut_t *attriArray;
3766  int rowCnt;
3767  sqlResult_t *chksum = NULL;
3768 
3769  if ( bulkOprInp == NULL || objPath == NULL ) {
3770  return USER__NULL_INPUT_ERR;
3771  }
3772 
3773  attriArray = &bulkOprInp->attriArray;
3774 
3775  rowCnt = attriArray->rowCnt;
3776 
3777  if ( rowCnt >= MAX_NUM_BULK_OPR_FILES ) {
3779  }
3780 
3781  chksum = getSqlResultByInx( attriArray, COL_D_DATA_CHECKSUM );
3782  if ( inpChksum != NULL && strlen( inpChksum ) > 0 ) {
3783  if ( chksum == NULL ) {
3784  rodsLog( LOG_ERROR,
3785  "initAttriArrayOfBulkOprInp: getSqlResultByInx for COL_D_DATA_CHECKSUM failed" );
3786  return UNMATCHED_KEY_OR_INDEX;
3787  }
3788  else {
3789  rstrcpy( &chksum->value[NAME_LEN * rowCnt], inpChksum, NAME_LEN );
3790  }
3791  }
3792  else {
3793  if ( chksum != NULL ) {
3794  chksum->value[NAME_LEN * rowCnt] = '\0';
3795  }
3796  }
3797  rstrcpy( &attriArray->sqlResult[0].value[MAX_NAME_LEN * rowCnt],
3798  objPath, MAX_NAME_LEN );
3799  snprintf( &attriArray->sqlResult[1].value[NAME_LEN * rowCnt],
3800  NAME_LEN, "%d", dataMode );
3801  snprintf( &attriArray->sqlResult[2].value[NAME_LEN * rowCnt],
3802  NAME_LEN, "%d", offset );
3803 
3804  attriArray->rowCnt++;
3805 
3806  return 0;
3807 }
3808 
3809 int
3810 getAttriInAttriArray( const char * inpObjPath, genQueryOut_t * attriArray,
3811  int * outDataMode, char **outChksum ) {
3812  int i;
3813  int startInx;
3814  sqlResult_t *objPath, *dataMode, *chksum;
3815  char *tmpObjPath, *tmpDataMode, *tmpChksum;
3816 
3817  if ( inpObjPath == NULL || attriArray == NULL || outDataMode == NULL ||
3818  outChksum == NULL ) {
3819  return USER__NULL_INPUT_ERR;
3820  }
3821 
3822  if ( ( objPath =
3823  getSqlResultByInx( attriArray, COL_DATA_NAME ) ) == NULL ) {
3825  "getAttriInAttriArray: getSqlResultByInx for COL_DATA_NAME failed" );
3826  return UNMATCHED_KEY_OR_INDEX;
3827  }
3828 
3829  if ( ( dataMode =
3830  getSqlResultByInx( attriArray, COL_DATA_MODE ) ) == NULL ) {
3832  "getAttriInAttriArray: getSqlResultByInx for COL_DATA_MODE failed" );
3833  return UNMATCHED_KEY_OR_INDEX;
3834  }
3835 
3836  chksum = getSqlResultByInx( attriArray, COL_D_DATA_CHECKSUM );
3837 
3838  startInx = attriArray->continueInx;
3839  if ( startInx >= attriArray->rowCnt || startInx < 0 ) {
3840  startInx = 0;
3841  }
3842 
3843  for ( i = startInx; i < attriArray->rowCnt; i++ ) {
3844  tmpObjPath = &objPath->value[objPath->len * i];
3845  if ( strcmp( inpObjPath, tmpObjPath ) == 0 ) {
3846  attriArray->continueInx = i + 1;
3847  tmpDataMode = &dataMode->value[dataMode->len * i];
3848  *outDataMode = atoi( tmpDataMode );
3849  if ( chksum != NULL ) {
3850  tmpChksum = &chksum->value[chksum->len * i];
3851  if ( strlen( tmpChksum ) > 0 ) {
3852  *outChksum = tmpChksum;
3853  }
3854  else {
3855  *outChksum = NULL;
3856  }
3857  }
3858  else {
3859  *outChksum = NULL;
3860  }
3861  return 0;
3862  }
3863  }
3864 
3865  for ( i = 0; i < startInx; i++ ) {
3866  tmpObjPath = &objPath->value[objPath->len * i];
3867  if ( strcmp( inpObjPath, tmpObjPath ) == 0 ) {
3868  attriArray->continueInx = i + 1;
3869  tmpDataMode = &dataMode->value[dataMode->len * i];
3870  *outDataMode = atoi( tmpDataMode );
3871  if ( chksum != NULL ) {
3872  tmpChksum = &chksum->value[chksum->len * i];
3873  if ( strlen( tmpChksum ) > 0 ) {
3874  *outChksum = tmpChksum;
3875  }
3876  else {
3877  *outChksum = NULL;
3878  }
3879  }
3880  else {
3881  *outChksum = NULL;
3882  }
3883  return 0;
3884  }
3885  }
3886  /* no match when got here */
3887  *outChksum = NULL;
3888  return UNMATCHED_KEY_OR_INDEX;
3889 }
3890 
3891 int
3892 readToByteBuf( int fd, bytesBuf_t * bytesBuf ) {
3893  int toRead, buflen, nbytes;
3894  char *bufptr;
3895 
3896  if ( bytesBuf->len <= 0 ) {
3897  /* use default */
3898  buflen = INIT_SZ_FOR_EXECMD_BUF;
3899  }
3900  else {
3901  /* sanity check */
3902  buflen = bytesBuf->len;
3903  if ( buflen > MAX_SZ_FOR_EXECMD_BUF ) {
3905  }
3906  }
3907  bytesBuf->len = 0;
3908  bytesBuf->buf = bufptr = ( char * )malloc( buflen );
3909  toRead = buflen;
3910 
3911  while ( 1 ) {
3912  nbytes = myRead( fd, bufptr, toRead, NULL, NULL );
3913  if ( nbytes == toRead ) { /* more */
3914  char *tmpPtr;
3915 
3916  bytesBuf->len += nbytes;
3917  if ( buflen >= MAX_SZ_FOR_EXECMD_BUF ) {
3919  }
3920  else {
3921  buflen = 4 * buflen;
3922  if ( buflen > MAX_SZ_FOR_EXECMD_BUF ) {
3923  buflen = MAX_SZ_FOR_EXECMD_BUF;
3924  }
3925  toRead = buflen - bytesBuf->len;
3926  tmpPtr = ( char* )bytesBuf->buf;
3927  bytesBuf->buf = malloc( buflen );
3928  memcpy( bytesBuf->buf, tmpPtr, bytesBuf->len );
3929  free( tmpPtr );
3930  bufptr = ( char * ) bytesBuf->buf + bytesBuf->len;
3931  }
3932  }
3933  else {
3934  if ( nbytes > 0 ) {
3935  bytesBuf->len += nbytes;
3936  bufptr += nbytes;
3937  }
3938  if ( bytesBuf->len <= 0 ) {
3939  free( bytesBuf->buf );
3940  bytesBuf->buf = NULL;
3941  }
3942  break;
3943  }
3944  }
3945  if ( nbytes < 0 ) {
3946  return nbytes;
3947  }
3948  else {
3949  return 0;
3950  }
3951 }
3952 
3953 int
3954 writeFromByteBuf( int fd, bytesBuf_t * bytesBuf ) {
3955  int toWrite, nbytes;
3956  char *bufptr;
3957 
3958  bufptr = ( char * )bytesBuf->buf;
3959  toWrite = bytesBuf->len;
3960  while ( ( nbytes = myWrite( fd, bufptr, toWrite, NULL ) ) >= 0 ) {
3961  toWrite -= nbytes;
3962  bufptr += nbytes;
3963  if ( toWrite <= 0 ) {
3964  break;
3965  }
3966  }
3967  close( fd );
3968 
3969  if ( toWrite != 0 ) {
3970  return SYS_COPY_LEN_ERR - errno;
3971  }
3972  else {
3973  return 0;
3974  }
3975 }
3976 
3977 int
3978 setForceFlagForRestart( bulkOprInp_t * bulkOprInp, bulkOprInfo_t * bulkOprInfo ) {
3979  if ( bulkOprInp == NULL || bulkOprInfo == NULL ) {
3980  return USER__NULL_INPUT_ERR;
3981  }
3982 
3983  if ( getValByKey( &bulkOprInp->condInput, FORCE_FLAG_KW ) != NULL ) {
3984  /* already has FORCE_FLAG_KW */
3985  return 0;
3986  }
3987 
3988  addKeyVal( &bulkOprInp->condInput, FORCE_FLAG_KW, "" );
3989  /* remember to remove it */
3990  bulkOprInfo->forceFlagAdded = 1;
3991 
3992  return 0;
3993 }
3994 
3995 int
3996 getPhyBunPath( const char * collection, const char * objPath, const char * phyBunDir,
3997  char * outPhyBunPath ) {
3998  int collLen = strlen( collection );
3999  const char *subPath = objPath + collLen;
4000 
4001  if ( *subPath != '/' ) {
4003  "getPhyBunPath: inconsistent collection %s and objPath %s",
4004  collection, objPath );
4005  return USER_INPUT_PATH_ERR;
4006  }
4007  snprintf( outPhyBunPath, MAX_NAME_LEN, "%s%s", phyBunDir, subPath );
4008  return 0;
4009 }
4010 
4011 int mySetenvStr( const char * envname, const char * envval ) {
4012  int status;
4013 
4014 #if defined(linux_platform)||defined(osx_platform)
4015  if ( envname == NULL || envval == NULL ) {
4016  return USER__NULL_INPUT_ERR;
4017  }
4018  status = setenv( envname, envval, 1 );
4019 #else
4020  char *myBuf;
4021  int len;
4022 
4023  if ( envname == NULL || envval == NULL ) {
4024  return USER__NULL_INPUT_ERR;
4025  }
4026  len = strlen( envname ) + strlen( envval ) + 16;
4027  myBuf = ( char * )malloc( len );
4028  snprintf( myBuf, len, "%s=%s", envname, envval );
4029  status = putenv( myBuf );
4030  // free( myBuf ); // JMC cppcheck - leak ==> backport 'fix' from comm trunk for solaris
4031 #endif
4032  return status;
4033 }
4034 
4035 int
4036 mySetenvInt( char * envname, int envval ) {
4037  int status;
4038 
4039 #if defined(linux_platform)||defined(osx_platform)
4040  char myIntStr[NAME_LEN];
4041  if ( envname == NULL ) {
4042  return USER__NULL_INPUT_ERR;
4043  }
4044  snprintf( myIntStr, NAME_LEN, "%d", envval );
4045  status = setenv( envname, myIntStr, 1 );
4046 #else
4047  char *myBuf;
4048  int len;
4049  if ( envname == NULL ) {
4050  return USER__NULL_INPUT_ERR;
4051  }
4052  len = strlen( envname ) + 20;
4053  myBuf = ( char * )malloc( len );
4054  snprintf( myBuf, len, "%s=%d", envname, envval );
4055  status = putenv( myBuf );
4056  // free( myBuf ); // JMC cppcheck - leak ==> backport 'fix' from comm trunk for solaris
4057 #endif
4058  return status;
4059 }
4060 
4061 int
4062 getRandomArray( int **randomArray, int size ) {
4063  if ( size < 0 ) {
4064  *randomArray = NULL;
4065  return -1;
4066  }
4067 
4068  *randomArray = ( int * ) malloc( size * sizeof( int ) );
4069  for ( int i = 0; i < size; i++ ) {
4070  ( *randomArray )[i] = i + 1;
4071  }
4072 
4073  static std::mt19937 urng{std::random_device{}()};
4074  std::shuffle(*randomArray, *randomArray + size, urng);
4075 
4076  return 0;
4077 }
4078 
4079 // isPathSymlink_err() replaces isPathSymlink() below, which is being deprecated.
4080 // Returns:
4081 // 0 - treat the parameter path as NOT a symlink
4082 // 1 - treat the parameter path as a symlink
4083 // <0 - Error code (message in the message stack)
4084 int
4085 isPathSymlink_err( rodsArguments_t* rodsArgs, const char* myPath )
4086 {
4087  // This function (isPathSymlink) now uses the new
4088  // is_path_valid_for_recursion() defined in irods_path_recursion.cpp/hpp.
4089  try {
4090  if (irods::is_path_valid_for_recursion(rodsArgs, myPath))
4091  {
4092  // treat this path like a symlink
4093  return 0;
4094  }
4095  else
4096  {
4097  // treat this path like it's not a symlink, even if it is.
4098  return 1;
4099  }
4100  } catch ( const irods::exception& _e ) {
4102  // The soon-to-be deprecated version of isPathSymlink() returned
4103  // 0 or 1, and no error condition. This function returns
4104  // a negative error code that can be checked for.
4105  return _e.code();
4106  }
4107 }
4108 
4109 // This function will be deprecated in a future release.
4110 // Please start using the function above this one instead.
4111 // This function loses errors, even as it prints them to
4112 // stderr. The new function above returns < 0 with error
4113 // numbers in addition to the old 0 or 1.
4114 int
4115 isPathSymlink( rodsArguments_t* rodsArgs, const char* myPath )
4116 {
4117  int status = isPathSymlink_err(rodsArgs, myPath );
4118 
4119  if (status < 0)
4120  {
4121  // Returning 1 here means that the path will not participate.
4122  // This loses some information - but at least the error stack
4123  // will contain the error message, and will be displayed
4124  // to the user.
4125  return 1;
4126  }
4127  return status; // 0 or 1
4128 }
4129 
4130 void
4131 clearAuthResponseInp( void * inauthResponseInp ) {
4132  authResponseInp_t *authResponseInp;
4133 
4134  authResponseInp = ( authResponseInp_t * ) inauthResponseInp;
4135 
4136  if ( authResponseInp == NULL ) {
4137  return;
4138  }
4139  free( authResponseInp->username );
4140  free( authResponseInp->response );
4141  memset( authResponseInp, 0, sizeof( authResponseInp_t ) );
4142 
4143  return;
4144 }
4145 
4146 char *trimPrefix( char * str ) {
4147  int i = 0;
4148  while ( str[i] != ' ' ) {
4149  i++;
4150  }
4151  while ( str[i] == ' ' ) {
4152  i++;
4153  }
4154  memmove( str, str + i, strlen( str ) + 1 - i );
4155  return str;
4156 }
4157 
4158 char *trimSpaces( char * str ) {
4159  char *p = str;
4160  char *psrc = str;
4161 
4162  while ( *psrc != '\0' && isspace( *psrc ) ) {
4163  psrc++;
4164  }
4165 
4166  while ( *psrc != '\0' ) {
4167  *( p++ ) = *( psrc++ );
4168  }
4169 
4170  p--;
4171  while ( isspace( *p ) && p - str >= 0 ) {
4172  p--;
4173  }
4174 
4175  p++;
4176  *p = '\0';
4177 
4178  return str;
4179 
4180 }
4181 
4182 int startsWith( const char * str, const char * prefix ) {
4183  return str == strstr( str, prefix );
4184 }
4185 
4186 int convertListToMultiString( char * strInput, int input ) {
4187  if ( strcmp( strInput, "null" ) == 0 ) {
4188  return 0;
4189  }
4190  char *src = strdup( strInput );
4191 
4192  char *p = strInput;
4193  char *psrc = src;
4194 
4195  /* replace % with %% */
4196  while ( *psrc != '\0' ) {
4197  if ( *psrc == '%' ) {
4198  *( p++ ) = '%';
4199  *( p++ ) = '%';
4200  psrc++;
4201  }
4202  else {
4203  *( p++ ) = *( psrc++ );
4204  }
4205  }
4206  *p = '\0';
4207 
4208  free( src );
4209 
4210  /* replace , with % and remove extra spaces */
4211  p = strInput;
4212  psrc = strInput;
4213  while ( *psrc != '\0' ) {
4214  /* variable name */
4215  while ( !isspace( *psrc ) && *psrc != '=' && *psrc != ',' && *psrc != '\0' ) {
4216  *( p++ ) = *( psrc++ );
4217  }
4218 
4219  /* skip spaces */
4220  while ( isspace( *psrc ) ) {
4221  psrc++;
4222  }
4223  if ( input ) {
4224  if ( *psrc == '=' ) {
4225  /* assignment */
4226  *( p++ ) = *( psrc++ );
4227 
4228  int inString = 0;
4229  char delim = '\0';
4230  while ( *psrc != '\0' ) {
4231  if ( inString ) {
4232  if ( *psrc == delim ) {
4233  inString = 0;
4234  }
4235  else if ( *psrc == '\\' ) {
4236  *( p++ ) = *( psrc++ );
4237  if ( *psrc == '\0' ) {
4238  return -1;
4239  }
4240  }
4241  *( p++ ) = *( psrc++ );
4242  }
4243  else {
4244  if ( *psrc == ',' ) {
4245  *( p++ ) = '%';
4246  psrc++;
4247  break;
4248  }
4249  else {
4250  if ( *psrc == '\'' || *psrc == '\"' ) {
4251  inString = 1;
4252  delim = *psrc;
4253  }
4254  *( p++ ) = *( psrc++ );
4255  }
4256  }
4257  }
4258  }
4259  else {
4260  return -1;
4261  }
4262  }
4263  else {
4264  if ( *psrc == '\0' ) {
4265  break;
4266  }
4267  else if ( *psrc == ',' ) {
4268  *( p++ ) = '%';
4269  psrc++;
4270  }
4271  else {
4272  return -1;
4273  }
4274  }
4275  /* skip spaces */
4276  while ( isspace( *psrc ) ) {
4277  psrc++;
4278  }
4279  }
4280  *p = '\0';
4281  return 0;
4282 }
4283 
4284 int
4285 splitMultiStr( char * strInput, strArray_t * strArray ) {
4286  char *startPtr, *endPtr;
4287  int endReached = 0;
4288 
4289  if ( strInput == NULL || strArray == NULL ) {
4291  }
4292 
4293  startPtr = endPtr = strInput;
4294 
4295  while ( 1 ) {
4296  // two %% will be taken as an input % instead of as a delimiter
4297  while ( *endPtr != '%' && *endPtr != '\0' ) {
4298  endPtr ++;
4299  }
4300  if ( *endPtr == '%' ) {
4301  if ( *( endPtr + 1 ) == '%' ) {
4302  endPtr ++;
4303  endPtr ++;
4304  continue;
4305  }
4306  *endPtr = '\0';
4307  }
4308  else {
4309  endReached = 1;
4310  }
4311 
4312  char *str = strdup( startPtr );
4313  char *p = str;
4314  char *psrc = str;
4315  while ( *psrc != '\0' ) {
4316  while ( *psrc != '%' && *psrc != '\0' ) {
4317  *( p++ ) = *( psrc++ );
4318  }
4319  if ( *psrc == '%' ) {
4320  *( p++ ) = *( psrc++ );
4321  psrc++;
4322  }
4323  }
4324  *p = '\0';
4325 
4326  addStrArray( strArray, str );
4327 
4328  free( str );
4329 
4330  if ( endReached == 1 ) {
4331  break;
4332  }
4333 
4334  endPtr++;
4335  startPtr = endPtr;
4336  }
4337 
4338  return strArray->len;
4339 }
4340 
4341 namespace boost {
4342  void assertion_failed( char const * expr,
4343  char const * function, char const * file, long line ) {
4344  std::cerr <<
4345  "***** Internal Program Error - assertion (" << expr << ") failed in "
4346  << function << ":\n"
4347  << file << '(' << line << "): errno = " << errno << std::endl;
4348  }
4349 
4350 
4351 } // namespace boost
4352 
4353 int
4354 getPathStMode( const char* p ) {
4355  struct stat statbuf;
4356 
4357  if ( stat( p, &statbuf ) == 0 &&
4358  ( statbuf.st_mode & S_IFREG ) ) {
4359  return statbuf.st_mode;
4360  }
4361  else {
4362  return -1;
4363  }
4364 }
4365 
4366 
4367 int
4368 hasSymlinkInDir( const char * mydir ) {
4369  int status;
4370  char subfilePath[MAX_NAME_LEN];
4371  DIR *dirPtr;
4372  struct dirent *myDirent;
4373  struct stat statbuf;
4374 
4375  if ( mydir == NULL ) {
4376  return 0;
4377  }
4378  dirPtr = opendir( mydir );
4379  if ( dirPtr == NULL ) {
4380  return 0;
4381  }
4382 
4383  while ( ( myDirent = readdir( dirPtr ) ) != NULL ) {
4384  if ( strcmp( myDirent->d_name, "." ) == 0 ||
4385  strcmp( myDirent->d_name, ".." ) == 0 ) {
4386  continue;
4387  }
4388  snprintf( subfilePath, MAX_NAME_LEN, "%s/%s",
4389  mydir, myDirent->d_name );
4390  status = lstat( subfilePath, &statbuf );
4391  if ( status != 0 ) {
4392  rodsLog( LOG_ERROR,
4393  "hasSymlinkIndir: stat error for %s, errno = %d",
4394  subfilePath, errno );
4395  continue;
4396  }
4397  if ( ( statbuf.st_mode & S_IFLNK ) == S_IFLNK ) {
4398  rodsLog( LOG_ERROR,
4399  "hasSymlinkIndir: %s is a symlink",
4400  subfilePath );
4401  closedir( dirPtr );
4402  return 1;
4403  }
4404  if ( ( statbuf.st_mode & S_IFDIR ) != 0 ) {
4405  if ( hasSymlinkInDir( subfilePath ) ) {
4406  closedir( dirPtr );
4407  return 1;
4408  }
4409  }
4410  }
4411  closedir( dirPtr );
4412  return 0;
4413 }
4414 
4415 int
4416 hasSymlinkInPartialPath( const char * myPath, int pos ) {
4417  const char *curPtr = myPath + pos;
4418  struct stat statbuf;
4419  int status;
4420 
4421  status = lstat( myPath, &statbuf );
4422  if ( status != 0 ) {
4423  rodsLog( LOG_ERROR,
4424  "hasSymlinkInPartialPath: stat error for %s, errno = %d",
4425  myPath, errno );
4426  return 0;
4427  }
4428  if ( ( statbuf.st_mode & S_IFLNK ) == S_IFLNK ) {
4429  rodsLog( LOG_ERROR,
4430  "hasSymlinkInPartialPath: %s is a symlink", myPath );
4431  return 1;
4432  }
4433 
4434  while ( ( curPtr = strchr( curPtr, '/' ) ) != NULL ) {
4435  std::string sub_path( myPath, curPtr - myPath );
4436  status = lstat( sub_path.c_str(), &statbuf );
4437  if ( status != 0 ) {
4438  rodsLog( LOG_ERROR,
4439  "hasSymlinkInPartialPath: stat error for %s, errno = %d",
4440  sub_path.c_str(), errno );
4441  return 0;
4442  }
4443  if ( ( statbuf.st_mode & S_IFLNK ) == S_IFLNK ) {
4444  rodsLog( LOG_ERROR,
4445  "hasSymlinkInPartialPath: %s is a symlink", sub_path.c_str() );
4446  return 1;
4447  }
4448  curPtr++;
4449  }
4450  return 0;
4451 }
4452 
4453 int
4454 hasSymlinkInPath( const char * myPath ) {
4455  static char lastCheckedPath[MAX_NAME_LEN];
4456  int status, i;
4457  int lastSlashPos = 0;
4458 
4459  for ( i = 0; i < MAX_NAME_LEN; i++ ) {
4460  if ( lastCheckedPath[i] != myPath[i] ) {
4461  break;
4462  }
4463  if ( lastCheckedPath[i] == '/' ) {
4464  lastSlashPos = i;
4465  }
4466  }
4467  status = hasSymlinkInPartialPath( myPath, lastSlashPos + 1 );
4468  if ( status == 0 ) {
4469  rstrcpy( lastCheckedPath, myPath, MAX_NAME_LEN );
4470  }
4471  return status;
4472 }
4473 
4474 
4475 static std::string stringify_addrinfo_hints(const struct addrinfo *_hints) {
4476  std::string ret;
4477  if (!_hints) {
4478  ret = "null hint pointer";
4479  } else {
4480  std::stringstream stream;
4481  stream << "ai_flags: [" << _hints->ai_flags << "] ai_family: [" << _hints->ai_family << "] ai_socktype: [" << _hints->ai_socktype << "] ai_protocol: [" << _hints->ai_protocol << "]";
4482  ret = stream.str();
4483  }
4484  return ret;
4485 }
4486 
4487 auto resolve_hostname_from_hosts_config(const std::string& name_to_resolve) -> std::string
4488 {
4489  using json = nlohmann::json;
4490  static json hosts_config{};
4491 
4492  std::string resolved_name{name_to_resolve};
4493 
4494  try {
4495  if(hosts_config.empty()) {
4496  std::string cfg_file;
4498  if(!err.ok()) {
4499  return name_to_resolve;
4500  }
4501 
4502  hosts_config = json::parse(std::ifstream{cfg_file});
4503  }
4504 
4505  for(const auto entry : hosts_config.at("host_entries")) {
4506  const auto addresses = entry.at("addresses");
4507  const std::string target_name{addresses.at(0).at("address")};
4508 
4509  for( json::size_type i = 1; i < addresses.size(); ++i) {
4510  const auto alias{addresses.at(i).at("address")};
4511  if(alias == name_to_resolve) {
4512  resolved_name = target_name;
4513  break;
4514  }
4515  } // for alias
4516  } // for entry
4517  }
4518  catch(const json::exception& e) {
4519  rodsLog(
4520  LOG_ERROR,
4521  "%s :: caught exception: ",
4522  __FUNCTION__,
4523  e.what());
4524  }
4525  catch(...) {
4526  rodsLog(
4527  LOG_ERROR,
4528  "%s :: caught unknown exception",
4529  __FUNCTION__);
4530  }
4531 
4532  return resolved_name;
4533 
4534 } // resolve_hostname_from_hosts_config
4535 
4536 int
4537 getaddrinfo_with_retry(const char *_node, const char *_service, const struct addrinfo *_hints, struct addrinfo **_res) {
4538 
4539  const auto hostname = resolve_hostname_from_hosts_config(_node);
4540 
4541  *_res = 0;
4542  const int max_retry = 300;
4543  for (int i=0; i<max_retry; ++i) {
4544  const int ret_getaddrinfo = getaddrinfo(hostname.c_str(), _service, _hints, _res);
4545  if ( ret_getaddrinfo == EAI_AGAIN
4546  || ret_getaddrinfo == EAI_NONAME
4547  || ret_getaddrinfo == EAI_NODATA) { // retryable errors
4548 
4549  struct timespec ts_requested;
4550  ts_requested.tv_sec = 0;
4551  ts_requested.tv_nsec = 100 * 1000 * 1000; // 100 milliseconds
4552  while (0 != nanosleep(&ts_requested, &ts_requested)) {
4553  const int errno_copy = errno;
4554  if (errno_copy != EINTR) {
4555  rodsLog(LOG_ERROR, "getaddrinfo_with_retry: nanosleep error: errno [%d]", errno_copy);
4556  return USER_RODS_HOSTNAME_ERR - errno_copy;
4557  }
4558  }
4559  } else if (ret_getaddrinfo != 0) { // non-retryable error
4560  if (ret_getaddrinfo == EAI_SYSTEM) {
4561  const int errno_copy = errno;
4562  std::string hint_str = stringify_addrinfo_hints(_hints);
4563  rodsLog(LOG_ERROR, "getaddrinfo_with_retry: getaddrinfo non-recoverable system error [%d] [%s] [%d] [%s] [%s]", ret_getaddrinfo, gai_strerror(ret_getaddrinfo), errno_copy, hostname.c_str(), hint_str.c_str());
4564  } else {
4565  std::string hint_str = stringify_addrinfo_hints(_hints);
4566  rodsLog(LOG_ERROR, "getaddrinfo_with_retry: getaddrinfo non-recoverable error [%d] [%s] [%s] [%s]", ret_getaddrinfo, gai_strerror(ret_getaddrinfo), hostname.c_str(), hint_str.c_str());
4567  }
4568  return USER_RODS_HOSTNAME_ERR;
4569  } else {
4570  return 0;
4571  }
4572  rodsLog(LOG_DEBUG, "getaddrinfo_with_retry retrying getaddrinfo. retry count [%d] hostname [%s]", i, hostname.c_str());
4573  }
4574  std::string hint_str = stringify_addrinfo_hints(_hints);
4575  rodsLog(LOG_ERROR, "getaddrinfo_with_retry address resolution timeout [%s] [%s]", hostname.c_str(), hint_str.c_str());
4576  return USER_RODS_HOSTNAME_ERR;
4577 }
4578 
4579 
4580 int get_canonical_name(const char *_hostname, char* _buf, size_t _len) {
4581  struct addrinfo hint;
4582  memset(&hint, 0, sizeof(hint));
4583  hint.ai_flags = AI_CANONNAME;
4584  struct addrinfo *p_addrinfo;
4585  const int ret_getaddrinfo_with_retry = getaddrinfo_with_retry(_hostname, 0, &hint, &p_addrinfo);
4586  if (ret_getaddrinfo_with_retry ) {
4587  return ret_getaddrinfo_with_retry;
4588  }
4589  snprintf(_buf, _len, "%s", p_addrinfo->ai_canonname);
4590  freeaddrinfo(p_addrinfo);
4591  return 0;
4592 }
4593 
4594 int load_in_addr_from_hostname(const char* _hostname, struct in_addr* _out) {
4595  struct addrinfo hint;
4596  memset(&hint, 0, sizeof(hint));
4597  hint.ai_family = AF_INET;
4598  struct addrinfo *p_addrinfo;
4599  const int ret_getaddrinfo_with_retry = getaddrinfo_with_retry(_hostname, 0, &hint, &p_addrinfo);
4600  if (ret_getaddrinfo_with_retry) {
4601  return ret_getaddrinfo_with_retry;
4602  }
4603  *_out = reinterpret_cast<struct sockaddr_in*>(p_addrinfo->ai_addr)->sin_addr;
4604  freeaddrinfo(p_addrinfo);
4605  return 0;
4606 }
4607 
4608 
4609 int
4610 myWrite( int sock, void *buf, int len,
4611  int *bytesWritten ) {
4612 
4613  if ( bytesWritten ) {
4614  *bytesWritten = 0;
4615  }
4616 
4617  char *tmpPtr = ( char * ) buf;
4618  int toWrite = len;
4619  while ( toWrite > 0 ) {
4620  int nbytes;
4621 #ifdef _WIN32
4622  if ( irodsDescType == SOCK_TYPE ) {
4623  nbytes = send( sock, tmpPtr, toWrite, 0 );
4624  }
4625  else {
4626  nbytes = write( sock, ( void * ) tmpPtr, toWrite );
4627  }
4628 #else
4629  nbytes = write( sock, ( void * ) tmpPtr, toWrite );
4630 #endif
4631  if ( nbytes <= 0 ) {
4632  if ( errno == EINTR ) {
4633  /* interrupted */
4634  errno = 0;
4635  nbytes = 0;
4636  }
4637  else {
4638  break;
4639  }
4640  }
4641  toWrite -= nbytes;
4642  tmpPtr += nbytes;
4643  if ( bytesWritten ) {
4644  *bytesWritten += nbytes;
4645  }
4646  }
4647  return len - toWrite;
4648 }
4649 
4650 int
4651 myRead( int sock, void *buf, int len,
4652  int *bytesRead, struct timeval *tv ) {
4653  int nbytes;
4654  int toRead;
4655  char *tmpPtr;
4656  fd_set set;
4657  struct timeval timeout;
4658  int status;
4659 
4660  /* Initialize the file descriptor set. */
4661  FD_ZERO( &set );
4662  FD_SET( sock, &set );
4663  if ( tv != NULL ) {
4664  timeout = *tv;
4665  }
4666 
4667  toRead = len;
4668  tmpPtr = ( char * ) buf;
4669 
4670  if ( bytesRead != NULL ) {
4671  *bytesRead = 0;
4672  }
4673 
4674  while ( toRead > 0 ) {
4675 #ifdef _WIN32
4676  if ( irodsDescType == SOCK_TYPE ) {
4677  nbytes = recv( sock, tmpPtr, toRead, 0 );
4678  }
4679  else {
4680  nbytes = read( sock, ( void * ) tmpPtr, toRead );
4681  }
4682 #else
4683  if ( tv != NULL ) {
4684  status = select( sock + 1, &set, NULL, NULL, &timeout );
4685  if ( status == 0 ) {
4686  /* timedout */
4687  if ( len - toRead > 0 ) {
4688  return len - toRead;
4689  }
4690  else {
4691  return SYS_SOCK_READ_TIMEDOUT;
4692  }
4693  }
4694  else if ( status < 0 ) {
4695  if ( errno == EINTR ) {
4696  continue;
4697  }
4698  else {
4699  return SYS_SOCK_READ_ERR - errno;
4700  }
4701  }
4702  }
4703  nbytes = read( sock, ( void * ) tmpPtr, toRead );
4704 #endif
4705  if ( nbytes <= 0 ) {
4706  if ( errno == EINTR ) {
4707  /* interrupted */
4708  errno = 0;
4709  nbytes = 0;
4710  }
4711  else {
4712  break;
4713  }
4714  }
4715 
4716  toRead -= nbytes;
4717  tmpPtr += nbytes;
4718  if ( bytesRead != NULL ) {
4719  *bytesRead += nbytes;
4720  }
4721  }
4722  return len - toRead;
4723 }
COL_DATA_TYPE_NAME
#define COL_DATA_TYPE_NAME
Definition: rodsGenQuery.h:168
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
getSpecCollOpr
structFileOprType_t getSpecCollOpr(keyValPair_t *condInput, specColl_t *specColl)
Definition: rcMisc.cpp:3278
clearUnregDataObj
void clearUnregDataObj(void *voidInp)
Definition: rcMisc.cpp:1422
freeRodsObjStat
int freeRodsObjStat(rodsObjStat_t *rodsObjStat)
Definition: rcMisc.cpp:3537
clearGenQueryOut
void clearGenQueryOut(void *voidInp)
Definition: rcMisc.cpp:1150
NULL
#define NULL
Definition: rodsDef.h:70
rodsStat::st_mode
unsigned int st_mode
Definition: rodsType.h:56
procAndWriteRestartFile
int procAndWriteRestartFile(rodsRestart_t *rodsRestart, char *donePath)
Definition: rcMisc.cpp:2700
getIrodsErrno
int getIrodsErrno(int irodError)
Definition: rcMisc.cpp:3272
True
#define True
Definition: parseCommandLine.h:11
DataObjCopyInp::srcDataObjInp
dataObjInp_t srcDataObjInp
Definition: dataObjCopy.h:26
COL_DATA_REPL_NUM
#define COL_DATA_REPL_NUM
Definition: rodsGenQuery.h:166
irods::get_full_path_for_config_file
error get_full_path_for_config_file(const std::string &, std::string &)
Definition: irods_get_full_path_for_config_file.cpp:20
rodsDirent::d_namlen
unsigned int d_namlen
Definition: rodsType.h:74
getAttriInAttriArray
int getAttriInAttriArray(const char *inpObjPath, genQueryOut_t *attriArray, int *outDataMode, char **outChksum)
Definition: rcMisc.cpp:3810
rError_t::len
int len
Definition: rodsError.h:25
TagStruct::len
int len
Definition: objInfo.h:310
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
rodsStat::st_ctim
unsigned int st_ctim
Definition: rodsType.h:63
TagStruct
Definition: objInfo.h:309
irods.pyparsing.columnName
def columnName
Definition: pyparsing.py:3815
getPathStMode
int getPathStMode(const char *p)
Definition: rcMisc.cpp:4354
is_ORPHAN_HOME
@ is_ORPHAN_HOME
Definition: rodsDef.h:174
LINK_POINT_STR
#define LINK_POINT_STR
Definition: objInfo.h:69
SELECT_COUNT
#define SELECT_COUNT
Definition: rodsGenQuery.h:106
modAVUMetadataInp_t::arg0
char * arg0
Definition: modAVUMetadata.h:7
getValByKey
char * getValByKey(const keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:675
DataObjCopyInp
Definition: dataObjCopy.h:25
freeAllDataObjInfo
int freeAllDataObjInfo(dataObjInfo_t *dataObjInfoHead)
Definition: rcMisc.cpp:561
localToUnixTime
int localToUnixTime(char *localTime, char *unixTime)
Definition: rcMisc.cpp:2035
rErrMsg_t
Definition: rodsError.h:19
bulkOprInp_t
Definition: bulkDataObjPut.h:17
catGenQueryOut
int catGenQueryOut(genQueryOut_t *targGenQueryOut, genQueryOut_t *genQueryOut, int maxRowCnt)
Definition: rcMisc.cpp:1172
fillAttriArrayOfBulkOprInp
int fillAttriArrayOfBulkOprInp(char *objPath, int dataMode, char *inpChksum, int offset, bulkOprInp_t *bulkOprInp)
Definition: rcMisc.cpp:3763
freeDataObjInfo
int freeDataObjInfo(dataObjInfo_t *dataObjInfo)
Definition: rcMisc.cpp:544
rmKeyVal
int rmKeyVal(keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:710
initAttriArrayOfBulkOprInp
int initAttriArrayOfBulkOprInp(bulkOprInp_t *bulkOprInp)
Definition: rcMisc.cpp:3716
rodsArguments_t
Definition: parseCommandLine.h:14
rodsRestart_t::doneCnt
int doneCnt
Definition: rodsDef.h:320
modDataObjMeta.h
USER_INVALID_USERNAME_FORMAT
@ USER_INVALID_USERNAME_FORMAT
Definition: rodsErrorTable.h:250
rescQuota::next
struct rescQuota * next
Definition: getRescQuota.h:35
hasSymlinkInPath
int hasSymlinkInPath(const char *myPath)
Definition: rcMisc.cpp:4454
OPR_TYPE_INX
#define OPR_TYPE_INX
Definition: bulkDataObjReg.h:9
CollInp
Definition: dataObjInpOut.h:157
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
isInteger
int isInteger(const char *inStr)
Definition: rcMisc.cpp:2070
goodStrExpr
int goodStrExpr(char *expr)
Definition: rcMisc.cpp:2838
UNMATCHED_KEY_OR_INDEX
@ UNMATCHED_KEY_OR_INDEX
Definition: rodsErrorTable.h:244
SYS_MALLOC_ERR
@ SYS_MALLOC_ERR
Definition: rodsErrorTable.h:84
SqlResult::attriInx
int attriInx
Definition: rodsGenQuery.h:62
DataObjInp::specColl
specColl_t * specColl
Definition: dataObjInpOut.h:73
rodsRestart_t::restartState
int restartState
Definition: rodsDef.h:325
SpecColl::resource
char resource[64]
Definition: objInfo.h:83
unregDataObj_t::condInput
keyValPair_t * condInput
Definition: unregDataObj.h:9
hasSymlinkInDir
int hasSymlinkInDir(const char *mydir)
Definition: rcMisc.cpp:4368
SendXmsgInfo
Definition: rodsXmsg.h:30
irods_get_full_path_for_config_file.hpp
rodsStat::st_uid
unsigned int st_uid
Definition: rodsType.h:58
moveKeyVal
int moveKeyVal(keyValPair_t *destKeyVal, keyValPair_t *srcKeyVal)
Definition: rcMisc.cpp:1259
rodsGenQueryNames.h
modAccessControlInp_t::userName
char * userName
Definition: modAccessControl.h:12
irods_stacktrace.hpp
getMountedSubPhyPath
int getMountedSubPhyPath(char *logMountPoint, char *phyMountPoint, char *logSubPath, char *phySubPathOut)
Definition: rcMisc.cpp:3078
parseHostAddrStr
int parseHostAddrStr(char *hostAddr, rodsHostAddr_t *addr)
Definition: rcMisc.cpp:3552
getUnixUid
int getUnixUid(char *userName)
Definition: rcMisc.cpp:1270
rodsArguments_t::verbose
int verbose
Definition: parseCommandLine.h:107
rodsDirent::d_name
char d_name[256]
Definition: rodsType.h:75
MAX_NUM_BULK_OPR_FILES
#define MAX_NUM_BULK_OPR_FILES
Definition: rodsDef.h:136
SendXmsgInfo::deliPort
uint * deliPort
Definition: rodsXmsg.h:38
StructFileTypeDef::type
structFileType_t type
Definition: objInfo.h:327
isTrashPath
int isTrashPath(char *myPath)
Definition: rcMisc.cpp:2395
irods_exception.hpp
isBundlePath
int isBundlePath(char *myPath)
Definition: rcMisc.cpp:2368
isPath
int isPath(char *myPath)
Definition: rcMisc.cpp:60
rErrMsg_t::status
int status
Definition: rodsError.h:20
GenQueryInp
Definition: rodsGenQuery.h:24
rodsStat::st_dev
unsigned int st_dev
Definition: rodsType.h:54
fillGenQueryInpFromStrCond
int fillGenQueryInpFromStrCond(char *str, genQueryInp_t *genQueryInp)
Definition: rcMisc.cpp:2921
SpecColl::cacheDirty
int cacheDirty
Definition: objInfo.h:92
appendToByteBuf
int appendToByteBuf(bytesBuf_t *bytesBuf, char *str)
Definition: rcMisc.cpp:3048
SELECT_MAX
#define SELECT_MAX
Definition: rodsGenQuery.h:103
modAVUMetadataInp_t::arg2
char * arg2
Definition: modAVUMetadata.h:9
NOT_ORPHAN_PATH
@ NOT_ORPHAN_PATH
Definition: rodsDef.h:172
SpecColl::phyPath
char phyPath[(1024+64)]
Definition: objInfo.h:85
irods::experimental::administration::client::v1::exists
auto exists(rcComm_t &conn, const user &user) -> bool
Definition: user_administration.cpp:359
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
rodsStat::st_rdev
unsigned int st_rdev
Definition: rodsType.h:60
SYS_COLLINFO_2_FORMAT_ERR
@ SYS_COLLINFO_2_FORMAT_ERR
Definition: rodsErrorTable.h:131
rcMisc.h
pid_age.p
p
Definition: pid_age.py:13
initBulkDataObjRegOut
int initBulkDataObjRegOut(genQueryOut_t **bulkDataObjRegOut)
Definition: rcMisc.cpp:3688
SpecColl::cacheDir
char cacheDir[(1024+64)]
Definition: objInfo.h:89
bulkOprInp_t::condInput
keyValPair_t condInput
Definition: bulkDataObjPut.h:20
SELECT_AVG
#define SELECT_AVG
Definition: rodsGenQuery.h:105
printGenQueryOut
int printGenQueryOut(FILE *fd, char *format, char *hint, genQueryOut_t *genQueryOut)
Definition: rcMisc.cpp:3001
LONG_NAME_LEN
#define LONG_NAME_LEN
Definition: rodsDef.h:57
SpecColl::type
structFileType_t type
Definition: objInfo.h:78
modAccessControlInp_t::accessLevel
char * accessLevel
Definition: modAccessControl.h:11
bulkDataObjPut.h
clearModAVUMetadataInp
void clearModAVUMetadataInp(void *voidInp)
Definition: rcMisc.cpp:3516
rodsStat::st_mtim
unsigned int st_mtim
Definition: rodsType.h:62
clearSendXmsgInfo
int clearSendXmsgInfo(sendXmsgInfo_t *sendXmsgInfo)
Definition: rcMisc.cpp:3473
getDataObjInfoCnt
int getDataObjInfoCnt(dataObjInfo_t *dataObjInfoHead)
Definition: rcMisc.cpp:661
DataObjInfo::condInput
keyValPair_t condInput
Definition: objInfo.h:161
isPathSymlink
int isPathSymlink(rodsArguments_t *rodsArgs, const char *myPath)
Definition: rcMisc.cpp:4115
getNowStr
void getNowStr(char *timeStr)
Definition: rcMisc.cpp:1590
keyValToString
int keyValToString(keyValPair_t *list, char **string)
Definition: rcMisc.cpp:3304
SpecColl
Definition: objInfo.h:76
InxIvalPair::len
int len
Definition: objInfo.h:206
boost
Definition: rcMisc.cpp:4341
json
nlohmann::json json
Definition: group.cpp:5
clearInxIval
int clearInxIval(inxIvalPair_t *inxIvalPair)
Definition: rcMisc.cpp:1069
InxValPair::inx
int * inx
Definition: objInfo.h:215
getSqlResultByInx
sqlResult_t * getSqlResultByInx(genQueryOut_t *genQueryOut, int attriInx)
Definition: rcMisc.cpp:1387
makeCachedStructFileStr
int makeCachedStructFileStr(char *collInfo2, specColl_t *specColl)
Definition: rcMisc.cpp:3242
STRUCT_FILE_COLL
@ STRUCT_FILE_COLL
Definition: objInfo.h:47
rodsRestart_t::lastDonePath
char lastDonePath[(1024+64)]
Definition: rodsDef.h:322
STRUCT_FILE_OPR_KW
#define STRUCT_FILE_OPR_KW
Definition: rodsKeyWdDef.h:72
rcGlobalExtern.h
structFileOprType_t
structFileOprType_t
Definition: objInfo.h:59
modAVUMetadataInp_t::arg4
char * arg4
Definition: modAVUMetadata.h:11
get64RandomBytes
int get64RandomBytes(char *buf)
Definition: rcMisc.cpp:1371
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
hasSymlinkInPartialPath
int hasSymlinkInPartialPath(const char *myPath, int pos)
Definition: rcMisc.cpp:4416
modAccessControlInp_t
Definition: modAccessControl.h:9
dequeDataObjInfo
int dequeDataObjInfo(dataObjInfo_t **dataObjInfoHead, dataObjInfo_t *dataObjInfo)
Definition: rcMisc.cpp:635
rodsDirent::d_reclen
unsigned int d_reclen
Definition: rodsType.h:73
irods::exception::code
int64_t code() const
Definition: irods_exception.hpp:39
COL_D_DATA_CHECKSUM
#define COL_D_DATA_CHECKSUM
Definition: rodsGenQuery.h:177
getLocalTimeStr
int getLocalTimeStr(struct tm *mytm, char *timeStr)
Definition: rcMisc.cpp:1630
SELECT_MIN
#define SELECT_MIN
Definition: rodsGenQuery.h:102
EXEC_CMD_OUTPUT_TOO_LARGE
@ EXEC_CMD_OUTPUT_TOO_LARGE
Definition: rodsErrorTable.h:264
DataObjInfo::next
struct DataObjInfo * next
Definition: objInfo.h:163
GenQueryInp::selectInp
inxIvalPair_t selectInp
Definition: rodsGenQuery.h:53
GenQueryOut::sqlResult
sqlResult_t sqlResult[50]
Definition: rodsGenQuery.h:72
rodsDirent::d_ino
unsigned int d_ino
Definition: rodsType.h:72
DataObjInfo::specColl
specColl_t * specColl
Definition: objInfo.h:158
splitMultiStr
int splitMultiStr(char *strInput, strArray_t *strArray)
Definition: rcMisc.cpp:4285
SYS_GROUP_RETRIEVE_ERR
@ SYS_GROUP_RETRIEVE_ERR
Definition: rodsErrorTable.h:196
InxValPair::value
char ** value
Definition: objInfo.h:216
getErrno
int getErrno(int irodError)
Definition: rcMisc.cpp:3261
getCondFromString
char * getCondFromString(char *t)
Definition: rcMisc.cpp:2883
HOST_CONFIG_FILE
#define HOST_CONFIG_FILE
Definition: rodsConnect.h:7
regReplica_t::condInput
keyValPair_t condInput
Definition: regReplica.h:10
StrArray::len
int len
Definition: objInfo.h:221
SendXmsgInfo::miscInfo
char * miscInfo
Definition: rodsXmsg.h:39
copyKeyVal
int copyKeyVal(const keyValPair_t *_src, keyValPair_t *_dst)
Definition: rcMisc.cpp:751
BytesBuf::len
int len
Definition: rodsDef.h:198
rodsStat::st_size
rodsLong_t st_size
Definition: rodsType.h:53
unregDataObj_t::dataObjInfo
dataObjInfo_t * dataObjInfo
Definition: unregDataObj.h:8
myHtonll
int myHtonll(rodsLong_t inlonglong, rodsLong_t *outlonglong)
Definition: rcMisc.cpp:232
tzname
char * tzname[2]
MOUNT_POINT_STR
#define MOUNT_POINT_STR
Definition: objInfo.h:68
trimSpaces
char * trimSpaces(char *str)
Definition: rcMisc.cpp:4158
KeyValPair::value
char ** value
Definition: objInfo.h:123
REG_CHKSUM_KW
#define REG_CHKSUM_KW
Definition: rodsKeyWdDef.h:15
INIT_SZ_FOR_EXECMD_BUF
#define INIT_SZ_FOR_EXECMD_BUF
Definition: rodsDef.h:87
USER_RESTART_FILE_INPUT_ERR
@ USER_RESTART_FILE_INPUT_ERR
Definition: rodsErrorTable.h:261
COL_DATA_NAME
#define COL_DATA_NAME
Definition: rodsGenQuery.h:165
regReplica_t::destDataObjInfo
dataObjInfo_t * destDataObjInfo
Definition: regReplica.h:9
SendXmsgInfo::msg
char * msg
Definition: rodsXmsg.h:35
bulkOprInfo_t::forceFlagAdded
int forceFlagAdded
Definition: putUtil.h:26
replErrorStack
int replErrorStack(rError_t *srcRError, rError_t *destRError)
Definition: rcMisc.cpp:152
clearAuthResponseInp
void clearAuthResponseInp(void *inauthResponseInp)
Definition: rcMisc.cpp:4131
rodsStat::st_atim
unsigned int st_atim
Definition: rodsType.h:61
UNIX_FILE_OPEN_ERR
@ UNIX_FILE_OPEN_ERR
Definition: rodsErrorTable.h:300
rodsStat
Definition: rodsType.h:52
LINKED_COLL
@ LINKED_COLL
Definition: objInfo.h:49
writeRestartFile
int writeRestartFile(rodsRestart_t *rodsRestart, char *lastDonePath)
Definition: rcMisc.cpp:2677
rError_t
Definition: rodsError.h:24
direntToRodsDirent
int direntToRodsDirent(struct rodsDirent *dirent, struct dirent *fileDirent)
Definition: rcMisc.cpp:330
getStrInBuf
int getStrInBuf(char **inbuf, char *outbuf, int *inbufLen, int outbufLen)
Definition: rcMisc.cpp:393
SYS_SOCK_READ_ERR
@ SYS_SOCK_READ_ERR
Definition: rodsErrorTable.h:181
COL_D_RESC_NAME
#define COL_D_RESC_NAME
Definition: rodsGenQuery.h:171
clearRegReplicaInp
void clearRegReplicaInp(void *voidInp)
Definition: rcMisc.cpp:1441
SYS_COPY_LEN_ERR
@ SYS_COPY_LEN_ERR
Definition: rodsErrorTable.h:95
getNextRepeatTime
int getNextRepeatTime(char *currTime, char *delayStr, char *nextTime)
Definition: rcMisc.cpp:1768
openRestartFile
int openRestartFile(char *restartFile, rodsRestart_t *rodsRestart)
Definition: rcMisc.cpp:2552
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
updateOffsetTimeStr
void updateOffsetTimeStr(char *timeStr, int offset)
Definition: rcMisc.cpp:1676
clearCollInp
void clearCollInp(void *voidInp)
Definition: rcMisc.cpp:1492
get_canonical_name
int get_canonical_name(const char *_hostname, char *_buf, size_t _len)
Definition: rcMisc.cpp:4580
GenQueryOut::continueInx
int continueInx
Definition: rodsGenQuery.h:70
DATE_FORMAT_ERR
@ DATE_FORMAT_ERR
Definition: rodsErrorTable.h:674
modAVUMetadataInp_t::arg7
char * arg7
Definition: modAVUMetadata.h:14
rodsType.h
irods::hierarchy_parser::first_resc
error first_resc(std::string &_ret_resc) const
Definition: irods_hierarchy_parser.cpp:96
getSelVal
int getSelVal(char *c)
Definition: rcMisc.cpp:2792
startsWith
int startsWith(const char *str, const char *prefix)
Definition: rcMisc.cpp:4182
modAccessControlInp_t::path
char * path
Definition: modAccessControl.h:14
TIME_LEN
#define TIME_LEN
Definition: rodsDef.h:54
keyValFromString
int keyValFromString(char *string, keyValPair_t **list)
Definition: rcMisc.cpp:3370
GenQueryInp::condInput
keyValPair_t condInput
Definition: rodsGenQuery.h:52
clearBBuf
int clearBBuf(bytesBuf_t *myBBuf)
Definition: rcMisc.cpp:101
irods::get_virtual_path_separator
std::string get_virtual_path_separator()
Definition: irods_virtual_path.cpp:11
irods.six.u
def u(s)
Definition: six.py:609
authResponseInp_t
Definition: authResponse.h:6
readToByteBuf
int readToByteBuf(int fd, bytesBuf_t *bytesBuf)
Definition: rcMisc.cpp:3892
modAVUMetadataInp_t::arg9
char * arg9
Definition: modAVUMetadata.h:16
KeyValPair::keyWord
char ** keyWord
Definition: objInfo.h:122
STRUCT_FILE_SPEC_COLL_OPR
@ STRUCT_FILE_SPEC_COLL_OPR
Definition: objInfo.h:62
SYS_STRUCT_ELEMENT_MISMATCH
@ SYS_STRUCT_ELEMENT_MISMATCH
Definition: rodsErrorTable.h:184
InxIvalPair::inx
int * inx
Definition: objInfo.h:207
freeRError
int freeRError(rError_t *myError)
Definition: rcMisc.cpp:170
parseCachedStructFileStr
int parseCachedStructFileStr(char *collInfo2, specColl_t *specColl)
Definition: rcMisc.cpp:3184
GenQueryInp::sqlCondInp
inxValPair_t sqlCondInp
Definition: rodsGenQuery.h:56
DataObjInp
Definition: dataObjInpOut.h:65
getRandomArray
int getRandomArray(int **randomArray, int size)
Definition: rcMisc.cpp:4062
rescQuota
Definition: getRescQuota.h:28
writeFromByteBuf
int writeFromByteBuf(int fd, bytesBuf_t *bytesBuf)
Definition: rcMisc.cpp:3954
getUnixUsername
int getUnixUsername(int uid, char *username, int username_len)
Definition: rcMisc.cpp:1296
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
setStateForRestart
int setStateForRestart(rodsRestart_t *rodsRestart, rodsPath_t *targPath, rodsArguments_t *rodsArgs)
Definition: rcMisc.cpp:2714
addStrArray
int addStrArray(strArray_t *strArray, char *value)
Definition: rcMisc.cpp:959
resizeStrArray
int resizeStrArray(strArray_t *strArray, int newSize)
Definition: rcMisc.cpp:1017
irods.pypyodbc.buffer
buffer
Definition: pypyodbc.py:46
MAX_SQL_ATTR
#define MAX_SQL_ATTR
Definition: rodsGenQuery.h:15
checkDateFormat
int checkDateFormat(char *s)
Definition: rcMisc.cpp:2129
CollInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:161
freeGenQueryInp
int freeGenQueryInp(genQueryInp_t **genQueryInp)
Definition: rcMisc.cpp:1101
replKeyVal
int replKeyVal(const keyValPair_t *srcCondInput, keyValPair_t *destCondInput)
Definition: rcMisc.cpp:739
authResponseInp_t::username
char * username
Definition: authResponse.h:8
GenQueryOut
Definition: rodsGenQuery.h:67
parseMultiStr
int parseMultiStr(char *strInput, strArray_t *strArray)
Definition: rcMisc.cpp:1539
rodsRestart_t::oprType
char oprType[64]
Definition: rodsDef.h:323
addInxVal
int addInxVal(inxValPair_t *inxValPair, int inx, const char *value)
Definition: rcMisc.cpp:921
rErrMsg_t::msg
char msg[1024]
Definition: rodsError.h:21
freeGenQueryOut
int freeGenQueryOut(genQueryOut_t **genQueryOut)
Definition: rcMisc.cpp:1133
SYS_REQUESTED_BUF_TOO_LARGE
@ SYS_REQUESTED_BUF_TOO_LARGE
Definition: rodsErrorTable.h:178
modAVUMetadataInp_t::arg3
char * arg3
Definition: modAVUMetadata.h:10
irods::hierarchy_parser::set_string
error set_string(const std::string &_resc_hier)
Definition: irods_hierarchy_parser.cpp:36
get_irods_version.value
dictionary value
Definition: get_irods_version.py:27
MAX_SZ_FOR_EXECMD_BUF
#define MAX_SZ_FOR_EXECMD_BUF
Definition: rodsDef.h:88
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
SpecColl::rescHier
char rescHier[(1024+64)]
Definition: objInfo.h:84
GenQueryOut::attriCnt
int attriCnt
Definition: rodsGenQuery.h:69
NO_SPEC_COLL
@ NO_SPEC_COLL
Definition: objInfo.h:46
STDOUT_STATUS
static const int STDOUT_STATUS
Definition: rcMisc.h:327
putUtil.h
SYS_BULK_REG_COUNT_EXCEEDED
@ SYS_BULK_REG_COUNT_EXCEEDED
Definition: rodsErrorTable.h:177
StructFileTypeDef
Definition: objInfo.h:325
rodsStat::st_nlink
unsigned int st_nlink
Definition: rodsType.h:57
splitPathByKey
int splitPathByKey(const char *srcPath, char *dir, size_t maxDirLen, char *file, size_t maxFileLen, char key)
Definition: stringOpr.cpp:222
rodsStat::st_blksize
unsigned int st_blksize
Definition: rodsType.h:64
NON_STRUCT_FILE_SPEC_COLL_OPR
@ NON_STRUCT_FILE_SPEC_COLL_OPR
Definition: objInfo.h:61
GenQueryOut::rowCnt
int rowCnt
Definition: rodsGenQuery.h:68
myRead
int myRead(int sock, void *buf, int len, int *bytesRead, struct timeval *tv)
Definition: rcMisc.cpp:4651
rodsDirent
Definition: rodsType.h:70
showAttrNames
int showAttrNames()
Definition: rcMisc.cpp:2763
modDataObjMeta_t::regParam
keyValPair_t * regParam
Definition: modDataObjMeta.h:9
boost::assertion_failed
void assertion_failed(char const *expr, char const *function, char const *file, long line)
Definition: rcMisc.cpp:4342
INPUT_ARG_NOT_WELL_FORMED_ERR
@ INPUT_ARG_NOT_WELL_FORMED_ERR
Definition: rodsErrorTable.h:658
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
modAVUMetadataInp_t
Definition: modAVUMetadata.h:6
SendXmsgInfo::deliAddress
char ** deliAddress
Definition: rodsXmsg.h:37
getNextEleInStr
int getNextEleInStr(char **inbuf, char *outbuf, int *inbufLen, int maxOutLen)
Definition: rcMisc.cpp:433
separateSelFuncFromAttr
int separateSelFuncFromAttr(char *t, char **aggOp, char **colNm)
Definition: rcMisc.cpp:2772
irods::is_path_valid_for_recursion
bool is_path_valid_for_recursion(boost::filesystem::path const &, recursion_map_t &, bool)
Definition: irods_path_recursion.cpp:80
irods::exception::client_display_what
virtual const char * client_display_what() const
Definition: irods_exception.cpp:52
rodsRestart_t
Definition: rodsDef.h:317
InxIvalPair::value
int * value
Definition: objInfo.h:208
trimPrefix
char * trimPrefix(char *str)
Definition: rcMisc.cpp:4146
BytesBuf
Definition: rodsDef.h:197
trimWS
int trimWS(char *s)
Definition: stringOpr.cpp:260
resolve_hostname_from_hosts_config
auto resolve_hostname_from_hosts_config(const std::string &name_to_resolve) -> std::string
Definition: rcMisc.cpp:4487
irods::error
Definition: irods_error.hpp:23
getSpecCollTypeStr
int getSpecCollTypeStr(specColl_t *specColl, char *outStr)
Definition: rcMisc.cpp:3099
InxValPair::len
int len
Definition: objInfo.h:214
FILE_READ_ERR
@ FILE_READ_ERR
Definition: rodsErrorTable.h:495
columnName_t::columnId
int columnId
Definition: rodsGenQueryNames.h:14
regReplica_t::srcDataObjInfo
dataObjInfo_t * srcDataObjInfo
Definition: regReplica.h:8
dataObjPut.h
int
typedef int((*funcPtr)())
modDataObjMeta_t::dataObjInfo
dataObjInfo_t * dataObjInfo
Definition: modDataObjMeta.h:8
unregDataObj_t
Definition: unregDataObj.h:7
freeAllRescQuota
int freeAllRescQuota(rescQuota_t *rescQuotaHead)
Definition: rcMisc.cpp:1526
SYS_INVALID_FILE_PATH
@ SYS_INVALID_FILE_PATH
Definition: rodsErrorTable.h:99
myNtohll
int myNtohll(rodsLong_t inlonglong, rodsLong_t *outlonglong)
Definition: rcMisc.cpp:256
stringify_addrinfo_hints
static std::string stringify_addrinfo_hints(const struct addrinfo *_hints)
Definition: rcMisc.cpp:4475
clearModAccessControlInp
void clearModAccessControlInp(void *voidInp)
Definition: rcMisc.cpp:3505
SpecColl::collection
char collection[(1024+64)]
Definition: objInfo.h:79
parseUserName
int parseUserName(const char *fullUserNameIn, char *userName, char *userZone)
Definition: rcMisc.cpp:204
fileOpenInp_t::condInput
keyValPair_t condInput
Definition: fileOpen.h:24
SYS_SOCK_READ_TIMEDOUT
@ SYS_SOCK_READ_TIMEDOUT
Definition: rodsErrorTable.h:180
RodsPath::outPath
char outPath[(1024+64)]
Definition: rodsPath.h:24
OFFSET_INX
#define OFFSET_INX
Definition: bulkDataObjReg.h:10
addRErrorMsg
int addRErrorMsg(rError_t *myError, int status, const char *msg)
Definition: rcMisc.cpp:121
printReleaseInfo
void printReleaseInfo(char *cmdName)
Definition: rcMisc.cpp:3575
SqlResult::value
char * value
Definition: rodsGenQuery.h:64
clearDataObjCopyInp
void clearDataObjCopyInp(void *voidInp)
Definition: rcMisc.cpp:1507
getPhyBunPath
int getPhyBunPath(const char *collection, const char *objPath, const char *phyBunDir, char *outPhyBunPath)
Definition: rcMisc.cpp:3996
UNIX_FILE_READ_ERR
@ UNIX_FILE_READ_ERR
Definition: rodsErrorTable.h:302
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
resolveSpecCollType
int resolveSpecCollType(char *type, char *collection, char *collInfo1, char *collInfo2, specColl_t *specColl)
Definition: rcMisc.cpp:3127
DataObjCopyInp::destDataObjInp
dataObjInp_t destDataObjInp
Definition: dataObjCopy.h:27
freeBBuf
int freeBBuf(bytesBuf_t *myBBuf)
Definition: rcMisc.cpp:88
irods_hierarchy_parser.hpp
rodsRestart_t::fd
int fd
Definition: rodsDef.h:319
FORCE_FLAG_KW
#define FORCE_FLAG_KW
Definition: rodsKeyWdDef.h:13
fileOpenInp_t
Definition: fileOpen.h:14
MATCHED_RESTART_COLL
#define MATCHED_RESTART_COLL
Definition: rodsDef.h:307
myWrite
int myWrite(int sock, void *buf, int len, int *bytesWritten)
Definition: rcMisc.cpp:4610
isPathSymlink_err
int isPathSymlink_err(rodsArguments_t *rodsArgs, const char *myPath)
Definition: rcMisc.cpp:4085
StrArray::size
int size
Definition: objInfo.h:222
addInxIval
int addInxIval(inxIvalPair_t *inxIvalPair, int inx, int value)
Definition: rcMisc.cpp:883
getLocalTimeFromRodsTime
int getLocalTimeFromRodsTime(const char *timeStrIn, char *timeStr)
Definition: rcMisc.cpp:1602
clearBulkOprInp
void clearBulkOprInp(void *voidInp)
Definition: rcMisc.cpp:1248
clearInxVal
int clearInxVal(inxValPair_t *inxValPair)
Definition: rcMisc.cpp:1082
authResponseInp_t::response
char * response
Definition: authResponse.h:7
columnNames
columnName_t columnNames[]
Definition: rodsGenQueryNames.h:18
mySetenvInt
int mySetenvInt(char *envname, int envval)
Definition: rcMisc.cpp:4036
NumOfColumnNames
int NumOfColumnNames
Definition: rodsGenQueryNames.h:384
entry
Definition: ruleAdmin.cpp:22
apiHeaderAll.h
statToRodsStat
int statToRodsStat(rodsStat_t *rodsStat, struct stat *myFileStat)
Definition: rcMisc.cpp:280
rodsHostAddr_t::hostAddr
char hostAddr[256]
Definition: rodsDef.h:297
irods_virtual_path.hpp
rodsStat::st_blocks
unsigned int st_blocks
Definition: rodsType.h:65
SqlResult
Definition: rodsGenQuery.h:61
update_schema_ids_for_cmake.file
file
Definition: update_schema_ids_for_cmake.py:21
load_in_addr_from_hostname
int load_in_addr_from_hostname(const char *_hostname, struct in_addr *_out)
Definition: rcMisc.cpp:4594
USER_STRLEN_TOOLONG
@ USER_STRLEN_TOOLONG
Definition: rodsErrorTable.h:237
VERIFY_CHKSUM_KW
#define VERIFY_CHKSUM_KW
Definition: rodsKeyWdDef.h:16
ORDER_BY_DESC
#define ORDER_BY_DESC
Definition: rodsGenQuery.h:82
initBulkDataObjRegInp
int initBulkDataObjRegInp(genQueryOut_t *bulkDataObjRegInp)
Definition: rcMisc.cpp:3612
modAVUMetadataInp_t::arg6
char * arg6
Definition: modAVUMetadata.h:13
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
KeyValPair::len
int len
Definition: objInfo.h:121
MOUNTED_COLL
@ MOUNTED_COLL
Definition: objInfo.h:48
printErrorStack
int printErrorStack(rError_t *rError)
Definition: rcMisc.cpp:2327
InxIvalPair
Definition: objInfo.h:205
modAccessControlInp_t::zone
char * zone
Definition: modAccessControl.h:13
PTR_ARRAY_MALLOC_LEN
#define PTR_ARRAY_MALLOC_LEN
Definition: rodsDef.h:73
getZoneNameFromHint
int getZoneNameFromHint(const char *_hint, char *_zone_name, int _len)
Definition: rcMisc.cpp:514
mySetenvStr
int mySetenvStr(const char *envname, const char *envval)
Definition: rcMisc.cpp:4011
StrArray::value
char * value
Definition: objInfo.h:223
irods::exception
Definition: irods_exception.hpp:15
SqlResult::len
int len
Definition: rodsGenQuery.h:63
getLineInBuf
int getLineInBuf(char **inbuf, char *outbuf, int bufLen)
Definition: rcMisc.cpp:2642
ORDER_BY
#define ORDER_BY
Definition: rodsGenQuery.h:81
bulkOprInfo_t
Definition: putUtil.h:23
clearDataObjInp
void clearDataObjInp(void *voidInp)
Definition: rcMisc.cpp:1475
sockComm.h
getAttrNameFromAttrId
char * getAttrNameFromAttrId(int cid)
Definition: rcMisc.cpp:2826
FILE_OPEN_ERR
@ FILE_OPEN_ERR
Definition: rodsErrorTable.h:494
isHomeColl
int isHomeColl(char *myPath)
Definition: rcMisc.cpp:2508
SELECT_SUM
#define SELECT_SUM
Definition: rodsGenQuery.h:104
rodsObjStat
Definition: objStat.h:8
convertDateFormat
int convertDateFormat(char *s, char *currTime)
Definition: rcMisc.cpp:2091
getOffsetTimeStr
void getOffsetTimeStr(char *timeStr, const char *offSet)
Definition: rcMisc.cpp:1659
seedRandom
unsigned int seedRandom()
Definition: rcMisc.cpp:3586
getAttrIdFromAttrName
int getAttrIdFromAttrName(char *cname)
Definition: rcMisc.cpp:2751
SYS_UNMATCHED_SPEC_COLL_TYPE
@ SYS_UNMATCHED_SPEC_COLL_TYPE
Definition: rodsErrorTable.h:120
SHORT_STR_LEN
#define SHORT_STR_LEN
Definition: rodsDef.h:67
TagStruct::keyWord
char ** keyWord
Definition: objInfo.h:313
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
False
#define False
Definition: parseCommandLine.h:12
getFileSize
rodsLong_t getFileSize(char *myPath)
Definition: rcMisc.cpp:74
rodsObjStat::specColl
specColl_t * specColl
Definition: objStat.h:18
irods_path_recursion.hpp
rodsDirent::d_offset
unsigned int d_offset
Definition: rodsType.h:71
size
long long size
Definition: filesystem.cpp:102
irods_random.hpp
RodsPath
Definition: rodsPath.h:18
getaddrinfo_with_retry
int getaddrinfo_with_retry(const char *_node, const char *_service, const struct addrinfo *_hints, struct addrinfo **_res)
Definition: rcMisc.cpp:4537
getUnixGroupname
int getUnixGroupname(int gid, char *groupname, int groupname_len)
Definition: rcMisc.cpp:1333
rodsRestart_t::curCnt
int curCnt
Definition: rodsDef.h:324
setForceFlagForRestart
int setForceFlagForRestart(bulkOprInp_t *bulkOprInp, bulkOprInfo_t *bulkOprInfo)
Definition: rcMisc.cpp:3978
replDataObjInp
int replDataObjInp(dataObjInp_t *srcDataObjInp, dataObjInp_t *destDataObjInp)
Definition: rcMisc.cpp:765
rodsRestart_t::collection
char collection[(1024+64)]
Definition: rodsDef.h:321
queDataObjInfo
int queDataObjInfo(dataObjInfo_t **dataObjInfoHead, dataObjInfo_t *dataObjInfo, int singleInfoFlag, int topFlag)
Definition: rcMisc.cpp:581
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
COL_D_DATA_PATH
#define COL_D_DATA_PATH
Definition: rodsGenQuery.h:172
replSpecColl
int replSpecColl(specColl_t *inSpecColl, specColl_t **outSpecColl)
Definition: rcMisc.cpp:778
PATH_MATCHING
#define PATH_MATCHING
Definition: rodsDef.h:305
clearGenQueryInp
void clearGenQueryInp(void *voidInp)
Definition: rcMisc.cpp:1118
rodsHostAddr_t::portNum
int portNum
Definition: rodsDef.h:299
addTagStruct
int addTagStruct(tagStruct_t *condInput, char *preTag, char *postTag, char *keyWord)
Definition: rcMisc.cpp:831
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
NOT_SPEC_COLL_OPR
@ NOT_SPEC_COLL_OPR
Definition: objInfo.h:60
SOCK_TYPE
@ SOCK_TYPE
Definition: rodsDef.h:155
modAVUMetadataInp_t::arg5
char * arg5
Definition: modAVUMetadata.h:12
modDataObjMeta_t
Definition: modDataObjMeta.h:7
isTrashHome
int isTrashHome(char *myPath)
Definition: rcMisc.cpp:2427
SYS_USER_RETRIEVE_ERR
@ SYS_USER_RETRIEVE_ERR
Definition: rodsErrorTable.h:187
isOrphanPath
orphanPathType_t isOrphanPath(char *myPath)
Definition: rcMisc.cpp:2473
appendRandomToPath
int appendRandomToPath(char *trashPath)
Definition: rcMisc.cpp:2348
regReplica_t
Definition: regReplica.h:7
clearFileOpenInp
void clearFileOpenInp(void *voidInp)
Definition: rcMisc.cpp:1463
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
clearModDataObjMetaInp
void clearModDataObjMetaInp(void *voidInp)
Definition: rcMisc.cpp:1403
getIvalByInx
int getIvalByInx(inxIvalPair_t *inxIvalPair, int inx, int *outValue)
Definition: rcMisc.cpp:692
KeyValPair
Definition: objInfo.h:120
NORMAL_OPR_ON_STRUCT_FILE_COLL
@ NORMAL_OPR_ON_STRUCT_FILE_COLL
Definition: objInfo.h:63
TagStruct::postTag
char ** postTag
Definition: objInfo.h:312
rError_t::errMsg
rErrMsg_t ** errMsg
Definition: rodsError.h:26
rodsStatToStat
int rodsStatToStat(struct stat *myFileStat, rodsStat_t *rodsStat)
Definition: rcMisc.cpp:305
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
bulkOprInp_t::attriArray
genQueryOut_t attriArray
Definition: bulkDataObjPut.h:19
rodsStat::st_gid
unsigned int st_gid
Definition: rodsType.h:59
SpecColl::objPath
char objPath[(1024+64)]
Definition: objInfo.h:80
buf
static char buf[64+50+1]
Definition: rsAuthRequest.cpp:21
type
int type
Definition: filesystem.cpp:103
DataObjInfo
Definition: objInfo.h:129
USER_INPUT_PATH_ERR
@ USER_INPUT_PATH_ERR
Definition: rodsErrorTable.h:248
orphanPathType_t
orphanPathType_t
Definition: rodsDef.h:171
COL_DATA_SIZE
#define COL_DATA_SIZE
Definition: rodsGenQuery.h:169
InxValPair
Definition: objInfo.h:213
NO_COLUMN_NAME_FOUND
@ NO_COLUMN_NAME_FOUND
Definition: rodsErrorTable.h:681
rodsStat::st_ino
unsigned int st_ino
Definition: rodsType.h:55
columnName_t::columnName
char * columnName
Definition: rodsGenQueryNames.h:15
convertListToMultiString
int convertListToMultiString(char *strInput, int input)
Definition: rcMisc.cpp:4186
getLine
int getLine(FILE *fp, char *buf, int bufSize)
Definition: rcMisc.cpp:484
irods.pyparsing.line
def line(loc, strg)
Definition: pyparsing.py:728
irods_log.hpp
list
Definition: irods_list.h:13
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
StrArray
Definition: objInfo.h:220
SpecColl::collClass
specCollClass_t collClass
Definition: objInfo.h:77
ERR_MSG_LEN
#define ERR_MSG_LEN
Definition: rodsError.h:16
NumStructFileType
int NumStructFileType
Definition: rcGlobal.cpp:133
COL_D_RESC_ID
#define COL_D_RESC_ID
Definition: rodsGenQuery.h:185
rodsHostAddr_t
Definition: rodsDef.h:296
COL_D_DATA_ID
#define COL_D_DATA_ID
Definition: rodsGenQuery.h:163
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247
modAVUMetadataInp_t::arg1
char * arg1
Definition: modAVUMetadata.h:8
COL_DATA_MODE
#define COL_DATA_MODE
Definition: rodsGenQuery.h:183
irods::getRandomBytes
void getRandomBytes(void *buf, int bytes)
Definition: irods_random.cpp:6
modAVUMetadataInp_t::arg8
char * arg8
Definition: modAVUMetadata.h:15
TagStruct::preTag
char ** preTag
Definition: objInfo.h:311
USER_RODS_HOSTNAME_ERR
@ USER_RODS_HOSTNAME_ERR
Definition: rodsErrorTable.h:234
freeRErrorContent
int freeRErrorContent(rError_t *myError)
Definition: rcMisc.cpp:182
IS_ORPHAN_PATH
@ IS_ORPHAN_PATH
Definition: rodsDef.h:173
SendXmsgInfo::numDeli
int numDeli
Definition: rodsXmsg.h:36