aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreschnett <eschnett@83718e91-0e4f-0410-abf4-91180603181f>2014-03-27 18:04:13 +0000
committereschnett <eschnett@83718e91-0e4f-0410-abf4-91180603181f>2014-03-27 18:04:13 +0000
commitcf31d4fb7306e6e2dd0b1185f1e885f75be4dbf1 (patch)
tree3e9155edf32cac2b1831e3bfee90e29b8a3e78b5
parent93ce33e282f5c94624fb23422b5973ff1707fbc8 (diff)
Replace std::endl by "\n"
git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@246 83718e91-0e4f-0410-abf4-91180603181f
-rw-r--r--src/announce.cc8
-rw-r--r--src/file.cc8
-rw-r--r--src/portal.cc92
-rw-r--r--src/rdf.cc126
-rw-r--r--src/rdf_publisher.cc2
-rw-r--r--src/senddata.cc80
6 files changed, 157 insertions, 159 deletions
diff --git a/src/announce.cc b/src/announce.cc
index 0c1b1ed..b566b04 100644
--- a/src/announce.cc
+++ b/src/announce.cc
@@ -108,7 +108,7 @@ namespace Formaline
string const filenamestring = filenamebuf.str();
ofstream fil;
fil.open (filenamestring.c_str(), ios::trunc);
- fil << get_config_id (cctkGH) << endl;
+ fil << get_config_id (cctkGH) << "\n";
fil.close ();
}
{
@@ -117,7 +117,7 @@ namespace Formaline
string const filenamestring = filenamebuf.str();
ofstream fil;
fil.open (filenamestring.c_str(), ios::trunc);
- fil << get_build_id (cctkGH) << endl;
+ fil << get_build_id (cctkGH) << "\n";
fil.close ();
}
{
@@ -126,7 +126,7 @@ namespace Formaline
string const filenamestring = filenamebuf.str();
ofstream fil;
fil.open (filenamestring.c_str(), ios::trunc);
- fil << get_simulation_id (cctkGH) << endl;
+ fil << get_simulation_id (cctkGH) << "\n";
fil.close ();
}
{
@@ -135,7 +135,7 @@ namespace Formaline
string const filenamestring = filenamebuf.str();
ofstream fil;
fil.open (filenamestring.c_str(), ios::trunc);
- fil << get_run_id (cctkGH) << endl;
+ fil << get_run_id (cctkGH) << "\n";
fil.close ();
}
}
diff --git a/src/file.cc b/src/file.cc
index cc93ca9..fbc1057 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -80,7 +80,7 @@ namespace Formaline
valuebuf << (value ? "yes" : "no");
ostringstream buf;
- buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
+ buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << "\n";
write (buf.str());
}
@@ -99,7 +99,7 @@ namespace Formaline
valuebuf << value;
ostringstream buf;
- buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
+ buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << "\n";
write (buf.str());
}
@@ -120,7 +120,7 @@ namespace Formaline
valuebuf << setprecision(prec) << value;
ostringstream buf;
- buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
+ buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << "\n";
write (buf.str());
}
@@ -140,7 +140,7 @@ namespace Formaline
ostringstream buf;
buf << clean (keybuf.str()) << "="
- << "\"" << clean (valuebuf.str()) << "\"" << endl;
+ << "\"" << clean (valuebuf.str()) << "\"\n";
write (buf.str());
}
diff --git a/src/portal.cc b/src/portal.cc
index f2513c7..b798685 100644
--- a/src/portal.cc
+++ b/src/portal.cc
@@ -116,12 +116,12 @@ namespace Formaline
// Write the script
ostringstream scriptbuf;
scriptbuf
-<< "#! /usr/bin/perl -w" << endl
-<< endl
-<< "use strict;" << endl
-<< "use Socket;" << endl
-<< endl
-<< "my $input = '" << datafilename << "';" << endl
+<< "#! /usr/bin/perl -w\n"
+<< "\n"
+<< "use strict;\n"
+<< "use Socket;\n"
+<< "\n"
+<< "my $input = '" << datafilename << "';\n"
<< "my @hostlist = (";
// NUM_PORTAL_ENTRIES must match the size of the
@@ -132,50 +132,50 @@ namespace Formaline
// add all array parameters which have been set
for (int i = 0; i < NUM_PORTAL_ENTRIES; i++) {
if (*portal_hostname[i]) {
- if (i) scriptbuf << "," << endl << " ";
+ if (i) scriptbuf << ",\n" << " ";
scriptbuf << "'" << portal_hostname[i] << ":" << portal_port[i] << "'";
}
}
scriptbuf
-<< ");" << endl
-<< endl
-<< "foreach my $entry (@hostlist) {" << endl
-<< " next if ($entry !~ /^(.+):(\\d+)$/);" << endl
-<< endl
-<< " my $host = $1;" << endl
-<< " my $port = $2;" << endl
-<< endl
-<< " my $SH;" << endl
-<< endl
-<< " # try to use IO::Socket::INET if the module exists;" << endl
-<< " # it accepts a timeout for its internal connect call" << endl
-<< " eval 'use IO::Socket::INET;" << endl
-<< endl
-<< " $SH = IO::Socket::INET->new (PeerAddr => $host," << endl
-<< " PeerPort => $port," << endl
-<< " Proto => \\'tcp\\'," << endl
-<< " Type => SOCK_STREAM," << endl
-<< " Timeout => 0.2);';" << endl
-<< " # if that failed, fall back to making the standard socket/connect calls" << endl
-<< " # (with their built-in fixed timeout)" << endl
-<< " if ($@) {" << endl
-<< " my $iaddr = inet_aton ($host);" << endl
-<< " next if (not $iaddr);" << endl
-<< "" << endl
-<< " socket ($SH, PF_INET, SOCK_STREAM, getprotobyname ('tcp'));" << endl
-<< " my $sin = sockaddr_in ($port, $iaddr);" << endl
-<< " connect ($SH, $sin) || next;" << endl
-<< " }" << endl
-<< endl
-<< " # send off the data" << endl
-<< " if (defined $SH) {" << endl
-<< " open (my $FH, '<' . $input);" << endl
-<< " print $SH $_ while (<$FH>);" << endl
-<< " close $FH;" << endl
-<< " close $SH;" << endl
-<< " }" << endl
-<< "}" << endl
-<< endl;
+<< ");\n"
+<< "\n"
+<< "foreach my $entry (@hostlist) {\n"
+<< " next if ($entry !~ /^(.+):(\\d+)$/);\n"
+<< "\n"
+<< " my $host = $1;\n"
+<< " my $port = $2;\n"
+<< "\n"
+<< " my $SH;\n"
+<< "\n"
+<< " # try to use IO::Socket::INET if the module exists;\n"
+<< " # it accepts a timeout for its internal connect call\n"
+<< " eval 'use IO::Socket::INET;\n"
+<< "\n"
+<< " $SH = IO::Socket::INET->new (PeerAddr => $host,\n"
+<< " PeerPort => $port,\n"
+<< " Proto => \\'tcp\\',\n"
+<< " Type => SOCK_STREAM,\n"
+<< " Timeout => 0.2);';\n"
+<< " # if that failed, fall back to making the standard socket/connect calls\n"
+<< " # (with their built-in fixed timeout)\n"
+<< " if ($@) {\n"
+<< " my $iaddr = inet_aton ($host);\n"
+<< " next if (not $iaddr);\n"
+<< "\n"
+<< " socket ($SH, PF_INET, SOCK_STREAM, getprotobyname ('tcp'));\n"
+<< " my $sin = sockaddr_in ($port, $iaddr);\n"
+<< " connect ($SH, $sin) || next;\n"
+<< " }\n"
+<< "\n"
+<< " # send off the data\n"
+<< " if (defined $SH) {\n"
+<< " open (my $FH, '<' . $input);\n"
+<< " print $SH $_ while (<$FH>);\n"
+<< " close $FH;\n"
+<< " close $SH;\n"
+<< " }\n"
+<< "}\n"
+<< "\n";
string const scriptstr = scriptbuf.str();
ostringstream scriptfilenamebuf;
diff --git a/src/rdf.cc b/src/rdf.cc
index 5de7c05..be3d278 100644
--- a/src/rdf.cc
+++ b/src/rdf.cc
@@ -121,24 +121,24 @@ namespace Formaline
const string bbhID(clean(static_cast<const char *> (UniqueSimulationID(0))));
const string runID(clean(static_cast<const char *> (UniqueRunID(0))));
- msgbuf << "<cctk:Simulation rdf:about=\"#" << jobID << "\"" << endl
- << "\tcctk:simulationID=\"" << jobID << "\"" << endl
- << "\tcctk:host=\"" << host << "\"" << endl
- << "\tcctk:user=\"" << user << "\"" << endl
- << "\tcctk:executable=\"" << executable << "\"" << endl
- << "\tcctk:version=\"" << version << "\"" << endl
- << "\tcctk:title=\"" << title << "\"" << endl
- << "\tcctk:configID=\"" << configID << "\"" << endl
- << "\tcctk:buildID=\"" << buildID << "\"" << endl
- << "\tcctk:bbhID=\"" << bbhID << "\"" << endl
- << "\tcctk:runID=\"" << runID << "\"" << endl;
+ msgbuf << "<cctk:Simulation rdf:about=\"#" << jobID << "\"\n"
+ << "\tcctk:simulationID=\"" << jobID << "\"\n"
+ << "\tcctk:host=\"" << host << "\"\n"
+ << "\tcctk:user=\"" << user << "\"\n"
+ << "\tcctk:executable=\"" << executable << "\"\n"
+ << "\tcctk:version=\"" << version << "\"\n"
+ << "\tcctk:title=\"" << title << "\"\n"
+ << "\tcctk:configID=\"" << configID << "\"\n"
+ << "\tcctk:buildID=\"" << buildID << "\"\n"
+ << "\tcctk:bbhID=\"" << bbhID << "\"\n"
+ << "\tcctk:runID=\"" << runID << "\"\n";
const char* const pbsJobID = getenv ("PBS_JOBID");
if (pbsJobID) {
- msgbuf << "\tcctk:pbsJobID=\"" << clean (pbsJobID) << "\"" << endl;
+ msgbuf << "\tcctk:pbsJobID=\"" << clean (pbsJobID) << "\"\n";
}
const char* const pbsJobname = getenv ("PBS_JOBNAME");
if (pbsJobname) {
- msgbuf << "\tcctk:pbsJobname=\"" << clean (pbsJobname) << "\"" << endl;
+ msgbuf << "\tcctk:pbsJobname=\"" << clean (pbsJobname) << "\"\n";
}
#if 0
const char* pbsHost = getenv ("PBS_O_HOST");
@@ -160,45 +160,45 @@ namespace Formaline
} else if (strcmp(pbsHost, "damiana.damiana.admin") == 0) {
pbsHost = "damiana.aei.mpg.de";
}
- msgbuf << "\tcctk:pbsHost=\"" << clean (pbsHost) << "\"" << endl;
+ msgbuf << "\tcctk:pbsHost=\"" << clean (pbsHost) << "\"\n";
}
#endif
- msgbuf << "\tcctk:cwd=\"" << cwd << "\">" << endl
+ msgbuf << "\tcctk:cwd=\"" << cwd << "\">\n"
<< "\t<cctk:nProcs rdf:datatype=\"&xsd;integer\">"
- << nprocs << "</cctk:nProcs>" << endl
+ << nprocs << "</cctk:nProcs>\n"
<< "\t<cctk:compiledAt rdf:datatype=\"&xsd;dateTime\">"
- << compiled_at << "</cctk:compiledAt>" << endl
+ << compiled_at << "</cctk:compiledAt>\n"
<< "\t<cctk:startedAt rdf:datatype=\"&xsd;dateTime\">"
- << started_at << "</cctk:startedAt>" << endl
+ << started_at << "</cctk:startedAt>\n"
<< "\t<cctk:lastUpdated rdf:datatype=\"&xsd;dateTime\">"
- << started_at << "</cctk:lastUpdated>" << endl;
+ << started_at << "</cctk:lastUpdated>\n";
//
// metadata as references to other nodes
//
- msgbuf << "\t<cctk:thornList rdf:resource=\"#ThornList\"/>" << endl
- << "\t<cctk:parameterFile rdf:resource=\"#ParameterFile\"/>" << endl
- << "</cctk:Simulation>" << endl << endl;
+ msgbuf << "\t<cctk:thornList rdf:resource=\"#ThornList\"/>\n"
+ << "\t<cctk:parameterFile rdf:resource=\"#ParameterFile\"/>\n"
+ << "</cctk:Simulation>\n\n";
#ifdef ALSO_STORE_THORNLIST_AND_PARAMETERS
// store thorn list
- msgbuf << "<cctk:ThornList rdf:about=\"#ThornList\">" << endl;
+ msgbuf << "<cctk:ThornList rdf:about=\"#ThornList\">\n";
const int numthorns = CCTK_NumCompiledThorns ();
for (int thorn = 0; thorn < numthorns; ++ thorn) {
const char* const thornname = CCTK_CompiledThorn (thorn);
msgbuf << "\t<cctk:thorn rdf:resource=\"#Thorns/"
- << thornname << "\"/>" << endl;
+ << thornname << "\"/>\n";
}
- msgbuf << "</cctk:ThornList>" << endl << endl;
+ msgbuf << "</cctk:ThornList>\n\n";
#endif
// store parameter file name and contents
char parfilebuf[512] = "";
CCTK_ParameterFilename (sizeof (parfilebuf), parfilebuf);
const string parfile = clean (parfilebuf);
- msgbuf << "<cctk:ParameterFile rdf:about=\"#ParameterFile\"" << endl
- << "\tcctk:name=\"" << parfile << "\">" << endl
+ msgbuf << "<cctk:ParameterFile rdf:about=\"#ParameterFile\"\n"
+ << "\tcctk:name=\"" << parfile << "\">\n"
<< "\t<rdf:value>";
ifstream file (parfile.c_str());
char c;
@@ -207,20 +207,20 @@ namespace Formaline
file.close();
msgbuf << clean (filebuf.str());
filebuf.clear();
- msgbuf << "</rdf:value>" << endl
- << "</cctk:ParameterFile>" << endl << endl;
+ msgbuf << "</rdf:value>\n"
+ << "</cctk:ParameterFile>\n\n";
#ifdef ALSO_STORE_THORNLIST_AND_PARAMETERS
// store all parameters which have been set in the parfile
msgbuf
-<< "<!-- ============================================================ -->" << endl
-<< "<!-- thorn graphs with their parameters -->" << endl
-<< "<!-- ============================================================ -->" << endl;
+<< "<!-- ============================================================ -->\n"
+<< "<!-- thorn graphs with their parameters -->\n"
+<< "<!-- ============================================================ -->\n";
ostringstream parambuf;
parambuf
-<< "<!-- ============================================================ -->" << endl
-<< "<!-- list of parameters and their values -->" << endl
-<< "<!-- ============================================================ -->" << endl;
+<< "<!-- ============================================================ -->\n"
+<< "<!-- list of parameters and their values -->\n"
+<< "<!-- ============================================================ -->\n";
const bool list_all_parameters = CCTK_Equals (out_save_parameters, "all");
@@ -228,13 +228,13 @@ namespace Formaline
const char* const thornname = CCTK_CompiledThorn (thorn);
msgbuf << "<cctk:Thorn rdf:about=\"#Thorns/"
- << thornname << "\"" << endl;
- msgbuf << "\tcctk:name=\"" << thornname << "\">" << endl;
+ << thornname << "\"\n";
+ msgbuf << "\tcctk:name=\"" << thornname << "\">\n";
// skip parameters that belong to inactive thorns
const bool is_active = CCTK_IsThornActive (thornname);
msgbuf << "\t<cctk:active rdf:datatype=\"&xsd;boolean\">"
- << (is_active ? "true" : "false") << "</cctk:active>" << endl;
+ << (is_active ? "true" : "false") << "</cctk:active>\n";
// loop over all parameters of this thorn (if it is active)
if (is_active) {
@@ -251,7 +251,7 @@ namespace Formaline
// brackets in array parameter names have to be escaped
msgbuf << "\t<cctk:parameter rdf:resource=\"#Parameters/"
<< pdata->thorn << "/" << cleanURI (pdata->name) << "\"/>"
- << endl;
+ << "\n";
// get its value
const void* const pvalue
@@ -316,11 +316,11 @@ namespace Formaline
// brackets in array parameter names have to be escaped
parambuf << "<cctk:" << paramtype << " rdf:about=\"#Parameters/"
<< pdata->thorn << "/" << cleanURI (pdata->name) << "\""
- << endl
- << "\tcctk:name=\"" << fullname <<"\">" << endl
+ << "\n"
+ << "\tcctk:name=\"" << fullname <<"\">\n"
<< "\t<cctk:value rdf:datatype=\"&xsd;" << paramdatatype
- << "\">" << paramvaluebuf.str() << "</cctk:value>" << endl
- << "</cctk:" << paramtype << ">" << endl;
+ << "\">" << paramvaluebuf.str() << "</cctk:value>\n"
+ << "</cctk:" << paramtype << ">\n";
} // if (pdata->n_set or list_all_parameters)
free (fullname);
@@ -328,11 +328,11 @@ namespace Formaline
} // loop over all parameters of this thorn
} // if (is_active)
- msgbuf << "</cctk:Thorn>" << endl;
+ msgbuf << "</cctk:Thorn>\n";
} // loop over all thorns
- msgbuf << endl << parambuf.str();
+ msgbuf << "\n" << parambuf.str();
#endif
}
@@ -459,9 +459,9 @@ namespace Formaline
if (parent)
{
- parent->msgbuf << "<cctk:" << groupname << ">" << endl
+ parent->msgbuf << "<cctk:" << groupname << ">\n"
<< msgbuf.str()
- << "</cctk:" << groupname << ">" << endl;
+ << "</cctk:" << groupname << ">\n";
return;
}
@@ -563,22 +563,22 @@ namespace Formaline
for (list<string>::const_iterator lsi = keys.begin();
lsi != keys.end(); ++ lsi)
{
- msgbuf << indent_string << "<form:" << * lsi << ">" << endl;
+ msgbuf << indent_string << "<form:" << * lsi << ">\n";
indent_string.append (NUM_INDENT_SPACES, ' ');
}
msgbuf << indent_string
<< "<form:" << node << " rdf:datatype=\"&xsd;boolean\">"
<< clean (valuebuf.str())
- << "</form:" << node << ">" << endl;
+ << "</form:" << node << ">\n";
for (list<string>::const_reverse_iterator lsi = keys.rbegin();
lsi != keys.rend(); ++ lsi)
{
indent_string.erase(0, NUM_INDENT_SPACES);
- msgbuf << indent_string << "</form:" << * lsi << ">" << endl;
+ msgbuf << indent_string << "</form:" << * lsi << ">\n";
}
- msgbuf << endl;
+ msgbuf << "\n";
#endif
}
@@ -600,22 +600,22 @@ namespace Formaline
for (list<string>::const_iterator lsi = keys.begin();
lsi != keys.end(); ++ lsi)
{
- msgbuf << indent_string << "<form:" << * lsi << ">" << endl;
+ msgbuf << indent_string << "<form:" << * lsi << ">\n";
indent_string.append (NUM_INDENT_SPACES, ' ');
}
msgbuf << indent_string
<< "<form:" << node << " rdf:datatype=\"&xsd;integer\">"
<< clean (valuebuf.str())
- << "</form:" << node << ">" << endl;
+ << "</form:" << node << ">\n";
for (list<string>::const_reverse_iterator lsi = keys.rbegin();
lsi != keys.rend(); ++ lsi)
{
indent_string.erase(0, NUM_INDENT_SPACES);
- msgbuf << indent_string << "</form:" << * lsi << ">" << endl;
+ msgbuf << indent_string << "</form:" << * lsi << ">\n";
}
- msgbuf << endl;
+ msgbuf << "\n";
#endif
}
@@ -638,22 +638,22 @@ namespace Formaline
for (list<string>::const_iterator lsi = keys.begin();
lsi != keys.end(); ++ lsi)
{
- msgbuf << indent_string << "<form:" << * lsi << ">" << endl;
+ msgbuf << indent_string << "<form:" << * lsi << ">\n";
indent_string.append (NUM_INDENT_SPACES, ' ');
}
msgbuf << indent_string
<< "<form:" << node << " rdf:datatype=\"&xsd;double\">"
<< clean (valuebuf.str())
- << "</form:" << node << ">" << endl;
+ << "</form:" << node << ">\n";
for (list<string>::const_reverse_iterator lsi = keys.rbegin();
lsi != keys.rend(); ++ lsi)
{
indent_string.erase(0, NUM_INDENT_SPACES);
- msgbuf << indent_string << "</form:" << * lsi << ">" << endl;
+ msgbuf << indent_string << "</form:" << * lsi << ">\n";
}
- msgbuf << endl;
+ msgbuf << "\n";
#endif
}
@@ -678,7 +678,7 @@ namespace Formaline
for (list<string>::const_iterator lsi = keys.begin();
lsi != keys.end(); ++ lsi)
{
- msgbuf << indent_string << "<form:" << * lsi << ">" << endl;
+ msgbuf << indent_string << "<form:" << * lsi << ">\n";
indent_string.append (NUM_INDENT_SPACES, ' ');
}
@@ -686,15 +686,15 @@ namespace Formaline
// FIXME: is <string> the default datatype for RDF objects ??
<< "<form:" << node << ">" // " rdf:datatype=\"&xsd;string\">"
<< clean (valuebuf.str())
- << "</form:" << node << ">" << endl;
+ << "</form:" << node << ">\n";
for (list<string>::const_reverse_iterator lsi = keys.rbegin();
lsi != keys.rend(); ++ lsi)
{
indent_string.erase(0, NUM_INDENT_SPACES);
- msgbuf << indent_string << "</form:" << * lsi << ">" << endl;
+ msgbuf << indent_string << "</form:" << * lsi << ">\n";
}
- msgbuf << endl;
+ msgbuf << "\n";
#endif
}
diff --git a/src/rdf_publisher.cc b/src/rdf_publisher.cc
index a256668..ea1b193 100644
--- a/src/rdf_publisher.cc
+++ b/src/rdf_publisher.cc
@@ -16,8 +16,6 @@
#include "rdf.hh"
-using std::endl;
-
namespace Formaline
{
diff --git a/src/senddata.cc b/src/senddata.cc
index 09dcf89..ae8a47e 100644
--- a/src/senddata.cc
+++ b/src/senddata.cc
@@ -74,18 +74,18 @@ namespace Formaline
// Create a script that sends the data
ostringstream scriptbuf;
scriptbuf
-<< "#! /usr/bin/perl -w" << endl
-<< "" << endl
-<< "use strict;" << endl
-<< "use Socket;" << endl
-<< "use POSIX;" << endl
-<< "" << endl
-<< "my $verbose = " << verbose << ";" << endl
-<< "my $input = '" << datafilename << "';" << endl
-<< "my $host = '" << hostname << "';" << endl
-<< "my $port = " << port << ";" << endl
-<< "" << endl
-<< "# Set a timeout for the entire interaction with this server" << endl
+<< "#! /usr/bin/perl -w\n"
+<< "\n"
+<< "use strict;\n"
+<< "use Socket;\n"
+<< "use POSIX;\n"
+<< "\n"
+<< "my $verbose = " << verbose << ";\n"
+<< "my $input = '" << datafilename << "';\n"
+<< "my $host = '" << hostname << "';\n"
+<< "my $port = " << port << ";\n"
+<< "\n"
+<< "# Set a timeout for the entire interaction with this server\n"
//
// Use POSIX::sigaction to bypass the Perl interpreter's signal
// handling which uses deferred signals, effectively ignoring
@@ -97,34 +97,34 @@ namespace Formaline
// The difference is that the POSIX function does not clean up, but
// that should be fine.
//
-<< "POSIX::sigaction (SIGALRM, POSIX::SigAction->new (sub { POSIX::_exit 1; }))" << endl
-<< " or die \"Error setting SIGALRM handler: $!\";" << endl
-<< "alarm " << timeout << ";" << endl
-<< "" << endl
-<< "if ($verbose) { print STDERR \"Getting IP address\\n\"; }" << endl
-<< "my $iaddr = inet_aton ($host);" << endl
-<< "$iaddr or die \"Couldn't get IP address for '$host'\";" << endl
-<< "if ($verbose) { print STDERR \"Creating sockaddr_in\\n\"; }" << endl
-<< "my $sin = sockaddr_in ($port, $iaddr);" << endl
-<< "if ($verbose) { print STDERR \"Opening socket\\n\"; }" << endl
-<< "socket (my $SH, PF_INET, SOCK_STREAM, getprotobyname ('tcp'));" << endl
-<< "defined $SH or die \"Couldn't open TCP socket\";" << endl
-<< "" << endl
-<< "# Connect and send off the data" << endl
-<< "if ($verbose) { print STDERR \"Connecting\\n\"; }" << endl
-<< "connect ($SH, $sin) or die \"Couldn't connect to '$host:$port'\";" << endl
-<< "" << endl
-<< "if ($verbose) { print STDERR \"Opening local data file\\n\"; }" << endl
-<< "open (my $FH, \"< $input\");" << endl
-<< "if ($verbose) { print STDERR \"Sending data\\n\"; }" << endl
-<< "send ($SH, $_, 0) while (<$FH>);" << endl
-<< "if ($verbose) { print STDERR \"Closing local data file\\n\"; }" << endl
-<< "close $FH;" << endl
-<< "if ($verbose) { print STDERR \"Receiving acknowledgement\\n\"; }" << endl
-<< "recv ($SH, $_, 1, 0);" << endl
-<< "if ($verbose) { print STDERR \"Shutting down connection\\n\"; }" << endl
-<< "close $SH;" << endl
-<< "if ($verbose) { print STDERR \"Done.\\n\"; }" << endl;
+<< "POSIX::sigaction (SIGALRM, POSIX::SigAction->new (sub { POSIX::_exit 1; }))\n"
+<< " or die \"Error setting SIGALRM handler: $!\";\n"
+<< "alarm " << timeout << ";\n"
+<< "\n"
+<< "if ($verbose) { print STDERR \"Getting IP address\\n\"; }\n"
+<< "my $iaddr = inet_aton ($host);\n"
+<< "$iaddr or die \"Couldn't get IP address for '$host'\";\n"
+<< "if ($verbose) { print STDERR \"Creating sockaddr_in\\n\"; }\n"
+<< "my $sin = sockaddr_in ($port, $iaddr);\n"
+<< "if ($verbose) { print STDERR \"Opening socket\\n\"; }\n"
+<< "socket (my $SH, PF_INET, SOCK_STREAM, getprotobyname ('tcp'));\n"
+<< "defined $SH or die \"Couldn't open TCP socket\";\n"
+<< "\n"
+<< "# Connect and send off the data\n"
+<< "if ($verbose) { print STDERR \"Connecting\\n\"; }\n"
+<< "connect ($SH, $sin) or die \"Couldn't connect to '$host:$port'\";\n"
+<< "\n"
+<< "if ($verbose) { print STDERR \"Opening local data file\\n\"; }\n"
+<< "open (my $FH, \"< $input\");\n"
+<< "if ($verbose) { print STDERR \"Sending data\\n\"; }\n"
+<< "send ($SH, $_, 0) while (<$FH>);\n"
+<< "if ($verbose) { print STDERR \"Closing local data file\\n\"; }\n"
+<< "close $FH;\n"
+<< "if ($verbose) { print STDERR \"Receiving acknowledgement\\n\"; }\n"
+<< "recv ($SH, $_, 1, 0);\n"
+<< "if ($verbose) { print STDERR \"Shutting down connection\\n\"; }\n"
+<< "close $SH;\n"
+<< "if ($verbose) { print STDERR \"Done.\\n\"; }\n";
string const scriptstr = scriptbuf.str();
// Write the script to a file