summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-21 15:25:55 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-07-04 12:41:59 (GMT)
commit8e541ddaffcab6eaa36faf86304b51a0bc6a92a1 (patch) (side-by-side diff)
treefc909de2e7322c9ad04e8d51d0f9e5213b552cb1
parent17d95ceb6d3f749e9ce20747197703e40e453759 (diff)
downloadgrecs-8e541ddaffcab6eaa36faf86304b51a0bc6a92a1.tar.gz
grecs-8e541ddaffcab6eaa36faf86304b51a0bc6a92a1.tar.bz2
Split declarations between several header files.
* Makefile.am (SUBDIRS): Add include * am/grecs.m4 (GRECS_INCLUDES): Update (GRECS_COND_BUILD_INSTALL) (GRECS_COND_BUILD_SHARED) (GRECS_COND_BUILD_STATIC): New conditions. Build include/Makefile and include/grecs/Makefile. * configure.ac: Use src/grecs-gram.y as a source validity marker * include/Makefile.a: New file. * src/grecs.hin: Remove. Split into include/*. See below. * include/grecs.h: New file. * include/grecs/.gitignore: New file. * include/grecs/Makefile.am: New file. * include/grecs/doc.h: New file. * include/grecs/error.h: New file. * include/grecs/format.h: New file. * include/grecs/lex.h: New file. * include/grecs/list.h: New file. * include/grecs/mem.h: New file. * include/grecs/node.h: New file. * include/grecs/parser.h: New file. * include/grecs/preproc.h: New file. * include/grecs/sockaddr.h: New file. * include/grecs/symtab.h: New file. * include/grecs/table.h: New file. * include/grecs/tree.h: New file. * include/grecs/txtacc.h: New file. * include/grecs/types.h.in: New file. * include/grecs/util.h: New file. * include/grecs/value.h: New file. * include/grecs/version.h: New file. * src/grecs-locus.h: Move to ... * include/grecs/locus.h: ... here * src/grecsopt.h: Move to ... * include/grecs/opt.h: ... here * src/json.h: Move to ... * include/grecs/json.h: ... here * src/wordsplit.h: Move to ... * include/wordsplit.h: ... here * src/Make-inst.am (include_HEADERS): Remove. * src/Make-shared.am (grecsinclude_HEADERS) (noinst_HEADERS): Remove. * src/Make-static.am (noinst_HEADERS): Remove. * src/Make.am: Remove header-related stuff * src/bind-gram.y: Fix includes. * src/bind-lex.l: Likewise. * src/cidr.c: Likewise. * src/dhcpd-gram.y: Likewise. * src/dhcpd-lex.l: Likewise. * src/diag.c: Likewise. * src/format.c: Likewise. * src/grecs-gram.y: Likewise. * src/grecs-lex.l: Likewise. * src/json-gram.y: Likewise. * src/json-lex.l: Likewise. * src/jsonfmt.c: Likewise. * src/lookup.c: Likewise. * src/meta1-gram.y: Likewise. * src/meta1-lex.l: Likewise. * src/opthelp.c: Likewise. * src/preproc.c: Likewise. * src/sockaddr.c: Likewise. * src/txtacc.c: Likewise. * src/version.c: Likewise. * tests/gcfenum.c: Likewise. * tests/gcffmt.c: Likewise. * tests/gcfpeek.c: Likewise. * tests/gcfset.c: Likewise. * tests/gcfver.c: Likewise. * tests/json.c: Likewise.
Diffstat (more/less context) (ignore whitespace changes)
-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
@@ -15,7 +15,7 @@
# along with Grecs. If not, see <http://www.gnu.org/licenses/>.
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
noinst_HEADERS = gitid.h
diff --git a/am/grecs.m4 b/am/grecs.m4
index 74b7840..60244a1 100644
--- a/am/grecs.m4
+++ b/am/grecs.m4
@@ -202,13 +202,14 @@ AC_DEFUN([GRECS_SETUP],[
AC_SUBST([GRECS_CHANGELOG])
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'
GRECS_CHANGELOG=
@@ -218,18 +219,27 @@ AC_DEFUN([GRECS_SETUP],[
grecsdir[doc/Makefile])
],[shared],[
LT_INIT
+ GRECS_BUILD_TYPE=shared
GRECS_LDADD=['$(top_builddir)/]grecsdir[src/libgrecs.la']
GRECS_CHANGELOG='#'
GRECS_README=README.submodule
_GRECS_IF_OPTION_SET([syntax-doc],[GRECS_DISTDOC=doc/grecs-syntax.texi])
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='#'
GRECS_README=README.submodule
_GRECS_IF_OPTION_SET([syntax-doc],[GRECS_DISTDOC=doc/grecs-syntax.texi])
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
@@ -16,7 +16,7 @@
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])
AM_INIT_AUTOMAKE([1.11 gnu tar-ustar dist-xz std-options silent-rules])
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 0000000..21a51e7
--- a/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
--- a/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
--- a/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
--- a/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
--- a/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
--- a/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
--- a/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
--- a/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
--- a/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
@@ -14,6 +14,28 @@
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_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
#define YYLLOC_DEFAULT(Current, Rhs, N) \
@@ -55,3 +77,4 @@
(Loc).beg.col); \
} while (0)
+#endif
diff --git a/include/grecs/mem.h b/include/grecs/mem.h
new file mode 100644
index 0000000..de46b32
--- a/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
--- a/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
@@ -14,8 +14,8 @@
You should have received a copy of the GNU General Public License along
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 {
const char *progname;
diff --git a/include/grecs/parser.h b/include/grecs/parser.h
new file mode 100644
index 0000000..00878f4
--- a/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_flags;
+extern grecs_parser_t grecs_parser_fun;
+extern int grecs_default_port;
+
+extern struct grecs_locus_point grecs_current_locus_point;
+extern grecs_locus_t grecs_locus;
+extern int grecs_adjust_string_locations;
+extern int grecs_error_count;
+
+/* Main entry point */
+struct grecs_node *grecs_parse(const char *name);
+void grecs_gram_trace(int n);
+void grecs_lex_trace(int n);
+
+/* Parsers: */
+struct grecs_node *grecs_grecs_parser(const char *name, int traceflags);
+struct grecs_node *grecs_meta1_parser(const char *name, int traceflags);
+struct grecs_node *grecs_bind_parser(const char *name, int traceflags);
+struct grecs_node *grecs_dhcpd_parser(const char *name, int traceflags);
+struct grecs_node *grecs_git_parser(const char *name, int traceflags);
+struct grecs_node *grecs_path_parser(const char *name, int traceflags);
+
+
+/* Parser database */
+int grecs_enumerate_parsers(int (*fun)(const char *, grecs_parser_t, void *),
+ void *);
+grecs_parser_t grecs_get_parser_by_type(const char *type);
+
+#endif
diff --git a/include/grecs/preproc.h b/include/grecs/preproc.h
new file mode 100644
index 0000000..798e879
--- a/dev/null
+++ b/include/grecs/preproc.h
@@ -0,0 +1,46 @@
+/* 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_PREPROC_H
+#define _GRECS_PREPROC_H
+
+#include <sys/types.h>
+
+extern const char *grecs_preprocessor;
+
+size_t grecs_preproc_fill_buffer(char *buf, size_t size);
+void grecs_preproc_add_include_dir(char *dir);
+int grecs_preproc_init(const char *name);
+void grecs_preproc_done(void);
+int grecs_preproc_run(const char *config_file, const char *extpp);
+
+#define GRECS_STD_INCLUDE 0x01
+#define GRECS_USR_INCLUDE 0x02
+
+size_t grecs_include_path_count(int flag);
+int grecs_foreach_include_dir(int flag, int (*fun)(int, const char *, void *),
+ void *data);
+
+char *grecs_find_include_file(const char *name, int allow_cwd);
+
+FILE *grecs_preproc_extrn_start(const char *file, pid_t *ppid);
+void grecs_preproc_extrn_shutdown(pid_t pid);
+
+void grecs_include_path_clear(void);
+void grecs_include_path_setup(const char *dir, ...);
+void grecs_include_path_setup_v(char **dirs);
+
+#endif
diff --git a/include/grecs/sockaddr.h b/include/grecs/sockaddr.h
new file mode 100644
index 0000000..c8a3de2
--- a/dev/null
+++ b/include/grecs/sockaddr.h
@@ -0,0 +1,66 @@
+/* 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_SOCKADDR_H
+#define _GRECS_SOCKADDR_H
+
+struct grecs_sockaddr {
+#if GRECS_SOCKADDR_LIST
+ struct grecs_sockaddr *next;
+#endif
+ int len;
+ struct sockaddr *sa;
+};
+
+#if GRECS_SOCKADDR_LIST
+
+#define GRECS_AH_PASSIVE 0x01
+#define GRECS_HINT_SERVICE 0x02
+#define GRECS_HINT_PORT 0x04
+
+struct grecs_sockaddr_hints {
+ int flags;
+ char *service;
+ unsigned short port;
+};
+
+extern struct grecs_sockaddr_hints *grecs_sockaddr_hints;
+
+struct grecs_sockaddr *grecs_sockaddr_new(size_t s);
+void grecs_sockaddr_free(struct grecs_sockaddr *p);
+
+int grecs_str_to_sockaddr(struct grecs_sockaddr **sap,
+ const char *arg, struct grecs_sockaddr_hints *gh,
+ grecs_locus_t const *locus);
+#endif
+
+#define GRECS_INADDR_BYTES 16
+
+struct grecs_cidr
+{
+ int family;
+ int len;
+ unsigned char address[GRECS_INADDR_BYTES];
+ unsigned char netmask[GRECS_INADDR_BYTES];
+};
+
+int grecs_str_to_cidr(struct grecs_cidr *pcidr, const char *str,
+ grecs_locus_t const *locus);
+
+int grecs_sockaddr_to_cidr(struct grecs_cidr *cidr, const struct sockaddr *sa);
+int grecs_sockadd_cidr_match(struct sockaddr *sa, struct grecs_cidr *cidr);
+
+#endif
diff --git a/include/grecs/symtab.h b/include/grecs/symtab.h
new file mode 100644
index 0000000..a4a7106
--- a/dev/null
+++ b/include/grecs/symtab.h
@@ -0,0 +1,52 @@
+/* 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_SYMTAB_H
+#define _GRECS_SYMTAB_H
+
+typedef struct grecs_symtab *grecs_symtab_t;
+
+struct grecs_syment {
+ char *name;
+};
+
+typedef int (*grecs_symtab_enumerator_t)(void *sym, void *data);
+
+const char *grecs_symtab_strerror(int rc);
+
+void *grecs_symtab_lookup_or_install(grecs_symtab_t st,
+ void *key, int *install);
+void grecs_symtab_clear(grecs_symtab_t st);
+grecs_symtab_t grecs_symtab_create(size_t elsize,
+ unsigned (*hash_fun)(void *, unsigned long),
+ int (*cmp_fun)(const void *, const void *),
+ int (*copy_fun)(void *, void *),
+ void *(*alloc_fun)(size_t),
+ void (*free_fun)(void *));
+grecs_symtab_t grecs_symtab_create_default(size_t elsize);
+
+void grecs_symtab_free(grecs_symtab_t pst);
+int grecs_symtab_remove(grecs_symtab_t st, void *elt);
+int grecs_symtab_replace(grecs_symtab_t st, void *ent, void **old_ent);
+int grecs_symtab_enumerate(grecs_symtab_t st,
+ grecs_symtab_enumerator_t fun, void *data);
+
+size_t grecs_symtab_count_entries(grecs_symtab_t st);
+
+unsigned grecs_hash_string(const char *name, unsigned long hashsize);
+unsigned grecs_hash_string_ci(const char *name, unsigned long hashsize);
+
+#endif
diff --git a/include/grecs/table.h b/include/grecs/table.h
new file mode 100644
index 0000000..4210c6f
--- a/dev/null
+++ b/include/grecs/table.h
@@ -0,0 +1,98 @@
+/* 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_TABLE_H
+#define _GRECS_TABLE_H
+
+#include <grecs/node.h>
+
+enum grecs_data_type {
+ grecs_type_void,
+ grecs_type_string,
+ grecs_type_short,
+ grecs_type_ushort,
+ grecs_type_int,
+ grecs_type_uint,
+ grecs_type_long,
+ grecs_type_ulong,
+ grecs_type_size,
+/* grecs_type_off,*/
+ grecs_type_time,
+ grecs_type_bool,
+ grecs_type_ipv4,
+ grecs_type_cidr,
+ grecs_type_host,
+ grecs_type_sockaddr,
+ grecs_type_section,
+ grecs_type_null
+};
+
+#define GRECS_DFLT 0x00
+#define GRECS_AGGR 0x01
+#define GRECS_MULT 0x02
+#define GRECS_INAC 0x04
+#define GRECS_LIST 0x08
+#define GRECS_HIDDEN 0x10
+
+enum grecs_callback_command {
+ grecs_callback_section_begin,
+ grecs_callback_section_end,
+ grecs_callback_set_value
+};
+
+typedef int (*grecs_callback_fn)(
+#if GRECS_TREE_API
+ enum grecs_callback_command cmd,
+ grecs_node_t * /* node */,
+ void * /* varptr */,
+ void * /* cb_data */
+#else
+ enum grecs_callback_command cmd,
+ grecs_locus_t * /* locus */,
+ void * /* varptr */,
+ grecs_value_t * /* value */,
+ void * /* cb_data */
+#endif
+ );
+
+struct grecs_keyword {
+ const char *ident;
+ const char *argname;
+ const char *docstring;
+ enum grecs_data_type type;
+ int flags;
+ void *varptr;
+ size_t offset;
+ grecs_callback_fn callback;
+ void *callback_data;
+ struct grecs_keyword *kwd;
+};
+
+extern int grecs_string_convert(void *target, enum grecs_data_type type,
+ const char *string,
+ grecs_locus_t const *locus);
+extern void grecs_process_ident(struct grecs_keyword *kwp,
+ grecs_value_t *value,
+ void *base,
+ grecs_locus_t *locus);
+
+const char *grecs_data_type_string(enum grecs_data_type type);
+
+int grecs_tree_process(struct grecs_node *node, struct grecs_keyword *kwd);
+int grecs_tree_reduce(struct grecs_node *node, struct grecs_keyword *kwd,
+ int flags);
+
+#endif
diff --git a/include/grecs/tree.h b/include/grecs/tree.h
new file mode 100644
index 0000000..2fb26dd
--- a/dev/null
+++ b/include/grecs/tree.h
@@ -0,0 +1,71 @@
+/* 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_TREE_H
+#define _GRECS_TREE_H
+
+#include <grecs/node.h>
+
+int grecs_tree_free(struct grecs_node *node);
+void grecs_tree_sort(struct grecs_node *node,
+ int (*compare)(struct grecs_node const *,
+ struct grecs_node const *));
+struct grecs_node *grecs_tree_first_node(struct grecs_node *tree);
+struct grecs_node *grecs_next_node(struct grecs_node *node);
+
+struct grecs_node *grecs_find_node(struct grecs_node *node, const char *path);
+
+enum grecs_tree_recurse_op {
+ grecs_tree_recurse_set,
+ grecs_tree_recurse_pre,
+ grecs_tree_recurse_post
+};
+
+enum grecs_tree_recurse_res {
+ grecs_tree_recurse_ok,
+ grecs_tree_recurse_fail,
+ grecs_tree_recurse_skip,
+ grecs_tree_recurse_stop
+};
+
+typedef enum grecs_tree_recurse_res
+ (*grecs_tree_recursor_t)(enum grecs_tree_recurse_op,
+ struct grecs_node *, void *);
+
+int grecs_tree_recurse(struct grecs_node *node, grecs_tree_recursor_t recfun,
+ void *data);
+int grecs_tree_join(struct grecs_node *dst, struct grecs_node *src);
+
+enum grecs_tree_recurse_res grecs_node_exact_match(
+ enum grecs_tree_recurse_op op,
+ struct grecs_node *node, void *data);
+
+typedef struct grecs_match_buf *grecs_match_buf_t;
+struct grecs_node *grecs_match_first(struct grecs_node *tree,
+ const char *pattern,
+ grecs_match_buf_t *buf);
+struct grecs_node *grecs_match_next(struct grecs_match_buf *buf);
+void grecs_match_buf_free(struct grecs_match_buf *buf);
+grecs_match_buf_t grecs_match_buf_create(int argc, char **argv,
+ struct grecs_value **labelv);
+struct grecs_node *grecs_match_buf_first(struct grecs_match_buf *buf,
+ struct grecs_node *tree);
+struct grecs_node *grecs_match_buf_get_node(grecs_match_buf_t buf);
+size_t grecs_match_buf_get_args(grecs_match_buf_t buf, char ***argv);
+struct grecs_node *grecs_match_buf_get_root(grecs_match_buf_t buf);
+void grecs_match_buf_set_root(grecs_match_buf_t buf, struct grecs_node *root);
+
+#endif
diff --git a/include/grecs/txtacc.h b/include/grecs/txtacc.h
new file mode 100644
index 0000000..d6dc1c4
--- a/dev/null
+++ b/include/grecs/txtacc.h
@@ -0,0 +1,36 @@
+/* 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_TXTACC_H
+#define _GRECS_TXTACC_H
+
+#define GRECS_TXTACC_BUFSIZE 1024
+typedef struct grecs_txtacc *grecs_txtacc_t;
+
+grecs_txtacc_t grecs_txtacc_create(void);
+void grecs_txtacc_free(grecs_txtacc_t);
+void grecs_txtacc_grow(grecs_txtacc_t, const char *, size_t);
+void grecs_txtacc_grow_string(grecs_txtacc_t, const char *);
+void grecs_txtacc_grow_string_escape(grecs_txtacc_t, const char *);
+#define grecs_txtacc_grow_char(acc,c) \
+ do { \
+ char __ch = c; \
+ grecs_txtacc_grow(acc,&__ch,1); \
+ } while (0)
+char *grecs_txtacc_finish(grecs_txtacc_t, int);
+void grecs_txtacc_free_string(grecs_txtacc_t, char *);
+
+#endif
diff --git a/include/grecs/types.h.in b/include/grecs/types.h.in
new file mode 100644
index 0000000..b891a05
--- a/dev/null
+++ b/include/grecs/types.h.in
@@ -0,0 +1,24 @@
+#ifndef _GRECS_TYPES_H
+#define _GRECS_TYPES_H
+
+#define GRECS_VERSION_MAJOR 1
+#define GRECS_VERSION_MINOR 0
+
+#define GRECS_TREE_API @GRECS_TREE_API@
+#define GRECS_SOCKADDR_LIST @GRECS_SOCKADDR_LIST@
+
+#if ENABLE_NLS
+# include "gettext.h"
+#else
+# ifndef gettext
+# define gettext(msgid) msgid
+# endif
+#endif
+#ifndef _
+# define _(msgid) gettext(msgid)
+#endif
+#ifndef N_
+# define N_(s) s
+#endif
+
+#endif
diff --git a/include/grecs/util.h b/include/grecs/util.h
new file mode 100644
index 0000000..cf3bee1
--- a/dev/null
+++ b/include/grecs/util.h
@@ -0,0 +1,26 @@
+/* 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_UTIL_H
+#define _GRECS_UTIL_H
+
+#include <stdarg.h>
+
+ssize_t grecs_getline(char **pbuf, size_t *psize, FILE *fp);
+int grecs_vasprintf(char **pbuf, size_t *psize, const char *fmt, va_list ap);
+int grecs_asprintf(char **pbuf, size_t *psize, const char *fmt, ...);
+
+#endif
diff --git a/include/grecs/value.h b/include/grecs/value.h
new file mode 100644
index 0000000..73f979c
--- a/dev/null
+++ b/include/grecs/value.h
@@ -0,0 +1,52 @@
+/* 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_VALUE_H
+#define _GRECS_VALUE_H
+
+#include <grecs/locus.h>
+#include <grecs/list.h>
+
+#define GRECS_TYPE_STRING 0
+#define GRECS_TYPE_LIST 1
+#define GRECS_TYPE_ARRAY 2
+
+typedef struct grecs_value {
+ int type;
+ grecs_locus_t locus;
+ union {
+ grecs_list_t list;
+ char *string;
+ struct {
+ size_t c;
+ struct grecs_value **v;
+ } arg;
+ } v;
+} grecs_value_t;
+
+#define GRECS_VALUE_EMPTY_P(val) \
+ (!(val) || \
+ ((val)->type == GRECS_TYPE_STRING && (val)->v.string == NULL))
+
+void grecs_value_free(struct grecs_value *val);
+void grecs_value_free_content(struct grecs_value *val);
+grecs_value_t *grecs_value_ptr_from_static(grecs_value_t *input);
+
+int grecs_value_eq(struct grecs_value *a, struct grecs_value *b);
+int grecs_value_match(struct grecs_value *pat, struct grecs_value *b,
+ int flags);
+
+#endif
diff --git a/include/grecs/version.h b/include/grecs/version.h
new file mode 100644
index 0000000..f37adc6
--- a/dev/null
+++ b/include/grecs/version.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_VERSION_H
+#define _GRECS_VERSION_H
+
+struct grecs_version_info {
+ const char *package;
+ const char *version;
+ const char *id;
+ int major;
+ int minor;
+ int patch;
+ char *suffix;
+ char *buffer;
+};
+
+struct grecs_version_info *grecs_version(void);
+int grecs_version_cmp(const char *, const char *, int *);
+int grecs_version_ok(const char *);
+void grecs_version_info_free(struct grecs_version_info *);
+struct grecs_version_info *grecs_version_split(const char *);
+int grecs_version_info_cmp(struct grecs_version_info *,
+ struct grecs_version_info *,
+ int *);
+
+#endif
diff --git a/src/wordsplit.h b/include/wordsplit.h
index a7f6dd5..a7f6dd5 100644
--- a/src/wordsplit.h
+++ b/include/wordsplit.h
diff --git a/src/Make-inst.am b/src/Make-inst.am
index 9dac1ad..a4b6aea 100644
--- a/src/Make-inst.am
+++ b/src/Make-inst.am
@@ -17,6 +17,5 @@
include Make.am
lib_LTLIBRARIES=libgrecs.la
libgrecs_la_SOURCES = $(GRECS_SRC)
-include_HEADERS = $(GRECS_HDR)
m4datadir = $(datadir)/aclocal
dist_m4data_DATA = libgrecs.m4
diff --git a/src/Make-shared.am b/src/Make-shared.am
index 8ec4a76..9a762a4 100644
--- a/src/Make-shared.am
+++ b/src/Make-shared.am
@@ -17,9 +17,3 @@ include Make.am
noinst_LTLIBRARIES=libgrecs.la
libgrecs_la_SOURCES = $(GRECS_SRC)
-if GRECS_COND_INSTALLHEADERS
- grecsincludedir = @GRECS_INCLUDE_DIR@
- grecsinclude_HEADERS = $(GRECS_HDR)
-else
- noinst_HEADERS += $(GRECS_HDR)
-endif
diff --git a/src/Make-static.am b/src/Make-static.am
index 7532562..2688b40 100644
--- a/src/Make-static.am
+++ b/src/Make-static.am
@@ -16,6 +16,5 @@
include Make.am
noinst_LIBRARIES=libgrecs.a
libgrecs_a_SOURCES = $(GRECS_SRC)
-noinst_HEADERS += $(GRECS_HDR)
diff --git a/src/Make.am b/src/Make.am
index cfae734..227973e 100644
--- a/src/Make.am
+++ b/src/Make.am
@@ -75,20 +75,12 @@ GRECS_SRC = \
$(GRECS_PARSER_GIT)\
$(GRECS_PARSER_META1)
-GRECS_HDR = grecs.h grecsopt.h wordsplit.h
-if GRECS_COND_JSON
- GRECS_HDR += json.h
-endif
-
if GRECS_COND_SOCKADDR_LIST
GRECS_SRC += sockaddr.c
endif
-noinst_HEADERS = grecs-locus.h
-
EXTRA_DIST=\
grecs-gram.h\
- grecs.hin\
$(GRECS_EXTRA_BIND)\
$(GRECS_EXTRA_DHCPD)\
$(GRECS_EXTRA_JSON)\
@@ -96,8 +88,6 @@ EXTRA_DIST=\
$(PP_SETUP_FILE)\
Make.am Make-inst.am Make-shared.am Make-static.am
-BUILT_SOURCES=grecs.h
-
AM_CPPFLAGS = \
-I$(srcdir)\
-I$(top_srcdir)/@GRECS_SUBDIR@\
@@ -112,3 +102,7 @@ inc_DATA = $(PP_SETUP_FILE)
LEXCOMPILE = $(top_srcdir)/@GRECS_SUBDIR@/build-aux/yyrename '$(LEX) $(LFLAGS) $(AM_LFLAGS)'
YACCCOMPILE = $(top_srcdir)/@GRECS_SUBDIR@/build-aux/yyrename '$(YACC) $(YFLAGS) $(AM_YFLAGS)'
+
+
+
+
diff --git a/src/bind-gram.y b/src/bind-gram.y
index 4c8d394..18deb0d 100644
--- a/src/bind-gram.y
+++ b/src/bind-gram.y
@@ -19,7 +19,6 @@
# include <config.h>
#endif
#include <grecs.h>
-#include <grecs-locus.h>
#include <bind-gram.h>
#include <stdlib.h>
#include <stdarg.h>
diff --git a/src/bind-lex.l b/src/bind-lex.l
index 096d1f2..e0659e7 100644
--- a/src/bind-lex.l
+++ b/src/bind-lex.l
@@ -24,7 +24,6 @@
with Grecs. If not, see <http://www.gnu.org/licenses/>. */
#include <grecs.h>
-#include <grecs-locus.h>
#include <bind-gram.h>
#include <unistd.h>
#include <fcntl.h>
diff --git a/src/cidr.c b/src/cidr.c
index bffa35e..7566fa6 100644
--- a/src/cidr.c
+++ b/src/cidr.c
@@ -22,6 +22,7 @@
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <stdlib.h>
#include "grecs.h"
static void
diff --git a/src/dhcpd-gram.y b/src/dhcpd-gram.y
index 86bfde9..11dd1b2 100644
--- a/src/dhcpd-gram.y
+++ b/src/dhcpd-gram.y
@@ -19,7 +19,6 @@
# include <config.h>
#endif
#include <grecs.h>
-#include <grecs-locus.h>
#include <dhcpd-gram.h>
#include <stdlib.h>
#include <stdarg.h>
diff --git a/src/dhcpd-lex.l b/src/dhcpd-lex.l
index 490fd72..79c7274 100644
--- a/src/dhcpd-lex.l
+++ b/src/dhcpd-lex.l
@@ -23,7 +23,6 @@
with Grecs. If not, see <http://www.gnu.org/licenses/>. */
#include <grecs.h>
-#include <grecs-locus.h>
#include <dhcpd-gram.h>
#include <unistd.h>
#include <fcntl.h>
diff --git a/src/diag.c b/src/diag.c
index 1424437..bdbb407 100644
--- a/src/diag.c
+++ b/src/diag.c
@@ -18,7 +18,6 @@
# include <config.h>
#endif
#include <grecs.h>
-#include <grecs-locus.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/src/format.c b/src/format.c
index 89202a0..af87329 100644
--- a/src/format.c
+++ b/src/format.c
@@ -18,12 +18,12 @@
# include <config.h>
#endif
#include <grecs.h>
+#include <wordsplit.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
-#include "wordsplit.h"
const char *
grecs_data_type_string(enum grecs_data_type type)
diff --git a/src/grecs-gram.y b/src/grecs-gram.y
index 4545c85..05ed2f5 100644
--- a/src/grecs-gram.y
+++ b/src/grecs-gram.y
@@ -19,7 +19,6 @@
# include <config.h>
#endif
#include <grecs.h>
-#include <grecs-locus.h>
#include <grecs-gram.h>
#include <stdlib.h>
#include <stdarg.h>
diff --git a/src/grecs-lex.l b/src/grecs-lex.l
index 5223765..113ee88 100644
--- a/src/grecs-lex.l
+++ b/src/grecs-lex.l
@@ -24,7 +24,6 @@
with Grecs. If not, see <http://www.gnu.org/licenses/>. */
#include <grecs.h>
-#include <grecs-locus.h>
#include <grecs-gram.h>
#include <unistd.h>
#include <fcntl.h>
diff --git a/src/grecs.hin b/src/grecs.hin
deleted file mode 100644
index bfaaa49..0000000
--- a/src/grecs.hin
+++ b/dev/null
@@ -1,584 +0,0 @@
-/* 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 <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-#if ENABLE_NLS
-# include "gettext.h"
-#else
-# ifndef gettext
-# define gettext(msgid) msgid
-# endif
-#endif
-#ifndef _
-# define _(msgid) gettext(msgid)
-#endif
-#ifndef N_
-# define N_(s) s
-#endif
-
-#define GRECS_VERSION_MAJOR 1
-#define GRECS_VERSION_MINOR 0
-
-#define GRECS_TREE_API @GRECS_TREE_API@
-#define GRECS_SOCKADDR_LIST @GRECS_SOCKADDR_LIST@
-
-struct grecs_version_info {
- const char *package;
- const char *version;
- const char *id;
- int major;
- int minor;
- int patch;
- char *suffix;
- char *buffer;
-};
-
-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;
-
-extern grecs_locus_t grecs_locus;
-extern int grecs_adjust_string_locations;
-
-enum grecs_data_type {
- grecs_type_void,
- grecs_type_string,
- grecs_type_short,
- grecs_type_ushort,
- grecs_type_int,
- grecs_type_uint,
- grecs_type_long,
- grecs_type_ulong,
- grecs_type_size,
-/* grecs_type_off,*/
- grecs_type_time,
- grecs_type_bool,
- grecs_type_ipv4,
- grecs_type_cidr,
- grecs_type_host,
- grecs_type_sockaddr,
- grecs_type_section,
- grecs_type_null
-};
-
-#define GRECS_DFLT 0x00 /* Default keyword flags */
-#define GRECS_AGGR 0x01 /* Multiple entries aggregate */
-#define GRECS_MULT 0x02 /* Statement can appear multiple times */
-#define GRECS_INAC 0x04 /* Inactive keyword */
-#define GRECS_LIST 0x08 /* Value is a list of declared type */
-#define GRECS_HIDDEN 0x10 /* Hidden keyword: don't display in help output */
-#define GRECS_CONST 0x20 /* For string types: initial value is constant,
- don't try to free it before assigning new value.
- This flag is cleared after the first assignment.
- */
-
-enum grecs_callback_command {
- grecs_callback_section_begin,
- grecs_callback_section_end,
- grecs_callback_set_value
-};
-
-#define GRECS_TYPE_STRING 0
-#define GRECS_TYPE_LIST 1
-#define GRECS_TYPE_ARRAY 2
-
-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 *);
-};
-
-typedef struct grecs_value {
- int type;
- grecs_locus_t locus;
- union {
- struct grecs_list *list;
- char *string;
- struct {
- size_t c;
- struct grecs_value **v;
- } arg;
- } v;
-} grecs_value_t;
-
-#define GRECS_VALUE_EMPTY_P(val) \
- (!(val) || \
- ((val)->type == GRECS_TYPE_STRING && (val)->v.string == NULL))
-
-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 {
- struct grecs_value *value;
- struct grecs_symtab *texttab;
- } v;
-} grecs_node_t;
-
-typedef int (*grecs_callback_fn)(
-#if GRECS_TREE_API
- enum grecs_callback_command cmd,
- grecs_node_t * /* node */,
- void * /* varptr */,
- void * /* cb_data */
-#else
- enum grecs_callback_command cmd,
- grecs_locus_t * /* locus */,
- void * /* varptr */,
- grecs_value_t * /* value */,
- void * /* cb_data */
-#endif
- );
-
-struct grecs_keyword {
- const char *ident;
- const char *argname;
- const char *docstring;
- enum grecs_data_type type;
- int flags;
- void *varptr;
- size_t offset;
- grecs_callback_fn callback;
- void *callback_data;
- struct grecs_keyword *kwd;
-};
-
-struct grecs_sockaddr {
-#if GRECS_SOCKADDR_LIST
- struct grecs_sockaddr *next;
-#endif
- int len;
- struct sockaddr *sa;
-};
-
-struct grecs_version_info *grecs_version(void);
-int grecs_version_cmp(const char *vstr1, const char *vstr2, int *pres);
-int grecs_version_ok(const char *vstr);
-void grecs_version_info_free(struct grecs_version_info *pv);
-struct grecs_version_info *grecs_version_split(const char *vstr);
-int grecs_version_info_cmp(struct grecs_version_info *vx,
- struct grecs_version_info *vy,
- int *pres);
-
-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);
-
-grecs_value_t *grecs_value_ptr_from_static(grecs_value_t *input);
-
-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);
-
-
-extern int grecs_trace_flags;
-
-#define GRECS_TRACE_GRAM 0x01
-#define GRECS_TRACE_LEX 0x02
-void grecs_gram_trace(int n);
-void grecs_lex_trace(int n);
-
-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);
-
-
-
-int grecs_lex_begin(const char*, int);
-void grecs_lex_end(int err);
-struct grecs_node *grecs_parse(const char *name);
-
-typedef struct grecs_node *(*grecs_parser_t)(const char *name, int trace);
-
-extern grecs_parser_t grecs_parser_fun;
-
-/* Parsers: */
-struct grecs_node *grecs_grecs_parser(const char *name, int traceflags);
-struct grecs_node *grecs_meta1_parser(const char *name, int traceflags);
-struct grecs_node *grecs_bind_parser(const char *name, int traceflags);
-struct grecs_node *grecs_dhcpd_parser(const char *name, int traceflags);
-struct grecs_node *grecs_git_parser(const char *name, int traceflags);
-struct grecs_node *grecs_path_parser(const char *name, int traceflags);
-
-
-/* Parser database */
-int grecs_enumerate_parsers(int (*fun)(const char *, grecs_parser_t, void *),
- void *);
-grecs_parser_t grecs_get_parser_by_type(const char *type);
-
-
-struct grecs_list *_grecs_simple_list_create(int dispose);
-struct grecs_list *grecs_value_list_create(void);
-
-void grecs_line_acc_create(void);
-void grecs_line_acc_free(void);
-void grecs_line_acc_grow_char(int c);
-int 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,
- grecs_locus_t const *loc);
-
-void grecs_line_begin(void);
-#define grecs_line_add grecs_line_acc_grow
-char *grecs_line_finish(void);
-
-extern int grecs_string_convert(void *target, enum grecs_data_type type,
- const char *string,
- grecs_locus_t const *locus);
-extern void grecs_process_ident(struct grecs_keyword *kwp,
- grecs_value_t *value,
- void *base,
- grecs_locus_t *locus);
-
-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);
-
-
-extern struct grecs_locus_point grecs_current_locus_point;
-extern int grecs_error_count;
-extern int grecs_default_port;
-
-extern const char *grecs_preprocessor;
-extern int grecs_log_to_stderr;
-extern void (*grecs_log_setup_hook)();
-
-size_t grecs_preproc_fill_buffer(char *buf, size_t size);
-void grecs_preproc_add_include_dir(char *dir);
-int grecs_preproc_init(const char *name);
-void grecs_preproc_done(void);
-int grecs_preproc_run(const char *config_file, const char *extpp);
-
-#define GRECS_STD_INCLUDE 0x01
-#define GRECS_USR_INCLUDE 0x02
-
-size_t grecs_include_path_count(int flag);
-int grecs_foreach_include_dir(int flag, int (*fun)(int, const char *, void *),
- void *data);
-
-char *grecs_find_include_file(const char *name, int allow_cwd);
-
-FILE *grecs_preproc_extrn_start(const char *file, pid_t *ppid);
-void grecs_preproc_extrn_shutdown(pid_t pid);
-
-char *grecs_install_text(const char *str);
-void grecs_destroy_text(void);
-struct grecs_symtab *grecs_text_table(void);
-
-void grecs_include_path_clear(void);
-void grecs_include_path_setup(const char *dir, ...);
-void grecs_include_path_setup_v(char **dirs);
-
-ssize_t grecs_getline(char **pbuf, size_t *psize, FILE *fp);
-
-const char *grecs_data_type_string(enum grecs_data_type type);
-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);
-
-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);
-
-struct grecs_txtacc;
-void grecs_txtacc_format_value(struct grecs_value *val, int flags,
- struct grecs_txtacc *acc);
-
-
-
-struct grecs_list *grecs_list_create(void);
-size_t grecs_list_size(struct grecs_list *lp);
-void grecs_list_append(struct grecs_list *lp, void *val);
-void grecs_list_push(struct grecs_list *lp, void *val);
-void *grecs_list_pop(struct grecs_list *lp);
-void *grecs_list_locate(struct grecs_list *lp, void *data);
-void *grecs_list_index(struct grecs_list *lp, size_t idx);
-void *grecs_list_remove_tail(struct grecs_list *lp);
-void grecs_list_remove_entry(struct grecs_list *lp,
- struct grecs_list_entry *ent);
-void grecs_list_clear(struct grecs_list *lp);
-void grecs_list_free(struct grecs_list *lp);
-void grecs_list_add(struct grecs_list *dst, struct grecs_list *src);
-int grecs_list_compare(struct grecs_list *a, struct grecs_list *b);
-
-int grecs_vasprintf(char **pbuf, size_t *psize, const char *fmt, va_list ap);
-int grecs_asprintf(char **pbuf, size_t *psize, const char *fmt, ...);
-
-#define GRECS_TXTACC_BUFSIZE 1024
-struct grecs_txtacc *grecs_txtacc_create(void);
-void grecs_txtacc_free(struct grecs_txtacc *acc);
-void grecs_txtacc_grow(struct grecs_txtacc *acc, const char *buf, size_t size);
-void grecs_txtacc_grow_string(struct grecs_txtacc *acc, const char *buf);
-void grecs_txtacc_grow_string_escape(struct grecs_txtacc *acc,
- const char *buf);
-#define grecs_txtacc_grow_char(acc,c) \
- do { \
- char __ch = c; \
- grecs_txtacc_grow(acc,&__ch,1); \
- } while (0)
-char *grecs_txtacc_finish(struct grecs_txtacc *acc, int steal);
-void grecs_txtacc_free_string(struct grecs_txtacc *acc, char *str);
-
-struct grecs_symtab;
-
-struct grecs_syment {
- char *name;
-};
-
-typedef int (*grecs_symtab_enumerator_t)(void *sym, void *data);
-
-const char *grecs_symtab_strerror(int rc);
-
-void *grecs_symtab_lookup_or_install(struct grecs_symtab *st,
- void *key, int *install);
-void grecs_symtab_clear(struct grecs_symtab *st);
-struct grecs_symtab *grecs_symtab_create(size_t elsize,
- unsigned (*hash_fun)(void *, unsigned long),
- int (*cmp_fun)(const void *, const void *),
- int (*copy_fun)(void *, void *),
- void *(*alloc_fun)(size_t),
- void (*free_fun)(void *));
-struct grecs_symtab *grecs_symtab_create_default(size_t elsize);
-
-void grecs_symtab_free(struct grecs_symtab *pst);
-int grecs_symtab_remove(struct grecs_symtab *st, void *elt);
-int grecs_symtab_replace(struct grecs_symtab *st, void *ent, void **old_ent);
-int grecs_symtab_enumerate(struct grecs_symtab *st,
- grecs_symtab_enumerator_t fun, void *data);
-
-size_t grecs_symtab_count_entries(struct grecs_symtab *st);
-
-unsigned grecs_hash_string(const char *name, unsigned long hashsize);
-unsigned grecs_hash_string_ci(const char *name, unsigned long hashsize);
-
-
-void grecs_value_free(struct grecs_value *val);
-void grecs_value_free_content(struct grecs_value *val);
-void grecs_node_free(struct grecs_node *node);
-int grecs_node_unlink(struct grecs_node *node);
-int grecs_tree_free(struct grecs_node *node);
-
-enum grecs_tree_recurse_op {
- grecs_tree_recurse_set,
- grecs_tree_recurse_pre,
- grecs_tree_recurse_post
-};
-
-enum grecs_tree_recurse_res {
- grecs_tree_recurse_ok,
- grecs_tree_recurse_fail,
- grecs_tree_recurse_skip,
- grecs_tree_recurse_stop
-};
-
-typedef enum grecs_tree_recurse_res
- (*grecs_tree_recursor_t)(enum grecs_tree_recurse_op,
- struct grecs_node *, void *);
-
-int grecs_tree_recurse(struct grecs_node *node, grecs_tree_recursor_t recfun,
- void *data);
-int grecs_tree_join(struct grecs_node *dst, struct grecs_node *src);
-
-
-int grecs_tree_process(struct grecs_node *node, struct grecs_keyword *kwd);
-
-typedef struct grecs_match_buf *grecs_match_buf_t;
-struct grecs_node *grecs_match_first(struct grecs_node *tree,
- const char *pattern,
- grecs_match_buf_t *buf);
-struct grecs_node *grecs_match_next(struct grecs_match_buf *buf);
-void grecs_match_buf_free(struct grecs_match_buf *buf);
-grecs_match_buf_t grecs_match_buf_create(int argc, char **argv,
- struct grecs_value **labelv);
-struct grecs_node *grecs_match_buf_first(struct grecs_match_buf *buf,
- struct grecs_node *tree);
-struct grecs_node *grecs_match_buf_get_node(grecs_match_buf_t buf);
-size_t grecs_match_buf_get_args(grecs_match_buf_t buf, char ***argv);
-struct grecs_node *grecs_match_buf_get_root(grecs_match_buf_t buf);
-void grecs_match_buf_set_root(grecs_match_buf_t buf, struct grecs_node *root);
-
-int grecs_value_eq(struct grecs_value *a, struct grecs_value *b);
-int grecs_value_match(struct grecs_value *pat, struct grecs_value *b,
- int flags);
-
-enum grecs_tree_recurse_res grecs_node_exact_match(
- enum grecs_tree_recurse_op op,
- struct grecs_node *node, void *data);
-
-struct grecs_node *grecs_find_node(struct grecs_node *node, const char *path);
-
-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);
-int grecs_tree_reduce(struct grecs_node *node, struct grecs_keyword *kwd,
- int flags);
-
-void grecs_tree_sort(struct grecs_node *node,
- int (*compare)(struct grecs_node const *,
- struct grecs_node const *));
-
-struct grecs_node *grecs_tree_first_node(struct grecs_node *tree);
-struct grecs_node *grecs_next_node(struct grecs_node *node);
-
-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);
-
-#if GRECS_SOCKADDR_LIST
-
-#define GRECS_AH_PASSIVE 0x01
-#define GRECS_HINT_SERVICE 0x02
-#define GRECS_HINT_PORT 0x04
-
-struct grecs_sockaddr_hints {
- int flags;
- char *service;
- unsigned short port;
-};
-
-extern struct grecs_sockaddr_hints *grecs_sockaddr_hints;
-
-struct grecs_sockaddr *grecs_sockaddr_new(size_t s);
-void grecs_sockaddr_free(struct grecs_sockaddr *p);
-
-int grecs_str_to_sockaddr(struct grecs_sockaddr **sap,
- const char *arg, struct grecs_sockaddr_hints *gh,
- grecs_locus_t const *locus);
-#endif
-
-#define GRECS_INADDR_BYTES 16
-
-struct grecs_cidr
-{
- int family;
- int len;
- unsigned char address[GRECS_INADDR_BYTES];
- unsigned char netmask[GRECS_INADDR_BYTES];
-};
-
-int grecs_str_to_cidr(struct grecs_cidr *pcidr, const char *str,
- grecs_locus_t const *locus);
-
-int grecs_sockaddr_to_cidr(struct grecs_cidr *cidr, const struct sockaddr *sa);
-int grecs_sockadd_cidr_match(struct sockaddr *sa, struct grecs_cidr *cidr);
-
-#endif
diff --git a/src/json-gram.y b/src/json-gram.y
index 4d5ae0f..fe8996b 100644
--- a/src/json-gram.y
+++ b/src/json-gram.y
@@ -19,11 +19,11 @@
# include <config.h>
#endif
#include "grecs.h"
-#include <grecs-locus.h>
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
#include "json-gram.h"
-#include "json.h"
+#include "grecs/json.h"
struct json_value *json_return_obj;
diff --git a/src/json-lex.l b/src/json-lex.l
index 1ab6f74..169cf32 100644
--- a/src/json-lex.l
+++ b/src/json-lex.l
@@ -23,9 +23,8 @@
along with Grecs. If not, see <http://www.gnu.org/licenses/>. */
#include "grecs.h"
-#include <grecs-locus.h>
#include "json-gram.h"
-#include "json.h"
+#include "grecs/json.h"
static char const *input_ptr;
static size_t input_size;
diff --git a/src/jsonfmt.c b/src/jsonfmt.c
index dda919b..9ccac37 100644
--- a/src/jsonfmt.c
+++ b/src/jsonfmt.c
@@ -18,8 +18,9 @@
# include <config.h>
#endif
#include <string.h>
+#include <stdlib.h>
#include "grecs.h"
-#include "json.h"
+#include "grecs/json.h"
static void
json_writez(struct json_format *fmt, char const *str)
diff --git a/src/lookup.c b/src/lookup.c
index f6c0865..7cb95df 100644
--- a/src/lookup.c
+++ b/src/lookup.c
@@ -23,6 +23,7 @@
#include "grecs.h"
#include "wordsplit.h"
#include <fnmatch.h>
+#include <stdlib.h>
static int
_grecs_list_eq(struct grecs_value *a, struct grecs_value *b)
@@ -177,7 +178,7 @@ grecs_match_buf_create(int argc, char **argv, struct grecs_value **labelv)
for (j = i + 1;
j < buf->argc && ISWC(buf->argv[j], '*'); j++) {
- free(buf->argv[j]);
+ free(buf->argv[j]);
grecs_value_free_content(buf->labelv[i]);
}
j -= i;
diff --git a/src/meta1-gram.y b/src/meta1-gram.y
index 96ebd3d..3b9ca63 100644
--- a/src/meta1-gram.y
+++ b/src/meta1-gram.y
@@ -21,7 +21,6 @@
#include <errno.h>
#include <string.h>
#include "grecs.h"
-#include "grecs-locus.h"
int yylex(void);
int yyerror(char const *s);
diff --git a/src/meta1-lex.l b/src/meta1-lex.l
index 8050e5b..a5f873b 100644
--- a/src/meta1-lex.l
+++ b/src/meta1-lex.l
@@ -25,7 +25,6 @@
# include <config.h>
#endif
#include "grecs.h"
-#include "grecs-locus.h"
#include "meta1-gram.h"
#include <ctype.h>
}
diff --git a/src/opthelp.c b/src/opthelp.c
index 6428a46..c9b7b46 100644
--- a/src/opthelp.c
+++ b/src/opthelp.c
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include "grecs.h"
-#include "grecsopt.h"
+#include "grecs/opt.h"
#include "wordsplit.h"
static void
diff --git a/src/preproc.c b/src/preproc.c
index cf752f6..4d69602 100644
--- a/src/preproc.c
+++ b/src/preproc.c
@@ -18,6 +18,7 @@
# include <config.h>
#endif
#include <grecs.h>
+#include <wordsplit.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -29,8 +30,8 @@
#include <errno.h>
#include <signal.h>
#include <glob.h>
+#include <unistd.h>
-#include <wordsplit.h>
int grecs_log_to_stderr = 1;
void (*grecs_log_setup_hook) () = NULL;
diff --git a/src/sockaddr.c b/src/sockaddr.c
index d3a969b..8cd790d 100644
--- a/src/sockaddr.c
+++ b/src/sockaddr.c
@@ -28,6 +28,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>
+#include <stdlib.h>
#include "grecs.h"
struct grecs_sockaddr *
diff --git a/src/txtacc.c b/src/txtacc.c
index ee00170..5b9a197 100644
--- a/src/txtacc.c
+++ b/src/txtacc.c
@@ -18,6 +18,7 @@
# include <config.h>
#endif
#include <string.h>
+#include <stdlib.h>
#include "grecs.h"
struct grecs_txtacc_entry
@@ -73,7 +74,7 @@ static void
grecs_txtacc_entry_tailor(struct grecs_txtacc_entry *ent)
{
if (ent->size > ent->len) {
- char *p = realloc(ent->buf, ent->len);
+ char *p = grecs_realloc(ent->buf, ent->len);
if (!p)
return;
ent->buf = p;
diff --git a/src/version.c b/src/version.c
index 58ed799..e769e31 100644
--- a/src/version.c
+++ b/src/version.c
@@ -20,6 +20,7 @@
#include <grecs.h>
#include <string.h>
#include <ctype.h>
+#include <stdlib.h>
#include "gitid.h"
const char *grecs_vcs_id = "$Id: " GRECS_GIT_ID " $";
diff --git a/tests/gcfenum.c b/tests/gcfenum.c
index 1faa5c7..e36dbac 100644
--- a/tests/gcfenum.c
+++ b/tests/gcfenum.c
@@ -19,6 +19,7 @@
#endif
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
#include "grecs.h"
static void
diff --git a/tests/gcffmt.c b/tests/gcffmt.c
index 6bfc53e..8e378f9 100644
--- a/tests/gcffmt.c
+++ b/tests/gcffmt.c
@@ -19,6 +19,7 @@
#endif
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
#include "grecs.h"
struct list_helper {
diff --git a/tests/gcfpeek.c b/tests/gcfpeek.c
index cd7136a..8e71c62 100644
--- a/tests/gcfpeek.c
+++ b/tests/gcfpeek.c
@@ -19,6 +19,7 @@
#endif
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
#include "grecs.h"
static void
diff --git a/tests/gcfset.c b/tests/gcfset.c
index ee005a6..f241738 100644
--- a/tests/gcfset.c
+++ b/tests/gcfset.c
@@ -20,6 +20,7 @@
#include <stddef.h>
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
#include "grecs.h"
struct logging_setup {
diff --git a/tests/gcfver.c b/tests/gcfver.c
index e0396c1..b5c9bab 100644
--- a/tests/gcfver.c
+++ b/tests/gcfver.c
@@ -17,6 +17,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
+#include <stdlib.h>
#include "grecs.h"
int
diff --git a/tests/json.c b/tests/json.c
index fd244b5..0166c1a 100644
--- a/tests/json.c
+++ b/tests/json.c
@@ -22,8 +22,9 @@
#include <fcntl.h>
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
#include "grecs.h"
-#include "json.h"
+#include "grecs/json.h"
static void
printer(void *d, char const *buf, size_t size)

Return to:

Send suggestions and report system problems to the System administrator.