From: Kevin Day Date: Fri, 16 Aug 2019 02:07:12 +0000 (-0500) Subject: Bugfix: f_socket and fl_socket, numerous problems X-Git-Tag: 0.5.0~481 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=a2f702263343e761fe035d5f4f5a7fb85a70bb2f;p=fll Bugfix: f_socket and fl_socket, numerous problems It looks like the f_socket and fl_socket were not completed or otherwise written incorrectly. Change the behavior to at least compile. --- diff --git a/level_0/f_socket/c/socket.h b/level_0/f_socket/c/socket.h index 0487417..de3c653 100644 --- a/level_0/f_socket/c/socket.h +++ b/level_0/f_socket/c/socket.h @@ -14,7 +14,6 @@ #include #include #include -#include // fll includes #include @@ -26,7 +25,6 @@ extern "C"{ #endif #ifndef _di_f_socket_types_ - #define f_socket_address struct sockaddr_un #define f_socket_id f_s_int #define f_socket_close_id f_u_short diff --git a/level_1/fl_socket/c/socket.c b/level_1/fl_socket/c/socket.c index 850c68f..d333632 100644 --- a/level_1/fl_socket/c/socket.c +++ b/level_1/fl_socket/c/socket.c @@ -1,16 +1,16 @@ -#include +#include #ifdef __cplusplus extern "C"{ #endif #ifndef _di_fl_socket_file_bind_ - f_return_status fl_socket_file_bind(const f_string socket_path, f_socket_id *socket_id, f_socket_address *socket_address) { - memset(&socket_address, 0, structure_socket_length); - socket_address.sun_family = SOCKET_FAMILY; - strncpy(socket_address.sun_path, socket_path, sizeof(socket_address.sun_path) - 1); + f_return_status fl_socket_file_bind(const f_string socket_path, f_socket_id *socket_id, struct sockaddr_un *socket_address) { + memset(&socket_address, 0, sizeof(struct sockaddr_un)); + socket_address->sun_family = AF_UNIX; + strncpy(socket_address->sun_path, socket_path, sizeof(socket_address->sun_path) - 1); - if (bind(*socket_id, (f_socket_address *) socket_address, structure_socket_length) < 0) { + if (bind(*socket_id, (struct sockaddr *) socket_address, sizeof(struct sockaddr_un)) < 0) { if (errno == EACCES) { return f_access_denied; } @@ -77,7 +77,7 @@ extern "C"{ #ifndef _di_fl_socket_close_client_ // terminate a socket connection. - f_return_status fl_socket_close_client(const f_socket_id socket_id_client, const f_socket_close_id close_action = f_socket_close_fast) { + f_return_status fl_socket_close_client(const f_socket_id socket_id_client, const f_socket_close_id close_action) { f_u_int error_code = 0; if (close_action == f_socket_close_fast) { @@ -98,22 +98,22 @@ extern "C"{ } if (error_code > 0) { - if (result == EBADF) { + if (error_code == EBADF) { return f_file_descriptor_error; } - else if (result == EINVAL) { + else if (error_code == EINVAL) { return f_invalid_value; } - else if (result == ENOTCONN) { + else if (error_code == ENOTCONN) { return f_not_connected; } - else if (result == ENOTSOCK) { + else if (error_code == ENOTSOCK) { return f_invalid_socket; } - else if (result == EINTR) { + else if (error_code == EINTR) { return f_interrupted; } - else if (result == EBADF) { + else if (error_code == EBADF) { return f_input_output_error; } diff --git a/level_1/fl_socket/c/socket.h b/level_1/fl_socket/c/socket.h index d625dc4..781f4b6 100644 --- a/level_1/fl_socket/c/socket.h +++ b/level_1/fl_socket/c/socket.h @@ -7,19 +7,23 @@ * * Provide means to connect to and use sockets. */ -#ifndef _F_socket_h -#define _F_socket_h +#ifndef _FL_socket_h +#define _FL_socket_h // libc includes #include #include #include #include +#include +#include +#include // fll includes #include #include #include +#include #ifdef __cplusplus extern "C"{ @@ -29,7 +33,7 @@ extern "C"{ /** * bind a socket. */ - extern f_return_status fl_socket_file_bind(const f_string socket_path, f_socket_id *socket_id, f_socket_address *socket_address); + extern f_return_status fl_socket_file_bind(const f_string socket_path, f_socket_id *socket_id, struct sockaddr_un *socket_address); #endif // _di_fl_socket_file_bind_ #ifndef _di_fl_socket_listen_ @@ -52,4 +56,4 @@ extern "C"{ } // extern "C" #endif -#endif // _F_socket_h +#endif // _FL_socket_h diff --git a/level_1/fl_socket/data/build/settings b/level_1/fl_socket/data/build/settings index fdf7957..2b1637b 100644 --- a/level_1/fl_socket/data/build/settings +++ b/level_1/fl_socket/data/build/settings @@ -1,7 +1,7 @@ # fss-0000 project_name fl_socket -project_level 0 +project_level 1 version_major 0 version_minor 5