XROAD
xroad_base_writer.h File Reference
#include <sys/uio.h>
#include <stdbool.h>
#include <common/xroad_common_types.h>
Include dependency graph for xroad_base_writer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XROAD_WEAK   __attribute__((weak))
 
#define __xroad_writer_dtor__   __dtor__(xroad_writer_destructor)
 

Typedefs

typedef struct xroad_base_writer_s xroad_base_writer_t
 Base structure for a file writer. Implementations should extend this structure.
 
typedef void(* xroad_writer_on_done_t) (xroad_context_t user_data, size_t bytes_written, xroad_errno_t err_code)
 Callback function type for handling completion of write operations.
 

Enumerations

enum  { xroad_writer_nofd = -1 , xroad_writer_no_fd_available = -2 }
 

Functions

XROAD_WEAK ssize_t xroad_writer_writev (xroad_base_writer_t *writer, struct iovec *iov, int iovcnt, xroad_writer_on_done_t on_done, xroad_context_t user_data)
 Write data to a file using the file writer. Returns number of bytes written or negative error code (xroad_errno_t).
 
XROAD_WEAK xroad_errno_t xroad_writer_rotate (xroad_base_writer_t *writer, bool force, int flags)
 Rotate the file associated with the writer. Flags is reserved.
 
XROAD_WEAK xroad_errno_t xroad_writer_sync (xroad_base_writer_t *writer, uint32_t flags)
 Synchronize the recent writer operation(s). flags is reserved.
 
XROAD_WEAK int xroad_writer_get_fd (xroad_base_writer_t *writer)
 
XROAD_WEAK void xroad_writer_destroy (xroad_base_writer_t *writer)
 Destroy the writer object.
 
void xroad_writer_destructor (xroad_base_writer_t **w)
 

Detailed Description

Author
Vladimir Solontsov

Contains interface of a file writer. Constructors of writer implementations are not declared here.

Considerations... Writer currently represents a stream. Client can write data while the stream creates new files as needed. For single-threaded logger we need just a stream. But for tracing we need

Function Documentation

◆ xroad_writer_get_fd()

XROAD_WEAK int xroad_writer_get_fd ( xroad_base_writer_t *  writer)

Get file descriptor associated with the writer. Returns -1 if no file opened, -2 if fd is not available for this type of writer.