Handle out-of-order charset descriptors
The ZOC emulator returns the primary character set descriptor after the alternate descriptor. Need to pick the right one based on searching for ID 0.
This commit is contained in:
1 parent
7b7d375e91
commit
ab58ba7a87
1 file changed
+17
-4
@@ -480,18 +480,31 @@ func getCodepageID(buf []byte) int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Descriptor length -- and do we have at least one descriptor?
|
// Descriptor length
|
||||||
dl := int(buf[10])
|
dl := int(buf[10])
|
||||||
if len(buf) < 11+dl {
|
|
||||||
|
// There may be more than one descriptors, and we need to find the first
|
||||||
|
// one with local ID 0.
|
||||||
|
pos := 11 // first descriptor
|
||||||
|
for {
|
||||||
|
if len(buf) < pos+dl {
|
||||||
|
// No more descriptors and we haven't found anything yet
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if buf[pos] != 0 {
|
||||||
|
// not the descriptor we're looking for, try the next one
|
||||||
|
pos += dl
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is the first descriptor we've seen with ID 0, we'll use it.
|
||||||
// No matter how long the descriptor is, the code page will 2-byte big
|
// No matter how long the descriptor is, the code page will 2-byte big
|
||||||
// endian integer in the last two bytes.
|
// endian integer in the last two bytes.
|
||||||
cpid := int(buf[11+dl-2])<<8 + int(buf[11+dl-1])
|
cpid := int(buf[pos+dl-2])<<8 + int(buf[pos+dl-1])
|
||||||
|
|
||||||
return cpid
|
return cpid
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// getRPGNames checks the "Query Reply (RPQ NAMES)" response to see if the
|
// getRPGNames checks the "Query Reply (RPQ NAMES)" response to see if the
|
||||||
// client is in the x3270 family. The byte slice passed in to buf must begin
|
// client is in the x3270 family. The byte slice passed in to buf must begin
|
||||||
|
|||||||
Reference in new issue
Block a user