10 use vars qw
/ $opt_action $opt_fname $opt_section $opt_key $opt_value $opt_data /;
11 GetOptions
("action=s","fname:s","section:s","key:s@"=>\
$opt_key,"value:s@"=>\
$opt_value,"data:s");
13 ## &&(defined($opt_section))&&(defined(@{$opt_key}))&&(defined(@{$opt_value})))
15 unless (($opt_action)&&(defined($opt_fname)))
17 print STDERR
"Not enough params\n";
20 if ($opt_action=~/listsections/i)
26 if ($opt_action=~/addsectionvaluesxt/i)
32 if ($opt_action=~/addsectionvalues/i)
38 if ($opt_action=~/getsectionvaluesxt/i)
44 if ($opt_action=~/getsectionvalues/i)
50 if ($opt_action=~/delsection/i)
56 #####################################################################
59 my $rc = new Asterisk
::config
(file
=>$opt_fname);
60 my $section_list = $rc->fetch_sections_list();
61 foreach my $section( sort @
{$section_list})
67 sub addsectionvalues
{
68 my $rc = new Asterisk
::config
(file
=>$opt_fname);
69 $rc->assign_addsection(section
=>$opt_section);
70 for (my $i=@
{$opt_key}-1; $i>-1;$i--)
72 $rc->assign_append(point
=>'down',section
=>$opt_section,data
=>"${$opt_key}[$i]=${$opt_value}[$i]");
74 $rc->save_file(new_file
=>$opt_fname);
77 sub addsectionvaluesxt
{
78 my $rc = new Asterisk
::config
(file
=>$opt_fname);
79 $rc->assign_addsection(section
=>$opt_section);
80 for (my $i=@
{$opt_key}-1; $i>-1;$i--)
82 $rc->assign_append(point
=>'down',section
=>$opt_section,data
=>"${$opt_key}[$i] => ${$opt_value}[$i]");
84 $rc->save_file(new_file
=>$opt_fname);
87 sub getsectionvalues
{
88 my $rc = new Asterisk
::config
(file
=>$opt_fname);
89 my $key_ref = $rc->fetch_keys_hashref(section
=>$opt_section);
90 if ( $key_ref == '0') { print "Section not found!\n";}
92 for my $k1 ( sort keys %$key_ref )
94 for my $k2 ( @
{$key_ref->{ $k1 }} )
103 sub getsectionvaluesxt
{
104 my $rc = new Asterisk
::config
(file
=>$opt_fname);
105 my $key_ref = $rc->fetch_keys_hashref(section
=>$opt_section);
106 if ( $key_ref == '0') { print "Section not found!\n";}
108 for my $k1 ( sort keys %$key_ref )
110 for my $k2 ( @
{$key_ref->{ $k1 }} )
112 print "$k1 => $k2\n";
119 my $rc = new Asterisk
::config
(file
=>$opt_fname);
120 $rc->assign_delsection(section
=>$opt_section);
121 $rc->save_file(new_file
=>$opt_fname);