FreeCalypso > hg > fc-pcsc-tools
annotate libutil/nibbles2asc.c @ 161:884b93362449
libutil: nibbles_to_ascii() function implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 26 Feb 2021 21:10:26 +0000 |
parents | |
children |
rev | line source |
---|---|
161
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements a function for turning a nibble array |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * into printable ASCII. |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 void |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 nibbles_to_ascii(nib, len, out) |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 u_char *nib; |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 unsigned len; |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 char *out; |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 unsigned n; |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 for (n = 0; n < len; n++) |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 *out++ = encode_hex_digit(*nib++); |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 *out = '\0'; |
884b93362449
libutil: nibbles_to_ascii() function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 } |