CLEANUP: htx: Fix indentation here and there in HTX files
diff --git a/include/proto/htx.h b/include/proto/htx.h
index d803947..3fd8fba 100644
--- a/include/proto/htx.h
+++ b/include/proto/htx.h
@@ -35,7 +35,7 @@
struct htx_blk *htx_remove_blk(struct htx *htx, struct htx_blk *blk);
struct htx_blk *htx_replace_blk_value(struct htx *htx, struct htx_blk *blk,
- const struct ist old, const struct ist new);
+ const struct ist old, const struct ist new);
struct htx_ret htx_xfer_blks(struct htx *dst, struct htx *src, uint32_t count,
enum htx_blk_type mark);
@@ -45,7 +45,7 @@
const struct ist p2, const struct ist p3);
struct htx_blk *htx_replace_header(struct htx *htx, struct htx_blk *blk,
- const struct ist name, const struct ist value);
+ const struct ist name, const struct ist value);
struct htx_blk *htx_add_header(struct htx *htx, const struct ist name, const struct ist value);
struct htx_blk *htx_add_all_headers(struct htx *htx, const struct http_hdr *hdrs);
@@ -88,10 +88,10 @@
#define HTX_SL_RES_CPTR(sl) HTX_SL_P2_PTR(sl)
#define HTX_SL_RES_RPTR(sl) HTX_SL_P3_PTR(sl)
-static inline const struct ist htx_sl_p1(const struct htx_sl *sl)
-{
- return ist2(HTX_SL_P1_PTR(sl), HTX_SL_P1_LEN(sl));
-}
+ static inline const struct ist htx_sl_p1(const struct htx_sl *sl)
+ {
+ return ist2(HTX_SL_P1_PTR(sl), HTX_SL_P1_LEN(sl));
+ }
static inline const struct ist htx_sl_p2(const struct htx_sl *sl)
{
@@ -149,25 +149,25 @@
/* Returns the array index of a block given its position <pos> */
static inline uint32_t htx_pos_to_idx(const struct htx *htx, uint32_t pos)
{
- return ((htx->size / sizeof(htx->blocks[0])) - pos - 1);
+ return ((htx->size / sizeof(htx->blocks[0])) - pos - 1);
}
/* Returns the position of the block <blk> */
static inline uint32_t htx_get_blk_pos(const struct htx *htx, const struct htx_blk *blk)
{
- return (htx->blocks + (htx->size / sizeof(htx->blocks[0])) - blk - 1);
+ return (htx->blocks + (htx->size / sizeof(htx->blocks[0])) - blk - 1);
}
/* Returns the block at the position <pos> */
static inline struct htx_blk *htx_get_blk(const struct htx *htx, uint32_t pos)
{
- return ((struct htx_blk *)(htx->blocks) + htx_pos_to_idx(htx, pos));
+ return ((struct htx_blk *)(htx->blocks) + htx_pos_to_idx(htx, pos));
}
/* Returns the type of the block <blk> */
static inline enum htx_blk_type htx_get_blk_type(const struct htx_blk *blk)
{
- return (blk->info >> 28);
+ return (blk->info >> 28);
}
/* Returns the pseudo-header type of the block <blk>. If it's not a
@@ -175,36 +175,36 @@
*/
static inline enum htx_phdr_type htx_get_blk_phdr(const struct htx_blk *blk)
{
- enum htx_blk_type type = htx_get_blk_type(blk);
- enum htx_phdr_type phdr;
+ enum htx_blk_type type = htx_get_blk_type(blk);
+ enum htx_phdr_type phdr;
- switch (type) {
- case HTX_BLK_PHDR:
- phdr = (blk->info & 0xff);
- return phdr;
+ switch (type) {
+ case HTX_BLK_PHDR:
+ phdr = (blk->info & 0xff);
+ return phdr;
- default:
- /* Not a pseudo-header */
- return HTX_PHDR_UNKNOWN;
- }
+ default:
+ /* Not a pseudo-header */
+ return HTX_PHDR_UNKNOWN;
+ }
}
/* Returns the size of the block <blk>, depending of its type */
static inline uint32_t htx_get_blksz(const struct htx_blk *blk)
{
- enum htx_blk_type type = htx_get_blk_type(blk);
+ enum htx_blk_type type = htx_get_blk_type(blk);
- switch (type) {
- case HTX_BLK_HDR:
- /* name.length + value.length */
- return ((blk->info & 0xff) + ((blk->info >> 8) & 0xfffff));
- case HTX_BLK_PHDR:
- /* value.length */
- return ((blk->info >> 8) & 0xfffff);
- default:
- /* value.length */
- return (blk->info & 0xfffffff);
- }
+ switch (type) {
+ case HTX_BLK_HDR:
+ /* name.length + value.length */
+ return ((blk->info & 0xff) + ((blk->info >> 8) & 0xfffff));
+ case HTX_BLK_PHDR:
+ /* value.length */
+ return ((blk->info >> 8) & 0xfffff);
+ default:
+ /* value.length */
+ return (blk->info & 0xfffffff);
+ }
}
/* Returns the position of the oldest entry (head).
@@ -215,15 +215,15 @@
*/
static inline int32_t htx_get_head(const struct htx *htx)
{
- if (!htx->used)
- return -1;
+ if (!htx->used)
+ return -1;
- return (((htx->tail + 1U < htx->used) ? htx->wrap : 0) + htx->tail + 1U - htx->used);
+ return (((htx->tail + 1U < htx->used) ? htx->wrap : 0) + htx->tail + 1U - htx->used);
}
/* Returns the oldest HTX block (head) if the HTX message is not
* empty. Otherwise it returns NULL.
-*/
+ */
static inline struct htx_blk *htx_get_head_blk(const struct htx *htx)
{
int32_t head = htx_get_head(htx);
@@ -249,12 +249,12 @@
*/
static inline int32_t htx_get_tail(const struct htx *htx)
{
- return (htx->used ? htx->tail : -1);
+ return (htx->used ? htx->tail : -1);
}
/* Returns the newest HTX block (tail) if the HTX message is not
* empty. Otherwise it returns NULL.
-*/
+ */
static inline struct htx_blk *htx_get_tail_blk(const struct htx *htx)
{
int32_t tail = htx_get_tail(htx);
@@ -281,19 +281,19 @@
*/
static inline int32_t htx_get_prev(const struct htx *htx, uint32_t pos)
{
- int32_t head;
+ int32_t head;
- head = htx_get_head(htx);
- if (head == -1 || pos == head)
- return -1;
- if (!pos)
- return (htx->wrap - 1);
- return (pos - 1);
+ head = htx_get_head(htx);
+ if (head == -1 || pos == head)
+ return -1;
+ if (!pos)
+ return (htx->wrap - 1);
+ return (pos - 1);
}
/* Returns the HTX block before <blk> in the HTX message <htx>. If <blk> is the
* head, NULL returned.
-*/
+ */
static inline struct htx_blk *htx_get_prev_blk(const struct htx *htx,
const struct htx_blk *blk)
{
@@ -312,21 +312,21 @@
*/
static inline int32_t htx_get_next(const struct htx *htx, uint32_t pos)
{
- if (!htx->used)
- return -1;
+ if (!htx->used)
+ return -1;
- if (pos == htx->tail)
- return -1;
- pos++;
- if (pos >= htx->wrap)
- pos = 0;
- return pos;
+ if (pos == htx->tail)
+ return -1;
+ pos++;
+ if (pos >= htx->wrap)
+ pos = 0;
+ return pos;
}
/* Returns the HTX block after <blk> in the HTX message <htx>. If <blk> is the
* tail, NULL returned.
-*/
+ */
static inline struct htx_blk *htx_get_next_blk(const struct htx *htx,
const struct htx_blk *blk)
{
@@ -338,24 +338,24 @@
static inline int32_t htx_find_front(const struct htx *htx)
{
- int32_t front, pos;
- uint32_t addr = 0;
+ int32_t front, pos;
+ uint32_t addr = 0;
- if (!htx->used)
- return -1;
+ if (!htx->used)
+ return -1;
- front = -1;
- for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) {
- struct htx_blk *blk = htx_get_blk(htx, pos);
- enum htx_blk_type type = htx_get_blk_type(blk);
+ front = -1;
+ for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) {
+ struct htx_blk *blk = htx_get_blk(htx, pos);
+ enum htx_blk_type type = htx_get_blk_type(blk);
- if (type != HTX_BLK_UNUSED && blk->addr >= addr) {
- front = pos;
- addr = blk->addr;
- }
- }
+ if (type != HTX_BLK_UNUSED && blk->addr >= addr) {
+ front = pos;
+ addr = blk->addr;
+ }
+ }
- return front;
+ return front;
}
/* Returns the HTX block containing data with the <offset>, relatively to the
@@ -383,24 +383,24 @@
*/
static inline void htx_set_blk_value_len(struct htx_blk *blk, uint32_t vlen)
{
- enum htx_blk_type type = htx_get_blk_type(blk);
+ enum htx_blk_type type = htx_get_blk_type(blk);
- switch (type) {
- case HTX_BLK_HDR:
- case HTX_BLK_PHDR:
- blk->info = (type << 28) + (vlen << 8) + (blk->info & 0xff);
- break;
- case HTX_BLK_REQ_SL:
- case HTX_BLK_RES_SL:
- case HTX_BLK_DATA:
- case HTX_BLK_TLR:
- case HTX_BLK_OOB:
- blk->info = (type << 28) + vlen;
- break;
- default:
- /* Unexpected case */
- break;
- }
+ switch (type) {
+ case HTX_BLK_HDR:
+ case HTX_BLK_PHDR:
+ blk->info = (type << 28) + (vlen << 8) + (blk->info & 0xff);
+ break;
+ case HTX_BLK_REQ_SL:
+ case HTX_BLK_RES_SL:
+ case HTX_BLK_DATA:
+ case HTX_BLK_TLR:
+ case HTX_BLK_OOB:
+ blk->info = (type << 28) + vlen;
+ break;
+ default:
+ /* Unexpected case */
+ break;
+ }
}
/* Returns the data pointer of the block <blk> */
@@ -414,19 +414,19 @@
*/
static inline struct ist htx_get_blk_name(const struct htx *htx, const struct htx_blk *blk)
{
- enum htx_blk_type type = htx_get_blk_type(blk);
- struct ist ret;
+ enum htx_blk_type type = htx_get_blk_type(blk);
+ struct ist ret;
- switch (type) {
- case HTX_BLK_HDR:
- ret.ptr = htx_get_blk_ptr(htx, blk);
- ret.len = blk->info & 0xff;
- break;
+ switch (type) {
+ case HTX_BLK_HDR:
+ ret.ptr = htx_get_blk_ptr(htx, blk);
+ ret.len = blk->info & 0xff;
+ break;
- default:
- return ist("");
- }
- return ret;
+ default:
+ return ist("");
+ }
+ return ret;
}
@@ -435,33 +435,33 @@
*/
static inline struct ist htx_get_blk_value(const struct htx *htx, const struct htx_blk *blk)
{
- enum htx_blk_type type = htx_get_blk_type(blk);
- struct ist ret;
+ enum htx_blk_type type = htx_get_blk_type(blk);
+ struct ist ret;
- switch (type) {
- case HTX_BLK_HDR:
- ret.ptr = htx_get_blk_ptr(htx, blk) + (blk->info & 0xff);
- ret.len = (blk->info >> 8) & 0xfffff;
- break;
+ switch (type) {
+ case HTX_BLK_HDR:
+ ret.ptr = htx_get_blk_ptr(htx, blk) + (blk->info & 0xff);
+ ret.len = (blk->info >> 8) & 0xfffff;
+ break;
- case HTX_BLK_PHDR:
- ret.ptr = htx_get_blk_ptr(htx, blk);
- ret.len = (blk->info >> 8) & 0xfffff;
- break;
+ case HTX_BLK_PHDR:
+ ret.ptr = htx_get_blk_ptr(htx, blk);
+ ret.len = (blk->info >> 8) & 0xfffff;
+ break;
- case HTX_BLK_REQ_SL:
- case HTX_BLK_RES_SL:
- case HTX_BLK_DATA:
- case HTX_BLK_TLR:
- case HTX_BLK_OOB:
- ret.ptr = htx_get_blk_ptr(htx, blk);
- ret.len = blk->info & 0xfffffff;
- break;
+ case HTX_BLK_REQ_SL:
+ case HTX_BLK_RES_SL:
+ case HTX_BLK_DATA:
+ case HTX_BLK_TLR:
+ case HTX_BLK_OOB:
+ ret.ptr = htx_get_blk_ptr(htx, blk);
+ ret.len = blk->info & 0xfffffff;
+ break;
- default:
- return ist("");
- }
- return ret;
+ default:
+ return ist("");
+ }
+ return ret;
}
/* Removes <n> bytes from the beginning of DATA block <blk>. The block's start
@@ -481,19 +481,19 @@
/* Returns the space used by metadata in <htx>. */
static inline uint32_t htx_meta_space(const struct htx *htx)
{
- return (htx->used * sizeof(htx->blocks[0]));
+ return (htx->used * sizeof(htx->blocks[0]));
}
/* Returns the space used (data + metadata) in <htx> */
static inline uint32_t htx_used_space(const struct htx *htx)
{
- return (htx->data + htx_meta_space(htx));
+ return (htx->data + htx_meta_space(htx));
}
/* Returns the free space in <htx> */
static inline uint32_t htx_free_space(const struct htx *htx)
{
- return (htx->size - htx_used_space(htx));
+ return (htx->size - htx_used_space(htx));
}
/* Returns the maximum size available to store some data in <htx> if a new block
@@ -501,24 +501,24 @@
*/
static inline uint32_t htx_free_data_space(const struct htx *htx)
{
- uint32_t free = htx_free_space(htx);
+ uint32_t free = htx_free_space(htx);
- if (free < sizeof(htx->blocks[0]))
- return 0;
- return (free - sizeof(htx->blocks[0]));
+ if (free < sizeof(htx->blocks[0]))
+ return 0;
+ return (free - sizeof(htx->blocks[0]));
}
/* Returns 1 if the message has less than 1/4 of its capacity free, otherwise 0 */
static inline int htx_almost_full(const struct htx *htx)
{
- if (!htx->size || htx_free_space(htx) < htx->size / 4)
- return 1;
- return 0;
+ if (!htx->size || htx_free_space(htx) < htx->size / 4)
+ return 1;
+ return 0;
}
static inline void htx_reset(struct htx *htx)
{
- htx->data = htx->used = htx->tail = htx->wrap = htx->front = 0;
+ htx->data = htx->used = htx->tail = htx->wrap = htx->front = 0;
htx->extra = 0;
htx->flags = HTX_FL_NONE;
htx->sl_off = -1;
@@ -587,88 +587,88 @@
/* Returns 1 if the message is empty, otherwise it returns 0. */
static inline int htx_is_empty(const struct htx *htx)
{
- return (!htx || !htx->used);
+ return (!htx || !htx->used);
}
/* Returns 1 if the message is not empty, otherwise it returns 0. */
static inline int htx_is_not_empty(const struct htx *htx)
{
- return (htx && htx->used);
+ return (htx && htx->used);
}
/* For debugging purpose */
static inline const char *htx_blk_type_str(enum htx_blk_type type)
{
- switch (type) {
- case HTX_BLK_REQ_SL: return "HTX_BLK_REQ_SL";
- case HTX_BLK_RES_SL: return "HTX_BLK_RES_SL";
- case HTX_BLK_HDR: return "HTX_BLK_HDR";
- case HTX_BLK_PHDR: return "HTX_BLK_PHDR";
- case HTX_BLK_EOH: return "HTX_BLK_EOH";
- case HTX_BLK_DATA: return "HTX_BLK_DATA";
- case HTX_BLK_EOD: return "HTX_BLK_EOD";
- case HTX_BLK_TLR: return "HTX_BLK_TLR";
- case HTX_BLK_EOM: return "HTX_BLK_EOM";
- case HTX_BLK_OOB: return "HTX_BLK_OOB";
- case HTX_BLK_UNUSED: return "HTX_BLK_UNUSED";
- default: return "HTX_BLK_???";
- };
+ switch (type) {
+ case HTX_BLK_REQ_SL: return "HTX_BLK_REQ_SL";
+ case HTX_BLK_RES_SL: return "HTX_BLK_RES_SL";
+ case HTX_BLK_HDR: return "HTX_BLK_HDR";
+ case HTX_BLK_PHDR: return "HTX_BLK_PHDR";
+ case HTX_BLK_EOH: return "HTX_BLK_EOH";
+ case HTX_BLK_DATA: return "HTX_BLK_DATA";
+ case HTX_BLK_EOD: return "HTX_BLK_EOD";
+ case HTX_BLK_TLR: return "HTX_BLK_TLR";
+ case HTX_BLK_EOM: return "HTX_BLK_EOM";
+ case HTX_BLK_OOB: return "HTX_BLK_OOB";
+ case HTX_BLK_UNUSED: return "HTX_BLK_UNUSED";
+ default: return "HTX_BLK_???";
+ };
}
static inline const char *htx_blk_phdr_str(enum htx_phdr_type phdr)
{
- switch (phdr) {
- case HTX_PHDR_UNKNOWN: return "HTX_PHDR_UNKNOWN";
- default: return "HTX_PHDR_???";
- }
+ switch (phdr) {
+ case HTX_PHDR_UNKNOWN: return "HTX_PHDR_UNKNOWN";
+ default: return "HTX_PHDR_???";
+ }
}
static inline void htx_dump(struct htx *htx)
{
- int32_t pos;
+ int32_t pos;
- fprintf(stderr, "htx:%p [ size=%u - data=%u - used=%u - wrap=%s - extra=%llu]\n",
- htx, htx->size, htx->data, htx->used,
- (!htx->used || htx->tail+1 == htx->wrap) ? "NO" : "YES",
+ fprintf(stderr, "htx:%p [ size=%u - data=%u - used=%u - wrap=%s - extra=%llu]\n",
+ htx, htx->size, htx->data, htx->used,
+ (!htx->used || htx->tail+1 == htx->wrap) ? "NO" : "YES",
(unsigned long long)htx->extra);
- fprintf(stderr, "\thead=%d - tail=%u - front=%u - wrap=%u\n",
- htx_get_head(htx), htx->tail, htx->front, htx->wrap);
+ fprintf(stderr, "\thead=%d - tail=%u - front=%u - wrap=%u\n",
+ htx_get_head(htx), htx->tail, htx->front, htx->wrap);
- for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) {
+ for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) {
struct htx_sl *sl;
- struct htx_blk *blk = htx_get_blk(htx, pos);
- enum htx_blk_type type = htx_get_blk_type(blk);
- enum htx_phdr_type phdr = htx_get_blk_phdr(blk);
- uint32_t sz = htx_get_blksz(blk);
- struct ist n, v;
+ struct htx_blk *blk = htx_get_blk(htx, pos);
+ enum htx_blk_type type = htx_get_blk_type(blk);
+ enum htx_phdr_type phdr = htx_get_blk_phdr(blk);
+ uint32_t sz = htx_get_blksz(blk);
+ struct ist n, v;
- n = htx_get_blk_name(htx, blk);
- v = htx_get_blk_value(htx, blk);
+ n = htx_get_blk_name(htx, blk);
+ v = htx_get_blk_value(htx, blk);
- if (type == HTX_BLK_REQ_SL || type == HTX_BLK_RES_SL) {
+ if (type == HTX_BLK_REQ_SL || type == HTX_BLK_RES_SL) {
sl = htx_get_blk_ptr(htx, blk);
- fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s %.*s %.*s\n",
- pos, htx_blk_type_str(type), sz, blk->addr,
- HTX_SL_P1_LEN(sl), HTX_SL_P1_PTR(sl),
- HTX_SL_P2_LEN(sl), HTX_SL_P2_PTR(sl),
- HTX_SL_P3_LEN(sl), HTX_SL_P3_PTR(sl));
+ fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s %.*s %.*s\n",
+ pos, htx_blk_type_str(type), sz, blk->addr,
+ HTX_SL_P1_LEN(sl), HTX_SL_P1_PTR(sl),
+ HTX_SL_P2_LEN(sl), HTX_SL_P2_PTR(sl),
+ HTX_SL_P3_LEN(sl), HTX_SL_P3_PTR(sl));
}
- else if (type == HTX_BLK_HDR)
- fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s: %.*s\n",
- pos, htx_blk_type_str(type), sz, blk->addr,
- (int)n.len, n.ptr,
- (int)v.len, v.ptr);
+ else if (type == HTX_BLK_HDR)
+ fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s: %.*s\n",
+ pos, htx_blk_type_str(type), sz, blk->addr,
+ (int)n.len, n.ptr,
+ (int)v.len, v.ptr);
- else if (type == HTX_BLK_PHDR)
- fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s\n",
- pos, htx_blk_phdr_str(phdr), sz, blk->addr,
- (int)v.len, v.ptr);
- else
- fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u%s\n",
- pos, htx_blk_type_str(type), sz, blk->addr,
- (!v.len ? "\t<empty>" : ""));
- }
- fprintf(stderr, "\n");
+ else if (type == HTX_BLK_PHDR)
+ fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s\n",
+ pos, htx_blk_phdr_str(phdr), sz, blk->addr,
+ (int)v.len, v.ptr);
+ else
+ fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u%s\n",
+ pos, htx_blk_type_str(type), sz, blk->addr,
+ (!v.len ? "\t<empty>" : ""));
+ }
+ fprintf(stderr, "\n");
}
#endif /* _PROTO_HTX_H */