On Sun, Nov 19, 2017, at 01:18 PM, Nir Simionovich wrote: > Hi All, > > Ok, this email may be totally pointless to some, but I'm having some > conceptual difficulties with the methodology of processing .conf files. > > Allow me to explain my current issues in ramping up on this one. As > part > of the > beanstalk work I've done, I would like to create either an app_beanstalk > or > func_beanstalk or to be better, a res_beanstalk. > > In my mind, I see a configuration file works something like the > following: > > ; > ; Beanstalk job queue resourcing application > ; > > [general] > ttr = 60 ; an integer number of seconds to allow a worker to > run > a job > delay = 0 ; an integer number of seconds to wait before marking > a > job as ready. > ; A job will be set as "delayed" in this period of > time > > > [tube1] > enabled = no > ;host = 127.0.0.1 ; Specify the remote IP address of the Beanstalkd > server > ;port = 11300 ; Specify the remote PORT of the the Beanstalkd > server > ;tube = asterisk-cdr ; Specify the default job queue to use > ;priority = 99 ; Specify the default job priority for the queue. > The > lower the number, > ; the higher the priority. > > > [tube2] > enabled = no > ;host = 127.0.0.1 ; Specify the remote IP address of the Beanstalkd > server > ;port = 11300 ; Specify the remote PORT of the the Beanstalkd > server > ;tube = asterisk-cdr ; Specify the default job queue to > ;priority = 99 ; Specify the default job priority for the queue. > The > lower the number, > ; the higher the priority. > > Now, I've trying to figure out how the configuration parser works with > "free form" data. I've tried looking > into app_voicemail.c, as that uses a fairly similar concept, however, > that > didn't provide much help. > > From what I gathered, there are two main functions that I need to > understand how they work: > ast_category_browse and ast_variable_browse. Now, the basic methodology > of > the various Asterisk > config files is fairly static, namely, a configuration for a singular > function - very much like cdr_beanstalkd.conf. > However, for my new tool to work, I need to be able to create dynamically > allocated "tube contexts". I couldn't find > any specific sample that would describe this kind of methodology of > operation in a coherent manner.
You need to use the ast_category_browse function you've mentioned to iterate the parsed categories of the .conf file - these being the general, tube1, tube2, etc. What happens with those categories and what meaning they have is up to you. The ast_variable_browse function can then be used to iterate the set options inside of the category, or you can directly get values for things. The core config parser just presents the data in categories/variables, nothing more. New code though should use either ACO (Asterisk config options) or Sorcery (ACO + Sorcery + other features). Which one should be used really depends on the use case. These sit on top of the config parser and map things into C structures automatically and atomically. You define how a category maps to a C structure (for example requires a type=tube option being set), and then each option can be mapped to a field in the C structure or can execute arbitrary code. -- Joshua Colp Digium, Inc. | Senior Software Developer 445 Jan Davis Drive NW - Huntsville, AL 35806 - US Check us out at: www.digium.com & www.asterisk.org -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev
