head 1.33; access; symbols LMTP2NNTP_1_4_1:1.33 LMTP2NNTP_1_4_0:1.33 VAR_1_1_3:1.33 VAR_1_1_2:1.32 VAR_1_1_1:1.31 LMTP2NNTP_1_3_0:1.31 LMTP2NNTP_1_3b2:1.31 LMTP2NNTP_1_3b1:1.31 LMTP2NNTP_1_3a3:1.31 LMTP2NNTP_1_3a2:1.31 LMTP2NNTP_1_3a1:1.31 VAR_1_1_0:1.31 VAR_1_0_0:1.30 LMTP2NNTP_1_2_0:1.29 LMTP2NNTP_1_2b4:1.29 LMTP2NNTP_1_2b3:1.29 LMTP2NNTP_1_2b2:1.29 LMTP2NNTP_1_2b1:1.29 LMTP2NNTP_1_2a8:1.29 LMTP2NNTP_1_2a7:1.29 LMTP2NNTP_1_2a6:1.29 LMTP2NNTP_1_2a5:1.29 LMTP2NNTP_1_2a4:1.29 VAR_0_9_0:1.29 LMTP2NNTP_1_2a3:1.27 OSSP_RC_SPEC:1.22; locks; strict; comment @ * @; 1.33 date 2005.01.20.20.29.06; author rse; state Exp; branches; next 1.32; 1.32 date 2004.10.29.19.42.20; author rse; state Exp; branches; next 1.31; 1.31 date 2004.04.04.08.07.34; author rse; state Exp; branches; next 1.30; 1.30 date 2003.02.14.21.17.07; author rse; state Exp; branches; next 1.29; 1.29 date 2002.03.08.12.55.52; author rse; state Exp; branches; next 1.28; 1.28 date 2002.03.07.12.11.09; author rse; state Exp; branches; next 1.27; 1.27 date 2002.03.04.11.53.27; author rse; state Exp; branches; next 1.26; 1.26 date 2002.02.28.12.40.01; author thl; state Exp; branches; next 1.25; 1.25 date 2002.02.28.08.48.44; author rse; state Exp; branches; next 1.24; 1.24 date 2002.02.28.08.08.16; author rse; state Exp; branches; next 1.23; 1.23 date 2002.02.27.13.44.16; author rse; state Exp; branches; next 1.22; 1.22 date 2002.01.30.19.37.14; author rse; state Exp; branches; next 1.21; 1.21 date 2002.01.02.17.12.18; author rse; state Exp; branches; next 1.20; 1.20 date 2001.12.17.10.29.43; author rse; state Exp; branches; next 1.19; 1.19 date 2001.12.16.23.40.16; author rse; state Exp; branches; next 1.18; 1.18 date 2001.12.14.13.47.01; author rse; state Exp; branches; next 1.17; 1.17 date 2001.12.12.16.51.20; author simons; state Exp; branches; next 1.16; 1.16 date 2001.12.08.16.27.57; author simons; state Exp; branches; next 1.15; 1.15 date 2001.12.04.13.37.27; author simons; state Exp; branches; next 1.14; 1.14 date 2001.12.03.10.51.27; author simons; state Exp; branches; next 1.13; 1.13 date 2001.11.19.16.09.44; author simons; state Exp; branches; next 1.12; 1.12 date 2001.11.19.16.07.15; author simons; state Exp; branches; next 1.11; 1.11 date 2001.11.19.15.56.17; author thl; state Exp; branches; next 1.10; 1.10 date 2001.11.14.15.55.09; author ms; state Exp; branches; next 1.9; 1.9 date 2001.11.14.12.05.26; author rse; state Exp; branches; next 1.8; 1.8 date 2001.11.14.12.02.40; author rse; state Exp; branches; next 1.7; 1.7 date 2001.11.14.11.11.01; author rse; state Exp; branches; next 1.6; 1.6 date 2001.11.14.11.04.12; author ms; state Exp; branches; next 1.5; 1.5 date 2001.11.13.14.42.57; author simons; state Exp; branches; next 1.4; 1.4 date 2001.11.13.14.36.55; author simons; state Exp; branches; next 1.3; 1.3 date 2001.11.13.12.46.24; author simons; state Exp; branches; next 1.2; 1.2 date 2001.11.13.12.15.42; author simons; state Exp; branches; next 1.1; 1.1 date 2001.11.13.12.08.30; author simons; state Exp; branches; next ; desc @@ 1.33 log @Bumped year in copyright messages for new year 2005 @ text @/* ** OSSP var - Variable Expansion ** Copyright (c) 2001-2005 Ralf S. Engelschall ** Copyright (c) 2001-2005 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001-2005 Cable & Wireless (http://www.cw.com/) ** ** This file is part of OSSP var, a variable expansion ** library which can be found at http://www.ossp.org/pkg/lib/var/. ** ** Permission to use, copy, modify, and distribute this software for ** any purpose with or without fee is hereby granted, provided that ** the above copyright notice and this permission notice appear in all ** copies. ** ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** var.h: library API */ #ifndef __VAR_H__ #define __VAR_H__ /* required system headers */ #include #include /* minimum C++ support */ #ifdef __cplusplus #define DECLARATION_BEGIN extern "C" { #define DECLARATION_END } #else #define DECLARATION_BEGIN #define DECLARATION_END #endif DECLARATION_BEGIN /* error codes */ typedef enum { VAR_ERR_CALLBACK = -64, VAR_ERR_FORMATTING_FAILURE = -45, VAR_ERR_UNDEFINED_OPERATION = -44, VAR_ERR_MALFORMED_OPERATION_ARGUMENTS = -43, VAR_ERR_INVALID_CHAR_IN_LOOP_LIMITS = -42, VAR_ERR_UNTERMINATED_LOOP_CONSTRUCT = -41, VAR_ERR_DIVISION_BY_ZERO_IN_INDEX = -40, VAR_ERR_UNCLOSED_BRACKET_IN_INDEX = -39, VAR_ERR_INCOMPLETE_INDEX_SPEC = -37, VAR_ERR_INVALID_CHAR_IN_INDEX_SPEC = -36, VAR_ERR_ARRAY_LOOKUPS_ARE_UNSUPPORTED = -35, VAR_ERR_INCOMPLETE_QUOTED_PAIR = -34, VAR_ERR_INVALID_ARGUMENT = -34, VAR_ERR_SUBMATCH_OUT_OF_RANGE = -33, VAR_ERR_UNKNOWN_QUOTED_PAIR_IN_REPLACE = -32, VAR_ERR_EMPTY_PADDING_FILL_STRING = -31, VAR_ERR_MISSING_PADDING_WIDTH = -30, VAR_ERR_MALFORMATTED_PADDING = -29, VAR_ERR_INCORRECT_TRANSPOSE_CLASS_SPEC = -28, VAR_ERR_EMPTY_TRANSPOSE_CLASS = -27, VAR_ERR_TRANSPOSE_CLASSES_MISMATCH = -26, VAR_ERR_MALFORMATTED_TRANSPOSE = -25, VAR_ERR_OFFSET_LOGIC = -24, VAR_ERR_OFFSET_OUT_OF_BOUNDS = -23, VAR_ERR_RANGE_OUT_OF_BOUNDS = -22, VAR_ERR_INVALID_OFFSET_DELIMITER = -21, VAR_ERR_MISSING_START_OFFSET = -20, VAR_ERR_EMPTY_SEARCH_STRING = -19, VAR_ERR_MISSING_PARAMETER_IN_COMMAND = -18, VAR_ERR_INVALID_REGEX_IN_REPLACE = -17, VAR_ERR_UNKNOWN_REPLACE_FLAG = -16, VAR_ERR_MALFORMATTED_REPLACE = -15, VAR_ERR_UNKNOWN_COMMAND_CHAR = -14, VAR_ERR_INPUT_ISNT_TEXT_NOR_VARIABLE = -13, VAR_ERR_UNDEFINED_VARIABLE = -12, VAR_ERR_INCOMPLETE_VARIABLE_SPEC = -11, VAR_ERR_OUT_OF_MEMORY = -10, VAR_ERR_INVALID_CONFIGURATION = -9, VAR_ERR_INCORRECT_CLASS_SPEC = -8, VAR_ERR_INCOMPLETE_GROUPED_HEX = -7, VAR_ERR_INCOMPLETE_OCTAL = -6, VAR_ERR_INVALID_OCTAL = -5, VAR_ERR_OCTAL_TOO_LARGE = -4, VAR_ERR_INVALID_HEX = -3, VAR_ERR_INCOMPLETE_HEX = -2, VAR_ERR_INCOMPLETE_NAMED_CHARACTER = -1, VAR_OK = 0 } var_rc_t; /* opaque data type */ struct var_st; typedef struct var_st var_t; /* var_config() modes */ typedef enum { VAR_CONFIG_SYNTAX, VAR_CONFIG_CB_VALUE, VAR_CONFIG_CB_OPERATION } var_config_t; /* VAR_CONFIG_SYNTAX type */ typedef struct { char escape; /* default: '\' */ char delim_init; /* default: '$' */ char delim_open; /* default: '{' */ char delim_close; /* default: '}' */ char index_open; /* default: '[' */ char index_close; /* default: ']' */ char index_mark; /* default: '#' */ char *name_chars; /* default: "a-zA-Z0-9_" */ } var_syntax_t; /* VAR_CONFIG_CB_VALUE type */ typedef var_rc_t (*var_cb_value_t)( var_t *var, void *ctx, const char *var_ptr, size_t var_len, int var_idx, const char **val_ptr, size_t *val_len, size_t *val_size ); /* VAR_CONFIG_CB_OPERATION type */ typedef var_rc_t (*var_cb_operation_t)( var_t *var, void *ctx, const char *op_ptr, size_t op_len, const char *arg_ptr, size_t arg_len, const char *val_ptr, size_t val_len, const char **out_ptr, size_t *out_len, size_t *out_size ); /* library API identification */ extern const char var_id[]; /* library API functions */ var_rc_t var_create (var_t **var); var_rc_t var_destroy (var_t *var); var_rc_t var_config (var_t *var, var_config_t mode, ...); var_rc_t var_unescape (var_t *var, const char *src_ptr, size_t src_len, char *dst_ptr, size_t dst_len, int all); var_rc_t var_expand (var_t *var, const char *src_ptr, size_t src_len, char **dst_ptr, size_t *dst_len, int force_expand); var_rc_t var_formatv (var_t *var, char **dst_ptr, int force_expand, const char *fmt, va_list ap); var_rc_t var_format (var_t *var, char **dst_ptr, int force_expand, const char *fmt, ...); var_rc_t var_strerror (var_t *var, var_rc_t rc, char **str); DECLARATION_END #endif /* __VAR_H__ */ @ 1.32 log @o Various code comment cleanups. o Fixed dmalloc support. @ text @d3 3 a5 3 ** Copyright (c) 2001-2004 Ralf S. Engelschall ** Copyright (c) 2001-2004 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001-2004 Cable & Wireless (http://www.cw.com/) @ 1.31 log @adjust copyrights @ text @d34 1 d38 12 a49 1 /* Error codes */ d100 1 d104 1 d111 1 d123 1 d126 1 a126 1 const char *var_ptr, size_t var_len, int var_idx, d130 1 d133 3 a135 3 const char *op_ptr, size_t op_len, const char *arg_ptr, size_t arg_len, const char *val_ptr, size_t val_len, d139 1 d142 1 d152 2 @ 1.30 log @final polishing for release 1.0.0 @ text @d3 3 a5 3 ** Copyright (c) 2001-2003 Ralf S. Engelschall ** Copyright (c) 2001-2003 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001-2003 Cable & Wireless Deutschland (http://www.cw.com/de/) @ 1.29 log @polishing and copyright extension (add natural person) @ text @d3 3 a5 3 ** Copyright (c) 2001-2002 Ralf S. Engelschall ** Copyright (c) 2001-2002 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/) @ 1.28 log @New API functions var_format and var_formatv which provide a convinience interface to printf-style expansion and variable expansion. var_format is like a combination of snprintf(3) and var_expand(). Example: Assume the variable value context gives "bar" for ${ARRAY[7]}, then the call.. var_format(var, &tmp, 1, "foo${ARRAY[%d]}quux", 7);o ..results in tmp containing the malloc(3)'ed string "foobarquux". Thanks to Thomas L. for providing the hint to this functionality. @ text @d3 1 @ 1.27 log @Add new important feature: user-supplied post-operation functions. This allows one to configure a var_cb_operation_t callback in the var_t context and allow it to implement functions triggered by ${name:%func[(arg)]}. This is especially intended for application-specific encoding and post-adjustment functions. @ text @d34 1 d39 1 d128 2 @ 1.26 log @prepare for API finally passing "val_t *" to callback, currently pass NULL @ text @d38 2 d90 2 a91 1 VAR_CONFIG_CB_VALUE d109 8 @ 1.25 log @URL fixing and additional documents @ text @d103 1 a103 1 void *ctx, @ 1.24 log @HEADS UPS: Mega-commit, revamping the whole library! - completely new API - completely new manual page @ text @d7 1 a7 1 ** library which can be found at http://www.ossp.org/pkg/var/. @ 1.23 log @style and text cleanups @ text @d80 1 a80 1 VAR_OK = 0 d83 2 a84 2 /* Expand quoted pairs to their binary representation. */ var_rc_t var_unescape(const char *src, size_t len, char *dst, int unescape_all); d86 4 a89 7 /* Prototype for the lookup callback used in var_expand(). */ typedef var_rc_t (*var_cb_t)( void *context, const char *varname, size_t name_len, int idx, const char **data, size_t *data_len, size_t *buffer_size ); a90 1 /* Configure the var_expand() parser's tokens. */ d92 15 a106 9 char varinit; /* '$' */ char startdelim; /* '{' */ char enddelim; /* '}' */ char startindex; /* '[' */ char endindex; /* ']' */ char current_index; /* '#' */ char escape; /* '\' */ char *namechars; /* 'a-zA-Z0-9_' */ } var_config_t; d108 1 a108 8 /* The default configuration */ extern const var_config_t var_config_default; /* Expand variable expressions in a text buffer. */ var_rc_t var_expand(const char *input, size_t input_len, char **result, size_t *result_len, var_cb_t lookup, void *lookup_context, const var_config_t *config, int force_expand); d110 6 a115 5 /* Map an error code to a text message. */ const char *var_strerror(var_rc_t rc); /* Unique library identifier. */ extern const char var_id[]; @ 1.22 log @add optional OSSP ex based exception handling support @ text @d2 1 a2 1 ** VAR - OSSP variable expression library. d6 1 a6 1 ** This file is part of OSSP VAR, an extensible data serialization d27 1 a27 1 ** var.h: VAR library API d35 1 a35 2 /* Error codes returned by the varexp library. */ d37 43 a79 43 VAR_ERR_CALLBACK = -64, VAR_ERR_INVALID_CHAR_IN_LOOP_LIMITS = -43, VAR_ERR_UNTERMINATED_LOOP_CONSTRUCT = -42, VAR_ERR_DIVISION_BY_ZERO_IN_INDEX = -41, VAR_ERR_UNCLOSED_BRACKET_IN_INDEX = -40, VAR_ERR_INCOMPLETE_INDEX_SPEC = -39, VAR_ERR_INVALID_CHAR_IN_INDEX_SPEC = -38, VAR_ERR_ARRAY_LOOKUPS_ARE_UNSUPPORTED = -37, VAR_ERR_INCOMPLETE_QUOTED_PAIR = -36, VAR_ERR_INVALID_ARGUMENT = -35, VAR_ERR_SUBMATCH_OUT_OF_RANGE = -34, VAR_ERR_UNKNOWN_QUOTED_PAIR_IN_REPLACE = -33, VAR_ERR_EMPTY_PADDING_FILL_STRING = -32, VAR_ERR_MISSING_PADDING_WIDTH = -31, VAR_ERR_MALFORMATTED_PADDING = -30, VAR_ERR_INCORRECT_TRANSPOSE_CLASS_SPEC = -29, VAR_ERR_EMPTY_TRANSPOSE_CLASS = -28, VAR_ERR_TRANSPOSE_CLASSES_MISMATCH = -27, VAR_ERR_MALFORMATTED_TRANSPOSE = -26, VAR_ERR_OFFSET_LOGIC = -25, VAR_ERR_OFFSET_OUT_OF_BOUNDS = -24, VAR_ERR_RANGE_OUT_OF_BOUNDS = -23, VAR_ERR_INVALID_OFFSET_DELIMITER = -22, VAR_ERR_MISSING_START_OFFSET = -21, VAR_ERR_EMPTY_SEARCH_STRING = -20, VAR_ERR_MISSING_PARAMETER_IN_COMMAND = -19, VAR_ERR_INVALID_REGEX_IN_REPLACE = -18, VAR_ERR_UNKNOWN_REPLACE_FLAG = -17, VAR_ERR_MALFORMATTED_REPLACE = -16, VAR_ERR_UNKNOWN_COMMAND_CHAR = -14, VAR_ERR_INPUT_ISNT_TEXT_NOR_VARIABLE = -13, VAR_ERR_UNDEFINED_VARIABLE = -12, VAR_ERR_INCOMPLETE_VARIABLE_SPEC = -11, VAR_ERR_OUT_OF_MEMORY = -10, VAR_ERR_INVALID_CONFIGURATION = -9, VAR_ERR_INCORRECT_CLASS_SPEC = -8, VAR_ERR_INCOMPLETE_GROUPED_HEX = -7, VAR_ERR_INCOMPLETE_OCTAL = -6, VAR_ERR_INVALID_OCTAL = -5, VAR_ERR_OCTAL_TOO_LARGE = -4, VAR_ERR_INVALID_HEX = -3, VAR_ERR_INCOMPLETE_HEX = -2, VAR_ERR_INCOMPLETE_NAMED_CHARACTER = -1, d84 1 a84 3 var_rc_t var_unescape(const char *src, size_t len, char *dst, int unescape_all); d87 2 a88 2 typedef var_rc_t (*var_cb_t) (void *context, d91 2 a92 1 size_t *buffer_size); a94 1 d105 2 a109 1 d111 3 a113 3 char **result, size_t *result_len, var_cb_t lookup, void *lookup_context, const var_config_t *config, int force_expand); a115 1 d118 1 a118 1 /* unique library identifier */ @ 1.21 log @bump copyright year @ text @d119 4 a122 1 const char* var_strerror(var_rc_t rc); @ 1.20 log @Finally adjust return code semantics of var_cb_t to use var_rc_t only. @ text @d3 2 a4 2 ** Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) @ 1.19 log @Implemented loops with explicit start, stop, and step values. @ text @d91 1 a91 1 typedef int (*var_cb_t) (void *context, @ 1.18 log @Get rid of the following warnings under "gcc -O2 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-align -Winline -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-long-long": var.h:91: warning: declaration of `index' shadows global declaration var.c: In function `expression': var.c:693: warning: declaration of `index' shadows global declaration var.c: At top level: var.c:1769: warning: declaration of `varname' shadows global declaration var.c:1769: warning: declaration of `index' shadows global declaration var.c: In function `lookup_wrapper': var.c:1772: warning: declaration of `index' shadows global declaration var.c:1772: warning: declaration of `varname' shadows global declaration var_test.c:13: warning: declaration of `index' shadows global declaration var_test.c: In function `var_lookup': var_test.c:16: warning: declaration of `index' shadows global declaration @ text @d39 1 @ 1.17 log @Implemented the looping construct. However, there are still some semantical issues that need to be clarified before the code is stable. @ text @d91 1 a91 1 const char *varname, size_t name_len, int index, @ 1.16 log @Implemented division-by-zero error. @ text @d39 1 @ 1.15 log @Added the return codes VAR_ERR_UNCLOSED_BRACKET_IN_INDEX, VAR_ERR_INCOMPLETE_INDEX_SPEC, and VAR_ERR_INVALID_CHAR_IN_INDEX_SPEC, which are used by the index parser. @ text @d39 1 @ 1.14 log @Extended the interface of var_cb_t to support variable arrays. To customize your already existing lookup functions quickly to the new interface, just add the "int index" parameter to the function's prototype and add the lines if (index != 0) return VAR_ERR_ARRAY_LOOKUPS_ARE_UNSUPPORTED; to the function itself. @ text @d39 3 @ 1.13 log @Cleaned the header file up. @ text @d39 1 d86 1 a86 1 const char *varname, size_t name_len, d96 3 @ 1.12 log @Implemented var_strerror(). @ text @d77 1 a77 13 /* Expand the following named characters to their binary representation: \t tab \n newline \r return \033 octal char \x1B hex char \x{263a} wide hex char Any other character quoted by a backslash is copied verbatim. */ d82 1 a82 23 /* The callback will be called by variable_expand(), providing the following parameters: context - passed through from variable_expand()'s parameters varname - pointer to the name of the variable to expand name_len - length of the string starting at varname data - location, where the callback should store the pointer to the contents of the looked-up variable data_len - location, where the callback should store the length of the data malloced_buffer - location, where the callback should store either TRUE or FALSE, telling the framework whether the buffer must be free(3)ed. The return code is interpreted as follows: >0 - OK 0 - undefined variable <0 - error */ a86 1 //FIXME THL: description "malloced_buffer" vs. prototype "size_t *buffer_size" d89 1 a89 11 /* This structure configures the parser's specials. I think, the fields are pretty self-explanatory. The only one worth mentioning is force_expand, which is a boolean. If set to TRUE, variable_expand() will fail with an error if the lookup callback returns "undefined variable". If set to FALSE, variable_expand() will copy the expression that failed verbatimly to the output so that another pass may expand it. The comments after each field show the default configuration. */ a96 1 //FIXME THL: should we support namechars with different first char, i.e. [a-z][a-z0-9]* d100 1 a100 8 /* variable_expand() will parse the contents of input for variable expressions and expand them using the provided lookup callback. The pointer to the resulting buffer is stored in result, its length in result_len. The buffer is always terminated by a '\0' byte, which is not included in the result_len count. The buffer must be free(3)ed by the caller. */ d106 2 a107 1 //FIXME THL: "force_expand" used here but described and unused above in "var_config_t" @ 1.11 log @THLs review @ text @d161 2 @ 1.10 log @Minor corrections. @ text @d121 1 d142 1 d159 1 @ 1.9 log @bugfix: make sure errors use different numbers @ text @d96 1 a96 1 following parameterns: d120 2 a121 2 const char **data, size_t * data_len, size_t * buffer_size); d154 1 a154 1 char **result, size_t * result_len, d156 1 a156 1 const var_config_t * config, int force_expand); @ 1.8 log @Safe time by cleaning up var_expand() myself instead of first writing down the wishes and having Peter do it himself afterwards: - use tokenbuf_init() instead of doing it manually - perform additional argument sanity checks - some minor coding style adjustments @ text @d39 1 a73 1 VAR_ERR_INCOMPLETE_QUOTED_PAIR = -1, @ 1.7 log @Rename the return codes VAR_XXX to VAR_ERR_XXX (except for VAR_OK) to be consistent with other OSSP libraries like L2. @ text @d39 1 @ 1.6 log @Removed tabs, fixed readability. @ text @d30 2 a31 2 #ifndef LIB_OSSP_VAR_H #define LIB_OSSP_VAR_H d38 35 a72 35 VAR_CALLBACK_ERROR = -64, VAR_SUBMATCH_OUT_OF_RANGE = -34, VAR_UNKNOWN_QUOTED_PAIR_IN_REPLACE = -33, VAR_EMPTY_PADDING_FILL_STRING = -32, VAR_MISSING_PADDING_WIDTH = -31, VAR_MALFORMATTED_PADDING = -30, VAR_INCORRECT_TRANSPOSE_CLASS_SPEC = -29, VAR_EMPTY_TRANSPOSE_CLASS = -28, VAR_TRANSPOSE_CLASSES_MISMATCH = -27, VAR_MALFORMATTED_TRANSPOSE = -26, VAR_OFFSET_LOGIC_ERROR = -25, VAR_OFFSET_OUT_OF_BOUNDS = -24, VAR_RANGE_OUT_OF_BOUNDS = -23, VAR_INVALID_OFFSET_DELIMITER = -22, VAR_MISSING_START_OFFSET = -21, VAR_EMPTY_SEARCH_STRING = -20, VAR_MISSING_PARAMETER_IN_COMMAND = -19, VAR_INVALID_REGEX_IN_REPLACE = -18, VAR_UNKNOWN_REPLACE_FLAG = -17, VAR_MALFORMATTED_REPLACE = -16, VAR_UNKNOWN_COMMAND_CHAR = -14, VAR_INPUT_ISNT_TEXT_NOR_VARIABLE = -13, VAR_UNDEFINED_VARIABLE = -12, VAR_INCOMPLETE_VARIABLE_SPEC = -11, VAR_OUT_OF_MEMORY = -10, VAR_INVALID_CONFIGURATION = -9, VAR_INCORRECT_CLASS_SPEC = -8, VAR_INCOMPLETE_GROUPED_HEX = -7, VAR_INCOMPLETE_OCTAL = -6, VAR_INVALID_OCTAL = -5, VAR_OCTAL_TOO_LARGE = -4, VAR_INVALID_HEX = -3, VAR_INCOMPLETE_HEX = -2, VAR_INCOMPLETE_NAMED_CHARACTER = -1, VAR_INCOMPLETE_QUOTED_PAIR = -1, d157 2 a158 1 #endif /* !defined(LIB_OSSP_VAR_H) */ @ 1.5 log @Reformatted the sources to Kernighan & Ritchie style according to the wishes of Ralf. @ text @d91 1 a91 1 int unescape_all); d118 3 a120 3 const char *varname, size_t name_len, const char **data, size_t * data_len, size_t * buffer_size); d135 5 a139 5 char varinit; /* '$' */ char startdelim; /* '{' */ char enddelim; /* '}' */ char escape; /* '\' */ char *namechars; /* 'a-zA-Z0-9_' */ d153 3 a155 3 char **result, size_t * result_len, var_cb_t lookup, void *lookup_context, const var_config_t * config, int force_expand); d157 1 a157 1 #endif /* !defined(LIB_OSSP_VAR_H) */ @ 1.4 log @Implemented submatching in regular expressions and added the appropriate test cases. @ text @d37 3 a39 4 typedef enum { VAR_CALLBACK_ERROR = -64, VAR_SUBMATCH_OUT_OF_RANGE = -34, d41 3 a43 3 VAR_EMPTY_PADDING_FILL_STRING = -32, VAR_MISSING_PADDING_WIDTH = -31, VAR_MALFORMATTED_PADDING = -30, d45 30 a74 31 VAR_EMPTY_TRANSPOSE_CLASS = -28, VAR_TRANSPOSE_CLASSES_MISMATCH = -27, VAR_MALFORMATTED_TRANSPOSE = -26, VAR_OFFSET_LOGIC_ERROR = -25, VAR_OFFSET_OUT_OF_BOUNDS = -24, VAR_RANGE_OUT_OF_BOUNDS = -23, VAR_INVALID_OFFSET_DELIMITER = -22, VAR_MISSING_START_OFFSET = -21, VAR_EMPTY_SEARCH_STRING = -20, VAR_MISSING_PARAMETER_IN_COMMAND = -19, VAR_INVALID_REGEX_IN_REPLACE = -18, VAR_UNKNOWN_REPLACE_FLAG = -17, VAR_MALFORMATTED_REPLACE = -16, VAR_UNKNOWN_COMMAND_CHAR = -14, VAR_INPUT_ISNT_TEXT_NOR_VARIABLE = -13, VAR_UNDEFINED_VARIABLE = -12, VAR_INCOMPLETE_VARIABLE_SPEC = -11, VAR_OUT_OF_MEMORY = -10, VAR_INVALID_CONFIGURATION = -9, VAR_INCORRECT_CLASS_SPEC = -8, VAR_INCOMPLETE_GROUPED_HEX = -7, VAR_INCOMPLETE_OCTAL = -6, VAR_INVALID_OCTAL = -5, VAR_OCTAL_TOO_LARGE = -4, VAR_INVALID_HEX = -3, VAR_INCOMPLETE_HEX = -2, VAR_INCOMPLETE_NAMED_CHARACTER = -1, VAR_INCOMPLETE_QUOTED_PAIR = -1, VAR_OK = 0 } var_rc_t; d90 2 a91 1 var_rc_t var_unescape(const char* src, size_t len, char* dst, int unescape_all); d117 4 a120 3 typedef int (*var_cb_t)(void* context, const char* varname, size_t name_len, const char** data, size_t* data_len, size_t* buffer_size); d134 7 a140 9 typedef struct { char varinit; /* '$' */ char startdelim; /* '{' */ char enddelim; /* '}' */ char escape; /* '\' */ char* namechars; /* 'a-zA-Z0-9_' */ } var_config_t; d152 4 a155 4 var_rc_t var_expand(const char* input, size_t input_len, char** result, size_t* result_len, var_cb_t lookup, void* lookup_context, const var_config_t* config, int force_expand); d157 1 a157 1 #endif /* !defined(LIB_OSSP_VAR_H) */ @ 1.3 log @- Added VAR_CALLBACK_ERROR define. - Renamed expand_named_characters() to var_unescape while adding the flag telling the function whether to expand anything or only constructs it knows. @ text @d40 2 @ 1.2 log @Added OSSP copyright header. @ text @d39 1 d90 1 a90 1 var_rc_t expand_named_characters(const char* src, size_t len, char* dst); @ 1.1 log @- Moved all routines into a single source file var.c. - Renamed varexp.h to var.h. - Removed odin-based build system. - Moved test cases into var_test.c. - Adapted build system. @ text @d1 31 a31 2 #ifndef LIB_VARIABLE_EXPAND_H #define LIB_VARIABLE_EXPAND_H d156 1 a156 1 #endif /* !defined(LIB_VARIABLE_EXPAND_H) */ @