home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_09
/
9n09084a
< prev
next >
Wrap
Text File
|
1991-07-10
|
3KB
|
84 lines
/*****************************************************
* Listing 4 hc_error.c
*
* Error handler for HOSTCOM
*
****************************************************/
#include <conio.h>
#include "hc.h"
static char *hostcom_err[] = {
"", /* hostcom_err[0] not used */
"Not connected to session",
"Invalid PSID",
"Connection to PS failed",
"Host busy, not all keystrokes sent",
"Input inhibited or rejected, all keys not sent",
"System error (a host problem)",
"Timeout error while waiting. Try IGNORE first"
" to give host more time to respond",
"input_to_host(): invalid prm passed to send_key()",
"find_msg(): invalid param passed to send_key()",
"Keyboard locked",
"keys_to_host(): invalid param passed to send_key()",
"Resource unavailable; PS in use",
"Bad PSID or data string in dspy_cursor()"
};
int process_error(int host_err)
{
int k, y = 1;
write_string(1, y++,
hostcom_err[host_err], stat_attr);
write_string(1, y++,
"Select recovery option:", stat_attr);
write_string(1, y++,
" 1. 3270 Clear", stat_attr);
write_string(1, y++,
" 2. 3270 Reset", stat_attr);
write_string(1, y++,
" 3. Ignore error", stat_attr);
write_string(1, y++,
" 4. Exit unconditionally",stat_attr);
do {
k = get_key();
} while (k < '1' || k > '4');
/* Process recovery option. If clear or reset
* fails then exit program. send_key() is used
* instead of input_to_host() to avoid a call
* to host_wait(), which would result in an
* immediate failure if the host needs a clear
* or reset is called for.
*/
switch (k) {
case '1': /* clear */
/* If the clear key flag is not set,
* send enter key then clear
*/
if (clear_flag == 0) {
if (send_key("@E") != 0)
return(1);
}
clear_flag = 0; /* reset clear flag */
if (send_key("@C") != 0)
return(1);
else
return(0);
case '2': /* reset */
if (send_key("@R") != 0)
return(1);
else
return(0);
case '3': return(0); /* ignore */
case '4': return(1); /* exit */
}
}