master - report: select: add dm_report_field_string_list to libdm
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=76467bdcfd297ffbe2c088b6340ecc7d17d56742 Commit: 76467bdcfd297ffbe2c088b6340ecc7d17d56742 Parent: 5abdb52fdc66316d3e7d54085d4e79160024b95e Author: Peter Rajnoha <[email protected]> AuthorDate: Thu May 29 09:41:18 2014 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Tue Jun 17 16:27:20 2014 +0200
report: select: add dm_report_field_string_list to libdm
Add a separate dm_report_field_string_list fn to libdevmapper to support reporting string lists. Before, the code used libdevmappers's dm_report_field_string fn which required formatting the list to a single string. This functionality is now moved to libdevmapper and the code that needs to report the string list just needs to pass the list itself and libdevmapper will take care of this. This also enhances code reuse.
The dm_report_field_string_list also accepts an argument to define custom delimiter to use. If not defined, a default "," (comma) is used as item delimiter in the string list reported.
The dm_report_field_string_list automatically sorts the items in the list before formatting it to a final string. It also encodes the position and length within the final string where each element can be found. This can be used to support checking against each list item reported since since when formatted as a single string for the actual report, we would lose this information otherwise (we don't want to copy each item, the position and length within the final string is enough for us to get the original items back).
When such lists are checked against the selection tree, we can check each item individually this way and we can support operators like "match any" and "match all".
--- libdm/libdevmapper.h | 2 + libdm/libdm-report.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 0 deletions(-)
libdm/libdevmapper.h +2 -0
@@ -1676,6 +1676,8 @@ int dm_report_set_output_field_name_prefix(struct dm_report *rh,*/ int dm_report_field_string (struct dm_report *rh,struct dm_report_field *field,const char *const *data); +int dm_report_field_string_list (struct dm_report *rh,struct dm_report_field *field, +const struct dm_list *data,const char *delimiter);int dm_report_field_int32 (struct dm_report *rh,struct dm_report_field *field,const int32_t *data); int dm_report_field_uint32(struct dm_report *rh, struct dm_report_field *field,
libdm/libdm-report.c +127 -0
133 lines not on this page · raw message