Annotation of embedaddon/strongswan/src/libcharon/plugins/vici/vici_builder.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2014 Martin Willi
3: * Copyright (C) 2014 revosec AG
4: *
5: * This program is free software; you can redistribute it and/or modify it
6: * under the terms of the GNU General Public License as published by the
7: * Free Software Foundation; either version 2 of the License, or (at your
8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9: *
10: * This program is distributed in the hope that it will be useful, but
11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13: * for more details.
14: */
15:
16: /**
17: * @defgroup vici_builder vici_builder
18: * @{ @ingroup vici
19: */
20:
21: #ifndef VICI_BUILDER_H_
22: #define VICI_BUILDER_H_
23:
24: #include "vici_message.h"
25:
26: typedef struct vici_builder_t vici_builder_t;
27:
28: /**
29: * Build helper for vici message
30: */
31: struct vici_builder_t {
32:
33: /**
34: * Append a generic message element to message.
35: *
36: * The additional arguments are type specific, it may be nothing, a string,
37: * a chunk value or both.
38: *
39: * @param type element type to add
40: * @param ... additional type specific arguments
41: */
42: void (*add)(vici_builder_t *this, vici_type_t type, ...);
43:
44: /**
45: * Append a key/value element using a format string.
46: *
47: * Instead of passing the type specific value as a chunk, this method
48: * takes a printf() style format string followed by its arguments. The
49: * key name for a key/value type is still a fixed string.
50: *
51: * @param key key name of the key/value to add
52: * @param fmt value format string
53: * @param ... arguments to value format string
54: */
55: void (*add_kv)(vici_builder_t *this, char *key, char *fmt, ...);
56:
57: /**
58: * Append a message element using a format string and va_list.
59: *
60: * Instead of passing the type specific value as a chunk, this method
61: * takes a printf() style format string followed by its arguments. The
62: * key name for a key/value type is still a fixed string.
63: *
64: * @param key key name of the key/value to add
65: * @param fmt value format string
66: * @param args arguments to value format string
67: */
68: void (*vadd_kv)(vici_builder_t *this, char *key, char *fmt, va_list args);
69:
70: /**
71: * Append a list item element using a format string.
72: *
73: * Instead of passing the type specific value as a chunk, this method
74: * takes a printf() style format string followed by its arguments.
75: *
76: * @param fmt value format string
77: * @param ... arguments to value format string
78: */
79: void (*add_li)(vici_builder_t *this, char *fmt, ...);
80:
81: /**
82: * Append a list item element using a format string and va_list.
83: *
84: * Instead of passing the type specific value as a chunk, this method
85: * takes a printf() style format string followed by its arguments.
86: *
87: * @param fmt value format string
88: * @param args arguments to value format string
89: */
90: void (*vadd_li)(vici_builder_t *this, char *fmt, va_list args);
91:
92: /**
93: * Begin a new section.
94: *
95: * @param name name of section to begin
96: */
97: void (*begin_section)(vici_builder_t *this, char *name);
98:
99: /**
100: * End the currently open section.
101: */
102: void (*end_section)(vici_builder_t *this);
103:
104: /**
105: * Begin a new list.
106: *
107: * @param name name of list to begin
108: */
109: void (*begin_list)(vici_builder_t *this, char *name);
110:
111: /**
112: * End the currently open list.
113: */
114: void (*end_list)(vici_builder_t *this);
115:
116: /**
117: * Finalize a vici message with all added elements, destroy builder.
118: *
119: * @return vici message, NULL on error
120: */
121: vici_message_t* (*finalize)(vici_builder_t *this);
122:
123: /**
124: * Destroy a vici builder without finalization.
125: *
126: * Note that finalize() already destroys the message, and calling destroy()
127: * is required only if the message does not get finalize()d.
128: */
129: void (*destroy)(vici_builder_t *this);
130: };
131:
132: /**
133: * Create a vici_builder instance.
134: */
135: vici_builder_t *vici_builder_create();
136:
137: #endif /** VICI_BUILDER_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>