mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-08 08:07:10 +02:00
MINOR: sample: add ltrim converter
This converter strips specified characters from the beginning of a string.
This commit is contained in:
parent
ea159d6130
commit
51fc9d1bf1
@ -14249,6 +14249,10 @@ ltime(<format>[,<offset>])
|
|||||||
# e.g. 20140710162350 127.0.0.1:57325
|
# e.g. 20140710162350 127.0.0.1:57325
|
||||||
log-format %[date,ltime(%Y%m%d%H%M%S)]\ %ci:%cp
|
log-format %[date,ltime(%Y%m%d%H%M%S)]\ %ci:%cp
|
||||||
|
|
||||||
|
ltrim(<chars>)
|
||||||
|
Skips any characters from <chars> from the beginning of the string
|
||||||
|
representation of the input sample.
|
||||||
|
|
||||||
map(<map_file>[,<default_value>])
|
map(<map_file>[,<default_value>])
|
||||||
map_<match_type>(<map_file>[,<default_value>])
|
map_<match_type>(<map_file>[,<default_value>])
|
||||||
map_<match_type>_<output_type>(<map_file>[,<default_value>])
|
map_<match_type>_<output_type>(<map_file>[,<default_value>])
|
||||||
|
22
src/sample.c
22
src/sample.c
@ -2994,6 +2994,27 @@ static int sample_conv_cut_crlf(const struct arg *arg_p, struct sample *smp, voi
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int sample_conv_ltrim(const struct arg *arg_p, struct sample *smp, void *private)
|
||||||
|
{
|
||||||
|
char *delimiters, *p;
|
||||||
|
size_t dlen, l;
|
||||||
|
|
||||||
|
delimiters = arg_p[0].data.str.area;
|
||||||
|
dlen = arg_p[0].data.str.data;
|
||||||
|
|
||||||
|
l = smp->data.u.str.data;
|
||||||
|
p = smp->data.u.str.area;
|
||||||
|
while (l && memchr(delimiters, *p, dlen) != NULL) {
|
||||||
|
p++;
|
||||||
|
l--;
|
||||||
|
}
|
||||||
|
|
||||||
|
smp->data.u.str.area = p;
|
||||||
|
smp->data.u.str.data = l;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* All supported sample fetch functions must be declared here */
|
/* All supported sample fetch functions must be declared here */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
@ -3464,6 +3485,7 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
|
|||||||
|
|
||||||
{ "htonl", sample_conv_htonl, 0, NULL, SMP_T_SINT, SMP_T_BIN },
|
{ "htonl", sample_conv_htonl, 0, NULL, SMP_T_SINT, SMP_T_BIN },
|
||||||
{ "cut_crlf", sample_conv_cut_crlf, 0, NULL, SMP_T_STR, SMP_T_STR },
|
{ "cut_crlf", sample_conv_cut_crlf, 0, NULL, SMP_T_STR, SMP_T_STR },
|
||||||
|
{ "ltrim", sample_conv_ltrim, ARG1(1,STR), NULL, SMP_T_STR, SMP_T_STR },
|
||||||
{ NULL, NULL, 0, 0, 0 },
|
{ NULL, NULL, 0, 0, 0 },
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user