Re: Named.conf logical blocks

2011-06-29 Thread Phil Mayers

On 06/28/2011 09:54 PM, Stefan Certic wrote:

I am more looking for a solution to read data with perl and convert to some
native data structure, like hash reference, or multidimenzional array, so i
can access and change data in form of: $named_conf_file-{view1}-{zoneblah} =
'somedata' and then dump it back into original format.


Ok, that didn't really come across in your email.

http://augeas.net/

...does what you want. It has a lense (their term for a config file 
description) for ISC dhcpd, which is a very similar syntax. It should be 
relatively trivial to turn out a lense for ISC bind.


Or use Config::Parser, or adapt the script I sent round (which in fact 
was the reason I wrote it); tokenisation of the bind config file is 
easy, and the core grammar is straightforward because everything is 
;-terminated, with the form:


item = thing+ block semicolon
thing = word | quoted-string
block = { item+ }
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Named.conf logical blocks

2011-06-29 Thread Chris Buxton
On Jun 29, 2011, at 12:21 AM, Phil Mayers wrote:
 Or use Config::Parser, or adapt the script I sent round (which in fact was 
 the reason I wrote it); tokenisation of the bind config file is easy, and the 
 core grammar is straightforward because everything is ;-terminated, with the 
 form:
 
 item = thing+ block semicolon
 thing = word | quoted-string
 block = { item+ }

Not entirely. There is at least one construct that looks like this (using your 
terms):

thing+ block thing block semicolon

For example, within the controls statement:

inet * allow { trusted; } keys { some.key; };

Regards,
Chris Buxton
BlueCat Networks
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Named.conf logical blocks

2011-06-29 Thread Phil Mayers

On 06/29/2011 02:37 PM, Chris Buxton wrote:


Not entirely. There is at least one construct that looks like this (using your 
terms):

thing+ block thing block semicolon

For example, within the controls statement:

inet * allow { trusted; } keys { some.key; };


Good point.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Named.conf logical blocks

2011-06-28 Thread Stefan Certic
Hi Guys,

Does anyone have a sample grammar for pharsing named.conf into a data 
structure? Perl or PHP are preffered, but anything would be fine just to get a 
clear picture about grammar and logical blocks.

Thanks!

-- 
Stefan Certic

RoutoMessaging
48 Charlotte Street
London, W1T 2NS
United Kingdom
http://www.routomessaging.com
GSMA Associate Member

Switchboard +44 (0) 870 231  
Fax + 44 (0) 870 231 7775

Email  : ste...@routotelecom.com
MSN ID : ste...@routotelecom.com
 
DISCLAIMER

This email contains information provided by Routo Telecommunications
Ltd, which may be privileged or confidential. It is meant only for the
individual(s) or entity named above. If you are not the intended
recipient, note that disclosing, copying, distributing or using this
information is prohibited. If you have received this email in error,
please let me know immediately on the email address above.

Routo Telecommunications Ltd may not be held responsible for the
content of this email as it may reflect the personal view of the
sender and not that of the company.

Internet communications cannot be guaranteed to be timely, secure,
error or virus-free. The sender does not accept liability for any
errors or omissions.

We monitor our email system and may record your emails.

Routo Telecommunications Ltd Registration Number 04546322 has its
principal place of business at 48 Charlotte Street, London, W1T 2NS,
United Kingdom.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Named.conf logical blocks

2011-06-28 Thread Phil Mayers

On 06/28/2011 05:53 PM, Stefan Certic wrote:

Hi Guys,

Does anyone have a sample grammar for pharsing named.conf into a data
structure? Perl or PHP are preffered, but anything would be fine just to get a
clear picture about grammar and logical blocks.


The only think I ever wrote was a quick python hack that used a big 
regexp and an eat block function. Maybe it'll be of some interest, but 
beware - regexp engines are not parsers, as jwz once famously pointed 
out: You have a problem, and you decide to solve it with regexps. Now 
you have two problems. ;o)


Anyway, break the regexp up and it's fairly obvious what it's doing. You 
can get better results with a proper state-machine based parser.


#!/usr/bin/python

import re
import sys
import pprint

token_re = 
re.compile(r'/\*.*\*/|//[^\n]*\n|#[^\n]*\n|;|{|}|\d+\.\d+\.\d+\.\d+|[-a-zA-Z0-9]+|[^]+')


def eat(toklist):
all = []
v = []
while toklist:
t = toklist.pop(0)
if t=='{':
inner = eat(toklist)
v.append(inner)
elif t=='}' and toklist and toklist[0]==';':
break
elif t==';':
all.append(v)
v = []
else:
v.append(t)
return all

data = sys.stdin.read()
tokens = token_re.findall(data)
pprint.pprint(
eat(tokens)
)
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Named.conf logical blocks

2011-06-28 Thread David Forrest


On 06/28/2011 05:53 PM, Stefan Certic wrote:

Hi Guys,

Does anyone have a sample grammar for pharsing named.conf into a data
structure? Perl or PHP are preffered, but anything would be fine just to 
get a

clear picture about grammar and logical blocks.


I send mine through named-checkconf to put it in a consistent state. 
This helps to reduce the includes and sort out the views and 
blocks logically.


See man named-checkconf.

/usr/local/sbin/named-checkconf -p /var/named/named.conf.canonical ||\
echo -e \nConversion failed, as will named if attempted \
/var/named/named.conf.canonical

--
David Forrest
Maple Park Development Corporation
St. Louis, Missouri
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Named.conf logical blocks

2011-06-28 Thread Stefan Certic
I am more looking for a solution to read data with perl and convert to some 
native data structure, like hash reference, or multidimenzional array, so i 
can access and change data in form of: $named_conf_file-{view1}-{zoneblah} = 
'somedata' and then dump it back into original format.

Regards,

On Tuesday, June 28, 2011 09:46:29 pm David Forrest wrote:
 On 06/28/2011 05:53 PM, Stefan Certic wrote:
  Hi Guys,
  
  Does anyone have a sample grammar for pharsing named.conf into a data
  structure? Perl or PHP are preffered, but anything would be fine just to
  get a
  clear picture about grammar and logical blocks.
 
 I send mine through named-checkconf to put it in a consistent state.
 This helps to reduce the includes and sort out the views and
 blocks logically.
 
 See man named-checkconf.
 
 /usr/local/sbin/named-checkconf -p /var/named/named.conf.canonical ||\
 echo -e \nConversion failed, as will named if attempted \
 /var/named/named.conf.canonical

-- 
Stefan Certic

RoutoMessaging
48 Charlotte Street
London, W1T 2NS
United Kingdom
http://www.routomessaging.com
GSMA Associate Member

Switchboard +44 (0) 870 231  
Fax + 44 (0) 870 231 7775

Email  : ste...@routotelecom.com
MSN ID : ste...@routotelecom.com
 
DISCLAIMER

This email contains information provided by Routo Telecommunications
Ltd, which may be privileged or confidential. It is meant only for the
individual(s) or entity named above. If you are not the intended
recipient, note that disclosing, copying, distributing or using this
information is prohibited. If you have received this email in error,
please let me know immediately on the email address above.

Routo Telecommunications Ltd may not be held responsible for the
content of this email as it may reflect the personal view of the
sender and not that of the company.

Internet communications cannot be guaranteed to be timely, secure,
error or virus-free. The sender does not accept liability for any
errors or omissions.

We monitor our email system and may record your emails.

Routo Telecommunications Ltd Registration Number 04546322 has its
principal place of business at 48 Charlotte Street, London, W1T 2NS,
United Kingdom.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


RE: Named.conf logical blocks

2011-06-28 Thread Todd Snyder
there is a perl module out there that may help:

http://cpan.uwinnipeg.ca/htdocs/BIND-Config-Parser/BIND/Config/Parser.html

I don't know - I'm not much of a perl monkey (or any of one, really), but I may 
work for what you'd like.

t.

-Original Message-
From: bind-users-bounces+tsnyder=rim@lists.isc.org 
[mailto:bind-users-bounces+tsnyder=rim@lists.isc.org] On Behalf Of Stefan 
Certic
Sent: Tuesday, June 28, 2011 4:55 PM
To: bind-users@lists.isc.org; d...@maplepark.com
Subject: Re: Named.conf logical blocks

I am more looking for a solution to read data with perl and convert to some 
native data structure, like hash reference, or multidimenzional array, so i 
can access and change data in form of: $named_conf_file-{view1}-{zoneblah} = 
'somedata' and then dump it back into original format.

Regards,

On Tuesday, June 28, 2011 09:46:29 pm David Forrest wrote:
 On 06/28/2011 05:53 PM, Stefan Certic wrote:
  Hi Guys,
  
  Does anyone have a sample grammar for pharsing named.conf into a data
  structure? Perl or PHP are preffered, but anything would be fine just to
  get a
  clear picture about grammar and logical blocks.
 
 I send mine through named-checkconf to put it in a consistent state.
 This helps to reduce the includes and sort out the views and
 blocks logically.
 
 See man named-checkconf.
 
 /usr/local/sbin/named-checkconf -p /var/named/named.conf.canonical ||\
 echo -e \nConversion failed, as will named if attempted \
 /var/named/named.conf.canonical

-- 
Stefan Certic

RoutoMessaging
48 Charlotte Street
London, W1T 2NS
United Kingdom
http://www.routomessaging.com
GSMA Associate Member

Switchboard +44 (0) 870 231  
Fax + 44 (0) 870 231 7775

Email  : ste...@routotelecom.com
MSN ID : ste...@routotelecom.com
 
DISCLAIMER

This email contains information provided by Routo Telecommunications
Ltd, which may be privileged or confidential. It is meant only for the
individual(s) or entity named above. If you are not the intended
recipient, note that disclosing, copying, distributing or using this
information is prohibited. If you have received this email in error,
please let me know immediately on the email address above.

Routo Telecommunications Ltd may not be held responsible for the
content of this email as it may reflect the personal view of the
sender and not that of the company.

Internet communications cannot be guaranteed to be timely, secure,
error or virus-free. The sender does not accept liability for any
errors or omissions.

We monitor our email system and may record your emails.

Routo Telecommunications Ltd Registration Number 04546322 has its
principal place of business at 48 Charlotte Street, London, W1T 2NS,
United Kingdom.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users

-
This transmission (including any attachments) may contain confidential 
information, privileged material (including material protected by the 
solicitor-client or other applicable privileges), or constitute non-public 
information. Any use of this information by anyone other than the intended 
recipient is prohibited. If you have received this transmission in error, 
please immediately reply to the sender and delete this information from your 
system. Use, dissemination, distribution, or reproduction of this transmission 
by unintended recipients is not authorized and may be unlawful.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Named.conf logical blocks

2011-06-28 Thread Mark Andrews

In message 201106281853.55303.ste...@routotelecom.com, Stefan Certic writes:
 Hi Guys,
 
 Does anyone have a sample grammar for pharsing named.conf into a data 
 structure? Perl or PHP are preffered, but anything would be fine just to get a
 clear picture about grammar and logical blocks.
 
 Thanks!

You could just call named's parser.  It's in lib/isccfg.

Mark
-- 
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742 INTERNET: ma...@isc.org
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users