/[libconf]/libconf/perl-Libconf/templates/passwd_template.pm
ViewVC logotype

Diff of /libconf/perl-Libconf/templates/passwd_template.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by dams, Mon Apr 14 19:03:49 2003 UTC revision 1.9 by dams, Thu Apr 17 21:28:10 2003 UTC
# Line 30  $templates{passwd} = { Line 30  $templates{passwd} = {
30                                       q(                                       q(
31                                         if (my @infos = $in =~ /^\s*(\S+?):(\S*?):(\S*?):(\S*?):(.*?):(.*?):(.*?)\s*$/) {                                         if (my @infos = $in =~ /^\s*(\S+?):(\S*?):(\S*?):(\S*?):(.*?):(.*?):(.*?)\s*$/) {
32                                             $in = '';                                             $in = '';
33                                             $atom->{type} = 'VALUES';                                             $atom->{type} = 'KEY_VALUES';
34                                             @{$atom->{values}}{qw(account passwd UID GID GECOS directory shell)} = @infos;                                             $atom->{key} = shift @infos;
35                                               @{$atom->{values}}{qw(passwd UID GID GECOS directory shell)} = @infos;
36                                             $matched = 1;                                             $matched = 1;
37                                         }                                         }
38                                       ),                                       ),
# Line 39  $templates{passwd} = { Line 40  $templates{passwd} = {
40                             comments => [ ['#'] ],                             comments => [ ['#'] ],
41                             comment_output => q(/^(\s*)$/ ? "$_\n" : "#$_\n"),                             comment_output => q(/^(\s*)$/ ? "$_\n" : "#$_\n"),
42                             output => {                             output => {
43                                        VALUES => q(                                        KEY_VALUES => q(
44                                              join(':', @{$atom->{values}}{qw(account passwd UID GID GECOS directory shell)}) . "\n";                                           join(':', $atom->{key}, @{$atom->{values}}{qw(account passwd UID GID GECOS directory shell)}) . "\n";
45                                        ),                                        ),
46                                       },                                       },
47                             edit_atom => q(                             edit_atom => q(
48                                             if ($index == -1) {                                             if ($index == -1) {
49                                                 my $i = 0;                                                 my $i = 0;
50                                                 foreach (@{$out->{atoms}}) {                                                 foreach (@{$out->{atoms}}) {
51                                                  $_->{values}{account} eq $args{values}{account} and $index = $i; #we don't exit the loop, to have the last atom if multiples ones match                                                     $_->{key} eq $args{key} and $index = $i;
52                                                  $i++;                                                     $i++;
53                                                 }                                                 }
54                                                 $index == -1 and return -2;                                                 $index == -1 and return -2;
55                                             }                                             }
# Line 60  $templates{passwd} = { Line 61  $templates{passwd} = {
61                                               my @res;                                               my @res;
62                                               foreach my $atom (@{$out->{atoms}}) {                                               foreach my $atom (@{$out->{atoms}}) {
63                                                   my $flag = 1;                                                   my $flag = 1;
64                                                   foreach (keys(%args)) {                                                   foreach my $key (keys(%args)) {
65                                                       $atom->{$_} eq $args{$_} or $flag = 0;                                                       if ($key eq 'values') {
66                                                             foreach (keys(%{$args{values}})) {
67                                                                 $atom->{values}{$_} eq $args{values}->{$_} or $flag = 0, last;
68                                                             }
69                                                         } else {
70                                                             $atom->{$key} eq $args{$key} or $flag = 0, last;
71                                                         }
72                                                   }                                                   }
73                                                   $flag and push(@res, $i);                                                   $flag and push(@res, $i);
74                                                   $i++;                                                   $i++;

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26