Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix whitespace in ftplib.cpp #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions ftplib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ ftplib::ftplib()
printf("WSAStartup() failed, %lu\n", (unsigned long)GetLastError());
}
#endif

#ifndef NOSSL
SSL_library_init();
#endif
#endif

mp_ftphandle = static_cast<ftphandle *>(calloc(1,sizeof(ftphandle)));
if (mp_ftphandle == NULL) perror("calloc");
Expand Down Expand Up @@ -261,7 +261,7 @@ int ftplib::readline(char *buf,int max,ftphandle *ctl)
else x = net_read(ctl->handle,ctl->cput,ctl->cleft);
}
#else
x = net_read(ctl->handle,ctl->cput,ctl->cleft);
x = net_read(ctl->handle,ctl->cput,ctl->cleft);
#endif
if ( x == -1)
{
Expand Down Expand Up @@ -331,7 +331,7 @@ int ftplib::writeline(char *buf, int len, ftphandle *nData)
else w = net_write(nData->handle, nbp, FTPLIB_BUFSIZ);
#else
w = net_write(nData->handle, nbp, FTPLIB_BUFSIZ);
#endif
#endif
if (w != FTPLIB_BUFSIZ)
{
printf("write(2) returned %d, errno = %d\n", w, errno);
Expand All @@ -348,7 +348,7 @@ int ftplib::writeline(char *buf, int len, ftphandle *nData)
if (nData->tlsctrl) w = SSL_write(nData->ssl, nbp, nb);
else w = net_write(nData->handle, nbp, nb);
#else
w = net_write(nData->handle, nbp, nb);
w = net_write(nData->handle, nbp, nb);
#endif
if (w != nb)
{
Expand All @@ -368,13 +368,12 @@ int ftplib::writeline(char *buf, int len, ftphandle *nData)
int ftplib::readresp(char c, ftphandle *nControl)
{
char match[5];

if (readline(nControl->response,256,nControl) == -1)
{
perror("Control socket read failed");
return 0;
}

if (nControl->response[3] == '-')
{
strncpy(match,nControl->response,3);
Expand Down Expand Up @@ -417,18 +416,18 @@ int ftplib::Connect(const char *host)
int ret;
char *lhost;
char *pnum;

mp_ftphandle->dir = FTPLIB_CONTROL;
mp_ftphandle->ctrl = NULL;
mp_ftphandle->xfered = 0;
mp_ftphandle->xfered1 = 0;
#ifndef NOSSL
#ifndef NOSSL
mp_ftphandle->tlsctrl = 0;
mp_ftphandle->tlsdata = 0;
#endif
mp_ftphandle->offset = 0;
mp_ftphandle->handle = 0;

memset(&sin,0,sizeof(sin));
sin.sin_family = AF_INET;
lhost = strdup(host);
Expand All @@ -453,7 +452,7 @@ int ftplib::Connect(const char *host)
sin.sin_port = pse->s_port;
}
}

#if defined(_WIN32)
if ((sin.sin_addr.s_addr = inet_addr(lhost)) == -1)
#else
Expand All @@ -469,7 +468,7 @@ int ftplib::Connect(const char *host)
}
memcpy((char *)&sin.sin_addr, phe->h_addr, phe->h_length);
}

free(lhost);

sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
Expand All @@ -478,7 +477,7 @@ int ftplib::Connect(const char *host)
perror("socket");
return 0;
}

if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR, SETSOCKOPT_OPTVAL_TYPE &on, sizeof(on)) == -1)
{
perror("setsockopt");
Expand Down Expand Up @@ -532,7 +531,7 @@ int ftplib::FtpSendCmd(const char *cmd, char expresp, ftphandle *nControl)
}

if (mp_ftphandle->logcb != NULL) mp_ftphandle->logcb(buf, mp_ftphandle->cbarg, false);

return readresp(expresp, nControl);
}

Expand Down Expand Up @@ -1410,7 +1409,7 @@ int ftplib::Fxp(ftplib* src, ftplib* dst, const char *pathSrc, const char *pathD
unsigned char v[6];
char buf[256];
int retval = 0;

sprintf(buf, "TYPE %c", mode);
if (!dst->FtpSendCmd(buf,'2',dst->mp_ftphandle)) return -1;
if (!src->FtpSendCmd(buf,'2',src->mp_ftphandle)) return -1;
Expand Down Expand Up @@ -1466,7 +1465,7 @@ int ftplib::Fxp(ftplib* src, ftplib* dst, const char *pathSrc, const char *pathD
hours and i was absolutely clueless, playing around with
ABOR and whatever, when i desperately checked the pftp
source which gave me this final hint. thanks dude(s). */

dst->FtpSendCmd("PASV", '2', dst->mp_ftphandle);
src->readresp('4', src->mp_ftphandle);
return 0;
Expand All @@ -1475,7 +1474,7 @@ int ftplib::Fxp(ftplib* src, ftplib* dst, const char *pathSrc, const char *pathD
retval = (src->readresp('2', src->mp_ftphandle)) & (dst->readresp('2', dst->mp_ftphandle));

}
else
else
{
// PASV src

Expand Down Expand Up @@ -1575,13 +1574,13 @@ int ftplib::NegotiateEncryption()

ret = SSL_connect(mp_ftphandle->ssl);
if (ret == 1) mp_ftphandle->tlsctrl = 1;

if (mp_ftphandle->certcb != NULL)
{
X509 *cert = SSL_get_peer_certificate(mp_ftphandle->ssl);
if (!mp_ftphandle->certcb(mp_ftphandle->cbarg, cert)) return 0;
}

if (ret < 1) return 0;

return 1;
Expand All @@ -1593,7 +1592,7 @@ void ftplib::SetCallbackCertFunction(FtpCallbackCert pointer)
#ifdef NOSSL
(void)pointer;
#else
mp_ftphandle->certcb = pointer;
mp_ftphandle->certcb = pointer;
#endif
}

Expand Down Expand Up @@ -1644,7 +1643,7 @@ void ftplib::ClearHandle()
mp_ftphandle->xfered = 0;
mp_ftphandle->xfered1 = 0;
mp_ftphandle->cbbytes = 0;
#ifndef NOSSL
#ifndef NOSSL
mp_ftphandle->tlsctrl = 0;
mp_ftphandle->tlsdata = 0;
mp_ftphandle->certcb = NULL;
Expand All @@ -1667,9 +1666,9 @@ int ftplib::CorrectPasvResponse(unsigned char *v)
net_close(mp_ftphandle->handle);
return 0;
}

for (int i = 2; i < 6; i++) v[i] = ipholder.sa_data[i];

return 1;
}

Expand All @@ -1685,7 +1684,7 @@ ftphandle* ftplib::RawOpen(const char *path, accesstype type, transfermode mode)
int ftplib::RawClose(ftphandle* handle)
{
return FtpClose(handle);
}
}

int ftplib::RawWrite(void* buf, int len, ftphandle* handle)
{
Expand Down