Emeric Brun | 107ca30 | 2010-01-04 16:16:05 +0100 | [diff] [blame] | 1 | /* |
Willy Tarreau | cd3b094 | 2012-04-27 21:52:18 +0200 | [diff] [blame] | 2 | * include/proto/sample.h |
| 3 | * Functions for samples management. |
Emeric Brun | 107ca30 | 2010-01-04 16:16:05 +0100 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2009-2010 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr> |
Willy Tarreau | cd3b094 | 2012-04-27 21:52:18 +0200 | [diff] [blame] | 6 | * Copyright (C) 2012 Willy Tarreau <w@1wt.eu> |
Emeric Brun | 107ca30 | 2010-01-04 16:16:05 +0100 | [diff] [blame] | 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public |
| 10 | * License as published by the Free Software Foundation, version 2.1 |
| 11 | * exclusively. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public |
| 19 | * License along with this library; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ |
| 22 | |
Willy Tarreau | cd3b094 | 2012-04-27 21:52:18 +0200 | [diff] [blame] | 23 | #ifndef _PROTO_SAMPLE_H |
| 24 | #define _PROTO_SAMPLE_H |
Emeric Brun | 107ca30 | 2010-01-04 16:16:05 +0100 | [diff] [blame] | 25 | |
Willy Tarreau | cd3b094 | 2012-04-27 21:52:18 +0200 | [diff] [blame] | 26 | #include <types/sample.h> |
Emeric Brun | 107ca30 | 2010-01-04 16:16:05 +0100 | [diff] [blame] | 27 | #include <types/stick_table.h> |
| 28 | |
Willy Tarreau | 975c178 | 2013-12-12 23:16:54 +0100 | [diff] [blame] | 29 | struct sample_expr *sample_parse_expr(char **str, int *idx, char **err, struct arg_list *al); |
Thierry FOURNIER | 20f4996 | 2013-11-21 10:51:50 +0100 | [diff] [blame] | 30 | struct sample_conv *find_sample_conv(const char *kw, int len); |
Willy Tarreau | 1278578 | 2012-04-27 21:37:17 +0200 | [diff] [blame] | 31 | struct sample *sample_process(struct proxy *px, struct session *l4, |
| 32 | void *l7, unsigned int dir, struct sample_expr *expr, |
Willy Tarreau | b4a88f0 | 2012-04-23 21:35:11 +0200 | [diff] [blame] | 33 | struct sample *p); |
Willy Tarreau | e7ad4bb | 2012-12-21 00:02:32 +0100 | [diff] [blame] | 34 | struct sample *sample_fetch_string(struct proxy *px, struct session *l4, void *l7, |
| 35 | unsigned int opt, struct sample_expr *expr); |
Willy Tarreau | 1278578 | 2012-04-27 21:37:17 +0200 | [diff] [blame] | 36 | void sample_register_fetches(struct sample_fetch_kw_list *psl); |
| 37 | void sample_register_convs(struct sample_conv_kw_list *psl); |
Willy Tarreau | 80aca90 | 2013-01-07 15:42:20 +0100 | [diff] [blame] | 38 | const char *sample_src_names(unsigned int use); |
Willy Tarreau | a91d0a5 | 2013-03-25 08:12:18 +0100 | [diff] [blame] | 39 | const char *sample_ckp_names(unsigned int use); |
Willy Tarreau | 8ed669b | 2013-01-11 15:49:37 +0100 | [diff] [blame] | 40 | struct sample_fetch *find_sample_fetch(const char *kw, int len); |
Willy Tarreau | a4312fa | 2013-04-02 16:34:32 +0200 | [diff] [blame] | 41 | int smp_resolve_args(struct proxy *p); |
Thierry FOURNIER | 348971e | 2013-11-21 10:50:10 +0100 | [diff] [blame] | 42 | int smp_expr_output_type(struct sample_expr *expr); |
Willy Tarreau | cd3b094 | 2012-04-27 21:52:18 +0200 | [diff] [blame] | 43 | |
Thierry FOURNIER | e3ded59 | 2013-12-06 15:36:54 +0100 | [diff] [blame] | 44 | /* |
| 45 | * This function just apply a cast on sample. It returns 0 if the cast is not |
| 46 | * avalaible or if the cast fails, otherwise returns 1. It does not modify the |
| 47 | * input sample on failure. |
| 48 | */ |
| 49 | static inline |
| 50 | int sample_convert(struct sample *sample, int req_type) |
| 51 | { |
| 52 | if (!sample_casts[sample->type][req_type]) |
| 53 | return 0; |
| 54 | return sample_casts[sample->type][req_type](sample); |
| 55 | } |
| 56 | |
Willy Tarreau | cd3b094 | 2012-04-27 21:52:18 +0200 | [diff] [blame] | 57 | #endif /* _PROTO_SAMPLE_H */ |