diff options
Diffstat (limited to 'include/argot/format.h')
-rw-r--r-- | include/argot/format.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/include/argot/format.h b/include/argot/format.h new file mode 100644 index 0000000..f989904 --- /dev/null +++ b/include/argot/format.h @@ -0,0 +1,62 @@ +/* argot - Gray's Extensible Configuration System -*- c -*- + Copyright (C) 2007-2016 Sergey Poznyakoff + + Grecs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3 of the License, or (at your + option) any later version. + + Grecs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Grecs. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef _ARGOT_FORMAT_H +#define _ARGOT_FORMAT_H + +#include <argot/value.h> +#include <argot/locus.h> +#include <argot/node.h> +#include <argot/txtacc.h> + +struct argot_format_closure { + int (*fmtfun)(const char *, void *); + void *data; +}; + +void argot_format_locus(argot_locus_t *locus, struct argot_format_closure *fp); +void argot_format_node_path(struct argot_node *node, int flag, + struct argot_format_closure *fp); +void argot_format_value(struct argot_value *val, int flags, + struct argot_format_closure *fp); + +#define ARGOT_NODE_FLAG_PATH 0x00100 +#define ARGOT_NODE_FLAG_VALUE 0x00200 +#define ARGOT_NODE_FLAG_DESCEND 0x01000 +#define ARGOT_NODE_FLAG_LOCUS 0x02000 +#define ARGOT_NODE_FLAG_QUOTE 0x04000 +#define ARGOT_NODE_FLAG_NOQUOTE 0x08000 +#define ARGOT_NODE_FLAG_QUOTE_HEX 0x10000 + +#define _ARGOT_NODE_MASK_DELIM 0x000ff +#define _ARGOT_NODE_MASK_OUTPUT 0x00f00 + +#define ARGOT_NODE_FLAG_DEFAULT \ + (ARGOT_NODE_FLAG_PATH|ARGOT_NODE_FLAG_VALUE|\ + ARGOT_NODE_FLAG_DESCEND|ARGOT_NODE_FLAG_QUOTE) +int argot_format_node(struct argot_node *node, int flags, + struct argot_format_closure *fp); + +void argot_print_locus(argot_locus_t *locus, FILE *fp); +void argot_print_node_path(struct argot_node *node, int flag, FILE *fp); +void argot_print_value(struct argot_value *val, int flags, FILE *fp); + +int argot_print_node(struct argot_node *node, int flags, FILE *fp); + +void argot_txtacc_format_value(struct argot_value *val, int flags, + argot_txtacc_t acc); + +#endif |