32
|
1 |
#
|
|
2 |
# Copyright (c) 1997-2000 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
use strict;
|
|
18 |
use integer;
|
|
19 |
|
|
20 |
BEGIN
|
|
21 |
{
|
|
22 |
my $perlScriptPath=$0;
|
|
23 |
$perlScriptPath=~s/\//\\/g; # replace any forward-slashes with back-slashes
|
|
24 |
$perlScriptPath=~s/(\\?)[^\\]+$/$1/; # get rid of this Perl-script's file-name
|
|
25 |
unshift(@INC, $perlScriptPath); # can't do "use lib $perlScriptPath" here as "use lib" only seems to work with *hard-coded* directory names
|
|
26 |
}
|
|
27 |
use PARSER;
|
|
28 |
use WRITER;
|
|
29 |
|
|
30 |
$|=1; # ensures that any progress information sent to the screen is displayed immediately and not buffered
|
|
31 |
if ((@ARGV==0) || ($ARGV[0]=~/\?/i) || ($ARGV[0]=~/-h/i) || ($ARGV[0]=~/\/h/i) || ($ARGV[0]=~/help/i))
|
|
32 |
{
|
|
33 |
die("\nVersion 021\n\nCharacter-set standard-names and MIB-enums tool\nCopyright (c) 2000 Symbian Ltd\n\nUsage:\n\n\tsnmtool <input-file> <output-file>\n\n");
|
|
34 |
}
|
|
35 |
my $inputFileName=shift;
|
|
36 |
my $outputFileName=shift;
|
|
37 |
print "Generating $outputFileName...\n";
|
|
38 |
open(INPUT_FILE, "< $inputFileName") or die("Error: could not open \"$inputFileName\" for reading\n");
|
|
39 |
my %characerSets=();
|
|
40 |
&readInputFile(\*INPUT_FILE, $inputFileName, \%characerSets);
|
|
41 |
close(INPUT_FILE) or die("Error: could not close \"$inputFileName\"\n");
|
|
42 |
open(OUTPUT_FILE, "> $outputFileName") or die("Error: could not open \"$outputFileName\" for writing\n");
|
|
43 |
binmode OUTPUT_FILE;
|
|
44 |
&writeOutputFile(\*OUTPUT_FILE, \%characerSets);
|
|
45 |
close(OUTPUT_FILE) or die("Error: could not close \"$outputFileName\"\n");
|
|
46 |
print "complete\n\n";
|
|
47 |
|
|
48 |
sub readInputFile
|
|
49 |
{
|
|
50 |
my $fileHandle=shift;
|
|
51 |
my $fileName=shift;
|
|
52 |
my $characerSets=shift;
|
|
53 |
my $line;
|
|
54 |
my $strippedDownLine;
|
|
55 |
my $identifier="";
|
|
56 |
for (;;)
|
|
57 |
{
|
|
58 |
($line, $strippedDownLine)=&nextNonEmptyStrippedDownLine($fileHandle);
|
|
59 |
if ($strippedDownLine eq "")
|
|
60 |
{
|
|
61 |
last;
|
|
62 |
}
|
|
63 |
if ($strippedDownLine=~/^CharacterSet\s+0x([0-9a-f]+)$/i)
|
|
64 |
{
|
|
65 |
$identifier=lc($1);
|
|
66 |
$characerSets->{$identifier}=[[], []];
|
|
67 |
}
|
|
68 |
else
|
|
69 |
{
|
|
70 |
if ($identifier eq "")
|
|
71 |
{
|
|
72 |
close($fileHandle);
|
|
73 |
die("Error: unexpected line in \"$fileName\":\n $line\n");
|
|
74 |
}
|
|
75 |
if ($strippedDownLine=~/^StandardName\s+"(.*)"$/i)
|
|
76 |
{
|
|
77 |
push @{$characerSets->{$identifier}->[0]}, $1;
|
|
78 |
}
|
|
79 |
elsif ($strippedDownLine=~/^MibEnum\s+([0-9]+)$/i)
|
|
80 |
{
|
|
81 |
push @{$characerSets->{$identifier}->[1]}, $1;
|
|
82 |
}
|
|
83 |
else
|
|
84 |
{
|
|
85 |
close($fileHandle);
|
|
86 |
die("Error: unexpected line in \"$fileName\":\n $line\n");
|
|
87 |
}
|
|
88 |
}
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
sub writeOutputFile
|
|
93 |
{
|
|
94 |
my $fileHandle=shift;
|
|
95 |
my $characerSets=shift;
|
|
96 |
&writeUids($fileHandle, 0x1000589b, 0, 0);
|
|
97 |
my $characerSetIdentifier;
|
|
98 |
my $identifier;
|
|
99 |
my $data;
|
|
100 |
while (($identifier, $data)=each(%$characerSets))
|
|
101 |
{
|
|
102 |
&write32($fileHandle, hex($identifier));
|
|
103 |
&writePositiveIntegerCompacted15($fileHandle, scalar(@{$data->[0]}));
|
|
104 |
&writePositiveIntegerCompacted15($fileHandle, scalar(@{$data->[1]}));
|
|
105 |
my $standardName;
|
|
106 |
foreach $standardName (@{$data->[0]})
|
|
107 |
{
|
|
108 |
&writePositiveIntegerCompacted15($fileHandle, length($standardName));
|
|
109 |
&writeString($fileHandle, $standardName);
|
|
110 |
}
|
|
111 |
my $mibEnum;
|
|
112 |
foreach $mibEnum (@{$data->[1]})
|
|
113 |
{
|
|
114 |
&writePositiveIntegerCompacted30($fileHandle, $mibEnum);
|
|
115 |
}
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|