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

Apply EBCDIC to ASCII conversions only if node wasn't built with -qASCII #138

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
richardlau marked this conversation as resolved.
Show resolved Hide resolved
__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