parport.xs

filter: Statementstmt 0.0% 0 / 18 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 22 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Device/ParallelPort/drv/parport.pm ↑ Summary
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 #include <stdio.h>
6 #include <unistd.h>
7 #include <fcntl.h>
8 #include <errno.h>
9 #include <sys/stat.h>
10 #include <sys/sysmacros.h>
11 #include <linux/parport.h>
12 #include <sys/ioctl.h>
13 #include <linux/ppdev.h>
14  
15 #include "parport.h"
16  
17 MODULE = Device::ParallelPort::drv::parport PACKAGE = Device::ParallelPort::drv::parport
18  
19 int
20 parport_opendev(dev)
21 char *dev
22 CODE:
23 int fd;
24  
25 0 fd = open(dev, O_RDWR|O_NONBLOCK);
26 0 ▶ if(fd < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(fd < 0) { 0 0 0
27 0 RETVAL = -1;
28 } else {
29 0 ▶ if(ioctl(fd, PPCLAIM, 0) != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(ioctl(fd, PPCLAIM, 0) != 0) { 0 0 0
30 0 close(fd);
31 0 RETVAL = -1;
32 } else {
33 0 RETVAL = fd;
34 }
35 }
36 OUTPUT:
37 RETVAL
38  
39 void
40 parport_closedev(base)
41 int base
42 CODE:
43 0 close(base);
44  
45 char
46 parport_rd_data(base)
47 int base
48 CODE:
49 int d;
50 unsigned char byte;
51 0 ioctl(base, PPRDATA, &byte);
52 0 RETVAL = byte;
53 OUTPUT:
54 RETVAL
55  
56 void
57 parport_wr_data(base, val)
58 int base
59 char val
60 CODE:
61 unsigned char byte;
62 0 byte = val & 0xff;
63 0 ioctl(base, PPWDATA, &byte);
64  
65 char
66 parport_rd_ctrl(base)
67 int base
68 CODE:
69 unsigned char byte;
70 0 ioctl(base, PPRCONTROL, &byte);
71 0 RETVAL = byte;
72 OUTPUT:
73 RETVAL
74  
75 void
76 parport_wr_ctrl(base, val)
77 int base
78 char val
79 CODE:
80 unsigned char byte;
81 0 byte = val & 0xff;
82 0 ioctl(base, PPWCONTROL, &byte);
83  
84 char
85 parport_rd_status(base)
86 int base
87 CODE:
88 unsigned char byte;
89 0 ioctl(base, PPRSTATUS, &byte);
90 0 RETVAL = byte;
91 OUTPUT:
92 RETVAL
93  
« blib/lib/Device/ParallelPort/drv/parport.pm ↑ Summary