| 1 |
/* |
| 2 |
* COPYRIGHT (c) International Business Machines Corp. 2022 |
| 3 |
* |
| 4 |
* This program is provided under the terms of the Common Public License, |
| 5 |
* version 1.0 (CPL-1.0). Any use, reproduction or distribution for this |
| 6 |
* software constitutes recipient's acceptance of CPL-1.0 terms which can be |
| 7 |
* found in the file LICENSE file or at |
| 8 |
* https://opensource.org/licenses/cpl1.0.php |
| 9 |
*/ |
| 10 |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
| 12 |
#include <unistd.h> |
| 13 |
|
| 14 |
#include <pin_prompt.h> |
| 15 |
#include "unittest.h" |
| 16 |
|
| 17 |
int main(int argc, char *argv[]) |
| 18 |
{ |
| 19 |
const char *pin; |
| 20 |
char *buf = NULL; |
| 21 |
|
| 22 |
switch(getopt(argc, argv, "pn")) { |
| 23 |
case 'p': |
| 24 |
pin = pin_prompt(&buf, "Enter the PIN: "); |
| 25 |
/* AIX prints an empty string instead of Linux-style (null) */ |
| 26 |
printf("pin: %s\n", pin != NULL ? pin : "(null)"); |
| 27 |
break; |
| 28 |
case 'n': |
| 29 |
pin = pin_prompt_new(&buf, "Enter new PIN: ", "Re-enter new PIN: "); |
| 30 |
printf("pin: %s\n", pin != NULL ? pin : "(null)"); |
| 31 |
break; |
| 32 |
default: |
| 33 |
break; |
| 34 |
} |
| 35 |
|
| 36 |
pin_free(&buf); |
| 37 |
return 0; |
| 38 |
} |