2 ** OSSP var - Variable Expansion
3 ** Copyright (c) 2001-2002 Ralf S. Engelschall <rse@engelschall.com>
4 ** Copyright (c) 2001-2002 The OSSP Project (http://www.ossp.org/)
5 ** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/)
7 ** This file is part of OSSP var, a variable expansion
8 ** library which can be found at http://www.ossp.org/pkg/lib/var/.
10 ** Permission to use, copy, modify, and distribute this software for
11 ** any purpose with or without fee is hereby granted, provided that
12 ** the above copyright notice and this permission notice appear in all
15 ** For disclaimer see below.
18 * Modified for use with Bacula by Kern Sibbald, June 2003
21 Bacula® - The Network Backup Solution
23 Copyright (C) 2003-2006 Free Software Foundation Europe e.V.
25 The main author of Bacula is Kern Sibbald, with contributions from
26 many others, a complete list can be found in the file AUTHORS.
27 This program is Free Software; you can redistribute it and/or
28 modify it under the terms of version two of the GNU General Public
29 License as published by the Free Software Foundation plus additions
30 that are listed in the file LICENSE.
32 This program is distributed in the hope that it will be useful, but
33 WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 General Public License for more details.
37 You should have received a copy of the GNU General Public License
38 along with this program; if not, write to the Free Software
39 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
42 Bacula® is a registered trademark ofJohn Walker.
43 The licensor of Bacula is the Free Software Foundation Europe
44 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
45 Switzerland, email:ftf@fsfeurope.org.
55 VAR_ERR_CALLBACK = -64,
56 VAR_ERR_FORMATTING_FAILURE = -45,
57 VAR_ERR_UNDEFINED_OPERATION = -44,
58 VAR_ERR_MALFORMED_OPERATION_ARGUMENTS = -43,
59 VAR_ERR_INVALID_CHAR_IN_LOOP_LIMITS = -42,
60 VAR_ERR_UNTERMINATED_LOOP_CONSTRUCT = -41,
61 VAR_ERR_DIVISION_BY_ZERO_IN_INDEX = -40,
62 VAR_ERR_UNCLOSED_BRACKET_IN_INDEX = -39,
63 VAR_ERR_INCOMPLETE_INDEX_SPEC = -37,
64 VAR_ERR_INVALID_CHAR_IN_INDEX_SPEC = -36,
65 VAR_ERR_ARRAY_LOOKUPS_ARE_UNSUPPORTED = -35,
66 VAR_ERR_INCOMPLETE_QUOTED_PAIR = -34,
67 VAR_ERR_INVALID_ARGUMENT = -34,
68 VAR_ERR_SUBMATCH_OUT_OF_RANGE = -33,
69 VAR_ERR_UNKNOWN_QUOTED_PAIR_IN_REPLACE = -32,
70 VAR_ERR_EMPTY_PADDING_FILL_STRING = -31,
71 VAR_ERR_MISSING_PADDING_WIDTH = -30,
72 VAR_ERR_MALFORMATTED_PADDING = -29,
73 VAR_ERR_INCORRECT_TRANSPOSE_CLASS_SPEC = -28,
74 VAR_ERR_EMPTY_TRANSPOSE_CLASS = -27,
75 VAR_ERR_TRANSPOSE_CLASSES_MISMATCH = -26,
76 VAR_ERR_MALFORMATTED_TRANSPOSE = -25,
77 VAR_ERR_OFFSET_LOGIC = -24,
78 VAR_ERR_OFFSET_OUT_OF_BOUNDS = -23,
79 VAR_ERR_RANGE_OUT_OF_BOUNDS = -22,
80 VAR_ERR_INVALID_OFFSET_DELIMITER = -21,
81 VAR_ERR_MISSING_START_OFFSET = -20,
82 VAR_ERR_EMPTY_SEARCH_STRING = -19,
83 VAR_ERR_MISSING_PARAMETER_IN_COMMAND = -18,
84 VAR_ERR_INVALID_REGEX_IN_REPLACE = -17,
85 VAR_ERR_UNKNOWN_REPLACE_FLAG = -16,
86 VAR_ERR_MALFORMATTED_REPLACE = -15,
87 VAR_ERR_UNKNOWN_COMMAND_CHAR = -14,
88 VAR_ERR_INPUT_ISNT_TEXT_NOR_VARIABLE = -13,
89 VAR_ERR_UNDEFINED_VARIABLE = -12,
90 VAR_ERR_INCOMPLETE_VARIABLE_SPEC = -11,
91 VAR_ERR_OUT_OF_MEMORY = -10,
92 VAR_ERR_INVALID_CONFIGURATION = -9,
93 VAR_ERR_INCORRECT_CLASS_SPEC = -8,
94 VAR_ERR_INCOMPLETE_GROUPED_HEX = -7,
95 VAR_ERR_INCOMPLETE_OCTAL = -6,
96 VAR_ERR_INVALID_OCTAL = -5,
97 VAR_ERR_OCTAL_TOO_LARGE = -4,
98 VAR_ERR_INVALID_HEX = -3,
99 VAR_ERR_INCOMPLETE_HEX = -2,
100 VAR_ERR_INCOMPLETE_NAMED_CHARACTER = -1,
105 typedef struct var_st var_t;
110 VAR_CONFIG_CB_OPERATION
114 char escape; /* default: '\' */
115 char delim_init; /* default: '$' */
116 char delim_open; /* default: '{' */
117 char delim_close; /* default: '}' */
118 char index_open; /* default: '[' */
119 char index_close; /* default: ']' */
120 char index_mark; /* default: '#' */
121 const char *name_chars; /* default: "a-zA-Z0-9_" */
124 typedef var_rc_t (*var_cb_value_t)(
125 var_t *var, void *ctx,
126 const char *var_ptr, int var_len, int var_inc, int var_idx,
127 const char **val_ptr, int *val_len, int *val_size
130 typedef var_rc_t (*var_cb_operation_t)(
131 var_t *var, void *ctx,
132 const char *op_ptr, int op_len,
133 const char *arg_ptr, int arg_len,
134 const char *val_ptr, int val_len,
135 const char **out_ptr, int *out_len, int *out_size
139 var_rc_t var_create (var_t **var);
140 var_rc_t var_destroy (var_t *var);
141 var_rc_t var_config (var_t *var, var_config_t mode, ...);
142 var_rc_t var_unescape (var_t *var, const char *src_ptr, int src_len, char *dst_ptr, int dst_len, int all);
143 var_rc_t var_expand (var_t *var, const char *src_ptr, int src_len, char **dst_ptr, int *dst_len, int force_expand);
144 var_rc_t var_formatv (var_t *var, char **dst_ptr, int force_expand, const char *fmt, va_list ap);
145 var_rc_t var_format (var_t *var, char **dst_ptr, int force_expand, const char *fmt, ...);
146 const char *var_strerror (var_t *var, var_rc_t rc);
148 #endif /* __VAR_H__ */