summaryrefslogtreecommitdiff
path: root/xpp/perl_modules/Dahdi.pm
blob: fa5955ac834de7a65f1ac3b658f5c8e147bdc800 (plain)
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
package Dahdi;
#
# Written by Oron Peled <oron@actcom.co.il>
# Copyright (C) 2007, Xorcom
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
# $Id$
#
use strict;
use Dahdi::Span;

=head1 NAME

Dahdi - Perl interface to Dahdi information

This package allows access from Perl to information about Dahdi
hardware and loaded Dahdi devices.

=head1 SYNOPSIS

  # Listing channels in analog spans:
  use Dahdi;
  # scans system:
  my @spans = Dahdi::spans();
  for my $span (@spans) {
    next if ($span->is_digital);
     $span->num. " - [". $span->type ."] ". $span->name. "\n";
    for my $chan ($span->chans) {
      print " - ".$chan->num . " - [". $chan->type. "] ". $chan->fqn". \n";
    }
  }
=cut

my $proc_base = "/proc/dahdi";

=head1 spans()

Returns a list of span objects, ordered by span number.

=cut

sub spans() {
	my @spans;

	-d $proc_base or return ();
	foreach my $zfile (glob "$proc_base/*") {
		$zfile =~ s:$proc_base/::;
		next unless ($zfile =~ /^\d+$/);
		my $span = Dahdi::Span->new($zfile);
		push(@spans, $span);
	}
	@spans = sort { $a->num <=> $b->num } @spans;
	return @spans;
}

=head1 SEE ALSO

Span objects: L<Dahdi::Span>.

Dahdi channels objects: L<Dahdi::Chan>.

Dahdi hardware devices information: L<Dahdi::Hardware>.

Xorcom Astribank -specific information: L<Dahdi::Xpp>.

=cut

1;