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)  

rsSubStructFileRead.cpp
Go to the documentation of this file.
1 
3 #include "subStructFileRead.h"
4 #include "miscServerFunct.hpp"
5 #include "dataObjOpr.hpp"
7 
9 
10 int
11 rsSubStructFileRead( rsComm_t *rsComm, subStructFileFdOprInp_t *subStructFileReadInp,
12  bytesBuf_t *subStructFileReadOutBBuf ) {
14  int remoteFlag;
15  int status;
16 
17  remoteFlag = resolveHost( &subStructFileReadInp->addr, &rodsServerHost );
18 
19  if ( subStructFileReadInp->len > 0 ) {
20  if ( subStructFileReadOutBBuf->buf == NULL ) {
21  subStructFileReadOutBBuf->buf = malloc( subStructFileReadInp->len );
22  }
23  }
24  else {
25  return 0;
26  }
27 
28  if ( remoteFlag == LOCAL_HOST ) {
29  status = _rsSubStructFileRead( rsComm, subStructFileReadInp, subStructFileReadOutBBuf );
30  }
31  else if ( remoteFlag == REMOTE_HOST ) {
32  status = remoteSubStructFileRead( rsComm, subStructFileReadInp, subStructFileReadOutBBuf,
34  }
35  else {
36  if ( remoteFlag < 0 ) {
37  return remoteFlag;
38  }
39  else {
41  "rsSubStructFileRead: resolveHost returned unrecognized value %d",
42  remoteFlag );
44  }
45  }
46 
47  return status;
48 }
49 
50 int
52  bytesBuf_t *subStructFileReadOutBBuf, rodsServerHost_t *rodsServerHost ) {
53  int status;
54 
55  if ( rodsServerHost == NULL ) {
57  "remoteSubStructFileRead: Invalid rodsServerHost" );
59  }
60 
61  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
62  return status;
63  }
64 
65  status = rcSubStructFileRead( rodsServerHost->conn, subStructFileReadInp,
66  subStructFileReadOutBBuf );
67 
68  if ( status < 0 ) {
70  "remoteSubStructFileRead: rcFileRead failed for fd %d", subStructFileReadInp->fd );
71  }
72 
73  return status;
74 
75 }
76 
77 // =-=-=-=-=-=-=-
78 // api for file read of a structured file
80  subStructFileFdOprInp_t* _read_inp,
81  bytesBuf_t* _out_buf ) {
82 
83  // =-=-=-=-=-=-=-
84  // create first class structured object
86  new irods::structured_object( *_read_inp ) );
87  struct_obj->comm( _comm );
88  struct_obj->resc_hier( _read_inp->resc_hier );
89  struct_obj->file_descriptor( _read_inp->fd );
90 
91  // =-=-=-=-=-=-=-
92  // call abstrcated interface to read a file
93  irods::error read_err = fileRead(
94  _comm,
95  struct_obj,
96  _out_buf->buf,
97  _read_inp->len );
98  if ( !read_err.ok() ) {
99  std::stringstream msg;
100  msg << "failed on call to fileRead for [";
101  msg << struct_obj->physical_path();
102  msg << "]";
103  irods::log( PASSMSG( msg.str(), read_err ) );
104  _out_buf->len = 0;
105  return read_err.code();
106 
107  }
108  else {
109  _out_buf->len = read_err.code();
110  return read_err.code();
111 
112  }
113 
114 } // _rsSubStructFileRead
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
SubStructFileFdOpr::addr
rodsHostAddr_t addr
Definition: subStructFileRead.h:9
rsComm_t
Definition: rcConnect.h:145
SubStructFileFdOpr::len
int len
Definition: subStructFileRead.h:12
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
rsSubStructFileRead
int rsSubStructFileRead(rsComm_t *rsComm, subStructFileFdOprInp_t *subStructFileReadInp, bytesBuf_t *subStructFileReadOutBBuf)
Definition: rsSubStructFileRead.cpp:11
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
rsSubStructFileRead.hpp
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
remoteSubStructFileRead
int remoteSubStructFileRead(rsComm_t *rsComm, subStructFileFdOprInp_t *subStructFileReadInp, bytesBuf_t *subStructFileReadOutBBuf, rodsServerHost_t *rodsServerHost)
Definition: rsSubStructFileRead.cpp:51
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
SubStructFileFdOpr
Definition: subStructFileRead.h:8
BytesBuf::len
int len
Definition: rodsDef.h:198
irods::error::code
long long code() const
Definition: irods_error.cpp:194
_rsSubStructFileRead
int _rsSubStructFileRead(rsComm_t *_comm, subStructFileFdOprInp_t *_read_inp, bytesBuf_t *_out_buf)
Definition: rsSubStructFileRead.cpp:79
irods::structured_object
Definition: irods_structured_object.hpp:15
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
irods::log
void log(const error &)
Definition: irods_log.cpp:13
irods::structured_object_ptr
boost::shared_ptr< structured_object > structured_object_ptr
Definition: irods_structured_object.hpp:107
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
BytesBuf
Definition: rodsDef.h:197
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
SubStructFileFdOpr::resc_hier
char resc_hier[(1024+64)]
Definition: subStructFileRead.h:13
SubStructFileFdOpr::fd
int fd
Definition: subStructFileRead.h:11
rodsServerHost
Definition: rodsConnect.h:62
irods_structured_object.hpp
dataObjOpr.hpp
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
rcSubStructFileRead
int rcSubStructFileRead(rcComm_t *conn, subStructFileFdOprInp_t *subStructFileReadInp, bytesBuf_t *subStructFileReadOutBBuf)
Definition: rcSubStructFileRead.cpp:24
fileRead
irods::error fileRead(rsComm_t *, irods::first_class_object_ptr, void *, int)
Definition: fileDriver.cpp:81
resolveHost
int resolveHost(rodsHostAddr_t *addr, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:375
subStructFileRead.h