summaryrefslogtreecommitdiffstats
path: root/include/utils.h
diff options
context:
space:
mode:
authorFilip Wandzio <contact@philw.dev>2026-03-01 17:45:00 +0100
committerFilip Wandzio <contact@philw.dev>2026-03-01 17:45:00 +0100
commit9e9c1b21569faeabd33716e4153a881e2eed7134 (patch)
treef3a7ad21aed4b1c4f51c3ee308ffef88430deafc /include/utils.h
parent57b077a4788b7fb5ed6add1df4ba3f15c9e6349b (diff)
downloadysnp-9e9c1b21569faeabd33716e4153a881e2eed7134.tar.gz
ysnp-9e9c1b21569faeabd33716e4153a881e2eed7134.zip
Separate quiz logic from main function fo dedicated moduleHEADmaster
Signed-off-by: Filip Wandzio <contact@philw.dev>
Diffstat (limited to 'include/utils.h')
-rw-r--r--include/utils.h30
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 */
4void print_line(void); 7void print_line(void);
5void wait_enter(const char *msg); 8
6char ask_yes_no(const char *msg); 9/** Pause until the user presses ENTER */
7void now_str(char *buf, size_t size); 10void wait_for_enter(const char* prompt);
8size_t rand_index(size_t max); 11
12/** Ask a yes/no question and return boolean */
13bool 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 */
21void 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 */
30size_t get_random_question_index(unsigned int* seed, size_t total_questions);