INN commit: trunk (doc/pod/innconfval.pod lib/innconf.c)

INN Commit Russ_Allbery at isc.org
Sun Apr 12 17:30:50 UTC 2009


    Date: Sunday, April 12, 2009 @ 10:30:50
  Author: iulius
Revision: 8414

Return a string instead of an array when "innconfval -s" is
used because pure Bourne shell does not recognize arrays.

Modified:
  trunk/doc/pod/innconfval.pod
  trunk/lib/innconf.c

------------------------+
 doc/pod/innconfval.pod |   49 ++++++++++++++++++++++++++++++++++++++++-------
 lib/innconf.c          |   13 ++++++++----
 2 files changed, 51 insertions(+), 11 deletions(-)

Modified: doc/pod/innconfval.pod
===================================================================
--- doc/pod/innconfval.pod	2009-04-12 11:58:22 UTC (rev 8413)
+++ doc/pod/innconfval.pod	2009-04-12 17:30:50 UTC (rev 8414)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-innconfval - Get configuration parameters from inn.conf
+innconfval - Get configuration parameters from F<inn.conf>
 
 =head1 SYNOPSIS
 
@@ -44,9 +44,22 @@
 Print out parameters as Perl assignment statements.  The variable name
 will be the same as the F<inn.conf> parameter, and string values will be
 enclosed in single quotes with appropriate escaping.  Boolean values will
-be mapped to C<true> or C<false>, and string parameters that are set to
-NULL will be mapped to empty strings.
+be mapped to the strings C<true> or C<false>, and string parameters that
+are set to NULL will be mapped to empty strings.  List values will be
+mapped to an array of strings.
 
+Here is an example:
+
+    $domain = '';
+    $enableoverview = 'true';
+    @extraoverviewadvertised = ( 'Newsgroups', 'Injection-Info' );
+    @extraoverviewhidden = ( );
+    $organization = 'Let\'s try nasty "quotes"';
+    $maxforks = 10;
+
+If B<innconfval> is called via the Perl C<INN::Config> module, all
+these variables are properly exported.
+
 =item B<-s>
 
 Print out parameters as Bourne shell assignment statements.  The variable
@@ -54,16 +67,38 @@
 variables will be exported.  String values will be enclosed in single
 quotes with appropriate escaping, and boolean values will be mapped to
 C<true> or C<false>.  String parameters that are set to NULL will be
-mapped to empty strings.
+mapped to empty strings.  List values will be mapped to a string
+representing an array of strings (as Bourne shell does not recognize
+arrays, contrary to several other shells, an array cannot be returned
+for interoperability reasons).
 
+Here is an example:
+
+    DOMAIN=''; export DOMAIN;
+    ENABLEOVERVIEW=true; export ENABLEOVERVIEW;
+    EXTRAOVERVIEWADVERTISED='( "Newsgroups" "Injection-Info" )'; export EXTRAOVERVIEWADVERTISED;
+    EXTRAOVERVIEWHIDDEN='( )'; export EXTRAOVERVIEWHIDDEN;
+    ORGANIZATION='Let'\''s try nasty "quotes"'; export ORGANIZATION;
+    MAXFORKS=10; export MAXFORKS;
+
 =item B<-t>
 
 Print out parameters as Tcl assignment statements.  The variable name will
 be the same as the F<inn.conf> parameter name but with C<inn_> prepended,
 and string variables will be escaped appropriately.  Boolean values will
-be mapped to C<true> or C<false> and string parameters that are set to
-NULL will be mapped to empty strings.
+be mapped to the strings C<true> or C<false>, and string parameters that
+are set to NULL will be mapped to empty strings.  List values will be
+mapped to an array of strings.
 
+Here is an example:
+
+    set inn_domain ""
+    set inn_enableoverview "true"
+    set inn_extraoverviewadvertised { "Newsgroups" "Injection-Info" }
+    set inn_extraoverviewhidden { }
+    set inn_organization "Let's try nasty \"quotes\""
+    set inn_maxforks 10
+
 =item B<-v>
 
 Print INN's version.  This is equivalent to C<innconfval version>.
@@ -78,6 +113,6 @@
 
 =head1 SEE ALSO
 
-inn.conf(5)
+inn.conf(5), INN::Config(3pm).
 
 =cut

Modified: lib/innconf.c
===================================================================
--- lib/innconf.c	2009-04-12 11:58:22 UTC (rev 8413)
+++ lib/innconf.c	2009-04-12 17:30:50 UTC (rev 8414)
@@ -748,23 +748,28 @@
         upper = xstrdup(key);
         for (p = upper; *p != '\0'; p++)
             *p = toupper(*p);
-        fprintf(file, "%s=( ", upper);
+        /* For interoperability reasons, we return a string representing
+         * an array (pure Bourne shell does not have the notion of an
+         * array for instance). */
+        fprintf(file, "%s='( ", upper);
         if (value != NULL && value->strings != NULL) {
             for (i = 0; i < value->count; i++) {
-                fprintf(file, "'");
+                fprintf(file, "\"");
                 for (letter = value->strings[i]; letter != NULL
                      && *letter != '\0'; letter++) {
                     if (*letter == '\'')
                         fputs("'\\''", file);
+                    else if (*letter == '"')
+                        fputs("\\\"", file);
                     else if (*letter == '\\')
                         fputs("\\\\", file);
                     else
                         fputc(*letter, file);
                 }
-                fprintf(file, "' ");
+                fprintf(file, "\" ");
             }
         }
-        fprintf(file, "); export %s;\n", upper);
+        fprintf(file, ")'; export %s;\n", upper);
         free(upper);
         break;
     case INNCONF_QUOTE_PERL:




More information about the inn-committers mailing list