Exemple #1
0
/* windows NT DOS dir syntax.
 * looks like:
 *            1         2         3         4         5
 *  012345678901234567890123456789012345678901234567890
 *  06-29-95  03:05PM       <DIR>          muntemp
 *  05-02-95  10:03AM               961590 naxp11e.zip
 *  05-17-2007  07:58PM       <DIR>          muntemp
 *  09-09-2008  03:50AM                 1506 naxp11e.zip
 *  04-06-1995  02:03
 *  07-13-1995  11:39
 *  05-27-11  09:31       <DIR>          3

 *  The date time directory indicator and FindData.cFileName
 *  are always in a fixed position.  The file
 *  size always ends at position 37.
 */
BOOL WINAPI idPRParceDos(const FTPServerInfo* Server, FTPFileInfo* p, char *entry, int entry_len)
{
	NET_FileEntryInfo  entry_info;
	char              *e, *m;
	int offset = 0;
	CHECK((entry_len < 11), FALSE);

	if(entry[10] == ' ')
		offset = 2;

	CHECK((entry_len < 38+offset || entry[17+offset]!=' '), FALSE)
	CHECK((!net_parse_dos_date_time(entry, entry_info.date)), FALSE)
	// <DIR> | digits
	e = SkipSpace(SkipNSpace(entry+15));

	if(StrCmp(e, "<DIR> ",5,FALSE) == 0)
	{
		entry_info.FileType = NET_DIRECTORY;
		m = SkipSpace(e+5);
	}
	else
	{
		m = SkipNSpace(e);
		*m = 0;
		entry_info.size = AtoI(e,(__int64)-1);
		m = SkipSpace(m+1);
		CHECK((entry_info.size == -1), FALSE)
	}

	StrCpy(entry_info.FindData.cFileName, m, ARRAYSIZE(entry_info.FindData.cFileName));
	return ConvertEntry(&entry_info,p);
}
Exemple #2
0
BOOL WINAPI idPRParceMVS(const FTPServerInfo* Server, FTPFileInfo* p, char *entry, int entry_len)
{
	NET_FileEntryInfo ei;
	BOOL needDot = FALSE;
	BOOL hidden = FALSE;
	memset(&ei,0,sizeof(ei));

	if(strncmp(entry,"Volume Unit    Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname",63)==0) return FALSE;

	if(strncmp(entry," Name     VV.MM   Created       Changed      Size  Init   Mod   Id",66)==0) return FALSE;

	if(strncmp(entry," Name      Size   TTR   Alias-of AC --------- Attributes --------- Amode Rmode",78)==0) return FALSE;

	if(strncmp(entry,"No jobs found on Held queue",27)==0) return FALSE;

	if(strlen(entry)>51&&(strncmp(entry+51," PO ",4)==0))
		ei.FileType = NET_DIRECTORY;
	else if(strncmp(entry,"Pseudo Directory",16)==0)
	{
		ei.FileType = NET_DIRECTORY;
//      ei.FileType = NET_SYM_LINK_TO_DIR;
		needDot = TRUE;
	}
	else if(strncmp(entry,"User catalog connector",22)==0)
	{
		ei.FileType = NET_DIRECTORY;
		hidden = TRUE;
		strcpy(ei.UnixMode,"VSAM");
//      ei.FileType = NET_SYM_LINK_TO_DIR;
		needDot = TRUE;
	}
	else if(strncmp(entry+7,"Error determining attributes",28)==0||
	        strncmp(entry+7,"Not Mounted",11)==0)
	{
		strcpy(ei.UnixMode,"-offline-");
		hidden = TRUE;
	}

#define BYTES_PER_TRACK_3380 47476
#define BYTES_PER_TRACK_3390 56664

	if(entry_len>8&&entry[6]!=' '&&entry[8]!=' '&&!needDot) // UNIX like
	{
		memcpy(ei.UnixMode,entry,10);
		ei.UnixMode[10]=0;

		if((entry[0]|0x20)=='d')
			ei.FileType = NET_DIRECTORY;

		if((entry[0]|0x20)=='l')
			ei.FileType = NET_SYM_LINK;

		if(entry[39])
		{
			int sz;
			sscanf(entry+33,"%d",&sz);
			ei.size=sz;
		}

		char* pdata = entry + 41;
		net_convert_unix_date(pdata, ei.date);

		if(entry[15]!=' ')
		{
			memcpy(ei.FTPOwner,entry+15,8+1+8);
			ei.FTPOwner[8+1+8]=0;
		}

		entry += 54;
		entry_len-=54;
		char* s = strstr(entry," -> ");

		if(s)
		{
			*s=0;

			if(s[4]) sscanf(s+4,"%s",ei.Link);
		}
	}
	else if(entry_len>56&&entry[56]!=' ')
	{
		int usedTrk, lrecl, blkSize, type;
		usedTrk=lrecl=blkSize=type=0;

		if(entry[7]!=' ') sscanf(entry+7,"%d",&type);

		if(entry[31]!=' ') sscanf(entry+27,"%d",&usedTrk);

		if(entry[43]!=' ') sscanf(entry+39,"%d",&lrecl);

		if(entry[49]!=' ') sscanf(entry+45,"%d",&blkSize);

		if(type==3380) ei.size = usedTrk * BYTES_PER_TRACK_3380;

		if(type==3390) ei.size = usedTrk * BYTES_PER_TRACK_3390;

		net_parse_mvs_date_time(entry + 14, ei.acc_date);

		if(!needDot) sscanf(entry,"%s",ei.FTPOwner);

		if(entry[52]!=' ')
		{
			memcpy(ei.UnixMode,entry+51,5);
			memcpy(ei.UnixMode+5,entry+33,5);
			ei.UnixMode[10]=0;

			if(strncmp(ei.UnixMode,"VSAM",4)==0||
			        strncmp(ei.UnixMode,"PATH",4)==0||
			        strncmp(ei.UnixMode,"GDG",3)==0)
				hidden=TRUE;
		}

		entry += 56;
		entry_len-=56;
	}
	else if(entry_len>8) // PO
	{
		if(entry_len>62)
		{
			if(entry[15]==' ') // PO F
			{
				net_parse_mvs_date_time(entry + 27, ei.date, TRUE);
				net_parse_mvs_date_time(entry + 16, ei.cr_date);
				int sz;
				sscanf(entry+44,"%d",&sz);
				ei.size=sz;
				sscanf(entry+62,"%s",ei.FTPOwner);
			}
			else if(entry[19]!=' ') // PO U
			{
				UINT sz;
				sscanf(entry+10,"%X",&sz);
				ei.size=sz;

				if(entry[24]!=' ')
					sscanf(entry+24,"%s",ei.Link);
			}
			else               // JES
			{
				UINT sz;
				sscanf(entry+30,"%X",&sz);
				ei.size=sz;
				entry+=10;
			}
		}

		entry[8]=0;
	}

//Name
	entry = SkipSpace(entry);

	if(*entry=='\'') entry++;

	StrCpy(ei.FindData.cFileName, entry, ARRAYSIZE(ei.FindData.cFileName));
	size_t le = strlen(ei.FindData.cFileName);

	if(le&&ei.FindData.cFileName[le-1]=='\'')ei.FindData.cFileName[le-1]=0;

	//e=strchr(ei.FindData.cFileName,'.');
	//if(e) { *(e+1)=0; ei.FileType = NET_DIRECTORY; }
	if(needDot) strcat(ei.FindData.cFileName, ".");

	XP_StripLine(ei.FindData.cFileName);

	if(hidden) ei.FindData.dwFileAttributes|=FILE_ATTRIBUTE_HIDDEN;

//     if(ei.FileType == NET_SYM_LINK_TO_DIR )
//      strcpy(ei.Link,ei.FindData.cFileName);
	return ConvertEntry(&ei,p);
}
Exemple #3
0
/*          1         2         3         4         5         6         7
  01234567890123456789012345678901234567890123456789012345678901234567890123456789
  - [RWCEAFMS] IGOR                         106278016 May 07  2001 w2ksp2.ex
  - [RWCEAFMS] SERG                           102400 Oct 16  2000 UUUUUU.LZH
  - [RWCEAFMS] SERG                            24576 Jun 14  2001 WINSOC.RAR
  - [RWCEAFMS] SERG                             3335 Jan 27  2001 ZD001206.ARJ
  - [RWCEAFMS] COM                            276043 Mar 05  2002 basa_iva.ARJ
  - [RWCEAFMS] SERG                             7680 Apr 27  2001 12032001.xls
  - [RWCEAFMS] COM                           1142784 Jan 29 16:03 Дай мне быть с тобою рядом (Фристайл).mp3
  - [RWCEAFMS] COM                             12288 Dec 20  2001 nds10009.xls
  - [RWCEAFMS] COM                             30000 Jul 16  2002 TRACK22.WAV
  - [RWCEAFMS] ASDU                            22528 Dec 16  2002 '_'-Rбв вRЄ.xls
  - [RWCEAFMS] COM                             96256 Jul 09  2001 ZP010621.XLS
  - [RWCEAFMS] COM                            266240 Jul 27  2001 rgp18i.zip
  d [RWCEAFMS] SERG                              512 Mar 13 14:29 baza_arz
  d [RWCEAFMS] SERG                              512 Mar 10 01:09 chebocs
  d [RWCEAFMS] SERG                              512 Mar 10 01:09 volgskoe
  d [RWCEAFMS] PHD3                              512 Mar 10 01:09 a
  d [RWCEAFMS] TB1                               512 Mar 13 16:08 GEYKO
  d [RWCEAFMS]          0                        512 Apr 11 08:47 admin
  d [RWCEAFMS]          0                        512 Apr 06 04:12 aviso
  -[RWCEMFA]  1 lipinl1       253 Apr 11 00:20 jednicka.asm
*/
BOOL WINAPI idPRParceNETWARE(const FTPServerInfo* Server, FTPFileInfo* p, char *entry, int entry_len)
{
	NET_FileEntryInfo entry_info;
	BOOL              remove_size = FALSE;
	char             *m;

	if(entry_len < 43) return FALSE;

//Dir
	if(NET_TO_UPPER(*entry) == 'D')
	{
		entry_info.FileType = NET_DIRECTORY;
		remove_size          = TRUE; /* size is not useful */
	}
	else

//File
		if(NET_TO_UPPER(*entry) == '-')
		{
			//Plain file
		}
		else
//unk
			return FALSE;

//Attrs
	entry++;

	if(NET_IS_SPACE(*entry)) entry++;

	if(*entry != '[') return FALSE;

	m = SkipNX(entry,']');

	if(*m != ']') return FALSE;

	entry = m+1;
	entry_info.FindData.dwFileAttributes = 0;
//Owner
	entry = SkipSpace(entry);
	m = SkipNSpace(entry);
	StrCpy(entry_info.FTPOwner, entry, (int)(m-entry+1));
	entry = SkipSpace(m);

	if(!NET_IS_DIGIT(*entry))
	{
		m = SkipNSpace(entry);
		StrCpy(entry_info.FTPOwner, entry, (int)(m-entry+1));
		entry = SkipSpace(m);
	}

//Size
	m = SkipDigit(entry);

	if(m[0] != ' ') return FALSE;

	*m = 0;
	entry_info.size = AtoI(entry, (int64_t)-1);
	*m = ' ';

	if(entry_info.size == -1) return FALSE;

	entry = SkipSpace(m);

//Date
	if(!net_convert_unix_date(entry, entry_info.date))
		return FALSE;

	entry = SkipSpace(entry);
//FileName
	StrCpy(entry_info.FindData.cFileName, entry, ARRAYSIZE(entry_info.FindData.cFileName));

	if(!entry_info.FindData.cFileName[0])
		return FALSE;

	if(remove_size) entry_info.size = 0;

	return ConvertEntry(&entry_info,p);
}