From a068a2951d84519a938a969d5061ca3ec3a27eb9 Mon Sep 17 00:00:00 2001 From: Emeric Brun Date: Wed, 17 Oct 2012 15:34:03 +0200 Subject: [PATCH] MINOR: sample: export 'sample_get_trash_chunk(void)' This will be used on external fetch modules. --- include/proto/sample.h | 1 + src/sample.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/proto/sample.h b/include/proto/sample.h index 471eb5f2a7..47099b3d4e 100644 --- a/include/proto/sample.h +++ b/include/proto/sample.h @@ -32,5 +32,6 @@ struct sample *sample_process(struct proxy *px, struct session *l4, struct sample *p); void sample_register_fetches(struct sample_fetch_kw_list *psl); void sample_register_convs(struct sample_conv_kw_list *psl); +struct chunk *sample_get_trash_chunk(void); #endif /* _PROTO_SAMPLE_H */ diff --git a/src/sample.c b/src/sample.c index b9e3c18b43..296dea22f3 100644 --- a/src/sample.c +++ b/src/sample.c @@ -107,7 +107,7 @@ struct sample_conv *find_sample_conv(const char *kw, int len) * Returns a static trash struct chunk to use in sample casts or format conversions * Swiths the 2 available trash buffers to protect data during convert */ -static struct chunk *get_trash_chunk(void) +struct chunk *sample_get_trash_chunk(void) { if (sample_trash_buf == sample_trash_buf1) sample_trash_buf = sample_trash_buf2; @@ -133,7 +133,7 @@ static int c_ip2int(struct sample *smp) static int c_ip2str(struct sample *smp) { - struct chunk *trash = get_trash_chunk(); + struct chunk *trash = sample_get_trash_chunk(); if (!inet_ntop(AF_INET, (void *)&smp->data.ipv4, trash->str, trash->size)) return 0; @@ -152,7 +152,7 @@ static int c_ip2ipv6(struct sample *smp) static int c_ipv62str(struct sample *smp) { - struct chunk *trash = get_trash_chunk(); + struct chunk *trash = sample_get_trash_chunk(); if (!inet_ntop(AF_INET6, (void *)&smp->data.ipv6, trash->str, trash->size)) return 0; @@ -189,7 +189,7 @@ static int c_str2ipv6(struct sample *smp) static int c_bin2str(struct sample *smp) { - struct chunk *trash = get_trash_chunk(); + struct chunk *trash = sample_get_trash_chunk(); unsigned char c; int ptr = 0; @@ -205,7 +205,7 @@ static int c_bin2str(struct sample *smp) static int c_int2str(struct sample *smp) { - struct chunk *trash = get_trash_chunk(); + struct chunk *trash = sample_get_trash_chunk(); char *pos; pos = ultoa_r(smp->data.uint, trash->str, trash->size); @@ -222,7 +222,7 @@ static int c_int2str(struct sample *smp) static int c_datadup(struct sample *smp) { - struct chunk *trash = get_trash_chunk(); + struct chunk *trash = sample_get_trash_chunk(); trash->len = smp->data.str.len < trash->size ? smp->data.str.len : trash->size; memcpy(trash->str, smp->data.str.str, trash->len); -- 2.47.3