source: trunk/server/source4/build/pasn1/pasn1.pl

Last change on this file was 414, checked in by Herwig Bauernfeind, 16 years ago

Samba 3.5.0: Initial import

File size: 2.0 KB
Line 
1#!/usr/bin/perl -w
2
3###################################################
4# package to parse ASN.1 files and generate code for
5# LDAP functions in Samba
6# Copyright tridge@samba.org 2002-2003
7# Copyright metze@samba.org 2004
8
9# released under the GNU GPL
10
11use strict;
12
13use FindBin qw($RealBin);
14use lib "$RealBin";
15use lib "$RealBin/lib";
16use Getopt::Long;
17use File::Basename;
18use asn1;
19use util;
20
21my($opt_help) = 0;
22my($opt_output);
23
24my $asn1_parser = new asn1;
25
26#####################################################################
27# parse an ASN.1 file returning a structure containing all the data
28sub ASN1Parse($)
29{
30 my $filename = shift;
31 my $asn1 = $asn1_parser->parse_asn1($filename);
32 util::CleanData($asn1);
33 return $asn1;
34}
35
36
37#########################################
38# display help text
39sub ShowHelp()
40{
41 print "
42 perl ASN.1 parser and code generator
43 Copyright (C) tridge\@samba.org
44 Copyright (C) metze\@samba.org
45
46 Usage: pasn1.pl [options] <asn1file>
47
48 Options:
49 --help this help page
50 --output OUTNAME put output in OUTNAME
51 \n";
52 exit(0);
53}
54
55# main program
56GetOptions (
57 'help|h|?' => \$opt_help,
58 'output|o=s' => \$opt_output,
59 );
60
61if ($opt_help) {
62 ShowHelp();
63 exit(0);
64}
65
66sub process_file($)
67{
68 my $input_file = shift;
69 my $output_file;
70 my $pasn1;
71
72 my $basename = basename($input_file, ".asn1");
73
74 if (!defined($opt_output)) {
75 $output_file = util::ChangeExtension($input_file, ".pasn1");
76 } else {
77 $output_file = $opt_output;
78 }
79
80# if (file is .pasn1) {
81# $pasn1 = util::LoadStructure($pasn1_file);
82# defined $pasn1 || die "Failed to load $pasn1_file - maybe you need --parse\n";
83# } else {
84 $pasn1 = ASN1Parse($input_file);
85 defined $pasn1 || die "Failed to parse $input_file";
86 util::SaveStructure($output_file, $pasn1) ||
87 die "Failed to save $output_file\n";
88 #}
89}
90
91foreach my $filename (@ARGV) {
92 process_file($filename);
93}
Note: See TracBrowser for help on using the repository browser.