65
65
66
66
#ifdef WIN32_FIXME
67
67
68
- //#include <sys/socket.h>
69
-
70
- //#define mkdir(a, b) _mkdir(a)
71
-
72
- //#define lstat(PATH, BUF) _stat(PATH, BUF)
73
-
74
- /*
75
- * Don't use fstat() function redefined
76
- * in socket.h ported header. It is wrong
77
- * in this context.
78
- */
79
-
80
- //#ifdef fstat
81
- //#undef fstat
82
- //#endif
83
-
84
68
int glob (const char * pattern , int flags , int (* errfunc )(const char * epath , int eerrno ),
85
69
glob_t * pglob )
86
70
{
124
108
//free(pglob);
125
109
}
126
110
}
127
-
128
- pid_t waitpid (pid_t pid , int * stat_loc , int options )
129
- {
130
- return 0 ;
131
- }
132
-
133
- /*
134
- * Write array of buffers to file descriptor.
135
- *
136
- * fd - file descriptor to write (IN).
137
- * iovec - array of iovec with buffers to send (IN).
138
- * iovecnt - number of buffers in iovec (IN).
139
- *
140
- * RETURNS: Number of bytes written or -1 if error.
141
- */
142
-
111
+
112
+ /** TODO - Move this to POSIX wrapper**/
113
+ /* ??? What if fd is nonblocking ???*/
143
114
int writev (int fd , struct iovec * iov , int iovcnt )
144
115
{
145
- int written = 0 ;
116
+ int written = 0 ;
146
117
147
- int i = 0 ;
148
-
149
- for (i = 0 ; i < iovcnt ; i ++ )
150
- {
151
- int ret = write (fd , iov [i ].iov_base , iov [i ].iov_len );
118
+ int i = 0 ;
152
119
153
- if (ret > 0 )
154
- {
155
- written += ret ;
156
- }
157
- }
158
-
159
- return written ;
120
+ for (i = 0 ; i < iovcnt ; i ++ )
121
+ {
122
+ int ret = write (fd , iov [i ].iov_base , iov [i ].iov_len );
123
+
124
+ if (ret > 0 )
125
+ {
126
+ written += ret ;
127
+ }
128
+ }
129
+
130
+ return written ;
160
131
}
161
132
162
133
#endif
@@ -1315,16 +1286,9 @@ do_download(struct sftp_conn *conn, const char *remote_path,
1315
1286
return (-1 );
1316
1287
}
1317
1288
1318
- #if (0 )//def WIN32_FIXME
1319
-
1320
- local_fd = _open (local_path ,
1321
- O_WRONLY | O_CREAT | O_BINARY | (resume_flag ? 0 : O_TRUNC ), mode | S_IWUSR );
1322
-
1323
- #else
1324
- local_fd = open (local_path ,
1325
- O_WRONLY | O_CREAT | (resume_flag ? 0 : O_TRUNC ), mode | S_IWUSR ); // PRAGMA:TODO
1289
+ local_fd = open (local_path ,
1290
+ O_WRONLY | O_CREAT | (resume_flag ? 0 : O_TRUNC ), mode | S_IWUSR );
1326
1291
1327
- #endif
1328
1292
1329
1293
if (local_fd == -1 ) {
1330
1294
error ("Couldn't open local file \"%s\" for writing: %s" ,
@@ -1433,16 +1397,8 @@ do_download(struct sftp_conn *conn, const char *remote_path,
1433
1397
fatal ("Received more data than asked for "
1434
1398
"%zu > %zu" , len , req -> len );
1435
1399
if ((lseek (local_fd , req -> offset , SEEK_SET ) == -1 ||
1436
- #if (0 )//def WIN32_FIXME
1437
-
1438
- atomicio (_write , local_fd , data , len ) != len ) & &
1439
-
1440
- #else
1441
-
1442
1400
atomicio (vwrite , local_fd , data , len ) != len ) &&
1443
1401
1444
- #endif
1445
-
1446
1402
!write_error ) {
1447
1403
write_errno = errno ;
1448
1404
write_error = 1 ;
@@ -1556,15 +1512,7 @@ do_download(struct sftp_conn *conn, const char *remote_path,
1556
1512
}
1557
1513
#endif
1558
1514
}
1559
- #if (0 )//def WIN32_FIXME
1560
-
1561
- _close (local_fd );
1562
-
1563
- #else
1564
-
1565
1515
close (local_fd );
1566
-
1567
- #endif
1568
1516
sshbuf_free (msg );
1569
1517
free (handle );
1570
1518
@@ -1730,15 +1678,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
1730
1678
}
1731
1679
if (!S_ISREG (sb .st_mode )) {
1732
1680
error ("%s is not a regular file" , local_path );
1733
- #if (0 )//def WIN32_FIXME
1734
-
1735
- _close (local_fd );
1736
-
1737
- #else
1738
-
1739
1681
close (local_fd );
1740
-
1741
- #endif
1742
1682
return (-1 );
1743
1683
}
1744
1684
stat_to_attrib (& sb , & a );
@@ -1789,16 +1729,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
1789
1729
handle = get_handle (conn , id , & handle_len ,
1790
1730
"remote open(\"%s\")" , remote_path );
1791
1731
if (handle == NULL ) {
1792
- #if (0 )//def WIN32_FIXME
1793
-
1794
- _close (local_fd );
1795
-
1796
- #else
1797
-
1798
1732
close (local_fd );
1799
-
1800
- #endif
1801
-
1802
1733
sshbuf_free (msg );
1803
1734
return -1 ;
1804
1735
}
@@ -1824,16 +1755,8 @@ do_upload(struct sftp_conn *conn, const char *local_path,
1824
1755
if (interrupted || status != SSH2_FX_OK )
1825
1756
len = 0 ;
1826
1757
else do
1827
- #if (0 )//def WIN32_FIXME
1828
-
1829
- len = _read (local_fd , data , conn -> transfer_buflen );
1830
-
1831
- #else
1832
-
1833
1758
len = read (local_fd , data , conn -> transfer_buflen );
1834
1759
1835
- #endif
1836
-
1837
1760
while ((len == -1 ) &&
1838
1761
(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK ));
1839
1762
@@ -1916,16 +1839,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
1916
1839
status = SSH2_FX_FAILURE ;
1917
1840
}
1918
1841
1919
- #if (0 )//def WIN32_FIXME
1920
-
1921
- if (_close (local_fd ) == -1 )
1922
- {
1923
-
1924
- #else
1925
-
1926
1842
if (close (local_fd ) == -1 ) {
1927
-
1928
- #endif
1929
1843
error ("Couldn't close local file \"%s\": %s" , local_path ,
1930
1844
strerror (errno ));
1931
1845
status = SSH2_FX_FAILURE ;
0 commit comments