head 1.26; access; symbols FSL_1_7_0:1.26 CFG_0_9_11:1.26 FSL_1_6_1:1.25 CFG_0_9_10:1.25 FSL_1_6_0:1.25 FSL_1_6b2:1.25 CFG_0_9_9:1.25 FSL_1_6b1:1.25 CFG_0_9_8:1.25 CFG_0_9_7:1.24 CFG_0_9_6:1.24 CFG_0_9_5:1.20 CFG_0_9_4:1.17 FSL_1_5_0:1.16 FSL_1_5a3:1.16 CFG_0_9_3:1.16 FSL_1_5a2:1.16 FSL_1_5a1:1.16 FSL_1_4_0:1.16 FSL_1_4b1:1.16 CFG_0_9_2:1.16 CFG_0_9_1:1.16 FSL_1_4a1:1.16 FSL_1_3_0:1.16 FSL_1_3b1:1.16 FSL_1_2_1:1.16 FSL_1_2_0:1.16 FSL_1_1_0:1.16 FSL_1_1b1:1.16 FSL_1_0_8:1.16 FSL_1_0_7:1.16 FSL_1_0_6:1.13 FSL_1_0_5:1.13 FSL_1_0_4:1.13 FSL_1_0_3:1.13 FSL_1_0_2:1.13 FSL_1_0_1:1.13 FSL_1_0_0:1.13 FSL_0_9_0:1.13 CFG_0_9_0:1.13 FSL_0_1_12:1.13 FSL_0_1_11:1.13 FSL_0_1_10:1.13 FSL_0_1_9:1.13 FSL_0_1_8:1.13 FSL_0_1_7:1.13 FSL_0_1_6:1.13 FSL_0_1_5:1.13 FSL_0_1_1:1.13; locks; strict; comment @ * @; 1.26 date 2006.08.10.19.35.57; author rse; state Exp; branches; next 1.25; commitid Isy241gp4yykKkIr; 1.25 date 2004.12.31.19.16.25; author rse; state Exp; branches; next 1.24; 1.24 date 2004.11.29.07.09.33; author rse; state Exp; branches; next 1.23; 1.23 date 2004.11.28.17.23.45; author rse; state Exp; branches; next 1.22; 1.22 date 2004.11.28.14.17.52; author rse; state Exp; branches; next 1.21; 1.21 date 2004.11.28.13.49.11; author rse; state Exp; branches; next 1.20; 1.20 date 2004.11.20.14.52.56; author rse; state Exp; branches; next 1.19; 1.19 date 2004.11.20.12.54.07; author rse; state Exp; branches; next 1.18; 1.18 date 2004.11.20.12.02.32; author rse; state Exp; branches; next 1.17; 1.17 date 2004.07.17.07.37.55; author rse; state Exp; branches; next 1.16; 1.16 date 2003.01.06.11.17.43; author rse; state Exp; branches; next 1.15; 1.15 date 2002.11.18.09.51.29; author rse; state Exp; branches; next 1.14; 1.14 date 2002.11.10.12.12.23; author rse; state Exp; branches; next 1.13; 1.13 date 2002.07.18.15.34.55; author rse; state Exp; branches; next 1.12; 1.12 date 2002.07.10.14.46.28; author rse; state Exp; branches; next 1.11; 1.11 date 2002.07.10.12.00.23; author rse; state Exp; branches; next 1.10; 1.10 date 2002.07.08.13.45.13; author rse; state Exp; branches; next 1.9; 1.9 date 2002.07.05.20.49.58; author rse; state Exp; branches; next 1.8; 1.8 date 2002.07.05.18.32.37; author rse; state Exp; branches; next 1.7; 1.7 date 2002.07.05.17.21.40; author rse; state Exp; branches; next 1.6; 1.6 date 2002.07.05.17.15.14; author rse; state Exp; branches; next 1.5; 1.5 date 2002.07.05.15.32.42; author rse; state Exp; branches; next 1.4; 1.4 date 2002.07.05.15.21.19; author rse; state Exp; branches; next 1.3; 1.3 date 2002.07.05.14.33.10; author rse; state Exp; branches; next 1.2; 1.2 date 2002.07.04.14.51.21; author rse; state Exp; branches; next 1.1; 1.1 date 2002.07.03.13.25.34; author rse; state Exp; branches; next ; desc @@ 1.26 log @cleanup source tree for status as of 2006 @ text @/* ** OSSP cfg - Configuration Parsing ** Copyright (c) 2002-2006 Ralf S. Engelschall ** Copyright (c) 2002-2006 The OSSP Project (http://www.ossp.org/) ** ** This file is part of OSSP cfg, a configuration parsing ** library which can be found at http://www.ossp.org/pkg/lib/cfg/. ** ** 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. ** ** cfg_syn.c: syntax parsing and formatting */ #include #include #include "cfg.h" #include "cfg_grid.h" #include "cfg_node.h" #include "cfg_fmt.h" #include "cfg_syn.h" #include "cfg_buf.h" #include "cfg_global.h" /* prototypes for Flex-generated scanner */ extern int cfg_syn_lex_init(void *); extern int cfg_syn_lex_destroy(void *); extern void cfg_syn_set_extra(void *, void *); /* prototypes for Bison-generated parser */ extern int cfg_syn_parse(void *); /* build a node tree according to a textual specification */ cfg_rc_t cfg_syn_import( cfg_t *cfg, cfg_node_t **node, const char *in_ptr, size_t in_len, char *err_buf, size_t err_len) { cfg_syn_ctx_t ctx; cfg_buf_t *buf; cfg_rc_t rc; void *yyscan; /* argument sanity checking */ if (node == NULL || in_ptr == NULL) return CFG_ERR_ARG; /* initialize scanner */ cfg_syn_lex_init(&yyscan); cfg_syn_set_extra(&ctx, yyscan); /* initialize temporary buffer context */ if ((rc = cfg_buf_create(&buf)) != CFG_OK) return rc; /* establish our own context which is passed through the parser and scanner */ ctx.inputptr = in_ptr; ctx.inputbuf = in_ptr; ctx.inputlen = in_len; ctx.cfg = cfg; ctx.node = NULL; ctx.rv = CFG_OK; ctx.buf = buf; ctx.err_buf = err_buf; ctx.err_len = err_len; ctx.yyscan = yyscan; /* start the parser loop */ if (cfg_syn_parse(&ctx)) ctx.rv = (ctx.rv == CFG_OK ? CFG_ERR_INT : ctx.rv); /* destroy temporary buffer */ cfg_buf_destroy(buf); /* destroy scanner */ cfg_syn_lex_destroy(yyscan); /* provide root/top-level node as result */ *node = ctx.node; return ctx.rv; } /* helper function for copying out input with escaping of characters */ static size_t cfg_syn_error_cpyout(char *out_ptr, const char *in_ptr, size_t in_len) { size_t out_len; char c; out_len = 0; while (in_len-- > 0) { c = *in_ptr++; switch (c) { case '\n': *out_ptr++ = '\\'; *out_ptr++ = 'n'; out_len += 2; break; case '\r': *out_ptr++ = '\\'; *out_ptr++ = 'r'; out_len += 2; break; case '\t': *out_ptr++ = '\\'; *out_ptr++ = 't'; out_len += 2; break; case '\b': *out_ptr++ = '\\'; *out_ptr++ = 'b'; out_len += 2; break; case '\f': *out_ptr++ = '\\'; *out_ptr++ = 'f'; out_len += 2; break; default: { if (!isprint((int)c)) { *out_ptr++ = '\\'; *out_ptr++ = '?'; out_len += 2; } else { *out_ptr++ = c; out_len++; } } } } return out_len; } /* remember a parsing error (used internally) */ void cfg_syn_error(cfg_syn_ctx_t *ctx, cfg_rc_t rv, YYLTYPE *loc, const char *fmt, ...) { va_list ap; const char *cpF, *cpL; const char *cpP, *cpE; int line, column; char *cpBuf; char *cp; size_t n; /* remember error code */ ctx->rv = rv; /* short circuit processing if no error buffer exists */ if (ctx->err_buf == NULL || ctx->err_len <= 0) return; /* determine first and last positions of token */ cpF = ctx->inputbuf+loc->first; if (cpF < ctx->inputbuf) cpF = ctx->inputbuf; if (cpF > ctx->inputbuf+ctx->inputlen) cpF = ctx->inputbuf+ctx->inputlen; cpL = ctx->inputbuf+loc->last; if (cpL < ctx->inputbuf) cpL = ctx->inputbuf; if (cpL > ctx->inputbuf+ctx->inputlen) cpL = ctx->inputbuf+ctx->inputlen; /* determine epilog and prolog of token */ cpP = cpF-4; if (cpP < ctx->inputbuf) cpP = ctx->inputbuf; cpE = cpL+4; if (cpE > ctx->inputbuf+ctx->inputlen) cpE = ctx->inputbuf+ctx->inputlen; /* calculate line and column of token */ line = 1; column = 1; for (cp = (char *)ctx->inputbuf; cp < (ctx->inputbuf+ctx->inputlen) && cp != cpF; cp++) { column++; if (*cp == '\n') { column = 1; line++; } } /* extract token context with mark token borders */ if ((cpBuf = malloc((size_t)(((cpE-cpP)*2)+2+1))) == NULL) return; cp = cpBuf; cp += cfg_syn_error_cpyout(cp, cpP, cpF-cpP); *cp++ = '<'; cp += cfg_syn_error_cpyout(cp, cpF, cpL-cpF); *cp++ = '>'; cp += cfg_syn_error_cpyout(cp, cpL, cpE-cpL); *cp++ = '\0'; /* remember parsing error: part I (context part) */ cfg_fmt_sprintf(ctx->err_buf, ctx->err_len, "line %d, column %d: `%s': ", line, column, cpBuf); free(cpBuf); /* remember parsing error: part II (parsing part) */ n = strlen(ctx->err_buf); va_start(ap, fmt); cfg_fmt_vsprintf(ctx->err_buf+n, ctx->err_len-n, fmt, ap); va_end(ap); return; } /* internal cfg_syn_export structure */ typedef struct { cfg_t *cfg; cfg_buf_t *buf; int indent; } export_t; /* internal cfg_syn_export helper function: sprintf(3) style output formatting */ static void export_format(export_t *ctx, char *fmt, ...) { int i; char *cp; char *cp2; va_list ap; char *str; va_start(ap, fmt); if ((str = cfg_fmt_vasprintf(fmt, ap)) == NULL) return; cp = str; while ((cp2 = strchr(cp, '\n')) != NULL) { cfg_buf_format(ctx->buf, "%.*s", cp2-cp+1, cp); for (i = 0; i < ctx->indent; i++) cfg_buf_format(ctx->buf, " "); cp = cp2+1; } if (cp[0] != '\0') cfg_buf_format(ctx->buf, "%s", cp); free(str); va_end(ap); return; } /* internal cfg_syn_export helper function: indentation handling */ static void export_indent(export_t *ctx, signed int n) { if (n > 0) { while (n > 0) { n--; ctx->indent++; cfg_buf_format(ctx->buf, " "); } } else { while (n < 0 && ctx->indent > 0) { n++; ctx->indent--; cfg_buf_resize(ctx->buf, -4); } } } /* internal cfg_syn_export helper function: token output formatting */ static void export_token(export_t *ctx, const char *token) { const char *cp; char *out; int plain; char c; plain = 1; for (cp = token; *cp != '\0'; cp++) { if ( !isprint((int)(*cp)) || strchr(" \n\r\t\b\f;{}\\\"'", (int)(*cp)) != NULL) { plain = 0; break; } } if (plain) export_format(ctx, "%s", token); else { export_format(ctx, "\""); cp = token; while ((c = *cp++) != '\0') { out = NULL; switch (c) { case '\n': out = "\\n"; break; case '\r': out = "\\r"; break; case '\t': out = "\\t"; break; case '\b': out = "\\b"; break; case '\f': out = "\\f"; break; case '\\': out = "\\\\"; break; case '"' : out = "\\\""; break; } if (out != NULL) export_format(ctx, "%s", out); else { if (isprint((int)c)) export_format(ctx, "%c", c); else export_format(ctx, "\\x%02x", c); } } export_format(ctx, "\""); } return; } /* internal cfg_syn_export helper function: recursive node processing */ static void export_node(export_t *ctx, cfg_node_t *node) { cfg_node_type_t type; cfg_node_t *node2; cfg_rc_t rc; char *token; if ((rc = cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_TYPE, &type)) != CFG_OK) return; if (type == CFG_NODE_TYPE_SEQ) { /* node is a sequence */ export_format(ctx, "{\n"); export_indent(ctx, 1); cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_CHILD1, &node2); while (node2 != NULL) { export_node(ctx, node2); /* recursion */ cfg_node_get(ctx->cfg, node2, CFG_NODE_ATTR_RBROTH, &node2); } export_indent(ctx, -1); export_format(ctx, "}"); } else if (type == CFG_NODE_TYPE_DIR) { /* node is a directive */ cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_CHILD1, &node2); while (node2 != NULL) { export_node(ctx, node2); /* recursion */ cfg_node_get(ctx->cfg, node2, CFG_NODE_ATTR_RBROTH, &node2); if (node2 != NULL) export_format(ctx, " "); } cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_RBROTH, &node2); if (node2 != NULL) export_format(ctx, ";"); export_format(ctx, "\n"); } else if (type == CFG_NODE_TYPE_ARG) { /* node is a token */ cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_TOKEN, &token); if (token != NULL) export_token(ctx, token); else export_format(ctx, ""); } return; } /* export configuration node tree into textual OSSP cfg syntax */ cfg_rc_t cfg_syn_export( cfg_t *cfg, cfg_node_t *node, char **output) { cfg_buf_t *buf; cfg_rc_t rc; export_t ctx; cfg_node_t *root; if (node == NULL || output == NULL) return CFG_ERR_ARG; if ((rc = cfg_buf_create(&buf)) != CFG_OK) return rc; ctx.cfg = cfg; ctx.buf = buf; ctx.indent = 0; if ((rc = cfg_node_root(cfg, NULL, &root)) != CFG_OK) return rc; if (node == root) { /* if we dump the whole configuration, treat the first SEQ node special because of the implicit braces around it. So expand it manually instead of just calling once export_node(&ctx, node); */ cfg_node_get(cfg, node, CFG_NODE_ATTR_CHILD1, &node); while (node != NULL) { export_node(&ctx, node); cfg_node_get(cfg, node, CFG_NODE_ATTR_RBROTH, &node); } } else { export_node(&ctx, node); } cfg_buf_content(buf, output, NULL, NULL); cfg_buf_destroy(buf); return CFG_OK; } /* internal cfg_syn_destroy helper function: recursive node destruction */ static cfg_rc_t cfg_syn_destroy_node(cfg_t *cfg, cfg_node_t *node) { if (node == NULL) return CFG_ERR_ARG; if (node->child1 != NULL) cfg_syn_destroy_node(cfg, node->child1); /* recursion */ if (node->rbroth != NULL) cfg_syn_destroy_node(cfg, node->rbroth); /* recursion */ cfg_node_destroy(cfg, node); return CFG_OK; } /* destroy syntax node tree */ cfg_rc_t cfg_syn_destroy(cfg_t *cfg, cfg_node_t *node) { if (node == NULL) return CFG_ERR_ARG; cfg_syn_destroy_node(cfg, node); return CFG_OK; } @ 1.25 log @Adjust copyright messages for new year 2005. @ text @d3 2 a4 3 ** Copyright (c) 2002-2005 Ralf S. Engelschall ** Copyright (c) 2002-2005 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2002-2005 Cable & Wireless (http://www.cw.com/) @ 1.24 log @Fix optional DMalloc build support. @ text @d3 3 a5 3 ** Copyright (c) 2002-2004 Ralf S. Engelschall ** Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2002-2004 Cable & Wireless (http://www.cw.com/) @ 1.23 log @Replace fixed-size token buffer in scanner by a dynamic buffer (cfg_buf_t). This eliminates the old 1024 size limit on tokens and makes the scanner more robust. @ text @a34 1 #include "cfg_global.h" d40 1 @ 1.22 log @Fix annotational error reporting in scanner/parser. @ text @d60 2 d72 4 d84 1 d93 3 @ 1.21 log @Escape non-printable characters of input extracts in error messages. @ text @d188 1 a188 1 "line %d, column %d: `%s'", d195 1 a195 1 cfg_fmt_vsprintf(ctx->err_buf+n, sizeof(ctx->err_len)-n, fmt, ap); @ 1.20 log @Change cfg_node_root() API function to be able to both set and/or get the root node. @ text @d95 31 d176 1 a176 1 if ((cpBuf = malloc((size_t)((cpE-cpP)+2+1))) == NULL) d179 1 a179 2 n = cpF-cpP; memcpy(cp, cpP, n); cp += n; d181 1 a181 2 n = cpL-cpF; memcpy(cp, cpF, n); cp += n; d183 1 a183 2 n = cpE-cpL; memcpy(cp, cpL, n); cp += n; @ 1.19 log @- Fixed cfg_test program by correctly passing the used number of bytes in the buffer instead of the size of the buffer. - Accept zero-length strings for parsing. - Correctly handle end-of-file during plain text token scanning. @ text @d338 1 a338 1 if ((rc = cfg_node_root(cfg, &root)) != CFG_OK) @ 1.18 log @annotate code with more comments @ text @d63 1 a63 1 if (node == NULL || in_ptr == NULL || in_len == 0) @ 1.17 log @Adjust copyright messages for new year 2004. @ text @d28 1 a28 1 ** cfg_syn.c: syntax parsing d173 1 d180 1 d206 1 d225 1 d271 1 d282 1 d287 1 a287 1 export_node(ctx, node2); d294 1 d297 1 a297 1 export_node(ctx, node2); d308 1 d318 1 d360 1 d366 1 a366 1 cfg_syn_destroy_node(cfg, node->child1); d368 1 a368 1 cfg_syn_destroy_node(cfg, node->rbroth); d373 1 @ 1.16 log @update copyright messages for new year @ text @d3 3 a5 3 ** Copyright (c) 2002-2003 Ralf S. Engelschall ** Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/) @ 1.15 log @add Dmalloc support @ text @d3 3 a5 3 ** Copyright (c) 1999-2002 Ralf S. Engelschall ** Copyright (c) 1999-2002 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/) @ 1.14 log @remove trailing whitespaces @ text @d35 1 @ 1.13 log @flush work of today: first cut for real cfg_node_select() @ text @d51 2 a52 2 cfg_t *cfg, cfg_node_t **node, d55 1 a55 1 char *err_buf, d60 1 a60 1 d69 1 a69 1 /* establish our own context which is passed d158 1 a158 1 cfg_fmt_sprintf(ctx->err_buf, ctx->err_len, d230 1 a230 1 if ( !isprint((int)(*cp)) d310 2 a311 2 cfg_t *cfg, cfg_node_t *node, @ 1.12 log @Step 2 in API overhauling and implementation filling. @ text @d273 2 a274 1 rc = cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_TYPE, &type); d317 1 d328 13 a340 4 /* first SEQ node is special, so expand it manually instead of just calling once export_node(&ctx, node); */ cfg_node_get(cfg, node, CFG_NODE_ATTR_CHILD1, &node); while (node != NULL) { a341 1 cfg_node_get(cfg, node, CFG_NODE_ATTR_RBROTH, &node); @ 1.11 log @Mega-change: full API overhauling. @ text @d53 4 a56 2 const char *input, char *err_buf, size_t err_len) d62 1 a62 1 if (node == NULL || input == NULL) d71 3 a73 3 ctx.inputptr = input; ctx.inputbuf = input; ctx.inputlen = strlen(input); @ 1.10 log @add more error checking @ text @d171 1 d271 1 a271 1 rc = cfg_node_get(node, CFG_NODE_ATTR_TYPE, &type); d275 1 a275 1 cfg_node_goto(node, CFG_NODE_GOTO_CHILD1, &node2); d278 1 a278 1 cfg_node_goto(node2, CFG_NODE_GOTO_RBROTH, &node2); d284 1 a284 1 cfg_node_goto(node, CFG_NODE_GOTO_CHILD1, &node2); d287 1 a287 1 cfg_node_goto(node2, CFG_NODE_GOTO_RBROTH, &node2); d291 1 a291 1 cfg_node_goto(node, CFG_NODE_GOTO_RBROTH, &node2); d296 2 a297 2 else if (type == CFG_NODE_TYPE_TOK) { cfg_node_get(node, CFG_NODE_ATTR_TOKEN, &token); d320 1 d326 1 a326 1 cfg_node_goto(node, CFG_NODE_GOTO_CHILD1, &node); d329 1 a329 1 cfg_node_goto(node, CFG_NODE_GOTO_RBROTH, &node); d338 1 a338 1 static cfg_rc_t cfg_syn_destroy_node(cfg_node_t *node) d343 1 a343 1 cfg_syn_destroy_node(node->child1); d345 2 a346 2 cfg_syn_destroy_node(node->rbroth); cfg_node_destroy(node); d354 1 a354 1 cfg_syn_destroy_node(node); @ 1.9 log @More scanner enhancement for supporting Perl-style \x{HHHHHH} sequences and for better escaping in export output. @ text @d112 4 d117 4 @ 1.8 log @Add line-continuation support and make export output correctly quote the tokens. @ text @d32 1 d214 2 a215 1 int n; d217 9 a225 2 if (strcspn(token, " \n\r\t\b\f;{}\\\"'") == strlen(token)) /* plain text token */ d230 10 a239 4 while (*cp != '\0') { if ((n = strcspn(cp, "\n\r\t\b\f\\\"")) > 0) { export_format(ctx, "%.*s", n, cp); cp += n; d241 2 d244 4 a247 12 switch (*cp) { case '\n': out = "\\n"; break; case '\r': out = "\\r"; break; case '\t': out = "\\t"; break; case '\b': out = "\\b"; break; case '\f': out = "\\f"; break; case '\\': out = "\\\\"; break; case '"' : out = "\\\""; break; default : out = ""; } export_format(ctx, "%s", out); cp++; @ 1.7 log @remove top-level implicit indentation and sequence braces @ text @d211 6 a216 3 if (strcspn(token, " {};\\") != strlen(token)) export_format(ctx, "\"%s\"", token); else d218 25 @ 1.6 log @fix indentation in export output @ text @d273 1 d276 9 a284 1 export_node(&ctx, node); d287 1 @ 1.5 log @thanks to Dmalloc we can fix the memory holes @ text @d191 1 a191 1 static void export_indent(export_t *ctx, int n) d245 4 a248 1 export_format(ctx, ";\n"); @ 1.4 log @fix memory free @ text @d278 20 @ 1.3 log @Add support for Perl-like q(.)[^\1]\1 style quotations which allow one to place arbitrary stuff into a single syntax token. This is especially useful if you think about complex OSSP l2 or OSSP pcbe expressions which else had to be escaped into double- or single-quoted strings in order to be placed into a OSSP cfg syntax. @ text @d170 1 d177 3 a179 2 while ((cp = strchr(str, '\n')) != NULL) { cfg_buf_format(ctx->buf, "%.*s", cp-str+1, str); d182 1 a182 1 str = cp+1; d184 2 a185 2 if (str[0] != '\0') cfg_buf_format(ctx->buf, "%s", str); @ 1.2 log @Flush today's work: the library is now able to parse a .cfg file into an internal node tree and export this again in textual .cfg file format (including indented blocks). @ text @d147 2 a148 2 cfg_fmt_sprintf(ctx->err_buf, sizeof(ctx->err_len), "line %d, column %d: `%s'; %s", @ 1.1 log @Add this first cut for the forthcoming OSSP cfg library to CVS. This is work in progress and still not ready for use anywhere. @ text @d31 2 d38 1 d49 5 a53 1 cfg_rc_t cfg_syn(cfg_t *cfg, cfg_node_t **node, char *err_buf, size_t err_len, const char *input) d57 4 d159 115 @