automotive-dlt
dlt-system-filetransfer.c File Reference
#include <pthread.h>
#include <unistd.h>
#include <libgen.h>
#include <dirent.h>
#include <zlib.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "dlt-system.h"
#include "dlt.h"
#include "dlt_filetransfer.h"
Include dependency graph for dlt-system-filetransfer.c:

Go to the source code of this file.

Macros

#define Z_CHUNK_SZ   1024*128
 
#define COMPRESS_EXTENSION   ".gz"
 
#define SUBDIR_COMPRESS   ".tocompress"
 
#define SUBDIR_TOSEND   ".tosend"
 

Functions

uint32_t getFileSerialNumber (const char *file, int *ok)
 Get some information about the file serial number of a file. More...
 
 DLT_IMPORT_CONTEXT (dltsystem)
 
char * unique_name (char *src)
 
void send_dumped_file (FiletransferOptions const *opts, char *dst_tosend)
 
int compress_file_to (char *src, char *dst, int level)
 
int send_one (char *src, FiletransferOptions const *opts, int which)
 Sends one file over DLT. More...
 
int flush_dir_send (FiletransferOptions const *opts, const char *compress_dir, const char *send_dir)
 
int flush_dir_compress (FiletransferOptions const *opts, int which, const char *compress_dir, const char *send_dir)
 
int flush_dir_original (FiletransferOptions const *opts, int which)
 
int flush_dir (FiletransferOptions const *opts, int which)
 Cleans the surveyed directories and subdirectories. Sends residing files into trace. More...
 
int init_filetransfer_dirs (FiletransferOptions const *opts)
 Initializes the surveyed directories. More...
 
int wait_for_files (FiletransferOptions const *opts)
 
void filetransfer_thread (void *v_conf)
 
void start_filetransfer (DltSystemConfiguration *conf)
 

Variables

DltSystemThreads threads
 

Detailed Description

Macro Definition Documentation

#define COMPRESS_EXTENSION   ".gz"

Definition at line 76 of file dlt-system-filetransfer.c.

Referenced by flush_dir_compress(), flush_dir_send(), and send_one().

#define SUBDIR_COMPRESS   ".tocompress"

Definition at line 77 of file dlt-system-filetransfer.c.

Referenced by flush_dir(), init_filetransfer_dirs(), and send_one().

#define SUBDIR_TOSEND   ".tosend"

Definition at line 78 of file dlt-system-filetransfer.c.

Referenced by flush_dir(), init_filetransfer_dirs(), and send_one().

#define Z_CHUNK_SZ   1024*128

Definition at line 75 of file dlt-system-filetransfer.c.

Referenced by compress_file_to().

Function Documentation

int compress_file_to ( char *  src,
char *  dst,
int  level 
)

compress file, delete the source file modification: compress into subdirectory File whis is compress will be deleted afterwards

Parameters
srcFile to be sent
dstdestination where to compress the file
levelof compression

Definition at line 191 of file dlt-system-filetransfer.c.

References DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_WARN, DLT_STRING, MALLOC_ASSERT, NULL, and Z_CHUNK_SZ.

Referenced by flush_dir_compress(), and send_one().

DLT_IMPORT_CONTEXT ( dltsystem  )

Definition at line 86 of file dlt-system-filetransfer.c.

References DLT_LOG, DLT_LOG_ERROR, DLT_STRING, DLT_SYSTEM_LOG_DIRS_MAX, and NULL.

int flush_dir ( FiletransferOptions const *  opts,
int  which 
)

Cleans the surveyed directories and subdirectories. Sends residing files into trace.

Parameters
optsFiletransferOptions
whichwhich directory is affected -> position in list of opts->Directory
Returns
Returns 0 if everything was okay. If there was a failure a value < 0 will be returned.

Definition at line 556 of file dlt-system-filetransfer.c.

References FiletransferOptions::Directory, DLT_LOG, DLT_LOG_DEBUG, DLT_STRING, flush_dir_compress(), flush_dir_original(), flush_dir_send(), MALLOC_ASSERT, SUBDIR_COMPRESS, and SUBDIR_TOSEND.

Referenced by init_filetransfer_dirs().

int flush_dir_compress ( FiletransferOptions const *  opts,
int  which,
const char *  compress_dir,
const char *  send_dir 
)
int flush_dir_original ( FiletransferOptions const *  opts,
int  which 
)
int flush_dir_send ( FiletransferOptions const *  opts,
const char *  compress_dir,
const char *  send_dir 
)
uint32_t getFileSerialNumber ( const char *  file,
int *  ok 
)

Get some information about the file serial number of a file.

See stat(2) for more informations.

Parameters
fileAbsolute file path
value*ok == 0 -> error; *ok == 1 -> ok
Returns
Returns a unique number associated with each filename

Definition at line 124 of file dlt_filetransfer.c.

References stringHash().

Referenced by dlt_user_log_file_data(), dlt_user_log_file_end(), dlt_user_log_file_errorMessage(), dlt_user_log_file_header(), dlt_user_log_file_header_alias(), dlt_user_log_file_infoAbout(), and unique_name().

int init_filetransfer_dirs ( FiletransferOptions const *  opts)

Initializes the surveyed directories.

On startup, the inotifiy handlers are created, and existing files shall be sent into DLT stream

Parameters
optsFiletransferOptions
Returns
Returns 0 if everything was okay. If there was a failure a value < 0 will be returned.

Definition at line 605 of file dlt-system-filetransfer.c.

References FiletransferOptions::Count, FiletransferOptions::Directory, DLT_INT, DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_ERROR, DLT_LOG_FATAL, DLT_STRING, flush_dir(), MALLOC_ASSERT, SUBDIR_COMPRESS, and SUBDIR_TOSEND.

Referenced by filetransfer_thread().

int send_one ( char *  src,
FiletransferOptions const *  opts,
int  which 
)

Sends one file over DLT.

If configured in opts, compresses it, then sends it. uses subdirecties for compressing and before sending, to avoid that those files get changed in the meanwhile

Definition at line 252 of file dlt-system-filetransfer.c.

References COMPRESS_EXTENSION, compress_file_to(), FiletransferOptions::Compression, FiletransferOptions::CompressionLevel, DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_ERROR, DLT_STRING, MALLOC_ASSERT, NULL, send_dumped_file(), SUBDIR_COMPRESS, SUBDIR_TOSEND, FiletransferOptions::TimeDelay, and unique_name().

Referenced by flush_dir_original(), and wait_for_files().

void start_filetransfer ( DltSystemConfiguration conf)
char* unique_name ( char *  src)

Variable Documentation

Definition at line 58 of file dlt-system-process-handling.c.

Referenced by logfile_thread(), and start_logfile().