2 # Copyright (c) 2001-2004 International Business Machines
3 # Corporation and others. All Rights Reserved.
5 ####################################################################################
7 # This tool filters the RFC-3454 txt file for StringPrep tables and creates a table
8 # to be used in NamePrepProfile
10 # Author: Ram Viswanadha
12 ####################################################################################
23 $copyright = "#################\n# This file was generated from RFC 3454 (http://www.ietf.org/rfc/rfc3454.txt)\n# Copyright (C) The Internet Society (2002). All Rights Reserved. \n###################\n\n";
24 $warning = "###################\n# WARNING: This table is generated by filterRFC3454.pl tool. DO NOT EDIT \n###################\n\n";
28 #---------------------------------------------------------------------
33 "--sourcedir=s" => \
$sourceDir,
34 "--destdir=s" => \
$destDir,
35 "--src-filename=s" => \
$srcFileName,
36 "--dest-filename=s" => \
$destFileName,
52 "--ldh-chars" => \
$writeLDHChars,
53 "--iscsi" => \
$writeISCSIChars,
55 usage
() unless defined $sourceDir;
56 usage
() unless defined $destDir;
57 usage
() unless defined $srcFileName;
58 usage
() unless defined $destFileName;
60 $infile = $sourceDir."/".$srcFileName;
61 $inFH = IO
::File-
>new($infile,"r")
62 or die "could not open the file $infile for reading: $! \n";
63 $outfile = $destDir."/".$destFileName;
66 $outFH = IO
::File-
>new($outfile,"a")
67 or die "could not open the file $outfile for writing: $! \n";
68 print $outFH $copyright;
69 print $outFH $warning;
72 if(defined $b2 && defined $b3){
73 die "ERROR: --B2 and --B3 are both specified\!\n";
76 while(defined ($line=<$inFH>)){
77 next unless $line=~ /Start\sTable/;
79 createUnassignedTable
($inFH,$outfile);
81 if($line =~ /B.1/ && defined $b1){
82 createMapToNothing
($inFH,$outfile);
84 if($line =~ /B.2/ && defined $b2){
85 createCaseMapNorm
($inFH,$outfile);
87 if($line =~ /B.3/ && defined $b3){
88 createCaseMapNoNorm
($inFH,$outfile);
90 if($line =~ /C.1.1/ && defined $c11 ){
91 createProhibitedTable
($inFH,$outfile,$line);
93 if($line =~ /C.1.2/ && defined $c12 ){
94 createProhibitedTable
($inFH,$outfile,$line);
96 if($line =~ /C.2.1/ && defined $c21 ){
97 createProhibitedTable
($inFH,$outfile,$line);
99 if($line =~ /C.2.2/ && defined $c22 ){
100 createProhibitedTable
($inFH,$outfile,$line);
102 if($line =~ /C.3/ && defined $c3 ){
103 createProhibitedTable
($inFH,$outfile,$line);
105 if($line =~ /C.4/ && defined $c4 ){
106 createProhibitedTable
($inFH,$outfile,$line);
108 if($line =~ /C.5/ && defined $c5 ){
109 createProhibitedTable
($inFH,$outfile,$line);
111 if($line =~ /C.6/ && defined $c6 ){
112 createProhibitedTable
($inFH,$outfile,$line);
114 if($line =~ /C.7/ && defined $c7 ){
115 createProhibitedTable
($inFH,$outfile,$line);
117 if($line =~ /C.8/ && defined $c8 ){
118 createProhibitedTable
($inFH,$outfile,$line);
120 if($line =~ /C.9/ && defined $c9 ){
121 createProhibitedTable
($inFH,$outfile,$line);
124 if( defined $writeISCSIChars){
125 create_iSCSIExtraProhibitedTable
($inFH, $outfile);
130 #-----------------------------------------------------------------------
132 local ($inFH, $outFH,$comment, $table) = @_;
134 print $outFH $comment."\n";
135 while(defined ($line = <$inFH>)){
136 next if $line =~ /Hoffman\s\&\sBlanchet/; # ignore heading
137 next if $line =~ /RFC\s3454/; # ignore heading
138 next if $line =~ /\f/; # ignore form feed
139 next if $line eq "\n"; # ignore blank lines
140 # break if "End Table" is found
141 if( $line =~ /End\sTable/){
142 print $outFH "\n# Total code points $count\n\n";
155 ($code, $noise) = split /;/ , $line;
156 $line = $code."; ; UNASSIGNED\n";
157 }elsif ( $table =~ /B\.1/ ){
158 $line =~ s/Map to nothing/MAP/;
159 }elsif ( $table =~ /B\.[23]/ ){
160 $line =~ s/Case map/MAP/;
161 $line =~ s/Additional folding/MAP/;
162 }elsif ( $table =~ /C/ ) {
163 ($code, $noise) = split /;/ , $line;
164 $line = $code."; ; PROHIBITED\n";
167 ($code, $noise) = split /;/ , $line;
168 ($startStr, $endStr ) = split /\.\./, $code;
169 $start = atoi
($startStr);
170 $end = atoi
($endStr);
171 #print $start." ".$end."\n";
172 while($start <= $end){
182 #-----------------------------------------------------------------------
185 foreach my $d (split(//, shift())) {
190 #-----------------------------------------------------------------------
191 sub createUnassignedTable
{
192 ($inFH,$outfile) = @_;
193 $outFH = IO
::File-
>new($outfile,"a")
194 or die "could not open the file $outfile for writing: $! \n";
195 $comment = "# This table contains code points from Table A.1 from RFC 3454\n";
196 readPrint
($inFH,$outFH, $comment, "A");
199 #-----------------------------------------------------------------------
200 sub createMapToNothing
{
201 ($inFH,$outfile) = @_;
202 $outFH = IO
::File-
>new($outfile,"a")
203 or die "could not open the file $outfile for writing: $! \n";
204 $comment = "# This table contains code points from Table B.1 from RFC 3454\n";
205 readPrint
($inFH,$outFH,$comment, "B.1");
208 #-----------------------------------------------------------------------
209 sub createCaseMapNorm
{
210 ($inFH,$outfile) = @_;
211 $outFH = IO
::File-
>new($outfile,"a")
212 or die "could not open the file $outfile for writing: $! \n";
213 $comment = $warning."# This table contains code points from Table B.2 from RFC 3454\n";
214 readPrint
($inFH,$outFH,$comment, "B.2");
217 #-----------------------------------------------------------------------
218 sub createCaseMapNoNorm
{
219 ($inFH,$outfile) = @_;
220 $outFH = IO
::File-
>new($outfile,"a")
221 or die "could not open the file $outfile for writing: $! \n";
222 $comment = $warning."# This table contains code points from Table B.3 from RFC 3454\n";
223 readPrint
($inFH,$outFH,$comment, "B.3");
226 #-----------------------------------------------------------------------
227 sub createProhibitedTable
{
228 ($inFH,$outfile,$line) = @_;
231 $comment = "# code points from $line";
233 $outFH = IO
::File-
>new($outfile, "a")
234 or die "could not open the file $outfile for writing: $! \n";
235 readPrint
($inFH,$outFH,$comment, "C");
239 #-----------------------------------------------------------------------
240 sub create_iSCSIExtraProhibitedTable
{
241 ($inFH,$outfile,$line) = @_;
242 $comment ="# Additional prohibitions from draft-ietf-ips-iscsi-string-prep-06.txt\n";
244 $outFH = IO
::File-
>new($outfile, "a")
245 or die "could not open the file $outfile for writing: $! \n";
246 print $outFH $comment;
247 print $outFH "0021..002C; ; PROHIBITED\n";
248 print $outFH "002F; ; PROHIBITED\n";
249 print $outFH "003B..0040; ; PROHIBITED\n";
250 print $outFH "005B..0060; ; PROHIBITED\n";
251 print $outFH "007B..007E; ; PROHIBITED\n";
252 print $outFH "3002; ; PROHIBITED\n";
253 print $outFH "\n# Total code points 30\n";
256 #-----------------------------------------------------------------------
262 --sourcedir
=<directory
>
263 --destdir
=<directory
>
264 --src-filename
=<name of RFC file
>
265 --dest-filename
=<name of destination file
>
266 --A1 Generate data
for table A
.1
267 --B1 Generate data
for table B
.1
268 --B2 Generate data
for table B
.2
269 --B3 Generate data
for table B
.3
270 --C11 Generate data
for table C
.1.1
271 --C12 Generate data
for table C
.1.2
272 --C21 Generate data
for table C
.2.1
273 --C22 Generate data
for table C
.2.2
274 --C3 Generate data
for table C
.3
275 --C4 Generate data
for table C
.4
276 --C5 Generate data
for table C
.5
277 --C6 Generate data
for table C
.6
278 --C7 Generate data
for table C
.7
279 --C8 Generate data
for table C
.8
280 --C9 Generate data
for table C
.9
281 --iscsi Generate data
for extra prohibited iSCSI chars
283 Note
, --B2
and --B3 are mutually exclusive
.
285 e
.g
.: filterRFC3454
.pl
--sourcedir
=. --destdir
=./output
--src-filename
=rfc3454
.txt
--dest-filename
=NamePrepProfile
.txt
--A1
--B1
--B2
--C12
--C22
--C3
--C4
--C5
--C6
--C7
--C8
--C9
287 filterRFC3454
.pl filters the RFC file
and creates String prep table files
.
288 The RFC text can be downloaded from ftp
://ftp
.rfc-editor
.org
/in-notes/rfc3454
.txt