summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-09 15:27:29 (UTC)
committer llornkcor <llornkcor>2002-11-09 15:27:29 (UTC)
commitfee37fd9a7c038dbf5cce74172721ca3cdc8745b (patch) (side-by-side diff)
treedc9ed0da618d4ef6e96777e992cfc88fa619656c
parentd5d079c5bfaa10c310628d1ef7905d98b64dfa81 (diff)
downloadopie-fee37fd9a7c038dbf5cce74172721ca3cdc8745b.zip
opie-fee37fd9a7c038dbf5cce74172721ca3cdc8745b.tar.gz
opie-fee37fd9a7c038dbf5cce74172721ca3cdc8745b.tar.bz2
move ftp stuff from opieftp to shared lib
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/ftplib/ftplib.c (renamed from noncore/net/opieftp/ftplib.c)60
-rw-r--r--noncore/net/ftplib/ftplib.control9
-rw-r--r--noncore/net/ftplib/ftplib.h (renamed from noncore/net/opieftp/ftplib.h)0
-rw-r--r--noncore/net/ftplib/ftplib.pro6
-rw-r--r--noncore/net/opieftp/opieftp.control2
-rw-r--r--noncore/net/opieftp/opieftp.cpp6
-rw-r--r--noncore/net/opieftp/opieftp.h2
-rw-r--r--noncore/net/opieftp/opieftp.pro4
8 files changed, 81 insertions, 8 deletions
diff --git a/noncore/net/opieftp/ftplib.c b/noncore/net/ftplib/ftplib.c
index 5116170..421f855 100644
--- a/noncore/net/opieftp/ftplib.c
+++ b/noncore/net/ftplib/ftplib.c
@@ -20,5 +20,6 @@
/* */
/***************************************************************************/
-
+// changes made by Lorn Potter <llornkcor@handhelds.org>
+//
#if defined(__unix__) || defined(__VMS)
#include <unistd.h>
@@ -27,4 +28,5 @@
#include <windows.h>
#endif
+
#include <stdio.h>
#include <stdlib.h>
@@ -32,5 +34,10 @@
#include <errno.h>
#include <ctype.h>
+
#if defined(__unix__)
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -39,5 +46,7 @@
#include <netdb.h>
#include <arpa/inet.h>
+
#elif defined(VMS)
+
#include <types.h>
#include <socket.h>
@@ -45,6 +54,9 @@
#include <netdb.h>
#include <inet.h>
+
#elif defined(_WIN32)
+
#include <winsock.h>
+
#endif
@@ -59,5 +71,5 @@
#define FTPLIB_BUFSIZ 8192
-#define ACCEPT_TIMEOUT 15
+#define ACCEPT_TIMEOUT 10
#define FTPLIB_CONTROL 0
@@ -383,5 +395,5 @@ GLOBALDEF char *FtpLastResponse(netbuf *nControl)
GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
{
- int sControl;
+ int sControl, stat, flags, oldflags;
struct sockaddr_in sin;
struct hostent *phe;
@@ -391,4 +403,6 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
char *lhost;
char *pnum;
+ struct timeval tv;
+ fd_set wr;
memset(&sin,0,sizeof(sin));
@@ -427,7 +441,10 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
return 0;
}
+
memcpy((char *)&sin.sin_addr, phe->h_addr, phe->h_length);
+
}
free(lhost);
+
sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sControl == -1)
@@ -436,4 +453,5 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
return 0;
}
+
if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR,
SETSOCKOPT_OPTVAL_TYPE &on, sizeof(on)) == -1)
@@ -443,5 +461,14 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
return 0;
}
- if (connect(sControl, (struct sockaddr *)&sin, sizeof(sin)) == -1)
+
+ //set nonblocking for connection timeout
+ flags = fcntl( sControl, F_GETFL,0);
+ oldflags=flags;
+ fcntl( sControl, F_SETFL, O_NONBLOCK|flags);
+
+ stat=connect( sControl, (struct sockaddr *)&sin, sizeof(sin));
+ if (stat < 0)
+ {
+ if (errno != EWOULDBLOCK && errno != EINPROGRESS)
{
perror("connect");
@@ -449,4 +476,28 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
return 0;
}
+ }
+
+ FD_ZERO(&wr);
+ FD_SET( sControl, &wr);
+
+ tv.tv_sec = ACCEPT_TIMEOUT;
+ tv.tv_usec = 0;
+
+ stat = select(sControl+1, 0, &wr, 0, &tv);
+
+ if (stat < 1)
+ {
+ // time out has expired,
+ // or an error has ocurred
+ perror("timeout");
+ net_close(sControl);
+ return 0;
+ }
+
+ printf("connected\n");
+
+ //set original flags
+ fcntl( sControl, F_SETFL, oldflags);
+
ctrl = calloc(1,sizeof(netbuf));
if (ctrl == NULL)
@@ -738,4 +789,5 @@ static int FtpAcceptConnection(netbuf *nData, netbuf *nControl)
tv.tv_usec = 0;
tv.tv_sec = ACCEPT_TIMEOUT;
+ printf("<<<<<<<<<<<<<<<<%d\n",ACCEPT_TIMEOUT);
i = nControl->handle;
if (i < nData->handle)
diff --git a/noncore/net/ftplib/ftplib.control b/noncore/net/ftplib/ftplib.control
new file mode 100644
index 0000000..67765ad
--- a/dev/null
+++ b/noncore/net/ftplib/ftplib.control
@@ -0,0 +1,9 @@
+Files: $QTDIR/lib/libftplib.*
+Priority: optional
+Section: Communications
+Maintainer: L.J. Potter <ljp@llornkcor.com>
+Architecture: arm
+Version: $QPE_VERSION-$SUB_VERSION
+Depends: opie-base ($QPE_VERSION)
+Description: Libftp
+ The ftp library for the Opie environment.
diff --git a/noncore/net/opieftp/ftplib.h b/noncore/net/ftplib/ftplib.h
index 75a90ae..75a90ae 100644
--- a/noncore/net/opieftp/ftplib.h
+++ b/noncore/net/ftplib/ftplib.h
diff --git a/noncore/net/ftplib/ftplib.pro b/noncore/net/ftplib/ftplib.pro
new file mode 100644
index 0000000..9ee3605
--- a/dev/null
+++ b/noncore/net/ftplib/ftplib.pro
@@ -0,0 +1,6 @@
+TEMPLATE = lib
+CONFIG = qt warn_on release
+HEADERS = ftplib.h
+SOURCES = ftplib.c
+DESTDIR = $(QTDIR)/lib$(PROJMAK)
+INTERFACES =
diff --git a/noncore/net/opieftp/opieftp.control b/noncore/net/opieftp/opieftp.control
index 18ec80f..42590bd 100644
--- a/noncore/net/opieftp/opieftp.control
+++ b/noncore/net/opieftp/opieftp.control
@@ -5,5 +5,5 @@ Maintainer: L.J. Potter <ljp@llornkcor.com>
Architecture: arm
Version: $QPE_VERSION-$SUB_VERSION
-Depends: opie-base ($QPE_VERSION)
+Depends: opie-base ($QPE_VERSION), ftplib
Description: OpieFtp
The ftp client for the Opie environment.
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 292cc9d..7c83223 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -15,5 +15,5 @@
extern "C" {
-#include "ftplib.h"
+#include "../ftplib/ftplib.h"
}
@@ -1511,2 +1511,6 @@ void OpieFtp::serverListClicked( const QString &item) {
}
}
+
+void OpieFtp::timerOut() {
+
+}
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index 2aa691a..109b5f8 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -40,4 +40,5 @@ class QToolButton;
class QStringList;
class QListBox;
+class QTimer;
class OpieFtp : public QMainWindow
@@ -68,4 +69,5 @@ public:
int currentServerConfig;
protected slots:
+ void timerOut();
void upDir();
void homeButtonPushed();
diff --git a/noncore/net/opieftp/opieftp.pro b/noncore/net/opieftp/opieftp.pro
index 6d88530..ae72ff3 100644
--- a/noncore/net/opieftp/opieftp.pro
+++ b/noncore/net/opieftp/opieftp.pro
@@ -2,10 +2,10 @@ TEMPLATE = app
CONFIG += qt warn_on release
HEADERS = opieftp.h inputDialog.h ftplib.h
-SOURCES = opieftp.cpp inputDialog.cpp ftplib.c main.cpp
+SOURCES = opieftp.cpp inputDialog.cpp main.cpp
TARGET = opieftp
DESTDIR = $(OPIEDIR)/bin
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
+LIBS += -lqpe -lftplib
TRANSLATIONS = ../../../i18n/de/opieftp.ts \