2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Written by: Eric Bollengier, December MMXIII
30 OT_SIZE, /* int64 size */
31 OT_PINT32, /* Uint32 */
33 OT_PINT64, /* Uint64 */
36 OT_BTIME, /* btime_t */
37 OT_UTIME, /* utime_t */
41 OT_PLUGINS, /* Plugin alist */
42 OT_RATIO, /* Double %.2f format */
45 OT_END, /* Last operator (no extra arg) */
46 OT_START_OBJ, /* Skip a line to start a new object (no extra arg) */
47 OT_END_OBJ, /* Skip a line to end current object (no extra arg) */
48 OT_CLEAR /* truncate current buffer (no extra arg) */
51 /* Keep the same order for get_options/parse_options */
54 OTT_TIME_UNIX = 1, /* unix time stamp */
55 OTT_TIME_NC = 2 /* Formatted time for user display: dd-Mon hh:mm */
58 #define OW_DEFAULT_SEPARATOR '\n'
59 #define OW_DEFAULT_TIMEFORMAT OTT_TIME_ISO
61 /* If included from output.c, mark the class as export (else, symboles are
62 * exported from all files...
65 # define OUTPUT_EXPORT DLL_IMP_EXP
67 # define OUTPUT_EXPORT
70 class OUTPUT_EXPORT OutputWriter: public SMARTALLOC
75 separator = OW_DEFAULT_SEPARATOR;
76 separator_str[0] = OW_DEFAULT_SEPARATOR;
78 timeformat = OW_DEFAULT_TIMEFORMAT;
84 virtual char *get_output(va_list ap, POOLMEM **out, OutputType first);
85 void get_buf(bool append); /* Allocate buf if needed */
89 char separator_str[2];
90 char object_separator;
91 OutputTimeType timeformat;
95 OutputWriter(const char *opts) {
104 virtual ~OutputWriter() {
105 free_and_null_pool_memory(buf);
108 /* s[ascii code]t[0-3]
110 * separator time format
111 * "s43" => + will be used as separator
112 * "s43t1" => + as separator and time as unix timestamp
114 virtual void parse_options(const char *opts);
115 virtual char *get_options(char *dest_l128); /* MAX_NAME_LENGTH mini */
117 /* Make a clear separation in the output*/
118 virtual char *start_group(const char *name, bool append=true);
119 virtual char *end_group(bool append=true);
121 /* Make a clear separation in the output for list*/
122 virtual char *start_list(const char *name, bool append=true);
123 virtual char *end_list(bool append=true);
125 /* \n by default, can be \t for example */
126 void set_separator(char sep) {
128 separator_str[0] = sep;
131 void set_object_separator(char sep) {
132 object_separator = sep;
135 void set_time_format(OutputTimeType fmt) {
141 * OT_STRING, "name", "value",
142 * OT_PINT32, "age", 10,
143 * OT_TIME, "birth-date", 1120202002,
144 * OT_PINT64, "weight", 100,
148 * "name=value\nage=10\nbirt-date=2012-01-12 10:20:00\nweight=100\n"
152 /* Use a user supplied buffer */
153 char *get_output(POOLMEM **out, OutputType first, ...);
155 /* Use the internal buffer */
156 char *get_output(OutputType first, ...);