Changeset 291ec6b in OpenSC
- Timestamp:
- 06/11/11 07:33:30 (12 months ago)
- Branches:
- master, staging
- Children:
- 61855eb
- Parents:
- 4cc1ab41
- git-author:
- Peter Marschall <peter@…> (06/02/11 14:15:30)
- git-committer:
- Peter Marschall <peter@…> (06/11/11 07:33:30)
- File:
-
- 1 edited
-
src/tools/opensc-explorer.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tools/opensc-explorer.c
r4cc1ab41 r291ec6b 72 72 }; 73 73 74 static size_t hex2binary(u8 *out, size_t outlen, const char *in);75 74 76 75 /* declare functions called by user commands */ … … 1093 1092 } 1094 1093 1095 static size_t hex2binary(u8 *out, size_t outlen, const char *in)1096 {1097 size_t inlen = strlen(in), len = outlen;1098 const char *p = in;1099 int s = 0;1100 1101 out--;1102 while (inlen && (len || s)) {1103 char c = *p++;1104 inlen--;1105 if (!isxdigit(c))1106 continue;1107 if (c >= '0' && c <= '9')1108 c -= '0';1109 else if (c >= 'a' && c <= 'f')1110 c -= 'a' - 10;1111 else /* (c >= 'A' && c <= 'F') */1112 c -= 'A' - 10;1113 if (s)1114 *out <<= 4;1115 else {1116 len--;1117 *(++out) = 0;1118 }1119 s = !s;1120 *out |= (u8)c;1121 }1122 if (s) {1123 printf("Error: the number of hex digits must be even.\n");1124 return 0;1125 }1126 1127 return outlen - len;1128 }1129 1130 1094 static int do_update_binary(int argc, char **argv) 1131 1095 {
Note: See TracChangeset
for help on using the changeset viewer.
