… | |
… | |
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 | /*****************************************************************************/ |
|
|
135 | |
|
|
136 | void rand_fill (void *data, int len); |
|
|
137 | |
|
|
138 | template<class T> |
|
|
139 | inline void rand_fill (T &t) |
|
|
140 | { |
|
|
141 | rand_fill (&t, sizeof (T)); |
|
|
142 | } |
133 | |
143 | |
134 | /*****************************************************************************/ |
144 | /*****************************************************************************/ |
135 | |
145 | |
136 | // run work_cb in another thread, call done_cb in main thread when finished |
146 | // 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. |
147 | // only one work_cb will execute at any one time. |