diff options
| author | Tristan Riehs <tristan.riehs@inria.fr> | 2026-04-26 12:22:52 +0200 |
|---|---|---|
| committer | Tristan Riehs <tristan.riehs@inria.fr> | 2026-04-26 12:30:07 +0200 |
| commit | c89eb42d58321d3e1325a684ef50a05ee3f99cfa (patch) | |
| tree | 811a2f7ad41618fa975dbe7d2212377edd599a4a /src/main.c | |
| parent | 2991c0b3560781344488680625954aa3ef0893c6 (diff) | |
Add a "input" module
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 30 |
1 files changed, 1 insertions, 29 deletions
@@ -11,6 +11,7 @@ #include <unistd.h> #include "config.h" +#include "input.h" #include "system.h" #include "utils.h" @@ -53,35 +54,6 @@ static void __sqlite3_check(int rc, sqlite3 *db, const char *file, int line, con #define sqlite3_check(RC, DB) \ __sqlite3_check(RC, DB, __FILE__, __LINE__, __func__) -/* Prompt the user for yes or no (default is yes). Before calling, a prompt - * should be printed to stdout, eventually not with an ending newline. */ -static int prompt_yes_no(void) -{ - puts(" [Y/n]"); - fflush(stdout); - size_t line_size = 3; - char *line = malloc(line_size); - int attempts = 0; - do { - getline(&line, &line_size, stdin); - char input = line[0]; - if (input == '\n'/*no input*/ || input == 'y' || input == 'Y') - return 1; - else if (input == 'n' || input == 'N') - return 0; - attempts++; - } - while(attempts < 3); - return 0; -} - -static void remove_ending_newline(char *str) -{ - int idx = strlen(str) - 1; - assert(str[idx] == '\n'); - str[idx] = '\0'; -} - /* Convert heap-allocated *STR from C string to SQL string, essentially by * adding single quotes to escape single quotes. */ static void sanitize_sql_str(char **str) |
