MIDAS
Loading...
Searching...
No Matches
WriterFtp Class Reference
Inheritance diagram for WriterFtp:
Collaboration diagram for WriterFtp:

Public Member Functions

 WriterFtp (LOG_CHN *log_chn)
 
 ~WriterFtp ()
 
int wr_open (LOG_CHN *log_chn, int run_number)
 
int wr_write (LOG_CHN *log_chn, const void *data, const int size)
 
int wr_close (LOG_CHN *log_chn, int run_number)
 
std::string wr_get_file_ext ()
 
std::string wr_get_chain ()
 
- Public Member Functions inherited from WriterInterface
 WriterInterface ()
 
virtual ~WriterInterface ()
 

Private Attributes

FTP_CONfFtp
 

Additional Inherited Members

- Public Attributes inherited from WriterInterface
bool fTrace
 
double fBytesIn
 
double fBytesOut
 

Detailed Description

Definition at line 2889 of file mlogger.cxx.

Constructor & Destructor Documentation

◆ WriterFtp()

WriterFtp::WriterFtp ( LOG_CHN log_chn)
inline

Definition at line 2892 of file mlogger.cxx.

2893 {
2894 if (fTrace)
2895 printf("WriterFtp: path [%s]\n", log_chn->path.c_str());
2896
2897 fFtp = NULL;
2898 }
FTP_CON * fFtp
Definition mlogger.cxx:2986
std::string path
Definition mlogger.cxx:250

◆ ~WriterFtp()

WriterFtp::~WriterFtp ( )
inline

Definition at line 2900 of file mlogger.cxx.

2901 {
2902 if (fTrace)
2903 printf("WriterFtp: destructor\n");
2904
2905 if (fFtp) {
2906 ftp_bye(fFtp);
2907 fFtp = NULL;
2908 }
2909 }
int ftp_bye(FTP_CON *con)
Definition ftplib.cxx:422
Here is the call graph for this function:

Member Function Documentation

◆ wr_close()

int WriterFtp::wr_close ( LOG_CHN log_chn,
int  run_number 
)
inlinevirtual

Implements WriterInterface.

Definition at line 2959 of file mlogger.cxx.

2960 {
2961 if (fTrace)
2962 printf("WriterFtp: close path [%s]\n", log_chn->path.c_str());
2963
2964 assert(fFtp != NULL);
2965
2966 ftp_close(fFtp);
2967 ftp_bye(fFtp);
2968 fFtp = NULL;
2969
2970 log_chn->handle = 0;
2971
2972 return SUCCESS;
2973 }
int ftp_close(FTP_CON *con)
Definition ftplib.cxx:334
#define SUCCESS
Definition mcstd.h:54
INT handle
Definition mlogger.cxx:249
Here is the call graph for this function:

◆ wr_get_chain()

std::string WriterFtp::wr_get_chain ( )
inlinevirtual

Implements WriterInterface.

Definition at line 2980 of file mlogger.cxx.

2981 {
2982 return "FTP";
2983 }

◆ wr_get_file_ext()

std::string WriterFtp::wr_get_file_ext ( )
inlinevirtual

Reimplemented from WriterInterface.

Definition at line 2975 of file mlogger.cxx.

2976 {
2977 return "";
2978 }

◆ wr_open()

int WriterFtp::wr_open ( LOG_CHN log_chn,
int  run_number 
)
inlinevirtual

Implements WriterInterface.

Definition at line 2911 of file mlogger.cxx.

2912 {
2913 fBytesIn = 0;
2914 fBytesOut = 0;
2915
2916 if (fTrace)
2917 printf("WriterFtp: open path [%s]\n", log_chn->path.c_str());
2918
2919 assert(fFtp == NULL);
2920
2921 int status = ftp_open(log_chn->path.c_str(), &fFtp);
2922 if (status != SS_SUCCESS || fFtp == NULL) {
2923 cm_msg(MERROR, "WriterFtp::wr_open", "Cannot open FTP connection \'%s\', ftp_open() status %d, errno %d (%s)", log_chn->path.c_str(), status, errno, strerror(errno));
2924 return SS_FILE_ERROR;
2925 }
2926
2927 log_chn->handle = 9999;
2928
2929 return SUCCESS;
2930 }
#define SS_SUCCESS
Definition midas.h:664
#define SS_FILE_ERROR
Definition midas.h:670
#define MERROR
Definition midas.h:559
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:931
INT ftp_open(const char *xdestination, FTP_CON **con)
Definition mlogger.cxx:2806
DWORD status
Definition odbhist.cxx:39
Here is the call graph for this function:

◆ wr_write()

int WriterFtp::wr_write ( LOG_CHN log_chn,
const void *  data,
const int  size 
)
inlinevirtual

Implements WriterInterface.

Definition at line 2932 of file mlogger.cxx.

2933 {
2934 if (fTrace)
2935 printf("WriterFtp: write path [%s], size %d\n", log_chn->path.c_str(), size);
2936
2937 if (size == 0)
2938 return SUCCESS;
2939
2940 if (fFtp == NULL) {
2941 return SS_FILE_ERROR;
2942 }
2943
2944 fBytesIn += size;
2945
2946 int wr = ftp_send(fFtp->data, (const char*)data, size);
2947
2948 if (wr > 0)
2949 fBytesOut += wr;
2950
2951 if (wr != size) {
2952 cm_msg(MERROR, "WriterFtp::wr_write", "Cannot write to FTP connection \'%s\', ftp_send(%d) returned %d, errno %d (%s)", log_chn->path.c_str(), size, wr, errno, strerror(errno));
2953 return SS_FILE_ERROR;
2954 }
2955
2956 return SUCCESS;
2957 }
int ftp_send(int sock, const char *buffer, int n_bytes_to_write)
Definition ftplib.cxx:346
void * data
Definition mana.cxx:268
int data
Definition ftplib.h:27
Here is the call graph for this function:

Member Data Documentation

◆ fFtp

FTP_CON* WriterFtp::fFtp
private

Definition at line 2986 of file mlogger.cxx.


The documentation for this class was generated from the following file: