1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

OpenBSD patches for ttsnoop.

Mostly adding std:: for strstream interfaces.
This commit is contained in:
Pascal Stumpf 2012-08-11 14:12:47 +02:00 committed by Jon Trulson
parent 76984653b4
commit 43bae997c8
9 changed files with 43 additions and 43 deletions

View file

@ -34,7 +34,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#if defined(linux) #if defined(linux) || defined(CSRG_BASED)
#include <strstream> #include <strstream>
#else #else
#include <strstream.h> #include <strstream.h>
@ -468,7 +468,7 @@ DtTtSetLabel(
) )
{ {
Tt_status status = tt_ptr_error( val ); Tt_status status = tt_ptr_error( val );
ostrstream errStream; std::ostrstream errStream;
errStream << func << " = " << val << " (" << status << ")" << ends; errStream << func << " = " << val << " (" << status << ")" << ends;
char *label = errStream.str(); char *label = errStream.str();
DtTtSetLabel( labelWidget, label ); DtTtSetLabel( labelWidget, label );
@ -483,7 +483,7 @@ DtTtSetLabel(
Tt_status status Tt_status status
) )
{ {
ostrstream errStream; std::ostrstream errStream;
errStream << func << " = " << status << ends; errStream << func << " = " << status << ends;
char *label = errStream.str(); char *label = errStream.str();
DtTtSetLabel( labelWidget, label ); DtTtSetLabel( labelWidget, label );
@ -498,7 +498,7 @@ DtTtSetLabel(
int returnVal int returnVal
) )
{ {
ostrstream errStream; std::ostrstream errStream;
errStream << func << " = " << returnVal << ends; errStream << func << " = " << returnVal << ends;
char *label = errStream.str(); char *label = errStream.str();
DtTtSetLabel( labelWidget, label ); DtTtSetLabel( labelWidget, label );
@ -519,7 +519,7 @@ _DtTtChoices(
return 0; return 0;
} }
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
ostrstream itemStream; std::ostrstream 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 );
@ -566,7 +566,7 @@ _DtTtChoices(
} }
*itemCount = dtTtMessagesCount; *itemCount = dtTtMessagesCount;
for (i = 0; i < dtTtMessagesCount; i++) { for (i = 0; i < dtTtMessagesCount; i++) {
ostrstream itemStream; std::ostrstream 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 ))) {
@ -592,7 +592,7 @@ _DtTtChoices(
} }
*itemCount = dtTtPatternsCount; *itemCount = dtTtPatternsCount;
for (i = 0; i < dtTtPatternsCount; i++) { for (i = 0; i < dtTtPatternsCount; i++) {
ostrstream itemStream; std::ostrstream itemStream;
itemStream << (void *)dtTtPatterns[ i ] << ends; itemStream << (void *)dtTtPatterns[ i ] << ends;
items[ i ] = XmStringCreateLocalized( items[ i ] = XmStringCreateLocalized(
itemStream.str() ); itemStream.str() );
@ -636,11 +636,11 @@ _DtOpen(
) )
{ {
char *file = tempnam( 0, AIX_CONST_STRING tempnamTemplate ); char *file = tempnam( 0, AIX_CONST_STRING tempnamTemplate );
ostrstream cmdStream; std::ostrstream cmdStream;
cmdStream << cmd << " > " << file << ends; cmdStream << cmd << " > " << file << ends;
int sysStat = system( cmdStream.str() ); int sysStat = system( cmdStream.str() );
if (! WIFEXITED( sysStat )) { if (! WIFEXITED( sysStat )) {
ostrstream func; std::ostrstream func;
func << "system( \"" << cmdStream.str() << "\" )" << ends; func << "system( \"" << cmdStream.str() << "\" )" << ends;
DtTtSetLabel( label, func.str(), sysStat ); DtTtSetLabel( label, func.str(), sysStat );
delete cmdStream.str(); delete cmdStream.str();
@ -662,12 +662,12 @@ _DtOpen(
const char * file const char * file
) )
{ {
ostrstream labelStream; std::ostrstream labelStream;
labelStream << "dtaction Open " << file << ends; labelStream << "dtaction Open " << file << ends;
DtTtSetLabel( label, labelStream.str() ); DtTtSetLabel( label, labelStream.str() );
delete labelStream.str(); delete labelStream.str();
ostrstream cmd; std::ostrstream 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;
@ -699,12 +699,12 @@ _DtMan(
const char * topic const char * topic
) )
{ {
ostrstream labelStream; std::ostrstream labelStream;
labelStream << "dtaction Dtmanpageview " << topic << ends; labelStream << "dtaction Dtmanpageview " << topic << ends;
DtTtSetLabel( label, labelStream.str() ); DtTtSetLabel( label, labelStream.str() );
delete labelStream.str(); delete labelStream.str();
ostrstream cmd; std::ostrstream 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() );

View file

@ -40,7 +40,7 @@
*** Add include files, types, macros, externs, and user functions here. *** Add include files, types, macros, externs, and user functions here.
***/ ***/
#if defined(linux) #if defined(linux) || defined(CSRG_BASED)
#include <fstream> #include <fstream>
#include <strstream> #include <strstream>
#else #else
@ -50,7 +50,7 @@
#include "DtTt.h" #include "DtTt.h"
extern ofstream snoopStream; extern std::ofstream snoopStream;
typedef enum { typedef enum {
DoJustPrint, DoJustPrint,

View file

@ -39,7 +39,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <Xm/TextF.h> #include <Xm/TextF.h>
#if defined(linux) #if defined(linux) || defined(CSRG_BASED)
#include <fstream> #include <fstream>
#include <strstream> #include <strstream>
#else #else
@ -61,7 +61,7 @@ extern XtPointer _XmStringUngenerate (XmString string,
XmTextType output_type); XmTextType output_type);
} }
extern ofstream snoopStream; extern std::ofstream snoopStream;
extern int globalTimeout; extern int globalTimeout;
typedef struct _FileChooserInfo { typedef struct _FileChooserInfo {
@ -217,7 +217,7 @@ fileOkayed(
XtVaGetValues( instance->fchooser, XmNuserData, &xtPtr, 0 ); XtVaGetValues( instance->fchooser, XmNuserData, &xtPtr, 0 );
FileChooserInfo *info = (FileChooserInfo *)xtPtr; FileChooserInfo *info = (FileChooserInfo *)xtPtr;
Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label; Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
ostrstream script; std::ostrstream script;
switch (info->choice) { switch (info->choice) {
Tt_pattern *pats; Tt_pattern *pats;
Tt_message msg; Tt_message msg;
@ -305,7 +305,7 @@ fileOkayed(
break; break;
} }
if (WEXITSTATUS( ival ) != 0) { if (WEXITSTATUS( ival ) != 0) {
ostrstream diagnosis; std::ostrstream 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() );

View file

@ -40,7 +40,7 @@
*** Add include files, types, macros, externs, and user functions here. *** Add include files, types, macros, externs, and user functions here.
***/ ***/
#if defined(linux) #if defined(linux) || defined(CSRG_BASED)
#include <strstream> #include <strstream>
#else #else
#include <strstream.h> #include <strstream.h>
@ -620,7 +620,7 @@ DtTtMessageWidgetCreate(
} }
} }
ostrstream labelStream; std::ostrstream labelStream;
labelStream << "Tt_message " << (void *)msg; labelStream << "Tt_message " << (void *)msg;
XtVaSetValues( instance->messageProps, XtVaSetValues( instance->messageProps,
XmNtitle, labelStream.str(), XmNtitle, labelStream.str(),
@ -1408,7 +1408,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 ***/
ostrstream action; // XXX when to delete .str()? std::ostrstream action; // XXX when to delete .str()?
DtbMessagePropsMessagePropsInfo instance = DtbMessagePropsMessagePropsInfo instance =
(DtbMessagePropsMessagePropsInfo)clientData; (DtbMessagePropsMessagePropsInfo)clientData;
Tt_message msg = messageProps2Msg( instance ); Tt_message msg = messageProps2Msg( instance );
@ -1475,7 +1475,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 ***/
ostrstream code; // XXX when to delete .str()? std::ostrstream code; // XXX when to delete .str()?
DtbMessagePropsMessagePropsInfo instance = DtbMessagePropsMessagePropsInfo instance =
(DtbMessagePropsMessagePropsInfo)clientData; (DtbMessagePropsMessagePropsInfo)clientData;
Tt_message msg = messageProps2Msg( instance ); Tt_message msg = messageProps2Msg( instance );
@ -1878,7 +1878,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 ***/
ostrstream ptype; // XXX when to delete .str()? std::ostrstream ptype; // XXX when to delete .str()?
DtbMessagePropsMessagePropsInfo instance = DtbMessagePropsMessagePropsInfo instance =
(DtbMessagePropsMessagePropsInfo)clientData; (DtbMessagePropsMessagePropsInfo)clientData;
Tt_message msg = messageProps2Msg( instance ); Tt_message msg = messageProps2Msg( instance );

View file

@ -40,7 +40,7 @@
*** Add include files, types, macros, externs, and user functions here. *** Add include files, types, macros, externs, and user functions here.
***/ ***/
#if defined(linux) #if defined(linux) || defined(CSRG_BASED)
#include <strstream> #include <strstream>
#else #else
#include <strstream.h> #include <strstream.h>
@ -371,7 +371,7 @@ DtTtPatternWidgetCreate(
} }
} }
ostrstream labelStream; std::ostrstream 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(),

View file

@ -42,7 +42,7 @@
#include <Xm/TextF.h> #include <Xm/TextF.h>
#if defined(linux) #if defined(linux) || defined(CSRG_BASED)
#include <fstream> #include <fstream>
#include <strstream> #include <strstream>
#else #else
@ -52,7 +52,7 @@
#include "DtTt.h" #include "DtTt.h"
extern ofstream snoopStream; extern std::ofstream snoopStream;
void void
_DtSessionChooserSet( _DtSessionChooserSet(

View file

@ -42,7 +42,7 @@
#include <stdio.h> #include <stdio.h>
#if defined(linux) #if defined(linux) || defined(CSRG_BASED)
#include <strstream> #include <strstream>
#else #else
#include <strstream.h> #include <strstream.h>
@ -213,7 +213,7 @@ _DtTtChooserSet(
XmTextFieldSetString( instance->chooserText, 0 ); XmTextFieldSetString( instance->chooserText, 0 );
XtVaSetValues( instance->chooser, XmNtitle, title, 0 ); XtVaSetValues( instance->chooser, XmNtitle, title, 0 );
ostrstream valuesStream; std::ostrstream valuesStream;
valuesStream << itemCount << " " << valuesLabel; valuesStream << itemCount << " " << valuesLabel;
if (itemCount != 1) valuesStream << "s"; if (itemCount != 1) valuesStream << "s";
valuesStream << ends; valuesStream << ends;
@ -314,7 +314,7 @@ choiceSelected(
break; break;
} }
void *entity = DtTtNth( type, info->item_position - 1 ); void *entity = DtTtNth( type, info->item_position - 1 );
ostrstream entityName; std::ostrstream entityName;
if (isString) { if (isString) {
entityName << (char *)entity << ends; entityName << (char *)entity << ends;
} else { } else {

View file

@ -63,7 +63,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <time.h> #include <time.h>
#if defined(linux) #if defined(linux) || defined(CSRG_BASED)
#include <iostream> #include <iostream>
#include <strstream> #include <strstream>
#include <fstream> #include <fstream>
@ -112,8 +112,8 @@ unsigned int snoopedArgsCount = 0;
char * optTraceScript = 0; char * optTraceScript = 0;
String apiTracerArgv[ 10 ]; String apiTracerArgv[ 10 ];
String snooperArgv[ 10 ]; String snooperArgv[ 10 ];
ostrstream tttraceCmd; std::ostrstream tttraceCmd;
ofstream snoopStream; std::ofstream snoopStream;
// Xt squats on -tf ?! XXX // Xt squats on -tf ?! XXX
const char Usage[] = const char Usage[] =
@ -196,7 +196,7 @@ signalHandler(
} }
} }
#if defined(SVR4) || defined(aix) || defined(hpux) || defined(__osf__) || defined(linux) #if defined(SVR4) || defined(aix) || defined(hpux) || defined(__osf__) || defined(linux) || defined(CSRG_BASED)
#if !defined(SIG_PF) #if !defined(SIG_PF)
typedef void (*sig_pf_t)(int); typedef void (*sig_pf_t)(int);
#define SIG_PF sig_pf_t #define SIG_PF sig_pf_t
@ -208,7 +208,7 @@ _tt_sigset(
int sig, int sig,
SIG_PF handler ) SIG_PF handler )
{ {
#if defined(hpux) || defined(linux) #if defined(hpux) || defined(linux) || defined(CSRG_BASED)
struct sigaction act; struct sigaction act;
act.sa_handler = handler; act.sa_handler = handler;
sigemptyset(&act.sa_mask); sigemptyset(&act.sa_mask);
@ -670,7 +670,7 @@ main(int argc, char **argv)
} }
Tt_status status; Tt_status status;
snoopStream.open( snoopFile, ios::app ); snoopStream.open( snoopFile, ios::app );
ostrstream envStr; std::ostrstream envStr;
envStr << "TT_TRACE_SCRIPT=> "; envStr << "TT_TRACE_SCRIPT=> ";
envStr << traceFile << ends; envStr << traceFile << ends;
traceScript = envStr.str(); traceScript = envStr.str();

View file

@ -37,7 +37,7 @@
#include <unistd.h> #include <unistd.h>
#if defined(linux) #if defined(linux) || defined(CSRG_BASED)
#include <fstream> #include <fstream>
#include <strstream> #include <strstream>
#else #else
@ -50,7 +50,7 @@
extern "C" { const char *_tt_lib_version; }; extern "C" { const char *_tt_lib_version; };
extern ofstream snoopStream; extern std::ofstream snoopStream;
extern unsigned int globalSaveLines; extern unsigned int globalSaveLines;
extern char * traceScript; extern char * traceScript;
extern const char * globalVersionString; extern const char * globalVersionString;
@ -93,7 +93,7 @@ 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;
ostrstream tttraceCmd; std::ostrstream 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 &";
@ -659,7 +659,7 @@ 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;
ostrstream advice; std::ostrstream advice;
advice << "pause(); /* kill -CONT " << getpid() << " */"; advice << "pause(); /* kill -CONT " << getpid() << " */";
DtTtSetLabel( instance->ttsnoopWin_label, advice.str() ); DtTtSetLabel( instance->ttsnoopWin_label, advice.str() );
delete advice.str(); delete advice.str();
@ -667,7 +667,7 @@ libcPause(
// //
// run "(if dterror.ds blah blah; then kill -CONT pid; fi)&" // run "(if dterror.ds blah blah; then kill -CONT pid; fi)&"
// //
ostrstream script; std::ostrstream script;
script << "(if dterror.ds "; script << "(if dterror.ds ";
// arg 1: text // arg 1: text
script << "\"kill -CONT " << getpid() << "\" "; script << "\"kill -CONT " << getpid() << "\" ";
@ -1343,7 +1343,7 @@ toggleSnooping(
if (! tt_is_err( status )) { if (! tt_is_err( status )) {
snoopPatIsRegistered = ! snoopPatIsRegistered; snoopPatIsRegistered = ! snoopPatIsRegistered;
} }
ostrstream stream; std::ostrstream stream;
stream << func << (void *)snoopPat << ")" << ends; stream << func << (void *)snoopPat << ")" << ends;
DtTtSetLabel( instance->ttsnoopWin_label, stream.str(), status ); DtTtSetLabel( instance->ttsnoopWin_label, stream.str(), status );
delete stream.str(); delete stream.str();