File: G15Daemon.pm

package info (click to toggle)
g15daemon 1.9.5.3-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 2,144 kB
  • sloc: sh: 9,189; ansic: 3,188; perl: 115; makefile: 66
file content (99 lines) | stat: -rw-r--r-- 1,562 bytes parent folder | download | duplicates (5)
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
88
89
90
91
92
93
94
95
96
97
98
99
package G15Daemon;
use base 'Exporter';
use warnings;
use strict;

use 5.008007;
our $VERSION = '0.2';

require Exporter;

our @EXPORT = qw( $g15wbmp $g15pbuf $g15txt );

use Inline C =>
        DATA => 
        LIBS => '-lg15daemon_client';

our $WIDTH = '160';
our $HEIGHT = '43';

*g15pbuf = \0;
*g15txt = \1;
*g15wbmp = \2;

sub apiversion {
  my $self = shift;
  return g15version();
}

sub width {
  my $self = shift;
  return $WIDTH;
}
sub height {
  my $self = shift;
  return $HEIGHT;
}

sub new
{
  my ($class, $screentype) = @_;
  my $sock = g15newscreen ($screentype);
  my $self = {socket => $sock};
  bless $self, $_[0];
}

sub DESTROY {
  my $self = shift;
  return g15closescreen($self->{socket});
}

sub closescreen {
  my $self = shift;
  return g15closescreen($self->{socket});
}

sub send {
  my $self = shift;
  my ($buffer) = @_;
  my $len = length($buffer);
  return g15send($self->{socket}, $buffer, $len);
}

sub recv{
  my $self = shift;
  my ($buffer, $len) = @_;
  return g15recv($self->{socket}, $buffer, $len);
}

1;

__DATA__
__C__

#include <g15daemon_client.h>

SV* g15version() {
  return newSVpvf("%s\n", G15DAEMON_VERSION);
}

int g15newscreen (int screentype) {
  return new_g15_screen(screentype);
}

int g15closescreen(int sockfd) {
  return g15_close_screen(sockfd);
}

int g15send(int sockfd, char *buf, unsigned int len) {
  int retval = g15_send(sockfd, buf, len);
  memset(buf,0,len);
  return retval;
}

char * g15recv(int sockfd, char *buf, unsigned int len) {
  g15_recv(sockfd, buf, len);
  return buf;
}

__END__