2024-12-20 21:17:21 +08:00
|
|
|
#pragma once
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2024-12-25 19:40:27 +08:00
|
|
|
typedef ssize_t (*read_fun_ptr_t)(int fd, void* buf, size_t count);
|
|
|
|
typedef ssize_t (*write_fun_ptr_t)(int fd, const void* buf, size_t count);
|
|
|
|
typedef int (*accept_fun_ptr_t)(int sockfd, struct sockaddr* addr, socklen_t* addrlen);
|
2024-12-20 21:17:21 +08:00
|
|
|
|
|
|
|
namespace tinyrpc {
|
|
|
|
|
2024-12-25 19:40:27 +08:00
|
|
|
ssize_t read_hook(int fd, void* buf, size_t count);
|
|
|
|
ssize_t write_hook(int fd, const void* buf, size_t count);
|
|
|
|
int accept_hook(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
|
2024-12-20 21:17:21 +08:00
|
|
|
void enableHook();
|
|
|
|
void disableHook();
|
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" {
|
2024-12-25 19:40:27 +08:00
|
|
|
ssize_t read(int fd, void* buf, size_t count);
|
|
|
|
ssize_t write(int fd, const void* buf, size_t count);
|
2024-12-20 21:17:21 +08:00
|
|
|
}
|