On 15 June 2015 at 19:35, Andy Zhou <[email protected]> wrote: > Any ovsdb programs that accepts a single schema file name will be > extended to accepts multiple file names. This patch implements the > s/to accepts/to accept
> file name parsing logic for future patches. > > Signed-off-by: Andy Zhou <[email protected]> > --- > ovsdb/ovsdb.c | 39 +++++++++++++++++++++++++++++++++++++++ > ovsdb/ovsdb.h | 2 ++ > 2 files changed, 41 insertions(+) > > diff --git a/ovsdb/ovsdb.c b/ovsdb/ovsdb.c > index 5ec59ca..02db118 100644 > --- a/ovsdb/ovsdb.c > +++ b/ovsdb/ovsdb.c > @@ -24,6 +24,8 @@ > #include "ovsdb-types.h" > #include "simap.h" > #include "table.h" > +#include "table.h" > +#include "sset.h" > How about maintaining alphabetical order? > #include "transaction.h" > > struct ovsdb_schema * > @@ -608,3 +610,40 @@ error: > > return err; > } > + > +/* > + * Parse schemea file names passed from a string. > schemea? > + * > + * A leading comma indicates the default schema name. > + * > + * Duplicated filenames will be ignored. */ > +void > +ovsdb_parse_schema_file_names(const char *file_names, struct sset > *name_set, > + const char *default_schema) > +{ > + const char *delimiter=", \t\r\n"; > + const char *filename; > + char *saveptr; > + char *fns; > + > + if (!file_names) { > + sset_add(name_set, default_schema); > + return; > + } > + > + if (*file_names == ',') { > + sset_add(name_set, default_schema); > + } > + > + fns = xstrdup(file_names); > + filename = strtok_r(fns, delimiter, &saveptr); > + if (!filename) { > + filename = default_schema; > + } > + > + while(filename) { > + sset_add(name_set, filename); > + filename = strtok_r(NULL, delimiter, &saveptr); > + } > + free(fns); > +} > diff --git a/ovsdb/ovsdb.h b/ovsdb/ovsdb.h > index e3f3b1e..c711585 100644 > --- a/ovsdb/ovsdb.h > +++ b/ovsdb/ovsdb.h > @@ -52,6 +52,8 @@ struct ovsdb_error *ovsdb_schema_from_json(struct json *, > struct json *ovsdb_schema_to_json(const struct ovsdb_schema *); > > /* Multiple schemas. */ > +void ovsdb_parse_schema_file_names(const char *file_names, struct sset > *names, > + const char *default_schema); > struct ovsdb_error *ovsdb_schemata_from_files(struct sset *files, > struct shash* schemata); > void ovsdb_schemata_destroy(struct shash *schemata); > -- > 1.9.1 > > _______________________________________________ > dev mailing list > [email protected] > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
