new: working on the gen command

This commit is contained in:
ngn
2024-05-02 22:53:52 +03:00
parent 0d00678c30
commit e29c3ce419
11 changed files with 380 additions and 113 deletions

View File

@ -138,31 +138,31 @@ void input(const char *msg, ...) {
va_end(args);
}
bool yesno(const char *msg){
if(env_mc_yes())
bool yesno(const char *msg) {
if (env_mc_yes())
return true;
char *yes[] = {_("y"), _("Y")};
char *no[] = {_("n"), _("N")};
char question[strlen(msg)+12], c;
char question[strlen(msg) + 12], c;
sprintf(question, _("%s [y/N] "), msg);
while(true){
while (true) {
input(question);
int c = getchar();
if(c == '\n')
if (c == '\n')
return false;
getchar();
for(int i = 0; i < sizeof(yes)/sizeof(char*); i++){
if(yes[i][0] == c)
for (int i = 0; i < sizeof(yes) / sizeof(char *); i++) {
if (yes[i][0] == c)
return true;
}
for(int i = 0; i < sizeof(no)/sizeof(char*); i++){
if(no[i][0] == c)
for (int i = 0; i < sizeof(no) / sizeof(char *); i++) {
if (no[i][0] == c)
return false;
}