changeset 322:85046c97a50f

Simplified some configuration file syntax
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 05 Mar 2009 13:52:14 +0900
parents 6b69942ecadb
children 74ab9d60d452
files doc/waaad.conf.sample waaad/waaad.l waaad/waaad.y
diffstat 3 files changed, 35 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/doc/waaad.conf.sample	Mon Mar 02 18:43:05 2009 +0900
+++ b/doc/waaad.conf.sample	Thu Mar 05 13:52:14 2009 +0900
@@ -77,29 +77,24 @@
 [extensions]
 
 # Each dynamic extension that must be loaded is specified with this syntax:
-# "extname" = { filename="path/to/extfile"; conffile="path/to/conffile"; };
+# "path/to/extfile";
+# or:
+# "path/to/extfile" : "path/to/conffile";
 # Where:
-#  extname  is an alias for the extension. You may provide anything here.
-#  filename is the location of the dynamic library to open.
-#  conffile is optional. When provided, it is passed to the extension.
-#
-#"sample" = {
-#	filename="/root/sources/waaad/build/extensions/sample/.libs/sample.so";
-#};
+#  path/to/extfile is the location of the dynamic library to open.
+#  path/to/conffile is an extension-dependent string, usually path to extension configuration file.
 #
-"sec_nosec" = {
-	filename="/root/sources/waaad-cmake-bld/extensions/libsec_nosec.so";
-	conffile="/root/sources/waaad/doc/sec_nosec.conf.sample";
-};
-#"sec_tls" = {
-#	filename="/root/sources/waaad/build/extensions/sec_tls_gnutls/.libs/sec_tls_gnutls.so";
-#	conffile="/root/sources/waaad/doc/sec_tls_gnutls.conf.sample";
-#};
+# Examples:
+#  "build/extensions/libsample.so";
+#
+#  "libsample.so" : "/etc/waaad/sample.conf";
+#
+"extensions/libsec_nosec.so"
+	: "../doc/sec_nosec.conf.sample";
 
-"rt_default" = {
-	filename="/root/sources/waaad-cmake-bld/extensions/librt_default.so";
-	conffile="/root/sources/waaad/doc/rt_default.conf.sample";
-};
+"extensions/librt_default.so"
+	: "../doc/rt_default.conf.sample";
+
 
 [peers]
 
@@ -109,6 +104,8 @@
 # the connexion will be closed.
 #
 # The format is:
+# "peer_fqdn";
+# or
 # "peer_fqdn" = { uri="peer_uri"; sctp_streams=30; };
 # where:
 #  peer_fqdn is the Diameter-Id of the remote peer.
@@ -130,5 +127,5 @@
 	uri = "aaas://aaa.koganei.wide.ad.jp:3869;transport=tcp";
 };
 
-"jules.nautilus6.org" = {};
+"jules.nautilus6.org";
 
--- a/waaad/waaad.l	Mon Mar 02 18:43:05 2009 +0900
+++ b/waaad/waaad.l	Thu Mar 05 13:52:14 2009 +0900
@@ -182,7 +182,7 @@
 			}
 	
 	/* Valid single characters for yyparse */
-<*>[=,;{}]		{ return yytext[0]; }
+<*>[=,:;{}]		{ return yytext[0]; }
 
 	/* Unrecognized token */
 <*>[[:alnum:]]+		|	/* This rule is only useful to print a complete token in error messages */
--- a/waaad/waaad.y	Mon Mar 02 18:43:05 2009 +0900
+++ b/waaad/waaad.y	Thu Mar 05 13:52:14 2009 +0900
@@ -552,51 +552,40 @@
 				if (ext_detail.fname) { free(ext_detail.fname); ext_detail.fname = NULL; }
 				if (ext_detail.cname) { free(ext_detail.cname); ext_detail.cname = NULL; }
 			}
-			QSTRING '=' '{' extension_params '}' ';'
+			extension_params ';'
 			{
 				int ret = 0;
 				
 				/* Add this extension */
 				ret = ext_register( ext_detail.fname, ext_detail.cname );
 				
+				if (ret != 0) {
+					log_error("Failed to register extension %s: %s\n", ext_detail.fname, strerror(ret));
+				}
+
 				/* Free the strings */
 				if (ext_detail.fname) { free(ext_detail.fname); ext_detail.fname = NULL; }
 				if (ext_detail.cname) { free(ext_detail.cname); ext_detail.cname = NULL; }
 				
 				/* Check error */
 				if (ret != 0) {
-					log_error("Failed to register extension %s: %s\n", $2, strerror(ret));
 					YYERROR;
 				}
 			}
 			;
 
-extension_params:	extension_confname extension_filename extension_confname	/* confname appears twice on purpose, to allow any order */
-			;
-
-extension_filename:	EXT_FILENAME '=' FILENAME ';'
+extension_params:	FILENAME extension_confname	/* confname appears twice on purpose, to allow any order */
 			{
 				if (ext_detail.fname) { free(ext_detail.fname); ext_detail.fname = NULL; }
-				ext_detail.fname = $3;
-			}
-			| EXT_FILENAME '=' error ';'
-			{
-				log_error("You must provide a valid filename for extension.\n");
-				YYERROR;
+				ext_detail.fname = $1;
 			}
 			;
 
 extension_confname:	/* This one is optional */
-			| EXT_CONFFILE '=' FILENAME ';'
+			| ':' FILENAME
 			{
 				if (ext_detail.cname) { free(ext_detail.cname); ext_detail.cname = NULL; }
-				ext_detail.cname = $3;
-			}
-			| EXT_CONFFILE '=' error ';'
-			{
-				log_error("If you provide a configuration file for the extension, it must be a valid file.\n"
-					  " Note that you may remove the 'conffile' directive if your extension has no configuration.\n");
-				YYERROR;
+				ext_detail.cname = $2;
 			}
 			;
 
@@ -605,17 +594,17 @@
 			;
 
 peers_content:		/* empty is allowed */
-			| peers_content peer_detail
+			| peers_content peer_def
 			;
 
-peer_detail:		{
+peer_def:		{
 				/* Initialize the peer details */
 				if (peer_detail.locator ) { free(peer_detail.locator); }
 				memset(&peer_detail, 0, sizeof(peer_detail));
 				peer_detail.port = 3868;
 				peer_detail.sctp_streams = pconfig->pub.sctp_streams;
 			}
-			FQDN '=' '{' peer_content '}' ';'
+			FQDN peer_detail ';'
 			{
 				int ret = 0;
 				peer_add_t data;
@@ -677,6 +666,10 @@
 			}
 			;
 			
+peer_detail:		/* empty is allowed */
+			| '=' '{' peer_content '}'
+			;
+
 peer_content:		/* empty is allowed */
 			| peer_content peer_uri
 			| peer_content peer_sctp_streams
"Welcome to our mercurial repository"