示例#1
0
文件: dos.cpp 项目: CyberShadow/FAR
/* 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);
}
示例#2
0
/*
ROOT         21147648 05/29/08 10:16:58 *FILE      AMSAVF.SAVF
ROOT           217088 04/14/08 11:41:28 *FILE      CYN_COLLEC.FILE
ROOT                                    *MEM       CYN_COLLEC.FILE/SH.MBR
ROOT            16384 04/08/08 12:17:34 *FILE      EVFEVENT.FILE
ROOT           954368 04/08/08 11:48:21 *FILE      LIBCCLOG.SAVF
ROOT           163840 04/08/08 11:48:21 *FILE      LIBCFFDC.SAVF
ROOT           503808 04/08/08 11:48:21 *FILE      LIBMSG23.SAVF
QPGMR          143360 08/05/06 18:09:14 *FILE      QAAPFILE.FILE
QPGMR                                   *MEM       QAAPFILE.FILE/QAAPF1X1.MBR
QPGMR                                   *MEM       QAAPFILE.FILE/QAAPF1X2.MBR
QPGMR                                   *MEM       QAAPFILE.FILE/QAAPF2X2.MBR
QSYS           131072 06/27/06 19:12:53 *DIR       QOpenSys/
QDOC            69120 12/31/69 19:00:00 *FLR       QDLS/
QSYS         13778944 07/10/06 16:21:25 *LIB       QSYS.LIB/
QDFTOWN          4096 12/31/69 19:00:00 *DDIR      QOPT/
QSYS             2272 07/05/06 06:08:14 *DDIR      QFileSvr.400/
QDFTOWN          1200 07/05/06 06:08:14 *DDIR      QNTC/
QSYS            40960 06/27/06 19:10:15 *DIR       dev/
QSYS             8192 06/27/06 16:29:44 *DIR       home/
QSYS            12288 07/07/06 23:24:53 *DIR       tmp/
MUELLERJ      1282232 01/18/06 11:40:23 *STMF      PARCELST.TXT
MUELLERJ           58 01/03/06 11:29:17 *STMF      UNTITLED.TXT
*/
BOOL net_parse_ls_line(char *line, NET_FileEntryInfo* entry_info)
{
	char *e;
	int   len;
	static Time_t savedate;
//Owner
	e = SkipNSpace(line);
	CHECK((*e == 0), FALSE)
	len = Min((int)ARRAYSIZE(entry_info->FTPOwner)-1, (int)(e-line));
	StrCpy(entry_info->FTPOwner, line, len+1);
	line = SkipSpace(e);

	if(line[0] != '*')
	{
		//Size
		e = SkipNSpace(line);
		CHECK((*e == 0), FALSE)
		*e = 0;
		entry_info->size = AtoI(line, (__int64)-1);
		*e = ' ';
		CHECK((entry_info->size == (__int64)-1), FALSE)
		//Date
		line = SkipSpace(e);
		CHECK((!parse_os400_date_time(line,entry_info->date)), FALSE)
		//save date of *FILE for *MEM members
		savedate = entry_info->date;
		line = SkipSpace(line);
		CHECK((*line == 0), FALSE)
	}
示例#3
0
__int64 FtpFileSize(Connection *Connect,LPCSTR fnm)
{
	String Command, name;
	BYTE Line[20];

	if(!Connect) return -1;

	if (Connect->Host.ServerType == FTP_TYPE_VMS)
	{
		name = fnm;
		correct_vms_name(name);
		fnm = name.c_str();
	}
	Command.printf("size \x1%s\x1",fnm);

	if(!Connect->ProcessCommand(Command))
	{
		Log(("!size"));
		return -1;
	}
	else
	{
		Connect->GetReply(Line,sizeof(Line));
		return AtoI((LPCSTR)(Line+4),(__int64)-1);
	}
}
示例#4
0
void platycanvasdata::OnUpdated_Stroke(BxPanel* panel, string message, void* data)
{
	if(StrSameCount(message, "Stroke:") == 7)
	{
		BxVar<BxString::Parse> Elements;
		BxString::Parse::Division(Elements, message + 7);
		const byte Thick = (byte) AtoI(Elements[0]);
		const byte Opacity = (byte) AtoI(Elements[1]);
		const byte Aqua = (byte) AtoI(Elements[2]);
		Command::SetThick(THICK_SIZE * Thick / 255);
		Color CurColor = Command::GetColor();
		CurColor.a = Opacity;
		CurColor.aqua = Aqua;
		Command::SetColor(CurColor);
	}
}
示例#5
0
文件: FtpAPI.cpp 项目: elfmz/far2l
int64_t FtpFileSize(Connection *Connect,LPCSTR fnm)
{
	String Command;
	BYTE Line[20];

	if(!Connect) return -1;

	Command.printf("size \x1%s\x1",fnm);

	if(!Connect->ProcessCommand(Command))
	{
		Log(("!size"));
		return -1;
	}
	else
	{
		Connect->GetReply(Line,sizeof(Line));
		return AtoI((LPCSTR)(Line+4),(int64_t)-1);
	}
}
示例#6
0
文件: unix.cpp 项目: CyberShadow/FAR
/*
 *--Full format

            1         2         3         4         5         6         7
  01234567890123456789012345678901234567890123456789012345678901234567890123456789
  Sep  1  1990   - start with ' '
  Sep 11 11:59
  Sep 11 01:59   - start with 0
  Sep 11  1:59   - start with ' '
  Dec 12 1989
  FCv 23 1990

 *--Short format:

            1         2         3         4         5         6         7
  01234567890123456789012345678901234567890123456789012345678901234567890123456789
  f 01:07   - time
  f 01:7    - minutes with one digit
  F 15:43
  f  2002   - only year

 *--Expanded format:

            1         2         3         4         5         6         7
  01234567890123456789012345678901234567890123456789012345678901234567890123456789
 *2005-06-20 14:22
 *2005-07-08 19:21
 *2004-10-14 14:14
 *2004-10-14 14:14
*/
BOOL net_convert_unix_date(LPSTR& datestr, Time_t& decoded)
{
	SYSTEMTIME st;
	GetSystemTime(&st);
	st.wMilliseconds = 0;
	st.wSecond       = 0;
	st.wDayOfWeek    = 0;
	char *bcol = datestr;         /* Column begin */
	char *ecol;                   /* Column end */
	//Expanded format (DDDD-)
	if(NET_IS_DIGIT(bcol[0]) && NET_IS_DIGIT(bcol[1]) && NET_IS_DIGIT(bcol[2]) && NET_IS_DIGIT(bcol[3]) &&
	        bcol[4] == '-')
	{
#define CVT( nm, start, end )              bcol[end] = 0;                       \
	st.nm = atoi(bcol+start);   \
	CHECK( (st.nm == MAX_WORD), FALSE )
		CVT(wYear,   0,  4)
		CVT(wMonth,  5,  7)
		CVT(wDay,    8, 10)
		CVT(wHour,  11, 13)
		CVT(wMinute,14, 16)
#undef CVT
		datestr = bcol + 17;
		return SystemTimeToFileTime(&st, decoded);
	}

	//Month+day or short format
	// (ecol must be set to char after decoded part)
	if(NET_TO_UPPER(bcol[0]) == 'F' &&
	        NET_IS_SPACE(bcol[1]))
	{
		//Short format - ignore month and day
		ecol = bcol + 2;
	}
	else
	{
		//Month
		if(NET_IS_DIGIT(bcol[0]) && NET_IS_DIGIT(bcol[1]) && NET_IS_SPACE(bcol[2]))
			st.wMonth = AtoI(bcol,MAX_WORD);
		else
			st.wMonth = NET_MonthNo(datestr);

		CHECK((st.wMonth == MAX_WORD), FALSE)
		bcol = SkipSpace(SkipNSpace(bcol));
		CHECK((*bcol == 0), FALSE)
		//Day
		ecol = SkipNSpace(bcol);

		if(*ecol != ' ')
			return FALSE;

		*ecol = 0;
		st.wDay = AtoI(bcol,MAX_WORD);
		*ecol = ' ';
		CHECK((st.wDay == MAX_WORD), FALSE)
	}

	//Year or time
	ecol = SkipSpace(ecol);
	bcol = ecol;

	if(bcol[2] != ':' && bcol[1] != ':')
	{
		//Four digits year
		ecol = SkipDigit(bcol);
		CHECK((ecol == bcol), FALSE)
		*ecol = 0;
		st.wYear = AtoI(bcol,MAX_WORD);
		ecol++;
		CHECK((st.wYear == MAX_WORD), FALSE)

		//Only first three digits of year with cut last digit
		if(st.wYear > 190 && st.wYear < 300)
		{
			st.wYear *= 10;
		}

		st.wSecond = 0;
		st.wMinute = 0;
		st.wHour   = 0;
	}
示例#7
0
文件: netware.cpp 项目: elfmz/far2l
/*          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);
}
示例#8
0
Parser::Parser(ifstream* reader,string type)
{
	m_CurPosition = 0;
	m_bufRead = reader;
	m_ResetPoint = reader->tellg();
	m_wigType = "";
	m_LineDelimiter = '\n';
    string line;

	getline(*m_bufRead, line, m_LineDelimiter);
	m_CurPosition += line.size() + NEWLINE_LEN;
    while(!line.empty())
	{
    	if(type == "WIG")
    	{
			string uppercaseLine = Parser::ToUpper(line);
    		if((int)uppercaseLine.find("VARIABLESTEP") >= 0)
			{
				m_bufRead->seekg(m_ResetPoint);
				m_CurPosition = m_ResetPoint;
        		break;
        	}
    		else if((int)uppercaseLine.find("FIXEDSTEP") >= 0)
    		{
				string err = "Wig fixedStep format is not supported\n";
    			throw err;
    		}
    		else if((int)line.find("=") >= 0 || (int)line.find("#") >= 0)
    		{
    			m_ResetPoint = m_CurPosition;
    			getline(*m_bufRead, line, m_LineDelimiter);
				m_CurPosition += line.size() + NEWLINE_LEN;
    			continue;
    		}
    		else
    		{
				string err = "The variableStep definition is missing in the wig file\n";
    			throw err;
    		}
    	}
    	else //BED format
    	{
    		 if((int)line.find("=") >= 0 || (int)line.find("#") >= 0)
    		{
    			m_ResetPoint = m_CurPosition;
    			getline(*m_bufRead, line, m_LineDelimiter);
				m_CurPosition += line.size() + NEWLINE_LEN;
    			continue;
    		}
    		else
    		{
    			vector<string> myelements;
				Tokenize(line, myelements, " \t");
    			if(myelements.size() == 4)
    			{
    				try
					{
						AtoI(myelements[1]);
						AtoI(myelements[2]);
            		}
    				catch(exception& e)
					{
						string err = "Invalid BedGraph file format in line starting with \"" + line + "\"\n";
    					throw err;
    				}
    			}
    			else
    			{
					string err = "Invalid BedGraph file format in line starting with \"" + line + "\"\n";
    				throw err;
    			}
    			m_bufRead->seekg(m_ResetPoint);
				m_CurPosition = m_ResetPoint;
    			break;
    		}
    	}
    }
}