#!perl # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. $copyright = '/* THIS IS A GENERATED FILE */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ '; $count = -1; $i = 0; open(INPUT, "<$ARGV[0]") || die "Can't open $ARGV[0]: $!"; while() { s/^((?:[^"#]+|"[^"]*")*)(\s*#.*$)/$1/; next if (/^\s*$/); # print; /^([\S]+)\s+([^"][\S]*|"[^"]*")/; $name = $1; $value = $2; if( ($name =~ "FUNCTION") && !($name =~ "CK_FUNCTION") ) { $count++; $x[$count]{name} = $value; $i = 0; } else { if( $count < 0 ) { $value =~ s/"//g; $g{$name} = $value; } else { $x[$count]{args}[$i]{type} = $name; $x[$count]{args}[$i]{name} = $value; $i++; $x[$count]{nargs} = $i; # rewritten each time, oh well } } } close INPUT; # dodump(); doprint(); sub dodump { for( $j = 0; $j <= $count; $j++ ) { print "CK_RV CK_ENTRY $x[$j]{name}\n"; for( $i = 0; $i < $x[$j]{nargs}; $i++ ) { print " $x[$j]{args}[$i]{type} $x[$j]{args}[$i]{name}"; if( $i == ($x[$j]{nargs} - 1) ) { print "\n"; } else { print ",\n"; } } } } sub doprint { open(PROTOTYPE, ">nssckg.h") || die "Can't open nssckg.h: $!"; open(TYPEDEF, ">nssckft.h") || die "Can't open nssckft.h: $!"; open(EPV, ">nssckepv.h") || die "Can't open nssckepv.h: $!"; open(API, ">nssck.api") || die "Can't open nssck.api: $!"; select PROTOTYPE; print $copyright; print <