char *string
; /* if non-zero, where to connect to */
struct sockaddr_in server
;
string
= getenv("API3270"); /* Get API */
"API3270 environmental variable not set - no API.\n");
if (sscanf(string
, "%[^:]:%d", thehostname
, &port
) != 2) {
fprintf(stderr
, "API3270 environmental variable has bad format.\n");
/* Now, try to connect */
sock
= socket(AF_INET
, SOCK_STREAM
, 0);
perror("opening API socket");
server
.sin_family
= AF_INET
;
hp
= gethostbyname(thehostname
);
fprintf(stderr
, "%s specifies bad host name.\n", string
);
bcopy(hp
->h_addr
, &server
.sin_addr
, hp
->h_length
);
server
.sin_port
= htons(port
);
if (connect(sock
, &server
, sizeof server
) < 0) {
perror("connecting to API server");
return 0; /* Happiness! */
api_exch_api(regs
, sregs
)