Documentation & misc fixes:
authorJose Luis Tallon <jltallon@adv-solutions.net>
Sun, 22 Nov 2015 22:49:23 +0000 (23:49 +0100)
committerJose Luis Tallon <jltallon@adv-solutions.net>
Wed, 23 Dec 2015 23:29:04 +0000 (00:29 +0100)
 - Document the include_dir directive
 - Robustness: filter out non-files (where scandir supports it)
 - Add myself to the credits

AUTHORS
doc/libconfig.texi
lib/scanner.l

diff --git a/AUTHORS b/AUTHORS
index 501791c..c12bf6e 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -4,3 +4,4 @@ Daniel Marjamäki - Enhancements & bugfixes.
 Andrew Tytula - Windows port.
 Glenn Herteg - Enhancements, bugfixes, documentation corrections.
 Matt Renaud - Enhancements & bugfixes.
+JoseLuis Tallon - Enhacements
index a273241..d263a28 100644 (file)
@@ -36,7 +36,7 @@
 
 @page
 @vskip 0pt plus 1filll
-Copyright @copyright{} 2005-2014  Mark A Lindner
+Copyright @copyright{} 2005-2015  Mark A Lindner
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
@@ -640,6 +640,48 @@ info: @{
 @end smallexample
 @end cartouche
 
+The resulting configuration will be equivalent to one in which the
+contents of the ``quote.cfg`` file appeared at the point where the
+@@include directive is placed.
+
+@cindex include_dir directive
+Additionally, a directory containing configuration snippets can be 
+processed using an @i{include_dir directive}. This directive has the 
+effect of inlining the contents of the files contained in the named
+directory at the point of inclusion.
+The files are ordered lexicographically and ``hidden`` files (those
+having a name beginning with a dot) are excluded.
+
+An include_dir directive must appear on its own line in the input:
+
+@b{@@include_dir "}@i{dirname}@b{"}
+
+The same quoting rules as for @i{@@include} apply.
+
+
+@cartouche
+@smallexample
+# directory: myapp/conf.d
+00prolog.cfg
+01header.cfg
+02body.cfg
+03footer.cfg
+99epilog.cfg
+@end smallexample
+@end cartouche   
+
+@cartouche
+@smallexample
+# file: test.cfg
+docinfo: @{
+  name = "Some complex config";
+  @@include_dir "myapp/conf.d"
+@};
+@end smallexample
+@end cartouche   
+
+Please keep in mind that the files will be included in lexicographical order.
+
 Include files may be nested to a maximum of 10 levels; exceeding this
 limit results in a parse error.
 
index 4dc97c4..ffe6bb9 100644 (file)
@@ -87,6 +87,14 @@ static unsigned long long fromhex(const char *s)
 static int filter_dotfiles(const struct dirent *de)
 {
   const char *fname = de->d_name;
+
+#ifdef _DIRENT_HAVE_D_TYPE
+  /* filter out non-files and non-symlinks */
+  if( DT_REG!=de->d_type && DT_LNK!=de->d_type
+    && DT_UNKNOWN!=de->d_type )
+            return 0;
+#endif
+
   return ( NULL != fname 
     && '\0' != fname[0] /* can't really happen */
     && '.' != fname[0] ) ? 1 : 0 ;