diff options
Diffstat (limited to 'meta/recipes-devtools/opkg/opkg/0001-string_util-New-file-with-bin_to_hex-function.patch')
-rw-r--r-- | meta/recipes-devtools/opkg/opkg/0001-string_util-New-file-with-bin_to_hex-function.patch | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/meta/recipes-devtools/opkg/opkg/0001-string_util-New-file-with-bin_to_hex-function.patch b/meta/recipes-devtools/opkg/opkg/0001-string_util-New-file-with-bin_to_hex-function.patch new file mode 100644 index 0000000000..fb3ac462df --- /dev/null +++ b/meta/recipes-devtools/opkg/opkg/0001-string_util-New-file-with-bin_to_hex-function.patch | |||
@@ -0,0 +1,122 @@ | |||
1 | From 646b80024567a6245c598be3374653fa1fa09a12 Mon Sep 17 00:00:00 2001 | ||
2 | From: Paul Barker <paul@paulbarker.me.uk> | ||
3 | Date: Sat, 7 Nov 2015 10:23:49 +0000 | ||
4 | Subject: [PATCH 1/4] string_util: New file with bin_to_hex function | ||
5 | |||
6 | This function does very simple conversion from binary data to a hex string. | ||
7 | |||
8 | Signed-off-by: Paul Barker <paul@paulbarker.me.uk> | ||
9 | Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com> | ||
10 | |||
11 | Upstream-Status: Accepted | ||
12 | --- | ||
13 | libopkg/Makefile.am | 4 ++-- | ||
14 | libopkg/string_util.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | ||
15 | libopkg/string_util.h | 24 ++++++++++++++++++++++++ | ||
16 | 3 files changed, 68 insertions(+), 2 deletions(-) | ||
17 | create mode 100644 libopkg/string_util.c | ||
18 | create mode 100644 libopkg/string_util.h | ||
19 | |||
20 | diff --git a/libopkg/Makefile.am b/libopkg/Makefile.am | ||
21 | index ee3fbee..3e62c24 100644 | ||
22 | --- a/libopkg/Makefile.am | ||
23 | +++ b/libopkg/Makefile.am | ||
24 | @@ -13,7 +13,7 @@ opkg_headers = active_list.h cksum_list.h conffile.h conffile_list.h \ | ||
25 | pkg_depends.h pkg_dest.h pkg_dest_list.h pkg_extract.h pkg_hash.h \ | ||
26 | pkg_parse.h pkg_src.h pkg_src_list.h pkg_vec.h release.h \ | ||
27 | release_parse.h sha256.h sprintf_alloc.h str_list.h void_list.h \ | ||
28 | - xregex.h xsystem.h xfuncs.h opkg_verify.h | ||
29 | + xregex.h xsystem.h xfuncs.h opkg_verify.h string_util.h | ||
30 | |||
31 | opkg_sources = opkg_cmd.c opkg_configure.c opkg_download.c \ | ||
32 | opkg_install.c opkg_remove.c opkg_conf.c release.c \ | ||
33 | @@ -23,7 +23,7 @@ opkg_sources = opkg_cmd.c opkg_configure.c opkg_download.c \ | ||
34 | pkg_src.c pkg_src_list.c str_list.c void_list.c active_list.c \ | ||
35 | file_util.c opkg_message.c md5.c parse_util.c cksum_list.c \ | ||
36 | sprintf_alloc.c xregex.c xsystem.c xfuncs.c opkg_archive.c \ | ||
37 | - opkg_verify.c | ||
38 | + opkg_verify.c string_util.c | ||
39 | |||
40 | if HAVE_CURL | ||
41 | opkg_sources += opkg_download_curl.c | ||
42 | diff --git a/libopkg/string_util.c b/libopkg/string_util.c | ||
43 | new file mode 100644 | ||
44 | index 0000000..822cab6 | ||
45 | --- /dev/null | ||
46 | +++ b/libopkg/string_util.c | ||
47 | @@ -0,0 +1,42 @@ | ||
48 | +/* vi: set expandtab sw=4 sts=4: */ | ||
49 | +/* string_util.c - convenience routines for common string operations | ||
50 | + | ||
51 | + Copyright (C) 2015 Paul Barker | ||
52 | + | ||
53 | + This program is free software; you can redistribute it and/or | ||
54 | + modify it under the terms of the GNU General Public License as | ||
55 | + published by the Free Software Foundation; either version 2, or (at | ||
56 | + your option) any later version. | ||
57 | + | ||
58 | + This program is distributed in the hope that it will be useful, but | ||
59 | + WITHOUT ANY WARRANTY; without even the implied warranty of | ||
60 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
61 | + General Public License for more details. | ||
62 | +*/ | ||
63 | + | ||
64 | +#include "config.h" | ||
65 | + | ||
66 | +#include "string_util.h" | ||
67 | +#include "xfuncs.h" | ||
68 | + | ||
69 | +char *bin_to_hex(const void *bin_data, size_t len) | ||
70 | +{ | ||
71 | + const unsigned char *src = (const unsigned char *)bin_data; | ||
72 | + char *buf = xmalloc(2 * len + 1); | ||
73 | + int i; | ||
74 | + | ||
75 | + static const unsigned char bin2hex[16] = { | ||
76 | + '0', '1', '2', '3', | ||
77 | + '4', '5', '6', '7', | ||
78 | + '8', '9', 'a', 'b', | ||
79 | + 'c', 'd', 'e', 'f' | ||
80 | + }; | ||
81 | + | ||
82 | + for (i = 0; i < len; i++) { | ||
83 | + buf[i * 2] = bin2hex[src[i] >> 4]; | ||
84 | + buf[i * 2 + 1] = bin2hex[src[i] & 0xf]; | ||
85 | + } | ||
86 | + | ||
87 | + buf[len * 2] = '\0'; | ||
88 | + return buf; | ||
89 | +} | ||
90 | diff --git a/libopkg/string_util.h b/libopkg/string_util.h | ||
91 | new file mode 100644 | ||
92 | index 0000000..a920e2a | ||
93 | --- /dev/null | ||
94 | +++ b/libopkg/string_util.h | ||
95 | @@ -0,0 +1,24 @@ | ||
96 | +/* vi: set expandtab sw=4 sts=4: */ | ||
97 | +/* string_util.h - convenience routines for common file operations | ||
98 | + | ||
99 | + Copyright (C) 2015 Paul Barker | ||
100 | + | ||
101 | + This program is free software; you can redistribute it and/or | ||
102 | + modify it under the terms of the GNU General Public License as | ||
103 | + published by the Free Software Foundation; either version 2, or (at | ||
104 | + your option) any later version. | ||
105 | + | ||
106 | + This program is distributed in the hope that it will be useful, but | ||
107 | + WITHOUT ANY WARRANTY; without even the implied warranty of | ||
108 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
109 | + General Public License for more details. | ||
110 | +*/ | ||
111 | + | ||
112 | +#ifndef STRING_UTIL_H | ||
113 | +#define STRING_UTIL_H | ||
114 | + | ||
115 | +#include <stddef.h> | ||
116 | + | ||
117 | +char *bin_to_hex(const void *bin_data, size_t len); | ||
118 | + | ||
119 | +#endif /* STRING_UTIL_H */ | ||
120 | -- | ||
121 | 1.9.1 | ||
122 | |||