Subversion Repositories tpanel

Rev

Rev 355 | Rev 380 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 355 Rev 370
Line 171... Line 171...
171
        {
171
        {
172
            x = (max >= ctl->cavail) ? ctl->cavail : max - 1;
172
            x = (max >= ctl->cavail) ? ctl->cavail : max - 1;
173
            end = static_cast<char*>(memccpy(bp, ctl->cget, '\n', x));
173
            end = static_cast<char*>(memccpy(bp, ctl->cget, '\n', x));
174
 
174
 
175
            if (end != NULL)
175
            if (end != NULL)
176
                x = end - bp;
176
                x = (int)(end - bp);
177
 
177
 
178
            retval += x;
178
            retval += x;
179
            bp += x;
179
            bp += x;
180
            *bp = '\0';
180
            *bp = '\0';
181
            max -= x;
181
            max -= x;
Line 227... Line 227...
227
        else
227
        else
228
        {
228
        {
229
            if (ctl->tlsctrl)
229
            if (ctl->tlsctrl)
230
                x = SSL_read(ctl->ssl, ctl->cput, ctl->cleft);
230
                x = SSL_read(ctl->ssl, ctl->cput, ctl->cleft);
231
            else
231
            else
232
                x = read(ctl->handle, ctl->cput, ctl->cleft);
232
                x = (int)read(ctl->handle, ctl->cput, ctl->cleft);
233
        }
233
        }
234
 
234
 
235
#else
235
#else
236
        x = read(ctl->handle, ctl->cput, ctl->cleft);
236
        x = read(ctl->handle, ctl->cput, ctl->cleft);
237
#endif
237
#endif
Line 291... Line 291...
291
#ifndef NOSSL
291
#ifndef NOSSL
292
 
292
 
293
                if (nData->tlsctrl)
293
                if (nData->tlsctrl)
294
                    w = SSL_write(nData->ssl, nbp, FTPLIB_BUFSIZ);
294
                    w = SSL_write(nData->ssl, nbp, FTPLIB_BUFSIZ);
295
                else
295
                else
296
                    w = write(nData->handle, nbp, FTPLIB_BUFSIZ);
296
                    w = (int)write(nData->handle, nbp, FTPLIB_BUFSIZ);
297
 
297
 
298
#else
298
#else
299
                w = write(nData->handle, nbp, FTPLIB_BUFSIZ);
299
                w = write(nData->handle, nbp, FTPLIB_BUFSIZ);
300
#endif
300
#endif
301
 
301
 
Line 320... Line 320...
320
#ifndef NOSSL
320
#ifndef NOSSL
321
 
321
 
322
            if (nData->tlsctrl)
322
            if (nData->tlsctrl)
323
                w = SSL_write(nData->ssl, nbp, FTPLIB_BUFSIZ);
323
                w = SSL_write(nData->ssl, nbp, FTPLIB_BUFSIZ);
324
            else
324
            else
325
                w = write(nData->handle, nbp, FTPLIB_BUFSIZ);
325
                w = (int)write(nData->handle, nbp, FTPLIB_BUFSIZ);
326
 
326
 
327
#else
327
#else
328
            w = write(nData->handle, nbp, FTPLIB_BUFSIZ);
328
            w = write(nData->handle, nbp, FTPLIB_BUFSIZ);
329
#endif
329
#endif
330
 
330
 
Line 346... Line 346...
346
        if (!socket_wait(nData))
346
        if (!socket_wait(nData))
347
            return x;
347
            return x;
348
 
348
 
349
#ifndef NOSSL
349
#ifndef NOSSL
350
 
350
 
-
 
351
        if (nData->tlsctrl)
351
        if (nData->tlsctrl) w = SSL_write(nData->ssl, nbp, nb);
352
            w = SSL_write(nData->ssl, nbp, nb);
-
 
353
        else
352
        else w = write(nData->handle, nbp, nb);
354
            w = (int)write(nData->handle, nbp, nb);
353
 
355
 
354
#else
356
#else
355
        w = write(nData->handle, nbp, nb);
357
        w = write(nData->handle, nbp, nb);
356
#endif
358
#endif
357
 
359
 
Line 541... Line 543...
541
 
543
 
542
    snprintf(buf, sizeof(buf), "%s\r\n", cmd);
544
    snprintf(buf, sizeof(buf), "%s\r\n", cmd);
543
 
545
 
544
#ifndef NOSSL
546
#ifndef NOSSL
545
    if (nControl->tlsctrl)
547
    if (nControl->tlsctrl)
546
        x = SSL_write(nControl->ssl, buf, strlen(buf));
548
        x = SSL_write(nControl->ssl, buf, (int)strlen(buf));
547
    else
549
    else
548
        x = write(nControl->handle, buf, strlen(buf));
550
        x = (int)write(nControl->handle, buf, (int)strlen(buf));
549
 
551
 
550
#else
552
#else
551
    x = write(nControl->handle, buf, strlen(buf));
553
    x = write(nControl->handle, buf, strlen(buf));
552
#endif
554
#endif
553
 
555
 
Line 729... Line 731...
729
        buf[i++] = ' ';
731
        buf[i++] = ' ';
730
 
732
 
731
        if ((strlen(path) + i) >= sizeof(buf))
733
        if ((strlen(path) + i) >= sizeof(buf))
732
            return 0;
734
            return 0;
733
 
735
 
734
        strcpy(&buf[i], path);
736
        strncpy(&buf[i], path, sizeof(buf));
735
    }
737
    }
736
 
738
 
737
    if (nControl->cmode == ftplib::pasv)
739
    if (nControl->cmode == ftplib::pasv)
738
    {
740
    {
739
        if (FtpOpenPasv(nControl, nData, mode, dir, buf) == -1)
741
        if (FtpOpenPasv(nControl, nData, mode, dir, buf) == -1)
Line 1032... Line 1034...
1032
 
1034
 
1033
    memcpy(cmd + strlen(cmd), "\r\n\0", 3);
1035
    memcpy(cmd + strlen(cmd), "\r\n\0", 3);
1034
#ifndef NOSSL
1036
#ifndef NOSSL
1035
 
1037
 
1036
    if (nControl->tlsctrl)
1038
    if (nControl->tlsctrl)
1037
        ret = SSL_write(nControl->ssl, cmd, strlen(cmd));
1039
        ret = SSL_write(nControl->ssl, cmd, (int)strlen(cmd));
1038
    else
1040
    else
1039
        ret = write(nControl->handle, cmd, strlen(cmd));
1041
        ret = (int)write(nControl->handle, cmd, (int)strlen(cmd));
1040
 
1042
 
1041
#else
1043
#else
1042
    ret = write(nControl->handle, cmd, strlen(cmd));
1044
    ret = write(nControl->handle, cmd, strlen(cmd));
1043
#endif
1045
#endif
1044
 
1046
 
Line 1107... Line 1109...
1107
 */
1109
 */
1108
int ftplib::FtpClose(ftphandle *nData)
1110
int ftplib::FtpClose(ftphandle *nData)
1109
{
1111
{
1110
    ftphandle *ctrl;
1112
    ftphandle *ctrl;
1111
 
1113
 
-
 
1114
    if (!nData)
-
 
1115
        return 0;
-
 
1116
 
1112
    if (nData->dir == FTPLIB_WRITE)
1117
    if (nData->dir == FTPLIB_WRITE)
1113
    {
1118
    {
1114
        if (nData->buf != NULL)
1119
        if (nData->buf != NULL)
1115
            writeline(NULL, 0, nData);
1120
            writeline(NULL, 0, nData);
1116
    }
1121
    }
Line 1156... Line 1161...
1156
 
1161
 
1157
#ifndef NOSSL
1162
#ifndef NOSSL
1158
        if (nData->tlsdata)
1163
        if (nData->tlsdata)
1159
            i = SSL_read(nData->ssl, buf, max);
1164
            i = SSL_read(nData->ssl, buf, max);
1160
        else
1165
        else
1161
            i = read(nData->handle, buf, max);
1166
            i = (int)read(nData->handle, buf, max);
1162
 
1167
 
1163
#else
1168
#else
1164
        i = read(nData->handle, buf, max);
1169
        i = read(nData->handle, buf, max);
1165
#endif
1170
#endif
1166
    }
1171
    }
Line 1203... Line 1208...
1203
#ifndef NOSSL
1208
#ifndef NOSSL
1204
 
1209
 
1205
        if (nData->tlsdata)
1210
        if (nData->tlsdata)
1206
            i = SSL_write(nData->ssl, buf, len);
1211
            i = SSL_write(nData->ssl, buf, len);
1207
        else
1212
        else
1208
            i = write(nData->handle, buf, len);
1213
            i = (int)write(nData->handle, buf, len);
1209
 
1214
 
1210
#else
1215
#else
1211
        i = write(nData->handle, buf, len);
1216
        i = write(nData->handle, buf, len);
1212
#endif
1217
#endif
1213
    }
1218
    }
Line 1479... Line 1484...
1479
 
1484
 
1480
    dbuf = static_cast<char*>(malloc(FTPLIB_BUFSIZ));
1485
    dbuf = static_cast<char*>(malloc(FTPLIB_BUFSIZ));
1481
 
1486
 
1482
    if ((type == ftplib::filewrite) || (type == ftplib::filewriteappend))
1487
    if ((type == ftplib::filewrite) || (type == ftplib::filewriteappend))
1483
    {
1488
    {
1484
        while ((l = fread(dbuf, 1, FTPLIB_BUFSIZ, local)) > 0)
1489
        while ((l = (int)fread(dbuf, 1, FTPLIB_BUFSIZ, local)) > 0)
1485
        {
1490
        {
1486
            if ((c = FtpWrite(dbuf, l, nData)) < l)
1491
            if ((c = FtpWrite(dbuf, l, nData)) < l)
1487
            {
1492
            {
1488
                std::string msg = string("short write: passed ") + std::to_string(l) + ", wrote " + std::to_string(c);
1493
                std::string msg = string("short write: passed ") + std::to_string(l) + ", wrote " + std::to_string(c);
1489
                errorHandler(msg.c_str(), 0, 0);
1494
                errorHandler(msg.c_str(), 0, 0);
Line 1730... Line 1735...
1730
 
1735
 
1731
        strcpy(buf, "RETR");
1736
        strcpy(buf, "RETR");
1732
 
1737
 
1733
        if (pathSrc != NULL)
1738
        if (pathSrc != NULL)
1734
        {
1739
        {
1735
            int i = strlen(buf);
1740
            int i = (int)strlen(buf);
1736
            buf[i++] = ' ';
1741
            buf[i++] = ' ';
1737
 
1742
 
1738
            if ((strlen(pathSrc) + i) >= sizeof(buf))
1743
            if ((strlen(pathSrc) + i) >= sizeof(buf))
1739
                return 0;
1744
                return 0;
1740
 
1745