sl@0
|
1 |
#!perl -w
|
sl@0
|
2 |
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
# All rights reserved.
|
sl@0
|
4 |
# This component and the accompanying materials are made available
|
sl@0
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
# which accompanies this distribution, and is available
|
sl@0
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
#
|
sl@0
|
9 |
# Initial Contributors:
|
sl@0
|
10 |
# Nokia Corporation - initial contribution.
|
sl@0
|
11 |
#
|
sl@0
|
12 |
# Contributors:
|
sl@0
|
13 |
#
|
sl@0
|
14 |
# Description:
|
sl@0
|
15 |
#
|
sl@0
|
16 |
|
sl@0
|
17 |
use strict;
|
sl@0
|
18 |
|
sl@0
|
19 |
#
|
sl@0
|
20 |
# A simple class to maintain a single 'default supported range' feature
|
sl@0
|
21 |
# object.
|
sl@0
|
22 |
#
|
sl@0
|
23 |
package FeatureDSR;
|
sl@0
|
24 |
|
sl@0
|
25 |
sub new
|
sl@0
|
26 |
{
|
sl@0
|
27 |
my $arg = shift;
|
sl@0
|
28 |
my $class = ref($arg) || $arg;
|
sl@0
|
29 |
my($low, $high) = @_;
|
sl@0
|
30 |
my $self = {
|
sl@0
|
31 |
lowuid => $low,
|
sl@0
|
32 |
highuid => $high,
|
sl@0
|
33 |
endian => "LE",
|
sl@0
|
34 |
};
|
sl@0
|
35 |
bless $self, $class;
|
sl@0
|
36 |
return $self;
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
sub LowUID
|
sl@0
|
40 |
{
|
sl@0
|
41 |
my $self = shift;
|
sl@0
|
42 |
return undef unless(ref($self));
|
sl@0
|
43 |
my $arg = shift;
|
sl@0
|
44 |
return $self->{lowuid} unless(defined($arg));
|
sl@0
|
45 |
$self->{lowuid} = $arg;
|
sl@0
|
46 |
return $arg;
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
sub HighUID
|
sl@0
|
50 |
{
|
sl@0
|
51 |
my $self = shift;
|
sl@0
|
52 |
return undef unless(ref($self));
|
sl@0
|
53 |
my $arg = shift;
|
sl@0
|
54 |
return $self->{highuid} unless(defined($arg));
|
sl@0
|
55 |
$self->{highuid} = $arg;
|
sl@0
|
56 |
return $arg;
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
sub Endian
|
sl@0
|
60 |
{
|
sl@0
|
61 |
my $self = shift;
|
sl@0
|
62 |
return undef unless(ref($self));
|
sl@0
|
63 |
my $arg = shift;
|
sl@0
|
64 |
return $self->{endian} unless($arg =~ m/(LE|BE)i/);
|
sl@0
|
65 |
$arg = uc($arg);
|
sl@0
|
66 |
$self->{endian} = $arg;
|
sl@0
|
67 |
return $arg;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
# Return the content of this object as packed binary, i.e 8 bytes
|
sl@0
|
71 |
# of the specified endian-ness.
|
sl@0
|
72 |
sub BinaryContent
|
sl@0
|
73 |
{
|
sl@0
|
74 |
my $self = shift;
|
sl@0
|
75 |
return undef unless(ref($self));
|
sl@0
|
76 |
my $packstring = "V2";
|
sl@0
|
77 |
$packstring = "N2" if($self->{endian} eq "BE");
|
sl@0
|
78 |
my $retstring = pack($packstring, ( $self->LowUID, $self->HighUID ) );
|
sl@0
|
79 |
return $retstring;
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
# Display the content of the DSR in english.
|
sl@0
|
83 |
sub Show
|
sl@0
|
84 |
{
|
sl@0
|
85 |
my $self = shift;
|
sl@0
|
86 |
return undef unless(ref($self));
|
sl@0
|
87 |
my $fd = shift;
|
sl@0
|
88 |
$fd = *STDOUT unless(defined($fd));
|
sl@0
|
89 |
printf $fd "LOW UID 0x%08x\n", $self->LowUID();
|
sl@0
|
90 |
printf $fd "HIGH UID 0x%08x\n", $self->HighUID();
|
sl@0
|
91 |
return 1;
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
1;
|