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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
*** Protocol.pm.orig Fri Aug 22 18:39:18 2003
--- Protocol.pm Sat Oct 11 13:09:04 2003
***************
*** 15,21 ****
@EXPORT_OK = qw(pad padding padded hexi make_num_hash default_error_handler);
! $VERSION = "0.51";
sub padding ($) {
my($x) = @_;
--- 15,21 ----
@EXPORT_OK = qw(pad padding padded hexi make_num_hash default_error_handler);
! $VERSION = "0.51.s2";
sub padding ($) {
my($x) = @_;
***************
*** 571,593 ****
return $mask;
}
sub default_error_handler {
! my($self, $data) = @_;
! my($type, $seq, $info, $minor_op, $major_op)
! = unpack("xCSLSCxxxxxxxxxxxxxxxxxxxxx", $data);
! my($t);
! $t = join("", "Protocol error: bad $type (",
! $self->do_interp('Error', $type), "); ",
! "Sequence Number $seq\n",
! " Opcode ($major_op, $minor_op) = ",
! ($self->do_interp('Request', $major_op)
! or $self->{'ext_request'}{$major_op}[$minor_op][0]), "\n");
! if ($type == 2) {
! $t .= " Bad value $info (" . hexi($info) . ")\n";
! } elsif ($self->{'error_type'}[$type] & 1) {
! $t .= " Bad resource $info (" . hexi($info) . ")\n";
! }
! croak($t);
}
sub handle_input {
--- 571,598 ----
return $mask;
}
+ sub make_error_msg {
+ my($self, $data) = @_;
+ my($type, $seq, $info, $minor_op, $major_op)
+ = unpack("xCSLSCxxxxxxxxxxxxxxxxxxxxx", $data);
+ my($t);
+ $t = join("", "Protocol error: bad $type (",
+ $self->do_interp('Error', $type), "); ",
+ "Sequence Number $seq\n",
+ " Opcode ($major_op, $minor_op) = ",
+ ($self->do_interp('Request', $major_op)
+ or $self->{'ext_request'}{$major_op}[$minor_op][0]), "\n");
+ if ($type == 2) {
+ $t .= " Bad value $info (" . hexi($info) . ")\n";
+ } elsif ($self->{'error_type'}[$type] & 1) {
+ $t .= " Bad resource $info (" . hexi($info) . ")\n";
+ }
+ return $t;
+ }
+
sub default_error_handler {
! my($self, $data) = @_;
! croak($self->make_error_msg($data));
}
sub handle_input {
***************
*** 597,604 ****
$type_b = $self->get(1);
$type = unpack "C", $type_b;
if ($type == 0) {
! &{$self->{'error_handler'}}($self, $type_b . $self->get(31));
! return 0;
} elsif ($type > 1) {
if ($self->{'event_handler'} eq "queue") {
push @{$self->{'event_queue'}}, $type_b . $self->get(31);
--- 602,614 ----
$type_b = $self->get(1);
$type = unpack "C", $type_b;
if ($type == 0) {
! my $data = $type_b . $self->get(31);
! my ($type, $seq, $info, $minor_op, $major_op)
! = unpack("xCSLSCxxxxxxxxxxxxxxxxxxxxx", $data);
! &{$self->{'error_handler'}}($self, $data);
! # return 0 to denote an error & the sequence number to identify
! # which request it applies to.
! return (0, $seq);
} elsif ($type > 1) {
if ($self->{'event_handler'} eq "queue") {
push @{$self->{'event_queue'}}, $type_b . $self->get(31);
***************
*** 2031,2036 ****
--- 2041,2047 ----
my($op, $args, $major, $minor) = (@_, 0);
my($data);
($data, $minor) = (&{$op->[1]}($self, @$args), $minor);
+ # print($op->[0] . " req has seq: " . $self->{sequence_num} . "\n");
$minor = 0 unless defined $minor;
my($len) = (length($data) / 4) + 1;
croak "Request too long!\n" if $len > $self->{'maximum_request_length'};
***************
*** 2054,2061 ****
$self->give($self->assemble_request($op, \@args, $major, $minor));
$seq = $self->next_sequence();
$self->add_reply($seq & 0xffff, \$data);
! $self->handle_input() until $data;
$self->delete_reply($seq & 0xffff);
return &{$op->[2]}($self, $data);
} elsif (@$op == 4) { # Many replies
my($seq, $data, @stuff, @ret);
--- 2065,2077 ----
$self->give($self->assemble_request($op, \@args, $major, $minor));
$seq = $self->next_sequence();
$self->add_reply($seq & 0xffff, \$data);
! while (1)
! {
! my @ret = $self->handle_input();
! last if ($data || ($ret[0] == 0 && $ret[1] == $seq));
! }
$self->delete_reply($seq & 0xffff);
+ return undef unless $data;
return &{$op->[2]}($self, $data);
} elsif (@$op == 4) { # Many replies
my($seq, $data, @stuff, @ret);
***************
*** 2063,2069 ****
$seq = $self->next_sequence();
$self->add_reply($seq & 0xffff, \$data);
for (;;) {
! $data = 0; $self->handle_input() until $data;
@stuff = &{$op->[2]}($self, $data);
last unless @stuff;
if ($op->[3] eq "ARRAY") {
--- 2079,2095 ----
$seq = $self->next_sequence();
$self->add_reply($seq & 0xffff, \$data);
for (;;) {
! $data = 0;
! while (1)
! {
! my @ret = $self->handle_input();
! last if ($data || ($ret[0] == 0 && $ret[1] == $seq));
! }
! if (!$data)
! {
! $self->delete_reply($seq & 0xffff);
! return undef;
! }
@stuff = &{$op->[2]}($self, $data);
last unless @stuff;
if ($op->[3] eq "ARRAY") {
***************
*** 2392,2399 ****
$self->give($self->assemble_request($op, \@_, $major, $minor));
$seq = $self->next_sequence();
$self->add_reply($seq, \$data);
! $self->handle_input() until $data;
$self->delete_reply($seq);
return &{$op->[2]}($self, $data);
};
} else { # ListFontsWithInfo
--- 2418,2430 ----
$self->give($self->assemble_request($op, \@_, $major, $minor));
$seq = $self->next_sequence();
$self->add_reply($seq, \$data);
! while (1)
! {
! my @ret = $self->handle_input();
! last if ($data || ($ret[0] == 0 && $ret[1] == $seq));
! }
$self->delete_reply($seq);
+ return undef unless $data;
return &{$op->[2]}($self, $data);
};
} else { # ListFontsWithInfo
|