@@ -251,6 +251,9 @@ char *port = NULL;
251
251
/* This is set password if given on the command line. */
252
252
char * password = NULL ;
253
253
254
+ /* This is set ssh_config if given on the command line. */
255
+ char * ssh_config = NULL ;
256
+
254
257
int ipv_restrict = 0 ;
255
258
256
259
#define ONLY_IPV4 1
@@ -811,6 +814,10 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
811
814
args [i ++ ] = "-p" ;
812
815
args [i ++ ] = port ;
813
816
}
817
+ if (ssh_config ) {
818
+ args [i ++ ] = "-F" ;
819
+ args [i ++ ] = ssh_config ;
820
+ }
814
821
if (remuser != NULL ) {
815
822
args [i ++ ] = "-l" ;
816
823
args [i ++ ] = remuser ;
@@ -893,6 +900,18 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
893
900
NULL
894
901
);
895
902
903
+ if (port )
904
+ free (port );
905
+
906
+ if (cipher )
907
+ free (cipher );
908
+
909
+ if (identity )
910
+ free (identity );
911
+
912
+ if (ssh_config )
913
+ free (ssh_config );
914
+
896
915
if (!rc ) {
897
916
printf ("%s could not be started\n" , ssh_program );
898
917
exit (1 );
@@ -1100,32 +1119,67 @@ main(int argc, char **argv)
1100
1119
case '1' :
1101
1120
case '2' :
1102
1121
case '4' :
1122
+ ipv_restrict = ONLY_IPV4 ;
1123
+ break ;
1103
1124
case '6' :
1125
+ ipv_restrict = ONLY_IPV6 ;
1126
+ break ;
1104
1127
case 'C' :
1105
1128
addargs (& args , "-%c" , ch );
1106
1129
addargs (& remote_remote_args , "-%c" , ch );
1130
+
1131
+ compress = ch ;
1132
+
1107
1133
break ;
1108
1134
case '3' :
1109
1135
throughlocal = 1 ;
1110
1136
break ;
1111
1137
case 'o' :
1112
1138
case 'c' :
1139
+ addargs (& remote_remote_args , "-%c" , ch );
1140
+ addargs (& remote_remote_args , "%s" , optarg );
1141
+ addargs (& args , "-%c" , ch );
1142
+ addargs (& args , "%s" , optarg );
1143
+
1144
+ cipher = malloc (strlen (optarg ) + 1 );
1145
+ if (cipher )
1146
+ strcpy (cipher , optarg );
1147
+ break ;
1113
1148
case 'i' :
1114
- case 'F' :
1149
+ addargs (& remote_remote_args , "-%c" , ch );
1150
+ addargs (& remote_remote_args , "%s" , optarg );
1151
+ addargs (& args , "-%c" , ch );
1152
+ addargs (& args , "%s" , optarg );
1153
+
1154
+ identity = malloc (strlen (optarg ) + 1 );
1155
+ if (identity )
1156
+ strcpy (identity , optarg );
1157
+ break ;
1158
+ case 'F' :
1115
1159
addargs (& remote_remote_args , "-%c" , ch );
1116
1160
addargs (& remote_remote_args , "%s" , optarg );
1117
1161
addargs (& args , "-%c" , ch );
1118
1162
addargs (& args , "%s" , optarg );
1119
- break ;
1163
+
1164
+ ssh_config = malloc (strlen (optarg ) + 1 );
1165
+ if (ssh_config )
1166
+ strcpy (ssh_config , optarg );
1167
+ break ;
1120
1168
case 'P' :
1121
1169
addargs (& remote_remote_args , "-p" );
1122
1170
addargs (& remote_remote_args , "%s" , optarg );
1123
1171
addargs (& args , "-p" );
1124
1172
addargs (& args , "%s" , optarg );
1173
+
1174
+ port = malloc (strlen (optarg ) + 1 );
1175
+ if (port )
1176
+ strcpy (port , optarg );
1125
1177
break ;
1126
1178
case 'B' :
1127
1179
addargs (& remote_remote_args , "\"-oBatchmode yes\"" );
1128
1180
addargs (& args , "\"-oBatchmode yes\"" );
1181
+
1182
+ batchmode = 1 ;
1129
1183
break ;
1130
1184
case 'l' :
1131
1185
limit_kbps = strtonum (optarg , 1 , 100 * 1024 * 1024 ,
@@ -1590,7 +1644,17 @@ rsource(char *name, struct stat *statp)
1590
1644
(void ) snprintf (path , sizeof path , "D%04o %d %.1024s\n" ,
1591
1645
(u_int ) (statp -> st_mode & FILEMODEMASK ), 0 , last );
1592
1646
if (verbose_mode )
1593
- fprintf (stderr , "Entering directory: %s" , path );
1647
+ #ifdef WINDOWS
1648
+ {
1649
+ printf ("Entering directory: " );
1650
+ wchar_t * wtmp = utf8_to_utf16 (path );
1651
+ WriteConsoleW (GetStdHandle (STD_ERROR_HANDLE ), wtmp , wcslen (wtmp ), 0 , 0 );
1652
+ free (wtmp );
1653
+ }
1654
+ #else
1655
+ fprintf (stderr , "Entering directory: %s" , path );
1656
+ #endif
1657
+
1594
1658
(void ) atomicio (vwrite , remout , path , strlen (path ));
1595
1659
if (response () < 0 ) {
1596
1660
closedir (dirp );
@@ -1665,8 +1729,16 @@ sink(int argc, char **argv)
1665
1729
} while (cp < & buf [sizeof (buf ) - 1 ] && ch != '\n' );
1666
1730
* cp = 0 ;
1667
1731
if (verbose_mode )
1668
- fprintf (stderr , "Sink: %s" , buf );
1669
-
1732
+ #ifdef WINDOWS
1733
+ {
1734
+ printf ("Sink: " );
1735
+ wchar_t * wtmp = utf8_to_utf16 (buf );
1736
+ WriteConsoleW (GetStdHandle (STD_ERROR_HANDLE ), wtmp , wcslen (wtmp ), 0 , 0 );
1737
+ free (wtmp );
1738
+ }
1739
+ #else
1740
+ fprintf (stderr , "Sink: %s" , buf );
1741
+ #endif
1670
1742
if (buf [0 ] == '\01' || buf [0 ] == '\02' ) {
1671
1743
if (iamremote == 0 )
1672
1744
(void ) atomicio (vwrite , STDERR_FILENO ,
0 commit comments