diff --git a/fio-stl.h b/fio-stl.h index 3b10b71..e52281f 100644 --- a/fio-stl.h +++ b/fio-stl.h @@ -11066,6 +11066,8 @@ typedef enum { FIO_CLI_ARG_PRINT_HEADER, } fio_cli_arg_e; +#define FIO_CLI_ARG_NONE FIO_CLI_ARG_PRINT_HEADER + typedef struct { fio_cli_arg_e t; const char *l; @@ -11225,6 +11227,10 @@ SFUNC size_t fio_cli_each(int (*task)(fio_buf_info_s name, fio_cli_arg_e arg_type, void *udata), void *udata); + +/** Returns the argument's expected content type. */ +SFUNC fio_cli_arg_e fio_cli_type(char const *name); + /* ***************************************************************************** CLI Implementation ***************************************************************************** */ @@ -11480,6 +11486,17 @@ SFUNC void __attribute__((destructor)) fio_cli_end(void) { CLI Public Get/Set API ***************************************************************************** */ +/** Returns the argument's expected content type. */ +SFUNC fio_cli_arg_e fio_cli_type(char const *name) { + fio_cli_arg_e r = FIO_CLI_ARG_NONE; + fio___cli_aliases_s o = {.name = + fio_cli_str_tmp(FIO_BUF_INFO1((char *)name))}; + fio___cli_aliases_s *a = fio___cli_amap_get(&fio___cli_data.aliases, o); + if (a) + r = a->t; + return r; +} + /** Returns the argument's value as a NUL terminated C String. */ SFUNC char const *fio_cli_get(char const *name) { if (!name) @@ -28308,8 +28325,12 @@ SFUNC void *fio_srv_listen(struct fio_srv_listen_args args); #define fio_srv_listen(...) \ fio_srv_listen((struct fio_srv_listen_args){__VA_ARGS__}) +/** Notifies a listener to stop listening. */ SFUNC void fio_srv_listen_stop(void *listener); +/** Returns the URL on which the listener is listening. */ +SFUNC fio_buf_info_s fio_srv_listener_url(void *listener); + /* ***************************************************************************** Listening to Incoming Connections ***************************************************************************** */ @@ -29976,6 +29997,7 @@ static void fio___srv_spawn_worker(void *ignr_1, void *ignr_2) { if (fio_atomic_or_fetch(&fio___srvdata.stop, 2) != 2) return; + fio___srvdata.tick = FIO___SRV_GET_TIME_MILLI(); fio_state_callback_force(FIO_CALL_BEFORE_FORK); /* do not allow master tasks to run in worker */ fio_queue_perform_all(fio___srv_tasks); @@ -30469,6 +30491,12 @@ SFUNC void fio_srv_listen_stop(void *listener) { fio___srv_listen_free(listener); } +/** Returns the URL on which the listener is listening. */ +SFUNC fio_buf_info_s fio_srv_listener_url(void *listener) { + fio___srv_listen_s *l = (fio___srv_listen_s *)listener; + return FIO_BUF_INFO2(l->url, l->url_len); +} + static void fio___srv_listen_on_data_task(void *io_, void *ignr_) { (void)ignr_; fio_s *io = (fio_s *)io_; @@ -30716,6 +30744,7 @@ Managing data after a fork FIO_SFUNC void fio___srv_after_fork(void *ignr_) { (void)ignr_; fio___srvdata.pid = fio_thread_getpid(); + fio___srvdata.tick = FIO___SRV_GET_TIME_MILLI(); fio_queue_perform_all(fio___srv_tasks); FIO_LIST_EACH(fio_protocol_s, reserved.protocols, @@ -30739,6 +30768,7 @@ FIO_SFUNC void fio___srv_cleanup_at_exit(void *ignr_) { fio_thread_mutex_destroy(&fio___srvdata.valid_lock); #endif #endif /* FIO_VALIDATE_IO_MUTEX / FIO_VALIDITY_MAP_USE */ + fio___srvdata.tick = FIO___SRV_GET_TIME_MILLI(); fio_queue_perform_all(fio___srv_tasks); fio_timer_destroy(fio___srv_timer); fio_queue_perform_all(fio___srv_tasks); diff --git a/fio-stl/005 cli.h b/fio-stl/005 cli.h index 381549d..4c19f5d 100644 --- a/fio-stl/005 cli.h +++ b/fio-stl/005 cli.h @@ -35,6 +35,8 @@ typedef enum { FIO_CLI_ARG_PRINT_HEADER, } fio_cli_arg_e; +#define FIO_CLI_ARG_NONE FIO_CLI_ARG_PRINT_HEADER + typedef struct { fio_cli_arg_e t; const char *l; @@ -194,6 +196,10 @@ SFUNC size_t fio_cli_each(int (*task)(fio_buf_info_s name, fio_cli_arg_e arg_type, void *udata), void *udata); + +/** Returns the argument's expected content type. */ +SFUNC fio_cli_arg_e fio_cli_type(char const *name); + /* ***************************************************************************** CLI Implementation ***************************************************************************** */ @@ -449,6 +455,17 @@ SFUNC void __attribute__((destructor)) fio_cli_end(void) { CLI Public Get/Set API ***************************************************************************** */ +/** Returns the argument's expected content type. */ +SFUNC fio_cli_arg_e fio_cli_type(char const *name) { + fio_cli_arg_e r = FIO_CLI_ARG_NONE; + fio___cli_aliases_s o = {.name = + fio_cli_str_tmp(FIO_BUF_INFO1((char *)name))}; + fio___cli_aliases_s *a = fio___cli_amap_get(&fio___cli_data.aliases, o); + if (a) + r = a->t; + return r; +} + /** Returns the argument's value as a NUL terminated C String. */ SFUNC char const *fio_cli_get(char const *name) { if (!name) diff --git a/fio-stl/400 server.h b/fio-stl/400 server.h index ce88e46..080005c 100644 --- a/fio-stl/400 server.h +++ b/fio-stl/400 server.h @@ -157,8 +157,12 @@ SFUNC void *fio_srv_listen(struct fio_srv_listen_args args); #define fio_srv_listen(...) \ fio_srv_listen((struct fio_srv_listen_args){__VA_ARGS__}) +/** Notifies a listener to stop listening. */ SFUNC void fio_srv_listen_stop(void *listener); +/** Returns the URL on which the listener is listening. */ +SFUNC fio_buf_info_s fio_srv_listener_url(void *listener); + /* ***************************************************************************** Listening to Incoming Connections ***************************************************************************** */ @@ -1825,6 +1829,7 @@ static void fio___srv_spawn_worker(void *ignr_1, void *ignr_2) { if (fio_atomic_or_fetch(&fio___srvdata.stop, 2) != 2) return; + fio___srvdata.tick = FIO___SRV_GET_TIME_MILLI(); fio_state_callback_force(FIO_CALL_BEFORE_FORK); /* do not allow master tasks to run in worker */ fio_queue_perform_all(fio___srv_tasks); @@ -2318,6 +2323,12 @@ SFUNC void fio_srv_listen_stop(void *listener) { fio___srv_listen_free(listener); } +/** Returns the URL on which the listener is listening. */ +SFUNC fio_buf_info_s fio_srv_listener_url(void *listener) { + fio___srv_listen_s *l = (fio___srv_listen_s *)listener; + return FIO_BUF_INFO2(l->url, l->url_len); +} + static void fio___srv_listen_on_data_task(void *io_, void *ignr_) { (void)ignr_; fio_s *io = (fio_s *)io_; @@ -2565,6 +2576,7 @@ Managing data after a fork FIO_SFUNC void fio___srv_after_fork(void *ignr_) { (void)ignr_; fio___srvdata.pid = fio_thread_getpid(); + fio___srvdata.tick = FIO___SRV_GET_TIME_MILLI(); fio_queue_perform_all(fio___srv_tasks); FIO_LIST_EACH(fio_protocol_s, reserved.protocols, @@ -2588,6 +2600,7 @@ FIO_SFUNC void fio___srv_cleanup_at_exit(void *ignr_) { fio_thread_mutex_destroy(&fio___srvdata.valid_lock); #endif #endif /* FIO_VALIDATE_IO_MUTEX / FIO_VALIDITY_MAP_USE */ + fio___srvdata.tick = FIO___SRV_GET_TIME_MILLI(); fio_queue_perform_all(fio___srv_tasks); fio_timer_destroy(fio___srv_timer); fio_queue_perform_all(fio___srv_tasks); diff --git a/fio-stl/431 http handle.h b/fio-stl/431 http handle.h index c66ee8f..1ccae17 100644 --- a/fio-stl/431 http handle.h +++ b/fio-stl/431 http handle.h @@ -312,6 +312,11 @@ typedef struct fio_http_cookie_args_s { unsigned secure : 1; /** Limit cookie to HTTP (intended to prevent JavaScript access/hijacking).*/ unsigned http_only : 1; + /** + * Set the Partitioned (third party) cookie flag: + * https://developer.mozilla.org/en-US/docs/Web/Privacy/Partitioned_cookies + */ + unsigned partitioned : 1; } fio_http_cookie_args_s; /** @@ -1693,6 +1698,13 @@ SFUNC int fio_http_cookie_set FIO_NOOP(fio_http_s *h, "secure; ", 8); } + if (cookie.partitioned) { + fio_string_write( + &t, + ((t.buf == tmp_buf) ? FIO_STRING_ALLOC_COPY : FIO_STRING_REALLOC), + "partitioned; ", + 13); + } switch (cookie.same_site) { case FIO_HTTP_COOKIE_SAME_SITE_BROWSER_DEFAULT: /* fall through */ default: break;