summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/CMakeLists.txt3
-rw-r--r--core/misc_tools.c43
-rw-r--r--core/misc_tools.h29
3 files changed, 74 insertions, 1 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 6ddd5b9b..7e5c119a 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -12,6 +12,7 @@ set(core_sources
12 net_crypto.c 12 net_crypto.c
13 friend_requests.c 13 friend_requests.c
14 LAN_discovery.c 14 LAN_discovery.c
15 Messenger.c) 15 Messenger.c
16 misc_tools.c)
16 17
17add_library(core ${core_sources}) 18add_library(core ${core_sources})
diff --git a/core/misc_tools.c b/core/misc_tools.c
new file mode 100644
index 00000000..34d64bf4
--- /dev/null
+++ b/core/misc_tools.c
@@ -0,0 +1,43 @@
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 "misc_tools.h"
25
26#include <string.h>
27#include <stdlib.h>
28#include <stdio.h> //for sscanf
29
30//TODO: rewrite
31unsigned char * hex_string_to_bin(char hex_string[])
32{
33 size_t len = strlen(hex_string);
34 unsigned char *val = malloc(len);
35 char *pos = hex_string;
36 int i=0;
37 while(i < len) {
38 sscanf(pos,"%2hhx",&val[i]);
39 pos+=2;
40 i++;
41 }
42 return val;
43} \ No newline at end of file
diff --git a/core/misc_tools.h b/core/misc_tools.h
new file mode 100644
index 00000000..29b37ce5
--- /dev/null
+++ b/core/misc_tools.h
@@ -0,0 +1,29 @@
1/* misc_tools.h
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#ifndef MISC_TOOLS_H
25#define MISC_TOOLS_H
26
27unsigned char * hex_string_to_bin(char hex_string[]);
28
29#endif // MISC_TOOLS_H \ No newline at end of file