aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--am/grecs.m416
-rw-r--r--configure.ac2
-rw-r--r--include/Makefile.am19
-rw-r--r--include/grecs.h40
-rw-r--r--include/grecs/.gitignore1
-rw-r--r--include/grecs/Makefile.am43
-rw-r--r--include/grecs/doc.h32
-rw-r--r--include/grecs/error.h38
-rw-r--r--include/grecs/format.h62
-rw-r--r--include/grecs/json.h (renamed from src/json.h)0
-rw-r--r--include/grecs/lex.h51
-rw-r--r--include/grecs/list.h55
-rw-r--r--include/grecs/locus.h (renamed from src/grecs-locus.h)23
-rw-r--r--include/grecs/mem.h33
-rw-r--r--include/grecs/node.h62
-rw-r--r--include/grecs/opt.h (renamed from src/grecsopt.h)4
-rw-r--r--include/grecs/parser.h53
-rw-r--r--include/grecs/preproc.h46
-rw-r--r--include/grecs/sockaddr.h66
-rw-r--r--include/grecs/symtab.h52
-rw-r--r--include/grecs/table.h98
-rw-r--r--include/grecs/tree.h71
-rw-r--r--include/grecs/txtacc.h36
-rw-r--r--include/grecs/types.h.in24
-rw-r--r--include/grecs/util.h26
-rw-r--r--include/grecs/value.h52
-rw-r--r--include/grecs/version.h40
-rw-r--r--include/wordsplit.h (renamed from src/wordsplit.h)0
-rw-r--r--src/Make-inst.am1
-rw-r--r--src/Make-shared.am6
-rw-r--r--src/Make-static.am1
-rw-r--r--src/Make.am14
-rw-r--r--src/bind-gram.y1
-rw-r--r--src/bind-lex.l1
-rw-r--r--src/cidr.c1
-rw-r--r--src/dhcpd-gram.y1
-rw-r--r--src/dhcpd-lex.l1
-rw-r--r--src/diag.c1
-rw-r--r--src/format.c2
-rw-r--r--src/grecs-gram.y1
-rw-r--r--src/grecs-lex.l1
-rw-r--r--src/grecs.hin584
-rw-r--r--src/json-gram.y4
-rw-r--r--src/json-lex.l3
-rw-r--r--src/jsonfmt.c3
-rw-r--r--src/lookup.c3
-rw-r--r--src/meta1-gram.y1
-rw-r--r--src/meta1-lex.l1
-rw-r--r--src/opthelp.c2
-rw-r--r--src/preproc.c3
-rw-r--r--src/sockaddr.c1
-rw-r--r--src/txtacc.c3
-rw-r--r--src/version.c1
-rw-r--r--tests/gcfenum.c1
-rw-r--r--tests/gcffmt.c1
-rw-r--r--tests/gcfpeek.c1
-rw-r--r--tests/gcfset.c1
-rw-r--r--tests/gcfver.c1
-rw-r--r--tests/json.c3
60 files changed, 1067 insertions, 629 deletions
diff --git a/Makefile.am b/Makefile.am
index e499bb4..3eaa8df 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,5 +16,5 @@
ACLOCAL_AMFLAGS = -I am
-SUBDIRS=. src @GRECS_TESTDIR@ @GRECS_DOCDIR@
+SUBDIRS=. include src @GRECS_TESTDIR@ @GRECS_DOCDIR@
EXTRA_DIST=build-aux/yyrename @GRECS_BUILD_AUX@ @GRECS_DISTDOC@ gitid.h
diff --git a/am/grecs.m4 b/am/grecs.m4
index 74b7840..60244a1 100644
--- a/am/grecs.m4
+++ b/am/grecs.m4
@@ -203,11 +203,12 @@ AC_DEFUN([GRECS_SETUP],[
AC_SUBST([GRECS_DISTCK_AT])
AC_SUBST([GRECS_README])
- AC_SUBST([GRECS_INCLUDES],['-I$(top_srcdir)/]grecsdir[src] [-I$(top_builddir)/]grecsdir[src]')
+ AC_SUBST([GRECS_INCLUDES],['-I$(top_srcdir)/]grecsdir[include] [-I$(top_builddir)/]grecsdir[include]')
AC_SUBST([GRECS_HOST_PROJECT_INCLUDES])
AC_SUBST([GRECS_DISTDOC])
AC_SUBST([GRECS_INCLUDE_DIR],['$(pkgincludedir)'])
-
+
_GRECS_OPTION_SWITCH([install],[
LT_INIT
+ GRECS_BUILD_TYPE=install
GRECS_LDADD=['$(top_builddir)/]grecsdir[src/libgrecs.la']
GRECS_DOCDIR='doc'
@@ -219,4 +220,5 @@ AC_DEFUN([GRECS_SETUP],[
],[shared],[
LT_INIT
+ GRECS_BUILD_TYPE=shared
GRECS_LDADD=['$(top_builddir)/]grecsdir[src/libgrecs.la']
GRECS_CHANGELOG='#'
@@ -225,4 +227,5 @@ AC_DEFUN([GRECS_SETUP],[
AC_CONFIG_FILES(grecsdir[src/Makefile]:grecsdir[src/Make-shared.in])
],[
+ GRECS_BUILD_TYPE=static
GRECS_LDADD=['$(top_builddir)/]grecsdir[src/libgrecs.a']
GRECS_CHANGELOG='#'
@@ -231,5 +234,12 @@ AC_DEFUN([GRECS_SETUP],[
AC_CONFIG_FILES(grecsdir[src/Makefile]:grecsdir[src/Make-static.in])
])
- AC_CONFIG_FILES(grecsdir[Makefile] grecsdir[src/grecs.h]:grecsdir[src/grecs.hin])
+ AM_CONDITIONAL([GRECS_COND_BUILD_INSTALL],[test $GRECS_BUILD_TYPE = install])
+ AM_CONDITIONAL([GRECS_COND_BUILD_SHARED],[test $GRECS_BUILD_TYPE = shared])
+ AM_CONDITIONAL([GRECS_COND_BUILD_STATIC],[test $GRECS_BUILD_TYPE = static])
+
+ AC_CONFIG_FILES(grecsdir[Makefile]
+ grecsdir[include/Makefile]
+ grecsdir[include/grecs/Makefile]
+ grecsdir[include/grecs/types.h]:grecsdir[include/grecs/types.h.in])
m4_popdef([grecsdir])
])
diff --git a/configure.ac b/configure.ac
index b923c9b..6ffa55b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,5 +17,5 @@
AC_PREREQ(2.63)
AC_INIT([libgrecs], [1.0], [gray+grecs@gnu.org.ua])
-AC_CONFIG_SRCDIR([src/grecs.hin])
+AC_CONFIG_SRCDIR([src/grecs-gram.y])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADER([config.h])
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 0000000..21a51e7
--- /dev/null
+++ b/include/Makefile.am
@@ -0,0 +1,19 @@
+SUBDIRS = grecs
+GRECS_HDR = grecs.h wordsplit.h
+
+if GRECS_COND_BUILD_INSTALL
+ include_HEADERS = $(GRECS_HDR)
+endif
+
+if GRECS_COND_BUILD_SHARED
+ if GRECS_COND_INSTALLHEADERS
+ grecsincludedir = @GRECS_INCLUDE_DIR@
+ grecsinclude_HEADERS = $(GRECS_HDR)
+ else
+ noinst_HEADERS = $(GRECS_HDR)
+ endif
+endif
+
+if GRECS_COND_BUILD_STATIC
+ noinst_HEADERS = $(GRECS_HDR)
+endif
diff --git a/include/grecs.h b/include/grecs.h
new file mode 100644
index 0000000..eac11d4
--- /dev/null
+++ b/include/grecs.h
@@ -0,0 +1,40 @@
+/* grecs - 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 _GRECS_H
+#define _GRECS_H
+
+#include <grecs/types.h>
+#include <grecs/version.h>
+#include <grecs/doc.h>
+#include <grecs/error.h>
+#include <grecs/format.h>
+#include <grecs/lex.h>
+#include <grecs/list.h>
+#include <grecs/locus.h>
+#include <grecs/mem.h>
+#include <grecs/node.h>
+#include <grecs/parser.h>
+#include <grecs/preproc.h>
+#include <grecs/sockaddr.h>
+#include <grecs/symtab.h>
+#include <grecs/table.h>
+#include <grecs/tree.h>
+#include <grecs/txtacc.h>
+#include <grecs/util.h>
+#include <grecs/value.h>
+
+#endif
diff --git a/include/grecs/.gitignore b/include/grecs/.gitignore
new file mode 100644
index 0000000..8cb8a05
--- /dev/null
+++ b/include/grecs/.gitignore
@@ -0,0 +1 @@
+types.h
diff --git a/include/grecs/Makefile.am b/include/grecs/Makefile.am
new file mode 100644
index 0000000..c239c1b
--- /dev/null
+++ b/include/grecs/Makefile.am
@@ -0,0 +1,43 @@
+GRECS_PKG_HDR =\
+ doc.h\
+ error.h\
+ format.h\
+ lex.h\
+ list.h\
+ locus.h\
+ mem.h\
+ node.h\
+ opt.h\
+ parser.h\
+ preproc.h\
+ sockaddr.h\
+ symtab.h\
+ table.h\
+ tree.h\
+ txtacc.h\
+ types.h\
+ util.h\
+ value.h\
+ version.h
+
+if GRECS_COND_JSON
+ GRECS_PKG_HDR += json.h
+endif
+
+if GRECS_COND_BUILD_INSTALL
+ grecsincludedir = @GRECS_INCLUDE_DIR@
+ grecsinclude_HEADERS = $(GRECS_PKG_HDR)
+endif
+
+if GRECS_COND_BUILD_SHARED
+ if GRECS_COND_INSTALLHEADERS
+ grecsincludedir = @GRECS_INCLUDE_DIR@
+ grecsinclude_HEADERS = $(GRECS_PKG_HDR)
+ else
+ noinst_HEADERS = $(GRECS_PKG_HDR)
+ endif
+endif
+
+if GRECS_COND_BUILD_STATIC
+ noinst_HEADERS = $(GRECS_PKG_HDR)
+endif
diff --git a/include/grecs/doc.h b/include/grecs/doc.h
new file mode 100644
index 0000000..b2514fb
--- /dev/null
+++ b/include/grecs/doc.h
@@ -0,0 +1,32 @@
+/* grecs - 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 _GRECS_DOC_H
+#define _GRECS_DOC_H
+
+#include <stdio.h>
+#include <grecs/table.h>
+
+void grecs_print_docstring(const char *docstring, unsigned level,
+ FILE *stream);
+void grecs_print_simple_statement(struct grecs_keyword *kwp,
+ unsigned level, FILE *stream);
+void grecs_print_block_statement(struct grecs_keyword *kwp,
+ unsigned level, FILE *stream);
+void grecs_print_statement_array(struct grecs_keyword *kwp,
+ unsigned n,
+ unsigned level, FILE *stream);
+#endif
diff --git a/include/grecs/error.h b/include/grecs/error.h
new file mode 100644
index 0000000..8630b8a
--- /dev/null
+++ b/include/grecs/error.h
@@ -0,0 +1,38 @@
+/* grecs - 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 _GRECS_ERROR_H
+#define _GRECS_ERROR_H
+
+#include <grecs/locus.h>
+
+extern int grecs_log_to_stderr;
+extern void (*grecs_log_setup_hook)(void);
+
+extern void (*grecs_print_diag_fun)(grecs_locus_t const *, int, int,
+ const char*);
+
+void grecs_warning(grecs_locus_t const *locus,
+ int errcode, const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 3, 4)));
+void grecs_error(grecs_locus_t const *locus, int errcode,
+ const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 3, 4)));
+
+int grecs_asprint_locus(char **locstr, size_t *size,
+ grecs_locus_t const *locus);
+
+#endif
diff --git a/include/grecs/format.h b/include/grecs/format.h
new file mode 100644
index 0000000..7ac8458
--- /dev/null
+++ b/include/grecs/format.h
@@ -0,0 +1,62 @@
+/* grecs - 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 _GRECS_FORMAT_H
+#define _GRECS_FORMAT_H
+
+#include <grecs/value.h>
+#include <grecs/locus.h>
+#include <grecs/node.h>
+#include <grecs/txtacc.h>
+
+struct grecs_format_closure {
+ int (*fmtfun)(const char *, void *);
+ void *data;
+};
+
+void grecs_format_locus(grecs_locus_t *locus, struct grecs_format_closure *fp);
+void grecs_format_node_path(struct grecs_node *node, int flag,
+ struct grecs_format_closure *fp);
+void grecs_format_value(struct grecs_value *val, int flags,
+ struct grecs_format_closure *fp);
+
+#define GRECS_NODE_FLAG_PATH 0x00100
+#define GRECS_NODE_FLAG_VALUE 0x00200
+#define GRECS_NODE_FLAG_DESCEND 0x01000
+#define GRECS_NODE_FLAG_LOCUS 0x02000
+#define GRECS_NODE_FLAG_QUOTE 0x04000
+#define GRECS_NODE_FLAG_NOQUOTE 0x08000
+#define GRECS_NODE_FLAG_QUOTE_HEX 0x10000
+
+#define _GRECS_NODE_MASK_DELIM 0x000ff
+#define _GRECS_NODE_MASK_OUTPUT 0x00f00
+
+#define GRECS_NODE_FLAG_DEFAULT \
+ (GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE|\
+ GRECS_NODE_FLAG_DESCEND|GRECS_NODE_FLAG_QUOTE)
+int grecs_format_node(struct grecs_node *node, int flags,
+ struct grecs_format_closure *fp);
+
+void grecs_print_locus(grecs_locus_t *locus, FILE *fp);
+void grecs_print_node_path(struct grecs_node *node, int flag, FILE *fp);
+void grecs_print_value(struct grecs_value *val, int flags, FILE *fp);
+
+int grecs_print_node(struct grecs_node *node, int flags, FILE *fp);
+
+void grecs_txtacc_format_value(struct grecs_value *val, int flags,
+ grecs_txtacc_t acc);
+
+#endif
diff --git a/src/json.h b/include/grecs/json.h
index f8402e7..f8402e7 100644
--- a/src/json.h
+++ b/include/grecs/json.h
diff --git a/include/grecs/lex.h b/include/grecs/lex.h
new file mode 100644
index 0000000..fe2365f
--- /dev/null
+++ b/include/grecs/lex.h
@@ -0,0 +1,51 @@
+/* grecs - 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 _GRECS_LEX_H
+#define _GRECS_LEX_H
+
+int grecs_lex_begin(const char*, int);
+void grecs_lex_end(int err);
+
+char *grecs_install_text(const char *str);
+void grecs_destroy_text(void);
+struct grecs_symtab *grecs_text_table(void);
+
+void grecs_parse_line_directive(char *text, grecs_locus_t *ploc,
+ struct grecs_locus_point *ppoint,
+ size_t *pxlines);
+void grecs_parse_line_directive_cpp(char *text, grecs_locus_t *ploc,
+ struct grecs_locus_point *ppoint,
+ size_t *pxlines);
+
+void grecs_line_acc_create(void);
+void grecs_line_acc_free(void);
+void grecs_line_acc_grow_char(int c);
+void grecs_line_acc_grow_char_unescape(int c);
+void grecs_line_acc_grow(const char *text, size_t len);
+void grecs_line_acc_grow_unescape_last(char *text, size_t len);
+
+void grecs_line_begin(void);
+#define grecs_line_add grecs_line_acc_grow
+char *grecs_line_finish(void);
+
+int grecs_str_is_ipv4(const char *addr);
+int grecs_str_is_num(const char *s);
+int grecs_str_is_ipv6(const char *addr);
+int grecs_str_is_num(const char *s);
+int grecs_str_is_ipaddr(const char *addr);
+
+#endif
diff --git a/include/grecs/list.h b/include/grecs/list.h
new file mode 100644
index 0000000..efccd56
--- /dev/null
+++ b/include/grecs/list.h
@@ -0,0 +1,55 @@
+/* grecs - 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 _GRECS_LIST_H
+#define _GRECS_LIST_H
+
+typedef struct grecs_list_entry *grecs_list_entry_t;
+typedef struct grecs_list *grecs_list_t;
+
+struct grecs_list_entry {
+ struct grecs_list_entry *next, *prev;
+ void *data;
+};
+
+struct grecs_list {
+ struct grecs_list_entry *head, *tail;
+ size_t count;
+ int (*cmp)(const void *, const void *);
+ void (*free_entry)(void *);
+};
+
+grecs_list_t grecs_list_create(void);
+size_t grecs_list_size(grecs_list_t);
+void grecs_list_append(grecs_list_t, void *);
+void grecs_list_push(grecs_list_t, void *);
+void *grecs_list_pop(grecs_list_t);
+void *grecs_list_locate(grecs_list_t, void *);
+void *grecs_list_index(grecs_list_t, size_t);
+void *grecs_list_remove_tail(grecs_list_t);
+void grecs_list_remove_entry(grecs_list_t, grecs_list_entry_t);
+void grecs_list_clear(grecs_list_t);
+void grecs_list_free(grecs_list_t);
+void grecs_list_add(grecs_list_t, grecs_list_t);
+
+/* FIXME */
+struct grecs_list *_grecs_simple_list_create(int dispose);
+struct grecs_list *grecs_value_list_create(void);
+
+
+
+
+#endif
diff --git a/src/grecs-locus.h b/include/grecs/locus.h
index b5573fd..4ca6d21 100644
--- a/src/grecs-locus.h
+++ b/include/grecs/locus.h
@@ -15,4 +15,26 @@
with Grecs. If not, see <http://www.gnu.org/licenses/>. */
+#ifndef _GRECS_LOCUS_H
+#define _GRECS_LOCUS_H
+
+struct grecs_locus_point {
+ char *file;
+ unsigned line;
+ unsigned col;
+};
+
+#define grecs_locus_point_advance_line(loc) do { \
+ (loc).line++; \
+ (loc).col = 0; \
+ } while (0)
+
+#define GRECS_LOCUS_POINT_EQ(a,b) \
+ ((strcmp((a)->file, (b)->file) == 0) && ((a)->line == (b)->line))
+
+typedef struct grecs_locus {
+ struct grecs_locus_point beg;
+ struct grecs_locus_point end;
+} grecs_locus_t;
+
#define YYLTYPE grecs_locus_t
@@ -56,2 +78,3 @@
} while (0)
+#endif
diff --git a/include/grecs/mem.h b/include/grecs/mem.h
new file mode 100644
index 0000000..de46b32
--- /dev/null
+++ b/include/grecs/mem.h
@@ -0,0 +1,33 @@
+/* grecs - 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 _GRECS_MEM_H
+#define _GRECS_MEM_H
+
+extern void *(*grecs_malloc_fun)(size_t size);
+extern void *(*grecs_realloc_fun)(void *ptr, size_t size);
+extern void (*grecs_alloc_die_fun)(void);
+extern void (*grecs_free_fun)(void *ptr);
+
+void *grecs_malloc(size_t size);
+void *grecs_zalloc(size_t size);
+void *grecs_calloc(size_t nmemb, size_t size);
+void *grecs_realloc(void *ptr, size_t size);
+void grecs_alloc_die(void);
+char *grecs_strdup(const char *str);
+void grecs_free(void *ptr);
+
+#endif
diff --git a/include/grecs/node.h b/include/grecs/node.h
new file mode 100644
index 0000000..5bbe9dc
--- /dev/null
+++ b/include/grecs/node.h
@@ -0,0 +1,62 @@
+/* grecs - 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 _GRECS_NODE_H
+#define _GRECS_NODE_H
+
+#include <grecs/locus.h>
+#include <grecs/symtab.h>
+#include <grecs/value.h>
+
+enum grecs_node_type {
+ grecs_node_root,
+ grecs_node_stmt,
+ grecs_node_block
+};
+
+typedef struct grecs_node {
+ enum grecs_node_type type;
+ grecs_locus_t locus;
+ struct grecs_node *up;
+ struct grecs_node *down;
+ struct grecs_node *next;
+ struct grecs_node *prev;
+ char *ident;
+ grecs_locus_t idloc;
+ union {
+ grecs_value_t *value;
+ grecs_symtab_t texttab;
+ } v;
+} grecs_node_t;
+
+void grecs_node_free(struct grecs_node *node);
+struct grecs_node *grecs_node_create(enum grecs_node_type type,
+ grecs_locus_t *loc);
+struct grecs_node *grecs_node_create_points(enum grecs_node_type type,
+ struct grecs_locus_point beg,
+ struct grecs_locus_point end);
+void grecs_node_bind(struct grecs_node *master, struct grecs_node *node,
+ int dn);
+int grecs_node_eq(struct grecs_node *a, struct grecs_node *b);
+int grecs_node_unlink(struct grecs_node *node);
+
+struct grecs_node *grecs_node_from_path(const char *path, const char *value);
+struct grecs_node *grecs_node_from_path_locus(const char *path,
+ const char *value,
+ grecs_locus_t *locus,
+ grecs_locus_t *vallocus);
+
+#endif
diff --git a/src/grecsopt.h b/include/grecs/opt.h
index 49c0b53..5153033 100644
--- a/src/grecsopt.h
+++ b/include/grecs/opt.h
@@ -15,6 +15,6 @@
with Grecs. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef _GRECSOPT_H
-#define _GRECSOPT_H
+#ifndef _GRECS_OPT_H
+#define _GRECS_OPT_H
struct grecs_proginfo {
diff --git a/include/grecs/parser.h b/include/grecs/parser.h
new file mode 100644
index 0000000..00878f4
--- /dev/null
+++ b/include/grecs/parser.h
@@ -0,0 +1,53 @@
+/* grecs - 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 _GRECS_PARSER_H
+#define _GRECS_PARSER_H
+
+typedef struct grecs_node *(*grecs_parser_t)(const char *name, int trace);
+
+#define GRECS_TRACE_GRAM 0x01
+#define GRECS_TRACE_LEX 0x02
+
+extern int grecs_trace_fl