… | |
… | |
34 | #ifndef UTIL_H__ |
34 | #ifndef UTIL_H__ |
35 | #define UTIL_H__ |
35 | #define UTIL_H__ |
36 | |
36 | |
37 | #include <cstring> |
37 | #include <cstring> |
38 | #include <sys/types.h> |
38 | #include <sys/types.h> |
39 | |
|
|
40 | #include <openssl/rsa.h> |
|
|
41 | |
39 | |
42 | #include "gettext.h" |
40 | #include "gettext.h" |
43 | |
41 | |
44 | #include "slog.h" |
42 | #include "slog.h" |
45 | #include "ev_cpp.h" |
43 | #include "ev_cpp.h" |
… | |
… | |
125 | typedef callback<const char *()> run_script_cb; |
123 | typedef callback<const char *()> run_script_cb; |
126 | |
124 | |
127 | // run a shell script (or actually an external program). |
125 | // run a shell script (or actually an external program). |
128 | pid_t run_script (const run_script_cb &cb, bool wait); |
126 | pid_t run_script (const run_script_cb &cb, bool wait); |
129 | |
127 | |
|
|
128 | void hexdump (const char *header, void *data, int len); |
|
|
129 | |
130 | #if ENABLE_HTTP_PROXY |
130 | #if ENABLE_HTTP_PROXY |
131 | u8 *base64_encode (const u8 *data, unsigned int len); |
131 | u8 *base64_encode (const u8 *data, unsigned int len); |
132 | #endif |
132 | #endif |
|
|
133 | |
|
|
134 | /* always take more or less the same time to compare */ |
|
|
135 | bool slow_memeq (const void *a, const void *b, int len); |
|
|
136 | |
|
|
137 | /*****************************************************************************/ |
|
|
138 | |
|
|
139 | void rand_fill (void *data, int len); |
|
|
140 | |
|
|
141 | template<class T> |
|
|
142 | inline void rand_fill (T &t) |
|
|
143 | { |
|
|
144 | rand_fill (&t, sizeof (T)); |
|
|
145 | } |
133 | |
146 | |
134 | /*****************************************************************************/ |
147 | /*****************************************************************************/ |
135 | |
148 | |
136 | // run work_cb in another thread, call done_cb in main thread when finished |
149 | // run work_cb in another thread, call done_cb in main thread when finished |
137 | // only one work_cb will execute at any one time. |
150 | // only one work_cb will execute at any one time. |