]> Kevux Git Server - fll/commitdiff
Bugfix: f_socket and fl_socket, numerous problems
authorKevin Day <thekevinday@gmail.com>
Fri, 16 Aug 2019 02:07:12 +0000 (21:07 -0500)
committerKevin Day <thekevinday@gmail.com>
Fri, 16 Aug 2019 02:07:12 +0000 (21:07 -0500)
It looks like the f_socket and fl_socket were not completed or otherwise written incorrectly.
Change the behavior to at least compile.

level_0/f_socket/c/socket.h
level_1/fl_socket/c/socket.c
level_1/fl_socket/c/socket.h
level_1/fl_socket/data/build/settings

index 04874173b30b4deda5a3c2e80420a82168eaf22c..de3c6536e9f3370668a728904cff29611e703aaa 100644 (file)
@@ -14,7 +14,6 @@
 #include <malloc.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/socket.h>
 
 // fll includes
 #include <level_0/errors.h>
@@ -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
 
index 850c68f226852e61fe8eb6f834482524aacf7daf..d3336325ea60b664b8fdaf1ff57a1819e66c0afe 100644 (file)
@@ -1,16 +1,16 @@
-#include <level_0/socket.h>
+#include <level_1/socket.h>
 
 #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;
       }
 
index d625dc4cb3b74c1d02e03d0e6b4b047a98826190..781f4b689ccf73fc82be2d149ff4ca7b7c1cf2c3 100644 (file)
@@ -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 <malloc.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <unistd.h>
 
 // fll includes
 #include <level_0/errors.h>
 #include <level_0/strings.h>
 #include <level_0/types.h>
+#include <level_0/socket.h>
 
 #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
index fdf7957f79eb361d30c222694464e0d8e8c839ce..2b1637bb20f99580578be62650e12bd4775211c0 100644 (file)
@@ -1,7 +1,7 @@
 # fss-0000
 
 project_name fl_socket
-project_level 0
+project_level 1
 
 version_major 0
 version_minor 5