login | register
Sat 05 of Jul, 2008 [22:29 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.
 
Google Ads
Shoutbox
  • Samuel, Thu 03 of Jul, 2008 [13:41 UTC]: ok thank you
  • Mats Karlsson, Thu 03 of Jul, 2008 [13:37 UTC]: Nice Samuel, will look forward to rad it.
  • bwl_fernstudent, Thu 03 of Jul, 2008 [09:08 UTC]: Your blog shows some usefull code
  • Samuel, Thu 03 of Jul, 2008 [08:04 UTC]: I'll translate it, for sure
  • Mats Karlsson, Wed 02 of Jul, 2008 [20:46 UTC]: LOL, in french! Translate it to English and I will read it.
  • Samuel, Wed 02 of Jul, 2008 [08:07 UTC]: Hello, i wrote a blog about Asterisk, speaking about installation,programming and more http://sambranche.blogspot.com/
  • Nick Barnes, Tue 01 of Jul, 2008 [17:46 UTC]: Steve - Asterisk doesn't 'fit into linux' - it's an application which runs on top of Linux.
  • Steve, Mon 30 of Jun, 2008 [18:07 UTC]: anyone know where I can find a block diagram of how asterisk fits into linux. my f'ing bosses want me to draw something up.. ugh.
  • akbar, Fri 27 of Jun, 2008 [10:37 UTC]: marley_boyz@yahoo.com how to configure call forward, call back, call pick up using TDM and asterisk 1.2.13... please help me.. thx...
  • Matthew Williams, Tue 24 of Jun, 2008 [22:37 UTC]: We are looking for Tier II VoIP Support Technicians in St Louis. Send resumes to mwilliams AT voxitas DOT com.
Server Stats
  • Execution time: 0.40s
  • Memory usage: 2.59MB
  • Database queries: 32
  • GZIP: Disabled
  • Server load: 1.08

Asterisk::config

Asterisk::config is new perl module for Asterisk.

Access http://search.cpan.org/~hoowa/Asterisk-config/ for more details.



NAME

Asterisk::config - the Asterisk config read and write module.
SYNOPSIS

   use Asterisk::config;

   my $sip_conf = new Asterisk::config(file=>'/etc/asterisk/sip.conf');
   my $conference = new Asterisk::config(file=>'/etc/asterisk/meetme.conf',
                                             keep_resource_array=>0);

   $allow = $sip_conf->fetch_values_arrayref(section=>'general',key=>'allow');
   print $allow->0;

   $sip_conf->assign_append(point=>'down',data=>"userb\ntype=friend\n");

   $sip_conf->save();

DESCRIPTION

Asterisk::config can parse and saving data with Asterisk config files. this module support asterisk 1.0 1.2 1.4 1.6, and it also support Zaptel config files.
Note

Version 0.9 syntax incompitable with 0.8.
CLASS METHOD
new

   $sip_conf = new Asterisk::config(file=>'file name',
                                    stream_data=>$string,
                                    object variable);

Instantiates a new object of file. read data from stream_data or file.
OBJECT VARIABLE
file

config file name and path. if file no exists (exp. data from stream_data ) you can't saving by save_file.
keep_resource_array

use resource array when save make fast than open file, but need more memory, default enabled. use set_objvar to change it.
reload_when_save

when save done, auto call .

default enable. use set_variable to change it.
clean_when_reload

when reload done, auto clean_assign with current object. default enable. use set_objvar to change it.
commit_list

internal variable listed all command. i suggest don't modify and change this variable.
parsed_conf

internal variable of parsed. i suggest don't modify and change this variable.
OBJECT READ METHOD
get_objvar

   $sip_conf->get_objvar(var_name);

return defined object variables.
fetch_sections_list

   $sip_conf->fetch_sections_list();

only return sections name list. does not include 'unsection'.
fetch_sections_hashref

   $sip_conf->fetch_sections_hashref();

this function return parsed config files data.
fetch_keys_list

   $sip_conf->fetch_keys_list(section=>unsection);

return keys list of section name or unsection.
fetch_keys_hashref

   $sip_conf->fetch_keys_hashref(section=>unsection);

return referenced key list (and keys value), section value 'unsection' return all unsection keys, if section name unreachable return failed.
fetch_values_arrayref

   $sip_conf->fetch_values_arrayref(section=>unsection,
                                    key=>key name);

return referenced value list, if section name unreachable return failed. if key name unreachable return failed.
reload

   $sip_conf->reload();

reload and parse config file. if clean_when_reload true will do clean_assign.
OBJECT WRITE METHOD
set_objvar

   $sip_conf->set_objvar('var_name'=>'value');

set the object variables to new value.
assign_cleanfile

   $sip_conf->assign_cleanfile();

assign clean all to file.
assign_matchreplace

   $sip_conf->assign_matchreplace(match=>string,replace=>string);

replace new data when matched.

   * match -> string of matched data.
   * replace -> new data string.

assign_append

   $sip_conf->assign_append(point=>up>'down',
                            section=>section name,
                            data=>'key=value'|key=value','key=value>'key=value','key=value'|{key=>'value',key=>'value'});

append data around with section name.

   * point -> append data up / down / foot with section.
   * section -> matched section name, expect 'unsection'.
   * data -> new replace data in string/array/hash.

   $sip_conf->assign_append(point=>up>'down',
                            section=>section name,
                            comkey=>key,value,
                            data=>'key=value'|key=value','key=value>'key=value','key=value'|{key=>'value',key=>'value'};

append data around with section name and key/value in same section.

   * point -> over will overwrite with key/value matched.
   * comkey -> match key and value.

   $sip_conf->assign_append(point=>'up'|'down',
                            data=>'key=value'|key=value','key=value>'key=value','key=value'|{key=>'value',key=>'value'});

simple append data without any section.
assign_replacesection

   $sip_conf->assign_replacesection(section=>unsection,
                            data=>'key=value'|key=value','key=value>'key=value','key=value'|{key=>'value',key=>'value'});

replace the section body data.

   * section -> all section name and 'unsection'.

assign_delsection

   $sip_conf->assign_delsection(section=>unsection);

erase section name and section data.

   * section -> all section and 'unsection'.

assign_addsection

   $sip_conf->assign_addsection(section=>section);

add section with name.

   * section -> name of new section.

assign_editkey

   $sip_conf->assign_editkey(section=>unsection,key=>keyname,value=>value,new_value=>new_value);

modify value with matched section.if don't assign value=> will replace all matched key.

warnning example script:

   $sip_conf->assign_editkey(section=>'990001',key=>'all',new_value=>'gsm');

data:

   all=g711
   all=ilbc

will convert to:

   all=gsm
   all=gsm

assign_delkey

   $sip_conf->assign_delkey(section=>unsection,key=>keyname,value=>value);

erase all matched keyname in section or in 'unsection'.
save_file

   $sip_conf->save_file(new_file=>'filename');

process commit list and save to file. if reload_when_save true will do reload. if no object variable file or file not exists or can't be save return failed. if defined new_file will save to new file, default overwrite objvar 'file'.
clean_assign

   $sip_conf->clean_assign();

clean all assign rules.
EXAMPLES

see example in source tree.
AUTHORS

Asterisk::config by Sun bing <hoowa.sun@gmail.com>

Version 0.7 patch by Liu Hailong.
COPYRIGHT

The Asterisk::config module is Copyright (c) Sun bing <hoowa.sun@gmail.com> All rights reserved.

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
WARRANTY

The Asterisk::config is free Open Source software.

IT COMES WITHOUT WARRANTY OF ANY KIND.
SUPPORT

Sun bing <hoowa.sun@gmail.com>

The Asterisk::config be Part of FreeIris opensource Telephony Project Access http://www.freeiris.org for more details.
Created by hoowa, Last modification by hoowa on Fri 25 of Jan, 2008 [06:14 UTC]

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2008 VOIP-Info.org LLC

Powered by bitweaver