2 Copyright (c) 2018 Martin Wilck, SUSE Linux GmbH
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>.
27 * Methods implemented for gen_multipath "objects"
29 struct gen_multipath_ops {
31 * method: get_pathgroups(gmp)
32 * caller is responsible to returned data using rel_pathgroups()
33 * caller is also responsible to lock the gmp (directly or indirectly)
34 * while working with the return value.
35 * @param gmp: generic multipath object to act on
36 * @returns a vector of const struct gen_pathgroup*
38 const struct _vector* (*get_pathgroups)(const struct gen_multipath*);
40 * method: rel_pathgroups(gmp, v)
41 * free data allocated by get_pathgroups(), if any
42 * @param gmp: generic multipath object to act on
43 * @param v the value returned by get_pathgroups()
45 void (*rel_pathgroups)(const struct gen_multipath*,
46 const struct _vector*);
48 * method: snprint(gmp, buf, len, wildcard)
49 * prints the property of the multipath map matching
50 * the passed-in wildcard character into "buf",
51 * 0-terminated, no more than "len" characters including trailing '\0'.
53 * @param gmp: generic multipath object to act on
54 * @param buf: output struct strbuf
55 * @param wildcard: the multipath wildcard (see print.c)
56 * @returns the number of characters printed (without trailing '\0').
58 int (*snprint)(const struct gen_multipath*,
59 struct strbuf *buf, char wildcard);
61 * method: style(gmp, buf, len, verbosity)
62 * returns the format string to be used for the multipath object,
63 * defined with the wildcards as defined in print.c
64 * generic_style() should work well in most cases.
65 * @param gmp: generic multipath object to act on
66 * @param buf: output strbuf
67 * @param verbosity: verbosity level
68 * @returns number of format chars printed
70 int (*style)(const struct gen_multipath*,
71 struct strbuf *buf, int verbosity);
75 * Methods implemented for gen_pathgroup "objects"
77 struct gen_pathgroup_ops {
79 * method: get_paths(gpg)
80 * caller is responsible to returned data using rel_paths()
81 * @param gpg: generic pathgroup object to act on
82 * @returns a vector of const struct gen_path*
84 const struct _vector* (*get_paths)(const struct gen_pathgroup*);
86 * method: rel_paths(gpg, v)
87 * free data allocated by get_paths(), if any
88 * @param gmp: generic pathgroup object to act on
89 * @param v the value returned by get_paths()
91 void (*rel_paths)(const struct gen_pathgroup*, const struct _vector*);
94 * see gen_multipath_ops->snprint() above
96 int (*snprint)(const struct gen_pathgroup*,
97 struct strbuf *buf, char wildcard);
100 struct gen_path_ops {
103 * see gen_multipath_ops->snprint() above
105 int (*snprint)(const struct gen_path*,
106 struct strbuf *buf, char wildcard);
109 struct gen_multipath {
110 const struct gen_multipath_ops *ops;
113 struct gen_pathgroup {
114 const struct gen_pathgroup_ops *ops;
118 const struct gen_path_ops *ops;
122 * Helper functions for setting up the various generic_X_ops
127 * A simple style() method (see above) that should fit most
130 int generic_style(const struct gen_multipath*,
131 struct strbuf *buf, int verbosity);
133 #endif /* _GENERIC_H */