]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: list registered sample converter functions
authorWilly Tarreau <w@1wt.eu>
Tue, 29 Mar 2022 14:59:49 +0000 (16:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 29 Mar 2022 16:01:37 +0000 (18:01 +0200)
Similar to the sample fetch keywords, let's also list the converter
keywords. They're much simpler since there's no compatibility matrix.
Instead the input and output types are listed. This is called by
dump_registered_keywords() for the "cnv" keywords class.

include/haproxy/sample.h
src/haproxy.c
src/sample.c

index f6ce3c0f92e370fad746d8235b10215aa1eff7ed..9ec4df16d1479a6cca263035ae51befe882f6baf 100644 (file)
@@ -50,6 +50,7 @@ const char *sample_src_names(unsigned int use);
 const char *sample_ckp_names(unsigned int use);
 struct sample_fetch *find_sample_fetch(const char *kw, int len);
 void smp_dump_fetch_kw(void);
+void smp_dump_conv_kw(void);
 struct sample_fetch *sample_fetch_getnext(struct sample_fetch *current, int *idx);
 struct sample_conv *sample_conv_getnext(struct sample_conv *current, int *idx);
 int smp_resolve_args(struct proxy *p, char **err);
index a17692c25b5abb2f87d8bb7e540f418566d796f0..adb9a7a4d7abe11bd496b55f9be3f9141d889554 100644 (file)
@@ -1828,6 +1828,7 @@ static void dump_registered_keywords(void)
                        printf("acl: ACL keywords\n");
                        printf("cfg: configuration keywords\n");
                        printf("cli: CLI keywords\n");
+                       printf("cnv: sample converter keywords\n");
                        printf("flt: filter names\n");
                        printf("smp: sample fetch functions\n");
                        printf("svc: service names\n");
@@ -1852,6 +1853,11 @@ static void dump_registered_keywords(void)
                        cli_list_keywords();
                }
 
+               if (all || strcmp(kwd_dump, "cnv") == 0) {
+                       printf("# List of registered sample converter functions:\n");
+                       smp_dump_conv_kw();
+               }
+
                if (all || strcmp(kwd_dump, "flt") == 0) {
                        printf("# List of registered filter names:\n");
                        flt_dump_kws(NULL);
index c4b7da97128acb6f90d5e2bc14adb3a97b286e33..e4d254b173cf51f45ab84d6b97c351c1a6c5ff18 100644 (file)
@@ -495,6 +495,45 @@ void smp_dump_fetch_kw(void)
        }
 }
 
+/* dump list of registered sample converter keywords on stdout */
+void smp_dump_conv_kw(void)
+{
+       struct sample_conv_kw_list *kwl;
+       struct sample_conv *kw;
+       uint64_t mask;
+       int index;
+       int arg;
+
+       list_for_each_entry(kwl, &sample_convs.list, list) {
+               for (index = 0; kwl->kw[index].kw != NULL; index++) {
+                       kw = &kwl->kw[index];
+                       printf("%s", kw->kw);
+                       if (kw->arg_mask) {
+                               mask = kw->arg_mask >> ARGM_BITS;
+                               printf("(");
+                               for (arg = 0;
+                                    arg < ARGM_NBARGS && ((mask >> (arg * ARGT_BITS)) & ARGT_MASK);
+                                    arg++) {
+                                       if (arg == (kw->arg_mask & ARGM_MASK)) {
+                                               /* now dumping extra args */
+                                               printf("[");
+                                       }
+                                       if (arg)
+                                               printf(",");
+                                       printf("%s", arg_type_names[(mask >> (arg * ARGT_BITS)) & ARGT_MASK]);
+                               }
+                               if (arg > (kw->arg_mask & ARGM_MASK)) {
+                                       /* extra args were dumped */
+                                       printf("]");
+                               }
+                               printf(")");
+                       }
+                       printf(": %s => %s", smp_to_type[kw->out_type], smp_to_type[kw->in_type]);
+                       printf("\n");
+               }
+       }
+}
+
 /* This function browses the list of available sample fetches. <current> is
  * the last used sample fetch. If it is the first call, it must set to NULL.
  * <idx> is the index of the next sample fetch entry. It is used as private