diff options
| author | Filip Wandzio <contact@philw.dev> | 2026-03-01 17:45:00 +0100 |
|---|---|---|
| committer | Filip Wandzio <contact@philw.dev> | 2026-03-01 17:45:00 +0100 |
| commit | 9e9c1b21569faeabd33716e4153a881e2eed7134 (patch) | |
| tree | f3a7ad21aed4b1c4f51c3ee308ffef88430deafc /include/utils.h | |
| parent | 57b077a4788b7fb5ed6add1df4ba3f15c9e6349b (diff) | |
| download | ysnp-9e9c1b21569faeabd33716e4153a881e2eed7134.tar.gz ysnp-9e9c1b21569faeabd33716e4153a881e2eed7134.zip | |
Signed-off-by: Filip Wandzio <contact@philw.dev>
Diffstat (limited to 'include/utils.h')
| -rw-r--r-- | include/utils.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/include/utils.h b/include/utils.h index 74c0ca1..08895c0 100644 --- a/include/utils.h +++ b/include/utils.h | |||
| @@ -1,8 +1,30 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | |||
| 3 | #include <stdbool.h> | ||
| 2 | #include <stddef.h> | 4 | #include <stddef.h> |
| 3 | 5 | ||
| 6 | /** Print a horizontal separator line */ | ||
| 4 | void print_line(void); | 7 | void print_line(void); |
| 5 | void wait_enter(const char *msg); | 8 | |
| 6 | char ask_yes_no(const char *msg); | 9 | /** Pause until the user presses ENTER */ |
| 7 | void now_str(char *buf, size_t size); | 10 | void wait_for_enter(const char* prompt); |
| 8 | size_t rand_index(size_t max); | 11 | |
| 12 | /** Ask a yes/no question and return boolean */ | ||
| 13 | bool ask_yes_no(const char* prompt); | ||
| 14 | |||
| 15 | /** | ||
| 16 | * Get the current timestamp for recording when a question was answered | ||
| 17 | * | ||
| 18 | * @param answer_time_buffer Buffer to store the formatted timestamp | ||
| 19 | * @param buffer_capacity Size of the buffer in bytes | ||
| 20 | */ | ||
| 21 | void get_answer_timestamp(char* answer_time_buffer, size_t buffer_capacity); | ||
| 22 | |||
| 23 | /** | ||
| 24 | * Get a random question index in the quiz (thread-safe) | ||
| 25 | * | ||
| 26 | * @param seed Pointer to an unsigned int seed (per-thread) | ||
| 27 | * @param total_questions Number of questions in the current quiz session | ||
| 28 | * @return Random index in the range [0, total_questions-1] | ||
| 29 | */ | ||
| 30 | size_t get_random_question_index(unsigned int* seed, size_t total_questions); | ||
