diff options
author | irungentoo <irungentoo@gmail.com> | 2013-08-30 08:16:34 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-08-30 08:16:34 -0400 |
commit | 8f0bef5f20e5f9518889010387edce4d3af9b3dc (patch) | |
tree | 87e8f2e3d9fbdd223def556698ef9952b8620ce3 /testing/misc_tools.c | |
parent | 7441a234b7f6dae025819bc2717026d6462e151a (diff) |
Fixed warnings and moved hex_string_to_bin to testing/
Diffstat (limited to 'testing/misc_tools.c')
-rw-r--r-- | testing/misc_tools.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/testing/misc_tools.c b/testing/misc_tools.c new file mode 100644 index 00000000..6e775867 --- /dev/null +++ b/testing/misc_tools.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* misc_tools.c | ||
2 | * | ||
3 | * Miscellaneous functions and data structures for doing random things. | ||
4 | * | ||
5 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
6 | * | ||
7 | * This file is part of Tox. | ||
8 | * | ||
9 | * Tox is free software: you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation, either version 3 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * Tox is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <string.h> | ||
25 | #include <stdlib.h> | ||
26 | #include <stdio.h> | ||
27 | |||
28 | #ifdef DEBUG | ||
29 | #include <assert.h> | ||
30 | #endif // DEBUG | ||
31 | |||
32 | /* TODO: rewrite */ | ||
33 | unsigned char *hex_string_to_bin(char hex_string[]) | ||
34 | { | ||
35 | size_t len = strlen(hex_string); | ||
36 | unsigned char *val = malloc(len); | ||
37 | char *pos = hex_string; | ||
38 | int i; | ||
39 | |||
40 | for (i = 0; i < len; ++i, pos += 2) | ||
41 | sscanf(pos, "%2hhx", &val[i]); | ||
42 | |||
43 | return val; | ||
44 | } | ||