|
28 | 28 | #include <stdlib.h> |
29 | 29 | #include <string.h> |
30 | 30 |
|
| 31 | +#include "compat.h" |
31 | 32 | #include "xbps/json.h" |
| 33 | +#include "xbps/xbps_array.h" |
| 34 | +#include "xbps/xbps_bool.h" |
| 35 | +#include "xbps/xbps_data.h" |
| 36 | +#include "xbps/xbps_dictionary.h" |
| 37 | +#include "xbps/xbps_number.h" |
| 38 | +#include "xbps/xbps_object.h" |
| 39 | +#include "xbps/xbps_string.h" |
32 | 40 | #include "xbps_api_impl.h" |
33 | | -#include "compat.h" |
34 | 41 |
|
35 | 42 | /** |
36 | 43 | * @file lib/format.c |
@@ -638,10 +645,6 @@ xbps_fmt(const struct xbps_fmt *fmt, xbps_fmt_cb *cb, void *data, FILE *fp) |
638 | 645 | return 0; |
639 | 646 | } |
640 | 647 |
|
641 | | -struct fmt_dict_cb { |
642 | | - xbps_dictionary_t dict; |
643 | | -}; |
644 | | - |
645 | 648 | int |
646 | 649 | xbps_fmt_print_string(const struct xbps_fmt *fmt, const char *str, size_t len, FILE *fp) |
647 | 650 | { |
@@ -775,24 +778,28 @@ xbps_fmt_print_object(const struct xbps_fmt *fmt, xbps_object_t obj, FILE *fp) |
775 | 778 | return 0; |
776 | 779 | } |
777 | 780 |
|
| 781 | +struct fmt_dict_ctx { |
| 782 | + xbps_dictionary_t dict; |
| 783 | +}; |
| 784 | + |
778 | 785 | static int |
779 | 786 | fmt_dict_cb(FILE *fp, const struct xbps_fmt *fmt, void *data) |
780 | 787 | { |
781 | | - struct fmt_dict_cb *ctx = data; |
| 788 | + struct fmt_dict_ctx *ctx = data; |
782 | 789 | xbps_object_t obj = xbps_dictionary_get(ctx->dict, fmt->var); |
783 | 790 | return xbps_fmt_print_object(fmt, obj, fp); |
784 | 791 | } |
785 | 792 |
|
786 | 793 | int |
787 | 794 | xbps_fmt_dictionary(const struct xbps_fmt *fmt, xbps_dictionary_t dict, FILE *fp) |
788 | 795 | { |
789 | | - struct fmt_dict_cb ctx = {.dict = dict}; |
| 796 | + struct fmt_dict_ctx ctx = {.dict = dict}; |
790 | 797 | return xbps_fmt(fmt, &fmt_dict_cb, &ctx, fp); |
791 | 798 | } |
792 | 799 |
|
793 | 800 | int |
794 | 801 | xbps_fmts_dictionary(const char *format, xbps_dictionary_t dict, FILE *fp) |
795 | 802 | { |
796 | | - struct fmt_dict_cb ctx = {.dict = dict}; |
| 803 | + struct fmt_dict_ctx ctx = {.dict = dict}; |
797 | 804 | return xbps_fmts(format, &fmt_dict_cb, &ctx, fp); |
798 | 805 | } |
0 commit comments