]> git.proxmox.com Git - mirror_ovs.git/blame - lib/svec.h
netdev-offload-tc: Use single 'once' variable for probing tc features
[mirror_ovs.git] / lib / svec.h
CommitLineData
064af421 1/*
e0edde6f 2 * Copyright (c) 2008, 2009, 2011 Nicira, Inc.
064af421 3 *
a14bc59f
BP
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
064af421 7 *
a14bc59f
BP
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
064af421
BP
15 */
16
17#ifndef SVEC_H
18#define SVEC_H 1
19
20#include <stdbool.h>
21#include <stddef.h>
d295e8e9 22
f4ade105
JG
23#ifdef __cplusplus
24extern "C" {
25#endif
064af421
BP
26
27struct svec {
28 char **names;
29 size_t n;
30 size_t allocated;
31};
32
33#define SVEC_EMPTY_INITIALIZER { NULL, 0, 0 }
34
35void svec_init(struct svec *);
36void svec_clone(struct svec *, const struct svec *);
37void svec_destroy(struct svec *);
38void svec_clear(struct svec *);
8ecd5308 39bool svec_is_empty(const struct svec *);
064af421
BP
40void svec_add(struct svec *, const char *);
41void svec_add_nocopy(struct svec *, char *);
42void svec_del(struct svec *, const char *);
43void svec_append(struct svec *, const struct svec *);
44void svec_terminate(struct svec *);
45void svec_sort(struct svec *);
46void svec_sort_unique(struct svec *);
47void svec_unique(struct svec *);
48void svec_compact(struct svec *);
8cf6bbb1 49void svec_shuffle(struct svec *);
064af421
BP
50void svec_diff(const struct svec *a, const struct svec *b,
51 struct svec *a_only, struct svec *both, struct svec *b_only);
52bool svec_contains(const struct svec *, const char *);
53size_t svec_find(const struct svec *, const char *);
54bool svec_is_sorted(const struct svec *);
55bool svec_is_unique(const struct svec *);
56const char *svec_get_duplicate(const struct svec *);
57void svec_swap(struct svec *a, struct svec *b);
58void svec_print(const struct svec *svec, const char *title);
59void svec_parse_words(struct svec *svec, const char *words);
60bool svec_equal(const struct svec *, const struct svec *);
61char *svec_join(const struct svec *,
62 const char *delimiter, const char *terminator);
63const char *svec_back(const struct svec *);
64void svec_pop_back(struct svec *);
65
c338e47f
BP
66/* Iterates over the names in SVEC, assigning each name in turn to NAME and its
67 * index to INDEX. */
68#define SVEC_FOR_EACH(INDEX, NAME, SVEC) \
69 for ((INDEX) = 0; \
70 ((INDEX) < (SVEC)->n \
71 ? (NAME) = (SVEC)->names[INDEX], 1 \
72 : 0); \
73 (INDEX)++)
d295e8e9 74
f4ade105
JG
75#ifdef __cplusplus
76}
77#endif
c338e47f 78
064af421 79#endif /* svec.h */