forked from six-ddc/httpflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
56 lines (45 loc) · 1.34 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef util_h
#define util_h
#include <memory.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <zlib.h>
#include <stdint.h>
struct packet_info {
long ts_usc;
std::string src_addr;
std::string dst_addr;
bool is_syn;
bool is_fin;
bool is_rst;
std::string body;
uint32_t seq;
uint32_t nxtseq;
uint32_t ack;
};
extern bool is_atty;
#define USE_ANSI_COLOR
#ifdef USE_ANSI_COLOR
#define ANSI_COLOR_RED (is_atty ? "\x1b[31m" : "")
#define ANSI_COLOR_GREEN (is_atty ? "\x1b[32m" : "")
#define ANSI_COLOR_YELLOW (is_atty ? "\x1b[33m" : "")
#define ANSI_COLOR_BLUE (is_atty ? "\x1b[34m" : "")
#define ANSI_COLOR_MAGENTA (is_atty ? "\x1b[35m" : "")
#define ANSI_COLOR_CYAN (is_atty ? "\x1b[36m" : "")
#define ANSI_COLOR_RESET (is_atty ? "\x1b[0m" : "")
#else
#define ANSI_COLOR_RED ""
#define ANSI_COLOR_GREEN ""
#define ANSI_COLOR_YELLOW ""
#define ANSI_COLOR_BLUE ""
#define ANSI_COLOR_MAGENTA ""
#define ANSI_COLOR_CYAN ""
#define ANSI_COLOR_RESET ""
#endif // USE_ANSI_COLOR
bool is_plain_text(const std::string &s);
void get_join_addr(const std::string &src_addr, const std::string &dst_addr, std::string &ret);
std::string timeval2tr(const struct timeval *ts);
bool gzip_decompress(std::string &src, std::string &dst);
std::string urlencode(const std::string &s);
#endif