2009-10-03 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Put all MetalinkParserState subclasses into
	MetalinkParserStateImpl.cc. Use stack to track element structure.
pull/1/head
Tatsuhiro Tsujikawa 2009-10-03 12:52:16 +00:00
parent 99654e4160
commit c55d2e5512
40 changed files with 125 additions and 2419 deletions

View File

@ -1,3 +1,46 @@
2009-10-03 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Put all MetalinkParserState subclasses into
MetalinkParserStateImpl.cc. Use stack to track element structure.
* src/FileMetalinkParserState.cc: Removed
* src/FileMetalinkParserState.h: Removed
* src/FilesMetalinkParserState.cc: Removed
* src/FilesMetalinkParserState.h: Removed
* src/FinMetalinkParserState.cc: Removed
* src/FinMetalinkParserState.h: Removed
* src/HashMetalinkParserState.cc: Removed
* src/HashMetalinkParserState.h: Removed
* src/InitialMetalinkParserState.cc: Removed
* src/InitialMetalinkParserState.h: Removed
* src/LanguageMetalinkParserState.cc: Removed
* src/LanguageMetalinkParserState.h: Removed
* src/Makefile.am
* src/MetalinkMetalinkParserState.cc: Removed
* src/MetalinkMetalinkParserState.h: Removed
* src/MetalinkParserState.h
* src/MetalinkParserStateMachine.cc
* src/MetalinkParserStateMachine.h
* src/OSMetalinkParserState.cc: Removed
* src/OSMetalinkParserState.h: Removed
* src/PieceHashMetalinkParserState.cc: Removed
* src/PieceHashMetalinkParserState.h: Removed
* src/PiecesMetalinkParserState.cc: Removed
* src/PiecesMetalinkParserState.h: Removed
* src/ResourcesMetalinkParserState.cc: Removed
* src/ResourcesMetalinkParserState.h: Removed
* src/SignatureMetalinkParserState.cc: Removed
* src/SignatureMetalinkParserState.h: Removed
* src/SizeMetalinkParserState.cc: Removed
* src/SizeMetalinkParserState.h: Removed
* src/SkipTagMetalinkParserState.cc: Removed
* src/SkipTagMetalinkParserState.h: Removed
* src/URLMetalinkParserState.cc: Removed
* src/URLMetalinkParserState.h: Removed
* src/VerificationMetalinkParserState.cc: Removed
* src/VerificationMetalinkParserState.h: Removed
* src/VersionMetalinkParserState.cc: Removed
* src/VersionMetalinkParserState.h: Removed
2009-09-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Move all functions in PeerMessageUtil to bittorrent_helper.

View File

@ -1,100 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "FileMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
#include "Util.h"
#include "RecoverableException.h"
namespace aria2 {
const std::string FileMetalinkParserState::SIZE("size");
const std::string FileMetalinkParserState::METALINK_VERSION("version");
const std::string FileMetalinkParserState::LANGUAGE("language");
const std::string FileMetalinkParserState::OS("os");
const std::string FileMetalinkParserState::VERIFICATION("verification");
const std::string FileMetalinkParserState::RESOURCES("resources");
const std::string FileMetalinkParserState::MAXCONNECTIONS("maxconnections");
void FileMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
if(name == FileMetalinkParserState::SIZE) {
stm->setSizeState();
} else if(name == FileMetalinkParserState::METALINK_VERSION) {
stm->setVersionState();
} else if(name == FileMetalinkParserState::LANGUAGE) {
stm->setLanguageState();
} else if(name == FileMetalinkParserState::OS) {
stm->setOSState();
} else if(name == FileMetalinkParserState::VERIFICATION) {
stm->setVerificationState();
} else if(name == FileMetalinkParserState::RESOURCES) {
stm->setResourcesState();
int maxConnections;
{
std::map<std::string, std::string>::const_iterator itr =
attrs.find(FileMetalinkParserState::MAXCONNECTIONS);
if(itr == attrs.end()) {
maxConnections = -1;
} else {
try {
maxConnections = Util::parseInt((*itr).second);
} catch(RecoverableException& e) {
maxConnections = -1;
}
}
}
stm->setMaxConnectionsOfEntry(maxConnections);
} else {
stm->setSkipTagState(this);
}
}
void FileMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->commitEntryTransaction();
stm->setFilesState();
}
} // namespace aria2

View File

@ -1,74 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_FILE_METALINK_PARSER_STATE_H_
#define _D_FILE_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class FileMetalinkParserState:public MetalinkParserState
{
private:
static const std::string SIZE;
// VERSION is not allowed here because it is defined in macro.
static const std::string METALINK_VERSION;
static const std::string LANGUAGE;
static const std::string OS;
static const std::string VERIFICATION;
static const std::string RESOURCES;
static const std::string MAXCONNECTIONS;
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_FILE_METALINK_PARSER_STATE_H_

View File

@ -1,68 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "FilesMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
const std::string FilesMetalinkParserState::FILE("file");
const std::string FilesMetalinkParserState::NAME("name");
void FilesMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
if(name == FilesMetalinkParserState::FILE) {
stm->setFileState();
std::map<std::string, std::string>::const_iterator itr =
attrs.find(FilesMetalinkParserState::NAME);
if(itr != attrs.end()) {
stm->newEntryTransaction();
stm->setFileNameOfEntry((*itr).second);
}
} else {
stm->setSkipTagState(this);
}
}
void FilesMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setMetalinkState();
}
} // namespace aria2

View File

@ -1,63 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_FILES_METALINK_PARSER_STATE_H_
#define _D_FILES_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class FilesMetalinkParserState:public MetalinkParserState
{
private:
static const std::string FILE;
static const std::string NAME;
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_FILES_METALINK_PARSER_STATE_H_

View File

@ -1,49 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "FinMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
void FinMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{}
void FinMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters)
{}
} // namespace aria2

View File

@ -1,59 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_FIN_METALINK_PARSER_STATE_H_
#define _D_FIN_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class FinMetalinkParserState:public MetalinkParserState
{
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return false;
}
};
} // namespace aria2
#endif // _D_FIN_METALINK_PARSER_STATE_H_

View File

@ -1,56 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "HashMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
void HashMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
stm->setSkipTagState(this);
}
void HashMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setHashOfChecksum(characters);
stm->commitChecksumTransaction();
stm->setVerificationState();
}
} // namespace aria2

View File

@ -1,59 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_HASH_METALINK_PARSER_STATE_H_
#define _D_HASH_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class HashMetalinkParserState:public MetalinkParserState
{
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_HASH_METALINK_PARSER_STATE_H_

View File

@ -1,57 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "InitialMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
const std::string InitialMetalinkParserState::METALINK("metalink");
void InitialMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
if(name == InitialMetalinkParserState::METALINK) {
stm->setMetalinkState();
} else {
stm->setSkipTagState(this);
}
}
void InitialMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters)
{}
} // namespace aria2

View File

@ -1,61 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_INITIAL_METALINK_PARSER_STATE_H_
#define _D_INITIAL_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class InitialMetalinkParserState:public MetalinkParserState
{
private:
static const std::string METALINK;
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return false;
}
};
} // namespace aria2
#endif // _D_INITIAL_METALINK_PARSER_STATE_H_

View File

@ -1,55 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "LanguageMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
void LanguageMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
stm->setSkipTagState(this);
}
void LanguageMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setLanguageOfEntry(characters);
stm->setFileState();
}
} // namespace aria2

View File

@ -1,59 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_LANGUAGE_METALINK_PARSER_STATE_H_
#define _D_LANGUAGE_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class LanguageMetalinkParserState:public MetalinkParserState
{
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_LANGUAGE_METALINK_PARSER_STATE_H_

View File

@ -444,23 +444,7 @@ SRCS += Metalinker.cc Metalinker.h\
MetalinkParserController.cc MetalinkParserController.h\
MetalinkParserStateMachine.cc MetalinkParserStateMachine.h\
MetalinkParserState.h\
InitialMetalinkParserState.cc InitialMetalinkParserState.h\
MetalinkMetalinkParserState.cc MetalinkMetalinkParserState.h\
FilesMetalinkParserState.cc FilesMetalinkParserState.h\
FileMetalinkParserState.cc FileMetalinkParserState.h\
SizeMetalinkParserState.cc SizeMetalinkParserState.h\
VersionMetalinkParserState.cc VersionMetalinkParserState.h\
LanguageMetalinkParserState.cc LanguageMetalinkParserState.h\
OSMetalinkParserState.cc OSMetalinkParserState.h\
VerificationMetalinkParserState.cc VerificationMetalinkParserState.h\
HashMetalinkParserState.cc HashMetalinkParserState.h\
PiecesMetalinkParserState.cc PiecesMetalinkParserState.h\
PieceHashMetalinkParserState.cc PieceHashMetalinkParserState.h\
SignatureMetalinkParserState.cc SignatureMetalinkParserState.h\
ResourcesMetalinkParserState.cc ResourcesMetalinkParserState.h\
URLMetalinkParserState.cc URLMetalinkParserState.h\
FinMetalinkParserState.cc FinMetalinkParserState.h\
SkipTagMetalinkParserState.cc SkipTagMetalinkParserState.h\
MetalinkParserStateImpl.cc MetalinkParserStateImpl.h\
Metalink2RequestGroup.cc Metalink2RequestGroup.h\
MetalinkPostDownloadHandler.cc MetalinkPostDownloadHandler.h\
MetalinkHelper.cc MetalinkHelper.h

View File

@ -239,23 +239,7 @@ bin_PROGRAMS = aria2c$(EXEEXT)
@ENABLE_METALINK_TRUE@ MetalinkParserController.cc MetalinkParserController.h\
@ENABLE_METALINK_TRUE@ MetalinkParserStateMachine.cc MetalinkParserStateMachine.h\
@ENABLE_METALINK_TRUE@ MetalinkParserState.h\
@ENABLE_METALINK_TRUE@ InitialMetalinkParserState.cc InitialMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ MetalinkMetalinkParserState.cc MetalinkMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ FilesMetalinkParserState.cc FilesMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ FileMetalinkParserState.cc FileMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ SizeMetalinkParserState.cc SizeMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ VersionMetalinkParserState.cc VersionMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ LanguageMetalinkParserState.cc LanguageMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ OSMetalinkParserState.cc OSMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ VerificationMetalinkParserState.cc VerificationMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ HashMetalinkParserState.cc HashMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ PiecesMetalinkParserState.cc PiecesMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ PieceHashMetalinkParserState.cc PieceHashMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ SignatureMetalinkParserState.cc SignatureMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ ResourcesMetalinkParserState.cc ResourcesMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ URLMetalinkParserState.cc URLMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ FinMetalinkParserState.cc FinMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ SkipTagMetalinkParserState.cc SkipTagMetalinkParserState.h\
@ENABLE_METALINK_TRUE@ MetalinkParserStateImpl.cc MetalinkParserStateImpl.h\
@ENABLE_METALINK_TRUE@ Metalink2RequestGroup.cc Metalink2RequestGroup.h\
@ENABLE_METALINK_TRUE@ MetalinkPostDownloadHandler.cc MetalinkPostDownloadHandler.h\
@ENABLE_METALINK_TRUE@ MetalinkHelper.cc MetalinkHelper.h
@ -567,24 +551,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
MetalinkResource.cc MetalinkResource.h MetalinkProcessor.h \
MetalinkParserController.cc MetalinkParserController.h \
MetalinkParserStateMachine.cc MetalinkParserStateMachine.h \
MetalinkParserState.h InitialMetalinkParserState.cc \
InitialMetalinkParserState.h MetalinkMetalinkParserState.cc \
MetalinkMetalinkParserState.h FilesMetalinkParserState.cc \
FilesMetalinkParserState.h FileMetalinkParserState.cc \
FileMetalinkParserState.h SizeMetalinkParserState.cc \
SizeMetalinkParserState.h VersionMetalinkParserState.cc \
VersionMetalinkParserState.h LanguageMetalinkParserState.cc \
LanguageMetalinkParserState.h OSMetalinkParserState.cc \
OSMetalinkParserState.h VerificationMetalinkParserState.cc \
VerificationMetalinkParserState.h HashMetalinkParserState.cc \
HashMetalinkParserState.h PiecesMetalinkParserState.cc \
PiecesMetalinkParserState.h PieceHashMetalinkParserState.cc \
PieceHashMetalinkParserState.h SignatureMetalinkParserState.cc \
SignatureMetalinkParserState.h ResourcesMetalinkParserState.cc \
ResourcesMetalinkParserState.h URLMetalinkParserState.cc \
URLMetalinkParserState.h FinMetalinkParserState.cc \
FinMetalinkParserState.h SkipTagMetalinkParserState.cc \
SkipTagMetalinkParserState.h Metalink2RequestGroup.cc \
MetalinkParserState.h MetalinkParserStateImpl.cc \
MetalinkParserStateImpl.h Metalink2RequestGroup.cc \
Metalink2RequestGroup.h MetalinkPostDownloadHandler.cc \
MetalinkPostDownloadHandler.h MetalinkHelper.cc \
MetalinkHelper.h XML2SAXMetalinkProcessor.cc \
@ -739,23 +707,7 @@ am__objects_6 =
@ENABLE_METALINK_TRUE@ MetalinkResource.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkParserController.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkParserStateMachine.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ InitialMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ FilesMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ FileMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ SizeMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ VersionMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ LanguageMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ OSMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ VerificationMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ HashMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ PiecesMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ PieceHashMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ SignatureMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ ResourcesMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ URLMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ FinMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ SkipTagMetalinkParserState.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkParserStateImpl.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ Metalink2RequestGroup.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkPostDownloadHandler.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkHelper.$(OBJEXT)
@ -1426,10 +1378,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileAllocationDispatcherCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileAllocationEntry.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileEntry.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilesMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FillRequestGroupCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FinMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FtpConnection.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FtpDownloadCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FtpFinishDownloadCommand.Po@am__quote@
@ -1440,7 +1389,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GZipDecoder.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GrowSegment.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HandshakeExtensionMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HashMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HaveEraseCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpConnection.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpDownloadCommand.Po@am__quote@
@ -1461,13 +1409,11 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpSkipResponseCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InOrderURISelector.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IndexBtMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InitialMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InitiateConnectionCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InitiateConnectionCommandFactory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InitiatorMSEHandshakeCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IteratableChecksumValidator.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IteratableChunkChecksumValidator.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LanguageMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibgnutlsTLSContext.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibsslTLSContext.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogFactory.Po@am__quote@
@ -1479,8 +1425,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Metalink2RequestGroup.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkEntry.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkHelper.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkParserController.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkParserStateImpl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkParserStateMachine.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkPostDownloadHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkResource.Po@am__quote@
@ -1492,7 +1438,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Netrc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NetrcAuthResolver.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NsCookieParser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OSMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Option.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OptionHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OptionHandlerException.Po@am__quote@
@ -1512,10 +1457,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerSessionResource.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Piece.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PieceHashCheckIntegrityEntry.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PieceHashMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PieceStatMan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PiecedSegment.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PiecesMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Platform.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ProtocolDetector.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RangeBtMessage.Po@am__quote@
@ -1527,20 +1470,16 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupEntry.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupMan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestSlot.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ResourcesMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SeedCheckCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SegmentMan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SelectEventPoll.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStatMan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Signature.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SignatureMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimpleBtMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimpleLogger.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimpleRandomizer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SingleFileAllocationIterator.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SizeMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SkipTagMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SleepCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SocketBuffer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SocketCore.Po@am__quote@
@ -1555,13 +1494,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerWatcherCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TransferStat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/URIResult.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/URLMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UTPexExtensionMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnknownLengthPieceStorage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UriListParser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VerificationMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VersionMetalinkParserState.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XML2SAXMetalinkProcessor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xml2XmlRpcRequestProcessor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XmlRpcElements.Po@am__quote@

View File

@ -1,60 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "MetalinkMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
const std::string MetalinkMetalinkParserState::FILES("files");
void MetalinkMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
if(name == MetalinkMetalinkParserState::FILES) {
stm->setFilesState();
} else {
stm->setSkipTagState(this);
}
}
void MetalinkMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setFinState();
}
} // namespace aria2

View File

@ -1,61 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_METALINK_METALINK_PARSER_STATE_H_
#define _D_METALINK_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class MetalinkMetalinkParserState:public MetalinkParserState
{
private:
static const std::string FILES;
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return false;
}
};
} // namespace aria2
#endif // _D_METALINK_METALINK_PARSER_STATE_H_

View File

@ -48,11 +48,14 @@ class MetalinkParserState
public:
virtual ~MetalinkParserState() {}
virtual void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs) = 0;
virtual void beginElement
(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs) = 0;
virtual void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters) = 0;
virtual void endElement
(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters) = 0;
virtual bool needsCharactersBuffering() const = 0;
};

View File

@ -33,147 +33,129 @@
*/
/* copyright --> */
#include "MetalinkParserStateMachine.h"
#include "InitialMetalinkParserState.h"
#include "MetalinkMetalinkParserState.h"
#include "FilesMetalinkParserState.h"
#include "FileMetalinkParserState.h"
#include "SizeMetalinkParserState.h"
#include "VersionMetalinkParserState.h"
#include "LanguageMetalinkParserState.h"
#include "OSMetalinkParserState.h"
#include "VerificationMetalinkParserState.h"
#include "HashMetalinkParserState.h"
#include "PiecesMetalinkParserState.h"
#include "PieceHashMetalinkParserState.h"
#include "SignatureMetalinkParserState.h"
#include "ResourcesMetalinkParserState.h"
#include "URLMetalinkParserState.h"
#include "FinMetalinkParserState.h"
#include "SkipTagMetalinkParserState.h"
#include "MetalinkParserStateImpl.h"
#include "Metalinker.h"
#include "MetalinkEntry.h"
namespace aria2 {
MetalinkParserState* MetalinkParserStateMachine::_initialState = new InitialMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_metalinkState = new MetalinkMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_filesState = new FilesMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_fileState = new FileMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_sizeState = new SizeMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_versionState = new VersionMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_languageState = new LanguageMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_osState = new OSMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_verificationState = new VerificationMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_hashState = new HashMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_piecesState = new PiecesMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_pieceHashState = new PieceHashMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_initialState =
new InitialMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_metalinkState =
new MetalinkMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_filesState =
new FilesMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_fileState =
new FileMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_sizeState =
new SizeMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_versionState =
new VersionMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_languageState =
new LanguageMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_osState =
new OSMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_verificationState =
new VerificationMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_hashState =
new HashMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_piecesState =
new PiecesMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_pieceHashState =
new PieceHashMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_signatureState =
new SignatureMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_resourcesState = new ResourcesMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_urlState = new URLMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_finState = new FinMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_resourcesState =
new ResourcesMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_urlState =
new URLMetalinkParserState();
MetalinkParserState* MetalinkParserStateMachine::_skipTagState =
new SkipTagMetalinkParserState();
MetalinkParserStateMachine::MetalinkParserStateMachine():
_ctrl(new MetalinkParserController()),
_state(_initialState),
_skipTagState(0) {}
MetalinkParserStateMachine::~MetalinkParserStateMachine()
_ctrl(new MetalinkParserController())
{
delete _skipTagState;
_stateStack.push(_initialState);
}
void MetalinkParserStateMachine::setMetalinkState()
{
_state = _metalinkState;
_stateStack.push(_metalinkState);
}
void MetalinkParserStateMachine::setFilesState()
{
_state = _filesState;
_stateStack.push(_filesState);
}
void MetalinkParserStateMachine::setFileState()
{
_state = _fileState;
_stateStack.push(_fileState);
}
void MetalinkParserStateMachine::setSizeState()
{
_state = _sizeState;
_stateStack.push(_sizeState);
}
void MetalinkParserStateMachine::setVersionState()
{
_state = _versionState;
_stateStack.push(_versionState);
}
void MetalinkParserStateMachine::setLanguageState()
{
_state = _languageState;
_stateStack.push(_languageState);
}
void MetalinkParserStateMachine::setOSState()
{
_state = _osState;
_stateStack.push(_osState);
}
void MetalinkParserStateMachine::setVerificationState()
{
_state = _verificationState;
_stateStack.push(_verificationState);
}
void MetalinkParserStateMachine::setHashState()
{
_state = _hashState;
_stateStack.push(_hashState);
}
void MetalinkParserStateMachine::setPiecesState()
{
_state = _piecesState;
_stateStack.push(_piecesState);
}
void MetalinkParserStateMachine::setPieceHashState()
{
_state = _pieceHashState;
_stateStack.push(_pieceHashState);
}
void MetalinkParserStateMachine::setSignatureState()
{
_state = _signatureState;
_stateStack.push(_signatureState);
}
void MetalinkParserStateMachine::setResourcesState()
{
_state = _resourcesState;
_stateStack.push(_resourcesState);
}
void MetalinkParserStateMachine::setURLState()
{
_state = _urlState;
_stateStack.push(_urlState);
}
void MetalinkParserStateMachine::setFinState()
void MetalinkParserStateMachine::setSkipTagState()
{
_state = _finState;
}
void MetalinkParserStateMachine::setSkipTagState(MetalinkParserState* prevState)
{
_skipTagState = new SkipTagMetalinkParserState(prevState);
_state = _skipTagState;
}
void MetalinkParserStateMachine::restoreSavedState()
{
_state = _skipTagState->getPreviousState();
delete _skipTagState;
_skipTagState = 0;
_stateStack.push(_skipTagState);
}
bool MetalinkParserStateMachine::finished() const
{
return _state == _finState;
return _stateStack.top() == _initialState;
}
void MetalinkParserStateMachine::newEntryTransaction()
@ -231,7 +213,8 @@ void MetalinkParserStateMachine::setTypeOfResource(const std::string& type)
_ctrl->setTypeOfResource(type);
}
void MetalinkParserStateMachine::setLocationOfResource(const std::string& location)
void MetalinkParserStateMachine::setLocationOfResource
(const std::string& location)
{
_ctrl->setLocationOfResource(location);
}
@ -301,7 +284,8 @@ void MetalinkParserStateMachine::createNewHashOfChunkChecksum(size_t order)
_ctrl->createNewHashOfChunkChecksum(order);
}
void MetalinkParserStateMachine::setMessageDigestOfChunkChecksum(const std::string& md)
void MetalinkParserStateMachine::setMessageDigestOfChunkChecksum
(const std::string& md)
{
_ctrl->setMessageDigestOfChunkChecksum(md);
}
@ -351,20 +335,23 @@ void MetalinkParserStateMachine::cancelSignatureTransaction()
_ctrl->cancelSignatureTransaction();
}
void MetalinkParserStateMachine::beginElement(const std::string& name,
const std::map<std::string, std::string>& attrs)
void MetalinkParserStateMachine::beginElement
(const std::string& name,
const std::map<std::string, std::string>& attrs)
{
_state->beginElement(this, name, attrs);
_stateStack.top()->beginElement(this, name, attrs);
}
void MetalinkParserStateMachine::endElement(const std::string& name, const std::string& characters)
void MetalinkParserStateMachine::endElement
(const std::string& name, const std::string& characters)
{
_state->endElement(this, name, characters);
_stateStack.top()->endElement(this, name, characters);
_stateStack.pop();
}
bool MetalinkParserStateMachine::needsCharactersBuffering() const
{
return _state->needsCharactersBuffering();
return _stateStack.top()->needsCharactersBuffering();
}
} // namespace aria2

View File

@ -38,6 +38,7 @@
#include "common.h"
#include <string>
#include <map>
#include <stack>
#include "SharedHandle.h"
#include "MetalinkParserController.h"
@ -45,14 +46,13 @@
namespace aria2 {
class MetalinkParserState;
class SkipTagMetalinkParserState;
class Metalinker;
class MetalinkParserStateMachine {
private:
SharedHandle<MetalinkParserController> _ctrl;
MetalinkParserState* _state;
std::stack<MetalinkParserState*> _stateStack;
static MetalinkParserState* _initialState;
static MetalinkParserState* _metalinkState;
@ -69,14 +69,10 @@ private:
static MetalinkParserState* _signatureState;
static MetalinkParserState* _resourcesState;
static MetalinkParserState* _urlState;
static MetalinkParserState* _finState;
SkipTagMetalinkParserState* _skipTagState;
static MetalinkParserState* _skipTagState;
public:
MetalinkParserStateMachine();
~MetalinkParserStateMachine();
void setMetalinkState();
void setFilesState();
@ -105,18 +101,12 @@ public:
void setURLState();
void setFinState();
void setSkipTagState();
void setSkipTagState(MetalinkParserState* prevState);
void restoreSavedState();
bool finished() const;
bool error() const;
void beginElement(const std::string& name, const std::map<std::string,
std::string>& attrs);
void beginElement
(const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(const std::string& name, const std::string& characters);

View File

@ -1,55 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "OSMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
void OSMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
stm->setSkipTagState(this);
}
void OSMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setOSOfEntry(characters);
stm->setFileState();
}
} // namespace aria2

View File

@ -1,59 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_OS_METALINK_PARSER_STATE_H_
#define _D_OS_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class OSMetalinkParserState:public MetalinkParserState
{
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_OS_METALINK_PARSER_STATE_H_

View File

@ -1,56 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "PieceHashMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
void PieceHashMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
stm->setSkipTagState(this);
}
void PieceHashMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setMessageDigestOfChunkChecksum(characters);
stm->addHashOfChunkChecksum();
stm->setPiecesState();
}
} // namespace aria2

View File

@ -1,59 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_PIECE_HASH_METALINK_PARSER_STATE_H_
#define _D_PIECE_HASH_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class PieceHashMetalinkParserState:public MetalinkParserState
{
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_PIECE_HASH_METALINK_PARSER_STATE_H_

View File

@ -1,76 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "PiecesMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
#include "RecoverableException.h"
#include "Util.h"
namespace aria2 {
const std::string PiecesMetalinkParserState::HASH("hash");
const std::string PiecesMetalinkParserState::PIECE("piece");
void PiecesMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
if(name == PiecesMetalinkParserState::HASH) {
stm->setPieceHashState();
std::map<std::string, std::string>::const_iterator itr =
attrs.find(PiecesMetalinkParserState::PIECE);
if(itr == attrs.end()) {
stm->cancelChunkChecksumTransaction();
} else {
try {
stm->createNewHashOfChunkChecksum(Util::parseInt((*itr).second));
} catch(RecoverableException& e) {
stm->cancelChunkChecksumTransaction();
}
}
} else {
stm->setSkipTagState(this);
}
}
void PiecesMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->commitChunkChecksumTransaction();
stm->setVerificationState();
}
} // namespace aria2

View File

@ -1,63 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_PIECES_METALINK_PARSER_STATE_H_
#define _D_PIECES_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class PiecesMetalinkParserState:public MetalinkParserState
{
private:
static const std::string HASH;
static const std::string PIECE;
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_PIECES_METALINK_PARSER_STATE_H_

View File

@ -1,121 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "ResourcesMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
#include "Util.h"
#include "RecoverableException.h"
namespace aria2 {
const std::string ResourcesMetalinkParserState::URL("url");
const std::string ResourcesMetalinkParserState::TYPE("type");
const std::string ResourcesMetalinkParserState::LOCATION("location");
const std::string ResourcesMetalinkParserState::PREFERENCE("preference");
const std::string ResourcesMetalinkParserState::MAXCONNECTIONS("maxconnections");
void ResourcesMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
if(name == ResourcesMetalinkParserState::URL) {
stm->setURLState();
std::string type;
{
std::map<std::string, std::string>::const_iterator itr =
attrs.find(ResourcesMetalinkParserState::TYPE);
if(itr == attrs.end()) {
return;
} else {
type = (*itr).second;
}
}
std::string location;
{
std::map<std::string, std::string>::const_iterator itr =
attrs.find(ResourcesMetalinkParserState::LOCATION);
if(itr != attrs.end()) {
location = Util::toUpper((*itr).second);
}
}
int preference;
{
std::map<std::string, std::string>::const_iterator itr =
attrs.find(ResourcesMetalinkParserState::PREFERENCE);
if(itr == attrs.end()) {
preference = 0;
} else {
try {
preference = Util::parseInt((*itr).second);
} catch(RecoverableException& e) {
preference = 0;
}
}
}
int maxConnections;
{
std::map<std::string, std::string>::const_iterator itr =
attrs.find(ResourcesMetalinkParserState::MAXCONNECTIONS);
if(itr == attrs.end()) {
maxConnections = -1;
} else {
try {
maxConnections = Util::parseInt((*itr).second);
} catch(RecoverableException& e) {
maxConnections = -1;
}
}
}
stm->newResourceTransaction();
stm->setTypeOfResource(type);
stm->setLocationOfResource(location);
stm->setPreferenceOfResource(preference);
stm->setMaxConnectionsOfResource(maxConnections);
} else {
stm->setSkipTagState(this);
}
}
void ResourcesMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setFileState();
}
} // namespace aria2

View File

@ -1,69 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_RESOURCES_METALINK_PARSER_STATE_H_
#define _D_RESOURCES_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class ResourcesMetalinkParserState:public MetalinkParserState
{
private:
static const std::string URL;
static const std::string TYPE;
static const std::string LOCATION;
static const std::string PREFERENCE;
static const std::string MAXCONNECTIONS;
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_RESOURCES_METALINK_PARSER_STATE_H_

View File

@ -1,58 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "SignatureMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
void SignatureMetalinkParserState::beginElement
(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
stm->setSkipTagState(this);
}
void SignatureMetalinkParserState::endElement
(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setBodyOfSignature(characters);
stm->commitSignatureTransaction();
stm->setVerificationState();
}
} // namespace aria2

View File

@ -1,60 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_SIGNATURE_METALINK_PARSER_STATE_H_
#define _D_SIGNATURE_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class SignatureMetalinkParserState:public MetalinkParserState
{
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string,
std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_SIGNATURE_METALINK_PARSER_STATE_H_

View File

@ -1,61 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "SizeMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
#include "Util.h"
#include "RecoverableException.h"
namespace aria2 {
void SizeMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
stm->setSkipTagState(this);
}
void SizeMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
try {
stm->setFileLengthOfEntry(Util::parseLLInt(characters));
} catch(RecoverableException& e) {
// current metalink specification doesn't require size element.
}
stm->setFileState();
}
} // namespace aria2

View File

@ -1,59 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_SIZE_METALINK_PARSER_STATE_H_
#define _D_SIZE_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class SizeMetalinkParserState:public MetalinkParserState
{
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_SIZE_METALINK_PARSER_STATE_H_

View File

@ -1,59 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "SkipTagMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
SkipTagMetalinkParserState::SkipTagMetalinkParserState(MetalinkParserState* prevState):
_prevState(prevState), _depth(1) {}
void SkipTagMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
++_depth;
}
void SkipTagMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
if(--_depth == 0) {
stm->restoreSavedState();
}
}
} // namespace aria2

View File

@ -1,69 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_SKIP_TAG_METALINK_PARSER_STATE_H_
#define _D_SKIP_TAG_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class SkipTagMetalinkParserState:public MetalinkParserState
{
private:
MetalinkParserState* _prevState;
unsigned int _depth;
public:
SkipTagMetalinkParserState(MetalinkParserState* prevState);
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return false;
}
MetalinkParserState* getPreviousState() const
{
return _prevState;
}
};
} // namespace aria2
#endif // _D_SKIP_TAG_METALINK_PARSER_STATE_H_

View File

@ -1,57 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "URLMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
void URLMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
stm->setSkipTagState(this);
}
void URLMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setURLOfResource(characters);
stm->commitResourceTransaction();
stm->setResourcesState();
}
} // namespace aria2

View File

@ -1,59 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_URL_METALINK_PARSER_STATE_H_
#define _D_URL_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class URLMetalinkParserState:public MetalinkParserState
{
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_URL_METALINK_PARSER_STATE_H_

View File

@ -1,131 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "VerificationMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
#include "DlAbortEx.h"
#include "Util.h"
namespace aria2 {
const std::string VerificationMetalinkParserState::HASH("hash");
const std::string VerificationMetalinkParserState::TYPE("type");
const std::string VerificationMetalinkParserState::PIECES("pieces");
const std::string VerificationMetalinkParserState::LENGTH("length");
const std::string VerificationMetalinkParserState::SIGNATURE("signature");
const std::string VerificationMetalinkParserState::FILE("file");
void VerificationMetalinkParserState::beginElement
(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(name == VerificationMetalinkParserState::HASH) {
stm->setHashState();
std::map<std::string, std::string>::const_iterator itr =
attrs.find(VerificationMetalinkParserState::TYPE);
if(itr == attrs.end()) {
return;
} else {
std::string type = (*itr).second;
stm->newChecksumTransaction();
stm->setTypeOfChecksum(type);
}
} else if(name == VerificationMetalinkParserState::PIECES) {
stm->setPiecesState();
try {
size_t length;
{
std::map<std::string, std::string>::const_iterator itr =
attrs.find(VerificationMetalinkParserState::LENGTH);
if(itr == attrs.end()) {
return;
} else {
length = Util::parseInt((*itr).second);
}
}
std::string type;
{
std::map<std::string, std::string>::const_iterator itr =
attrs.find(VerificationMetalinkParserState::TYPE);
if(itr == attrs.end()) {
return;
} else {
type = (*itr).second;
}
}
stm->newChunkChecksumTransaction();
stm->setLengthOfChunkChecksum(length);
stm->setTypeOfChunkChecksum(type);
} catch(RecoverableException& e) {
stm->cancelChunkChecksumTransaction();
}
} else
#endif // ENABLE_MESSAGE_DIGEST
if(name == VerificationMetalinkParserState::SIGNATURE) {
stm->setSignatureState();
std::map<std::string, std::string>::const_iterator itr =
attrs.find(VerificationMetalinkParserState::TYPE);
if(itr == attrs.end()) {
return;
} else {
stm->newSignatureTransaction();
stm->setTypeOfSignature((*itr).second);
std::map<std::string, std::string>::const_iterator itr =
attrs.find(VerificationMetalinkParserState::FILE);
if(itr != attrs.end()) {
stm->setFileOfSignature((*itr).second);
}
}
} else {
stm->setSkipTagState(this);
}
}
void VerificationMetalinkParserState::endElement
(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setFileState();
}
} // namespace aria2

View File

@ -1,71 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_VERIFICATION_METALINK_PARSER_STATE_H_
#define _D_VERIFICATION_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class VerificationMetalinkParserState:public MetalinkParserState
{
private:
static const std::string HASH;
static const std::string TYPE;
static const std::string PIECES;
static const std::string LENGTH;
static const std::string SIGNATURE;
static const std::string FILE;
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_VERIFICATION_METALINK_PARSER_STATE_H_

View File

@ -1,55 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "VersionMetalinkParserState.h"
#include "MetalinkParserStateMachine.h"
namespace aria2 {
void VersionMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::map<std::string, std::string>& attrs)
{
stm->setSkipTagState(this);
}
void VersionMetalinkParserState::endElement(MetalinkParserStateMachine* stm,
const std::string& name,
const std::string& characters)
{
stm->setVersionOfEntry(characters);
stm->setFileState();
}
} // namespace aria2

View File

@ -1,59 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_VERSION_METALINK_PARSER_STATE_H_
#define _D_VERSION_METALINK_PARSER_STATE_H_
#include "MetalinkParserState.h"
namespace aria2 {
class VersionMetalinkParserState:public MetalinkParserState
{
public:
void beginElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::map<std::string, std::string>& attrs);
void endElement(MetalinkParserStateMachine* stm,
const std::string& name, const std::string& characters);
virtual bool needsCharactersBuffering() const
{
return true;
}
};
} // namespace aria2
#endif // _D_VERSION_METALINK_PARSER_STATE_H_