diff --git a/AUTHORS.md b/AUTHORS.md index b25126d..7528dc2 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -11,4 +11,4 @@ Authors ordered by first contribution: - Richard Lau (https://github.com/richardlau) - Gibson Fahnestock (https://github.com/gibfahn) - Abdirahim Musse (https://github.com/ab-m) - + - Gaby Baghdadi (https://github.com/gabylb) diff --git a/binding.gyp b/binding.gyp index e5f0a16..e2f0482 100644 --- a/binding.gyp +++ b/binding.gyp @@ -71,7 +71,7 @@ }], ['OS in "os390 zos"', { "defines": [ "_ZOS", "_UNIX03_THREADS" ], - 'cflags_cc': ['-Wc,EXPORTALL', '-qnoconvlit'], + 'cflags_cc': ['-Wc,EXPORTALL', '-qascii'], 'cflags!': [ '-fno-omit-frame-pointer' ], }], ['OS=="linux"', { diff --git a/src/ibmras/common/LogManager.cpp b/src/ibmras/common/LogManager.cpp index c11fe31..7ba9918 100644 --- a/src/ibmras/common/LogManager.cpp +++ b/src/ibmras/common/LogManager.cpp @@ -29,6 +29,10 @@ #define VPRINT vsprintf #endif +#ifdef _ZOS +extern "C" int dprintf(int fd, const char *fmt, ...); +#endif + extern "C" { DECL void* ibmras_common_LogManager_getLogger(const char* name) { @@ -56,8 +60,12 @@ void LogManager::processMsg(const std::string &msg) { if (localLogFunc) { localLogFunc(msg); } else { +#ifdef _ZOS + dprintf(2,"%s\n",msg.c_str()); +#else std::cerr << msg << '\n'; std::cerr.flush(); +#endif } return; } diff --git a/src/ibmras/common/util/strUtils.cpp b/src/ibmras/common/util/strUtils.cpp index 03c8405..c0e69f8 100644 --- a/src/ibmras/common/util/strUtils.cpp +++ b/src/ibmras/common/util/strUtils.cpp @@ -100,11 +100,12 @@ std::string expectedNativeCodepage() { } -void convertCodePage(char * str, const char* toCodePage, const char * fromCodePage) { +int convertCodePage(char * str, const char* toCodePage, const char * fromCodePage) { + // return 0: no change, 1: changed, -1: error std::string codepage = expectedNativeCodepage(); if (codepage.compare("IBM-1047") == 0) { //already in that codepage - return - return; + return 0; } char *cp = (char*)ibmras::common::memory::allocate(strlen(str) + 1); strcpy(cp,str); @@ -117,15 +118,19 @@ void convertCodePage(char * str, const char* toCodePage, const char * fromCodePa if ((cd = iconv_open(toCodePage, fromCodePage)) == (iconv_t)(-1)) { fprintf(stderr, "Cannot open converter to %s from %s\n", toCodePage, fromCodePage); - return; + return -1; } rc = iconv(cd, &inptr, &inleft, &outptr, &outleft); if (rc == -1) { fprintf(stderr, "Error in converting characters\n"); } + else { + rc = 1; + } iconv_close(cd); ibmras::common::memory::deallocate((unsigned char**)&cp); + return rc; } #endif @@ -135,9 +140,11 @@ void native2Ascii(char * str, bool convertToCurrentLocale) { if ( NULL != str ) { if (convertToCurrentLocale) { - convertCodePage(str, expectedNativeCodepage().c_str(), "IBM-1047"); + int rc = convertCodePage(str, expectedNativeCodepage().c_str(), "IBM-1047"); + if (rc==1) { + __etoa(str); + } } - __etoa(str); } #endif }