HP-UX Reference (11i v2 04/09) - 3 Library Functions A-M (vol 6)

b
blmode(3C) blmode(3C)
(OBSOLETED in Itanium(R)-based Systems)
#define NBREPLY 64
struct blmodeio {
unsigned long cb_flags; /* Modes */
unsigned char cb_trig1c; /* First trigger */
unsigned char cb_trig2c; /* Second trigger */
unsigned char cb_alertc; /* Alert character */
unsigned char cb_termc; /* Terminating char */
unsigned char cb_replen; /* cb_reply length */
char cb_reply[NBREPLY]; /* optional reply */
};
The cb_flags field controls the basic block-mode protocol:
CB_BMTRANS 0000001
Enable mandatory block-mode transmission.
CB_OWNTERM 0000002
Enable user control of handshake.
If
CB_BMTRANS is set, all transmissions are processed as block-mode transmissions. The block-mode
handshake is not required and data read is processed as block-mode transfer data. The block-mode
handshake can still be invoked by receipt of an alert character as the first character seen. A
blread()
issued with the CB_BMTRANS bit set causes any existing input buffer data to be flushed.
If
CB_BMTRANS is not set, and if the alert character is defined and is detected anywhere in the input
stream, the input buffer is flushed and the block-mode handshake is invoked. The system then sends the
cb_trig2c character to the terminal, and a block-mode transfer follows. The alert character can be
escaped by preceding it with a backslash (\).
If
CB_OWNTERM is set, reads are terminated upon receipt of a non-escaped alert character. No input
buffer flushing is performed, and the alert character is returned in the data read. This allows application
code to perform its own block-mode handshaking. If the bit is clear, a non-escaped alert character causes
normal block-mode handshaking to be used.
The initial
cb_flags value is all-bits-cleared.
There are several special characters (both input and output) that are used with block mode. These char-
acters and the initial values for these characters are described below. Any of these characters can be
undefined by setting its value to 0377.
cb_trig1c (default DC1) is the initial trigger character sent to the terminal at the beginning of a
read request.
cb_trig2c (default DC1) is the secondary trigger character sent to the terminal after the alert char-
acter has been seen.
cb_alertc (default DC2) is the alert character sent by the terminal in response to the first trigger
character. It signifies that the terminal is ready to send the data block. The alert char-
acter can be escaped by preceding it with a backslash ("\").
cb_termc (default RS) is sent by the terminal after the block-mode transfer has completed. It
signifies the end of the data block to the computer.
The
cb_replen field specifies the length in bytes of the cb_reply field. If set to zero, the
cb_reply string is not used. The cb_replen field is initially set to zero.
The
cb_reply array contains a string to be sent out after receipt of the alert character, but before the
second trigger character is sent by the computer. Any character can be included in the reply string. The
number of characters sent is specified by cb_replen. The initial value of all characters in the
cb_reply array is NULL.
RETURN VALUE
If an error occurs, all calls return a value of 1 and
errno is set to indicate the error. If no error is
detected, blread() returns the number of characters read. All other calls return 0 upon successful
completion.
During a read, it is possible for the user’s buffer to be altered, even if an error value is returned. The
data in the user’s buffer should be ignored as it is not complete. The following errors can be returned by
the library calls indicated:
HP-UX 11i Version 2: September 2004 3 Hewlett-Packard Company Section 361