mathieu: server/perl-kolab/lib/Kolab Conf.pm,1.11,1.12

cvs at kolab.org cvs at kolab.org
Thu Dec 10 18:43:39 CET 2009


Author: mathieu

Update of /kolabrepository/server/perl-kolab/lib/Kolab
In directory doto:/tmp/cvs-serv14804/lib/Kolab

Modified Files:
	Conf.pm 
Log Message:
Reindent and remove old comments


Index: Conf.pm
===================================================================
RCS file: /kolabrepository/server/perl-kolab/lib/Kolab/Conf.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Conf.pm	24 Nov 2009 18:44:58 -0000	1.11
+++ Conf.pm	10 Dec 2009 17:43:37 -0000	1.12
@@ -128,11 +128,11 @@
     my $templatedir = $Kolab::config{"templatedir"};
 
     my %special_templates = (
-	"$templatedir/transport.template"      => 1,
-	"$templatedir/virtual.template"        => 1,
-	"$templatedir/imapd.group.template"    => 1,
-	"$templatedir/slapd.access.template"   => 1,
-	"$templatedir/slapd.replicas.template" => 1
+	    "$templatedir/transport.template"      => 1,
+	    "$templatedir/virtual.template"        => 1,
+	    "$templatedir/imapd.group.template"    => 1,
+	    "$templatedir/slapd.access.template"   => 1,
+	    "$templatedir/slapd.replicas.template" => 1
 	);
 
     my $oldmask = umask 077;
@@ -142,44 +142,40 @@
         Kolab::log('T', "`$cfg' creation detected", KOLAB_DEBUG );
     }
     copy($cfg, $oldcfg);
-    #chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
     # To avoid warnings, the backup files must be owned by root
     chown(0, 0, $oldcfg);
     umask $oldmask;
     #chmod(0600, $oldcfg) if ($oldcfg =~ /openldap/);
 
     Kolab::log('T', "Creating new configuration file `$cfg' from template `$tmpl'", KOLAB_DEBUG );
-    #print STDERR "Creating new configuration file `$cfg' from template `$tmpl'\n";
 
     my $template;
     if (!($template = IO::File->new($tmpl, 'r'))) {
         Kolab::log('T', "Unable to open template file `$tmpl': $!", KOLAB_ERROR);
-	# Error, fail gracefully
-	return;
+        # Error, fail gracefully
+        return;
     }
     my $config;
     if (!($config = new File::Temp( TEMPLATE => 'tmpXXXXX',
-				    DIR => $Kolab::config{"kolabdir"},
-				    SUFFIX => '.kolabtmp',
-				    UNLINK => 0 ))) {
+                                    DIR => $Kolab::config{"kolabdir"},
+                                    SUFFIX => '.kolabtmp',
+                                    UNLINK => 0 ))) {
         Kolab::log('T', "Unable to open configuration file `$cfg': $!", KOLAB_ERROR);
         exit(1);
     }
 
-    #Kolab::log('T', "Using temporary file '".$config->filename."'", KOLAB_DEBUG );
-
     my $skip = 0;
     my $keep = 0;
     while (<$template>) {
-    	#Eat the meta data sections
-	if (/^KOLAB_META_START$/) {
-	    my $found_end;
-	    while (!$found_end) {	
-		$_ = <$template>;
-		$found_end = /^KOLAB_META_END$/;
-	    }
-	    $_ = <$template>;
-	}
+        #Eat the meta data sections
+        if (/^KOLAB_META_START$/) {
+            my $found_end;
+            while (!$found_end) {	
+            $_ = <$template>;
+            $found_end = /^KOLAB_META_END$/;
+            }
+            $_ = <$template>;
+        }
 
         if (/\@{3}if\s+exists\(\s*(\S+?)\s*\)\@{3}/) {
             # @@@if exists(/full/path/to/file)@@@
@@ -198,82 +194,82 @@
             # its value set to either 'false' or 'true'
             if ($Kolab::config{$1} && lc($Kolab::config{$1}) ne "false" ) {
                 # Keep text
-		$keep = 1;
+                $keep = 1;
             } else {
                 # Skip text
                 $skip++;
-		$keep = 0;
+                $keep = 0;
             }
             s/\@{3}if (\S+?)\@{3}\n?//;
-	} elsif (/\@{3}else\@{3}/) {
-	    if( $keep == 0 ) {
-		# Now keep
-		$keep = 1;
-		$skip--;
-	    } else {
-		# Now skip
-		$keep = 0;
-                $skip++;
-	    }
-            s/\@{3}else\@{3}\n?//;
+        } elsif (/\@{3}else\@{3}/) {
+            if( $keep == 0 ) {
+            # Now keep
+            $keep = 1;
+            $skip--;
+            } else {
+            # Now skip
+            $keep = 0;
+                    $skip++;
+            }
+                s/\@{3}else\@{3}\n?//;
 
         } elsif (/\@{3}endif\@{3}/) {
             ($skip > 0) && $skip--;
             s/\@{3}endif\@{3}\n?//;
 
-        } elsif (/\@{3}warning\@{3}/) { 
+        } elsif (/\@{3}warning\@{3}/) {
 
             printWarning($config, $tmpl, $cchr);
 
         } else {
             while (/\@{3}([^\s\@]+?)(\|(.+?)\((.*)\))?\@{3}/) {
-		my $attr = $1;
-		my $fct  = $3;
-		my $args = $4;
-		#print STDERR "attr=\"$attr\", fct=\"$fct\", args=\"$args\"\n";
-		if ($Kolab::config{$attr}) {
-		    my $val = "";
-		    if( !$fct ) {
-			if (ref $Kolab::config{$attr} eq "ARRAY") {
-			    $val = $Kolab::config{$attr}->[0];
-			} else {
-			    $val = $Kolab::config{$attr};
-			}
-		    } else {
-			# Modifier functions
-		      SWITCH: {
-			  # Join function 
-			  $fct eq 'join' && do {
-			      if (ref $Kolab::config{$attr} eq "ARRAY") {
-				  my @vals = @{$Kolab::config{$attr}} ;
-				  # We want to make sure subdomain.domain.tld comes before domain.tld
-				  my @length_sorted_vals = sort {length $b cmp length $a} @vals;
-				  $val = join ($args, @length_sorted_vals) ;
-			      } else {
-				  $val = $Kolab::config{$attr};
-			      }
-			      last SWITCH;
-			  };
-			  # Quote function
-			  $fct eq 'quote' && do {
-			      # slapd.conf compatible quoting
-			      $val = $Kolab::config{$attr};
-			      $val =~ s/"/\"/g;
-			      $val = '"'.$val.'"';
-			      last SWITCH;
-			  }
-			}
-		    }
-		    s/\@{3}([^\s\@]+?)(\|.+?)?\@{3}/$val/;
-		    last if ( $val eq "\@\@\@$attr\@\@\@" ); # prevent endless loop
-		} else {
-		    # Only warn the user in case we are not skipping the section
-		    ($skip == 0) && Kolab::log('T', "No configuration variable corresponding to `$1' exists", KOLAB_WARN);
-		    s/\@{3}([^\s\@]+?)\@{3}//;
-		}
-	    }
-	    ($skip == 0) && print $config $_;
-	}
+                my $attr = $1;
+                my $fct  = $3;
+                my $args = $4;
+                #print STDERR "attr=\"$attr\", fct=\"$fct\", args=\"$args\"\n";
+                if ($Kolab::config{$attr}) {
+                    my $val = "";
+                    if( !$fct ) {
+                        if (ref $Kolab::config{$attr} eq "ARRAY") {
+                            $val = $Kolab::config{$attr}->[0];
+                        } else {
+                            $val = $Kolab::config{$attr};
+                        }
+                    } else {
+                        # Modifier functions
+                        SWITCH: {
+                            # Join function 
+                            $fct eq 'join' && do {
+                                if (ref $Kolab::config{$attr} eq "ARRAY") {
+                                my @vals = @{$Kolab::config{$attr}} ;
+                                # We want to make sure subdomain.domain.tld comes before domain.tld
+                                my @length_sorted_vals = sort {length $b cmp length $a} @vals;
+                                $val = join ($args, @length_sorted_vals) ;
+                                } else {
+                                $val = $Kolab::config{$attr};
+                                }
+                                last SWITCH;
+                            };
+                            # Quote function
+                            $fct eq 'quote' && do {
+                                # slapd.conf compatible quoting
+                                $val = $Kolab::config{$attr};
+                                $val =~ s/"/\"/g;
+                                $val = '"'.$val.'"';
+                                last SWITCH;
+                            }
+                        }
+                    }
+                    s/\@{3}([^\s\@]+?)(\|.+?)?\@{3}/$val/;
+                    last if ( $val eq "\@\@\@$attr\@\@\@" ); # prevent endless loop
+                } else {
+                    # Only warn the user in case we are not skipping the section
+                    ($skip == 0) && Kolab::log('T', "No configuration variable corresponding to `$1' exists", KOLAB_WARN);
+                    s/\@{3}([^\s\@]+?)\@{3}//;
+                }
+            }
+            ($skip == 0) && print $config $_;
+        }
     }
     
     $template->close;





More information about the commits mailing list