char yes_no_prompt(const char *prompt, ...) { int c = 0, ret = 0; va_list ap; sigint_allow(); do { if (c == '\n' || !c) { va_start(ap, prompt); vprintf(prompt, ap); va_end(ap); } if ((c = getchar()) == EOF) { ret = 'n'; break; } c = tolower(c); if ((c == 'y') || (c == 'n')) ret = c; } while (!ret || c != '\n'); sigint_restore(); if (c != '\n') printf("\n"); return ret; }
/* we only use sighandler here because the registers are not important */ static void sigint_handler_sighandler (int signum) { g_print ("Caught interrupt -- "); sigint_restore (); /* we set a flag that is checked by the mainloop, we cannot do much in the * interrupt handler (no mutex or other blocking stuff) */ caught_intr = TRUE; }
static void sigint_handler_sighandler (G_GNUC_UNUSED int signum) { sigint_received++; sigint_restore (); }