* Copyright (c) 1988 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
"@(#) Copyright (c) 1988 Regents of the University of California.\n\
static char sccsid
[] = "@(#)prt3270.c 3.3 (Berkeley) 3/28/88";
#include "../general/general.h"
#include "../api/asc_ebc.h"
#include "../ctlr/hostctlr.h"
#include "../ctlr/screen.h"
#include "../ctlr/function.h"
#include "../api/astosc.h"
#include "../general/globals.h"
#include "../ctlr/kbd.out"
unsigned char printBuffer
[200], *print
= printBuffer
;
#define ColsLeft() (79-column) /* A little room for error */
unsigned char *ourPrint
= print
;
print
= printBuffer
; /* For mutual calls */
if (column
!= (indenting
*8+1)) {
for (i
= 0; i
< indenting
; i
++) {
printf("%s", printBuffer
);
column
+= strlen(printBuffer
);
if (print
!= printBuffer
) {
if (column
!= (indenting
*8+1)) {
if ((column
!= (indenting
*8+1)) || (print
!= printBuffer
)) {
if ((column
!= (indenting
*8+1)) || (print
!= printBuffer
)) {
fprintf(stderr
, "INTERNAL ERROR: indenting < 0.\n");
sprintf(place
, "%02x", i
);
putChar(ebc_asc
[character
]);
for (this = &astosc
[0]; this <= &astosc
[highestof(astosc
)]; this++) {
if (this->function
== FCN_AID
) {
switch (this->shiftstate
) {
case (SHIFT_UPSHIFT
|SHIFT_ALT
):
fprintf(stderr
, "Bad shiftstate 0x%x.\n", this->shiftstate
);
if (hits
[this->scancode
].hit
[j
].code
== i
) {
putstr("Unknown AID 0x");
putdecimal(ScreenLine(i
));
putdecimal(ScreenLineOffset(i
));
/* returns the number of characters consumed */
DataFromNetwork(buffer
, count
, control
)
register unsigned char *buffer
; /* what the data is */
register int count
; /* and how much there is */
int control
; /* this buffer ended block? */
static int LastWasTerminated
= 1; /* was "control" = 1 last time? */
fprintf(stderr
, "Short count received from host!\n");
switch (Command
) { /* This had better be a read command */
putstr("read_modified command\n");
case CMD_SNA_READ_MODIFIED
:
putstr("sna_read_modified command\n");
case CMD_SNA_READ_MODIFIED_ALL
:
putstr("sna_read_modified_all command\n");
putstr("read_buffer command\n");
case CMD_SNA_READ_BUFFER
:
putstr("sna_read_buffer command\n");
return(1); /* We consumed everything */
putstr("erase write command ");
case CMD_ERASE_WRITE_ALTERNATE
:
putstr("erase write alternate command ");
case CMD_SNA_ERASE_WRITE
:
putstr("sna erase write command ");
case CMD_SNA_ERASE_WRITE_ALTERNATE
:
putstr("erase write alternate command ");
case CMD_ERASE_ALL_UNPROTECTED
:
putstr("erase all unprotected command ");
case CMD_SNA_ERASE_ALL_UNPROTECTED
:
putstr("sna erase write command ");
putstr("write command ");
putstr("sna write command ");
putstr("Unexpected command code 0x");
count
-= 2; /* strip off command and wcc */
LastWasTerminated
= 0; /* then, reset at end... */
# define Ensure(x) if (count < x) { \
return(origCount-(count+1)); \
/* XXX - should not occur */ \
PrintAddr(Addr3270(i
,c
));
i
= Addr3270(buffer
[0], buffer
[1]);
case ORDER_EUA
: /* (from [here,there), ie: half open interval] */
PrintAddr(Addr3270(buffer
[0], buffer
[1]));
case ORDER_YALE
: /* special YALE defined order */
Ensure(2); /* need at least two characters */
putstr("UNKNOWN ORDER: 0x");
/* Data comes in large clumps - take it all */
while (count
&& !IsOrder(c
)) {
LastWasTerminated
= control
;
return origCount
- count
;
DataToNetwork(buffer
, count
, control
)
static int state
= NEED_AID
;
return origCount
- count
+ DataToNetwork(buffer
, count
, control
);
PrintAddr(Addr3270(buffer
[0], buffer
[1]));
return origCount
- count
+ DataToNetwork(buffer
, count
, control
);
if (*buffer
== ORDER_SBA
) {
if (state
== DATA_CONTINUE
) {
PrintAddr(Addr3270(buffer
[1], buffer
[2]));
if (state
== DATA_CONTINUE
) {
fprintf(stderr
, "Non-hex digit 0x%x.\n");
unsigned char outbound
[8192], inbound
[8192],
*outnext
= outbound
, *innext
= inbound
, *p
= 0;
termblock(old
, new, control
)
new; /* old and new directions */
count
= DataFromNetwork(outbound
, outnext
-outbound
, control
);
if (outbound
+count
== outnext
) {
memcpy(outbound
, outbound
+count
, outnext
-(outbound
+count
));
outnext
= outbound
+count
;
count
= DataToNetwork(inbound
, innext
-inbound
, control
);
if (inbound
+count
== innext
) {
memcpy(inbound
, inbound
+count
, innext
-(inbound
+count
));
fprintf(stderr
, "Bad direction character '%c'.\n", new);
memset(Orders
, 0, sizeof Orders
);
Orders
[ORDER_SF
] = Orders
[ORDER_SBA
] = Orders
[ORDER_IC
]
= Orders
[ORDER_PT
] = Orders
[ORDER_RA
] = Orders
[ORDER_EUA
]
= Orders
[ORDER_YALE
] = 1;
while (scanf("%c 0x%x\t", &new, &location
) != EOF
) {
termblock(direction
, new, 0);
while (((c
= getchar()) != EOF
) && (c
!= '\n') && (isxdigit(c
))) {
static int state
= NORMAL
;
c
= (GetXValue(c
) << 4) + GetXValue(c1
);
termblock(direction
, direction
, 1);