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)  

phybunUtil.cpp
Go to the documentation of this file.
1 
3 #include "rodsPath.h"
4 #include "rodsErrorTable.h"
5 #include "rodsLog.h"
6 #include "phybunUtil.h"
7 #include "miscUtil.h"
8 #include "rcGlobalExtern.h"
9 
10 int
11 phybunUtil( rcComm_t *conn, rodsArguments_t *myRodsArgs,
12  rodsPathInp_t *rodsPathInp ) {
13  if ( rodsPathInp == NULL ) {
14  return USER__NULL_INPUT_ERR;
15  }
16 
17  rodsPath_t *collPath;
18  structFileExtAndRegInp_t phyBundleCollInp;
19  int savedStatus = initCondForPhybunOpr( myRodsArgs, &phyBundleCollInp );
20  if ( savedStatus < 0 ) {
21  return savedStatus;
22  }
23 
24  for ( int i = 0; i < rodsPathInp->numSrc; i++ ) {
25  collPath = &rodsPathInp->srcPath[i]; /* iRODS Collection */
26 
27  int status = getRodsObjType( conn, collPath );
28 
29  if ( collPath->objType != COLL_OBJ_T ) {
31  "phybunUtil: input path %s is not a collection",
32  collPath->outPath );
33  return USER_INPUT_PATH_ERR;
34  }
35 
36  rstrcpy( phyBundleCollInp.collection, collPath->outPath, MAX_NAME_LEN );
37 
38  status = rcPhyBundleColl( conn, &phyBundleCollInp );
39  if ( status < 0 &&
42  "phybunUtil: opr error for %s, status = %d",
43  collPath->outPath, status );
44  savedStatus = status;
45  }
46  }
47  return savedStatus;
48 }
49 
50 int
52  structFileExtAndRegInp_t *phyBundleCollInp ) {
53  char tmpStr[NAME_LEN]; // JMC - backport 4771
54 
55  if ( phyBundleCollInp == NULL ) {
57  "initCondForPhybunOpr: NULL phyBundleCollInp input" );
58  return USER__NULL_INPUT_ERR;
59  }
60 
61  memset( phyBundleCollInp, 0, sizeof( structFileExtAndRegInp_t ) );
62 
63  if ( rodsArgs == NULL ) {
64  return 0;
65  }
66 
67  if ( rodsArgs->resource == True ) {
68  if ( rodsArgs->resourceString == NULL ) {
70  "initCondForPhybunOpr: NULL resourceString error" );
71  return USER__NULL_INPUT_ERR;
72  }
73  else {
74  addKeyVal( &phyBundleCollInp->condInput,
75  DEST_RESC_NAME_KW, rodsArgs->resourceString );
76  }
77  }
78  else {
80  "initCondForPhybunOpr: A -Rresource must be input" );
81  return USER__NULL_INPUT_ERR;
82  }
83 
84  if ( rodsArgs->srcResc == True ) {
85  addKeyVal( &phyBundleCollInp->condInput, RESC_NAME_KW,
86  rodsArgs->srcRescString );
87  }
88 
89  if ( rodsArgs->verifyChecksum == True ) { // JMC - backport 4528
90  addKeyVal( &phyBundleCollInp->condInput, VERIFY_CHKSUM_KW, "" );
91  }
92  // =-=-=-=-=-=-=
93  // JMC - backport 4658
94  if ( rodsArgs->dataTypeString != NULL ) {
95  if ( strcmp( rodsArgs->dataTypeString, "t" ) == 0 ||
96  strcmp( rodsArgs->dataTypeString, TAR_DT_STR ) == 0 ||
97  strcmp( rodsArgs->dataTypeString, "tar" ) == 0 ) {
98  addKeyVal( &phyBundleCollInp->condInput, DATA_TYPE_KW,
100  }
101  else if ( strcmp( rodsArgs->dataTypeString, "g" ) == 0 ||
102  strcmp( rodsArgs->dataTypeString, GZIP_TAR_DT_STR ) == 0 ||
103  strcmp( rodsArgs->dataTypeString, "gzip" ) == 0 ) {
104  addKeyVal( &phyBundleCollInp->condInput, DATA_TYPE_KW,
106  }
107  else if ( strcmp( rodsArgs->dataTypeString, "b" ) == 0 ||
108  strcmp( rodsArgs->dataTypeString, BZIP2_TAR_DT_STR ) == 0 ||
109  strcmp( rodsArgs->dataTypeString, "bzip" ) == 0 ) {
110  addKeyVal( &phyBundleCollInp->condInput, DATA_TYPE_KW,
112  }
113  else if ( strcmp( rodsArgs->dataTypeString, "z" ) == 0 ||
114  strcmp( rodsArgs->dataTypeString, ZIP_DT_STR ) == 0 ||
115  strcmp( rodsArgs->dataTypeString, "zip" ) == 0 ) {
116  addKeyVal( &phyBundleCollInp->condInput, DATA_TYPE_KW,
118  }
119  else {
120  addKeyVal( &phyBundleCollInp->condInput, DATA_TYPE_KW,
121  rodsArgs->dataTypeString );
122  }
123  }
124  // =-=-=-=-=-=-=
125  if ( rodsArgs->number == True ) { // JMC - backport 4771
126  snprintf( tmpStr, NAME_LEN, "%d", rodsArgs->numberValue );
127  addKeyVal( &phyBundleCollInp->condInput, MAX_SUB_FILE_KW, tmpStr );
128  }
129 
130  if ( rodsArgs->sizeFlag == True ) {
131  char tmpStr1[NAME_LEN];
132  snprintf( tmpStr1, sizeof( tmpStr1 ), "%ji", ( intmax_t )rodsArgs->size );
133  addKeyVal( &phyBundleCollInp->condInput, MAX_BUNDLE_SIZE_KW, tmpStr1 );
134  }
135 
136  return 0;
137 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
RESC_NAME_KW
#define RESC_NAME_KW
Definition: rodsKeyWdDef.h:19
rcComm_t
Definition: rcConnect.h:95
NULL
#define NULL
Definition: rodsDef.h:70
MAX_SUB_FILE_KW
#define MAX_SUB_FILE_KW
Definition: rodsKeyWdDef.h:123
True
#define True
Definition: parseCommandLine.h:11
initCondForPhybunOpr
int initCondForPhybunOpr(rodsArguments_t *rodsArgs, structFileExtAndRegInp_t *phyBundleCollInp)
Definition: phybunUtil.cpp:51
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
rodsPath.h
rodsArguments_t::sizeFlag
int sizeFlag
Definition: parseCommandLine.h:90
rodsArguments_t
Definition: parseCommandLine.h:14
BZIP2_TAR_BUNDLE_DT_STR
#define BZIP2_TAR_BUNDLE_DT_STR
Definition: objInfo.h:36
RodsPathInp
Definition: rodsPath.h:33
TAR_DT_STR
#define TAR_DT_STR
Definition: objInfo.h:28
rodsArguments_t::srcRescString
char * srcRescString
Definition: parseCommandLine.h:93
StructFileExtAndRegInp
Definition: structFileExtAndReg.h:7
BZIP2_TAR_DT_STR
#define BZIP2_TAR_DT_STR
Definition: objInfo.h:30
rodsArguments_t::dataTypeString
char * dataTypeString
Definition: parseCommandLine.h:55
rodsArguments_t::resource
int resource
Definition: parseCommandLine.h:86
rcGlobalExtern.h
RodsPathInp::srcPath
rodsPath_t * srcPath
Definition: rodsPath.h:35
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
MAX_BUNDLE_SIZE_KW
#define MAX_BUNDLE_SIZE_KW
Definition: rodsKeyWdDef.h:119
RodsPath::objType
objType_t objType
Definition: rodsPath.h:19
DATA_TYPE_KW
#define DATA_TYPE_KW
Definition: rodsKeyWdDef.h:23
StructFileExtAndRegInp::collection
char collection[(1024+64)]
Definition: structFileExtAndReg.h:9
COLL_OBJ_T
@ COLL_OBJ_T
Definition: rodsType.h:39
ZIP_BUNDLE_DT_STR
#define ZIP_BUNDLE_DT_STR
Definition: objInfo.h:37
DEST_RESC_NAME_KW
#define DEST_RESC_NAME_KW
Definition: rodsKeyWdDef.h:20
rodsArguments_t::srcResc
int srcResc
Definition: parseCommandLine.h:92
rodsArguments_t::verifyChecksum
int verifyChecksum
Definition: parseCommandLine.h:53
phybunUtil
int phybunUtil(rcComm_t *conn, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp)
Definition: phybunUtil.cpp:11
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
ZIP_DT_STR
#define ZIP_DT_STR
Definition: objInfo.h:31
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
StructFileExtAndRegInp::condInput
keyValPair_t condInput
Definition: structFileExtAndReg.h:12
rodsLog.h
rodsArguments_t::resourceString
char * resourceString
Definition: parseCommandLine.h:87
RodsPath::outPath
char outPath[(1024+64)]
Definition: rodsPath.h:24
TAR_BUNDLE_DT_STR
#define TAR_BUNDLE_DT_STR
Definition: objInfo.h:34
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
VERIFY_CHKSUM_KW
#define VERIFY_CHKSUM_KW
Definition: rodsKeyWdDef.h:16
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
RodsPathInp::numSrc
int numSrc
Definition: rodsPath.h:34
GZIP_TAR_DT_STR
#define GZIP_TAR_DT_STR
Definition: objInfo.h:29
rodsErrorTable.h
RodsPath
Definition: rodsPath.h:18
phybunUtil.h
miscUtil.h
rodsArguments_t::numberValue
int numberValue
Definition: parseCommandLine.h:69
rodsArguments_t::size
rodsLong_t size
Definition: parseCommandLine.h:91
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
getRodsObjType
int getRodsObjType(rcComm_t *conn, rodsPath_t *rodsPath)
Definition: miscUtil.cpp:200
USER_INPUT_PATH_ERR
@ USER_INPUT_PATH_ERR
Definition: rodsErrorTable.h:248
GZIP_TAR_BUNDLE_DT_STR
#define GZIP_TAR_BUNDLE_DT_STR
Definition: objInfo.h:35
rodsArguments_t::number
int number
Definition: parseCommandLine.h:68
rcPhyBundleColl
int rcPhyBundleColl(rcComm_t *conn, structFileExtAndRegInp_t *phyBundleCollInp)
Definition: rcPhyBundleColl.cpp:33
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247