FreeCalypso > hg > fc-pcsc-tools
annotate libutil/pinentry.c @ 183:2545dd27ca38
fc-simtool write-imsi-sh command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 06 Mar 2021 05:24:26 +0000 |
parents | f064dbcc5f41 |
children |
rev | line source |
---|---|
3
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <sys/types.h> |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <ctype.h> |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <stdio.h> |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 encode_pin_entry(arg, dest) |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 char *arg; |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 u_char *dest; |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 { |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 unsigned n; |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 n = 0; |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 while (*arg) { |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 if (!isdigit(*arg)) { |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 fprintf(stderr, |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 "error: PIN argument contains a non-digit character\n"); |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 return(-1); |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 } |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (n >= 8) { |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 fprintf(stderr, "error: PIN argument is too long\n"); |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 return(-1); |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 } |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 *dest++ = *arg++; |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 n++; |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 for (; n < 8; n++) |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 *dest++ = 0xFF; |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 return(0); |
e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } |