|
Revision 4671, 0.8 kB
(checked in by khali, 1 year ago)
|
License fix.
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
#include <stdio.h> |
|---|
| 12 |
#include "util.h" |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
int user_ack(int def) |
|---|
| 16 |
{ |
|---|
| 17 |
char s[2]; |
|---|
| 18 |
int ret; |
|---|
| 19 |
|
|---|
| 20 |
if (!fgets(s, 2, stdin)) |
|---|
| 21 |
return 0; |
|---|
| 22 |
|
|---|
| 23 |
switch (s[0]) { |
|---|
| 24 |
case 'y': |
|---|
| 25 |
case 'Y': |
|---|
| 26 |
ret = 1; |
|---|
| 27 |
break; |
|---|
| 28 |
case 'n': |
|---|
| 29 |
case 'N': |
|---|
| 30 |
ret = 0; |
|---|
| 31 |
break; |
|---|
| 32 |
default: |
|---|
| 33 |
ret = def; |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
while (s[0] != '\n') { |
|---|
| 38 |
int c = fgetc(stdin); |
|---|
| 39 |
if (c == EOF) { |
|---|
| 40 |
ret = 0; |
|---|
| 41 |
break; |
|---|
| 42 |
} |
|---|
| 43 |
s[0] = c; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
return ret; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|