Skip to content

Commit 6c1247f

Browse files
committed
Code format
- Update clang-format script and format code
1 parent d6c82d4 commit 6c1247f

16 files changed

+120
-90
lines changed

fmt.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
clang-format-4.0 \
3+
clang-format \
44
-style=file \
55
-i \
66
src/*.cpp \

src/dns.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ void fill_in_visible_char_map_rfc1035()
4747
|| (i >= 'A' && i <= 'Z')
4848
|| (i >= '0' && i <= '9')
4949
|| (i == '-' || i == '_')) {
50-
visible_char_map[i] = i;
51-
} else { // espaping needed
50+
visible_char_map[i] = i;
51+
} else { // espaping needed
5252
visible_char_map[i] = 0;
5353
}
5454
}

src/dns.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class Parse_dns : public Packet_handler {
461461

462462
Parse_dns(bool escape_dnsnames);
463463

464-
virtual void on_table_created(Table* table, const std::vector<int>& columns);
464+
virtual void on_table_created(Table* table, const std::vector<int>& columns);
465465
virtual Packet::ParseResult parse(Packet& packet, const std::vector<int>& columns, Row& destination_row, bool sample);
466466

467467
void add_packet_columns();

src/icmp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Parse_icmp : public Packet_handler {
5050

5151
Parse_icmp();
5252

53-
virtual void on_table_created(Table* table, const std::vector<int>& columns);
53+
virtual void on_table_created(Table* table, const std::vector<int>& columns);
5454
virtual Packet::ParseResult parse(Packet& packet, const std::vector<int>& columns, Row& destination_row, bool sample);
5555

5656
void add_packet_columns();

src/output.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@ class Output {
7676
if (c == '\\') {
7777
m_buffer[m_len++] = '\\';
7878
c = '\\';
79-
}
80-
else if (c == '"') {
79+
} else if (c == '"') {
8180
m_buffer[m_len++] = '\\';
82-
}
83-
else if (c < 0x20) {
81+
} else if (c < 0x20) {
8482
m_buffer[m_len++] = '\\';
8583
m_buffer[m_len++] = 'u';
8684
m_buffer[m_len++] = '0';
@@ -199,7 +197,7 @@ class Output {
199197
if (i == longest_p) {
200198
if (i == 0)
201199
m_buffer[m_len++] = ':';
202-
m_buffer[m_len++] = ':';
200+
m_buffer[m_len++] = ':';
203201
}
204202
} else {
205203
add_hex_ushort(digs[i]);
@@ -357,7 +355,7 @@ class Str_conv {
357355
if (i == longest_p) {
358356
if (i == 0)
359357
m_buffer[m_len++] = ':';
360-
m_buffer[m_len++] = ':';
358+
m_buffer[m_len++] = ':';
361359
}
362360
} else {
363361
add_hex_ushort(digs[i]);

src/packet_handler.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Str_conv converter;
4040
class Fragments {
4141
private:
4242
Fragments& operator=(const Fragments& other);
43-
Fragments(Fragments &&other) noexcept;
44-
Fragments const & operator=(Fragments &&other);
43+
Fragments(Fragments&& other) noexcept;
44+
Fragments const& operator=(Fragments&& other);
4545

4646
public:
4747
class Range {
@@ -85,7 +85,7 @@ class Fragments {
8585
m_frags++;
8686
if (head.fragments == 0)
8787
m_complete = head.offset + len;
88-
bool complete = add_range(head.offset, head.offset + len);
88+
bool complete = add_range(head.offset, head.offset + len);
8989
memcpy((void*)&m_buffer[head.offset], data, len);
9090
if (complete) {
9191
m_complete = head.offset + len;

src/packet_handler.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class IP_header {
100100
memset(&dst_ip, 0, sizeof(dst_ip));
101101
}
102102

103-
void reset();
104-
int decode(unsigned char* data, int ether_type, int id);
103+
void reset();
104+
int decode(unsigned char* data, int ether_type, int id);
105105
unsigned int s;
106106
unsigned int us;
107107
unsigned short ethertype;
@@ -176,9 +176,9 @@ class Packet {
176176
}
177177

178178
ParseResult parse(Packet_handler* handler, const std::vector<int>& columns, Row& destination_row, bool sample);
179-
bool parse_ethernet();
180-
bool parse_ip(unsigned char* data, int len, int ether_type);
181-
bool parse_transport(unsigned char* data, int len);
179+
bool parse_ethernet();
180+
bool parse_ip(unsigned char* data, int len, int ether_type);
181+
bool parse_transport(unsigned char* data, int len);
182182

183183
IP_header m_ip_header;
184184
unsigned char* m_data;
@@ -209,7 +209,7 @@ class Packet_handler {
209209
Table* create_table(const std::vector<int>& columns);
210210

211211
// for actual packet handlers to fill in
212-
virtual void on_table_created(Table* table, const std::vector<int>& columns) = 0;
212+
virtual void on_table_created(Table* table, const std::vector<int>& columns) = 0;
213213
virtual Packet::ParseResult parse(Packet& packet, const std::vector<int>& columns, Row& destination_row, bool sample) = 0;
214214

215215
const char* table_name;

src/packetq.cpp

+32-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,38 @@ int main(int argc, char* argv[])
160160

161161
std::string webroot = "", pcaproot = "";
162162
std::string queries[NUM_QUERIES] = {
163-
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
163+
"",
164+
"",
165+
"",
166+
"",
167+
"",
168+
"",
169+
"",
170+
"",
171+
"",
172+
"",
173+
"",
174+
"",
175+
"",
176+
"",
177+
"",
178+
"",
179+
"",
180+
"",
181+
"",
182+
"",
183+
"",
184+
"",
185+
"",
186+
"",
187+
"",
188+
"",
189+
"",
190+
"",
191+
"",
192+
"",
193+
"",
194+
"",
164195
};
165196
int qcount = 0;
166197

src/pcap.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ namespace packetq {
3434
class Pcap_file {
3535
private:
3636
Pcap_file& operator=(const Pcap_file& other);
37-
Pcap_file(Pcap_file &&other) noexcept;
38-
Pcap_file const & operator=(Pcap_file &&other);
37+
Pcap_file(Pcap_file&& other) noexcept;
38+
Pcap_file const& operator=(Pcap_file&& other);
3939

4040
public:
4141
static const bool TAKE_OVER_FP = true;

src/refcountstring.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct RefCountString {
7373
{
7474
int length = to - from;
7575
if (length < 0)
76-
length = 0;
76+
length = 0;
7777
RefCountString* str = RefCountString::allocate(length + 1);
7878
std::memcpy(str->data, data + from, length);
7979
str->data[length - 1 + 1] = '\0';
@@ -84,8 +84,8 @@ struct RefCountString {
8484
class RefCountStringHandle {
8585
private:
8686
RefCountStringHandle& operator=(const RefCountStringHandle& other);
87-
RefCountStringHandle(RefCountStringHandle &&other) noexcept;
88-
RefCountStringHandle const & operator=(RefCountStringHandle &&other);
87+
RefCountStringHandle(RefCountStringHandle&& other) noexcept;
88+
RefCountStringHandle const& operator=(RefCountStringHandle&& other);
8989

9090
public:
9191
RefCountStringHandle()

src/segzip.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class Buffer {
4646
class Zip {
4747
private:
4848
Zip& operator=(const Zip& other);
49-
Zip(Zip &&other) noexcept;
50-
Zip const & operator=(Zip &&other);
49+
Zip(Zip&& other) noexcept;
50+
Zip const& operator=(Zip&& other);
5151

5252
public:
5353
Zip()

src/server.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ namespace httpd {
114114
public:
115115
class Buffer {
116116
private:
117-
Buffer& operator=(const Buffer& other);
118-
Buffer const & operator=(Buffer &&other);
117+
Buffer& operator=(const Buffer& other);
118+
Buffer const& operator=(Buffer&& other);
119119

120120
public:
121121
Buffer(const unsigned char* buf, int len)
@@ -125,11 +125,11 @@ namespace httpd {
125125
m_len = len;
126126
m_pos = 0;
127127
}
128-
Buffer(Buffer &&other) noexcept
128+
Buffer(Buffer&& other) noexcept
129129
{
130-
m_buf = other.m_buf;
131-
m_len = other.m_len;
132-
m_pos = other.m_pos;
130+
m_buf = other.m_buf;
131+
m_len = other.m_len;
132+
m_pos = other.m_pos;
133133
other.m_buf = 0;
134134
other.m_len = 0;
135135
other.m_pos = 0;
@@ -196,8 +196,8 @@ namespace httpd {
196196
class Socket {
197197
private:
198198
Socket& operator=(const Socket& other);
199-
Socket(Socket &&other) noexcept;
200-
Socket const & operator=(Socket &&other);
199+
Socket(Socket&& other) noexcept;
200+
Socket const& operator=(Socket&& other);
201201

202202
public:
203203
Socket(int s, bool serv)
@@ -539,7 +539,7 @@ namespace httpd {
539539
n = c - 'a' + 10;
540540
if (c >= 'A' && c <= 'F')
541541
n = c - 'A' + 10;
542-
code = (code << 4) | n;
542+
code = (code << 4) | n;
543543
percent_state--;
544544
if (!percent_state) {
545545
dst += char(code);
@@ -564,8 +564,8 @@ namespace httpd {
564564
return m_path;
565565
}
566566

567-
std::string m_full;
568-
std::string m_path;
567+
std::string m_full;
568+
std::string m_path;
569569
std::map<std::string, std::string> m_params;
570570
std::map<std::string, int> m_counts;
571571
};
@@ -739,7 +739,7 @@ namespace httpd {
739739
void* ptr = &((struct sockaddr_in*)res->ai_addr)->sin_addr;
740740
if (res->ai_family == AF_INET6)
741741
ptr = &((struct sockaddr_in6*)res->ai_addr)->sin6_addr;
742-
tmp[0] = 0;
742+
tmp[0] = 0;
743743
inet_ntop(res->ai_family, ptr, tmp, sizeof(tmp));
744744
printf("%s\"%s\"", sep, tmp);
745745
sep = line;
@@ -863,8 +863,8 @@ namespace httpd {
863863
class Http_socket : public Socket {
864864
private:
865865
Http_socket& operator=(const Http_socket& other);
866-
Http_socket(Http_socket &&other) noexcept;
867-
Http_socket const & operator=(Http_socket &&other);
866+
Http_socket(Http_socket&& other) noexcept;
867+
Http_socket const& operator=(Http_socket&& other);
868868

869869
public:
870870
enum State {

src/sql.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,9 @@ void printrep(int n, char c)
585585
return;
586586
char buf[3000];
587587
int i;
588-
for (i = 0; i < n; i++)
588+
for (i = 0; i < n; i++)
589589
buf[i] = c;
590-
buf[i] = 0;
590+
buf[i] = 0;
591591
printf("%s", buf);
592592
}
593593

@@ -814,10 +814,10 @@ void Table::csv(bool format)
814814
int cols = (int)m_cols.size();
815815
std::vector<int> col_len(cols);
816816

817-
for (int i = 0; i < cols; i++)
817+
for (int i = 0; i < cols; i++)
818818
col_len[i] = 0;
819-
int max = 0;
820-
char* tmp = 0;
819+
int max = 0;
820+
char* tmp = 0;
821821
if (format) {
822822
for (std::list<Row*>::iterator it = m_rows.begin(); it != m_rows.end(); it++) {
823823
Row* r = *it;
@@ -872,7 +872,7 @@ void Table::csv(bool format)
872872
tmp = new char[max + 1];
873873
for (int i = 0; i < max; i++)
874874
tmp[i] = 32;
875-
tmp[max] = 0;
875+
tmp[max] = 0;
876876
}
877877

878878
for (int i = 0; i < cols; i++) {
@@ -1774,8 +1774,8 @@ void Query::parse()
17741774

17751775
// return column and index in tables, or 0 for column if column isn't found
17761776
std::pair<Column*, int> lookup_column_in_tables(const std::vector<Table*>& tables,
1777-
const std::vector<int>& search_order,
1778-
const char* name)
1777+
const std::vector<int>& search_order,
1778+
const char* name)
17791779
{
17801780
if (strcmp(name, "*") == 0)
17811781
return std::pair<Column*, int>((Column*)0, 0);
@@ -1868,7 +1868,7 @@ OP* OP::compile(const std::vector<Table*>& tables, const std::vector<int>& searc
18681868
m_t = m_param[1]->m_t;
18691869
if (m_param[2]->m_t > m_t)
18701870
m_t = m_param[2]->m_t;
1871-
ret = new If_func(*this);
1871+
ret = new If_func(*this);
18721872
} else if (cmpi(get_token(), "name") && m_param[1]) {
18731873
m_t = Coltype::_text;
18741874
ret = new Name_func(*this);
@@ -2420,9 +2420,9 @@ bool DB::query(const char* q)
24202420

24212421
Table* DB::get_table(const char* i_name)
24222422
{
2423-
std::string name = lower(i_name);
2424-
Table* t = 0;
2425-
std::map<std::string, Table*>::iterator it = m_tables.find(name);
2423+
std::string name = lower(i_name);
2424+
Table* t = 0;
2425+
std::map<std::string, Table*>::iterator it = m_tables.find(name);
24262426
if (it != m_tables.end())
24272427
t = it->second;
24282428

0 commit comments

Comments
 (0)