Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
/* 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;
}
Ejemplo n.º 3
0
static void
sigint_handler_sighandler (G_GNUC_UNUSED int signum)
{
  sigint_received++;
  sigint_restore ();
}