Reformat printed strings in source
Consolidate multiple printfs. Break up multiline strings with string concatentation, for better clarity and shorter lines. Use fputs where appropriate. This also has the benefit of producing a single constant string with copyright and versions in the binaries.
This commit is contained in:
@@ -72,16 +72,18 @@
|
|||||||
|
|
||||||
static void print_version( FILE *file )
|
static void print_version( FILE *file )
|
||||||
{
|
{
|
||||||
fprintf( file, "mosh-client (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION );
|
fputs( "mosh-client (" PACKAGE_STRING ") [build " BUILD_VERSION "]\n"
|
||||||
fprintf( file, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
|
"Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n"
|
||||||
fprintf( file, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n" );
|
"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n"
|
||||||
|
"This is free software: you are free to change and redistribute it.\n"
|
||||||
|
"There is NO WARRANTY, to the extent permitted by law.\n", file );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_usage( FILE *file, const char *argv0 )
|
static void print_usage( FILE *file, const char *argv0 )
|
||||||
{
|
{
|
||||||
print_version( file );
|
print_version( file );
|
||||||
fprintf( file, "\n" );
|
fprintf( file, "\nUsage: %s [-# 'ARGS'] IP PORT\n"
|
||||||
fprintf( file, "Usage: %s [-# 'ARGS'] IP PORT\n %s -c\n", argv0, argv0 );
|
" %s -c\n", argv0, argv0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_colorcount( void )
|
static void print_colorcount( void )
|
||||||
@@ -165,7 +167,7 @@ int main( int argc, char *argv[] )
|
|||||||
/* Read key from environment */
|
/* Read key from environment */
|
||||||
char *env_key = getenv( "MOSH_KEY" );
|
char *env_key = getenv( "MOSH_KEY" );
|
||||||
if ( env_key == NULL ) {
|
if ( env_key == NULL ) {
|
||||||
fprintf( stderr, "MOSH_KEY environment variable not found.\n" );
|
fputs( "MOSH_KEY environment variable not found.\n", stderr );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+26
-17
@@ -108,9 +108,11 @@ using namespace std;
|
|||||||
|
|
||||||
static void print_version( FILE *file )
|
static void print_version( FILE *file )
|
||||||
{
|
{
|
||||||
fprintf( file, "mosh-server (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION );
|
fputs( "mosh-server (" PACKAGE_STRING ") [build " BUILD_VERSION "]\n"
|
||||||
fprintf( file, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
|
"Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n"
|
||||||
fprintf( file, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n" );
|
"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n"
|
||||||
|
"This is free software: you are free to change and redistribute it.\n"
|
||||||
|
"There is NO WARRANTY, to the extent permitted by law.\n", file );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_usage( FILE *stream, const char *argv0 )
|
static void print_usage( FILE *stream, const char *argv0 )
|
||||||
@@ -142,14 +144,14 @@ static string get_SSH_IP( void )
|
|||||||
{
|
{
|
||||||
const char *SSH_CONNECTION = getenv( "SSH_CONNECTION" );
|
const char *SSH_CONNECTION = getenv( "SSH_CONNECTION" );
|
||||||
if ( !SSH_CONNECTION ) { /* Older sshds don't set this */
|
if ( !SSH_CONNECTION ) { /* Older sshds don't set this */
|
||||||
fprintf( stderr, "Warning: SSH_CONNECTION not found; binding to any interface.\n" );
|
fputs( "Warning: SSH_CONNECTION not found; binding to any interface.\n", stderr );
|
||||||
return string( "" );
|
return string( "" );
|
||||||
}
|
}
|
||||||
istringstream ss( SSH_CONNECTION );
|
istringstream ss( SSH_CONNECTION );
|
||||||
string dummy, local_interface_IP;
|
string dummy, local_interface_IP;
|
||||||
ss >> dummy >> dummy >> local_interface_IP;
|
ss >> dummy >> dummy >> local_interface_IP;
|
||||||
if ( !ss ) {
|
if ( !ss ) {
|
||||||
fprintf( stderr, "Warning: Could not parse SSH_CONNECTION; binding to any interface.\n" );
|
fputs( "Warning: Could not parse SSH_CONNECTION; binding to any interface.\n", stderr );
|
||||||
return string( "" );
|
return string( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,9 +345,12 @@ int main( int argc, char *argv[] )
|
|||||||
LocaleVar client_ctype = get_ctype();
|
LocaleVar client_ctype = get_ctype();
|
||||||
string client_charset( locale_charset() );
|
string client_charset( locale_charset() );
|
||||||
|
|
||||||
fprintf( stderr, "mosh-server needs a UTF-8 native locale to run.\n\n" );
|
fprintf( stderr, "mosh-server needs a UTF-8 native locale to run.\n\n"
|
||||||
fprintf( stderr, "Unfortunately, the local environment (%s) specifies\nthe character set \"%s\",\n\n", native_ctype.str().c_str(), native_charset.c_str() );
|
"Unfortunately, the local environment (%s) specifies\n"
|
||||||
fprintf( stderr, "The client-supplied environment (%s) specifies\nthe character set \"%s\".\n\n", client_ctype.str().c_str(), client_charset.c_str() );
|
"the character set \"%s\",\n\n"
|
||||||
|
"The client-supplied environment (%s) specifies\n"
|
||||||
|
"the character set \"%s\".\n\n",
|
||||||
|
native_ctype.str().c_str(), native_charset.c_str(), client_ctype.str().c_str(), client_charset.c_str() );
|
||||||
int unused __attribute((unused)) = system( "locale" );
|
int unused __attribute((unused)) = system( "locale" );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
@@ -375,9 +380,9 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
char *endptr;
|
char *endptr;
|
||||||
network_timeout = strtol( timeout_envar, &endptr, 10 );
|
network_timeout = strtol( timeout_envar, &endptr, 10 );
|
||||||
if ( *endptr != '\0' || ( network_timeout == 0 && errno == EINVAL ) ) {
|
if ( *endptr != '\0' || ( network_timeout == 0 && errno == EINVAL ) ) {
|
||||||
fprintf( stderr, "MOSH_SERVER_NETWORK_TMOUT not a valid integer, ignoring\n" );
|
fputs( "MOSH_SERVER_NETWORK_TMOUT not a valid integer, ignoring\n", stderr );
|
||||||
} else if ( network_timeout < 0 ) {
|
} else if ( network_timeout < 0 ) {
|
||||||
fprintf( stderr, "MOSH_SERVER_NETWORK_TMOUT is negative, ignoring\n" );
|
fputs( "MOSH_SERVER_NETWORK_TMOUT is negative, ignoring\n", stderr );
|
||||||
network_timeout = 0;
|
network_timeout = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,9 +394,9 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
char *endptr;
|
char *endptr;
|
||||||
network_signaled_timeout = strtol( signal_envar, &endptr, 10 );
|
network_signaled_timeout = strtol( signal_envar, &endptr, 10 );
|
||||||
if ( *endptr != '\0' || ( network_signaled_timeout == 0 && errno == EINVAL ) ) {
|
if ( *endptr != '\0' || ( network_signaled_timeout == 0 && errno == EINVAL ) ) {
|
||||||
fprintf( stderr, "MOSH_SERVER_SIGNAL_TMOUT not a valid integer, ignoring\n" );
|
fputs( "MOSH_SERVER_SIGNAL_TMOUT not a valid integer, ignoring\n", stderr );
|
||||||
} else if ( network_signaled_timeout < 0 ) {
|
} else if ( network_signaled_timeout < 0 ) {
|
||||||
fprintf( stderr, "MOSH_SERVER_SIGNAL_TMOUT is negative, ignoring\n" );
|
fputs( "MOSH_SERVER_SIGNAL_TMOUT is negative, ignoring\n", stderr );
|
||||||
network_signaled_timeout = 0;
|
network_signaled_timeout = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -443,13 +448,17 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
if ( the_pid < 0 ) {
|
if ( the_pid < 0 ) {
|
||||||
perror( "fork" );
|
perror( "fork" );
|
||||||
} else if ( the_pid > 0 ) {
|
} else if ( the_pid > 0 ) {
|
||||||
fprintf( stderr, "\nmosh-server (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION );
|
fputs( "\nmosh-server (" PACKAGE_STRING ") [build " BUILD_VERSION "]\n"
|
||||||
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
|
"Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n"
|
||||||
fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" );
|
"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n"
|
||||||
|
"This is free software: you are free to change and redistribute it.\n"
|
||||||
|
"There is NO WARRANTY, to the extent permitted by law.\n\n", stderr );
|
||||||
|
|
||||||
fprintf( stderr, "[mosh-server detached, pid = %d]\n", static_cast<int>(the_pid) );
|
fprintf( stderr, "[mosh-server detached, pid = %d]\n", static_cast<int>(the_pid) );
|
||||||
#ifndef HAVE_IUTF8
|
#ifndef HAVE_IUTF8
|
||||||
fprintf( stderr, "\nWarning: termios IUTF8 flag not defined.\nCharacter-erase of multibyte character sequence\nprobably does not work properly on this platform.\n" );
|
fputs( "\nWarning: termios IUTF8 flag not defined.\n"
|
||||||
|
"Character-erase of multibyte character sequence\n"
|
||||||
|
"probably does not work properly on this platform.\n", stderr );
|
||||||
#endif /* HAVE_IUTF8 */
|
#endif /* HAVE_IUTF8 */
|
||||||
|
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
@@ -623,7 +632,7 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
delete network;
|
delete network;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "\n[mosh-server is exiting.]\n" );
|
fputs( "\n[mosh-server is exiting.]\n", stdout );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,10 @@ void STMClient::init( void )
|
|||||||
LocaleVar native_ctype = get_ctype();
|
LocaleVar native_ctype = get_ctype();
|
||||||
string native_charset( locale_charset() );
|
string native_charset( locale_charset() );
|
||||||
|
|
||||||
fprintf( stderr, "mosh-client needs a UTF-8 native locale to run.\n\n" );
|
fprintf( stderr, "mosh-client needs a UTF-8 native locale to run.\n\n"
|
||||||
fprintf( stderr, "Unfortunately, the client's environment (%s) specifies\nthe character set \"%s\".\n\n", native_ctype.str().c_str(), native_charset.c_str() );
|
"Unfortunately, the client's environment (%s) specifies\n"
|
||||||
|
"the character set \"%s\".\n\n",
|
||||||
|
native_ctype.str().c_str(), native_charset.c_str() );
|
||||||
int unused __attribute((unused)) = system( "locale" );
|
int unused __attribute((unused)) = system( "locale" );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
@@ -213,10 +215,12 @@ void STMClient::shutdown( void )
|
|||||||
if ( still_connecting() ) {
|
if ( still_connecting() ) {
|
||||||
fprintf( stderr, "\nmosh did not make a successful connection to %s:%s.\n", ip.c_str(), port.c_str() );
|
fprintf( stderr, "\nmosh did not make a successful connection to %s:%s.\n", ip.c_str(), port.c_str() );
|
||||||
fprintf( stderr, "Please verify that UDP port %s is not firewalled and can reach the server.\n\n", port.c_str() );
|
fprintf( stderr, "Please verify that UDP port %s is not firewalled and can reach the server.\n\n", port.c_str() );
|
||||||
fprintf( stderr, "(By default, mosh uses a UDP port between 60000 and 61000. The -p option\nselects a specific UDP port number.)\n" );
|
fputs( "(By default, mosh uses a UDP port between 60000 and 61000. The -p option\n"
|
||||||
|
"selects a specific UDP port number.)\n", stderr );
|
||||||
} else if ( network ) {
|
} else if ( network ) {
|
||||||
if ( !clean_shutdown ) {
|
if ( !clean_shutdown ) {
|
||||||
fprintf( stderr, "\n\nmosh did not shut down cleanly. Please note that the\nmosh-server process may still be running on the server.\n" );
|
fputs( "\n\nmosh did not shut down cleanly. Please note that the\n"
|
||||||
|
"mosh-server process may still be running on the server.\n", stderr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -337,7 +341,7 @@ bool STMClient::process_user_input( int fd )
|
|||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "\n\033[37;44m[mosh is suspended.]\033[m\n" );
|
fputs( "\n\033[37;44m[mosh is suspended.]\033[m\n", stdout );
|
||||||
|
|
||||||
fflush( NULL );
|
fflush( NULL );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user