diff options
Diffstat (limited to 'src/include/gnunet_util_lib.h')
-rw-r--r-- | src/include/gnunet_util_lib.h | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h index cc4f3a01e..ee850bc3c 100644 --- a/src/include/gnunet_util_lib.h +++ b/src/include/gnunet_util_lib.h | |||
@@ -30,6 +30,10 @@ | |||
30 | #ifndef GNUNET_UTIL_LIB_H | 30 | #ifndef GNUNET_UTIL_LIB_H |
31 | #define GNUNET_UTIL_LIB_H | 31 | #define GNUNET_UTIL_LIB_H |
32 | 32 | ||
33 | #define __GNUNET_UTIL_LIB_H_INSIDE__ | ||
34 | |||
35 | #include <sys/socket.h> | ||
36 | |||
33 | #ifdef __cplusplus | 37 | #ifdef __cplusplus |
34 | extern "C" | 38 | extern "C" |
35 | { | 39 | { |
@@ -59,9 +63,10 @@ extern "C" | |||
59 | * this service available to anyone but yourself. | 63 | * this service available to anyone but yourself. |
60 | */ | 64 | */ |
61 | #define GNUNET_AGPL_URL "https://git.gnunet.org/gnunet.git/tag/?h=v" \ | 65 | #define GNUNET_AGPL_URL "https://git.gnunet.org/gnunet.git/tag/?h=v" \ |
62 | PACKAGE_VERSION | 66 | GNUNET_VERSION |
63 | |||
64 | 67 | ||
68 | #include "gnunet_config.h" | ||
69 | #include "gnunet_common.h" | ||
65 | #include "gnunet_crypto_lib.h" | 70 | #include "gnunet_crypto_lib.h" |
66 | #include "gnunet_bandwidth_lib.h" | 71 | #include "gnunet_bandwidth_lib.h" |
67 | #include "gnunet_bio_lib.h" | 72 | #include "gnunet_bio_lib.h" |
@@ -72,6 +77,7 @@ extern "C" | |||
72 | #include "gnunet_helper_lib.h" | 77 | #include "gnunet_helper_lib.h" |
73 | #include "gnunet_mst_lib.h" | 78 | #include "gnunet_mst_lib.h" |
74 | #include "gnunet_mq_lib.h" | 79 | #include "gnunet_mq_lib.h" |
80 | #include "gnunet_nt_lib.h" | ||
75 | #include "gnunet_nc_lib.h" | 81 | #include "gnunet_nc_lib.h" |
76 | #include "gnunet_op_lib.h" | 82 | #include "gnunet_op_lib.h" |
77 | #include "gnunet_os_lib.h" | 83 | #include "gnunet_os_lib.h" |
@@ -86,6 +92,53 @@ extern "C" | |||
86 | #include "gnunet_dnsstub_lib.h" | 92 | #include "gnunet_dnsstub_lib.h" |
87 | #include "gnunet_dnsparser_lib.h" | 93 | #include "gnunet_dnsparser_lib.h" |
88 | #include "gnunet_child_management_lib.h" | 94 | #include "gnunet_child_management_lib.h" |
95 | #include "gnunet_error_codes.h" | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Stringify operator. | ||
100 | * | ||
101 | * @param a some expression to stringify. Must NOT be a macro. | ||
102 | * @return same expression as a constant string. | ||
103 | */ | ||
104 | #define GNUNET_S(a) #a | ||
105 | |||
106 | /** | ||
107 | * Try to compress the given block of data using libz. Only returns | ||
108 | * the compressed block if compression worked and the new block is | ||
109 | * actually smaller. Decompress using #GNUNET_decompress(). | ||
110 | * | ||
111 | * @param data block to compress; if compression | ||
112 | * resulted in a smaller block, the first | ||
113 | * bytes of data are updated to the compressed | ||
114 | * data | ||
115 | * @param old_size number of bytes in data | ||
116 | * @param[out] result set to the compressed data, if compression worked | ||
117 | * @param[out] new_size set to size of result, if compression worked | ||
118 | * @return #GNUNET_YES if compression reduce the size, | ||
119 | * #GNUNET_NO if compression did not help | ||
120 | */ | ||
121 | int | ||
122 | GNUNET_try_compression (const char *data, | ||
123 | size_t old_size, | ||
124 | char **result, | ||
125 | size_t *new_size); | ||
126 | |||
127 | /** | ||
128 | * Decompress input, return the decompressed data as output. Dual to | ||
129 | * #GNUNET_try_compression(). Caller must set @a output_size to the | ||
130 | * number of bytes that were originally compressed. | ||
131 | * | ||
132 | * @param input compressed data | ||
133 | * @param input_size number of bytes in input | ||
134 | * @param output_size expected size of the output | ||
135 | * @return NULL on error, buffer of @a output_size decompressed bytes otherwise | ||
136 | */ | ||
137 | char * | ||
138 | GNUNET_decompress (const char *input, | ||
139 | size_t input_size, | ||
140 | size_t output_size); | ||
141 | |||
89 | 142 | ||
90 | #if 0 /* keep Emacsens' auto-indent happy */ | 143 | #if 0 /* keep Emacsens' auto-indent happy */ |
91 | { | 144 | { |
@@ -94,4 +147,6 @@ extern "C" | |||
94 | } | 147 | } |
95 | #endif | 148 | #endif |
96 | 149 | ||
150 | #undef __GNUNET_UTIL_LIB_H_INSIDE__ | ||
151 | |||
97 | #endif | 152 | #endif |