2024-10-01 22:48:28 +00:00
|
|
|
#ifndef RDBSERVER_CLIENT_H_
|
|
|
|
#define RDBSERVER_CLIENT_H_
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2024-10-02 01:24:48 +00:00
|
|
|
#include <stdint.h>
|
2024-10-01 22:48:28 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#define RDB_CLIENT_BUFLEN 8096
|
|
|
|
|
|
|
|
typedef struct RdbClient {
|
|
|
|
int connfd;
|
|
|
|
char full_buf[RDB_CLIENT_BUFLEN];
|
|
|
|
size_t len;
|
|
|
|
char chk;
|
|
|
|
bool should_ack;
|
|
|
|
} RdbClient;
|
|
|
|
|
|
|
|
void rdb_client_init(RdbClient *self, int connfd);
|
|
|
|
void rdb_client_begin_packet(RdbClient *self);
|
|
|
|
bool rdb_client_write_str(RdbClient *self, const char *str);
|
|
|
|
bool rdb_client_write_str_hex(RdbClient *self, const char *str);
|
2024-10-02 01:24:48 +00:00
|
|
|
bool rdb_client_write_i8_hex(RdbClient *self, uint8_t value);
|
|
|
|
bool rdb_client_write_i32_hex(RdbClient *self, uint32_t value);
|
2024-10-01 22:48:28 +00:00
|
|
|
int rdb_client_send_packet(RdbClient *self);
|
|
|
|
|
|
|
|
#endif
|