Skip to content

Commit

Permalink
Improved Instructions and fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mkulke committed Apr 28, 2019
1 parent 0876974 commit 868547e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
1 change: 1 addition & 0 deletions CREDITS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Thomas Pfau (ftplib author)
Eli Moulton (bugfix)
wangxi19 (bugfix)
5 changes: 4 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v2.0.5
- Fixed Bug when seeking on potentially unopened file.

v2.0.4

- Added support for MSVC 2012.
Expand Down Expand Up @@ -34,4 +37,4 @@ v1.0.1

- ftplib::Fxp was always returning 0, fixed this.
- Quit returns if there's no connection anymore to do QUIT.
- Fixed a bug in secure upload.
- Fixed a bug in secure upload.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ FROM debian:jessie

RUN apt-get -y update
RUN apt-get -y install build-essential libssl-dev
COPY / /src
WORKDIR /src
CMD make
# COPY / /src
# WORKDIR /src
# CMD make
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ DEPFLAGS =

UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
LIBS = -lssl -lcrypto
SOFLAG=install_name
ifndef NOSSL
LIBS = -lssl -lcrypto
else
LIBS =
endif
endif
ifeq ($(UNAME), Linux)
LIBS = -lssl
SOFLAG=soname
ifndef NOSSL
LIBS = -lssl
else
LIBS =
endif
endif

all : $(TARGETS)
Expand All @@ -41,19 +51,14 @@ install : all
depend :
$(CC) $(CFLAGS) -M $(SOURCES) > .depend

# build without -fPIC
#unshared/ftplib.o: ftplib.cpp ftplib.h
# -mkdir unshared
# $(CC) -c $(CFLAGS) -D_REENTRANT $< -o $@

ftplib.o: ftplib.cpp ftplib.h
$(CC) -c $(CFLAGS) -fPIC -D_REENTRANT $< -o $@
$(CC) -c $(CFLAGS) -fPIC -D_REENTRANT -DNOSSL $< -o $@

libftp++.a: ftplib.o
ar -rcs $@ $<

libftp.so.$(SOVERSION): ftplib.o
$(CC) -shared -Wl,-soname,libftp.so.$(SONAME) $(LIBS) -lc -o $@ $<
$(CC) -shared -Wl,-$(SOFLAG),libftp.so.$(SONAME) $(LIBS) -lc -o $@ $<

libftp++.so: libftp.so.$(SOVERSION)
ln -sf $< libftp.so.$(SONAME)
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

Platform independent c++ library providing ftp client functionality.

ftplibpp contains a c++ class providing ftp client functionality. It supports all basic
ftp functionality plus some advanced features like resuming, fxp, ssl/tls encryption,
large file support, or logging to fit todays standards.
ftplibpp contains a c++ class providing ftp client functionality. It supports all basic ftp functionality plus some advanced features like resuming, fxp, ssl/tls encryption, large file support, or logging to fit todays standards.

## Build

### Docker (Linux)

```
docker build -t build-env .
docker run -e -v $PWD:/src -w /src build-env make
```

### MacOS without SSL

```
NOSSL=1 make
```

## Documentation

Expand Down
25 changes: 14 additions & 11 deletions ftplib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ typedef int socklen_t;
#define strdup _strdup
#endif

#ifndef NOLFS
#define _fseek fseek
#define _fopen fopen
#else
#define _fseek fseeko64
#define _fopen fopen64
#endif

using namespace std;

/* socket values */
Expand Down Expand Up @@ -1198,9 +1206,6 @@ int ftplib::FtpXfer(const char *localfile, const char *path, ftphandle *nControl

if (localfile != NULL)
{
// printf("localfile: -%s-", localfile);

//local = fopen(localfile, (typ == ftplib::filewrite) ? "r" : "w");
char ac[3] = " ";
if ((type == ftplib::dir) || (type == ftplib::dirverbose)) { ac[0] = 'w'; ac[1] = '\0'; }
if (type == ftplib::fileread) { ac[0] = 'w'; ac[1] = '\0'; }
Expand All @@ -1209,22 +1214,20 @@ int ftplib::FtpXfer(const char *localfile, const char *path, ftphandle *nControl
if (type == ftplib::filewrite) { ac[0] = 'r'; ac[1] = '\0'; }
if (mode == ftplib::image) ac[1] = 'b';

#ifndef NOLFS
local = fopen64(localfile, ac);
if (type == ftplib::filewriteappend) fseeko64(local,mp_ftphandle->offset,SEEK_SET);
#else
local = fopen(localfile, ac);
if (type == ftplib::filewriteappend) fseek(local,mp_ftphandle->offset,SEEK_SET);
#endif
local = _fopen(localfile, ac);
if (local == NULL)
{
strncpy(nControl->response, strerror(errno), sizeof(nControl->response));
return 0;
}
if (type == ftplib::filewriteappend) _fseek(local,mp_ftphandle->offset,SEEK_SET);
}
if (local == NULL) local = ((type == ftplib::filewrite)
|| (type == ftplib::filewriteappend)) ? stdin : stdout;
if (!FtpAccess(path, type, mode, nControl, &nData)) return 0;
if (!FtpAccess(path, type, mode, nControl, &nData)) {
if (localfile != NULL) fclose(local);
return 0;
}

dbuf = static_cast<char*>(malloc(FTPLIB_BUFSIZ));
if ((type == ftplib::filewrite) || (type == ftplib::filewriteappend))
Expand Down

0 comments on commit 868547e

Please sign in to comment.