Changed implementation function names

This commit is contained in:
Randy Jordan 2024-11-15 19:53:37 -06:00
parent 77bbae984a
commit 04faf2790d
Signed by: Randy-Jordan
GPG Key ID: D57FA29E3B54663E

View File

@ -8,7 +8,7 @@ static const int WRITE_END = 1;
static const int INVALID_FD = -1; static const int INVALID_FD = -1;
/*--------- FILE DESCRIPTORS ----------- */ /*--------- FILE DESCRIPTORS ----------- */
int fio_open(const char *path, int flags){ int ext_open(const char *path, int flags){
int status = open(path,flags); int status = open(path,flags);
if(status == -1){ if(status == -1){
@ -18,7 +18,7 @@ int fio_open(const char *path, int flags){
return status; return status;
} }
int fio_close(int fd){ int ext_close(int fd){
int status = close(fd); int status = close(fd);
if(status == -1){ if(status == -1){
@ -28,17 +28,17 @@ int fio_close(int fd){
return status; return status;
} }
int fio_invalidate(int *fd){ int ext_invalidate(int *fd){
int status = -1; int status = -1;
if (*fd != INVALID_FD) { if (*fd != INVALID_FD) {
status = fio_close(*fd); status = ext_close(*fd);
*fd = INVALID_FD; *fd = INVALID_FD;
} }
return status; return status;
} }
/*---------- FILE STREAMS ------------- */ /*---------- FILE STREAMS ------------- */
FILE *fio_fopen(const char *path, const char *mode){ FILE *ext_fopen(const char *path, const char *mode){
FILE *status = fopen(path,mode); FILE *status = fopen(path,mode);
if(status == NULL){ if(status == NULL){
@ -50,7 +50,7 @@ FILE *fio_fopen(const char *path, const char *mode){
} }
FILE *fio_fdopen(int fd, const char *mode){ FILE *ext_fdopen(int fd, const char *mode){
FILE *status = fdopen(fd,mode); FILE *status = fdopen(fd,mode);
if(status == NULL){ if(status == NULL){
@ -60,7 +60,7 @@ FILE *fio_fdopen(int fd, const char *mode){
return status; return status;
} }
int fio_fclose(FILE *stream){ int ext_fclose(FILE *stream){
int status = fclose(stream); int status = fclose(stream);
if(status == -1){ if(status == -1){
@ -72,7 +72,7 @@ int fio_fclose(FILE *stream){
} }
/*---------- InterProcessComm ----------*/ /*---------- InterProcessComm ----------*/
pid_t fio_fork(void){ pid_t ext_fork(void){
pid_t status = fork(); pid_t status = fork();
if (status < 0) { if (status < 0) {
@ -82,7 +82,7 @@ pid_t fio_fork(void){
return status; return status;
} }
int fio_dup2(int oldfd, int newfd){ int ext_dup2(int oldfd, int newfd){
int status = dup2(oldfd,newfd); int status = dup2(oldfd,newfd);
if(status == -1 ){ if(status == -1 ){
@ -92,7 +92,7 @@ int fio_dup2(int oldfd, int newfd){
return status; return status;
} }
int fio_pipe(int fds[2]){ int ext_pipe(int fds[2]){
int status = pipe(fds); int status = pipe(fds);
if(status == -1){ if(status == -1){
@ -133,23 +133,23 @@ int bi_popen(const char* const command, FILE** const in, FILE** const out){
pid_t pid = INVALID_FD; pid_t pid = INVALID_FD;
TRY { TRY {
fio_pipe(to_child); ext_pipe(to_child);
fio_pipe(to_parent); ext_pipe(to_parent);
pid = fio_fork(); pid = ext_fork();
if(pid == 0 ){ // Child Process. if(pid == 0 ){ // Child Process.
fio_dup2(to_child[READ_END], STDIN_FILENO); ext_dup2(to_child[READ_END], STDIN_FILENO);
fio_dup2(to_parent[WRITE_END], STDOUT_FILENO); ext_dup2(to_parent[WRITE_END], STDOUT_FILENO);
execlp(command, command, NULL); execlp(command, command, NULL);
Exception e = { strerror(errno) }; Exception e = { strerror(errno) };
RAISE(e); RAISE(e);
} }
// Parent process. // Parent process.
fio_invalidate(&to_child[READ_END]); ext_invalidate(&to_child[READ_END]);
fio_invalidate(&to_parent[WRITE_END]); ext_invalidate(&to_parent[WRITE_END]);
*in = fio_fdopen(to_parent[READ_END], "r"); *in = ext_fdopen(to_parent[READ_END], "r");
*out = fio_fdopen(to_child[WRITE_END], "w"); *out = ext_fdopen(to_child[WRITE_END], "w");
} ELSE { } ELSE {
bi_pclose(in, out,to_child, to_parent); bi_pclose(in, out,to_child, to_parent);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -165,7 +165,7 @@ int execute_job( const char *path, char *const argv[], char *const envp[]){
int result = -1; int result = -1;
TRY{ TRY{
pid_t pid = fio_fork(); pid_t pid = ext_fork();
if(pid == 0){ // Child process if(pid == 0){ // Child process
execve(path, argv, envp); execve(path, argv, envp);
@ -188,7 +188,7 @@ int execute_job( const char *path, char *const argv[], char *const envp[]){
} }
/*---------- Networking Sockets --------*/ /*---------- Networking Sockets --------*/
int fio_socket(int domain, int type, int protocol){ int ext_socket(int domain, int type, int protocol){
int status = socket(domain,type,protocol); int status = socket(domain,type,protocol);
if(status == -1){ if(status == -1){
@ -197,7 +197,7 @@ int fio_socket(int domain, int type, int protocol){
} }
return status; return status;
} }
int fio_bind(int sockfd, const SA *addr,socklen_t addrlen){ int ext_bind(int sockfd, const SA *addr,socklen_t addrlen){
int status = bind(sockfd,addr,addrlen); int status = bind(sockfd,addr,addrlen);
if(status == -1){ if(status == -1){
@ -207,7 +207,7 @@ int fio_bind(int sockfd, const SA *addr,socklen_t addrlen){
return status; return status;
} }
int fio_listen(int sockfd, int backlog){ int ext_listen(int sockfd, int backlog){
int status = listen(sockfd,backlog); int status = listen(sockfd,backlog);
if(status == -1){ if(status == -1){
Exception e = { strerror(errno) }; Exception e = { strerror(errno) };
@ -215,7 +215,7 @@ int fio_listen(int sockfd, int backlog){
} }
return status; return status;
} }
int fio_connect(int sockfd, const SA *addr, socklen_t addrlen){ int ext_connect(int sockfd, const SA *addr, socklen_t addrlen){
int status = connect(sockfd, addr,addrlen); int status = connect(sockfd, addr,addrlen);
if(status == -1){ if(status == -1){
@ -225,7 +225,7 @@ int fio_connect(int sockfd, const SA *addr, socklen_t addrlen){
return status; return status;
} }
int fio_accept(int sockfd, SA *addr, socklen_t *addrlen){ int ext_accept(int sockfd, SA *addr, socklen_t *addrlen){
int status = accept(sockfd,addr,addrlen); int status = accept(sockfd,addr,addrlen);
if(status == -1){ if(status == -1){
@ -236,7 +236,7 @@ int fio_accept(int sockfd, SA *addr, socklen_t *addrlen){
} }
/*---------- Epoll ---------------------*/ /*---------- Epoll ---------------------*/
int fio_epoll_create(int flags){ int ext_epoll_create(int flags){
int status = epoll_create1(flags); int status = epoll_create1(flags);
if(status == -1){ if(status == -1){
Exception e = { strerror(errno) }; Exception e = { strerror(errno) };
@ -244,7 +244,7 @@ int fio_epoll_create(int flags){
} }
return status; return status;
} }
int fio_epoll_ctl(int epfd, int op, int fd, uint32_t events){ int ext_epoll_ctl(int epfd, int op, int fd, uint32_t events){
struct epoll_event ev; struct epoll_event ev;
ev.events = events; ev.events = events;
ev.data.fd = fd; ev.data.fd = fd;
@ -256,7 +256,7 @@ int fio_epoll_ctl(int epfd, int op, int fd, uint32_t events){
return status; return status;
} }
int fio_setnonblocking(int fd){ int ext_setnonblocking(int fd){
int status = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); int status = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
if(status == -1) { if(status == -1) {
Exception e = { strerror(errno) }; Exception e = { strerror(errno) };
@ -265,7 +265,7 @@ int fio_setnonblocking(int fd){
} }
return status; return status;
} }
int fio_epoll_wait(int epfd, struct epoll_event *events,int maxevents, int timeout){ int ext_epoll_wait(int epfd, struct epoll_event *events,int maxevents, int timeout){
int status = epoll_wait(epfd, events,maxevents,timeout); int status = epoll_wait(epfd, events,maxevents,timeout);
if(status == -1){ if(status == -1){