2016-09-18 13:35:43 -07:00
|
|
|
#ifndef IO_H
|
|
|
|
#define IO_H
|
|
|
|
|
2016-11-02 00:09:04 -07:00
|
|
|
#include <stdbool.h>
|
2016-09-18 13:35:43 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2016-11-04 00:41:20 -07:00
|
|
|
#include "utarray.h"
|
|
|
|
|
2016-09-27 18:51:35 -07:00
|
|
|
enum common_message_type {
|
|
|
|
/** Disconnect a client. */
|
|
|
|
DISCONNECT_CLIENT,
|
|
|
|
/** Log a message from a client. */
|
|
|
|
LOG_MESSAGE,
|
|
|
|
/** Submit a task to the local scheduler. */
|
|
|
|
SUBMIT_TASK,
|
|
|
|
};
|
|
|
|
|
2016-09-18 13:35:43 -07:00
|
|
|
/* Helper functions for socket communication. */
|
|
|
|
|
2016-11-02 00:09:04 -07:00
|
|
|
int bind_inet_sock(const int port, bool shall_listen);
|
|
|
|
int bind_ipc_sock(const char *socket_pathname, bool shall_listen);
|
2016-09-18 13:35:43 -07:00
|
|
|
int connect_ipc_sock(const char *socket_pathname);
|
|
|
|
|
|
|
|
int accept_client(int socket_fd);
|
|
|
|
|
2016-11-04 00:41:20 -07:00
|
|
|
/* Reading and writing data. */
|
2016-09-18 13:35:43 -07:00
|
|
|
|
2016-10-18 12:38:30 -07:00
|
|
|
int write_message(int fd, int64_t type, int64_t length, uint8_t *bytes);
|
2016-09-27 18:51:35 -07:00
|
|
|
void read_message(int fd, int64_t *type, int64_t *length, uint8_t **bytes);
|
2016-11-04 00:41:20 -07:00
|
|
|
int64_t read_buffer(int fd, int64_t *type, UT_array *buffer);
|
2016-09-18 13:35:43 -07:00
|
|
|
|
2016-09-27 18:51:35 -07:00
|
|
|
void write_log_message(int fd, char *message);
|
|
|
|
void write_formatted_log_message(int fd, const char *format, ...);
|
|
|
|
char *read_log_message(int fd);
|
2016-09-18 13:35:43 -07:00
|
|
|
|
2016-11-02 00:09:04 -07:00
|
|
|
#endif /* IO_H */
|