X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ovsdb%2Fcolumn.c;h=26b7a0b372e2b0d86e8ad41826baec49f8caf9aa;hb=a5ed8fe32cb3c996837c61af2e358fa34dc9936f;hp=be346e4d6062f4c2150f089d8998a5549ec03278;hpb=1cb29ab050c601448a89eb7311a9f07095921bbd;p=sliver-openvswitch.git diff --git a/ovsdb/column.c b/ovsdb/column.c index be346e4d6..26b7a0b37 100644 --- a/ovsdb/column.c +++ b/ovsdb/column.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010, 2011 Nicira Networks +/* Copyright (c) 2009, 2010, 2011 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ #include #include "column.h" +#include "dynamic-string.h" #include "json.h" #include "ovsdb-error.h" #include "ovsdb-parser.h" @@ -203,6 +204,27 @@ ovsdb_column_set_to_json(const struct ovsdb_column_set *set) return json; } +/* Returns an English string listing the contents of 'set', e.g. "columns + * \"a\", \"b\", and \"c\"". The caller must free the string. */ +char * +ovsdb_column_set_to_string(const struct ovsdb_column_set *set) +{ + if (!set->n_columns) { + return xstrdup("no columns"); + } else { + struct ds s; + size_t i; + + ds_init(&s); + ds_put_format(&s, "column%s ", set->n_columns > 1 ? "s" : ""); + for (i = 0; i < set->n_columns; i++) { + const char *delimiter = english_list_delimiter(i, set->n_columns); + ds_put_format(&s, "%s\"%s\"", delimiter, set->columns[i]->name); + } + return ds_steal_cstr(&s); + } +} + void ovsdb_column_set_add(struct ovsdb_column_set *set, const struct ovsdb_column *column)