[WININET] Support for WinNT FTP directory format.

Lionel Ulmer lionel.ulmer at free.fr
Tue Jul 15 13:17:05 CDT 2003


This makes RO's patching tool go a tad bit further... It still fails, but
there are some progresses :-)

                Lionel

Changelog:
 - fix spec file for FTPFindFirstFileA/W functions
 - implement parsing of NT directory format
 
-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: dlls/wininet/ftp.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/ftp.c,v
retrieving revision 1.28
diff -u -r1.28 ftp.c
--- dlls/wininet/ftp.c	14 Jan 2003 23:43:42 -0000	1.28
+++ dlls/wininet/ftp.c	15 Jul 2003 18:14:50 -0000
@@ -2521,83 +2521,137 @@
         pszToken = strtok(pszLine, " \t" );
 
         /* HACK! If this is not a file listing skip the line */
-        if (!pszToken || 10 != strlen(pszToken) || nBufLen <= MIN_LEN_DIR_ENTRY)
+        if (!pszToken || nBufLen <= MIN_LEN_DIR_ENTRY)
 	{
             nBufLen = MAX_REPLY_LEN;
             continue;
 	}
-
-        FTP_ParsePermission(pszToken, curFileProp);
-
-        nTokenToSkip = 3;
-        nCount = 0;
-        do
-        {
-            pszToken = strtok( NULL, " \t" );
-            nCount++;
-        } while( nCount <= nTokenToSkip );
-
-        /* Store the size of the file in the param list. */
-        TRACE("nSize-> %s\n", pszToken);
-        if (pszToken != NULL)
-            curFileProp->nSize = atol(pszToken);
-
-        /* Parse last modified time. */
-        nSeconds = 0;
-        nMinutes = 0;
-        nHour    = 0;
-        nDay     = 0;
-        nMonth   = 0;
-        nYear    = 0;
-
-        pszToken = strtok( NULL, " \t" );
-        strncpy(pszMonth, pszToken, MAX_MONTH_LEN);
-        CharUpperA(pszMonth);
-        pszMatch = strstr(szMonths, pszMonth);
-        if( pszMatch != NULL )
-            nMonth = (pszMatch - szMonths) / 3;
-
-        pszToken = strtok(NULL, " \t");
-        TRACE("nDay -> %s\n", pszToken);
-        if (pszToken != NULL)
-            nDay = atoi(pszToken);
-
-        pszToken = strtok(NULL, " \t");
-        pszMinutes = strchr(pszToken, ':');
-        if( pszMinutes != NULL )
-        {
-            pszMinutes++;
-            nMinutes = atoi(pszMinutes);
-            pszHour = pszMinutes - 3;
-            if (pszHour != NULL)
-                nHour = atoi(pszHour);
-            time(&aTime);
-            apTM = localtime( &aTime );
-            nYear = apTM->tm_year;
-        }
-        else
-        {
-            nYear  = atoi(pszToken);
-            nYear -= 1900;
-            nHour  = 12;
-        }
-
-        curFileProp->tmLastModified.tm_sec  = nSeconds;
-        curFileProp->tmLastModified.tm_min  = nMinutes;
-        curFileProp->tmLastModified.tm_hour = nHour;
-        curFileProp->tmLastModified.tm_mday = nDay;
-        curFileProp->tmLastModified.tm_mon  = nMonth;
-        curFileProp->tmLastModified.tm_year = nYear;
-
-        pszToken = strtok(NULL, " \t");
-        if(pszToken != NULL)
-        {
-            curFileProp->lpszName = FTP_strdup(pszToken);
-            TRACE(": %s\n", curFileProp->lpszName);
-        }
-
-        nBufLen = MAX_REPLY_LEN;
-        indexFilePropArray++;
+	if (10 == strlen(pszToken)) {
+	    /* Unix way of parsing ... */
+	    FTP_ParsePermission(pszToken, curFileProp);
+	    
+	    nTokenToSkip = 3;
+	    nCount = 0;
+	    do {
+		pszToken = strtok( NULL, " \t" );
+		nCount++;
+	    } while( nCount <= nTokenToSkip );
+	    
+	    /* Store the size of the file in the param list. */
+	    TRACE("nSize-> %s\n", pszToken);
+	    if (pszToken != NULL)
+		curFileProp->nSize = atol(pszToken);
+	    
+	    /* Parse last modified time. */
+	    nSeconds = 0;
+	    nMinutes = 0;
+	    nHour    = 0;
+	    nDay     = 0;
+	    nMonth   = 0;
+	    nYear    = 0;
+	    
+	    pszToken = strtok( NULL, " \t" );
+	    strncpy(pszMonth, pszToken, MAX_MONTH_LEN);
+	    CharUpperA(pszMonth);
+	    pszMatch = strstr(szMonths, pszMonth);
+	    if( pszMatch != NULL )
+		nMonth = (pszMatch - szMonths) / 3;
+	    
+	    pszToken = strtok(NULL, " \t");
+	    TRACE("nDay -> %s\n", pszToken);
+	    if (pszToken != NULL)
+		nDay = atoi(pszToken);
+	    
+	    pszToken = strtok(NULL, " \t");
+	    pszMinutes = strchr(pszToken, ':');
+	    if( pszMinutes != NULL ) {
+		pszMinutes++;
+		nMinutes = atoi(pszMinutes);
+		pszHour = pszMinutes - 3;
+		if (pszHour != NULL)
+		    nHour = atoi(pszHour);
+		time(&aTime);
+		apTM = localtime( &aTime );
+		nYear = apTM->tm_year;
+	    } else {
+		nYear  = atoi(pszToken);
+		nYear -= 1900;
+		nHour  = 12;
+	    }
+
+	    curFileProp->tmLastModified.tm_sec  = nSeconds;
+	    curFileProp->tmLastModified.tm_min  = nMinutes;
+	    curFileProp->tmLastModified.tm_hour = nHour;
+	    curFileProp->tmLastModified.tm_mday = nDay;
+	    curFileProp->tmLastModified.tm_mon  = nMonth;
+	    curFileProp->tmLastModified.tm_year = nYear;
+	    
+	    pszToken = strtok(NULL, " \t");
+	    if(pszToken != NULL) {
+		curFileProp->lpszName = FTP_strdup(pszToken);
+		TRACE(": %s\n", curFileProp->lpszName);
+	    }
+	    
+	    nBufLen = MAX_REPLY_LEN;
+	    indexFilePropArray++;
+	} else if (8 == strlen(pszToken)) {
+	    /* NT way of parsing ... :
+	       
+	          07-13-03  08:55PM       <DIR>          sakpatch
+		  05-09-03  06:02PM             12656686 2003-04-21bgm_cmd_e.rgz
+	    */
+
+	    curFileProp->permissions = 0xFFFF; /* No idea, put full permission :-) */
+	    
+	    sscanf(pszToken, "%d-%d-%d",
+		   &curFileProp->tmLastModified.tm_mon,
+		   &curFileProp->tmLastModified.tm_mday,
+		   &curFileProp->tmLastModified.tm_year); /* Do we check for Y2K problems ? */
+	    
+	    pszToken = strtok(NULL, " \t");
+	    if (pszToken == NULL) {
+		nBufLen = MAX_REPLY_LEN;
+		continue;
+	    }
+	    sscanf(pszToken, "%d:%d",
+		   &curFileProp->tmLastModified.tm_hour,
+		   &curFileProp->tmLastModified.tm_min);
+	    if ((pszToken[5] == 'P') && (pszToken[6] == 'M')) {
+		curFileProp->tmLastModified.tm_hour += 12;
+	    }
+	    curFileProp->tmLastModified.tm_sec = 0;
+
+	    TRACE("Mod time: %2d:%2d:%2d  %2d/%2d/%2d\n",
+		  curFileProp->tmLastModified.tm_hour, curFileProp->tmLastModified.tm_min, curFileProp->tmLastModified.tm_sec,
+		  curFileProp->tmLastModified.tm_year, curFileProp->tmLastModified.tm_mon, curFileProp->tmLastModified.tm_mday);
+	    
+	    pszToken = strtok(NULL, " \t");
+	    if (pszToken == NULL) {
+		nBufLen = MAX_REPLY_LEN;
+		continue;
+	    }
+	    if (!strcasecmp(pszToken, "<DIR>")) {
+		curFileProp->bIsDirectory = TRUE;
+		TRACE("Is directory\n");
+	    } else {
+		curFileProp->bIsDirectory = FALSE;
+		curFileProp->nSize = atol(pszToken);
+		TRACE("nSize: %ld\n", curFileProp->nSize);
+	    }
+	    
+	    pszToken = strtok(NULL, " \t");
+	    if (pszToken == NULL) {
+		nBufLen = MAX_REPLY_LEN;
+		continue;
+	    }
+	    curFileProp->lpszName = FTP_strdup(pszToken);
+	    TRACE("Name: %s\n", curFileProp->lpszName);
+	    
+	    nBufLen = MAX_REPLY_LEN;
+	    indexFilePropArray++;	    
+	} else {
+	    nBufLen = MAX_REPLY_LEN;
+	}
     }
 
     if (bSuccess && indexFilePropArray)
Index: dlls/wininet/wininet.spec
===================================================================
RCS file: /home/wine/wine/dlls/wininet/wininet.spec,v
retrieving revision 1.39
diff -u -r1.39 wininet.spec
--- dlls/wininet/wininet.spec	16 Jun 2003 19:40:27 -0000	1.39
+++ dlls/wininet/wininet.spec	15 Jul 2003 18:14:51 -0000
@@ -35,8 +35,8 @@
 @ stdcall FtpCreateDirectoryW(ptr wstr)
 @ stdcall FtpDeleteFileA(ptr str)
 @ stub FtpDeleteFileW
-@ stdcall FtpFindFirstFileA(ptr str str long long)
-@ stdcall FtpFindFirstFileW(ptr wstr wstr long long)
+@ stdcall FtpFindFirstFileA(ptr str ptr long long)
+@ stdcall FtpFindFirstFileW(ptr wstr ptr long long)
 @ stdcall FtpGetCurrentDirectoryA(ptr str ptr)
 @ stdcall FtpGetCurrentDirectoryW(ptr wstr ptr)
 @ stdcall FtpGetFileA(ptr str str long long long long)


More information about the wine-patches mailing list