summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/nnwt/buffer.h3
-rw-r--r--include/nnwt/common.h3
-rw-r--r--include/nnwt/error.h3
-rw-r--r--include/nnwt/thread.h1
-rw-r--r--include/nnwt/time.h3
-rw-r--r--src/common.c2
-rw-r--r--src/multiplex.c2
-rw-r--r--src/packet_stream.c11
-rw-r--r--src/util/error.c3
-rw-r--r--subprojects/libalabaster.wrap4
-rw-r--r--subprojects/libcurl.wrap4
-rw-r--r--tests/command_line_args.c31
-rw-r--r--tests/meson.build15
-rw-r--r--tests/timer_loop.c1
-rw-r--r--tests/timer_thread.c2
15 files changed, 64 insertions, 24 deletions
diff --git a/include/nnwt/buffer.h b/include/nnwt/buffer.h
new file mode 100644
index 0000000..27efb8d
--- /dev/null
+++ b/include/nnwt/buffer.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#include "../../src/util/buffer.h"
diff --git a/include/nnwt/common.h b/include/nnwt/common.h
index 71b0ed7..7da1720 100644
--- a/include/nnwt/common.h
+++ b/include/nnwt/common.h
@@ -1,6 +1,3 @@
#pragma once
#include "../../src/common.h"
-#include "../../src/util/error.h"
-#include "../../src/util/buffer.h"
-#include "../../src/util/timer/timer.h"
diff --git a/include/nnwt/error.h b/include/nnwt/error.h
new file mode 100644
index 0000000..0db5935
--- /dev/null
+++ b/include/nnwt/error.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#include "../../src/util/error.h"
diff --git a/include/nnwt/thread.h b/include/nnwt/thread.h
index 729b1d4..4759077 100644
--- a/include/nnwt/thread.h
+++ b/include/nnwt/thread.h
@@ -1,4 +1,3 @@
#pragma once
#include "../../src/util/thread/thread.h"
-#include "../../src/util/timer/timer.h"
diff --git a/include/nnwt/time.h b/include/nnwt/time.h
new file mode 100644
index 0000000..f64956d
--- /dev/null
+++ b/include/nnwt/time.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#include "../../src/util/timer/timer.h"
diff --git a/src/common.c b/src/common.c
index 01483f0..d0bd863 100644
--- a/src/common.c
+++ b/src/common.c
@@ -88,7 +88,7 @@ bool nn_common_init(const char *thread_name)
free, malloc_lock, malloc_unlock);
#endif
- al_rand_init((u32)(nn_get_timestamp() / 1000000));
+ al_random_init((u32)(nn_get_timestamp() / 1000000));
#ifdef NAUNET_ON_WINDOWS
if (!nn_windows_init()) return false;
diff --git a/src/multiplex.c b/src/multiplex.c
index 9744957..2de4621 100644
--- a/src/multiplex.c
+++ b/src/multiplex.c
@@ -34,7 +34,7 @@ static void socket_read_callback(struct ev_loop *loop, ev_io *w, s32 revents)
return;
}
- log_trace("ID byte: 0x%hhx.\n", id);
+ log_trace("ID byte: 0x%hhx.", id);
switch (id) {
case 0x48: // '(H)EAD'
break;
diff --git a/src/packet_stream.c b/src/packet_stream.c
index 0cf296c..7868242 100644
--- a/src/packet_stream.c
+++ b/src/packet_stream.c
@@ -31,13 +31,6 @@ static void stop_write_internal(struct nn_packet_stream *stream)
ev_io_stop(stream->loop->ev, &stream->wevent);
}
-static void shutdown_internal(struct nn_packet_stream *stream)
-{
- stream->connect = PACKET_STREAM_DISCONNECTING;
- // This assumes select()/poll() will return after shutdown().
- nn_socket_shutdown(&stream->sock);
-}
-
static void discard_out_queue_internal(struct nn_packet_stream *stream)
{
// stream->out.running can be true here. The stream will stop the
@@ -352,7 +345,9 @@ void nn_packet_stream_disconnect(struct nn_packet_stream *stream)
// This relies on stream_read_callback() to resolve and call stop_internal().
// Note that read() can still return data after shutdown(). This is why we have to
// check if connect = DISCONNECTING in send_packet().
- shutdown_internal(stream);
+ stream->connect = PACKET_STREAM_DISCONNECTING;
+ // This assumes select()/poll() will return after shutdown().
+ nn_socket_shutdown(&stream->sock);
}
}
diff --git a/src/util/error.c b/src/util/error.c
index 61c6136..97c7502 100644
--- a/src/util/error.c
+++ b/src/util/error.c
@@ -22,6 +22,7 @@ char *nn_strerror(s32 errnum)
// https://stackoverflow.com/a/46104456
char *nn_win32_error_message(s32 err)
{
+ /*
DWORD ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
err,
@@ -30,5 +31,7 @@ char *nn_win32_error_message(s32 err)
NNWT_ERROR_STR_MAXLEN,
NULL);
return !ret ? NULL : errorbuf;
+ */
+ return NULL;
}
#endif
diff --git a/subprojects/libalabaster.wrap b/subprojects/libalabaster.wrap
index 3f7a977..c48903d 100644
--- a/subprojects/libalabaster.wrap
+++ b/subprojects/libalabaster.wrap
@@ -1,5 +1,5 @@
[wrap-git]
-directory = libalabaster-dd7a1d1
+directory = libalabaster-c633226
url = https://git.akon.city/libalabaster.git
-revision = dd7a1d1afb8b3e93ab1005abdc21edb6efca840a
+revision = c633226d2b615f46ef38cc99603775dccdf96ecd
depth = 1
diff --git a/subprojects/libcurl.wrap b/subprojects/libcurl.wrap
index d1bf82a..19e3c96 100644
--- a/subprojects/libcurl.wrap
+++ b/subprojects/libcurl.wrap
@@ -1,6 +1,6 @@
[wrap-git]
-directory = libcurl-8.17.0
+directory = libcurl-8.19.0
url = https://github.com/curl/curl.git
-revision = curl-8_17_0
+revision = curl-8_19_0
depth = 1
method = cmake
diff --git a/tests/command_line_args.c b/tests/command_line_args.c
new file mode 100644
index 0000000..cda9328
--- /dev/null
+++ b/tests/command_line_args.c
@@ -0,0 +1,31 @@
+#ifndef _UNICODE
+#define _UNICODE
+#endif
+#ifndef UNICODE
+#define UNICODE
+#endif
+#include <al/types.h>
+#include <al/str.h>
+#include <al/wstr.h>
+#include <nnwt/common.h>
+
+#ifdef NAUNET_ON_WINDOWS
+s32 wmain(s32 argc, wchar_t **argv)
+#else
+s32 main(s32 argc, char *argv[])
+#endif
+{
+ if (!nn_common_init(NULL)) {
+ return EXIT_FAILURE;
+ }
+
+ for (s32 i = 0; i < argc; i++) {
+#ifdef NAUNET_ON_WINDOWS
+ al_printf("%d: %ls %zu\n", i, argv[i], al_wcsnlen(argv[i], MAX_ALLOC_32 / sizeof(wchar_t)));
+#else
+ al_printf("%d: %.*s %zu\n", i, al_str_x(&al_str_cr(argv[i])), al_strlen(argv[i]));
+#endif
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/meson.build b/tests/meson.build
index 0482bec..0ff6ffb 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,9 +1,12 @@
-executable('timer_thread', ['timer_thread.c'], dependencies: naunet)
-executable('timer_loop', ['timer_loop.c'], dependencies: naunet)
-executable('loop_sleep', ['loop_sleep.c'], dependencies: naunet)
executable('misc_file', ['misc_file.c'], dependencies: naunet)
executable('condition_variable', ['condition_variable.c'], dependencies: naunet)
-if not is_windows
- executable('stdin_lines', ['stdin_lines.c'], dependencies: naunet)
- executable('fs_event', ['fs_event_local.c'], dependencies: naunet)
+executable('timer_thread', ['timer_thread.c'], dependencies: naunet)
+if get_option('event-loop').enabled()
+ executable('timer_loop', ['timer_loop.c'], dependencies: naunet)
+ executable('loop_sleep', ['loop_sleep.c'], dependencies: naunet)
+ if not is_windows
+ executable('stdin_lines', ['stdin_lines.c'], dependencies: naunet)
+ executable('fs_event', ['fs_event_local.c'], dependencies: naunet)
+ endif
endif
+executable('cmd_args', ['command_line_args.c'], dependencies: naunet, link_args: is_windows ? ['-mwindows', '-municode'] : [])
diff --git a/tests/timer_loop.c b/tests/timer_loop.c
index 1df6863..77ea956 100644
--- a/tests/timer_loop.c
+++ b/tests/timer_loop.c
@@ -1,6 +1,7 @@
#include <nnwt/common.h>
#include <nnwt/thread.h>
#include <nnwt/timer.h>
+#include <nnwt/time.h>
#define DELAY 100000
#define REPEAT 21
diff --git a/tests/timer_thread.c b/tests/timer_thread.c
index 8ffbbc2..26a638b 100644
--- a/tests/timer_thread.c
+++ b/tests/timer_thread.c
@@ -1,5 +1,7 @@
+#include <al/lib.h>
#include <nnwt/common.h>
#include <nnwt/thread.h>
+#include <nnwt/time.h>
#define DELAY 100000
#define REPEAT 21