From 365015c2c7947456b249b1c13ea1a1f6b40369e6 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Sat, 1 Jun 2024 02:45:40 +0900 Subject: Add a couple comments --- src/calculer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/calculer.c b/src/calculer.c index 6b279ec..8d13052 100644 --- a/src/calculer.c +++ b/src/calculer.c @@ -41,12 +41,15 @@ calculer_rand(void) return lower + rand()%(upper-lower); } +/* Compute the number of milliseconds TP contains. */ static intptr_t tp_ms(struct timespec const *tp) { return tp->tv_sec*1000 + tp->tv_nsec/1000000; } +/* Called just before prompting the user. The returned pointer will be given + back as a parameter of measure_after. */ static void * measure_before(void) { @@ -55,6 +58,7 @@ measure_before(void) return (void *)tp_ms(&tp); } +/* Called just after the user prompt has been read and checked. */ int measure_after(void *data, int correct) { @@ -111,6 +115,7 @@ main(int argc, char *argv[]) srand(time(NULL)); + /* Store the prefix "YYYY-MM-DD" in LOGBUF. */ time_t now = time(NULL); struct tm *tm = localtime(&now); size_t bytes_written = strftime(logbuf, sizeof(logbuf), "%F\t", tm); -- cgit v1.2.3