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)  

rsDataObjRead.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See dataObjRead.h for a description of this API call.*/
5 
6 #include "dataObjRead.h"
7 #include "rodsLog.h"
8 #include "objMetaOpr.hpp"
9 #include "rsGlobalExtern.hpp"
10 #include "rcGlobalExtern.h"
11 #include "subStructFileRead.h" /* XXXXX can be taken out when structFile api done */
12 #include "rsDataObjRead.hpp"
13 #include "rsSubStructFileRead.hpp"
14 #include "rsFileRead.hpp"
15 
16 // =-=-=-=-=-=-=-
19 
20 int
21 applyRuleForPostProcForRead( rsComm_t *rsComm, bytesBuf_t *dataObjReadOutBBuf, char *objPath ) {
22  if ( ReadWriteRuleState != ON_STATE ) {
23  return 0;
24  }
25 
26  ruleExecInfo_t rei2;
27  memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
28  msParamArray_t msParamArray;
29  memset( ( char* )&msParamArray, 0, sizeof( msParamArray_t ) );
30 
31  if ( rsComm != NULL ) {
32  rei2.rsComm = rsComm;
33  rei2.uoic = &rsComm->clientUser;
34  rei2.uoip = &rsComm->proxyUser;
35  }
36  rei2.doi = ( dataObjInfo_t* )malloc( sizeof( dataObjInfo_t ) );
37  memset(rei2.doi,0,sizeof(dataObjInfo_t));
38 
39  snprintf( rei2.doi->objPath, sizeof( rei2.doi->objPath ), "%s", objPath );
40 
41  memset( &msParamArray, 0, sizeof( msParamArray ) );
42  int * myInOutStruct = ( int* )malloc( sizeof( int ) );
43  *myInOutStruct = dataObjReadOutBBuf->len;
44  addMsParamToArray( &msParamArray, "*ReadBuf", BUF_LEN_MS_T, myInOutStruct,
45  dataObjReadOutBBuf, 0 );
46  int status = applyRule( "acPostProcForDataObjRead(*ReadBuf)", &msParamArray, &rei2,
47  NO_SAVE_REI );
48  free( rei2.doi );
49  if ( status < 0 ) {
50  if ( rei2.status < 0 ) {
51  status = rei2.status;
52  }
54  "rsDataObjRead: acPostProcForDataObjRead error=%d", status );
55  clearMsParamArray( &msParamArray, 0 );
56  return status;
57  }
58  clearMsParamArray( &msParamArray, 0 );
59 
60  return 0;
61 
62 }
63 
64 int
65 rsDataObjRead( rsComm_t *rsComm, openedDataObjInp_t *dataObjReadInp,
66  bytesBuf_t *dataObjReadOutBBuf ) {
67  int bytesRead;
68  int l1descInx = dataObjReadInp->l1descInx;
69 
70  if ( l1descInx < 2 || l1descInx >= NUM_L1_DESC ) {
72  "rsDataObjRead: l1descInx %d out of range",
73  l1descInx );
75  }
76  if ( L1desc[l1descInx].inuseFlag != FD_INUSE ) {
77  return BAD_INPUT_DESC_INDEX;
78  }
79 
80  if ( L1desc[l1descInx].remoteZoneHost != NULL ) {
81  /* cross zone operation */
82  dataObjReadInp->l1descInx = L1desc[l1descInx].remoteL1descInx;
83  bytesRead = rcDataObjRead( L1desc[l1descInx].remoteZoneHost->conn,
84  dataObjReadInp, dataObjReadOutBBuf );
85  dataObjReadInp->l1descInx = l1descInx;
86  }
87  else {
88  int i;
89  bytesRead = l3Read( rsComm, l1descInx, dataObjReadInp->len,
90  dataObjReadOutBBuf );
91  i = applyRuleForPostProcForRead( rsComm, dataObjReadOutBBuf,
92  L1desc[l1descInx].dataObjInfo->objPath );
93  if ( i < 0 ) {
94  return i;
95  }
96  }
97 
98  return bytesRead;
99 }
100 
101 int
102 l3Read( rsComm_t *rsComm, int l1descInx, int len,
103  bytesBuf_t *dataObjReadOutBBuf ) {
104  int bytesRead;
105 
106  dataObjInfo_t *dataObjInfo;
107  dataObjInfo = L1desc[l1descInx].dataObjInfo;
108 
109  // =-=-=-=-=-=-=-
110  // extract the host location from the resource hierarchy
111  std::string location;
112  irods::error ret = irods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
113  if ( !ret.ok() ) {
114  irods::log( PASSMSG( "l3Read - failed in get_loc_for_hier_string", ret ) );
115  return -1;
116  }
117 
118 
119  if ( getStructFileType( dataObjInfo->specColl ) >= 0 ) {
120  subStructFileFdOprInp_t subStructFileReadInp;
121  memset( &subStructFileReadInp, 0, sizeof( subStructFileReadInp ) );
122  subStructFileReadInp.type = dataObjInfo->specColl->type;
123  subStructFileReadInp.fd = L1desc[l1descInx].l3descInx;
124  subStructFileReadInp.len = len;
125  rstrcpy( subStructFileReadInp.addr.hostAddr, location.c_str(), NAME_LEN );
126  rstrcpy( subStructFileReadInp.resc_hier, dataObjInfo->rescHier, MAX_NAME_LEN );
127  bytesRead = rsSubStructFileRead( rsComm, &subStructFileReadInp, dataObjReadOutBBuf );
128  }
129  else {
130  fileReadInp_t fileReadInp;
131  int category = FILE_CAT; // do not support DB type
132  switch ( category ) {
133  case FILE_CAT:
134  memset( &fileReadInp, 0, sizeof( fileReadInp ) );
135  fileReadInp.fileInx = L1desc[l1descInx].l3descInx;
136  fileReadInp.len = len;
137  bytesRead = rsFileRead( rsComm, &fileReadInp, dataObjReadOutBBuf );
138  break;
139 
140  default:
142  "l3Read: rescCat type %d is not recognized", category );
143  bytesRead = SYS_INVALID_RESC_TYPE;
144  break;
145  }
146  }
147  return bytesRead;
148 }
149 
150 int
151 _l3Read( rsComm_t *rsComm, int l3descInx, void *buf, int len ) {
152  fileReadInp_t fileReadInp;
153  bytesBuf_t dataObjReadInpBBuf;
154  int bytesRead;
155 
156  dataObjReadInpBBuf.len = len;
157  dataObjReadInpBBuf.buf = buf;
158 
159 
160  memset( &fileReadInp, 0, sizeof( fileReadInp ) );
161  fileReadInp.fileInx = l3descInx;
162  fileReadInp.len = len;
163  bytesRead = rsFileRead( rsComm, &fileReadInp, &dataObjReadInpBBuf );
164 
165  return bytesRead;
166 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
OpenedDataObjInp
Definition: dataObjInpOut.h:104
L1desc
l1desc_t L1desc[1026]
Definition: irods_server_globals.cpp:29
dataObjRead.h
NULL
#define NULL
Definition: rodsDef.h:70
SubStructFileFdOpr::addr
rodsHostAddr_t addr
Definition: subStructFileRead.h:9
rsComm_t
Definition: rcConnect.h:145
FileReadInp::len
int len
Definition: fileRead.h:9
_l3Read
int _l3Read(rsComm_t *rsComm, int l3descInx, void *buf, int len)
Definition: rsDataObjRead.cpp:151
SubStructFileFdOpr::len
int len
Definition: subStructFileRead.h:12
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
rcDataObjRead
int rcDataObjRead(rcComm_t *conn, openedDataObjInp_t *dataObjReadInp, bytesBuf_t *dataObjReadOutBBuf)
Definition: rcDataObjRead.cpp:69
ReadWriteRuleState
irodsStateFlag_t ReadWriteRuleState
Definition: irods_server_globals.cpp:74
applyRuleForPostProcForRead
int applyRuleForPostProcForRead(rsComm_t *rsComm, bytesBuf_t *dataObjReadOutBBuf, char *objPath)
Definition: rsDataObjRead.cpp:21
OpenedDataObjInp::l1descInx
int l1descInx
Definition: dataObjInpOut.h:105
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
BUF_LEN_MS_T
#define BUF_LEN_MS_T
Definition: msParam.h:25
l1desc::remoteL1descInx
int remoteL1descInx
Definition: objDesc.hpp:52
SpecColl::type
structFileType_t type
Definition: objInfo.h:78
rsSubStructFileRead.hpp
l1desc::dataObjInfo
dataObjInfo_t * dataObjInfo
Definition: objDesc.hpp:42
getStructFileType
int getStructFileType(specColl_t *specColl)
Definition: objMetaOpr.cpp:386
DataObjInfo::rescHier
char rescHier[(1024+64)]
Definition: objInfo.h:132
SYS_INVALID_RESC_TYPE
@ SYS_INVALID_RESC_TYPE
Definition: rodsErrorTable.h:98
irods_resource_backport.hpp
rsDataObjRead
int rsDataObjRead(rsComm_t *rsComm, openedDataObjInp_t *dataObjReadInp, bytesBuf_t *dataObjReadOutBBuf)
Definition: rsDataObjRead.cpp:65
l1desc::l3descInx
int l3descInx
Definition: objDesc.hpp:35
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
rcGlobalExtern.h
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
DataObjInfo::specColl
specColl_t * specColl
Definition: objInfo.h:158
SubStructFileFdOpr
Definition: subStructFileRead.h:8
BytesBuf::len
int len
Definition: rodsDef.h:198
rsGlobalExtern.hpp
FileReadInp
Definition: fileRead.h:7
clearMsParamArray
int clearMsParamArray(msParamArray_t *msParamArray, int freeStruct)
Definition: msParam.cpp:447
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
OpenedDataObjInp::len
int len
Definition: dataObjInpOut.h:106
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rodsLog.h
ON_STATE
@ ON_STATE
Definition: rodsDef.h:168
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
BytesBuf
Definition: rodsDef.h:197
irods::error
Definition: irods_error.hpp:23
FileReadInp::fileInx
int fileInx
Definition: fileRead.h:8
NUM_L1_DESC
#define NUM_L1_DESC
Definition: objDesc.hpp:24
rsSubStructFileRead
int rsSubStructFileRead(rsComm_t *rsComm, subStructFileFdOprInp_t *subStructFileReadInp, bytesBuf_t *subStructFileReadOutBBuf)
Definition: rsSubStructFileRead.cpp:11
addMsParamToArray
int addMsParamToArray(msParamArray_t *msParamArray, const char *label, const char *type, void *inOutStruct, bytesBuf_t *inpOutBuf, int replFlag)
Definition: msParam.cpp:47
BAD_INPUT_DESC_INDEX
@ BAD_INPUT_DESC_INDEX
Definition: rodsErrorTable.h:266
FD_INUSE
#define FD_INUSE
Definition: fileOpr.hpp:21
SubStructFileFdOpr::resc_hier
char resc_hier[(1024+64)]
Definition: subStructFileRead.h:13
rsFileRead.hpp
SubStructFileFdOpr::fd
int fd
Definition: subStructFileRead.h:11
irods_hierarchy_parser.hpp
SubStructFileFdOpr::type
structFileType_t type
Definition: subStructFileRead.h:10
rsDataObjRead.hpp
rsFileRead
int rsFileRead(rsComm_t *rsComm, fileReadInp_t *fileReadInp, bytesBuf_t *fileReadOutBBuf)
Definition: rsFileRead.cpp:19
rodsHostAddr_t::hostAddr
char hostAddr[256]
Definition: rodsDef.h:297
RuleExecInfo
Definition: irods_re_structs.hpp:18
applyRule
int applyRule(char *inAction, msParamArray_t *inMsParamArray, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:65
l3Read
int l3Read(rsComm_t *rsComm, int l1descInx, int len, bytesBuf_t *dataObjReadOutBBuf)
Definition: rsDataObjRead.cpp:102
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
MsParamArray
Definition: msParam.h:84
irods::get_loc_for_hier_string
error get_loc_for_hier_string(const std::string &_hier, std::string &_loc)
Definition: irods_resource_backport.cpp:633
SYS_FILE_DESC_OUT_OF_RANGE
@ SYS_FILE_DESC_OUT_OF_RANGE
Definition: rodsErrorTable.h:87
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
buf
static char buf[64+50+1]
Definition: rsAuthRequest.cpp:21
DataObjInfo
Definition: objInfo.h:129
FILE_CAT
@ FILE_CAT
Definition: objInfo.h:236
objMetaOpr.hpp
subStructFileRead.h