@@ -92,41 +92,12 @@ static std::string toStdString(Local<String> s) {
9292 s->WriteUtf8 (isolate, buf);
9393#else
9494 s->WriteUtf8 (buf);
95- #endif
96- #if defined(_ZOS)
97- __atoe (buf);
9895#endif
9996 std::string result (buf);
10097 delete[] buf;
10198 return result;
10299}
103100
104- static std::string asciiString (std::string s) {
105- #if defined(_ZOS)
106- char * cp = new char [s.length () + 1 ];
107- std::strcpy (cp, s.c_str ());
108- __etoa (cp);
109- std::string returnString (cp);
110- delete[] cp;
111- return returnString;
112- #else
113- return s;
114- #endif
115- }
116-
117- static std::string nativeString (std::string s) {
118- #if defined(_ZOS)
119- char * cp = new char [s.length () + 1 ];
120- std::strcpy (cp, s.c_str ());
121- __atoe (cp);
122- std::string returnString (cp);
123- delete[] cp;
124- return returnString;
125- #else
126- return s;
127- #endif
128- }
129-
130101#if defined(_WINDOWS)
131102// std::cout << "Test empty: " << portDirname("") << std::endl;
132103// std::cout << "Test /: " << portDirname("/") << std::endl;
@@ -189,7 +160,7 @@ static std::string fileJoin(const std::string& path, const std::string& filename
189160}
190161
191162static std::string* getModuleDir (Local<Object> module ) {
192- Local<String> filenameKey = Nan::New<String>(asciiString ( " filename" ) ).ToLocalChecked ();
163+ Local<String> filenameKey = Nan::New<String>(" filename" ).ToLocalChecked ();
193164 Local<Value> filenameValue = Nan::Get (module , filenameKey).ToLocalChecked ();
194165 Local<String> filenameString = Nan::To<String>(filenameValue).ToLocalChecked ();
195166 std::string moduleFilename (toStdString (filenameString));
@@ -202,13 +173,13 @@ static Local<Object> getSubObject(Local<Object> parentObj, Local<String> subObje
202173}
203174
204175static Local<Object> getProcessObject () {
205- Local<String> processString = Nan::New<String>(asciiString ( " process" ) ).ToLocalChecked ();
176+ Local<String> processString = Nan::New<String>(" process" ).ToLocalChecked ();
206177 Local<Object> processObj = getSubObject (Nan::GetCurrentContext ()->Global (), processString);
207178 return processObj;
208179}
209180
210181static std::string* findApplicationDir () {
211- Local<String> mainModuleString = Nan::New<String>(asciiString ( " mainModule" ) ).ToLocalChecked ();
182+ Local<String> mainModuleString = Nan::New<String>(" mainModule" ).ToLocalChecked ();
212183 Local<Value> mainModuleValue = Nan::Get (getProcessObject (), mainModuleString).ToLocalChecked ();
213184 if (!mainModuleValue->IsUndefined ()) {
214185 return getModuleDir (Nan::To<Object>(mainModuleValue).ToLocalChecked ());
@@ -314,7 +285,7 @@ static bool isMonitorApiValid() {
314285}
315286
316287static bool initMonitorApi () {
317- std::string pluginPath = nativeString ( loaderApi->getProperty (" com.ibm.diagnostics.healthcenter.plugin.path" ) );
288+ std::string pluginPath = loaderApi->getProperty (" com.ibm.diagnostics.healthcenter.plugin.path" );
318289
319290 monitorApi::pushData = (void (*)(const char *)) getMonitorApiFunction (pluginPath, std::string (" apiPushData" ));
320291 monitorApi::sendControl = (void (*)(const char *, unsigned int , void *)) getMonitorApiFunction (pluginPath, std::string (" sendControl" ));
@@ -444,7 +415,7 @@ static void emitMessage(uv_async_t *handle, int status) {
444415 Local<Value> argv[argc];
445416 const char * source = (*currentMessage->source ).c_str ();
446417
447- Local<Object> buffer = Nan::CopyBuffer (asciiString ( std::string ((char *)currentMessage->data ) ).c_str (), currentMessage->size ).ToLocalChecked ();
418+ Local<Object> buffer = Nan::CopyBuffer (std::string ((char *)currentMessage->data ).c_str (), currentMessage->size ).ToLocalChecked ();
448419 argv[0 ] = Nan::New<String>(source).ToLocalChecked ();
449420 argv[1 ] = buffer;
450421
@@ -502,7 +473,7 @@ static void sendData(const char* sourceId, unsigned int size, void *data) {
502473NAN_METHOD (nativeEmit) {
503474
504475 if (!isMonitorApiValid ()) {
505- Nan::ThrowError (asciiString ( " Monitoring API is not initialized" ). c_str () );
476+ Nan::ThrowError (" Monitoring API is not initialized" );
506477 // NanReturnUndefined();
507478 }
508479
@@ -515,7 +486,7 @@ NAN_METHOD(nativeEmit) {
515486 /*
516487 * Error handling as we don't have a valid parameter
517488 */
518- return Nan::ThrowError (asciiString ( " First argument must a event name string" ). c_str () );
489+ return Nan::ThrowError (" First argument must a event name string" );
519490 }
520491 if (info[1 ]->IsString ()) {
521492 Nan::Utf8String str (info[1 ]);
@@ -526,7 +497,7 @@ NAN_METHOD(nativeEmit) {
526497 /*
527498 * Error handling as we don't have a valid parameter
528499 */
529- Nan::ThrowError (asciiString ( " Second argument must be a JSON string or a comma separated list of key value pairs" ). c_str () );
500+ Nan::ThrowError (" Second argument must be a JSON string or a comma separated list of key value pairs" );
530501 return ;
531502 }
532503 contentss << ' \n ' ;
@@ -539,7 +510,7 @@ NAN_METHOD(nativeEmit) {
539510NAN_METHOD (sendControlCommand) {
540511
541512 if (!isMonitorApiValid ()) {
542- Nan::ThrowError (asciiString ( " Monitoring API is not initialized" ). c_str () );
513+ Nan::ThrowError (" Monitoring API is not initialized" );
543514 return ;
544515 }
545516
@@ -551,7 +522,7 @@ NAN_METHOD(sendControlCommand) {
551522 unsigned int length = command.length ();
552523 monitorApi::sendControl (topic.c_str (), length, (void *)command.c_str ());
553524 } else {
554- return Nan::ThrowError (asciiString ( " Arguments must be strings containing the plugin name and control command" ). c_str () );
525+ return Nan::ThrowError (" Arguments must be strings containing the plugin name and control command" );
555526 }
556527
557528 return ;
@@ -570,12 +541,12 @@ NAN_METHOD(setHeadlessZipFunction) {
570541
571542NAN_METHOD (localConnect) {
572543 if (!isMonitorApiValid ()) {
573- Nan::ThrowError (asciiString ( " Monitoring API is not initialized" ). c_str () );
544+ Nan::ThrowError (" Monitoring API is not initialized" );
574545 return ;
575546 }
576547
577548 if (!info[0 ]->IsFunction ()) {
578- return Nan::ThrowError (asciiString ( " First argument must be a callback function" ). c_str () );
549+ return Nan::ThrowError (" First argument must be a callback function" );
579550 }
580551 Nan::Callback *callback = new Nan::Callback (info[0 ].As <Function>());
581552
@@ -637,14 +608,14 @@ void lrtime(const Nan::FunctionCallbackInfo<v8::Value>& info) {
637608// executing require('module')._cache)
638609static Local<Object> getRequireCache (Local<Object> module ) {
639610 Nan::EscapableHandleScope scope;
640- Local<Value> args[] = { Nan::New<String>(asciiString ( " module" ) ).ToLocalChecked () };
641- Local<String> require_string = Nan::New<String>(asciiString ( " require" ) ).ToLocalChecked ();
611+ Local<Value> args[] = { Nan::New<String>(" module" ).ToLocalChecked () };
612+ Local<String> require_string = Nan::New<String>(" require" ).ToLocalChecked ();
642613 Local<Value> require_v = Nan::Get (module , require_string).ToLocalChecked ();
643614 Local<Object> require_obj = Nan::To<Object>(require_v).ToLocalChecked ();
644615 Local<Object> global_obj = Nan::GetCurrentContext ()->Global ();
645616 Local<Value> module_v = Nan::CallAsFunction (require_obj, global_obj, 1 , args).ToLocalChecked ();
646617 Local<Object> module_obj = Nan::To<Object>(module_v).ToLocalChecked ();
647- Local<String> cache_string = Nan::New<String>(asciiString ( " _cache" ) ).ToLocalChecked ();
618+ Local<String> cache_string = Nan::New<String>(" _cache" ).ToLocalChecked ();
648619 Local<Value> cache_v = Nan::Get (module_obj, cache_string).ToLocalChecked ();
649620 Local<Object> cache_obj = Nan::To<Object>(cache_v).ToLocalChecked ();
650621 return scope.Escape (cache_obj);
@@ -673,11 +644,11 @@ static bool isAppMetricsFile(std::string expected, std::string potentialMatch) {
673644
674645static bool isGlobalAgent (Local<Object> module ) {
675646 Nan::HandleScope scope;
676- Local<String> parentString = Nan::New<String>(asciiString ( " parent" ) ).ToLocalChecked ();
647+ Local<String> parentString = Nan::New<String>(" parent" ).ToLocalChecked ();
677648 Local<Value> parentValue = Nan::Get (module , parentString).ToLocalChecked ();
678649 if (parentValue->IsObject ()) {
679650 Local<Object> parentObj = Nan::To<Object>(parentValue).ToLocalChecked ();
680- Local<String> filenameString = Nan::New<String>(asciiString ( " filename" ) ).ToLocalChecked ();
651+ Local<String> filenameString = Nan::New<String>(" filename" ).ToLocalChecked ();
681652 Local<Value> filenameValue = Nan::Get (parentObj, filenameString).ToLocalChecked ();
682653 if (
683654 filenameValue->IsString ()
@@ -725,7 +696,7 @@ void init(Local<Object> exports, Local<Object> module) {
725696 */
726697 Nan::HandleScope scope;
727698 if (!isGlobalAgent (module ) && isGlobalAgentAlreadyLoaded (module )) {
728- Nan::ThrowError (asciiString ( " Conflicting appmetrics module was already loaded by node-hc. Try running with node instead." ). c_str () );
699+ Nan::ThrowError (" Conflicting appmetrics module was already loaded by node-hc. Try running with node instead." );
729700 return ;
730701 }
731702 // Setup global data mutex
@@ -738,30 +709,30 @@ void init(Local<Object> exports, Local<Object> module) {
738709 /*
739710 * Set exported functions
740711 */
741- Nan::SetMethod (exports, asciiString ( " getOption" ). c_str () , getOption);
742- Nan::SetMethod (exports, asciiString ( " setOption" ). c_str () , setOption);
743- Nan::SetMethod (exports, asciiString ( " start" ). c_str () , start);
744- Nan::SetMethod (exports, asciiString ( " spath" ). c_str () , spath);
745- Nan::SetMethod (exports, asciiString ( " stop" ). c_str () , stop);
746- Nan::SetMethod (exports, asciiString ( " localConnect" ). c_str () , localConnect);
747- Nan::SetMethod (exports, asciiString ( " nativeEmit" ). c_str () , nativeEmit);
748- Nan::SetMethod (exports, asciiString ( " sendControlCommand" ). c_str () , sendControlCommand);
712+ Nan::SetMethod (exports, " getOption" , getOption);
713+ Nan::SetMethod (exports, " setOption" , setOption);
714+ Nan::SetMethod (exports, " start" , start);
715+ Nan::SetMethod (exports, " spath" , spath);
716+ Nan::SetMethod (exports, " stop" , stop);
717+ Nan::SetMethod (exports, " localConnect" , localConnect);
718+ Nan::SetMethod (exports, " nativeEmit" , nativeEmit);
719+ Nan::SetMethod (exports, " sendControlCommand" , sendControlCommand);
749720#if !defined(_ZOS)
750- Nan::SetMethod (exports, asciiString ( " setHeadlessZipFunction" ). c_str () , setHeadlessZipFunction);
721+ Nan::SetMethod (exports, " setHeadlessZipFunction" , setHeadlessZipFunction);
751722#endif
752723#if defined(_LINUX)
753- Nan::SetMethod (exports, asciiString ( " lrtime" ). c_str () , lrtime);
724+ Nan::SetMethod (exports, " lrtime" , lrtime);
754725#endif
755726#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
756- Nan::SetMethod (exports, asciiString ( " getObjectHistogram" ). c_str () , getObjectHistogram);
727+ Nan::SetMethod (exports, " getObjectHistogram" , getObjectHistogram);
757728#endif
758729 /*
759730 * Initialize healthcenter core library
760731 */
761732 applicationDir = findApplicationDir ();
762733 appmetricsDir = getModuleDir (module );
763734 if (!initLoaderApi ()) {
764- Nan::ThrowError (asciiString ( " Failed to initialize Agent Core library" ). c_str () );
735+ Nan::ThrowError (" Failed to initialize Agent Core library" );
765736 return ;
766737 }
767738 if (!loadProperties ()) {
@@ -783,7 +754,7 @@ void init(Local<Object> exports, Local<Object> module) {
783754 * Log startup message with version information
784755 */
785756 std::stringstream msg;
786- msg << " Node Application Metrics " << APPMETRICS_VERSION << " (Agent Core " << nativeString ( loaderApi->getAgentVersion () ) << " )" ;
757+ msg << " Node Application Metrics " << APPMETRICS_VERSION << " (Agent Core " << loaderApi->getAgentVersion () << " )" ;
787758 loaderApi->logMessage (info, msg.str ().c_str ());
788759}
789760
0 commit comments