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
@@ -21,3 +21,4 @@
/***************************************************************************/
-
+// changes made by Lorn Potter <llornkcor@handhelds.org>
+//
#if defined(__unix__) || defined(__VMS)
@@ -28,2 +29,3 @@
#endif
+
#include <stdio.h>
@@ -33,3 +35,8 @@
#include <ctype.h>
+
#if defined(__unix__)
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
#include <sys/time.h>
@@ -40,3 +47,5 @@
#include <arpa/inet.h>
+
#elif defined(VMS)
+
#include <types.h>
@@ -46,4 +55,7 @@
#include <inet.h>
+
#elif defined(_WIN32)
+
#include <winsock.h>
+
#endif
@@ -60,3 +72,3 @@
#define FTPLIB_BUFSIZ 8192
-#define ACCEPT_TIMEOUT 15
+#define ACCEPT_TIMEOUT 10
@@ -384,3 +396,3 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
{
- int sControl;
+ int sControl, stat, flags, oldflags;
struct sockaddr_in sin;
@@ -392,2 +404,4 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
char *pnum;
+ struct timeval tv;
+ fd_set wr;
@@ -428,5 +442,8 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
}
+
memcpy((char *)&sin.sin_addr, phe->h_addr, phe->h_length);
+
}
free(lhost);
+
sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
@@ -437,2 +454,3 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
}
+
if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR,
@@ -444,3 +462,12 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
}
- 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)
{
@@ -450,2 +477,26 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
}
+ }
+
+ 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));
@@ -739,2 +790,3 @@ static int FtpAcceptConnection(netbuf *nData, netbuf *nControl)
tv.tv_sec = ACCEPT_TIMEOUT;
+ printf("<<<<<<<<<<<<<<<<%d\n",ACCEPT_TIMEOUT);
i = nControl->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
@@ -6,3 +6,3 @@ Architecture: arm
Version: $QPE_VERSION-$SUB_VERSION
-Depends: opie-base ($QPE_VERSION)
+Depends: opie-base ($QPE_VERSION), ftplib
Description: OpieFtp
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
@@ -16,3 +16,3 @@
extern "C" {
-#include "ftplib.h"
+#include "../ftplib/ftplib.h"
}
@@ -1512 +1512,5 @@ 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
@@ -41,2 +41,3 @@ class QStringList;
class QListBox;
+class QTimer;
@@ -69,2 +70,3 @@ public:
protected slots:
+ void timerOut();
void upDir();
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
@@ -3,3 +3,3 @@ 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
@@ -8,3 +8,3 @@ INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
+LIBS += -lqpe -lftplib