Commit ed29f501a2d72a4f947bb2b16aa5119ee3bad4f5

Thomas de Grivel 2024-08-02T14:28:38

misc

diff --git a/.gitignore b/.gitignore
index 9a95ce0..4ab7f92 100644
--- a/.gitignore
+++ b/.gitignore
@@ -85,6 +85,8 @@ libkc3_window/sdl2/demo/macos/kc3_window_sdl2_demo_debug.app/
 .libs/
 *.lo
 macos/kc3-v*
+/misc/http_request_offsets
+/misc/http_response_offsets
 *.o
 release/
 .test
diff --git a/misc/Makefile b/misc/Makefile
new file mode 100644
index 0000000..95118e3
--- /dev/null
+++ b/misc/Makefile
@@ -0,0 +1,36 @@
+## kc3
+## Copyright 2022-2024 kmx.io <contact@kmx.io>
+##
+## Permission is hereby granted to use this software granted the above
+## copyright notice and this permission paragraph are included in all
+## copies and substantial portions of this software.
+##
+## THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+## PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+## THIS SOFTWARE.
+
+CLEANFILES = http_request_offsets http_response_offsets
+
+CPPFLAGS += -I/usr/local/include -I.. -W -Wall -Werror
+
+all: http_request_offsets http_response_offsets
+
+build: all
+
+clean:
+	rm -rf ${CLEANFILES}
+
+distclean: clean
+
+http_request_offsets: http_request_offsets.c
+	${CC} ${CPPFLAGS} -I.. http_request_offsets.c -o http_request_offsets
+
+http_response_offsets: http_response_offsets.c
+	${CC} ${CPPFLAGS} -I.. http_response_offsets.c -o http_response_offsets
+
+.PHONY: \
+	all \
+	build \
+	clean \
+	distclean
diff --git a/misc/http_request_offset b/misc/http_request_offset
new file mode 100755
index 0000000..db6eaec
Binary files /dev/null and b/misc/http_request_offset differ
diff --git a/misc/http_request_offsets.c b/misc/http_request_offsets.c
new file mode 100644
index 0000000..8ca3e64
--- /dev/null
+++ b/misc/http_request_offsets.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stddef.h>
+#include <assert.h>
+#include "../http/types.h"
+
+void print_offsets() {
+    printf("Offset of method: %zu\n", offsetof(struct http_request, method));
+    printf("Offset of url: %zu\n", offsetof(struct http_request, url));
+    printf("Offset of protocol: %zu\n", offsetof(struct http_request, protocol));
+    printf("Offset of headers: %zu\n", offsetof(struct http_request, headers));
+}
+
+int main (void) {
+  print_offsets();
+  return 0;
+}
diff --git a/misc/http_response_offset b/misc/http_response_offset
new file mode 100755
index 0000000..75268d1
Binary files /dev/null and b/misc/http_response_offset differ
diff --git a/misc/http_response_offsets.c b/misc/http_response_offsets.c
new file mode 100644
index 0000000..3cecc4f
--- /dev/null
+++ b/misc/http_response_offsets.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stddef.h>
+#include <assert.h>
+#include "../http/types.h"
+
+// Function to calculate and print offsets
+void print_offsets() {
+    printf("Offset of protocol: %zu\n", offsetof(struct http_response, protocol));
+    printf("Offset of code: %zu\n", offsetof(struct http_response, code));
+    printf("Offset of message: %zu\n", offsetof(struct http_response, message));
+    printf("Offset of headers: %zu\n", offsetof(struct http_response, headers));
+    printf("Offset of body: %zu\n", offsetof(struct http_response, body));
+}
+
+// Main function
+int main() {
+    // Print offsets
+    print_offsets();
+
+    return 0;
+}
\ No newline at end of file
diff --git a/misc/offset_request.c b/misc/offset_request.c
deleted file mode 100644
index ff7ec0b..0000000
--- a/misc/offset_request.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdio.h>
-#include <stddef.h>
-#include <assert.h>
-#include "../http/types.h"
-
-// Function to calculate and print offsets
-void print_offsets() {
-    printf("Offset of method: %zu\n", offsetof(struct http_request, method));
-    printf("Offset of url: %zu\n", offsetof(struct http_request, url));
-    printf("Offset of protocol: %zu\n", offsetof(struct http_request, protocol));
-    printf("Offset of headers: %zu\n", offsetof(struct http_request, headers));
-}
-
-// Main function
-int main() {
-    // Print offsets
-    print_offsets();
-
-    return 0;
-}
\ No newline at end of file
diff --git a/misc/offset_response.c b/misc/offset_response.c
deleted file mode 100644
index 3cecc4f..0000000
--- a/misc/offset_response.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <stdio.h>
-#include <stddef.h>
-#include <assert.h>
-#include "../http/types.h"
-
-// Function to calculate and print offsets
-void print_offsets() {
-    printf("Offset of protocol: %zu\n", offsetof(struct http_response, protocol));
-    printf("Offset of code: %zu\n", offsetof(struct http_response, code));
-    printf("Offset of message: %zu\n", offsetof(struct http_response, message));
-    printf("Offset of headers: %zu\n", offsetof(struct http_response, headers));
-    printf("Offset of body: %zu\n", offsetof(struct http_response, body));
-}
-
-// Main function
-int main() {
-    // Print offsets
-    print_offsets();
-
-    return 0;
-}
\ No newline at end of file