summaryrefslogtreecommitdiff
path: root/noncore/net/ftplib/ftplib.c
Unidiff
Diffstat (limited to 'noncore/net/ftplib/ftplib.c') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/ftplib/ftplib.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/noncore/net/ftplib/ftplib.c b/noncore/net/ftplib/ftplib.c
index 421f855..efcd6f0 100644
--- a/noncore/net/ftplib/ftplib.c
+++ b/noncore/net/ftplib/ftplib.c
@@ -937,49 +937,50 @@ GLOBALDEF int FtpRead(void *buf, int max, netbuf *nData)
937 { 937 {
938 nData->xfered1 += i; 938 nData->xfered1 += i;
939 if (nData->xfered1 > nData->cbbytes) 939 if (nData->xfered1 > nData->cbbytes)
940 { 940 {
941 if (nData->idlecb(nData, nData->xfered, nData->idlearg) == 0) 941 if (nData->idlecb(nData, nData->xfered, nData->idlearg) == 0)
942 return 0; 942 return 0;
943 nData->xfered1 = 0; 943 nData->xfered1 = 0;
944 } 944 }
945 } 945 }
946 return i; 946 return i;
947} 947}
948 948
949/* 949/*
950 * FtpWrite - write to a data connection 950 * FtpWrite - write to a data connection
951 */ 951 */
952GLOBALDEF int FtpWrite(void *buf, int len, netbuf *nData) 952GLOBALDEF int FtpWrite(void *buf, int len, netbuf *nData)
953{ 953{
954 int i; 954 int i;
955 if (nData->dir != FTPLIB_WRITE) 955 if (nData->dir != FTPLIB_WRITE)
956 return 0; 956 return 0;
957 if (nData->buf) 957 if (nData->buf)
958 i = writeline(buf, len, nData); 958 i = writeline(buf, len, nData);
959 else 959 else
960 { 960 {
961 socket_wait(nData); 961 if (socket_wait(nData) < 0)
962 fprintf(stderr, "FtpWrite: socket_wait failed with %s\n", nData->ctrl->response);
962 i = net_write(nData->handle, buf, len); 963 i = net_write(nData->handle, buf, len);
963 } 964 }
964 if (i == -1) 965 if (i == -1)
965 return 0; 966 return 0;
966 nData->xfered += i; 967 nData->xfered += i;
967 if (nData->idlecb && nData->cbbytes) 968 if (nData->idlecb && nData->cbbytes)
968 { 969 {
969 nData->xfered1 += i; 970 nData->xfered1 += i;
970 if (nData->xfered1 > nData->cbbytes) 971 if (nData->xfered1 > nData->cbbytes)
971 { 972 {
972 nData->idlecb(nData, nData->xfered, nData->idlearg); 973 nData->idlecb(nData, nData->xfered, nData->idlearg);
973 nData->xfered1 = 0; 974 nData->xfered1 = 0;
974 } 975 }
975 } 976 }
976 return i; 977 return i;
977} 978}
978 979
979/* 980/*
980 * FtpClose - close a data connection 981 * FtpClose - close a data connection
981 */ 982 */
982GLOBALDEF int FtpClose(netbuf *nData) 983GLOBALDEF int FtpClose(netbuf *nData)
983{ 984{
984 netbuf *ctrl; 985 netbuf *ctrl;
985 switch (nData->dir) 986 switch (nData->dir)
@@ -1318,29 +1319,32 @@ GLOBALDEF int FtpRename(const char *src, const char *dst, netbuf *nControl)
1318 * 1319 *
1319 * return 1 if successful, 0 otherwise 1320 * return 1 if successful, 0 otherwise
1320 */ 1321 */
1321GLOBALDEF int FtpDelete(const char *fnm, netbuf *nControl) 1322GLOBALDEF int FtpDelete(const char *fnm, netbuf *nControl)
1322{ 1323{
1323 char cmd[256]; 1324 char cmd[256];
1324 1325
1325 if ((strlen(fnm) + 7) > sizeof(cmd)) 1326 if ((strlen(fnm) + 7) > sizeof(cmd))
1326 return 0; 1327 return 0;
1327 sprintf(cmd,"DELE %s",fnm); 1328 sprintf(cmd,"DELE %s",fnm);
1328 if (!FtpSendCmd(cmd,'2', nControl)) 1329 if (!FtpSendCmd(cmd,'2', nControl))
1329 return 0; 1330 return 0;
1330 return 1; 1331 return 1;
1331} 1332}
1332 1333
1333/* 1334/*
1334 * FtpQuit - disconnect from remote 1335 * FtpQuit - disconnect from remote
1335 * 1336 *
1336 * return 1 if successful, 0 otherwise 1337 * return 1 if successful, 0 otherwise
1337 */ 1338 */
1338GLOBALDEF void FtpQuit(netbuf *nControl) 1339GLOBALDEF void FtpQuit(netbuf *nControl)
1339{ 1340{
1340 if (nControl->dir != FTPLIB_CONTROL) 1341 if (nControl->dir != FTPLIB_CONTROL)
1341 return; 1342 return;
1342 FtpSendCmd("QUIT",'2',nControl); 1343 if (FtpSendCmd("QUIT",'2',nControl) == 1) {
1344 if (ftplib_debug > 2)
1345 fprintf(stderr, "FtpQuit: FtpSendCmd(QUIT) failed\n");
1346 }
1343 net_close(nControl->handle); 1347 net_close(nControl->handle);
1344 free(nControl->buf); 1348 free(nControl->buf);
1345 free(nControl); 1349 free(nControl);
1346} 1350}