Chapter 9. Porting open system applications to a z/TPF system 197
/* issue SSL_get_peer_certificate_subject_info() */
c_len = sizeof(country);
st_len = sizeof(state);
city_len = sizeof(city);
company_len = sizeof(company);
c_unit_len = sizeof(company_unit);
name_len = sizeof(common_name);
email_len = sizeof(email);
SSL_get_peer_certificate_subject_info(myssl, country, c_len, state, st_len, city,
city_len, company, company_len, company_unit, c_unit_len,
common_name, name_len, email, email_len);
/*Send message to the server.*/
err=SSL_write(myssl,"Hello there!!!!",sizeof("Hello there!!!!")+1);
/*Read servers response.*/
err = SSL_read (myssl, buff, sizeof(buff));
printf("Server said: %s\n",buff);
err=SSL_shutdown(myssl);
close(socketfd);
SSL_free(myssl);
SSL_CTX_free(ctx);
exit(0);
}
9.2 Character conversion
In this section we introduce character conversion while porting open system applications to
z/TPF, that is, converting from ASCII to EBCDIC character set. For example, take function
fopen, in stdio.h. The definition of the function is fopen(const char *filename, char *mode).
The two parameters, filename and mode, are ASCII string, while the z/TPF system expects to
be in EBCDIC. In this condition, character conversion is required.
Follow these three main steps for character conversion:
1. Take function
foobar (in foobar.h) as an example.
a. First create the a2e wrapper of function foobar, atoe_foobar, which converts the
parameter string from ASCII to EBCDIC and then call foobar.
b. Then create the header file for atoe_foobar as shown in Example 9-7.