mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 17:15:00 -06:00
9.04 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
8874e4fbc9
commit
829409452d
@@ -2,9 +2,6 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../C/7zCrc.h"
|
||||
}
|
||||
|
||||
struct CCRCTableInit { CCRCTableInit() { CrcGenerateTable(); } } g_CRCTableInit;
|
||||
|
||||
@@ -42,6 +42,9 @@ void ConvertUInt64ToString(UInt64 value, wchar_t *s)
|
||||
*s = L'\0';
|
||||
}
|
||||
|
||||
void ConvertUInt32ToString(UInt32 value, char *s) { ConvertUInt64ToString(value, s); }
|
||||
void ConvertUInt32ToString(UInt32 value, wchar_t *s) { ConvertUInt64ToString(value, s); }
|
||||
|
||||
void ConvertInt64ToString(Int64 value, char *s)
|
||||
{
|
||||
if (value < 0)
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
// Common/IntToString.h
|
||||
|
||||
#ifndef __COMMON_INTTOSTRING_H
|
||||
#define __COMMON_INTTOSTRING_H
|
||||
#ifndef __COMMON_INT_TO_STRING_H
|
||||
#define __COMMON_INT_TO_STRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "Types.h"
|
||||
|
||||
void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base = 10);
|
||||
void ConvertUInt64ToString(UInt64 value, wchar_t *s);
|
||||
|
||||
void ConvertInt64ToString(Int64 value, char *s);
|
||||
void ConvertInt64ToString(Int64 value, wchar_t *s);
|
||||
|
||||
void ConvertUInt32ToString(UInt32 value, char *s);
|
||||
void ConvertUInt32ToString(UInt32 value, wchar_t *s);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@ static bool IsSpaceChar(char c)
|
||||
return (c == ' ' || c == '\t' || c == 0x0D || c == 0x0A);
|
||||
}
|
||||
|
||||
#define SKEEP_SPACES(s, pos) while (IsSpaceChar(s[pos])) pos++;
|
||||
#define SKIP_SPACES(s, pos) while (IsSpaceChar(s[pos])) pos++;
|
||||
|
||||
static bool ReadProperty(const AString &s, int &pos, CXmlProp &prop)
|
||||
{
|
||||
@@ -35,11 +35,11 @@ static bool ReadProperty(const AString &s, int &pos, CXmlProp &prop)
|
||||
if (prop.Name.IsEmpty())
|
||||
return false;
|
||||
|
||||
SKEEP_SPACES(s, pos);
|
||||
SKIP_SPACES(s, pos);
|
||||
if (s[pos++] != '=')
|
||||
return false;
|
||||
|
||||
SKEEP_SPACES(s, pos);
|
||||
SKIP_SPACES(s, pos);
|
||||
if (s[pos++] != '\"')
|
||||
return false;
|
||||
|
||||
@@ -109,7 +109,7 @@ bool CXmlItem::ParseItems(const AString &s, int &pos, int numAllowedLevels)
|
||||
AString finishString = "</";
|
||||
for (;;)
|
||||
{
|
||||
SKEEP_SPACES(s, pos);
|
||||
SKIP_SPACES(s, pos);
|
||||
|
||||
if (s.Mid(pos, finishString.Length()) == finishString)
|
||||
return true;
|
||||
@@ -123,7 +123,7 @@ bool CXmlItem::ParseItems(const AString &s, int &pos, int numAllowedLevels)
|
||||
|
||||
bool CXmlItem::ParseItem(const AString &s, int &pos, int numAllowedLevels)
|
||||
{
|
||||
SKEEP_SPACES(s, pos);
|
||||
SKIP_SPACES(s, pos);
|
||||
|
||||
int pos2 = s.Find('<', pos);
|
||||
if (pos2 < 0)
|
||||
@@ -138,7 +138,7 @@ bool CXmlItem::ParseItem(const AString &s, int &pos, int numAllowedLevels)
|
||||
IsTag = true;
|
||||
|
||||
pos++;
|
||||
SKEEP_SPACES(s, pos);
|
||||
SKIP_SPACES(s, pos);
|
||||
|
||||
for (; pos < s.Length(); pos++)
|
||||
{
|
||||
@@ -153,11 +153,11 @@ bool CXmlItem::ParseItem(const AString &s, int &pos, int numAllowedLevels)
|
||||
int posTemp = pos;
|
||||
for (;;)
|
||||
{
|
||||
SKEEP_SPACES(s, pos);
|
||||
SKIP_SPACES(s, pos);
|
||||
if (s[pos] == '/')
|
||||
{
|
||||
pos++;
|
||||
// SKEEP_SPACES(s, pos);
|
||||
// SKIP_SPACES(s, pos);
|
||||
return (s[pos++] == '>');
|
||||
}
|
||||
if (s[pos] == '>')
|
||||
@@ -181,16 +181,16 @@ bool CXmlItem::ParseItem(const AString &s, int &pos, int numAllowedLevels)
|
||||
}
|
||||
}
|
||||
|
||||
bool SkeepHeader(const AString &s, int &pos, const AString &startString, const AString &endString)
|
||||
static bool SkipHeader(const AString &s, int &pos, const AString &startString, const AString &endString)
|
||||
{
|
||||
SKEEP_SPACES(s, pos);
|
||||
SKIP_SPACES(s, pos);
|
||||
if (s.Mid(pos, startString.Length()) == startString)
|
||||
{
|
||||
pos = s.Find(endString, pos);
|
||||
if (pos < 0)
|
||||
return false;
|
||||
pos += endString.Length();
|
||||
SKEEP_SPACES(s, pos);
|
||||
SKIP_SPACES(s, pos);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -198,12 +198,12 @@ bool SkeepHeader(const AString &s, int &pos, const AString &startString, const A
|
||||
bool CXml::Parse(const AString &s)
|
||||
{
|
||||
int pos = 0;
|
||||
if (!SkeepHeader(s, pos, "<?xml", "?>"))
|
||||
if (!SkipHeader(s, pos, "<?xml", "?>"))
|
||||
return false;
|
||||
if (!SkeepHeader(s, pos, "<!DOCTYPE", ">"))
|
||||
if (!SkipHeader(s, pos, "<!DOCTYPE", ">"))
|
||||
return false;
|
||||
if (!Root.ParseItem(s, pos, 1000))
|
||||
return false;
|
||||
SKEEP_SPACES(s, pos);
|
||||
SKIP_SPACES(s, pos);
|
||||
return (pos == s.Length() && Root.IsTag);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
#include "StdInStream.h"
|
||||
#include "StringConvert.h"
|
||||
#include "UTFConvert.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// "was declared deprecated" disabling
|
||||
@@ -19,6 +22,8 @@ static const char *kIllegalCharMessage = "Illegal character in input stream";
|
||||
|
||||
static LPCTSTR kFileOpenMode = TEXT("r");
|
||||
|
||||
extern int g_CodePage;
|
||||
|
||||
CStdInStream g_StdIn(stdin);
|
||||
|
||||
bool CStdInStream::Open(LPCTSTR fileName)
|
||||
@@ -42,14 +47,18 @@ CStdInStream::~CStdInStream()
|
||||
Close();
|
||||
}
|
||||
|
||||
AString CStdInStream::ScanStringUntilNewLine()
|
||||
AString CStdInStream::ScanStringUntilNewLine(bool allowEOF)
|
||||
{
|
||||
AString s;
|
||||
for (;;)
|
||||
{
|
||||
int intChar = GetChar();
|
||||
if (intChar == EOF)
|
||||
{
|
||||
if (allowEOF)
|
||||
break;
|
||||
throw kEOFMessage;
|
||||
}
|
||||
char c = char(intChar);
|
||||
if (c == kIllegalChar)
|
||||
throw kIllegalCharMessage;
|
||||
@@ -60,6 +69,20 @@ AString CStdInStream::ScanStringUntilNewLine()
|
||||
return s;
|
||||
}
|
||||
|
||||
UString CStdInStream::ScanUStringUntilNewLine()
|
||||
{
|
||||
AString s = ScanStringUntilNewLine(true);
|
||||
int codePage = g_CodePage;
|
||||
if (codePage == -1)
|
||||
codePage = CP_OEMCP;
|
||||
UString dest;
|
||||
if (codePage == CP_UTF8)
|
||||
ConvertUTF8ToUnicode(s, dest);
|
||||
else
|
||||
dest = MultiByteToUnicodeString(s, (UINT)codePage);
|
||||
return dest;
|
||||
}
|
||||
|
||||
void CStdInStream::ReadToString(AString &resultString)
|
||||
{
|
||||
resultString.Empty();
|
||||
|
||||
@@ -19,8 +19,9 @@ public:
|
||||
bool Open(LPCTSTR fileName);
|
||||
bool Close();
|
||||
|
||||
AString ScanStringUntilNewLine();
|
||||
AString ScanStringUntilNewLine(bool allowEOF = false);
|
||||
void ReadToString(AString &resultString);
|
||||
UString ScanUStringUntilNewLine();
|
||||
|
||||
bool Eof();
|
||||
int GetChar();
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
#include "StdOutStream.h"
|
||||
#include "IntToString.h"
|
||||
#include "StdOutStream.h"
|
||||
#include "StringConvert.h"
|
||||
#include "UTFConvert.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// "was declared deprecated" disabling
|
||||
@@ -17,6 +18,8 @@ static const char kNewLineChar = '\n';
|
||||
|
||||
static const char *kFileOpenMode = "wt";
|
||||
|
||||
extern int g_CodePage;
|
||||
|
||||
CStdOutStream g_StdOut(stdout);
|
||||
CStdOutStream g_StdErr(stderr);
|
||||
|
||||
@@ -60,15 +63,23 @@ CStdOutStream & endl(CStdOutStream & outStream)
|
||||
return outStream << kNewLineChar;
|
||||
}
|
||||
|
||||
CStdOutStream & CStdOutStream::operator<<(const char *string)
|
||||
CStdOutStream & CStdOutStream::operator<<(const char *s)
|
||||
{
|
||||
fputs(string, _stream);
|
||||
fputs(s, _stream);
|
||||
return *this;
|
||||
}
|
||||
|
||||
CStdOutStream & CStdOutStream::operator<<(const wchar_t *string)
|
||||
CStdOutStream & CStdOutStream::operator<<(const wchar_t *s)
|
||||
{
|
||||
*this << (const char *)UnicodeStringToMultiByte(string, CP_OEMCP);
|
||||
int codePage = g_CodePage;
|
||||
if (codePage == -1)
|
||||
codePage = CP_OEMCP;
|
||||
AString dest;
|
||||
if (codePage == CP_UTF8)
|
||||
ConvertUnicodeToUTF8(s, dest);
|
||||
else
|
||||
dest = UnicodeStringToMultiByte(s, (UINT)codePage);
|
||||
*this << (const char *)dest;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
#ifndef __COMMON_TYPES_H
|
||||
#define __COMMON_TYPES_H
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../C/Types.h"
|
||||
}
|
||||
|
||||
typedef int HRes;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user