Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Apply EBCDIC to ASCII conversions only if node wasn't built with -qAS…
Browse files Browse the repository at this point in the history
…CII (#138)

PR-URL: #138
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
  • Loading branch information
gabylb authored and richardlau committed Oct 31, 2019
1 parent 2bf09c6 commit e8bf52a
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <sys/procfs.h> // psinfo_t structure
#endif
#ifdef __MVS__
#include <_Nascii.h>
extern "C" char **__getargv_a(void);
extern "C" int __getargc(void);
extern "C" void *_convert_e2a(void *dst, const void *src, size_t size);
Expand Down Expand Up @@ -304,8 +305,10 @@ void reportEndpoint(uv_handle_t* h, struct sockaddr* addr, const char* prefix,
uv_getnameinfo_t endpoint;
if (uv_getnameinfo(h->loop, &endpoint, nullptr, addr, NI_NUMERICSERV) == 0) {
#ifdef __MVS__
__e2a_s(endpoint.host);
__e2a_s(endpoint.service);
if (__isASCII() == 0) {
__e2a_s(endpoint.host);
__e2a_s(endpoint.service);
}
#endif
out << prefix << endpoint.host << ":" << endpoint.service;
} else {
Expand All @@ -321,7 +324,9 @@ void reportEndpoint(uv_handle_t* h, struct sockaddr* addr, const char* prefix,
reinterpret_cast<sockaddr_in*>(addr)->sin_port :
reinterpret_cast<sockaddr_in6*>(addr)->sin6_port);
#ifdef __MVS__
__e2a_s(host);
if (__isASCII() == 0) {
__e2a_s(host);
}
#endif
out << prefix << host << ":" << port;
}
Expand Down Expand Up @@ -400,14 +405,20 @@ void reportPath(uv_handle_t* h, std::ostringstream& out) {
if (rc == 0) {
// buffer is not null terminated.
#ifdef __MVS__
char *tmpbuf = (char*)malloc(size);
_convert_e2a(tmpbuf, buffer, size);
std::string name(tmpbuf, size);
free(tmpbuf);
if (__isASCII() == 0) {
char *tmpbuf = (char*)malloc(size);
_convert_e2a(tmpbuf, buffer, size);
std::string name(tmpbuf, size);
free(tmpbuf);
out << "filename: " << name;
} else {
std::string name(buffer, size);
out << "filename: " << name;
}
#else
std::string name(buffer, size);
#endif
out << "filename: " << name;
#endif
}
free(buffer);
}
Expand Down

0 comments on commit e8bf52a

Please sign in to comment.