mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
CLEANUP: da: move the converter registration to da.c
There's no reason to put it into sample.c, it's better to register it locally in da.c, it removes a number of ifdefs and exports.
This commit is contained in:
parent
ba3dd2b7e0
commit
f63386ad27
@ -8,6 +8,5 @@
|
|||||||
void da_register_cfgkeywords(void);
|
void da_register_cfgkeywords(void);
|
||||||
int init_deviceatlas(void);
|
int init_deviceatlas(void);
|
||||||
void deinit_deviceatlas(void);
|
void deinit_deviceatlas(void);
|
||||||
int da_haproxy(const struct arg *, struct sample *, void *);
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
16
src/da.c
16
src/da.c
@ -3,7 +3,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <common/cfgparse.h>
|
#include <common/cfgparse.h>
|
||||||
|
#include <proto/arg.h>
|
||||||
#include <proto/log.h>
|
#include <proto/log.h>
|
||||||
|
#include <proto/sample.h>
|
||||||
#include <import/da.h>
|
#include <import/da.h>
|
||||||
|
|
||||||
static int da_json_file(char **args, int section_type, struct proxy *curpx,
|
static int da_json_file(char **args, int section_type, struct proxy *curpx,
|
||||||
@ -141,7 +143,7 @@ void deinit_deviceatlas(void)
|
|||||||
da_fini();
|
da_fini();
|
||||||
}
|
}
|
||||||
|
|
||||||
int da_haproxy(const struct arg *args, struct sample *smp, void *private)
|
static int da_haproxy(const struct arg *args, struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct chunk *tmp;
|
struct chunk *tmp;
|
||||||
da_deviceinfo_t devinfo;
|
da_deviceinfo_t devinfo;
|
||||||
@ -229,4 +231,16 @@ int da_haproxy(const struct arg *args, struct sample *smp, void *private)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Note: must not be declared <const> as its list will be overwritten */
|
||||||
|
static struct sample_conv_kw_list conv_kws = {ILH, {
|
||||||
|
{ "da-csv", da_haproxy, ARG5(1,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_T_STR },
|
||||||
|
{ NULL, NULL, 0, 0, 0 },
|
||||||
|
}};
|
||||||
|
|
||||||
|
__attribute__((constructor))
|
||||||
|
static void __da_init(void)
|
||||||
|
{
|
||||||
|
/* register sample fetch and format conversion keywords */
|
||||||
|
sample_register_convs(&conv_kws);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,10 +32,6 @@
|
|||||||
#include <proto/sample.h>
|
#include <proto/sample.h>
|
||||||
#include <proto/stick_table.h>
|
#include <proto/stick_table.h>
|
||||||
|
|
||||||
#ifdef USE_DEVICEATLAS
|
|
||||||
#include <import/da.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* sample type names */
|
/* sample type names */
|
||||||
const char *smp_to_type[SMP_TYPES] = {
|
const char *smp_to_type[SMP_TYPES] = {
|
||||||
[SMP_T_BOOL] = "bool",
|
[SMP_T_BOOL] = "bool",
|
||||||
@ -2282,9 +2278,6 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
|
|||||||
{ "div", sample_conv_arith_div, ARG1(1,UINT), NULL, SMP_T_UINT, SMP_T_UINT },
|
{ "div", sample_conv_arith_div, ARG1(1,UINT), NULL, SMP_T_UINT, SMP_T_UINT },
|
||||||
{ "mod", sample_conv_arith_mod, ARG1(1,UINT), NULL, SMP_T_UINT, SMP_T_UINT },
|
{ "mod", sample_conv_arith_mod, ARG1(1,UINT), NULL, SMP_T_UINT, SMP_T_UINT },
|
||||||
{ "neg", sample_conv_arith_neg, 0, NULL, SMP_T_UINT, SMP_T_UINT },
|
{ "neg", sample_conv_arith_neg, 0, NULL, SMP_T_UINT, SMP_T_UINT },
|
||||||
#ifdef USE_DEVICEATLAS
|
|
||||||
{ "da-csv", da_haproxy, ARG5(1,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_T_STR },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{ NULL, NULL, 0, 0, 0 },
|
{ NULL, NULL, 0, 0, 0 },
|
||||||
}};
|
}};
|
||||||
|
Loading…
Reference in New Issue
Block a user