diff options
| author | dec05eba <dec05eba@protonmail.com> | 2026-08-01 19:13:38 +0200 |
|---|---|---|
| committer | dec05eba <dec05eba@protonmail.com> | 2026-08-01 19:13:38 +0200 |
| commit | 5611e6a7a70b79496da20ffd171d636c2d3c9065 (patch) | |
| tree | 5479b59421f3c4f8e16f7dc1934c2a28f5ee09fa /include | |
| parent | c150d0e6ba0ab1f9ecd6a1c933a58050187e0c81 (diff) | |
Move string/date/array helpers from main.cpp to utils as reusable C functions
Diffstat (limited to 'include')
| -rw-r--r-- | include/utils.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/utils.h b/include/utils.h index d2c3b7d..d1a2a3c 100644 --- a/include/utils.h +++ b/include/utils.h @@ -6,6 +6,7 @@ #include "../include/defs.h" #include <stdbool.h> #include <stdint.h> +#include <stddef.h> typedef struct AVCodecContext AVCodecContext; typedef struct AVFrame AVFrame; @@ -64,4 +65,21 @@ unsigned int gl_create_texture(gsr_egl *egl, int width, int height, int internal bool get_nvidia_driver_version(int *major, int *minor); +/* Return false from the callback to stop splitting */ +typedef bool (*gsr_string_split_callback)(const char *str, size_t size, void *userdata); +void gsr_string_split(const char *str, char delimiter, gsr_string_split_callback callback, void *userdata); + +bool gsr_string_starts_with(const char *str, size_t str_size, const char *substr); +bool gsr_string_ends_with(const char *str, const char *substr); + +bool gsr_string_to_int(const char *str, size_t size, int *number); +bool gsr_string_to_int64(const char *str, size_t size, int64_t *number); + +bool gsr_array_ensure_capacity(void **array, size_t num_items, size_t *capacity_items, size_t item_size); + +/* These write a formatted local date/time into |str|, which should be at least 128 bytes in size */ +void gsr_get_date_str(char *str, size_t size); +void gsr_get_date_only_str(char *str, size_t size); +void gsr_get_time_only_str(char *str, size_t size); + #endif /* GSR_UTILS_H */ |
