ROOT logo
// @(#)root/net:$Id$
// Author: Adrien Devresse and Tigran Mkrtchyan

/*************************************************************************
 * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TDavixFile
#define ROOT_TDavixFile

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TDavixFile                                                           //
//                                                                      //
// A TDavixFile is like a normal TFile except that it uses              //
// libdavix to read/write remote files.                                 //
// It supports HTTP and HTTPS in a number of dialects and options       //
//  e.g. S3 is one of them                                              //
// Other caracteristics come from the full support of Davix,            //
//  e.g. full redirection support in any circumstance                   //
//                                                                      //
// Authors:     Adrien Devresse (CERN IT/SDC)                           //
//              Tigran Mkrtchyan (DESY)                                 //
//                                                                      //
// Checks, refactoring and ROOT5 porting:                               //
//              Fabrizio Furano (CERN IT/SDC)                           //
//                                                                      //
// September 2013                                                       //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

//
// Parameters that influence the behavior of TDavixFile/TDavixSystem. The names should be self-explanatory
//
//Davix.Debug
//Davix.GSI.UserProxy
//Davix.GSI.UserCert
//Davix.GSI.UserKey

//Davix.GSI.CAdir
//Davix.GSI.CACheck
//Davix.GSI.GridMode
//
// Environment variables:
// X509_USER_CERT, X509_USER_KEY, X509_USER_PROXY ... usual meaning for the X509 Grid things. gEnv vars have higher priority.

#include "TFile.h"
#include "TUrl.h"
#include "TSystem.h"
#include "TMutex.h"

class TDavixFileInternal;
struct Davix_fd;


class TDavixFile : public TFile {
private:
    TDavixFileInternal* d_ptr;

    void Init(Bool_t init);
    Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len);
    Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len);
    Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
    Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len);
    Int_t DavixStat(struct stat *st) const;

    // perfStats
    Double_t eventStart();
    void eventStop(Double_t t, Long64_t len);

public:
    ///
    ///  Open function for TDavixFile
    ///
    /// TDavixFile supports several options :
    ///
    ///  - GRID_MODE=yes    : enable the grid authentication and CA support
    ///  - CA_CHECK=no      : remove all the certificate authority check, this option can create a security vulnerability
    ///  - S3_SECKEY=string : Amazon S3 secret token
    ///  - S3_ACCKEY=string : Amazon S3 access token
    ///
    /// Several parameters can be used if separated with whitespace

   TDavixFile(const char* url, Option_t *option="", const char *ftitle="", Int_t compress=1);

   ~TDavixFile();

    // TFile interface.
    virtual Long64_t GetSize() const;
    virtual void  Seek(Long64_t offset, ERelativeTo pos = kBeg);
    virtual Bool_t ReadBuffer(char *buf, Int_t len);
    virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
    virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
    virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
    virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength);

    // TDavixFile options
    /// Enable or disable certificate authority check
    void setCACheck(Bool_t check);

    /// Enable the grid mode
    /// The grid Mode configure automatically all grid-CA path, VOMS authentication
    /// and grid related extension for a grid analysis usage
    void enableGridMode();

    ClassDef(TDavixFile, 0)
};

#endif
 TDavixFile.h:1
 TDavixFile.h:2
 TDavixFile.h:3
 TDavixFile.h:4
 TDavixFile.h:5
 TDavixFile.h:6
 TDavixFile.h:7
 TDavixFile.h:8
 TDavixFile.h:9
 TDavixFile.h:10
 TDavixFile.h:11
 TDavixFile.h:12
 TDavixFile.h:13
 TDavixFile.h:14
 TDavixFile.h:15
 TDavixFile.h:16
 TDavixFile.h:17
 TDavixFile.h:18
 TDavixFile.h:19
 TDavixFile.h:20
 TDavixFile.h:21
 TDavixFile.h:22
 TDavixFile.h:23
 TDavixFile.h:24
 TDavixFile.h:25
 TDavixFile.h:26
 TDavixFile.h:27
 TDavixFile.h:28
 TDavixFile.h:29
 TDavixFile.h:30
 TDavixFile.h:31
 TDavixFile.h:32
 TDavixFile.h:33
 TDavixFile.h:34
 TDavixFile.h:35
 TDavixFile.h:36
 TDavixFile.h:37
 TDavixFile.h:38
 TDavixFile.h:39
 TDavixFile.h:40
 TDavixFile.h:41
 TDavixFile.h:42
 TDavixFile.h:43
 TDavixFile.h:44
 TDavixFile.h:45
 TDavixFile.h:46
 TDavixFile.h:47
 TDavixFile.h:48
 TDavixFile.h:49
 TDavixFile.h:50
 TDavixFile.h:51
 TDavixFile.h:52
 TDavixFile.h:53
 TDavixFile.h:54
 TDavixFile.h:55
 TDavixFile.h:56
 TDavixFile.h:57
 TDavixFile.h:58
 TDavixFile.h:59
 TDavixFile.h:60
 TDavixFile.h:61
 TDavixFile.h:62
 TDavixFile.h:63
 TDavixFile.h:64
 TDavixFile.h:65
 TDavixFile.h:66
 TDavixFile.h:67
 TDavixFile.h:68
 TDavixFile.h:69
 TDavixFile.h:70
 TDavixFile.h:71
 TDavixFile.h:72
 TDavixFile.h:73
 TDavixFile.h:74
 TDavixFile.h:75
 TDavixFile.h:76
 TDavixFile.h:77
 TDavixFile.h:78
 TDavixFile.h:79
 TDavixFile.h:80
 TDavixFile.h:81
 TDavixFile.h:82
 TDavixFile.h:83
 TDavixFile.h:84
 TDavixFile.h:85
 TDavixFile.h:86
 TDavixFile.h:87
 TDavixFile.h:88
 TDavixFile.h:89
 TDavixFile.h:90
 TDavixFile.h:91
 TDavixFile.h:92
 TDavixFile.h:93
 TDavixFile.h:94
 TDavixFile.h:95
 TDavixFile.h:96
 TDavixFile.h:97
 TDavixFile.h:98
 TDavixFile.h:99
 TDavixFile.h:100
 TDavixFile.h:101
 TDavixFile.h:102
 TDavixFile.h:103
 TDavixFile.h:104
 TDavixFile.h:105
 TDavixFile.h:106
 TDavixFile.h:107
 TDavixFile.h:108
 TDavixFile.h:109
 TDavixFile.h:110
 TDavixFile.h:111
 TDavixFile.h:112
 TDavixFile.h:113