eventlog-socket-0.1.1.0: cbits/eventlog_socket/control.h
#ifndef EVENTLOG_SOCKET_CONTROL_H
#define EVENTLOG_SOCKET_CONTROL_H
#include <pthread.h>
#include <stdbool.h>
#include "./macros.h"
#include "eventlog_socket.h"
/// @brief Start the control thread.
///
/// @param control_thread
/// The function writes the thread handle to this location.
/// @param control_fd_ptr
/// The control thread reads the eventlog socket file descriptor from this
/// pointer. It should be nonnull.
/// @param control_fd_mutex_ptr
/// The control thread uses this mutex to guard its reads of `control_fd_ptr`.
/// All other accesses of the memory location pointed to by `control_fd_ptr`
/// should also be guarded using this mutex. Should be nonnull.
/// @param new_conn_cond_ptr
/// The control thread uses this condition together with
/// `control_fd_mutex_ptr` to wait for changes in `control_fd_ptr`.
///
/// @return Upon successful completion, 0 is returned.
///
/// @return On error, On error, -1 is returned, errno is set to indicate the
/// error.
///
/// @par Errors
/// @parblock
/// `EAGAIN`, `EINVAL`, `EPERM`, or `ESRCH`.
/// @endparblock
HIDDEN EventlogSocketStatus control_start(pthread_t *control_thread,
const volatile int *control_fd_ptr,
pthread_mutex_t *control_fd_mutex_ptr,
pthread_cond_t *new_conn_cond_ptr);
/// @see eventlog_socket_signal_ghc_rts_ready
HIDDEN EventlogSocketStatus control_signal_ghc_rts_ready(void);
/// @see eventlog_socket_control_strnamespace
HIDDEN const char *
control_strnamespace(EventlogSocketControlNamespace *namespace);
/// @see eventlog_socket_control_register_namespace
HIDDEN EventlogSocketStatus control_register_namespace(
uint8_t namespace_len, const char namespace[namespace_len],
EventlogSocketControlNamespace **namespace_out);
/// @see eventlog_socket_control_register_command
HIDDEN EventlogSocketStatus
control_register_command(EventlogSocketControlNamespace *namespace,
EventlogSocketControlCommandId command_id,
EventlogSocketControlCommandHandler command_handler,
const void *command_data);
#endif /* EVENTLOG_SOCKET_CONTROL_H */