Skip to content

Commit 57dbda5

Browse files
committed
massive coding style fixes.
1 parent 3234983 commit 57dbda5

9 files changed

+228
-225
lines changed

src/ngx_http_rds_csv_filter_module.c

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
* Copyright (C) agentzh
3+
* Copyright (C) Yichun Zhang (agentzh)
44
*/
55

66

@@ -9,6 +9,7 @@
99
#endif
1010
#include "ddebug.h"
1111

12+
1213
#include "ngx_http_rds_csv_filter_module.h"
1314
#include "ngx_http_rds_csv_util.h"
1415
#include "ngx_http_rds_csv_processor.h"
@@ -33,9 +34,9 @@ static char *ngx_http_rds_csv_merge_loc_conf(ngx_conf_t *cf, void *parent,
3334
void *child);
3435
static ngx_int_t ngx_http_rds_csv_filter_init(ngx_conf_t *cf);
3536
static char *ngx_http_rds_csv_row_terminator(ngx_conf_t *cf,
36-
ngx_command_t *cmd, void *conf);
37+
ngx_command_t *cmd, void *conf);
3738
static char *ngx_http_rds_csv_field_separator(ngx_conf_t *cf,
38-
ngx_command_t *cmd, void *conf);
39+
ngx_command_t *cmd, void *conf);
3940
static char * ngx_http_rds_csv(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
4041
static void * ngx_http_rds_csv_create_main_conf(ngx_conf_t *cf);
4142

@@ -104,10 +105,10 @@ static ngx_http_module_t ngx_http_rds_csv_filter_module_ctx = {
104105
ngx_http_rds_csv_filter_init, /* postconfiguration */
105106

106107
ngx_http_rds_csv_create_main_conf, /* create main configuration */
107-
NULL, /* init main configuration */
108+
NULL, /* init main configuration */
108109

109-
NULL, /* create server configuration */
110-
NULL, /* merge server configuration */
110+
NULL, /* create server configuration */
111+
NULL, /* merge server configuration */
111112

112113
ngx_http_rds_csv_create_loc_conf, /* create location configuration */
113114
ngx_http_rds_csv_merge_loc_conf /* merge location configuration */
@@ -157,23 +158,23 @@ ngx_http_rds_csv_header_filter(ngx_http_request_t *r)
157158

158159
conf = ngx_http_get_module_loc_conf(r, ngx_http_rds_csv_filter_module);
159160

160-
if ( ! conf->enabled) {
161+
if (!conf->enabled) {
161162
return ngx_http_rds_csv_next_header_filter(r);
162163
}
163164

164165
if (ngx_http_rds_csv_test_content_type(r) != NGX_OK) {
165166
return ngx_http_rds_csv_next_header_filter(r);
166167
}
167168

168-
if (conf->content_type.len == sizeof(ngx_http_rds_csv_content_type) - 1 &&
169-
ngx_strncmp(conf->content_type.data, ngx_http_rds_csv_content_type,
170-
sizeof(ngx_http_rds_csv_content_type) - 1) == 0)
169+
if (conf->content_type.len == sizeof(ngx_http_rds_csv_content_type) - 1
170+
&& ngx_strncmp(conf->content_type.data, ngx_http_rds_csv_content_type,
171+
sizeof(ngx_http_rds_csv_content_type) - 1) == 0)
171172
{
172173
/* MIME type is text/csv, we process Content-Type
173174
* according to RFC 4180 */
174175

175-
len = sizeof(ngx_http_rds_csv_content_type) - 1 +
176-
sizeof("; header=") - 1;
176+
len = sizeof(ngx_http_rds_csv_content_type) - 1
177+
+ sizeof("; header=") - 1;
177178

178179
if (conf->field_name_header) {
179180
len += sizeof("presence") - 1;
@@ -203,9 +204,9 @@ ngx_http_rds_csv_header_filter(ngx_http_request_t *r)
203204

204205
if (p - r->headers_out.content_type.data != (ssize_t) len) {
205206
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
206-
"rds_csv: content type buffer error: %uz != %uz",
207-
(size_t) (p - r->headers_out.content_type.data),
208-
len);
207+
"rds_csv: content type buffer error: %uz != %uz",
208+
(size_t) (p - r->headers_out.content_type.data),
209+
len);
209210

210211
return NGX_ERROR;
211212
}
@@ -306,8 +307,8 @@ ngx_http_rds_csv_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
306307
break;
307308
default:
308309
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
309-
"rds_csv: invalid internal state: %d",
310-
ctx->state);
310+
"rds_csv: invalid internal state: %d",
311+
ctx->state);
311312

312313
rc = NGX_ERROR;
313314

@@ -319,7 +320,7 @@ ngx_http_rds_csv_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
319320
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
320321
ctx->state = state_done;
321322

322-
if (! ctx->header_sent) {
323+
if (!ctx->header_sent) {
323324
ctx->header_sent = 1;
324325

325326
if (rc == NGX_ERROR) {
@@ -411,24 +412,24 @@ ngx_http_rds_csv_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
411412
ngx_conf_merge_value(conf->field_name_header, prev->field_name_header, 1);
412413

413414
ngx_conf_merge_uint_value(conf->field_sep, prev->field_sep,
414-
(ngx_uint_t) ',');
415+
(ngx_uint_t) ',');
415416

416417
ngx_conf_merge_str_value(conf->row_term, prev->row_term,
417-
ngx_http_rds_csv_row_term);
418+
ngx_http_rds_csv_row_term);
418419

419420
ngx_conf_merge_str_value(conf->content_type, prev->content_type,
420-
ngx_http_rds_csv_content_type);
421+
ngx_http_rds_csv_content_type);
421422

422423
ngx_conf_merge_size_value(conf->buf_size, prev->buf_size,
423-
(size_t) ngx_pagesize);
424+
(size_t) ngx_pagesize);
424425

425426
return NGX_CONF_OK;
426427
}
427428

428429

429430
static char *
430431
ngx_http_rds_csv_row_terminator(ngx_conf_t *cf, ngx_command_t *cmd,
431-
void *conf)
432+
void *conf)
432433
{
433434
ngx_http_rds_csv_loc_conf_t *rlcf = conf;
434435
ngx_str_t *value;
@@ -446,8 +447,8 @@ ngx_http_rds_csv_row_terminator(ngx_conf_t *cf, ngx_command_t *cmd,
446447
return "takes empty string value";
447448
}
448449

449-
if ((term->len == 1 && term->data[0] == '\n') ||
450-
(term->len == 2 && term->data[0] == '\r' && term->data[1] == '\n'))
450+
if ((term->len == 1 && term->data[0] == '\n')
451+
|| (term->len == 2 && term->data[0] == '\r' && term->data[1] == '\n'))
451452
{
452453
return ngx_conf_set_str_slot(cf, cmd, conf);
453454
}
@@ -458,7 +459,7 @@ ngx_http_rds_csv_row_terminator(ngx_conf_t *cf, ngx_command_t *cmd,
458459

459460
static char *
460461
ngx_http_rds_csv_field_separator(ngx_conf_t *cf, ngx_command_t *cmd,
461-
void *conf)
462+
void *conf)
462463
{
463464
ngx_http_rds_csv_loc_conf_t *rlcf = conf;
464465
ngx_str_t *value;

src/ngx_http_rds_csv_filter_module.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
* Copyright (C) agentzh
44
*/
55

6+
67
#ifndef NGX_HTTP_RDS_CSV_FILTER_MODULE_H
78
#define NGX_HTTP_RDS_CSV_FILTER_MODULE_H
89

10+
911
#include "ngx_http_rds.h"
1012

1113
#include <ngx_core.h>
@@ -19,6 +21,7 @@
1921

2022

2123
extern ngx_module_t ngx_http_rds_csv_filter_module;
24+
2225
extern ngx_http_output_header_filter_pt ngx_http_rds_csv_next_header_filter;
2326
extern ngx_http_output_body_filter_pt ngx_http_rds_csv_next_body_filter;
2427

@@ -84,4 +87,3 @@ typedef struct {
8487

8588

8689
#endif /* NGX_HTTP_RDS_CSV_FILTER_MODULE_H */
87-

0 commit comments

Comments
 (0)