mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
ttsnoop: drag into a modern C++ century
This program has never worked very well, and it may still not work very well. This commit removes the ancient C++ headers and uses modern replacements with some changes required due to the different interfaces. It builds a lot cleaner, and no longer does stupid things like deleteing char *, ostream.str()'s, and the like. This program could be really useful if it worked well. Some thought should be givien in the future to decouple this SW from dtappbuilder and maybe just rewrite from scratch.
This commit is contained in:
parent
780ec11b8a
commit
af6c2fd881
10 changed files with 72 additions and 145 deletions
|
@ -34,11 +34,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
#include <sstream>
|
||||||
#include <strstream>
|
|
||||||
#else
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Xm/TextF.h>
|
#include <Xm/TextF.h>
|
||||||
#include <Dt/SpinBox.h>
|
#include <Dt/SpinBox.h>
|
||||||
|
@ -468,11 +464,10 @@ DtTtSetLabel(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Tt_status status = tt_ptr_error( val );
|
Tt_status status = tt_ptr_error( val );
|
||||||
std::ostrstream errStream;
|
std::ostringstream errStream;
|
||||||
errStream << func << " = " << val << " (" << status << ")" << ends;
|
errStream << func << " = " << val << " (" << status << ")" << ends;
|
||||||
char *label = errStream.str();
|
const char *label = errStream.str().c_str();
|
||||||
DtTtSetLabel( labelWidget, label );
|
DtTtSetLabel( labelWidget, label );
|
||||||
delete label;
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,11 +478,10 @@ DtTtSetLabel(
|
||||||
Tt_status status
|
Tt_status status
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::ostrstream errStream;
|
std::ostringstream errStream;
|
||||||
errStream << func << " = " << status << ends;
|
errStream << func << " = " << status << ends;
|
||||||
char *label = errStream.str();
|
const char *label = errStream.str().c_str();
|
||||||
DtTtSetLabel( labelWidget, label );
|
DtTtSetLabel( labelWidget, label );
|
||||||
delete label;
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,11 +492,10 @@ DtTtSetLabel(
|
||||||
int returnVal
|
int returnVal
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::ostrstream errStream;
|
std::ostringstream errStream;
|
||||||
errStream << func << " = " << returnVal << ends;
|
errStream << func << " = " << returnVal << ends;
|
||||||
char *label = errStream.str();
|
const char *label = errStream.str().c_str();
|
||||||
DtTtSetLabel( labelWidget, label );
|
DtTtSetLabel( labelWidget, label );
|
||||||
delete label;
|
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +512,7 @@ _DtTtChoices(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
std::ostrstream itemStream;
|
std::ostringstream itemStream;
|
||||||
itemStream << (void *)pPats[ i ];
|
itemStream << (void *)pPats[ i ];
|
||||||
char *name = (char *)
|
char *name = (char *)
|
||||||
tt_pattern_user( *pPats[ i ], _DtTtPatsNameKey );
|
tt_pattern_user( *pPats[ i ], _DtTtPatsNameKey );
|
||||||
|
@ -528,9 +521,8 @@ _DtTtChoices(
|
||||||
tt_free( name );
|
tt_free( name );
|
||||||
}
|
}
|
||||||
itemStream << ends;
|
itemStream << ends;
|
||||||
char *string = itemStream.str();
|
char *string = const_cast<char *>(itemStream.str().c_str());
|
||||||
items[ i ] = XmStringCreateLocalized( string );
|
items[ i ] = XmStringCreateLocalized( string );
|
||||||
delete string;
|
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -566,7 +558,7 @@ _DtTtChoices(
|
||||||
}
|
}
|
||||||
*itemCount = dtTtMessagesCount;
|
*itemCount = dtTtMessagesCount;
|
||||||
for (i = 0; i < dtTtMessagesCount; i++) {
|
for (i = 0; i < dtTtMessagesCount; i++) {
|
||||||
std::ostrstream itemStream;
|
std::ostringstream itemStream;
|
||||||
itemStream << (void *)dtTtMessages[ i ];
|
itemStream << (void *)dtTtMessages[ i ];
|
||||||
char *op = tt_message_op( dtTtMessages[ i ] );
|
char *op = tt_message_op( dtTtMessages[ i ] );
|
||||||
if (! tt_is_err( tt_ptr_error( op ))) {
|
if (! tt_is_err( tt_ptr_error( op ))) {
|
||||||
|
@ -579,9 +571,8 @@ _DtTtChoices(
|
||||||
tt_free( id );
|
tt_free( id );
|
||||||
}
|
}
|
||||||
itemStream << ends;
|
itemStream << ends;
|
||||||
char *string = itemStream.str();
|
char *string = const_cast<char *>(itemStream.str().c_str());
|
||||||
items[ i ] = XmStringCreateLocalized( string );
|
items[ i ] = XmStringCreateLocalized( string );
|
||||||
delete string;
|
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
case DTTT_PATTERN:
|
case DTTT_PATTERN:
|
||||||
|
@ -592,11 +583,10 @@ _DtTtChoices(
|
||||||
}
|
}
|
||||||
*itemCount = dtTtPatternsCount;
|
*itemCount = dtTtPatternsCount;
|
||||||
for (i = 0; i < dtTtPatternsCount; i++) {
|
for (i = 0; i < dtTtPatternsCount; i++) {
|
||||||
std::ostrstream itemStream;
|
std::ostringstream itemStream;
|
||||||
itemStream << (void *)dtTtPatterns[ i ] << ends;
|
itemStream << (void *)dtTtPatterns[ i ] << ends;
|
||||||
items[ i ] = XmStringCreateLocalized(
|
items[ i ] = XmStringCreateLocalized(
|
||||||
itemStream.str() );
|
const_cast<char *>(itemStream.str().c_str()) );
|
||||||
delete itemStream.str();
|
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
case DTTT_DTSESSION:
|
case DTTT_DTSESSION:
|
||||||
|
@ -636,23 +626,19 @@ _DtOpen(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
char *file = tempnam( 0, AIX_CONST_STRING tempnamTemplate );
|
char *file = tempnam( 0, AIX_CONST_STRING tempnamTemplate );
|
||||||
std::ostrstream cmdStream;
|
std::ostringstream cmdStream;
|
||||||
cmdStream << cmd << " > " << file << ends;
|
cmdStream << cmd << " > " << file << ends;
|
||||||
int sysStat = system( cmdStream.str() );
|
int sysStat = system( cmdStream.str().c_str() );
|
||||||
if (! WIFEXITED( sysStat )) {
|
if (! WIFEXITED( sysStat )) {
|
||||||
std::ostrstream func;
|
std::ostringstream func;
|
||||||
func << "system( \"" << cmdStream.str() << "\" )" << ends;
|
func << "system( \"" << cmdStream.str() << "\" )" << ends;
|
||||||
DtTtSetLabel( label, func.str(), sysStat );
|
DtTtSetLabel( label, func.str().c_str(), sysStat );
|
||||||
delete cmdStream.str();
|
|
||||||
delete func.str();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (WEXITSTATUS( sysStat ) != 0) {
|
if (WEXITSTATUS( sysStat ) != 0) {
|
||||||
DtTtSetLabel( label, cmdStream.str(), WEXITSTATUS( sysStat ));
|
DtTtSetLabel( label, cmdStream.str().c_str(), WEXITSTATUS( sysStat ));
|
||||||
delete cmdStream.str();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete cmdStream.str();
|
|
||||||
_DtOpen( label, file );
|
_DtOpen( label, file );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,17 +648,15 @@ _DtOpen(
|
||||||
const char * file
|
const char * file
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::ostrstream labelStream;
|
std::ostringstream labelStream;
|
||||||
labelStream << "dtaction Open " << file << ends;
|
labelStream << "dtaction Open " << file << ends;
|
||||||
DtTtSetLabel( label, labelStream.str() );
|
DtTtSetLabel( label, labelStream.str().c_str() );
|
||||||
delete labelStream.str();
|
|
||||||
|
|
||||||
std::ostrstream cmd;
|
std::ostringstream cmd;
|
||||||
cmd << "( unset TT_TRACE_SCRIPT; if dtaction Open " << file
|
cmd << "( unset TT_TRACE_SCRIPT; if dtaction Open " << file
|
||||||
<< "; then :; else textedit " << file << "; fi; sleep 600; rm -f "
|
<< "; then :; else textedit " << file << "; fi; sleep 600; rm -f "
|
||||||
<< file << " ) &" << ends;
|
<< file << " ) &" << ends;
|
||||||
system( cmd.str() );
|
system( cmd.str().c_str() );
|
||||||
delete cmd.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -699,16 +683,14 @@ _DtMan(
|
||||||
const char * topic
|
const char * topic
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::ostrstream labelStream;
|
std::ostringstream labelStream;
|
||||||
labelStream << "dtaction Dtmanpageview " << topic << ends;
|
labelStream << "dtaction Dtmanpageview " << topic << ends;
|
||||||
DtTtSetLabel( label, labelStream.str() );
|
DtTtSetLabel( label, labelStream.str().c_str() );
|
||||||
delete labelStream.str();
|
|
||||||
|
|
||||||
std::ostrstream cmd;
|
std::ostringstream cmd;
|
||||||
cmd << "unset TT_TRACE_SCRIPT; if dtaction Dtmanpageview " << topic
|
cmd << "unset TT_TRACE_SCRIPT; if dtaction Dtmanpageview " << topic
|
||||||
<< "; then :; else cmdtool -c man " << topic << "; fi &" << ends;
|
<< "; then :; else cmdtool -c man " << topic << "; fi &" << ends;
|
||||||
system( cmd.str() );
|
system( cmd.str().c_str() );
|
||||||
delete cmd.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean
|
Boolean
|
||||||
|
|
|
@ -41,13 +41,8 @@
|
||||||
*** Add include files, types, macros, externs, and user functions here.
|
*** Add include files, types, macros, externs, and user functions here.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <strstream>
|
#include <sstream>
|
||||||
#else
|
|
||||||
#include <fstream.h>
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "DtTt.h"
|
#include "DtTt.h"
|
||||||
|
|
||||||
|
|
|
@ -39,13 +39,8 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <Xm/TextF.h>
|
#include <Xm/TextF.h>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <strstream>
|
#include <sstream>
|
||||||
#else
|
|
||||||
#include <fstream.h>
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "DtTt.h"
|
#include "DtTt.h"
|
||||||
#include "ttsnoop_ui.h"
|
#include "ttsnoop_ui.h"
|
||||||
|
@ -217,7 +212,7 @@ fileOkayed(
|
||||||
XtVaGetValues( instance->fchooser, XmNuserData, &xtPtr, NULL );
|
XtVaGetValues( instance->fchooser, XmNuserData, &xtPtr, NULL );
|
||||||
FileChooserInfo *info = (FileChooserInfo *)xtPtr;
|
FileChooserInfo *info = (FileChooserInfo *)xtPtr;
|
||||||
Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
|
Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
|
||||||
std::ostrstream script;
|
std::ostringstream script;
|
||||||
switch (info->choice) {
|
switch (info->choice) {
|
||||||
Tt_pattern *pats;
|
Tt_pattern *pats;
|
||||||
Tt_message msg;
|
Tt_message msg;
|
||||||
|
@ -297,19 +292,17 @@ fileOkayed(
|
||||||
script << "numChars=`tt_type_comp -p \"" << path;
|
script << "numChars=`tt_type_comp -p \"" << path;
|
||||||
script << "\" | wc -c`; if [ $numChars = 0 ]; "
|
script << "\" | wc -c`; if [ $numChars = 0 ]; "
|
||||||
"then exit 1; else exit 0; fi" << endl;
|
"then exit 1; else exit 0; fi" << endl;
|
||||||
ival = system( script.str() );
|
ival = system( script.str().c_str() );
|
||||||
delete script.str();
|
|
||||||
if (! WIFEXITED( ival )) {
|
if (! WIFEXITED( ival )) {
|
||||||
DtTtSetLabel( label,
|
DtTtSetLabel( label,
|
||||||
"system( \"tt_type_comp -p\" )", ival );
|
"system( \"tt_type_comp -p\" )", ival );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (WEXITSTATUS( ival ) != 0) {
|
if (WEXITSTATUS( ival ) != 0) {
|
||||||
std::ostrstream diagnosis;
|
std::ostringstream diagnosis;
|
||||||
diagnosis << "tt_type_comp -p: syntax error in "
|
diagnosis << "tt_type_comp -p: syntax error in "
|
||||||
<< path << ends;
|
<< path << ends;
|
||||||
DtTtSetLabel( label, diagnosis.str() );
|
DtTtSetLabel( label, diagnosis.str().c_str() );
|
||||||
delete diagnosis.str();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sess = tt_default_session();
|
sess = tt_default_session();
|
||||||
|
|
|
@ -41,11 +41,7 @@
|
||||||
*** Add include files, types, macros, externs, and user functions here.
|
*** Add include files, types, macros, externs, and user functions here.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
#include <sstream>
|
||||||
#include <strstream>
|
|
||||||
#else
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Xm/TextF.h>
|
#include <Xm/TextF.h>
|
||||||
#include <Dt/SpinBox.h>
|
#include <Dt/SpinBox.h>
|
||||||
|
@ -621,12 +617,11 @@ DtTtMessageWidgetCreate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostrstream labelStream;
|
std::ostringstream labelStream;
|
||||||
labelStream << "Tt_message " << (void *)msg;
|
labelStream << "Tt_message " << (void *)msg;
|
||||||
XtVaSetValues( instance->messageProps,
|
XtVaSetValues( instance->messageProps,
|
||||||
XmNtitle, labelStream.str(),
|
XmNtitle, labelStream.str().c_str(),
|
||||||
NULL );
|
NULL );
|
||||||
delete labelStream.str();
|
|
||||||
|
|
||||||
_DtTtMessageWidgetUpdate( instance, msg, _DtTtMessageFullUpdate );
|
_DtTtMessageWidgetUpdate( instance, msg, _DtTtMessageFullUpdate );
|
||||||
|
|
||||||
|
@ -1409,7 +1404,7 @@ msgGenAction(
|
||||||
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
||||||
|
|
||||||
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
||||||
std::ostrstream action; // XXX when to delete .str()?
|
std::ostringstream action;
|
||||||
DtbMessagePropsMessagePropsInfo instance =
|
DtbMessagePropsMessagePropsInfo instance =
|
||||||
(DtbMessagePropsMessagePropsInfo)clientData;
|
(DtbMessagePropsMessagePropsInfo)clientData;
|
||||||
Tt_message msg = messageProps2Msg( instance );
|
Tt_message msg = messageProps2Msg( instance );
|
||||||
|
@ -1457,10 +1452,9 @@ msgGenAction(
|
||||||
}
|
}
|
||||||
// XXX emit commented warnings for e.g. TT_OFFER, TT_HANDLER
|
// XXX emit commented warnings for e.g. TT_OFFER, TT_HANDLER
|
||||||
action << "}\n";
|
action << "}\n";
|
||||||
// XtVaSetValues( instance->messageText, XmNvalue, action.str(), 0 );
|
// XtVaSetValues( instance->messageText, XmNvalue, action.str().c_str(), 0 );
|
||||||
_DtOpen( instance->messageFooterLabel, (void *)action.str(),
|
_DtOpen( instance->messageFooterLabel, (void *)action.str().c_str(),
|
||||||
action.pcount(), "actio" );
|
action.str().size(), "actio" );
|
||||||
delete action.str();
|
|
||||||
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1476,7 +1470,7 @@ msgGenC(
|
||||||
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
||||||
|
|
||||||
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
||||||
std::ostrstream code; // XXX when to delete .str()?
|
std::ostringstream code;
|
||||||
DtbMessagePropsMessagePropsInfo instance =
|
DtbMessagePropsMessagePropsInfo instance =
|
||||||
(DtbMessagePropsMessagePropsInfo)clientData;
|
(DtbMessagePropsMessagePropsInfo)clientData;
|
||||||
Tt_message msg = messageProps2Msg( instance );
|
Tt_message msg = messageProps2Msg( instance );
|
||||||
|
@ -1602,10 +1596,9 @@ msgGenC(
|
||||||
code << "}\n";
|
code << "}\n";
|
||||||
}
|
}
|
||||||
tt_free( op );
|
tt_free( op );
|
||||||
// XtVaSetValues( instance->messageText, XmNvalue, code.str(), 0 );
|
// XtVaSetValues( instance->messageText, XmNvalue, code.str().c_str(), 0 );
|
||||||
_DtOpen( instance->messageFooterLabel, (void *)code.str(),
|
_DtOpen( instance->messageFooterLabel, (void *)code.str().c_str(),
|
||||||
code.pcount(), "msgC" );
|
code.str().size(), "msgC" );
|
||||||
delete code.str();
|
|
||||||
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1879,7 +1872,7 @@ genObserver(
|
||||||
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
||||||
|
|
||||||
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
||||||
std::ostrstream ptype; // XXX when to delete .str()?
|
std::ostringstream ptype;
|
||||||
DtbMessagePropsMessagePropsInfo instance =
|
DtbMessagePropsMessagePropsInfo instance =
|
||||||
(DtbMessagePropsMessagePropsInfo)clientData;
|
(DtbMessagePropsMessagePropsInfo)clientData;
|
||||||
Tt_message msg = messageProps2Msg( instance );
|
Tt_message msg = messageProps2Msg( instance );
|
||||||
|
@ -1941,10 +1934,9 @@ genObserver(
|
||||||
ptype << "\t\t\t) => start opnum=1;\n";
|
ptype << "\t\t\t) => start opnum=1;\n";
|
||||||
ptype << "};\n";
|
ptype << "};\n";
|
||||||
// XXX contexts
|
// XXX contexts
|
||||||
// XtVaSetValues( instance->messageText, XmNvalue, ptype.str(), 0 );
|
// XtVaSetValues( instance->messageText, XmNvalue, ptype.str().c_str(), 0 );
|
||||||
_DtOpen( instance->messageFooterLabel, (void *)ptype.str(),
|
_DtOpen( instance->messageFooterLabel, (void *)ptype.str().c_str(),
|
||||||
ptype.pcount(), "ptype" );
|
ptype.str().size(), "ptype" );
|
||||||
delete ptype.str();
|
|
||||||
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,7 @@
|
||||||
*** Add include files, types, macros, externs, and user functions here.
|
*** Add include files, types, macros, externs, and user functions here.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
#include <sstream>
|
||||||
#include <strstream>
|
|
||||||
#else
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Tt/tttk.h>
|
#include <Tt/tttk.h>
|
||||||
#include "DtTt.h"
|
#include "DtTt.h"
|
||||||
|
@ -372,12 +368,11 @@ DtTtPatternWidgetCreate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostrstream labelStream;
|
std::ostringstream labelStream;
|
||||||
labelStream << "Tt_pattern " << (void *)pat << ends;
|
labelStream << "Tt_pattern " << (void *)pat << ends;
|
||||||
XtVaSetValues( instance->patternProps,
|
XtVaSetValues( instance->patternProps,
|
||||||
XmNtitle, labelStream.str(),
|
XmNtitle, labelStream.str().c_str(),
|
||||||
NULL );
|
NULL );
|
||||||
delete labelStream.str();
|
|
||||||
|
|
||||||
_DtTtPatternWidgetUpdate( instance, pat );
|
_DtTtPatternWidgetUpdate( instance, pat );
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,8 @@
|
||||||
|
|
||||||
#include <Xm/TextF.h>
|
#include <Xm/TextF.h>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <strstream>
|
#include <sstream>
|
||||||
#else
|
|
||||||
#include <fstream.h>
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "DtTt.h"
|
#include "DtTt.h"
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,7 @@
|
||||||
|
|
||||||
#include <Xm/TextF.h>
|
#include <Xm/TextF.h>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#else
|
|
||||||
#include <fstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "DtTt.h"
|
#include "DtTt.h"
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
#include <sstream>
|
||||||
#include <strstream>
|
|
||||||
#else
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Xm/TextF.h>
|
#include <Xm/TextF.h>
|
||||||
#include <Xm/List.h>
|
#include <Xm/List.h>
|
||||||
|
@ -214,12 +210,11 @@ _DtTtChooserSet(
|
||||||
XmTextFieldSetString( instance->chooserText, 0 );
|
XmTextFieldSetString( instance->chooserText, 0 );
|
||||||
XtVaSetValues( instance->chooser, XmNtitle, title, NULL );
|
XtVaSetValues( instance->chooser, XmNtitle, title, NULL );
|
||||||
|
|
||||||
std::ostrstream valuesStream;
|
std::ostringstream valuesStream;
|
||||||
valuesStream << itemCount << " " << valuesLabel;
|
valuesStream << itemCount << " " << valuesLabel;
|
||||||
if (itemCount != 1) valuesStream << "s";
|
if (itemCount != 1) valuesStream << "s";
|
||||||
valuesStream << ends;
|
valuesStream << ends;
|
||||||
DtTtSetLabel( instance->chooserList_label, valuesStream.str() );
|
DtTtSetLabel( instance->chooserList_label, valuesStream.str().c_str() );
|
||||||
delete valuesStream.str();
|
|
||||||
|
|
||||||
// Remember dialog mode, entity
|
// Remember dialog mode, entity
|
||||||
XtVaSetValues( instance->chooserOkButton, XmNuserData, choice, NULL );
|
XtVaSetValues( instance->chooserOkButton, XmNuserData, choice, NULL );
|
||||||
|
@ -315,14 +310,13 @@ choiceSelected(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
void *entity = DtTtNth( type, info->item_position - 1 );
|
void *entity = DtTtNth( type, info->item_position - 1 );
|
||||||
std::ostrstream entityName;
|
std::ostringstream entityName;
|
||||||
if (isString) {
|
if (isString) {
|
||||||
entityName << (char *)entity << ends;
|
entityName << (char *)entity << ends;
|
||||||
} else {
|
} else {
|
||||||
entityName << entity << ends;
|
entityName << entity << ends;
|
||||||
}
|
}
|
||||||
XmTextFieldSetString( instance->chooserText, entityName.str() );
|
XmTextFieldSetString( instance->chooserText, const_cast<char *>(entityName.str().c_str()) );
|
||||||
delete entityName.str();
|
|
||||||
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,15 +63,9 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <strstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#else
|
|
||||||
#include <iostream.h>
|
|
||||||
#include <strstream.h>
|
|
||||||
#include <fstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Dt/Term.h>
|
#include <Dt/Term.h>
|
||||||
#include <Tt/tt_c.h>
|
#include <Tt/tt_c.h>
|
||||||
|
@ -95,7 +89,7 @@ char * snoopFile = 0;
|
||||||
Boolean unlinkSnoopFile = True;
|
Boolean unlinkSnoopFile = True;
|
||||||
char * traceFile = 0;
|
char * traceFile = 0;
|
||||||
Boolean unlinkTraceFile = True;
|
Boolean unlinkTraceFile = True;
|
||||||
char * traceScript = 0;
|
const char * traceScript = 0;
|
||||||
int globalTimeout = 20000;
|
int globalTimeout = 20000;
|
||||||
unsigned int globalSaveLines = 5000;
|
unsigned int globalSaveLines = 5000;
|
||||||
const char * globalVersionString = "1.0";
|
const char * globalVersionString = "1.0";
|
||||||
|
@ -112,7 +106,7 @@ unsigned int snoopedArgsCount = 0;
|
||||||
char * optTraceScript = 0;
|
char * optTraceScript = 0;
|
||||||
String apiTracerArgv[ 10 ];
|
String apiTracerArgv[ 10 ];
|
||||||
String snooperArgv[ 10 ];
|
String snooperArgv[ 10 ];
|
||||||
std::ostrstream tttraceCmd;
|
std::ostringstream tttraceCmd;
|
||||||
std::ofstream snoopStream;
|
std::ofstream snoopStream;
|
||||||
|
|
||||||
// Xt squats on -tf ?! XXX
|
// Xt squats on -tf ?! XXX
|
||||||
|
@ -188,7 +182,7 @@ signalHandler(
|
||||||
if ((child > 0) && WIFEXITED( status )) {
|
if ((child > 0) && WIFEXITED( status )) {
|
||||||
snoopStream << endl << endl << "SIGCHLD: WEXITSTATUS=="
|
snoopStream << endl << endl << "SIGCHLD: WEXITSTATUS=="
|
||||||
<< WEXITSTATUS(status) << ": "
|
<< WEXITSTATUS(status) << ": "
|
||||||
<< tttraceCmd.str() << endl << endl;
|
<< tttraceCmd.str().c_str() << endl << endl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SIGCONT:
|
case SIGCONT:
|
||||||
|
@ -666,14 +660,14 @@ main(int argc, char **argv)
|
||||||
installSignalHandler();
|
installSignalHandler();
|
||||||
if (snoopedArgsCount > 0) {
|
if (snoopedArgsCount > 0) {
|
||||||
DtTtSetLabel( dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label,
|
DtTtSetLabel( dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label,
|
||||||
tttraceCmd.str() );
|
tttraceCmd.str().c_str() );
|
||||||
}
|
}
|
||||||
Tt_status status;
|
Tt_status status;
|
||||||
snoopStream.open( snoopFile, ios::app );
|
snoopStream.open( snoopFile, ios::app );
|
||||||
std::ostrstream envStr;
|
std::ostringstream envStr;
|
||||||
envStr << "TT_TRACE_SCRIPT=> ";
|
envStr << "TT_TRACE_SCRIPT=> ";
|
||||||
envStr << traceFile << ends;
|
envStr << traceFile << ends;
|
||||||
traceScript = envStr.str();
|
traceScript = envStr.str().c_str();
|
||||||
if (optImmediateTracing) {
|
if (optImmediateTracing) {
|
||||||
turnOnTracing( 0, 0, 0 );
|
turnOnTracing( 0, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,8 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(CSRG_BASED) || defined(sun)
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <strstream>
|
#include <sstream>
|
||||||
#else
|
|
||||||
#include <fstream.h>
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "apiTracer_ui.h"
|
#include "apiTracer_ui.h"
|
||||||
#include "DtTt.h"
|
#include "DtTt.h"
|
||||||
|
@ -93,13 +88,12 @@ fork_tttrace(
|
||||||
|
|
||||||
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
||||||
DtbTtsnoopTtsnoopWinInfo instance = (DtbTtsnoopTtsnoopWinInfo)clientData;
|
DtbTtsnoopTtsnoopWinInfo instance = (DtbTtsnoopTtsnoopWinInfo)clientData;
|
||||||
std::ostrstream tttraceCmd;
|
std::ostringstream tttraceCmd;
|
||||||
tttraceCmd << "unset TT_TRACE_SCRIPT; dtterm -sb -sl ";
|
tttraceCmd << "unset TT_TRACE_SCRIPT; dtterm -sb -sl ";
|
||||||
tttraceCmd << globalSaveLines;
|
tttraceCmd << globalSaveLines;
|
||||||
tttraceCmd << " -title tttrace -geometry 120x24 -e tttrace &";
|
tttraceCmd << " -title tttrace -geometry 120x24 -e tttrace &";
|
||||||
DtTtSetLabel( instance->ttsnoopWin_label, "tttrace" );
|
DtTtSetLabel( instance->ttsnoopWin_label, "tttrace" );
|
||||||
system( tttraceCmd.str() );
|
system( tttraceCmd.str().c_str() );
|
||||||
delete tttraceCmd.str();
|
|
||||||
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,15 +653,14 @@ libcPause(
|
||||||
|
|
||||||
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
||||||
DtbTtsnoopTtsnoopWinInfo instance = (DtbTtsnoopTtsnoopWinInfo)clientData;
|
DtbTtsnoopTtsnoopWinInfo instance = (DtbTtsnoopTtsnoopWinInfo)clientData;
|
||||||
std::ostrstream advice;
|
std::ostringstream advice;
|
||||||
advice << "pause(); /* kill -CONT " << getpid() << " */";
|
advice << "pause(); /* kill -CONT " << getpid() << " */";
|
||||||
DtTtSetLabel( instance->ttsnoopWin_label, advice.str() );
|
DtTtSetLabel( instance->ttsnoopWin_label, advice.str().c_str() );
|
||||||
delete advice.str();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// run "(if dterror.ds blah blah; then kill -CONT pid; fi)&"
|
// run "(if dterror.ds blah blah; then kill -CONT pid; fi)&"
|
||||||
//
|
//
|
||||||
std::ostrstream script;
|
std::ostringstream script;
|
||||||
script << "(if dterror.ds ";
|
script << "(if dterror.ds ";
|
||||||
// arg 1: text
|
// arg 1: text
|
||||||
script << "\"kill -CONT " << getpid() << "\" ";
|
script << "\"kill -CONT " << getpid() << "\" ";
|
||||||
|
@ -677,8 +670,7 @@ libcPause(
|
||||||
script << "CONT; then ";
|
script << "CONT; then ";
|
||||||
// After confirmation, invoke kill(1)
|
// After confirmation, invoke kill(1)
|
||||||
script << "kill -CONT " << getpid() << "; fi)&";
|
script << "kill -CONT " << getpid() << "; fi)&";
|
||||||
system( script.str() );
|
system( script.str().c_str() );
|
||||||
delete script.str();
|
|
||||||
|
|
||||||
// Run the event loop a few laps, to paint the footer
|
// Run the event loop a few laps, to paint the footer
|
||||||
tttk_block_while( XtWidgetToApplicationContext( widget ), 0, 50 );
|
tttk_block_while( XtWidgetToApplicationContext( widget ), 0, 50 );
|
||||||
|
@ -1343,10 +1335,9 @@ toggleSnooping(
|
||||||
if (! tt_is_err( status )) {
|
if (! tt_is_err( status )) {
|
||||||
snoopPatIsRegistered = ! snoopPatIsRegistered;
|
snoopPatIsRegistered = ! snoopPatIsRegistered;
|
||||||
}
|
}
|
||||||
std::ostrstream stream;
|
std::ostringstream stream;
|
||||||
stream << func << (void *)snoopPat << ")" << ends;
|
stream << func << (void *)snoopPat << ")" << ends;
|
||||||
DtTtSetLabel( instance->ttsnoopWin_label, stream.str(), status );
|
DtTtSetLabel( instance->ttsnoopWin_label, stream.str().c_str(), status );
|
||||||
delete stream.str();
|
|
||||||
DtTtSetLabel( instance->menubar_Snoop_item_Snoop_menu_items.Off_item,
|
DtTtSetLabel( instance->menubar_Snoop_item_Snoop_menu_items.Off_item,
|
||||||
snoopPatIsRegistered ? "Off" : "On" );
|
snoopPatIsRegistered ? "Off" : "On" );
|
||||||
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
||||||
|
|
Loading…
Reference in a new issue