summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Chernyakhovsky <alex@achernya.com>2023-07-30 17:46:02 -0400
committerAlex Chernyakhovsky <achernya@mit.edu>2023-07-30 19:02:51 -0400
commit19ad493dcbc639e29ad07e5442ffc9f3e5af91d6 (patch)
tree003264f5317b2050a33fb2b06c33c0d79a300976
parent8469db91db49c4e41c175c266019e8da816e75df (diff)
Remove using-declarations for std:: types
-rw-r--r--src/crypto/crypto.cc16
-rw-r--r--src/crypto/crypto.h20
-rw-r--r--src/examples/benchmark.cc6
-rw-r--r--src/examples/encrypt.cc2
-rw-r--r--src/frontend/mosh-client.cc2
-rw-r--r--src/frontend/mosh-server.cc54
-rw-r--r--src/frontend/stmclient.cc38
-rw-r--r--src/frontend/terminaloverlay.cc10
-rw-r--r--src/frontend/terminaloverlay.h16
-rw-r--r--src/network/compressor.cc9
-rw-r--r--src/network/network.cc16
-rw-r--r--src/network/network.h24
-rw-r--r--src/network/networktransport-impl.h18
-rw-r--r--src/network/networktransport.h6
-rw-r--r--src/network/transportfragment.cc30
-rw-r--r--src/network/transportfragment.h14
-rw-r--r--src/network/transportsender-impl.h26
-rw-r--r--src/network/transportsender.h10
-rw-r--r--src/statesync/user.cc16
-rw-r--r--src/statesync/user.h12
-rw-r--r--src/terminal/terminaluserinput.cc17
21 files changed, 173 insertions, 189 deletions
diff --git a/src/crypto/crypto.cc b/src/crypto/crypto.cc
index 10f3a03..b530ed9 100644
--- a/src/crypto/crypto.cc
+++ b/src/crypto/crypto.cc
@@ -107,13 +107,13 @@ AlignedBuffer::AlignedBuffer( size_t len, const char *data )
}
}
-Base64Key::Base64Key( string printable_key )
+Base64Key::Base64Key( std::string printable_key )
{
if ( printable_key.length() != 22 ) {
throw CryptoException( "Key must be 22 letters long." );
}
- string base64 = printable_key + "==";
+ std::string base64 = printable_key + "==";
size_t len = 16;
if ( !base64_decode( base64.data(), 24, key, &len ) ) {
@@ -140,7 +140,7 @@ Base64Key::Base64Key(PRNG &prng)
prng.fill( key, sizeof( key ) );
}
-string Base64Key::printable_key( void ) const
+std::string Base64Key::printable_key( void ) const
{
char base64[ 24 ];
@@ -148,11 +148,11 @@ string Base64Key::printable_key( void ) const
if ( (base64[ 23 ] != '=')
|| (base64[ 22 ] != '=') ) {
- throw CryptoException( string( "Unexpected output from base64_encode: " ) + string( base64, 24 ) );
+ throw CryptoException( std::string( "Unexpected output from base64_encode: " ) + std::string( base64, 24 ) );
}
base64[ 22 ] = 0;
- return string( base64 );
+ return std::string( base64 );
}
Session::Session( Base64Key s_key )
@@ -197,7 +197,7 @@ Nonce::Nonce( const char *s_bytes, size_t len )
memcpy( bytes + 4, s_bytes, 8 );
}
-const string Session::encrypt( const Message & plaintext )
+const std::string Session::encrypt( const Message & plaintext )
{
const size_t pt_len = plaintext.text.size();
const int ciphertext_len = pt_len + 16;
@@ -242,7 +242,7 @@ const string Session::encrypt( const Message & plaintext )
throw CryptoException( "Encrypted 2^47 blocks.", true );
}
- string text( ciphertext_buffer.data(), ciphertext_len );
+ std::string text( ciphertext_buffer.data(), ciphertext_len );
return plaintext.nonce.cc_str() + text;
}
@@ -280,7 +280,7 @@ const Message Session::decrypt( const char *str, size_t len )
throw CryptoException( "Packet failed integrity check." );
}
- const Message ret( nonce, string( plaintext_buffer.data(), pt_len ) );
+ const Message ret( nonce, std::string( plaintext_buffer.data(), pt_len ) );
return ret;
}
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index e634d3e..dfde2ba 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -46,13 +46,11 @@ long int myatoi( const char *str );
class PRNG;
namespace Crypto {
- using std::string;
-
class CryptoException : public std::exception {
public:
- string text;
+ std::string text;
bool fatal;
- CryptoException( string s_text, bool s_fatal = false )
+ CryptoException( std::string s_text, bool s_fatal = false )
: text( s_text ), fatal( s_fatal ) {};
const char *what() const throw () { return text.c_str(); }
~CryptoException() throw () {}
@@ -95,8 +93,8 @@ namespace Crypto {
public:
Base64Key(); /* random key */
Base64Key(PRNG &prng);
- Base64Key( string printable_key );
- string printable_key( void ) const;
+ Base64Key( std::string printable_key );
+ std::string printable_key( void ) const;
unsigned char *data( void ) { return key; }
};
@@ -111,7 +109,7 @@ namespace Crypto {
Nonce( uint64_t val );
Nonce( const char *s_bytes, size_t len );
- string cc_str( void ) const { return string( bytes + 4, 8 ); }
+ std::string cc_str( void ) const { return std::string( bytes + 4, 8 ); }
const char *data( void ) const { return bytes; }
uint64_t val( void ) const;
};
@@ -119,14 +117,14 @@ namespace Crypto {
class Message {
public:
const Nonce nonce;
- const string text;
+ const std::string text;
Message( const char *nonce_bytes, size_t nonce_len,
const char *text_bytes, size_t text_len )
: nonce( nonce_bytes, nonce_len ),
text( text_bytes, text_len ) {}
- Message( const Nonce & s_nonce, const string & s_text )
+ Message( const Nonce & s_nonce, const std::string & s_text )
: nonce( s_nonce ),
text( s_text ) {}
};
@@ -150,9 +148,9 @@ namespace Crypto {
Session( Base64Key s_key );
~Session();
- const string encrypt( const Message & plaintext );
+ const std::string encrypt( const Message & plaintext );
const Message decrypt( const char *str, size_t len );
- const Message decrypt( const string & ciphertext ) {
+ const Message decrypt( const std::string & ciphertext ) {
return decrypt( ciphertext.data(), ciphertext.size() );
}
diff --git a/src/examples/benchmark.cc b/src/examples/benchmark.cc
index d2f3b2a..a52797a 100644
--- a/src/examples/benchmark.cc
+++ b/src/examples/benchmark.cc
@@ -106,9 +106,9 @@ int main( int argc, char **argv )
overlays.apply( *new_state );
/* calculate minimal difference from where we are */
- const string diff( display.new_frame( false,
- *local_framebuffer,
- *new_state ) );
+ const std::string diff( display.new_frame( false,
+ *local_framebuffer,
+ *new_state ) );
/* make sure to use diff */
if ( diff.size() > INT_MAX ) {
diff --git a/src/examples/encrypt.cc b/src/examples/encrypt.cc
index 0957ef7..b5afefe 100644
--- a/src/examples/encrypt.cc
+++ b/src/examples/encrypt.cc
@@ -56,7 +56,7 @@ int main( int argc, char *argv[] )
/* Encrypt message */
- string ciphertext = session.encrypt( Message( nonce, input.str() ) );
+ std::string ciphertext = session.encrypt( Message( nonce, input.str() ) );
std::cerr << "Key: " << key.printable_key() << std::endl;
diff --git a/src/frontend/mosh-client.cc b/src/frontend/mosh-client.cc
index 9c3db8d..242aa48 100644
--- a/src/frontend/mosh-client.cc
+++ b/src/frontend/mosh-client.cc
@@ -179,7 +179,7 @@ int main( int argc, char *argv[] )
char *predict_overwrite = getenv( "MOSH_PREDICTION_OVERWRITE" );
/* can be NULL */
- string key( env_key );
+ std::string key( env_key );
if ( unsetenv( "MOSH_KEY" ) < 0 ) {
perror( "unsetenv" );
diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc
index 7c49ab9..9324fdb 100644
--- a/src/frontend/mosh-server.cc
+++ b/src/frontend/mosh-server.cc
@@ -104,7 +104,7 @@ static void serve( int host_fd,
long network_signaled_timeout );
static int run_server( const char *desired_ip, const char *desired_port,
- const string &command_path, char *command_argv[],
+ const std::string &command_path, char *command_argv[],
const int colors, unsigned int verbose, bool with_motd );
@@ -125,7 +125,7 @@ static void print_usage( FILE *stream, const char *argv0 )
static bool print_motd( const char *filename );
static void chdir_homedir( void );
static bool motd_hushed( void );
-static void warn_unattached( const string & ignore_entry );
+static void warn_unattached( const std::string & ignore_entry );
/* Simple spinloop */
static void spin( void )
@@ -142,19 +142,19 @@ static void spin( void )
}
}
-static string get_SSH_IP( void )
+static std::string get_SSH_IP( void )
{
const char *SSH_CONNECTION = getenv( "SSH_CONNECTION" );
if ( !SSH_CONNECTION ) { /* Older sshds don't set this */
fputs( "Warning: SSH_CONNECTION not found; binding to any interface.\n", stderr );
- return string( "" );
+ return std::string( "" );
}
std::istringstream ss( SSH_CONNECTION );
- string dummy, local_interface_IP;
+ std::string dummy, local_interface_IP;
ss >> dummy >> dummy >> local_interface_IP;
if ( !ss ) {
fputs( "Warning: Could not parse SSH_CONNECTION; binding to any interface.\n", stderr );
- return string( "" );
+ return std::string( "" );
}
/* Strip IPv6 prefix. */
@@ -177,14 +177,14 @@ int main( int argc, char *argv[] )
fatal_assert( argc > 0 );
const char *desired_ip = NULL;
- string desired_ip_str;
+ std::string desired_ip_str;
const char *desired_port = NULL;
- string command_path;
+ std::string command_path;
char **command_argv = NULL;
int colors = 0;
unsigned int verbose = 0; /* don't close stdin/stdout/stderr */
/* Will cause mosh-server not to correctly detach on old versions of sshd. */
- list<string> locale_vars;
+ std::list<std::string> locale_vars;
/* strip off command */
for ( int i = 1; i < argc; i++ ) {
@@ -249,7 +249,7 @@ int main( int argc, char *argv[] )
verbose++;
break;
case 'l':
- locale_vars.push_back( string( optarg ) );
+ locale_vars.push_back( std::string( optarg ) );
break;
default:
/* don't die on unknown options */
@@ -286,7 +286,7 @@ int main( int argc, char *argv[] )
/* Get shell */
char *my_argv[ 2 ];
- string shell_name;
+ std::string shell_name;
if ( !command_argv ) {
/* get shell name */
const char *shell = getenv( "SHELL" );
@@ -299,7 +299,7 @@ int main( int argc, char *argv[] )
shell = pw->pw_shell;
}
- string shell_path( shell );
+ std::string shell_path( shell );
if ( shell_path.empty() ) { /* empty shell means Bourne shell */
shell_path = _PATH_BSHELL;
}
@@ -307,7 +307,7 @@ int main( int argc, char *argv[] )
command_path = shell_path;
size_t shell_slash( shell_path.rfind('/') );
- if ( shell_slash == string::npos ) {
+ if ( shell_slash == std::string::npos ) {
shell_name = shell_path;
} else {
shell_name = shell_path.substr(shell_slash + 1);
@@ -332,11 +332,11 @@ int main( int argc, char *argv[] )
if ( !is_utf8_locale() ) {
/* save details for diagnostic */
LocaleVar native_ctype = get_ctype();
- string native_charset( locale_charset() );
+ std::string native_charset( locale_charset() );
/* apply locale-related environment variables from client */
clear_locale_variables();
- for ( list<string>::const_iterator i = locale_vars.begin();
+ for ( std::list<std::string>::const_iterator i = locale_vars.begin();
i != locale_vars.end();
i++ ) {
char *env_string = strdup( i->c_str() );
@@ -350,7 +350,7 @@ int main( int argc, char *argv[] )
set_native_locale();
if ( !is_utf8_locale() ) {
LocaleVar client_ctype = get_ctype();
- string client_charset( locale_charset() );
+ std::string client_charset( locale_charset() );
fprintf( stderr, "mosh-server needs a UTF-8 native locale to run.\n\n"
"Unfortunately, the local environment (%s) specifies\n"
@@ -377,7 +377,7 @@ int main( int argc, char *argv[] )
}
static int run_server( const char *desired_ip, const char *desired_port,
- const string &command_path, char *command_argv[],
+ const std::string &command_path, char *command_argv[],
const int colors, unsigned int verbose, bool with_motd ) {
/* get network idle timeout */
long network_timeout = 0;
@@ -723,7 +723,7 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
now = Network::timestamp();
uint64_t time_since_remote_state = now - network.get_latest_remote_state().timestamp;
- string terminal_to_host;
+ std::string terminal_to_host;
if ( sel.read( network_fd ) ) {
/* packet received from the network */
@@ -842,7 +842,7 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
if ( bytes_read <= 0 ) {
network.start_shutdown();
} else {
- terminal_to_host += terminal.act( string( buf, bytes_read ) );
+ terminal_to_host += terminal.act( std::string( buf, bytes_read ) );
/* update client with new state of terminal */
network.set_current_state( terminal );
@@ -992,13 +992,13 @@ static bool motd_hushed( void )
#ifdef HAVE_UTMPX_H
static bool device_exists( const char *ut_line )
{
- string device_name = string( "/dev/" ) + string( ut_line );
+ std::string device_name = std::string( "/dev/" ) + std::string( ut_line );
struct stat buf;
return 0 == lstat( device_name.c_str(), &buf );
}
#endif
-static void warn_unattached( const string & ignore_entry )
+static void warn_unattached( const std::string & ignore_entry )
{
#ifdef HAVE_UTMPX_H
/* get username */
@@ -1009,16 +1009,16 @@ static void warn_unattached( const string & ignore_entry )
return;
}
- const string username( pw->pw_name );
+ const std::string username( pw->pw_name );
/* look for unattached sessions */
- vector< string > unattached_mosh_servers;
+ std::vector< std::string > unattached_mosh_servers;
while ( struct utmpx *entry = getutxent() ) {
if ( (entry->ut_type == USER_PROCESS)
- && (username == string( entry->ut_user )) ) {
+ && (username == std::string( entry->ut_user )) ) {
/* does line show unattached mosh session */
- string text( entry->ut_host );
+ std::string text( entry->ut_host );
if ( (text.size() >= 5)
&& (text.substr( 0, 5 ) == "mosh ")
&& (text[ text.size() - 1 ] == ']')
@@ -1036,9 +1036,9 @@ static void warn_unattached( const string & ignore_entry )
printf( "\033[37;44mMosh: You have a detached Mosh session on this server (%s).\033[m\n\n",
unattached_mosh_servers.front().c_str() );
} else {
- string pid_string;
+ std::string pid_string;
- for ( vector< string >::const_iterator it = unattached_mosh_servers.begin();
+ for ( std::vector< std::string >::const_iterator it = unattached_mosh_servers.begin();
it != unattached_mosh_servers.end();
it++ ) {
pid_string += " - " + *it + "\n";
diff --git a/src/frontend/stmclient.cc b/src/frontend/stmclient.cc
index 29cb4f2..2a1a37a 100644
--- a/src/frontend/stmclient.cc
+++ b/src/frontend/stmclient.cc
@@ -63,8 +63,6 @@
#include "src/network/networktransport-impl.h"
-using std::wstring;
-
void STMClient::resume( void )
{
/* Restore termios state */
@@ -84,7 +82,7 @@ void STMClient::init( void )
{
if ( !is_utf8_locale() ) {
LocaleVar native_ctype = get_ctype();
- string native_charset( locale_charset() );
+ std::string native_charset( locale_charset() );
fprintf( stderr, "mosh-client needs a UTF-8 native locale to run.\n\n"
"Unfortunately, the client's environment (%s) specifies\n"
@@ -123,7 +121,7 @@ void STMClient::init( void )
/* Add our name to window title */
if ( !getenv( "MOSH_TITLE_NOPREFIX" ) ) {
- overlays.set_title_prefix( wstring( L"[mosh] " ) );
+ overlays.set_title_prefix( std::wstring( L"[mosh] " ) );
}
/* Set terminal escape key. */
@@ -185,25 +183,25 @@ void STMClient::init( void )
snprintf(escape_key_name_buf, sizeof escape_key_name_buf, "\"%c\"", escape_key);
escape_requires_lf = true;
}
- string tmp;
- tmp = string( escape_pass_name_buf );
- wstring escape_pass_name = std::wstring(tmp.begin(), tmp.end());
- tmp = string( escape_key_name_buf );
- wstring escape_key_name = std::wstring(tmp.begin(), tmp.end());
+ std::string tmp;
+ tmp = std::string( escape_pass_name_buf );
+ std::wstring escape_pass_name = std::wstring(tmp.begin(), tmp.end());
+ tmp = std::string( escape_key_name_buf );
+ std::wstring escape_key_name = std::wstring(tmp.begin(), tmp.end());
escape_key_help = L"Commands: Ctrl-Z suspends, \".\" quits, " + escape_pass_name + L" gives literal " + escape_key_name;
overlays.get_notification_engine().set_escape_key_string( tmp );
}
wchar_t tmp[ 128 ];
swprintf( tmp, 128, L"Nothing received from server on UDP port %s.", port.c_str() );
- connecting_notification = wstring( tmp );
+ connecting_notification = std::wstring( tmp );
}
void STMClient::shutdown( void )
{
/* Restore screen state */
- overlays.get_notification_engine().set_notification_string( wstring( L"" ) );
+ overlays.get_notification_engine().set_notification_string( std::wstring( L"" ) );
overlays.get_notification_engine().server_heard( timestamp() );
- overlays.set_title_prefix( wstring( L"" ) );
+ overlays.set_title_prefix( std::wstring( L"" ) );
output_new_frame();
/* Restore terminal and terminal-driver state */
@@ -246,7 +244,7 @@ void STMClient::main_init( void )
new_state = Terminal::Framebuffer( 1, 1 );
/* initialize screen */
- string init = display.new_frame( false, local_framebuffer, local_framebuffer );
+ std::string init = display.new_frame( false, local_framebuffer, local_framebuffer );
swrite( STDOUT_FILENO, init.data(), init.size() );
/* open network */
@@ -277,7 +275,7 @@ void STMClient::output_new_frame( void )
overlays.apply( new_state );
/* calculate minimal difference from where we are */
- const string diff( display.new_frame( !repaint_requested,
+ const std::string diff( display.new_frame( !repaint_requested,
local_framebuffer,
new_state ) );
swrite( STDOUT_FILENO, diff.data(), diff.size() );
@@ -337,7 +335,7 @@ bool STMClient::process_user_input( int fd )
if ( quit_sequence_started ) {
if ( the_byte == '.' ) { /* Quit sequence is Ctrl-^ . */
if ( net.has_remote_addr() && (!net.shutdown_in_progress()) ) {
- overlays.get_notification_engine().set_notification_string( wstring( L"Exiting on user request..." ), true );
+ overlays.get_notification_engine().set_notification_string( std::wstring( L"Exiting on user request..." ), true );
net.start_shutdown();
return true;
}
@@ -485,7 +483,7 @@ bool STMClient::main( void )
if ( !network->has_remote_addr() ) {
break;
} else if ( !network->shutdown_in_progress() ) {
- overlays.get_notification_engine().set_notification_string( wstring( L"Exiting..." ), true );
+ overlays.get_notification_engine().set_notification_string( std::wstring( L"Exiting..." ), true );
network->start_shutdown();
}
}
@@ -506,7 +504,7 @@ bool STMClient::main( void )
if ( !network->has_remote_addr() ) {
break;
} else if ( !network->shutdown_in_progress() ) {
- overlays.get_notification_engine().set_notification_string( wstring( L"Signal received, shutting down..." ), true );
+ overlays.get_notification_engine().set_notification_string( std::wstring( L"Signal received, shutting down..." ), true );
network->start_shutdown();
}
}
@@ -534,7 +532,7 @@ bool STMClient::main( void )
&& (timestamp() - network->get_latest_remote_state().timestamp > 250) ) {
if ( timestamp() - network->get_latest_remote_state().timestamp > 15000 ) {
if ( !network->shutdown_in_progress() ) {
- overlays.get_notification_engine().set_notification_string( wstring( L"Timed out waiting for server..." ), true );
+ overlays.get_notification_engine().set_notification_string( std::wstring( L"Timed out waiting for server..." ), true );
network->start_shutdown();
}
} else {
@@ -548,7 +546,7 @@ bool STMClient::main( void )
network->tick();
- string & send_error = network->get_send_error();
+ std::string & send_error = network->get_send_error();
if ( !send_error.empty() ) {
overlays.get_notification_engine().set_network_error( send_error );
send_error.clear();
@@ -571,7 +569,7 @@ bool STMClient::main( void )
} else {
wchar_t tmp[ 128 ];
swprintf( tmp, 128, L"Crypto exception: %s", e.what() );
- overlays.get_notification_engine().set_notification_string( wstring( tmp ) );
+ overlays.get_notification_engine().set_notification_string( std::wstring( tmp ) );
}
}
}
diff --git a/src/frontend/terminaloverlay.cc b/src/frontend/terminaloverlay.cc
index efbdaba..74dfeff 100644
--- a/src/frontend/terminaloverlay.cc
+++ b/src/frontend/terminaloverlay.cc
@@ -100,7 +100,7 @@ Validity ConditionalOverlayCell::get_validity( const Framebuffer &fb, int row,
}
if ( current.contents_match( replacement ) ) {
- vector<Cell>::const_iterator it = original_contents.begin();
+ std::vector<Cell>::const_iterator it = original_contents.begin();
for ( ; it != original_contents.end(); it++ ) {
if ( it->contents_match( replacement ) )
break;
@@ -248,14 +248,14 @@ void NotificationEngine::apply( Framebuffer &fb ) const
explanation, keystroke_str );
}
- wstring string_to_draw( tmp );
+ std::wstring string_to_draw( tmp );
int overlay_col = 0;
Cell *combining_cell = fb.get_mutable_cell( 0, 0 );
/* We unfortunately duplicate the terminal's logic for how to render a Unicode sequence into graphemes */
- for ( wstring::const_iterator i = string_to_draw.begin(); i != string_to_draw.end(); i++ ) {
+ for ( std::wstring::const_iterator i = string_to_draw.begin(); i != string_to_draw.end(); i++ ) {
if ( overlay_col >= fb.ds.get_width() ) {
break;
}
@@ -339,7 +339,7 @@ void OverlayManager::apply( Framebuffer &fb )
title.apply( fb );
}
-void TitleEngine::set_prefix( const wstring &s )
+void TitleEngine::set_prefix( const std::wstring &s )
{
prefix = Terminal::Framebuffer::title_type( s.begin(), s.end() );
}
@@ -615,7 +615,7 @@ void PredictionEngine::cull( const Framebuffer &fb )
/* NB: switching from list to another STL container could break this code.
So we don't use the cursors_type typedef. */
- for ( list<ConditionalCursorMove>::iterator it = cursors.begin();
+ for ( std::list<ConditionalCursorMove>::iterator it = cursors.begin();
it != cursors.end(); ) {
if ( it->get_validity( fb, local_frame_acked, local_frame_late_acked ) != Pending ) {
it = cursors.erase( it );
diff --git a/src/frontend/terminaloverlay.h b/src/frontend/terminaloverlay.h
index 648c1bc..99bbc24 100644
--- a/src/frontend/terminaloverlay.h
+++ b/src/frontend/terminaloverlay.h
@@ -44,8 +44,6 @@
namespace Overlay {
using namespace Terminal;
using namespace Network;
- using std::deque;
- using std::wstring;
enum Validity {
Pending,
@@ -139,8 +137,8 @@ namespace Overlay {
private:
uint64_t last_word_from_server;
uint64_t last_acked_state;
- string escape_key_string;
- wstring message;
+ std::string escape_key_string;
+ std::wstring message;
bool message_is_network_error;
uint64_t message_expiration;
bool show_quit_keystroke;
@@ -152,12 +150,12 @@ namespace Overlay {
public:
void adjust_message( void );
void apply( Framebuffer &fb ) const;
- const wstring &get_notification_string( void ) const { return message; }
+ const std::wstring &get_notification_string( void ) const { return message; }
void server_heard( uint64_t s_last_word ) { last_word_from_server = s_last_word; }
void server_acked( uint64_t s_last_acked ) { last_acked_state = s_last_acked; }
int wait_time( void ) const;
- void set_notification_string( const wstring &s_message, bool permanent = false, bool s_show_quit_keystroke = true )
+ void set_notification_string( const std::wstring &s_message, bool permanent = false, bool s_show_quit_keystroke = true )
{
message = s_message;
if ( permanent ) {
@@ -169,7 +167,7 @@ namespace Overlay {
show_quit_keystroke = s_show_quit_keystroke;
}
- void set_escape_key_string( const string &s_name )
+ void set_escape_key_string( const std::string &s_name )
{
char tmp[ 128 ];
snprintf( tmp, sizeof tmp, " [To quit: %s .]", s_name.c_str() );
@@ -312,7 +310,7 @@ namespace Overlay {
public:
void apply( Framebuffer &fb ) const { fb.prefix_window_title( prefix ); }
TitleEngine() : prefix() {}
- void set_prefix( const wstring &s );
+ void set_prefix( const std::wstring &s );
};
/* the overlay manager */
@@ -328,7 +326,7 @@ namespace Overlay {
NotificationEngine & get_notification_engine( void ) { return notifications; }
PredictionEngine & get_prediction_engine( void ) { return predictions; }
- void set_title_prefix( const wstring &s ) { title.set_prefix( s ); }
+ void set_title_prefix( const std::wstring &s ) { title.set_prefix( s ); }
OverlayManager() : notifications(), predictions(), title() {}
diff --git a/src/network/compressor.cc b/src/network/compressor.cc
index 2056f6b..ec49270 100644
--- a/src/network/compressor.cc
+++ b/src/network/compressor.cc
@@ -36,24 +36,23 @@
#include "src/util/dos_assert.h"
using namespace Network;
-using std::string;
-string Compressor::compress_str( const string &input )
+std::string Compressor::compress_str( const std::string &input )
{
long unsigned int len = BUFFER_SIZE;
dos_assert( Z_OK == compress( buffer, &len,
reinterpret_cast<const unsigned char *>( input.data() ),
input.size() ) );
- return string( reinterpret_cast<char *>( buffer ), len );
+ return std::string( reinterpret_cast<char *>( buffer ), len );
}
-string Compressor::uncompress_str( const string &input )
+std::string Compressor::uncompress_str( const std::string &input )
{
long unsigned int len = BUFFER_SIZE;
dos_assert( Z_OK == uncompress( buffer, &len,
reinterpret_cast<const unsigned char *>( input.data() ),
input.size() ) );
- return string( reinterpret_cast<char *>( buffer ), len );
+ return std::string( reinterpret_cast<char *>( buffer ), len );
}
/* construct on first use */
diff --git a/src/network/network.cc b/src/network/network.cc
index d4168cc..ea58bae 100644
--- a/src/network/network.cc
+++ b/src/network/network.cc
@@ -80,7 +80,7 @@ Packet::Packet( const Message & message )
timestamp = be16toh( data[ 0 ] );
timestamp_reply = be16toh( data[ 1 ] );
- payload = string( message.text.begin() + 2 * sizeof( uint16_t ), message.text.end() );
+ payload = std::string( message.text.begin() + 2 * sizeof( uint16_t ), message.text.end() );
}
/* Output from packet */
@@ -91,12 +91,12 @@ Message Packet::toMessage( void )
uint16_t ts_net[ 2 ] = { static_cast<uint16_t>( htobe16( timestamp ) ),
static_cast<uint16_t>( htobe16( timestamp_reply ) ) };
- string timestamps = string( (char *)ts_net, 2 * sizeof( uint16_t ) );
+ std::string timestamps = std::string( (char *)ts_net, 2 * sizeof( uint16_t ) );
return Message( Nonce( direction_seq ), timestamps + payload );
}
-Packet Connection::new_packet( const string &s_payload )
+Packet Connection::new_packet( const std::string &s_payload )
{
uint16_t outgoing_timestamp_reply = -1;
@@ -391,7 +391,7 @@ Connection::Connection( const char *key_str, const char *ip, const char *port )
set_MTU( remote_addr.sa.sa_family );
}
-void Connection::send( const string & s )
+void Connection::send( const std::string & s )
{
if ( !has_remote_addr ) {
return;
@@ -399,7 +399,7 @@ void Connection::send( const string & s )
Packet px = new_packet( s );
- string p = session.encrypt( px.toMessage() );
+ std::string p = session.encrypt( px.toMessage() );
ssize_t bytes_sent = sendto( sock(), p.data(), p.size(), MSG_DONTWAIT,
&remote_addr.sa, remote_addr_len );
@@ -428,13 +428,13 @@ void Connection::send( const string & s )
}
}
-string Connection::recv( void )
+std::string Connection::recv( void )
{
assert( !socks.empty() );
for ( std::deque< Socket >::const_iterator it = socks.begin();
it != socks.end();
it++ ) {
- string payload;
+ std::string payload;
try {
payload = recv_one( it->fd());
} catch ( NetworkException & e ) {
@@ -453,7 +453,7 @@ string Connection::recv( void )
throw NetworkException( "No packet received" );
}
-string Connection::recv_one( int sock_to_recv )
+std::string Connection::recv_one( int sock_to_recv )
{
/* receive source address, ECN, and payload in msghdr structure */
Addr packet_remote_addr;
diff --git a/src/network/network.h b/src/network/network.h
index 471aaf5..35042f7 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -57,12 +57,12 @@ namespace Network {
class NetworkException : public std::exception {
public:
- string function;
+ std::string function;
int the_errno;
private:
- string my_what;
+ std::string my_what;
public:
- NetworkException( string s_function="<none>", int s_errno=0)
+ NetworkException( std::string s_function="<none>", int s_errno=0)
: function( s_function ), the_errno( s_errno ),
my_what(function + ": " + strerror(the_errno)) {}
const char *what() const throw () { return my_what.c_str(); }
@@ -79,10 +79,10 @@ namespace Network {
const uint64_t seq;
Direction direction;
uint16_t timestamp, timestamp_reply;
- string payload;
+ std::string payload;
Packet( Direction s_direction,
- uint16_t s_timestamp, uint16_t s_timestamp_reply, const string & s_payload )
+ uint16_t s_timestamp, uint16_t s_timestamp_reply, const std::string & s_payload )
: seq( Crypto::unique() ), direction( s_direction ),
timestamp( s_timestamp ), timestamp_reply( s_timestamp_reply ), payload( s_payload )
{}
@@ -188,9 +188,9 @@ namespace Network {
double RTTVAR;
/* Error from send()/sendto(). */
- string send_error;
+ std::string send_error;
- Packet new_packet( const string &s_payload );
+ Packet new_packet( const std::string &s_payload );
void hop_port( void );
@@ -198,7 +198,7 @@ namespace Network {
void prune_sockets( void );
- string recv_one( int sock_to_recv );
+ std::string recv_one( int sock_to_recv );
void set_MTU( int family );
@@ -209,13 +209,13 @@ namespace Network {
Connection( const char *desired_ip, const char *desired_port ); /* server */
Connection( const char *key_str, const char *ip, const char *port ); /* client */
- void send( const string & s );
- string recv( void );
+ void send( const std::string & s );
+ std::string recv( void );
const std::vector< int > fds( void ) const;
int get_MTU( void ) const { return MTU; }
std::string port( void ) const;
- string get_key( void ) const { return key.printable_key(); }
+ std::string get_key( void ) const { return key.printable_key(); }
bool get_has_remote_addr( void ) const { return has_remote_addr; }
uint64_t timeout( void ) const;
@@ -224,7 +224,7 @@ namespace Network {
const Addr &get_remote_addr( void ) const { return remote_addr; }
socklen_t get_remote_addr_len( void ) const { return remote_addr_len; }
- string &get_send_error( void )
+ std::string &get_send_error( void )
{
return send_error;
}
diff --git a/src/network/networktransport-impl.h b/src/network/networktransport-impl.h
index b3dc522..61c9cd7 100644
--- a/src/network/networktransport-impl.h
+++ b/src/network/networktransport-impl.h
@@ -70,7 +70,7 @@ Transport<MyState, RemoteState>::Transport( MyState &initial_state, RemoteState</