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)  

rsDataObjLseek.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See dataObjLseek.h for a description of this API call.*/
5 
6 #include "dataObjLseek.h"
7 #include "rodsLog.h"
8 #include "rsGlobalExtern.hpp"
9 #include "rcGlobalExtern.h"
10 #include "subStructFileLseek.h"
11 #include "objMetaOpr.hpp"
12 #include "subStructFileUnlink.h"
13 #include "rsDataObjLseek.hpp"
14 #include "rsSubStructFileLseek.hpp"
15 #include "rsFileLseek.hpp"
16 
17 // =-=-=-=-=-=-=-
19 
20 int
21 rsDataObjLseek( rsComm_t *rsComm, openedDataObjInp_t *dataObjLseekInp,
22  fileLseekOut_t **dataObjLseekOut ) {
23  int status;
24  int l1descInx, l3descInx;
25  dataObjInfo_t *dataObjInfo;
26 
27  l1descInx = dataObjLseekInp->l1descInx;
28 
29  if ( l1descInx <= 2 || l1descInx >= NUM_L1_DESC ) {
31  "rsDataObjLseek: l1descInx %d out of range",
32  l1descInx );
34  }
35  if ( L1desc[l1descInx].inuseFlag != FD_INUSE ) {
36  return BAD_INPUT_DESC_INDEX;
37  }
38  if ( L1desc[l1descInx].remoteZoneHost != NULL ) {
39  /* cross zone operation */
40  dataObjLseekInp->l1descInx = L1desc[l1descInx].remoteL1descInx;
41  status = rcDataObjLseek( L1desc[l1descInx].remoteZoneHost->conn,
42  dataObjLseekInp, dataObjLseekOut );
43  dataObjLseekInp->l1descInx = l1descInx;
44  return status;
45  }
46 
47  l3descInx = L1desc[l1descInx].l3descInx;
48 
49  if ( l3descInx <= 2 ) {
51  "rsDataObjLseek: l3descInx %d out of range",
52  l3descInx );
54  }
55 
56  dataObjInfo = L1desc[l1descInx].dataObjInfo;
57 
58  // =-=-=-=-=-=-=-
59  // extract the host location from the resource hierarchy
60  std::string location;
61  irods::error ret = irods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
62  if ( !ret.ok() ) {
63  irods::log( PASSMSG( "rsDataObjLseek - failed in get_loc_for_hier_string", ret ) );
64  return -1;
65  }
66 
67 
68  if ( getStructFileType( dataObjInfo->specColl ) >= 0 ) {
69  subStructFileLseekInp_t subStructFileLseekInp;
70  memset( &subStructFileLseekInp, 0, sizeof( subStructFileLseekInp ) );
71  subStructFileLseekInp.type = dataObjInfo->specColl->type;
72  subStructFileLseekInp.fd = L1desc[l1descInx].l3descInx;
73  subStructFileLseekInp.offset = dataObjLseekInp->offset;
74  subStructFileLseekInp.whence = dataObjLseekInp->whence;
75  rstrcpy( subStructFileLseekInp.addr.hostAddr,
76  location.c_str(),
77  NAME_LEN );
78  rstrcpy( subStructFileLseekInp.resc_hier,
79  dataObjInfo->rescHier,
80  NAME_LEN );
81  status = rsSubStructFileLseek( rsComm, &subStructFileLseekInp, dataObjLseekOut );
82  }
83  else {
84  *dataObjLseekOut = ( fileLseekOut_t* )malloc( sizeof( fileLseekOut_t ) );
85  memset( *dataObjLseekOut, 0, sizeof( fileLseekOut_t ) );
86 
87  ( *dataObjLseekOut )->offset = _l3Lseek( rsComm, l3descInx,
88  dataObjLseekInp->offset, dataObjLseekInp->whence );
89 
90  if ( ( *dataObjLseekOut )->offset >= 0 ) {
91  status = 0;
92  }
93  else {
94  status = ( *dataObjLseekOut )->offset;
95  }
96  }
97 
98  return status;
99 }
100 
102 _l3Lseek( rsComm_t *rsComm, int l3descInx,
103  rodsLong_t offset, int whence ) {
104  fileLseekInp_t fileLseekInp;
105  fileLseekOut_t *fileLseekOut = NULL;
106  int status;
107 
108  memset( &fileLseekInp, 0, sizeof( fileLseekInp ) );
109  fileLseekInp.fileInx = l3descInx;
110  fileLseekInp.offset = offset;
111  fileLseekInp.whence = whence;
112  status = rsFileLseek( rsComm, &fileLseekInp, &fileLseekOut );
113  if ( status < 0 ) {
114  return status;
115  }
116  else {
117  rodsLong_t off = fileLseekOut->offset;
118  free( fileLseekOut );
119  return off;
120  }
121 }
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
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
SubStructFileLseekInp::addr
rodsHostAddr_t addr
Definition: subStructFileLseek.h:11
OpenedDataObjInp::l1descInx
int l1descInx
Definition: dataObjInpOut.h:105
rsSubStructFileLseek
int rsSubStructFileLseek(rsComm_t *rsComm, subStructFileLseekInp_t *subStructFileLseekInp, fileLseekOut_t **subStructFileLseekOut)
Definition: rsSubStructFileLseek.cpp:13
_l3Lseek
rodsLong_t _l3Lseek(rsComm_t *rsComm, int l3descInx, rodsLong_t offset, int whence)
Definition: rsDataObjLseek.cpp:102
SubStructFileLseekInp::offset
rodsLong_t offset
Definition: subStructFileLseek.h:14
l1desc::remoteL1descInx
int remoteL1descInx
Definition: objDesc.hpp:52
SpecColl::type
structFileType_t type
Definition: objInfo.h:78
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
SubStructFileLseekInp::resc_hier
char resc_hier[(1024+64)]
Definition: subStructFileLseek.h:16
dataObjLseek.h
subStructFileLseek.h
irods_resource_backport.hpp
OpenedDataObjInp::whence
int whence
Definition: dataObjInpOut.h:107
l1desc::l3descInx
int l3descInx
Definition: objDesc.hpp:35
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
rcGlobalExtern.h
DataObjInfo::specColl
specColl_t * specColl
Definition: objInfo.h:158
rsGlobalExtern.hpp
rsDataObjLseek
int rsDataObjLseek(rsComm_t *rsComm, openedDataObjInp_t *dataObjLseekInp, fileLseekOut_t **dataObjLseekOut)
Definition: rsDataObjLseek.cpp:21
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
SubStructFileLseekInp
Definition: subStructFileLseek.h:10
rodsLog.h
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rsSubStructFileLseek.hpp
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
irods::error
Definition: irods_error.hpp:23
FileLseekOut
Definition: fileLseek.h:53
NUM_L1_DESC
#define NUM_L1_DESC
Definition: objDesc.hpp:24
BAD_INPUT_DESC_INDEX
@ BAD_INPUT_DESC_INDEX
Definition: rodsErrorTable.h:266
FD_INUSE
#define FD_INUSE
Definition: fileOpr.hpp:21
SubStructFileLseekInp::fd
int fd
Definition: subStructFileLseek.h:13
rsDataObjLseek.hpp
FileLseekOut::offset
rodsLong_t offset
Definition: fileLseek.h:54
rodsHostAddr_t::hostAddr
char hostAddr[256]
Definition: rodsDef.h:297
FileLseekInp::fileInx
int fileInx
Definition: fileLseek.h:33
SubStructFileLseekInp::type
structFileType_t type
Definition: subStructFileLseek.h:12
OpenedDataObjInp::offset
rodsLong_t offset
Definition: dataObjInpOut.h:109
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
FileLseekInp
Definition: fileLseek.h:32
rsFileLseek
int rsFileLseek(rsComm_t *rsComm, fileLseekInp_t *fileLseekInp, fileLseekOut_t **fileLseekOut)
Definition: rsFileLseek.cpp:17
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
rsFileLseek.hpp
rcDataObjLseek
int rcDataObjLseek(rcComm_t *conn, openedDataObjInp_t *dataObjLseekInp, fileLseekOut_t **dataObjLseekOut)
Definition: rcDataObjLseek.cpp:77
SubStructFileLseekInp::whence
int whence
Definition: subStructFileLseek.h:15
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
DataObjInfo
Definition: objInfo.h:129
FileLseekInp::offset
rodsLong_t offset
Definition: fileLseek.h:34
FileLseekInp::whence
int whence
Definition: fileLseek.h:35
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
objMetaOpr.hpp