Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions ds4_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -6819,15 +6819,24 @@ static void agent_worker_free(agent_worker *w) {
}

static bool agent_prompt_yes_no(const char *prompt) {
char buf[32];
for (;;) {
printf("%s", prompt);
fflush(stdout);
if (!fgets(buf, sizeof(buf), stdin)) return false;
char *p = buf;
while (*p == ' ' || *p == '\t') p++;
if (*p == 'y' || *p == 'Y') return true;
if (*p == 'n' || *p == 'N') return false;
int answer = 0;
for (;;) {
int c = getchar();
if (c == EOF || c == 4) {
printf("\n");
return false;
}
if (c == '\n' || c == '\r') {
printf("\n");
if (answer == 'y' || answer == 'Y') return true;
if (answer == 'n' || answer == 'N' || !answer) return false;
break;
}
if (!answer && c != ' ' && c != '\t') answer = c;
}
}
}

Expand Down