/usr/share/perl5/Device/Gsm/Sms/Token/UD.pm is in libdevice-gsm-perl 1.60-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | # Sms::Token::UD - SMS UD (user data length + user data) token
# Copyright (C) 2002-2006 Cosimo Streppone, cosimo@cpan.org
# Copyright (C) 2006-2011 Grzegorz Wozniak, wozniakg@gmail.com
#
# This program is free software; you can redistribute it and/or modify
# it only under the terms of Perl itself.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Perl licensing terms for details.
#
# $Id$
package Sms::Token::UD;
use integer;
use strict;
use Device::Gsm::Charset;
use Device::Gsm::Pdu;
use Device::Gsm::Sms::Token;
#my $udh1_length=UDH1_LENGTH;
#my $udh2_length=UDH2_LENGTH;
@Sms::Token::UD::ISA = ('Sms::Token');
# takes (scalar message (string) reference)
# returns success/failure of decoding
# if all ok, removes user data from message
sub decode {
my ($self, $rMessage) = @_;
my $ok = 0;
my $padding = 0;
# Get length of message
my $ud_len = hex substr($$rMessage, 0, 2);
# Finally get text of message
my $dcs = $self->get('_messageTokens')->{'DCS'}->get('_data')->[0];
my $is_csms = $self->get('_messageTokens')->{'UDH'}->{'_IS_CSMS'};
$is_csms
and my $udhl = $self->get('_messageTokens')->{'UDH'}->{'_length'};
my $text;
if ($dcs == 8) {
$text = Device::Gsm::Pdu::decode_text_UCS2($$rMessage);
}
else {
if ($is_csms) {
$padding = Sms::Token::UDH::calculate_padding($udhl);
$text = Device::Gsm::Pdu::decode_text7_udh($$rMessage, $padding);
}
else {
$text = Device::Gsm::Pdu::decode_text7($$rMessage);
}
$text = Device::Gsm::Charset::gsm0338_to_iso8859($text);
}
$self->set('padding' => $padding);
$self->set('length' => $ud_len);
$self->set('text' => $text);
$self->data($text);
$self->state(Sms::Token::DECODED);
# Empty message
$$rMessage = '';
return 1;
}
#
# [token]->encode( [$data] )
#
# takes internal token data and encodes it, returning the result or undef value in case of errors
#
sub encode {
my $self = shift;
my $padding = shift;
#my $ud_len = $self->get('length');
my $text = $self->get('text');
return Device::Gsm::Pdu::encode_text7($text);
}
1;
|