The currently available list of transformation keywords include :
+base64
+ Converts a binary input sample to a base64 string. It is used to log or
+ transfer binary content in a way that can be reliably transferred (eg:
+ an SSL ID can be copied in a header).
+
lower
Convert a string sample to lower case. This can only be placed after a string
sample fetch function or after a transformation keyword returning a string
#include <common/chunk.h>
#include <common/standard.h>
#include <common/uri_auth.h>
+#include <common/base64.h>
#include <proto/arg.h>
#include <proto/auth.h>
/* These functions set the data type on return. */
/*****************************************************************/
+static int sample_conv_bin2base64(const struct arg *arg_p, struct sample *smp)
+{
+ struct chunk *trash = get_trash_chunk();
+ int b64_len;
+
+ trash->len = 0;
+ b64_len = a2base64(smp->data.str.str, smp->data.str.len, trash->str, trash->size);
+ if (b64_len < 0)
+ return 0;
+
+ trash->len = b64_len;
+ smp->data.str = *trash;
+ smp->type = SMP_T_STR;
+ smp->flags &= ~SMP_F_CONST;
+ return 1;
+}
+
static int sample_conv_bin2hex(const struct arg *arg_p, struct sample *smp)
{
struct chunk *trash = get_trash_chunk();
/* Note: must not be declared <const> as its list will be overwritten */
static struct sample_conv_kw_list sample_conv_kws = {ILH, {
+ { "base64", sample_conv_bin2base64,0, NULL, SMP_T_BIN, SMP_T_STR },
{ "upper", sample_conv_str2upper, 0, NULL, SMP_T_STR, SMP_T_STR },
{ "lower", sample_conv_str2lower, 0, NULL, SMP_T_STR, SMP_T_STR },
{ "hex", sample_conv_bin2hex, 0, NULL, SMP_T_BIN, SMP_T_STR },