1 | # |
---|
2 | # Copyright (c) 2004-2007 - Consultas, PKG.fr |
---|
3 | # |
---|
4 | # This file is part of A2P. |
---|
5 | # |
---|
6 | # A2P is free software; you can redistribute it and/or modify |
---|
7 | # it under the terms of the GNU General Public License as published by |
---|
8 | # the Free Software Foundation; either version 2 of the License, or |
---|
9 | # (at your option) any later version. |
---|
10 | # |
---|
11 | # A2P is distributed in the hope that it will be useful, |
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | # GNU General Public License for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License |
---|
17 | # along with A2P; if not, write to the Free Software |
---|
18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
19 | # |
---|
20 | # $Id: OCD.pm 3 2007-10-18 16:20:19Z guillaume $ |
---|
21 | # |
---|
22 | # Class to export Object Container Data members |
---|
23 | # |
---|
24 | # cf ref #2, p. 276 |
---|
25 | # |
---|
26 | |
---|
27 | package AFPDS::MODCA::OCD ; |
---|
28 | |
---|
29 | use strict ; |
---|
30 | use A2P::Globals ; |
---|
31 | use A2P::Syslog ; |
---|
32 | use AFPDS::MODCA::Common ; |
---|
33 | |
---|
34 | BEGIN { |
---|
35 | our $VERSION = sprintf "%s", q$Rev: 1007 $ =~ /([0-9.]+)\s+/ ; |
---|
36 | } |
---|
37 | our $VERSION ; |
---|
38 | our @ISA = ("AFPDS::MODCA"); |
---|
39 | our $IDENTS ; |
---|
40 | |
---|
41 | sub _ID { 0xD3EE92 } |
---|
42 | |
---|
43 | sub new { |
---|
44 | my $class = shift ; |
---|
45 | &Debug("new " . __PACKAGE__ . " v$VERSION object"); |
---|
46 | |
---|
47 | my $self = { |
---|
48 | FLUX => 0, # Associated flux |
---|
49 | IDENT => _ID, # MO:DCA identity |
---|
50 | FLAG => 0, # MO:DCA flags |
---|
51 | RESERVED => 0, # MO:DCA reserved |
---|
52 | LONG => 0, # MO:DCA buffer length |
---|
53 | BUFFER => '' # MO:DCA content buffer |
---|
54 | }; |
---|
55 | |
---|
56 | return bless $self , $class ; |
---|
57 | } |
---|
58 | |
---|
59 | sub validate { |
---|
60 | my $self = shift ; |
---|
61 | |
---|
62 | &Debug("Found OCD for integrated resource data"); |
---|
63 | &UPSTAT('GET-RESOURCE-DATA'); |
---|
64 | |
---|
65 | # Just control the autorized size of buffer |
---|
66 | return ( 251, "Not authorized " . $self->{LONG} . " OCD size" ) |
---|
67 | if ( $self->{LONG} < 0 or $self->{LONG} > 32759 ); |
---|
68 | |
---|
69 | # Check FLUX is a Flux object |
---|
70 | return ( 251, "OCD needs to be used with Flux object" ) |
---|
71 | unless ( ref($self->{FLUX}) =~ /^AFPDS::Flux$/ ); |
---|
72 | |
---|
73 | return () ; |
---|
74 | } |
---|
75 | |
---|
76 | sub create { |
---|
77 | my $self = shift ; |
---|
78 | |
---|
79 | if ($self->{LONG}) { |
---|
80 | my $flux = $self->{FLUX} ; |
---|
81 | |
---|
82 | my $object = $flux->get_resource ; |
---|
83 | return ( 252, "No object container available for datas" ) |
---|
84 | unless ( $object ); |
---|
85 | |
---|
86 | my $struct = $object->{STRUCT} || 0 ; |
---|
87 | return ( 253, "Unexpected '$struct' structure found for container" ) |
---|
88 | unless ( $struct == 0xDC00 ); |
---|
89 | |
---|
90 | # Initialize buffer if not exist |
---|
91 | $object->{RESOURCE_BUFFER} = "" |
---|
92 | unless (exists($object->{RESOURCE_BUFFER})); |
---|
93 | |
---|
94 | # Concatenate current buffers |
---|
95 | $object->{RESOURCE_BUFFER} .= $self->{BUFFER} ; |
---|
96 | |
---|
97 | } else { |
---|
98 | &Debug("Empty object container data found"); |
---|
99 | } |
---|
100 | |
---|
101 | return () ; |
---|
102 | } |
---|
103 | |
---|
104 | &Debug("Module " . __PACKAGE__ . " v$VERSION loaded"); |
---|
105 | |
---|
106 | ( $IDENTS->{&_ID} ) = __PACKAGE__ =~ /(\w+)$/ ; |
---|