File: mib2c.extract.pl

package info (click to toggle)
net-snmp 5.9.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 38,720 kB
  • sloc: ansic: 282,878; perl: 17,704; sh: 12,151; makefile: 2,711; python: 734; xml: 663; pascal: 62; sql: 47
file content (43 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl

# read comments from mib2c and insert them in mib2c.conf.5
my $mib2csrc = shift;

while (<>) {
    if (/COMMANDSHERE/) {
	open(I,$mib2csrc);
	while (<I>) {
	    last if (/^# which include:/);
	}
	while (<I>) {
	    last if (!/^#/);
	    s/^#\s+//;
	    # Avoid ' at the beginning of a line
	    s/^'/\\&'/;
	    # Quotes in a quoted argument must be doubled.
	    s/"/""/g;
	    s/^(\@.*\@)$/.IP "$1"/;
	    print;
	}
	close(I);
    } elsif (/VAREXPANSIONSHERE/) {
	open(I,$mib2csrc);
	while (<I>) {
	    last if (/^# Mib components,/);
	}
	while (<I>) {
	    last if (!/^#/);
	    next if (/^#\s*$/);
	    s/^#\s+//;
	    # Avoid ' at the beginning of a line
	    s/^'/\\&'/;
	    # Quotes in a quoted argument must be doubled.
	    s/"/""/g;
	    s/^(\S+)\s+--\s+(.*)/.IP "$1"\n$2/;
	    print;
	}
	close(I);
    } else {
	print;
    }
}