1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/featuremgmt/featuremgr/tools/datfilehelpers/FeatureDSR.pm Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,94 @@
1.4 +#!perl -w
1.5 +# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +# All rights reserved.
1.7 +# This component and the accompanying materials are made available
1.8 +# under the terms of "Eclipse Public License v1.0"
1.9 +# which accompanies this distribution, and is available
1.10 +# at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +#
1.12 +# Initial Contributors:
1.13 +# Nokia Corporation - initial contribution.
1.14 +#
1.15 +# Contributors:
1.16 +#
1.17 +# Description:
1.18 +#
1.19 +
1.20 +use strict;
1.21 +
1.22 +#
1.23 +# A simple class to maintain a single 'default supported range' feature
1.24 +# object.
1.25 +#
1.26 +package FeatureDSR;
1.27 +
1.28 +sub new
1.29 +{
1.30 + my $arg = shift;
1.31 + my $class = ref($arg) || $arg;
1.32 + my($low, $high) = @_;
1.33 + my $self = {
1.34 + lowuid => $low,
1.35 + highuid => $high,
1.36 + endian => "LE",
1.37 + };
1.38 + bless $self, $class;
1.39 + return $self;
1.40 +}
1.41 +
1.42 +sub LowUID
1.43 +{
1.44 + my $self = shift;
1.45 + return undef unless(ref($self));
1.46 + my $arg = shift;
1.47 + return $self->{lowuid} unless(defined($arg));
1.48 + $self->{lowuid} = $arg;
1.49 + return $arg;
1.50 +}
1.51 +
1.52 +sub HighUID
1.53 +{
1.54 + my $self = shift;
1.55 + return undef unless(ref($self));
1.56 + my $arg = shift;
1.57 + return $self->{highuid} unless(defined($arg));
1.58 + $self->{highuid} = $arg;
1.59 + return $arg;
1.60 +}
1.61 +
1.62 +sub Endian
1.63 +{
1.64 + my $self = shift;
1.65 + return undef unless(ref($self));
1.66 + my $arg = shift;
1.67 + return $self->{endian} unless($arg =~ m/(LE|BE)i/);
1.68 + $arg = uc($arg);
1.69 + $self->{endian} = $arg;
1.70 + return $arg;
1.71 +}
1.72 +
1.73 +# Return the content of this object as packed binary, i.e 8 bytes
1.74 +# of the specified endian-ness.
1.75 +sub BinaryContent
1.76 +{
1.77 + my $self = shift;
1.78 + return undef unless(ref($self));
1.79 + my $packstring = "V2";
1.80 + $packstring = "N2" if($self->{endian} eq "BE");
1.81 + my $retstring = pack($packstring, ( $self->LowUID, $self->HighUID ) );
1.82 + return $retstring;
1.83 +}
1.84 +
1.85 +# Display the content of the DSR in english.
1.86 +sub Show
1.87 +{
1.88 + my $self = shift;
1.89 + return undef unless(ref($self));
1.90 + my $fd = shift;
1.91 + $fd = *STDOUT unless(defined($fd));
1.92 + printf $fd "LOW UID 0x%08x\n", $self->LowUID();
1.93 + printf $fd "HIGH UID 0x%08x\n", $self->HighUID();
1.94 + return 1;
1.95 +}
1.96 +
1.97 +1;