Jacek Caban : wininet: Moved INTERNET_GetNextLine to ftp.c.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Feb 13 07:55:57 CST 2015


Module: wine
Branch: master
Commit: 7410bf5896b9787bb3c3f86a577284d274d83eb0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7410bf5896b9787bb3c3f86a577284d274d83eb0

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Feb 13 12:11:27 2015 +0100

wininet: Moved INTERNET_GetNextLine to ftp.c.

---

 dlls/wininet/ftp.c      | 63 ++++++++++++++++++++++++++++++++++++++++++--
 dlls/wininet/internet.c | 70 -------------------------------------------------
 dlls/wininet/internet.h |  1 -
 3 files changed, 61 insertions(+), 73 deletions(-)

diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 855e5a8..082eb58 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -51,6 +51,12 @@
 #ifdef HAVE_SYS_IOCTL_H
 # include <sys/ioctl.h>
 #endif
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#endif
+#ifdef HAVE_SYS_POLL_H
+# include <sys/poll.h>
+#endif
 #include <time.h>
 #include <assert.h>
 
@@ -70,6 +76,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
 
+#define RESPONSE_TIMEOUT        30
+
 typedef struct _ftp_session_t ftp_session_t;
 
 typedef struct
@@ -2660,6 +2668,57 @@ lend:
     return bSuccess;
 }
 
+/***********************************************************************
+ *           FTP_GetNextLine  (internal)
+ *
+ * Parse next line in directory string listing
+ *
+ * RETURNS
+ *   Pointer to beginning of next line
+ *   NULL on failure
+ *
+ */
+
+static LPSTR FTP_GetNextLine(INT nSocket, LPDWORD dwLen)
+{
+    struct pollfd pfd;
+    INT nRecv = 0;
+    LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
+
+    TRACE("\n");
+
+    pfd.fd = nSocket;
+    pfd.events = POLLIN;
+
+    while (nRecv < MAX_REPLY_LEN)
+    {
+        if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0)
+        {
+            if (sock_recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
+            {
+                INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
+                return NULL;
+            }
+
+            if (lpszBuffer[nRecv] == '\n')
+            {
+                lpszBuffer[nRecv] = '\0';
+                *dwLen = nRecv - 1;
+                TRACE(":%d %s\n", nRecv, lpszBuffer);
+                return lpszBuffer;
+            }
+            if (lpszBuffer[nRecv] != '\r')
+                nRecv++;
+        }
+	else
+	{
+            INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
+            return NULL;
+        }
+    }
+
+    return NULL;
+}
 
 /***********************************************************************
  *           FTP_SendCommandA (internal)
@@ -2759,7 +2818,7 @@ INT FTP_ReceiveResponse(ftp_session_t *lpwfs, DWORD_PTR dwContext)
 
     while(1)
     {
-	if (!INTERNET_GetNextLine(lpwfs->sndSocket, &nRecv))
+	if (!FTP_GetNextLine(lpwfs->sndSocket, &nRecv))
 	    goto lerror;
 
         if (nRecv >= 3)
@@ -3619,7 +3678,7 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT
     
     lpfp->lpszName = NULL;
     do {
-        if(!(pszLine = INTERNET_GetNextLine(nSocket, &nBufLen)))
+        if(!(pszLine = FTP_GetNextLine(nSocket, &nBufLen)))
             return FALSE;
     
         pszToken = strtok(pszLine, szSpace);
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index aa9c259..c915513 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -40,12 +40,6 @@
 #ifdef HAVE_SYS_SOCKET_H
 # include <sys/socket.h>
 #endif
-#ifdef HAVE_POLL_H
-#include <poll.h>
-#endif
-#ifdef HAVE_SYS_POLL_H
-# include <sys/poll.h>
-#endif
 #ifdef HAVE_SYS_TIME_H
 # include <sys/time.h>
 #endif
@@ -85,8 +79,6 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
 
-#define RESPONSE_TIMEOUT        30
-
 typedef struct
 {
     DWORD  dwError;
@@ -3918,68 +3910,6 @@ LPSTR INTERNET_GetResponseBuffer(void)
     return lpwite->response;
 }
 
-/***********************************************************************
- *           INTERNET_GetNextLine  (internal)
- *
- * Parse next line in directory string listing
- *
- * RETURNS
- *   Pointer to beginning of next line
- *   NULL on failure
- *
- */
-
-LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen)
-{
-    struct pollfd pfd;
-    BOOL bSuccess = FALSE;
-    INT nRecv = 0;
-    LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
-
-    TRACE("\n");
-
-    pfd.fd = nSocket;
-    pfd.events = POLLIN;
-
-    while (nRecv < MAX_REPLY_LEN)
-    {
-        if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0)
-        {
-            if (sock_recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
-            {
-                INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
-                goto lend;
-            }
-
-            if (lpszBuffer[nRecv] == '\n')
-	    {
-		bSuccess = TRUE;
-                break;
-	    }
-            if (lpszBuffer[nRecv] != '\r')
-                nRecv++;
-        }
-	else
-	{
-            INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
-            goto lend;
-        }
-    }
-
-lend:
-    if (bSuccess)
-    {
-        lpszBuffer[nRecv] = '\0';
-	*dwLen = nRecv - 1;
-        TRACE(":%d %s\n", nRecv, lpszBuffer);
-        return lpszBuffer;
-    }
-    else
-    {
-        return NULL;
-    }
-}
-
 /**********************************************************
  *	InternetQueryDataAvailable (WININET.@)
  *
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index 23f4a41..f0b09c8 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -430,7 +430,6 @@ void INTERNET_SetLastError(DWORD dwError) DECLSPEC_HIDDEN;
 DWORD INTERNET_GetLastError(void) DECLSPEC_HIDDEN;
 DWORD INTERNET_AsyncCall(task_header_t*) DECLSPEC_HIDDEN;
 LPSTR INTERNET_GetResponseBuffer(void) DECLSPEC_HIDDEN;
-LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen) DECLSPEC_HIDDEN;
 
 VOID SendAsyncCallback(object_header_t *hdr, DWORD_PTR dwContext,
                        DWORD dwInternetStatus, LPVOID lpvStatusInfo,




More information about the wine-cvs mailing list