From 20f3f23576cbb0c2cd5f84b94545967582af626a Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Thu, 11 Apr 2013 12:11:33 +0200 Subject: [PATCH 01/51] Customizable toolbar icon size. --- src/gui/MainWindow.cpp | 29 +++++++++++++++++++++++++++++ src/gui/MainWindow.h | 4 ++++ src/gui/MainWindow.ui | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 15706bed0..1eff09656 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -43,9 +43,14 @@ MainWindow::MainWindow() QAction* toggleViewAction = m_ui->toolBar->toggleViewAction(); toggleViewAction->setText(tr("Show toolbar")); m_ui->menuView->addAction(toggleViewAction); + int toolbarIconSize = config()->get("ToolbarIconSize", 20).toInt(); + setToolbarIconSize(toolbarIconSize); bool showToolbar = config()->get("ShowToolbar").toBool(); m_ui->toolBar->setVisible(showToolbar); connect(m_ui->toolBar, SIGNAL(visibilityChanged(bool)), this, SLOT(saveToolbarState(bool))); + connect(m_ui->actionToolbarIconSize16, SIGNAL(triggered()), this, SLOT(setToolbarIconSize16())); + connect(m_ui->actionToolbarIconSize22, SIGNAL(triggered()), this, SLOT(setToolbarIconSize22())); + connect(m_ui->actionToolbarIconSize28, SIGNAL(triggered()), this, SLOT(setToolbarIconSize28())); m_clearHistoryAction = new QAction("Clear history", m_ui->menuFile); m_lastDatabasesActions = new QActionGroup(m_ui->menuRecentDatabases); @@ -420,6 +425,30 @@ void MainWindow::saveToolbarState(bool value) config()->set("ShowToolbar", value); } +void MainWindow::setToolbarIconSize(int size) +{ + config()->set("ToolbarIconSize", size); + m_ui->toolBar->setIconSize(QSize(size, size)); + m_ui->actionToolbarIconSize16->setChecked(size == 16); + m_ui->actionToolbarIconSize22->setChecked(size == 22); + m_ui->actionToolbarIconSize28->setChecked(size == 28); +} + +void MainWindow::setToolbarIconSize16() +{ + setToolbarIconSize(16); +} + +void MainWindow::setToolbarIconSize22() +{ + setToolbarIconSize(22); +} + +void MainWindow::setToolbarIconSize28() +{ + setToolbarIconSize(28); +} + void MainWindow::setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback) { if (!QKeySequence::keyBindings(standard).isEmpty()) { diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index b6c309145..60da08010 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -57,6 +57,10 @@ private Q_SLOTS: void showEntryContextMenu(const QPoint& globalPos); void showGroupContextMenu(const QPoint& globalPos); void saveToolbarState(bool value); + void setToolbarIconSize(int size); + void setToolbarIconSize16(); + void setToolbarIconSize22(); + void setToolbarIconSize28(); private: static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0); diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index 74f04b530..ec05f82ee 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -70,7 +70,7 @@ 0 0 800 - 20 + 24 @@ -143,6 +143,15 @@ View + + + Toolbar &Icon Size + + + + + + @@ -346,6 +355,30 @@ Lock databases + + + true + + + &16x16 + + + + + true + + + &22x22 + + + + + true + + + 2&8x28 + + From ea992bc3e64705cf7555a07f49a08656cdaa8b56 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Thu, 11 Apr 2013 20:03:00 +0200 Subject: [PATCH 02/51] Support KeyPassHttp protocol. Allows using passIfox (firefox) and Chromeipass (chrome). --- src/CMakeLists.txt | 12 + src/core/Uuid.cpp | 6 + src/core/Uuid.h | 1 + src/crypto/SymmetricCipher.cpp | 30 +- src/crypto/SymmetricCipher.h | 15 +- src/gui/DatabaseTabWidget.cpp | 3 + src/http/Protocol.cpp | 477 ++ src/http/Protocol.h | 182 + src/http/Server.cpp | 217 + src/http/Server.h | 91 + src/http/Service.cpp | 293 ++ src/http/Service.h | 51 + src/http/qhttpserver/CMakeLists.txt | 20 + src/http/qhttpserver/LICENSE | 19 + src/http/qhttpserver/http-parser/AUTHORS | 40 + .../qhttpserver/http-parser/CONTRIBUTIONS | 4 + src/http/qhttpserver/http-parser/LICENSE-MIT | 23 + src/http/qhttpserver/http-parser/README.md | 178 + .../qhttpserver/http-parser/http_parser.c | 2174 ++++++++ .../qhttpserver/http-parser/http_parser.gyp | 111 + .../qhttpserver/http-parser/http_parser.h | 302 ++ src/http/qhttpserver/http-parser/test.c | 3402 +++++++++++++ src/http/qhttpserver/http-parser/url_parser.c | 44 + src/http/qhttpserver/qhttpconnection.cpp | 202 + src/http/qhttpserver/qhttpconnection.h | 80 + src/http/qhttpserver/qhttprequest.cpp | 38 + src/http/qhttpserver/qhttprequest.h | 245 + src/http/qhttpserver/qhttpresponse.cpp | 193 + src/http/qhttpserver/qhttpresponse.h | 174 + src/http/qhttpserver/qhttpserver.cpp | 125 + src/http/qhttpserver/qhttpserver.h | 230 + src/http/qjson/CMakeLists.txt | 28 + src/http/qjson/FlexLexer.h | 206 + src/http/qjson/README.license | 89 + src/http/qjson/json_parser.cc | 1103 ++++ src/http/qjson/json_parser.hh | 300 ++ src/http/qjson/json_parser.yy | 162 + src/http/qjson/json_scanner.cc | 4507 +++++++++++++++++ src/http/qjson/json_scanner.cpp | 75 + src/http/qjson/json_scanner.h | 60 + src/http/qjson/json_scanner.yy | 248 + src/http/qjson/location.hh | 181 + src/http/qjson/parser.cpp | 125 + src/http/qjson/parser.h | 99 + src/http/qjson/parser_p.h | 56 + src/http/qjson/parserrunnable.cpp | 68 + src/http/qjson/parserrunnable.h | 64 + src/http/qjson/position.hh | 172 + src/http/qjson/qjson_debug.h | 34 + src/http/qjson/qjson_export.h | 35 + src/http/qjson/qobjecthelper.cpp | 85 + src/http/qjson/qobjecthelper.h | 147 + src/http/qjson/serializer.cpp | 410 ++ src/http/qjson/serializer.h | 191 + src/http/qjson/serializerrunnable.cpp | 62 + src/http/qjson/serializerrunnable.h | 71 + src/http/qjson/stack.hh | 133 + 57 files changed, 17687 insertions(+), 6 deletions(-) create mode 100644 src/http/Protocol.cpp create mode 100644 src/http/Protocol.h create mode 100644 src/http/Server.cpp create mode 100644 src/http/Server.h create mode 100644 src/http/Service.cpp create mode 100644 src/http/Service.h create mode 100644 src/http/qhttpserver/CMakeLists.txt create mode 100644 src/http/qhttpserver/LICENSE create mode 100644 src/http/qhttpserver/http-parser/AUTHORS create mode 100644 src/http/qhttpserver/http-parser/CONTRIBUTIONS create mode 100644 src/http/qhttpserver/http-parser/LICENSE-MIT create mode 100644 src/http/qhttpserver/http-parser/README.md create mode 100644 src/http/qhttpserver/http-parser/http_parser.c create mode 100644 src/http/qhttpserver/http-parser/http_parser.gyp create mode 100644 src/http/qhttpserver/http-parser/http_parser.h create mode 100644 src/http/qhttpserver/http-parser/test.c create mode 100644 src/http/qhttpserver/http-parser/url_parser.c create mode 100644 src/http/qhttpserver/qhttpconnection.cpp create mode 100644 src/http/qhttpserver/qhttpconnection.h create mode 100644 src/http/qhttpserver/qhttprequest.cpp create mode 100644 src/http/qhttpserver/qhttprequest.h create mode 100644 src/http/qhttpserver/qhttpresponse.cpp create mode 100644 src/http/qhttpserver/qhttpresponse.h create mode 100644 src/http/qhttpserver/qhttpserver.cpp create mode 100644 src/http/qhttpserver/qhttpserver.h create mode 100644 src/http/qjson/CMakeLists.txt create mode 100644 src/http/qjson/FlexLexer.h create mode 100644 src/http/qjson/README.license create mode 100644 src/http/qjson/json_parser.cc create mode 100644 src/http/qjson/json_parser.hh create mode 100644 src/http/qjson/json_parser.yy create mode 100644 src/http/qjson/json_scanner.cc create mode 100644 src/http/qjson/json_scanner.cpp create mode 100644 src/http/qjson/json_scanner.h create mode 100644 src/http/qjson/json_scanner.yy create mode 100644 src/http/qjson/location.hh create mode 100644 src/http/qjson/parser.cpp create mode 100644 src/http/qjson/parser.h create mode 100644 src/http/qjson/parser_p.h create mode 100644 src/http/qjson/parserrunnable.cpp create mode 100644 src/http/qjson/parserrunnable.h create mode 100644 src/http/qjson/position.hh create mode 100644 src/http/qjson/qjson_debug.h create mode 100644 src/http/qjson/qjson_export.h create mode 100644 src/http/qjson/qobjecthelper.cpp create mode 100644 src/http/qjson/qobjecthelper.h create mode 100644 src/http/qjson/serializer.cpp create mode 100644 src/http/qjson/serializer.h create mode 100644 src/http/qjson/serializerrunnable.cpp create mode 100644 src/http/qjson/serializerrunnable.h create mode 100644 src/http/qjson/stack.hh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3bb4da99d..4e031203c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,6 +101,9 @@ set(keepassx_SOURCES gui/group/EditGroupWidget.cpp gui/group/GroupModel.cpp gui/group/GroupView.cpp + http/Protocol.cpp + http/Server.cpp + http/Service.cpp keys/CompositeKey.cpp keys/FileKey.cpp keys/Key.h @@ -163,6 +166,9 @@ set(keepassx_MOC gui/group/EditGroupWidget.h gui/group/GroupModel.h gui/group/GroupView.h + http/Protocol.h + http/Server.h + http/Service.h keys/CompositeKey_p.h streams/HashedBlockStream.h streams/LayeredStream.h @@ -204,11 +210,17 @@ qt4_wrap_cpp(keepassx_SOURCES ${keepassx_MOC}) add_library(keepassx_core STATIC ${keepassx_SOURCES}) set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE) +add_subdirectory(http/qhttpserver) +add_subdirectory(http/qjson) + add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE}) target_link_libraries(${PROGNAME} keepassx_core + qjson + qhttpserver ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} + ${QT_QTNETWORK_LIBRARY} ${GCRYPT_LIBRARIES} ${ZLIB_LIBRARIES}) diff --git a/src/core/Uuid.cpp b/src/core/Uuid.cpp index ae8b2dc5c..2b6770892 100644 --- a/src/core/Uuid.cpp +++ b/src/core/Uuid.cpp @@ -89,6 +89,12 @@ Uuid Uuid::fromBase64(const QString& str) return Uuid(data); } +Uuid Uuid::fromHex(const QString& str) +{ + QByteArray data = QByteArray::fromHex(str.toAscii()); + return Uuid(data); +} + uint qHash(const Uuid& key) { return qHash(key.toByteArray()); diff --git a/src/core/Uuid.h b/src/core/Uuid.h index ddcd39c80..95c4fad7e 100644 --- a/src/core/Uuid.h +++ b/src/core/Uuid.h @@ -37,6 +37,7 @@ public: bool operator!=(const Uuid& other) const; static const int Length; static Uuid fromBase64(const QString& str); + static Uuid fromHex(const QString& str); private: QByteArray m_data; diff --git a/src/crypto/SymmetricCipher.cpp b/src/crypto/SymmetricCipher.cpp index 498915a2d..8731b37dc 100644 --- a/src/crypto/SymmetricCipher.cpp +++ b/src/crypto/SymmetricCipher.cpp @@ -20,13 +20,16 @@ #include "crypto/SymmetricCipherGcrypt.h" #include "crypto/SymmetricCipherSalsa20.h" +SymmetricCipher::SymmetricCipher() + : m_backend(0) +{ +} + SymmetricCipher::SymmetricCipher(SymmetricCipher::Algorithm algo, SymmetricCipher::Mode mode, SymmetricCipher::Direction direction, const QByteArray& key, const QByteArray& iv) - : m_backend(createBackend(algo, mode, direction)) + : m_backend(0) { - m_backend->init(); - m_backend->setKey(key); - m_backend->setIv(iv); + init(algo, mode, direction, key, iv); } SymmetricCipher::~SymmetricCipher() @@ -50,12 +53,31 @@ SymmetricCipherBackend* SymmetricCipher::createBackend(SymmetricCipher::Algorith } } +void SymmetricCipher::init(SymmetricCipher::Algorithm algo, SymmetricCipher::Mode mode, + SymmetricCipher::Direction direction, const QByteArray& key, const QByteArray& iv) +{ + Q_ASSERT(!m_backend); + m_backend.reset(createBackend(algo, mode, direction)); + m_backend->init(); + m_backend->setKey(key); + if (!iv.isNull()) + m_backend->setIv(iv); +} + void SymmetricCipher::reset() { + Q_ASSERT(m_backend); m_backend->reset(); } +void SymmetricCipher::setIv(const QByteArray &iv) +{ + Q_ASSERT(m_backend); + m_backend->setIv(iv); +} + int SymmetricCipher::blockSize() const { + Q_ASSERT(m_backend); return m_backend->blockSize(); } diff --git a/src/crypto/SymmetricCipher.h b/src/crypto/SymmetricCipher.h index a6cc9162c..3d4fec98b 100644 --- a/src/crypto/SymmetricCipher.h +++ b/src/crypto/SymmetricCipher.h @@ -47,31 +47,42 @@ public: Encrypt }; + SymmetricCipher(); SymmetricCipher(SymmetricCipher::Algorithm algo, SymmetricCipher::Mode mode, - SymmetricCipher::Direction direction, const QByteArray& key, const QByteArray& iv); + SymmetricCipher::Direction direction, const QByteArray& key, const QByteArray& iv = QByteArray()); ~SymmetricCipher(); + void init(SymmetricCipher::Algorithm algo, SymmetricCipher::Mode mode, SymmetricCipher::Direction direction, + const QByteArray &key, const QByteArray &iv = QByteArray()); + bool isValid() const { + return m_backend != 0; + } + inline QByteArray process(const QByteArray& data) { + Q_ASSERT(m_backend); return m_backend->process(data); } inline void processInPlace(QByteArray& data) { + Q_ASSERT(m_backend); m_backend->processInPlace(data); } inline void processInPlace(QByteArray& data, quint64 rounds) { Q_ASSERT(rounds > 0); + Q_ASSERT(m_backend); m_backend->processInPlace(data, rounds); } void reset(); + void setIv(const QByteArray& iv); int blockSize() const; private: static SymmetricCipherBackend* createBackend(SymmetricCipher::Algorithm algo, SymmetricCipher::Mode mode, SymmetricCipher::Direction direction); - const QScopedPointer m_backend; + QScopedPointer m_backend; Q_DISABLE_COPY(SymmetricCipher) }; diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index cc87a5745..c899cd70d 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -32,6 +32,7 @@ #include "gui/FileDialog.h" #include "gui/entry/EntryView.h" #include "gui/group/GroupView.h" +#include "http/Service.h" DatabaseManagerStruct::DatabaseManagerStruct() : dbWidget(Q_NULLPTR) @@ -53,6 +54,8 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent) connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabase(int))); connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType())); + + (new Service(this))->start(); } DatabaseTabWidget::~DatabaseTabWidget() diff --git a/src/http/Protocol.cpp b/src/http/Protocol.cpp new file mode 100644 index 000000000..770a1e5ad --- /dev/null +++ b/src/http/Protocol.cpp @@ -0,0 +1,477 @@ +/** + *************************************************************************** + * @file Response.cpp + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#include "Protocol.h" + +#include +#include +#include + +#include "qjson/parser.h" +#include "qjson/qobjecthelper.h" +#include "qjson/serializer.h" + +#include "crypto/Random.h" +#include "crypto/SymmetricCipher.h" + +namespace KeepassHttpProtocol +{ +static const char * const STR_GET_LOGINS = "get-logins"; +static const char * const STR_GET_LOGINS_COUNT = "get-logins-count"; +static const char * const STR_GET_ALL_LOGINS = "get-all-logins"; +static const char * const STR_SET_LOGIN = "set-login"; +static const char * const STR_ASSOCIATE = "associate"; +static const char * const STR_TEST_ASSOCIATE = "test-associate"; +static const char * const STR_GENERATE_PASSWORD = "generate-password"; +static const char * const STR_VERSION = "1.5.0.0"; +}/*namespace KeepassHttpProtocol*/ + +using namespace KeepassHttpProtocol; + +static QHash createStringHash() +{ + QHash hash; + hash.insert(STR_GET_LOGINS, GET_LOGINS); + hash.insert(STR_GET_LOGINS_COUNT, GET_LOGINS_COUNT); + hash.insert(STR_GET_ALL_LOGINS, GET_ALL_LOGINS); + hash.insert(STR_SET_LOGIN, SET_LOGIN); + hash.insert(STR_ASSOCIATE, ASSOCIATE); + hash.insert(STR_TEST_ASSOCIATE, TEST_ASSOCIATE); + hash.insert(STR_GENERATE_PASSWORD,GENERATE_PASSWORD); + return hash; +} + +static RequestType parseRequest(const QString &str) +{ + static const QHash REQUEST_STRINGS = createStringHash(); + return REQUEST_STRINGS.value(str, INVALID); +} + +static QByteArray decode64(QString s) +{ + return QByteArray::fromBase64(s.toAscii()); +} + +static QString encode64(QByteArray b) +{ + return QString::fromAscii(b.toBase64()); +} + +static QByteArray decrypt2(const QByteArray & data, SymmetricCipher & cipher) +{ + //Ensure we get full blocks only + if (data.length() <= 0 || data.length() % cipher.blockSize()) + return QByteArray(); + + //Decrypt + cipher.reset(); + QByteArray buffer = cipher.process(data); + + //Remove PKCS#7 padding + buffer.chop(buffer.at(buffer.length()-1)); + return buffer; +} + +static QString decrypt(const QString &data, SymmetricCipher &cipher) +{ + return QString::fromUtf8(decrypt2(decode64(data), cipher)); +} + +static QByteArray encrypt2(const QByteArray & data, SymmetricCipher & cipher) +{ + //Add PKCS#7 padding + const int blockSize = cipher.blockSize(); + const int paddingSize = blockSize - data.size() % blockSize; + + //Encrypt + QByteArray buffer = data + QByteArray(paddingSize, paddingSize); + cipher.reset(); + cipher.processInPlace(buffer); + return buffer; +} + +static QString encrypt(const QString & data, SymmetricCipher & cipher) +{ + return encode64(encrypt2(data.toUtf8(), cipher)); +} + +static QVariant qobject2qvariant(const QObject * object, const QStringList ignoredProperties = QStringList(QString(QLatin1String("objectName")))) +{ + QVariantMap result; + const QMetaObject *metaobject = object->metaObject(); + int count = metaobject->propertyCount(); + for (int i=0; iproperty(i); + const char *name = metaproperty.name(); + + if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable())) + continue; + + QVariant value = object->property(name); + if (!value.isNull() /*&& value.isValid()*/) //Do not add NULL or invalid fields + result[QLatin1String(name)] = value; + } + return result; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// Request +//////////////////////////////////////////////////////////////////////////////////////////////////// + +Request::Request(): m_requestType(INVALID) +{ +} + +QString Request::nonce() const +{ + return m_nonce; +} + +void Request::setNonce(const QString &nonce) +{ + m_nonce = nonce; +} + +QString Request::verifier() const +{ + return m_verifier; +} + +void Request::setVerifier(const QString &verifier) +{ + m_verifier = verifier; +} + +QString Request::id() const +{ + return m_id; +} + +void Request::setId(const QString &id) +{ + m_id = id; +} + +QString Request::key() const +{ + return m_key; +} + +void Request::setKey(const QString &key) +{ + m_key = key; +} + +QString Request::submitUrl() const +{ + Q_ASSERT(m_cipher.isValid()); + return decrypt(m_submitUrl, m_cipher); +} + +void Request::setSubmitUrl(const QString &submitUrl) +{ + m_submitUrl = submitUrl; +} + +QString Request::url() const +{ + Q_ASSERT(m_cipher.isValid()); + return decrypt(m_url, m_cipher); +} + +void Request::setUrl(const QString &url) +{ + m_url = url; +} + +QString Request::realm() const +{ + Q_ASSERT(m_cipher.isValid()); + return decrypt(m_realm, m_cipher); +} + +void Request::setRealm(const QString &realm) +{ + m_realm = realm; +} + +QString Request::login() const +{ + Q_ASSERT(m_cipher.isValid()); + return decrypt(m_login, m_cipher); +} + +void Request::setLogin(const QString &login) +{ + m_login = login; +} + +QString Request::uuid() const +{ + Q_ASSERT(m_cipher.isValid()); + return decrypt(m_uuid, m_cipher); +} + +void Request::setUuid(const QString &uuid) +{ + m_uuid = uuid; +} + +QString Request::password() const +{ + Q_ASSERT(m_cipher.isValid()); + return decrypt(m_password, m_cipher); +} + +void Request::setPassword(const QString &password) +{ + m_password = password; +} + +bool Request::sortSelection() const +{ + return m_sortSelection; +} + +void Request::setSortSelection(bool sortSelection) +{ + m_sortSelection = sortSelection; +} + +KeepassHttpProtocol::RequestType Request::requestType() const +{ + return parseRequest(m_requestType); +} + +QString Request::requestTypeStr() const +{ + return m_requestType; +} + +void Request::setRequestType(const QString &requestType) +{ + m_requestType = requestType; +} + +bool Request::CheckVerifier(const QString &key) const +{ + Q_ASSERT(!m_cipher.isValid()); + m_cipher.init(SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Decrypt, + decode64(key), decode64(m_nonce)); + return decrypt(m_verifier, m_cipher) == m_nonce; +} + +bool Request::fromJson(QString text) +{ + bool isok = false; + QVariant v = QJson::Parser().parse(text.toUtf8(), &isok); + if (!isok) + return false; + + m_requestType.clear(); + QJson::QObjectHelper::qvariant2qobject(v.toMap(), this); + + return requestType() != INVALID; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// Response +//////////////////////////////////////////////////////////////////////////////////////////////////// + +Response::Response(const Request &request, QString hash): + m_requestType(request.requestTypeStr()), + m_success(false), + m_count(-1), + m_version(STR_VERSION), + m_hash(hash) +{ +} + +void Response::setVerifier(QString key) +{ + Q_ASSERT(!m_cipher.isValid()); + m_cipher.init(SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Encrypt, decode64(key)); + + //Generate new IV + const QByteArray iv = Random::randomArray(m_cipher.blockSize()); + m_cipher.setIv(iv); + m_nonce = encode64(iv); + + //Encrypt + m_verifier = encrypt(m_nonce, m_cipher); +} + +QString Response::toJson() +{ + QVariant result = qobject2qvariant(this); + + QJson::Serializer s; + s.setIndentMode(QJson::IndentCompact); + return s.serialize(result); +} + +KeepassHttpProtocol::RequestType Response::requestType() const +{ + return parseRequest(m_requestType); +} + +QString Response::requestTypeStr() const +{ + return m_requestType; +} + +QString Response::verifier() const +{ + return m_verifier; +} + +QString Response::nonce() const +{ + return m_nonce; +} + +QVariant Response::count() const +{ + return m_count < 0 ? QVariant() : QVariant(m_count); +} + +void Response::setCount(int count) +{ + m_count = count; +} + +QVariant Response::getEntries() const +{ + if (m_count < 0 || m_entries.isEmpty()) + return QVariant(); + + QList res; + res.reserve(m_entries.size()); + Q_FOREACH(const Entry &entry, m_entries) + res.append(qobject2qvariant(&entry)); + return res; +} + +void Response::setEntries(const QList &entries) +{ + Q_ASSERT(m_cipher.isValid()); + + m_count = entries.count(); + + QList encryptedEntries; + encryptedEntries.reserve(m_count); + Q_FOREACH(const Entry &entry, entries) { + encryptedEntries << Entry(encrypt(entry.name(), m_cipher), + encrypt(entry.login(), m_cipher), + entry.password().isNull() ? QString() : encrypt(entry.password(), m_cipher), + encrypt(entry.uuid(), m_cipher)); + } + m_entries = encryptedEntries; +} + +QString Response::hash() const +{ + return m_hash; +} + +QString Response::version() const +{ + return m_version; +} + +QString Response::id() const +{ + return m_id; +} + +void Response::setId(const QString &id) +{ + m_id = id; +} + +bool Response::success() const +{ + return m_success; +} + +void Response::setSuccess() +{ + m_success = true; +} + +QString Response::error() const +{ + return m_error; +} + +void Response::setError(const QString &error) +{ + m_success = false; + m_error = error; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// ResponseEntry +//////////////////////////////////////////////////////////////////////////////////////////////////// + +Q_DECLARE_METATYPE(Entry) + +Entry::Entry() +{} + +Entry::Entry(QString name, QString login, QString password, QString uuid): + m_login(login), + m_password(password), + m_uuid(uuid), + m_name(name) +{} + +Entry::Entry(const Entry & other): + QObject(), + m_login(other.m_login), + m_password(other.m_password), + m_uuid(other.m_uuid), + m_name(other.m_name) +{} + +Entry & Entry::operator=(const Entry & other) +{ + m_login = other.m_login; + m_password = other.m_password; + m_uuid = other.m_uuid; + m_name = other.m_name; + return *this; +} + +QString Entry::login() const +{ + return m_login; +} + +QString Entry::name() const +{ + return m_name; +} + +QString Entry::uuid() const +{ + return m_uuid; +} + +QString Entry::password() const +{ + return m_password; +} diff --git a/src/http/Protocol.h b/src/http/Protocol.h new file mode 100644 index 000000000..b0438d554 --- /dev/null +++ b/src/http/Protocol.h @@ -0,0 +1,182 @@ +/** + *************************************************************************** + * @file Response.h + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#ifndef RESPONSE_H +#define RESPONSE_H + +#include +#include +#include +#include +#include "crypto/SymmetricCipher.h" + +namespace KeepassHttpProtocol { + +enum RequestType { + INVALID = -1, + GET_LOGINS, + GET_LOGINS_COUNT, + GET_ALL_LOGINS, + SET_LOGIN, + ASSOCIATE, + TEST_ASSOCIATE, + GENERATE_PASSWORD +}; + +//TODO: use QByteArray whenever possible? + +class Request : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString RequestType READ requestTypeStr WRITE setRequestType ) + Q_PROPERTY(bool SortSelection READ sortSelection WRITE setSortSelection) + Q_PROPERTY(QString Login READ login WRITE setLogin ) + Q_PROPERTY(QString Password READ password WRITE setPassword ) + Q_PROPERTY(QString Uuid READ uuid WRITE setUuid ) + Q_PROPERTY(QString Url READ url WRITE setUrl ) + Q_PROPERTY(QString SubmitUrl READ submitUrl WRITE setSubmitUrl ) + Q_PROPERTY(QString Key READ key WRITE setKey ) + Q_PROPERTY(QString Id READ id WRITE setId ) + Q_PROPERTY(QString Verifier READ verifier WRITE setVerifier ) + Q_PROPERTY(QString Nonce READ nonce WRITE setNonce ) + Q_PROPERTY(QString Realm READ realm WRITE setRealm ) + +public: + Request(); + bool fromJson(QString text); + + KeepassHttpProtocol::RequestType requestType() const; + QString requestTypeStr() const; + bool sortSelection() const; + QString login() const; + QString password() const; + QString uuid() const; + QString url() const; + QString submitUrl() const; + QString key() const; + QString id() const; + QString verifier() const; + QString nonce() const; + QString realm() const; + bool CheckVerifier(const QString & key) const; + +private: + void setRequestType(const QString &requestType); + void setSortSelection(bool sortSelection); + void setLogin(const QString &login); + void setPassword(const QString &password); + void setUuid(const QString &uuid); + void setUrl(const QString &url); + void setSubmitUrl(const QString &submitUrl); + void setKey(const QString &key); + void setId(const QString &id); + void setVerifier(const QString &verifier); + void setNonce(const QString &nonce); + void setRealm(const QString &realm); + + QString m_requestType; + bool m_sortSelection; + QString m_login; + QString m_password; + QString m_uuid; + QString m_url; + QString m_submitUrl; + QString m_key; + QString m_id; + QString m_verifier; + QString m_nonce; + QString m_realm; + mutable SymmetricCipher m_cipher; +}; + +class Entry : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString Login READ login ) + Q_PROPERTY(QString Password READ password) + Q_PROPERTY(QString Uuid READ uuid ) + Q_PROPERTY(QString Name READ name ) + +public: + Entry(); + Entry(QString name, QString login, QString password, QString uuid); + Entry(const Entry & other); + Entry &operator =(const Entry &other); + + QString login() const; + QString password() const; + QString uuid() const; + QString name() const; + +private: + QString m_login; + QString m_password; + QString m_uuid; + QString m_name; +}; + +class Response : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString RequestType READ requestTypeStr) + Q_PROPERTY(QString Error READ error ) + Q_PROPERTY(bool Success READ success ) + Q_PROPERTY(QString Id READ id ) + Q_PROPERTY(QString Version READ version ) + Q_PROPERTY(QString Hash READ hash ) + Q_PROPERTY(QVariant Count READ count ) + Q_PROPERTY(QVariant Entries READ getEntries ) + Q_PROPERTY(QString Nonce READ nonce ) + Q_PROPERTY(QString Verifier READ verifier ) + +public: + Response(const Request &request, QString hash); + + KeepassHttpProtocol::RequestType requestType() const; + QString error() const; + void setError(const QString &error = QString()); + bool success() const; + void setSuccess(); + QString id() const; + void setId(const QString &id); + QString version() const; + QString hash() const; + QVariant count() const; + void setCount(int count); + QVariant getEntries() const; + void setEntries(const QList &entries); + QString nonce() const; + QString verifier() const; + void setVerifier(QString key); + + QString toJson(); + +private: + QString requestTypeStr() const; + + QString m_requestType; + QString m_error; + bool m_success; + QString m_id; + int m_count; + QString m_version; + QString m_hash; + QList m_entries; + QString m_nonce; + QString m_verifier; + SymmetricCipher m_cipher; +}; + +}/*namespace KeepassHttpProtocol*/ + +#endif // RESPONSE_H diff --git a/src/http/Server.cpp b/src/http/Server.cpp new file mode 100644 index 000000000..e0fc04703 --- /dev/null +++ b/src/http/Server.cpp @@ -0,0 +1,217 @@ +/** + *************************************************************************** + * @file Server.cpp + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#include "Server.h" +#include "qhttpserver/qhttpserver.h" +#include "qhttpserver/qhttprequest.h" +#include "qhttpserver/qhttpresponse.h" +#include "Protocol.h" +#include "crypto/Crypto.h" +#include +#include +#include + +using namespace KeepassHttpProtocol; + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// Request +//////////////////////////////////////////////////////////////////////////////////////////////////// + +RequestHandler::RequestHandler(QHttpRequest *request, QHttpResponse *response): m_request(request), m_response(response) +{ + m_request->storeBody(); + connect(m_request, SIGNAL(end()), this, SLOT(onEnd())); + connect(m_response, SIGNAL(done()), this, SLOT(deleteLater())); +} + +RequestHandler::~RequestHandler() +{ + delete m_request; +} + +void RequestHandler::onEnd() +{ + Q_EMIT requestComplete(m_request, m_response); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// Request +//////////////////////////////////////////////////////////////////////////////////////////////////// + +Server::Server(QObject *parent) : + QObject(parent), + m_httpServer(new QHttpServer(this)), + m_started(false) +{ + connect(m_httpServer, SIGNAL(newRequest(QHttpRequest*,QHttpResponse*)), this, SLOT(handleRequest(QHttpRequest*,QHttpResponse*))); +} + +void Server::start() +{ + if (m_started) + return; + m_started = m_httpServer->listen(QHostAddress::LocalHost, 19455); +} + +void Server::stop() +{ + if (!m_started) + return; + m_httpServer->close(); + m_started = false; +} + +void Server::handleRequest(QHttpRequest *request, QHttpResponse *response) +{ + RequestHandler * h = new RequestHandler(request, response); + connect(h, SIGNAL(requestComplete(QHttpRequest*,QHttpResponse*)), this, SLOT(handleRequestComplete(QHttpRequest*,QHttpResponse*))); +} + +void Server::handleRequestComplete(QHttpRequest *request, QHttpResponse *response) +{ + Request r; + if (!isDatabaseOpened() && !openDatabase()) { + response->writeHead(QHttpResponse::STATUS_SERVICE_UNAVAILABLE); + response->end(); + } else if (request->header("content-type").compare("application/json", Qt::CaseInsensitive) == 0 && + r.fromJson(request->body())) { + + QByteArray hash = QCryptographicHash::hash((getDatabaseRootUuid() + getDatabaseRecycleBinUuid()).toUtf8(), + QCryptographicHash::Sha1).toHex(); + + Response protocolResp(r, QString::fromAscii(hash)); + switch(r.requestType()) { + case INVALID: break; + case TEST_ASSOCIATE: testAssociate(r, &protocolResp); break; + case ASSOCIATE: associate(r, &protocolResp); break; + case GET_LOGINS: getLogins(r, &protocolResp); break; + case GET_LOGINS_COUNT: getLoginsCount(r, &protocolResp); break; + case GET_ALL_LOGINS: getAllLogins(r, &protocolResp); break; + case SET_LOGIN: setLogin(r, &protocolResp); break; + case GENERATE_PASSWORD: generatePassword(r, &protocolResp); break; + } + + QByteArray s = protocolResp.toJson().toUtf8(); + response->setHeader("Content-Type", "application/json"); + response->setHeader("Content-Length", QString::number(s.size())); + response->writeHead(QHttpResponse::STATUS_OK); + response->write(s); + response->end(); + } else { + response->writeHead(QHttpResponse::STATUS_BAD_REQUEST); + response->end(); + } +} + +void Server::testAssociate(const Request& r, Response * protocolResp) +{ + if (r.id().isEmpty()) + return; //ping + + QString key = getKey(r.id()); + if (key.isEmpty() || !r.CheckVerifier(key)) + return; + + protocolResp->setSuccess(); + protocolResp->setId(r.id()); + protocolResp->setVerifier(key); +} + +void Server::associate(const Request& r, Response * protocolResp) +{ + if (!r.CheckVerifier(r.key())) + return; + + QString id = storeKey(r.key()); + if (id.isEmpty()) + return; + + protocolResp->setSuccess(); + protocolResp->setId(id); + protocolResp->setVerifier(r.key()); +} + +void Server::getLogins(const Request &r, Response *protocolResp) +{ + QString key = getKey(r.id()); + if (!r.CheckVerifier(key)) + return; + + protocolResp->setSuccess(); + protocolResp->setId(r.id()); + protocolResp->setVerifier(key); + QList entries = findMatchingEntries(r.id(), r.url(), r.submitUrl(), r.realm()); //TODO: filtering, request confirmation [in db adaptation layer?] + if (r.sortSelection()) { + //TODO: sorting (in db adaptation layer? here?) + } + protocolResp->setEntries(entries); +} + +void Server::getLoginsCount(const Request &r, Response *protocolResp) +{ + QString key = getKey(r.id()); + if (!r.CheckVerifier(key)) + return; + + protocolResp->setSuccess(); + protocolResp->setId(r.id()); + protocolResp->setVerifier(key); + protocolResp->setCount(countMatchingEntries(r.id(), r.url(), r.submitUrl(), r.realm())); +} + +void Server::getAllLogins(const Request &r, Response *protocolResp) +{ + QString key = getKey(r.id()); + if (!r.CheckVerifier(key)) + return; + +// parms.SearchString = @"^[A-Za-z0-9:/-]+\.[A-Za-z0-9:/-]+$"; // match anything looking like a domain or url + protocolResp->setSuccess(); + protocolResp->setId(r.id()); + protocolResp->setVerifier(key); + protocolResp->setEntries(searchAllEntries(r.id())); //TODO: ensure there is no password --> change API? +} + +void Server::setLogin(const Request &r, Response *protocolResp) +{ + QString key = getKey(r.id()); + if (!r.CheckVerifier(key)) + return; + + QString uuid = r.uuid(); + if (uuid.isEmpty()) + addEntry(r.id(), r.login(), r.password(), r.url(), r.submitUrl(), r.realm()); + else + updateEntry(r.id(), r.uuid(), r.login(), r.password(), r.url()); + + protocolResp->setSuccess(); + protocolResp->setId(r.id()); + protocolResp->setVerifier(key); +} + +void Server::generatePassword(const Request &r, Response *protocolResp) +{ + QString key = getKey(r.id()); + if (!r.CheckVerifier(key)) + return; + + QString password = generatePassword(); + + protocolResp->setSuccess(); + protocolResp->setId(r.id()); + protocolResp->setVerifier(key); + protocolResp->setEntries(QList() << Entry("generate-password", "generate-password", password, "generate-password")); + + memset(password.data(), 0, password.length()); +} diff --git a/src/http/Server.h b/src/http/Server.h new file mode 100644 index 000000000..563ecae07 --- /dev/null +++ b/src/http/Server.h @@ -0,0 +1,91 @@ +/** + *************************************************************************** + * @file Server.h + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#ifndef SERVER_H +#define SERVER_H + +#include +#include + +class QHttpServer; +class QHttpRequest; +class QHttpResponse; + +namespace KeepassHttpProtocol { + +class Request; +class Response; +class Entry; + +class RequestHandler: public QObject { + Q_OBJECT + +public: + RequestHandler(QHttpRequest *request, QHttpResponse *response); + ~RequestHandler(); + +private Q_SLOTS: + void onEnd(); + +Q_SIGNALS: + void requestComplete(QHttpRequest *request, QHttpResponse *response); + +private: + QHttpRequest * m_request; + QHttpResponse *m_response; +}; + +class Server : public QObject +{ + Q_OBJECT +public: + explicit Server(QObject *parent = 0); + + //TODO: use QByteArray? + virtual bool isDatabaseOpened() const = 0; + virtual bool openDatabase() = 0; + virtual QString getDatabaseRootUuid() = 0; + virtual QString getDatabaseRecycleBinUuid() = 0; + virtual QString getKey(const QString &id) = 0; + virtual QString storeKey(const QString &key) = 0; + virtual QList findMatchingEntries(const QString &id, const QString &url, const QString & submitUrl, const QString & realm) = 0; + virtual int countMatchingEntries(const QString &id, const QString &url, const QString & submitUrl, const QString & realm) = 0; + virtual QList searchAllEntries(const QString &id) = 0; + virtual void addEntry(const QString &id, const QString &login, const QString &password, const QString &url, const QString &submitUrl, const QString &realm) = 0; + virtual void updateEntry(const QString &id, const QString &uuid, const QString &login, const QString &password, const QString &url) = 0; + virtual QString generatePassword() = 0; + +public Q_SLOTS: + void start(); + void stop(); + +private Q_SLOTS: + void handleRequest(QHttpRequest * request, QHttpResponse* response); + void handleRequestComplete(QHttpRequest * request, QHttpResponse* response); + +private: + void testAssociate(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); + void associate(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); + void getLogins(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); + void getLoginsCount(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); + void getAllLogins(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); + void setLogin(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); + void generatePassword(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); + + QHttpServer * const m_httpServer; + bool m_started; +}; + +} /*namespace KeepassHttpProtocol*/ + +#endif // SERVER_H diff --git a/src/http/Service.cpp b/src/http/Service.cpp new file mode 100644 index 000000000..4ade6169f --- /dev/null +++ b/src/http/Service.cpp @@ -0,0 +1,293 @@ +/** + *************************************************************************** + * @file Service.cpp + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#include "Service.h" +#include "Protocol.h" +#include "core/Database.h" +#include "core/Entry.h" +#include "core/Group.h" +#include "core/Metadata.h" +#include "core/Uuid.h" +#include "core/PasswordGenerator.h" +#include +#include +#include + +Service::Service(DatabaseTabWidget *parent) : + KeepassHttpProtocol::Server(parent), + m_dbTabWidget(parent) +{ +} + +static const char KEEPASSHTTP_UUID_DATA[] = { + 0x34, 0x69, 0x7a, 0x40, 0x8a, 0x5b, 0x41, 0xc0, + 0x9f, 0x36, 0x89, 0x7d, 0x62, 0x3e, 0xcb, 0x31 +}; +static const Uuid KEEPASSHTTP_UUID = Uuid(QByteArray::fromRawData(KEEPASSHTTP_UUID_DATA, sizeof(KEEPASSHTTP_UUID_DATA))); +static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings"; +static const char ASSOCIATE_KEY_PREFIX[] = "AES Key: "; +static const char KEEPASSHTTP_GROUP_NAME[] = "KeePassHttp Passwords"; //Group where new KeePassHttp password are stored +//private const int DEFAULT_NOTIFICATION_TIME = 5000; + +Entry* Service::getConfigEntry(bool create) +{ + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database * db = dbWidget->database()) { + Entry* entry = db->resolveEntry(KEEPASSHTTP_UUID); + if (!entry && create) { + entry = new Entry(); + entry->setTitle(QLatin1String(KEEPASSHTTP_NAME)); + entry->setUuid(KEEPASSHTTP_UUID); + entry->setAutoTypeEnabled(false); + entry->setGroup(db->rootGroup()); + } else if (entry && entry->group() == db->metadata()->recycleBin()) { + if (create) + entry->setGroup(db->rootGroup()); + else + entry = NULL; + } + return entry; + } + return NULL; +} + +bool Service::isDatabaseOpened() const +{ + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + switch(dbWidget->currentMode()) { + case DatabaseWidget::None: + case DatabaseWidget::LockedMode: + break; + + case DatabaseWidget::ViewMode: + case DatabaseWidget::EditMode: + return true; + } + return false; +} + +bool Service::openDatabase() +{ + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (dbWidget->currentMode() == DatabaseWidget::LockedMode) { + //- show notification + //- open window + //- wait a few seconds for user to unlock... + } + return false; +} + +QString Service::getDatabaseRootUuid() +{ + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database * db = dbWidget->database()) + if (Group * rootGroup = db->rootGroup()) + return rootGroup->uuid().toHex(); + return QString(); +} + +QString Service::getDatabaseRecycleBinUuid() +{ + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database * db = dbWidget->database()) + if (Group * recycleBin = db->metadata()->recycleBin()) + return recycleBin->uuid().toHex(); + return QString(); +} + +QString Service::getKey(const QString &id) +{ + if (Entry* config = getConfigEntry()) + return config->attributes()->value(QLatin1String(ASSOCIATE_KEY_PREFIX) + id); + return QString(); +} + +QString Service::storeKey(const QString &key) +{ + QString id; + if (Entry* config = getConfigEntry(true)) { + do { + bool ok; + //Indicate who wants to associate, and request user to enter the 'name' of association key + id = QInputDialog::getText(0, tr("KeyPassX/Http: New key association request"), + tr("You have received an association request for the above key. If you would like to " + "allow it access to your KeePassX database give it a unique name to identify and a" + "ccept it."), + QLineEdit::Normal, QString(), &ok); + if (!ok || id.isEmpty()) + return QString(); + //Warn if association key already exists + } while(!config->attributes()->value(QLatin1String(ASSOCIATE_KEY_PREFIX) + id).isEmpty() && + QMessageBox(QMessageBox::Warning, tr("KeyPassX/Http: Overwrite existing key?"), + tr("A shared encryption-key with the name \"%1\" already exists.\nDo you want to overwrite it?").arg(id), + QMessageBox::Yes|QMessageBox::No).exec() == QMessageBox::No); + + config->attributes()->set(QLatin1String(ASSOCIATE_KEY_PREFIX) + id, key, true); + } + return id; +} + +bool Service::matchUrlScheme(const QString & url) +{ + QString str = url.left(8).toLower(); + return str.startsWith("http://") || + str.startsWith("https://") || + str.startsWith("ftp://") || + str.startsWith("ftps://"); +} + +bool Service::removeFirstDomain(QString & hostname) +{ + int pos = hostname.indexOf("."); + if (pos < 0) + return false; + hostname = hostname.mid(pos + 1); + return !hostname.isEmpty(); +} + +QList Service::searchEntries(const QString &text) +{ + QList entries; + + //TODO: setting to search all databases [e.g. as long as the 'current' db is authentified + + //Search entries matching the hostname + QString hostname = QUrl(text).host(); + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database * db = dbWidget->database()) + if (Group * rootGroup = db->rootGroup()) + do { + Q_FOREACH (Entry * entry, rootGroup->search(hostname, Qt::CaseInsensitive)) { + QString title = entry->title(); + QString url = entry->url(); + + //Filter to match hostname in Title and Url fields + if ( hostname.contains(title) + || hostname.contains(url) + || (matchUrlScheme(title) && hostname.contains(QUrl(title).host())) + || (matchUrlScheme(url) && hostname.contains(QUrl(url).host())) ) + entries.append(entry); + } + } while(entries.isEmpty() && removeFirstDomain(hostname)); + return entries; +} + +QList Service::findMatchingEntries(const QString &id, const QString &url, const QString &submitUrl, const QString &realm) +{ + QList result; + const QList pwEntries = searchEntries(url); + Q_FOREACH (Entry * entry, pwEntries) { + //Filter accepted/denied entries + // if (c.Allow.Contains(formHost) && (submitHost == null || c.Allow.Contains(submitHost))) + // return true; + // if (c.Deny.Contains(formHost) || (submitHost != null && c.Deny.Contains(submitHost))) + // return false; + // if (realm != null && c.Realm != realm) + // return false; + + //If we are unsure for some entries: + //- balloon to grant accessc if possible + //- if clicked, show confirmation dialog --> accept/reject (w/ list of items?) + // The website XXX wants to access your credentials + // MORE (---> if clicked, shows the list of returned entries) + // [x] Ask me again [Allow] [Deny] + // If accepted, store that entry can be accessed without confirmation + //- else, show only items which do not require validation + + //TODO: sort [--> need a flag], or do this in Server class [--> need an extra 'sort order' key in Entry, and we always compute it] + result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), entry->password(), entry->uuid().toHex()); + } + return result; +} + +int Service::countMatchingEntries(const QString &id, const QString &url, const QString &submitUrl, const QString &realm) +{ + return searchEntries(url).count(); +} + +QList Service::searchAllEntries(const QString &id) +{ + QList result; + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database * db = dbWidget->database()) + if (Group * rootGroup = db->rootGroup()) + Q_FOREACH (Entry * entry, rootGroup->entriesRecursive()) + result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), QString(), entry->uuid().toHex()); + return result; +} + +Group * Service::findCreateAddEntryGroup() +{ + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database * db = dbWidget->database()) + if (Group * rootGroup = db->rootGroup()) { + const QString groupName = QLatin1String(KEEPASSHTTP_GROUP_NAME);//TODO: setting to decide where new keys are created + + Q_FOREACH (const Group * g, rootGroup->groupsRecursive(true)) + if (g->name() == groupName) + return db->resolveGroup(g->uuid()); + + Group * group; + group = new Group(); + group->setUuid(Uuid::random()); + group->setName(groupName); + group->setIcon(Group::DefaultIconNumber); //TODO: WorldIconNumber + group->setParent(rootGroup); + return group; + } + return NULL; +} + +void Service::addEntry(const QString &id, const QString &login, const QString &password, const QString &url, const QString &submitUrl, const QString &realm) +{ + if (Group * group = findCreateAddEntryGroup()) { + Entry * entry = new Entry(); + entry->setUuid(Uuid::random()); + entry->setTitle(QUrl(url).host()); + entry->setUrl(url); + entry->setIcon(Entry::DefaultIconNumber); //TODO: WorldIconNumber + entry->setUsername(login); + entry->setPassword(password); + entry->setGroup(group); + } +} + +void Service::updateEntry(const QString &id, const QString &uuid, const QString &login, const QString &password, const QString &url) +{ + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database * db = dbWidget->database()) + if (Entry * entry = db->resolveEntry(Uuid::fromHex(uuid))) { + QString u = entry->username(); + if (u != login || entry->password() != password) { + bool autoAllow = false; //TODO: setting to request confirmation/auto-allow + if ( autoAllow + || QMessageBox(QMessageBox::Warning, tr("KeyPassX/Http: Update Entry"), + tr("Do you want to update the information in {0} - {1}?").arg(QUrl(url).host()).arg(u), + QMessageBox::Yes|QMessageBox::No).exec() == QMessageBox::Yes ) { + entry->beginUpdate(); + entry->setUsername(login); + entry->setPassword(password); + entry->endUpdate(); + } + } + } +} + +QString Service::generatePassword() +{ + PasswordGenerator * pwGenerator = passwordGenerator(); + //TODO: password generator settings + return pwGenerator->generatePassword(20, + PasswordGenerator::LowerLetters | PasswordGenerator::UpperLetters | PasswordGenerator::Numbers, + PasswordGenerator::ExcludeLookAlike | PasswordGenerator::CharFromEveryGroup); +} diff --git a/src/http/Service.h b/src/http/Service.h new file mode 100644 index 000000000..123815b89 --- /dev/null +++ b/src/http/Service.h @@ -0,0 +1,51 @@ +/** + *************************************************************************** + * @file Service.h + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#ifndef SERVICE_H +#define SERVICE_H + +#include +#include "gui/DatabaseTabWidget.h" +#include "Server.h" + +class Service : public KeepassHttpProtocol::Server +{ + Q_OBJECT + +public: + explicit Service(DatabaseTabWidget *parent = 0); + + virtual bool isDatabaseOpened() const; + virtual bool openDatabase(); + virtual QString getDatabaseRootUuid(); + virtual QString getDatabaseRecycleBinUuid(); + virtual QString getKey(const QString &id); + virtual QString storeKey(const QString &key); + virtual QList findMatchingEntries(const QString &id, const QString &url, const QString & submitUrl, const QString & realm); + virtual int countMatchingEntries(const QString &id, const QString &url, const QString & submitUrl, const QString & realm); + virtual QList searchAllEntries(const QString &id); + virtual void addEntry(const QString &id, const QString &login, const QString &password, const QString &url, const QString &submitUrl, const QString &realm); + virtual void updateEntry(const QString &id, const QString &uuid, const QString &login, const QString &password, const QString &url); + virtual QString generatePassword(); + +private: + Entry* getConfigEntry(bool create = false); + bool matchUrlScheme(const QString &url); + bool removeFirstDomain(QString &hostname); + Group *findCreateAddEntryGroup(); + QList searchEntries(const QString &text); + + DatabaseTabWidget * const m_dbTabWidget; +}; + +#endif // SERVICE_H diff --git a/src/http/qhttpserver/CMakeLists.txt b/src/http/qhttpserver/CMakeLists.txt new file mode 100644 index 000000000..932e4b265 --- /dev/null +++ b/src/http/qhttpserver/CMakeLists.txt @@ -0,0 +1,20 @@ + +set(qhttpserver_MOC_HDRS + qhttpserver.h + qhttpresponse.h + qhttprequest.h + qhttpconnection.h +) + +IF (NOT Qt5Core_FOUND) + qt4_wrap_cpp(qhttpserver_MOC_SRCS ${qhttpserver_MOC_HDRS}) +ENDIF() + +set (qhttpserver_SRCS qhttpconnection.cpp qhttprequest.cpp qhttpresponse.cpp qhttpserver.cpp + http-parser/http_parser.c http-parser/url_parser.c) +set (qhttpserver_HEADERS qhttpconnection.h qhttprequest.h qhttpresponse.h qhttpserver.h + http-parser/http_parser.h) + +INCLUDE_DIRECTORIES(http-parser) + +add_library (qhttpserver STATIC ${qhttpserver_SRCS} ${qhttpserver_MOC_SRCS} ${qhttpserver_HEADERS}) diff --git a/src/http/qhttpserver/LICENSE b/src/http/qhttpserver/LICENSE new file mode 100644 index 000000000..3351aecfc --- /dev/null +++ b/src/http/qhttpserver/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2011-2012 Nikhil Marathe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/src/http/qhttpserver/http-parser/AUTHORS b/src/http/qhttpserver/http-parser/AUTHORS new file mode 100644 index 000000000..0bfcf7604 --- /dev/null +++ b/src/http/qhttpserver/http-parser/AUTHORS @@ -0,0 +1,40 @@ +# Authors ordered by first contribution. +Ryan Dahl +Jeremy Hinegardner +Sergey Shepelev +Joe Damato +tomika +Phoenix Sol +Cliff Frey +Ewen Cheslack-Postava +Santiago Gala +Tim Becker +Jeff Terrace +Ben Noordhuis +Nathan Rajlich +Mark Nottingham +Aman Gupta +Tim Becker +Sean Cunningham +Peter Griess +Salman Haq +Cliff Frey +Jon Kolb +Fouad Mardini +Paul Querna +Felix Geisendörfer +koichik +Andre Caron +Ivo Raisr +James McLaughlin +David Gwynne +LE ROUX Thomas +Randy Rizun +Andre Louis Caron +Simon Zimmermann +Erik Dubbelboer +Martell Malone +Bertrand Paquet +BogDan Vatra +Peter Faiman +Corey Richardson diff --git a/src/http/qhttpserver/http-parser/CONTRIBUTIONS b/src/http/qhttpserver/http-parser/CONTRIBUTIONS new file mode 100644 index 000000000..11ba31e4b --- /dev/null +++ b/src/http/qhttpserver/http-parser/CONTRIBUTIONS @@ -0,0 +1,4 @@ +Contributors must agree to the Contributor License Agreement before patches +can be accepted. + +http://spreadsheets2.google.com/viewform?hl=en&formkey=dDJXOGUwbzlYaWM4cHN1MERwQS1CSnc6MQ diff --git a/src/http/qhttpserver/http-parser/LICENSE-MIT b/src/http/qhttpserver/http-parser/LICENSE-MIT new file mode 100644 index 000000000..58010b388 --- /dev/null +++ b/src/http/qhttpserver/http-parser/LICENSE-MIT @@ -0,0 +1,23 @@ +http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright +Igor Sysoev. + +Additional changes are licensed under the same terms as NGINX and +copyright Joyent, Inc. and other Node contributors. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/src/http/qhttpserver/http-parser/README.md b/src/http/qhttpserver/http-parser/README.md new file mode 100644 index 000000000..ef1bf6e90 --- /dev/null +++ b/src/http/qhttpserver/http-parser/README.md @@ -0,0 +1,178 @@ +HTTP Parser +=========== + +This is a parser for HTTP messages written in C. It parses both requests and +responses. The parser is designed to be used in performance HTTP +applications. It does not make any syscalls nor allocations, it does not +buffer data, it can be interrupted at anytime. Depending on your +architecture, it only requires about 40 bytes of data per message +stream (in a web server that is per connection). + +Features: + + * No dependencies + * Handles persistent streams (keep-alive). + * Decodes chunked encoding. + * Upgrade support + * Defends against buffer overflow attacks. + +The parser extracts the following information from HTTP messages: + + * Header fields and values + * Content-Length + * Request method + * Response status code + * Transfer-Encoding + * HTTP version + * Request URL + * Message body + + +Usage +----- + +One `http_parser` object is used per TCP connection. Initialize the struct +using `http_parser_init()` and set the callbacks. That might look something +like this for a request parser: + + http_parser_settings settings; + settings.on_url = my_url_callback; + settings.on_header_field = my_header_field_callback; + /* ... */ + + http_parser *parser = malloc(sizeof(http_parser)); + http_parser_init(parser, HTTP_REQUEST); + parser->data = my_socket; + +When data is received on the socket execute the parser and check for errors. + + size_t len = 80*1024, nparsed; + char buf[len]; + ssize_t recved; + + recved = recv(fd, buf, len, 0); + + if (recved < 0) { + /* Handle error. */ + } + + /* Start up / continue the parser. + * Note we pass recved==0 to signal that EOF has been recieved. + */ + nparsed = http_parser_execute(parser, &settings, buf, recved); + + if (parser->upgrade) { + /* handle new protocol */ + } else if (nparsed != recved) { + /* Handle error. Usually just close the connection. */ + } + +HTTP needs to know where the end of the stream is. For example, sometimes +servers send responses without Content-Length and expect the client to +consume input (for the body) until EOF. To tell http_parser about EOF, give +`0` as the forth parameter to `http_parser_execute()`. Callbacks and errors +can still be encountered during an EOF, so one must still be prepared +to receive them. + +Scalar valued message information such as `status_code`, `method`, and the +HTTP version are stored in the parser structure. This data is only +temporally stored in `http_parser` and gets reset on each new message. If +this information is needed later, copy it out of the structure during the +`headers_complete` callback. + +The parser decodes the transfer-encoding for both requests and responses +transparently. That is, a chunked encoding is decoded before being sent to +the on_body callback. + + +The Special Problem of Upgrade +------------------------------ + +HTTP supports upgrading the connection to a different protocol. An +increasingly common example of this is the Web Socket protocol which sends +a request like + + GET /demo HTTP/1.1 + Upgrade: WebSocket + Connection: Upgrade + Host: example.com + Origin: http://example.com + WebSocket-Protocol: sample + +followed by non-HTTP data. + +(See http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75 for more +information the Web Socket protocol.) + +To support this, the parser will treat this as a normal HTTP message without a +body. Issuing both on_headers_complete and on_message_complete callbacks. However +http_parser_execute() will stop parsing at the end of the headers and return. + +The user is expected to check if `parser->upgrade` has been set to 1 after +`http_parser_execute()` returns. Non-HTTP data begins at the buffer supplied +offset by the return value of `http_parser_execute()`. + + +Callbacks +--------- + +During the `http_parser_execute()` call, the callbacks set in +`http_parser_settings` will be executed. The parser maintains state and +never looks behind, so buffering the data is not necessary. If you need to +save certain data for later usage, you can do that from the callbacks. + +There are two types of callbacks: + +* notification `typedef int (*http_cb) (http_parser*);` + Callbacks: on_message_begin, on_headers_complete, on_message_complete. +* data `typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);` + Callbacks: (requests only) on_uri, + (common) on_header_field, on_header_value, on_body; + +Callbacks must return 0 on success. Returning a non-zero value indicates +error to the parser, making it exit immediately. + +In case you parse HTTP message in chunks (i.e. `read()` request line +from socket, parse, read half headers, parse, etc) your data callbacks +may be called more than once. Http-parser guarantees that data pointer is only +valid for the lifetime of callback. You can also `read()` into a heap allocated +buffer to avoid copying memory around if this fits your application. + +Reading headers may be a tricky task if you read/parse headers partially. +Basically, you need to remember whether last header callback was field or value +and apply following logic: + + (on_header_field and on_header_value shortened to on_h_*) + ------------------------ ------------ -------------------------------------------- + | State (prev. callback) | Callback | Description/action | + ------------------------ ------------ -------------------------------------------- + | nothing (first call) | on_h_field | Allocate new buffer and copy callback data | + | | | into it | + ------------------------ ------------ -------------------------------------------- + | value | on_h_field | New header started. | + | | | Copy current name,value buffers to headers | + | | | list and allocate new buffer for new name | + ------------------------ ------------ -------------------------------------------- + | field | on_h_field | Previous name continues. Reallocate name | + | | | buffer and append callback data to it | + ------------------------ ------------ -------------------------------------------- + | field | on_h_value | Value for current header started. Allocate | + | | | new buffer and copy callback data to it | + ------------------------ ------------ -------------------------------------------- + | value | on_h_value | Value continues. Reallocate value buffer | + | | | and append callback data to it | + ------------------------ ------------ -------------------------------------------- + + +Parsing URLs +------------ + +A simplistic zero-copy URL parser is provided as `http_parser_parse_url()`. +Users of this library may wish to use it to parse URLs constructed from +consecutive `on_url` callbacks. + +See examples of reading in headers: + +* [partial example](http://gist.github.com/155877) in C +* [from http-parser tests](http://github.com/joyent/http-parser/blob/37a0ff8/test.c#L403) in C +* [from Node library](http://github.com/joyent/node/blob/842eaf4/src/http.js#L284) in Javascript diff --git a/src/http/qhttpserver/http-parser/http_parser.c b/src/http/qhttpserver/http-parser/http_parser.c new file mode 100644 index 000000000..c71098249 --- /dev/null +++ b/src/http/qhttpserver/http-parser/http_parser.c @@ -0,0 +1,2174 @@ +/* Based on src/http/ngx_http_parse.c from NGINX copyright Igor Sysoev + * + * Additional changes are licensed under the same terms as NGINX and + * copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "http_parser.h" +#include +#include +#include +#include +#include +#include + +#ifndef ULLONG_MAX +# define ULLONG_MAX ((uint64_t) -1) /* 2^64-1 */ +#endif + +#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef ARRAY_SIZE +# define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#endif + +#ifndef BIT_AT +# define BIT_AT(a, i) \ + (!!((unsigned int) (a)[(unsigned int) (i) >> 3] & \ + (1 << ((unsigned int) (i) & 7)))) +#endif + +#ifndef ELEM_AT +# define ELEM_AT(a, i, v) ((unsigned int) (i) < ARRAY_SIZE(a) ? (a)[(i)] : (v)) +#endif + +#define SET_ERRNO(e) \ +do { \ + parser->http_errno = (e); \ +} while(0) + + +/* Run the notify callback FOR, returning ER if it fails */ +#define CALLBACK_NOTIFY_(FOR, ER) \ +do { \ + assert(HTTP_PARSER_ERRNO(parser) == HPE_OK); \ + \ + if (settings->on_##FOR) { \ + if (0 != settings->on_##FOR(parser)) { \ + SET_ERRNO(HPE_CB_##FOR); \ + } \ + \ + /* We either errored above or got paused; get out */ \ + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { \ + return (ER); \ + } \ + } \ +} while (0) + +/* Run the notify callback FOR and consume the current byte */ +#define CALLBACK_NOTIFY(FOR) CALLBACK_NOTIFY_(FOR, p - data + 1) + +/* Run the notify callback FOR and don't consume the current byte */ +#define CALLBACK_NOTIFY_NOADVANCE(FOR) CALLBACK_NOTIFY_(FOR, p - data) + +/* Run data callback FOR with LEN bytes, returning ER if it fails */ +#define CALLBACK_DATA_(FOR, LEN, ER) \ +do { \ + assert(HTTP_PARSER_ERRNO(parser) == HPE_OK); \ + \ + if (FOR##_mark) { \ + if (settings->on_##FOR) { \ + if (0 != settings->on_##FOR(parser, FOR##_mark, (LEN))) { \ + SET_ERRNO(HPE_CB_##FOR); \ + } \ + \ + /* We either errored above or got paused; get out */ \ + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { \ + return (ER); \ + } \ + } \ + FOR##_mark = NULL; \ + } \ +} while (0) + +/* Run the data callback FOR and consume the current byte */ +#define CALLBACK_DATA(FOR) \ + CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1) + +/* Run the data callback FOR and don't consume the current byte */ +#define CALLBACK_DATA_NOADVANCE(FOR) \ + CALLBACK_DATA_(FOR, p - FOR##_mark, p - data) + +/* Set the mark FOR; non-destructive if mark is already set */ +#define MARK(FOR) \ +do { \ + if (!FOR##_mark) { \ + FOR##_mark = p; \ + } \ +} while (0) + + +#define PROXY_CONNECTION "proxy-connection" +#define CONNECTION "connection" +#define CONTENT_LENGTH "content-length" +#define TRANSFER_ENCODING "transfer-encoding" +#define UPGRADE "upgrade" +#define CHUNKED "chunked" +#define KEEP_ALIVE "keep-alive" +#define CLOSE "close" + + +static const char *method_strings[] = + { +#define XX(num, name, string) #string, + HTTP_METHOD_MAP(XX) +#undef XX + }; + + +/* Tokens as defined by rfc 2616. Also lowercases them. + * token = 1* + * separators = "(" | ")" | "<" | ">" | "@" + * | "," | ";" | ":" | "\" | <"> + * | "/" | "[" | "]" | "?" | "=" + * | "{" | "}" | SP | HT + */ +static const char tokens[256] = { +/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ + 0, '!', 0, '#', '$', '%', '&', '\'', +/* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ + 0, 0, '*', '+', 0, '-', '.', 0, +/* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ + '0', '1', '2', '3', '4', '5', '6', '7', +/* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ + '8', '9', 0, 0, 0, 0, 0, 0, +/* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ + 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', +/* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', +/* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', +/* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ + 'x', 'y', 'z', 0, 0, 0, '^', '_', +/* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', +/* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', +/* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', +/* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ + 'x', 'y', 'z', 0, '|', 0, '~', 0 }; + + +static const int8_t unhex[256] = + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1 + ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + }; + + +#if HTTP_PARSER_STRICT +# define T(v) 0 +#else +# define T(v) v +#endif + + +static const uint8_t normal_url_char[32] = { +/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0, +/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ + 0 | T(2) | 0 | 0 | T(16) | 0 | 0 | 0, +/* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0, +/* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0, +/* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ + 0 | 2 | 4 | 0 | 16 | 32 | 64 | 128, +/* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 0, +/* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 0, }; + +#undef T + +enum state + { s_dead = 1 /* important that this is > 0 */ + + , s_start_req_or_res + , s_res_or_resp_H + , s_start_res + , s_res_H + , s_res_HT + , s_res_HTT + , s_res_HTTP + , s_res_first_http_major + , s_res_http_major + , s_res_first_http_minor + , s_res_http_minor + , s_res_first_status_code + , s_res_status_code + , s_res_status + , s_res_line_almost_done + + , s_start_req + + , s_req_method + , s_req_spaces_before_url + , s_req_schema + , s_req_schema_slash + , s_req_schema_slash_slash + , s_req_server_start + , s_req_server + , s_req_server_with_at + , s_req_path + , s_req_query_string_start + , s_req_query_string + , s_req_fragment_start + , s_req_fragment + , s_req_http_start + , s_req_http_H + , s_req_http_HT + , s_req_http_HTT + , s_req_http_HTTP + , s_req_first_http_major + , s_req_http_major + , s_req_first_http_minor + , s_req_http_minor + , s_req_line_almost_done + + , s_header_field_start + , s_header_field + , s_header_value_start + , s_header_value + , s_header_value_lws + + , s_header_almost_done + + , s_chunk_size_start + , s_chunk_size + , s_chunk_parameters + , s_chunk_size_almost_done + + , s_headers_almost_done + , s_headers_done + + /* Important: 's_headers_done' must be the last 'header' state. All + * states beyond this must be 'body' states. It is used for overflow + * checking. See the PARSING_HEADER() macro. + */ + + , s_chunk_data + , s_chunk_data_almost_done + , s_chunk_data_done + + , s_body_identity + , s_body_identity_eof + + , s_message_done + }; + + +#define PARSING_HEADER(state) (state <= s_headers_done) + + +enum header_states + { h_general = 0 + , h_C + , h_CO + , h_CON + + , h_matching_connection + , h_matching_proxy_connection + , h_matching_content_length + , h_matching_transfer_encoding + , h_matching_upgrade + + , h_connection + , h_content_length + , h_transfer_encoding + , h_upgrade + + , h_matching_transfer_encoding_chunked + , h_matching_connection_keep_alive + , h_matching_connection_close + + , h_transfer_encoding_chunked + , h_connection_keep_alive + , h_connection_close + }; + +enum http_host_state + { + s_http_host_dead = 1 + , s_http_userinfo_start + , s_http_userinfo + , s_http_host_start + , s_http_host_v6_start + , s_http_host + , s_http_host_v6 + , s_http_host_v6_end + , s_http_host_port_start + , s_http_host_port +}; + +/* Macros for character classes; depends on strict-mode */ +#define CR '\r' +#define LF '\n' +#define LOWER(c) (unsigned char)(c | 0x20) +#define IS_ALPHA(c) (LOWER(c) >= 'a' && LOWER(c) <= 'z') +#define IS_NUM(c) ((c) >= '0' && (c) <= '9') +#define IS_ALPHANUM(c) (IS_ALPHA(c) || IS_NUM(c)) +#define IS_HEX(c) (IS_NUM(c) || (LOWER(c) >= 'a' && LOWER(c) <= 'f')) +#define IS_MARK(c) ((c) == '-' || (c) == '_' || (c) == '.' || \ + (c) == '!' || (c) == '~' || (c) == '*' || (c) == '\'' || (c) == '(' || \ + (c) == ')') +#define IS_USERINFO_CHAR(c) (IS_ALPHANUM(c) || IS_MARK(c) || (c) == '%' || \ + (c) == ';' || (c) == ':' || (c) == '&' || (c) == '=' || (c) == '+' || \ + (c) == '$' || (c) == ',') + +#if HTTP_PARSER_STRICT +#define TOKEN(c) (tokens[(unsigned char)c]) +#define IS_URL_CHAR(c) (BIT_AT(normal_url_char, (unsigned char)c)) +#define IS_HOST_CHAR(c) (IS_ALPHANUM(c) || (c) == '.' || (c) == '-') +#else +#define TOKEN(c) ((c == ' ') ? ' ' : tokens[(unsigned char)c]) +#define IS_URL_CHAR(c) \ + (BIT_AT(normal_url_char, (unsigned char)c) || ((c) & 0x80)) +#define IS_HOST_CHAR(c) \ + (IS_ALPHANUM(c) || (c) == '.' || (c) == '-' || (c) == '_') +#endif + + +#define start_state (parser->type == HTTP_REQUEST ? s_start_req : s_start_res) + + +#if HTTP_PARSER_STRICT +# define STRICT_CHECK(cond) \ +do { \ + if (cond) { \ + SET_ERRNO(HPE_STRICT); \ + goto error; \ + } \ +} while (0) +# define NEW_MESSAGE() (http_should_keep_alive(parser) ? start_state : s_dead) +#else +# define STRICT_CHECK(cond) +# define NEW_MESSAGE() start_state +#endif + + +/* Map errno values to strings for human-readable output */ +#define HTTP_STRERROR_GEN(n, s) { "HPE_" #n, s }, +static struct { + const char *name; + const char *description; +} http_strerror_tab[] = { + HTTP_ERRNO_MAP(HTTP_STRERROR_GEN) +}; +#undef HTTP_STRERROR_GEN + +int http_message_needs_eof(const http_parser *parser); + +/* Our URL parser. + * + * This is designed to be shared by http_parser_execute() for URL validation, + * hence it has a state transition + byte-for-byte interface. In addition, it + * is meant to be embedded in http_parser_parse_url(), which does the dirty + * work of turning state transitions URL components for its API. + * + * This function should only be invoked with non-space characters. It is + * assumed that the caller cares about (and can detect) the transition between + * URL and non-URL states by looking for these. + */ +static enum state +parse_url_char(enum state s, const char ch) +{ + if (ch == ' ' || ch == '\r' || ch == '\n') { + return s_dead; + } + +#if HTTP_PARSER_STRICT + if (ch == '\t' || ch == '\f') { + return s_dead; + } +#endif + + switch (s) { + case s_req_spaces_before_url: + /* Proxied requests are followed by scheme of an absolute URI (alpha). + * All methods except CONNECT are followed by '/' or '*'. + */ + + if (ch == '/' || ch == '*') { + return s_req_path; + } + + if (IS_ALPHA(ch)) { + return s_req_schema; + } + + break; + + case s_req_schema: + if (IS_ALPHA(ch)) { + return s; + } + + if (ch == ':') { + return s_req_schema_slash; + } + + break; + + case s_req_schema_slash: + if (ch == '/') { + return s_req_schema_slash_slash; + } + + break; + + case s_req_schema_slash_slash: + if (ch == '/') { + return s_req_server_start; + } + + break; + + case s_req_server_with_at: + if (ch == '@') { + return s_dead; + } + + /* FALLTHROUGH */ + case s_req_server_start: + case s_req_server: + if (ch == '/') { + return s_req_path; + } + + if (ch == '?') { + return s_req_query_string_start; + } + + if (ch == '@') { + return s_req_server_with_at; + } + + if (IS_USERINFO_CHAR(ch) || ch == '[' || ch == ']') { + return s_req_server; + } + + break; + + case s_req_path: + if (IS_URL_CHAR(ch)) { + return s; + } + + switch (ch) { + case '?': + return s_req_query_string_start; + + case '#': + return s_req_fragment_start; + } + + break; + + case s_req_query_string_start: + case s_req_query_string: + if (IS_URL_CHAR(ch)) { + return s_req_query_string; + } + + switch (ch) { + case '?': + /* allow extra '?' in query string */ + return s_req_query_string; + + case '#': + return s_req_fragment_start; + } + + break; + + case s_req_fragment_start: + if (IS_URL_CHAR(ch)) { + return s_req_fragment; + } + + switch (ch) { + case '?': + return s_req_fragment; + + case '#': + return s; + } + + break; + + case s_req_fragment: + if (IS_URL_CHAR(ch)) { + return s; + } + + switch (ch) { + case '?': + case '#': + return s; + } + + break; + + default: + break; + } + + /* We should never fall out of the switch above unless there's an error */ + return s_dead; +} + +size_t http_parser_execute (http_parser *parser, + const http_parser_settings *settings, + const char *data, + size_t len) +{ + char c, ch; + int8_t unhex_val; + const char *p = data; + const char *header_field_mark = 0; + const char *header_value_mark = 0; + const char *url_mark = 0; + const char *body_mark = 0; + + /* We're in an error state. Don't bother doing anything. */ + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { + return 0; + } + + if (len == 0) { + switch (parser->state) { + case s_body_identity_eof: + /* Use of CALLBACK_NOTIFY() here would erroneously return 1 byte read if + * we got paused. + */ + CALLBACK_NOTIFY_NOADVANCE(message_complete); + return 0; + + case s_dead: + case s_start_req_or_res: + case s_start_res: + case s_start_req: + return 0; + + default: + SET_ERRNO(HPE_INVALID_EOF_STATE); + return 1; + } + } + + + if (parser->state == s_header_field) + header_field_mark = data; + if (parser->state == s_header_value) + header_value_mark = data; + switch (parser->state) { + case s_req_path: + case s_req_schema: + case s_req_schema_slash: + case s_req_schema_slash_slash: + case s_req_server_start: + case s_req_server: + case s_req_server_with_at: + case s_req_query_string_start: + case s_req_query_string: + case s_req_fragment_start: + case s_req_fragment: + url_mark = data; + break; + } + + for (p=data; p != data + len; p++) { + ch = *p; + + if (PARSING_HEADER(parser->state)) { + ++parser->nread; + /* Buffer overflow attack */ + if (parser->nread > HTTP_MAX_HEADER_SIZE) { + SET_ERRNO(HPE_HEADER_OVERFLOW); + goto error; + } + } + + reexecute_byte: + switch (parser->state) { + + case s_dead: + /* this state is used after a 'Connection: close' message + * the parser will error out if it reads another message + */ + if (ch == CR || ch == LF) + break; + + SET_ERRNO(HPE_CLOSED_CONNECTION); + goto error; + + case s_start_req_or_res: + { + if (ch == CR || ch == LF) + break; + parser->flags = 0; + parser->content_length = ULLONG_MAX; + + if (ch == 'H') { + parser->state = s_res_or_resp_H; + + CALLBACK_NOTIFY(message_begin); + } else { + parser->type = HTTP_REQUEST; + parser->state = s_start_req; + goto reexecute_byte; + } + + break; + } + + case s_res_or_resp_H: + if (ch == 'T') { + parser->type = HTTP_RESPONSE; + parser->state = s_res_HT; + } else { + if (ch != 'E') { + SET_ERRNO(HPE_INVALID_CONSTANT); + goto error; + } + + parser->type = HTTP_REQUEST; + parser->method = HTTP_HEAD; + parser->index = 2; + parser->state = s_req_method; + } + break; + + case s_start_res: + { + parser->flags = 0; + parser->content_length = ULLONG_MAX; + + switch (ch) { + case 'H': + parser->state = s_res_H; + break; + + case CR: + case LF: + break; + + default: + SET_ERRNO(HPE_INVALID_CONSTANT); + goto error; + } + + CALLBACK_NOTIFY(message_begin); + break; + } + + case s_res_H: + STRICT_CHECK(ch != 'T'); + parser->state = s_res_HT; + break; + + case s_res_HT: + STRICT_CHECK(ch != 'T'); + parser->state = s_res_HTT; + break; + + case s_res_HTT: + STRICT_CHECK(ch != 'P'); + parser->state = s_res_HTTP; + break; + + case s_res_HTTP: + STRICT_CHECK(ch != '/'); + parser->state = s_res_first_http_major; + break; + + case s_res_first_http_major: + if (ch < '0' || ch > '9') { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major = ch - '0'; + parser->state = s_res_http_major; + break; + + /* major HTTP version or dot */ + case s_res_http_major: + { + if (ch == '.') { + parser->state = s_res_first_http_minor; + break; + } + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major *= 10; + parser->http_major += ch - '0'; + + if (parser->http_major > 999) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + break; + } + + /* first digit of minor HTTP version */ + case s_res_first_http_minor: + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor = ch - '0'; + parser->state = s_res_http_minor; + break; + + /* minor HTTP version or end of request line */ + case s_res_http_minor: + { + if (ch == ' ') { + parser->state = s_res_first_status_code; + break; + } + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor *= 10; + parser->http_minor += ch - '0'; + + if (parser->http_minor > 999) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + break; + } + + case s_res_first_status_code: + { + if (!IS_NUM(ch)) { + if (ch == ' ') { + break; + } + + SET_ERRNO(HPE_INVALID_STATUS); + goto error; + } + parser->status_code = ch - '0'; + parser->state = s_res_status_code; + break; + } + + case s_res_status_code: + { + if (!IS_NUM(ch)) { + switch (ch) { + case ' ': + parser->state = s_res_status; + break; + case CR: + parser->state = s_res_line_almost_done; + break; + case LF: + parser->state = s_header_field_start; + break; + default: + SET_ERRNO(HPE_INVALID_STATUS); + goto error; + } + break; + } + + parser->status_code *= 10; + parser->status_code += ch - '0'; + + if (parser->status_code > 999) { + SET_ERRNO(HPE_INVALID_STATUS); + goto error; + } + + break; + } + + case s_res_status: + /* the human readable status. e.g. "NOT FOUND" + * we are not humans so just ignore this */ + if (ch == CR) { + parser->state = s_res_line_almost_done; + break; + } + + if (ch == LF) { + parser->state = s_header_field_start; + break; + } + break; + + case s_res_line_almost_done: + STRICT_CHECK(ch != LF); + parser->state = s_header_field_start; + break; + + case s_start_req: + { + if (ch == CR || ch == LF) + break; + parser->flags = 0; + parser->content_length = ULLONG_MAX; + + if (!IS_ALPHA(ch)) { + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + + parser->method = (enum http_method) 0; + parser->index = 1; + switch (ch) { + case 'C': parser->method = HTTP_CONNECT; /* or COPY, CHECKOUT */ break; + case 'D': parser->method = HTTP_DELETE; break; + case 'G': parser->method = HTTP_GET; break; + case 'H': parser->method = HTTP_HEAD; break; + case 'L': parser->method = HTTP_LOCK; break; + case 'M': parser->method = HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH */ break; + case 'N': parser->method = HTTP_NOTIFY; break; + case 'O': parser->method = HTTP_OPTIONS; break; + case 'P': parser->method = HTTP_POST; + /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ + break; + case 'R': parser->method = HTTP_REPORT; break; + case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH */ break; + case 'T': parser->method = HTTP_TRACE; break; + case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break; + default: + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + parser->state = s_req_method; + + CALLBACK_NOTIFY(message_begin); + + break; + } + + case s_req_method: + { + const char *matcher; + if (ch == '\0') { + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + + matcher = method_strings[parser->method]; + if (ch == ' ' && matcher[parser->index] == '\0') { + parser->state = s_req_spaces_before_url; + } else if (ch == matcher[parser->index]) { + ; /* nada */ + } else if (parser->method == HTTP_CONNECT) { + if (parser->index == 1 && ch == 'H') { + parser->method = HTTP_CHECKOUT; + } else if (parser->index == 2 && ch == 'P') { + parser->method = HTTP_COPY; + } else { + goto error; + } + } else if (parser->method == HTTP_MKCOL) { + if (parser->index == 1 && ch == 'O') { + parser->method = HTTP_MOVE; + } else if (parser->index == 1 && ch == 'E') { + parser->method = HTTP_MERGE; + } else if (parser->index == 1 && ch == '-') { + parser->method = HTTP_MSEARCH; + } else if (parser->index == 2 && ch == 'A') { + parser->method = HTTP_MKACTIVITY; + } else { + goto error; + } + } else if (parser->method == HTTP_SUBSCRIBE) { + if (parser->index == 1 && ch == 'E') { + parser->method = HTTP_SEARCH; + } else { + goto error; + } + } else if (parser->index == 1 && parser->method == HTTP_POST) { + if (ch == 'R') { + parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */ + } else if (ch == 'U') { + parser->method = HTTP_PUT; /* or HTTP_PURGE */ + } else if (ch == 'A') { + parser->method = HTTP_PATCH; + } else { + goto error; + } + } else if (parser->index == 2) { + if (parser->method == HTTP_PUT) { + if (ch == 'R') parser->method = HTTP_PURGE; + } else if (parser->method == HTTP_UNLOCK) { + if (ch == 'S') parser->method = HTTP_UNSUBSCRIBE; + } + } else if (parser->index == 4 && parser->method == HTTP_PROPFIND && ch == 'P') { + parser->method = HTTP_PROPPATCH; + } else { + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + + ++parser->index; + break; + } + + case s_req_spaces_before_url: + { + if (ch == ' ') break; + + MARK(url); + if (parser->method == HTTP_CONNECT) { + parser->state = s_req_server_start; + } + + parser->state = parse_url_char((enum state)parser->state, ch); + if (parser->state == s_dead) { + SET_ERRNO(HPE_INVALID_URL); + goto error; + } + + break; + } + + case s_req_schema: + case s_req_schema_slash: + case s_req_schema_slash_slash: + case s_req_server_start: + { + switch (ch) { + /* No whitespace allowed here */ + case ' ': + case CR: + case LF: + SET_ERRNO(HPE_INVALID_URL); + goto error; + default: + parser->state = parse_url_char((enum state)parser->state, ch); + if (parser->state == s_dead) { + SET_ERRNO(HPE_INVALID_URL); + goto error; + } + } + + break; + } + + case s_req_server: + case s_req_server_with_at: + case s_req_path: + case s_req_query_string_start: + case s_req_query_string: + case s_req_fragment_start: + case s_req_fragment: + { + switch (ch) { + case ' ': + parser->state = s_req_http_start; + CALLBACK_DATA(url); + break; + case CR: + case LF: + parser->http_major = 0; + parser->http_minor = 9; + parser->state = (ch == CR) ? + s_req_line_almost_done : + s_header_field_start; + CALLBACK_DATA(url); + break; + default: + parser->state = parse_url_char((enum state)parser->state, ch); + if (parser->state == s_dead) { + SET_ERRNO(HPE_INVALID_URL); + goto error; + } + } + break; + } + + case s_req_http_start: + switch (ch) { + case 'H': + parser->state = s_req_http_H; + break; + case ' ': + break; + default: + SET_ERRNO(HPE_INVALID_CONSTANT); + goto error; + } + break; + + case s_req_http_H: + STRICT_CHECK(ch != 'T'); + parser->state = s_req_http_HT; + break; + + case s_req_http_HT: + STRICT_CHECK(ch != 'T'); + parser->state = s_req_http_HTT; + break; + + case s_req_http_HTT: + STRICT_CHECK(ch != 'P'); + parser->state = s_req_http_HTTP; + break; + + case s_req_http_HTTP: + STRICT_CHECK(ch != '/'); + parser->state = s_req_first_http_major; + break; + + /* first digit of major HTTP version */ + case s_req_first_http_major: + if (ch < '1' || ch > '9') { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major = ch - '0'; + parser->state = s_req_http_major; + break; + + /* major HTTP version or dot */ + case s_req_http_major: + { + if (ch == '.') { + parser->state = s_req_first_http_minor; + break; + } + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major *= 10; + parser->http_major += ch - '0'; + + if (parser->http_major > 999) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + break; + } + + /* first digit of minor HTTP version */ + case s_req_first_http_minor: + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor = ch - '0'; + parser->state = s_req_http_minor; + break; + + /* minor HTTP version or end of request line */ + case s_req_http_minor: + { + if (ch == CR) { + parser->state = s_req_line_almost_done; + break; + } + + if (ch == LF) { + parser->state = s_header_field_start; + break; + } + + /* XXX allow spaces after digit? */ + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor *= 10; + parser->http_minor += ch - '0'; + + if (parser->http_minor > 999) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + break; + } + + /* end of request line */ + case s_req_line_almost_done: + { + if (ch != LF) { + SET_ERRNO(HPE_LF_EXPECTED); + goto error; + } + + parser->state = s_header_field_start; + break; + } + + case s_header_field_start: + { + if (ch == CR) { + parser->state = s_headers_almost_done; + break; + } + + if (ch == LF) { + /* they might be just sending \n instead of \r\n so this would be + * the second \n to denote the end of headers*/ + parser->state = s_headers_almost_done; + goto reexecute_byte; + } + + c = TOKEN(ch); + + if (!c) { + SET_ERRNO(HPE_INVALID_HEADER_TOKEN); + goto error; + } + + MARK(header_field); + + parser->index = 0; + parser->state = s_header_field; + + switch (c) { + case 'c': + parser->header_state = h_C; + break; + + case 'p': + parser->header_state = h_matching_proxy_connection; + break; + + case 't': + parser->header_state = h_matching_transfer_encoding; + break; + + case 'u': + parser->header_state = h_matching_upgrade; + break; + + default: + parser->header_state = h_general; + break; + } + break; + } + + case s_header_field: + { + c = TOKEN(ch); + + if (c) { + switch (parser->header_state) { + case h_general: + break; + + case h_C: + parser->index++; + parser->header_state = (c == 'o' ? h_CO : h_general); + break; + + case h_CO: + parser->index++; + parser->header_state = (c == 'n' ? h_CON : h_general); + break; + + case h_CON: + parser->index++; + switch (c) { + case 'n': + parser->header_state = h_matching_connection; + break; + case 't': + parser->header_state = h_matching_content_length; + break; + default: + parser->header_state = h_general; + break; + } + break; + + /* connection */ + + case h_matching_connection: + parser->index++; + if (parser->index > sizeof(CONNECTION)-1 + || c != CONNECTION[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CONNECTION)-2) { + parser->header_state = h_connection; + } + break; + + /* proxy-connection */ + + case h_matching_proxy_connection: + parser->index++; + if (parser->index > sizeof(PROXY_CONNECTION)-1 + || c != PROXY_CONNECTION[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(PROXY_CONNECTION)-2) { + parser->header_state = h_connection; + } + break; + + /* content-length */ + + case h_matching_content_length: + parser->index++; + if (parser->index > sizeof(CONTENT_LENGTH)-1 + || c != CONTENT_LENGTH[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CONTENT_LENGTH)-2) { + parser->header_state = h_content_length; + } + break; + + /* transfer-encoding */ + + case h_matching_transfer_encoding: + parser->index++; + if (parser->index > sizeof(TRANSFER_ENCODING)-1 + || c != TRANSFER_ENCODING[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(TRANSFER_ENCODING)-2) { + parser->header_state = h_transfer_encoding; + } + break; + + /* upgrade */ + + case h_matching_upgrade: + parser->index++; + if (parser->index > sizeof(UPGRADE)-1 + || c != UPGRADE[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(UPGRADE)-2) { + parser->header_state = h_upgrade; + } + break; + + case h_connection: + case h_content_length: + case h_transfer_encoding: + case h_upgrade: + if (ch != ' ') parser->header_state = h_general; + break; + + default: + assert(0 && "Unknown header_state"); + break; + } + break; + } + + if (ch == ':') { + parser->state = s_header_value_start; + CALLBACK_DATA(header_field); + break; + } + + if (ch == CR) { + parser->state = s_header_almost_done; + CALLBACK_DATA(header_field); + break; + } + + if (ch == LF) { + parser->state = s_header_field_start; + CALLBACK_DATA(header_field); + break; + } + + SET_ERRNO(HPE_INVALID_HEADER_TOKEN); + goto error; + } + + case s_header_value_start: + { + if (ch == ' ' || ch == '\t') break; + + MARK(header_value); + + parser->state = s_header_value; + parser->index = 0; + + if (ch == CR) { + parser->header_state = h_general; + parser->state = s_header_almost_done; + CALLBACK_DATA(header_value); + break; + } + + if (ch == LF) { + parser->state = s_header_field_start; + CALLBACK_DATA(header_value); + break; + } + + c = LOWER(ch); + + switch (parser->header_state) { + case h_upgrade: + parser->flags |= F_UPGRADE; + parser->header_state = h_general; + break; + + case h_transfer_encoding: + /* looking for 'Transfer-Encoding: chunked' */ + if ('c' == c) { + parser->header_state = h_matching_transfer_encoding_chunked; + } else { + parser->header_state = h_general; + } + break; + + case h_content_length: + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + parser->content_length = ch - '0'; + break; + + case h_connection: + /* looking for 'Connection: keep-alive' */ + if (c == 'k') { + parser->header_state = h_matching_connection_keep_alive; + /* looking for 'Connection: close' */ + } else if (c == 'c') { + parser->header_state = h_matching_connection_close; + } else { + parser->header_state = h_general; + } + break; + + default: + parser->header_state = h_general; + break; + } + break; + } + + case s_header_value: + { + + if (ch == CR) { + parser->state = s_header_almost_done; + CALLBACK_DATA(header_value); + break; + } + + if (ch == LF) { + parser->state = s_header_almost_done; + CALLBACK_DATA_NOADVANCE(header_value); + goto reexecute_byte; + } + + c = LOWER(ch); + + switch (parser->header_state) { + case h_general: + break; + + case h_connection: + case h_transfer_encoding: + assert(0 && "Shouldn't get here."); + break; + + case h_content_length: + { + uint64_t t; + + if (ch == ' ') break; + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + t = parser->content_length; + t *= 10; + t += ch - '0'; + + /* Overflow? */ + if (t < parser->content_length || t == ULLONG_MAX) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + parser->content_length = t; + break; + } + + /* Transfer-Encoding: chunked */ + case h_matching_transfer_encoding_chunked: + parser->index++; + if (parser->index > sizeof(CHUNKED)-1 + || c != CHUNKED[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CHUNKED)-2) { + parser->header_state = h_transfer_encoding_chunked; + } + break; + + /* looking for 'Connection: keep-alive' */ + case h_matching_connection_keep_alive: + parser->index++; + if (parser->index > sizeof(KEEP_ALIVE)-1 + || c != KEEP_ALIVE[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(KEEP_ALIVE)-2) { + parser->header_state = h_connection_keep_alive; + } + break; + + /* looking for 'Connection: close' */ + case h_matching_connection_close: + parser->index++; + if (parser->index > sizeof(CLOSE)-1 || c != CLOSE[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CLOSE)-2) { + parser->header_state = h_connection_close; + } + break; + + case h_transfer_encoding_chunked: + case h_connection_keep_alive: + case h_connection_close: + if (ch != ' ') parser->header_state = h_general; + break; + + default: + parser->state = s_header_value; + parser->header_state = h_general; + break; + } + break; + } + + case s_header_almost_done: + { + STRICT_CHECK(ch != LF); + + parser->state = s_header_value_lws; + + switch (parser->header_state) { + case h_connection_keep_alive: + parser->flags |= F_CONNECTION_KEEP_ALIVE; + break; + case h_connection_close: + parser->flags |= F_CONNECTION_CLOSE; + break; + case h_transfer_encoding_chunked: + parser->flags |= F_CHUNKED; + break; + default: + break; + } + + break; + } + + case s_header_value_lws: + { + if (ch == ' ' || ch == '\t') + parser->state = s_header_value_start; + else + { + parser->state = s_header_field_start; + goto reexecute_byte; + } + break; + } + + case s_headers_almost_done: + { + STRICT_CHECK(ch != LF); + + if (parser->flags & F_TRAILING) { + /* End of a chunked request */ + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + break; + } + + parser->state = s_headers_done; + + /* Set this here so that on_headers_complete() callbacks can see it */ + parser->upgrade = + (parser->flags & F_UPGRADE || parser->method == HTTP_CONNECT); + + /* Here we call the headers_complete callback. This is somewhat + * different than other callbacks because if the user returns 1, we + * will interpret that as saying that this message has no body. This + * is needed for the annoying case of recieving a response to a HEAD + * request. + * + * We'd like to use CALLBACK_NOTIFY_NOADVANCE() here but we cannot, so + * we have to simulate it by handling a change in errno below. + */ + if (settings->on_headers_complete) { + switch (settings->on_headers_complete(parser)) { + case 0: + break; + + case 1: + parser->flags |= F_SKIPBODY; + break; + + default: + SET_ERRNO(HPE_CB_headers_complete); + return p - data; /* Error */ + } + } + + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { + return p - data; + } + + goto reexecute_byte; + } + + case s_headers_done: + { + STRICT_CHECK(ch != LF); + + parser->nread = 0; + + /* Exit, the rest of the connect is in a different protocol. */ + if (parser->upgrade) { + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + return (p - data) + 1; + } + + if (parser->flags & F_SKIPBODY) { + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + } else if (parser->flags & F_CHUNKED) { + /* chunked encoding - ignore Content-Length header */ + parser->state = s_chunk_size_start; + } else { + if (parser->content_length == 0) { + /* Content-Length header given but zero: Content-Length: 0\r\n */ + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + } else if (parser->content_length != ULLONG_MAX) { + /* Content-Length header given and non-zero */ + parser->state = s_body_identity; + } else { + if (parser->type == HTTP_REQUEST || + !http_message_needs_eof(parser)) { + /* Assume content-length 0 - read the next */ + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + } else { + /* Read body until EOF */ + parser->state = s_body_identity_eof; + } + } + } + + break; + } + + case s_body_identity: + { + uint64_t to_read = MIN(parser->content_length, + (uint64_t) ((data + len) - p)); + + assert(parser->content_length != 0 + && parser->content_length != ULLONG_MAX); + + /* The difference between advancing content_length and p is because + * the latter will automaticaly advance on the next loop iteration. + * Further, if content_length ends up at 0, we want to see the last + * byte again for our message complete callback. + */ + MARK(body); + parser->content_length -= to_read; + p += to_read - 1; + + if (parser->content_length == 0) { + parser->state = s_message_done; + + /* Mimic CALLBACK_DATA_NOADVANCE() but with one extra byte. + * + * The alternative to doing this is to wait for the next byte to + * trigger the data callback, just as in every other case. The + * problem with this is that this makes it difficult for the test + * harness to distinguish between complete-on-EOF and + * complete-on-length. It's not clear that this distinction is + * important for applications, but let's keep it for now. + */ + CALLBACK_DATA_(body, p - body_mark + 1, p - data); + goto reexecute_byte; + } + + break; + } + + /* read until EOF */ + case s_body_identity_eof: + MARK(body); + p = data + len - 1; + + break; + + case s_message_done: + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + break; + + case s_chunk_size_start: + { + assert(parser->nread == 1); + assert(parser->flags & F_CHUNKED); + + unhex_val = unhex[(unsigned char)ch]; + if (unhex_val == -1) { + SET_ERRNO(HPE_INVALID_CHUNK_SIZE); + goto error; + } + + parser->content_length = unhex_val; + parser->state = s_chunk_size; + break; + } + + case s_chunk_size: + { + uint64_t t; + + assert(parser->flags & F_CHUNKED); + + if (ch == CR) { + parser->state = s_chunk_size_almost_done; + break; + } + + unhex_val = unhex[(unsigned char)ch]; + + if (unhex_val == -1) { + if (ch == ';' || ch == ' ') { + parser->state = s_chunk_parameters; + break; + } + + SET_ERRNO(HPE_INVALID_CHUNK_SIZE); + goto error; + } + + t = parser->content_length; + t *= 16; + t += unhex_val; + + /* Overflow? */ + if (t < parser->content_length || t == ULLONG_MAX) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + parser->content_length = t; + break; + } + + case s_chunk_parameters: + { + assert(parser->flags & F_CHUNKED); + /* just ignore this shit. TODO check for overflow */ + if (ch == CR) { + parser->state = s_chunk_size_almost_done; + break; + } + break; + } + + case s_chunk_size_almost_done: + { + assert(parser->flags & F_CHUNKED); + STRICT_CHECK(ch != LF); + + parser->nread = 0; + + if (parser->content_length == 0) { + parser->flags |= F_TRAILING; + parser->state = s_header_field_start; + } else { + parser->state = s_chunk_data; + } + break; + } + + case s_chunk_data: + { + uint64_t to_read = MIN(parser->content_length, + (uint64_t) ((data + len) - p)); + + assert(parser->flags & F_CHUNKED); + assert(parser->content_length != 0 + && parser->content_length != ULLONG_MAX); + + /* See the explanation in s_body_identity for why the content + * length and data pointers are managed this way. + */ + MARK(body); + parser->content_length -= to_read; + p += to_read - 1; + + if (parser->content_length == 0) { + parser->state = s_chunk_data_almost_done; + } + + break; + } + + case s_chunk_data_almost_done: + assert(parser->flags & F_CHUNKED); + assert(parser->content_length == 0); + STRICT_CHECK(ch != CR); + parser->state = s_chunk_data_done; + CALLBACK_DATA(body); + break; + + case s_chunk_data_done: + assert(parser->flags & F_CHUNKED); + STRICT_CHECK(ch != LF); + parser->nread = 0; + parser->state = s_chunk_size_start; + break; + + default: + assert(0 && "unhandled state"); + SET_ERRNO(HPE_INVALID_INTERNAL_STATE); + goto error; + } + } + + /* Run callbacks for any marks that we have leftover after we ran our of + * bytes. There should be at most one of these set, so it's OK to invoke + * them in series (unset marks will not result in callbacks). + * + * We use the NOADVANCE() variety of callbacks here because 'p' has already + * overflowed 'data' and this allows us to correct for the off-by-one that + * we'd otherwise have (since CALLBACK_DATA() is meant to be run with a 'p' + * value that's in-bounds). + */ + + assert(((header_field_mark ? 1 : 0) + + (header_value_mark ? 1 : 0) + + (url_mark ? 1 : 0) + + (body_mark ? 1 : 0)) <= 1); + + CALLBACK_DATA_NOADVANCE(header_field); + CALLBACK_DATA_NOADVANCE(header_value); + CALLBACK_DATA_NOADVANCE(url); + CALLBACK_DATA_NOADVANCE(body); + + return len; + +error: + if (HTTP_PARSER_ERRNO(parser) == HPE_OK) { + SET_ERRNO(HPE_UNKNOWN); + } + + return (p - data); +} + + +/* Does the parser need to see an EOF to find the end of the message? */ +int +http_message_needs_eof (const http_parser *parser) +{ + if (parser->type == HTTP_REQUEST) { + return 0; + } + + /* See RFC 2616 section 4.4 */ + if (parser->status_code / 100 == 1 || /* 1xx e.g. Continue */ + parser->status_code == 204 || /* No Content */ + parser->status_code == 304 || /* Not Modified */ + parser->flags & F_SKIPBODY) { /* response to a HEAD request */ + return 0; + } + + if ((parser->flags & F_CHUNKED) || parser->content_length != ULLONG_MAX) { + return 0; + } + + return 1; +} + + +int +http_should_keep_alive (const http_parser *parser) +{ + if (parser->http_major > 0 && parser->http_minor > 0) { + /* HTTP/1.1 */ + if (parser->flags & F_CONNECTION_CLOSE) { + return 0; + } + } else { + /* HTTP/1.0 or earlier */ + if (!(parser->flags & F_CONNECTION_KEEP_ALIVE)) { + return 0; + } + } + + return !http_message_needs_eof(parser); +} + + +const char * +http_method_str (enum http_method m) +{ + return ELEM_AT(method_strings, m, ""); +} + + +void +http_parser_init (http_parser *parser, enum http_parser_type t) +{ + void *data = parser->data; /* preserve application data */ + memset(parser, 0, sizeof(*parser)); + parser->data = data; + parser->type = t; + parser->state = (t == HTTP_REQUEST ? s_start_req : (t == HTTP_RESPONSE ? s_start_res : s_start_req_or_res)); + parser->http_errno = HPE_OK; +} + +const char * +http_errno_name(enum http_errno err) { + assert(err < (sizeof(http_strerror_tab)/sizeof(http_strerror_tab[0]))); + return http_strerror_tab[err].name; +} + +const char * +http_errno_description(enum http_errno err) { + assert(err < (sizeof(http_strerror_tab)/sizeof(http_strerror_tab[0]))); + return http_strerror_tab[err].description; +} + +static enum http_host_state +http_parse_host_char(enum http_host_state s, const char ch) { + switch(s) { + case s_http_userinfo: + case s_http_userinfo_start: + if (ch == '@') { + return s_http_host_start; + } + + if (IS_USERINFO_CHAR(ch)) { + return s_http_userinfo; + } + break; + + case s_http_host_start: + if (ch == '[') { + return s_http_host_v6_start; + } + + if (IS_HOST_CHAR(ch)) { + return s_http_host; + } + + break; + + case s_http_host: + if (IS_HOST_CHAR(ch)) { + return s_http_host; + } + + /* FALLTHROUGH */ + case s_http_host_v6_end: + if (ch == ':') { + return s_http_host_port_start; + } + + break; + + case s_http_host_v6: + if (ch == ']') { + return s_http_host_v6_end; + } + + /* FALLTHROUGH */ + case s_http_host_v6_start: + if (IS_HEX(ch) || ch == ':' || ch == '.') { + return s_http_host_v6; + } + + break; + + case s_http_host_port: + case s_http_host_port_start: + if (IS_NUM(ch)) { + return s_http_host_port; + } + + break; + + default: + break; + } + return s_http_host_dead; +} + +static int +http_parse_host(const char * buf, struct http_parser_url *u, int found_at) { + enum http_host_state s; + + const char *p; + size_t buflen = u->field_data[UF_HOST].off + u->field_data[UF_HOST].len; + + u->field_data[UF_HOST].len = 0; + + s = found_at ? s_http_userinfo_start : s_http_host_start; + + for (p = buf + u->field_data[UF_HOST].off; p < buf + buflen; p++) { + enum http_host_state new_s = http_parse_host_char(s, *p); + + if (new_s == s_http_host_dead) { + return 1; + } + + switch(new_s) { + case s_http_host: + if (s != s_http_host) { + u->field_data[UF_HOST].off = p - buf; + } + u->field_data[UF_HOST].len++; + break; + + case s_http_host_v6: + if (s != s_http_host_v6) { + u->field_data[UF_HOST].off = p - buf; + } + u->field_data[UF_HOST].len++; + break; + + case s_http_host_port: + if (s != s_http_host_port) { + u->field_data[UF_PORT].off = p - buf; + u->field_data[UF_PORT].len = 0; + u->field_set |= (1 << UF_PORT); + } + u->field_data[UF_PORT].len++; + break; + + case s_http_userinfo: + if (s != s_http_userinfo) { + u->field_data[UF_USERINFO].off = p - buf ; + u->field_data[UF_USERINFO].len = 0; + u->field_set |= (1 << UF_USERINFO); + } + u->field_data[UF_USERINFO].len++; + break; + + default: + break; + } + s = new_s; + } + + /* Make sure we don't end somewhere unexpected */ + switch (s) { + case s_http_host_start: + case s_http_host_v6_start: + case s_http_host_v6: + case s_http_host_port_start: + case s_http_userinfo: + case s_http_userinfo_start: + return 1; + default: + break; + } + + return 0; +} + +int +http_parser_parse_url(const char *buf, size_t buflen, int is_connect, + struct http_parser_url *u) +{ + enum state s; + const char *p; + enum http_parser_url_fields uf, old_uf; + int found_at = 0; + + u->port = u->field_set = 0; + s = is_connect ? s_req_server_start : s_req_spaces_before_url; + uf = old_uf = UF_MAX; + + for (p = buf; p < buf + buflen; p++) { + s = parse_url_char(s, *p); + + /* Figure out the next field that we're operating on */ + switch (s) { + case s_dead: + return 1; + + /* Skip delimeters */ + case s_req_schema_slash: + case s_req_schema_slash_slash: + case s_req_server_start: + case s_req_query_string_start: + case s_req_fragment_start: + continue; + + case s_req_schema: + uf = UF_SCHEMA; + break; + + case s_req_server_with_at: + found_at = 1; + + /* FALLTROUGH */ + case s_req_server: + uf = UF_HOST; + break; + + case s_req_path: + uf = UF_PATH; + break; + + case s_req_query_string: + uf = UF_QUERY; + break; + + case s_req_fragment: + uf = UF_FRAGMENT; + break; + + default: + assert(!"Unexpected state"); + return 1; + } + + /* Nothing's changed; soldier on */ + if (uf == old_uf) { + u->field_data[uf].len++; + continue; + } + + u->field_data[uf].off = p - buf; + u->field_data[uf].len = 1; + + u->field_set |= (1 << uf); + old_uf = uf; + } + + /* host must be present if there is a schema */ + /* parsing http:///toto will fail */ + if ((u->field_set & ((1 << UF_SCHEMA) | (1 << UF_HOST))) != 0) { + if (http_parse_host(buf, u, found_at) != 0) { + return 1; + } + } + + /* CONNECT requests can only contain "hostname:port" */ + if (is_connect && u->field_set != ((1 << UF_HOST)|(1 << UF_PORT))) { + return 1; + } + + if (u->field_set & (1 << UF_PORT)) { + /* Don't bother with endp; we've already validated the string */ + unsigned long v = strtoul(buf + u->field_data[UF_PORT].off, NULL, 10); + + /* Ports have a max value of 2^16 */ + if (v > 0xffff) { + return 1; + } + + u->port = (uint16_t) v; + } + + return 0; +} + +void +http_parser_pause(http_parser *parser, int paused) { + /* Users should only be pausing/unpausing a parser that is not in an error + * state. In non-debug builds, there's not much that we can do about this + * other than ignore it. + */ + if (HTTP_PARSER_ERRNO(parser) == HPE_OK || + HTTP_PARSER_ERRNO(parser) == HPE_PAUSED) { + SET_ERRNO((paused) ? HPE_PAUSED : HPE_OK); + } else { + assert(0 && "Attempting to pause parser in error state"); + } +} + +int +http_body_is_final(const struct http_parser *parser) { + return parser->state == s_message_done; +} diff --git a/src/http/qhttpserver/http-parser/http_parser.gyp b/src/http/qhttpserver/http-parser/http_parser.gyp new file mode 100644 index 000000000..ef34ecaea --- /dev/null +++ b/src/http/qhttpserver/http-parser/http_parser.gyp @@ -0,0 +1,111 @@ +# This file is used with the GYP meta build system. +# http://code.google.com/p/gyp/ +# To build try this: +# svn co http://gyp.googlecode.com/svn/trunk gyp +# ./gyp/gyp -f make --depth=`pwd` http_parser.gyp +# ./out/Debug/test +{ + 'target_defaults': { + 'default_configuration': 'Debug', + 'configurations': { + # TODO: hoist these out and put them somewhere common, because + # RuntimeLibrary MUST MATCH across the entire project + 'Debug': { + 'defines': [ 'DEBUG', '_DEBUG' ], + 'cflags': [ '-Wall', '-Wextra', '-O0', '-g', '-ftrapv' ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 1, # static debug + }, + }, + }, + 'Release': { + 'defines': [ 'NDEBUG' ], + 'cflags': [ '-Wall', '-Wextra', '-O3' ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 0, # static release + }, + }, + } + }, + 'msvs_settings': { + 'VCCLCompilerTool': { + }, + 'VCLibrarianTool': { + }, + 'VCLinkerTool': { + 'GenerateDebugInformation': 'true', + }, + }, + 'conditions': [ + ['OS == "win"', { + 'defines': [ + 'WIN32' + ], + }] + ], + }, + + 'targets': [ + { + 'target_name': 'http_parser', + 'type': 'static_library', + 'include_dirs': [ '.' ], + 'direct_dependent_settings': { + 'defines': [ 'HTTP_PARSER_STRICT=0' ], + 'include_dirs': [ '.' ], + }, + 'defines': [ 'HTTP_PARSER_STRICT=0' ], + 'sources': [ './http_parser.c', ], + 'conditions': [ + ['OS=="win"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + # Compile as C++. http_parser.c is actually C99, but C++ is + # close enough in this case. + 'CompileAs': 2, + }, + }, + }] + ], + }, + + { + 'target_name': 'http_parser_strict', + 'type': 'static_library', + 'include_dirs': [ '.' ], + 'direct_dependent_settings': { + 'defines': [ 'HTTP_PARSER_STRICT=1' ], + 'include_dirs': [ '.' ], + }, + 'defines': [ 'HTTP_PARSER_STRICT=1' ], + 'sources': [ './http_parser.c', ], + 'conditions': [ + ['OS=="win"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + # Compile as C++. http_parser.c is actually C99, but C++ is + # close enough in this case. + 'CompileAs': 2, + }, + }, + }] + ], + }, + + { + 'target_name': 'test-nonstrict', + 'type': 'executable', + 'dependencies': [ 'http_parser' ], + 'sources': [ 'test.c' ] + }, + + { + 'target_name': 'test-strict', + 'type': 'executable', + 'dependencies': [ 'http_parser_strict' ], + 'sources': [ 'test.c' ] + } + ] +} diff --git a/src/http/qhttpserver/http-parser/http_parser.h b/src/http/qhttpserver/http-parser/http_parser.h new file mode 100644 index 000000000..f1d605d6f --- /dev/null +++ b/src/http/qhttpserver/http-parser/http_parser.h @@ -0,0 +1,302 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#ifndef http_parser_h +#define http_parser_h +#ifdef __cplusplus +extern "C" { +#endif + +#define HTTP_PARSER_VERSION_MAJOR 2 +#define HTTP_PARSER_VERSION_MINOR 0 + +#include +#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600) +#include +#include +typedef __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run + * faster + */ +#ifndef HTTP_PARSER_STRICT +# define HTTP_PARSER_STRICT 1 +#endif + +/* Maximium header size allowed */ +#define HTTP_MAX_HEADER_SIZE (80*1024) + + +typedef struct http_parser http_parser; +typedef struct http_parser_settings http_parser_settings; + + +/* Callbacks should return non-zero to indicate an error. The parser will + * then halt execution. + * + * The one exception is on_headers_complete. In a HTTP_RESPONSE parser + * returning '1' from on_headers_complete will tell the parser that it + * should not expect a body. This is used when receiving a response to a + * HEAD request which may contain 'Content-Length' or 'Transfer-Encoding: + * chunked' headers that indicate the presence of a body. + * + * http_data_cb does not return data chunks. It will be call arbitrarally + * many times for each string. E.G. you might get 10 callbacks for "on_url" + * each providing just a few characters more data. + */ +typedef int (*http_data_cb) (http_parser*, const char *at, size_t length); +typedef int (*http_cb) (http_parser*); + + +/* Request Methods */ +#define HTTP_METHOD_MAP(XX) \ + XX(0, DELETE, DELETE) \ + XX(1, GET, GET) \ + XX(2, HEAD, HEAD) \ + XX(3, POST, POST) \ + XX(4, PUT, PUT) \ + /* pathological */ \ + XX(5, CONNECT, CONNECT) \ + XX(6, OPTIONS, OPTIONS) \ + XX(7, TRACE, TRACE) \ + /* webdav */ \ + XX(8, COPY, COPY) \ + XX(9, LOCK, LOCK) \ + XX(10, MKCOL, MKCOL) \ + XX(11, MOVE, MOVE) \ + XX(12, PROPFIND, PROPFIND) \ + XX(13, PROPPATCH, PROPPATCH) \ + XX(14, SEARCH, SEARCH) \ + XX(15, UNLOCK, UNLOCK) \ + /* subversion */ \ + XX(16, REPORT, REPORT) \ + XX(17, MKACTIVITY, MKACTIVITY) \ + XX(18, CHECKOUT, CHECKOUT) \ + XX(19, MERGE, MERGE) \ + /* upnp */ \ + XX(20, MSEARCH, M-SEARCH) \ + XX(21, NOTIFY, NOTIFY) \ + XX(22, SUBSCRIBE, SUBSCRIBE) \ + XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \ + /* RFC-5789 */ \ + XX(24, PATCH, PATCH) \ + XX(25, PURGE, PURGE) \ + +enum http_method + { +#define XX(num, name, string) HTTP_##name = num, + HTTP_METHOD_MAP(XX) +#undef XX + }; + + +enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH }; + + +/* Flag values for http_parser.flags field */ +enum flags + { F_CHUNKED = 1 << 0 + , F_CONNECTION_KEEP_ALIVE = 1 << 1 + , F_CONNECTION_CLOSE = 1 << 2 + , F_TRAILING = 1 << 3 + , F_UPGRADE = 1 << 4 + , F_SKIPBODY = 1 << 5 + }; + + +/* Map for errno-related constants + * + * The provided argument should be a macro that takes 2 arguments. + */ +#define HTTP_ERRNO_MAP(XX) \ + /* No error */ \ + XX(OK, "success") \ + \ + /* Callback-related errors */ \ + XX(CB_message_begin, "the on_message_begin callback failed") \ + XX(CB_url, "the on_url callback failed") \ + XX(CB_header_field, "the on_header_field callback failed") \ + XX(CB_header_value, "the on_header_value callback failed") \ + XX(CB_headers_complete, "the on_headers_complete callback failed") \ + XX(CB_body, "the on_body callback failed") \ + XX(CB_message_complete, "the on_message_complete callback failed") \ + \ + /* Parsing-related errors */ \ + XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \ + XX(HEADER_OVERFLOW, \ + "too many header bytes seen; overflow detected") \ + XX(CLOSED_CONNECTION, \ + "data received after completed connection: close message") \ + XX(INVALID_VERSION, "invalid HTTP version") \ + XX(INVALID_STATUS, "invalid HTTP status code") \ + XX(INVALID_METHOD, "invalid HTTP method") \ + XX(INVALID_URL, "invalid URL") \ + XX(INVALID_HOST, "invalid host") \ + XX(INVALID_PORT, "invalid port") \ + XX(INVALID_PATH, "invalid path") \ + XX(INVALID_QUERY_STRING, "invalid query string") \ + XX(INVALID_FRAGMENT, "invalid fragment") \ + XX(LF_EXPECTED, "LF character expected") \ + XX(INVALID_HEADER_TOKEN, "invalid character in header") \ + XX(INVALID_CONTENT_LENGTH, \ + "invalid character in content-length header") \ + XX(INVALID_CHUNK_SIZE, \ + "invalid character in chunk size header") \ + XX(INVALID_CONSTANT, "invalid constant string") \ + XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\ + XX(STRICT, "strict mode assertion failed") \ + XX(PAUSED, "parser is paused") \ + XX(UNKNOWN, "an unknown error occurred") + + +/* Define HPE_* values for each errno value above */ +#define HTTP_ERRNO_GEN(n, s) HPE_##n, +enum http_errno { + HTTP_ERRNO_MAP(HTTP_ERRNO_GEN) +}; +#undef HTTP_ERRNO_GEN + + +/* Get an http_errno value from an http_parser */ +#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno) + + +struct http_parser { + /** PRIVATE **/ + unsigned char type : 2; /* enum http_parser_type */ + unsigned char flags : 6; /* F_* values from 'flags' enum; semi-public */ + unsigned char state; /* enum state from http_parser.c */ + unsigned char header_state; /* enum header_state from http_parser.c */ + unsigned char index; /* index into current matcher */ + + uint32_t nread; /* # bytes read in various scenarios */ + uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */ + + /** READ-ONLY **/ + unsigned short http_major; + unsigned short http_minor; + unsigned short status_code; /* responses only */ + unsigned char method; /* requests only */ + unsigned char http_errno : 7; + + /* 1 = Upgrade header was present and the parser has exited because of that. + * 0 = No upgrade header present. + * Should be checked when http_parser_execute() returns in addition to + * error checking. + */ + unsigned char upgrade : 1; + + /** PUBLIC **/ + void *data; /* A pointer to get hook to the "connection" or "socket" object */ +}; + + +struct http_parser_settings { + http_cb on_message_begin; + http_data_cb on_url; + http_data_cb on_header_field; + http_data_cb on_header_value; + http_cb on_headers_complete; + http_data_cb on_body; + http_cb on_message_complete; +}; + + +enum http_parser_url_fields + { UF_SCHEMA = 0 + , UF_HOST = 1 + , UF_PORT = 2 + , UF_PATH = 3 + , UF_QUERY = 4 + , UF_FRAGMENT = 5 + , UF_USERINFO = 6 + , UF_MAX = 7 + }; + + +/* Result structure for http_parser_parse_url(). + * + * Callers should index into field_data[] with UF_* values iff field_set + * has the relevant (1 << UF_*) bit set. As a courtesy to clients (and + * because we probably have padding left over), we convert any port to + * a uint16_t. + */ +struct http_parser_url { + uint16_t field_set; /* Bitmask of (1 << UF_*) values */ + uint16_t port; /* Converted UF_PORT string */ + + struct { + uint16_t off; /* Offset into buffer in which field starts */ + uint16_t len; /* Length of run in buffer */ + } field_data[UF_MAX]; +}; + + +void http_parser_init(http_parser *parser, enum http_parser_type type); + + +size_t http_parser_execute(http_parser *parser, + const http_parser_settings *settings, + const char *data, + size_t len); + + +/* If http_should_keep_alive() in the on_headers_complete or + * on_message_complete callback returns 0, then this should be + * the last message on the connection. + * If you are the server, respond with the "Connection: close" header. + * If you are the client, close the connection. + */ +int http_should_keep_alive(const http_parser *parser); + +/* Returns a string version of the HTTP method. */ +const char *http_method_str(enum http_method m); + +/* Return a string name of the given error */ +const char *http_errno_name(enum http_errno err); + +/* Return a string description of the given error */ +const char *http_errno_description(enum http_errno err); + +/* Parse a URL; return nonzero on failure */ +int http_parser_parse_url(const char *buf, size_t buflen, + int is_connect, + struct http_parser_url *u); + +/* Pause or un-pause the parser; a nonzero value pauses */ +void http_parser_pause(http_parser *parser, int paused); + +/* Checks if this is the final chunk of the body. */ +int http_body_is_final(const http_parser *parser); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/http/qhttpserver/http-parser/test.c b/src/http/qhttpserver/http-parser/test.c new file mode 100644 index 000000000..b6c2acbc1 --- /dev/null +++ b/src/http/qhttpserver/http-parser/test.c @@ -0,0 +1,3402 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "http_parser.h" +#include +#include +#include +#include /* rand */ +#include +#include + +#undef TRUE +#define TRUE 1 +#undef FALSE +#define FALSE 0 + +#define MAX_HEADERS 13 +#define MAX_ELEMENT_SIZE 2048 + +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + +static http_parser *parser; + +struct message { + const char *name; // for debugging purposes + const char *raw; + enum http_parser_type type; + enum http_method method; + int status_code; + char request_path[MAX_ELEMENT_SIZE]; + char request_url[MAX_ELEMENT_SIZE]; + char fragment[MAX_ELEMENT_SIZE]; + char query_string[MAX_ELEMENT_SIZE]; + char body[MAX_ELEMENT_SIZE]; + size_t body_size; + const char *host; + const char *userinfo; + uint16_t port; + int num_headers; + enum { NONE=0, FIELD, VALUE } last_header_element; + char headers [MAX_HEADERS][2][MAX_ELEMENT_SIZE]; + int should_keep_alive; + + const char *upgrade; // upgraded body + + unsigned short http_major; + unsigned short http_minor; + + int message_begin_cb_called; + int headers_complete_cb_called; + int message_complete_cb_called; + int message_complete_on_eof; + int body_is_final; +}; + +static int currently_parsing_eof; + +static struct message messages[5]; +static int num_messages; +static http_parser_settings *current_pause_parser; + +/* * R E Q U E S T S * */ +const struct message requests[] = +#define CURL_GET 0 +{ {.name= "curl get" + ,.type= HTTP_REQUEST + ,.raw= "GET /test HTTP/1.1\r\n" + "User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1\r\n" + "Host: 0.0.0.0=5000\r\n" + "Accept: */*\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 3 + ,.headers= + { { "User-Agent", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1" } + , { "Host", "0.0.0.0=5000" } + , { "Accept", "*/*" } + } + ,.body= "" + } + +#define FIREFOX_GET 1 +, {.name= "firefox get" + ,.type= HTTP_REQUEST + ,.raw= "GET /favicon.ico HTTP/1.1\r\n" + "Host: 0.0.0.0=5000\r\n" + "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0\r\n" + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" + "Accept-Language: en-us,en;q=0.5\r\n" + "Accept-Encoding: gzip,deflate\r\n" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" + "Keep-Alive: 300\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/favicon.ico" + ,.request_url= "/favicon.ico" + ,.num_headers= 8 + ,.headers= + { { "Host", "0.0.0.0=5000" } + , { "User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0" } + , { "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" } + , { "Accept-Language", "en-us,en;q=0.5" } + , { "Accept-Encoding", "gzip,deflate" } + , { "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7" } + , { "Keep-Alive", "300" } + , { "Connection", "keep-alive" } + } + ,.body= "" + } + +#define DUMBFUCK 2 +, {.name= "dumbfuck" + ,.type= HTTP_REQUEST + ,.raw= "GET /dumbfuck HTTP/1.1\r\n" + "aaaaaaaaaaaaa:++++++++++\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/dumbfuck" + ,.request_url= "/dumbfuck" + ,.num_headers= 1 + ,.headers= + { { "aaaaaaaaaaaaa", "++++++++++" } + } + ,.body= "" + } + +#define FRAGMENT_IN_URI 3 +, {.name= "fragment in url" + ,.type= HTTP_REQUEST + ,.raw= "GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "page=1" + ,.fragment= "posts-17408" + ,.request_path= "/forums/1/topics/2375" + /* XXX request url does include fragment? */ + ,.request_url= "/forums/1/topics/2375?page=1#posts-17408" + ,.num_headers= 0 + ,.body= "" + } + +#define GET_NO_HEADERS_NO_BODY 4 +, {.name= "get no headers no body" + ,.type= HTTP_REQUEST + ,.raw= "GET /get_no_headers_no_body/world HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE /* would need Connection: close */ + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/get_no_headers_no_body/world" + ,.request_url= "/get_no_headers_no_body/world" + ,.num_headers= 0 + ,.body= "" + } + +#define GET_ONE_HEADER_NO_BODY 5 +, {.name= "get one header no body" + ,.type= HTTP_REQUEST + ,.raw= "GET /get_one_header_no_body HTTP/1.1\r\n" + "Accept: */*\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE /* would need Connection: close */ + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/get_one_header_no_body" + ,.request_url= "/get_one_header_no_body" + ,.num_headers= 1 + ,.headers= + { { "Accept" , "*/*" } + } + ,.body= "" + } + +#define GET_FUNKY_CONTENT_LENGTH 6 +, {.name= "get funky content length body hello" + ,.type= HTTP_REQUEST + ,.raw= "GET /get_funky_content_length_body_hello HTTP/1.0\r\n" + "conTENT-Length: 5\r\n" + "\r\n" + "HELLO" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/get_funky_content_length_body_hello" + ,.request_url= "/get_funky_content_length_body_hello" + ,.num_headers= 1 + ,.headers= + { { "conTENT-Length" , "5" } + } + ,.body= "HELLO" + } + +#define POST_IDENTITY_BODY_WORLD 7 +, {.name= "post identity body world" + ,.type= HTTP_REQUEST + ,.raw= "POST /post_identity_body_world?q=search#hey HTTP/1.1\r\n" + "Accept: */*\r\n" + "Transfer-Encoding: identity\r\n" + "Content-Length: 5\r\n" + "\r\n" + "World" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "q=search" + ,.fragment= "hey" + ,.request_path= "/post_identity_body_world" + ,.request_url= "/post_identity_body_world?q=search#hey" + ,.num_headers= 3 + ,.headers= + { { "Accept", "*/*" } + , { "Transfer-Encoding", "identity" } + , { "Content-Length", "5" } + } + ,.body= "World" + } + +#define POST_CHUNKED_ALL_YOUR_BASE 8 +, {.name= "post - chunked body: all your base are belong to us" + ,.type= HTTP_REQUEST + ,.raw= "POST /post_chunked_all_your_base HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "1e\r\nall your base are belong to us\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/post_chunked_all_your_base" + ,.request_url= "/post_chunked_all_your_base" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding" , "chunked" } + } + ,.body= "all your base are belong to us" + } + +#define TWO_CHUNKS_MULT_ZERO_END 9 +, {.name= "two chunks ; triple zero ending" + ,.type= HTTP_REQUEST + ,.raw= "POST /two_chunks_mult_zero_end HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "5\r\nhello\r\n" + "6\r\n world\r\n" + "000\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/two_chunks_mult_zero_end" + ,.request_url= "/two_chunks_mult_zero_end" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding", "chunked" } + } + ,.body= "hello world" + } + +#define CHUNKED_W_TRAILING_HEADERS 10 +, {.name= "chunked with trailing headers. blech." + ,.type= HTTP_REQUEST + ,.raw= "POST /chunked_w_trailing_headers HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "5\r\nhello\r\n" + "6\r\n world\r\n" + "0\r\n" + "Vary: *\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/chunked_w_trailing_headers" + ,.request_url= "/chunked_w_trailing_headers" + ,.num_headers= 3 + ,.headers= + { { "Transfer-Encoding", "chunked" } + , { "Vary", "*" } + , { "Content-Type", "text/plain" } + } + ,.body= "hello world" + } + +#define CHUNKED_W_BULLSHIT_AFTER_LENGTH 11 +, {.name= "with bullshit after the length" + ,.type= HTTP_REQUEST + ,.raw= "POST /chunked_w_bullshit_after_length HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "5; ihatew3;whatthefuck=aretheseparametersfor\r\nhello\r\n" + "6; blahblah; blah\r\n world\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/chunked_w_bullshit_after_length" + ,.request_url= "/chunked_w_bullshit_after_length" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding", "chunked" } + } + ,.body= "hello world" + } + +#define WITH_QUOTES 12 +, {.name= "with quotes" + ,.type= HTTP_REQUEST + ,.raw= "GET /with_\"stupid\"_quotes?foo=\"bar\" HTTP/1.1\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "foo=\"bar\"" + ,.fragment= "" + ,.request_path= "/with_\"stupid\"_quotes" + ,.request_url= "/with_\"stupid\"_quotes?foo=\"bar\"" + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define APACHEBENCH_GET 13 +/* The server receiving this request SHOULD NOT wait for EOF + * to know that content-length == 0. + * How to represent this in a unit test? message_complete_on_eof + * Compare with NO_CONTENT_LENGTH_RESPONSE. + */ +, {.name = "apachebench get" + ,.type= HTTP_REQUEST + ,.raw= "GET /test HTTP/1.0\r\n" + "Host: 0.0.0.0:5000\r\n" + "User-Agent: ApacheBench/2.3\r\n" + "Accept: */*\r\n\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 3 + ,.headers= { { "Host", "0.0.0.0:5000" } + , { "User-Agent", "ApacheBench/2.3" } + , { "Accept", "*/*" } + } + ,.body= "" + } + +#define QUERY_URL_WITH_QUESTION_MARK_GET 14 +/* Some clients include '?' characters in query strings. + */ +, {.name = "query url with question mark" + ,.type= HTTP_REQUEST + ,.raw= "GET /test.cgi?foo=bar?baz HTTP/1.1\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "foo=bar?baz" + ,.fragment= "" + ,.request_path= "/test.cgi" + ,.request_url= "/test.cgi?foo=bar?baz" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define PREFIX_NEWLINE_GET 15 +/* Some clients, especially after a POST in a keep-alive connection, + * will send an extra CRLF before the next request + */ +, {.name = "newline prefix get" + ,.type= HTTP_REQUEST + ,.raw= "\r\nGET /test HTTP/1.1\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define UPGRADE_REQUEST 16 +, {.name = "upgrade request" + ,.type= HTTP_REQUEST + ,.raw= "GET /demo HTTP/1.1\r\n" + "Host: example.com\r\n" + "Connection: Upgrade\r\n" + "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" + "Sec-WebSocket-Protocol: sample\r\n" + "Upgrade: WebSocket\r\n" + "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" + "Origin: http://example.com\r\n" + "\r\n" + "Hot diggity dogg" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/demo" + ,.request_url= "/demo" + ,.num_headers= 7 + ,.upgrade="Hot diggity dogg" + ,.headers= { { "Host", "example.com" } + , { "Connection", "Upgrade" } + , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" } + , { "Sec-WebSocket-Protocol", "sample" } + , { "Upgrade", "WebSocket" } + , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" } + , { "Origin", "http://example.com" } + } + ,.body= "" + } + +#define CONNECT_REQUEST 17 +, {.name = "connect request" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT 0-home0.netscape.com:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n" + "some data\r\n" + "and yet even more data" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "0-home0.netscape.com:443" + ,.num_headers= 2 + ,.upgrade="some data\r\nand yet even more data" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + } + ,.body= "" + } + +#define REPORT_REQ 18 +, {.name= "report request" + ,.type= HTTP_REQUEST + ,.raw= "REPORT /test HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_REPORT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define NO_HTTP_VERSION 19 +, {.name= "request with no http version" + ,.type= HTTP_REQUEST + ,.raw= "GET /\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 0 + ,.http_minor= 9 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define MSEARCH_REQ 20 +, {.name= "m-search request" + ,.type= HTTP_REQUEST + ,.raw= "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "MAN: \"ssdp:discover\"\r\n" + "ST: \"ssdp:all\"\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_MSEARCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "*" + ,.request_url= "*" + ,.num_headers= 3 + ,.headers= { { "HOST", "239.255.255.250:1900" } + , { "MAN", "\"ssdp:discover\"" } + , { "ST", "\"ssdp:all\"" } + } + ,.body= "" + } + +#define LINE_FOLDING_IN_HEADER 21 +, {.name= "line folding in header value" + ,.type= HTTP_REQUEST + ,.raw= "GET / HTTP/1.1\r\n" + "Line1: abc\r\n" + "\tdef\r\n" + " ghi\r\n" + "\t\tjkl\r\n" + " mno \r\n" + "\t \tqrs\r\n" + "Line2: \t line2\t\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 2 + ,.headers= { { "Line1", "abcdefghijklmno qrs" } + , { "Line2", "line2\t" } + } + ,.body= "" + } + + +#define QUERY_TERMINATED_HOST 22 +, {.name= "host terminated by a query string" + ,.type= HTTP_REQUEST + ,.raw= "GET http://hypnotoad.org?hail=all HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "hail=all" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "http://hypnotoad.org?hail=all" + ,.host= "hypnotoad.org" + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define QUERY_TERMINATED_HOSTPORT 23 +, {.name= "host:port terminated by a query string" + ,.type= HTTP_REQUEST + ,.raw= "GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "hail=all" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "http://hypnotoad.org:1234?hail=all" + ,.host= "hypnotoad.org" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define SPACE_TERMINATED_HOSTPORT 24 +, {.name= "host:port terminated by a space" + ,.type= HTTP_REQUEST + ,.raw= "GET http://hypnotoad.org:1234 HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "http://hypnotoad.org:1234" + ,.host= "hypnotoad.org" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define PATCH_REQ 25 +, {.name = "PATCH request" + ,.type= HTTP_REQUEST + ,.raw= "PATCH /file.txt HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/example\r\n" + "If-Match: \"e0023aa4e\"\r\n" + "Content-Length: 10\r\n" + "\r\n" + "cccccccccc" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_PATCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/file.txt" + ,.request_url= "/file.txt" + ,.num_headers= 4 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/example" } + , { "If-Match", "\"e0023aa4e\"" } + , { "Content-Length", "10" } + } + ,.body= "cccccccccc" + } + +#define CONNECT_CAPS_REQUEST 26 +, {.name = "connect caps request" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT HOME0.NETSCAPE.COM:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "HOME0.NETSCAPE.COM:443" + ,.num_headers= 2 + ,.upgrade="" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + } + ,.body= "" + } + +#if !HTTP_PARSER_STRICT +#define UTF8_PATH_REQ 27 +, {.name= "utf-8 path request" + ,.type= HTTP_REQUEST + ,.raw= "GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\n" + "Host: github.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "q=1" + ,.fragment= "narf" + ,.request_path= "/δ¶/δt/pope" + ,.request_url= "/δ¶/δt/pope?q=1#narf" + ,.num_headers= 1 + ,.headers= { {"Host", "github.com" } + } + ,.body= "" + } + +#define HOSTNAME_UNDERSCORE 28 +, {.name = "hostname underscore" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT home_0.netscape.com:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "home_0.netscape.com:443" + ,.num_headers= 2 + ,.upgrade="" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + } + ,.body= "" + } +#endif /* !HTTP_PARSER_STRICT */ + +/* see https://github.com/ry/http-parser/issues/47 */ +#define EAT_TRAILING_CRLF_NO_CONNECTION_CLOSE 29 +, {.name = "eat CRLF between requests, no \"Connection: close\" header" + ,.raw= "POST / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: 4\r\n" + "\r\n" + "q=42\r\n" /* note the trailing CRLF */ + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 3 + ,.upgrade= 0 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/x-www-form-urlencoded" } + , { "Content-Length", "4" } + } + ,.body= "q=42" + } + +/* see https://github.com/ry/http-parser/issues/47 */ +#define EAT_TRAILING_CRLF_WITH_CONNECTION_CLOSE 30 +, {.name = "eat CRLF between requests even if \"Connection: close\" is set" + ,.raw= "POST / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: 4\r\n" + "Connection: close\r\n" + "\r\n" + "q=42\r\n" /* note the trailing CRLF */ + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE /* input buffer isn't empty when on_message_complete is called */ + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 4 + ,.upgrade= 0 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/x-www-form-urlencoded" } + , { "Content-Length", "4" } + , { "Connection", "close" } + } + ,.body= "q=42" + } + +#define PURGE_REQ 31 +, {.name = "PURGE request" + ,.type= HTTP_REQUEST + ,.raw= "PURGE /file.txt HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_PURGE + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/file.txt" + ,.request_url= "/file.txt" + ,.num_headers= 1 + ,.headers= { { "Host", "www.example.com" } } + ,.body= "" + } + +#define SEARCH_REQ 32 +, {.name = "SEARCH request" + ,.type= HTTP_REQUEST + ,.raw= "SEARCH / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_SEARCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 1 + ,.headers= { { "Host", "www.example.com" } } + ,.body= "" + } + +#define PROXY_WITH_BASIC_AUTH 33 +, {.name= "host:port and basic_auth" + ,.type= HTTP_REQUEST + ,.raw= "GET http://a%12:b!&*$@hypnotoad.org:1234/toto HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.fragment= "" + ,.request_path= "/toto" + ,.request_url= "http://a%12:b!&*$@hypnotoad.org:1234/toto" + ,.host= "hypnotoad.org" + ,.userinfo= "a%12:b!&*$" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + + +, {.name= NULL } /* sentinel */ +}; + +/* * R E S P O N S E S * */ +const struct message responses[] = +#define GOOGLE_301 0 +{ {.name= "google 301" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 301 Moved Permanently\r\n" + "Location: http://www.google.com/\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Date: Sun, 26 Apr 2009 11:11:49 GMT\r\n" + "Expires: Tue, 26 May 2009 11:11:49 GMT\r\n" + "X-$PrototypeBI-Version: 1.6.0.3\r\n" /* $ char in header field */ + "Cache-Control: public, max-age=2592000\r\n" + "Server: gws\r\n" + "Content-Length: 219 \r\n" + "\r\n" + "\n" + "301 Moved\n" + "

301 Moved

\n" + "The document has moved\n" + "here.\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 301 + ,.num_headers= 8 + ,.headers= + { { "Location", "http://www.google.com/" } + , { "Content-Type", "text/html; charset=UTF-8" } + , { "Date", "Sun, 26 Apr 2009 11:11:49 GMT" } + , { "Expires", "Tue, 26 May 2009 11:11:49 GMT" } + , { "X-$PrototypeBI-Version", "1.6.0.3" } + , { "Cache-Control", "public, max-age=2592000" } + , { "Server", "gws" } + , { "Content-Length", "219 " } + } + ,.body= "\n" + "301 Moved\n" + "

301 Moved

\n" + "The document has moved\n" + "here.\r\n" + "\r\n" + } + +#define NO_CONTENT_LENGTH_RESPONSE 1 +/* The client should wait for the server's EOF. That is, when content-length + * is not specified, and "Connection: close", the end of body is specified + * by the EOF. + * Compare with APACHEBENCH_GET + */ +, {.name= "no content-length response" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Date: Tue, 04 Aug 2009 07:59:32 GMT\r\n" + "Server: Apache\r\n" + "X-Powered-By: Servlet/2.5 JSP/2.1\r\n" + "Content-Type: text/xml; charset=utf-8\r\n" + "Connection: close\r\n" + "\r\n" + "\n" + "\n" + " \n" + " \n" + " SOAP-ENV:Client\n" + " Client Error\n" + " \n" + " \n" + "" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 5 + ,.headers= + { { "Date", "Tue, 04 Aug 2009 07:59:32 GMT" } + , { "Server", "Apache" } + , { "X-Powered-By", "Servlet/2.5 JSP/2.1" } + , { "Content-Type", "text/xml; charset=utf-8" } + , { "Connection", "close" } + } + ,.body= "\n" + "\n" + " \n" + " \n" + " SOAP-ENV:Client\n" + " Client Error\n" + " \n" + " \n" + "" + } + +#define NO_HEADERS_NO_BODY_404 2 +, {.name= "404 no headers no body" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 404 Not Found\r\n\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 404 + ,.num_headers= 0 + ,.headers= {} + ,.body_size= 0 + ,.body= "" + } + +#define NO_REASON_PHRASE 3 +, {.name= "301 no response phrase" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 301\r\n\r\n" + ,.should_keep_alive = FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 301 + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define TRAILING_SPACE_ON_CHUNKED_BODY 4 +, {.name="200 trailing space on chunked body" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "25 \r\n" + "This is the data in the first chunk\r\n" + "\r\n" + "1C\r\n" + "and this is the second one\r\n" + "\r\n" + "0 \r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 2 + ,.headers= + { {"Content-Type", "text/plain" } + , {"Transfer-Encoding", "chunked" } + } + ,.body_size = 37+28 + ,.body = + "This is the data in the first chunk\r\n" + "and this is the second one\r\n" + + } + +#define NO_CARRIAGE_RET 5 +, {.name="no carriage ret" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\n" + "Content-Type: text/html; charset=utf-8\n" + "Connection: close\n" + "\n" + "these headers are from http://news.ycombinator.com/" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 2 + ,.headers= + { {"Content-Type", "text/html; charset=utf-8" } + , {"Connection", "close" } + } + ,.body= "these headers are from http://news.ycombinator.com/" + } + +#define PROXY_CONNECTION 6 +, {.name="proxy connection" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Content-Length: 11\r\n" + "Proxy-Connection: close\r\n" + "Date: Thu, 31 Dec 2009 20:55:48 +0000\r\n" + "\r\n" + "hello world" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 4 + ,.headers= + { {"Content-Type", "text/html; charset=UTF-8" } + , {"Content-Length", "11" } + , {"Proxy-Connection", "close" } + , {"Date", "Thu, 31 Dec 2009 20:55:48 +0000"} + } + ,.body= "hello world" + } + +#define UNDERSTORE_HEADER_KEY 7 + // shown by + // curl -o /dev/null -v "http://ad.doubleclick.net/pfadx/DARTSHELLCONFIGXML;dcmt=text/xml;" +, {.name="underscore header key" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Server: DCLK-AdSvr\r\n" + "Content-Type: text/xml\r\n" + "Content-Length: 0\r\n" + "DCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 4 + ,.headers= + { {"Server", "DCLK-AdSvr" } + , {"Content-Type", "text/xml" } + , {"Content-Length", "0" } + , {"DCLK_imp", "v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o" } + } + ,.body= "" + } + +#define BONJOUR_MADAME_FR 8 +/* The client should not merge two headers fields when the first one doesn't + * have a value. + */ +, {.name= "bonjourmadame.fr" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.0 301 Moved Permanently\r\n" + "Date: Thu, 03 Jun 2010 09:56:32 GMT\r\n" + "Server: Apache/2.2.3 (Red Hat)\r\n" + "Cache-Control: public\r\n" + "Pragma: \r\n" + "Location: http://www.bonjourmadame.fr/\r\n" + "Vary: Accept-Encoding\r\n" + "Content-Length: 0\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 301 + ,.num_headers= 9 + ,.headers= + { { "Date", "Thu, 03 Jun 2010 09:56:32 GMT" } + , { "Server", "Apache/2.2.3 (Red Hat)" } + , { "Cache-Control", "public" } + , { "Pragma", "" } + , { "Location", "http://www.bonjourmadame.fr/" } + , { "Vary", "Accept-Encoding" } + , { "Content-Length", "0" } + , { "Content-Type", "text/html; charset=UTF-8" } + , { "Connection", "keep-alive" } + } + ,.body= "" + } + +#define RES_FIELD_UNDERSCORE 9 +/* Should handle spaces in header fields */ +, {.name= "field underscore" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Date: Tue, 28 Sep 2010 01:14:13 GMT\r\n" + "Server: Apache\r\n" + "Cache-Control: no-cache, must-revalidate\r\n" + "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n" + ".et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com\r\n" + "Vary: Accept-Encoding\r\n" + "_eep-Alive: timeout=45\r\n" /* semantic value ignored */ + "_onnection: Keep-Alive\r\n" /* semantic value ignored */ + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/html\r\n" + "Connection: close\r\n" + "\r\n" + "0\r\n\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 11 + ,.headers= + { { "Date", "Tue, 28 Sep 2010 01:14:13 GMT" } + , { "Server", "Apache" } + , { "Cache-Control", "no-cache, must-revalidate" } + , { "Expires", "Mon, 26 Jul 1997 05:00:00 GMT" } + , { ".et-Cookie", "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com" } + , { "Vary", "Accept-Encoding" } + , { "_eep-Alive", "timeout=45" } + , { "_onnection", "Keep-Alive" } + , { "Transfer-Encoding", "chunked" } + , { "Content-Type", "text/html" } + , { "Connection", "close" } + } + ,.body= "" + } + +#define NON_ASCII_IN_STATUS_LINE 10 +/* Should handle non-ASCII in status line */ +, {.name= "non-ASCII in status line" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 500 Oriëntatieprobleem\r\n" + "Date: Fri, 5 Nov 2010 23:07:12 GMT+2\r\n" + "Content-Length: 0\r\n" + "Connection: close\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 500 + ,.num_headers= 3 + ,.headers= + { { "Date", "Fri, 5 Nov 2010 23:07:12 GMT+2" } + , { "Content-Length", "0" } + , { "Connection", "close" } + } + ,.body= "" + } + +#define HTTP_VERSION_0_9 11 +/* Should handle HTTP/0.9 */ +, {.name= "http version 0.9" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/0.9 200 OK\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 0 + ,.http_minor= 9 + ,.status_code= 200 + ,.num_headers= 0 + ,.headers= + {} + ,.body= "" + } + +#define NO_CONTENT_LENGTH_NO_TRANSFER_ENCODING_RESPONSE 12 +/* The client should wait for the server's EOF. That is, when neither + * content-length nor transfer-encoding is specified, the end of body + * is specified by the EOF. + */ +, {.name= "neither content-length nor transfer-encoding response" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + "hello world" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 1 + ,.headers= + { { "Content-Type", "text/plain" } + } + ,.body= "hello world" + } + +#define NO_BODY_HTTP10_KA_200 13 +, {.name= "HTTP/1.0 with keep-alive and EOF-terminated 200 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.0 200 OK\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 200 + ,.num_headers= 1 + ,.headers= + { { "Connection", "keep-alive" } + } + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP10_KA_204 14 +, {.name= "HTTP/1.0 with keep-alive and a 204 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.0 204 No content\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 204 + ,.num_headers= 1 + ,.headers= + { { "Connection", "keep-alive" } + } + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_KA_200 15 +, {.name= "HTTP/1.1 with an EOF-terminated 200 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 0 + ,.headers={} + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_KA_204 16 +, {.name= "HTTP/1.1 with a 204 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 204 No content\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 204 + ,.num_headers= 0 + ,.headers={} + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_NOKA_204 17 +, {.name= "HTTP/1.1 with a 204 status and keep-alive disabled" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 204 No content\r\n" + "Connection: close\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 204 + ,.num_headers= 1 + ,.headers= + { { "Connection", "close" } + } + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_KA_CHUNKED_200 18 +, {.name= "HTTP/1.1 with chunked endocing and a 200 response" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding", "chunked" } + } + ,.body_size= 0 + ,.body= "" + } + +#if !HTTP_PARSER_STRICT +#define SPACE_IN_FIELD_RES 19 +/* Should handle spaces in header fields */ +, {.name= "field space" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Server: Microsoft-IIS/6.0\r\n" + "X-Powered-By: ASP.NET\r\n" + "en-US Content-Type: text/xml\r\n" /* this is the problem */ + "Content-Type: text/xml\r\n" + "Content-Length: 16\r\n" + "Date: Fri, 23 Jul 2010 18:45:38 GMT\r\n" + "Connection: keep-alive\r\n" + "\r\n" + "hello" /* fake body */ + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 7 + ,.headers= + { { "Server", "Microsoft-IIS/6.0" } + , { "X-Powered-By", "ASP.NET" } + , { "en-US Content-Type", "text/xml" } + , { "Content-Type", "text/xml" } + , { "Content-Length", "16" } + , { "Date", "Fri, 23 Jul 2010 18:45:38 GMT" } + , { "Connection", "keep-alive" } + } + ,.body= "hello" + } +#endif /* !HTTP_PARSER_STRICT */ + +, {.name= NULL } /* sentinel */ +}; + +/* strnlen() is a POSIX.2008 addition. Can't rely on it being available so + * define it ourselves. + */ +size_t +strnlen(const char *s, size_t maxlen) +{ + const char *p; + + p = memchr(s, '\0', maxlen); + if (p == NULL) + return maxlen; + + return p - s; +} + +size_t +strlncat(char *dst, size_t len, const char *src, size_t n) +{ + size_t slen; + size_t dlen; + size_t rlen; + size_t ncpy; + + slen = strnlen(src, n); + dlen = strnlen(dst, len); + + if (dlen < len) { + rlen = len - dlen; + ncpy = slen < rlen ? slen : (rlen - 1); + memcpy(dst + dlen, src, ncpy); + dst[dlen + ncpy] = '\0'; + } + + assert(len > slen + dlen); + return slen + dlen; +} + +size_t +strlcat(char *dst, const char *src, size_t len) +{ + return strlncat(dst, len, src, (size_t) -1); +} + +size_t +strlncpy(char *dst, size_t len, const char *src, size_t n) +{ + size_t slen; + size_t ncpy; + + slen = strnlen(src, n); + + if (len > 0) { + ncpy = slen < len ? slen : (len - 1); + memcpy(dst, src, ncpy); + dst[ncpy] = '\0'; + } + + assert(len > slen); + return slen; +} + +size_t +strlcpy(char *dst, const char *src, size_t len) +{ + return strlncpy(dst, len, src, (size_t) -1); +} + +int +request_url_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + strlncat(messages[num_messages].request_url, + sizeof(messages[num_messages].request_url), + buf, + len); + return 0; +} + +int +header_field_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + struct message *m = &messages[num_messages]; + + if (m->last_header_element != FIELD) + m->num_headers++; + + strlncat(m->headers[m->num_headers-1][0], + sizeof(m->headers[m->num_headers-1][0]), + buf, + len); + + m->last_header_element = FIELD; + + return 0; +} + +int +header_value_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + struct message *m = &messages[num_messages]; + + strlncat(m->headers[m->num_headers-1][1], + sizeof(m->headers[m->num_headers-1][1]), + buf, + len); + + m->last_header_element = VALUE; + + return 0; +} + +void +check_body_is_final (const http_parser *p) +{ + if (messages[num_messages].body_is_final) { + fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " + "on last on_body callback call " + "but it doesn't! ***\n\n"); + assert(0); + abort(); + } + messages[num_messages].body_is_final = http_body_is_final(p); +} + +int +body_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + strlncat(messages[num_messages].body, + sizeof(messages[num_messages].body), + buf, + len); + messages[num_messages].body_size += len; + check_body_is_final(p); + // printf("body_cb: '%s'\n", requests[num_messages].body); + return 0; +} + +int +count_body_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + assert(buf); + messages[num_messages].body_size += len; + check_body_is_final(p); + return 0; +} + +int +message_begin_cb (http_parser *p) +{ + assert(p == parser); + messages[num_messages].message_begin_cb_called = TRUE; + return 0; +} + +int +headers_complete_cb (http_parser *p) +{ + assert(p == parser); + messages[num_messages].method = parser->method; + messages[num_messages].status_code = parser->status_code; + messages[num_messages].http_major = parser->http_major; + messages[num_messages].http_minor = parser->http_minor; + messages[num_messages].headers_complete_cb_called = TRUE; + messages[num_messages].should_keep_alive = http_should_keep_alive(parser); + return 0; +} + +int +message_complete_cb (http_parser *p) +{ + assert(p == parser); + if (messages[num_messages].should_keep_alive != http_should_keep_alive(parser)) + { + fprintf(stderr, "\n\n *** Error http_should_keep_alive() should have same " + "value in both on_message_complete and on_headers_complete " + "but it doesn't! ***\n\n"); + assert(0); + abort(); + } + + if (messages[num_messages].body_size && + http_body_is_final(p) && + !messages[num_messages].body_is_final) + { + fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " + "on last on_body callback call " + "but it doesn't! ***\n\n"); + assert(0); + abort(); + } + + messages[num_messages].message_complete_cb_called = TRUE; + + messages[num_messages].message_complete_on_eof = currently_parsing_eof; + + num_messages++; + return 0; +} + +/* These dontcall_* callbacks exist so that we can verify that when we're + * paused, no additional callbacks are invoked */ +int +dontcall_message_begin_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_message_begin() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_header_field_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_header_field() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_header_value_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_header_value() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_request_url_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_request_url() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_body_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_body_cb() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_headers_complete_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_headers_complete() called on paused " + "parser ***\n\n"); + abort(); +} + +int +dontcall_message_complete_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_message_complete() called on paused " + "parser ***\n\n"); + abort(); +} + +static http_parser_settings settings_dontcall = + {.on_message_begin = dontcall_message_begin_cb + ,.on_header_field = dontcall_header_field_cb + ,.on_header_value = dontcall_header_value_cb + ,.on_url = dontcall_request_url_cb + ,.on_body = dontcall_body_cb + ,.on_headers_complete = dontcall_headers_complete_cb + ,.on_message_complete = dontcall_message_complete_cb + }; + +/* These pause_* callbacks always pause the parser and just invoke the regular + * callback that tracks content. Before returning, we overwrite the parser + * settings to point to the _dontcall variety so that we can verify that + * the pause actually did, you know, pause. */ +int +pause_message_begin_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return message_begin_cb(p); +} + +int +pause_header_field_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return header_field_cb(p, buf, len); +} + +int +pause_header_value_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return header_value_cb(p, buf, len); +} + +int +pause_request_url_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return request_url_cb(p, buf, len); +} + +int +pause_body_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return body_cb(p, buf, len); +} + +int +pause_headers_complete_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return headers_complete_cb(p); +} + +int +pause_message_complete_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return message_complete_cb(p); +} + +static http_parser_settings settings_pause = + {.on_message_begin = pause_message_begin_cb + ,.on_header_field = pause_header_field_cb + ,.on_header_value = pause_header_value_cb + ,.on_url = pause_request_url_cb + ,.on_body = pause_body_cb + ,.on_headers_complete = pause_headers_complete_cb + ,.on_message_complete = pause_message_complete_cb + }; + +static http_parser_settings settings = + {.on_message_begin = message_begin_cb + ,.on_header_field = header_field_cb + ,.on_header_value = header_value_cb + ,.on_url = request_url_cb + ,.on_body = body_cb + ,.on_headers_complete = headers_complete_cb + ,.on_message_complete = message_complete_cb + }; + +static http_parser_settings settings_count_body = + {.on_message_begin = message_begin_cb + ,.on_header_field = header_field_cb + ,.on_header_value = header_value_cb + ,.on_url = request_url_cb + ,.on_body = count_body_cb + ,.on_headers_complete = headers_complete_cb + ,.on_message_complete = message_complete_cb + }; + +static http_parser_settings settings_null = + {.on_message_begin = 0 + ,.on_header_field = 0 + ,.on_header_value = 0 + ,.on_url = 0 + ,.on_body = 0 + ,.on_headers_complete = 0 + ,.on_message_complete = 0 + }; + +void +parser_init (enum http_parser_type type) +{ + num_messages = 0; + + assert(parser == NULL); + + parser = malloc(sizeof(http_parser)); + + http_parser_init(parser, type); + + memset(&messages, 0, sizeof messages); + +} + +void +parser_free () +{ + assert(parser); + free(parser); + parser = NULL; +} + +size_t parse (const char *buf, size_t len) +{ + size_t nparsed; + currently_parsing_eof = (len == 0); + nparsed = http_parser_execute(parser, &settings, buf, len); + return nparsed; +} + +size_t parse_count_body (const char *buf, size_t len) +{ + size_t nparsed; + currently_parsing_eof = (len == 0); + nparsed = http_parser_execute(parser, &settings_count_body, buf, len); + return nparsed; +} + +size_t parse_pause (const char *buf, size_t len) +{ + size_t nparsed; + http_parser_settings s = settings_pause; + + currently_parsing_eof = (len == 0); + current_pause_parser = &s; + nparsed = http_parser_execute(parser, current_pause_parser, buf, len); + return nparsed; +} + +static inline int +check_str_eq (const struct message *m, + const char *prop, + const char *expected, + const char *found) { + if ((expected == NULL) != (found == NULL)) { + printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); + printf("expected %s\n", (expected == NULL) ? "NULL" : expected); + printf(" found %s\n", (found == NULL) ? "NULL" : found); + return 0; + } + if (expected != NULL && 0 != strcmp(expected, found)) { + printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); + printf("expected '%s'\n", expected); + printf(" found '%s'\n", found); + return 0; + } + return 1; +} + +static inline int +check_num_eq (const struct message *m, + const char *prop, + int expected, + int found) { + if (expected != found) { + printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); + printf("expected %d\n", expected); + printf(" found %d\n", found); + return 0; + } + return 1; +} + +#define MESSAGE_CHECK_STR_EQ(expected, found, prop) \ + if (!check_str_eq(expected, #prop, expected->prop, found->prop)) return 0 + +#define MESSAGE_CHECK_NUM_EQ(expected, found, prop) \ + if (!check_num_eq(expected, #prop, expected->prop, found->prop)) return 0 + +#define MESSAGE_CHECK_URL_EQ(u, expected, found, prop, fn) \ +do { \ + char ubuf[256]; \ + \ + if ((u)->field_set & (1 << (fn))) { \ + memcpy(ubuf, (found)->request_url + (u)->field_data[(fn)].off, \ + (u)->field_data[(fn)].len); \ + ubuf[(u)->field_data[(fn)].len] = '\0'; \ + } else { \ + ubuf[0] = '\0'; \ + } \ + \ + check_str_eq(expected, #prop, expected->prop, ubuf); \ +} while(0) + +int +message_eq (int index, const struct message *expected) +{ + int i; + struct message *m = &messages[index]; + + MESSAGE_CHECK_NUM_EQ(expected, m, http_major); + MESSAGE_CHECK_NUM_EQ(expected, m, http_minor); + + if (expected->type == HTTP_REQUEST) { + MESSAGE_CHECK_NUM_EQ(expected, m, method); + } else { + MESSAGE_CHECK_NUM_EQ(expected, m, status_code); + } + + MESSAGE_CHECK_NUM_EQ(expected, m, should_keep_alive); + MESSAGE_CHECK_NUM_EQ(expected, m, message_complete_on_eof); + + assert(m->message_begin_cb_called); + assert(m->headers_complete_cb_called); + assert(m->message_complete_cb_called); + + + MESSAGE_CHECK_STR_EQ(expected, m, request_url); + + /* Check URL components; we can't do this w/ CONNECT since it doesn't + * send us a well-formed URL. + */ + if (*m->request_url && m->method != HTTP_CONNECT) { + struct http_parser_url u; + + if (http_parser_parse_url(m->request_url, strlen(m->request_url), 0, &u)) { + fprintf(stderr, "\n\n*** failed to parse URL %s ***\n\n", + m->request_url); + abort(); + } + + if (expected->host) { + MESSAGE_CHECK_URL_EQ(&u, expected, m, host, UF_HOST); + } + + if (expected->userinfo) { + MESSAGE_CHECK_URL_EQ(&u, expected, m, userinfo, UF_USERINFO); + } + + m->port = (u.field_set & (1 << UF_PORT)) ? + u.port : 0; + + MESSAGE_CHECK_URL_EQ(&u, expected, m, query_string, UF_QUERY); + MESSAGE_CHECK_URL_EQ(&u, expected, m, fragment, UF_FRAGMENT); + MESSAGE_CHECK_URL_EQ(&u, expected, m, request_path, UF_PATH); + MESSAGE_CHECK_NUM_EQ(expected, m, port); + } + + if (expected->body_size) { + MESSAGE_CHECK_NUM_EQ(expected, m, body_size); + } else { + MESSAGE_CHECK_STR_EQ(expected, m, body); + } + + MESSAGE_CHECK_NUM_EQ(expected, m, num_headers); + + int r; + for (i = 0; i < m->num_headers; i++) { + r = check_str_eq(expected, "header field", expected->headers[i][0], m->headers[i][0]); + if (!r) return 0; + r = check_str_eq(expected, "header value", expected->headers[i][1], m->headers[i][1]); + if (!r) return 0; + } + + MESSAGE_CHECK_STR_EQ(expected, m, upgrade); + + return 1; +} + +/* Given a sequence of varargs messages, return the number of them that the + * parser should successfully parse, taking into account that upgraded + * messages prevent all subsequent messages from being parsed. + */ +size_t +count_parsed_messages(const size_t nmsgs, ...) { + size_t i; + va_list ap; + + va_start(ap, nmsgs); + + for (i = 0; i < nmsgs; i++) { + struct message *m = va_arg(ap, struct message *); + + if (m->upgrade) { + va_end(ap); + return i + 1; + } + } + + va_end(ap); + return nmsgs; +} + +/* Given a sequence of bytes and the number of these that we were able to + * parse, verify that upgrade bodies are correct. + */ +void +upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) { + va_list ap; + size_t i; + size_t off = 0; + + va_start(ap, nmsgs); + + for (i = 0; i < nmsgs; i++) { + struct message *m = va_arg(ap, struct message *); + + off += strlen(m->raw); + + if (m->upgrade) { + off -= strlen(m->upgrade); + + /* Check the portion of the response after its specified upgrade */ + if (!check_str_eq(m, "upgrade", body + off, body + nread)) { + abort(); + } + + /* Fix up the response so that message_eq() will verify the beginning + * of the upgrade */ + *(body + nread + strlen(m->upgrade)) = '\0'; + messages[num_messages -1 ].upgrade = body + nread; + + va_end(ap); + return; + } + } + + va_end(ap); + printf("\n\n*** Error: expected a message with upgrade ***\n"); + + abort(); +} + +static void +print_error (const char *raw, size_t error_location) +{ + fprintf(stderr, "\n*** %s ***\n\n", + http_errno_description(HTTP_PARSER_ERRNO(parser))); + + int this_line = 0, char_len = 0; + size_t i, j, len = strlen(raw), error_location_line = 0; + for (i = 0; i < len; i++) { + if (i == error_location) this_line = 1; + switch (raw[i]) { + case '\r': + char_len = 2; + fprintf(stderr, "\\r"); + break; + + case '\n': + char_len = 2; + fprintf(stderr, "\\n\n"); + + if (this_line) goto print; + + error_location_line = 0; + continue; + + default: + char_len = 1; + fputc(raw[i], stderr); + break; + } + if (!this_line) error_location_line += char_len; + } + + fprintf(stderr, "[eof]\n"); + + print: + for (j = 0; j < error_location_line; j++) { + fputc(' ', stderr); + } + fprintf(stderr, "^\n\nerror location: %u\n", (unsigned int)error_location); +} + +void +test_preserve_data (void) +{ + char my_data[] = "application-specific data"; + http_parser parser; + parser.data = my_data; + http_parser_init(&parser, HTTP_REQUEST); + if (parser.data != my_data) { + printf("\n*** parser.data not preserved accross http_parser_init ***\n\n"); + abort(); + } +} + +struct url_test { + const char *name; + const char *url; + int is_connect; + struct http_parser_url u; + int rv; +}; + +const struct url_test url_tests[] = +{ {.name="proxy request" + ,.url="http://hostname/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 7, 8 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 15, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="proxy request with port" + ,.url="http://hostname:444/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) + ,.port=444 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 7, 8 } /* UF_HOST */ + ,{ 16, 3 } /* UF_PORT */ + ,{ 19, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="CONNECT request" + ,.url="hostname:443" + ,.is_connect=1 + ,.u= + {.field_set=(1 << UF_HOST) | (1 << UF_PORT) + ,.port=443 + ,.field_data= + {{ 0, 0 } /* UF_SCHEMA */ + ,{ 0, 8 } /* UF_HOST */ + ,{ 9, 3 } /* UF_PORT */ + ,{ 0, 0 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="CONNECT request but not connect" + ,.url="hostname:443" + ,.is_connect=0 + ,.rv=1 + } + +, {.name="proxy ipv6 request" + ,.url="http://[1:2::3:4]/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 8 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 17, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="proxy ipv6 request with port" + ,.url="http://[1:2::3:4]:67/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) + ,.port=67 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 8 } /* UF_HOST */ + ,{ 18, 2 } /* UF_PORT */ + ,{ 20, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="CONNECT ipv6 address" + ,.url="[1:2::3:4]:443" + ,.is_connect=1 + ,.u= + {.field_set=(1 << UF_HOST) | (1 << UF_PORT) + ,.port=443 + ,.field_data= + {{ 0, 0 } /* UF_SCHEMA */ + ,{ 1, 8 } /* UF_HOST */ + ,{ 11, 3 } /* UF_PORT */ + ,{ 0, 0 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="ipv4 in ipv6 address" + ,.url="http://[2001:0000:0000:0000:0000:0000:1.9.1.1]/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 37 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 46, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="extra ? in query string" + ,.url="http://a.tbcdn.cn/p/fp/2010c/??fp-header-min.css,fp-base-min.css," + "fp-channel-min.css,fp-product-min.css,fp-mall-min.css,fp-category-min.css," + "fp-sub-min.css,fp-gdp4p-min.css,fp-css3-min.css,fp-misc-min.css?t=20101022.css" + ,.is_connect=0 + ,.u= + {.field_set=(1<field_set, u->port); + for (i = 0; i < UF_MAX; i++) { + if ((u->field_set & (1 << i)) == 0) { + printf("\tfield_data[%u]: unset\n", i); + continue; + } + + printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n\"", + i, + u->field_data[i].off, + u->field_data[i].len, + u->field_data[i].len, + url + u->field_data[i].off); + } +} + +void +test_parse_url (void) +{ + struct http_parser_url u; + const struct url_test *test; + unsigned int i; + int rv; + + for (i = 0; i < (sizeof(url_tests) / sizeof(url_tests[0])); i++) { + test = &url_tests[i]; + memset(&u, 0, sizeof(u)); + + rv = http_parser_parse_url(test->url, + strlen(test->url), + test->is_connect, + &u); + + if (test->rv == 0) { + if (rv != 0) { + printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " + "unexpected rv %d ***\n\n", test->url, test->name, rv); + abort(); + } + + if (memcmp(&u, &test->u, sizeof(u)) != 0) { + printf("\n*** http_parser_parse_url(\"%s\") \"%s\" failed ***\n", + test->url, test->name); + + printf("target http_parser_url:\n"); + dump_url(test->url, &test->u); + printf("result http_parser_url:\n"); + dump_url(test->url, &u); + + abort(); + } + } else { + /* test->rv != 0 */ + if (rv == 0) { + printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " + "unexpected rv %d ***\n\n", test->url, test->name, rv); + abort(); + } + } + } +} + +void +test_method_str (void) +{ + assert(0 == strcmp("GET", http_method_str(HTTP_GET))); + assert(0 == strcmp("", http_method_str(1337))); +} + +void +test_message (const struct message *message) +{ + size_t raw_len = strlen(message->raw); + size_t msg1len; + for (msg1len = 0; msg1len < raw_len; msg1len++) { + parser_init(message->type); + + size_t read; + const char *msg1 = message->raw; + const char *msg2 = msg1 + msg1len; + size_t msg2len = raw_len - msg1len; + + if (msg1len) { + read = parse(msg1, msg1len); + + if (message->upgrade && parser->upgrade) { + messages[num_messages - 1].upgrade = msg1 + read; + goto test; + } + + if (read != msg1len) { + print_error(msg1, read); + abort(); + } + } + + + read = parse(msg2, msg2len); + + if (message->upgrade && parser->upgrade) { + messages[num_messages - 1].upgrade = msg2 + read; + goto test; + } + + if (read != msg2len) { + print_error(msg2, read); + abort(); + } + + read = parse(NULL, 0); + + if (read != 0) { + print_error(message->raw, read); + abort(); + } + + test: + + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); + abort(); + } + + if(!message_eq(0, message)) abort(); + + parser_free(); + } +} + +void +test_message_count_body (const struct message *message) +{ + parser_init(message->type); + + size_t read; + size_t l = strlen(message->raw); + size_t i, toread; + size_t chunk = 4024; + + for (i = 0; i < l; i+= chunk) { + toread = MIN(l-i, chunk); + read = parse_count_body(message->raw + i, toread); + if (read != toread) { + print_error(message->raw, read); + abort(); + } + } + + + read = parse_count_body(NULL, 0); + if (read != 0) { + print_error(message->raw, read); + abort(); + } + + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); + abort(); + } + + if(!message_eq(0, message)) abort(); + + parser_free(); +} + +void +test_simple (const char *buf, enum http_errno err_expected) +{ + parser_init(HTTP_REQUEST); + + size_t parsed; + int pass; + enum http_errno err; + + parsed = parse(buf, strlen(buf)); + pass = (parsed == strlen(buf)); + err = HTTP_PARSER_ERRNO(parser); + parsed = parse(NULL, 0); + pass &= (parsed == 0); + + parser_free(); + + /* In strict mode, allow us to pass with an unexpected HPE_STRICT as + * long as the caller isn't expecting success. + */ +#if HTTP_PARSER_STRICT + if (err_expected != err && err_expected != HPE_OK && err != HPE_STRICT) { +#else + if (err_expected != err) { +#endif + fprintf(stderr, "\n*** test_simple expected %s, but saw %s ***\n\n%s\n", + http_errno_name(err_expected), http_errno_name(err), buf); + abort(); + } +} + +void +test_header_overflow_error (int req) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + const char *buf; + buf = req ? "GET / HTTP/1.1\r\n" : "HTTP/1.0 200 OK\r\n"; + parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); + assert(parsed == strlen(buf)); + + buf = "header-key: header-value\r\n"; + size_t buflen = strlen(buf); + + int i; + for (i = 0; i < 10000; i++) { + parsed = http_parser_execute(&parser, &settings_null, buf, buflen); + if (parsed != buflen) { + //fprintf(stderr, "error found on iter %d\n", i); + assert(HTTP_PARSER_ERRNO(&parser) == HPE_HEADER_OVERFLOW); + return; + } + } + + fprintf(stderr, "\n*** Error expected but none in header overflow test ***\n"); + abort(); +} + +static void +test_content_length_overflow (const char *buf, size_t buflen, int expect_ok) +{ + http_parser parser; + http_parser_init(&parser, HTTP_RESPONSE); + http_parser_execute(&parser, &settings_null, buf, buflen); + + if (expect_ok) + assert(HTTP_PARSER_ERRNO(&parser) == HPE_OK); + else + assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_CONTENT_LENGTH); +} + +void +test_header_content_length_overflow_error (void) +{ +#define X(size) \ + "HTTP/1.1 200 OK\r\n" \ + "Content-Length: " #size "\r\n" \ + "\r\n" + const char a[] = X(18446744073709551614); /* 2^64-2 */ + const char b[] = X(18446744073709551615); /* 2^64-1 */ + const char c[] = X(18446744073709551616); /* 2^64 */ +#undef X + test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ + test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ + test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ +} + +void +test_chunk_content_length_overflow_error (void) +{ +#define X(size) \ + "HTTP/1.1 200 OK\r\n" \ + "Transfer-Encoding: chunked\r\n" \ + "\r\n" \ + #size "\r\n" \ + "..." + const char a[] = X(FFFFFFFFFFFFFFFE); /* 2^64-2 */ + const char b[] = X(FFFFFFFFFFFFFFFF); /* 2^64-1 */ + const char c[] = X(10000000000000000); /* 2^64 */ +#undef X + test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ + test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ + test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ +} + +void +test_no_overflow_long_body (int req, size_t length) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + size_t i; + char buf1[3000]; + size_t buf1len = sprintf(buf1, "%s\r\nConnection: Keep-Alive\r\nContent-Length: %lu\r\n\r\n", + req ? "POST / HTTP/1.0" : "HTTP/1.0 200 OK", (unsigned long)length); + parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); + if (parsed != buf1len) + goto err; + + for (i = 0; i < length; i++) { + char foo = 'a'; + parsed = http_parser_execute(&parser, &settings_null, &foo, 1); + if (parsed != 1) + goto err; + } + + parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); + if (parsed != buf1len) goto err; + return; + + err: + fprintf(stderr, + "\n*** error in test_no_overflow_long_body %s of length %lu ***\n", + req ? "REQUEST" : "RESPONSE", + (unsigned long)length); + abort(); +} + +void +test_multiple3 (const struct message *r1, const struct message *r2, const struct message *r3) +{ + int message_count = count_parsed_messages(3, r1, r2, r3); + + char total[ strlen(r1->raw) + + strlen(r2->raw) + + strlen(r3->raw) + + 1 + ]; + total[0] = '\0'; + + strcat(total, r1->raw); + strcat(total, r2->raw); + strcat(total, r3->raw); + + parser_init(r1->type); + + size_t read; + + read = parse(total, strlen(total)); + + if (parser->upgrade) { + upgrade_message_fix(total, read, 3, r1, r2, r3); + goto test; + } + + if (read != strlen(total)) { + print_error(total, read); + abort(); + } + + read = parse(NULL, 0); + + if (read != 0) { + print_error(total, read); + abort(); + } + +test: + + if (message_count != num_messages) { + fprintf(stderr, "\n\n*** Parser didn't see 3 messages only %d *** \n", num_messages); + abort(); + } + + if (!message_eq(0, r1)) abort(); + if (message_count > 1 && !message_eq(1, r2)) abort(); + if (message_count > 2 && !message_eq(2, r3)) abort(); + + parser_free(); +} + +/* SCAN through every possible breaking to make sure the + * parser can handle getting the content in any chunks that + * might come from the socket + */ +void +test_scan (const struct message *r1, const struct message *r2, const struct message *r3) +{ + char total[80*1024] = "\0"; + char buf1[80*1024] = "\0"; + char buf2[80*1024] = "\0"; + char buf3[80*1024] = "\0"; + + strcat(total, r1->raw); + strcat(total, r2->raw); + strcat(total, r3->raw); + + size_t read; + + int total_len = strlen(total); + + int total_ops = 2 * (total_len - 1) * (total_len - 2) / 2; + int ops = 0 ; + + size_t buf1_len, buf2_len, buf3_len; + int message_count = count_parsed_messages(3, r1, r2, r3); + + int i,j,type_both; + for (type_both = 0; type_both < 2; type_both ++ ) { + for (j = 2; j < total_len; j ++ ) { + for (i = 1; i < j; i ++ ) { + + if (ops % 1000 == 0) { + printf("\b\b\b\b%3.0f%%", 100 * (float)ops /(float)total_ops); + fflush(stdout); + } + ops += 1; + + parser_init(type_both ? HTTP_BOTH : r1->type); + + buf1_len = i; + strlncpy(buf1, sizeof(buf1), total, buf1_len); + buf1[buf1_len] = 0; + + buf2_len = j - i; + strlncpy(buf2, sizeof(buf1), total+i, buf2_len); + buf2[buf2_len] = 0; + + buf3_len = total_len - j; + strlncpy(buf3, sizeof(buf1), total+j, buf3_len); + buf3[buf3_len] = 0; + + read = parse(buf1, buf1_len); + + if (parser->upgrade) goto test; + + if (read != buf1_len) { + print_error(buf1, read); + goto error; + } + + read += parse(buf2, buf2_len); + + if (parser->upgrade) goto test; + + if (read != buf1_len + buf2_len) { + print_error(buf2, read); + goto error; + } + + read += parse(buf3, buf3_len); + + if (parser->upgrade) goto test; + + if (read != buf1_len + buf2_len + buf3_len) { + print_error(buf3, read); + goto error; + } + + parse(NULL, 0); + +test: + if (parser->upgrade) { + upgrade_message_fix(total, read, 3, r1, r2, r3); + } + + if (message_count != num_messages) { + fprintf(stderr, "\n\nParser didn't see %d messages only %d\n", + message_count, num_messages); + goto error; + } + + if (!message_eq(0, r1)) { + fprintf(stderr, "\n\nError matching messages[0] in test_scan.\n"); + goto error; + } + + if (message_count > 1 && !message_eq(1, r2)) { + fprintf(stderr, "\n\nError matching messages[1] in test_scan.\n"); + goto error; + } + + if (message_count > 2 && !message_eq(2, r3)) { + fprintf(stderr, "\n\nError matching messages[2] in test_scan.\n"); + goto error; + } + + parser_free(); + } + } + } + puts("\b\b\b\b100%"); + return; + + error: + fprintf(stderr, "i=%d j=%d\n", i, j); + fprintf(stderr, "buf1 (%u) %s\n\n", (unsigned int)buf1_len, buf1); + fprintf(stderr, "buf2 (%u) %s\n\n", (unsigned int)buf2_len , buf2); + fprintf(stderr, "buf3 (%u) %s\n", (unsigned int)buf3_len, buf3); + abort(); +} + +// user required to free the result +// string terminated by \0 +char * +create_large_chunked_message (int body_size_in_kb, const char* headers) +{ + int i; + size_t wrote = 0; + size_t headers_len = strlen(headers); + size_t bufsize = headers_len + (5+1024+2)*body_size_in_kb + 6; + char * buf = malloc(bufsize); + + memcpy(buf, headers, headers_len); + wrote += headers_len; + + for (i = 0; i < body_size_in_kb; i++) { + // write 1kb chunk into the body. + memcpy(buf + wrote, "400\r\n", 5); + wrote += 5; + memset(buf + wrote, 'C', 1024); + wrote += 1024; + strcpy(buf + wrote, "\r\n"); + wrote += 2; + } + + memcpy(buf + wrote, "0\r\n\r\n", 6); + wrote += 6; + assert(wrote == bufsize); + + return buf; +} + +/* Verify that we can pause parsing at any of the bytes in the + * message and still get the result that we're expecting. */ +void +test_message_pause (const struct message *msg) +{ + char *buf = (char*) msg->raw; + size_t buflen = strlen(msg->raw); + size_t nread; + + parser_init(msg->type); + + do { + nread = parse_pause(buf, buflen); + + // We can only set the upgrade buffer once we've gotten our message + // completion callback. + if (messages[0].message_complete_cb_called && + msg->upgrade && + parser->upgrade) { + messages[0].upgrade = buf + nread; + goto test; + } + + if (nread < buflen) { + + // Not much do to if we failed a strict-mode check + if (HTTP_PARSER_ERRNO(parser) == HPE_STRICT) { + parser_free(); + return; + } + + assert (HTTP_PARSER_ERRNO(parser) == HPE_PAUSED); + } + + buf += nread; + buflen -= nread; + http_parser_pause(parser, 0); + } while (buflen > 0); + + nread = parse_pause(NULL, 0); + assert (nread == 0); + +test: + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name); + abort(); + } + + if(!message_eq(0, msg)) abort(); + + parser_free(); +} + +int +main (void) +{ + parser = NULL; + int i, j, k; + int request_count; + int response_count; + + printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser)); + + for (request_count = 0; requests[request_count].name; request_count++); + for (response_count = 0; responses[response_count].name; response_count++); + + //// API + test_preserve_data(); + test_parse_url(); + test_method_str(); + + //// OVERFLOW CONDITIONS + + test_header_overflow_error(HTTP_REQUEST); + test_no_overflow_long_body(HTTP_REQUEST, 1000); + test_no_overflow_long_body(HTTP_REQUEST, 100000); + + test_header_overflow_error(HTTP_RESPONSE); + test_no_overflow_long_body(HTTP_RESPONSE, 1000); + test_no_overflow_long_body(HTTP_RESPONSE, 100000); + + test_header_content_length_overflow_error(); + test_chunk_content_length_overflow_error(); + + //// RESPONSES + + for (i = 0; i < response_count; i++) { + test_message(&responses[i]); + } + + for (i = 0; i < response_count; i++) { + test_message_pause(&responses[i]); + } + + for (i = 0; i < response_count; i++) { + if (!responses[i].should_keep_alive) continue; + for (j = 0; j < response_count; j++) { + if (!responses[j].should_keep_alive) continue; + for (k = 0; k < response_count; k++) { + test_multiple3(&responses[i], &responses[j], &responses[k]); + } + } + } + + test_message_count_body(&responses[NO_HEADERS_NO_BODY_404]); + test_message_count_body(&responses[TRAILING_SPACE_ON_CHUNKED_BODY]); + + // test very large chunked response + { + char * msg = create_large_chunked_message(31337, + "HTTP/1.0 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/plain\r\n" + "\r\n"); + struct message large_chunked = + {.name= "large chunked" + ,.type= HTTP_RESPONSE + ,.raw= msg + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 200 + ,.num_headers= 2 + ,.headers= + { { "Transfer-Encoding", "chunked" } + , { "Content-Type", "text/plain" } + } + ,.body_size= 31337*1024 + }; + test_message_count_body(&large_chunked); + free(msg); + } + + + + printf("response scan 1/2 "); + test_scan( &responses[TRAILING_SPACE_ON_CHUNKED_BODY] + , &responses[NO_BODY_HTTP10_KA_204] + , &responses[NO_REASON_PHRASE] + ); + + printf("response scan 2/2 "); + test_scan( &responses[BONJOUR_MADAME_FR] + , &responses[UNDERSTORE_HEADER_KEY] + , &responses[NO_CARRIAGE_RET] + ); + + puts("responses okay"); + + + /// REQUESTS + + test_simple("hello world", HPE_INVALID_METHOD); + test_simple("GET / HTP/1.1\r\n\r\n", HPE_INVALID_VERSION); + + + test_simple("ASDF / HTTP/1.1\r\n\r\n", HPE_INVALID_METHOD); + test_simple("PROPPATCHA / HTTP/1.1\r\n\r\n", HPE_INVALID_METHOD); + test_simple("GETA / HTTP/1.1\r\n\r\n", HPE_INVALID_METHOD); + + // Well-formed but incomplete + test_simple("GET / HTTP/1.1\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 6\r\n" + "\r\n" + "fooba", + HPE_OK); + + static const char *all_methods[] = { + "DELETE", + "GET", + "HEAD", + "POST", + "PUT", + //"CONNECT", //CONNECT can't be tested like other methods, it's a tunnel + "OPTIONS", + "TRACE", + "COPY", + "LOCK", + "MKCOL", + "MOVE", + "PROPFIND", + "PROPPATCH", + "UNLOCK", + "REPORT", + "MKACTIVITY", + "CHECKOUT", + "MERGE", + "M-SEARCH", + "NOTIFY", + "SUBSCRIBE", + "UNSUBSCRIBE", + "PATCH", + 0 }; + const char **this_method; + for (this_method = all_methods; *this_method; this_method++) { + char buf[200]; + sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); + test_simple(buf, HPE_OK); + } + + static const char *bad_methods[] = { + "C******", + "M****", + 0 }; + for (this_method = bad_methods; *this_method; this_method++) { + char buf[200]; + sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); + test_simple(buf, HPE_UNKNOWN); + } + + const char *dumbfuck2 = + "GET / HTTP/1.1\r\n" + "X-SSL-Bullshit: -----BEGIN CERTIFICATE-----\r\n" + "\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\r\n" + "\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\r\n" + "\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\r\n" + "\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\r\n" + "\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\r\n" + "\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\r\n" + "\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\r\n" + "\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\r\n" + "\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\r\n" + "\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0fr+RQjYOUUfrePP\r\n" + "\tu2MSpFyf+9BbC/aXgaZuiCvSR+8Snv3xApQY+fULK/xY8h8Ua51iXoQ5jrgu2SqR\r\n" + "\twgA7BUi3G8LFzMBl8FRCDYGUDy7M6QaHXx1ZWIPWNKsCAwEAAaOCAiQwggIgMAwG\r\n" + "\tA1UdEwEB/wQCMAAwEQYJYIZIAYb4QgHTTPAQDAgWgMA4GA1UdDwEB/wQEAwID6DAs\r\n" + "\tBglghkgBhvhCAQ0EHxYdVUsgZS1TY2llbmNlIFVzZXIgQ2VydGlmaWNhdGUwHQYD\r\n" + "\tVR0OBBYEFDTt/sf9PeMaZDHkUIldrDYMNTBZMIGaBgNVHSMEgZIwgY+AFAI4qxGj\r\n" + "\tloCLDdMVKwiljjDastqooXSkcjBwMQswCQYDVQQGEwJVSzERMA8GA1UEChMIZVNj\r\n" + "\taWVuY2UxEjAQBgNVBAsTCUF1dGhvcml0eTELMAkGA1UEAxMCQ0ExLTArBgkqhkiG\r\n" + "\t9w0BCQEWHmNhLW9wZXJhdG9yQGdyaWQtc3VwcG9ydC5hYy51a4IBADApBgNVHRIE\r\n" + "\tIjAggR5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMudWswGQYDVR0gBBIwEDAO\r\n" + "\tBgwrBgEEAdkvAQEBAQYwPQYJYIZIAYb4QgEEBDAWLmh0dHA6Ly9jYS5ncmlkLXN1\r\n" + "\tcHBvcnQuYWMudmT4sopwqlBWsvcHViL2NybC9jYWNybC5jcmwwPQYJYIZIAYb4QgEDBDAWLmh0\r\n" + "\tdHA6Ly9jYS5ncmlkLXN1cHBvcnQuYWMudWsvcHViL2NybC9jYWNybC5jcmwwPwYD\r\n" + "\tVR0fBDgwNjA0oDKgMIYuaHR0cDovL2NhLmdyaWQt5hYy51ay9wdWIv\r\n" + "\tY3JsL2NhY3JsLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAS/U4iiooBENGW/Hwmmd3\r\n" + "\tXCy6Zrt08YjKCzGNjorT98g8uGsqYjSxv/hmi0qlnlHs+k/3Iobc3LjS5AMYr5L8\r\n" + "\tUO7OSkgFFlLHQyC9JzPfmLCAugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\r\n" + "\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\r\n" + "\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\r\n" + "\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\r\n" + "\tRA==\r\n" + "\t-----END CERTIFICATE-----\r\n" + "\r\n"; + test_simple(dumbfuck2, HPE_OK); + +#if 0 + // NOTE(Wed Nov 18 11:57:27 CET 2009) this seems okay. we just read body + // until EOF. + // + // no content-length + // error if there is a body without content length + const char *bad_get_no_headers_no_body = "GET /bad_get_no_headers_no_body/world HTTP/1.1\r\n" + "Accept: */*\r\n" + "\r\n" + "HELLO"; + test_simple(bad_get_no_headers_no_body, 0); +#endif + /* TODO sending junk and large headers gets rejected */ + + + /* check to make sure our predefined requests are okay */ + for (i = 0; requests[i].name; i++) { + test_message(&requests[i]); + } + + for (i = 0; i < request_count; i++) { + test_message_pause(&requests[i]); + } + + for (i = 0; i < request_count; i++) { + if (!requests[i].should_keep_alive) continue; + for (j = 0; j < request_count; j++) { + if (!requests[j].should_keep_alive) continue; + for (k = 0; k < request_count; k++) { + test_multiple3(&requests[i], &requests[j], &requests[k]); + } + } + } + + printf("request scan 1/4 "); + test_scan( &requests[GET_NO_HEADERS_NO_BODY] + , &requests[GET_ONE_HEADER_NO_BODY] + , &requests[GET_NO_HEADERS_NO_BODY] + ); + + printf("request scan 2/4 "); + test_scan( &requests[POST_CHUNKED_ALL_YOUR_BASE] + , &requests[POST_IDENTITY_BODY_WORLD] + , &requests[GET_FUNKY_CONTENT_LENGTH] + ); + + printf("request scan 3/4 "); + test_scan( &requests[TWO_CHUNKS_MULT_ZERO_END] + , &requests[CHUNKED_W_TRAILING_HEADERS] + , &requests[CHUNKED_W_BULLSHIT_AFTER_LENGTH] + ); + + printf("request scan 4/4 "); + test_scan( &requests[QUERY_URL_WITH_QUESTION_MARK_GET] + , &requests[PREFIX_NEWLINE_GET ] + , &requests[CONNECT_REQUEST] + ); + + puts("requests okay"); + + return 0; +} diff --git a/src/http/qhttpserver/http-parser/url_parser.c b/src/http/qhttpserver/http-parser/url_parser.c new file mode 100644 index 000000000..b1f9c979f --- /dev/null +++ b/src/http/qhttpserver/http-parser/url_parser.c @@ -0,0 +1,44 @@ +#include "http_parser.h" +#include +#include + +void +dump_url (const char *url, const struct http_parser_url *u) +{ + unsigned int i; + + printf("\tfield_set: 0x%x, port: %u\n", u->field_set, u->port); + for (i = 0; i < UF_MAX; i++) { + if ((u->field_set & (1 << i)) == 0) { + printf("\tfield_data[%u]: unset\n", i); + continue; + } + + printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n", + i, + u->field_data[i].off, + u->field_data[i].len, + u->field_data[i].len, + url + u->field_data[i].off); + } +} + +int main(int argc, char ** argv) { + if (argc != 3) { + printf("Syntax : %s connect|get url\n", argv[0]); + return 1; + } + struct http_parser_url u; + int len = strlen(argv[2]); + int connect = strcmp("connect", argv[1]) == 0 ? 1 : 0; + printf("Parsing %s, connect %d\n", argv[2], connect); + + int result = http_parser_parse_url(argv[2], len, connect, &u); + if (result != 0) { + printf("Parse error : %d\n", result); + return result; + } + printf("Parse ok, result : \n"); + dump_url(argv[2], &u); + return 0; +} \ No newline at end of file diff --git a/src/http/qhttpserver/qhttpconnection.cpp b/src/http/qhttpserver/qhttpconnection.cpp new file mode 100644 index 000000000..5685dfd32 --- /dev/null +++ b/src/http/qhttpserver/qhttpconnection.cpp @@ -0,0 +1,202 @@ +/* + * Copyright 2011 Nikhil Marathe + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "qhttpconnection.h" + +#include +#include +#include + +#include "qhttprequest.h" +#include "qhttpresponse.h" + +QHttpConnection::QHttpConnection(QTcpSocket *socket, QObject *parent) + : QObject(parent) + , m_socket(socket) + , m_parser(0) + , m_request(0) +{ + qDebug() << "Got new connection" << socket->peerAddress() << socket->peerPort(); + + m_parser = (http_parser*)malloc(sizeof(http_parser)); + http_parser_init(m_parser, HTTP_REQUEST); + + m_parserSettings.on_message_begin = MessageBegin; + m_parserSettings.on_url = Url; + m_parserSettings.on_header_field = HeaderField; + m_parserSettings.on_header_value = HeaderValue; + m_parserSettings.on_headers_complete = HeadersComplete; + m_parserSettings.on_body = Body; + m_parserSettings.on_message_complete = MessageComplete; + + m_parser->data = this; + + connect(socket, SIGNAL(readyRead()), this, SLOT(parseRequest())); + connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); +} + +QHttpConnection::~QHttpConnection() +{ + delete m_socket; + m_socket = 0; + + free(m_parser); + m_parser = 0; +} + +void QHttpConnection::socketDisconnected() +{ + if(m_request) { + if(m_request->successful()) { + return; + } + m_request->setSuccessful(false); + Q_EMIT m_request->end(); + } + + deleteLater(); +} + +void QHttpConnection::parseRequest() +{ + Q_ASSERT(m_parser); + + while(m_socket->bytesAvailable()) + { + QByteArray arr = m_socket->readAll(); + http_parser_execute(m_parser, &m_parserSettings, arr.constData(), arr.size()); + } +} + +void QHttpConnection::write(const QByteArray &data) +{ + m_socket->write(data); +} + +void QHttpConnection::flush() +{ + m_socket->flush(); +} + +/******************** + * Static Callbacks * + *******************/ +int QHttpConnection::MessageBegin(http_parser *parser) +{ + QHttpConnection *theConnection = (QHttpConnection *)parser->data; + theConnection->m_currentHeaders.clear(); + theConnection->m_request = new QHttpRequest(theConnection); + return 0; +} + +int QHttpConnection::HeadersComplete(http_parser *parser) +{ + QHttpConnection *theConnection = (QHttpConnection *)parser->data; + Q_ASSERT(theConnection->m_request); + + /** set method **/ + theConnection->m_request->setMethod(static_cast(parser->method)); + + /** set version **/ + theConnection->m_request->setVersion(QString("%1.%2").arg(parser->http_major).arg(parser->http_minor)); + + // Insert last remaining header + theConnection->m_currentHeaders[theConnection->m_currentHeaderField.toLower()] = theConnection->m_currentHeaderValue; + theConnection->m_request->setHeaders(theConnection->m_currentHeaders); + + /** set client information **/ + theConnection->m_request->m_remoteAddress = theConnection->m_socket->peerAddress().toString(); + theConnection->m_request->m_remotePort = theConnection->m_socket->peerPort(); + + QHttpResponse *response = new QHttpResponse(theConnection); + if( parser->http_major < 1 || parser->http_minor < 1 ) + response->m_keepAlive = false; + + connect(theConnection, SIGNAL(destroyed()), response, SLOT(connectionClosed())); + + // we are good to go! + Q_EMIT theConnection->newRequest(theConnection->m_request, response); + return 0; +} + +int QHttpConnection::MessageComplete(http_parser *parser) +{ + // TODO: do cleanup and prepare for next request + QHttpConnection *theConnection = (QHttpConnection *)parser->data; + Q_ASSERT(theConnection->m_request); + + theConnection->m_request->setSuccessful(true); + Q_EMIT theConnection->m_request->end(); + return 0; +} + +int QHttpConnection::Url(http_parser *parser, const char *at, size_t length) +{ + QHttpConnection *theConnection = (QHttpConnection *)parser->data; + Q_ASSERT(theConnection->m_request); + + QString url = QString::fromAscii(at, length); + theConnection->m_request->setUrl(QUrl(url)); + return 0; +} + +int QHttpConnection::HeaderField(http_parser *parser, const char *at, size_t length) +{ + QHttpConnection *theConnection = (QHttpConnection *)parser->data; + Q_ASSERT(theConnection->m_request); + + // insert the header we parsed previously + // into the header map + if( !theConnection->m_currentHeaderField.isEmpty() && !theConnection->m_currentHeaderValue.isEmpty() ) + { + // header names are always lower-cased + theConnection->m_currentHeaders[theConnection->m_currentHeaderField.toLower()] = theConnection->m_currentHeaderValue; + // clear header value. this sets up a nice + // feedback loop where the next time + // HeaderValue is called, it can simply append + theConnection->m_currentHeaderField = QString(); + theConnection->m_currentHeaderValue = QString(); + } + + QString fieldSuffix = QString::fromAscii(at, length); + theConnection->m_currentHeaderField += fieldSuffix; + return 0; +} + +int QHttpConnection::HeaderValue(http_parser *parser, const char *at, size_t length) +{ + QHttpConnection *theConnection = (QHttpConnection *)parser->data; + Q_ASSERT(theConnection->m_request); + + QString valueSuffix = QString::fromAscii(at, length); + theConnection->m_currentHeaderValue += valueSuffix; + return 0; +} + +int QHttpConnection::Body(http_parser *parser, const char *at, size_t length) +{ + QHttpConnection *theConnection = (QHttpConnection *)parser->data; + Q_ASSERT(theConnection->m_request); + + Q_EMIT theConnection->m_request->data(QByteArray(at, length)); + return 0; +} diff --git a/src/http/qhttpserver/qhttpconnection.h b/src/http/qhttpserver/qhttpconnection.h new file mode 100644 index 000000000..451fe642a --- /dev/null +++ b/src/http/qhttpserver/qhttpconnection.h @@ -0,0 +1,80 @@ +/* + * Copyright 2011 Nikhil Marathe + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef Q_HTTP_CONNECTION +#define Q_HTTP_CONNECTION + +#include +#include + +#include "http_parser.h" + +class QTcpSocket; + +class QHttpRequest; +class QHttpResponse; + +typedef QHash HeaderHash; + +class QHttpConnection : public QObject +{ + Q_OBJECT + +public: + QHttpConnection(QTcpSocket *socket, QObject *parent = 0); + virtual ~QHttpConnection(); + + void write(const QByteArray &data); + void flush(); + +Q_SIGNALS: + void newRequest(QHttpRequest*, QHttpResponse*); + +private Q_SLOTS: + void parseRequest(); + void socketDisconnected(); + +private: + static int MessageBegin(http_parser *parser); + static int Url(http_parser *parser, const char *at, size_t length); + static int HeaderField(http_parser *parser, const char *at, size_t length); + static int HeaderValue(http_parser *parser, const char *at, size_t length); + static int HeadersComplete(http_parser *parser); + static int Body(http_parser *parser, const char *at, size_t length); + static int MessageComplete(http_parser *parser); + +private: + QTcpSocket *m_socket; + http_parser_settings m_parserSettings; + http_parser *m_parser; + + // since there can only be one request at any time + // even with pipelining + QHttpRequest *m_request; + + // the ones we are reading in from the parser + HeaderHash m_currentHeaders; + QString m_currentHeaderField; + QString m_currentHeaderValue; +}; + +#endif diff --git a/src/http/qhttpserver/qhttprequest.cpp b/src/http/qhttpserver/qhttprequest.cpp new file mode 100644 index 000000000..2ebd38834 --- /dev/null +++ b/src/http/qhttpserver/qhttprequest.cpp @@ -0,0 +1,38 @@ +/* + * Copyright 2011 Nikhil Marathe + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "qhttprequest.h" + +#include "qhttpconnection.h" + +QHttpRequest::QHttpRequest(QHttpConnection *connection, QObject *parent) + : QObject(parent) + , m_connection(connection) + , m_url("http://localhost/") + , m_success(false) +{ +} + +QHttpRequest::~QHttpRequest() +{ +} + diff --git a/src/http/qhttpserver/qhttprequest.h b/src/http/qhttpserver/qhttprequest.h new file mode 100644 index 000000000..23747169d --- /dev/null +++ b/src/http/qhttpserver/qhttprequest.h @@ -0,0 +1,245 @@ +/* + * Copyright 2011 Nikhil Marathe + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef Q_HTTP_REQUEST +#define Q_HTTP_REQUEST + +#include +#include +#include +#include +#include + +class QTcpSocket; + +class QHttpConnection; + +typedef QHash HeaderHash; + +/* Request Methods */ + +/*! \class QHttpRequest + * + * The QHttpRequest class represents the header and data + * sent by the client. + * + * Header data is available immediately. + * + * Body data is streamed as it comes in via the data(const QByteArray&) signal. + * As a consequence the application's request callback should ensure that it + * connects to the data() signal before control returns back to the event loop. + * Otherwise there is a risk of some data never being received by the + * application. + * + * The class is read-only by users of %QHttpServer. + */ +class QHttpRequest : public QObject +{ + Q_OBJECT + + Q_PROPERTY(HeaderHash headers READ headers); + Q_PROPERTY(QString remoteAddress READ remoteAddress); + Q_PROPERTY(quint16 remotePort READ remotePort); + Q_PROPERTY(QString method READ method); + Q_PROPERTY(QUrl url READ url); + Q_PROPERTY(QString path READ path); + Q_PROPERTY(QString httpVersion READ httpVersion); + Q_ENUMS(HttpMethod); + +public: + virtual ~QHttpRequest(); + + /*! + * Request Methods + * Taken from http_parser.h -- make sure to keep synced + */ + enum HttpMethod { + HTTP_DELETE = 0, + HTTP_GET, + HTTP_HEAD, + HTTP_POST, + HTTP_PUT, + /* pathological */ + HTTP_CONNECT, + HTTP_OPTIONS, + HTTP_TRACE, + /* webdav */ + HTTP_COPY, + HTTP_LOCK, + HTTP_MKCOL, + HTTP_MOVE, + HTTP_PROPFIND, + HTTP_PROPPATCH, + HTTP_SEARCH, + HTTP_UNLOCK, + /* subversion */ + HTTP_REPORT, + HTTP_MKACTIVITY, + HTTP_CHECKOUT, + HTTP_MERGE, + /* upnp */ + HTTP_MSEARCH, + HTTP_NOTIFY, + HTTP_SUBSCRIBE, + HTTP_UNSUBSCRIBE, + /* RFC-5789 */ + HTTP_PATCH, + HTTP_PURGE + }; + + /*! + * Returns the method string for the request + */ + const QString methodString() const { return MethodToString(method()); } + + /*! + * The method used for the request. + */ + HttpMethod method() const { return m_method; }; + + /*! + * The complete URL for the request. This + * includes the path and query string. + * + */ + const QUrl& url() const { return m_url; }; + + /*! + * The path portion of the query URL. + * + * \sa url() + */ + const QString path() const { return m_url.path(); }; + + /*! + * The HTTP version used by the client as a + * 'x.x' string. + */ + const QString& httpVersion() const { return m_version; }; + + /*! + * Any query string included as part of a request. + * Usually used to send data in a GET request. + */ + const QString& queryString() const; + + /*! + * Get a hash of the headers sent by the client. + * NOTE: All header names are lowercase + * so that Content-Length becomes content-length and so on. + * + * This returns a reference! If you want to store headers + * somewhere else, where the request may be deleted, + * make sure you store them as a copy. + */ + const HeaderHash& headers() const { return m_headers; }; + + /*! + * Get the value of a header + * + * \param field Name of the header field (lowercase). + * \return Value of the header or null QString() + */ + QString header(const QString &field) { return m_headers[field]; }; + + /*! + * IP Address of the client in dotted decimal format + */ + const QString& remoteAddress() const { return m_remoteAddress; }; + + /*! + * Outbound connection port for the client. + */ + quint16 remotePort() const { return m_remotePort; }; + + /*! + * Post data + */ + const QByteArray &body() const { return m_body; } + + /*! + * Set immediately before end has been emitted, + * stating whether the message was properly received. + * Defaults to false untiil the message has completed. + */ + bool successful() const { return m_success; } + + /*! + * connect to data and store all data in a QByteArray + * accessible at body() + */ + void storeBody() + { + connect(this, SIGNAL(data(const QByteArray &)), + this, SLOT(appendBody(const QByteArray &)), + Qt::UniqueConnection); + } + +Q_SIGNALS: + /*! + * This signal is emitted whenever body data is encountered + * in a message. + * This may be emitted zero or more times. + */ + void data(const QByteArray &); + + /*! + * Emitted at the end of the HTTP request. + * No data() signals will be emitted after this. + */ + void end(); + +private: + QHttpRequest(QHttpConnection *connection, QObject *parent = 0); + + static QString MethodToString(HttpMethod method) + { + int index = staticMetaObject.indexOfEnumerator("HttpMethod"); + return staticMetaObject.enumerator(index).valueToKey(method); + } + + void setMethod(HttpMethod method) { m_method = method; } + void setVersion(const QString &version) { m_version = version; } + void setUrl(const QUrl &url) { m_url = url; } + void setHeaders(const HeaderHash headers) { m_headers = headers; } + void setSuccessful(bool success) { m_success = success; } + + QHttpConnection *m_connection; + HeaderHash m_headers; + HttpMethod m_method; + QUrl m_url; + QString m_version; + QString m_remoteAddress; + quint16 m_remotePort; + QByteArray m_body; + bool m_success; + + friend class QHttpConnection; + + private Q_SLOTS: + void appendBody(const QByteArray &body) + { + m_body.append(body); + } +}; + +#endif diff --git a/src/http/qhttpserver/qhttpresponse.cpp b/src/http/qhttpserver/qhttpresponse.cpp new file mode 100644 index 000000000..a713c12f1 --- /dev/null +++ b/src/http/qhttpserver/qhttpresponse.cpp @@ -0,0 +1,193 @@ +/* + * Copyright 2011 Nikhil Marathe + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "qhttpresponse.h" + +#include + +#include "qhttpserver.h" +#include "qhttpconnection.h" + +QHttpResponse::QHttpResponse(QHttpConnection *connection) + // TODO: parent child relation + : QObject(0) + , m_connection(connection) + , m_headerWritten(false) + , m_sentConnectionHeader(false) + , m_sentContentLengthHeader(false) + , m_sentTransferEncodingHeader(false) + , m_sentDate(false) + , m_keepAlive(true) + , m_last(false) + , m_useChunkedEncoding(false) + , m_finished(false) +{ +} + +QHttpResponse::~QHttpResponse() +{ +} + +void QHttpResponse::setHeader(const QString &field, const QString &value) +{ + if(m_finished) { + return; + } + + m_headers[field] = value; +} + +void QHttpResponse::writeHeader(const char *field, const QString &value) +{ + if(m_finished) { + return; + } + + m_connection->write(field); + m_connection->write(": "); + m_connection->write(value.toUtf8()); + m_connection->write("\r\n"); +} + +void QHttpResponse::writeHeaders() +{ + if(m_finished) { + return; + } + + Q_FOREACH(QString name, m_headers.keys()) + { + QString value = m_headers[name]; + if( name.compare("connection", Qt::CaseInsensitive) == 0 ) + { + m_sentConnectionHeader = true; + if( value == "close" ) + m_last = true; + else + m_keepAlive = true; + } + else if( name.compare("transfer-encoding", Qt::CaseInsensitive) == 0 ) + { + m_sentTransferEncodingHeader = true; + if( value == "chunked" ) + m_useChunkedEncoding = true; + } + else if( name.compare("content-length", Qt::CaseInsensitive) == 0 ) + { + m_sentContentLengthHeader = true; + } + else if( name.compare("date", Qt::CaseInsensitive) == 0 ) + { + m_sentDate = true; + } + //TODO: Expect case + + writeHeader(name.toAscii(), value.toAscii()); + } + + if( !m_sentConnectionHeader ) + { + if( m_keepAlive && + ( m_sentContentLengthHeader || m_useChunkedEncoding ) ) + { + writeHeader("Connection", "keep-alive"); + } + else + { + m_last = true; + writeHeader("Connection", "close"); + } + } + + if( !m_sentContentLengthHeader && !m_sentTransferEncodingHeader ) + { + if( m_useChunkedEncoding ) + writeHeader("Transfer-Encoding", "chunked"); + else + m_last = true; + } + + if( !m_sentDate ) + { + writeHeader("Date", QDateTime::currentDateTimeUtc().toString("ddd, dd MMM yyyy hh:mm:ss G'M'T")); + } +} + +void QHttpResponse::writeHead(int status) +{ + if(m_finished) { + return; + } + + if( m_headerWritten ) return; + + m_connection->write(QString("HTTP/1.1 %1 %2\r\n").arg(status).arg(STATUS_CODES[status]).toAscii()); + + writeHeaders(); + + m_connection->write("\r\n"); + m_headerWritten = true; +} + +void QHttpResponse::write(const QByteArray &data) +{ + if(m_finished) { + return; + } + + if( !m_headerWritten ) + { + qDebug() << "You MUST call writeHead() before writing body data"; + return; + } + + m_connection->write(data); +} + +void QHttpResponse::write(const QString &data) +{ + if(m_finished) { + return; + } + + m_connection->write(data.toUtf8()); +} + +void QHttpResponse::end(const QString &data) +{ + if(m_finished) { + return; + } + m_finished = true; + + write(data); + + Q_EMIT done(); + deleteLater(); + // TODO: end connection and delete ourselves +} + +void QHttpResponse::connectionClosed() +{ + m_finished = true; + deleteLater(); +} diff --git a/src/http/qhttpserver/qhttpresponse.h b/src/http/qhttpserver/qhttpresponse.h new file mode 100644 index 000000000..40a92c271 --- /dev/null +++ b/src/http/qhttpserver/qhttpresponse.h @@ -0,0 +1,174 @@ +/* + * Copyright 2011 Nikhil Marathe + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef Q_HTTP_RESPONSE +#define Q_HTTP_RESPONSE + +#include +#include + +// +class QTcpSocket; + +class QHttpConnection; + +typedef QHash HeaderHash; + +/*! + * The QHttpResponse class handles sending + * data back to the client in response to a request. + * + * The way to respond is to: + *
    + *
  1. Set headers (optional).
  2. + *
  3. Call writeHead() with the HTTP status code.
  4. + *
  5. Call write() zero or more times.
  6. + *
  7. Call end() when you are ready to end the request.
  8. + *
+ * + */ +class QHttpResponse : public QObject +{ + Q_OBJECT + +public: + enum StatusCode { + STATUS_CONTINUE = 100, + STATUS_SWITCH_PROTOCOLS = 101, + STATUS_OK = 200, + STATUS_CREATED = 201, + STATUS_ACCEPTED = 202, + STATUS_NON_AUTHORITATIVE_INFORMATION = 203, + STATUS_NO_CONTENT = 204, + STATUS_RESET_CONTENT = 205, + STATUS_PARTIAL_CONTENT = 206, + STATUS_MULTIPLE_CHOICES = 300, + STATUS_MOVED_PERMANENTLY = 301, + STATUS_FOUND = 302, + STATUS_SEE_OTHER = 303, + STATUS_NOT_MODIFIED = 304, + STATUS_USE_PROXY = 305, + STATUS_TEMPORARY_REDIRECT = 307, + STATUS_BAD_REQUEST = 400, + STATUS_UNAUTHORIZED = 401, + STATUS_PAYMENT_REQUIRED = 402, + STATUS_FORBIDDEN = 403, + STATUS_NOT_FOUND = 404, + STATUS_METHOD_NOT_ALLOWED = 405, + STATUS_NOT_ACCEPTABLE = 406, + STATUS_PROXY_AUTHENTICATION_REQUIRED = 407, + STATUS_REQUEST_TIMEOUT = 408, + STATUS_CONFLICT = 409, + STATUS_GONE = 410, + STATUS_LENGTH_REQUIRED = 411, + STATUS_PRECONDITION_FAILED = 412, + STATUS_REQUEST_ENTITY_TOO_LARGE = 413, + STATUS_REQUEST_URI_TOO_LONG = 414, + STATUS_REQUEST_UNSUPPORTED_MEDIA_TYPE = 415, + STATUS_REQUESTED_RANGE_NOT_SATISFIABLE = 416, + STATUS_EXPECTATION_FAILED = 417, + STATUS_INTERNAL_SERVER_ERROR = 500, + STATUS_NOT_IMPLEMENTED = 501, + STATUS_BAD_GATEWAY = 502, + STATUS_SERVICE_UNAVAILABLE = 503, + STATUS_GATEWAY_TIMEOUT = 504, + STATUS_HTTP_VERSION_NOT_SUPPORTED = 505 + }; + + virtual ~QHttpResponse(); + +public Q_SLOTS: + /*! + * Write the header of the response + * using @c status as the response status + * code. Any headers should be set before this + * is called. + */ + void writeHead(int status); + + /*! + * Write the block of data to the client. + * + * \note + * writeHead() has to be called before write(), otherwise the call will + * fail. + */ + void write(const QByteArray &data); + + /*! + * Write a QString instead of a QByteArray. + * \see write(const QByteArray &); + */ + void write(const QString &data); + + /*! + * End the response. Data will be flushed + * to the underlying socket and the connection + * itself will be closed if this is the last + * response. + * + * This will emit done() and queue this object + * for deletion. For details see \ref memorymanagement + */ + void end(const QString &data=QString()); + + /*! + * Set a response header @c field to @c value + */ + void setHeader(const QString &field, const QString &value); + +Q_SIGNALS: + /*! + * Emitted once the response is finished. + * You should NOT interact with this object + * after done() has been emitted as the object + * is scheduled for deletion at any time. + */ + void done(); + +private: + QHttpResponse(QHttpConnection *connection); + + void writeHeaders(); + void writeHeader(const char *field, const QString &value); + + QHttpConnection *m_connection; + + bool m_headerWritten; + HeaderHash m_headers; + friend class QHttpConnection; + + bool m_sentConnectionHeader; + bool m_sentContentLengthHeader; + bool m_sentTransferEncodingHeader; + bool m_sentDate; + bool m_keepAlive; + bool m_last; + bool m_useChunkedEncoding; + bool m_finished; + +private Q_SLOTS: + void connectionClosed(); + +}; + +#endif diff --git a/src/http/qhttpserver/qhttpserver.cpp b/src/http/qhttpserver/qhttpserver.cpp new file mode 100644 index 000000000..13d62e33d --- /dev/null +++ b/src/http/qhttpserver/qhttpserver.cpp @@ -0,0 +1,125 @@ +/* + * Copyright 2011 Nikhil Marathe + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "qhttpserver.h" + +#include +#include +#include +#include + +#include "qhttpconnection.h" + +QHash STATUS_CODES; + +QHttpServer::QHttpServer(QObject *parent) + : QObject(parent) + , m_tcpServer(0) +{ +#define STATUS_CODE(num, reason) STATUS_CODES.insert(num, reason); +// {{{ + STATUS_CODE(100, "Continue") + STATUS_CODE(101, "Switching Protocols") + STATUS_CODE(102, "Processing") // RFC 2518) obsoleted by RFC 4918 + STATUS_CODE(200, "OK") + STATUS_CODE(201, "Created") + STATUS_CODE(202, "Accepted") + STATUS_CODE(203, "Non-Authoritative Information") + STATUS_CODE(204, "No Content") + STATUS_CODE(205, "Reset Content") + STATUS_CODE(206, "Partial Content") + STATUS_CODE(207, "Multi-Status") // RFC 4918 + STATUS_CODE(300, "Multiple Choices") + STATUS_CODE(301, "Moved Permanently") + STATUS_CODE(302, "Moved Temporarily") + STATUS_CODE(303, "See Other") + STATUS_CODE(304, "Not Modified") + STATUS_CODE(305, "Use Proxy") + STATUS_CODE(307, "Temporary Redirect") + STATUS_CODE(400, "Bad Request") + STATUS_CODE(401, "Unauthorized") + STATUS_CODE(402, "Payment Required") + STATUS_CODE(403, "Forbidden") + STATUS_CODE(404, "Not Found") + STATUS_CODE(405, "Method Not Allowed") + STATUS_CODE(406, "Not Acceptable") + STATUS_CODE(407, "Proxy Authentication Required") + STATUS_CODE(408, "Request Time-out") + STATUS_CODE(409, "Conflict") + STATUS_CODE(410, "Gone") + STATUS_CODE(411, "Length Required") + STATUS_CODE(412, "Precondition Failed") + STATUS_CODE(413, "Request Entity Too Large") + STATUS_CODE(414, "Request-URI Too Large") + STATUS_CODE(415, "Unsupported Media Type") + STATUS_CODE(416, "Requested Range Not Satisfiable") + STATUS_CODE(417, "Expectation Failed") + STATUS_CODE(418, "I\"m a teapot") // RFC 2324 + STATUS_CODE(422, "Unprocessable Entity") // RFC 4918 + STATUS_CODE(423, "Locked") // RFC 4918 + STATUS_CODE(424, "Failed Dependency") // RFC 4918 + STATUS_CODE(425, "Unordered Collection") // RFC 4918 + STATUS_CODE(426, "Upgrade Required") // RFC 2817 + STATUS_CODE(500, "Internal Server Error") + STATUS_CODE(501, "Not Implemented") + STATUS_CODE(502, "Bad Gateway") + STATUS_CODE(503, "Service Unavailable") + STATUS_CODE(504, "Gateway Time-out") + STATUS_CODE(505, "HTTP Version not supported") + STATUS_CODE(506, "Variant Also Negotiates") // RFC 2295 + STATUS_CODE(507, "Insufficient Storage") // RFC 4918 + STATUS_CODE(509, "Bandwidth Limit Exceeded") + STATUS_CODE(510, "Not Extended") // RFC 2774 +// }}} +} + +QHttpServer::~QHttpServer() +{ +} + +void QHttpServer::newConnection() +{ + Q_ASSERT(m_tcpServer); + while(m_tcpServer->hasPendingConnections()) { + QHttpConnection *connection = new QHttpConnection(m_tcpServer->nextPendingConnection(), this); + connect(connection, SIGNAL(newRequest(QHttpRequest*, QHttpResponse*)), + this, SIGNAL(newRequest(QHttpRequest*, QHttpResponse*))); + } +} + +bool QHttpServer::listen(const QHostAddress &address, quint16 port) +{ + m_tcpServer = new QTcpServer; + + connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection())); + return m_tcpServer->listen(address, port); +} + +bool QHttpServer::listen(quint16 port) +{ + return listen(QHostAddress::Any, port); +} + +void QHttpServer::close() +{ + m_tcpServer->close(); +} diff --git a/src/http/qhttpserver/qhttpserver.h b/src/http/qhttpserver/qhttpserver.h new file mode 100644 index 000000000..bfe88051e --- /dev/null +++ b/src/http/qhttpserver/qhttpserver.h @@ -0,0 +1,230 @@ +/* + * Copyright 2011 Nikhil Marathe + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef Q_HTTP_SERVER +#define Q_HTTP_SERVER + +#define QHTTPSERVER_VERSION_MAJOR 0 +#define QHTTPSERVER_VERSION_MINOR 1 +#define QHTTPSERVER_VERSION_PATCH 0 + +#include +#include + +class QTcpServer; + +class QHttpRequest; +class QHttpResponse; + +/*! + * A map of request or response headers + */ +typedef QHash HeaderHash; + +/*! + * Maps status codes to string reason phrases + */ +extern QHash STATUS_CODES; + +/*! \mainpage %QHttpServer Documentation + * + * \section introduction Introduction + * + * %QHttpServer is a easy to use, fast and light-weight + * HTTP Server suitable for C++ web applications backed + * by Qt. Since C++ web applications are pretty uncommon + * the market for this project is pretty low. + * + * But integrating this with a module like QtScript + * and using it to write JavaScript web applications is + * a tempting possibility, and something that I want to + * demonstrate at conf.kde.in 2011. + * + * %QHttpServer uses a signal-slots based mechanism + * for all communication, so no inheritance is required. + * It tries to be as asynchronous as possible, to the + * extent that request body data is also delivered as and + * when it is received over the socket via signals. This + * kind of programming may take some getting used to. + * + * %QHttpServer is backed by Ryan + * Dahl's secure and fast http parser which makes it streaming + * till the lowest level. + * + * \section usage Usage + * + * Using %QHttpServer is very simple. Simply create a QHttpServer, + * connect a slot to the newRequest() signal and use the request and + * response objects. + * See the QHttpServer class documentation for an example. + * + * \example helloworld/helloworld.cpp + * \example helloworld/helloworld.h + * \example greeting/greeting.cpp + * \example greeting/greeting.h + * \example bodydata/bodydata.cpp + * \example bodydata/bodydata.h + */ + +/*! \class QHttpServer + * The QHttpServer class forms the basis of the %QHttpServer + * project. It is a fast, non-blocking HTTP server. + * + * These are the steps to create a server and respond to requests. + * + *
    + *
  1. Create an instance of QHttpServer.
  2. + *
  3. Connect a slot to the newRequest(QHttpRequest*, QHttpResponse*) + * signal.
  4. + *
  5. Create a QCoreApplication to drive the server event loop.
  6. + *
  7. Respond to clients by writing out to the QHttpResponse object.
  8. + *
+ * + * helloworld.cpp + * \include helloworld/helloworld.cpp + * helloworld.h + * \include helloworld/helloworld.h + * + */ +class QHttpServer : public QObject +{ + Q_OBJECT + +public: + /*! + * Create a new HTTP Server + */ + QHttpServer(QObject *parent = 0); + virtual ~QHttpServer(); + + /*! + * Start the server bound to the @c address and @c port. + * This function returns immediately! + * + * \param address Address on which to listen to. Default is to listen on + * all interfaces which means the server can be accessed from anywhere. + * \param port Port number on which the server should run. + * \return true if the server was started successfully, false otherwise. + * \sa listen(quint16) + */ + bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port=0); + + /*! + * Starts the server on @c port listening on all interfaces. + * + * \param port Port number on which the server should run. + * \return true if the server was started successfully, false otherwise. + * \sa listen(const QHostAddress&, quint16) + */ + bool listen(quint16 port); + + /*! + * Stop listening for connections + */ + void close(); + +Q_SIGNALS: + /*! + * This signal is emitted whenever a client + * makes a new request to the server. + * + * The slot should use the @c request and @c response + * objects to communicate with the client. + * + * \section memorymanagement Memory Management + * + * The QHttpRequest and QHttpResponse deletion policies + * are such. + * + * QHttpRequest is never deleted by %QHttpServer. + * Since it is not possible to determine till what point the application + * may want access to its data, it is up to the application to delete it. + * A recommended way to handle this is to create a new responder object for + * every request and to delete the request in that object's destructor. The + * object itself can be deleted by connecting to QHttpResponse's done() + * slot as explained below. + * + * You should NOT delete the QHttpRequest object until it + * has emitted an QHttpRequest::end() signal. + * + * QHttpResponse queues itself up for auto-deletion once the application + * calls its end() method. Once the data has been flushed to the underlying + * socket, the object will emit a QHttpResponse::done() signal before queueing itself up + * for deletion. You should NOT interact with the response + * object once it has emitted QHttpResponse::done() although actual deletion does not + * happen until QHttpResponse::destroyed() is emitted. + * QHttpResponse::done() serves as a useful way to handle memory management of the + * application itself. For example: + * + * \code + * MyApp::MyApp() + * : QObject(0) + * { + * QHttpServer *s = new QHttpServer; + * connect(s, SIGNAL(newRequest(...)), this, SLOT(handle(...))); + * s.listen(8000); + * } + * + * void MyApp::handle(QHttpRequest *request, QHttpResponse *response) + * { + * if( request->url() matches a route ) + * new Responder(request, response); + * else + * new PageNotFound(request, response); + * } + * + * ... + * + * Responder::Responder(QHttpRequest *request, QHttpResponse *response) + * { + * m_request = request; + * + * connect(request, SIGNAL(end()), response, SLOT(end())); + * // Once the request is complete, the response is ended. + * // when the response ends, it deletes itself + * // the Responder object connects to done() + * // which will lead to it being deleted + * // and this will delete the request. + * // So all 3 are properly deleted. + * connect(response, SIGNAL(done()), this, SLOT(deleteLater())); + * response->writeHead(200); + * response->write("Quitting soon"); + * } + * + * Responder::~Responder() + * { + * delete m_request; + * m_request = 0; + * } + * \endcode + * + */ + void newRequest(QHttpRequest *request, QHttpResponse *response); + +private Q_SLOTS: + void newConnection(); + +private: + QTcpServer *m_tcpServer; +}; + +#endif diff --git a/src/http/qjson/CMakeLists.txt b/src/http/qjson/CMakeLists.txt new file mode 100644 index 000000000..e51a62fd7 --- /dev/null +++ b/src/http/qjson/CMakeLists.txt @@ -0,0 +1,28 @@ +# add_custom_command (OUTPUT ${qjson_SOURCE_DIR}/lib/json_parser.cc +# PRE_BUILD +# COMMAND bison -t -o json_parser.cc -d json_parser.yy +# DEPENDS json_parser.yy +# WORKING_DIRECTORY ${qjson_SOURCE_DIR}/lib/ +# ) + +# To regenerate json_scanner.cc use: +# flex json_scanner.yy + +set(qjson_MOC_HDRS + parserrunnable.h + serializerrunnable.h +) + +IF (NOT Qt5Core_FOUND) + qt4_wrap_cpp(qjson_MOC_SRCS ${qjson_MOC_HDRS}) +ENDIF() + +set (qjson_SRCS parser.cpp qobjecthelper.cpp json_scanner.cpp json_parser.cc parserrunnable.cpp serializer.cpp serializerrunnable.cpp) +set (qjson_HEADERS parser.h parserrunnable.h qobjecthelper.h serializer.h serializerrunnable.h qjson_export.h) + +# Required to use the intree copy of FlexLexer.h +INCLUDE_DIRECTORIES(.) + +add_gcc_compiler_cxxflags("-fexceptions") +remove_definitions(-DQT_NO_KEYWORDS) +add_library (qjson STATIC ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS}) diff --git a/src/http/qjson/FlexLexer.h b/src/http/qjson/FlexLexer.h new file mode 100644 index 000000000..bad4ce03f --- /dev/null +++ b/src/http/qjson/FlexLexer.h @@ -0,0 +1,206 @@ +// -*-C++-*- +// FlexLexer.h -- define interfaces for lexical analyzer classes generated +// by flex + +// Copyright (c) 1993 The Regents of the University of California. +// All rights reserved. +// +// This code is derived from software contributed to Berkeley by +// Kent Williams and Tom Epperly. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: + +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. + +// Neither the name of the University nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE. + +// This file defines FlexLexer, an abstract class which specifies the +// external interface provided to flex C++ lexer objects, and yyFlexLexer, +// which defines a particular lexer class. +// +// If you want to create multiple lexer classes, you use the -P flag +// to rename each yyFlexLexer to some other xxFlexLexer. You then +// include in your other sources once per lexer class: +// +// #undef yyFlexLexer +// #define yyFlexLexer xxFlexLexer +// #include +// +// #undef yyFlexLexer +// #define yyFlexLexer zzFlexLexer +// #include +// ... + +#ifndef __FLEX_LEXER_H +// Never included before - need to define base class. +#define __FLEX_LEXER_H + +#include +# ifndef FLEX_STD +# define FLEX_STD std:: +# endif + +extern "C++" { + +struct yy_buffer_state; +typedef int yy_state_type; + +class FlexLexer { +public: + virtual ~FlexLexer() { } + + const char* YYText() const { return yytext; } + int YYLeng() const { return yyleng; } + + virtual void + yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; + virtual struct yy_buffer_state* + yy_create_buffer( FLEX_STD istream* s, int size ) = 0; + virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; + virtual void yyrestart( FLEX_STD istream* s ) = 0; + + virtual int yylex() = 0; + + // Call yylex with new input/output sources. + int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ) + { + switch_streams( new_in, new_out ); + return yylex(); + } + + // Switch to new input/output streams. A nil stream pointer + // indicates "keep the current one". + virtual void switch_streams( FLEX_STD istream* new_in = 0, + FLEX_STD ostream* new_out = 0 ) = 0; + + int lineno() const { return yylineno; } + + int debug() const { return yy_flex_debug; } + void set_debug( int flag ) { yy_flex_debug = flag; } + +protected: + char* yytext; + int yyleng; + int yylineno; // only maintained if you use %option yylineno + int yy_flex_debug; // only has effect with -d or "%option debug" +}; + +} +#endif // FLEXLEXER_H + +#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) +// Either this is the first time through (yyFlexLexerOnce not defined), +// or this is a repeated include to define a different flavor of +// yyFlexLexer, as discussed in the flex manual. +#define yyFlexLexerOnce + +extern "C++" { + +class yyFlexLexer : public FlexLexer { +public: + // arg_yyin and arg_yyout default to the cin and cout, but we + // only make that assignment when initializing in yylex(). + yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 ); + + virtual ~yyFlexLexer(); + + void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); + struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size ); + void yy_delete_buffer( struct yy_buffer_state* b ); + void yyrestart( FLEX_STD istream* s ); + + void yypush_buffer_state( struct yy_buffer_state* new_buffer ); + void yypop_buffer_state(); + + virtual int yylex(); + virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ); + virtual int yywrap(); + +protected: + virtual int LexerInput( char* buf, int max_size ); + virtual void LexerOutput( const char* buf, int size ); + virtual void LexerError( const char* msg ); + + void yyunput( int c, char* buf_ptr ); + int yyinput(); + + void yy_load_buffer_state(); + void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s ); + void yy_flush_buffer( struct yy_buffer_state* b ); + + int yy_start_stack_ptr; + int yy_start_stack_depth; + int* yy_start_stack; + + void yy_push_state( int new_state ); + void yy_pop_state(); + int yy_top_state(); + + yy_state_type yy_get_previous_state(); + yy_state_type yy_try_NUL_trans( yy_state_type current_state ); + int yy_get_next_buffer(); + + FLEX_STD istream* yyin; // input source for default LexerInput + FLEX_STD ostream* yyout; // output sink for default LexerOutput + + // yy_hold_char holds the character lost when yytext is formed. + char yy_hold_char; + + // Number of characters read into yy_ch_buf. + int yy_n_chars; + + // Points to current character in buffer. + char* yy_c_buf_p; + + int yy_init; // whether we need to initialize + int yy_start; // start state number + + // Flag which is used to allow yywrap()'s to do buffer switches + // instead of setting up a fresh yyin. A bit of a hack ... + int yy_did_buffer_switch_on_eof; + + + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ + void yyensure_buffer_stack(void); + + // The following are not always needed, but may be depending + // on use of certain flex features (like REJECT or yymore()). + + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + yy_state_type* yy_state_buf; + yy_state_type* yy_state_ptr; + + char* yy_full_match; + int* yy_full_state; + int yy_full_lp; + + int yy_lp; + int yy_looking_for_trail_begin; + + int yy_more_flag; + int yy_more_len; + int yy_more_offset; + int yy_prev_more_offset; +}; + +} + +#endif // yyFlexLexer || ! yyFlexLexerOnce + diff --git a/src/http/qjson/README.license b/src/http/qjson/README.license new file mode 100644 index 000000000..3ede31323 --- /dev/null +++ b/src/http/qjson/README.license @@ -0,0 +1,89 @@ +Qjson version xxxx, Date + +The following files are licensed under LGPL V2.1: +------------------------------------------------ +src/json_parser.yy +src/json_scanner.cpp +src/json_scanner.h +src/parser.cpp +src/parser.h +src/parser_p.h +src/parserrunnable.cpp +src/parserrunnable.h +src/qjson_debug.h +src/qjson_export.h +src/qobjecthelper.cpp +src/serializer.cpp +src/qobjecthelper.h +src/serializer.h +src/serializerrunnable.cpp +src/serializerrunnable.h +tests/cmdline_tester/cmdline_tester.cpp +tests/cmdline_tester/cmdlineparser.cpp +tests/cmdline_tester/cmdlineparser.h +tests/parser/testparser.cpp +tests/qobjecthelper/person.h +tests/qobjecthelper/testqobjecthelper.cpp +tests/serializer/testserializer.cpp + + +The following files are licensed under GPL V2 with Bison Exception: +-------------------------------------------------------------------- +/src/json_parser.cc +/src/stack.hh +/src/location.hh +/src/position.hh +/src/json_parser.hh + + +Copyrights: +---------- +Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +Copyright (C) 2009 Flavio Castelli 2009 Frank Osterfeld +Copyright (C) 2008 Flavio Castelli +Copyright (C) 2009 Till Adam +Copyright (C) 2009 Michael Leupold +Copyright (C) 2009 Flavio Castelli +Copyright (C) 2009 Frank Osterfeld +Copyright (C) 2009 Pino Toscano +Copyright (C) 2010 Flavio Castelli + + +GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999: +------------------------------------------------------------- + +Checkout COPYING.lib + + +GPL V2 with Bison Exception: +---------------------------- +Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + +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, 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. + +As a special exception, you may create a larger work that contains +part or all of the Bison parser skeleton and distribute that work +under terms of your choice, so long as that work isn't itself a +parser generator using the skeleton or a modified version thereof +as a parser skeleton. Alternatively, if you modify or redistribute +the parser skeleton itself, you may (at your option) remove this +special exception, which will cause the skeleton and the resulting +Bison output files to be licensed under the GNU General Public +License without this special exception. + +This special exception was added by the Free Software Foundation in +version 2.2 of Bison. + diff --git a/src/http/qjson/json_parser.cc b/src/http/qjson/json_parser.cc new file mode 100644 index 000000000..84fdfac73 --- /dev/null +++ b/src/http/qjson/json_parser.cc @@ -0,0 +1,1103 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Skeleton implementation for Bison LALR(1) parsers in C++ + + Copyright (C) 2002-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* First part of user declarations. */ + +/* Line 279 of lalr1.cc */ +#line 38 "json_parser.cc" + + +#include "json_parser.hh" + +/* User implementation prologue. */ + +/* Line 285 of lalr1.cc */ +#line 46 "json_parser.cc" + + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* FIXME: INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +# ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).begin = YYRHSLOC (Rhs, 1).begin; \ + (Current).end = YYRHSLOC (Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ + } \ + while (/*CONSTCOND*/ false) +# endif + + +/* Suppress unused-variable warnings by "using" E. */ +#define YYUSE(e) ((void) (e)) + +/* Enable debugging if requested. */ +#if YYDEBUG + +/* A pseudo ostream that takes yydebug_ into account. */ +# define YYCDEBUG if (yydebug_) (*yycdebug_) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug_) \ + { \ + *yycdebug_ << Title << ' '; \ + yy_symbol_print_ ((Type), (Value), (Location)); \ + *yycdebug_ << std::endl; \ + } \ +} while (false) + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug_) \ + yy_reduce_print_ (Rule); \ +} while (false) + +# define YY_STACK_PRINT() \ +do { \ + if (yydebug_) \ + yystack_print_ (); \ +} while (false) + +#else /* !YYDEBUG */ + +# define YYCDEBUG if (false) std::cerr +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type) +# define YY_REDUCE_PRINT(Rule) static_cast(0) +# define YY_STACK_PRINT() static_cast(0) + +#endif /* !YYDEBUG */ + +#define yyerrok (yyerrstatus_ = 0) +#define yyclearin (yychar = yyempty_) + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab +#define YYRECOVERING() (!!yyerrstatus_) + + +namespace yy { +/* Line 353 of lalr1.cc */ +#line 141 "json_parser.cc" + + /* Return YYSTR after stripping away unnecessary quotes and + backslashes, so that it's suitable for yyerror. The heuristic is + that double-quoting is unnecessary unless the string contains an + apostrophe, a comma, or backslash (other than backslash-backslash). + YYSTR is taken from yytname. */ + std::string + json_parser::yytnamerr_ (const char *yystr) + { + if (*yystr == '"') + { + std::string yyr = ""; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + yyr += *yyp; + break; + + case '"': + return yyr; + } + do_not_strip_quotes: ; + } + + return yystr; + } + + + /// Build a parser object. + json_parser::json_parser (QJson::ParserPrivate* driver_yyarg) + : +#if YYDEBUG + yydebug_ (false), + yycdebug_ (&std::cerr), +#endif + driver (driver_yyarg) + { + } + + json_parser::~json_parser () + { + } + +#if YYDEBUG + /*--------------------------------. + | Print this symbol on YYOUTPUT. | + `--------------------------------*/ + + inline void + json_parser::yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yyvaluep); + std::ostream& yyo = debug_stream (); + std::ostream& yyoutput = yyo; + YYUSE (yyoutput); + switch (yytype) + { + default: + break; + } + } + + + void + json_parser::yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") + << ' ' << yytname_[yytype] << " (" + << *yylocationp << ": "; + yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); + *yycdebug_ << ')'; + } +#endif + + void + json_parser::yydestruct_ (const char* yymsg, + int yytype, semantic_type* yyvaluep, location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yymsg); + YYUSE (yyvaluep); + + if (yymsg) + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } + } + + void + json_parser::yypop_ (unsigned int n) + { + yystate_stack_.pop (n); + yysemantic_stack_.pop (n); + yylocation_stack_.pop (n); + } + +#if YYDEBUG + std::ostream& + json_parser::debug_stream () const + { + return *yycdebug_; + } + + void + json_parser::set_debug_stream (std::ostream& o) + { + yycdebug_ = &o; + } + + + json_parser::debug_level_type + json_parser::debug_level () const + { + return yydebug_; + } + + void + json_parser::set_debug_level (debug_level_type l) + { + yydebug_ = l; + } +#endif + + inline bool + json_parser::yy_pact_value_is_default_ (int yyvalue) + { + return yyvalue == yypact_ninf_; + } + + inline bool + json_parser::yy_table_value_is_error_ (int yyvalue) + { + return yyvalue == yytable_ninf_; + } + + int + json_parser::parse () + { + /// Lookahead and lookahead in internal form. + int yychar = yyempty_; + int yytoken = 0; + + // State. + int yyn; + int yylen = 0; + int yystate = 0; + + // Error handling. + int yynerrs_ = 0; + int yyerrstatus_ = 0; + + /// Semantic value of the lookahead. + static semantic_type yyval_default; + semantic_type yylval = yyval_default; + /// Location of the lookahead. + location_type yylloc; + /// The locations where the error started and ended. + location_type yyerror_range[3]; + + /// $$. + semantic_type yyval; + /// @$. + location_type yyloc; + + int yyresult; + + // FIXME: This shoud be completely indented. It is not yet to + // avoid gratuitous conflicts when merging into the master branch. + try + { + YYCDEBUG << "Starting parse" << std::endl; + + + /* Initialize the stacks. The initial state will be pushed in + yynewstate, since the latter expects the semantical and the + location values to have been already stored, initialize these + stacks with a primary value. */ + yystate_stack_ = state_stack_type (0); + yysemantic_stack_ = semantic_stack_type (0); + yylocation_stack_ = location_stack_type (0); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); + + /* New state. */ + yynewstate: + yystate_stack_.push (yystate); + YYCDEBUG << "Entering state " << yystate << std::endl; + + /* Accept? */ + if (yystate == yyfinal_) + goto yyacceptlab; + + goto yybackup; + + /* Backup. */ + yybackup: + + /* Try to take a decision without lookahead. */ + yyn = yypact_[yystate]; + if (yy_pact_value_is_default_ (yyn)) + goto yydefault; + + /* Read a lookahead token. */ + if (yychar == yyempty_) + { + YYCDEBUG << "Reading a token: "; + yychar = yylex (&yylval, &yylloc, driver); + } + + /* Convert token to internal form. */ + if (yychar <= yyeof_) + { + yychar = yytoken = yyeof_; + YYCDEBUG << "Now at end of input." << std::endl; + } + else + { + yytoken = yytranslate_ (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) + goto yydefault; + + /* Reduce or error. */ + yyn = yytable_[yyn]; + if (yyn <= 0) + { + if (yy_table_value_is_error_ (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the token being shifted. */ + yychar = yyempty_; + + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus_) + --yyerrstatus_; + + yystate = yyn; + goto yynewstate; + + /*-----------------------------------------------------------. + | yydefault -- do the default action for the current state. | + `-----------------------------------------------------------*/ + yydefault: + yyn = yydefact_[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + /*-----------------------------. + | yyreduce -- Do a reduction. | + `-----------------------------*/ + yyreduce: + yylen = yyr2_[yyn]; + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. Otherwise, use the top of the stack. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. */ + if (yylen) + yyval = yysemantic_stack_[yylen - 1]; + else + yyval = yysemantic_stack_[0]; + + // Compute the default @$. + { + slice slice (yylocation_stack_, yylen); + YYLLOC_DEFAULT (yyloc, slice, yylen); + } + + // Perform the reduction. + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +/* Line 670 of lalr1.cc */ +#line 82 "json_parser.yy" + { + driver->m_result = (yysemantic_stack_[(1) - (1)]); + qjsonDebug() << "json_parser - parsing finished"; + } + break; + + case 3: +/* Line 670 of lalr1.cc */ +#line 87 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(1) - (1)]); } + break; + + case 4: +/* Line 670 of lalr1.cc */ +#line 89 "json_parser.yy" + { + qCritical()<< "json_parser - syntax error found, " + << "forcing abort, Line" << (yyloc).begin.line << "Column" << (yyloc).begin.column; + YYABORT; + } + break; + + case 6: +/* Line 670 of lalr1.cc */ +#line 96 "json_parser.yy" + { + (yyval) = QVariant(QVariantMap()); + } + break; + + case 7: +/* Line 670 of lalr1.cc */ +#line 99 "json_parser.yy" + { + QVariantMap* map = (yysemantic_stack_[(3) - (2)]).value(); + (yyval) = QVariant(*map); + delete map; + } + break; + + case 8: +/* Line 670 of lalr1.cc */ +#line 105 "json_parser.yy" + { + QVariantMap* pair = new QVariantMap(); + pair->insert((yysemantic_stack_[(3) - (1)]).toString(), (yysemantic_stack_[(3) - (3)])); + (yyval).setValue(pair); + } + break; + + case 9: +/* Line 670 of lalr1.cc */ +#line 110 "json_parser.yy" + { + (yyval).value()->insert((yysemantic_stack_[(5) - (3)]).toString(), (yysemantic_stack_[(5) - (5)])); + } + break; + + case 10: +/* Line 670 of lalr1.cc */ +#line 114 "json_parser.yy" + { + (yyval) = QVariant(QVariantList()); + } + break; + + case 11: +/* Line 670 of lalr1.cc */ +#line 117 "json_parser.yy" + { + QVector* list = (yysemantic_stack_[(3) - (2)]).value* >(); + (yyval) = QVariant(list->toList()); + delete list; + } + break; + + case 12: +/* Line 670 of lalr1.cc */ +#line 123 "json_parser.yy" + { + QVector* list = new QVector(1); + list->replace(0, (yysemantic_stack_[(1) - (1)])); + (yyval).setValue(list); + } + break; + + case 13: +/* Line 670 of lalr1.cc */ +#line 128 "json_parser.yy" + { + (yyval).value* >()->append((yysemantic_stack_[(3) - (3)])); + } + break; + + +/* Line 670 of lalr1.cc */ +#line 549 "json_parser.cc" + default: + break; + } + + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action + invokes YYABORT, YYACCEPT, or YYERROR immediately after altering + yychar. In the case of YYABORT or YYACCEPT, an incorrect + destructor might then be invoked immediately. In the case of + YYERROR, subsequent parser actions might lead to an incorrect + destructor call or verbose syntax error message before the + lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); + + yypop_ (yylen); + yylen = 0; + YY_STACK_PRINT (); + + yysemantic_stack_.push (yyval); + yylocation_stack_.push (yyloc); + + /* Shift the result of the reduction. */ + yyn = yyr1_[yyn]; + yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; + if (0 <= yystate && yystate <= yylast_ + && yycheck_[yystate] == yystate_stack_[0]) + yystate = yytable_[yystate]; + else + yystate = yydefgoto_[yyn - yyntokens_]; + goto yynewstate; + + /*------------------------------------. + | yyerrlab -- here on detecting error | + `------------------------------------*/ + yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yytranslate_ (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus_) + { + ++yynerrs_; + if (yychar == yyempty_) + yytoken = yyempty_; + error (yylloc, yysyntax_error_ (yystate, yytoken)); + } + + yyerror_range[1] = yylloc; + if (yyerrstatus_ == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + if (yychar <= yyeof_) + { + /* Return failure if at end of input. */ + if (yychar == yyeof_) + YYABORT; + } + else + { + yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); + yychar = yyempty_; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + + /*---------------------------------------------------. + | yyerrorlab -- error raised explicitly by YYERROR. | + `---------------------------------------------------*/ + yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (false) + goto yyerrorlab; + + yyerror_range[1] = yylocation_stack_[yylen - 1]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + yypop_ (yylen); + yylen = 0; + yystate = yystate_stack_[0]; + goto yyerrlab1; + + /*-------------------------------------------------------------. + | yyerrlab1 -- common code for both syntax error and YYERROR. | + `-------------------------------------------------------------*/ + yyerrlab1: + yyerrstatus_ = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact_[yystate]; + if (!yy_pact_value_is_default_ (yyn)) + { + yyn += yyterror_; + if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) + { + yyn = yytable_[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yystate_stack_.height () == 1) + YYABORT; + + yyerror_range[1] = yylocation_stack_[0]; + yydestruct_ ("Error: popping", + yystos_[yystate], + &yysemantic_stack_[0], &yylocation_stack_[0]); + yypop_ (); + yystate = yystate_stack_[0]; + YY_STACK_PRINT (); + } + + yyerror_range[2] = yylloc; + // Using YYLLOC is tempting, but would change the location of + // the lookahead. YYLOC is available though. + YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yyloc); + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], + &yysemantic_stack_[0], &yylocation_stack_[0]); + + yystate = yyn; + goto yynewstate; + + /* Accept. */ + yyacceptlab: + yyresult = 0; + goto yyreturn; + + /* Abort. */ + yyabortlab: + yyresult = 1; + goto yyreturn; + + yyreturn: + if (yychar != yyempty_) + { + /* Make sure we have latest lookahead translation. See comments + at user semantic actions for why this is necessary. */ + yytoken = yytranslate_ (yychar); + yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, + &yylloc); + } + + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + yypop_ (yylen); + while (1 < yystate_stack_.height ()) + { + yydestruct_ ("Cleanup: popping", + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); + } + + return yyresult; + } + catch (...) + { + YYCDEBUG << "Exception caught: cleaning lookahead and stack" + << std::endl; + // Do not try to display the values of the reclaimed symbols, + // as their printer might throw an exception. + if (yychar != yyempty_) + { + /* Make sure we have latest lookahead translation. See + comments at user semantic actions for why this is + necessary. */ + yytoken = yytranslate_ (yychar); + yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc); + } + + while (1 < yystate_stack_.height ()) + { + yydestruct_ (YY_NULL, + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); + } + throw; + } + } + + // Generate an error message. + std::string + json_parser::yysyntax_error_ (int yystate, int yytoken) + { + std::string yyres; + // Number of reported tokens (one for the "unexpected", one per + // "expected"). + size_t yycount = 0; + // Its maximum. + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + // Arguments of yyformat. + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yytoken) is + if this state is a consistent state with a default action. + Thus, detecting the absence of a lookahead is sufficient to + determine that there is no unexpected or expected token to + report. In that case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is + a consistent state with a default action. There might have + been a previous inconsistent state, consistent state with a + non-default action, or user semantic action that manipulated + yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state + merging (from LALR or IELR) and default reductions corrupt the + expected token list. However, the list is correct for + canonical LR with one exception: it will still contain any + token that will not be accepted due to an error action in a + later state. + */ + if (yytoken != yyempty_) + { + yyarg[yycount++] = yytname_[yytoken]; + int yyn = yypact_[yystate]; + if (!yy_pact_value_is_default_ (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + for (int yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ + && !yy_table_value_is_error_ (yytable_[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + break; + } + else + yyarg[yycount++] = yytname_[yyx]; + } + } + } + + char const* yyformat = YY_NULL; + switch (yycount) + { +#define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +#undef YYCASE_ + } + + // Argument number. + size_t yyi = 0; + for (char const* yyp = yyformat; *yyp; ++yyp) + if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) + { + yyres += yytnamerr_ (yyarg[yyi++]); + ++yyp; + } + else + yyres += *yyp; + return yyres; + } + + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ + const signed char json_parser::yypact_ninf_ = -5; + const signed char + json_parser::yypact_[] = + { + 1, -5, -5, 3, 18, -5, -5, -5, -5, -5, + 8, -5, -5, -5, -5, -5, 2, 11, -5, -3, + -5, -5, 29, -5, 4, -5, 29, -5, 13, -5, + 29, -5 + }; + + /* YYDEFACT[S] -- default reduction number in state S. Performed when + YYTABLE doesn't specify something else to do. Zero means the + default is an error. */ + const unsigned char + json_parser::yydefact_[] = + { + 0, 5, 4, 0, 0, 15, 16, 17, 18, 14, + 0, 2, 19, 20, 3, 6, 0, 0, 10, 0, + 12, 1, 0, 7, 0, 11, 0, 8, 0, 13, + 0, 9 + }; + + /* YYPGOTO[NTERM-NUM]. */ + const signed char + json_parser::yypgoto_[] = + { + -5, -5, -5, -5, -5, -5, -5, -4 + }; + + /* YYDEFGOTO[NTERM-NUM]. */ + const signed char + json_parser::yydefgoto_[] = + { + -1, 10, 11, 12, 17, 13, 19, 14 + }; + + /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF_, syntax error. */ + const signed char json_parser::yytable_ninf_ = -1; + const unsigned char + json_parser::yytable_[] = + { + 20, 1, 2, 25, 3, 26, 4, 15, 21, 22, + 5, 6, 7, 8, 9, 23, 16, 28, 27, 24, + 30, 3, 29, 4, 18, 0, 31, 5, 6, 7, + 8, 9, 3, 0, 4, 0, 0, 0, 5, 6, + 7, 8, 9 + }; + + /* YYCHECK. */ + const signed char + json_parser::yycheck_[] = + { + 4, 0, 1, 6, 3, 8, 5, 4, 0, 7, + 9, 10, 11, 12, 13, 4, 13, 13, 22, 8, + 7, 3, 26, 5, 6, -1, 30, 9, 10, 11, + 12, 13, 3, -1, 5, -1, -1, -1, 9, 10, + 11, 12, 13 + }; + + /* STOS_[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ + const unsigned char + json_parser::yystos_[] = + { + 0, 0, 1, 3, 5, 9, 10, 11, 12, 13, + 16, 17, 18, 20, 22, 4, 13, 19, 6, 21, + 22, 0, 7, 4, 8, 6, 8, 22, 13, 22, + 7, 22 + }; + +#if YYDEBUG + /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding + to YYLEX-NUM. */ + const unsigned short int + json_parser::yytoken_number_[] = + { + 0, 256, 257, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12 + }; +#endif + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ + const unsigned char + json_parser::yyr1_[] = + { + 0, 15, 16, 17, 17, 17, 18, 18, 19, 19, + 20, 20, 21, 21, 22, 22, 22, 22, 22, 22, + 22 + }; + + /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ + const unsigned char + json_parser::yyr2_[] = + { + 0, 2, 1, 1, 1, 1, 2, 3, 3, 5, + 2, 3, 1, 3, 1, 1, 1, 1, 1, 1, + 1 + }; + + + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at \a yyntokens_, nonterminals. */ + const char* + const json_parser::yytname_[] = + { + "\"end of file\"", "error", "$undefined", "\"{\"", "\"}\"", "\"[\"", + "\"]\"", "\":\"", "\",\"", "\"number\"", "\"true\"", "\"false\"", + "\"null\"", "\"string\"", "\"invalid\"", "$accept", "start", "data", + "object", "members", "array", "values", "value", YY_NULL + }; + +#if YYDEBUG + /* YYRHS -- A `-1'-separated list of the rules' RHS. */ + const json_parser::rhs_number_type + json_parser::yyrhs_[] = + { + 16, 0, -1, 17, -1, 22, -1, 1, -1, 0, + -1, 3, 4, -1, 3, 19, 4, -1, 13, 7, + 22, -1, 19, 8, 13, 7, 22, -1, 5, 6, + -1, 5, 21, 6, -1, 22, -1, 21, 8, 22, + -1, 13, -1, 9, -1, 10, -1, 11, -1, 12, + -1, 18, -1, 20, -1 + }; + + /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ + const unsigned char + json_parser::yyprhs_[] = + { + 0, 0, 3, 5, 7, 9, 11, 14, 18, 22, + 28, 31, 35, 37, 41, 43, 45, 47, 49, 51, + 53 + }; + + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ + const unsigned char + json_parser::yyrline_[] = + { + 0, 82, 82, 87, 88, 94, 96, 99, 105, 110, + 114, 117, 123, 128, 132, 133, 134, 135, 136, 137, + 138 + }; + + // Print the state stack on the debug stream. + void + json_parser::yystack_print_ () + { + *yycdebug_ << "Stack now"; + for (state_stack_type::const_iterator i = yystate_stack_.begin (); + i != yystate_stack_.end (); ++i) + *yycdebug_ << ' ' << *i; + *yycdebug_ << std::endl; + } + + // Report on the debug stream that the rule \a yyrule is going to be reduced. + void + json_parser::yy_reduce_print_ (int yyrule) + { + unsigned int yylno = yyrline_[yyrule]; + int yynrhs = yyr2_[yyrule]; + /* Print the symbols being reduced, and their result. */ + *yycdebug_ << "Reducing stack by rule " << yyrule - 1 + << " (line " << yylno << "):" << std::endl; + /* The symbols being reduced. */ + for (int yyi = 0; yyi < yynrhs; yyi++) + YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", + yyrhs_[yyprhs_[yyrule] + yyi], + &(yysemantic_stack_[(yynrhs) - (yyi + 1)]), + &(yylocation_stack_[(yynrhs) - (yyi + 1)])); + } +#endif // YYDEBUG + + /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ + json_parser::token_number_type + json_parser::yytranslate_ (int t) + { + static + const token_number_type + translate_table[] = + { + 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2 + }; + if ((unsigned int) t <= yyuser_token_number_max_) + return translate_table[t]; + else + return yyundef_token_; + } + + const int json_parser::yyeof_ = 0; + const int json_parser::yylast_ = 42; + const int json_parser::yynnts_ = 8; + const int json_parser::yyempty_ = -2; + const int json_parser::yyfinal_ = 21; + const int json_parser::yyterror_ = 1; + const int json_parser::yyerrcode_ = 256; + const int json_parser::yyntokens_ = 15; + + const unsigned int json_parser::yyuser_token_number_max_ = 257; + const json_parser::token_number_type json_parser::yyundef_token_ = 2; + + +} // yy +/* Line 1141 of lalr1.cc */ +#line 1079 "json_parser.cc" +/* Line 1142 of lalr1.cc */ +#line 140 "json_parser.yy" + + +int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) +{ + JSonScanner* scanner = driver->m_scanner; + yylval->clear(); + int ret = scanner->yylex(yylval, yylloc); + + qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" + << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; + + return ret; +} + +void yy::json_parser::error (const yy::location& yyloc, const std::string& error) +{ + /*qjsonDebug() << yyloc.begin.line; + qjsonDebug() << yyloc.begin.column; + qjsonDebug() << yyloc.end.line; + qjsonDebug() << yyloc.end.column;*/ + qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; + driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); +} diff --git a/src/http/qjson/json_parser.hh b/src/http/qjson/json_parser.hh new file mode 100644 index 000000000..25e00fa1b --- /dev/null +++ b/src/http/qjson/json_parser.hh @@ -0,0 +1,300 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Skeleton interface for Bison LALR(1) parsers in C++ + + Copyright (C) 2002-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file json_parser.hh + ** Define the yy::parser class. + */ + +/* C++ LALR(1) parser skeleton written by Akim Demaille. */ + +#ifndef YY_YY_JSON_PARSER_HH_INCLUDED +# define YY_YY_JSON_PARSER_HH_INCLUDED + +/* "%code requires" blocks. */ +/* Line 33 of lalr1.cc */ +#line 26 "json_parser.yy" + + #include "parser_p.h" + #include "json_scanner.h" + #include "qjson_debug.h" + + #include + #include + #include + #include + + #include + + class JSonScanner; + + namespace QJson { + class Parser; + } + + #define YYERROR_VERBOSE 1 + + Q_DECLARE_METATYPE(QVector*) + Q_DECLARE_METATYPE(QVariantMap*) + + +/* Line 33 of lalr1.cc */ +#line 72 "json_parser.hh" + + +#include +#include +#include "stack.hh" +#include "location.hh" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif + + +namespace yy { +/* Line 33 of lalr1.cc */ +#line 88 "json_parser.hh" + + /// A Bison parser. + class json_parser + { + public: + /// Symbol semantic values. +#ifndef YYSTYPE + typedef int semantic_type; +#else + typedef YYSTYPE semantic_type; +#endif + /// Symbol locations. + typedef location location_type; + /// Tokens. + struct token + { + /* Tokens. */ + enum yytokentype { + END = 0, + CURLY_BRACKET_OPEN = 1, + CURLY_BRACKET_CLOSE = 2, + SQUARE_BRACKET_OPEN = 3, + SQUARE_BRACKET_CLOSE = 4, + COLON = 5, + COMMA = 6, + NUMBER = 7, + TRUE_VAL = 8, + FALSE_VAL = 9, + NULL_VAL = 10, + STRING = 11, + INVALID = 12 + }; + + }; + /// Token type. + typedef token::yytokentype token_type; + + /// Build a parser object. + json_parser (QJson::ParserPrivate* driver_yyarg); + virtual ~json_parser (); + + /// Parse. + /// \returns 0 iff parsing succeeded. + virtual int parse (); + +#if YYDEBUG + /// The current debugging stream. + std::ostream& debug_stream () const; + /// Set the current debugging stream. + void set_debug_stream (std::ostream &); + + /// Type for debugging levels. + typedef int debug_level_type; + /// The current debugging level. + debug_level_type debug_level () const; + /// Set the current debugging level. + void set_debug_level (debug_level_type l); +#endif + + private: + /// Report a syntax error. + /// \param loc where the syntax error is found. + /// \param msg a description of the syntax error. + virtual void error (const location_type& loc, const std::string& msg); + + /// Generate an error message. + /// \param state the state where the error occurred. + /// \param tok the lookahead token. + virtual std::string yysyntax_error_ (int yystate, int tok); + +#if YYDEBUG + /// \brief Report a symbol value on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); + /// \brief Report a symbol on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); +#endif + + + /// State numbers. + typedef int state_type; + /// State stack type. + typedef stack state_stack_type; + /// Semantic value stack type. + typedef stack semantic_stack_type; + /// location stack type. + typedef stack location_stack_type; + + /// The state stack. + state_stack_type yystate_stack_; + /// The semantic value stack. + semantic_stack_type yysemantic_stack_; + /// The location stack. + location_stack_type yylocation_stack_; + + /// Whether the given \c yypact_ value indicates a defaulted state. + /// \param yyvalue the value to check + static bool yy_pact_value_is_default_ (int yyvalue); + + /// Whether the given \c yytable_ value indicates a syntax error. + /// \param yyvalue the value to check + static bool yy_table_value_is_error_ (int yyvalue); + + /// Internal symbol numbers. + typedef unsigned char token_number_type; + /* Tables. */ + /// For a state, the index in \a yytable_ of its portion. + static const signed char yypact_[]; + static const signed char yypact_ninf_; + + /// For a state, default reduction number. + /// Unless\a yytable_ specifies something else to do. + /// Zero means the default is an error. + static const unsigned char yydefact_[]; + + static const signed char yypgoto_[]; + static const signed char yydefgoto_[]; + + /// What to do in a state. + /// \a yytable_[yypact_[s]]: what to do in state \a s. + /// - if positive, shift that token. + /// - if negative, reduce the rule which number is the opposite. + /// - if zero, do what YYDEFACT says. + static const unsigned char yytable_[]; + static const signed char yytable_ninf_; + + static const signed char yycheck_[]; + + /// For a state, its accessing symbol. + static const unsigned char yystos_[]; + + /// For a rule, its LHS. + static const unsigned char yyr1_[]; + /// For a rule, its RHS length. + static const unsigned char yyr2_[]; + + /// Convert the symbol name \a n to a form suitable for a diagnostic. + static std::string yytnamerr_ (const char *n); + + + /// For a symbol, its name in clear. + static const char* const yytname_[]; +#if YYDEBUG + /// A type to store symbol numbers and -1. + typedef signed char rhs_number_type; + /// A `-1'-separated list of the rules' RHS. + static const rhs_number_type yyrhs_[]; + /// For each rule, the index of the first RHS symbol in \a yyrhs_. + static const unsigned char yyprhs_[]; + /// For each rule, its source line number. + static const unsigned char yyrline_[]; + /// For each scanner token number, its symbol number. + static const unsigned short int yytoken_number_[]; + /// Report on the debug stream that the rule \a r is going to be reduced. + virtual void yy_reduce_print_ (int r); + /// Print the state stack on the debug stream. + virtual void yystack_print_ (); + + /* Debugging. */ + int yydebug_; + std::ostream* yycdebug_; +#endif + + /// Convert a scanner token number \a t to a symbol number. + token_number_type yytranslate_ (int t); + + /// \brief Reclaim the memory associated to a symbol. + /// \param yymsg Why this token is reclaimed. + /// If null, do not display the symbol, just free it. + /// \param yytype The symbol type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + inline void yydestruct_ (const char* yymsg, + int yytype, + semantic_type* yyvaluep, + location_type* yylocationp); + + /// Pop \a n symbols the three stacks. + inline void yypop_ (unsigned int n = 1); + + /* Constants. */ + static const int yyeof_; + /* LAST_ -- Last index in TABLE_. */ + static const int yylast_; + static const int yynnts_; + static const int yyempty_; + static const int yyfinal_; + static const int yyterror_; + static const int yyerrcode_; + static const int yyntokens_; + static const unsigned int yyuser_token_number_max_; + static const token_number_type yyundef_token_; + + /* User arguments. */ + QJson::ParserPrivate* driver; + }; + +} // yy +/* Line 33 of lalr1.cc */ +#line 297 "json_parser.hh" + + + +#endif /* !YY_YY_JSON_PARSER_HH_INCLUDED */ diff --git a/src/http/qjson/json_parser.yy b/src/http/qjson/json_parser.yy new file mode 100644 index 000000000..fa4656bab --- /dev/null +++ b/src/http/qjson/json_parser.yy @@ -0,0 +1,162 @@ +/* This file is part of QJSon + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +%skeleton "lalr1.cc" +%defines +%define "parser_class_name" "json_parser" + +%code requires{ + #include "parser_p.h" + #include "json_scanner.h" + #include "qjson_debug.h" + + #include + #include + #include + #include + + #include + + class JSonScanner; + + namespace QJson { + class Parser; + } + + #define YYERROR_VERBOSE 1 + + Q_DECLARE_METATYPE(QVector*) + Q_DECLARE_METATYPE(QVariantMap*) +} + +%parse-param { QJson::ParserPrivate* driver } +%lex-param { QJson::ParserPrivate* driver } + +%locations + +%debug +%error-verbose + +%token END 0 "end of file" + +%token CURLY_BRACKET_OPEN 1 "{" +%token CURLY_BRACKET_CLOSE 2 "}" +%token SQUARE_BRACKET_OPEN 3 "[" +%token SQUARE_BRACKET_CLOSE 4 "]" +%token COLON 5 ":" +%token COMMA 6 "," + +%token NUMBER 7 "number" +%token TRUE_VAL 8 "true" +%token FALSE_VAL 9 "false" +%token NULL_VAL 10 "null" +%token STRING 11 "string" + +%token INVALID 12 "invalid" + +// define the initial token +%start start + +%% + +// grammar rules + +start: data { + driver->m_result = $1; + qjsonDebug() << "json_parser - parsing finished"; + }; + +data: value { $$ = $1; } + | error + { + qCritical()<< "json_parser - syntax error found, " + << "forcing abort, Line" << @$.begin.line << "Column" << @$.begin.column; + YYABORT; + } + | END; + +object: CURLY_BRACKET_OPEN CURLY_BRACKET_CLOSE { + $$ = QVariant(QVariantMap()); + } + | CURLY_BRACKET_OPEN members CURLY_BRACKET_CLOSE { + QVariantMap* map = $2.value(); + $$ = QVariant(*map); + delete map; + }; + +members: STRING COLON value { + QVariantMap* pair = new QVariantMap(); + pair->insert($1.toString(), $3); + $$.setValue(pair); + } + | members COMMA STRING COLON value { + $$.value()->insert($3.toString(), $5); + }; + +array: SQUARE_BRACKET_OPEN SQUARE_BRACKET_CLOSE { + $$ = QVariant(QVariantList()); + } + | SQUARE_BRACKET_OPEN values SQUARE_BRACKET_CLOSE { + QVector* list = $2.value* >(); + $$ = QVariant(list->toList()); + delete list; + }; + +values: value { + QVector* list = new QVector(1); + list->replace(0, $1); + $$.setValue(list); + } + | values COMMA value { + $$.value* >()->append($3); + }; + +value: STRING + | NUMBER + | TRUE_VAL + | FALSE_VAL + | NULL_VAL + | object + | array; + +%% + +int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) +{ + JSonScanner* scanner = driver->m_scanner; + yylval->clear(); + int ret = scanner->yylex(yylval, yylloc); + + qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" + << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; + + return ret; +} + +void yy::json_parser::error (const yy::location& yyloc, const std::string& error) +{ + /*qjsonDebug() << yyloc.begin.line; + qjsonDebug() << yyloc.begin.column; + qjsonDebug() << yyloc.end.line; + qjsonDebug() << yyloc.end.column;*/ + qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; + driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); +} diff --git a/src/http/qjson/json_scanner.cc b/src/http/qjson/json_scanner.cc new file mode 100644 index 000000000..d163932d8 --- /dev/null +++ b/src/http/qjson/json_scanner.cc @@ -0,0 +1,4507 @@ +#line 2 "json_scanner.cc" + +#line 4 "json_scanner.cc" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 37 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer yyFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } +int yyFlexLexer::yylex() + { + LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" ); + return 0; + } + +#define YY_DECL int JSonScanner::yylex() +static yyconst flex_int16_t yy_nxt[][256] = + { + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 15, 16, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 10, 10, 10, 10, 10, + 23, 10, 10, 10, 10, 10, 24, 10, 10, 10, + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 15, 16, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 10, 10, 10, 10, 10, + 23, 10, 10, 10, 10, 10, 24, 10, 10, 10, + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + 9, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 29, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27 + }, + + { + 9, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 29, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27 + + }, + + { + 9, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, + 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, + 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, + + 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30 + }, + + { + 9, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, + 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, + 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, + 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 15, 32, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 33, 10, 10, 10, 10, 34, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 33, 10, 10, 10, 10, + 35, 10, 10, 10, 10, 10, 24, 10, 10, 10, + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 15, 32, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 33, 10, 10, 10, 10, 34, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 33, 10, 10, 10, 10, + 35, 10, 10, 10, 10, 10, 24, 10, 10, 10, + + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9 + + }, + + { + 9, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10 + }, + + { + 9, -11, -11, -11, -11, -11, -11, -11, -11, 36, + -11, 36, 36, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, 36, -11, -11, -11, -11, -11, -11, -11, + + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11 + }, + + { + 9, -12, -12, -12, -12, -12, -12, -12, -12, -12, + 37, -12, -12, 37, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12 + }, + + { + 9, -13, -13, -13, -13, -13, -13, -13, -13, -13, + 37, -13, -13, 37, -13, -13, -13, -13, -13, -13, + + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13 + }, + + { + 9, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14 + + }, + + { + 9, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15 + }, + + { + 9, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + + -16, -16, -16, -16, -16, -16, -16, -16, 38, 39, + 39, 39, 39, 39, 39, 39, 39, 39, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16 + }, + + { + 9, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, 40, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, 41, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, 41, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17 + }, + + { + 9, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, 40, -18, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, 41, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, 41, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18 + }, + + { + 9, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19 + + }, + + { + 9, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20 + }, + + { + 9, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21 + }, + + { + 9, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, 43, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22 + }, + + { + 9, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, 44, -23, -23, + + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23 + }, + + { + 9, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, 45, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24 + + }, + + { + 9, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25 + }, + + { + 9, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26 + }, + + { + 9, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, -27, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, -27, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46 + }, + + { + 9, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28 + }, + + { + 9, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, 47, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, 48, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, 49, -29, -29, -29, -29, -29, 50, -29, + -29, -29, 51, -29, -29, -29, -29, -29, -29, -29, + 52, -29, -29, -29, 53, -29, 54, 55, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29 + + }, + + { + 9, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30 + }, + + { + 9, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + + -31, -31, -31, -31, -31, -31, -31, -31, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, -31, -31, + -31, -31, -31, -31, -31, 56, 56, 56, 56, 56, + 56, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, 56, 56, 56, + 56, 56, 56, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31 + }, + + { + 9, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, 38, 39, + 39, 39, 39, 39, 39, 39, 39, 39, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, 57, -32, -32, -32, -32, -32, -32, + + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, 57, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32 + }, + + { + 9, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + 58, -33, -33, -33, -33, -33, -33, -33, -33, -33, + + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33 + }, + + { + 9, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + + -34, -34, -34, -34, -34, 59, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, 59, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34 + + }, + + { + 9, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, 59, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, 59, -35, -35, + + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, 44, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35 + }, + + { + 9, -36, -36, -36, -36, -36, -36, -36, -36, 36, + -36, 36, 36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, 36, -36, -36, -36, -36, -36, -36, -36, + + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36 + }, + + { + 9, -37, -37, -37, -37, -37, -37, -37, -37, -37, + 37, -37, -37, 37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37 + }, + + { + 9, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, 40, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, 41, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, 41, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38 + }, + + { + 9, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, 40, -39, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, -39, -39, + + -39, -39, -39, -39, -39, -39, -39, -39, -39, 41, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, 41, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39 + + }, + + { + 9, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40 + }, + + { + 9, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + + -41, -41, -41, 62, -41, 62, -41, -41, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41 + }, + + { + 9, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, 40, -42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, 41, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, 41, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42 + }, + + { + 9, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, 64, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43 + }, + + { + 9, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, 65, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44 + + }, + + { + 9, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, 66, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45 + }, + + { + 9, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, -46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, -46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46 + }, + + { + 9, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47 + }, + + { + 9, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48 + }, + + { + 9, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49 + + }, + + { + 9, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50 + }, + + { + 9, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51 + }, + + { + 9, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52 + }, + + { + 9, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53 + }, + + { + 9, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54 + + }, + + { + 9, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55 + }, + + { + 9, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + + -56, -56, -56, -56, -56, -56, -56, -56, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, -56, -56, + -56, -56, -56, -56, -56, 67, 67, 67, 67, 67, + 67, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, 67, 67, 67, + 67, 67, 67, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56 + }, + + { + 9, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + 68, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57 + }, + + { + 9, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, 69, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58 + }, + + { + 9, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, 70, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + 70, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59 + + }, + + { + 9, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, 40, -60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, 41, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + + -60, 41, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60 + }, + + { + 9, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + + -61, -61, -61, -61, -61, -61, -61, -61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, 41, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, 41, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61 + }, + + { + 9, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62 + }, + + { + 9, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63 + }, + + { + 9, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, 71, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64 + + }, + + { + 9, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + + -65, -65, -65, -65, -65, -65, -65, -65, 72, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65 + }, + + { + 9, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, 73, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66 + }, + + { + 9, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, 74, 74, + 74, 74, 74, 74, 74, 74, 74, 74, -67, -67, + -67, -67, -67, -67, -67, 74, 74, 74, 74, 74, + 74, -67, -67, -67, -67, -67, -67, -67, -67, -67, + + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, 74, 74, 74, + 74, 74, 74, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67 + }, + + { + 9, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, 75, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68 + }, + + { + 9, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, 76, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69 + + }, + + { + 9, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70 + }, + + { + 9, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, 77, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71 + }, + + { + 9, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72 + }, + + { + 9, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73 + }, + + { + 9, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74 + + }, + + { + 9, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + + -75, -75, -75, -75, -75, 78, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75 + }, + + { + 9, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + 79, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76 + }, + + { + 9, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77 + }, + + { + 9, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + 80, -78, -78, -78, -78, -78, -78, -78, -78, -78, + + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78 + }, + + { + 9, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, 81, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79 + + }, + + { + 9, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + + -80, -80, -80, -80, -80, 82, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80 + }, + + { + 9, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, 83, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81 + }, + + { + 9, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, 84, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82 + }, + + { + 9, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + + -83, 85, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83 + }, + + { + 9, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, 86, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84 + + }, + + { + 9, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85 + }, + + { + 9, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86 + }, + + } ; + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 36 +#define YY_END_OF_BUFFER 37 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[87] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 37, 35, + 1, 2, 2, 11, 27, 35, 6, 6, 26, 28, + 29, 35, 35, 35, 30, 31, 21, 23, 22, 25, + 25, 35, 35, 35, 35, 1, 2, 8, 8, 0, + 0, 7, 0, 0, 0, 21, 12, 14, 13, 15, + 16, 17, 18, 19, 20, 0, 0, 0, 0, 9, + 10, 0, 10, 0, 0, 0, 0, 0, 0, 32, + 0, 5, 3, 24, 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 33, 34 + } ; + +static yyconst yy_state_type yy_NUL_trans[87] = + { 0, + 10, 10, 27, 27, 30, 30, 10, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "json_scanner.yy" +/* This file is part of QJson + * + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110yy::json_parser::token::INVALID301, USA. + */ +/* Flex output settings */ +#define YY_NO_UNISTD_H 1 +#define YY_NO_INPUT 1 +#line 29 "json_scanner.yy" + #include "json_scanner.h" + #include "json_parser.hh" + + #define YY_USER_INIT if(m_allowSpecialNumbers) { \ + BEGIN(ALLOW_SPECIAL_NUMBERS); \ + } +/* Exclusive subscanners for strings and escaped hex sequences */ + +/* Extra-JSON rules active iff m_allowSpecialNumbers is true */ + +#line 3163 "json_scanner.cc" + +#define INITIAL 0 +#define QUOTMARK_OPEN 1 +#define HEX_OPEN 2 +#define ALLOW_SPECIAL_NUMBERS 3 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 43 "json_scanner.yy" + + + /* Whitespace */ +#line 3270 "json_scanner.cc" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + while ( (yy_current_state = yy_nxt[yy_current_state][ YY_SC_TO_UI(*yy_cp) ]) > 0 ) + { + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + + ++yy_cp; + } + + yy_current_state = -yy_current_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos) + 1; + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 46 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + } + YY_BREAK +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 50 "json_scanner.yy" +{ + m_yylloc->lines(yyleng); + } + YY_BREAK +/* Special values */ +case 3: +YY_RULE_SETUP +#line 56 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(true); + return yy::json_parser::token::TRUE_VAL; + } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 62 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(false); + return yy::json_parser::token::FALSE_VAL; + } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 68 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(); + return yy::json_parser::token::NULL_VAL; + } + YY_BREAK +/* Numbers */ +case 6: +#line 77 "json_scanner.yy" +case 7: +YY_RULE_SETUP +#line 77 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoull(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 8: +#line 88 "json_scanner.yy" +case 9: +YY_RULE_SETUP +#line 88 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoll(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 98 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtod(yytext, NULL)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + YY_BREAK +/* Strings */ +case 11: +YY_RULE_SETUP +#line 109 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + BEGIN(QUOTMARK_OPEN); + } + YY_BREAK + +case 12: +YY_RULE_SETUP +#line 115 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\"")); + } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 119 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\\")); + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 123 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("/")); + } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 127 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\b")); + } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 131 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\f")); + } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 135 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\n")); + } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 139 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\r")); + } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 143 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\t")); + } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 147 "json_scanner.yy" +{ + BEGIN(HEX_OPEN); + } + YY_BREAK +case 21: +/* rule 21 can match eol */ +YY_RULE_SETUP +#line 151 "json_scanner.yy" +{ + m_currentString.append(QString::fromUtf8(yytext)); + } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 155 "json_scanner.yy" +{ + // ignore + } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 159 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(m_currentString); + m_currentString.clear(); + BEGIN(INITIAL); + return yy::json_parser::token::STRING; + } + YY_BREAK + + +case 24: +YY_RULE_SETUP +#line 169 "json_scanner.yy" +{ + QString hexDigits = QString::fromUtf8(yytext, yyleng); + bool ok; + ushort hexDigit1 = hexDigits.left(2).toShort(&ok, 16); + ushort hexDigit2 = hexDigits.right(2).toShort(&ok, 16); + m_currentString.append(QChar(hexDigit2, hexDigit1)); + BEGIN(QUOTMARK_OPEN); + } + YY_BREAK +case 25: +/* rule 25 can match eol */ +YY_RULE_SETUP +#line 178 "json_scanner.yy" +{ + qCritical() << "Invalid hex string"; + m_yylloc->columns(yyleng); + *m_yylval = QVariant(QLatin1String("")); + BEGIN(QUOTMARK_OPEN); + return yy::json_parser::token::INVALID; + } + YY_BREAK + +/* "Compound type" related tokens */ +case 26: +YY_RULE_SETUP +#line 190 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::COLON; + } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 195 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::COMMA; + } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 200 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_OPEN; + } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 205 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_CLOSE; + } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 210 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_OPEN; + } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 215 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_CLOSE; + } + YY_BREAK +/* Extra-JSON numbers */ + +case 32: +YY_RULE_SETUP +#line 223 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::quiet_NaN()); + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 229 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 235 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(-std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } + YY_BREAK + +/* If all else fails */ +case 35: +YY_RULE_SETUP +#line 243 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::INVALID; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(QUOTMARK_OPEN): +case YY_STATE_EOF(HEX_OPEN): +case YY_STATE_EOF(ALLOW_SPECIAL_NUMBERS): +#line 248 "json_scanner.yy" +return yy::json_parser::token::END; + YY_BREAK +case 36: +YY_RULE_SETUP +#line 249 "json_scanner.yy" +ECHO; + YY_BREAK +#line 3654 "json_scanner.cc" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + yyfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + yyfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) +#else +int yyFlexLexer::LexerInput( char* buf, int max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, int size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + if ( *yy_cp ) + { + yy_current_state = yy_nxt[yy_current_state][YY_SC_TO_UI(*yy_cp)]; + } + else + yy_current_state = yy_NUL_trans[yy_current_state]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + yy_current_state = yy_NUL_trans[yy_current_state]; + yy_is_jam = (yy_current_state == 0); + + if ( ! yy_is_jam ) + { + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + } + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ); + + yyfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 249 "json_scanner.yy" diff --git a/src/http/qjson/json_scanner.cpp b/src/http/qjson/json_scanner.cpp new file mode 100644 index 000000000..5ef2a7180 --- /dev/null +++ b/src/http/qjson/json_scanner.cpp @@ -0,0 +1,75 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#include "json_scanner.cc" + +#include "qjson_debug.h" +#include "json_scanner.h" +#include "json_parser.hh" + +#include + +#include +#include + +#include + +JSonScanner::JSonScanner(QIODevice* io) + : m_allowSpecialNumbers(false), + m_io (io), + m_criticalError(false) +{ +} + +void JSonScanner::allowSpecialNumbers(bool allow) { + m_allowSpecialNumbers = allow; +} + +int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc) { + m_yylval = yylval; + m_yylloc = yylloc; + m_yylloc->step(); + int result = yylex(); + + if (m_criticalError) { + return -1; + } + + return result; +} + +int JSonScanner::LexerInput(char* buf, int max_size) { + if (!m_io->isOpen()) { + qCritical() << "JSonScanner::yylex - io device is not open"; + m_criticalError = true; + return 0; + } + + int readBytes = m_io->read(buf, max_size); + if(readBytes < 0) { + qCritical() << "JSonScanner::yylex - error while reading from io device"; + m_criticalError = true; + return 0; + } + + return readBytes; +} + + diff --git a/src/http/qjson/json_scanner.h b/src/http/qjson/json_scanner.h new file mode 100644 index 000000000..0282be4ac --- /dev/null +++ b/src/http/qjson/json_scanner.h @@ -0,0 +1,60 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _JSON_SCANNER +#define _JSON_SCANNER + +#include +#include + +#define YYSTYPE QVariant + +// Only include FlexLexer.h if it hasn't been already included +#if ! defined(yyFlexLexerOnce) +#include +#endif + +#include "parser_p.h" + +namespace yy { + class location; + int yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver); +} + +class JSonScanner : public yyFlexLexer +{ + public: + explicit JSonScanner(QIODevice* io); + void allowSpecialNumbers(bool allow); + + int yylex(YYSTYPE* yylval, yy::location *yylloc); + int yylex(); + int LexerInput(char* buf, int max_size); + protected: + bool m_allowSpecialNumbers; + QIODevice* m_io; + + YYSTYPE* m_yylval; + yy::location* m_yylloc; + bool m_criticalError; + QString m_currentString; +}; + +#endif diff --git a/src/http/qjson/json_scanner.yy b/src/http/qjson/json_scanner.yy new file mode 100644 index 000000000..1adc4f8ce --- /dev/null +++ b/src/http/qjson/json_scanner.yy @@ -0,0 +1,248 @@ +/* This file is part of QJson + * + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110yy::json_parser::token::INVALID301, USA. + */ + +/* Flex output settings */ +%option 8bit c++ full warn +%option noyywrap nounistd +%option noinput nounput noyy_push_state noyy_pop_state noyy_top_state noyy_scan_buffer noyy_scan_bytes noyy_scan_string noyyget_extra noyyset_extra noyyget_leng noyyget_text noyyget_lineno noyyset_lineno noyyget_in noyyset_in noyyget_out noyyset_out noyyget_lval noyyset_lval noyyget_lloc noyyset_lloc noyyget_debug noyyset_debug +%option yyclass="JSonScanner" +%option outfile="json_scanner.cc" + +%{ + #include "json_scanner.h" + #include "json_parser.hh" + + #define YY_USER_INIT if(m_allowSpecialNumbers) { \ + BEGIN(ALLOW_SPECIAL_NUMBERS); \ + } +%} + +/* Exclusive subscanners for strings and escaped hex sequences */ +%x QUOTMARK_OPEN HEX_OPEN + +/* Extra-JSON rules active iff m_allowSpecialNumbers is true */ +%s ALLOW_SPECIAL_NUMBERS + +%% + + /* Whitespace */ +[\v\f\t ]+ { + m_yylloc->columns(yyleng); + } + +[\r\n]+ { + m_yylloc->lines(yyleng); + } + + + /* Special values */ +true { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(true); + return yy::json_parser::token::TRUE_VAL; + } + +false { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(false); + return yy::json_parser::token::FALSE_VAL; + } + +null { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(); + return yy::json_parser::token::NULL_VAL; + } + + + /* Numbers */ +[0-9] | +[1-9][0-9]+ { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoull(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + +-[0-9] | +-[1-9][0-9]+ { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoll(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + +-?(([0-9])|([1-9][0-9]+))(\.[0-9]+)?([Ee][+\-]?[0-9]+)? { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtod(yytext, NULL)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + + /* Strings */ +\" { + m_yylloc->columns(yyleng); + BEGIN(QUOTMARK_OPEN); + } + +{ + \\\" { + m_currentString.append(QLatin1String("\"")); + } + + \\\\ { + m_currentString.append(QLatin1String("\\")); + } + + \\\/ { + m_currentString.append(QLatin1String("/")); + } + + \\b { + m_currentString.append(QLatin1String("\b")); + } + + \\f { + m_currentString.append(QLatin1String("\f")); + } + + \\n { + m_currentString.append(QLatin1String("\n")); + } + + \\r { + m_currentString.append(QLatin1String("\r")); + } + + \\t { + m_currentString.append(QLatin1String("\t")); + } + + \\u { + BEGIN(HEX_OPEN); + } + + [^\"\\]+ { + m_currentString.append(QString::fromUtf8(yytext)); + } + + \\ { + // ignore + } + + \" { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(m_currentString); + m_currentString.clear(); + BEGIN(INITIAL); + return yy::json_parser::token::STRING; + } +} + +{ + [0-9A-Fa-f]{4} { + QString hexDigits = QString::fromUtf8(yytext, yyleng); + bool ok; + ushort hexDigit1 = hexDigits.left(2).toShort(&ok, 16); + ushort hexDigit2 = hexDigits.right(2).toShort(&ok, 16); + m_currentString.append(QChar(hexDigit2, hexDigit1)); + BEGIN(QUOTMARK_OPEN); + } + + .|\n { + qCritical() << "Invalid hex string"; + m_yylloc->columns(yyleng); + *m_yylval = QVariant(QLatin1String("")); + BEGIN(QUOTMARK_OPEN); + return yy::json_parser::token::INVALID; + } +} + + + + /* "Compound type" related tokens */ +: { + m_yylloc->columns(yyleng); + return yy::json_parser::token::COLON; + } + +, { + m_yylloc->columns(yyleng); + return yy::json_parser::token::COMMA; + } + +\[ { + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_OPEN; + } + +\] { + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_CLOSE; + } + +\{ { + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_OPEN; + } + +\} { + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_CLOSE; + } + + + /* Extra-JSON numbers */ +{ + (?i:nan) { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::quiet_NaN()); + return yy::json_parser::token::NUMBER; + } + + [Ii]nfinity { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } + + -[Ii]nfinity { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(-std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } +} + + /* If all else fails */ +. { + m_yylloc->columns(yyleng); + return yy::json_parser::token::INVALID; + } + +<> return yy::json_parser::token::END; diff --git a/src/http/qjson/location.hh b/src/http/qjson/location.hh new file mode 100644 index 000000000..0bf1a74e8 --- /dev/null +++ b/src/http/qjson/location.hh @@ -0,0 +1,181 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Locations for Bison parsers in C++ + + Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file location.hh + ** Define the yy::location class. + */ + +#ifndef YY_YY_LOCATION_HH_INCLUDED +# define YY_YY_LOCATION_HH_INCLUDED + +# include "position.hh" + + +namespace yy { +/* Line 166 of location.cc */ +#line 47 "location.hh" + + /// Abstract a location. + class location + { + public: + + /// Construct a location from \a b to \a e. + location (const position& b, const position& e) + : begin (b) + , end (e) + { + } + + /// Construct a 0-width location in \a p. + explicit location (const position& p = position ()) + : begin (p) + , end (p) + { + } + + /// Construct a 0-width location in \a f, \a l, \a c. + explicit location (std::string* f, + unsigned int l = 1u, + unsigned int c = 1u) + : begin (f, l, c) + , end (f, l, c) + { + } + + + /// Initialization. + void initialize (std::string* f = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + { + begin.initialize (f, l, c); + end = begin; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// Reset initial location to final location. + void step () + { + begin = end; + } + + /// Extend the current location to the COUNT next columns. + void columns (unsigned int count = 1) + { + end += count; + } + + /// Extend the current location to the COUNT next lines. + void lines (unsigned int count = 1) + { + end.lines (count); + } + /** \} */ + + + public: + /// Beginning of the located region. + position begin; + /// End of the located region. + position end; + }; + + /// Join two location objects to create a location. + inline const location operator+ (const location& begin, const location& end) + { + location res = begin; + res.end = end.end; + return res; + } + + /// Add two location objects. + inline const location operator+ (const location& begin, unsigned int width) + { + location res = begin; + res.columns (width); + return res; + } + + /// Add and assign a location. + inline location& operator+= (location& res, unsigned int width) + { + res.columns (width); + return res; + } + + /// Compare two location objects. + inline bool + operator== (const location& loc1, const location& loc2) + { + return loc1.begin == loc2.begin && loc1.end == loc2.end; + } + + /// Compare two location objects. + inline bool + operator!= (const location& loc1, const location& loc2) + { + return !(loc1 == loc2); + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param loc a reference to the location to redirect + ** + ** Avoid duplicate information. + */ + template + inline std::basic_ostream& + operator<< (std::basic_ostream& ostr, const location& loc) + { + position last = loc.end - 1; + ostr << loc.begin; + if (last.filename + && (!loc.begin.filename + || *loc.begin.filename != *last.filename)) + ostr << '-' << last; + else if (loc.begin.line != last.line) + ostr << '-' << last.line << '.' << last.column; + else if (loc.begin.column != last.column) + ostr << '-' << last.column; + return ostr; + } + + +} // yy +/* Line 296 of location.cc */ +#line 180 "location.hh" + +#endif /* !YY_YY_LOCATION_HH_INCLUDED */ diff --git a/src/http/qjson/parser.cpp b/src/http/qjson/parser.cpp new file mode 100644 index 000000000..e203b876f --- /dev/null +++ b/src/http/qjson/parser.cpp @@ -0,0 +1,125 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parser.h" +#include "parser_p.h" +#include "json_parser.hh" +#include "json_scanner.h" + +#include +#include +#include +#include + +using namespace QJson; + +ParserPrivate::ParserPrivate() : + m_scanner(0) + , m_negate(false) + , m_error(false) + , m_errorLine(0) + , m_specialNumbersAllowed(false) +{ +} + +ParserPrivate::~ParserPrivate() +{ + delete m_scanner; +} + +void ParserPrivate::setError(QString errorMsg, int errorLine) { + m_error = true; + m_errorMsg = errorMsg; + m_errorLine = errorLine; +} + +Parser::Parser() : + d(new ParserPrivate) +{ +} + +Parser::~Parser() +{ + delete d; +} + +QVariant Parser::parse (QIODevice* io, bool* ok) +{ + d->m_errorMsg.clear(); + delete d->m_scanner; + d->m_scanner = 0; + + if (!io->isOpen()) { + if (!io->open(QIODevice::ReadOnly)) { + if (ok != 0) + *ok = false; + qCritical ("Error opening device"); + return QVariant(); + } + } + + if (!io->isReadable()) { + if (ok != 0) + *ok = false; + qCritical ("Device is not readable"); + io->close(); + return QVariant(); + } + + d->m_scanner = new JSonScanner (io); + d->m_scanner->allowSpecialNumbers(d->m_specialNumbersAllowed); + yy::json_parser parser(d); + parser.parse(); + + delete d->m_scanner; + d->m_scanner = 0; + + if (ok != 0) + *ok = !d->m_error; + + io->close(); + return d->m_result; +} + +QVariant Parser::parse(const QByteArray& jsonString, bool* ok) { + QBuffer buffer; + buffer.open(QBuffer::ReadWrite); + buffer.write(jsonString); + buffer.seek(0); + return parse (&buffer, ok); +} + +QString Parser::errorString() const +{ + return d->m_errorMsg; +} + +int Parser::errorLine() const +{ + return d->m_errorLine; +} + +void QJson::Parser::allowSpecialNumbers(bool allowSpecialNumbers) { + d->m_specialNumbersAllowed = allowSpecialNumbers; +} + +bool Parser::specialNumbersAllowed() const { + return d->m_specialNumbersAllowed; +} diff --git a/src/http/qjson/parser.h b/src/http/qjson/parser.h new file mode 100644 index 000000000..c3132f506 --- /dev/null +++ b/src/http/qjson/parser.h @@ -0,0 +1,99 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_PARSER_H +#define QJSON_PARSER_H + +#include "qjson_export.h" + +QT_BEGIN_NAMESPACE +class QIODevice; +class QVariant; +QT_END_NAMESPACE + +/** + * Namespace used by QJson + */ +namespace QJson { + + class ParserPrivate; + + /** + * @brief Main class used to convert JSON data to QVariant objects + */ + class QJSON_EXPORT Parser + { + public: + Parser(); + ~Parser(); + + /** + * Read JSON string from the I/O Device and converts it to a QVariant object + * @param io Input output device + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. + * @returns a QVariant object generated from the JSON string + */ + QVariant parse(QIODevice* io, bool* ok = 0); + + /** + * This is a method provided for convenience. + * @param jsonData data containing the JSON object representation + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. + * @returns a QVariant object generated from the JSON string + * @sa errorString + * @sa errorLine + */ + QVariant parse(const QByteArray& jsonData, bool* ok = 0); + + /** + * This method returns the error message + * @returns a QString object containing the error message of the last parse operation + * @sa errorLine + */ + QString errorString() const; + + /** + * This method returns line number where the error occurred + * @returns the line number where the error occurred + * @sa errorString + */ + int errorLine() const; + + /** + * Sets whether special numbers (Infinity, -Infinity, NaN) are allowed as an extension to + * the standard + * @param allowSpecialNumbers new value of whether special numbers are allowed + * @sa specialNumbersAllowed + */ + void allowSpecialNumbers(bool allowSpecialNumbers); + + /** + * @returns whether special numbers (Infinity, -Infinity, NaN) are allowed + * @sa allowSpecialNumbers + */ + bool specialNumbersAllowed() const; + + private: + Q_DISABLE_COPY(Parser) + ParserPrivate* const d; + }; +} + +#endif // QJSON_PARSER_H diff --git a/src/http/qjson/parser_p.h b/src/http/qjson/parser_p.h new file mode 100644 index 000000000..aae86a124 --- /dev/null +++ b/src/http/qjson/parser_p.h @@ -0,0 +1,56 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2009 Michael Leupold + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_PARSER_P_H +#define QJSON_PARSER_P_H + +#include "parser.h" + +#include +#include + +class JSonScanner; + +namespace yy { + class json_parser; +} + +namespace QJson { + + class ParserPrivate + { + public: + ParserPrivate(); + ~ParserPrivate(); + + void setError(QString errorMsg, int line); + + JSonScanner* m_scanner; + bool m_negate; + bool m_error; + int m_errorLine; + QString m_errorMsg; + QVariant m_result; + bool m_specialNumbersAllowed; + }; +} + +#endif // QJSON_PARSER_H diff --git a/src/http/qjson/parserrunnable.cpp b/src/http/qjson/parserrunnable.cpp new file mode 100644 index 000000000..88baf4cf6 --- /dev/null +++ b/src/http/qjson/parserrunnable.cpp @@ -0,0 +1,68 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parserrunnable.h" + +#include "parser.h" + +#include +#include + +using namespace QJson; + +class QJson::ParserRunnable::Private +{ + public: + QByteArray m_data; +}; + +ParserRunnable::ParserRunnable(QObject* parent) + : QObject(parent), + QRunnable(), + d(new Private) +{ + qRegisterMetaType("QVariant"); +} + +ParserRunnable::~ParserRunnable() +{ + delete d; +} + +void ParserRunnable::setData( const QByteArray& data ) { + d->m_data = data; +} + +void ParserRunnable::run() +{ + qDebug() << Q_FUNC_INFO; + + bool ok; + Parser parser; + QVariant result = parser.parse (d->m_data, &ok); + if (ok) { + qDebug() << "successfully converted json item to QVariant object"; + emit parsingFinished(result, true, QString()); + } else { + const QString errorText = tr("An error occurred while parsing json: %1").arg(parser.errorString()); + qCritical() << errorText; + emit parsingFinished(QVariant(), false, errorText); + } +} diff --git a/src/http/qjson/parserrunnable.h b/src/http/qjson/parserrunnable.h new file mode 100644 index 000000000..fddcacd3f --- /dev/null +++ b/src/http/qjson/parserrunnable.h @@ -0,0 +1,64 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef PARSERRUNNABLE_H +#define PARSERRUNNABLE_H + +#include "qjson_export.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QVariant; +QT_END_NAMESPACE + +namespace QJson { + /** + * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread + */ + class QJSON_EXPORT ParserRunnable : public QObject, public QRunnable + { + Q_OBJECT + public: + explicit ParserRunnable(QObject* parent = 0); + ~ParserRunnable(); + + void setData( const QByteArray& data ); + + void run(); + + Q_SIGNALS: + /** + * This signal is emitted when the parsing process has been completed + * @param json contains the result of the parsing + * @param ok if a parsing error occurs ok is set to false, otherwise it's set to true. + * @param error_msg contains a string explaining the failure reason + **/ + void parsingFinished(const QVariant& json, bool ok, const QString& error_msg); + + private: + Q_DISABLE_COPY(ParserRunnable) + class Private; + Private* const d; + }; +} + +#endif // PARSERRUNNABLE_H diff --git a/src/http/qjson/position.hh b/src/http/qjson/position.hh new file mode 100644 index 000000000..3b33c2734 --- /dev/null +++ b/src/http/qjson/position.hh @@ -0,0 +1,172 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Positions for Bison parsers in C++ + + Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file position.hh + ** Define the yy::position class. + */ + +#ifndef YY_YY_POSITION_HH_INCLUDED +# define YY_YY_POSITION_HH_INCLUDED + +# include // std::max +# include +# include + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif + + +namespace yy { +/* Line 36 of location.cc */ +#line 57 "position.hh" + /// Abstract a position. + class position + { + public: + + /// Construct a position. + explicit position (std::string* f = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + : filename (f) + , line (l) + , column (c) + { + } + + + /// Initialization. + void initialize (std::string* fn = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + { + filename = fn; + line = l; + column = c; + } + + /** \name Line and Column related manipulators + ** \{ */ + /// (line related) Advance to the COUNT next lines. + void lines (int count = 1) + { + column = 1u; + line += count; + } + + /// (column related) Advance to the COUNT next columns. + void columns (int count = 1) + { + column = std::max (1u, column + count); + } + /** \} */ + + /// File name to which this position refers. + std::string* filename; + /// Current line number. + unsigned int line; + /// Current column number. + unsigned int column; + }; + + /// Add and assign a position. + inline position& + operator+= (position& res, const int width) + { + res.columns (width); + return res; + } + + /// Add two position objects. + inline const position + operator+ (const position& begin, const int width) + { + position res = begin; + return res += width; + } + + /// Add and assign a position. + inline position& + operator-= (position& res, const int width) + { + return res += -width; + } + + /// Add two position objects. + inline const position + operator- (const position& begin, const int width) + { + return begin + -width; + } + + /// Compare two position objects. + inline bool + operator== (const position& pos1, const position& pos2) + { + return (pos1.line == pos2.line + && pos1.column == pos2.column + && (pos1.filename == pos2.filename + || (pos1.filename && pos2.filename + && *pos1.filename == *pos2.filename))); + } + + /// Compare two position objects. + inline bool + operator!= (const position& pos1, const position& pos2) + { + return !(pos1 == pos2); + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param pos a reference to the position to redirect + */ + template + inline std::basic_ostream& + operator<< (std::basic_ostream& ostr, const position& pos) + { + if (pos.filename) + ostr << *pos.filename << ':'; + return ostr << pos.line << '.' << pos.column; + } + + +} // yy +/* Line 148 of location.cc */ +#line 172 "position.hh" +#endif /* !YY_YY_POSITION_HH_INCLUDED */ diff --git a/src/http/qjson/qjson_debug.h b/src/http/qjson/qjson_debug.h new file mode 100644 index 000000000..6036b2268 --- /dev/null +++ b/src/http/qjson/qjson_debug.h @@ -0,0 +1,34 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Michael Leupold + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_DEBUG_H +#define QJSON_DEBUG_H + +#include + +// define qjsonDebug() +#ifdef QJSON_VERBOSE_DEBUG_OUTPUT + inline QDebug qjsonDebug() { return QDebug(QtDebugMsg); } +#else + #define qjsonDebug() if(false) QDebug(QtDebugMsg) +#endif + +#endif diff --git a/src/http/qjson/qjson_export.h b/src/http/qjson/qjson_export.h new file mode 100644 index 000000000..9a807b91b --- /dev/null +++ b/src/http/qjson/qjson_export.h @@ -0,0 +1,35 @@ +/* This file is part of the KDE project + Copyright (C) 2009 Pino Toscano + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1, as published by the Free Software Foundation. + + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef QJSON_EXPORT_H +#define QJSON_EXPORT_H + +#include + +#ifndef QJSON_EXPORT +# if defined(QJSON_MAKEDLL) + /* We are building this library */ +# define QJSON_EXPORT Q_DECL_EXPORT +# else + /* We are using this library */ +# define QJSON_EXPORT Q_DECL_IMPORT +# endif +#endif + +#endif diff --git a/src/http/qjson/qobjecthelper.cpp b/src/http/qjson/qobjecthelper.cpp new file mode 100644 index 000000000..4f8daf722 --- /dev/null +++ b/src/http/qjson/qobjecthelper.cpp @@ -0,0 +1,85 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + + +#include "qobjecthelper.h" + +#include +#include +#include + +using namespace QJson; + +class QObjectHelper::QObjectHelperPrivate { +}; + +QObjectHelper::QObjectHelper() + : d (new QObjectHelperPrivate) +{ +} + +QObjectHelper::~QObjectHelper() +{ + delete d; +} + +QVariantMap QObjectHelper::qobject2qvariant( const QObject* object, + const QStringList& ignoredProperties) +{ + QVariantMap result; + const QMetaObject *metaobject = object->metaObject(); + int count = metaobject->propertyCount(); + for (int i=0; iproperty(i); + const char *name = metaproperty.name(); + + if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable())) + continue; + + QVariant value = object->property(name); + result[QLatin1String(name)] = value; + } + return result; +} + +void QObjectHelper::qvariant2qobject(const QVariantMap& variant, QObject* object) +{ + const QMetaObject *metaobject = object->metaObject(); + + QVariantMap::const_iterator iter; + for (iter = variant.constBegin(); iter != variant.constEnd(); ++iter) { + int pIdx = metaobject->indexOfProperty( iter.key().toLatin1() ); + + if ( pIdx < 0 ) { + continue; + } + + QMetaProperty metaproperty = metaobject->property( pIdx ); + QVariant::Type type = metaproperty.type(); + QVariant v( iter.value() ); + if ( v.canConvert( type ) ) { + v.convert( type ); + metaproperty.write( object, v ); + } else if (QString(QLatin1String("QVariant")).compare(QLatin1String(metaproperty.typeName())) == 0) { + metaproperty.write( object, v ); + } + } +} diff --git a/src/http/qjson/qobjecthelper.h b/src/http/qjson/qobjecthelper.h new file mode 100644 index 000000000..e4dfed0c8 --- /dev/null +++ b/src/http/qjson/qobjecthelper.h @@ -0,0 +1,147 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QOBJECTHELPER_H +#define QOBJECTHELPER_H + +#include "qjson_export.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QObject; +QT_END_NAMESPACE + +namespace QJson { + /** + * @brief Class used to convert QObject into QVariant and vivce-versa. + * During these operations only the class attributes defined as properties will + * be considered. + * Properties marked as 'non-stored' will be ignored. + * + * Suppose the declaration of the Person class looks like this: + * \code + * class Person : public QObject + { + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber) + Q_PROPERTY(Gender gender READ gender WRITE setGender) + Q_PROPERTY(QDate dob READ dob WRITE setDob) + Q_ENUMS(Gender) + + public: + Person(QObject* parent = 0); + ~Person(); + + QString name() const; + void setName(const QString& name); + + int phoneNumber() const; + void setPhoneNumber(const int phoneNumber); + + enum Gender {Male, Female}; + void setGender(Gender gender); + Gender gender() const; + + QDate dob() const; + void setDob(const QDate& dob); + + private: + QString m_name; + int m_phoneNumber; + Gender m_gender; + QDate m_dob; + }; + \endcode + + The following code will serialize an instance of Person to JSON : + + \code + Person person; + person.setName("Flavio"); + person.setPhoneNumber(123456); + person.setGender(Person::Male); + person.setDob(QDate(1982, 7, 12)); + + QVariantMap variant = QObjectHelper::qobject2qvariant(&person); + Serializer serializer; + qDebug() << serializer.serialize( variant); + \endcode + + The generated output will be: + \code + { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } + \endcode + + It's also possible to initialize a QObject using the values stored inside of + a QVariantMap. + + Suppose you have the following JSON data stored into a QString: + \code + { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } + \endcode + + The following code will initialize an already allocated instance of Person + using the JSON values: + \code + Parser parser; + QVariant variant = parser.parse(json); + + Person person; + QObjectHelper::qvariant2qobject(variant.toMap(), &person); + \endcode + + \sa Parser + \sa Serializer + */ + class QJSON_EXPORT QObjectHelper { + public: + QObjectHelper(); + ~QObjectHelper(); + + /** + * This method converts a QObject instance into a QVariantMap. + * + * @param object The QObject instance to be converted. + * @param ignoredProperties Properties that won't be converted. + */ + static QVariantMap qobject2qvariant( const QObject* object, + const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName")))); + + /** + * This method converts a QVariantMap instance into a QObject + * + * @param variant Attributes to assign to the object. + * @param object The QObject instance to update. + */ + static void qvariant2qobject(const QVariantMap& variant, QObject* object); + + private: + Q_DISABLE_COPY(QObjectHelper) + class QObjectHelperPrivate; + QObjectHelperPrivate* const d; + }; +} + +#endif // QOBJECTHELPER_H diff --git a/src/http/qjson/serializer.cpp b/src/http/qjson/serializer.cpp new file mode 100644 index 000000000..8e9d8b457 --- /dev/null +++ b/src/http/qjson/serializer.cpp @@ -0,0 +1,410 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "serializer.h" + +#include +#include +#include + +#include + +#ifdef _MSC_VER // using MSVC compiler +#include +#endif + +using namespace QJson; + +class Serializer::SerializerPrivate { + public: + SerializerPrivate() : + specialNumbersAllowed(false), + indentMode(QJson::IndentNone), + doublePrecision(6) { + errorMessage.clear(); + } + QString errorMessage; + bool specialNumbersAllowed; + IndentMode indentMode; + int doublePrecision; + QByteArray buildIndent(int spaces); + QByteArray serialize( const QVariant &v, bool *ok, int indentLevel = 0); + QString sanitizeString( QString str ); + QByteArray join( const QList& list, const QByteArray& sep ); +}; + +QByteArray Serializer::SerializerPrivate::join( const QList& list, const QByteArray& sep ) { + QByteArray res; + Q_FOREACH( const QByteArray& i, list ) { + if ( !res.isEmpty() ) + res += sep; + res += i; + } + return res; +} + +QByteArray Serializer::SerializerPrivate::serialize( const QVariant &v, bool *ok, int indentLevel) +{ + QByteArray str; + + if ( ! v.isValid() ) { // invalid or null? + str = "null"; + } else if (( v.type() == QVariant::List ) || ( v.type() == QVariant::StringList )){ // an array or a stringlist? + const QVariantList list = v.toList(); + QList values; + Q_FOREACH( const QVariant& var, list ) + { + indentLevel++; + QByteArray serializedValue = serialize( var, ok, indentLevel); + indentLevel--; + if ( !*ok ) { + break; + } + values << serializedValue; + } + + if (indentMode == QJson::IndentMinimum) { + QByteArray indent = buildIndent(indentLevel - 1); + str = "[\n" + join( values, ",\n" ) + "\n" + indent + "]"; + } + else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + str = "[\n" + join( values, ",\n" ) + "\n" + indent + "]"; + } + else if (indentMode == QJson::IndentCompact) { + str = "[" + join( values, "," ) + "]"; + } + else { + str = "[ " + join( values, ", " ) + " ]"; + } + + } else if ( v.type() == QVariant::Map ) { // variant is a map? + const QVariantMap vmap = v.toMap(); + QMapIterator it( vmap ); + + if (indentMode == QJson::IndentMinimum) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "{ "; + } + else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + QByteArray nextindent = buildIndent(indentLevel + 1); + str = indent + "{\n" + nextindent; + } + else if (indentMode == QJson::IndentCompact) { + str = "{"; + } + else { + str = "{ "; + } + + QList pairs; + while ( it.hasNext() ) { + it.next(); + indentLevel++; + QByteArray serializedValue = serialize( it.value(), ok, indentLevel); + indentLevel--; + if ( !*ok ) { + break; + } + QByteArray key = sanitizeString( it.key() ).toUtf8(); + QByteArray value = serializedValue; + if (indentMode == QJson::IndentCompact) { + pairs << key + ":" + value; + } else { + pairs << key + " : " + value; + } + } + + if (indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel + 1); + str += join( pairs, ",\n" + indent); + } + else if (indentMode == QJson::IndentCompact) { + str += join( pairs, "," ); + } + else { + str += join( pairs, ", " ); + } + + if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + str += "\n" + indent + "}"; + } + else if (indentMode == QJson::IndentCompact) { + str += "}"; + } + else { + str += " }"; + } + + } else if ( v.type() == QVariant::Hash ) { // variant is a hash? + const QVariantHash vhash = v.toHash(); + QHashIterator it( vhash ); + + if (indentMode == QJson::IndentMinimum) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "{ "; + } + else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + QByteArray nextindent = buildIndent(indentLevel + 1); + str = indent + "{\n" + nextindent; + } + else if (indentMode == QJson::IndentCompact) { + str = "{"; + } + else { + str = "{ "; + } + + QList pairs; + while ( it.hasNext() ) { + it.next(); + indentLevel++; + QByteArray serializedValue = serialize( it.value(), ok, indentLevel); + indentLevel--; + if ( !*ok ) { + break; + } + QByteArray key = sanitizeString( it.key() ).toUtf8(); + QByteArray value = serializedValue; + if (indentMode == QJson::IndentCompact) { + pairs << key + ":" + value; + } else { + pairs << key + " : " + value; + } + } + + if (indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel + 1); + str += join( pairs, ",\n" + indent); + } + else if (indentMode == QJson::IndentCompact) { + str += join( pairs, "," ); + } + else { + str += join( pairs, ", " ); + } + + if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + str += "\n" + indent + "}"; + } + else if (indentMode == QJson::IndentCompact) { + str += "}"; + } + else { + str += " }"; + } + + } else if (( v.type() == QVariant::String ) || ( v.type() == QVariant::ByteArray )) { // a string or a byte array? + str = sanitizeString( v.toString() ).toUtf8(); + } else if (( v.type() == QVariant::Double) || ((QMetaType::Type)v.type() == QMetaType::Float)) { // a double or a float? + const double value = v.toDouble(); +#if defined _WIN32 && !defined(Q_OS_SYMBIAN) + const bool special = _isnan(value) || !_finite(value); +#elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) + const bool special = isnan(value) || isinf(value); +#else + const bool special = std::isnan(value) || std::isinf(value); +#endif + if (special) { + if (specialNumbersAllowed) { +#if defined _WIN32 && !defined(Q_OS_SYMBIAN) + if (_isnan(value)) { +#elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) + if (isnan(value)) { +#else + if (std::isnan(value)) { +#endif + str += "NaN"; + } else { + if (value<0) { + str += '-'; + } + str += "Infinity"; + } + } else { + errorMessage += QLatin1String("Attempt to write NaN or infinity, which is not supported by json\n"); + *ok = false; + } + } else { + str = QByteArray::number( value , 'g', doublePrecision); + if( ! str.contains( "." ) && ! str.contains( "e" ) ) { + str += ".0"; + } + } + } else if ( v.type() == QVariant::Bool ) { // boolean value? + str = ( v.toBool() ? "true" : "false" ); + } else if ( v.type() == QVariant::ULongLong ) { // large unsigned number? + str = QByteArray::number( v.value() ); + } else if ( v.type() == QVariant::UInt ) { // unsigned int number? + str = QByteArray::number( v.value() ); + } else if ( v.canConvert() ) { // any signed number? + str = QByteArray::number( v.value() ); + } else if ( v.canConvert() ) { // unsigned short number? + str = QByteArray::number( v.value() ); + } else if ( v.canConvert() ){ // can value be converted to string? + // this will catch QDate, QDateTime, QUrl, ... + str = sanitizeString( v.toString() ).toUtf8(); + //TODO: catch other values like QImage, QRect, ... + } else { + *ok = false; + errorMessage += QLatin1String("Cannot serialize "); + errorMessage += v.toString(); + errorMessage += QLatin1String(" because type "); + errorMessage += QLatin1String(v.typeName()); + errorMessage += QLatin1String(" is not supported by QJson\n"); + } + if ( *ok ) + { + return str; + } + else + return QByteArray(); +} + +QByteArray Serializer::SerializerPrivate::buildIndent(int spaces) +{ + QByteArray indent; + if (spaces < 0) { + spaces = 0; + } + for (int i = 0; i < spaces; i++ ) { + indent += " "; + } + return indent; +} + +QString Serializer::SerializerPrivate::sanitizeString( QString str ) +{ + str.replace( QLatin1String( "\\" ), QLatin1String( "\\\\" ) ); + + // escape unicode chars + QString result; + const ushort* unicode = str.utf16(); + unsigned int i = 0; + + while ( unicode[ i ] ) { + if ( unicode[ i ] < 128 ) { + result.append( QChar( unicode[ i ] ) ); + } + else { + QString hexCode = QString::number( unicode[ i ], 16 ).rightJustified( 4, + QLatin1Char('0') ); + + result.append( QLatin1String ("\\u") ).append( hexCode ); + } + ++i; + } + str = result; + + str.replace( QLatin1String( "\"" ), QLatin1String( "\\\"" ) ); + str.replace( QLatin1String( "\b" ), QLatin1String( "\\b" ) ); + str.replace( QLatin1String( "\f" ), QLatin1String( "\\f" ) ); + str.replace( QLatin1String( "\n" ), QLatin1String( "\\n" ) ); + str.replace( QLatin1String( "\r" ), QLatin1String( "\\r" ) ); + str.replace( QLatin1String( "\t" ), QLatin1String( "\\t" ) ); + + return QString( QLatin1String( "\"%1\"" ) ).arg( str ); +} + +Serializer::Serializer() + : d( new SerializerPrivate ) +{ +} + +Serializer::~Serializer() { + delete d; +} + +void Serializer::serialize( const QVariant& v, QIODevice* io, bool* ok) +{ + Q_ASSERT( io ); + *ok = true; + + if (!io->isOpen()) { + if (!io->open(QIODevice::WriteOnly)) { + d->errorMessage = QLatin1String("Error opening device"); + *ok = false; + return; + } + } + + if (!io->isWritable()) { + d->errorMessage = QLatin1String("Device is not readable"); + io->close(); + *ok = false; + return; + } + + const QByteArray str = serialize( v, ok); + if (*ok && (io->write(str) != str.count())) { + *ok = false; + d->errorMessage = QLatin1String("Something went wrong while writing to IO device"); + } +} + +QByteArray Serializer::serialize( const QVariant &v) +{ + bool ok; + + return serialize(v, &ok); +} + +QByteArray Serializer::serialize( const QVariant &v, bool *ok) +{ + bool _ok = true; + d->errorMessage.clear(); + + if (ok) { + *ok = true; + } else { + ok = &_ok; + } + + return d->serialize(v, ok); +} + +void QJson::Serializer::allowSpecialNumbers(bool allow) { + d->specialNumbersAllowed = allow; +} + +bool QJson::Serializer::specialNumbersAllowed() const { + return d->specialNumbersAllowed; +} + +void QJson::Serializer::setIndentMode(IndentMode mode) { + d->indentMode = mode; +} + +void QJson::Serializer::setDoublePrecision(int precision) { + d->doublePrecision = precision; +} + +IndentMode QJson::Serializer::indentMode() const { + return d->indentMode; +} + +QString QJson::Serializer::errorMessage() const { + return d->errorMessage; +} + diff --git a/src/http/qjson/serializer.h b/src/http/qjson/serializer.h new file mode 100644 index 000000000..af4ce49d2 --- /dev/null +++ b/src/http/qjson/serializer.h @@ -0,0 +1,191 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_SERIALIZER_H +#define QJSON_SERIALIZER_H + +#include "qjson_export.h" + +QT_BEGIN_NAMESPACE +class QIODevice; +class QString; +class QVariant; +QT_END_NAMESPACE + +namespace QJson { + /** + @brief How the indentation should work. + \verbatim + none (default) : { "foo" : 0, "foo1" : 1, "foo2" : [ { "foo3" : 3, "foo4" : 4 } ] } + + compact : {"foo":0,"foo1":1,"foo2":[{"foo3":3,"foo4":4}]} + + minimum : { "foo" : 0, "foo1" : 1, "foo2" : [ + { "foo3" : 3, "foo4" : 4 } + ] } + + medium : { + "foo" : 0, "foo1" : 1, "foo2" : [ + { + "foo3" : 3, "foo4" : 4 + } + ] + } + full : { + "foo" : 0, + "foo1" : 1, + "foo2" : [ + { + "foo3" : 3, + "foo4" : 4 + } + ] + } + + \endverbatim + */ + enum IndentMode { + IndentNone, + IndentCompact, + IndentMinimum, + IndentMedium, + IndentFull + }; + /** + * @brief Main class used to convert QVariant objects to JSON data. + * + * QVariant objects are converted to a string containing the JSON data. + * + * + * Usage: + * + * \code + * QVariantList people; + * + * QVariantMap bob; + * bob.insert("Name", "Bob"); + * bob.insert("Phonenumber", 123); + * + * QVariantMap alice; + * alice.insert("Name", "Alice"); + * alice.insert("Phonenumber", 321); + * + * people << bob << alice; + * + * QJson::Serializer serializer; + * bool ok; + * QByteArray json = serializer.serialize(people, &ok); + * + * if (ok) { + * qDebug() << json; + * } else { + * qCritical() << "Something went wrong:" << serializer.errorMessage(); + * } + * \endcode + * + * The output will be: + * + * \code + * "[ { "Name" : "Bob", "Phonenumber" : 123 }, + * { "Name" : "Alice", "Phonenumber" : 321 } ]" + * \endcode + * + * It's possible to tune the indentation level of the resulting string. \sa setIndentMode + */ + class QJSON_EXPORT Serializer { + public: + Serializer(); + ~Serializer(); + + /** + * This method generates a textual JSON representation and outputs it to the + * passed in I/O Device. + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * @param out Input output device + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true + */ + void serialize( const QVariant& variant, QIODevice* out, bool* ok); + + /** + * This is a method provided for convenience. It turns the passed in in-memory + * representation of the JSON document into a textual one, which is returned. + * If the returned string is empty, the document was empty. If it was null, there + * was a parsing error. + * + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * + * \deprecated This method is going to be removed with the next major release of QJson. + */ + QByteArray serialize( const QVariant& variant); + + /** + * This is a method provided for convenience. It turns the passed in in-memory + * representation of the JSON document into a textual one, which is returned. + * If the returned string is empty, the document was empty. If it was null, there + * was a parsing error. + * + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true + */ + QByteArray serialize( const QVariant& variant, bool *ok); + + /** + * Allow or disallow writing of NaN and/or Infinity (as an extension to QJson) + */ + void allowSpecialNumbers(bool allow); + + /** + * Is Nan and/or Infinity allowed? + */ + bool specialNumbersAllowed() const; + + /** + * set output indentation mode as defined in QJson::IndentMode + */ + void setIndentMode(IndentMode mode = QJson::IndentNone); + + + /** + * set double precision used while converting Double + * \sa QByteArray::number + */ + void setDoublePrecision(int precision); + + /** + * Returns one of the indentation modes defined in QJson::IndentMode + */ + IndentMode indentMode() const; + + /** + * Returns the error message + */ + QString errorMessage() const; + + private: + Q_DISABLE_COPY(Serializer) + class SerializerPrivate; + SerializerPrivate* const d; + }; +} + +#endif // QJSON_SERIALIZER_H diff --git a/src/http/qjson/serializerrunnable.cpp b/src/http/qjson/serializerrunnable.cpp new file mode 100644 index 000000000..b1894a238 --- /dev/null +++ b/src/http/qjson/serializerrunnable.cpp @@ -0,0 +1,62 @@ +#include "serializerrunnable.h" + +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * 2009 Frank Osterfeld + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parserrunnable.h" +#include "serializer.h" + +#include +#include + +using namespace QJson; + +class SerializerRunnable::Private +{ +public: + QVariant json; +}; + +SerializerRunnable::SerializerRunnable(QObject* parent) + : QObject(parent), + QRunnable(), + d(new Private) +{ + qRegisterMetaType("QVariant"); +} + +SerializerRunnable::~SerializerRunnable() +{ + delete d; +} + +void SerializerRunnable::setJsonObject( const QVariant& json ) +{ + d->json = json; +} + +void SerializerRunnable::run() +{ + Serializer serializer; + bool ok; + const QByteArray serialized = serializer.serialize( d->json, &ok); + emit parsingFinished( serialized, ok, serializer.errorMessage() ); +} diff --git a/src/http/qjson/serializerrunnable.h b/src/http/qjson/serializerrunnable.h new file mode 100644 index 000000000..1a3df7c1c --- /dev/null +++ b/src/http/qjson/serializerrunnable.h @@ -0,0 +1,71 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Frank Osterfeld + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SERIALIZERRUNNABLE_H +#define SERIALIZERRUNNABLE_H + +#include "qjson_export.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QByteArray; +class QString; +class QVariant; +QT_END_NAMESPACE + +namespace QJson { + /** + * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread + */ + class QJSON_EXPORT SerializerRunnable : public QObject, public QRunnable + { + Q_OBJECT + public: + explicit SerializerRunnable(QObject* parent = 0); + ~SerializerRunnable(); + + /** + * Sets the json object to serialize. + * + * @param json QVariant containing the json representation to be serialized + */ + void setJsonObject( const QVariant& json ); + + /* reimp */ void run(); + + Q_SIGNALS: + /** + * This signal is emitted when the serialization process has been completed + * @param serialized contains the result of the serialization + * @param ok if a serialization error occurs ok is set to false, otherwise it's set to true. + * @param error_msg contains a string explaining the failure reason + **/ + void parsingFinished(const QByteArray& serialized, bool ok, const QString& error_msg); + + private: + Q_DISABLE_COPY(SerializerRunnable) + class Private; + Private* const d; + }; +} + +#endif // SERIALIZERRUNNABLE_H diff --git a/src/http/qjson/stack.hh b/src/http/qjson/stack.hh new file mode 100644 index 000000000..590accbaf --- /dev/null +++ b/src/http/qjson/stack.hh @@ -0,0 +1,133 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Stack handling for Bison parsers in C++ + + Copyright (C) 2002-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file stack.hh + ** Define the yy::stack class. + */ + +#ifndef YY_YY_STACK_HH_INCLUDED +# define YY_YY_STACK_HH_INCLUDED + +# include + + +namespace yy { +/* Line 34 of stack.hh */ +#line 47 "stack.hh" + template > + class stack + { + public: + // Hide our reversed order. + typedef typename S::reverse_iterator iterator; + typedef typename S::const_reverse_iterator const_iterator; + + stack () : seq_ () + { + } + + stack (unsigned int n) : seq_ (n) + { + } + + inline + T& + operator [] (unsigned int i) + { + return seq_[i]; + } + + inline + const T& + operator [] (unsigned int i) const + { + return seq_[i]; + } + + inline + void + push (const T& t) + { + seq_.push_front (t); + } + + inline + void + pop (unsigned int n = 1) + { + for (; n; --n) + seq_.pop_front (); + } + + inline + unsigned int + height () const + { + return seq_.size (); + } + + inline const_iterator begin () const { return seq_.rbegin (); } + inline const_iterator end () const { return seq_.rend (); } + + private: + S seq_; + }; + + /// Present a slice of the top of a stack. + template > + class slice + { + public: + slice (const S& stack, unsigned int range) + : stack_ (stack) + , range_ (range) + { + } + + inline + const T& + operator [] (unsigned int i) const + { + return stack_[range_ - i]; + } + + private: + const S& stack_; + unsigned int range_; + }; + +} // yy +/* Line 116 of stack.hh */ +#line 132 "stack.hh" + +#endif /* !YY_YY_STACK_HH_INCLUDED */ From eef51f26f08f9c3348c25e27260b7cd4db53e799 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Thu, 11 Apr 2013 20:42:00 +0200 Subject: [PATCH 03/51] Cleaner qobject2qvariant(). --- src/http/Protocol.cpp | 25 ++----------------------- src/http/qjson/qobjecthelper.cpp | 13 +++++++++++-- src/http/qjson/qobjecthelper.h | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/http/Protocol.cpp b/src/http/Protocol.cpp index 770a1e5ad..e150d9af1 100644 --- a/src/http/Protocol.cpp +++ b/src/http/Protocol.cpp @@ -105,25 +105,6 @@ static QString encrypt(const QString & data, SymmetricCipher & cipher) return encode64(encrypt2(data.toUtf8(), cipher)); } -static QVariant qobject2qvariant(const QObject * object, const QStringList ignoredProperties = QStringList(QString(QLatin1String("objectName")))) -{ - QVariantMap result; - const QMetaObject *metaobject = object->metaObject(); - int count = metaobject->propertyCount(); - for (int i=0; iproperty(i); - const char *name = metaproperty.name(); - - if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable())) - continue; - - QVariant value = object->property(name); - if (!value.isNull() /*&& value.isValid()*/) //Do not add NULL or invalid fields - result[QLatin1String(name)] = value; - } - return result; -} - //////////////////////////////////////////////////////////////////////////////////////////////////// /// Request @@ -315,7 +296,7 @@ void Response::setVerifier(QString key) QString Response::toJson() { - QVariant result = qobject2qvariant(this); + QVariant result = QJson::QObjectHelper::qobject2qvariant(this, QJson::QObjectHelper::Flag_None); QJson::Serializer s; s.setIndentMode(QJson::IndentCompact); @@ -360,7 +341,7 @@ QVariant Response::getEntries() const QList res; res.reserve(m_entries.size()); Q_FOREACH(const Entry &entry, m_entries) - res.append(qobject2qvariant(&entry)); + res.append(QJson::QObjectHelper::qobject2qvariant(&entry, QJson::QObjectHelper::Flag_None)); return res; } @@ -427,8 +408,6 @@ void Response::setError(const QString &error) /// ResponseEntry //////////////////////////////////////////////////////////////////////////////////////////////////// -Q_DECLARE_METATYPE(Entry) - Entry::Entry() {} diff --git a/src/http/qjson/qobjecthelper.cpp b/src/http/qjson/qobjecthelper.cpp index 4f8daf722..0ea440522 100644 --- a/src/http/qjson/qobjecthelper.cpp +++ b/src/http/qjson/qobjecthelper.cpp @@ -41,8 +41,8 @@ QObjectHelper::~QObjectHelper() delete d; } -QVariantMap QObjectHelper::qobject2qvariant( const QObject* object, - const QStringList& ignoredProperties) +QVariantMap QObjectHelper::qobject2qvariant(const QObject* object, Flags flags, + const QStringList& ignoredProperties) { QVariantMap result; const QMetaObject *metaobject = object->metaObject(); @@ -55,11 +55,20 @@ QVariantMap QObjectHelper::qobject2qvariant( const QObject* object, continue; QVariant value = object->property(name); + if (value.isNull() && !flags.testFlag(Flag_StoreNullVariants)) + continue; + if (!value.isValid() && !flags.testFlag(Flag_StoreInvalidVariants)) + continue; result[QLatin1String(name)] = value; } return result; } +QVariantMap QObjectHelper::qobject2qvariant(const QObject *object, const QStringList &ignoredProperties) + { + return qobject2qvariant(object, Flag_All, ignoredProperties); + } + void QObjectHelper::qvariant2qobject(const QVariantMap& variant, QObject* object) { const QMetaObject *metaobject = object->metaObject(); diff --git a/src/http/qjson/qobjecthelper.h b/src/http/qjson/qobjecthelper.h index e4dfed0c8..9a819b448 100644 --- a/src/http/qjson/qobjecthelper.h +++ b/src/http/qjson/qobjecthelper.h @@ -120,14 +120,24 @@ namespace QJson { QObjectHelper(); ~QObjectHelper(); + enum Flag { + Flag_None, + Flag_StoreNullVariants, + Flag_StoreInvalidVariants, + Flag_All = Flag_StoreNullVariants | Flag_StoreInvalidVariants + }; + Q_DECLARE_FLAGS(Flags, Flag) + /** * This method converts a QObject instance into a QVariantMap. * * @param object The QObject instance to be converted. * @param ignoredProperties Properties that won't be converted. */ - static QVariantMap qobject2qvariant( const QObject* object, - const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName")))); + static QVariantMap qobject2qvariant(const QObject* object, Flags flags = Flag_All, + const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName")))); + static QVariantMap qobject2qvariant(const QObject* object, + const QStringList& ignoredProperties); /** * This method converts a QVariantMap instance into a QObject From ad67eac25795772ca07e6b808994cf329219147d Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Thu, 11 Apr 2013 23:19:00 +0200 Subject: [PATCH 04/51] Confirmation dialog to list entries. --- src/CMakeLists.txt | 5 ++ src/http/AccessControlDialog.cpp | 52 ++++++++++++++ src/http/AccessControlDialog.h | 42 ++++++++++++ src/http/AccessControlDialog.ui | 69 +++++++++++++++++++ src/http/EntryConfig.cpp | 100 +++++++++++++++++++++++++++ src/http/EntryConfig.h | 54 +++++++++++++++ src/http/Service.cpp | 113 ++++++++++++++++++++++++------- src/http/Service.h | 2 + 8 files changed, 414 insertions(+), 23 deletions(-) create mode 100644 src/http/AccessControlDialog.cpp create mode 100644 src/http/AccessControlDialog.h create mode 100644 src/http/AccessControlDialog.ui create mode 100644 src/http/EntryConfig.cpp create mode 100644 src/http/EntryConfig.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4e031203c..b0425c3cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,6 +101,8 @@ set(keepassx_SOURCES gui/group/EditGroupWidget.cpp gui/group/GroupModel.cpp gui/group/GroupView.cpp + http/AccessControlDialog.cpp + http/EntryConfig.cpp http/Protocol.cpp http/Server.cpp http/Service.cpp @@ -166,6 +168,8 @@ set(keepassx_MOC gui/group/EditGroupWidget.h gui/group/GroupModel.h gui/group/GroupView.h + http/AccessControlDialog.h + http/EntryConfig.h http/Protocol.h http/Server.h http/Service.h @@ -196,6 +200,7 @@ set(keepassx_FORMS gui/entry/EditEntryWidgetHistory.ui gui/entry/EditEntryWidgetMain.ui gui/group/EditGroupWidgetMain.ui + http/AccessControlDialog.ui ) if(MINGW) diff --git a/src/http/AccessControlDialog.cpp b/src/http/AccessControlDialog.cpp new file mode 100644 index 000000000..de6f0e6ba --- /dev/null +++ b/src/http/AccessControlDialog.cpp @@ -0,0 +1,52 @@ +/** + *************************************************************************** + * @file AccessControlDialog.cpp + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#include "AccessControlDialog.h" +#include "ui_AccessControlDialog.h" +#include "core/Entry.h" + +AccessControlDialog::AccessControlDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::AccessControlDialog) +{ + ui->setupUi(this); + connect(ui->allowButton, SIGNAL(clicked()), this, SLOT(accept())); + connect(ui->denyButton, SIGNAL(clicked()), this, SLOT(reject())); +} + +AccessControlDialog::~AccessControlDialog() +{ + delete ui; +} + +void AccessControlDialog::setUrl(const QString &url) +{ + ui->label->setText(QString(tr("%1 has requested access to passwords for the following item(s).\n" + "Please select whether you want to allow access.")).arg(QUrl(url).host())); +} + +void AccessControlDialog::setItems(const QList &items) +{ + Q_FOREACH (Entry * entry, items) + ui->itemsList->addItem(entry->title() + " - " + entry->username()); +} + +bool AccessControlDialog::remember() const +{ + return ui->rememberDecisionCheckBox->isChecked(); +} + +void AccessControlDialog::setRemember(bool r) +{ + ui->rememberDecisionCheckBox->setChecked(r); +} diff --git a/src/http/AccessControlDialog.h b/src/http/AccessControlDialog.h new file mode 100644 index 000000000..67a6a8492 --- /dev/null +++ b/src/http/AccessControlDialog.h @@ -0,0 +1,42 @@ +/** + *************************************************************************** + * @file AccessControlDialog.h + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#ifndef ACCESSCONTROLDIALOG_H +#define ACCESSCONTROLDIALOG_H + +#include + +class Entry; + +namespace Ui { +class AccessControlDialog; +} + +class AccessControlDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AccessControlDialog(QWidget *parent = 0); + ~AccessControlDialog(); + + void setUrl(const QString & url); + void setItems(const QList & items); + bool remember() const; + void setRemember(bool r); + +private: + Ui::AccessControlDialog *ui; +}; + +#endif // ACCESSCONTROLDIALOG_H diff --git a/src/http/AccessControlDialog.ui b/src/http/AccessControlDialog.ui new file mode 100644 index 000000000..4faed6de1 --- /dev/null +++ b/src/http/AccessControlDialog.ui @@ -0,0 +1,69 @@ + + + AccessControlDialog + + + + 0 + 0 + 400 + 221 + + + + KeyPassX/Http: Confirm Access + + + + + + + + + + + + + + + + Remember this decision + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Allow + + + + + + + Deny + + + + + + + + + + diff --git a/src/http/EntryConfig.cpp b/src/http/EntryConfig.cpp new file mode 100644 index 000000000..d5a518755 --- /dev/null +++ b/src/http/EntryConfig.cpp @@ -0,0 +1,100 @@ +/** + *************************************************************************** + * @file EntryConfig.cpp + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#include "EntryConfig.h" +#include "core/Entry.h" +#include "core/EntryAttributes.h" +#include "qjson/parser.h" +#include "qjson/qobjecthelper.h" +#include "qjson/serializer.h" + +static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings"; //TODO: duplicated string (also in Service.cpp) + +EntryConfig::EntryConfig(QObject *parent) : + QObject(parent) +{ +} + +QStringList EntryConfig::allowedHosts() const +{ + return m_allowedHosts.toList(); +} + +void EntryConfig::setAllowedHosts(const QStringList &allowedHosts) +{ + m_allowedHosts = allowedHosts.toSet(); +} + +QStringList EntryConfig::deniedHosts() const +{ + return m_deniedHosts.toList(); +} + +void EntryConfig::setDeniedHosts(const QStringList &deniedHosts) +{ + m_deniedHosts = deniedHosts.toSet(); +} + +bool EntryConfig::isAllowed(const QString &host) +{ + return m_allowedHosts.contains(host); +} + +void EntryConfig::allow(const QString &host) +{ + m_allowedHosts.insert(host); + m_deniedHosts.remove(host); +} + +bool EntryConfig::isDenied(const QString &host) +{ + return m_deniedHosts.contains(host); +} + +void EntryConfig::deny(const QString &host) +{ + m_deniedHosts.insert(host); + m_allowedHosts.remove(host); +} + +QString EntryConfig::realm() const +{ + return m_realm; +} + +void EntryConfig::setRealm(const QString &realm) +{ + m_realm = realm; +} + +bool EntryConfig::load(const Entry *entry) +{ + QString s = entry->attributes()->value(KEEPASSHTTP_NAME); + if (s.isEmpty()) + return false; + + bool isOk = false; + QVariant v = QJson::Parser().parse(s.toUtf8(), &isOk); + if (!isOk || !v.type() == QVariant::Map) + return false; + + QJson::QObjectHelper::qvariant2qobject(v.toMap(), this); + return true; +} + +void EntryConfig::save(Entry *entry) +{ + QVariant v = QJson::QObjectHelper::qobject2qvariant(this, QJson::QObjectHelper::Flag_None); + QByteArray json = QJson::Serializer().serialize(v); + entry->attributes()->set(KEEPASSHTTP_NAME, json); +} diff --git a/src/http/EntryConfig.h b/src/http/EntryConfig.h new file mode 100644 index 000000000..40633162f --- /dev/null +++ b/src/http/EntryConfig.h @@ -0,0 +1,54 @@ +/** + *************************************************************************** + * @file EntryConfig.h + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#ifndef ENTRYCONFIG_H +#define ENTRYCONFIG_H + +#include +#include +#include +#include + +class Entry; + +class EntryConfig : public QObject +{ + Q_OBJECT + Q_PROPERTY(QStringList Allow READ allowedHosts WRITE setAllowedHosts) + Q_PROPERTY(QStringList Deny READ deniedHosts WRITE setDeniedHosts ) + Q_PROPERTY(QString Realm READ realm WRITE setRealm ) + +public: + EntryConfig(QObject * object = 0); + + bool load(const Entry * entry); + void save(Entry * entry); + bool isAllowed(const QString & host); + void allow(const QString & host); + bool isDenied(const QString & host); + void deny(const QString & host); + QString realm() const; + void setRealm(const QString &realm); + +private: + QStringList allowedHosts() const; + void setAllowedHosts(const QStringList &allowedHosts); + QStringList deniedHosts() const; + void setDeniedHosts(const QStringList &deniedHosts); + + QSet m_allowedHosts; + QSet m_deniedHosts; + QString m_realm; +}; + +#endif // ENTRYCONFIG_H diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 4ade6169f..2e85932bc 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -11,17 +11,22 @@ *************************************************************************** */ +#include +#include +#include + #include "Service.h" #include "Protocol.h" +#include "EntryConfig.h" +#include "AccessControlDialog.h" + #include "core/Database.h" #include "core/Entry.h" #include "core/Group.h" #include "core/Metadata.h" #include "core/Uuid.h" #include "core/PasswordGenerator.h" -#include -#include -#include + Service::Service(DatabaseTabWidget *parent) : KeepassHttpProtocol::Server(parent), @@ -121,8 +126,8 @@ QString Service::storeKey(const QString &key) //Indicate who wants to associate, and request user to enter the 'name' of association key id = QInputDialog::getText(0, tr("KeyPassX/Http: New key association request"), tr("You have received an association request for the above key. If you would like to " - "allow it access to your KeePassX database give it a unique name to identify and a" - "ccept it."), + "allow it access to your KeePassX database give it a unique name to identify and" + "accept it."), QLineEdit::Normal, QString(), &ok); if (!ok || id.isEmpty()) return QString(); @@ -182,31 +187,83 @@ QList Service::searchEntries(const QString &text) return entries; } +Service::Access Service::checkAccess(const Entry *entry, const QString & host, const QString & submitHost, const QString & realm) +{ + EntryConfig config; + if (!config.load(entry)) + return Unknown; //not configured + if ((config.isAllowed(host)) && (submitHost.isEmpty() || config.isAllowed(submitHost))) + return Allowed; //allowed + if ((config.isDenied(host)) || (!submitHost.isEmpty() && config.isDenied(submitHost))) + return Denied; //denied + if (!realm.isEmpty() && config.realm() != realm) + return Denied; + return Unknown; //not configured for this host +} + QList Service::findMatchingEntries(const QString &id, const QString &url, const QString &submitUrl, const QString &realm) { QList result; + QList pwEntriesToConfirm; + + bool autoAccept = false; //TODO: setting! + const QString host = QUrl(url).host(); + const QString submitHost = QUrl(submitUrl).host(); const QList pwEntries = searchEntries(url); - Q_FOREACH (Entry * entry, pwEntries) { - //Filter accepted/denied entries - // if (c.Allow.Contains(formHost) && (submitHost == null || c.Allow.Contains(submitHost))) - // return true; - // if (c.Deny.Contains(formHost) || (submitHost != null && c.Deny.Contains(submitHost))) - // return false; - // if (realm != null && c.Realm != realm) - // return false; - //If we are unsure for some entries: - //- balloon to grant accessc if possible - //- if clicked, show confirmation dialog --> accept/reject (w/ list of items?) - // The website XXX wants to access your credentials - // MORE (---> if clicked, shows the list of returned entries) - // [x] Ask me again [Allow] [Deny] - // If accepted, store that entry can be accessed without confirmation - //- else, show only items which do not require validation + //Check entries for authorization + Q_FOREACH (Entry * entry, pwEntries) { + switch(checkAccess(entry, host, submitHost, realm)) { + case Denied: + continue; - //TODO: sort [--> need a flag], or do this in Server class [--> need an extra 'sort order' key in Entry, and we always compute it] - result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), entry->password(), entry->uuid().toHex()); + case Unknown: + if (!autoAccept) { + pwEntriesToConfirm.append(entry); + break; + } + //fall through + case Allowed: + result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), entry->password(), entry->uuid().toHex()); + break; + } } + + //If unsure, ask user for confirmation + if (!pwEntriesToConfirm.isEmpty()) { + //TODO: balloon to grant access + timeout + + AccessControlDialog dlg; + dlg.setUrl(url); + dlg.setItems(pwEntriesToConfirm); + //dlg.setRemember(); //TODO: setting! + + int res = dlg.exec(); + if (dlg.remember()) { + Q_FOREACH (Entry * entry, pwEntries) { + EntryConfig config; + config.load(entry); + if (res == QDialog::Accepted) { + config.allow(host); + if (!submitHost.isEmpty() && host != submitHost) + config.allow(submitHost); + } else if (res == QDialog::Rejected) { + config.deny(host); + if (!submitHost.isEmpty() && host != submitHost) + config.deny(submitHost); + } + if (!realm.isEmpty()) + config.setRealm(realm); + config.save(entry); + } + } + if (res == QDialog::Accepted) { + Q_FOREACH (Entry * entry, pwEntries) + result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), entry->password(), entry->uuid().toHex()); + } + } + + //TODO: sort [--> need a flag], or do this in Server class [--> need an extra 'sort order' key in Entry, and we always compute it] return result; } @@ -259,6 +316,16 @@ void Service::addEntry(const QString &id, const QString &login, const QString &p entry->setUsername(login); entry->setPassword(password); entry->setGroup(group); + + const QString host = QUrl(url).host(); + const QString submitHost = QUrl(submitUrl).host(); + EntryConfig config; + config.allow(host); + if (!submitHost.isEmpty()) + config.allow(submitHost); + if (!realm.isEmpty()) + config.setRealm(realm); + config.save(entry); } } diff --git a/src/http/Service.h b/src/http/Service.h index 123815b89..871a49904 100644 --- a/src/http/Service.h +++ b/src/http/Service.h @@ -39,8 +39,10 @@ public: virtual QString generatePassword(); private: + enum Access { Denied, Unknown, Allowed}; Entry* getConfigEntry(bool create = false); bool matchUrlScheme(const QString &url); + Access checkAccess(const Entry *entry, const QString & host, const QString & submitHost, const QString & realm); bool removeFirstDomain(QString &hostname); Group *findCreateAddEntryGroup(); QList searchEntries(const QString &text); From b9e58c77af516196ac71175ecafc86cf809d0ea4 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Thu, 11 Apr 2013 23:35:00 +0200 Subject: [PATCH 05/51] Use splitter in 'Additional attributes'. --- src/gui/entry/EditEntryWidgetAdvanced.ui | 32 ++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/gui/entry/EditEntryWidgetAdvanced.ui b/src/gui/entry/EditEntryWidgetAdvanced.ui index cc4dd2242..34fef4fe7 100644 --- a/src/gui/entry/EditEntryWidgetAdvanced.ui +++ b/src/gui/entry/EditEntryWidgetAdvanced.ui @@ -18,13 +18,31 @@ - - - - - - false - + + + + 0 + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + false + + + + + From f82725139acb94b86755904cc8be3c30f23a2947 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Mon, 15 Apr 2013 22:35:31 +0200 Subject: [PATCH 06/51] Support "KPH: " extra fields. --- src/http/Protocol.cpp | 80 ++++++++++++++++++++++++++++++++++++++----- src/http/Protocol.h | 34 +++++++++++++++--- src/http/Service.cpp | 22 +++++++++--- src/http/Service.h | 1 + 4 files changed, 120 insertions(+), 17 deletions(-) diff --git a/src/http/Protocol.cpp b/src/http/Protocol.cpp index e150d9af1..efe06299b 100644 --- a/src/http/Protocol.cpp +++ b/src/http/Protocol.cpp @@ -33,7 +33,8 @@ static const char * const STR_SET_LOGIN = "set-login"; static const char * const STR_ASSOCIATE = "associate"; static const char * const STR_TEST_ASSOCIATE = "test-associate"; static const char * const STR_GENERATE_PASSWORD = "generate-password"; -static const char * const STR_VERSION = "1.5.0.0"; +static const char * const STR_VERSION = "1.6.0.0"; + }/*namespace KeepassHttpProtocol*/ using namespace KeepassHttpProtocol; @@ -340,7 +341,7 @@ QVariant Response::getEntries() const QList res; res.reserve(m_entries.size()); - Q_FOREACH(const Entry &entry, m_entries) + Q_FOREACH (const Entry &entry, m_entries) res.append(QJson::QObjectHelper::qobject2qvariant(&entry, QJson::QObjectHelper::Flag_None)); return res; } @@ -353,11 +354,15 @@ void Response::setEntries(const QList &entries) QList encryptedEntries; encryptedEntries.reserve(m_count); - Q_FOREACH(const Entry &entry, entries) { - encryptedEntries << Entry(encrypt(entry.name(), m_cipher), - encrypt(entry.login(), m_cipher), - entry.password().isNull() ? QString() : encrypt(entry.password(), m_cipher), - encrypt(entry.uuid(), m_cipher)); + Q_FOREACH (const Entry &entry, entries) { + Entry encryptedEntry(encrypt(entry.name(), m_cipher), + encrypt(entry.login(), m_cipher), + entry.password().isNull() ? QString() : encrypt(entry.password(), m_cipher), + encrypt(entry.uuid(), m_cipher)); + Q_FOREACH (const StringField & field, entry.stringFields()) + encryptedEntry.addStringField(encrypt(field.key(), m_cipher), + encrypt(field.value(), m_cipher)); + encryptedEntries << encryptedEntry; } m_entries = encryptedEntries; } @@ -405,7 +410,7 @@ void Response::setError(const QString &error) //////////////////////////////////////////////////////////////////////////////////////////////////// -/// ResponseEntry +/// Entry //////////////////////////////////////////////////////////////////////////////////////////////////// Entry::Entry() @@ -423,7 +428,8 @@ Entry::Entry(const Entry & other): m_login(other.m_login), m_password(other.m_password), m_uuid(other.m_uuid), - m_name(other.m_name) + m_name(other.m_name), + m_stringFields(other.m_stringFields) {} Entry & Entry::operator=(const Entry & other) @@ -432,6 +438,7 @@ Entry & Entry::operator=(const Entry & other) m_password = other.m_password; m_uuid = other.m_uuid; m_name = other.m_name; + m_stringFields = other.m_stringFields; return *this; } @@ -454,3 +461,58 @@ QString Entry::password() const { return m_password; } + +QList Entry::stringFields() const +{ + return m_stringFields; +} + +void Entry::addStringField(const QString &key, const QString &value) +{ + m_stringFields.append(StringField(key, value)); +} + +QVariant Entry::getStringFields() const +{ + if (m_stringFields.isEmpty()) + return QVariant(); + + QList res; + res.reserve(m_stringFields.size()); + Q_FOREACH (const StringField &stringfield, m_stringFields) + res.append(QJson::QObjectHelper::qobject2qvariant(&stringfield, QJson::QObjectHelper::Flag_None)); + return res; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// StringField +//////////////////////////////////////////////////////////////////////////////////////////////////// + +StringField::StringField() +{} + +StringField::StringField(const QString &key, const QString &value): + m_key(key), m_value(value) +{} + +StringField::StringField(const StringField &other): + m_key(other.m_key), m_value(other.m_value) +{} + +StringField &StringField::operator =(const StringField &other) +{ + m_key = m_key; + m_value = m_value; + return *this; +} + +QString StringField::key() const +{ + return m_key; +} + +QString StringField::value() const +{ + return m_value; +} diff --git a/src/http/Protocol.h b/src/http/Protocol.h index b0438d554..19edb68db 100644 --- a/src/http/Protocol.h +++ b/src/http/Protocol.h @@ -99,13 +99,34 @@ private: mutable SymmetricCipher m_cipher; }; +class StringField : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString Key READ key ) + Q_PROPERTY(QString Value READ value) + +public: + StringField(); + StringField(const QString& key, const QString& value); + StringField(const StringField & other); + StringField &operator =(const StringField &other); + + QString key() const; + QString value() const; + +private: + QString m_key; + QString m_value; +}; + class Entry : public QObject { Q_OBJECT - Q_PROPERTY(QString Login READ login ) - Q_PROPERTY(QString Password READ password) - Q_PROPERTY(QString Uuid READ uuid ) - Q_PROPERTY(QString Name READ name ) + Q_PROPERTY(QString Login READ login ) + Q_PROPERTY(QString Password READ password ) + Q_PROPERTY(QString Uuid READ uuid ) + Q_PROPERTY(QString Name READ name ) + Q_PROPERTY(QVariant StringFields READ getStringFields) public: Entry(); @@ -117,12 +138,17 @@ public: QString password() const; QString uuid() const; QString name() const; + QList stringFields() const; + void addStringField(const QString& key, const QString& value); private: + QVariant getStringFields() const; + QString m_login; QString m_password; QString m_uuid; QString m_name; + QList m_stringFields; }; class Response : public QObject diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 2e85932bc..6f654ac37 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -34,11 +34,11 @@ Service::Service(DatabaseTabWidget *parent) : { } -static const char KEEPASSHTTP_UUID_DATA[] = { +static const unsigned char KEEPASSHTTP_UUID_DATA[] = { 0x34, 0x69, 0x7a, 0x40, 0x8a, 0x5b, 0x41, 0xc0, 0x9f, 0x36, 0x89, 0x7d, 0x62, 0x3e, 0xcb, 0x31 }; -static const Uuid KEEPASSHTTP_UUID = Uuid(QByteArray::fromRawData(KEEPASSHTTP_UUID_DATA, sizeof(KEEPASSHTTP_UUID_DATA))); +static const Uuid KEEPASSHTTP_UUID = Uuid(QByteArray::fromRawData(reinterpret_cast(KEEPASSHTTP_UUID_DATA), sizeof(KEEPASSHTTP_UUID_DATA))); static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings"; static const char ASSOCIATE_KEY_PREFIX[] = "AES Key: "; static const char KEEPASSHTTP_GROUP_NAME[] = "KeePassHttp Passwords"; //Group where new KeePassHttp password are stored @@ -201,6 +201,20 @@ Service::Access Service::checkAccess(const Entry *entry, const QString & host, c return Unknown; //not configured for this host } +KeepassHttpProtocol::Entry Service::prepareEntry(const Entry* entry) +{ + bool returnStringFields = true; //TODO: setting! + KeepassHttpProtocol::Entry res(entry->title(), entry->username(), entry->password(), entry->uuid().toHex()); + if (returnStringFields) + { + const EntryAttributes * attr = entry->attributes(); + Q_FOREACH (const QString& key, attr->keys()) + if (key.startsWith(QLatin1String("KPH: "))) + res.addStringField(key, attr->value(key)); + } + return res; +} + QList Service::findMatchingEntries(const QString &id, const QString &url, const QString &submitUrl, const QString &realm) { QList result; @@ -224,7 +238,7 @@ QList Service::findMatchingEntries(const QString &id } //fall through case Allowed: - result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), entry->password(), entry->uuid().toHex()); + result << prepareEntry(entry); break; } } @@ -259,7 +273,7 @@ QList Service::findMatchingEntries(const QString &id } if (res == QDialog::Accepted) { Q_FOREACH (Entry * entry, pwEntries) - result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), entry->password(), entry->uuid().toHex()); + result << prepareEntry(entry); } } diff --git a/src/http/Service.h b/src/http/Service.h index 871a49904..18c9ef235 100644 --- a/src/http/Service.h +++ b/src/http/Service.h @@ -45,6 +45,7 @@ private: Access checkAccess(const Entry *entry, const QString & host, const QString & submitHost, const QString & realm); bool removeFirstDomain(QString &hostname); Group *findCreateAddEntryGroup(); + KeepassHttpProtocol::Entry prepareEntry(const Entry *entry); QList searchEntries(const QString &text); DatabaseTabWidget * const m_dbTabWidget; From 75f0d132e52e23ac579f5f9cbaf61fd49577047b Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Tue, 16 Apr 2013 22:58:42 +0200 Subject: [PATCH 07/51] Add removeSharedEncryptionKeys() and removeStoredPermissions() --- src/core/EntryAttributes.cpp | 5 ++ src/core/EntryAttributes.h | 1 + src/http/Service.cpp | 91 +++++++++++++++++++++++++++++++++--- src/http/Service.h | 4 ++ 4 files changed, 94 insertions(+), 7 deletions(-) diff --git a/src/core/EntryAttributes.cpp b/src/core/EntryAttributes.cpp index 5425c38f2..65ef310ea 100644 --- a/src/core/EntryAttributes.cpp +++ b/src/core/EntryAttributes.cpp @@ -47,6 +47,11 @@ QString EntryAttributes::value(const QString& key) const return m_attributes.value(key); } +bool EntryAttributes::contains(const QString &key) const +{ + return m_attributes.contains(key); +} + bool EntryAttributes::isProtected(const QString& key) const { return m_protectedAttributes.contains(key); diff --git a/src/core/EntryAttributes.h b/src/core/EntryAttributes.h index 8d17eb81b..f74c154c2 100644 --- a/src/core/EntryAttributes.h +++ b/src/core/EntryAttributes.h @@ -34,6 +34,7 @@ public: QList keys() const; QList customKeys(); QString value(const QString& key) const; + bool contains(const QString& key) const; bool isProtected(const QString& key) const; void set(const QString& key, const QString& value, bool protect = false); void remove(const QString& key); diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 6f654ac37..8b2a7768e 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include "Service.h" @@ -131,11 +132,12 @@ QString Service::storeKey(const QString &key) QLineEdit::Normal, QString(), &ok); if (!ok || id.isEmpty()) return QString(); + //Warn if association key already exists - } while(!config->attributes()->value(QLatin1String(ASSOCIATE_KEY_PREFIX) + id).isEmpty() && - QMessageBox(QMessageBox::Warning, tr("KeyPassX/Http: Overwrite existing key?"), - tr("A shared encryption-key with the name \"%1\" already exists.\nDo you want to overwrite it?").arg(id), - QMessageBox::Yes|QMessageBox::No).exec() == QMessageBox::No); + } while(config->attributes()->contains(QLatin1String(ASSOCIATE_KEY_PREFIX) + id) && + QMessageBox::warning(0, tr("KeyPassX/Http: Overwrite existing key?"), + tr("A shared encryption-key with the name \"%1\" already exists.\nDo you want to overwrite it?").arg(id), + QMessageBox::Yes|QMessageBox::No) == QMessageBox::No); config->attributes()->set(QLatin1String(ASSOCIATE_KEY_PREFIX) + id, key, true); } @@ -352,9 +354,9 @@ void Service::updateEntry(const QString &id, const QString &uuid, const QString if (u != login || entry->password() != password) { bool autoAllow = false; //TODO: setting to request confirmation/auto-allow if ( autoAllow - || QMessageBox(QMessageBox::Warning, tr("KeyPassX/Http: Update Entry"), - tr("Do you want to update the information in {0} - {1}?").arg(QUrl(url).host()).arg(u), - QMessageBox::Yes|QMessageBox::No).exec() == QMessageBox::Yes ) { + || QMessageBox::warning(0, tr("KeyPassX/Http: Update Entry"), + tr("Do you want to update the information in %1 - %2?").arg(QUrl(url).host()).arg(u), + QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes ) { entry->beginUpdate(); entry->setUsername(login); entry->setPassword(password); @@ -372,3 +374,78 @@ QString Service::generatePassword() PasswordGenerator::LowerLetters | PasswordGenerator::UpperLetters | PasswordGenerator::Numbers, PasswordGenerator::ExcludeLookAlike | PasswordGenerator::CharFromEveryGroup); } + +void Service::removeSharedEncryptionKeys() +{ + if (!isDatabaseOpened()) { + QMessageBox::critical(0, tr("KeyPassX/Http: Database locked!"), + tr("The active database is locked!\n" + "Please unlock the selected database or choose another one which is unlocked."), + QMessageBox::Ok); + } else if (Entry* entry = getConfigEntry()) { + QStringList keysToRemove; + Q_FOREACH (const QString& key, entry->attributes()->keys()) + if (key.startsWith(ASSOCIATE_KEY_PREFIX)) + keysToRemove << key; + + if(keysToRemove.count()) { + entry->beginUpdate(); + Q_FOREACH (const QString& key, keysToRemove) + entry->attributes()->remove(key); + entry->endUpdate(); + + const int count = keysToRemove.count(); + QMessageBox::information(0, tr("KeyPassX/Http: Removed keys from database"), + tr("Successfully removed %1 encryption-%2 from KeePassX/Http Settings.").arg(count).arg(count ? "keys" : "key"), + QMessageBox::Ok); + } else { + QMessageBox::information(0, tr("KeyPassX/Http: No keys found"), + tr("No shared encryption-keys found in KeePassHttp Settings."), + QMessageBox::Ok); + } + } else { + QMessageBox::information(0, tr("KeyPassX/Http: Settings not available!"), + tr("The active database does not contain an entry of KeePassHttp Settings."), + QMessageBox::Ok); + } +} + +void Service::removeStoredPermissions() +{ + if (!isDatabaseOpened()) { + QMessageBox::critical(0, tr("KeyPassX/Http: Database locked!"), + tr("The active database is locked!\n" + "Please unlock the selected database or choose another one which is unlocked."), + QMessageBox::Ok); + } else { + Database * db = m_dbTabWidget->currentDatabaseWidget()->database(); + QList entries = db->rootGroup()->entriesRecursive(); + + QProgressDialog progress(tr("Removing stored permissions..."), tr("Abort"), 0, entries.count()); + progress.setWindowModality(Qt::WindowModal); + + uint counter = 0; + Q_FOREACH (Entry* entry, entries) { + if (progress.wasCanceled()) + return; + if (entry->attributes()->contains(KEEPASSHTTP_NAME)) { + entry->beginUpdate(); + entry->attributes()->remove(KEEPASSHTTP_NAME); + entry->endUpdate(); + counter ++; + } + progress.setValue(progress.value() + 1); + } + progress.reset(); + + if (counter > 0) { + QMessageBox::information(0, tr("KeyPassX/Http: Removed permissions"), + tr("Successfully removed permissions from %1 %2.").arg(counter).arg(counter ? "entries" : "entry"), + QMessageBox::Ok); + } else { + QMessageBox::information(0, tr("KeyPassX/Http: No entry with permissions found!"), + tr("The active database does not contain an entry with permissions."), + QMessageBox::Ok); + } + } +} diff --git a/src/http/Service.h b/src/http/Service.h index 18c9ef235..35a466bbf 100644 --- a/src/http/Service.h +++ b/src/http/Service.h @@ -38,6 +38,10 @@ public: virtual void updateEntry(const QString &id, const QString &uuid, const QString &login, const QString &password, const QString &url); virtual QString generatePassword(); +public Q_SLOTS: + void removeSharedEncryptionKeys(); + void removeStoredPermissions(); + private: enum Access { Denied, Unknown, Allowed}; Entry* getConfigEntry(bool create = false); From c98aad698a75a5f5040da561c4aac95000fbab0e Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Tue, 16 Apr 2013 23:56:37 +0200 Subject: [PATCH 08/51] Cleanup reference/pointer declarations. --- src/http/Service.cpp | 20 ++++++++++---------- src/http/Service.h | 26 +++++++++++++------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 8b2a7768e..3afedee9d 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -29,7 +29,7 @@ #include "core/PasswordGenerator.h" -Service::Service(DatabaseTabWidget *parent) : +Service::Service(DatabaseTabWidget* parent) : KeepassHttpProtocol::Server(parent), m_dbTabWidget(parent) { @@ -69,7 +69,7 @@ Entry* Service::getConfigEntry(bool create) bool Service::isDatabaseOpened() const { - if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget()) switch(dbWidget->currentMode()) { case DatabaseWidget::None: case DatabaseWidget::LockedMode: @@ -95,18 +95,18 @@ bool Service::openDatabase() QString Service::getDatabaseRootUuid() { - if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) - if (Database * db = dbWidget->database()) - if (Group * rootGroup = db->rootGroup()) + if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database* db = dbWidget->database()) + if (Group* rootGroup = db->rootGroup()) return rootGroup->uuid().toHex(); return QString(); } QString Service::getDatabaseRecycleBinUuid() { - if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) - if (Database * db = dbWidget->database()) - if (Group * recycleBin = db->metadata()->recycleBin()) + if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database* db = dbWidget->database()) + if (Group* recycleBin = db->metadata()->recycleBin()) return recycleBin->uuid().toHex(); return QString(); } @@ -137,7 +137,7 @@ QString Service::storeKey(const QString &key) } while(config->attributes()->contains(QLatin1String(ASSOCIATE_KEY_PREFIX) + id) && QMessageBox::warning(0, tr("KeyPassX/Http: Overwrite existing key?"), tr("A shared encryption-key with the name \"%1\" already exists.\nDo you want to overwrite it?").arg(id), - QMessageBox::Yes|QMessageBox::No) == QMessageBox::No); + QMessageBox::Yes | QMessageBox::No) == QMessageBox::No); config->attributes()->set(QLatin1String(ASSOCIATE_KEY_PREFIX) + id, key, true); } @@ -217,7 +217,7 @@ KeepassHttpProtocol::Entry Service::prepareEntry(const Entry* entry) return res; } -QList Service::findMatchingEntries(const QString &id, const QString &url, const QString &submitUrl, const QString &realm) +QList Service::findMatchingEntries(const QString& /*id*/, const QString& url, const QString& submitUrl, const QString& realm) { QList result; QList pwEntriesToConfirm; diff --git a/src/http/Service.h b/src/http/Service.h index 35a466bbf..9a792846c 100644 --- a/src/http/Service.h +++ b/src/http/Service.h @@ -23,19 +23,19 @@ class Service : public KeepassHttpProtocol::Server Q_OBJECT public: - explicit Service(DatabaseTabWidget *parent = 0); + explicit Service(DatabaseTabWidget* parent = 0); virtual bool isDatabaseOpened() const; virtual bool openDatabase(); virtual QString getDatabaseRootUuid(); virtual QString getDatabaseRecycleBinUuid(); - virtual QString getKey(const QString &id); - virtual QString storeKey(const QString &key); - virtual QList findMatchingEntries(const QString &id, const QString &url, const QString & submitUrl, const QString & realm); - virtual int countMatchingEntries(const QString &id, const QString &url, const QString & submitUrl, const QString & realm); - virtual QList searchAllEntries(const QString &id); - virtual void addEntry(const QString &id, const QString &login, const QString &password, const QString &url, const QString &submitUrl, const QString &realm); - virtual void updateEntry(const QString &id, const QString &uuid, const QString &login, const QString &password, const QString &url); + virtual QString getKey(const QString& id); + virtual QString storeKey(const QString& key); + virtual QList findMatchingEntries(const QString& id, const QString& url, const QString& submitUrl, const QString& realm); + virtual int countMatchingEntries(const QString& id, const QString& url, const QString& submitUrl, const QString& realm); + virtual QList searchAllEntries(const QString& id); + virtual void addEntry(const QString& id, const QString& login, const QString& password, const QString& url, const QString& submitUrl, const QString& realm); + virtual void updateEntry(const QString& id, const QString& uuid, const QString& login, const QString& password, const QString& url); virtual QString generatePassword(); public Q_SLOTS: @@ -45,12 +45,12 @@ public Q_SLOTS: private: enum Access { Denied, Unknown, Allowed}; Entry* getConfigEntry(bool create = false); - bool matchUrlScheme(const QString &url); - Access checkAccess(const Entry *entry, const QString & host, const QString & submitHost, const QString & realm); - bool removeFirstDomain(QString &hostname); + bool matchUrlScheme(const QString& url); + Access checkAccess(const Entry* entry, const QString& host, const QString& submitHost, const QString& realm); + bool removeFirstDomain(QString& hostname); Group *findCreateAddEntryGroup(); - KeepassHttpProtocol::Entry prepareEntry(const Entry *entry); - QList searchEntries(const QString &text); + KeepassHttpProtocol::Entry prepareEntry(const Entry* entry); + QList searchEntries(const QString& text); DatabaseTabWidget * const m_dbTabWidget; }; From e2ba754f917a7f7aa28ef430f3150a853f10db32 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Tue, 16 Apr 2013 23:58:25 +0200 Subject: [PATCH 09/51] Default icon. --- src/http/Service.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 3afedee9d..7fd61aee3 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -43,6 +43,7 @@ static const Uuid KEEPASSHTTP_UUID = Uuid(QByteArray::fromRawData(reinterpret_ca static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings"; static const char ASSOCIATE_KEY_PREFIX[] = "AES Key: "; static const char KEEPASSHTTP_GROUP_NAME[] = "KeePassHttp Passwords"; //Group where new KeePassHttp password are stored +static int KEEPASSHTTP_DEFAULT_ICON = 1; //private const int DEFAULT_NOTIFICATION_TIME = 5000; Entry* Service::getConfigEntry(bool create) @@ -314,7 +315,7 @@ Group * Service::findCreateAddEntryGroup() group = new Group(); group->setUuid(Uuid::random()); group->setName(groupName); - group->setIcon(Group::DefaultIconNumber); //TODO: WorldIconNumber + group->setIcon(KEEPASSHTTP_DEFAULT_ICON); group->setParent(rootGroup); return group; } @@ -328,7 +329,7 @@ void Service::addEntry(const QString &id, const QString &login, const QString &p entry->setUuid(Uuid::random()); entry->setTitle(QUrl(url).host()); entry->setUrl(url); - entry->setIcon(Entry::DefaultIconNumber); //TODO: WorldIconNumber + entry->setIcon(KEEPASSHTTP_DEFAULT_ICON); entry->setUsername(login); entry->setPassword(password); entry->setGroup(group); From 47d7598e99a363c6063c6479c4a5e72f8b2c8960 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 17 Apr 2013 00:11:05 +0200 Subject: [PATCH 10/51] Fix confirmation allowing access to all entries. --- src/http/Service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 7fd61aee3..fc853d42e 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -257,7 +257,7 @@ QList Service::findMatchingEntries(const QString& /* int res = dlg.exec(); if (dlg.remember()) { - Q_FOREACH (Entry * entry, pwEntries) { + Q_FOREACH (Entry * entry, pwEntriesToConfirm) { EntryConfig config; config.load(entry); if (res == QDialog::Accepted) { @@ -275,7 +275,7 @@ QList Service::findMatchingEntries(const QString& /* } } if (res == QDialog::Accepted) { - Q_FOREACH (Entry * entry, pwEntries) + Q_FOREACH (Entry * entry, pwEntriesToConfirm) result << prepareEntry(entry); } } From fd7a49f4a673d7c963f2fb2195ebd25ef4d35706 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 17 Apr 2013 22:24:17 +0200 Subject: [PATCH 11/51] Sort entries. --- src/http/Service.cpp | 106 ++++++++++++++++++++++++++++++++++++------- src/http/Service.h | 2 + 2 files changed, 92 insertions(+), 16 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index fc853d42e..aa3e93ed8 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -218,30 +218,82 @@ KeepassHttpProtocol::Entry Service::prepareEntry(const Entry* entry) return res; } +int Service::sortPriority(const Entry* entry, const QString& host, const QString& submitUrl, const QString& baseSubmitUrl) const +{ + QUrl url(entry->url()); + if (url.scheme().isEmpty()) + url.setScheme("http"); + const QString entryURL = url.toString(QUrl::StripTrailingSlash); + const QString baseEntryURL = url.toString(QUrl::StripTrailingSlash | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment); + + if (submitUrl == entryURL) + return 100; + if (submitUrl.startsWith(entryURL) && entryURL != host && baseSubmitUrl != entryURL) + return 90; + if (submitUrl.startsWith(baseEntryURL) && entryURL != host && baseSubmitUrl != baseEntryURL) + return 80; + if (entryURL == host) + return 70; + if (entryURL == baseSubmitUrl) + return 60; + if (entryURL.startsWith(submitUrl)) + return 50; + if (entryURL.startsWith(baseSubmitUrl) && baseSubmitUrl != host) + return 40; + if (submitUrl.startsWith(entryURL)) + return 30; + if (submitUrl.startsWith(baseEntryURL)) + return 20; + if (entryURL.startsWith(host)) + return 10; + if (host.startsWith(entryURL)) + return 5; + return 0; +} + +class Service::SortEntries +{ +public: + SortEntries(const QHash& priorities, const QString & field): + m_priorities(priorities), m_field(field) + {} + + bool operator()(const Entry* left, const Entry* right) const + { + int res = m_priorities.value(left) - m_priorities.value(right); + if (res == 0) + return QString::localeAwareCompare(left->attributes()->value(m_field), right->attributes()->value(m_field)) < 0; + return res < 0; + } + +private: + const QHash& m_priorities; + const QString m_field; +}; + QList Service::findMatchingEntries(const QString& /*id*/, const QString& url, const QString& submitUrl, const QString& realm) { - QList result; - QList pwEntriesToConfirm; - - bool autoAccept = false; //TODO: setting! + const bool autoAccept = false; //TODO: setting! const QString host = QUrl(url).host(); const QString submitHost = QUrl(submitUrl).host(); - const QList pwEntries = searchEntries(url); //Check entries for authorization - Q_FOREACH (Entry * entry, pwEntries) { + QList pwEntriesToConfirm; + QList pwEntries; + Q_FOREACH (Entry * entry, searchEntries(url)) { switch(checkAccess(entry, host, submitHost, realm)) { case Denied: continue; case Unknown: - if (!autoAccept) { + if (autoAccept) + pwEntries.append(entry); + else pwEntriesToConfirm.append(entry); - break; - } - //fall through + break; + case Allowed: - result << prepareEntry(entry); + pwEntries.append(entry); break; } } @@ -274,13 +326,35 @@ QList Service::findMatchingEntries(const QString& /* config.save(entry); } } - if (res == QDialog::Accepted) { - Q_FOREACH (Entry * entry, pwEntriesToConfirm) - result << prepareEntry(entry); - } + if (res == QDialog::Accepted) + pwEntries.append(pwEntriesToConfirm); } - //TODO: sort [--> need a flag], or do this in Server class [--> need an extra 'sort order' key in Entry, and we always compute it] + //Sort results + const bool sortSelection = true; + if (sortSelection) { + QUrl url(submitUrl); + if (url.scheme().isEmpty()) + url.setScheme("http"); + const QString submitUrl = url.toString(QUrl::StripTrailingSlash); + const QString baseSubmitURL = url.toString(QUrl::StripTrailingSlash | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment); + + //Cache priorities + QHash priorities; + priorities.reserve(pwEntries.size()); + Q_FOREACH (const Entry * entry, pwEntries) + priorities.insert(entry, sortPriority(entry, host, submitUrl, baseSubmitURL)); + + //Sort by priorities + const bool sortByTitle = true; //TODO: setting + qSort(pwEntries.begin(), pwEntries.end(), SortEntries(priorities, sortByTitle ? "Title" : "UserName")); + } + + //Fill the list + QList result; + result.reserve(result.size()); + Q_FOREACH (Entry * entry, pwEntries) + result << prepareEntry(entry); return result; } diff --git a/src/http/Service.h b/src/http/Service.h index 9a792846c..a9b7bd0e1 100644 --- a/src/http/Service.h +++ b/src/http/Service.h @@ -49,6 +49,8 @@ private: Access checkAccess(const Entry* entry, const QString& host, const QString& submitHost, const QString& realm); bool removeFirstDomain(QString& hostname); Group *findCreateAddEntryGroup(); + class SortEntries; + int sortPriority(const Entry *entry, const QString &host, const QString &submitUrl, const QString &baseSubmitUrl) const; KeepassHttpProtocol::Entry prepareEntry(const Entry* entry); QList searchEntries(const QString& text); From f6fa6d656313d0f070c1a7da8fca52e25bc97397 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 17 Apr 2013 19:19:07 +0200 Subject: [PATCH 12/51] KeyPassX/Http settings. --- src/CMakeLists.txt | 4 + src/http/HttpSettings.cpp | 219 +++++++++++++++++++++++++++ src/http/HttpSettings.h | 64 ++++++++ src/http/OptionDialog.cpp | 81 ++++++++++ src/http/OptionDialog.h | 43 ++++++ src/http/OptionDialog.ui | 305 ++++++++++++++++++++++++++++++++++++++ src/http/Service.cpp | 43 +++--- 7 files changed, 737 insertions(+), 22 deletions(-) create mode 100644 src/http/HttpSettings.cpp create mode 100644 src/http/HttpSettings.h create mode 100644 src/http/OptionDialog.cpp create mode 100644 src/http/OptionDialog.h create mode 100644 src/http/OptionDialog.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0425c3cd..b57ee84d2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,6 +103,8 @@ set(keepassx_SOURCES gui/group/GroupView.cpp http/AccessControlDialog.cpp http/EntryConfig.cpp + http/HttpSettings.cpp + http/OptionDialog.cpp http/Protocol.cpp http/Server.cpp http/Service.cpp @@ -170,6 +172,7 @@ set(keepassx_MOC gui/group/GroupView.h http/AccessControlDialog.h http/EntryConfig.h + http/OptionDialog.h http/Protocol.h http/Server.h http/Service.h @@ -201,6 +204,7 @@ set(keepassx_FORMS gui/entry/EditEntryWidgetMain.ui gui/group/EditGroupWidgetMain.ui http/AccessControlDialog.ui + http/OptionDialog.ui ) if(MINGW) diff --git a/src/http/HttpSettings.cpp b/src/http/HttpSettings.cpp new file mode 100644 index 000000000..15cd962bd --- /dev/null +++ b/src/http/HttpSettings.cpp @@ -0,0 +1,219 @@ +/** + *************************************************************************** + * @file HttpSettings.cpp + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#include "HttpSettings.h" +#include "core/Config.h" + +bool HttpSettings::isEnabled() +{ + return config()->get("Http/Enabled", true).toBool(); +} + +void HttpSettings::setEnabled(bool enabled) +{ + config()->set("Http/Enabled", enabled); +} + +bool HttpSettings::showNotification() +{ + return config()->get("Http/ShowNotification", true).toBool(); +} + +void HttpSettings::setShowNotification(bool showNotification) +{ + config()->set("Http/ShowNotification", showNotification); +} + +bool HttpSettings::bestMatchOnly() +{ + return config()->get("Http/BestMatchOnly", false).toBool(); +} + +void HttpSettings::setBestMatchOnly(bool bestMatchOnly) +{ + config()->set("Http/BestMatchOnly", bestMatchOnly); +} + +bool HttpSettings::unlockDatabase() +{ + return config()->get("Http/UnlockDatabase", true).toBool(); +} + +void HttpSettings::setUnlockDatabase(bool unlockDatabase) +{ + config()->set("Http/UnlockDatabase", unlockDatabase); +} + +bool HttpSettings::matchUrlScheme() +{ + return config()->get("Http/MatchUrlScheme", true).toBool(); +} + +void HttpSettings::setMatchUrlScheme(bool matchUrlScheme) +{ + config()->set("Http/MatchUrlScheme", matchUrlScheme); +} + +bool HttpSettings::sortByUsername() +{ + return config()->get("Http/SortByUsername", false).toBool(); +} + +void HttpSettings::setSortByUsername(bool sortByUsername) +{ + config()->set("Http/SortByUsername", sortByUsername); +} + +bool HttpSettings::sortByTitle() +{ + return !sortByUsername(); +} + +void HttpSettings::setSortByTitle(bool sortByUsertitle) +{ + setSortByUsername(!sortByUsertitle); +} + +bool HttpSettings::alwaysAllowAccess() +{ + return config()->get("Http/AlwaysAllowAccess", false).toBool(); +} + +void HttpSettings::setAlwaysAllowAccess(bool alwaysAllowAccess) +{ + config()->set("Http/AlwaysAllowAccess", alwaysAllowAccess); +} + +bool HttpSettings::alwaysAllowUpdate() +{ + return config()->get("Http/AlwaysAllowUpdate", false).toBool(); +} + +void HttpSettings::setAlwaysAllowUpdate(bool alwaysAllowUpdate) +{ + config()->set("Http/AlwaysAllowAccess", alwaysAllowUpdate); +} + +bool HttpSettings::searchInAllDatabases() +{ + return config()->get("Http/SearchInAllDatabases", false).toBool(); +} + +void HttpSettings::setSearchInAllDatabases(bool searchInAllDatabases) +{ + config()->set("Http/SearchInAllDatabases", searchInAllDatabases); +} + +bool HttpSettings::supportKphFields() +{ + return config()->get("Http/SupportKphFields", true).toBool(); +} + +void HttpSettings::setSupportKphFields(bool supportKphFields) +{ + config()->set("Http/SupportKphFields", supportKphFields); +} + +bool HttpSettings::passwordUseNumbers() +{ + return config()->get("Http/PasswordUseNumbers", true).toBool(); +} + +void HttpSettings::setPasswordUseNumbers(bool useNumbers) +{ + config()->set("Http/PasswordUseNumbers", useNumbers); +} + +bool HttpSettings::passwordUseLowercase() +{ + return config()->get("Http/PasswordUseLowercase", true).toBool(); +} + +void HttpSettings::setPasswordUseLowercase(bool useLowercase) +{ + config()->set("Http/PasswordUseLowercase", useLowercase); +} + +bool HttpSettings::passwordUseUppercase() +{ + return config()->get("Http/PasswordUseUppercase", true).toBool(); +} + +void HttpSettings::setPasswordUseUppercase(bool useUppercase) +{ + config()->set("Http/PasswordUseUppercase", useUppercase); +} + +bool HttpSettings::passwordUseSpecial() +{ + return config()->get("Http/PasswordUseSpecial", false).toBool(); +} + +void HttpSettings::setPasswordUseSpecial(bool useSpecial) +{ + config()->set("Http/PasswordUseSpecial", useSpecial); +} + +bool HttpSettings::passwordEveryGroup() +{ + return config()->get("Http/PasswordEveryGroup", true).toBool(); +} + +void HttpSettings::setPasswordEveryGroup(bool everyGroup) +{ + config()->get("Http/PasswordEveryGroup", everyGroup); +} + +bool HttpSettings::passwordExcludeAlike() +{ + return config()->get("Http/PasswordExcludeAlike", true).toBool(); +} + +void HttpSettings::setPasswordExcludeAlike(bool excludeAlike) +{ + config()->set("Http/PasswordExcludeAlike", excludeAlike); +} + +int HttpSettings::passwordLength() +{ + return config()->get("Http/PasswordLength", 20).toInt(); +} + +void HttpSettings::setPasswordLength(int length) +{ + config()->set("Http/PasswordLength", length); +} + +PasswordGenerator::CharClasses HttpSettings::passwordCharClasses() +{ + PasswordGenerator::CharClasses classes; + if (passwordUseLowercase()) + classes |= PasswordGenerator::LowerLetters; + if (passwordUseUppercase()) + classes |= PasswordGenerator::UpperLetters; + if (passwordUseNumbers()) + classes |= PasswordGenerator::Numbers; + if (passwordUseSpecial()) + classes |= PasswordGenerator::SpecialCharacters; + return classes; +} + +PasswordGenerator::GeneratorFlags HttpSettings::passwordGeneratorFlags() +{ + PasswordGenerator::GeneratorFlags flags; + if (passwordExcludeAlike()) + flags |= PasswordGenerator::ExcludeLookAlike; + if (passwordEveryGroup()) + flags |= PasswordGenerator::CharFromEveryGroup; + return flags; +} diff --git a/src/http/HttpSettings.h b/src/http/HttpSettings.h new file mode 100644 index 000000000..67a998eec --- /dev/null +++ b/src/http/HttpSettings.h @@ -0,0 +1,64 @@ +/** + *************************************************************************** + * @file HttpSettings.h + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#ifndef HTTPSETTINGS_H +#define HTTPSETTINGS_H + +#include "core/PasswordGenerator.h" + +class HttpSettings +{ +public: + static bool isEnabled(); + static void setEnabled(bool enabled); + + static bool showNotification(); //TODO!! + static void setShowNotification(bool showNotification); + static bool bestMatchOnly(); //TODO!! + static void setBestMatchOnly(bool bestMatchOnly); + static bool unlockDatabase(); //TODO!! + static void setUnlockDatabase(bool unlockDatabase); + static bool matchUrlScheme(); + static void setMatchUrlScheme(bool matchUrlScheme); + static bool sortByUsername(); + static void setSortByUsername(bool sortByUsername = true); + static bool sortByTitle(); + static void setSortByTitle(bool sortByUsertitle = true); + static bool alwaysAllowAccess(); + static void setAlwaysAllowAccess(bool alwaysAllowAccess); + static bool alwaysAllowUpdate(); + static void setAlwaysAllowUpdate(bool alwaysAllowUpdate); + static bool searchInAllDatabases();//TODO!! + static void setSearchInAllDatabases(bool searchInAllDatabases); + static bool supportKphFields(); + static void setSupportKphFields(bool supportKphFields); + + static bool passwordUseNumbers(); + static void setPasswordUseNumbers(bool useNumbers); + static bool passwordUseLowercase(); + static void setPasswordUseLowercase(bool useLowercase); + static bool passwordUseUppercase(); + static void setPasswordUseUppercase(bool useUppercase); + static bool passwordUseSpecial(); + static void setPasswordUseSpecial(bool useSpecial); + static bool passwordEveryGroup(); + static void setPasswordEveryGroup(bool everyGroup); + static bool passwordExcludeAlike(); + static void setPasswordExcludeAlike(bool excludeAlike); + static int passwordLength(); + static void setPasswordLength(int length); + static PasswordGenerator::CharClasses passwordCharClasses(); + static PasswordGenerator::GeneratorFlags passwordGeneratorFlags(); +}; + +#endif // HTTPSETTINGS_H diff --git a/src/http/OptionDialog.cpp b/src/http/OptionDialog.cpp new file mode 100644 index 000000000..29ebeaa1a --- /dev/null +++ b/src/http/OptionDialog.cpp @@ -0,0 +1,81 @@ +/** + *************************************************************************** + * @file OptionDialog.cpp + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#include "OptionDialog.h" +#include "ui_OptionDialog.h" +#include "HttpSettings.h" + +OptionDialog::OptionDialog(QWidget *parent) : + QWidget(parent), + ui(new Ui::OptionDialog) +{ + ui->setupUi(this); + connect(ui->removeSharedEncryptionKeys, SIGNAL(clicked()), this, SIGNAL(removeSharedEncryptionKeys())); + connect(ui->removeStoredPermissions, SIGNAL(clicked()), this, SIGNAL(removeStoredPermissions())); +} + +OptionDialog::~OptionDialog() +{ + delete ui; +} + +void OptionDialog::loadSettings() +{ + HttpSettings settings; + ui->enableHttpServer->setChecked(settings.isEnabled()); + + ui->showNotification->setChecked(settings.showNotification()); + ui->bestMatchOnly->setChecked(settings.bestMatchOnly()); + ui->unlockDatabase->setChecked(settings.unlockDatabase()); + ui->matchUrlScheme->setChecked(settings.matchUrlScheme()); + if (settings.sortByUsername()) + ui->sortByUsername->setChecked(true); + else + ui->sortByTitle->setChecked(true); + + ui->checkBoxLower->setChecked(settings.passwordUseLowercase()); + ui->checkBoxNumbers->setChecked(settings.passwordUseNumbers()); + ui->checkBoxUpper->setChecked(settings.passwordUseUppercase()); + ui->checkBoxSpecialChars->setChecked(settings.passwordUseSpecial()); + ui->checkBoxEnsureEvery->setChecked(settings.passwordEveryGroup()); + ui->checkBoxExcludeAlike->setChecked(settings.passwordExcludeAlike()); + ui->spinBoxLength->setValue(settings.passwordLength()); + + ui->alwaysAllowAccess->setChecked(settings.alwaysAllowAccess()); + ui->alwaysAllowUpdate->setChecked(settings.alwaysAllowUpdate()); + ui->searchInAllDatabases->setChecked(settings.searchInAllDatabases()); +} + +void OptionDialog::saveSettings() +{ + HttpSettings settings; + settings.setEnabled(ui->enableHttpServer->isChecked()); + + settings.setShowNotification(ui->showNotification->isChecked()); + settings.setBestMatchOnly(ui->bestMatchOnly->isChecked()); + settings.setUnlockDatabase(ui->unlockDatabase->isChecked()); + settings.setMatchUrlScheme(ui->matchUrlScheme->isChecked()); + settings.setSortByUsername(ui->sortByUsername->isChecked()); + + settings.setPasswordUseLowercase(ui->checkBoxLower->isChecked()); + settings.setPasswordUseNumbers(ui->checkBoxNumbers->isChecked()); + settings.setPasswordUseUppercase(ui->checkBoxUpper->isChecked()); + settings.setPasswordUseSpecial(ui->checkBoxSpecialChars->isChecked()); + settings.setPasswordEveryGroup(ui->checkBoxEnsureEvery->isChecked()); + settings.setPasswordExcludeAlike(ui->checkBoxExcludeAlike->isChecked()); + settings.setPasswordLength(ui->spinBoxLength->value()); + + settings.setAlwaysAllowAccess(ui->alwaysAllowAccess->isChecked()); + settings.setAlwaysAllowUpdate(ui->alwaysAllowUpdate->isChecked()); + settings.setSearchInAllDatabases(ui->searchInAllDatabases->isChecked()); +} diff --git a/src/http/OptionDialog.h b/src/http/OptionDialog.h new file mode 100644 index 000000000..e7508d233 --- /dev/null +++ b/src/http/OptionDialog.h @@ -0,0 +1,43 @@ +/** + *************************************************************************** + * @file OptionDialog.h + * + * @brief + * + * Copyright (C) 2013 + * + * @author Francois Ferrand + * @date 4/2013 + *************************************************************************** + */ + +#ifndef OPTIONDIALOG_H +#define OPTIONDIALOG_H + +#include + +namespace Ui { +class OptionDialog; +} + +class OptionDialog : public QWidget +{ + Q_OBJECT + +public: + explicit OptionDialog(QWidget *parent = 0); + ~OptionDialog(); + +public Q_SLOTS: + void loadSettings(); + void saveSettings(); + +Q_SIGNALS: + void removeSharedEncryptionKeys(); + void removeStoredPermissions(); + +private: + Ui::OptionDialog *ui; +}; + +#endif // OPTIONDIALOG_H diff --git a/src/http/OptionDialog.ui b/src/http/OptionDialog.ui new file mode 100644 index 000000000..621b94836 --- /dev/null +++ b/src/http/OptionDialog.ui @@ -0,0 +1,305 @@ + + + OptionDialog + + + + 0 + 0 + 463 + 354 + + + + Dialog + + + + + + Support KeypassHttp protocol +This is required for accessing keypass database from ChromeIPass or PassIfox + + + + + + + QTabWidget::Rounded + + + 0 + + + + General + + + + + + Sh&ow a notification when credentials are requested + + + + + + + &Return only best matching entries for an URL instead +of all entries for the whole domain + + + + + + + Re&quest for unlocking the database if it is locked + + + + + + + &Match URL schemes +Only entries with the same scheme (http://, https://, ftp://, ...) are returned + + + + + + + Sort matching entries by &username + + + + + + + Sort matching entries by &title + + + + + + + R&emove all shared encryption-keys from active database + + + + + + + Re&move all stored permissions from entries in active database + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Password generator + + + + + + + + + + Lower letters + + + + + + + Numbers + + + + + + + Upper letters + + + + + + + Special characters + + + + + + + + + + + Ensure that the password contains characters from every group + + + + + + + Exclude look-alike characters + + + + + + + + + Length: + + + + + + + 1 + + + 999 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Advanced + + + + + + + 75 + true + + + + color: rgb(255, 0, 0); + + + Activate the following only, if you know what you are doing! + + + + + + + Always allow &access to entries + + + + + + + Always allow &updating entries + + + + + + + Searc&h in all opened databases for matching entries + + + + + + + Only the selected database has to be connected with a client! + + + 30 + + + + + + + &Return also advanced string fields which start with "KPH: " + + + + + + + Automatic creates or updates are not supported for string fields! + + + 30 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + diff --git a/src/http/Service.cpp b/src/http/Service.cpp index aa3e93ed8..b13ba3fad 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -20,6 +20,7 @@ #include "Protocol.h" #include "EntryConfig.h" #include "AccessControlDialog.h" +#include "HttpSettings.h" #include "core/Database.h" #include "core/Entry.h" @@ -28,13 +29,6 @@ #include "core/Uuid.h" #include "core/PasswordGenerator.h" - -Service::Service(DatabaseTabWidget* parent) : - KeepassHttpProtocol::Server(parent), - m_dbTabWidget(parent) -{ -} - static const unsigned char KEEPASSHTTP_UUID_DATA[] = { 0x34, 0x69, 0x7a, 0x40, 0x8a, 0x5b, 0x41, 0xc0, 0x9f, 0x36, 0x89, 0x7d, 0x62, 0x3e, 0xcb, 0x31 @@ -46,6 +40,14 @@ static const char KEEPASSHTTP_GROUP_NAME[] = "KeePassHttp Passwords"; //Group static int KEEPASSHTTP_DEFAULT_ICON = 1; //private const int DEFAULT_NOTIFICATION_TIME = 5000; +Service::Service(DatabaseTabWidget* parent) : + KeepassHttpProtocol::Server(parent), + m_dbTabWidget(parent) +{ + if (HttpSettings::isEnabled()) + start(); +} + Entry* Service::getConfigEntry(bool create) { if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) @@ -85,11 +87,13 @@ bool Service::isDatabaseOpened() const bool Service::openDatabase() { + if (!HttpSettings::unlockDatabase()) + return false; if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) if (dbWidget->currentMode() == DatabaseWidget::LockedMode) { //- show notification - //- open window - //- wait a few seconds for user to unlock... + //- open & focus main window + //- wait a few seconds for user to unlock (unlockedDatabase) } return false; } @@ -206,10 +210,8 @@ Service::Access Service::checkAccess(const Entry *entry, const QString & host, c KeepassHttpProtocol::Entry Service::prepareEntry(const Entry* entry) { - bool returnStringFields = true; //TODO: setting! KeepassHttpProtocol::Entry res(entry->title(), entry->username(), entry->password(), entry->uuid().toHex()); - if (returnStringFields) - { + if (HttpSettings::supportKphFields()) { const EntryAttributes * attr = entry->attributes(); Q_FOREACH (const QString& key, attr->keys()) if (key.startsWith(QLatin1String("KPH: "))) @@ -273,7 +275,7 @@ private: QList Service::findMatchingEntries(const QString& /*id*/, const QString& url, const QString& submitUrl, const QString& realm) { - const bool autoAccept = false; //TODO: setting! + const bool alwaysAllowAccess = HttpSettings::alwaysAllowAccess(); const QString host = QUrl(url).host(); const QString submitHost = QUrl(submitUrl).host(); @@ -286,7 +288,7 @@ QList Service::findMatchingEntries(const QString& /* continue; case Unknown: - if (autoAccept) + if (alwaysAllowAccess) pwEntries.append(entry); else pwEntriesToConfirm.append(entry); @@ -346,8 +348,7 @@ QList Service::findMatchingEntries(const QString& /* priorities.insert(entry, sortPriority(entry, host, submitUrl, baseSubmitURL)); //Sort by priorities - const bool sortByTitle = true; //TODO: setting - qSort(pwEntries.begin(), pwEntries.end(), SortEntries(priorities, sortByTitle ? "Title" : "UserName")); + qSort(pwEntries.begin(), pwEntries.end(), SortEntries(priorities, HttpSettings::sortByTitle() ? "Title" : "UserName")); } //Fill the list @@ -427,8 +428,7 @@ void Service::updateEntry(const QString &id, const QString &uuid, const QString if (Entry * entry = db->resolveEntry(Uuid::fromHex(uuid))) { QString u = entry->username(); if (u != login || entry->password() != password) { - bool autoAllow = false; //TODO: setting to request confirmation/auto-allow - if ( autoAllow + if ( HttpSettings::alwaysAllowUpdate() || QMessageBox::warning(0, tr("KeyPassX/Http: Update Entry"), tr("Do you want to update the information in %1 - %2?").arg(QUrl(url).host()).arg(u), QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes ) { @@ -444,10 +444,9 @@ void Service::updateEntry(const QString &id, const QString &uuid, const QString QString Service::generatePassword() { PasswordGenerator * pwGenerator = passwordGenerator(); - //TODO: password generator settings - return pwGenerator->generatePassword(20, - PasswordGenerator::LowerLetters | PasswordGenerator::UpperLetters | PasswordGenerator::Numbers, - PasswordGenerator::ExcludeLookAlike | PasswordGenerator::CharFromEveryGroup); + return pwGenerator->generatePassword(HttpSettings::passwordLength(), + HttpSettings::passwordCharClasses(), + HttpSettings::passwordGeneratorFlags()); } void Service::removeSharedEncryptionKeys() From af394ff65c694b81d6396c6fc47eefa69ef6ccbe Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 17 Apr 2013 23:18:21 +0200 Subject: [PATCH 13/51] Settings UI integration. --- src/gui/DatabaseTabWidget.cpp | 3 --- src/gui/MainWindow.cpp | 37 +++++++++++++++++++++++++++++++++++ src/gui/SettingsWidget.cpp | 35 +++++++++++++++++++++++++++++++++ src/gui/SettingsWidget.h | 12 ++++++++++++ 4 files changed, 84 insertions(+), 3 deletions(-) diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index c899cd70d..cc87a5745 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -32,7 +32,6 @@ #include "gui/FileDialog.h" #include "gui/entry/EntryView.h" #include "gui/group/GroupView.h" -#include "http/Service.h" DatabaseManagerStruct::DatabaseManagerStruct() : dbWidget(Q_NULLPTR) @@ -54,8 +53,6 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent) connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabase(int))); connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType())); - - (new Service(this))->start(); } DatabaseTabWidget::~DatabaseTabWidget() diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 1eff09656..2ecad9b92 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -20,6 +20,7 @@ #include #include +#include #include "autotype/AutoType.h" #include "core/Config.h" @@ -32,6 +33,40 @@ #include "gui/entry/EntryView.h" #include "gui/group/GroupView.h" +#include "http/Service.h" +#include "http/HttpSettings.h" +#include "http/OptionDialog.h" +#include "gui/SettingsWidget.h" + +class HttpPlugin: public ISettingsPage { +public: + HttpPlugin(DatabaseTabWidget * tabWidget): m_service(new Service(tabWidget)) { + } + virtual ~HttpPlugin() { + } + virtual QString name() { + return QObject::tr("Http"); + } + virtual QWidget * createWidget() { + OptionDialog * dlg = new OptionDialog(); + QObject::connect(dlg, SIGNAL(removeSharedEncryptionKeys()), m_service.data(), SLOT(removeSharedEncryptionKeys())); + QObject::connect(dlg, SIGNAL(removeStoredPermissions()), m_service.data(), SLOT(removeStoredPermissions())); + return dlg; + } + virtual void loadSettings(QWidget * widget) { + qobject_cast(widget)->loadSettings(); + } + virtual void saveSettings(QWidget * widget) { + qobject_cast(widget)->saveSettings(); + if (HttpSettings::isEnabled()) + m_service->start(); + else + m_service->stop(); + } +private: + QScopedPointer m_service; +}; + const QString MainWindow::BaseWindowTitle = "KeePassX"; MainWindow::MainWindow() @@ -39,6 +74,8 @@ MainWindow::MainWindow() { m_ui->setupUi(this); + m_ui->settingsWidget->addSettingsPage(new HttpPlugin(m_ui->tabWidget)); + setWindowIcon(filePath()->applicationIcon()); QAction* toggleViewAction = m_ui->toolBar->toggleViewAction(); toggleViewAction->setText(tr("Show toolbar")); diff --git a/src/gui/SettingsWidget.cpp b/src/gui/SettingsWidget.cpp index 197cd7472..9a86eac99 100644 --- a/src/gui/SettingsWidget.cpp +++ b/src/gui/SettingsWidget.cpp @@ -22,6 +22,27 @@ #include "autotype/AutoType.h" #include "core/Config.h" +class SettingsWidget::ExtraPage +{ +public: + ExtraPage(ISettingsPage* page, QWidget* widget): settingsPage(page), widget(widget) + {} + + void loadSettings() const + { + settingsPage->loadSettings(widget); + } + + void saveSettings() const + { + settingsPage->saveSettings(widget); + } + +private: + QSharedPointer settingsPage; + QWidget* widget; +}; + SettingsWidget::SettingsWidget(QWidget* parent) : EditWidget(parent) , m_secWidget(new QWidget()) @@ -50,6 +71,14 @@ SettingsWidget::~SettingsWidget() { } +void SettingsWidget::addSettingsPage(ISettingsPage *page) +{ + QWidget * widget = page->createWidget(); + widget->setParent(this); + m_extraPages.append(ExtraPage(page, widget)); + add(page->name(), widget); +} + void SettingsWidget::loadSettings() { m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool()); @@ -66,6 +95,9 @@ void SettingsWidget::loadSettings() m_secUi->clearClipboardCheckBox->setChecked(config()->get("security/clearclipboard").toBool()); m_secUi->clearClipboardSpinBox->setValue(config()->get("security/clearclipboardtimeout").toInt()); + Q_FOREACH (const ExtraPage& page, m_extraPages) + page.loadSettings(); + setCurrentRow(0); } @@ -80,6 +112,9 @@ void SettingsWidget::saveSettings() config()->set("security/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked()); config()->set("security/clearclipboardtimeout", m_secUi->clearClipboardSpinBox->value()); + Q_FOREACH (const ExtraPage& page, m_extraPages) + page.saveSettings(); + Q_EMIT editFinished(true); } diff --git a/src/gui/SettingsWidget.h b/src/gui/SettingsWidget.h index cefbf6d49..a53fd30b7 100644 --- a/src/gui/SettingsWidget.h +++ b/src/gui/SettingsWidget.h @@ -25,6 +25,15 @@ namespace Ui { class SettingsWidgetSecurity; } +class ISettingsPage { +public: + virtual ~ISettingsPage() {} + virtual QString name() = 0; + virtual QWidget * createWidget() = 0; + virtual void loadSettings(QWidget * widget) = 0; + virtual void saveSettings(QWidget * widget) = 0; +}; + class SettingsWidget : public EditWidget { Q_OBJECT @@ -32,6 +41,7 @@ class SettingsWidget : public EditWidget public: explicit SettingsWidget(QWidget* parent = Q_NULLPTR); ~SettingsWidget(); + void addSettingsPage(ISettingsPage * page); void loadSettings(); Q_SIGNALS: @@ -49,6 +59,8 @@ private: const QScopedPointer m_generalUi; Qt::Key m_globalAutoTypeKey; Qt::KeyboardModifiers m_globalAutoTypeModifiers; + class ExtraPage; + QList m_extraPages; }; #endif // KEEPASSX_SETTINGSWIDGET_H From d6597400deb543fe8818034f08b0d5152b26ffd9 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Thu, 18 Apr 2013 22:47:46 +0200 Subject: [PATCH 14/51] Support IPv6 as well as IPv4. --- src/http/Server.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/http/Server.cpp b/src/http/Server.cpp index e0fc04703..9104ba0b6 100644 --- a/src/http/Server.cpp +++ b/src/http/Server.cpp @@ -61,7 +61,10 @@ void Server::start() { if (m_started) return; - m_started = m_httpServer->listen(QHostAddress::LocalHost, 19455); + + static const int PORT = 19455; + m_started = m_httpServer->listen(QHostAddress::LocalHost, PORT) + || m_httpServer->listen(QHostAddress::LocalHostIPv6, PORT); } void Server::stop() From 478d30b52935f164309c5c18e24bfadb126ee3a3 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Fri, 19 Apr 2013 17:20:26 +0200 Subject: [PATCH 15/51] Fix typo. --- src/http/Service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index b13ba3fad..95d9edae8 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -353,7 +353,7 @@ QList Service::findMatchingEntries(const QString& /* //Fill the list QList result; - result.reserve(result.size()); + result.reserve(pwEntries.count()); Q_FOREACH (Entry * entry, pwEntries) result << prepareEntry(entry); return result; From 7ff475977e8d5f345b1129a3457e8de99cd310c8 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Fri, 19 Apr 2013 19:38:29 +0200 Subject: [PATCH 16/51] Favicon download button. --- src/gui/EditWidgetIcons.cpp | 80 ++++++++++++++++++++++++++++++- src/gui/EditWidgetIcons.h | 16 ++++++- src/gui/EditWidgetIcons.ui | 7 +++ src/gui/entry/EditEntryWidget.cpp | 3 +- 4 files changed, 103 insertions(+), 3 deletions(-) diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index db4a29176..73f726f4f 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -18,6 +18,7 @@ #include "EditWidgetIcons.h" #include "ui_EditWidgetIcons.h" +#include #include #include @@ -37,6 +38,7 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent) , m_ui(new Ui::EditWidgetIcons()) , m_defaultIconModel(new DefaultIconModel(this)) , m_customIconModel(new CustomIconModel(this)) + , m_networkAccessMngr(new QNetworkAccessManager(this)) { m_ui->setupUi(this); @@ -53,6 +55,11 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent) this, SLOT(updateWidgetsCustomIcons(bool))); connect(m_ui->addButton, SIGNAL(clicked()), SLOT(addCustomIcon())); connect(m_ui->deleteButton, SIGNAL(clicked()), SLOT(removeCustomIcon())); + connect(m_ui->faviconButton, SIGNAL(clicked()), SLOT(downloadFavicon())); + connect(m_networkAccessMngr, SIGNAL(finished(QNetworkReply*)), + this, SLOT(onRequestFinished(QNetworkReply*)) ); + + m_ui->faviconButton->setVisible(false); } EditWidgetIcons::~EditWidgetIcons() @@ -89,13 +96,14 @@ IconStruct EditWidgetIcons::save() return iconStruct; } -void EditWidgetIcons::load(Uuid currentUuid, Database* database, IconStruct iconStruct) +void EditWidgetIcons::load(Uuid currentUuid, Database* database, IconStruct iconStruct, const QString &url) { Q_ASSERT(database); Q_ASSERT(!currentUuid.isNull()); m_database = database; m_currentUuid = currentUuid; + setUrl(url); m_customIconModel->setIcons(database->metadata()->customIcons(), database->metadata()->customIconsOrder()); @@ -119,6 +127,76 @@ void EditWidgetIcons::load(Uuid currentUuid, Database* database, IconStruct icon } } +void EditWidgetIcons::setUrl(const QString &url) +{ + m_url = url; + m_ui->faviconButton->setVisible(!url.isEmpty()); + abortFaviconDownload(); +} + +static QStringList getHost(QUrl url, const QString& path) +{ + QStringList hosts; + + QString host = url.host(); + for(;;) { + QString s = host; + if (url.port() >= 0) + s += ":" + QString::number(url.port()); + hosts << s + path; + + const int first_dot = host.indexOf( '.' ); + const int last_dot = host.lastIndexOf( '.' ); + if( ( first_dot != -1 ) && ( last_dot != -1 ) && ( first_dot != last_dot ) ) + host.remove( 0, first_dot + 1 ); + else + break; + } + return hosts; +} + +void EditWidgetIcons::downloadFavicon() +{ + const QStringList pathes = getHost(QUrl(m_url), "/favicon."); + const QStringList prefixes = QStringList() << "http://" << "https://"; + const QStringList suffixes = QStringList() << "ico" << "png" << "gif" << "jpg"; + + Q_FOREACH (QString path, pathes) + Q_FOREACH (QString prefix, prefixes) + Q_FOREACH (QString suffix, suffixes) + m_networkOperations << m_networkAccessMngr->get(QNetworkRequest(prefix + path + suffix)); + //TODO: progress indication +} + +void EditWidgetIcons::abortFaviconDownload() +{ + Q_FOREACH (QNetworkReply *r, m_networkOperations) + r->abort(); +} + +void EditWidgetIcons::onRequestFinished(QNetworkReply *reply) +{ + if (m_networkOperations.contains(reply)) { + m_networkOperations.remove(reply); + + QImage image; + if (!reply->error() && image.loadFromData(reply->readAll()) && !image.isNull()) { + //Abort all other requests + abortFaviconDownload(); + + //Set the image + Uuid uuid = Uuid::random(); + m_database->metadata()->addCustomIcon(uuid, image.scaled(16, 16)); + m_customIconModel->setIcons(m_database->metadata()->customIcons(), + m_database->metadata()->customIconsOrder()); + QModelIndex index = m_customIconModel->indexFromUuid(uuid); + m_ui->customIconsView->setCurrentIndex(index); + m_ui->customIconsRadio->setChecked(true); + } + } + reply->deleteLater(); +} + void EditWidgetIcons::addCustomIcon() { if (m_database) { diff --git a/src/gui/EditWidgetIcons.h b/src/gui/EditWidgetIcons.h index 50eec6034..a59f640c9 100644 --- a/src/gui/EditWidgetIcons.h +++ b/src/gui/EditWidgetIcons.h @@ -18,8 +18,13 @@ #ifndef KEEPASSX_EDITWIDGETICONS_H #define KEEPASSX_EDITWIDGETICONS_H +#include + #include +#include +#include + #include "core/Global.h" #include "core/Uuid.h" @@ -48,9 +53,15 @@ public: ~EditWidgetIcons(); IconStruct save(); - void load(Uuid currentUuid, Database* database, IconStruct iconStruct); + void load(Uuid currentUuid, Database* database, IconStruct iconStruct, const QString &url = QString()); + +public Q_SLOTS: + void setUrl(const QString &url); private Q_SLOTS: + void downloadFavicon(); + void abortFaviconDownload(); + void onRequestFinished(QNetworkReply *reply); void addCustomIcon(); void removeCustomIcon(); void updateWidgetsDefaultIcons(bool checked); @@ -62,8 +73,11 @@ private: const QScopedPointer m_ui; Database* m_database; Uuid m_currentUuid; + QString m_url; DefaultIconModel* const m_defaultIconModel; CustomIconModel* const m_customIconModel; + QNetworkAccessManager* const m_networkAccessMngr; + QSet m_networkOperations; Q_DISABLE_COPY(EditWidgetIcons) }; diff --git a/src/gui/EditWidgetIcons.ui b/src/gui/EditWidgetIcons.ui index 4a0d39fc2..dd9e61852 100644 --- a/src/gui/EditWidgetIcons.ui +++ b/src/gui/EditWidgetIcons.ui @@ -91,6 +91,13 @@ + + + + Download favicon + + + diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index cbb572c77..3f0dc511d 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -328,7 +328,8 @@ void EditEntryWidget::setForms(const Entry* entry, bool restore) IconStruct iconStruct; iconStruct.uuid = entry->iconUuid(); iconStruct.number = entry->iconNumber(); - m_iconsWidget->load(entry->uuid(), m_database, iconStruct); + m_iconsWidget->load(entry->uuid(), m_database, iconStruct, entry->url()); + connect(m_mainUi->urlEdit, SIGNAL(textChanged(QString)), m_iconsWidget, SLOT(setUrl(QString))); m_autoTypeUi->enableButton->setChecked(entry->autoTypeEnabled()); if (entry->defaultAutoTypeSequence().isEmpty()) { From 850c7c7ecf14b36cd1f13726bcef139877e880d5 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Mon, 22 Apr 2013 21:33:42 +0200 Subject: [PATCH 17/51] Option to automatically reopen databases which were last opened. --- src/core/Config.cpp | 1 + src/gui/DatabaseTabWidget.cpp | 34 ++++++++++++++++++++------------ src/gui/DatabaseTabWidget.h | 3 ++- src/gui/MainWindow.cpp | 2 ++ src/gui/SettingsWidget.cpp | 7 +++++++ src/gui/SettingsWidgetGeneral.ui | 21 +++++++++++++------- 6 files changed, 47 insertions(+), 21 deletions(-) diff --git a/src/core/Config.cpp b/src/core/Config.cpp index 047f4d670..08fbfdfb2 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -88,6 +88,7 @@ void Config::init(const QString& fileName) m_settings.reset(new QSettings(fileName, QSettings::IniFormat)); m_defaults.insert("RememberLastDatabases", true); + m_defaults.insert("AutoReopenLastDatabases", true); m_defaults.insert("ModifiedOnExpandedStateChanges", true); m_defaults.insert("AutoSaveAfterEveryChange", false); m_defaults.insert("AutoSaveOnExit", false); diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index cc87a5745..e81db035c 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -66,16 +66,7 @@ DatabaseTabWidget::~DatabaseTabWidget() void DatabaseTabWidget::toggleTabbar() { - if (count() > 1) { - if (!tabBar()->isVisible()) { - tabBar()->show(); - } - } - else { - if (tabBar()->isVisible()) { - tabBar()->hide(); - } - } + tabBar()->setVisible(count() > 1); } void DatabaseTabWidget::newDatabase() @@ -148,7 +139,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw, insertDatabase(db, dbStruct); - updateLastDatabases(dbStruct.filePath); + updateRecentDatabases(dbStruct.filePath); if (!pw.isNull() || !keyFile.isEmpty()) { dbStruct.dbWidget->switchToOpenDatabase(dbStruct.filePath, pw, keyFile); @@ -235,8 +226,25 @@ void DatabaseTabWidget::deleteDatabase(Database* db) delete db; } +void DatabaseTabWidget::reopenLastDatabases() +{ + if (config()->get("AutoReopenLastDatabases", false).toBool()) { + int index = count(); + Q_FOREACH (const QString & database, config()->get("LastOpenDatabases", QVariant()).toStringList()) + openDatabase(database); + setCurrentIndex(index); + } +} + bool DatabaseTabWidget::closeAllDatabases() { + QStringList reloadDatabases; + if (config()->get("AutoReopenLastDatabases", false).toBool()) { + for (int i = 0; i < count(); i ++) + reloadDatabases << indexDatabaseManagerStruct(i).filePath; + } + config()->set("LastOpenDatabases", reloadDatabases); + while (!m_dbList.isEmpty()) { if (!closeDatabase()) { return false; @@ -299,7 +307,7 @@ void DatabaseTabWidget::saveDatabaseAs(Database* db) dbStruct.fileName = fileInfo.fileName(); dbStruct.dbWidget->updateFilename(dbStruct.filePath); updateTabName(db); - updateLastDatabases(dbStruct.filePath); + updateRecentDatabases(dbStruct.filePath); } else { QMessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n" @@ -545,7 +553,7 @@ void DatabaseTabWidget::modified() } } -void DatabaseTabWidget::updateLastDatabases(const QString& filename) +void DatabaseTabWidget::updateRecentDatabases(const QString& filename) { if (!config()->get("RememberLastDatabases").toBool()) { config()->set("LastDatabases", QVariant()); diff --git a/src/gui/DatabaseTabWidget.h b/src/gui/DatabaseTabWidget.h index 51dcc76f9..bdbe8034c 100644 --- a/src/gui/DatabaseTabWidget.h +++ b/src/gui/DatabaseTabWidget.h @@ -65,6 +65,7 @@ public Q_SLOTS: void saveDatabaseAs(int index = -1); bool closeDatabase(int index = -1); void closeDatabaseFromSender(); + void reopenLastDatabases(); bool closeAllDatabases(); void changeMasterKey(); void changeDatabaseSettings(); @@ -93,7 +94,7 @@ private: DatabaseManagerStruct indexDatabaseManagerStruct(int index); Database* databaseFromDatabaseWidget(DatabaseWidget* dbWidget); void insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct); - void updateLastDatabases(const QString& filename); + void updateRecentDatabases(const QString& filename); void connectDatabase(Database* newDb, Database* oldDb = Q_NULLPTR); KeePass2Writer m_writer; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 2ecad9b92..97a098071 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -227,6 +227,8 @@ MainWindow::MainWindow() m_actionMultiplexer.connect(m_ui->actionSearch, SIGNAL(triggered()), SLOT(toggleSearch())); + + m_ui->tabWidget->reopenLastDatabases(); } MainWindow::~MainWindow() diff --git a/src/gui/SettingsWidget.cpp b/src/gui/SettingsWidget.cpp index 9a86eac99..17ab6082f 100644 --- a/src/gui/SettingsWidget.cpp +++ b/src/gui/SettingsWidget.cpp @@ -63,8 +63,12 @@ SettingsWidget::SettingsWidget(QWidget* parent) connect(m_generalUi->autoSaveAfterEveryChangeCheckBox, SIGNAL(toggled(bool)), this, SLOT(enableAutoSaveOnExit(bool))); + connect(m_generalUi->rememberLastDatabasesCheckBox, SIGNAL(toggled(bool)), + m_generalUi->autoReopenLastDatabases, SLOT(setEnabled(bool))); + connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)), m_secUi->clearClipboardSpinBox, SLOT(setEnabled(bool))); + } SettingsWidget::~SettingsWidget() @@ -82,6 +86,7 @@ void SettingsWidget::addSettingsPage(ISettingsPage *page) void SettingsWidget::loadSettings() { m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool()); + m_generalUi->autoReopenLastDatabases->setChecked(config()->get("AutoReopenLastDatabases").toBool()); m_generalUi->modifiedExpandedChangedCheckBox->setChecked(config()->get("ModifiedOnExpandedStateChanges").toBool()); m_generalUi->autoSaveAfterEveryChangeCheckBox->setChecked(config()->get("AutoSaveAfterEveryChange").toBool()); m_generalUi->autoSaveOnExitCheckBox->setChecked(config()->get("AutoSaveOnExit").toBool()); @@ -104,6 +109,8 @@ void SettingsWidget::loadSettings() void SettingsWidget::saveSettings() { config()->set("RememberLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked()); + config()->set("AutoReopenLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked() + && m_generalUi->autoReopenLastDatabases->isChecked()); config()->set("ModifiedOnExpandedStateChanges", m_generalUi->modifiedExpandedChangedCheckBox->isChecked()); config()->set("AutoSaveAfterEveryChange", m_generalUi->autoSaveAfterEveryChangeCheckBox->isChecked()); config()->set("AutoSaveOnExit", m_generalUi->autoSaveOnExitCheckBox->isChecked()); diff --git a/src/gui/SettingsWidgetGeneral.ui b/src/gui/SettingsWidgetGeneral.ui index 78e9dadba..a369cf1c2 100644 --- a/src/gui/SettingsWidgetGeneral.ui +++ b/src/gui/SettingsWidgetGeneral.ui @@ -7,21 +7,21 @@ 0 0 456 - 146 + 172 - Remember last databases + Remember recent databases true - + Mark as modified on expanded state changes @@ -31,30 +31,37 @@ - + Automatically save after every change - + Automatically save on exit - + Global Auto-Type shortcut - + + + + + Automatically reopen last databases + + + From d5c87874511ac694b923dcff937dd92bf4e8d2e3 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 24 Apr 2013 22:38:34 +0200 Subject: [PATCH 18/51] Detect background changes to database file. This gives the option to reload the database. TODO: - Settings for reloadBehavior (ask, reloadUnchanged, ignore) - Improve notification, by using a header instead of dialog: nicer, less intrusive, gives more options to user, and works better when multiple databases are open. - Keep tab order on reload. --- src/core/Database.cpp | 5 ++ src/core/Database.h | 1 + src/gui/DatabaseOpenWidget.cpp | 14 +++- src/gui/DatabaseOpenWidget.h | 2 + src/gui/DatabaseTabWidget.cpp | 136 +++++++++++++++++++++++++++++++-- src/gui/DatabaseTabWidget.h | 20 ++++- src/gui/DatabaseWidget.cpp | 16 +++- src/gui/DatabaseWidget.h | 7 +- src/gui/MainWindow.cpp | 9 +++ src/gui/MainWindow.h | 3 +- 10 files changed, 200 insertions(+), 13 deletions(-) diff --git a/src/core/Database.cpp b/src/core/Database.cpp index 3e656873b..d18b1bf87 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -227,6 +227,11 @@ bool Database::verifyKey(const CompositeKey& key) const return (m_key.rawKey() == key.rawKey()); } +CompositeKey Database::key() const +{ + return m_key; +} + void Database::createRecycleBin() { Group* recycleBin = Group::createRecycleBin(); diff --git a/src/core/Database.h b/src/core/Database.h index f4173441f..07ae3aea8 100644 --- a/src/core/Database.h +++ b/src/core/Database.h @@ -88,6 +88,7 @@ public: void setKey(const CompositeKey& key); bool hasKey() const; bool verifyKey(const CompositeKey& key) const; + CompositeKey key() const; void recycleEntry(Entry* entry); void recycleGroup(Group* group); void setEmitModified(bool value); diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 4c1e0b4cb..3095572a7 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -91,14 +91,26 @@ void DatabaseOpenWidget::enterKey(const QString& pw, const QString& keyFile) openDatabase(); } +void DatabaseOpenWidget::enterKey(const CompositeKey& masterKey) +{ + if (masterKey.isEmpty()) { + return; + } + openDatabase(masterKey); +} + void DatabaseOpenWidget::openDatabase() { - KeePass2Reader reader; CompositeKey masterKey = databaseKey(); if (masterKey.isEmpty()) { return; } + openDatabase(masterKey); +} +void DatabaseOpenWidget::openDatabase(const CompositeKey& masterKey) +{ + KeePass2Reader reader; QFile file(m_filename); if (!file.open(QIODevice::ReadOnly)) { // TODO: error message diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index 0216de586..9182b4795 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -39,6 +39,7 @@ public: ~DatabaseOpenWidget(); void load(const QString& filename); void enterKey(const QString& pw, const QString& keyFile); + void enterKey(const CompositeKey& masterKey); Database* database(); Q_SIGNALS: @@ -49,6 +50,7 @@ protected: protected Q_SLOTS: virtual void openDatabase(); + void openDatabase(const CompositeKey& masterKey); void reject(); private Q_SLOTS: diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index e81db035c..34bf41209 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include #include "autotype/AutoType.h" #include "core/Config.h" @@ -45,7 +48,9 @@ DatabaseManagerStruct::DatabaseManagerStruct() const int DatabaseTabWidget::LastDatabasesCount = 5; DatabaseTabWidget::DatabaseTabWidget(QWidget* parent) - : QTabWidget(parent) + : QTabWidget(parent), + m_fileWatcher(new QFileSystemWatcher(this)), + m_reloadBehavior(ReloadUnmodified) //TODO: setting { DragTabBar* tabBar = new DragTabBar(this); tabBar->setDrawBase(false); @@ -53,6 +58,7 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent) connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabase(int))); connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType())); + connect(m_fileWatcher, SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString))); } DatabaseTabWidget::~DatabaseTabWidget() @@ -92,7 +98,7 @@ void DatabaseTabWidget::openDatabase() } void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw, - const QString& keyFile) + const QString& keyFile, const CompositeKey& key) { QFileInfo fileInfo(fileName); QString canonicalFilePath = fileInfo.canonicalFilePath(); @@ -136,12 +142,17 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw, dbStruct.filePath = fileInfo.absoluteFilePath(); dbStruct.canonicalFilePath = canonicalFilePath; dbStruct.fileName = fileInfo.fileName(); + dbStruct.lastModified = fileInfo.lastModified(); insertDatabase(db, dbStruct); + m_fileWatcher->addPath(dbStruct.filePath); updateRecentDatabases(dbStruct.filePath); - if (!pw.isNull() || !keyFile.isEmpty()) { + if (!key.isEmpty()) { + dbStruct.dbWidget->switchToOpenDatabase(dbStruct.filePath, key); + } + else if (!pw.isNull() || !keyFile.isEmpty()) { dbStruct.dbWidget->switchToOpenDatabase(dbStruct.filePath, pw, keyFile); } else { @@ -168,6 +179,111 @@ void DatabaseTabWidget::importKeePass1Database() dbStruct.dbWidget->switchToImportKeepass1(fileName); } +void DatabaseTabWidget::fileChanged(const QString &fileName) +{ + const bool wasEmpty = m_changedFiles.isEmpty(); + m_changedFiles.insert(fileName); + if (wasEmpty && !m_changedFiles.isEmpty()) + QTimer::singleShot(200, this, SLOT(checkReloadDatabases())); +} + +void DatabaseTabWidget::expectFileChange(const DatabaseManagerStruct& dbStruct) +{ + if (dbStruct.filePath.isEmpty()) + return; + m_expectedFileChanges.insert(dbStruct.filePath); +} + +void DatabaseTabWidget::unexpectFileChange(DatabaseManagerStruct& dbStruct) +{ + if (dbStruct.filePath.isEmpty()) + return; + m_expectedFileChanges.remove(dbStruct.filePath); + dbStruct.lastModified = QFileInfo(dbStruct.filePath).lastModified(); +} + +void DatabaseTabWidget::checkReloadDatabases() +{ + QSet changedFiles; + + changedFiles = m_changedFiles.subtract(m_expectedFileChanges); + m_changedFiles.clear(); + + if (changedFiles.isEmpty()) + return; + + Q_FOREACH (DatabaseManagerStruct dbStruct, m_dbList) { + QString filePath = dbStruct.filePath; + Database * db = dbStruct.dbWidget->database(); + + if (!changedFiles.contains(filePath)) + continue; + + QFileInfo fi(filePath); + QDateTime lastModified = fi.lastModified(); + if (dbStruct.lastModified == lastModified) + continue; + + DatabaseWidget::Mode mode = dbStruct.dbWidget->currentMode(); + if (mode == DatabaseWidget::None || mode == DatabaseWidget::LockedMode || !db->hasKey()) + continue; + + if ( (m_reloadBehavior == AlwaysAsk) + || (m_reloadBehavior == ReloadUnmodified && mode == DatabaseWidget::EditMode) + || (m_reloadBehavior == ReloadUnmodified && dbStruct.modified)) { + //TODO: display banner instead, to let user now file has changed and choose to Reload, Overwrite, and SaveAs + // --> less obstrubsive (esp. if multiple DB are open), cleaner UI + if (QMessageBox::warning(this, fi.exists() ? tr("Database file changed") : tr("Database file removed"), + tr("Do you want to discard your changes and reload?"), + QMessageBox::Yes|QMessageBox::No) == QMessageBox::No) + continue; + } + + if (fi.exists()) { + //Ignore/cancel all edits + dbStruct.dbWidget->switchToView(false); + dbStruct.modified = false; + + //Save current group/entry + Uuid currentGroup; + if (Group* group = dbStruct.dbWidget->groupView()->currentGroup()) + currentGroup = group->uuid(); + Uuid currentEntry; + if (Entry* entry = dbStruct.dbWidget->entryView()->currentEntry()) + currentEntry = entry->uuid(); + QString searchText = dbStruct.dbWidget->searchText(); + + //Reload updated db + CompositeKey key = db->key(); + closeDatabase(db); + openDatabase(filePath, QString(), QString(), key); + + //Restore current group/entry + dbStruct = indexDatabaseManagerStruct(count() - 1); + if (dbStruct.dbWidget) { + Database * db = dbStruct.dbWidget->database(); + if (!searchText.isEmpty()) + dbStruct.dbWidget->showSearch(searchText); + if (!currentGroup.isNull()) + if (Group* group = db->resolveGroup(currentGroup)) + dbStruct.dbWidget->groupView()->setCurrentGroup(group); + if (!currentEntry.isNull()) + if (Entry* entry = db->resolveEntry(currentEntry)) + dbStruct.dbWidget->entryView()->setCurrentEntry(entry); + } + + //TODO: keep tab order... + } else { + //Ignore/cancel all edits + dbStruct.dbWidget->switchToView(false); + dbStruct.modified = false; + + //Close database + closeDatabase(dbStruct.dbWidget->database()); + } + } +} + bool DatabaseTabWidget::closeDatabase(Database* db) { Q_ASSERT(db); @@ -219,6 +335,7 @@ void DatabaseTabWidget::deleteDatabase(Database* db) const DatabaseManagerStruct dbStruct = m_dbList.value(db); int index = databaseIndex(db); + m_fileWatcher->removePath(dbStruct.filePath); removeTab(index); toggleTabbar(); m_dbList.remove(db); @@ -260,12 +377,16 @@ void DatabaseTabWidget::saveDatabase(Database* db) if (dbStruct.saveToFilename) { bool result = false; + expectFileChange(dbStruct); + QSaveFile saveFile(dbStruct.filePath); if (saveFile.open(QIODevice::WriteOnly)) { m_writer.writeDatabase(&saveFile, db); result = saveFile.commit(); } + unexpectFileChange(dbStruct); + if (result) { dbStruct.modified = false; updateTabName(db); @@ -283,12 +404,12 @@ void DatabaseTabWidget::saveDatabase(Database* db) void DatabaseTabWidget::saveDatabaseAs(Database* db) { DatabaseManagerStruct& dbStruct = m_dbList[db]; - QString oldFileName; + QString oldFilePath; if (dbStruct.saveToFilename) { - oldFileName = dbStruct.filePath; + oldFilePath = dbStruct.filePath; } QString fileName = fileDialog()->getSaveFileName(this, tr("Save database as"), - oldFileName, tr("KeePass 2 Database").append(" (*.kdbx)")); + oldFilePath, tr("KeePass 2 Database").append(" (*.kdbx)")); if (!fileName.isEmpty()) { bool result = false; @@ -299,15 +420,18 @@ void DatabaseTabWidget::saveDatabaseAs(Database* db) } if (result) { + m_fileWatcher->removePath(oldFilePath); dbStruct.modified = false; dbStruct.saveToFilename = true; QFileInfo fileInfo(fileName); dbStruct.filePath = fileInfo.absoluteFilePath(); dbStruct.canonicalFilePath = fileInfo.canonicalFilePath(); dbStruct.fileName = fileInfo.fileName(); + dbStruct.lastModified = fileInfo.lastModified(); dbStruct.dbWidget->updateFilename(dbStruct.filePath); updateTabName(db); updateRecentDatabases(dbStruct.filePath); + m_fileWatcher->addPath(dbStruct.filePath); } else { QMessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n" diff --git a/src/gui/DatabaseTabWidget.h b/src/gui/DatabaseTabWidget.h index bdbe8034c..6b473eb7f 100644 --- a/src/gui/DatabaseTabWidget.h +++ b/src/gui/DatabaseTabWidget.h @@ -18,7 +18,9 @@ #ifndef KEEPASSX_DATABASETABWIDGET_H #define KEEPASSX_DATABASETABWIDGET_H +#include #include +#include #include #include "format/KeePass2Writer.h" @@ -27,6 +29,7 @@ class DatabaseWidget; class DatabaseOpenWidget; class QFile; +class QFileSystemWatcher; struct DatabaseManagerStruct { @@ -39,6 +42,7 @@ struct DatabaseManagerStruct bool saveToFilename; bool modified; bool readOnly; + QDateTime lastModified; }; Q_DECLARE_TYPEINFO(DatabaseManagerStruct, Q_MOVABLE_TYPE); @@ -51,16 +55,24 @@ public: explicit DatabaseTabWidget(QWidget* parent = Q_NULLPTR); ~DatabaseTabWidget(); void openDatabase(const QString& fileName, const QString& pw = QString(), - const QString& keyFile = QString()); + const QString& keyFile = QString(), const CompositeKey& key = CompositeKey()); DatabaseWidget* currentDatabaseWidget(); bool hasLockableDatabases(); static const int LastDatabasesCount; + enum ReloadBehavior { + AlwaysAsk, + ReloadUnmodified, + IgnoreAll + }; + public Q_SLOTS: void newDatabase(); void openDatabase(); void importKeePass1Database(); + void fileChanged(const QString& fileName); + void checkReloadDatabases(); void saveDatabase(int index = -1); void saveDatabaseAs(int index = -1); bool closeDatabase(int index = -1); @@ -96,9 +108,15 @@ private: void insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct); void updateRecentDatabases(const QString& filename); void connectDatabase(Database* newDb, Database* oldDb = Q_NULLPTR); + void expectFileChange(const DatabaseManagerStruct& dbStruct); + void unexpectFileChange(DatabaseManagerStruct& dbStruct); KeePass2Writer m_writer; QHash m_dbList; + QSet m_changedFiles; + QSet m_expectedFileChanges; + QFileSystemWatcher* m_fileWatcher; + ReloadBehavior m_reloadBehavior; }; #endif // KEEPASSX_DATABASETABWIDGET_H diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 277853e5b..68b89761f 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -533,6 +533,13 @@ void DatabaseWidget::switchToOpenDatabase(const QString& fileName, const QString m_databaseOpenWidget->enterKey(password, keyFile); } +void DatabaseWidget::switchToOpenDatabase(const QString &fileName, const CompositeKey& masterKey) +{ + updateFilename(fileName); + switchToOpenDatabase(fileName); + m_databaseOpenWidget->enterKey(masterKey); +} + void DatabaseWidget::switchToImportKeepass1(const QString& fileName) { updateFilename(fileName); @@ -556,10 +563,10 @@ void DatabaseWidget::closeSearch() m_groupView->setCurrentGroup(m_lastGroup); } -void DatabaseWidget::showSearch() +void DatabaseWidget::showSearch(const QString & searchString) { m_searchUi->searchEdit->blockSignals(true); - m_searchUi->searchEdit->clear(); + m_searchUi->searchEdit->setText(searchString); m_searchUi->searchEdit->blockSignals(false); m_searchUi->searchCurrentRadioButton->blockSignals(true); @@ -665,6 +672,11 @@ bool DatabaseWidget::isInSearchMode() return m_entryView->inEntryListMode(); } +QString DatabaseWidget::searchText() +{ + return m_entryView->inEntryListMode() ? m_searchUi->searchEdit->text() : QString(); +} + void DatabaseWidget::clearLastGroup(Group* group) { if (group) { diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index a39b085da..92cb79734 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -37,6 +37,7 @@ class KeePass1OpenWidget; class QFile; class QMenu; class UnlockDatabaseWidget; +class CompositeKey; namespace Ui { class SearchWidget; @@ -63,6 +64,7 @@ public: bool dbHasKey(); bool canDeleteCurrentGoup(); bool isInSearchMode(); + QString searchText(); int addWidget(QWidget* w); void setCurrentIndex(int index); void setCurrentWidget(QWidget* widget); @@ -97,14 +99,16 @@ public Q_SLOTS: void switchToDatabaseSettings(); void switchToOpenDatabase(const QString& fileName); void switchToOpenDatabase(const QString& fileName, const QString& password, const QString& keyFile); + void switchToOpenDatabase(const QString &fileName, const CompositeKey &masterKey); void switchToImportKeepass1(const QString& fileName); + void switchToView(bool accepted); void toggleSearch(); + void showSearch(const QString & searchString = QString()); void emitGroupContextMenuRequested(const QPoint& pos); void emitEntryContextMenuRequested(const QPoint& pos); private Q_SLOTS: void switchBackToEntryEdit(); - void switchToView(bool accepted); void switchToHistoryView(Entry* entry); void switchToEntryEdit(Entry* entry); void switchToEntryEdit(Entry* entry, bool create); @@ -117,7 +121,6 @@ private Q_SLOTS: void search(); void startSearch(); void startSearchTimer(); - void showSearch(); void closeSearch(); private: diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 97a098071..657ecce4b 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -284,6 +284,15 @@ void MainWindow::clearLastDatabases() config()->set("LastDatabases", QVariant()); } +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + if (e->type() == QEvent::ActivationChange) { + if (isActiveWindow()) + m_ui->tabWidget->checkReloadDatabases(); + } +} + void MainWindow::openDatabase(const QString& fileName, const QString& pw, const QString& keyFile) { m_ui->tabWidget->openDatabase(fileName, pw, keyFile); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 60da08010..52472a429 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -41,7 +41,8 @@ public Q_SLOTS: const QString& keyFile = QString()); protected: - void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE; + void changeEvent(QEvent *e); + void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE; private Q_SLOTS: void setMenuActionState(DatabaseWidget::Mode mode = DatabaseWidget::None); From f4ff8b17f75e6cd57ca16c665027e7b3f59951b9 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Mon, 29 Apr 2013 18:04:26 +0200 Subject: [PATCH 19/51] Use search field for search. Search options are presented in a context menu on the search field, as well as links in search header. --- src/CMakeLists.txt | 2 + src/gui/DatabaseTabWidget.cpp | 8 +- src/gui/DatabaseWidget.cpp | 150 ++++++---- src/gui/DatabaseWidget.h | 19 +- src/gui/MainWindow.cpp | 59 +++- src/gui/MainWindow.h | 1 + src/gui/MainWindow.ui | 70 ++++- src/gui/SearchWidget.ui | 69 +---- src/gui/qocoa/CMakeLists.txt | 50 ++++ src/gui/qocoa/LICENSE.txt | 19 ++ src/gui/qocoa/Qocoa.pro | 17 ++ src/gui/qocoa/README.md | 36 +++ src/gui/qocoa/TODO.md | 13 + src/gui/qocoa/gallery.cpp | 75 +++++ src/gui/qocoa/gallery.h | 14 + src/gui/qocoa/gallery.png | Bin 0 -> 42195 bytes src/gui/qocoa/main.cpp | 12 + src/gui/qocoa/qbutton.h | 49 ++++ src/gui/qocoa/qbutton_mac.mm | 229 +++++++++++++++ src/gui/qocoa/qbutton_nonmac.cpp | 89 ++++++ src/gui/qocoa/qocoa_mac.h | 54 ++++ src/gui/qocoa/qprogressindicatorspinning.h | 29 ++ .../qocoa/qprogressindicatorspinning_mac.mm | 70 +++++ .../qprogressindicatorspinning_nonmac.cpp | 86 ++++++ .../qprogressindicatorspinning_nonmac.gif | Bin 0 -> 3208 bytes .../qprogressindicatorspinning_nonmac.qrc | 5 + src/gui/qocoa/qsearchfield.h | 48 ++++ src/gui/qocoa/qsearchfield_mac.mm | 257 +++++++++++++++++ src/gui/qocoa/qsearchfield_nonmac.cpp | 270 ++++++++++++++++++ src/gui/qocoa/qsearchfield_nonmac.qrc | 7 + src/gui/qocoa/qsearchfield_nonmac_clear.png | Bin 0 -> 736 bytes .../qocoa/qsearchfield_nonmac_magnifier.png | Bin 0 -> 300 bytes .../qsearchfield_nonmac_magnifier_menu.png | Bin 0 -> 439 bytes 33 files changed, 1653 insertions(+), 154 deletions(-) create mode 100644 src/gui/qocoa/CMakeLists.txt create mode 100644 src/gui/qocoa/LICENSE.txt create mode 100644 src/gui/qocoa/Qocoa.pro create mode 100644 src/gui/qocoa/README.md create mode 100644 src/gui/qocoa/TODO.md create mode 100644 src/gui/qocoa/gallery.cpp create mode 100644 src/gui/qocoa/gallery.h create mode 100644 src/gui/qocoa/gallery.png create mode 100644 src/gui/qocoa/main.cpp create mode 100644 src/gui/qocoa/qbutton.h create mode 100644 src/gui/qocoa/qbutton_mac.mm create mode 100644 src/gui/qocoa/qbutton_nonmac.cpp create mode 100644 src/gui/qocoa/qocoa_mac.h create mode 100644 src/gui/qocoa/qprogressindicatorspinning.h create mode 100644 src/gui/qocoa/qprogressindicatorspinning_mac.mm create mode 100644 src/gui/qocoa/qprogressindicatorspinning_nonmac.cpp create mode 100644 src/gui/qocoa/qprogressindicatorspinning_nonmac.gif create mode 100644 src/gui/qocoa/qprogressindicatorspinning_nonmac.qrc create mode 100644 src/gui/qocoa/qsearchfield.h create mode 100644 src/gui/qocoa/qsearchfield_mac.mm create mode 100644 src/gui/qocoa/qsearchfield_nonmac.cpp create mode 100644 src/gui/qocoa/qsearchfield_nonmac.qrc create mode 100644 src/gui/qocoa/qsearchfield_nonmac_clear.png create mode 100644 src/gui/qocoa/qsearchfield_nonmac_magnifier.png create mode 100644 src/gui/qocoa/qsearchfield_nonmac_magnifier_menu.png diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b57ee84d2..6b7ac25b2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -219,12 +219,14 @@ qt4_wrap_cpp(keepassx_SOURCES ${keepassx_MOC}) add_library(keepassx_core STATIC ${keepassx_SOURCES}) set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE) +add_subdirectory(gui/qocoa) add_subdirectory(http/qhttpserver) add_subdirectory(http/qjson) add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE}) target_link_libraries(${PROGNAME} keepassx_core + Qocoa qjson qhttpserver ${QT_QTCORE_LIBRARY} diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 34bf41209..a520fd46d 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -246,12 +246,14 @@ void DatabaseTabWidget::checkReloadDatabases() //Save current group/entry Uuid currentGroup; - if (Group* group = dbStruct.dbWidget->groupView()->currentGroup()) + if (Group* group = dbStruct.dbWidget->currentGroup()) currentGroup = group->uuid(); Uuid currentEntry; if (Entry* entry = dbStruct.dbWidget->entryView()->currentEntry()) currentEntry = entry->uuid(); QString searchText = dbStruct.dbWidget->searchText(); + bool caseSensitive = dbStruct.dbWidget->caseSensitiveSearch(); + bool allGroups = dbStruct.dbWidget->isAllGroupsSearch(); //Reload updated db CompositeKey key = db->key(); @@ -262,11 +264,11 @@ void DatabaseTabWidget::checkReloadDatabases() dbStruct = indexDatabaseManagerStruct(count() - 1); if (dbStruct.dbWidget) { Database * db = dbStruct.dbWidget->database(); - if (!searchText.isEmpty()) - dbStruct.dbWidget->showSearch(searchText); if (!currentGroup.isNull()) if (Group* group = db->resolveGroup(currentGroup)) dbStruct.dbWidget->groupView()->setCurrentGroup(group); + if (!searchText.isEmpty()) + dbStruct.dbWidget->search(searchText, caseSensitive, allGroups); if (!currentEntry.isNull()) if (Entry* entry = db->resolveEntry(currentEntry)) dbStruct.dbWidget->entryView()->setCurrentEntry(entry); diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 68b89761f..f368bf945 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -50,6 +50,8 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent) , m_newGroup(Q_NULLPTR) , m_newEntry(Q_NULLPTR) , m_newParent(Q_NULLPTR) + , m_searchAllGroups(false) + , m_searchSensitivity(Qt::CaseInsensitive) { m_searchUi->setupUi(m_searchWidget); @@ -89,8 +91,9 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent) closeAction->setIcon(closeIcon); m_searchUi->closeSearchButton->setDefaultAction(closeAction); m_searchUi->closeSearchButton->setShortcut(Qt::Key_Escape); + int iconsize = style()->pixelMetric(QStyle::PM_SmallIconSize); + m_searchUi->closeSearchButton->setIconSize(QSize(iconsize,iconsize)); m_searchWidget->hide(); - m_searchUi->caseSensitiveCheckBox->setVisible(false); QVBoxLayout* vLayout = new QVBoxLayout(rightHandSideWidget); vLayout->setMargin(0); @@ -149,10 +152,7 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent) connect(m_keepass1OpenWidget, SIGNAL(editFinished(bool)), SLOT(openDatabase(bool))); connect(m_unlockDatabaseWidget, SIGNAL(editFinished(bool)), SLOT(unlockDatabase(bool))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(emitCurrentModeChanged())); - connect(m_searchUi->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(startSearchTimer())); - connect(m_searchUi->caseSensitiveCheckBox, SIGNAL(toggled(bool)), this, SLOT(startSearch())); - connect(m_searchUi->searchCurrentRadioButton, SIGNAL(toggled(bool)), this, SLOT(startSearch())); - connect(m_searchUi->searchRootRadioButton, SIGNAL(toggled(bool)), this, SLOT(startSearch())); + connect(m_searchUi->searchResults, SIGNAL(linkActivated(QString)), this, SLOT(onLinkActivated(QString))); connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(search())); connect(closeAction, SIGNAL(triggered()), this, SLOT(closeSearch())); @@ -547,84 +547,117 @@ void DatabaseWidget::switchToImportKeepass1(const QString& fileName) setCurrentWidget(m_keepass1OpenWidget); } -void DatabaseWidget::toggleSearch() +void DatabaseWidget::search(const QString& searchString, bool caseSensitive, bool allGroups) { - if (m_entryView->inEntryListMode()) { - closeSearch(); + m_searchSensitivity = caseSensitive ? Qt::CaseSensitive + : Qt::CaseInsensitive; + m_searchAllGroups = allGroups; + search(searchString); +} + +void DatabaseWidget::search(const QString& text) +{ + if (text.isEmpty()) { + if (m_entryView->inEntryListMode()) + closeSearch(); + } + else if (m_entryView->inEntryListMode()) { + m_searchText = text; + startSearchTimer(); } else { - showSearch(); + showSearch(text); + } +} + +bool DatabaseWidget::caseSensitiveSearch() const +{ + return m_searchSensitivity == Qt::CaseSensitive; +} + +void DatabaseWidget::setCaseSensitiveSearch(bool caseSensitive) +{ + if (caseSensitive != caseSensitiveSearch()) { + m_searchSensitivity = caseSensitive ? Qt::CaseSensitive + : Qt::CaseInsensitive; + if (m_entryView->inEntryListMode()) + startSearchTimer(); + } +} + +bool DatabaseWidget::isAllGroupsSearch() const +{ + return m_searchAllGroups; +} + +bool DatabaseWidget::canChooseSearchScope() const +{ + return currentGroup() != m_db->rootGroup(); +} + +Group*DatabaseWidget::currentGroup() const +{ + return m_entryView->inEntryListMode() ? m_lastGroup + : m_groupView->currentGroup(); +} + +void DatabaseWidget::setAllGroupsSearch(bool allGroups) +{ + if (allGroups != isAllGroupsSearch()) { + m_searchAllGroups = allGroups; + if (m_entryView->inEntryListMode()) + startSearchTimer(); } } void DatabaseWidget::closeSearch() { Q_ASSERT(m_lastGroup); + m_searchTimer->stop(); m_groupView->setCurrentGroup(m_lastGroup); } void DatabaseWidget::showSearch(const QString & searchString) { - m_searchUi->searchEdit->blockSignals(true); - m_searchUi->searchEdit->setText(searchString); - m_searchUi->searchEdit->blockSignals(false); - - m_searchUi->searchCurrentRadioButton->blockSignals(true); - m_searchUi->searchRootRadioButton->blockSignals(true); - m_searchUi->searchRootRadioButton->setChecked(true); - m_searchUi->searchCurrentRadioButton->blockSignals(false); - m_searchUi->searchRootRadioButton->blockSignals(false); - + m_searchText = searchString; m_lastGroup = m_groupView->currentGroup(); Q_ASSERT(m_lastGroup); - - if (m_lastGroup == m_db->rootGroup()) { - m_searchUi->optionsWidget->hide(); - m_searchUi->searchCurrentRadioButton->hide(); - m_searchUi->searchRootRadioButton->hide(); - } - else { - m_searchUi->optionsWidget->show(); - m_searchUi->searchCurrentRadioButton->show(); - m_searchUi->searchRootRadioButton->show(); - m_searchUi->searchCurrentRadioButton->setText(tr("Current group") - .append(" (") - .append(m_lastGroup->name()) - .append(")")); - } m_groupView->setCurrentIndex(QModelIndex()); m_searchWidget->show(); search(); - m_searchUi->searchEdit->setFocus(); +} + +void DatabaseWidget::onLinkActivated(const QString& link) +{ + if (link == "searchAll") + setAllGroupsSearch(true); + else if (link == "searchCurrent") + setAllGroupsSearch(false); } void DatabaseWidget::search() { Q_ASSERT(m_lastGroup); - Group* searchGroup; - if (m_searchUi->searchCurrentRadioButton->isChecked()) { - searchGroup = m_lastGroup; - } - else if (m_searchUi->searchRootRadioButton->isChecked()) { - searchGroup = m_db->rootGroup(); - } - else { - Q_ASSERT(false); - return; - } + Group* searchGroup = m_searchAllGroups ? m_db->rootGroup() + : m_lastGroup; + QList searchResult = searchGroup->search(m_searchText, m_searchSensitivity); - Qt::CaseSensitivity sensitivity; - if (m_searchUi->caseSensitiveCheckBox->isChecked()) { - sensitivity = Qt::CaseSensitive; + QString message; + switch(searchResult.count()) { + case 0: message = tr("No result found"); break; + case 1: message = tr("1 result found"); break; + default: message = tr("%1 results found").arg(searchResult.count()); break; } - else { - sensitivity = Qt::CaseInsensitive; - } - QList searchResult = searchGroup->search(m_searchUi->searchEdit->text(), sensitivity); - + if (searchGroup != m_db->rootGroup()) + message += tr(" in \"%1\". Search all groups...").arg(searchGroup->name()); + else if (m_lastGroup != m_db->rootGroup()) + message += tr(". Search in \"%1\"...").arg(m_lastGroup->name()); + else + message += tr("."); + m_searchUi->searchResults->setText(message); m_entryView->setEntryList(searchResult); } @@ -639,6 +672,9 @@ void DatabaseWidget::startSearchTimer() void DatabaseWidget::startSearch() { + if (!isInSearchMode()) + return; + if (!m_searchTimer->isActive()) { m_searchTimer->stop(); } @@ -667,14 +703,14 @@ bool DatabaseWidget::canDeleteCurrentGoup() return !isRootGroup && !isRecycleBin; } -bool DatabaseWidget::isInSearchMode() +bool DatabaseWidget::isInSearchMode() const { return m_entryView->inEntryListMode(); } -QString DatabaseWidget::searchText() +QString DatabaseWidget::searchText() const { - return m_entryView->inEntryListMode() ? m_searchUi->searchEdit->text() : QString(); + return m_entryView->inEntryListMode() ? m_searchText : QString(); } void DatabaseWidget::clearLastGroup(Group* group) diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index 92cb79734..0be097724 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -63,14 +63,19 @@ public: Database* database(); bool dbHasKey(); bool canDeleteCurrentGoup(); - bool isInSearchMode(); - QString searchText(); + bool isInSearchMode() const; + QString searchText() const; + bool caseSensitiveSearch() const; + bool isAllGroupsSearch() const; + bool canChooseSearchScope() const; + Group* currentGroup() const; int addWidget(QWidget* w); void setCurrentIndex(int index); void setCurrentWidget(QWidget* widget); DatabaseWidget::Mode currentMode(); void lock(); void updateFilename(const QString& filename); + void search(const QString & searchString, bool caseSensitive, bool allGroups); Q_SIGNALS: void closeRequest(); @@ -102,12 +107,15 @@ public Q_SLOTS: void switchToOpenDatabase(const QString &fileName, const CompositeKey &masterKey); void switchToImportKeepass1(const QString& fileName); void switchToView(bool accepted); - void toggleSearch(); - void showSearch(const QString & searchString = QString()); + void search(const QString & searchString); + void setCaseSensitiveSearch(bool caseSensitive); + void setAllGroupsSearch(bool allGroups); void emitGroupContextMenuRequested(const QPoint& pos); void emitEntryContextMenuRequested(const QPoint& pos); private Q_SLOTS: + void onLinkActivated(const QString& link); + void showSearch(const QString & searchString = QString()); void switchBackToEntryEdit(); void switchToHistoryView(Entry* entry); void switchToEntryEdit(Entry* entry); @@ -145,6 +153,9 @@ private: QTimer* m_searchTimer; QWidget* widgetBeforeLock; QString m_filename; + QString m_searchText; + bool m_searchAllGroups; + Qt::CaseSensitivity m_searchSensitivity; }; #endif // KEEPASSX_DATABASEWIDGET_H diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 657ecce4b..9dab8e048 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -37,6 +37,7 @@ #include "http/HttpSettings.h" #include "http/OptionDialog.h" #include "gui/SettingsWidget.h" +#include "gui/qocoa/qsearchfield.h" class HttpPlugin: public ISettingsPage { public: @@ -114,7 +115,11 @@ MainWindow::MainWindow() setShortcut(m_ui->actionDatabaseClose, QKeySequence::Close, Qt::CTRL + Qt::Key_W); m_ui->actionLockDatabases->setShortcut(Qt::CTRL + Qt::Key_L); setShortcut(m_ui->actionQuit, QKeySequence::Quit, Qt::CTRL + Qt::Key_Q); - setShortcut(m_ui->actionSearch, QKeySequence::Find, Qt::CTRL + Qt::Key_F); + //TODO: do not register shortcut on Q_OS_MAC, if this is done automatically?? + const QKeySequence seq = !QKeySequence::keyBindings(QKeySequence::Find).isEmpty() + ? QKeySequence::Find + : QKeySequence(Qt::CTRL + Qt::Key_F); + connect(new QShortcut(seq, this), SIGNAL(activated()), m_ui->searchField, SLOT(setFocus())); m_ui->actionEntryNew->setShortcut(Qt::CTRL + Qt::Key_N); m_ui->actionEntryEdit->setShortcut(Qt::CTRL + Qt::Key_E); m_ui->actionEntryDelete->setShortcut(Qt::CTRL + Qt::Key_D); @@ -152,8 +157,6 @@ MainWindow::MainWindow() m_ui->actionAbout->setIcon(filePath()->icon("actions", "help-about")); - m_ui->actionSearch->setIcon(filePath()->icon("actions", "system-search")); - m_actionMultiplexer.connect(SIGNAL(currentModeChanged(DatabaseWidget::Mode)), this, SLOT(setMenuActionState(DatabaseWidget::Mode))); m_actionMultiplexer.connect(SIGNAL(groupChanged()), @@ -225,8 +228,24 @@ MainWindow::MainWindow() connect(m_ui->actionAbout, SIGNAL(triggered()), SLOT(showAboutDialog())); - m_actionMultiplexer.connect(m_ui->actionSearch, SIGNAL(triggered()), - SLOT(toggleSearch())); + m_ui->searchField->setPlaceholderText(tr("Type to search")); + m_ui->searchField->setEnabled(false); + m_ui->toolBar->addWidget(m_ui->searchPanel); + m_actionMultiplexer.connect(m_ui->searchField, SIGNAL(textChanged(QString)), + SLOT(search(QString))); + QMenu* searchMenu = new QMenu(this); + searchMenu->addAction(m_ui->actionFindCaseSensitive); + searchMenu->addSeparator(); + searchMenu->addAction(m_ui->actionFindCurrentGroup); + searchMenu->addAction(m_ui->actionFindRootGroup); + m_ui->searchField->setMenu(searchMenu); + QActionGroup* group = new QActionGroup(this); + group->addAction(m_ui->actionFindCurrentGroup); + group->addAction(m_ui->actionFindRootGroup); + m_actionMultiplexer.connect(m_ui->actionFindCaseSensitive, SIGNAL(toggled(bool)), + SLOT(setCaseSensitiveSearch(bool))); + m_actionMultiplexer.connect(m_ui->actionFindRootGroup, SIGNAL(toggled(bool)), + SLOT(setAllGroupsSearch(bool))); m_ui->tabWidget->reopenLastDatabases(); } @@ -298,6 +317,26 @@ void MainWindow::openDatabase(const QString& fileName, const QString& pw, const m_ui->tabWidget->openDatabase(fileName, pw, keyFile); } +void MainWindow::updateSearchField(DatabaseWidget* dbWidget) +{ + bool enabled = dbWidget != NULL; + + m_ui->actionFindCaseSensitive->setChecked(enabled && dbWidget->caseSensitiveSearch()); + + m_ui->actionFindCurrentGroup->setEnabled(enabled && dbWidget->canChooseSearchScope()); + m_ui->actionFindRootGroup->setEnabled(enabled && dbWidget->canChooseSearchScope()); + if (enabled && dbWidget->isAllGroupsSearch()) + m_ui->actionFindRootGroup->setChecked(true); + else + m_ui->actionFindCurrentGroup->setChecked(true); + + m_ui->searchField->setEnabled(enabled); + if (enabled && dbWidget->isInSearchMode()) + m_ui->searchField->setText(dbWidget->searchText()); + else + m_ui->searchField->clear(); +} + void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) { bool inDatabaseTabWidget = (m_ui->stackedWidget->currentIndex() == 0); @@ -329,9 +368,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) m_ui->actionGroupNew->setEnabled(groupSelected); m_ui->actionGroupEdit->setEnabled(groupSelected); m_ui->actionGroupDelete->setEnabled(groupSelected && dbWidget->canDeleteCurrentGoup()); - m_ui->actionSearch->setEnabled(true); - // TODO: get checked state from db widget - m_ui->actionSearch->setChecked(inSearch); + updateSearchField(dbWidget); m_ui->actionChangeMasterKey->setEnabled(true); m_ui->actionChangeDatabaseSettings->setEnabled(true); m_ui->actionDatabaseSave->setEnabled(true); @@ -349,8 +386,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) } m_ui->menuEntryCopyAttribute->setEnabled(false); - m_ui->actionSearch->setEnabled(false); - m_ui->actionSearch->setChecked(false); + updateSearchField(); m_ui->actionChangeMasterKey->setEnabled(false); m_ui->actionChangeDatabaseSettings->setEnabled(false); m_ui->actionDatabaseSave->setEnabled(false); @@ -371,8 +407,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) } m_ui->menuEntryCopyAttribute->setEnabled(false); - m_ui->actionSearch->setEnabled(false); - m_ui->actionSearch->setChecked(false); + updateSearchField(); m_ui->actionChangeMasterKey->setEnabled(false); m_ui->actionChangeDatabaseSettings->setEnabled(false); m_ui->actionDatabaseSave->setEnabled(false); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 52472a429..04e600992 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -64,6 +64,7 @@ private Q_SLOTS: void setToolbarIconSize28(); private: + void updateSearchField(DatabaseWidget* dbWidget = NULL); static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0); static const QString BaseWindowTitle; diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index ec05f82ee..8f04f118a 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -55,6 +55,34 @@ + + + + + 0 + 0 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + @@ -173,7 +201,6 @@ - @@ -299,17 +326,6 @@ Clone entry - - - true - - - false - - - Find - - false @@ -379,6 +395,30 @@ 2&8x28 + + + true + + + Case Sensitive + + + + + true + + + Current Group + + + + + true + + + Root Group + + @@ -399,6 +439,12 @@
gui/WelcomeWidget.h
1
+ + QSearchField + QWidget +
gui/qocoa/qsearchfield.h
+ 1 +
diff --git a/src/gui/SearchWidget.ui b/src/gui/SearchWidget.ui index d6205768a..b8be91f32 100644 --- a/src/gui/SearchWidget.ui +++ b/src/gui/SearchWidget.ui @@ -7,17 +7,14 @@ 0 0 630 - 87 + 34 0 - - - - + @@ -27,72 +24,12 @@ - - - Find: - - + - - - - - 0 - - - - - Case sensitive - - - - - - - Current group - - - false - - - - - - - Root group - - - true - - - - - - - Qt::Horizontal - - - - 255 - 1 - - - - - - - - - - LineEdit - QLineEdit -
gui/LineEdit.h
-
-
diff --git a/src/gui/qocoa/CMakeLists.txt b/src/gui/qocoa/CMakeLists.txt new file mode 100644 index 000000000..7ea00cc65 --- /dev/null +++ b/src/gui/qocoa/CMakeLists.txt @@ -0,0 +1,50 @@ +project(Qocoa) +cmake_minimum_required(VERSION 2.8) + +#find_package(Qt4 COMPONENTS QtMain QtCore QtGui REQUIRED) +#include(UseQt4) + +set(SOURCES + #main.cpp + #gallery.cpp +) + +set(HEADERS + #gallery.h + qsearchfield.h + qbutton.h + qprogressindicatorspinning.h +) + +qt4_wrap_cpp(MOC_SOURCES ${HEADERS}) + +if(APPLE) + list(APPEND SOURCES + qsearchfield_mac.mm + qbutton_mac.mm + qprogressindicatorspinning_mac.mm + ) +else() + list(APPEND SOURCES + qsearchfield_nonmac.cpp + qbutton_nonmac.cpp + qprogressindicatorspinning_nonmac.cpp + ) + set(RESOURCES + qsearchfield_nonmac.qrc + qprogressindicatorspinning_nonmac.qrc + ) + qt4_add_resources(RESOURCES_SOURCES ${RESOURCES}) +endif() + +#add_executable(Qocoa +# WIN32 MACOSX_BUNDLE +# ${SOURCES} ${MOC_SOURCES} ${RESOURCES_SOURCES} +#) +#target_link_libraries(Qocoa ${QT_LIBRARIES}) + +add_library (Qocoa STATIC ${SOURCES} ${MOC_SOURCES} ${HEADERS} ${RESOURCES_SOURCES}) + +if(APPLE) + set_target_properties(Qocoa PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit") +endif() diff --git a/src/gui/qocoa/LICENSE.txt b/src/gui/qocoa/LICENSE.txt new file mode 100644 index 000000000..910eb6d20 --- /dev/null +++ b/src/gui/qocoa/LICENSE.txt @@ -0,0 +1,19 @@ +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/gui/qocoa/Qocoa.pro b/src/gui/qocoa/Qocoa.pro new file mode 100644 index 000000000..8b325d192 --- /dev/null +++ b/src/gui/qocoa/Qocoa.pro @@ -0,0 +1,17 @@ +SOURCES += main.cpp\ + gallery.cpp \ + +HEADERS += gallery.h \ + qocoa_mac.h \ + qsearchfield.h \ + qbutton.h \ + qprogressindicatorspinning.h \ + +mac { + OBJECTIVE_SOURCES += qsearchfield_mac.mm qbutton_mac.mm qprogressindicatorspinning_mac.mm + LIBS += -framework Foundation -framework Appkit + QMAKE_CFLAGS += -mmacosx-version-min=10.6 +} else { + SOURCES += qsearchfield_nonmac.cpp qbutton_nonmac.cpp qprogressindicatorspinning_nonmac.cpp + RESOURCES += qsearchfield_nonmac.qrc qprogressindicatorspinning_nonmac.qrc +} diff --git a/src/gui/qocoa/README.md b/src/gui/qocoa/README.md new file mode 100644 index 000000000..5f981893e --- /dev/null +++ b/src/gui/qocoa/README.md @@ -0,0 +1,36 @@ +# Qocoa +Qocoa is a collection of Qt wrappers for OSX's Cocoa widgets. + +## Features +- basic fallback to sensible Qt types on non-OSX platforms +- shared class headers which expose no implementation details +- typical Qt signal/slot-based API +- trivial to import into projects (class header/implementation, [single shared global header](https://github.com/mikemcquaid/Qocoa/blob/master/qocoa_mac.h)) + +## Building +``` +git clone git://github.com/mikemcquaid/Qocoa.git +cd Qocoa +qmake # or cmake . +make +``` + +## Status +Qocoa classes are currently provided for NSButton, a spinning NSProgressIndicator and NSSearchField. There is a [TODO list](https://github.com/mikemcquaid/Qocoa/blob/master/TODO.md) for classes I hope to implement. + +## Usage +For each class you want to use copy the [`qocoa_mac.h`](https://github.com/mikemcquaid/Qocoa/blob/master/qocoa_mac.h), `$CLASS.h`, `$CLASS_mac.*` and `$CLASS_nonmac.*` files into your source tree and add them to your buildsystem. Examples are provided for [CMake](https://github.com/mikemcquaid/Qocoa/blob/master/CMakeLists.txt) and [QMake](https://github.com/mikemcquaid/Qocoa/blob/master/Qocoa.pro). + +## Contact +[Mike McQuaid](mailto:mike@mikemcquaid.com) + +## License +Qocoa is licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License). +The full license text is available in [LICENSE.txt](https://github.com/mikemcquaid/Qocoa/blob/master/LICENSE.txt). + +Magnifier and EditClear icons taken from [QtCreator](http://qt-project.org/), licensed under [LGPL](http://www.gnu.org/copyleft/lesser.html). + +Other icons are taken from the [Oxygen Project](http://www.oxygen-icons.org/) and are licensed under the [Creative Commons Attribution-ShareAlike 3.0 License](http://creativecommons.org/licenses/by-sa/3.0/). + +## Gallery +![Qocoa Gallery](https://github.com/mikemcquaid/Qocoa/raw/master/gallery.png) diff --git a/src/gui/qocoa/TODO.md b/src/gui/qocoa/TODO.md new file mode 100644 index 000000000..45972bafa --- /dev/null +++ b/src/gui/qocoa/TODO.md @@ -0,0 +1,13 @@ +Widgets I hope to implement (or at least investigate): + +- NSTokenField +- NSSegmentedControl +- NSLevelIndicator +- NSPathControl +- NSSlider (Circular) +- NSSplitView +- NSTextFinder +- NSOutlineView in an NSScrollView (Source List) +- NSDrawer +- PDFView +- WebView diff --git a/src/gui/qocoa/gallery.cpp b/src/gui/qocoa/gallery.cpp new file mode 100644 index 000000000..210821ebd --- /dev/null +++ b/src/gui/qocoa/gallery.cpp @@ -0,0 +1,75 @@ +#include "gallery.h" + +#include + +#include "qsearchfield.h" +#include "qbutton.h" +#include "qprogressindicatorspinning.h" + +Gallery::Gallery(QWidget *parent) : QWidget(parent) +{ + setWindowTitle("Qocoa Gallery"); + QVBoxLayout *layout = new QVBoxLayout(this); + + QSearchField *searchField = new QSearchField(this); + layout->addWidget(searchField); + + QSearchField *searchFieldPlaceholder = new QSearchField(this); + searchFieldPlaceholder->setPlaceholderText("Placeholder text"); + layout->addWidget(searchFieldPlaceholder); + + QButton *roundedButton = new QButton(this, QButton::Rounded); + roundedButton->setText("Button"); + layout->addWidget(roundedButton); + + QButton *regularSquareButton = new QButton(this, QButton::RegularSquare); + regularSquareButton->setText("Button"); + layout->addWidget(regularSquareButton); + + QButton *disclosureButton = new QButton(this, QButton::Disclosure); + layout->addWidget(disclosureButton); + + QButton *shadowlessSquareButton = new QButton(this, QButton::ShadowlessSquare); + shadowlessSquareButton->setText("Button"); + layout->addWidget(shadowlessSquareButton); + + QButton *circularButton = new QButton(this, QButton::Circular); + layout->addWidget(circularButton); + + QButton *textureSquareButton = new QButton(this, QButton::TexturedSquare); + textureSquareButton->setText("Textured Button"); + layout->addWidget(textureSquareButton); + + QButton *helpButton = new QButton(this, QButton::HelpButton); + layout->addWidget(helpButton); + + QButton *smallSquareButton = new QButton(this, QButton::SmallSquare); + smallSquareButton->setText("Gradient Button"); + layout->addWidget(smallSquareButton); + + QButton *texturedRoundedButton = new QButton(this, QButton::TexturedRounded); + texturedRoundedButton->setText("Round Textured"); + layout->addWidget(texturedRoundedButton); + + QButton *roundedRectangleButton = new QButton(this, QButton::RoundRect); + roundedRectangleButton->setText("Rounded Rect Button"); + layout->addWidget(roundedRectangleButton); + + QButton *recessedButton = new QButton(this, QButton::Recessed); + recessedButton->setText("Recessed Button"); + layout->addWidget(recessedButton); + + QButton *roundedDisclosureButton = new QButton(this, QButton::RoundedDisclosure); + layout->addWidget(roundedDisclosureButton); + +#ifdef __MAC_10_7 + QButton *inlineButton = new QButton(this, QButton::Inline); + inlineButton->setText("Inline Button"); + layout->addWidget(inlineButton); +#endif + + + QProgressIndicatorSpinning *progressIndicatorSpinning = new QProgressIndicatorSpinning(this); + progressIndicatorSpinning->animate(); + layout->addWidget(progressIndicatorSpinning); +} diff --git a/src/gui/qocoa/gallery.h b/src/gui/qocoa/gallery.h new file mode 100644 index 000000000..1e83bad94 --- /dev/null +++ b/src/gui/qocoa/gallery.h @@ -0,0 +1,14 @@ +#ifndef GALLERY_H +#define GALLERY_H + +#include + +class Gallery : public QWidget +{ + Q_OBJECT + +public: + explicit Gallery(QWidget *parent = 0); +}; + +#endif // WIDGET_H diff --git a/src/gui/qocoa/gallery.png b/src/gui/qocoa/gallery.png new file mode 100644 index 0000000000000000000000000000000000000000..7a2736ff572491af1fefbbface2742caceabd6e3 GIT binary patch literal 42195 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 z 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 N002ovPDHLkV1hfpIk5l$ literal 0 HcmV?d00001 diff --git a/src/gui/qocoa/main.cpp b/src/gui/qocoa/main.cpp new file mode 100644 index 000000000..33e7eb8d7 --- /dev/null +++ b/src/gui/qocoa/main.cpp @@ -0,0 +1,12 @@ +#include +#include "gallery.h" + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + Gallery gallery; + gallery.show(); + + return application.exec(); +} diff --git a/src/gui/qocoa/qbutton.h b/src/gui/qocoa/qbutton.h new file mode 100644 index 000000000..8b8b7a74f --- /dev/null +++ b/src/gui/qocoa/qbutton.h @@ -0,0 +1,49 @@ +#ifndef QBUTTON_H +#define QBUTTON_H + +#include +#include + +class QButtonPrivate; +class QButton : public QWidget +{ + Q_OBJECT +public: + // Matches NSBezelStyle + enum BezelStyle { + Rounded = 1, + RegularSquare = 2, + Disclosure = 5, + ShadowlessSquare = 6, + Circular = 7, + TexturedSquare = 8, + HelpButton = 9, + SmallSquare = 10, + TexturedRounded = 11, + RoundRect = 12, + Recessed = 13, + RoundedDisclosure = 14, +#ifdef __MAC_10_7 + Inline = 15 +#endif + }; + + explicit QButton(QWidget *parent, BezelStyle bezelStyle = Rounded); + +public Q_SLOTS: + void setText(const QString &text); + void setImage(const QPixmap &image); + void setChecked(bool checked); + +public: + void setCheckable(bool checkable); + bool isChecked(); + +Q_SIGNALS: + void clicked(bool checked = false); + +private: + friend class QButtonPrivate; + QPointer pimpl; +}; +#endif // QBUTTON_H diff --git a/src/gui/qocoa/qbutton_mac.mm b/src/gui/qocoa/qbutton_mac.mm new file mode 100644 index 000000000..15490e453 --- /dev/null +++ b/src/gui/qocoa/qbutton_mac.mm @@ -0,0 +1,229 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qbutton.h" + +#include "qocoa_mac.h" + +#import "Foundation/NSAutoreleasePool.h" +#import "AppKit/NSButton.h" +#import "AppKit/NSFont.h" + +class QButtonPrivate : public QObject +{ +public: + QButtonPrivate(QButton *qButton, NSButton *nsButton, QButton::BezelStyle bezelStyle) + : QObject(qButton), qButton(qButton), nsButton(nsButton) + { + switch(bezelStyle) { + case QButton::Disclosure: + case QButton::Circular: +#ifdef __MAC_10_7 + case QButton::Inline: +#endif + case QButton::RoundedDisclosure: + case QButton::HelpButton: + [nsButton setTitle:@""]; + default: + break; + } + + NSFont* font = 0; + switch(bezelStyle) { + case QButton::RoundRect: + font = [NSFont fontWithName:@"Lucida Grande" size:12]; + break; + + case QButton::Recessed: + font = [NSFont fontWithName:@"Lucida Grande Bold" size:12]; + break; + +#ifdef __MAC_10_7 + case QButton::Inline: + font = [NSFont boldSystemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]; + break; +#endif + + default: + font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]; + break; + } + [nsButton setFont:font]; + + switch(bezelStyle) { + case QButton::Rounded: + qButton->setMinimumWidth(40); + qButton->setFixedHeight(24); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; + case QButton::RegularSquare: + case QButton::TexturedSquare: + qButton->setMinimumSize(14, 23); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::ShadowlessSquare: + qButton->setMinimumSize(5, 25); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::SmallSquare: + qButton->setMinimumSize(4, 21); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::TexturedRounded: + qButton->setMinimumSize(10, 22); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::RoundRect: + case QButton::Recessed: + qButton->setMinimumWidth(16); + qButton->setFixedHeight(18); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; + case QButton::Disclosure: + qButton->setMinimumWidth(13); + qButton->setFixedHeight(13); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; + case QButton::Circular: + qButton->setMinimumSize(16, 16); + qButton->setMaximumHeight(40); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::HelpButton: + case QButton::RoundedDisclosure: + qButton->setMinimumWidth(22); + qButton->setFixedHeight(22); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; +#ifdef __MAC_10_7 + case QButton::Inline: + qButton->setMinimumWidth(10); + qButton->setFixedHeight(16); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; +#endif + } + + switch(bezelStyle) { + case QButton::Recessed: + [nsButton setButtonType:NSPushOnPushOffButton]; + case QButton::Disclosure: + [nsButton setButtonType:NSOnOffButton]; + default: + [nsButton setButtonType:NSMomentaryPushInButton]; + } + + [nsButton setBezelStyle:bezelStyle]; + } + + void clicked() + { + emit qButton->clicked(qButton->isChecked()); + } + + ~QButtonPrivate() { + [[nsButton target] release]; + [nsButton setTarget:nil]; + } + + QButton *qButton; + NSButton *nsButton; +}; + +@interface QButtonTarget : NSObject +{ +@public + QPointer pimpl; +} +-(void)clicked; +@end + +@implementation QButtonTarget +-(void)clicked { + Q_ASSERT(pimpl); + if (pimpl) + pimpl->clicked(); +} +@end + +QButton::QButton(QWidget *parent, BezelStyle bezelStyle) : QWidget(parent) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSButton *button = [[NSButton alloc] init]; + pimpl = new QButtonPrivate(this, button, bezelStyle); + + QButtonTarget *target = [[QButtonTarget alloc] init]; + target->pimpl = pimpl; + [button setTarget:target]; + + [button setAction:@selector(clicked)]; + + setupLayout(button, this); + + [button release]; + + [pool drain]; +} + +void QButton::setText(const QString &text) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [pimpl->nsButton setTitle:fromQString(text)]; + [pool drain]; +} + +void QButton::setImage(const QPixmap &image) +{ + Q_ASSERT(pimpl); + if (pimpl) + [pimpl->nsButton setImage:fromQPixmap(image)]; +} + +void QButton::setChecked(bool checked) +{ + Q_ASSERT(pimpl); + if (pimpl) + [pimpl->nsButton setState:checked]; +} + +void QButton::setCheckable(bool checkable) +{ + const NSInteger cellMask = checkable ? NSChangeBackgroundCellMask : NSNoCellMask; + + Q_ASSERT(pimpl); + if (pimpl) + [[pimpl->nsButton cell] setShowsStateBy:cellMask]; +} + +bool QButton::isChecked() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return false; + + return [pimpl->nsButton state]; +} diff --git a/src/gui/qocoa/qbutton_nonmac.cpp b/src/gui/qocoa/qbutton_nonmac.cpp new file mode 100644 index 000000000..c7fafe6e4 --- /dev/null +++ b/src/gui/qocoa/qbutton_nonmac.cpp @@ -0,0 +1,89 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qbutton.h" + +#include +#include +#include +#include + +class QButtonPrivate : public QObject +{ +public: + QButtonPrivate(QButton *button, QAbstractButton *abstractButton) + : QObject(button), abstractButton(abstractButton) {} + QPointer abstractButton; +}; + +QButton::QButton(QWidget *parent, BezelStyle) : QWidget(parent) +{ + QAbstractButton *button = 0; + if (qobject_cast(parent)) + button = new QToolButton(this); + else + button = new QPushButton(this); + connect(button, SIGNAL(clicked()), + this, SIGNAL(clicked())); + pimpl = new QButtonPrivate(this, button); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->addWidget(button); +} + +void QButton::setText(const QString &text) +{ + Q_ASSERT(pimpl); + if (pimpl) + pimpl->abstractButton->setText(text); +} + +void QButton::setImage(const QPixmap &image) +{ + Q_ASSERT(pimpl); + if (pimpl) + pimpl->abstractButton->setIcon(image); +} + +void QButton::setChecked(bool checked) +{ + Q_ASSERT(pimpl); + if (pimpl) + pimpl->abstractButton->setChecked(checked); +} + +void QButton::setCheckable(bool checkable) +{ + Q_ASSERT(pimpl); + if (pimpl) + pimpl->abstractButton->setCheckable(checkable); +} + +bool QButton::isChecked() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return false; + + return pimpl->abstractButton->isChecked(); +} diff --git a/src/gui/qocoa/qocoa_mac.h b/src/gui/qocoa/qocoa_mac.h new file mode 100644 index 000000000..ced431173 --- /dev/null +++ b/src/gui/qocoa/qocoa_mac.h @@ -0,0 +1,54 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include +#include +#include + +static inline NSString* fromQString(const QString &string) +{ + const QByteArray utf8 = string.toUtf8(); + const char* cString = utf8.constData(); + return [[NSString alloc] initWithUTF8String:cString]; +} + +static inline QString toQString(NSString *string) +{ + if (!string) + return QString(); + return QString::fromUtf8([string UTF8String]); +} + +static inline NSImage* fromQPixmap(const QPixmap &pixmap) +{ + CGImageRef cgImage = pixmap.toMacCGImageRef(); + return [[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize]; +} + +static inline void setupLayout(void *cocoaView, QWidget *parent) +{ + parent->setAttribute(Qt::WA_NativeWindow); + QVBoxLayout *layout = new QVBoxLayout(parent); + layout->setMargin(0); + layout->addWidget(new QMacCocoaViewContainer(cocoaView, parent)); +} diff --git a/src/gui/qocoa/qprogressindicatorspinning.h b/src/gui/qocoa/qprogressindicatorspinning.h new file mode 100644 index 000000000..d78a4868d --- /dev/null +++ b/src/gui/qocoa/qprogressindicatorspinning.h @@ -0,0 +1,29 @@ +#ifndef QPROGRESSINDICATORSPINNING_H +#define QPROGRESSINDICATORSPINNING_H + +#include +#include + +class QProgressIndicatorSpinningPrivate; +class QProgressIndicatorSpinning : public QWidget +{ + Q_OBJECT +public: + // Matches NSProgressIndicatorThickness + enum Thickness { + Default = 14, + Small = 10, + Large = 18, + Aqua = 12 + }; + + explicit QProgressIndicatorSpinning(QWidget *parent, + Thickness thickness = Default); +public Q_SLOTS: + void animate(bool animate = true); +private: + friend class QProgressIndicatorSpinningPrivate; + QPointer pimpl; +}; + +#endif // QPROGRESSINDICATORSPINNING_H diff --git a/src/gui/qocoa/qprogressindicatorspinning_mac.mm b/src/gui/qocoa/qprogressindicatorspinning_mac.mm new file mode 100644 index 000000000..c67c7c567 --- /dev/null +++ b/src/gui/qocoa/qprogressindicatorspinning_mac.mm @@ -0,0 +1,70 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qprogressindicatorspinning.h" + +#include "qocoa_mac.h" + +#import "Foundation/NSAutoreleasePool.h" +#import "AppKit/NSProgressIndicator.h" + +class QProgressIndicatorSpinningPrivate : public QObject +{ +public: + QProgressIndicatorSpinningPrivate(QProgressIndicatorSpinning *qProgressIndicatorSpinning, + NSProgressIndicator *nsProgressIndicator) + : QObject(qProgressIndicatorSpinning), nsProgressIndicator(nsProgressIndicator) {} + + NSProgressIndicator *nsProgressIndicator; +}; + +QProgressIndicatorSpinning::QProgressIndicatorSpinning(QWidget *parent, + Thickness thickness) + : QWidget(parent) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSProgressIndicator *progress = [[NSProgressIndicator alloc] init]; + [progress setStyle:NSProgressIndicatorSpinningStyle]; + + pimpl = new QProgressIndicatorSpinningPrivate(this, progress); + + setupLayout(progress, this); + + setFixedSize(thickness, thickness); + + [progress release]; + + [pool drain]; +} + +void QProgressIndicatorSpinning::animate(bool animate) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + if (animate) + [pimpl->nsProgressIndicator startAnimation:nil]; + else + [pimpl->nsProgressIndicator stopAnimation:nil]; +} diff --git a/src/gui/qocoa/qprogressindicatorspinning_nonmac.cpp b/src/gui/qocoa/qprogressindicatorspinning_nonmac.cpp new file mode 100644 index 000000000..fae777830 --- /dev/null +++ b/src/gui/qocoa/qprogressindicatorspinning_nonmac.cpp @@ -0,0 +1,86 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qprogressindicatorspinning.h" + +#include +#include +#include + +class QProgressIndicatorSpinningPrivate : public QObject +{ +public: + QProgressIndicatorSpinningPrivate(QProgressIndicatorSpinning *qProgressIndicatorSpinning, + QMovie *movie) + : QObject(qProgressIndicatorSpinning), movie(movie) {} + + QPointer movie; +}; + +struct QProgressIndicatorSpinningResources +{ +#ifndef Q_OS_MAC + QProgressIndicatorSpinningResources() { + Q_INIT_RESOURCE(qprogressindicatorspinning_nonmac); + } + ~QProgressIndicatorSpinningResources() { + Q_CLEANUP_RESOURCE(qprogressindicatorspinning_nonmac); + } +#endif +}; + +QProgressIndicatorSpinning::QProgressIndicatorSpinning(QWidget *parent, + Thickness thickness) + : QWidget(parent) +{ + static QProgressIndicatorSpinningResources resources; + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + + QSize size(thickness, thickness); + QMovie *movie = new QMovie(this); + movie->setFileName(":/Qocoa/qprogressindicatorspinning_nonmac.gif"); + movie->setScaledSize(size); + // Roughly match OSX speed. + movie->setSpeed(200); + pimpl = new QProgressIndicatorSpinningPrivate(this, movie); + + QLabel *label = new QLabel(this); + label->setMovie(movie); + + layout->addWidget(label); + setFixedSize(size); +} + + +void QProgressIndicatorSpinning::animate(bool animate) +{ + Q_ASSERT(pimpl && pimpl->movie); + if (!(pimpl && pimpl->movie)) + return; + + if (animate) + pimpl->movie->start(); + else + pimpl->movie->stop(); +} diff --git a/src/gui/qocoa/qprogressindicatorspinning_nonmac.gif b/src/gui/qocoa/qprogressindicatorspinning_nonmac.gif new file mode 100644 index 0000000000000000000000000000000000000000..3288d1035d70bb86517e2c233f1a904e41f06b29 GIT binary patch literal 3208 zcmc(iX;4#H9>pJdFE7h`I{IF)0|5<6L}(j=N}5%L009EB2nYfyF)E0PvIqo$u!IC; z4PgyY5|S9AEh38G)(9eq4TbH7_UHg@yWrlIJ$6smIADL7s^P;_O;ykRc9soXl`UC*LwQJXkii*0rx|*7rI2=x7WaRkx_~XZqFJ8R3c=2Kg zf@aSAv8+BJ8+^hyay>(QR@t*blbKzsf0}bscEqRc5Hd3o(-N5RyW=zWB*zQw6Zh>* z2CROCDAbu#D`)S|J_o(lL9Yn3l*+8RdiRD_>iNz$#_IAzCna&Wl5 zSF_(rRCDD!wi#i8oAm&jYtn2_@VB%2-H*G%bN#|(6R6N?wM)3u`PiGzwuX7qmTgyF zpE)h0kuoxQ9?=kW7Y!=R@DmhU9)vwT*EZWzJ zrt+=2tqFts72yIp?|gvdLhs8Hfku^Z(){gmN%Y=K#P|%fkvgUj~HfIp3CuXqCtYGtJ#me+n+-LmP( z*XNuk%!aH8bIE@_Bj46>M*dSro|7<6vZ7WUHh5YQzN$>IJFqCb|CT!wj~R2C2%=q{ zpt8rzY$aw?W?=Ustv{jo?Ow@ZRkLe<)NItY>Cyhle*wR59dTdF6(@{5^ zAQBOB*hNtc3bkY-8{Cm$nFS@elbTtSqrt7MB{h_4y+~`!mVa}?c&N>&?P}GqdMuhQ z&@TD5Czd((DcG_Su~dKKV)Pj$-qi1WHM8_vc^O4?^!oY|tmK~i!{fjd&@_1E(T~r7 z_REZy&hMT^ySJB3W7l$4YhR`M(J7S5S~+4Q&3HPa)z%zPpisOp$^ zTEe99ig2$5_qFr!$;7A6CJ}PJmRhli>w?LC}Y`#HLGy6 zMU4EhL~dKCN5Ut;U2jd*83ShBNiu zcJB0l9>1Modc?-oM<R4?}3g}UJ%@K);kriq>)e*rh%hdqM)5Q)*+O8 zXm;SEbs@koiYS!9YXIclSg+5m_s~yrW#kKMdiRszg(gCP5HPmP7L)vCf8@fxUh6qY z@Z#TmkjzAZX{rwE+q|K~F2v5{_@vt%>yT_a#fF03SFt{0RXvDAiaY~K9CgS1O>frXgAjBCS}mEd4mIWZ$=ovd5| zR?GRdU}d6+Q`+JRW)|=v7$)XNkn3yE`!nAiSCvOB1jKT zG<1aK3s<0b0m==egTD#8i(Of=1pGDTOCho0XpIOMQ&P87cVKY1W=C6kIg z9cH=@a&zbm2+`|{(_?YC9fdm?1TY~-pwlBn?>=(~1pDKbco6jloP;0-cqRiwV1A_S zEyV0Dj8Pwy!nekzaN>{)7rgZ&_QLxK{~1yRe865^yx>}+a!ECd>#MMwddow z@CU{l+Rt$xuXuf}?ga{3IAr?Raql^c@a%sI0U5m}HvJ5O1#I%_MMPt#BH>OqUZ{-k zt>4Xzz=%jT*FVW(uYkWyx}9Gw$HdN*qU?Bit#ji(Wi7p-u|_8?h^%szIS^s^fNM}b zgGy>|=cbEufpguY5_6w~&ZLv=Bo06UF9EYIY;Er-1VK)SyF&!|J{axiE1z^(hXwVq zsFS=K-#zC}CcOs^8W{KAt+kK)jYDgDYbCXv{{rwsgqtIU3<910$CJi)s?? z_t8k{>7*0~4l~LLF7$WXT5OSq5QCTbP_l!SN|{R}3D&eWA8~0ltWh1IL+ZBX4rRSt zWF6Om3WDMu4xK^1(BF`2cL}rUCzhHAB`@j5&R-yk_l*t;mPGY|u2^o|myvcOdrg0W z%=lX;f^Vkqfp?u7*4qQq%A3Mpf!xspWBSKS@O%r*TSM}?dl(@*%{0Jm_8;(h{R__M Bt + + qprogressindicatorspinning_nonmac.gif + + diff --git a/src/gui/qocoa/qsearchfield.h b/src/gui/qocoa/qsearchfield.h new file mode 100644 index 000000000..1583b4627 --- /dev/null +++ b/src/gui/qocoa/qsearchfield.h @@ -0,0 +1,48 @@ +#ifndef QSEARCHFIELD_H +#define QSEARCHFIELD_H + +#include +#include +#include + +class QSearchFieldPrivate; +class QSearchField : public QWidget +{ + Q_OBJECT + + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true); + Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText); + +public: + explicit QSearchField(QWidget *parent); + + QString text() const; + QString placeholderText() const; + void setFocus(Qt::FocusReason); + void setMenu(QMenu *menu); + +public Q_SLOTS: + void setText(const QString &text); + void setPlaceholderText(const QString &text); + void clear(); + void selectAll(); + void setFocus(); + +Q_SIGNALS: + void textChanged(const QString &text); + void editingFinished(); + void returnPressed(); + +private Q_SLOTS: + void popupMenu(); + +protected: + void changeEvent(QEvent*); + void resizeEvent(QResizeEvent*); + +private: + friend class QSearchFieldPrivate; + QPointer pimpl; +}; + +#endif // QSEARCHFIELD_H diff --git a/src/gui/qocoa/qsearchfield_mac.mm b/src/gui/qocoa/qsearchfield_mac.mm new file mode 100644 index 000000000..7b43ecc75 --- /dev/null +++ b/src/gui/qocoa/qsearchfield_mac.mm @@ -0,0 +1,257 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qsearchfield.h" + +#include "qocoa_mac.h" + +#import "Foundation/NSAutoreleasePool.h" +#import "Foundation/NSNotification.h" +#import "AppKit/NSSearchField.h" + +#include +#include + +#define KEYCODE_A 0 +#define KEYCODE_X 7 +#define KEYCODE_C 8 +#define KEYCODE_V 9 + +class QSearchFieldPrivate : public QObject +{ +public: + QSearchFieldPrivate(QSearchField *qSearchField, NSSearchField *nsSearchField) + : QObject(qSearchField), qSearchField(qSearchField), nsSearchField(nsSearchField) {} + + void textDidChange(const QString &text) + { + if (qSearchField) + emit qSearchField->textChanged(text); + } + + void textDidEndEditing() + { + if (qSearchField) + emit qSearchField->editingFinished(); + } + + void returnPressed() + { + if (qSearchField) + emit qSearchField->returnPressed(); + } + + QPointer qSearchField; + NSSearchField *nsSearchField; +}; + +@interface QSearchFieldDelegate : NSObject +{ +@public + QPointer pimpl; +} +-(void)controlTextDidChange:(NSNotification*)notification; +-(void)controlTextDidEndEditing:(NSNotification*)notification; +@end + +@implementation QSearchFieldDelegate +-(void)controlTextDidChange:(NSNotification*)notification { + Q_ASSERT(pimpl); + if (pimpl) + pimpl->textDidChange(toQString([[notification object] stringValue])); +} + +-(void)controlTextDidEndEditing:(NSNotification*)notification { + Q_UNUSED(notification); + // No Q_ASSERT here as it is called on destruction. + if (pimpl) + pimpl->textDidEndEditing(); + + if ([[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement) + pimpl->returnPressed(); +} +@end + +@interface QocoaSearchField : NSSearchField +-(BOOL)performKeyEquivalent:(NSEvent*)event; +@end + +@implementation QocoaSearchField +-(BOOL)performKeyEquivalent:(NSEvent*)event { + if ([event type] == NSKeyDown && [event modifierFlags] & NSCommandKeyMask) + { + const unsigned short keyCode = [event keyCode]; + if (keyCode == KEYCODE_A) + { + [self performSelector:@selector(selectText:)]; + return YES; + } + else if (keyCode == KEYCODE_C) + { + QClipboard* clipboard = QApplication::clipboard(); + clipboard->setText(toQString([self stringValue])); + return YES; + } + else if (keyCode == KEYCODE_V) + { + QClipboard* clipboard = QApplication::clipboard(); + [self setStringValue:fromQString(clipboard->text())]; + return YES; + } + else if (keyCode == KEYCODE_X) + { + QClipboard* clipboard = QApplication::clipboard(); + clipboard->setText(toQString([self stringValue])); + [self setStringValue:@""]; + return YES; + } + } + + return NO; +} +@end + +QSearchField::QSearchField(QWidget *parent) : QWidget(parent) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSSearchField *search = [[QocoaSearchField alloc] init]; + + QSearchFieldDelegate *delegate = [[QSearchFieldDelegate alloc] init]; + pimpl = delegate->pimpl = new QSearchFieldPrivate(this, search); + [search setDelegate:delegate]; + + setupLayout(search, this); + + setFixedHeight(24); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + + [search release]; + + [pool drain]; +} + +void QSearchField::setMenu(QMenu *menu) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + NSMenu *nsMenu = menu->macMenu(); + [[pimpl->nsSearchField cell] setSearchMenuTemplate:nsMenu]; +} + +void QSearchField::popupMenu() +{ +} + +void QSearchField::setText(const QString &text) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [pimpl->nsSearchField setStringValue:fromQString(text)]; + [pool drain]; +} + +void QSearchField::setPlaceholderText(const QString &text) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[pimpl->nsSearchField cell] setPlaceholderString:fromQString(text)]; + [pool drain]; +} + +void QSearchField::clear() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + [pimpl->nsSearchField setStringValue:@""]; + emit textChanged(QString()); +} + +void QSearchField::selectAll() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + [pimpl->nsSearchField performSelector:@selector(selectText:)]; +} + +QString QSearchField::text() const +{ + Q_ASSERT(pimpl); + if (!pimpl) + return QString(); + + return toQString([pimpl->nsSearchField stringValue]); +} + +QString QSearchField::placeholderText() const +{ + Q_ASSERT(pimpl); + if (!pimpl) + return QString(); + + return toQString([[pimpl->nsSearchField cell] placeholderString]); +} + +void QSearchField::setFocus(Qt::FocusReason) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + if ([pimpl->nsSearchField acceptsFirstResponder]) + [[pimpl->nsSearchField window] makeFirstResponder: pimpl->nsSearchField]; +} + +void QSearchField::setFocus() +{ + setFocus(Qt::OtherFocusReason); +} + +void QSearchField::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::EnabledChange) { + Q_ASSERT(pimpl); + if (!pimpl) + return; + + const bool enabled = isEnabled(); + [pimpl->nsSearchField setEnabled: enabled] + } + QWidget::changeEvent(event); +} + +void QSearchField::resizeEvent(QResizeEvent *resizeEvent) +{ + QWidget::resizeEvent(resizeEvent); +} diff --git a/src/gui/qocoa/qsearchfield_nonmac.cpp b/src/gui/qocoa/qsearchfield_nonmac.cpp new file mode 100644 index 000000000..5244bd605 --- /dev/null +++ b/src/gui/qocoa/qsearchfield_nonmac.cpp @@ -0,0 +1,270 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qsearchfield.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +class QSearchFieldPrivate : public QObject +{ +public: + QSearchFieldPrivate(QSearchField *searchField, QLineEdit *lineEdit, QToolButton *clearButton, QToolButton *searchButton) + : QObject(searchField), lineEdit(lineEdit), clearButton(clearButton), searchButton(searchButton) {} + + int lineEditFrameWidth() const { + return lineEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + } + + int clearButtonPaddedWidth() const { + return clearButton->width() + lineEditFrameWidth() * 2; + } + + int clearButtonPaddedHeight() const { + return clearButton->height() + lineEditFrameWidth() * 2; + } + + int searchButtonPaddedWidth() const { + return searchButton->width() + lineEditFrameWidth() * 2; + } + + int searchButtonPaddedHeight() const { + return searchButton->height() + lineEditFrameWidth() * 2; + } + + QPointer lineEdit; + QPointer clearButton; + QPointer searchButton; + QPointer searchMenu; +}; + +struct QSearchFieldResources +{ +#ifndef Q_OS_MAC + QSearchFieldResources() { + Q_INIT_RESOURCE(qsearchfield_nonmac); + } + ~QSearchFieldResources() { + Q_CLEANUP_RESOURCE(qsearchfield_nonmac); + } +#endif +}; + +QSearchField::QSearchField(QWidget *parent) : QWidget(parent) +{ + static QSearchFieldResources resources; + + QLineEdit *lineEdit = new QLineEdit(this); + connect(lineEdit, SIGNAL(textChanged(QString)), + this, SIGNAL(textChanged(QString))); + connect(lineEdit, SIGNAL(editingFinished()), + this, SIGNAL(editingFinished())); + connect(lineEdit, SIGNAL(returnPressed()), + this, SIGNAL(returnPressed())); + connect(lineEdit, SIGNAL(textChanged(QString)), + this, SLOT(setText(QString))); + + int iconsize = style()->pixelMetric(QStyle::PM_SmallIconSize); + QToolButton *clearButton = new QToolButton(this); + QIcon clearIcon = QIcon::fromTheme(QLatin1String("edit-clear"), + QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_clear.png"))); + clearButton->setIcon(clearIcon); + clearButton->setIconSize(QSize(iconsize, iconsize)); + clearButton->setFixedSize(QSize(iconsize, iconsize)); + clearButton->setStyleSheet("border: none;"); + clearButton->hide(); + connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); + + QToolButton *searchButton = new QToolButton(this); + QIcon searchIcon = QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier.png")); + searchButton->setIcon(searchIcon); + searchButton->setIconSize(QSize(iconsize, iconsize)); + searchButton->setFixedSize(QSize(iconsize, iconsize)); + searchButton->setStyleSheet("border: none;"); + searchButton->setPopupMode(QToolButton::InstantPopup); + searchButton->setEnabled(false); + connect(searchButton, SIGNAL(clicked()), this, SLOT(popupMenu())); + + pimpl = new QSearchFieldPrivate(this, lineEdit, clearButton, searchButton); + + lineEdit->setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; } ") + .arg(pimpl->searchButtonPaddedWidth()) + .arg(pimpl->clearButtonPaddedWidth())); + const int width = qMax(lineEdit->minimumSizeHint().width(), pimpl->clearButtonPaddedWidth() + pimpl->searchButtonPaddedWidth()); + const int height = qMax(lineEdit->minimumSizeHint().height(), + qMax(pimpl->clearButtonPaddedHeight(), + pimpl->searchButtonPaddedHeight())); + lineEdit->setMinimumSize(width, height); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->addWidget(lineEdit); +} + +void QSearchField::setMenu(QMenu *menu) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + pimpl->searchMenu = menu; + + QIcon searchIcon = menu ? QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier_menu.png")) + : QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier.png")); + pimpl->searchButton->setIcon(searchIcon); + pimpl->searchButton->setEnabled(isEnabled() && menu); +} + +void QSearchField::popupMenu() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + if (pimpl->searchMenu) { + const QRect screenRect = qApp->desktop()->availableGeometry(pimpl->searchButton); + const QSize sizeHint = pimpl->searchMenu->sizeHint(); + const QRect rect = pimpl->searchButton->rect(); + const int x = pimpl->searchButton->isRightToLeft() + ? rect.right() - sizeHint.width() + : rect.left(); + const int y = pimpl->searchButton->mapToGlobal(QPoint(0, rect.bottom())).y() + sizeHint.height() <= screenRect.height() + ? rect.bottom() + : rect.top() - sizeHint.height(); + QPoint point = pimpl->searchButton->mapToGlobal(QPoint(x, y)); + point.rx() = qMax(screenRect.left(), qMin(point.x(), screenRect.right() - sizeHint.width())); + point.ry() += 1; + + pimpl->searchMenu->popup(point); + } +} + +void QSearchField::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::EnabledChange) { + Q_ASSERT(pimpl); + if (!pimpl) + return; + + const bool enabled = isEnabled(); + pimpl->searchButton->setEnabled(enabled && pimpl->searchMenu); + pimpl->lineEdit->setEnabled(enabled); + pimpl->clearButton->setEnabled(enabled); + } + QWidget::changeEvent(event); +} + +void QSearchField::setText(const QString &text) +{ + Q_ASSERT(pimpl && pimpl->clearButton && pimpl->lineEdit); + if (!(pimpl && pimpl->clearButton && pimpl->lineEdit)) + return; + + pimpl->clearButton->setVisible(!text.isEmpty()); + + if (text != this->text()) + pimpl->lineEdit->setText(text); +} + +void QSearchField::setPlaceholderText(const QString &text) +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return; + +#if QT_VERSION >= 0x040700 + pimpl->lineEdit->setPlaceholderText(text); +#endif +} + +void QSearchField::clear() +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return; + + pimpl->lineEdit->clear(); +} + +void QSearchField::selectAll() +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return; + + pimpl->lineEdit->selectAll(); +} + +QString QSearchField::text() const +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return QString(); + + return pimpl->lineEdit->text(); +} + +QString QSearchField::placeholderText() const { + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return QString(); + +#if QT_VERSION >= 0x040700 + return pimpl->lineEdit->placeholderText(); +#else + return QString(); +#endif +} + +void QSearchField::setFocus(Qt::FocusReason reason) +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (pimpl && pimpl->lineEdit) + pimpl->lineEdit->setFocus(reason); +} + +void QSearchField::setFocus() +{ + setFocus(Qt::OtherFocusReason); +} + +void QSearchField::resizeEvent(QResizeEvent *resizeEvent) +{ + Q_ASSERT(pimpl && pimpl->clearButton && pimpl->lineEdit); + if (!(pimpl && pimpl->clearButton && pimpl->lineEdit)) + return; + + QWidget::resizeEvent(resizeEvent); + const int x = width() - pimpl->clearButtonPaddedWidth(); + const int y = (height() - pimpl->clearButton->height())/2; + pimpl->clearButton->move(x, y); + + pimpl->searchButton->move(pimpl->lineEditFrameWidth() * 2, + (height() - pimpl->searchButton->height())/2); +} diff --git a/src/gui/qocoa/qsearchfield_nonmac.qrc b/src/gui/qocoa/qsearchfield_nonmac.qrc new file mode 100644 index 000000000..68b570d5b --- /dev/null +++ b/src/gui/qocoa/qsearchfield_nonmac.qrc @@ -0,0 +1,7 @@ + + + qsearchfield_nonmac_clear.png + qsearchfield_nonmac_magnifier_menu.png + qsearchfield_nonmac_magnifier.png + + diff --git a/src/gui/qocoa/qsearchfield_nonmac_clear.png b/src/gui/qocoa/qsearchfield_nonmac_clear.png new file mode 100644 index 0000000000000000000000000000000000000000..ec52c41bc2fbba0bcc2b30a96267d73be240dc13 GIT binary patch literal 736 zcmV<60w4W}P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igQ1 z5H}Q?5;Tqg00Ll1L_t(I%dL~KP8(SihQGOU@A%G)jYu&WzH`%nmEB~k%_)!0|LN%b|AGHm z-oG2$+uQ3>$}P|HIzosRKvh)}=iL2bvG{s(bCdlipx5iYRZ9ISrA(Dl2qAa@V2ok0 zSUehIK3`v7e|gpTKZ>>1@8dXrQ?J*FLsS(ar>K(E(Z z55w?XqtSR%uh-e%-)A2ykxBqT|~bUI}?98#7gQc7NC zTL2Qk_kDyA_`XjZ$7rp8@_S`v1>g5^&Mjw`8#w1C&N-~L#Bt1EFre9NlIJ;jp3`hL z84L!*ag4PV=N!(t$r4ai)xEVAV+`GHmo!ZokH_@;efs@ACb6=jZ2N{*lDHySr?2bF=h)KM8`M z@ne)p>7~2_ZUoUdwwqvaRgBnVYW{7Z(}7v%UkVf%q@6 SqLyO-0000Dhf?ouWA>yZ`s+BBx=){u((%TpyhhRjALHT2ckQc&d4&) z-n7Bm;H*K-pZ^kn7Mb{N&z!|jAk+T(YZimV`=g(K?qPLwkZ5DrlIwl{`;^p7iT5tI zx9yD4vv!!4s&o3#!*q*2WiQPZ0c-805^anh>)KKyITY=T68yi}@UJypmicbY)??rQ z+E&g>&)Y8jdRLLvT!xHUZR=iZbUpf-AmV!aZ=JhW=j&ZIa{LT^$CW)N?OE3SxI+54 wpr&f&y!tagmpaE@|F2cIdey48=Y>A7G=&6K*=^zp26~sl)78&qol`;+0Ic(R)c^nh literal 0 HcmV?d00001 diff --git a/src/gui/qocoa/qsearchfield_nonmac_magnifier_menu.png b/src/gui/qocoa/qsearchfield_nonmac_magnifier_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..0e652c945e4287939e4787cd02c891c50238c64a GIT binary patch literal 439 zcmV;o0Z9IdP)e+J+88IQ+ODwU{IDgdn4Yj(RG-ELPU zlgZB|=kxg)CX$;ex$!IiEsZ@$z hOGL13`%eoV{s($5(uCrFlfnQ1002ovPDHLkV1gsuzk~n) literal 0 HcmV?d00001 From d2ab008aa00cd419646d8e89c777a0551ee5b8d7 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Tue, 30 Apr 2013 17:31:08 +0200 Subject: [PATCH 20/51] Auto-reload settings. --- src/core/Config.cpp | 1 + src/gui/DatabaseTabWidget.cpp | 35 +++++++++++++++----------------- src/gui/DatabaseTabWidget.h | 6 +++--- src/gui/SettingsWidget.cpp | 2 ++ src/gui/SettingsWidgetGeneral.ui | 34 +++++++++++++++++++++++++++---- 5 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/core/Config.cpp b/src/core/Config.cpp index 08fbfdfb2..188758866 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -93,6 +93,7 @@ void Config::init(const QString& fileName) m_defaults.insert("AutoSaveAfterEveryChange", false); m_defaults.insert("AutoSaveOnExit", false); m_defaults.insert("ShowToolbar", true); + m_defaults.insert("ReloadBehavior", 0 /*always ask*/); m_defaults.insert("security/clearclipboard", true); m_defaults.insert("security/clearclipboardtimeout", 10); } diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index a520fd46d..6af2fe545 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -49,8 +49,7 @@ const int DatabaseTabWidget::LastDatabasesCount = 5; DatabaseTabWidget::DatabaseTabWidget(QWidget* parent) : QTabWidget(parent), - m_fileWatcher(new QFileSystemWatcher(this)), - m_reloadBehavior(ReloadUnmodified) //TODO: setting + m_fileWatcher(new QFileSystemWatcher(this)) { DragTabBar* tabBar = new DragTabBar(this); tabBar->setDrawBase(false); @@ -98,7 +97,7 @@ void DatabaseTabWidget::openDatabase() } void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw, - const QString& keyFile, const CompositeKey& key) + const QString& keyFile, const CompositeKey& key, int index) { QFileInfo fileInfo(fileName); QString canonicalFilePath = fileInfo.canonicalFilePath(); @@ -144,7 +143,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw, dbStruct.fileName = fileInfo.fileName(); dbStruct.lastModified = fileInfo.lastModified(); - insertDatabase(db, dbStruct); + insertDatabase(db, dbStruct, index); m_fileWatcher->addPath(dbStruct.filePath); updateRecentDatabases(dbStruct.filePath); @@ -228,14 +227,14 @@ void DatabaseTabWidget::checkReloadDatabases() if (mode == DatabaseWidget::None || mode == DatabaseWidget::LockedMode || !db->hasKey()) continue; - if ( (m_reloadBehavior == AlwaysAsk) - || (m_reloadBehavior == ReloadUnmodified && mode == DatabaseWidget::EditMode) - || (m_reloadBehavior == ReloadUnmodified && dbStruct.modified)) { - //TODO: display banner instead, to let user now file has changed and choose to Reload, Overwrite, and SaveAs - // --> less obstrubsive (esp. if multiple DB are open), cleaner UI - if (QMessageBox::warning(this, fi.exists() ? tr("Database file changed") : tr("Database file removed"), - tr("Do you want to discard your changes and reload?"), - QMessageBox::Yes|QMessageBox::No) == QMessageBox::No) + ReloadBehavior reloadBehavior = ReloadBehavior(config()->get("ReloadBehavior").toInt()); + if ( (reloadBehavior == AlwaysAsk) + || (reloadBehavior == ReloadUnmodified && mode == DatabaseWidget::EditMode) + || (reloadBehavior == ReloadUnmodified && dbStruct.modified)) { + int res = QMessageBox::warning(this, fi.exists() ? tr("Database file changed") : tr("Database file removed"), + tr("Do you want to discard your changes and reload?"), + QMessageBox::Yes|QMessageBox::No); + if (res == QMessageBox::No) continue; } @@ -257,12 +256,13 @@ void DatabaseTabWidget::checkReloadDatabases() //Reload updated db CompositeKey key = db->key(); + int tabPos = databaseIndex(db); closeDatabase(db); - openDatabase(filePath, QString(), QString(), key); + openDatabase(filePath, QString(), QString(), key, tabPos); //Restore current group/entry dbStruct = indexDatabaseManagerStruct(count() - 1); - if (dbStruct.dbWidget) { + if (dbStruct.dbWidget && dbStruct.dbWidget->currentMode() == DatabaseWidget::ViewMode) { Database * db = dbStruct.dbWidget->database(); if (!currentGroup.isNull()) if (Group* group = db->resolveGroup(currentGroup)) @@ -273,8 +273,6 @@ void DatabaseTabWidget::checkReloadDatabases() if (Entry* entry = db->resolveEntry(currentEntry)) dbStruct.dbWidget->entryView()->setCurrentEntry(entry); } - - //TODO: keep tab order... } else { //Ignore/cancel all edits dbStruct.dbWidget->switchToView(false); @@ -604,14 +602,13 @@ Database* DatabaseTabWidget::databaseFromDatabaseWidget(DatabaseWidget* dbWidget return Q_NULLPTR; } -void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct) +void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct, int index) { m_dbList.insert(db, dbStruct); - addTab(dbStruct.dbWidget, ""); + index = insertTab(index, dbStruct.dbWidget, ""); toggleTabbar(); updateTabName(db); - int index = databaseIndex(db); setCurrentIndex(index); connectDatabase(db); connect(dbStruct.dbWidget, SIGNAL(closeRequest()), SLOT(closeDatabaseFromSender())); diff --git a/src/gui/DatabaseTabWidget.h b/src/gui/DatabaseTabWidget.h index 6b473eb7f..c9ca003be 100644 --- a/src/gui/DatabaseTabWidget.h +++ b/src/gui/DatabaseTabWidget.h @@ -55,7 +55,8 @@ public: explicit DatabaseTabWidget(QWidget* parent = Q_NULLPTR); ~DatabaseTabWidget(); void openDatabase(const QString& fileName, const QString& pw = QString(), - const QString& keyFile = QString(), const CompositeKey& key = CompositeKey()); + const QString& keyFile = QString(), const CompositeKey& key = CompositeKey(), + int index = -1); DatabaseWidget* currentDatabaseWidget(); bool hasLockableDatabases(); @@ -105,7 +106,7 @@ private: Database* indexDatabase(int index); DatabaseManagerStruct indexDatabaseManagerStruct(int index); Database* databaseFromDatabaseWidget(DatabaseWidget* dbWidget); - void insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct); + void insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct, int index = -1); void updateRecentDatabases(const QString& filename); void connectDatabase(Database* newDb, Database* oldDb = Q_NULLPTR); void expectFileChange(const DatabaseManagerStruct& dbStruct); @@ -116,7 +117,6 @@ private: QSet m_changedFiles; QSet m_expectedFileChanges; QFileSystemWatcher* m_fileWatcher; - ReloadBehavior m_reloadBehavior; }; #endif // KEEPASSX_DATABASETABWIDGET_H diff --git a/src/gui/SettingsWidget.cpp b/src/gui/SettingsWidget.cpp index 17ab6082f..3afb5af19 100644 --- a/src/gui/SettingsWidget.cpp +++ b/src/gui/SettingsWidget.cpp @@ -90,6 +90,7 @@ void SettingsWidget::loadSettings() m_generalUi->modifiedExpandedChangedCheckBox->setChecked(config()->get("ModifiedOnExpandedStateChanges").toBool()); m_generalUi->autoSaveAfterEveryChangeCheckBox->setChecked(config()->get("AutoSaveAfterEveryChange").toBool()); m_generalUi->autoSaveOnExitCheckBox->setChecked(config()->get("AutoSaveOnExit").toBool()); + m_generalUi->reloadBehavior->setCurrentIndex(config()->get("ReloadBehavior").toInt()); m_globalAutoTypeKey = static_cast(config()->get("GlobalAutoTypeKey").toInt()); m_globalAutoTypeModifiers = static_cast(config()->get("GlobalAutoTypeModifiers").toInt()); @@ -114,6 +115,7 @@ void SettingsWidget::saveSettings() config()->set("ModifiedOnExpandedStateChanges", m_generalUi->modifiedExpandedChangedCheckBox->isChecked()); config()->set("AutoSaveAfterEveryChange", m_generalUi->autoSaveAfterEveryChangeCheckBox->isChecked()); config()->set("AutoSaveOnExit", m_generalUi->autoSaveOnExitCheckBox->isChecked()); + config()->set("ReloadBehavior", m_generalUi->reloadBehavior->currentIndex()); config()->set("GlobalAutoTypeKey", m_generalUi->autoTypeShortcutWidget->key()); config()->set("GlobalAutoTypeModifiers", static_cast(m_generalUi->autoTypeShortcutWidget->modifiers())); config()->set("security/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked()); diff --git a/src/gui/SettingsWidgetGeneral.ui b/src/gui/SettingsWidgetGeneral.ui index a369cf1c2..c7b08bd35 100644 --- a/src/gui/SettingsWidgetGeneral.ui +++ b/src/gui/SettingsWidgetGeneral.ui @@ -6,8 +6,8 @@ 0 0 - 456 - 172 + 481 + 202 @@ -45,14 +45,14 @@ - + Global Auto-Type shortcut - + @@ -62,6 +62,32 @@ + + + + When database files are externally modified + + + + + + + + Always ask + + + + + Reload unmodified databases + + + + + Ignore modifications + + + + From a85ac0757629ba34604f44f71dab4d66df603ab0 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 1 May 2013 09:43:09 +0200 Subject: [PATCH 21/51] Qocoa compilation fix for MacOS. --- src/CMakeLists.txt | 3 +++ src/gui/qocoa/CMakeLists.txt | 6 +++--- src/gui/qocoa/qbutton_mac.mm | 2 +- src/gui/qocoa/qocoa_mac.h | 6 +++--- src/gui/qocoa/qsearchfield_mac.mm | 16 ++++++++-------- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b7ac25b2..b7a532b91 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -238,6 +238,9 @@ target_link_libraries(${PROGNAME} if(UNIX AND NOT APPLE) target_link_libraries(${PROGNAME} ${QT_QTDBUS_LIBRARY}) endif() +if(APPLE) + set_target_properties(${PROGNAME} PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit") +endif() set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON) diff --git a/src/gui/qocoa/CMakeLists.txt b/src/gui/qocoa/CMakeLists.txt index 7ea00cc65..c1dcdce35 100644 --- a/src/gui/qocoa/CMakeLists.txt +++ b/src/gui/qocoa/CMakeLists.txt @@ -45,6 +45,6 @@ endif() add_library (Qocoa STATIC ${SOURCES} ${MOC_SOURCES} ${HEADERS} ${RESOURCES_SOURCES}) -if(APPLE) - set_target_properties(Qocoa PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit") -endif() +#if(APPLE) +# set_target_properties(Qocoa PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit") +#endif() diff --git a/src/gui/qocoa/qbutton_mac.mm b/src/gui/qocoa/qbutton_mac.mm index 15490e453..dccc771ac 100644 --- a/src/gui/qocoa/qbutton_mac.mm +++ b/src/gui/qocoa/qbutton_mac.mm @@ -137,7 +137,7 @@ public: void clicked() { - emit qButton->clicked(qButton->isChecked()); + Q_EMIT qButton->clicked(qButton->isChecked()); } ~QButtonPrivate() { diff --git a/src/gui/qocoa/qocoa_mac.h b/src/gui/qocoa/qocoa_mac.h index ced431173..74bee4418 100644 --- a/src/gui/qocoa/qocoa_mac.h +++ b/src/gui/qocoa/qocoa_mac.h @@ -21,9 +21,9 @@ THE SOFTWARE. */ #include -#include -#include -#include +#include +#include +#include static inline NSString* fromQString(const QString &string) { diff --git a/src/gui/qocoa/qsearchfield_mac.mm b/src/gui/qocoa/qsearchfield_mac.mm index 7b43ecc75..4c2db3944 100644 --- a/src/gui/qocoa/qsearchfield_mac.mm +++ b/src/gui/qocoa/qsearchfield_mac.mm @@ -28,8 +28,8 @@ THE SOFTWARE. #import "Foundation/NSNotification.h" #import "AppKit/NSSearchField.h" -#include -#include +#include +#include #define KEYCODE_A 0 #define KEYCODE_X 7 @@ -45,19 +45,19 @@ public: void textDidChange(const QString &text) { if (qSearchField) - emit qSearchField->textChanged(text); + Q_EMIT qSearchField->textChanged(text); } void textDidEndEditing() { if (qSearchField) - emit qSearchField->editingFinished(); + Q_EMIT qSearchField->editingFinished(); } void returnPressed() { if (qSearchField) - emit qSearchField->returnPressed(); + Q_EMIT qSearchField->returnPressed(); } QPointer qSearchField; @@ -193,7 +193,7 @@ void QSearchField::clear() return; [pimpl->nsSearchField setStringValue:@""]; - emit textChanged(QString()); + Q_EMIT textChanged(QString()); } void QSearchField::selectAll() @@ -246,9 +246,9 @@ void QSearchField::changeEvent(QEvent* event) return; const bool enabled = isEnabled(); - [pimpl->nsSearchField setEnabled: enabled] + [pimpl->nsSearchField setEnabled: enabled]; } - QWidget::changeEvent(event); + QWidget::changeEvent(event); } void QSearchField::resizeEvent(QResizeEvent *resizeEvent) From d8857bf42d23877321ff51d5987d116a05f5eef6 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 1 May 2013 12:08:20 +0200 Subject: [PATCH 22/51] Fix currentMode() while DB is not yet open. --- src/gui/DatabaseWidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index f368bf945..e14f93482 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -171,7 +171,8 @@ DatabaseWidget::Mode DatabaseWidget::currentMode() else if (currentWidget() == m_mainWidget) { return DatabaseWidget::ViewMode; } - else if (currentWidget() == m_unlockDatabaseWidget) { + else if (currentWidget() == m_unlockDatabaseWidget || + currentWidget() == m_databaseOpenWidget) { return DatabaseWidget::LockedMode; } else { From 8f33c5235bc260dddbc79114707c2badfdf9aa02 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 1 May 2013 11:12:53 +0200 Subject: [PATCH 23/51] Fix StringField copy. --- src/http/Protocol.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/http/Protocol.cpp b/src/http/Protocol.cpp index efe06299b..f7fb85dc3 100644 --- a/src/http/Protocol.cpp +++ b/src/http/Protocol.cpp @@ -33,7 +33,7 @@ static const char * const STR_SET_LOGIN = "set-login"; static const char * const STR_ASSOCIATE = "associate"; static const char * const STR_TEST_ASSOCIATE = "test-associate"; static const char * const STR_GENERATE_PASSWORD = "generate-password"; -static const char * const STR_VERSION = "1.6.0.0"; +static const char * const STR_VERSION = "1.7.0.0"; }/*namespace KeepassHttpProtocol*/ @@ -497,13 +497,13 @@ StringField::StringField(const QString &key, const QString &value): {} StringField::StringField(const StringField &other): - m_key(other.m_key), m_value(other.m_value) + QObject(NULL), m_key(other.m_key), m_value(other.m_value) {} StringField &StringField::operator =(const StringField &other) { - m_key = m_key; - m_value = m_value; + m_key = other.m_key; + m_value = other.m_value; return *this; } From 53b30e267c26aba4890c5bfafd97ce2ac6482571 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 1 May 2013 12:16:17 +0200 Subject: [PATCH 24/51] Fix entry partial matching rules. --- src/http/Service.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 95d9edae8..9cb52b9c9 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -167,7 +167,7 @@ bool Service::removeFirstDomain(QString & hostname) return !hostname.isEmpty(); } -QList Service::searchEntries(const QString &text) +QList Service::searchEntries(const QString& text) { QList entries; @@ -175,19 +175,19 @@ QList Service::searchEntries(const QString &text) //Search entries matching the hostname QString hostname = QUrl(text).host(); - if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) - if (Database * db = dbWidget->database()) - if (Group * rootGroup = db->rootGroup()) + if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database* db = dbWidget->database()) + if (Group* rootGroup = db->rootGroup()) do { - Q_FOREACH (Entry * entry, rootGroup->search(hostname, Qt::CaseInsensitive)) { + Q_FOREACH (Entry* entry, rootGroup->search(hostname, Qt::CaseInsensitive)) { QString title = entry->title(); QString url = entry->url(); //Filter to match hostname in Title and Url fields - if ( hostname.contains(title) - || hostname.contains(url) - || (matchUrlScheme(title) && hostname.contains(QUrl(title).host())) - || (matchUrlScheme(url) && hostname.contains(QUrl(url).host())) ) + if ( (!title.isEmpty() && hostname.contains(title)) + || (!url.isEmpty() && hostname.contains(url)) + || (matchUrlScheme(title) && hostname.endsWith(QUrl(title).host())) + || (matchUrlScheme(url) && hostname.endsWith(QUrl(url).host())) ) entries.append(entry); } } while(entries.isEmpty() && removeFirstDomain(hostname)); From db5654687104d8ccb30c286a6054814958dabf53 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 1 May 2013 12:17:12 +0200 Subject: [PATCH 25/51] Filter GetAllLogins entries, to return only entries with an URL. --- src/http/Server.cpp | 1 - src/http/Service.cpp | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/http/Server.cpp b/src/http/Server.cpp index 9104ba0b6..9725e56f3 100644 --- a/src/http/Server.cpp +++ b/src/http/Server.cpp @@ -179,7 +179,6 @@ void Server::getAllLogins(const Request &r, Response *protocolResp) if (!r.CheckVerifier(key)) return; -// parms.SearchString = @"^[A-Za-z0-9:/-]+\.[A-Za-z0-9:/-]+$"; // match anything looking like a domain or url protocolResp->setSuccess(); protocolResp->setId(r.id()); protocolResp->setVerifier(key); diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 9cb52b9c9..85551fa91 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -371,7 +371,8 @@ QList Service::searchAllEntries(const QString &id) if (Database * db = dbWidget->database()) if (Group * rootGroup = db->rootGroup()) Q_FOREACH (Entry * entry, rootGroup->entriesRecursive()) - result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), QString(), entry->uuid().toHex()); + if (!entry->url().isEmpty() || QUrl(entry->title()).isValid()) + result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), QString(), entry->uuid().toHex()); return result; } From be24872bba49e1d7c419b11d0df46845876711f7 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 1 May 2013 12:18:49 +0200 Subject: [PATCH 26/51] Notifications pseudo-code. --- src/http/Service.cpp | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 85551fa91..3f0b83050 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -89,12 +89,23 @@ bool Service::openDatabase() { if (!HttpSettings::unlockDatabase()) return false; - if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) - if (dbWidget->currentMode() == DatabaseWidget::LockedMode) { - //- show notification - //- open & focus main window - //- wait a few seconds for user to unlock (unlockedDatabase) + if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) { + switch(dbWidget->currentMode()) { + case DatabaseWidget::None: + case DatabaseWidget::LockedMode: + break; + + case DatabaseWidget::ViewMode: + case DatabaseWidget::EditMode: + return true; } + } + //if (HttpSettings::showNotification() + // && !ShowNotification(QString("%0: %1 is requesting access, click to allow or deny") + // .arg(id).arg(submitHost.isEmpty() ? host : submithost)); + // return false; + m_dbTabWidget->activateWindow(); + //Wait a bit for DB to be open... (w/ asynchronous reply?) return false; } @@ -127,6 +138,9 @@ QString Service::storeKey(const QString &key) { QString id; if (Entry* config = getConfigEntry(true)) { + + //ShowNotification("New key association requested") + do { bool ok; //Indicate who wants to associate, and request user to enter the 'name' of association key @@ -301,8 +315,13 @@ QList Service::findMatchingEntries(const QString& /* } //If unsure, ask user for confirmation + //if (!pwEntriesToConfirm.isEmpty() + // && HttpSettings::showNotification() + // && !ShowNotification(QString("%0: %1 is requesting access, click to allow or deny") + // .arg(id).arg(submitHost.isEmpty() ? host : submithost)); + // pwEntriesToConfirm.clear(); //timeout --> do not request confirmation + if (!pwEntriesToConfirm.isEmpty()) { - //TODO: balloon to grant access + timeout AccessControlDialog dlg; dlg.setUrl(url); @@ -351,6 +370,14 @@ QList Service::findMatchingEntries(const QString& /* qSort(pwEntries.begin(), pwEntries.end(), SortEntries(priorities, HttpSettings::sortByTitle() ? "Title" : "UserName")); } + //if (pwEntries.count() > 0) + //{ + // var names = (from e in resp.Entries select e.Name).Distinct(); + // var n = String.Join("\n ", names.ToArray()); + // if (HttpSettings::receiveCredentialNotification()) + // ShowNotification(QString("%0: %1 is receiving credentials for:\n%2").arg(Id).arg(host).arg(n))); + //} + //Fill the list QList result; result.reserve(pwEntries.count()); @@ -429,6 +456,7 @@ void Service::updateEntry(const QString &id, const QString &uuid, const QString if (Entry * entry = db->resolveEntry(Uuid::fromHex(uuid))) { QString u = entry->username(); if (u != login || entry->password() != password) { + //ShowNotification(QString("%0: You have an entry change prompt waiting, click to activate").arg(requestId)); if ( HttpSettings::alwaysAllowUpdate() || QMessageBox::warning(0, tr("KeyPassX/Http: Update Entry"), tr("Do you want to update the information in %1 - %2?").arg(QUrl(url).host()).arg(u), From 41be9e8178fad610fa9086557c8e50e71e8addd0 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 1 May 2013 13:55:43 +0200 Subject: [PATCH 27/51] Implement option to search all open databases. --- src/http/Service.cpp | 51 +++++++++++++++++++++++++++++--------------- src/http/Service.h | 1 + 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 3f0b83050..fad340d07 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -181,30 +181,47 @@ bool Service::removeFirstDomain(QString & hostname) return !hostname.isEmpty(); } -QList Service::searchEntries(const QString& text) +QList Service::searchEntries(Database* db, const QString& hostname) { QList entries; + if (Group* rootGroup = db->rootGroup()) + Q_FOREACH (Entry* entry, rootGroup->search(hostname, Qt::CaseInsensitive)) { + QString title = entry->title(); + QString url = entry->url(); - //TODO: setting to search all databases [e.g. as long as the 'current' db is authentified + //Filter to match hostname in Title and Url fields + if ( (!title.isEmpty() && hostname.contains(title)) + || (!url.isEmpty() && hostname.contains(url)) + || (matchUrlScheme(title) && hostname.endsWith(QUrl(title).host())) + || (matchUrlScheme(url) && hostname.endsWith(QUrl(url).host())) ) + entries.append(entry); + } + return entries; +} + +QList Service::searchEntries(const QString& text) +{ + //Get the list of databases to search + QList databases; + if (HttpSettings::searchInAllDatabases()) { + for (int i = 0; i < m_dbTabWidget->count(); i++) + if (DatabaseWidget* dbWidget = qobject_cast(m_dbTabWidget->widget(i))) + if (Database* db = dbWidget->database()) + databases << db; + } + else if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget()) { + if (Database* db = dbWidget->database()) + databases << db; + } //Search entries matching the hostname QString hostname = QUrl(text).host(); - if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget()) - if (Database* db = dbWidget->database()) - if (Group* rootGroup = db->rootGroup()) - do { - Q_FOREACH (Entry* entry, rootGroup->search(hostname, Qt::CaseInsensitive)) { - QString title = entry->title(); - QString url = entry->url(); + QList entries; + do { + Q_FOREACH (Database* db, databases) + entries << searchEntries(db, hostname); + } while(entries.isEmpty() && removeFirstDomain(hostname)); - //Filter to match hostname in Title and Url fields - if ( (!title.isEmpty() && hostname.contains(title)) - || (!url.isEmpty() && hostname.contains(url)) - || (matchUrlScheme(title) && hostname.endsWith(QUrl(title).host())) - || (matchUrlScheme(url) && hostname.endsWith(QUrl(url).host())) ) - entries.append(entry); - } - } while(entries.isEmpty() && removeFirstDomain(hostname)); return entries; } diff --git a/src/http/Service.h b/src/http/Service.h index a9b7bd0e1..04d1188fe 100644 --- a/src/http/Service.h +++ b/src/http/Service.h @@ -52,6 +52,7 @@ private: class SortEntries; int sortPriority(const Entry *entry, const QString &host, const QString &submitUrl, const QString &baseSubmitUrl) const; KeepassHttpProtocol::Entry prepareEntry(const Entry* entry); + QList searchEntries(Database* db, const QString& hostname); QList searchEntries(const QString& text); DatabaseTabWidget * const m_dbTabWidget; From d7a8a4302412441ee0fe61ed12015deed2d0a5ae Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 12:56:15 +0000 Subject: [PATCH 28/51] Temporary fixup for the password generator. --- src/http/Service.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index fad340d07..3342ef15b 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -489,10 +489,7 @@ void Service::updateEntry(const QString &id, const QString &uuid, const QString QString Service::generatePassword() { - PasswordGenerator * pwGenerator = passwordGenerator(); - return pwGenerator->generatePassword(HttpSettings::passwordLength(), - HttpSettings::passwordCharClasses(), - HttpSettings::passwordGeneratorFlags()); + return QString("nonrandompassword"); } void Service::removeSharedEncryptionKeys() From 304cebefe417e40808d7dbdc71abab1d22e8a90e Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 15:23:02 +0000 Subject: [PATCH 29/51] Removed qocoa so we can replace it with a subtree. --- src/gui/qocoa/CMakeLists.txt | 50 ---- src/gui/qocoa/LICENSE.txt | 19 -- src/gui/qocoa/Qocoa.pro | 17 -- src/gui/qocoa/README.md | 36 --- src/gui/qocoa/TODO.md | 13 - src/gui/qocoa/gallery.cpp | 75 ----- src/gui/qocoa/gallery.h | 14 - src/gui/qocoa/gallery.png | Bin 42195 -> 0 bytes src/gui/qocoa/main.cpp | 12 - src/gui/qocoa/qbutton.h | 49 ---- src/gui/qocoa/qbutton_mac.mm | 229 --------------- src/gui/qocoa/qbutton_nonmac.cpp | 89 ------ src/gui/qocoa/qocoa_mac.h | 54 ---- src/gui/qocoa/qprogressindicatorspinning.h | 29 -- .../qocoa/qprogressindicatorspinning_mac.mm | 70 ----- .../qprogressindicatorspinning_nonmac.cpp | 86 ------ .../qprogressindicatorspinning_nonmac.gif | Bin 3208 -> 0 bytes .../qprogressindicatorspinning_nonmac.qrc | 5 - src/gui/qocoa/qsearchfield.h | 48 ---- src/gui/qocoa/qsearchfield_mac.mm | 257 ----------------- src/gui/qocoa/qsearchfield_nonmac.cpp | 270 ------------------ src/gui/qocoa/qsearchfield_nonmac.qrc | 7 - src/gui/qocoa/qsearchfield_nonmac_clear.png | Bin 736 -> 0 bytes .../qocoa/qsearchfield_nonmac_magnifier.png | Bin 300 -> 0 bytes .../qsearchfield_nonmac_magnifier_menu.png | Bin 439 -> 0 bytes 25 files changed, 1429 deletions(-) delete mode 100644 src/gui/qocoa/CMakeLists.txt delete mode 100644 src/gui/qocoa/LICENSE.txt delete mode 100644 src/gui/qocoa/Qocoa.pro delete mode 100644 src/gui/qocoa/README.md delete mode 100644 src/gui/qocoa/TODO.md delete mode 100644 src/gui/qocoa/gallery.cpp delete mode 100644 src/gui/qocoa/gallery.h delete mode 100644 src/gui/qocoa/gallery.png delete mode 100644 src/gui/qocoa/main.cpp delete mode 100644 src/gui/qocoa/qbutton.h delete mode 100644 src/gui/qocoa/qbutton_mac.mm delete mode 100644 src/gui/qocoa/qbutton_nonmac.cpp delete mode 100644 src/gui/qocoa/qocoa_mac.h delete mode 100644 src/gui/qocoa/qprogressindicatorspinning.h delete mode 100644 src/gui/qocoa/qprogressindicatorspinning_mac.mm delete mode 100644 src/gui/qocoa/qprogressindicatorspinning_nonmac.cpp delete mode 100644 src/gui/qocoa/qprogressindicatorspinning_nonmac.gif delete mode 100644 src/gui/qocoa/qprogressindicatorspinning_nonmac.qrc delete mode 100644 src/gui/qocoa/qsearchfield.h delete mode 100644 src/gui/qocoa/qsearchfield_mac.mm delete mode 100644 src/gui/qocoa/qsearchfield_nonmac.cpp delete mode 100644 src/gui/qocoa/qsearchfield_nonmac.qrc delete mode 100644 src/gui/qocoa/qsearchfield_nonmac_clear.png delete mode 100644 src/gui/qocoa/qsearchfield_nonmac_magnifier.png delete mode 100644 src/gui/qocoa/qsearchfield_nonmac_magnifier_menu.png diff --git a/src/gui/qocoa/CMakeLists.txt b/src/gui/qocoa/CMakeLists.txt deleted file mode 100644 index c1dcdce35..000000000 --- a/src/gui/qocoa/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -project(Qocoa) -cmake_minimum_required(VERSION 2.8) - -#find_package(Qt4 COMPONENTS QtMain QtCore QtGui REQUIRED) -#include(UseQt4) - -set(SOURCES - #main.cpp - #gallery.cpp -) - -set(HEADERS - #gallery.h - qsearchfield.h - qbutton.h - qprogressindicatorspinning.h -) - -qt4_wrap_cpp(MOC_SOURCES ${HEADERS}) - -if(APPLE) - list(APPEND SOURCES - qsearchfield_mac.mm - qbutton_mac.mm - qprogressindicatorspinning_mac.mm - ) -else() - list(APPEND SOURCES - qsearchfield_nonmac.cpp - qbutton_nonmac.cpp - qprogressindicatorspinning_nonmac.cpp - ) - set(RESOURCES - qsearchfield_nonmac.qrc - qprogressindicatorspinning_nonmac.qrc - ) - qt4_add_resources(RESOURCES_SOURCES ${RESOURCES}) -endif() - -#add_executable(Qocoa -# WIN32 MACOSX_BUNDLE -# ${SOURCES} ${MOC_SOURCES} ${RESOURCES_SOURCES} -#) -#target_link_libraries(Qocoa ${QT_LIBRARIES}) - -add_library (Qocoa STATIC ${SOURCES} ${MOC_SOURCES} ${HEADERS} ${RESOURCES_SOURCES}) - -#if(APPLE) -# set_target_properties(Qocoa PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit") -#endif() diff --git a/src/gui/qocoa/LICENSE.txt b/src/gui/qocoa/LICENSE.txt deleted file mode 100644 index 910eb6d20..000000000 --- a/src/gui/qocoa/LICENSE.txt +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2011 by Mike McQuaid - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/gui/qocoa/Qocoa.pro b/src/gui/qocoa/Qocoa.pro deleted file mode 100644 index 8b325d192..000000000 --- a/src/gui/qocoa/Qocoa.pro +++ /dev/null @@ -1,17 +0,0 @@ -SOURCES += main.cpp\ - gallery.cpp \ - -HEADERS += gallery.h \ - qocoa_mac.h \ - qsearchfield.h \ - qbutton.h \ - qprogressindicatorspinning.h \ - -mac { - OBJECTIVE_SOURCES += qsearchfield_mac.mm qbutton_mac.mm qprogressindicatorspinning_mac.mm - LIBS += -framework Foundation -framework Appkit - QMAKE_CFLAGS += -mmacosx-version-min=10.6 -} else { - SOURCES += qsearchfield_nonmac.cpp qbutton_nonmac.cpp qprogressindicatorspinning_nonmac.cpp - RESOURCES += qsearchfield_nonmac.qrc qprogressindicatorspinning_nonmac.qrc -} diff --git a/src/gui/qocoa/README.md b/src/gui/qocoa/README.md deleted file mode 100644 index 5f981893e..000000000 --- a/src/gui/qocoa/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Qocoa -Qocoa is a collection of Qt wrappers for OSX's Cocoa widgets. - -## Features -- basic fallback to sensible Qt types on non-OSX platforms -- shared class headers which expose no implementation details -- typical Qt signal/slot-based API -- trivial to import into projects (class header/implementation, [single shared global header](https://github.com/mikemcquaid/Qocoa/blob/master/qocoa_mac.h)) - -## Building -``` -git clone git://github.com/mikemcquaid/Qocoa.git -cd Qocoa -qmake # or cmake . -make -``` - -## Status -Qocoa classes are currently provided for NSButton, a spinning NSProgressIndicator and NSSearchField. There is a [TODO list](https://github.com/mikemcquaid/Qocoa/blob/master/TODO.md) for classes I hope to implement. - -## Usage -For each class you want to use copy the [`qocoa_mac.h`](https://github.com/mikemcquaid/Qocoa/blob/master/qocoa_mac.h), `$CLASS.h`, `$CLASS_mac.*` and `$CLASS_nonmac.*` files into your source tree and add them to your buildsystem. Examples are provided for [CMake](https://github.com/mikemcquaid/Qocoa/blob/master/CMakeLists.txt) and [QMake](https://github.com/mikemcquaid/Qocoa/blob/master/Qocoa.pro). - -## Contact -[Mike McQuaid](mailto:mike@mikemcquaid.com) - -## License -Qocoa is licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License). -The full license text is available in [LICENSE.txt](https://github.com/mikemcquaid/Qocoa/blob/master/LICENSE.txt). - -Magnifier and EditClear icons taken from [QtCreator](http://qt-project.org/), licensed under [LGPL](http://www.gnu.org/copyleft/lesser.html). - -Other icons are taken from the [Oxygen Project](http://www.oxygen-icons.org/) and are licensed under the [Creative Commons Attribution-ShareAlike 3.0 License](http://creativecommons.org/licenses/by-sa/3.0/). - -## Gallery -![Qocoa Gallery](https://github.com/mikemcquaid/Qocoa/raw/master/gallery.png) diff --git a/src/gui/qocoa/TODO.md b/src/gui/qocoa/TODO.md deleted file mode 100644 index 45972bafa..000000000 --- a/src/gui/qocoa/TODO.md +++ /dev/null @@ -1,13 +0,0 @@ -Widgets I hope to implement (or at least investigate): - -- NSTokenField -- NSSegmentedControl -- NSLevelIndicator -- NSPathControl -- NSSlider (Circular) -- NSSplitView -- NSTextFinder -- NSOutlineView in an NSScrollView (Source List) -- NSDrawer -- PDFView -- WebView diff --git a/src/gui/qocoa/gallery.cpp b/src/gui/qocoa/gallery.cpp deleted file mode 100644 index 210821ebd..000000000 --- a/src/gui/qocoa/gallery.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "gallery.h" - -#include - -#include "qsearchfield.h" -#include "qbutton.h" -#include "qprogressindicatorspinning.h" - -Gallery::Gallery(QWidget *parent) : QWidget(parent) -{ - setWindowTitle("Qocoa Gallery"); - QVBoxLayout *layout = new QVBoxLayout(this); - - QSearchField *searchField = new QSearchField(this); - layout->addWidget(searchField); - - QSearchField *searchFieldPlaceholder = new QSearchField(this); - searchFieldPlaceholder->setPlaceholderText("Placeholder text"); - layout->addWidget(searchFieldPlaceholder); - - QButton *roundedButton = new QButton(this, QButton::Rounded); - roundedButton->setText("Button"); - layout->addWidget(roundedButton); - - QButton *regularSquareButton = new QButton(this, QButton::RegularSquare); - regularSquareButton->setText("Button"); - layout->addWidget(regularSquareButton); - - QButton *disclosureButton = new QButton(this, QButton::Disclosure); - layout->addWidget(disclosureButton); - - QButton *shadowlessSquareButton = new QButton(this, QButton::ShadowlessSquare); - shadowlessSquareButton->setText("Button"); - layout->addWidget(shadowlessSquareButton); - - QButton *circularButton = new QButton(this, QButton::Circular); - layout->addWidget(circularButton); - - QButton *textureSquareButton = new QButton(this, QButton::TexturedSquare); - textureSquareButton->setText("Textured Button"); - layout->addWidget(textureSquareButton); - - QButton *helpButton = new QButton(this, QButton::HelpButton); - layout->addWidget(helpButton); - - QButton *smallSquareButton = new QButton(this, QButton::SmallSquare); - smallSquareButton->setText("Gradient Button"); - layout->addWidget(smallSquareButton); - - QButton *texturedRoundedButton = new QButton(this, QButton::TexturedRounded); - texturedRoundedButton->setText("Round Textured"); - layout->addWidget(texturedRoundedButton); - - QButton *roundedRectangleButton = new QButton(this, QButton::RoundRect); - roundedRectangleButton->setText("Rounded Rect Button"); - layout->addWidget(roundedRectangleButton); - - QButton *recessedButton = new QButton(this, QButton::Recessed); - recessedButton->setText("Recessed Button"); - layout->addWidget(recessedButton); - - QButton *roundedDisclosureButton = new QButton(this, QButton::RoundedDisclosure); - layout->addWidget(roundedDisclosureButton); - -#ifdef __MAC_10_7 - QButton *inlineButton = new QButton(this, QButton::Inline); - inlineButton->setText("Inline Button"); - layout->addWidget(inlineButton); -#endif - - - QProgressIndicatorSpinning *progressIndicatorSpinning = new QProgressIndicatorSpinning(this); - progressIndicatorSpinning->animate(); - layout->addWidget(progressIndicatorSpinning); -} diff --git a/src/gui/qocoa/gallery.h b/src/gui/qocoa/gallery.h deleted file mode 100644 index 1e83bad94..000000000 --- a/src/gui/qocoa/gallery.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef GALLERY_H -#define GALLERY_H - -#include - -class Gallery : public QWidget -{ - Q_OBJECT - -public: - explicit Gallery(QWidget *parent = 0); -}; - -#endif // WIDGET_H diff --git a/src/gui/qocoa/gallery.png b/src/gui/qocoa/gallery.png deleted file mode 100644 index 7a2736ff572491af1fefbbface2742caceabd6e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 42195 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 z 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 N002ovPDHLkV1hfpIk5l$ diff --git a/src/gui/qocoa/main.cpp b/src/gui/qocoa/main.cpp deleted file mode 100644 index 33e7eb8d7..000000000 --- a/src/gui/qocoa/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "gallery.h" - -int main(int argc, char *argv[]) -{ - QApplication application(argc, argv); - - Gallery gallery; - gallery.show(); - - return application.exec(); -} diff --git a/src/gui/qocoa/qbutton.h b/src/gui/qocoa/qbutton.h deleted file mode 100644 index 8b8b7a74f..000000000 --- a/src/gui/qocoa/qbutton.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef QBUTTON_H -#define QBUTTON_H - -#include -#include - -class QButtonPrivate; -class QButton : public QWidget -{ - Q_OBJECT -public: - // Matches NSBezelStyle - enum BezelStyle { - Rounded = 1, - RegularSquare = 2, - Disclosure = 5, - ShadowlessSquare = 6, - Circular = 7, - TexturedSquare = 8, - HelpButton = 9, - SmallSquare = 10, - TexturedRounded = 11, - RoundRect = 12, - Recessed = 13, - RoundedDisclosure = 14, -#ifdef __MAC_10_7 - Inline = 15 -#endif - }; - - explicit QButton(QWidget *parent, BezelStyle bezelStyle = Rounded); - -public Q_SLOTS: - void setText(const QString &text); - void setImage(const QPixmap &image); - void setChecked(bool checked); - -public: - void setCheckable(bool checkable); - bool isChecked(); - -Q_SIGNALS: - void clicked(bool checked = false); - -private: - friend class QButtonPrivate; - QPointer pimpl; -}; -#endif // QBUTTON_H diff --git a/src/gui/qocoa/qbutton_mac.mm b/src/gui/qocoa/qbutton_mac.mm deleted file mode 100644 index dccc771ac..000000000 --- a/src/gui/qocoa/qbutton_mac.mm +++ /dev/null @@ -1,229 +0,0 @@ -/* -Copyright (C) 2011 by Mike McQuaid - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include "qbutton.h" - -#include "qocoa_mac.h" - -#import "Foundation/NSAutoreleasePool.h" -#import "AppKit/NSButton.h" -#import "AppKit/NSFont.h" - -class QButtonPrivate : public QObject -{ -public: - QButtonPrivate(QButton *qButton, NSButton *nsButton, QButton::BezelStyle bezelStyle) - : QObject(qButton), qButton(qButton), nsButton(nsButton) - { - switch(bezelStyle) { - case QButton::Disclosure: - case QButton::Circular: -#ifdef __MAC_10_7 - case QButton::Inline: -#endif - case QButton::RoundedDisclosure: - case QButton::HelpButton: - [nsButton setTitle:@""]; - default: - break; - } - - NSFont* font = 0; - switch(bezelStyle) { - case QButton::RoundRect: - font = [NSFont fontWithName:@"Lucida Grande" size:12]; - break; - - case QButton::Recessed: - font = [NSFont fontWithName:@"Lucida Grande Bold" size:12]; - break; - -#ifdef __MAC_10_7 - case QButton::Inline: - font = [NSFont boldSystemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]; - break; -#endif - - default: - font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]; - break; - } - [nsButton setFont:font]; - - switch(bezelStyle) { - case QButton::Rounded: - qButton->setMinimumWidth(40); - qButton->setFixedHeight(24); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - break; - case QButton::RegularSquare: - case QButton::TexturedSquare: - qButton->setMinimumSize(14, 23); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - break; - case QButton::ShadowlessSquare: - qButton->setMinimumSize(5, 25); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - break; - case QButton::SmallSquare: - qButton->setMinimumSize(4, 21); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - break; - case QButton::TexturedRounded: - qButton->setMinimumSize(10, 22); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - break; - case QButton::RoundRect: - case QButton::Recessed: - qButton->setMinimumWidth(16); - qButton->setFixedHeight(18); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - break; - case QButton::Disclosure: - qButton->setMinimumWidth(13); - qButton->setFixedHeight(13); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - break; - case QButton::Circular: - qButton->setMinimumSize(16, 16); - qButton->setMaximumHeight(40); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - break; - case QButton::HelpButton: - case QButton::RoundedDisclosure: - qButton->setMinimumWidth(22); - qButton->setFixedHeight(22); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - break; -#ifdef __MAC_10_7 - case QButton::Inline: - qButton->setMinimumWidth(10); - qButton->setFixedHeight(16); - qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - break; -#endif - } - - switch(bezelStyle) { - case QButton::Recessed: - [nsButton setButtonType:NSPushOnPushOffButton]; - case QButton::Disclosure: - [nsButton setButtonType:NSOnOffButton]; - default: - [nsButton setButtonType:NSMomentaryPushInButton]; - } - - [nsButton setBezelStyle:bezelStyle]; - } - - void clicked() - { - Q_EMIT qButton->clicked(qButton->isChecked()); - } - - ~QButtonPrivate() { - [[nsButton target] release]; - [nsButton setTarget:nil]; - } - - QButton *qButton; - NSButton *nsButton; -}; - -@interface QButtonTarget : NSObject -{ -@public - QPointer pimpl; -} --(void)clicked; -@end - -@implementation QButtonTarget --(void)clicked { - Q_ASSERT(pimpl); - if (pimpl) - pimpl->clicked(); -} -@end - -QButton::QButton(QWidget *parent, BezelStyle bezelStyle) : QWidget(parent) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - NSButton *button = [[NSButton alloc] init]; - pimpl = new QButtonPrivate(this, button, bezelStyle); - - QButtonTarget *target = [[QButtonTarget alloc] init]; - target->pimpl = pimpl; - [button setTarget:target]; - - [button setAction:@selector(clicked)]; - - setupLayout(button, this); - - [button release]; - - [pool drain]; -} - -void QButton::setText(const QString &text) -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [pimpl->nsButton setTitle:fromQString(text)]; - [pool drain]; -} - -void QButton::setImage(const QPixmap &image) -{ - Q_ASSERT(pimpl); - if (pimpl) - [pimpl->nsButton setImage:fromQPixmap(image)]; -} - -void QButton::setChecked(bool checked) -{ - Q_ASSERT(pimpl); - if (pimpl) - [pimpl->nsButton setState:checked]; -} - -void QButton::setCheckable(bool checkable) -{ - const NSInteger cellMask = checkable ? NSChangeBackgroundCellMask : NSNoCellMask; - - Q_ASSERT(pimpl); - if (pimpl) - [[pimpl->nsButton cell] setShowsStateBy:cellMask]; -} - -bool QButton::isChecked() -{ - Q_ASSERT(pimpl); - if (!pimpl) - return false; - - return [pimpl->nsButton state]; -} diff --git a/src/gui/qocoa/qbutton_nonmac.cpp b/src/gui/qocoa/qbutton_nonmac.cpp deleted file mode 100644 index c7fafe6e4..000000000 --- a/src/gui/qocoa/qbutton_nonmac.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright (C) 2011 by Mike McQuaid - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include "qbutton.h" - -#include -#include -#include -#include - -class QButtonPrivate : public QObject -{ -public: - QButtonPrivate(QButton *button, QAbstractButton *abstractButton) - : QObject(button), abstractButton(abstractButton) {} - QPointer abstractButton; -}; - -QButton::QButton(QWidget *parent, BezelStyle) : QWidget(parent) -{ - QAbstractButton *button = 0; - if (qobject_cast(parent)) - button = new QToolButton(this); - else - button = new QPushButton(this); - connect(button, SIGNAL(clicked()), - this, SIGNAL(clicked())); - pimpl = new QButtonPrivate(this, button); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->addWidget(button); -} - -void QButton::setText(const QString &text) -{ - Q_ASSERT(pimpl); - if (pimpl) - pimpl->abstractButton->setText(text); -} - -void QButton::setImage(const QPixmap &image) -{ - Q_ASSERT(pimpl); - if (pimpl) - pimpl->abstractButton->setIcon(image); -} - -void QButton::setChecked(bool checked) -{ - Q_ASSERT(pimpl); - if (pimpl) - pimpl->abstractButton->setChecked(checked); -} - -void QButton::setCheckable(bool checkable) -{ - Q_ASSERT(pimpl); - if (pimpl) - pimpl->abstractButton->setCheckable(checkable); -} - -bool QButton::isChecked() -{ - Q_ASSERT(pimpl); - if (!pimpl) - return false; - - return pimpl->abstractButton->isChecked(); -} diff --git a/src/gui/qocoa/qocoa_mac.h b/src/gui/qocoa/qocoa_mac.h deleted file mode 100644 index 74bee4418..000000000 --- a/src/gui/qocoa/qocoa_mac.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright (C) 2011 by Mike McQuaid - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include -#include -#include -#include - -static inline NSString* fromQString(const QString &string) -{ - const QByteArray utf8 = string.toUtf8(); - const char* cString = utf8.constData(); - return [[NSString alloc] initWithUTF8String:cString]; -} - -static inline QString toQString(NSString *string) -{ - if (!string) - return QString(); - return QString::fromUtf8([string UTF8String]); -} - -static inline NSImage* fromQPixmap(const QPixmap &pixmap) -{ - CGImageRef cgImage = pixmap.toMacCGImageRef(); - return [[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize]; -} - -static inline void setupLayout(void *cocoaView, QWidget *parent) -{ - parent->setAttribute(Qt::WA_NativeWindow); - QVBoxLayout *layout = new QVBoxLayout(parent); - layout->setMargin(0); - layout->addWidget(new QMacCocoaViewContainer(cocoaView, parent)); -} diff --git a/src/gui/qocoa/qprogressindicatorspinning.h b/src/gui/qocoa/qprogressindicatorspinning.h deleted file mode 100644 index d78a4868d..000000000 --- a/src/gui/qocoa/qprogressindicatorspinning.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QPROGRESSINDICATORSPINNING_H -#define QPROGRESSINDICATORSPINNING_H - -#include -#include - -class QProgressIndicatorSpinningPrivate; -class QProgressIndicatorSpinning : public QWidget -{ - Q_OBJECT -public: - // Matches NSProgressIndicatorThickness - enum Thickness { - Default = 14, - Small = 10, - Large = 18, - Aqua = 12 - }; - - explicit QProgressIndicatorSpinning(QWidget *parent, - Thickness thickness = Default); -public Q_SLOTS: - void animate(bool animate = true); -private: - friend class QProgressIndicatorSpinningPrivate; - QPointer pimpl; -}; - -#endif // QPROGRESSINDICATORSPINNING_H diff --git a/src/gui/qocoa/qprogressindicatorspinning_mac.mm b/src/gui/qocoa/qprogressindicatorspinning_mac.mm deleted file mode 100644 index c67c7c567..000000000 --- a/src/gui/qocoa/qprogressindicatorspinning_mac.mm +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright (C) 2011 by Mike McQuaid - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include "qprogressindicatorspinning.h" - -#include "qocoa_mac.h" - -#import "Foundation/NSAutoreleasePool.h" -#import "AppKit/NSProgressIndicator.h" - -class QProgressIndicatorSpinningPrivate : public QObject -{ -public: - QProgressIndicatorSpinningPrivate(QProgressIndicatorSpinning *qProgressIndicatorSpinning, - NSProgressIndicator *nsProgressIndicator) - : QObject(qProgressIndicatorSpinning), nsProgressIndicator(nsProgressIndicator) {} - - NSProgressIndicator *nsProgressIndicator; -}; - -QProgressIndicatorSpinning::QProgressIndicatorSpinning(QWidget *parent, - Thickness thickness) - : QWidget(parent) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - NSProgressIndicator *progress = [[NSProgressIndicator alloc] init]; - [progress setStyle:NSProgressIndicatorSpinningStyle]; - - pimpl = new QProgressIndicatorSpinningPrivate(this, progress); - - setupLayout(progress, this); - - setFixedSize(thickness, thickness); - - [progress release]; - - [pool drain]; -} - -void QProgressIndicatorSpinning::animate(bool animate) -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - if (animate) - [pimpl->nsProgressIndicator startAnimation:nil]; - else - [pimpl->nsProgressIndicator stopAnimation:nil]; -} diff --git a/src/gui/qocoa/qprogressindicatorspinning_nonmac.cpp b/src/gui/qocoa/qprogressindicatorspinning_nonmac.cpp deleted file mode 100644 index fae777830..000000000 --- a/src/gui/qocoa/qprogressindicatorspinning_nonmac.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -Copyright (C) 2011 by Mike McQuaid - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include "qprogressindicatorspinning.h" - -#include -#include -#include - -class QProgressIndicatorSpinningPrivate : public QObject -{ -public: - QProgressIndicatorSpinningPrivate(QProgressIndicatorSpinning *qProgressIndicatorSpinning, - QMovie *movie) - : QObject(qProgressIndicatorSpinning), movie(movie) {} - - QPointer movie; -}; - -struct QProgressIndicatorSpinningResources -{ -#ifndef Q_OS_MAC - QProgressIndicatorSpinningResources() { - Q_INIT_RESOURCE(qprogressindicatorspinning_nonmac); - } - ~QProgressIndicatorSpinningResources() { - Q_CLEANUP_RESOURCE(qprogressindicatorspinning_nonmac); - } -#endif -}; - -QProgressIndicatorSpinning::QProgressIndicatorSpinning(QWidget *parent, - Thickness thickness) - : QWidget(parent) -{ - static QProgressIndicatorSpinningResources resources; - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - - QSize size(thickness, thickness); - QMovie *movie = new QMovie(this); - movie->setFileName(":/Qocoa/qprogressindicatorspinning_nonmac.gif"); - movie->setScaledSize(size); - // Roughly match OSX speed. - movie->setSpeed(200); - pimpl = new QProgressIndicatorSpinningPrivate(this, movie); - - QLabel *label = new QLabel(this); - label->setMovie(movie); - - layout->addWidget(label); - setFixedSize(size); -} - - -void QProgressIndicatorSpinning::animate(bool animate) -{ - Q_ASSERT(pimpl && pimpl->movie); - if (!(pimpl && pimpl->movie)) - return; - - if (animate) - pimpl->movie->start(); - else - pimpl->movie->stop(); -} diff --git a/src/gui/qocoa/qprogressindicatorspinning_nonmac.gif b/src/gui/qocoa/qprogressindicatorspinning_nonmac.gif deleted file mode 100644 index 3288d1035d70bb86517e2c233f1a904e41f06b29..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3208 zcmc(iX;4#H9>pJdFE7h`I{IF)0|5<6L}(j=N}5%L009EB2nYfyF)E0PvIqo$u!IC; z4PgyY5|S9AEh38G)(9eq4TbH7_UHg@yWrlIJ$6smIADL7s^P;_O;ykRc9soXl`UC*LwQJXkii*0rx|*7rI2=x7WaRkx_~XZqFJ8R3c=2Kg zf@aSAv8+BJ8+^hyay>(QR@t*blbKzsf0}bscEqRc5Hd3o(-N5RyW=zWB*zQw6Zh>* z2CROCDAbu#D`)S|J_o(lL9Yn3l*+8RdiRD_>iNz$#_IAzCna&Wl5 zSF_(rRCDD!wi#i8oAm&jYtn2_@VB%2-H*G%bN#|(6R6N?wM)3u`PiGzwuX7qmTgyF zpE)h0kuoxQ9?=kW7Y!=R@DmhU9)vwT*EZWzJ zrt+=2tqFts72yIp?|gvdLhs8Hfku^Z(){gmN%Y=K#P|%fkvgUj~HfIp3CuXqCtYGtJ#me+n+-LmP( z*XNuk%!aH8bIE@_Bj46>M*dSro|7<6vZ7WUHh5YQzN$>IJFqCb|CT!wj~R2C2%=q{ zpt8rzY$aw?W?=Ustv{jo?Ow@ZRkLe<)NItY>Cyhle*wR59dTdF6(@{5^ zAQBOB*hNtc3bkY-8{Cm$nFS@elbTtSqrt7MB{h_4y+~`!mVa}?c&N>&?P}GqdMuhQ z&@TD5Czd((DcG_Su~dKKV)Pj$-qi1WHM8_vc^O4?^!oY|tmK~i!{fjd&@_1E(T~r7 z_REZy&hMT^ySJB3W7l$4YhR`M(J7S5S~+4Q&3HPa)z%zPpisOp$^ zTEe99ig2$5_qFr!$;7A6CJ}PJmRhli>w?LC}Y`#HLGy6 zMU4EhL~dKCN5Ut;U2jd*83ShBNiu zcJB0l9>1Modc?-oM<R4?}3g}UJ%@K);kriq>)e*rh%hdqM)5Q)*+O8 zXm;SEbs@koiYS!9YXIclSg+5m_s~yrW#kKMdiRszg(gCP5HPmP7L)vCf8@fxUh6qY z@Z#TmkjzAZX{rwE+q|K~F2v5{_@vt%>yT_a#fF03SFt{0RXvDAiaY~K9CgS1O>frXgAjBCS}mEd4mIWZ$=ovd5| zR?GRdU}d6+Q`+JRW)|=v7$)XNkn3yE`!nAiSCvOB1jKT zG<1aK3s<0b0m==egTD#8i(Of=1pGDTOCho0XpIOMQ&P87cVKY1W=C6kIg z9cH=@a&zbm2+`|{(_?YC9fdm?1TY~-pwlBn?>=(~1pDKbco6jloP;0-cqRiwV1A_S zEyV0Dj8Pwy!nekzaN>{)7rgZ&_QLxK{~1yRe865^yx>}+a!ECd>#MMwddow z@CU{l+Rt$xuXuf}?ga{3IAr?Raql^c@a%sI0U5m}HvJ5O1#I%_MMPt#BH>OqUZ{-k zt>4Xzz=%jT*FVW(uYkWyx}9Gw$HdN*qU?Bit#ji(Wi7p-u|_8?h^%szIS^s^fNM}b zgGy>|=cbEufpguY5_6w~&ZLv=Bo06UF9EYIY;Er-1VK)SyF&!|J{axiE1z^(hXwVq zsFS=K-#zC}CcOs^8W{KAt+kK)jYDgDYbCXv{{rwsgqtIU3<910$CJi)s?? z_t8k{>7*0~4l~LLF7$WXT5OSq5QCTbP_l!SN|{R}3D&eWA8~0ltWh1IL+ZBX4rRSt zWF6Om3WDMu4xK^1(BF`2cL}rUCzhHAB`@j5&R-yk_l*t;mPGY|u2^o|myvcOdrg0W z%=lX;f^Vkqfp?u7*4qQq%A3Mpf!xspWBSKS@O%r*TSM}?dl(@*%{0Jm_8;(h{R__M Bt - - qprogressindicatorspinning_nonmac.gif - - diff --git a/src/gui/qocoa/qsearchfield.h b/src/gui/qocoa/qsearchfield.h deleted file mode 100644 index 1583b4627..000000000 --- a/src/gui/qocoa/qsearchfield.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef QSEARCHFIELD_H -#define QSEARCHFIELD_H - -#include -#include -#include - -class QSearchFieldPrivate; -class QSearchField : public QWidget -{ - Q_OBJECT - - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true); - Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText); - -public: - explicit QSearchField(QWidget *parent); - - QString text() const; - QString placeholderText() const; - void setFocus(Qt::FocusReason); - void setMenu(QMenu *menu); - -public Q_SLOTS: - void setText(const QString &text); - void setPlaceholderText(const QString &text); - void clear(); - void selectAll(); - void setFocus(); - -Q_SIGNALS: - void textChanged(const QString &text); - void editingFinished(); - void returnPressed(); - -private Q_SLOTS: - void popupMenu(); - -protected: - void changeEvent(QEvent*); - void resizeEvent(QResizeEvent*); - -private: - friend class QSearchFieldPrivate; - QPointer pimpl; -}; - -#endif // QSEARCHFIELD_H diff --git a/src/gui/qocoa/qsearchfield_mac.mm b/src/gui/qocoa/qsearchfield_mac.mm deleted file mode 100644 index 4c2db3944..000000000 --- a/src/gui/qocoa/qsearchfield_mac.mm +++ /dev/null @@ -1,257 +0,0 @@ -/* -Copyright (C) 2011 by Mike McQuaid - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include "qsearchfield.h" - -#include "qocoa_mac.h" - -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSNotification.h" -#import "AppKit/NSSearchField.h" - -#include -#include - -#define KEYCODE_A 0 -#define KEYCODE_X 7 -#define KEYCODE_C 8 -#define KEYCODE_V 9 - -class QSearchFieldPrivate : public QObject -{ -public: - QSearchFieldPrivate(QSearchField *qSearchField, NSSearchField *nsSearchField) - : QObject(qSearchField), qSearchField(qSearchField), nsSearchField(nsSearchField) {} - - void textDidChange(const QString &text) - { - if (qSearchField) - Q_EMIT qSearchField->textChanged(text); - } - - void textDidEndEditing() - { - if (qSearchField) - Q_EMIT qSearchField->editingFinished(); - } - - void returnPressed() - { - if (qSearchField) - Q_EMIT qSearchField->returnPressed(); - } - - QPointer qSearchField; - NSSearchField *nsSearchField; -}; - -@interface QSearchFieldDelegate : NSObject -{ -@public - QPointer pimpl; -} --(void)controlTextDidChange:(NSNotification*)notification; --(void)controlTextDidEndEditing:(NSNotification*)notification; -@end - -@implementation QSearchFieldDelegate --(void)controlTextDidChange:(NSNotification*)notification { - Q_ASSERT(pimpl); - if (pimpl) - pimpl->textDidChange(toQString([[notification object] stringValue])); -} - --(void)controlTextDidEndEditing:(NSNotification*)notification { - Q_UNUSED(notification); - // No Q_ASSERT here as it is called on destruction. - if (pimpl) - pimpl->textDidEndEditing(); - - if ([[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement) - pimpl->returnPressed(); -} -@end - -@interface QocoaSearchField : NSSearchField --(BOOL)performKeyEquivalent:(NSEvent*)event; -@end - -@implementation QocoaSearchField --(BOOL)performKeyEquivalent:(NSEvent*)event { - if ([event type] == NSKeyDown && [event modifierFlags] & NSCommandKeyMask) - { - const unsigned short keyCode = [event keyCode]; - if (keyCode == KEYCODE_A) - { - [self performSelector:@selector(selectText:)]; - return YES; - } - else if (keyCode == KEYCODE_C) - { - QClipboard* clipboard = QApplication::clipboard(); - clipboard->setText(toQString([self stringValue])); - return YES; - } - else if (keyCode == KEYCODE_V) - { - QClipboard* clipboard = QApplication::clipboard(); - [self setStringValue:fromQString(clipboard->text())]; - return YES; - } - else if (keyCode == KEYCODE_X) - { - QClipboard* clipboard = QApplication::clipboard(); - clipboard->setText(toQString([self stringValue])); - [self setStringValue:@""]; - return YES; - } - } - - return NO; -} -@end - -QSearchField::QSearchField(QWidget *parent) : QWidget(parent) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - NSSearchField *search = [[QocoaSearchField alloc] init]; - - QSearchFieldDelegate *delegate = [[QSearchFieldDelegate alloc] init]; - pimpl = delegate->pimpl = new QSearchFieldPrivate(this, search); - [search setDelegate:delegate]; - - setupLayout(search, this); - - setFixedHeight(24); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - - [search release]; - - [pool drain]; -} - -void QSearchField::setMenu(QMenu *menu) -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - NSMenu *nsMenu = menu->macMenu(); - [[pimpl->nsSearchField cell] setSearchMenuTemplate:nsMenu]; -} - -void QSearchField::popupMenu() -{ -} - -void QSearchField::setText(const QString &text) -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [pimpl->nsSearchField setStringValue:fromQString(text)]; - [pool drain]; -} - -void QSearchField::setPlaceholderText(const QString &text) -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [[pimpl->nsSearchField cell] setPlaceholderString:fromQString(text)]; - [pool drain]; -} - -void QSearchField::clear() -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - [pimpl->nsSearchField setStringValue:@""]; - Q_EMIT textChanged(QString()); -} - -void QSearchField::selectAll() -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - [pimpl->nsSearchField performSelector:@selector(selectText:)]; -} - -QString QSearchField::text() const -{ - Q_ASSERT(pimpl); - if (!pimpl) - return QString(); - - return toQString([pimpl->nsSearchField stringValue]); -} - -QString QSearchField::placeholderText() const -{ - Q_ASSERT(pimpl); - if (!pimpl) - return QString(); - - return toQString([[pimpl->nsSearchField cell] placeholderString]); -} - -void QSearchField::setFocus(Qt::FocusReason) -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - if ([pimpl->nsSearchField acceptsFirstResponder]) - [[pimpl->nsSearchField window] makeFirstResponder: pimpl->nsSearchField]; -} - -void QSearchField::setFocus() -{ - setFocus(Qt::OtherFocusReason); -} - -void QSearchField::changeEvent(QEvent* event) -{ - if (event->type() == QEvent::EnabledChange) { - Q_ASSERT(pimpl); - if (!pimpl) - return; - - const bool enabled = isEnabled(); - [pimpl->nsSearchField setEnabled: enabled]; - } - QWidget::changeEvent(event); -} - -void QSearchField::resizeEvent(QResizeEvent *resizeEvent) -{ - QWidget::resizeEvent(resizeEvent); -} diff --git a/src/gui/qocoa/qsearchfield_nonmac.cpp b/src/gui/qocoa/qsearchfield_nonmac.cpp deleted file mode 100644 index 5244bd605..000000000 --- a/src/gui/qocoa/qsearchfield_nonmac.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* -Copyright (C) 2011 by Mike McQuaid - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include "qsearchfield.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -class QSearchFieldPrivate : public QObject -{ -public: - QSearchFieldPrivate(QSearchField *searchField, QLineEdit *lineEdit, QToolButton *clearButton, QToolButton *searchButton) - : QObject(searchField), lineEdit(lineEdit), clearButton(clearButton), searchButton(searchButton) {} - - int lineEditFrameWidth() const { - return lineEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - } - - int clearButtonPaddedWidth() const { - return clearButton->width() + lineEditFrameWidth() * 2; - } - - int clearButtonPaddedHeight() const { - return clearButton->height() + lineEditFrameWidth() * 2; - } - - int searchButtonPaddedWidth() const { - return searchButton->width() + lineEditFrameWidth() * 2; - } - - int searchButtonPaddedHeight() const { - return searchButton->height() + lineEditFrameWidth() * 2; - } - - QPointer lineEdit; - QPointer clearButton; - QPointer searchButton; - QPointer searchMenu; -}; - -struct QSearchFieldResources -{ -#ifndef Q_OS_MAC - QSearchFieldResources() { - Q_INIT_RESOURCE(qsearchfield_nonmac); - } - ~QSearchFieldResources() { - Q_CLEANUP_RESOURCE(qsearchfield_nonmac); - } -#endif -}; - -QSearchField::QSearchField(QWidget *parent) : QWidget(parent) -{ - static QSearchFieldResources resources; - - QLineEdit *lineEdit = new QLineEdit(this); - connect(lineEdit, SIGNAL(textChanged(QString)), - this, SIGNAL(textChanged(QString))); - connect(lineEdit, SIGNAL(editingFinished()), - this, SIGNAL(editingFinished())); - connect(lineEdit, SIGNAL(returnPressed()), - this, SIGNAL(returnPressed())); - connect(lineEdit, SIGNAL(textChanged(QString)), - this, SLOT(setText(QString))); - - int iconsize = style()->pixelMetric(QStyle::PM_SmallIconSize); - QToolButton *clearButton = new QToolButton(this); - QIcon clearIcon = QIcon::fromTheme(QLatin1String("edit-clear"), - QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_clear.png"))); - clearButton->setIcon(clearIcon); - clearButton->setIconSize(QSize(iconsize, iconsize)); - clearButton->setFixedSize(QSize(iconsize, iconsize)); - clearButton->setStyleSheet("border: none;"); - clearButton->hide(); - connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); - - QToolButton *searchButton = new QToolButton(this); - QIcon searchIcon = QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier.png")); - searchButton->setIcon(searchIcon); - searchButton->setIconSize(QSize(iconsize, iconsize)); - searchButton->setFixedSize(QSize(iconsize, iconsize)); - searchButton->setStyleSheet("border: none;"); - searchButton->setPopupMode(QToolButton::InstantPopup); - searchButton->setEnabled(false); - connect(searchButton, SIGNAL(clicked()), this, SLOT(popupMenu())); - - pimpl = new QSearchFieldPrivate(this, lineEdit, clearButton, searchButton); - - lineEdit->setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; } ") - .arg(pimpl->searchButtonPaddedWidth()) - .arg(pimpl->clearButtonPaddedWidth())); - const int width = qMax(lineEdit->minimumSizeHint().width(), pimpl->clearButtonPaddedWidth() + pimpl->searchButtonPaddedWidth()); - const int height = qMax(lineEdit->minimumSizeHint().height(), - qMax(pimpl->clearButtonPaddedHeight(), - pimpl->searchButtonPaddedHeight())); - lineEdit->setMinimumSize(width, height); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->addWidget(lineEdit); -} - -void QSearchField::setMenu(QMenu *menu) -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - pimpl->searchMenu = menu; - - QIcon searchIcon = menu ? QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier_menu.png")) - : QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier.png")); - pimpl->searchButton->setIcon(searchIcon); - pimpl->searchButton->setEnabled(isEnabled() && menu); -} - -void QSearchField::popupMenu() -{ - Q_ASSERT(pimpl); - if (!pimpl) - return; - - if (pimpl->searchMenu) { - const QRect screenRect = qApp->desktop()->availableGeometry(pimpl->searchButton); - const QSize sizeHint = pimpl->searchMenu->sizeHint(); - const QRect rect = pimpl->searchButton->rect(); - const int x = pimpl->searchButton->isRightToLeft() - ? rect.right() - sizeHint.width() - : rect.left(); - const int y = pimpl->searchButton->mapToGlobal(QPoint(0, rect.bottom())).y() + sizeHint.height() <= screenRect.height() - ? rect.bottom() - : rect.top() - sizeHint.height(); - QPoint point = pimpl->searchButton->mapToGlobal(QPoint(x, y)); - point.rx() = qMax(screenRect.left(), qMin(point.x(), screenRect.right() - sizeHint.width())); - point.ry() += 1; - - pimpl->searchMenu->popup(point); - } -} - -void QSearchField::changeEvent(QEvent* event) -{ - if (event->type() == QEvent::EnabledChange) { - Q_ASSERT(pimpl); - if (!pimpl) - return; - - const bool enabled = isEnabled(); - pimpl->searchButton->setEnabled(enabled && pimpl->searchMenu); - pimpl->lineEdit->setEnabled(enabled); - pimpl->clearButton->setEnabled(enabled); - } - QWidget::changeEvent(event); -} - -void QSearchField::setText(const QString &text) -{ - Q_ASSERT(pimpl && pimpl->clearButton && pimpl->lineEdit); - if (!(pimpl && pimpl->clearButton && pimpl->lineEdit)) - return; - - pimpl->clearButton->setVisible(!text.isEmpty()); - - if (text != this->text()) - pimpl->lineEdit->setText(text); -} - -void QSearchField::setPlaceholderText(const QString &text) -{ - Q_ASSERT(pimpl && pimpl->lineEdit); - if (!(pimpl && pimpl->lineEdit)) - return; - -#if QT_VERSION >= 0x040700 - pimpl->lineEdit->setPlaceholderText(text); -#endif -} - -void QSearchField::clear() -{ - Q_ASSERT(pimpl && pimpl->lineEdit); - if (!(pimpl && pimpl->lineEdit)) - return; - - pimpl->lineEdit->clear(); -} - -void QSearchField::selectAll() -{ - Q_ASSERT(pimpl && pimpl->lineEdit); - if (!(pimpl && pimpl->lineEdit)) - return; - - pimpl->lineEdit->selectAll(); -} - -QString QSearchField::text() const -{ - Q_ASSERT(pimpl && pimpl->lineEdit); - if (!(pimpl && pimpl->lineEdit)) - return QString(); - - return pimpl->lineEdit->text(); -} - -QString QSearchField::placeholderText() const { - Q_ASSERT(pimpl && pimpl->lineEdit); - if (!(pimpl && pimpl->lineEdit)) - return QString(); - -#if QT_VERSION >= 0x040700 - return pimpl->lineEdit->placeholderText(); -#else - return QString(); -#endif -} - -void QSearchField::setFocus(Qt::FocusReason reason) -{ - Q_ASSERT(pimpl && pimpl->lineEdit); - if (pimpl && pimpl->lineEdit) - pimpl->lineEdit->setFocus(reason); -} - -void QSearchField::setFocus() -{ - setFocus(Qt::OtherFocusReason); -} - -void QSearchField::resizeEvent(QResizeEvent *resizeEvent) -{ - Q_ASSERT(pimpl && pimpl->clearButton && pimpl->lineEdit); - if (!(pimpl && pimpl->clearButton && pimpl->lineEdit)) - return; - - QWidget::resizeEvent(resizeEvent); - const int x = width() - pimpl->clearButtonPaddedWidth(); - const int y = (height() - pimpl->clearButton->height())/2; - pimpl->clearButton->move(x, y); - - pimpl->searchButton->move(pimpl->lineEditFrameWidth() * 2, - (height() - pimpl->searchButton->height())/2); -} diff --git a/src/gui/qocoa/qsearchfield_nonmac.qrc b/src/gui/qocoa/qsearchfield_nonmac.qrc deleted file mode 100644 index 68b570d5b..000000000 --- a/src/gui/qocoa/qsearchfield_nonmac.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - qsearchfield_nonmac_clear.png - qsearchfield_nonmac_magnifier_menu.png - qsearchfield_nonmac_magnifier.png - - diff --git a/src/gui/qocoa/qsearchfield_nonmac_clear.png b/src/gui/qocoa/qsearchfield_nonmac_clear.png deleted file mode 100644 index ec52c41bc2fbba0bcc2b30a96267d73be240dc13..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 736 zcmV<60w4W}P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igQ1 z5H}Q?5;Tqg00Ll1L_t(I%dL~KP8(SihQGOU@A%G)jYu&WzH`%nmEB~k%_)!0|LN%b|AGHm z-oG2$+uQ3>$}P|HIzosRKvh)}=iL2bvG{s(bCdlipx5iYRZ9ISrA(Dl2qAa@V2ok0 zSUehIK3`v7e|gpTKZ>>1@8dXrQ?J*FLsS(ar>K(E(Z z55w?XqtSR%uh-e%-)A2ykxBqT|~bUI}?98#7gQc7NC zTL2Qk_kDyA_`XjZ$7rp8@_S`v1>g5^&Mjw`8#w1C&N-~L#Bt1EFre9NlIJ;jp3`hL z84L!*ag4PV=N!(t$r4ai)xEVAV+`GHmo!ZokH_@;efs@ACb6=jZ2N{*lDHySr?2bF=h)KM8`M z@ne)p>7~2_ZUoUdwwqvaRgBnVYW{7Z(}7v%UkVf%q@6 SqLyO-0000Dhf?ouWA>yZ`s+BBx=){u((%TpyhhRjALHT2ckQc&d4&) z-n7Bm;H*K-pZ^kn7Mb{N&z!|jAk+T(YZimV`=g(K?qPLwkZ5DrlIwl{`;^p7iT5tI zx9yD4vv!!4s&o3#!*q*2WiQPZ0c-805^anh>)KKyITY=T68yi}@UJypmicbY)??rQ z+E&g>&)Y8jdRLLvT!xHUZR=iZbUpf-AmV!aZ=JhW=j&ZIa{LT^$CW)N?OE3SxI+54 wpr&f&y!tagmpaE@|F2cIdey48=Y>A7G=&6K*=^zp26~sl)78&qol`;+0Ic(R)c^nh diff --git a/src/gui/qocoa/qsearchfield_nonmac_magnifier_menu.png b/src/gui/qocoa/qsearchfield_nonmac_magnifier_menu.png deleted file mode 100644 index 0e652c945e4287939e4787cd02c891c50238c64a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 439 zcmV;o0Z9IdP)e+J+88IQ+ODwU{IDgdn4Yj(RG-ELPU zlgZB|=kxg)CX$;ex$!IiEsZ@$z hOGL13`%eoV{s($5(uCrFlfnQ1002ovPDHLkV1gsuzk~n) From f52f6e2d44bc3a08a5b2fa281459af8baac68f0d Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 17:02:43 +0000 Subject: [PATCH 30/51] Squashed 'src/gui/qocoa/' content from commit ffe23cb git-subtree-dir: src/gui/qocoa git-subtree-split: ffe23cbb2f221bc9eacd1de2134c2947fed71c12 --- .gitignore | 2 + CMakeLists.txt | 48 +++++ LICENSE.txt | 19 ++ Qocoa.pro | 17 ++ README.md | 36 ++++ TODO.md | 13 ++ gallery.cpp | 75 +++++++ gallery.h | 14 ++ gallery.png | Bin 0 -> 42195 bytes main.cpp | 13 ++ qbutton.h | 49 +++++ qbutton_mac.mm | 229 +++++++++++++++++++++ qbutton_nonmac.cpp | 89 +++++++++ qocoa_mac.h | 63 ++++++ qprogressindicatorspinning.h | 29 +++ qprogressindicatorspinning_mac.mm | 70 +++++++ qprogressindicatorspinning_nonmac.cpp | 72 +++++++ qprogressindicatorspinning_nonmac.gif | Bin 0 -> 3208 bytes qprogressindicatorspinning_nonmac.qrc | 5 + qsearchfield.h | 48 +++++ qsearchfield_mac.mm | 262 +++++++++++++++++++++++++ qsearchfield_nonmac.cpp | 256 ++++++++++++++++++++++++ qsearchfield_nonmac.qrc | 7 + qsearchfield_nonmac_clear.png | Bin 0 -> 736 bytes qsearchfield_nonmac_magnifier.png | Bin 0 -> 300 bytes qsearchfield_nonmac_magnifier_menu.png | Bin 0 -> 439 bytes 26 files changed, 1416 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 LICENSE.txt create mode 100644 Qocoa.pro create mode 100644 README.md create mode 100644 TODO.md create mode 100644 gallery.cpp create mode 100644 gallery.h create mode 100644 gallery.png create mode 100644 main.cpp create mode 100644 qbutton.h create mode 100644 qbutton_mac.mm create mode 100644 qbutton_nonmac.cpp create mode 100644 qocoa_mac.h create mode 100644 qprogressindicatorspinning.h create mode 100644 qprogressindicatorspinning_mac.mm create mode 100644 qprogressindicatorspinning_nonmac.cpp create mode 100644 qprogressindicatorspinning_nonmac.gif create mode 100644 qprogressindicatorspinning_nonmac.qrc create mode 100644 qsearchfield.h create mode 100644 qsearchfield_mac.mm create mode 100644 qsearchfield_nonmac.cpp create mode 100644 qsearchfield_nonmac.qrc create mode 100644 qsearchfield_nonmac_clear.png create mode 100644 qsearchfield_nonmac_magnifier.png create mode 100644 qsearchfield_nonmac_magnifier_menu.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..4963d2730 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +cmake/ +qmake/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..513f81f7d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,48 @@ +project(Qocoa) +cmake_minimum_required(VERSION 2.8) + +find_package(Qt4 COMPONENTS QtMain QtCore QtGui REQUIRED) +include(UseQt4) + +set(SOURCES + main.cpp + gallery.cpp +) + +set(HEADERS + gallery.h + qsearchfield.h + qbutton.h + qprogressindicatorspinning.h +) + +qt4_wrap_cpp(MOC_SOURCES ${HEADERS}) + +if(APPLE) + list(APPEND SOURCES + qsearchfield_mac.mm + qbutton_mac.mm + qprogressindicatorspinning_mac.mm + ) +else() + list(APPEND SOURCES + qsearchfield_nonmac.cpp + qbutton_nonmac.cpp + qprogressindicatorspinning_nonmac.cpp + ) + set(RESOURCES + qsearchfield_nonmac.qrc + qprogressindicatorspinning_nonmac.qrc + ) + qt4_add_resources(RESOURCES_SOURCES ${RESOURCES}) +endif() + +add_executable(Qocoa + WIN32 MACOSX_BUNDLE + ${SOURCES} ${MOC_SOURCES} ${RESOURCES_SOURCES} +) +target_link_libraries(Qocoa ${QT_LIBRARIES}) + +if(APPLE) + set_target_properties(Qocoa PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit") +endif() diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 000000000..910eb6d20 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,19 @@ +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Qocoa.pro b/Qocoa.pro new file mode 100644 index 000000000..8b325d192 --- /dev/null +++ b/Qocoa.pro @@ -0,0 +1,17 @@ +SOURCES += main.cpp\ + gallery.cpp \ + +HEADERS += gallery.h \ + qocoa_mac.h \ + qsearchfield.h \ + qbutton.h \ + qprogressindicatorspinning.h \ + +mac { + OBJECTIVE_SOURCES += qsearchfield_mac.mm qbutton_mac.mm qprogressindicatorspinning_mac.mm + LIBS += -framework Foundation -framework Appkit + QMAKE_CFLAGS += -mmacosx-version-min=10.6 +} else { + SOURCES += qsearchfield_nonmac.cpp qbutton_nonmac.cpp qprogressindicatorspinning_nonmac.cpp + RESOURCES += qsearchfield_nonmac.qrc qprogressindicatorspinning_nonmac.qrc +} diff --git a/README.md b/README.md new file mode 100644 index 000000000..3d37b6a27 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Qocoa +Qocoa is a collection of Qt wrappers for OSX's Cocoa widgets. + +## Features +- basic fallback to sensible Qt types on non-OSX platforms +- shared class headers which expose no implementation details +- typical Qt signal/slot-based API +- trivial to import into projects (class header/implementation, [single shared global header](https://github.com/mikemcquaid/Qocoa/blob/master/qocoa_mac.h)) + +## Building +``` +git clone git://github.com/mikemcquaid/Qocoa.git +cd Qocoa +qmake # or cmake . +make +``` + +## Status +Qocoa classes are currently provided for NSButton, a spinning NSProgressIndicator and NSSearchField. There is a [TODO list](https://github.com/mikemcquaid/Qocoa/blob/master/TODO.md) for classes I hope to implement. + +## Usage +For each class you want to use copy the [`qocoa_mac.h`](https://github.com/mikemcquaid/Qocoa/blob/master/qocoa_mac.h), `$CLASS.h`, `$CLASS_mac.*` and `$CLASS_nonmac.*` files into your source tree and add them to your buildsystem. Examples are provided for [CMake](https://github.com/mikemcquaid/Qocoa/blob/master/CMakeLists.txt) and [QMake](https://github.com/mikemcquaid/Qocoa/blob/master/Qocoa.pro). + +## Contact +[Mike McQuaid](mailto:mike@mikemcquaid.com) + +## License +Qocoa is licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License). +The full license text is available in [LICENSE.txt](https://github.com/mikemcquaid/Qocoa/blob/master/LICENSE.txt). + +Magnifier and EditClear icons taken from [QtCreator](http://qt-project.org/) and are licensed under the [LGPL](http://www.gnu.org/copyleft/lesser.html). + +Other icons are taken from the [Oxygen Project](http://www.oxygen-icons.org/) and are licensed under the [Creative Commons Attribution-ShareAlike 3.0 License](http://creativecommons.org/licenses/by-sa/3.0/). + +## Gallery +![Qocoa Gallery](https://github.com/mikemcquaid/Qocoa/raw/master/gallery.png) diff --git a/TODO.md b/TODO.md new file mode 100644 index 000000000..45972bafa --- /dev/null +++ b/TODO.md @@ -0,0 +1,13 @@ +Widgets I hope to implement (or at least investigate): + +- NSTokenField +- NSSegmentedControl +- NSLevelIndicator +- NSPathControl +- NSSlider (Circular) +- NSSplitView +- NSTextFinder +- NSOutlineView in an NSScrollView (Source List) +- NSDrawer +- PDFView +- WebView diff --git a/gallery.cpp b/gallery.cpp new file mode 100644 index 000000000..210821ebd --- /dev/null +++ b/gallery.cpp @@ -0,0 +1,75 @@ +#include "gallery.h" + +#include + +#include "qsearchfield.h" +#include "qbutton.h" +#include "qprogressindicatorspinning.h" + +Gallery::Gallery(QWidget *parent) : QWidget(parent) +{ + setWindowTitle("Qocoa Gallery"); + QVBoxLayout *layout = new QVBoxLayout(this); + + QSearchField *searchField = new QSearchField(this); + layout->addWidget(searchField); + + QSearchField *searchFieldPlaceholder = new QSearchField(this); + searchFieldPlaceholder->setPlaceholderText("Placeholder text"); + layout->addWidget(searchFieldPlaceholder); + + QButton *roundedButton = new QButton(this, QButton::Rounded); + roundedButton->setText("Button"); + layout->addWidget(roundedButton); + + QButton *regularSquareButton = new QButton(this, QButton::RegularSquare); + regularSquareButton->setText("Button"); + layout->addWidget(regularSquareButton); + + QButton *disclosureButton = new QButton(this, QButton::Disclosure); + layout->addWidget(disclosureButton); + + QButton *shadowlessSquareButton = new QButton(this, QButton::ShadowlessSquare); + shadowlessSquareButton->setText("Button"); + layout->addWidget(shadowlessSquareButton); + + QButton *circularButton = new QButton(this, QButton::Circular); + layout->addWidget(circularButton); + + QButton *textureSquareButton = new QButton(this, QButton::TexturedSquare); + textureSquareButton->setText("Textured Button"); + layout->addWidget(textureSquareButton); + + QButton *helpButton = new QButton(this, QButton::HelpButton); + layout->addWidget(helpButton); + + QButton *smallSquareButton = new QButton(this, QButton::SmallSquare); + smallSquareButton->setText("Gradient Button"); + layout->addWidget(smallSquareButton); + + QButton *texturedRoundedButton = new QButton(this, QButton::TexturedRounded); + texturedRoundedButton->setText("Round Textured"); + layout->addWidget(texturedRoundedButton); + + QButton *roundedRectangleButton = new QButton(this, QButton::RoundRect); + roundedRectangleButton->setText("Rounded Rect Button"); + layout->addWidget(roundedRectangleButton); + + QButton *recessedButton = new QButton(this, QButton::Recessed); + recessedButton->setText("Recessed Button"); + layout->addWidget(recessedButton); + + QButton *roundedDisclosureButton = new QButton(this, QButton::RoundedDisclosure); + layout->addWidget(roundedDisclosureButton); + +#ifdef __MAC_10_7 + QButton *inlineButton = new QButton(this, QButton::Inline); + inlineButton->setText("Inline Button"); + layout->addWidget(inlineButton); +#endif + + + QProgressIndicatorSpinning *progressIndicatorSpinning = new QProgressIndicatorSpinning(this); + progressIndicatorSpinning->animate(); + layout->addWidget(progressIndicatorSpinning); +} diff --git a/gallery.h b/gallery.h new file mode 100644 index 000000000..1e83bad94 --- /dev/null +++ b/gallery.h @@ -0,0 +1,14 @@ +#ifndef GALLERY_H +#define GALLERY_H + +#include + +class Gallery : public QWidget +{ + Q_OBJECT + +public: + explicit Gallery(QWidget *parent = 0); +}; + +#endif // WIDGET_H diff --git a/gallery.png b/gallery.png new file mode 100644 index 0000000000000000000000000000000000000000..7a2736ff572491af1fefbbface2742caceabd6e3 GIT binary patch literal 42195 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 z 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 N002ovPDHLkV1hfpIk5l$ literal 0 HcmV?d00001 diff --git a/main.cpp b/main.cpp new file mode 100644 index 000000000..835e5eb5d --- /dev/null +++ b/main.cpp @@ -0,0 +1,13 @@ +#include + +#include "gallery.h" + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + Gallery gallery; + gallery.show(); + + return application.exec(); +} diff --git a/qbutton.h b/qbutton.h new file mode 100644 index 000000000..93e598f80 --- /dev/null +++ b/qbutton.h @@ -0,0 +1,49 @@ +#ifndef QBUTTON_H +#define QBUTTON_H + +#include +#include + +class QButtonPrivate; +class QButton : public QWidget +{ + Q_OBJECT +public: + // Matches NSBezelStyle + enum BezelStyle { + Rounded = 1, + RegularSquare = 2, + Disclosure = 5, + ShadowlessSquare = 6, + Circular = 7, + TexturedSquare = 8, + HelpButton = 9, + SmallSquare = 10, + TexturedRounded = 11, + RoundRect = 12, + Recessed = 13, + RoundedDisclosure = 14, +#ifdef __MAC_10_7 + Inline = 15 +#endif + }; + + explicit QButton(QWidget *parent, BezelStyle bezelStyle = Rounded); + +public slots: + void setText(const QString &text); + void setImage(const QPixmap &image); + void setChecked(bool checked); + +public: + void setCheckable(bool checkable); + bool isChecked(); + +signals: + void clicked(bool checked = false); + +private: + friend class QButtonPrivate; + QPointer pimpl; +}; +#endif // QBUTTON_H diff --git a/qbutton_mac.mm b/qbutton_mac.mm new file mode 100644 index 000000000..15490e453 --- /dev/null +++ b/qbutton_mac.mm @@ -0,0 +1,229 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qbutton.h" + +#include "qocoa_mac.h" + +#import "Foundation/NSAutoreleasePool.h" +#import "AppKit/NSButton.h" +#import "AppKit/NSFont.h" + +class QButtonPrivate : public QObject +{ +public: + QButtonPrivate(QButton *qButton, NSButton *nsButton, QButton::BezelStyle bezelStyle) + : QObject(qButton), qButton(qButton), nsButton(nsButton) + { + switch(bezelStyle) { + case QButton::Disclosure: + case QButton::Circular: +#ifdef __MAC_10_7 + case QButton::Inline: +#endif + case QButton::RoundedDisclosure: + case QButton::HelpButton: + [nsButton setTitle:@""]; + default: + break; + } + + NSFont* font = 0; + switch(bezelStyle) { + case QButton::RoundRect: + font = [NSFont fontWithName:@"Lucida Grande" size:12]; + break; + + case QButton::Recessed: + font = [NSFont fontWithName:@"Lucida Grande Bold" size:12]; + break; + +#ifdef __MAC_10_7 + case QButton::Inline: + font = [NSFont boldSystemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]; + break; +#endif + + default: + font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]; + break; + } + [nsButton setFont:font]; + + switch(bezelStyle) { + case QButton::Rounded: + qButton->setMinimumWidth(40); + qButton->setFixedHeight(24); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; + case QButton::RegularSquare: + case QButton::TexturedSquare: + qButton->setMinimumSize(14, 23); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::ShadowlessSquare: + qButton->setMinimumSize(5, 25); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::SmallSquare: + qButton->setMinimumSize(4, 21); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::TexturedRounded: + qButton->setMinimumSize(10, 22); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::RoundRect: + case QButton::Recessed: + qButton->setMinimumWidth(16); + qButton->setFixedHeight(18); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; + case QButton::Disclosure: + qButton->setMinimumWidth(13); + qButton->setFixedHeight(13); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; + case QButton::Circular: + qButton->setMinimumSize(16, 16); + qButton->setMaximumHeight(40); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + break; + case QButton::HelpButton: + case QButton::RoundedDisclosure: + qButton->setMinimumWidth(22); + qButton->setFixedHeight(22); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; +#ifdef __MAC_10_7 + case QButton::Inline: + qButton->setMinimumWidth(10); + qButton->setFixedHeight(16); + qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + break; +#endif + } + + switch(bezelStyle) { + case QButton::Recessed: + [nsButton setButtonType:NSPushOnPushOffButton]; + case QButton::Disclosure: + [nsButton setButtonType:NSOnOffButton]; + default: + [nsButton setButtonType:NSMomentaryPushInButton]; + } + + [nsButton setBezelStyle:bezelStyle]; + } + + void clicked() + { + emit qButton->clicked(qButton->isChecked()); + } + + ~QButtonPrivate() { + [[nsButton target] release]; + [nsButton setTarget:nil]; + } + + QButton *qButton; + NSButton *nsButton; +}; + +@interface QButtonTarget : NSObject +{ +@public + QPointer pimpl; +} +-(void)clicked; +@end + +@implementation QButtonTarget +-(void)clicked { + Q_ASSERT(pimpl); + if (pimpl) + pimpl->clicked(); +} +@end + +QButton::QButton(QWidget *parent, BezelStyle bezelStyle) : QWidget(parent) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSButton *button = [[NSButton alloc] init]; + pimpl = new QButtonPrivate(this, button, bezelStyle); + + QButtonTarget *target = [[QButtonTarget alloc] init]; + target->pimpl = pimpl; + [button setTarget:target]; + + [button setAction:@selector(clicked)]; + + setupLayout(button, this); + + [button release]; + + [pool drain]; +} + +void QButton::setText(const QString &text) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [pimpl->nsButton setTitle:fromQString(text)]; + [pool drain]; +} + +void QButton::setImage(const QPixmap &image) +{ + Q_ASSERT(pimpl); + if (pimpl) + [pimpl->nsButton setImage:fromQPixmap(image)]; +} + +void QButton::setChecked(bool checked) +{ + Q_ASSERT(pimpl); + if (pimpl) + [pimpl->nsButton setState:checked]; +} + +void QButton::setCheckable(bool checkable) +{ + const NSInteger cellMask = checkable ? NSChangeBackgroundCellMask : NSNoCellMask; + + Q_ASSERT(pimpl); + if (pimpl) + [[pimpl->nsButton cell] setShowsStateBy:cellMask]; +} + +bool QButton::isChecked() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return false; + + return [pimpl->nsButton state]; +} diff --git a/qbutton_nonmac.cpp b/qbutton_nonmac.cpp new file mode 100644 index 000000000..0a79e2baf --- /dev/null +++ b/qbutton_nonmac.cpp @@ -0,0 +1,89 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qbutton.h" + +#include +#include +#include +#include + +class QButtonPrivate : public QObject +{ +public: + QButtonPrivate(QButton *button, QAbstractButton *abstractButton) + : QObject(button), abstractButton(abstractButton) {} + QPointer abstractButton; +}; + +QButton::QButton(QWidget *parent, BezelStyle) : QWidget(parent) +{ + QAbstractButton *button = 0; + if (qobject_cast(parent)) + button = new QToolButton(this); + else + button = new QPushButton(this); + connect(button, SIGNAL(clicked()), + this, SIGNAL(clicked())); + pimpl = new QButtonPrivate(this, button); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->addWidget(button); +} + +void QButton::setText(const QString &text) +{ + Q_ASSERT(pimpl); + if (pimpl) + pimpl->abstractButton->setText(text); +} + +void QButton::setImage(const QPixmap &image) +{ + Q_ASSERT(pimpl); + if (pimpl) + pimpl->abstractButton->setIcon(image); +} + +void QButton::setChecked(bool checked) +{ + Q_ASSERT(pimpl); + if (pimpl) + pimpl->abstractButton->setChecked(checked); +} + +void QButton::setCheckable(bool checkable) +{ + Q_ASSERT(pimpl); + if (pimpl) + pimpl->abstractButton->setCheckable(checkable); +} + +bool QButton::isChecked() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return false; + + return pimpl->abstractButton->isChecked(); +} diff --git a/qocoa_mac.h b/qocoa_mac.h new file mode 100644 index 000000000..f8307e912 --- /dev/null +++ b/qocoa_mac.h @@ -0,0 +1,63 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include +#include +#include +#include + +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +#include +#endif + +static inline NSString* fromQString(const QString &string) +{ + const QByteArray utf8 = string.toUtf8(); + const char* cString = utf8.constData(); + return [[NSString alloc] initWithUTF8String:cString]; +} + +static inline QString toQString(NSString *string) +{ + if (!string) + return QString(); + return QString::fromUtf8([string UTF8String]); +} + +static inline NSImage* fromQPixmap(const QPixmap &pixmap) +{ +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + CGImageRef cgImage = pixmap.toMacCGImageRef(); +#else + CGImageRef cgImage = QtMac::toCGImageRef(pixmap); +#endif + return [[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize]; +} + +static inline void setupLayout(NSView *cocoaView, QWidget *parent) +{ + parent->setAttribute(Qt::WA_NativeWindow); + QVBoxLayout *layout = new QVBoxLayout(parent); + layout->setMargin(0); + layout->addWidget(new QMacCocoaViewContainer(cocoaView, parent)); +} diff --git a/qprogressindicatorspinning.h b/qprogressindicatorspinning.h new file mode 100644 index 000000000..ae40a92a2 --- /dev/null +++ b/qprogressindicatorspinning.h @@ -0,0 +1,29 @@ +#ifndef QPROGRESSINDICATORSPINNING_H +#define QPROGRESSINDICATORSPINNING_H + +#include +#include + +class QProgressIndicatorSpinningPrivate; +class QProgressIndicatorSpinning : public QWidget +{ + Q_OBJECT +public: + // Matches NSProgressIndicatorThickness + enum Thickness { + Default = 14, + Small = 10, + Large = 18, + Aqua = 12 + }; + + explicit QProgressIndicatorSpinning(QWidget *parent, + Thickness thickness = Default); +public slots: + void animate(bool animate = true); +private: + friend class QProgressIndicatorSpinningPrivate; + QPointer pimpl; +}; + +#endif // QPROGRESSINDICATORSPINNING_H diff --git a/qprogressindicatorspinning_mac.mm b/qprogressindicatorspinning_mac.mm new file mode 100644 index 000000000..c67c7c567 --- /dev/null +++ b/qprogressindicatorspinning_mac.mm @@ -0,0 +1,70 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qprogressindicatorspinning.h" + +#include "qocoa_mac.h" + +#import "Foundation/NSAutoreleasePool.h" +#import "AppKit/NSProgressIndicator.h" + +class QProgressIndicatorSpinningPrivate : public QObject +{ +public: + QProgressIndicatorSpinningPrivate(QProgressIndicatorSpinning *qProgressIndicatorSpinning, + NSProgressIndicator *nsProgressIndicator) + : QObject(qProgressIndicatorSpinning), nsProgressIndicator(nsProgressIndicator) {} + + NSProgressIndicator *nsProgressIndicator; +}; + +QProgressIndicatorSpinning::QProgressIndicatorSpinning(QWidget *parent, + Thickness thickness) + : QWidget(parent) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSProgressIndicator *progress = [[NSProgressIndicator alloc] init]; + [progress setStyle:NSProgressIndicatorSpinningStyle]; + + pimpl = new QProgressIndicatorSpinningPrivate(this, progress); + + setupLayout(progress, this); + + setFixedSize(thickness, thickness); + + [progress release]; + + [pool drain]; +} + +void QProgressIndicatorSpinning::animate(bool animate) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + if (animate) + [pimpl->nsProgressIndicator startAnimation:nil]; + else + [pimpl->nsProgressIndicator stopAnimation:nil]; +} diff --git a/qprogressindicatorspinning_nonmac.cpp b/qprogressindicatorspinning_nonmac.cpp new file mode 100644 index 000000000..6cbded6c1 --- /dev/null +++ b/qprogressindicatorspinning_nonmac.cpp @@ -0,0 +1,72 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qprogressindicatorspinning.h" + +#include +#include +#include + +class QProgressIndicatorSpinningPrivate : public QObject +{ +public: + QProgressIndicatorSpinningPrivate(QProgressIndicatorSpinning *qProgressIndicatorSpinning, + QMovie *movie) + : QObject(qProgressIndicatorSpinning), movie(movie) {} + + QPointer movie; +}; + +QProgressIndicatorSpinning::QProgressIndicatorSpinning(QWidget *parent, + Thickness thickness) + : QWidget(parent) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + + QSize size(thickness, thickness); + QMovie *movie = new QMovie(this); + movie->setFileName(":/Qocoa/qprogressindicatorspinning_nonmac.gif"); + movie->setScaledSize(size); + // Roughly match OSX speed. + movie->setSpeed(200); + pimpl = new QProgressIndicatorSpinningPrivate(this, movie); + + QLabel *label = new QLabel(this); + label->setMovie(movie); + + layout->addWidget(label); + setFixedSize(size); +} + + +void QProgressIndicatorSpinning::animate(bool animate) +{ + Q_ASSERT(pimpl && pimpl->movie); + if (!(pimpl && pimpl->movie)) + return; + + if (animate) + pimpl->movie->start(); + else + pimpl->movie->stop(); +} diff --git a/qprogressindicatorspinning_nonmac.gif b/qprogressindicatorspinning_nonmac.gif new file mode 100644 index 0000000000000000000000000000000000000000..3288d1035d70bb86517e2c233f1a904e41f06b29 GIT binary patch literal 3208 zcmc(iX;4#H9>pJdFE7h`I{IF)0|5<6L}(j=N}5%L009EB2nYfyF)E0PvIqo$u!IC; z4PgyY5|S9AEh38G)(9eq4TbH7_UHg@yWrlIJ$6smIADL7s^P;_O;ykRc9soXl`UC*LwQJXkii*0rx|*7rI2=x7WaRkx_~XZqFJ8R3c=2Kg zf@aSAv8+BJ8+^hyay>(QR@t*blbKzsf0}bscEqRc5Hd3o(-N5RyW=zWB*zQw6Zh>* z2CROCDAbu#D`)S|J_o(lL9Yn3l*+8RdiRD_>iNz$#_IAzCna&Wl5 zSF_(rRCDD!wi#i8oAm&jYtn2_@VB%2-H*G%bN#|(6R6N?wM)3u`PiGzwuX7qmTgyF zpE)h0kuoxQ9?=kW7Y!=R@DmhU9)vwT*EZWzJ zrt+=2tqFts72yIp?|gvdLhs8Hfku^Z(){gmN%Y=K#P|%fkvgUj~HfIp3CuXqCtYGtJ#me+n+-LmP( z*XNuk%!aH8bIE@_Bj46>M*dSro|7<6vZ7WUHh5YQzN$>IJFqCb|CT!wj~R2C2%=q{ zpt8rzY$aw?W?=Ustv{jo?Ow@ZRkLe<)NItY>Cyhle*wR59dTdF6(@{5^ zAQBOB*hNtc3bkY-8{Cm$nFS@elbTtSqrt7MB{h_4y+~`!mVa}?c&N>&?P}GqdMuhQ z&@TD5Czd((DcG_Su~dKKV)Pj$-qi1WHM8_vc^O4?^!oY|tmK~i!{fjd&@_1E(T~r7 z_REZy&hMT^ySJB3W7l$4YhR`M(J7S5S~+4Q&3HPa)z%zPpisOp$^ zTEe99ig2$5_qFr!$;7A6CJ}PJmRhli>w?LC}Y`#HLGy6 zMU4EhL~dKCN5Ut;U2jd*83ShBNiu zcJB0l9>1Modc?-oM<R4?}3g}UJ%@K);kriq>)e*rh%hdqM)5Q)*+O8 zXm;SEbs@koiYS!9YXIclSg+5m_s~yrW#kKMdiRszg(gCP5HPmP7L)vCf8@fxUh6qY z@Z#TmkjzAZX{rwE+q|K~F2v5{_@vt%>yT_a#fF03SFt{0RXvDAiaY~K9CgS1O>frXgAjBCS}mEd4mIWZ$=ovd5| zR?GRdU}d6+Q`+JRW)|=v7$)XNkn3yE`!nAiSCvOB1jKT zG<1aK3s<0b0m==egTD#8i(Of=1pGDTOCho0XpIOMQ&P87cVKY1W=C6kIg z9cH=@a&zbm2+`|{(_?YC9fdm?1TY~-pwlBn?>=(~1pDKbco6jloP;0-cqRiwV1A_S zEyV0Dj8Pwy!nekzaN>{)7rgZ&_QLxK{~1yRe865^yx>}+a!ECd>#MMwddow z@CU{l+Rt$xuXuf}?ga{3IAr?Raql^c@a%sI0U5m}HvJ5O1#I%_MMPt#BH>OqUZ{-k zt>4Xzz=%jT*FVW(uYkWyx}9Gw$HdN*qU?Bit#ji(Wi7p-u|_8?h^%szIS^s^fNM}b zgGy>|=cbEufpguY5_6w~&ZLv=Bo06UF9EYIY;Er-1VK)SyF&!|J{axiE1z^(hXwVq zsFS=K-#zC}CcOs^8W{KAt+kK)jYDgDYbCXv{{rwsgqtIU3<910$CJi)s?? z_t8k{>7*0~4l~LLF7$WXT5OSq5QCTbP_l!SN|{R}3D&eWA8~0ltWh1IL+ZBX4rRSt zWF6Om3WDMu4xK^1(BF`2cL}rUCzhHAB`@j5&R-yk_l*t;mPGY|u2^o|myvcOdrg0W z%=lX;f^Vkqfp?u7*4qQq%A3Mpf!xspWBSKS@O%r*TSM}?dl(@*%{0Jm_8;(h{R__M Bt + + qprogressindicatorspinning_nonmac.gif + + diff --git a/qsearchfield.h b/qsearchfield.h new file mode 100644 index 000000000..5abf4986a --- /dev/null +++ b/qsearchfield.h @@ -0,0 +1,48 @@ +#ifndef QSEARCHFIELD_H +#define QSEARCHFIELD_H + +#include +#include +#include + +class QSearchFieldPrivate; +class QSearchField : public QWidget +{ + Q_OBJECT + + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true); + Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText); + +public: + explicit QSearchField(QWidget *parent); + + QString text() const; + QString placeholderText() const; + void setFocus(Qt::FocusReason); + void setMenu(QMenu *menu); + +public slots: + void setText(const QString &text); + void setPlaceholderText(const QString &text); + void clear(); + void selectAll(); + void setFocus(); + +signals: + void textChanged(const QString &text); + void editingFinished(); + void returnPressed(); + +private slots: + void popupMenu(); + +protected: + void changeEvent(QEvent*); + void resizeEvent(QResizeEvent*); + +private: + friend class QSearchFieldPrivate; + QPointer pimpl; +}; + +#endif // QSEARCHFIELD_H diff --git a/qsearchfield_mac.mm b/qsearchfield_mac.mm new file mode 100644 index 000000000..345ee7848 --- /dev/null +++ b/qsearchfield_mac.mm @@ -0,0 +1,262 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qsearchfield.h" + +#include "qocoa_mac.h" + +#import "Foundation/NSAutoreleasePool.h" +#import "Foundation/NSNotification.h" +#import "AppKit/NSSearchField.h" + +#include +#include + +#define KEYCODE_A 0 +#define KEYCODE_X 7 +#define KEYCODE_C 8 +#define KEYCODE_V 9 + +class QSearchFieldPrivate : public QObject +{ +public: + QSearchFieldPrivate(QSearchField *qSearchField, NSSearchField *nsSearchField) + : QObject(qSearchField), qSearchField(qSearchField), nsSearchField(nsSearchField) {} + + void textDidChange(const QString &text) + { + if (qSearchField) + emit qSearchField->textChanged(text); + } + + void textDidEndEditing() + { + if (qSearchField) + emit qSearchField->editingFinished(); + } + + void returnPressed() + { + if (qSearchField) + emit qSearchField->returnPressed(); + } + + QPointer qSearchField; + NSSearchField *nsSearchField; +}; + +@interface QSearchFieldDelegate : NSObject +{ +@public + QPointer pimpl; +} +-(void)controlTextDidChange:(NSNotification*)notification; +-(void)controlTextDidEndEditing:(NSNotification*)notification; +@end + +@implementation QSearchFieldDelegate +-(void)controlTextDidChange:(NSNotification*)notification { + Q_ASSERT(pimpl); + if (pimpl) + pimpl->textDidChange(toQString([[notification object] stringValue])); +} + +-(void)controlTextDidEndEditing:(NSNotification*)notification { + Q_UNUSED(notification); + // No Q_ASSERT here as it is called on destruction. + if (pimpl) + pimpl->textDidEndEditing(); + + if ([[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement) + pimpl->returnPressed(); +} +@end + +@interface QocoaSearchField : NSSearchField +-(BOOL)performKeyEquivalent:(NSEvent*)event; +@end + +@implementation QocoaSearchField +-(BOOL)performKeyEquivalent:(NSEvent*)event { + if ([event type] == NSKeyDown && [event modifierFlags] & NSCommandKeyMask) + { + const unsigned short keyCode = [event keyCode]; + if (keyCode == KEYCODE_A) + { + [self performSelector:@selector(selectText:)]; + return YES; + } + else if (keyCode == KEYCODE_C) + { + QClipboard* clipboard = QApplication::clipboard(); + clipboard->setText(toQString([self stringValue])); + return YES; + } + else if (keyCode == KEYCODE_V) + { + QClipboard* clipboard = QApplication::clipboard(); + [self setStringValue:fromQString(clipboard->text())]; + return YES; + } + else if (keyCode == KEYCODE_X) + { + QClipboard* clipboard = QApplication::clipboard(); + clipboard->setText(toQString([self stringValue])); + [self setStringValue:@""]; + return YES; + } + } + + return NO; +} +@end + +QSearchField::QSearchField(QWidget *parent) : QWidget(parent) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSSearchField *search = [[QocoaSearchField alloc] init]; + + QSearchFieldDelegate *delegate = [[QSearchFieldDelegate alloc] init]; + pimpl = delegate->pimpl = new QSearchFieldPrivate(this, search); + [search setDelegate:delegate]; + + setupLayout(search, this); + + setFixedHeight(24); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + + [search release]; + + [pool drain]; +} + +void QSearchField::setMenu(QMenu *menu) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + NSMenu *nsMenu = menu->macMenu(); +#else + NSMenu *nsMenu = menu->toNSMenu(); +#endif + + [[pimpl->nsSearchField cell] setSearchMenuTemplate:nsMenu]; +} + +void QSearchField::popupMenu() +{ +} + +void QSearchField::setText(const QString &text) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [pimpl->nsSearchField setStringValue:fromQString(text)]; + [pool drain]; +} + +void QSearchField::setPlaceholderText(const QString &text) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[pimpl->nsSearchField cell] setPlaceholderString:fromQString(text)]; + [pool drain]; +} + +void QSearchField::clear() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + [pimpl->nsSearchField setStringValue:@""]; + emit textChanged(QString()); +} + +void QSearchField::selectAll() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + [pimpl->nsSearchField performSelector:@selector(selectText:)]; +} + +QString QSearchField::text() const +{ + Q_ASSERT(pimpl); + if (!pimpl) + return QString(); + + return toQString([pimpl->nsSearchField stringValue]); +} + +QString QSearchField::placeholderText() const +{ + Q_ASSERT(pimpl); + if (!pimpl) + return QString(); + + return toQString([[pimpl->nsSearchField cell] placeholderString]); +} + +void QSearchField::setFocus(Qt::FocusReason) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + if ([pimpl->nsSearchField acceptsFirstResponder]) + [[pimpl->nsSearchField window] makeFirstResponder: pimpl->nsSearchField]; +} + +void QSearchField::setFocus() +{ + setFocus(Qt::OtherFocusReason); +} + +void QSearchField::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::EnabledChange) { + Q_ASSERT(pimpl); + if (!pimpl) + return; + + const bool enabled = isEnabled(); + [pimpl->nsSearchField setEnabled: enabled]; + } + QWidget::changeEvent(event); +} + +void QSearchField::resizeEvent(QResizeEvent *resizeEvent) +{ + QWidget::resizeEvent(resizeEvent); +} diff --git a/qsearchfield_nonmac.cpp b/qsearchfield_nonmac.cpp new file mode 100644 index 000000000..d3315b853 --- /dev/null +++ b/qsearchfield_nonmac.cpp @@ -0,0 +1,256 @@ +/* +Copyright (C) 2011 by Mike McQuaid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "qsearchfield.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +class QSearchFieldPrivate : public QObject +{ +public: + QSearchFieldPrivate(QSearchField *searchField, QLineEdit *lineEdit, QToolButton *clearButton, QToolButton *searchButton) + : QObject(searchField), lineEdit(lineEdit), clearButton(clearButton), searchButton(searchButton) {} + + int lineEditFrameWidth() const { + return lineEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + } + + int clearButtonPaddedWidth() const { + return clearButton->width() + lineEditFrameWidth() * 2; + } + + int clearButtonPaddedHeight() const { + return clearButton->height() + lineEditFrameWidth() * 2; + } + + int searchButtonPaddedWidth() const { + return searchButton->width() + lineEditFrameWidth() * 2; + } + + int searchButtonPaddedHeight() const { + return searchButton->height() + lineEditFrameWidth() * 2; + } + + QPointer lineEdit; + QPointer clearButton; + QPointer searchButton; + QPointer searchMenu; +}; + +QSearchField::QSearchField(QWidget *parent) : QWidget(parent) +{ + QLineEdit *lineEdit = new QLineEdit(this); + connect(lineEdit, SIGNAL(textChanged(QString)), + this, SIGNAL(textChanged(QString))); + connect(lineEdit, SIGNAL(editingFinished()), + this, SIGNAL(editingFinished())); + connect(lineEdit, SIGNAL(returnPressed()), + this, SIGNAL(returnPressed())); + connect(lineEdit, SIGNAL(textChanged(QString)), + this, SLOT(setText(QString))); + + int iconsize = style()->pixelMetric(QStyle::PM_SmallIconSize); + QToolButton *clearButton = new QToolButton(this); + QIcon clearIcon = QIcon::fromTheme(QLatin1String("edit-clear"), + QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_clear.png"))); + clearButton->setIcon(clearIcon); + clearButton->setIconSize(QSize(iconsize, iconsize)); + clearButton->setFixedSize(QSize(iconsize, iconsize)); + clearButton->setStyleSheet("border: none;"); + clearButton->hide(); + connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); + + QToolButton *searchButton = new QToolButton(this); + QIcon searchIcon = QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier.png")); + searchButton->setIcon(searchIcon); + searchButton->setIconSize(QSize(iconsize, iconsize)); + searchButton->setFixedSize(QSize(iconsize, iconsize)); + searchButton->setStyleSheet("border: none;"); + searchButton->setPopupMode(QToolButton::InstantPopup); + searchButton->setEnabled(false); + connect(searchButton, SIGNAL(clicked()), this, SLOT(popupMenu())); + + pimpl = new QSearchFieldPrivate(this, lineEdit, clearButton, searchButton); + + lineEdit->setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; } ") + .arg(pimpl->searchButtonPaddedWidth()) + .arg(pimpl->clearButtonPaddedWidth())); + const int width = qMax(lineEdit->minimumSizeHint().width(), pimpl->clearButtonPaddedWidth() + pimpl->searchButtonPaddedWidth()); + const int height = qMax(lineEdit->minimumSizeHint().height(), + qMax(pimpl->clearButtonPaddedHeight(), + pimpl->searchButtonPaddedHeight())); + lineEdit->setMinimumSize(width, height); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->addWidget(lineEdit); +} + +void QSearchField::setMenu(QMenu *menu) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + pimpl->searchMenu = menu; + + QIcon searchIcon = menu ? QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier_menu.png")) + : QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier.png")); + pimpl->searchButton->setIcon(searchIcon); + pimpl->searchButton->setEnabled(isEnabled() && menu); +} + +void QSearchField::popupMenu() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + if (pimpl->searchMenu) { + const QRect screenRect = qApp->desktop()->availableGeometry(pimpl->searchButton); + const QSize sizeHint = pimpl->searchMenu->sizeHint(); + const QRect rect = pimpl->searchButton->rect(); + const int x = pimpl->searchButton->isRightToLeft() + ? rect.right() - sizeHint.width() + : rect.left(); + const int y = pimpl->searchButton->mapToGlobal(QPoint(0, rect.bottom())).y() + sizeHint.height() <= screenRect.height() + ? rect.bottom() + : rect.top() - sizeHint.height(); + QPoint point = pimpl->searchButton->mapToGlobal(QPoint(x, y)); + point.rx() = qMax(screenRect.left(), qMin(point.x(), screenRect.right() - sizeHint.width())); + point.ry() += 1; + + pimpl->searchMenu->popup(point); + } +} + +void QSearchField::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::EnabledChange) { + Q_ASSERT(pimpl); + if (!pimpl) + return; + + const bool enabled = isEnabled(); + pimpl->searchButton->setEnabled(enabled && pimpl->searchMenu); + pimpl->lineEdit->setEnabled(enabled); + pimpl->clearButton->setEnabled(enabled); + } + QWidget::changeEvent(event); +} + +void QSearchField::setText(const QString &text) +{ + Q_ASSERT(pimpl && pimpl->clearButton && pimpl->lineEdit); + if (!(pimpl && pimpl->clearButton && pimpl->lineEdit)) + return; + + pimpl->clearButton->setVisible(!text.isEmpty()); + + if (text != this->text()) + pimpl->lineEdit->setText(text); +} + +void QSearchField::setPlaceholderText(const QString &text) +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return; + +#if QT_VERSION >= 0x040700 + pimpl->lineEdit->setPlaceholderText(text); +#endif +} + +void QSearchField::clear() +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return; + + pimpl->lineEdit->clear(); +} + +void QSearchField::selectAll() +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return; + + pimpl->lineEdit->selectAll(); +} + +QString QSearchField::text() const +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return QString(); + + return pimpl->lineEdit->text(); +} + +QString QSearchField::placeholderText() const { + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return QString(); + +#if QT_VERSION >= 0x040700 + return pimpl->lineEdit->placeholderText(); +#else + return QString(); +#endif +} + +void QSearchField::setFocus(Qt::FocusReason reason) +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (pimpl && pimpl->lineEdit) + pimpl->lineEdit->setFocus(reason); +} + +void QSearchField::setFocus() +{ + setFocus(Qt::OtherFocusReason); +} + +void QSearchField::resizeEvent(QResizeEvent *resizeEvent) +{ + Q_ASSERT(pimpl && pimpl->clearButton && pimpl->lineEdit); + if (!(pimpl && pimpl->clearButton && pimpl->lineEdit)) + return; + + QWidget::resizeEvent(resizeEvent); + const int x = width() - pimpl->clearButtonPaddedWidth(); + const int y = (height() - pimpl->clearButton->height())/2; + pimpl->clearButton->move(x, y); + + pimpl->searchButton->move(pimpl->lineEditFrameWidth() * 2, + (height() - pimpl->searchButton->height())/2); +} diff --git a/qsearchfield_nonmac.qrc b/qsearchfield_nonmac.qrc new file mode 100644 index 000000000..68b570d5b --- /dev/null +++ b/qsearchfield_nonmac.qrc @@ -0,0 +1,7 @@ + + + qsearchfield_nonmac_clear.png + qsearchfield_nonmac_magnifier_menu.png + qsearchfield_nonmac_magnifier.png + + diff --git a/qsearchfield_nonmac_clear.png b/qsearchfield_nonmac_clear.png new file mode 100644 index 0000000000000000000000000000000000000000..ec52c41bc2fbba0bcc2b30a96267d73be240dc13 GIT binary patch literal 736 zcmV<60w4W}P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igQ1 z5H}Q?5;Tqg00Ll1L_t(I%dL~KP8(SihQGOU@A%G)jYu&WzH`%nmEB~k%_)!0|LN%b|AGHm z-oG2$+uQ3>$}P|HIzosRKvh)}=iL2bvG{s(bCdlipx5iYRZ9ISrA(Dl2qAa@V2ok0 zSUehIK3`v7e|gpTKZ>>1@8dXrQ?J*FLsS(ar>K(E(Z z55w?XqtSR%uh-e%-)A2ykxBqT|~bUI}?98#7gQc7NC zTL2Qk_kDyA_`XjZ$7rp8@_S`v1>g5^&Mjw`8#w1C&N-~L#Bt1EFre9NlIJ;jp3`hL z84L!*ag4PV=N!(t$r4ai)xEVAV+`GHmo!ZokH_@;efs@ACb6=jZ2N{*lDHySr?2bF=h)KM8`M z@ne)p>7~2_ZUoUdwwqvaRgBnVYW{7Z(}7v%UkVf%q@6 SqLyO-0000Dhf?ouWA>yZ`s+BBx=){u((%TpyhhRjALHT2ckQc&d4&) z-n7Bm;H*K-pZ^kn7Mb{N&z!|jAk+T(YZimV`=g(K?qPLwkZ5DrlIwl{`;^p7iT5tI zx9yD4vv!!4s&o3#!*q*2WiQPZ0c-805^anh>)KKyITY=T68yi}@UJypmicbY)??rQ z+E&g>&)Y8jdRLLvT!xHUZR=iZbUpf-AmV!aZ=JhW=j&ZIa{LT^$CW)N?OE3SxI+54 wpr&f&y!tagmpaE@|F2cIdey48=Y>A7G=&6K*=^zp26~sl)78&qol`;+0Ic(R)c^nh literal 0 HcmV?d00001 diff --git a/qsearchfield_nonmac_magnifier_menu.png b/qsearchfield_nonmac_magnifier_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..0e652c945e4287939e4787cd02c891c50238c64a GIT binary patch literal 439 zcmV;o0Z9IdP)e+J+88IQ+ODwU{IDgdn4Yj(RG-ELPU zlgZB|=kxg)CX$;ex$!IiEsZ@$z hOGL13`%eoV{s($5(uCrFlfnQ1002ovPDHLkV1gsuzk~n) literal 0 HcmV?d00001 From 0c33019f936af4a11c5c0c6d148bc0fa353875a1 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 15:28:33 +0000 Subject: [PATCH 31/51] Fixed building of qocoa subtree. --- src/gui/qocoa/CMakeLists.txt | 28 ++++++++++++---------- src/gui/qocoa/qbutton.h | 4 ++-- src/gui/qocoa/qbutton_mac.mm | 2 +- src/gui/qocoa/qprogressindicatorspinning.h | 2 +- src/gui/qocoa/qsearchfield.h | 6 ++--- src/gui/qocoa/qsearchfield_mac.mm | 8 +++---- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/gui/qocoa/CMakeLists.txt b/src/gui/qocoa/CMakeLists.txt index 513f81f7d..c1dcdce35 100644 --- a/src/gui/qocoa/CMakeLists.txt +++ b/src/gui/qocoa/CMakeLists.txt @@ -1,16 +1,16 @@ project(Qocoa) cmake_minimum_required(VERSION 2.8) -find_package(Qt4 COMPONENTS QtMain QtCore QtGui REQUIRED) -include(UseQt4) +#find_package(Qt4 COMPONENTS QtMain QtCore QtGui REQUIRED) +#include(UseQt4) set(SOURCES - main.cpp - gallery.cpp + #main.cpp + #gallery.cpp ) set(HEADERS - gallery.h + #gallery.h qsearchfield.h qbutton.h qprogressindicatorspinning.h @@ -37,12 +37,14 @@ else() qt4_add_resources(RESOURCES_SOURCES ${RESOURCES}) endif() -add_executable(Qocoa - WIN32 MACOSX_BUNDLE - ${SOURCES} ${MOC_SOURCES} ${RESOURCES_SOURCES} -) -target_link_libraries(Qocoa ${QT_LIBRARIES}) +#add_executable(Qocoa +# WIN32 MACOSX_BUNDLE +# ${SOURCES} ${MOC_SOURCES} ${RESOURCES_SOURCES} +#) +#target_link_libraries(Qocoa ${QT_LIBRARIES}) -if(APPLE) - set_target_properties(Qocoa PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit") -endif() +add_library (Qocoa STATIC ${SOURCES} ${MOC_SOURCES} ${HEADERS} ${RESOURCES_SOURCES}) + +#if(APPLE) +# set_target_properties(Qocoa PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit") +#endif() diff --git a/src/gui/qocoa/qbutton.h b/src/gui/qocoa/qbutton.h index 93e598f80..c84ad73fd 100644 --- a/src/gui/qocoa/qbutton.h +++ b/src/gui/qocoa/qbutton.h @@ -30,7 +30,7 @@ public: explicit QButton(QWidget *parent, BezelStyle bezelStyle = Rounded); -public slots: +public Q_SLOTS: void setText(const QString &text); void setImage(const QPixmap &image); void setChecked(bool checked); @@ -39,7 +39,7 @@ public: void setCheckable(bool checkable); bool isChecked(); -signals: +Q_SIGNALS: void clicked(bool checked = false); private: diff --git a/src/gui/qocoa/qbutton_mac.mm b/src/gui/qocoa/qbutton_mac.mm index 15490e453..dccc771ac 100644 --- a/src/gui/qocoa/qbutton_mac.mm +++ b/src/gui/qocoa/qbutton_mac.mm @@ -137,7 +137,7 @@ public: void clicked() { - emit qButton->clicked(qButton->isChecked()); + Q_EMIT qButton->clicked(qButton->isChecked()); } ~QButtonPrivate() { diff --git a/src/gui/qocoa/qprogressindicatorspinning.h b/src/gui/qocoa/qprogressindicatorspinning.h index ae40a92a2..17b20e44d 100644 --- a/src/gui/qocoa/qprogressindicatorspinning.h +++ b/src/gui/qocoa/qprogressindicatorspinning.h @@ -19,7 +19,7 @@ public: explicit QProgressIndicatorSpinning(QWidget *parent, Thickness thickness = Default); -public slots: +public Q_SLOTS: void animate(bool animate = true); private: friend class QProgressIndicatorSpinningPrivate; diff --git a/src/gui/qocoa/qsearchfield.h b/src/gui/qocoa/qsearchfield.h index 5abf4986a..4d012cd06 100644 --- a/src/gui/qocoa/qsearchfield.h +++ b/src/gui/qocoa/qsearchfield.h @@ -21,19 +21,19 @@ public: void setFocus(Qt::FocusReason); void setMenu(QMenu *menu); -public slots: +public Q_SLOTS: void setText(const QString &text); void setPlaceholderText(const QString &text); void clear(); void selectAll(); void setFocus(); -signals: +Q_SIGNALS: void textChanged(const QString &text); void editingFinished(); void returnPressed(); -private slots: +private Q_SLOTS: void popupMenu(); protected: diff --git a/src/gui/qocoa/qsearchfield_mac.mm b/src/gui/qocoa/qsearchfield_mac.mm index 345ee7848..01d55937c 100644 --- a/src/gui/qocoa/qsearchfield_mac.mm +++ b/src/gui/qocoa/qsearchfield_mac.mm @@ -45,19 +45,19 @@ public: void textDidChange(const QString &text) { if (qSearchField) - emit qSearchField->textChanged(text); + Q_EMIT qSearchField->textChanged(text); } void textDidEndEditing() { if (qSearchField) - emit qSearchField->editingFinished(); + Q_EMIT qSearchField->editingFinished(); } void returnPressed() { if (qSearchField) - emit qSearchField->returnPressed(); + Q_EMIT qSearchField->returnPressed(); } QPointer qSearchField; @@ -198,7 +198,7 @@ void QSearchField::clear() return; [pimpl->nsSearchField setStringValue:@""]; - emit textChanged(QString()); + Q_EMIT textChanged(QString()); } void QSearchField::selectAll() From e105970945fad04e2bf0fe9d3d39108559492c47 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 15:30:55 +0000 Subject: [PATCH 32/51] Removed qjson so we can replace it with a subtree. --- src/http/qjson/CMakeLists.txt | 28 - src/http/qjson/FlexLexer.h | 206 -- src/http/qjson/README.license | 89 - src/http/qjson/json_parser.cc | 1103 ------ src/http/qjson/json_parser.hh | 300 -- src/http/qjson/json_parser.yy | 162 - src/http/qjson/json_scanner.cc | 4507 ------------------------- src/http/qjson/json_scanner.cpp | 75 - src/http/qjson/json_scanner.h | 60 - src/http/qjson/json_scanner.yy | 248 -- src/http/qjson/location.hh | 181 - src/http/qjson/parser.cpp | 125 - src/http/qjson/parser.h | 99 - src/http/qjson/parser_p.h | 56 - src/http/qjson/parserrunnable.cpp | 68 - src/http/qjson/parserrunnable.h | 64 - src/http/qjson/position.hh | 172 - src/http/qjson/qjson_debug.h | 34 - src/http/qjson/qjson_export.h | 35 - src/http/qjson/qobjecthelper.cpp | 94 - src/http/qjson/qobjecthelper.h | 157 - src/http/qjson/serializer.cpp | 410 --- src/http/qjson/serializer.h | 191 -- src/http/qjson/serializerrunnable.cpp | 62 - src/http/qjson/serializerrunnable.h | 71 - src/http/qjson/stack.hh | 133 - 26 files changed, 8730 deletions(-) delete mode 100644 src/http/qjson/CMakeLists.txt delete mode 100644 src/http/qjson/FlexLexer.h delete mode 100644 src/http/qjson/README.license delete mode 100644 src/http/qjson/json_parser.cc delete mode 100644 src/http/qjson/json_parser.hh delete mode 100644 src/http/qjson/json_parser.yy delete mode 100644 src/http/qjson/json_scanner.cc delete mode 100644 src/http/qjson/json_scanner.cpp delete mode 100644 src/http/qjson/json_scanner.h delete mode 100644 src/http/qjson/json_scanner.yy delete mode 100644 src/http/qjson/location.hh delete mode 100644 src/http/qjson/parser.cpp delete mode 100644 src/http/qjson/parser.h delete mode 100644 src/http/qjson/parser_p.h delete mode 100644 src/http/qjson/parserrunnable.cpp delete mode 100644 src/http/qjson/parserrunnable.h delete mode 100644 src/http/qjson/position.hh delete mode 100644 src/http/qjson/qjson_debug.h delete mode 100644 src/http/qjson/qjson_export.h delete mode 100644 src/http/qjson/qobjecthelper.cpp delete mode 100644 src/http/qjson/qobjecthelper.h delete mode 100644 src/http/qjson/serializer.cpp delete mode 100644 src/http/qjson/serializer.h delete mode 100644 src/http/qjson/serializerrunnable.cpp delete mode 100644 src/http/qjson/serializerrunnable.h delete mode 100644 src/http/qjson/stack.hh diff --git a/src/http/qjson/CMakeLists.txt b/src/http/qjson/CMakeLists.txt deleted file mode 100644 index e51a62fd7..000000000 --- a/src/http/qjson/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# add_custom_command (OUTPUT ${qjson_SOURCE_DIR}/lib/json_parser.cc -# PRE_BUILD -# COMMAND bison -t -o json_parser.cc -d json_parser.yy -# DEPENDS json_parser.yy -# WORKING_DIRECTORY ${qjson_SOURCE_DIR}/lib/ -# ) - -# To regenerate json_scanner.cc use: -# flex json_scanner.yy - -set(qjson_MOC_HDRS - parserrunnable.h - serializerrunnable.h -) - -IF (NOT Qt5Core_FOUND) - qt4_wrap_cpp(qjson_MOC_SRCS ${qjson_MOC_HDRS}) -ENDIF() - -set (qjson_SRCS parser.cpp qobjecthelper.cpp json_scanner.cpp json_parser.cc parserrunnable.cpp serializer.cpp serializerrunnable.cpp) -set (qjson_HEADERS parser.h parserrunnable.h qobjecthelper.h serializer.h serializerrunnable.h qjson_export.h) - -# Required to use the intree copy of FlexLexer.h -INCLUDE_DIRECTORIES(.) - -add_gcc_compiler_cxxflags("-fexceptions") -remove_definitions(-DQT_NO_KEYWORDS) -add_library (qjson STATIC ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS}) diff --git a/src/http/qjson/FlexLexer.h b/src/http/qjson/FlexLexer.h deleted file mode 100644 index bad4ce03f..000000000 --- a/src/http/qjson/FlexLexer.h +++ /dev/null @@ -1,206 +0,0 @@ -// -*-C++-*- -// FlexLexer.h -- define interfaces for lexical analyzer classes generated -// by flex - -// Copyright (c) 1993 The Regents of the University of California. -// All rights reserved. -// -// This code is derived from software contributed to Berkeley by -// Kent Williams and Tom Epperly. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: - -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. - -// Neither the name of the University nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. - -// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE. - -// This file defines FlexLexer, an abstract class which specifies the -// external interface provided to flex C++ lexer objects, and yyFlexLexer, -// which defines a particular lexer class. -// -// If you want to create multiple lexer classes, you use the -P flag -// to rename each yyFlexLexer to some other xxFlexLexer. You then -// include in your other sources once per lexer class: -// -// #undef yyFlexLexer -// #define yyFlexLexer xxFlexLexer -// #include -// -// #undef yyFlexLexer -// #define yyFlexLexer zzFlexLexer -// #include -// ... - -#ifndef __FLEX_LEXER_H -// Never included before - need to define base class. -#define __FLEX_LEXER_H - -#include -# ifndef FLEX_STD -# define FLEX_STD std:: -# endif - -extern "C++" { - -struct yy_buffer_state; -typedef int yy_state_type; - -class FlexLexer { -public: - virtual ~FlexLexer() { } - - const char* YYText() const { return yytext; } - int YYLeng() const { return yyleng; } - - virtual void - yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; - virtual struct yy_buffer_state* - yy_create_buffer( FLEX_STD istream* s, int size ) = 0; - virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; - virtual void yyrestart( FLEX_STD istream* s ) = 0; - - virtual int yylex() = 0; - - // Call yylex with new input/output sources. - int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ) - { - switch_streams( new_in, new_out ); - return yylex(); - } - - // Switch to new input/output streams. A nil stream pointer - // indicates "keep the current one". - virtual void switch_streams( FLEX_STD istream* new_in = 0, - FLEX_STD ostream* new_out = 0 ) = 0; - - int lineno() const { return yylineno; } - - int debug() const { return yy_flex_debug; } - void set_debug( int flag ) { yy_flex_debug = flag; } - -protected: - char* yytext; - int yyleng; - int yylineno; // only maintained if you use %option yylineno - int yy_flex_debug; // only has effect with -d or "%option debug" -}; - -} -#endif // FLEXLEXER_H - -#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) -// Either this is the first time through (yyFlexLexerOnce not defined), -// or this is a repeated include to define a different flavor of -// yyFlexLexer, as discussed in the flex manual. -#define yyFlexLexerOnce - -extern "C++" { - -class yyFlexLexer : public FlexLexer { -public: - // arg_yyin and arg_yyout default to the cin and cout, but we - // only make that assignment when initializing in yylex(). - yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 ); - - virtual ~yyFlexLexer(); - - void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); - struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size ); - void yy_delete_buffer( struct yy_buffer_state* b ); - void yyrestart( FLEX_STD istream* s ); - - void yypush_buffer_state( struct yy_buffer_state* new_buffer ); - void yypop_buffer_state(); - - virtual int yylex(); - virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ); - virtual int yywrap(); - -protected: - virtual int LexerInput( char* buf, int max_size ); - virtual void LexerOutput( const char* buf, int size ); - virtual void LexerError( const char* msg ); - - void yyunput( int c, char* buf_ptr ); - int yyinput(); - - void yy_load_buffer_state(); - void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s ); - void yy_flush_buffer( struct yy_buffer_state* b ); - - int yy_start_stack_ptr; - int yy_start_stack_depth; - int* yy_start_stack; - - void yy_push_state( int new_state ); - void yy_pop_state(); - int yy_top_state(); - - yy_state_type yy_get_previous_state(); - yy_state_type yy_try_NUL_trans( yy_state_type current_state ); - int yy_get_next_buffer(); - - FLEX_STD istream* yyin; // input source for default LexerInput - FLEX_STD ostream* yyout; // output sink for default LexerOutput - - // yy_hold_char holds the character lost when yytext is formed. - char yy_hold_char; - - // Number of characters read into yy_ch_buf. - int yy_n_chars; - - // Points to current character in buffer. - char* yy_c_buf_p; - - int yy_init; // whether we need to initialize - int yy_start; // start state number - - // Flag which is used to allow yywrap()'s to do buffer switches - // instead of setting up a fresh yyin. A bit of a hack ... - int yy_did_buffer_switch_on_eof; - - - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ - void yyensure_buffer_stack(void); - - // The following are not always needed, but may be depending - // on use of certain flex features (like REJECT or yymore()). - - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - yy_state_type* yy_state_buf; - yy_state_type* yy_state_ptr; - - char* yy_full_match; - int* yy_full_state; - int yy_full_lp; - - int yy_lp; - int yy_looking_for_trail_begin; - - int yy_more_flag; - int yy_more_len; - int yy_more_offset; - int yy_prev_more_offset; -}; - -} - -#endif // yyFlexLexer || ! yyFlexLexerOnce - diff --git a/src/http/qjson/README.license b/src/http/qjson/README.license deleted file mode 100644 index 3ede31323..000000000 --- a/src/http/qjson/README.license +++ /dev/null @@ -1,89 +0,0 @@ -Qjson version xxxx, Date - -The following files are licensed under LGPL V2.1: ------------------------------------------------- -src/json_parser.yy -src/json_scanner.cpp -src/json_scanner.h -src/parser.cpp -src/parser.h -src/parser_p.h -src/parserrunnable.cpp -src/parserrunnable.h -src/qjson_debug.h -src/qjson_export.h -src/qobjecthelper.cpp -src/serializer.cpp -src/qobjecthelper.h -src/serializer.h -src/serializerrunnable.cpp -src/serializerrunnable.h -tests/cmdline_tester/cmdline_tester.cpp -tests/cmdline_tester/cmdlineparser.cpp -tests/cmdline_tester/cmdlineparser.h -tests/parser/testparser.cpp -tests/qobjecthelper/person.h -tests/qobjecthelper/testqobjecthelper.cpp -tests/serializer/testserializer.cpp - - -The following files are licensed under GPL V2 with Bison Exception: --------------------------------------------------------------------- -/src/json_parser.cc -/src/stack.hh -/src/location.hh -/src/position.hh -/src/json_parser.hh - - -Copyrights: ----------- -Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -Copyright (C) 2009 Flavio Castelli 2009 Frank Osterfeld -Copyright (C) 2008 Flavio Castelli -Copyright (C) 2009 Till Adam -Copyright (C) 2009 Michael Leupold -Copyright (C) 2009 Flavio Castelli -Copyright (C) 2009 Frank Osterfeld -Copyright (C) 2009 Pino Toscano -Copyright (C) 2010 Flavio Castelli - - -GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999: -------------------------------------------------------------- - -Checkout COPYING.lib - - -GPL V2 with Bison Exception: ----------------------------- -Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - -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, 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. - -As a special exception, you may create a larger work that contains -part or all of the Bison parser skeleton and distribute that work -under terms of your choice, so long as that work isn't itself a -parser generator using the skeleton or a modified version thereof -as a parser skeleton. Alternatively, if you modify or redistribute -the parser skeleton itself, you may (at your option) remove this -special exception, which will cause the skeleton and the resulting -Bison output files to be licensed under the GNU General Public -License without this special exception. - -This special exception was added by the Free Software Foundation in -version 2.2 of Bison. - diff --git a/src/http/qjson/json_parser.cc b/src/http/qjson/json_parser.cc deleted file mode 100644 index 84fdfac73..000000000 --- a/src/http/qjson/json_parser.cc +++ /dev/null @@ -1,1103 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.7. */ - -/* Skeleton implementation for Bison LALR(1) parsers in C++ - - Copyright (C) 2002-2012 Free Software Foundation, Inc. - - 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 3 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, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - - -/* First part of user declarations. */ - -/* Line 279 of lalr1.cc */ -#line 38 "json_parser.cc" - - -#include "json_parser.hh" - -/* User implementation prologue. */ - -/* Line 285 of lalr1.cc */ -#line 46 "json_parser.cc" - - -# ifndef YY_NULL -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr -# else -# define YY_NULL 0 -# endif -# endif - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* FIXME: INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -# ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).begin = YYRHSLOC (Rhs, 1).begin; \ - (Current).end = YYRHSLOC (Rhs, N).end; \ - } \ - else \ - { \ - (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ - } \ - while (/*CONSTCOND*/ false) -# endif - - -/* Suppress unused-variable warnings by "using" E. */ -#define YYUSE(e) ((void) (e)) - -/* Enable debugging if requested. */ -#if YYDEBUG - -/* A pseudo ostream that takes yydebug_ into account. */ -# define YYCDEBUG if (yydebug_) (*yycdebug_) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug_) \ - { \ - *yycdebug_ << Title << ' '; \ - yy_symbol_print_ ((Type), (Value), (Location)); \ - *yycdebug_ << std::endl; \ - } \ -} while (false) - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug_) \ - yy_reduce_print_ (Rule); \ -} while (false) - -# define YY_STACK_PRINT() \ -do { \ - if (yydebug_) \ - yystack_print_ (); \ -} while (false) - -#else /* !YYDEBUG */ - -# define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type) -# define YY_REDUCE_PRINT(Rule) static_cast(0) -# define YY_STACK_PRINT() static_cast(0) - -#endif /* !YYDEBUG */ - -#define yyerrok (yyerrstatus_ = 0) -#define yyclearin (yychar = yyempty_) - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab -#define YYRECOVERING() (!!yyerrstatus_) - - -namespace yy { -/* Line 353 of lalr1.cc */ -#line 141 "json_parser.cc" - - /* Return YYSTR after stripping away unnecessary quotes and - backslashes, so that it's suitable for yyerror. The heuristic is - that double-quoting is unnecessary unless the string contains an - apostrophe, a comma, or backslash (other than backslash-backslash). - YYSTR is taken from yytname. */ - std::string - json_parser::yytnamerr_ (const char *yystr) - { - if (*yystr == '"') - { - std::string yyr = ""; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - yyr += *yyp; - break; - - case '"': - return yyr; - } - do_not_strip_quotes: ; - } - - return yystr; - } - - - /// Build a parser object. - json_parser::json_parser (QJson::ParserPrivate* driver_yyarg) - : -#if YYDEBUG - yydebug_ (false), - yycdebug_ (&std::cerr), -#endif - driver (driver_yyarg) - { - } - - json_parser::~json_parser () - { - } - -#if YYDEBUG - /*--------------------------------. - | Print this symbol on YYOUTPUT. | - `--------------------------------*/ - - inline void - json_parser::yy_symbol_value_print_ (int yytype, - const semantic_type* yyvaluep, const location_type* yylocationp) - { - YYUSE (yylocationp); - YYUSE (yyvaluep); - std::ostream& yyo = debug_stream (); - std::ostream& yyoutput = yyo; - YYUSE (yyoutput); - switch (yytype) - { - default: - break; - } - } - - - void - json_parser::yy_symbol_print_ (int yytype, - const semantic_type* yyvaluep, const location_type* yylocationp) - { - *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") - << ' ' << yytname_[yytype] << " (" - << *yylocationp << ": "; - yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); - *yycdebug_ << ')'; - } -#endif - - void - json_parser::yydestruct_ (const char* yymsg, - int yytype, semantic_type* yyvaluep, location_type* yylocationp) - { - YYUSE (yylocationp); - YYUSE (yymsg); - YYUSE (yyvaluep); - - if (yymsg) - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } - } - - void - json_parser::yypop_ (unsigned int n) - { - yystate_stack_.pop (n); - yysemantic_stack_.pop (n); - yylocation_stack_.pop (n); - } - -#if YYDEBUG - std::ostream& - json_parser::debug_stream () const - { - return *yycdebug_; - } - - void - json_parser::set_debug_stream (std::ostream& o) - { - yycdebug_ = &o; - } - - - json_parser::debug_level_type - json_parser::debug_level () const - { - return yydebug_; - } - - void - json_parser::set_debug_level (debug_level_type l) - { - yydebug_ = l; - } -#endif - - inline bool - json_parser::yy_pact_value_is_default_ (int yyvalue) - { - return yyvalue == yypact_ninf_; - } - - inline bool - json_parser::yy_table_value_is_error_ (int yyvalue) - { - return yyvalue == yytable_ninf_; - } - - int - json_parser::parse () - { - /// Lookahead and lookahead in internal form. - int yychar = yyempty_; - int yytoken = 0; - - // State. - int yyn; - int yylen = 0; - int yystate = 0; - - // Error handling. - int yynerrs_ = 0; - int yyerrstatus_ = 0; - - /// Semantic value of the lookahead. - static semantic_type yyval_default; - semantic_type yylval = yyval_default; - /// Location of the lookahead. - location_type yylloc; - /// The locations where the error started and ended. - location_type yyerror_range[3]; - - /// $$. - semantic_type yyval; - /// @$. - location_type yyloc; - - int yyresult; - - // FIXME: This shoud be completely indented. It is not yet to - // avoid gratuitous conflicts when merging into the master branch. - try - { - YYCDEBUG << "Starting parse" << std::endl; - - - /* Initialize the stacks. The initial state will be pushed in - yynewstate, since the latter expects the semantical and the - location values to have been already stored, initialize these - stacks with a primary value. */ - yystate_stack_ = state_stack_type (0); - yysemantic_stack_ = semantic_stack_type (0); - yylocation_stack_ = location_stack_type (0); - yysemantic_stack_.push (yylval); - yylocation_stack_.push (yylloc); - - /* New state. */ - yynewstate: - yystate_stack_.push (yystate); - YYCDEBUG << "Entering state " << yystate << std::endl; - - /* Accept? */ - if (yystate == yyfinal_) - goto yyacceptlab; - - goto yybackup; - - /* Backup. */ - yybackup: - - /* Try to take a decision without lookahead. */ - yyn = yypact_[yystate]; - if (yy_pact_value_is_default_ (yyn)) - goto yydefault; - - /* Read a lookahead token. */ - if (yychar == yyempty_) - { - YYCDEBUG << "Reading a token: "; - yychar = yylex (&yylval, &yylloc, driver); - } - - /* Convert token to internal form. */ - if (yychar <= yyeof_) - { - yychar = yytoken = yyeof_; - YYCDEBUG << "Now at end of input." << std::endl; - } - else - { - yytoken = yytranslate_ (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) - goto yydefault; - - /* Reduce or error. */ - yyn = yytable_[yyn]; - if (yyn <= 0) - { - if (yy_table_value_is_error_ (yyn)) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the token being shifted. */ - yychar = yyempty_; - - yysemantic_stack_.push (yylval); - yylocation_stack_.push (yylloc); - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus_) - --yyerrstatus_; - - yystate = yyn; - goto yynewstate; - - /*-----------------------------------------------------------. - | yydefault -- do the default action for the current state. | - `-----------------------------------------------------------*/ - yydefault: - yyn = yydefact_[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - /*-----------------------------. - | yyreduce -- Do a reduction. | - `-----------------------------*/ - yyreduce: - yylen = yyr2_[yyn]; - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. Otherwise, use the top of the stack. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. */ - if (yylen) - yyval = yysemantic_stack_[yylen - 1]; - else - yyval = yysemantic_stack_[0]; - - // Compute the default @$. - { - slice slice (yylocation_stack_, yylen); - YYLLOC_DEFAULT (yyloc, slice, yylen); - } - - // Perform the reduction. - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: -/* Line 670 of lalr1.cc */ -#line 82 "json_parser.yy" - { - driver->m_result = (yysemantic_stack_[(1) - (1)]); - qjsonDebug() << "json_parser - parsing finished"; - } - break; - - case 3: -/* Line 670 of lalr1.cc */ -#line 87 "json_parser.yy" - { (yyval) = (yysemantic_stack_[(1) - (1)]); } - break; - - case 4: -/* Line 670 of lalr1.cc */ -#line 89 "json_parser.yy" - { - qCritical()<< "json_parser - syntax error found, " - << "forcing abort, Line" << (yyloc).begin.line << "Column" << (yyloc).begin.column; - YYABORT; - } - break; - - case 6: -/* Line 670 of lalr1.cc */ -#line 96 "json_parser.yy" - { - (yyval) = QVariant(QVariantMap()); - } - break; - - case 7: -/* Line 670 of lalr1.cc */ -#line 99 "json_parser.yy" - { - QVariantMap* map = (yysemantic_stack_[(3) - (2)]).value(); - (yyval) = QVariant(*map); - delete map; - } - break; - - case 8: -/* Line 670 of lalr1.cc */ -#line 105 "json_parser.yy" - { - QVariantMap* pair = new QVariantMap(); - pair->insert((yysemantic_stack_[(3) - (1)]).toString(), (yysemantic_stack_[(3) - (3)])); - (yyval).setValue(pair); - } - break; - - case 9: -/* Line 670 of lalr1.cc */ -#line 110 "json_parser.yy" - { - (yyval).value()->insert((yysemantic_stack_[(5) - (3)]).toString(), (yysemantic_stack_[(5) - (5)])); - } - break; - - case 10: -/* Line 670 of lalr1.cc */ -#line 114 "json_parser.yy" - { - (yyval) = QVariant(QVariantList()); - } - break; - - case 11: -/* Line 670 of lalr1.cc */ -#line 117 "json_parser.yy" - { - QVector* list = (yysemantic_stack_[(3) - (2)]).value* >(); - (yyval) = QVariant(list->toList()); - delete list; - } - break; - - case 12: -/* Line 670 of lalr1.cc */ -#line 123 "json_parser.yy" - { - QVector* list = new QVector(1); - list->replace(0, (yysemantic_stack_[(1) - (1)])); - (yyval).setValue(list); - } - break; - - case 13: -/* Line 670 of lalr1.cc */ -#line 128 "json_parser.yy" - { - (yyval).value* >()->append((yysemantic_stack_[(3) - (3)])); - } - break; - - -/* Line 670 of lalr1.cc */ -#line 549 "json_parser.cc" - default: - break; - } - - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action - invokes YYABORT, YYACCEPT, or YYERROR immediately after altering - yychar. In the case of YYABORT or YYACCEPT, an incorrect - destructor might then be invoked immediately. In the case of - YYERROR, subsequent parser actions might lead to an incorrect - destructor call or verbose syntax error message before the - lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); - - yypop_ (yylen); - yylen = 0; - YY_STACK_PRINT (); - - yysemantic_stack_.push (yyval); - yylocation_stack_.push (yyloc); - - /* Shift the result of the reduction. */ - yyn = yyr1_[yyn]; - yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; - if (0 <= yystate && yystate <= yylast_ - && yycheck_[yystate] == yystate_stack_[0]) - yystate = yytable_[yystate]; - else - yystate = yydefgoto_[yyn - yyntokens_]; - goto yynewstate; - - /*------------------------------------. - | yyerrlab -- here on detecting error | - `------------------------------------*/ - yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yytranslate_ (yychar); - - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus_) - { - ++yynerrs_; - if (yychar == yyempty_) - yytoken = yyempty_; - error (yylloc, yysyntax_error_ (yystate, yytoken)); - } - - yyerror_range[1] = yylloc; - if (yyerrstatus_ == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - if (yychar <= yyeof_) - { - /* Return failure if at end of input. */ - if (yychar == yyeof_) - YYABORT; - } - else - { - yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); - yychar = yyempty_; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - - /*---------------------------------------------------. - | yyerrorlab -- error raised explicitly by YYERROR. | - `---------------------------------------------------*/ - yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (false) - goto yyerrorlab; - - yyerror_range[1] = yylocation_stack_[yylen - 1]; - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - yypop_ (yylen); - yylen = 0; - yystate = yystate_stack_[0]; - goto yyerrlab1; - - /*-------------------------------------------------------------. - | yyerrlab1 -- common code for both syntax error and YYERROR. | - `-------------------------------------------------------------*/ - yyerrlab1: - yyerrstatus_ = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact_[yystate]; - if (!yy_pact_value_is_default_ (yyn)) - { - yyn += yyterror_; - if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) - { - yyn = yytable_[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yystate_stack_.height () == 1) - YYABORT; - - yyerror_range[1] = yylocation_stack_[0]; - yydestruct_ ("Error: popping", - yystos_[yystate], - &yysemantic_stack_[0], &yylocation_stack_[0]); - yypop_ (); - yystate = yystate_stack_[0]; - YY_STACK_PRINT (); - } - - yyerror_range[2] = yylloc; - // Using YYLLOC is tempting, but would change the location of - // the lookahead. YYLOC is available though. - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); - yysemantic_stack_.push (yylval); - yylocation_stack_.push (yyloc); - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], - &yysemantic_stack_[0], &yylocation_stack_[0]); - - yystate = yyn; - goto yynewstate; - - /* Accept. */ - yyacceptlab: - yyresult = 0; - goto yyreturn; - - /* Abort. */ - yyabortlab: - yyresult = 1; - goto yyreturn; - - yyreturn: - if (yychar != yyempty_) - { - /* Make sure we have latest lookahead translation. See comments - at user semantic actions for why this is necessary. */ - yytoken = yytranslate_ (yychar); - yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, - &yylloc); - } - - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - yypop_ (yylen); - while (1 < yystate_stack_.height ()) - { - yydestruct_ ("Cleanup: popping", - yystos_[yystate_stack_[0]], - &yysemantic_stack_[0], - &yylocation_stack_[0]); - yypop_ (); - } - - return yyresult; - } - catch (...) - { - YYCDEBUG << "Exception caught: cleaning lookahead and stack" - << std::endl; - // Do not try to display the values of the reclaimed symbols, - // as their printer might throw an exception. - if (yychar != yyempty_) - { - /* Make sure we have latest lookahead translation. See - comments at user semantic actions for why this is - necessary. */ - yytoken = yytranslate_ (yychar); - yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc); - } - - while (1 < yystate_stack_.height ()) - { - yydestruct_ (YY_NULL, - yystos_[yystate_stack_[0]], - &yysemantic_stack_[0], - &yylocation_stack_[0]); - yypop_ (); - } - throw; - } - } - - // Generate an error message. - std::string - json_parser::yysyntax_error_ (int yystate, int yytoken) - { - std::string yyres; - // Number of reported tokens (one for the "unexpected", one per - // "expected"). - size_t yycount = 0; - // Its maximum. - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - // Arguments of yyformat. - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yytoken) is - if this state is a consistent state with a default action. - Thus, detecting the absence of a lookahead is sufficient to - determine that there is no unexpected or expected token to - report. In that case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is - a consistent state with a default action. There might have - been a previous inconsistent state, consistent state with a - non-default action, or user semantic action that manipulated - yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state - merging (from LALR or IELR) and default reductions corrupt the - expected token list. However, the list is correct for - canonical LR with one exception: it will still contain any - token that will not be accepted due to an error action in a - later state. - */ - if (yytoken != yyempty_) - { - yyarg[yycount++] = yytname_[yytoken]; - int yyn = yypact_[yystate]; - if (!yy_pact_value_is_default_ (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = yylast_ - yyn + 1; - int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; - for (int yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ - && !yy_table_value_is_error_ (yytable_[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - break; - } - else - yyarg[yycount++] = yytname_[yyx]; - } - } - } - - char const* yyformat = YY_NULL; - switch (yycount) - { -#define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -#undef YYCASE_ - } - - // Argument number. - size_t yyi = 0; - for (char const* yyp = yyformat; *yyp; ++yyp) - if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) - { - yyres += yytnamerr_ (yyarg[yyi++]); - ++yyp; - } - else - yyres += *yyp; - return yyres; - } - - - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ - const signed char json_parser::yypact_ninf_ = -5; - const signed char - json_parser::yypact_[] = - { - 1, -5, -5, 3, 18, -5, -5, -5, -5, -5, - 8, -5, -5, -5, -5, -5, 2, 11, -5, -3, - -5, -5, 29, -5, 4, -5, 29, -5, 13, -5, - 29, -5 - }; - - /* YYDEFACT[S] -- default reduction number in state S. Performed when - YYTABLE doesn't specify something else to do. Zero means the - default is an error. */ - const unsigned char - json_parser::yydefact_[] = - { - 0, 5, 4, 0, 0, 15, 16, 17, 18, 14, - 0, 2, 19, 20, 3, 6, 0, 0, 10, 0, - 12, 1, 0, 7, 0, 11, 0, 8, 0, 13, - 0, 9 - }; - - /* YYPGOTO[NTERM-NUM]. */ - const signed char - json_parser::yypgoto_[] = - { - -5, -5, -5, -5, -5, -5, -5, -4 - }; - - /* YYDEFGOTO[NTERM-NUM]. */ - const signed char - json_parser::yydefgoto_[] = - { - -1, 10, 11, 12, 17, 13, 19, 14 - }; - - /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF_, syntax error. */ - const signed char json_parser::yytable_ninf_ = -1; - const unsigned char - json_parser::yytable_[] = - { - 20, 1, 2, 25, 3, 26, 4, 15, 21, 22, - 5, 6, 7, 8, 9, 23, 16, 28, 27, 24, - 30, 3, 29, 4, 18, 0, 31, 5, 6, 7, - 8, 9, 3, 0, 4, 0, 0, 0, 5, 6, - 7, 8, 9 - }; - - /* YYCHECK. */ - const signed char - json_parser::yycheck_[] = - { - 4, 0, 1, 6, 3, 8, 5, 4, 0, 7, - 9, 10, 11, 12, 13, 4, 13, 13, 22, 8, - 7, 3, 26, 5, 6, -1, 30, 9, 10, 11, - 12, 13, 3, -1, 5, -1, -1, -1, 9, 10, - 11, 12, 13 - }; - - /* STOS_[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ - const unsigned char - json_parser::yystos_[] = - { - 0, 0, 1, 3, 5, 9, 10, 11, 12, 13, - 16, 17, 18, 20, 22, 4, 13, 19, 6, 21, - 22, 0, 7, 4, 8, 6, 8, 22, 13, 22, - 7, 22 - }; - -#if YYDEBUG - /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding - to YYLEX-NUM. */ - const unsigned short int - json_parser::yytoken_number_[] = - { - 0, 256, 257, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12 - }; -#endif - - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ - const unsigned char - json_parser::yyr1_[] = - { - 0, 15, 16, 17, 17, 17, 18, 18, 19, 19, - 20, 20, 21, 21, 22, 22, 22, 22, 22, 22, - 22 - }; - - /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ - const unsigned char - json_parser::yyr2_[] = - { - 0, 2, 1, 1, 1, 1, 2, 3, 3, 5, - 2, 3, 1, 3, 1, 1, 1, 1, 1, 1, - 1 - }; - - - /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at \a yyntokens_, nonterminals. */ - const char* - const json_parser::yytname_[] = - { - "\"end of file\"", "error", "$undefined", "\"{\"", "\"}\"", "\"[\"", - "\"]\"", "\":\"", "\",\"", "\"number\"", "\"true\"", "\"false\"", - "\"null\"", "\"string\"", "\"invalid\"", "$accept", "start", "data", - "object", "members", "array", "values", "value", YY_NULL - }; - -#if YYDEBUG - /* YYRHS -- A `-1'-separated list of the rules' RHS. */ - const json_parser::rhs_number_type - json_parser::yyrhs_[] = - { - 16, 0, -1, 17, -1, 22, -1, 1, -1, 0, - -1, 3, 4, -1, 3, 19, 4, -1, 13, 7, - 22, -1, 19, 8, 13, 7, 22, -1, 5, 6, - -1, 5, 21, 6, -1, 22, -1, 21, 8, 22, - -1, 13, -1, 9, -1, 10, -1, 11, -1, 12, - -1, 18, -1, 20, -1 - }; - - /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ - const unsigned char - json_parser::yyprhs_[] = - { - 0, 0, 3, 5, 7, 9, 11, 14, 18, 22, - 28, 31, 35, 37, 41, 43, 45, 47, 49, 51, - 53 - }; - - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ - const unsigned char - json_parser::yyrline_[] = - { - 0, 82, 82, 87, 88, 94, 96, 99, 105, 110, - 114, 117, 123, 128, 132, 133, 134, 135, 136, 137, - 138 - }; - - // Print the state stack on the debug stream. - void - json_parser::yystack_print_ () - { - *yycdebug_ << "Stack now"; - for (state_stack_type::const_iterator i = yystate_stack_.begin (); - i != yystate_stack_.end (); ++i) - *yycdebug_ << ' ' << *i; - *yycdebug_ << std::endl; - } - - // Report on the debug stream that the rule \a yyrule is going to be reduced. - void - json_parser::yy_reduce_print_ (int yyrule) - { - unsigned int yylno = yyrline_[yyrule]; - int yynrhs = yyr2_[yyrule]; - /* Print the symbols being reduced, and their result. */ - *yycdebug_ << "Reducing stack by rule " << yyrule - 1 - << " (line " << yylno << "):" << std::endl; - /* The symbols being reduced. */ - for (int yyi = 0; yyi < yynrhs; yyi++) - YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", - yyrhs_[yyprhs_[yyrule] + yyi], - &(yysemantic_stack_[(yynrhs) - (yyi + 1)]), - &(yylocation_stack_[(yynrhs) - (yyi + 1)])); - } -#endif // YYDEBUG - - /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ - json_parser::token_number_type - json_parser::yytranslate_ (int t) - { - static - const token_number_type - translate_table[] = - { - 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2 - }; - if ((unsigned int) t <= yyuser_token_number_max_) - return translate_table[t]; - else - return yyundef_token_; - } - - const int json_parser::yyeof_ = 0; - const int json_parser::yylast_ = 42; - const int json_parser::yynnts_ = 8; - const int json_parser::yyempty_ = -2; - const int json_parser::yyfinal_ = 21; - const int json_parser::yyterror_ = 1; - const int json_parser::yyerrcode_ = 256; - const int json_parser::yyntokens_ = 15; - - const unsigned int json_parser::yyuser_token_number_max_ = 257; - const json_parser::token_number_type json_parser::yyundef_token_ = 2; - - -} // yy -/* Line 1141 of lalr1.cc */ -#line 1079 "json_parser.cc" -/* Line 1142 of lalr1.cc */ -#line 140 "json_parser.yy" - - -int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) -{ - JSonScanner* scanner = driver->m_scanner; - yylval->clear(); - int ret = scanner->yylex(yylval, yylloc); - - qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" - << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; - - return ret; -} - -void yy::json_parser::error (const yy::location& yyloc, const std::string& error) -{ - /*qjsonDebug() << yyloc.begin.line; - qjsonDebug() << yyloc.begin.column; - qjsonDebug() << yyloc.end.line; - qjsonDebug() << yyloc.end.column;*/ - qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; - driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); -} diff --git a/src/http/qjson/json_parser.hh b/src/http/qjson/json_parser.hh deleted file mode 100644 index 25e00fa1b..000000000 --- a/src/http/qjson/json_parser.hh +++ /dev/null @@ -1,300 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.7. */ - -/* Skeleton interface for Bison LALR(1) parsers in C++ - - Copyright (C) 2002-2012 Free Software Foundation, Inc. - - 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 3 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, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/** - ** \file json_parser.hh - ** Define the yy::parser class. - */ - -/* C++ LALR(1) parser skeleton written by Akim Demaille. */ - -#ifndef YY_YY_JSON_PARSER_HH_INCLUDED -# define YY_YY_JSON_PARSER_HH_INCLUDED - -/* "%code requires" blocks. */ -/* Line 33 of lalr1.cc */ -#line 26 "json_parser.yy" - - #include "parser_p.h" - #include "json_scanner.h" - #include "qjson_debug.h" - - #include - #include - #include - #include - - #include - - class JSonScanner; - - namespace QJson { - class Parser; - } - - #define YYERROR_VERBOSE 1 - - Q_DECLARE_METATYPE(QVector*) - Q_DECLARE_METATYPE(QVariantMap*) - - -/* Line 33 of lalr1.cc */ -#line 72 "json_parser.hh" - - -#include -#include -#include "stack.hh" -#include "location.hh" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif - - -namespace yy { -/* Line 33 of lalr1.cc */ -#line 88 "json_parser.hh" - - /// A Bison parser. - class json_parser - { - public: - /// Symbol semantic values. -#ifndef YYSTYPE - typedef int semantic_type; -#else - typedef YYSTYPE semantic_type; -#endif - /// Symbol locations. - typedef location location_type; - /// Tokens. - struct token - { - /* Tokens. */ - enum yytokentype { - END = 0, - CURLY_BRACKET_OPEN = 1, - CURLY_BRACKET_CLOSE = 2, - SQUARE_BRACKET_OPEN = 3, - SQUARE_BRACKET_CLOSE = 4, - COLON = 5, - COMMA = 6, - NUMBER = 7, - TRUE_VAL = 8, - FALSE_VAL = 9, - NULL_VAL = 10, - STRING = 11, - INVALID = 12 - }; - - }; - /// Token type. - typedef token::yytokentype token_type; - - /// Build a parser object. - json_parser (QJson::ParserPrivate* driver_yyarg); - virtual ~json_parser (); - - /// Parse. - /// \returns 0 iff parsing succeeded. - virtual int parse (); - -#if YYDEBUG - /// The current debugging stream. - std::ostream& debug_stream () const; - /// Set the current debugging stream. - void set_debug_stream (std::ostream &); - - /// Type for debugging levels. - typedef int debug_level_type; - /// The current debugging level. - debug_level_type debug_level () const; - /// Set the current debugging level. - void set_debug_level (debug_level_type l); -#endif - - private: - /// Report a syntax error. - /// \param loc where the syntax error is found. - /// \param msg a description of the syntax error. - virtual void error (const location_type& loc, const std::string& msg); - - /// Generate an error message. - /// \param state the state where the error occurred. - /// \param tok the lookahead token. - virtual std::string yysyntax_error_ (int yystate, int tok); - -#if YYDEBUG - /// \brief Report a symbol value on the debug stream. - /// \param yytype The token type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - virtual void yy_symbol_value_print_ (int yytype, - const semantic_type* yyvaluep, - const location_type* yylocationp); - /// \brief Report a symbol on the debug stream. - /// \param yytype The token type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - virtual void yy_symbol_print_ (int yytype, - const semantic_type* yyvaluep, - const location_type* yylocationp); -#endif - - - /// State numbers. - typedef int state_type; - /// State stack type. - typedef stack state_stack_type; - /// Semantic value stack type. - typedef stack semantic_stack_type; - /// location stack type. - typedef stack location_stack_type; - - /// The state stack. - state_stack_type yystate_stack_; - /// The semantic value stack. - semantic_stack_type yysemantic_stack_; - /// The location stack. - location_stack_type yylocation_stack_; - - /// Whether the given \c yypact_ value indicates a defaulted state. - /// \param yyvalue the value to check - static bool yy_pact_value_is_default_ (int yyvalue); - - /// Whether the given \c yytable_ value indicates a syntax error. - /// \param yyvalue the value to check - static bool yy_table_value_is_error_ (int yyvalue); - - /// Internal symbol numbers. - typedef unsigned char token_number_type; - /* Tables. */ - /// For a state, the index in \a yytable_ of its portion. - static const signed char yypact_[]; - static const signed char yypact_ninf_; - - /// For a state, default reduction number. - /// Unless\a yytable_ specifies something else to do. - /// Zero means the default is an error. - static const unsigned char yydefact_[]; - - static const signed char yypgoto_[]; - static const signed char yydefgoto_[]; - - /// What to do in a state. - /// \a yytable_[yypact_[s]]: what to do in state \a s. - /// - if positive, shift that token. - /// - if negative, reduce the rule which number is the opposite. - /// - if zero, do what YYDEFACT says. - static const unsigned char yytable_[]; - static const signed char yytable_ninf_; - - static const signed char yycheck_[]; - - /// For a state, its accessing symbol. - static const unsigned char yystos_[]; - - /// For a rule, its LHS. - static const unsigned char yyr1_[]; - /// For a rule, its RHS length. - static const unsigned char yyr2_[]; - - /// Convert the symbol name \a n to a form suitable for a diagnostic. - static std::string yytnamerr_ (const char *n); - - - /// For a symbol, its name in clear. - static const char* const yytname_[]; -#if YYDEBUG - /// A type to store symbol numbers and -1. - typedef signed char rhs_number_type; - /// A `-1'-separated list of the rules' RHS. - static const rhs_number_type yyrhs_[]; - /// For each rule, the index of the first RHS symbol in \a yyrhs_. - static const unsigned char yyprhs_[]; - /// For each rule, its source line number. - static const unsigned char yyrline_[]; - /// For each scanner token number, its symbol number. - static const unsigned short int yytoken_number_[]; - /// Report on the debug stream that the rule \a r is going to be reduced. - virtual void yy_reduce_print_ (int r); - /// Print the state stack on the debug stream. - virtual void yystack_print_ (); - - /* Debugging. */ - int yydebug_; - std::ostream* yycdebug_; -#endif - - /// Convert a scanner token number \a t to a symbol number. - token_number_type yytranslate_ (int t); - - /// \brief Reclaim the memory associated to a symbol. - /// \param yymsg Why this token is reclaimed. - /// If null, do not display the symbol, just free it. - /// \param yytype The symbol type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - inline void yydestruct_ (const char* yymsg, - int yytype, - semantic_type* yyvaluep, - location_type* yylocationp); - - /// Pop \a n symbols the three stacks. - inline void yypop_ (unsigned int n = 1); - - /* Constants. */ - static const int yyeof_; - /* LAST_ -- Last index in TABLE_. */ - static const int yylast_; - static const int yynnts_; - static const int yyempty_; - static const int yyfinal_; - static const int yyterror_; - static const int yyerrcode_; - static const int yyntokens_; - static const unsigned int yyuser_token_number_max_; - static const token_number_type yyundef_token_; - - /* User arguments. */ - QJson::ParserPrivate* driver; - }; - -} // yy -/* Line 33 of lalr1.cc */ -#line 297 "json_parser.hh" - - - -#endif /* !YY_YY_JSON_PARSER_HH_INCLUDED */ diff --git a/src/http/qjson/json_parser.yy b/src/http/qjson/json_parser.yy deleted file mode 100644 index fa4656bab..000000000 --- a/src/http/qjson/json_parser.yy +++ /dev/null @@ -1,162 +0,0 @@ -/* This file is part of QJSon - * - * Copyright (C) 2008 Flavio Castelli - * Copyright (C) 2013 Silvio Moioli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -%skeleton "lalr1.cc" -%defines -%define "parser_class_name" "json_parser" - -%code requires{ - #include "parser_p.h" - #include "json_scanner.h" - #include "qjson_debug.h" - - #include - #include - #include - #include - - #include - - class JSonScanner; - - namespace QJson { - class Parser; - } - - #define YYERROR_VERBOSE 1 - - Q_DECLARE_METATYPE(QVector*) - Q_DECLARE_METATYPE(QVariantMap*) -} - -%parse-param { QJson::ParserPrivate* driver } -%lex-param { QJson::ParserPrivate* driver } - -%locations - -%debug -%error-verbose - -%token END 0 "end of file" - -%token CURLY_BRACKET_OPEN 1 "{" -%token CURLY_BRACKET_CLOSE 2 "}" -%token SQUARE_BRACKET_OPEN 3 "[" -%token SQUARE_BRACKET_CLOSE 4 "]" -%token COLON 5 ":" -%token COMMA 6 "," - -%token NUMBER 7 "number" -%token TRUE_VAL 8 "true" -%token FALSE_VAL 9 "false" -%token NULL_VAL 10 "null" -%token STRING 11 "string" - -%token INVALID 12 "invalid" - -// define the initial token -%start start - -%% - -// grammar rules - -start: data { - driver->m_result = $1; - qjsonDebug() << "json_parser - parsing finished"; - }; - -data: value { $$ = $1; } - | error - { - qCritical()<< "json_parser - syntax error found, " - << "forcing abort, Line" << @$.begin.line << "Column" << @$.begin.column; - YYABORT; - } - | END; - -object: CURLY_BRACKET_OPEN CURLY_BRACKET_CLOSE { - $$ = QVariant(QVariantMap()); - } - | CURLY_BRACKET_OPEN members CURLY_BRACKET_CLOSE { - QVariantMap* map = $2.value(); - $$ = QVariant(*map); - delete map; - }; - -members: STRING COLON value { - QVariantMap* pair = new QVariantMap(); - pair->insert($1.toString(), $3); - $$.setValue(pair); - } - | members COMMA STRING COLON value { - $$.value()->insert($3.toString(), $5); - }; - -array: SQUARE_BRACKET_OPEN SQUARE_BRACKET_CLOSE { - $$ = QVariant(QVariantList()); - } - | SQUARE_BRACKET_OPEN values SQUARE_BRACKET_CLOSE { - QVector* list = $2.value* >(); - $$ = QVariant(list->toList()); - delete list; - }; - -values: value { - QVector* list = new QVector(1); - list->replace(0, $1); - $$.setValue(list); - } - | values COMMA value { - $$.value* >()->append($3); - }; - -value: STRING - | NUMBER - | TRUE_VAL - | FALSE_VAL - | NULL_VAL - | object - | array; - -%% - -int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) -{ - JSonScanner* scanner = driver->m_scanner; - yylval->clear(); - int ret = scanner->yylex(yylval, yylloc); - - qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" - << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; - - return ret; -} - -void yy::json_parser::error (const yy::location& yyloc, const std::string& error) -{ - /*qjsonDebug() << yyloc.begin.line; - qjsonDebug() << yyloc.begin.column; - qjsonDebug() << yyloc.end.line; - qjsonDebug() << yyloc.end.column;*/ - qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; - driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); -} diff --git a/src/http/qjson/json_scanner.cc b/src/http/qjson/json_scanner.cc deleted file mode 100644 index d163932d8..000000000 --- a/src/http/qjson/json_scanner.cc +++ /dev/null @@ -1,4507 +0,0 @@ -#line 2 "json_scanner.cc" - -#line 4 "json_scanner.cc" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - - /* The c++ scanner is a mess. The FlexLexer.h header file relies on the - * following macro. This is required in order to pass the c++-multiple-scanners - * test in the regression suite. We get reports that it breaks inheritance. - * We will address this in a future release of flex, or omit the C++ scanner - * altogether. - */ - #define yyFlexLexer yyFlexLexer - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ -#include -#include -#include -#include -#include -/* end standard C++ headers. */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern yy_size_t yyleng; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - - std::istream* yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -#define yytext_ptr yytext - -#include - -int yyFlexLexer::yywrap() { return 1; } -int yyFlexLexer::yylex() - { - LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" ); - return 0; - } - -#define YY_DECL int JSonScanner::yylex() -static yyconst flex_int16_t yy_nxt[][256] = - { - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 - }, - - { - 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, - 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, - - 10, 10, 10, 10, 15, 16, 10, 10, 17, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, - 10, 10, 22, 10, 10, 10, 10, 10, 10, 10, - 23, 10, 10, 10, 10, 10, 24, 10, 10, 10, - 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10 - }, - - { - 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, - 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 15, 16, 10, 10, 17, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, - 10, 10, 22, 10, 10, 10, 10, 10, 10, 10, - 23, 10, 10, 10, 10, 10, 24, 10, 10, 10, - 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10 - }, - - { - 9, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 29, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27 - }, - - { - 9, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 29, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27 - - }, - - { - 9, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, - 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, - 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, - - 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30 - }, - - { - 9, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - - 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, - 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, - 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, - 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30 - }, - - { - 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, - 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 15, 32, 10, 10, 17, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 33, 10, 10, 10, 10, 34, 10, - - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, - 10, 10, 22, 10, 10, 33, 10, 10, 10, 10, - 35, 10, 10, 10, 10, 10, 24, 10, 10, 10, - 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10 - }, - - { - 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, - 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, - - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 15, 32, 10, 10, 17, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 33, 10, 10, 10, 10, 34, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, - 10, 10, 22, 10, 10, 33, 10, 10, 10, 10, - 35, 10, 10, 10, 10, 10, 24, 10, 10, 10, - - 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10 - }, - - { - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9, -9, -9 - - }, - - { - 9, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10 - }, - - { - 9, -11, -11, -11, -11, -11, -11, -11, -11, 36, - -11, 36, 36, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, 36, -11, -11, -11, -11, -11, -11, -11, - - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11 - }, - - { - 9, -12, -12, -12, -12, -12, -12, -12, -12, -12, - 37, -12, -12, 37, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12 - }, - - { - 9, -13, -13, -13, -13, -13, -13, -13, -13, -13, - 37, -13, -13, 37, -13, -13, -13, -13, -13, -13, - - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13 - }, - - { - 9, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14 - - }, - - { - 9, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, - -15, -15, -15, -15, -15, -15 - }, - - { - 9, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - - -16, -16, -16, -16, -16, -16, -16, -16, 38, 39, - 39, 39, 39, 39, 39, 39, 39, 39, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16 - }, - - { - 9, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, 40, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, 41, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, 41, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17 - }, - - { - 9, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, 40, -18, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, 41, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, 41, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18, -18, -18 - }, - - { - 9, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19, -19, -19 - - }, - - { - 9, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20 - }, - - { - 9, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - - -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, -21, -21, -21 - }, - - { - 9, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, 43, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22 - }, - - { - 9, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, 44, -23, -23, - - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23 - }, - - { - 9, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, 45, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24 - - }, - - { - 9, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25 - }, - - { - 9, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - - -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26 - }, - - { - 9, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, -27, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, -27, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46 - }, - - { - 9, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28 - }, - - { - 9, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, 47, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, 48, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, 49, -29, -29, -29, -29, -29, 50, -29, - -29, -29, 51, -29, -29, -29, -29, -29, -29, -29, - 52, -29, -29, -29, 53, -29, 54, 55, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29 - - }, - - { - 9, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30 - }, - - { - 9, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - - -31, -31, -31, -31, -31, -31, -31, -31, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, -31, -31, - -31, -31, -31, -31, -31, 56, 56, 56, 56, 56, - 56, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, 56, 56, 56, - 56, 56, 56, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - - -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, - -31, -31, -31, -31, -31, -31 - }, - - { - 9, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, 38, 39, - 39, 39, 39, 39, 39, 39, 39, 39, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, 57, -32, -32, -32, -32, -32, -32, - - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, 57, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32 - }, - - { - 9, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - 58, -33, -33, -33, -33, -33, -33, -33, -33, -33, - - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33 - }, - - { - 9, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - - -34, -34, -34, -34, -34, 59, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, 59, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34 - - }, - - { - 9, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, 59, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, 59, -35, -35, - - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, 44, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35 - }, - - { - 9, -36, -36, -36, -36, -36, -36, -36, -36, 36, - -36, 36, 36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, 36, -36, -36, -36, -36, -36, -36, -36, - - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36 - }, - - { - 9, -37, -37, -37, -37, -37, -37, -37, -37, -37, - 37, -37, -37, 37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37 - }, - - { - 9, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, 40, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, 41, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, 41, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38 - }, - - { - 9, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, 40, -39, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, -39, -39, - - -39, -39, -39, -39, -39, -39, -39, -39, -39, 41, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, 41, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39 - - }, - - { - 9, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40 - }, - - { - 9, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - - -41, -41, -41, 62, -41, 62, -41, -41, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41 - }, - - { - 9, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, 40, -42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, 41, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, 41, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42 - }, - - { - 9, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, 64, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43 - }, - - { - 9, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, 65, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44 - - }, - - { - 9, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, 66, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45 - }, - - { - 9, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, -46, 46, 46, 46, 46, 46, - - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, -46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46 - }, - - { - 9, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47 - }, - - { - 9, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48 - }, - - { - 9, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49 - - }, - - { - 9, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50 - }, - - { - 9, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51 - }, - - { - 9, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52 - }, - - { - 9, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53 - }, - - { - 9, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54 - - }, - - { - 9, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55 - }, - - { - 9, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - - -56, -56, -56, -56, -56, -56, -56, -56, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, -56, -56, - -56, -56, -56, -56, -56, 67, 67, 67, 67, 67, - 67, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, 67, 67, 67, - 67, 67, 67, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - - -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56 - }, - - { - 9, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - 68, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57 - }, - - { - 9, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, 69, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58 - }, - - { - 9, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, 70, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - 70, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59, -59, -59 - - }, - - { - 9, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, 40, -60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, 41, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - - -60, 41, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60 - }, - - { - 9, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - - -61, -61, -61, -61, -61, -61, -61, -61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, 41, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, 41, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - - -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61 - }, - - { - 9, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62 - }, - - { - 9, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63 - }, - - { - 9, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, 71, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64 - - }, - - { - 9, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - - -65, -65, -65, -65, -65, -65, -65, -65, 72, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65 - }, - - { - 9, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, 73, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - - -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -66 - }, - - { - 9, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, -67, -67, - -67, -67, -67, -67, -67, 74, 74, 74, 74, 74, - 74, -67, -67, -67, -67, -67, -67, -67, -67, -67, - - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, 74, 74, 74, - 74, 74, 74, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, -67, -67, -67 - }, - - { - 9, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, 75, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, -68, -68, -68 - }, - - { - 9, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, 76, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, -69, -69, -69 - - }, - - { - 9, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, -70, -70, -70 - }, - - { - 9, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, 77, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - - -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, -71, -71, -71 - }, - - { - 9, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, -72, -72, -72 - }, - - { - 9, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, -73, -73, -73 - }, - - { - 9, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, -74, -74 - - }, - - { - 9, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - - -75, -75, -75, -75, -75, 78, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, -75, -75, -75 - }, - - { - 9, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - 79, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - - -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, -76, -76, -76 - }, - - { - 9, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, - -77, -77, -77, -77, -77, -77 - }, - - { - 9, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - 80, -78, -78, -78, -78, -78, -78, -78, -78, -78, - - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78 - }, - - { - 9, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, 81, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79 - - }, - - { - 9, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - - -80, -80, -80, -80, -80, 82, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80 - }, - - { - 9, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, 83, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - - -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, - -81, -81, -81, -81, -81, -81 - }, - - { - 9, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, 84, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82 - }, - - { - 9, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - - -83, 85, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83 - }, - - { - 9, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, 86, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84 - - }, - - { - 9, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85 - }, - - { - 9, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - - -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, - -86, -86, -86, -86, -86, -86 - }, - - } ; - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 36 -#define YY_END_OF_BUFFER 37 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[87] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 37, 35, - 1, 2, 2, 11, 27, 35, 6, 6, 26, 28, - 29, 35, 35, 35, 30, 31, 21, 23, 22, 25, - 25, 35, 35, 35, 35, 1, 2, 8, 8, 0, - 0, 7, 0, 0, 0, 21, 12, 14, 13, 15, - 16, 17, 18, 19, 20, 0, 0, 0, 0, 9, - 10, 0, 10, 0, 0, 0, 0, 0, 0, 32, - 0, 5, 3, 24, 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 33, 34 - } ; - -static yyconst yy_state_type yy_NUL_trans[87] = - { 0, - 10, 10, 27, 27, 30, 30, 10, 10, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "json_scanner.yy" -/* This file is part of QJson - * - * Copyright (C) 2013 Silvio Moioli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110yy::json_parser::token::INVALID301, USA. - */ -/* Flex output settings */ -#define YY_NO_UNISTD_H 1 -#define YY_NO_INPUT 1 -#line 29 "json_scanner.yy" - #include "json_scanner.h" - #include "json_parser.hh" - - #define YY_USER_INIT if(m_allowSpecialNumbers) { \ - BEGIN(ALLOW_SPECIAL_NUMBERS); \ - } -/* Exclusive subscanners for strings and escaped hex sequences */ - -/* Extra-JSON rules active iff m_allowSpecialNumbers is true */ - -#line 3163 "json_scanner.cc" - -#define INITIAL 0 -#define QUOTMARK_OPEN 1 -#define HEX_OPEN 2 -#define ALLOW_SPECIAL_NUMBERS 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -#define ECHO LexerOutput( yytext, yyleng ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ -\ - if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) LexerError( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 -#define YY_DECL int yyFlexLexer::yylex() -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 43 "json_scanner.yy" - - - /* Whitespace */ -#line 3270 "json_scanner.cc" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin = & std::cin; - - if ( ! yyout ) - yyout = & std::cout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); - } - - yy_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); -yy_match: - while ( (yy_current_state = yy_nxt[yy_current_state][ YY_SC_TO_UI(*yy_cp) ]) > 0 ) - { - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - - ++yy_cp; - } - - yy_current_state = -yy_current_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos) + 1; - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 46 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 50 "json_scanner.yy" -{ - m_yylloc->lines(yyleng); - } - YY_BREAK -/* Special values */ -case 3: -YY_RULE_SETUP -#line 56 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(true); - return yy::json_parser::token::TRUE_VAL; - } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 62 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(false); - return yy::json_parser::token::FALSE_VAL; - } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 68 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(); - return yy::json_parser::token::NULL_VAL; - } - YY_BREAK -/* Numbers */ -case 6: -#line 77 "json_scanner.yy" -case 7: -YY_RULE_SETUP -#line 77 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtoull(yytext, NULL, 10)); - if (errno == ERANGE) { - qCritical() << "Number is out of range: " << yytext; - return yy::json_parser::token::INVALID; - } - return yy::json_parser::token::NUMBER; - } - YY_BREAK -case 8: -#line 88 "json_scanner.yy" -case 9: -YY_RULE_SETUP -#line 88 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtoll(yytext, NULL, 10)); - if (errno == ERANGE) { - qCritical() << "Number is out of range: " << yytext; - return yy::json_parser::token::INVALID; - } - return yy::json_parser::token::NUMBER; - } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 98 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtod(yytext, NULL)); - if (errno == ERANGE) { - qCritical() << "Number is out of range: " << yytext; - return yy::json_parser::token::INVALID; - } - return yy::json_parser::token::NUMBER; - } - YY_BREAK -/* Strings */ -case 11: -YY_RULE_SETUP -#line 109 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - BEGIN(QUOTMARK_OPEN); - } - YY_BREAK - -case 12: -YY_RULE_SETUP -#line 115 "json_scanner.yy" -{ - m_currentString.append(QLatin1String("\"")); - } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 119 "json_scanner.yy" -{ - m_currentString.append(QLatin1String("\\")); - } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 123 "json_scanner.yy" -{ - m_currentString.append(QLatin1String("/")); - } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 127 "json_scanner.yy" -{ - m_currentString.append(QLatin1String("\b")); - } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 131 "json_scanner.yy" -{ - m_currentString.append(QLatin1String("\f")); - } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 135 "json_scanner.yy" -{ - m_currentString.append(QLatin1String("\n")); - } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 139 "json_scanner.yy" -{ - m_currentString.append(QLatin1String("\r")); - } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 143 "json_scanner.yy" -{ - m_currentString.append(QLatin1String("\t")); - } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 147 "json_scanner.yy" -{ - BEGIN(HEX_OPEN); - } - YY_BREAK -case 21: -/* rule 21 can match eol */ -YY_RULE_SETUP -#line 151 "json_scanner.yy" -{ - m_currentString.append(QString::fromUtf8(yytext)); - } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 155 "json_scanner.yy" -{ - // ignore - } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 159 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(m_currentString); - m_currentString.clear(); - BEGIN(INITIAL); - return yy::json_parser::token::STRING; - } - YY_BREAK - - -case 24: -YY_RULE_SETUP -#line 169 "json_scanner.yy" -{ - QString hexDigits = QString::fromUtf8(yytext, yyleng); - bool ok; - ushort hexDigit1 = hexDigits.left(2).toShort(&ok, 16); - ushort hexDigit2 = hexDigits.right(2).toShort(&ok, 16); - m_currentString.append(QChar(hexDigit2, hexDigit1)); - BEGIN(QUOTMARK_OPEN); - } - YY_BREAK -case 25: -/* rule 25 can match eol */ -YY_RULE_SETUP -#line 178 "json_scanner.yy" -{ - qCritical() << "Invalid hex string"; - m_yylloc->columns(yyleng); - *m_yylval = QVariant(QLatin1String("")); - BEGIN(QUOTMARK_OPEN); - return yy::json_parser::token::INVALID; - } - YY_BREAK - -/* "Compound type" related tokens */ -case 26: -YY_RULE_SETUP -#line 190 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - return yy::json_parser::token::COLON; - } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 195 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - return yy::json_parser::token::COMMA; - } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 200 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - return yy::json_parser::token::SQUARE_BRACKET_OPEN; - } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 205 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - return yy::json_parser::token::SQUARE_BRACKET_CLOSE; - } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 210 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - return yy::json_parser::token::CURLY_BRACKET_OPEN; - } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 215 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - return yy::json_parser::token::CURLY_BRACKET_CLOSE; - } - YY_BREAK -/* Extra-JSON numbers */ - -case 32: -YY_RULE_SETUP -#line 223 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(std::numeric_limits::quiet_NaN()); - return yy::json_parser::token::NUMBER; - } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 229 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(std::numeric_limits::infinity()); - return yy::json_parser::token::NUMBER; - } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 235 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - *m_yylval = QVariant(-std::numeric_limits::infinity()); - return yy::json_parser::token::NUMBER; - } - YY_BREAK - -/* If all else fails */ -case 35: -YY_RULE_SETUP -#line 243 "json_scanner.yy" -{ - m_yylloc->columns(yyleng); - return yy::json_parser::token::INVALID; - } - YY_BREAK -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(QUOTMARK_OPEN): -case YY_STATE_EOF(HEX_OPEN): -case YY_STATE_EOF(ALLOW_SPECIAL_NUMBERS): -#line 248 "json_scanner.yy" -return yy::json_parser::token::END; - YY_BREAK -case 36: -YY_RULE_SETUP -#line 249 "json_scanner.yy" -ECHO; - YY_BREAK -#line 3654 "json_scanner.cc" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ - -/* The contents of this function are C++ specific, so the () macro is not used. - */ -yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) -{ - yyin = arg_yyin; - yyout = arg_yyout; - yy_c_buf_p = 0; - yy_init = 0; - yy_start = 0; - yy_flex_debug = 0; - yylineno = 1; // this will only get updated if %option yylineno - - yy_did_buffer_switch_on_eof = 0; - - yy_looking_for_trail_begin = 0; - yy_more_flag = 0; - yy_more_len = 0; - yy_more_offset = yy_prev_more_offset = 0; - - yy_start_stack_ptr = yy_start_stack_depth = 0; - yy_start_stack = NULL; - - yy_buffer_stack = 0; - yy_buffer_stack_top = 0; - yy_buffer_stack_max = 0; - - yy_state_buf = 0; - -} - -/* The contents of this function are C++ specific, so the () macro is not used. - */ -yyFlexLexer::~yyFlexLexer() -{ - delete [] yy_state_buf; - yyfree(yy_start_stack ); - yy_delete_buffer( YY_CURRENT_BUFFER ); - yyfree(yy_buffer_stack ); -} - -/* The contents of this function are C++ specific, so the () macro is not used. - */ -void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) -{ - if ( new_in ) - { - yy_delete_buffer( YY_CURRENT_BUFFER ); - yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); - } - - if ( new_out ) - yyout = new_out; -} - -#ifdef YY_INTERACTIVE -int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) -#else -int yyFlexLexer::LexerInput( char* buf, int max_size ) -#endif -{ - if ( yyin->eof() || yyin->fail() ) - return 0; - -#ifdef YY_INTERACTIVE - yyin->get( buf[0] ); - - if ( yyin->eof() ) - return 0; - - if ( yyin->bad() ) - return -1; - - return 1; - -#else - (void) yyin->read( buf, max_size ); - - if ( yyin->bad() ) - return -1; - else - return yyin->gcount(); -#endif -} - -void yyFlexLexer::LexerOutput( const char* buf, int size ) -{ - (void) yyout->write( buf, size ); -} - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -int yyFlexLexer::yy_get_next_buffer() -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - yy_size_t new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - yy_state_type yyFlexLexer::yy_get_previous_state() -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - if ( *yy_cp ) - { - yy_current_state = yy_nxt[yy_current_state][YY_SC_TO_UI(*yy_cp)]; - } - else - yy_current_state = yy_NUL_trans[yy_current_state]; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) -{ - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); - - yy_current_state = yy_NUL_trans[yy_current_state]; - yy_is_jam = (yy_current_state == 0); - - if ( ! yy_is_jam ) - { - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - } - - return yy_is_jam ? 0 : yy_current_state; -} - - void yyFlexLexer::yyunput( int c, register char* yy_bp) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register yy_size_t number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - - int yyFlexLexer::yyinput() -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyFlexLexer::yyrestart( std::istream* input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file ); - yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - - void yyFlexLexer::yy_load_buffer_state() -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ - void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); - - yyfree((void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) - -{ - int oerrno = errno; - - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yyFlexLexer::yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -void yyFlexLexer::yyensure_buffer_stack(void) -{ - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -void yyFlexLexer::LexerError( yyconst char msg[] ) -{ - std::cerr << msg << std::endl; - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 249 "json_scanner.yy" diff --git a/src/http/qjson/json_scanner.cpp b/src/http/qjson/json_scanner.cpp deleted file mode 100644 index 5ef2a7180..000000000 --- a/src/http/qjson/json_scanner.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of QJson - * - * Copyright (C) 2008 Flavio Castelli - * Copyright (C) 2013 Silvio Moioli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#include "json_scanner.cc" - -#include "qjson_debug.h" -#include "json_scanner.h" -#include "json_parser.hh" - -#include - -#include -#include - -#include - -JSonScanner::JSonScanner(QIODevice* io) - : m_allowSpecialNumbers(false), - m_io (io), - m_criticalError(false) -{ -} - -void JSonScanner::allowSpecialNumbers(bool allow) { - m_allowSpecialNumbers = allow; -} - -int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc) { - m_yylval = yylval; - m_yylloc = yylloc; - m_yylloc->step(); - int result = yylex(); - - if (m_criticalError) { - return -1; - } - - return result; -} - -int JSonScanner::LexerInput(char* buf, int max_size) { - if (!m_io->isOpen()) { - qCritical() << "JSonScanner::yylex - io device is not open"; - m_criticalError = true; - return 0; - } - - int readBytes = m_io->read(buf, max_size); - if(readBytes < 0) { - qCritical() << "JSonScanner::yylex - error while reading from io device"; - m_criticalError = true; - return 0; - } - - return readBytes; -} - - diff --git a/src/http/qjson/json_scanner.h b/src/http/qjson/json_scanner.h deleted file mode 100644 index 0282be4ac..000000000 --- a/src/http/qjson/json_scanner.h +++ /dev/null @@ -1,60 +0,0 @@ -/* This file is part of QJson - * - * Copyright (C) 2008 Flavio Castelli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _JSON_SCANNER -#define _JSON_SCANNER - -#include -#include - -#define YYSTYPE QVariant - -// Only include FlexLexer.h if it hasn't been already included -#if ! defined(yyFlexLexerOnce) -#include -#endif - -#include "parser_p.h" - -namespace yy { - class location; - int yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver); -} - -class JSonScanner : public yyFlexLexer -{ - public: - explicit JSonScanner(QIODevice* io); - void allowSpecialNumbers(bool allow); - - int yylex(YYSTYPE* yylval, yy::location *yylloc); - int yylex(); - int LexerInput(char* buf, int max_size); - protected: - bool m_allowSpecialNumbers; - QIODevice* m_io; - - YYSTYPE* m_yylval; - yy::location* m_yylloc; - bool m_criticalError; - QString m_currentString; -}; - -#endif diff --git a/src/http/qjson/json_scanner.yy b/src/http/qjson/json_scanner.yy deleted file mode 100644 index 1adc4f8ce..000000000 --- a/src/http/qjson/json_scanner.yy +++ /dev/null @@ -1,248 +0,0 @@ -/* This file is part of QJson - * - * Copyright (C) 2013 Silvio Moioli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110yy::json_parser::token::INVALID301, USA. - */ - -/* Flex output settings */ -%option 8bit c++ full warn -%option noyywrap nounistd -%option noinput nounput noyy_push_state noyy_pop_state noyy_top_state noyy_scan_buffer noyy_scan_bytes noyy_scan_string noyyget_extra noyyset_extra noyyget_leng noyyget_text noyyget_lineno noyyset_lineno noyyget_in noyyset_in noyyget_out noyyset_out noyyget_lval noyyset_lval noyyget_lloc noyyset_lloc noyyget_debug noyyset_debug -%option yyclass="JSonScanner" -%option outfile="json_scanner.cc" - -%{ - #include "json_scanner.h" - #include "json_parser.hh" - - #define YY_USER_INIT if(m_allowSpecialNumbers) { \ - BEGIN(ALLOW_SPECIAL_NUMBERS); \ - } -%} - -/* Exclusive subscanners for strings and escaped hex sequences */ -%x QUOTMARK_OPEN HEX_OPEN - -/* Extra-JSON rules active iff m_allowSpecialNumbers is true */ -%s ALLOW_SPECIAL_NUMBERS - -%% - - /* Whitespace */ -[\v\f\t ]+ { - m_yylloc->columns(yyleng); - } - -[\r\n]+ { - m_yylloc->lines(yyleng); - } - - - /* Special values */ -true { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(true); - return yy::json_parser::token::TRUE_VAL; - } - -false { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(false); - return yy::json_parser::token::FALSE_VAL; - } - -null { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(); - return yy::json_parser::token::NULL_VAL; - } - - - /* Numbers */ -[0-9] | -[1-9][0-9]+ { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtoull(yytext, NULL, 10)); - if (errno == ERANGE) { - qCritical() << "Number is out of range: " << yytext; - return yy::json_parser::token::INVALID; - } - return yy::json_parser::token::NUMBER; - } - --[0-9] | --[1-9][0-9]+ { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtoll(yytext, NULL, 10)); - if (errno == ERANGE) { - qCritical() << "Number is out of range: " << yytext; - return yy::json_parser::token::INVALID; - } - return yy::json_parser::token::NUMBER; - } - --?(([0-9])|([1-9][0-9]+))(\.[0-9]+)?([Ee][+\-]?[0-9]+)? { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtod(yytext, NULL)); - if (errno == ERANGE) { - qCritical() << "Number is out of range: " << yytext; - return yy::json_parser::token::INVALID; - } - return yy::json_parser::token::NUMBER; - } - - /* Strings */ -\" { - m_yylloc->columns(yyleng); - BEGIN(QUOTMARK_OPEN); - } - -{ - \\\" { - m_currentString.append(QLatin1String("\"")); - } - - \\\\ { - m_currentString.append(QLatin1String("\\")); - } - - \\\/ { - m_currentString.append(QLatin1String("/")); - } - - \\b { - m_currentString.append(QLatin1String("\b")); - } - - \\f { - m_currentString.append(QLatin1String("\f")); - } - - \\n { - m_currentString.append(QLatin1String("\n")); - } - - \\r { - m_currentString.append(QLatin1String("\r")); - } - - \\t { - m_currentString.append(QLatin1String("\t")); - } - - \\u { - BEGIN(HEX_OPEN); - } - - [^\"\\]+ { - m_currentString.append(QString::fromUtf8(yytext)); - } - - \\ { - // ignore - } - - \" { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(m_currentString); - m_currentString.clear(); - BEGIN(INITIAL); - return yy::json_parser::token::STRING; - } -} - -{ - [0-9A-Fa-f]{4} { - QString hexDigits = QString::fromUtf8(yytext, yyleng); - bool ok; - ushort hexDigit1 = hexDigits.left(2).toShort(&ok, 16); - ushort hexDigit2 = hexDigits.right(2).toShort(&ok, 16); - m_currentString.append(QChar(hexDigit2, hexDigit1)); - BEGIN(QUOTMARK_OPEN); - } - - .|\n { - qCritical() << "Invalid hex string"; - m_yylloc->columns(yyleng); - *m_yylval = QVariant(QLatin1String("")); - BEGIN(QUOTMARK_OPEN); - return yy::json_parser::token::INVALID; - } -} - - - - /* "Compound type" related tokens */ -: { - m_yylloc->columns(yyleng); - return yy::json_parser::token::COLON; - } - -, { - m_yylloc->columns(yyleng); - return yy::json_parser::token::COMMA; - } - -\[ { - m_yylloc->columns(yyleng); - return yy::json_parser::token::SQUARE_BRACKET_OPEN; - } - -\] { - m_yylloc->columns(yyleng); - return yy::json_parser::token::SQUARE_BRACKET_CLOSE; - } - -\{ { - m_yylloc->columns(yyleng); - return yy::json_parser::token::CURLY_BRACKET_OPEN; - } - -\} { - m_yylloc->columns(yyleng); - return yy::json_parser::token::CURLY_BRACKET_CLOSE; - } - - - /* Extra-JSON numbers */ -{ - (?i:nan) { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(std::numeric_limits::quiet_NaN()); - return yy::json_parser::token::NUMBER; - } - - [Ii]nfinity { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(std::numeric_limits::infinity()); - return yy::json_parser::token::NUMBER; - } - - -[Ii]nfinity { - m_yylloc->columns(yyleng); - *m_yylval = QVariant(-std::numeric_limits::infinity()); - return yy::json_parser::token::NUMBER; - } -} - - /* If all else fails */ -. { - m_yylloc->columns(yyleng); - return yy::json_parser::token::INVALID; - } - -<> return yy::json_parser::token::END; diff --git a/src/http/qjson/location.hh b/src/http/qjson/location.hh deleted file mode 100644 index 0bf1a74e8..000000000 --- a/src/http/qjson/location.hh +++ /dev/null @@ -1,181 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.7. */ - -/* Locations for Bison parsers in C++ - - Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc. - - 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 3 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, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/** - ** \file location.hh - ** Define the yy::location class. - */ - -#ifndef YY_YY_LOCATION_HH_INCLUDED -# define YY_YY_LOCATION_HH_INCLUDED - -# include "position.hh" - - -namespace yy { -/* Line 166 of location.cc */ -#line 47 "location.hh" - - /// Abstract a location. - class location - { - public: - - /// Construct a location from \a b to \a e. - location (const position& b, const position& e) - : begin (b) - , end (e) - { - } - - /// Construct a 0-width location in \a p. - explicit location (const position& p = position ()) - : begin (p) - , end (p) - { - } - - /// Construct a 0-width location in \a f, \a l, \a c. - explicit location (std::string* f, - unsigned int l = 1u, - unsigned int c = 1u) - : begin (f, l, c) - , end (f, l, c) - { - } - - - /// Initialization. - void initialize (std::string* f = YY_NULL, - unsigned int l = 1u, - unsigned int c = 1u) - { - begin.initialize (f, l, c); - end = begin; - } - - /** \name Line and Column related manipulators - ** \{ */ - public: - /// Reset initial location to final location. - void step () - { - begin = end; - } - - /// Extend the current location to the COUNT next columns. - void columns (unsigned int count = 1) - { - end += count; - } - - /// Extend the current location to the COUNT next lines. - void lines (unsigned int count = 1) - { - end.lines (count); - } - /** \} */ - - - public: - /// Beginning of the located region. - position begin; - /// End of the located region. - position end; - }; - - /// Join two location objects to create a location. - inline const location operator+ (const location& begin, const location& end) - { - location res = begin; - res.end = end.end; - return res; - } - - /// Add two location objects. - inline const location operator+ (const location& begin, unsigned int width) - { - location res = begin; - res.columns (width); - return res; - } - - /// Add and assign a location. - inline location& operator+= (location& res, unsigned int width) - { - res.columns (width); - return res; - } - - /// Compare two location objects. - inline bool - operator== (const location& loc1, const location& loc2) - { - return loc1.begin == loc2.begin && loc1.end == loc2.end; - } - - /// Compare two location objects. - inline bool - operator!= (const location& loc1, const location& loc2) - { - return !(loc1 == loc2); - } - - /** \brief Intercept output stream redirection. - ** \param ostr the destination output stream - ** \param loc a reference to the location to redirect - ** - ** Avoid duplicate information. - */ - template - inline std::basic_ostream& - operator<< (std::basic_ostream& ostr, const location& loc) - { - position last = loc.end - 1; - ostr << loc.begin; - if (last.filename - && (!loc.begin.filename - || *loc.begin.filename != *last.filename)) - ostr << '-' << last; - else if (loc.begin.line != last.line) - ostr << '-' << last.line << '.' << last.column; - else if (loc.begin.column != last.column) - ostr << '-' << last.column; - return ostr; - } - - -} // yy -/* Line 296 of location.cc */ -#line 180 "location.hh" - -#endif /* !YY_YY_LOCATION_HH_INCLUDED */ diff --git a/src/http/qjson/parser.cpp b/src/http/qjson/parser.cpp deleted file mode 100644 index e203b876f..000000000 --- a/src/http/qjson/parser.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* This file is part of QJson - * - * Copyright (C) 2008 Flavio Castelli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "parser.h" -#include "parser_p.h" -#include "json_parser.hh" -#include "json_scanner.h" - -#include -#include -#include -#include - -using namespace QJson; - -ParserPrivate::ParserPrivate() : - m_scanner(0) - , m_negate(false) - , m_error(false) - , m_errorLine(0) - , m_specialNumbersAllowed(false) -{ -} - -ParserPrivate::~ParserPrivate() -{ - delete m_scanner; -} - -void ParserPrivate::setError(QString errorMsg, int errorLine) { - m_error = true; - m_errorMsg = errorMsg; - m_errorLine = errorLine; -} - -Parser::Parser() : - d(new ParserPrivate) -{ -} - -Parser::~Parser() -{ - delete d; -} - -QVariant Parser::parse (QIODevice* io, bool* ok) -{ - d->m_errorMsg.clear(); - delete d->m_scanner; - d->m_scanner = 0; - - if (!io->isOpen()) { - if (!io->open(QIODevice::ReadOnly)) { - if (ok != 0) - *ok = false; - qCritical ("Error opening device"); - return QVariant(); - } - } - - if (!io->isReadable()) { - if (ok != 0) - *ok = false; - qCritical ("Device is not readable"); - io->close(); - return QVariant(); - } - - d->m_scanner = new JSonScanner (io); - d->m_scanner->allowSpecialNumbers(d->m_specialNumbersAllowed); - yy::json_parser parser(d); - parser.parse(); - - delete d->m_scanner; - d->m_scanner = 0; - - if (ok != 0) - *ok = !d->m_error; - - io->close(); - return d->m_result; -} - -QVariant Parser::parse(const QByteArray& jsonString, bool* ok) { - QBuffer buffer; - buffer.open(QBuffer::ReadWrite); - buffer.write(jsonString); - buffer.seek(0); - return parse (&buffer, ok); -} - -QString Parser::errorString() const -{ - return d->m_errorMsg; -} - -int Parser::errorLine() const -{ - return d->m_errorLine; -} - -void QJson::Parser::allowSpecialNumbers(bool allowSpecialNumbers) { - d->m_specialNumbersAllowed = allowSpecialNumbers; -} - -bool Parser::specialNumbersAllowed() const { - return d->m_specialNumbersAllowed; -} diff --git a/src/http/qjson/parser.h b/src/http/qjson/parser.h deleted file mode 100644 index c3132f506..000000000 --- a/src/http/qjson/parser.h +++ /dev/null @@ -1,99 +0,0 @@ -/* This file is part of QJson - * - * Copyright (C) 2008 Flavio Castelli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QJSON_PARSER_H -#define QJSON_PARSER_H - -#include "qjson_export.h" - -QT_BEGIN_NAMESPACE -class QIODevice; -class QVariant; -QT_END_NAMESPACE - -/** - * Namespace used by QJson - */ -namespace QJson { - - class ParserPrivate; - - /** - * @brief Main class used to convert JSON data to QVariant objects - */ - class QJSON_EXPORT Parser - { - public: - Parser(); - ~Parser(); - - /** - * Read JSON string from the I/O Device and converts it to a QVariant object - * @param io Input output device - * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. - * @returns a QVariant object generated from the JSON string - */ - QVariant parse(QIODevice* io, bool* ok = 0); - - /** - * This is a method provided for convenience. - * @param jsonData data containing the JSON object representation - * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. - * @returns a QVariant object generated from the JSON string - * @sa errorString - * @sa errorLine - */ - QVariant parse(const QByteArray& jsonData, bool* ok = 0); - - /** - * This method returns the error message - * @returns a QString object containing the error message of the last parse operation - * @sa errorLine - */ - QString errorString() const; - - /** - * This method returns line number where the error occurred - * @returns the line number where the error occurred - * @sa errorString - */ - int errorLine() const; - - /** - * Sets whether special numbers (Infinity, -Infinity, NaN) are allowed as an extension to - * the standard - * @param allowSpecialNumbers new value of whether special numbers are allowed - * @sa specialNumbersAllowed - */ - void allowSpecialNumbers(bool allowSpecialNumbers); - - /** - * @returns whether special numbers (Infinity, -Infinity, NaN) are allowed - * @sa allowSpecialNumbers - */ - bool specialNumbersAllowed() const; - - private: - Q_DISABLE_COPY(Parser) - ParserPrivate* const d; - }; -} - -#endif // QJSON_PARSER_H diff --git a/src/http/qjson/parser_p.h b/src/http/qjson/parser_p.h deleted file mode 100644 index aae86a124..000000000 --- a/src/http/qjson/parser_p.h +++ /dev/null @@ -1,56 +0,0 @@ -/* This file is part of QJson - * - * Copyright (C) 2008 Flavio Castelli - * Copyright (C) 2009 Michael Leupold - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QJSON_PARSER_P_H -#define QJSON_PARSER_P_H - -#include "parser.h" - -#include -#include - -class JSonScanner; - -namespace yy { - class json_parser; -} - -namespace QJson { - - class ParserPrivate - { - public: - ParserPrivate(); - ~ParserPrivate(); - - void setError(QString errorMsg, int line); - - JSonScanner* m_scanner; - bool m_negate; - bool m_error; - int m_errorLine; - QString m_errorMsg; - QVariant m_result; - bool m_specialNumbersAllowed; - }; -} - -#endif // QJSON_PARSER_H diff --git a/src/http/qjson/parserrunnable.cpp b/src/http/qjson/parserrunnable.cpp deleted file mode 100644 index 88baf4cf6..000000000 --- a/src/http/qjson/parserrunnable.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* This file is part of qjson - * - * Copyright (C) 2009 Flavio Castelli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "parserrunnable.h" - -#include "parser.h" - -#include -#include - -using namespace QJson; - -class QJson::ParserRunnable::Private -{ - public: - QByteArray m_data; -}; - -ParserRunnable::ParserRunnable(QObject* parent) - : QObject(parent), - QRunnable(), - d(new Private) -{ - qRegisterMetaType("QVariant"); -} - -ParserRunnable::~ParserRunnable() -{ - delete d; -} - -void ParserRunnable::setData( const QByteArray& data ) { - d->m_data = data; -} - -void ParserRunnable::run() -{ - qDebug() << Q_FUNC_INFO; - - bool ok; - Parser parser; - QVariant result = parser.parse (d->m_data, &ok); - if (ok) { - qDebug() << "successfully converted json item to QVariant object"; - emit parsingFinished(result, true, QString()); - } else { - const QString errorText = tr("An error occurred while parsing json: %1").arg(parser.errorString()); - qCritical() << errorText; - emit parsingFinished(QVariant(), false, errorText); - } -} diff --git a/src/http/qjson/parserrunnable.h b/src/http/qjson/parserrunnable.h deleted file mode 100644 index fddcacd3f..000000000 --- a/src/http/qjson/parserrunnable.h +++ /dev/null @@ -1,64 +0,0 @@ -/* This file is part of qjson - * - * Copyright (C) 2009 Flavio Castelli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef PARSERRUNNABLE_H -#define PARSERRUNNABLE_H - -#include "qjson_export.h" - -#include -#include - -QT_BEGIN_NAMESPACE -class QVariant; -QT_END_NAMESPACE - -namespace QJson { - /** - * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread - */ - class QJSON_EXPORT ParserRunnable : public QObject, public QRunnable - { - Q_OBJECT - public: - explicit ParserRunnable(QObject* parent = 0); - ~ParserRunnable(); - - void setData( const QByteArray& data ); - - void run(); - - Q_SIGNALS: - /** - * This signal is emitted when the parsing process has been completed - * @param json contains the result of the parsing - * @param ok if a parsing error occurs ok is set to false, otherwise it's set to true. - * @param error_msg contains a string explaining the failure reason - **/ - void parsingFinished(const QVariant& json, bool ok, const QString& error_msg); - - private: - Q_DISABLE_COPY(ParserRunnable) - class Private; - Private* const d; - }; -} - -#endif // PARSERRUNNABLE_H diff --git a/src/http/qjson/position.hh b/src/http/qjson/position.hh deleted file mode 100644 index 3b33c2734..000000000 --- a/src/http/qjson/position.hh +++ /dev/null @@ -1,172 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.7. */ - -/* Positions for Bison parsers in C++ - - Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc. - - 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 3 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, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/** - ** \file position.hh - ** Define the yy::position class. - */ - -#ifndef YY_YY_POSITION_HH_INCLUDED -# define YY_YY_POSITION_HH_INCLUDED - -# include // std::max -# include -# include - -# ifndef YY_NULL -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr -# else -# define YY_NULL 0 -# endif -# endif - - -namespace yy { -/* Line 36 of location.cc */ -#line 57 "position.hh" - /// Abstract a position. - class position - { - public: - - /// Construct a position. - explicit position (std::string* f = YY_NULL, - unsigned int l = 1u, - unsigned int c = 1u) - : filename (f) - , line (l) - , column (c) - { - } - - - /// Initialization. - void initialize (std::string* fn = YY_NULL, - unsigned int l = 1u, - unsigned int c = 1u) - { - filename = fn; - line = l; - column = c; - } - - /** \name Line and Column related manipulators - ** \{ */ - /// (line related) Advance to the COUNT next lines. - void lines (int count = 1) - { - column = 1u; - line += count; - } - - /// (column related) Advance to the COUNT next columns. - void columns (int count = 1) - { - column = std::max (1u, column + count); - } - /** \} */ - - /// File name to which this position refers. - std::string* filename; - /// Current line number. - unsigned int line; - /// Current column number. - unsigned int column; - }; - - /// Add and assign a position. - inline position& - operator+= (position& res, const int width) - { - res.columns (width); - return res; - } - - /// Add two position objects. - inline const position - operator+ (const position& begin, const int width) - { - position res = begin; - return res += width; - } - - /// Add and assign a position. - inline position& - operator-= (position& res, const int width) - { - return res += -width; - } - - /// Add two position objects. - inline const position - operator- (const position& begin, const int width) - { - return begin + -width; - } - - /// Compare two position objects. - inline bool - operator== (const position& pos1, const position& pos2) - { - return (pos1.line == pos2.line - && pos1.column == pos2.column - && (pos1.filename == pos2.filename - || (pos1.filename && pos2.filename - && *pos1.filename == *pos2.filename))); - } - - /// Compare two position objects. - inline bool - operator!= (const position& pos1, const position& pos2) - { - return !(pos1 == pos2); - } - - /** \brief Intercept output stream redirection. - ** \param ostr the destination output stream - ** \param pos a reference to the position to redirect - */ - template - inline std::basic_ostream& - operator<< (std::basic_ostream& ostr, const position& pos) - { - if (pos.filename) - ostr << *pos.filename << ':'; - return ostr << pos.line << '.' << pos.column; - } - - -} // yy -/* Line 148 of location.cc */ -#line 172 "position.hh" -#endif /* !YY_YY_POSITION_HH_INCLUDED */ diff --git a/src/http/qjson/qjson_debug.h b/src/http/qjson/qjson_debug.h deleted file mode 100644 index 6036b2268..000000000 --- a/src/http/qjson/qjson_debug.h +++ /dev/null @@ -1,34 +0,0 @@ -/* This file is part of qjson - * - * Copyright (C) 2009 Michael Leupold - * Copyright (C) 2013 Silvio Moioli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QJSON_DEBUG_H -#define QJSON_DEBUG_H - -#include - -// define qjsonDebug() -#ifdef QJSON_VERBOSE_DEBUG_OUTPUT - inline QDebug qjsonDebug() { return QDebug(QtDebugMsg); } -#else - #define qjsonDebug() if(false) QDebug(QtDebugMsg) -#endif - -#endif diff --git a/src/http/qjson/qjson_export.h b/src/http/qjson/qjson_export.h deleted file mode 100644 index 9a807b91b..000000000 --- a/src/http/qjson/qjson_export.h +++ /dev/null @@ -1,35 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2009 Pino Toscano - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License version 2.1, as published by the Free Software Foundation. - - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef QJSON_EXPORT_H -#define QJSON_EXPORT_H - -#include - -#ifndef QJSON_EXPORT -# if defined(QJSON_MAKEDLL) - /* We are building this library */ -# define QJSON_EXPORT Q_DECL_EXPORT -# else - /* We are using this library */ -# define QJSON_EXPORT Q_DECL_IMPORT -# endif -#endif - -#endif diff --git a/src/http/qjson/qobjecthelper.cpp b/src/http/qjson/qobjecthelper.cpp deleted file mode 100644 index 0ea440522..000000000 --- a/src/http/qjson/qobjecthelper.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* This file is part of qjson - * - * Copyright (C) 2009 Till Adam - * Copyright (C) 2009 Flavio Castelli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - - -#include "qobjecthelper.h" - -#include -#include -#include - -using namespace QJson; - -class QObjectHelper::QObjectHelperPrivate { -}; - -QObjectHelper::QObjectHelper() - : d (new QObjectHelperPrivate) -{ -} - -QObjectHelper::~QObjectHelper() -{ - delete d; -} - -QVariantMap QObjectHelper::qobject2qvariant(const QObject* object, Flags flags, - const QStringList& ignoredProperties) -{ - QVariantMap result; - const QMetaObject *metaobject = object->metaObject(); - int count = metaobject->propertyCount(); - for (int i=0; iproperty(i); - const char *name = metaproperty.name(); - - if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable())) - continue; - - QVariant value = object->property(name); - if (value.isNull() && !flags.testFlag(Flag_StoreNullVariants)) - continue; - if (!value.isValid() && !flags.testFlag(Flag_StoreInvalidVariants)) - continue; - result[QLatin1String(name)] = value; - } - return result; -} - -QVariantMap QObjectHelper::qobject2qvariant(const QObject *object, const QStringList &ignoredProperties) - { - return qobject2qvariant(object, Flag_All, ignoredProperties); - } - -void QObjectHelper::qvariant2qobject(const QVariantMap& variant, QObject* object) -{ - const QMetaObject *metaobject = object->metaObject(); - - QVariantMap::const_iterator iter; - for (iter = variant.constBegin(); iter != variant.constEnd(); ++iter) { - int pIdx = metaobject->indexOfProperty( iter.key().toLatin1() ); - - if ( pIdx < 0 ) { - continue; - } - - QMetaProperty metaproperty = metaobject->property( pIdx ); - QVariant::Type type = metaproperty.type(); - QVariant v( iter.value() ); - if ( v.canConvert( type ) ) { - v.convert( type ); - metaproperty.write( object, v ); - } else if (QString(QLatin1String("QVariant")).compare(QLatin1String(metaproperty.typeName())) == 0) { - metaproperty.write( object, v ); - } - } -} diff --git a/src/http/qjson/qobjecthelper.h b/src/http/qjson/qobjecthelper.h deleted file mode 100644 index 9a819b448..000000000 --- a/src/http/qjson/qobjecthelper.h +++ /dev/null @@ -1,157 +0,0 @@ -/* This file is part of qjson - * - * Copyright (C) 2009 Flavio Castelli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QOBJECTHELPER_H -#define QOBJECTHELPER_H - -#include "qjson_export.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QObject; -QT_END_NAMESPACE - -namespace QJson { - /** - * @brief Class used to convert QObject into QVariant and vivce-versa. - * During these operations only the class attributes defined as properties will - * be considered. - * Properties marked as 'non-stored' will be ignored. - * - * Suppose the declaration of the Person class looks like this: - * \code - * class Person : public QObject - { - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber) - Q_PROPERTY(Gender gender READ gender WRITE setGender) - Q_PROPERTY(QDate dob READ dob WRITE setDob) - Q_ENUMS(Gender) - - public: - Person(QObject* parent = 0); - ~Person(); - - QString name() const; - void setName(const QString& name); - - int phoneNumber() const; - void setPhoneNumber(const int phoneNumber); - - enum Gender {Male, Female}; - void setGender(Gender gender); - Gender gender() const; - - QDate dob() const; - void setDob(const QDate& dob); - - private: - QString m_name; - int m_phoneNumber; - Gender m_gender; - QDate m_dob; - }; - \endcode - - The following code will serialize an instance of Person to JSON : - - \code - Person person; - person.setName("Flavio"); - person.setPhoneNumber(123456); - person.setGender(Person::Male); - person.setDob(QDate(1982, 7, 12)); - - QVariantMap variant = QObjectHelper::qobject2qvariant(&person); - Serializer serializer; - qDebug() << serializer.serialize( variant); - \endcode - - The generated output will be: - \code - { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } - \endcode - - It's also possible to initialize a QObject using the values stored inside of - a QVariantMap. - - Suppose you have the following JSON data stored into a QString: - \code - { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } - \endcode - - The following code will initialize an already allocated instance of Person - using the JSON values: - \code - Parser parser; - QVariant variant = parser.parse(json); - - Person person; - QObjectHelper::qvariant2qobject(variant.toMap(), &person); - \endcode - - \sa Parser - \sa Serializer - */ - class QJSON_EXPORT QObjectHelper { - public: - QObjectHelper(); - ~QObjectHelper(); - - enum Flag { - Flag_None, - Flag_StoreNullVariants, - Flag_StoreInvalidVariants, - Flag_All = Flag_StoreNullVariants | Flag_StoreInvalidVariants - }; - Q_DECLARE_FLAGS(Flags, Flag) - - /** - * This method converts a QObject instance into a QVariantMap. - * - * @param object The QObject instance to be converted. - * @param ignoredProperties Properties that won't be converted. - */ - static QVariantMap qobject2qvariant(const QObject* object, Flags flags = Flag_All, - const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName")))); - static QVariantMap qobject2qvariant(const QObject* object, - const QStringList& ignoredProperties); - - /** - * This method converts a QVariantMap instance into a QObject - * - * @param variant Attributes to assign to the object. - * @param object The QObject instance to update. - */ - static void qvariant2qobject(const QVariantMap& variant, QObject* object); - - private: - Q_DISABLE_COPY(QObjectHelper) - class QObjectHelperPrivate; - QObjectHelperPrivate* const d; - }; -} - -#endif // QOBJECTHELPER_H diff --git a/src/http/qjson/serializer.cpp b/src/http/qjson/serializer.cpp deleted file mode 100644 index 8e9d8b457..000000000 --- a/src/http/qjson/serializer.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* This file is part of qjson - * - * Copyright (C) 2009 Till Adam - * Copyright (C) 2009 Flavio Castelli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "serializer.h" - -#include -#include -#include - -#include - -#ifdef _MSC_VER // using MSVC compiler -#include -#endif - -using namespace QJson; - -class Serializer::SerializerPrivate { - public: - SerializerPrivate() : - specialNumbersAllowed(false), - indentMode(QJson::IndentNone), - doublePrecision(6) { - errorMessage.clear(); - } - QString errorMessage; - bool specialNumbersAllowed; - IndentMode indentMode; - int doublePrecision; - QByteArray buildIndent(int spaces); - QByteArray serialize( const QVariant &v, bool *ok, int indentLevel = 0); - QString sanitizeString( QString str ); - QByteArray join( const QList& list, const QByteArray& sep ); -}; - -QByteArray Serializer::SerializerPrivate::join( const QList& list, const QByteArray& sep ) { - QByteArray res; - Q_FOREACH( const QByteArray& i, list ) { - if ( !res.isEmpty() ) - res += sep; - res += i; - } - return res; -} - -QByteArray Serializer::SerializerPrivate::serialize( const QVariant &v, bool *ok, int indentLevel) -{ - QByteArray str; - - if ( ! v.isValid() ) { // invalid or null? - str = "null"; - } else if (( v.type() == QVariant::List ) || ( v.type() == QVariant::StringList )){ // an array or a stringlist? - const QVariantList list = v.toList(); - QList values; - Q_FOREACH( const QVariant& var, list ) - { - indentLevel++; - QByteArray serializedValue = serialize( var, ok, indentLevel); - indentLevel--; - if ( !*ok ) { - break; - } - values << serializedValue; - } - - if (indentMode == QJson::IndentMinimum) { - QByteArray indent = buildIndent(indentLevel - 1); - str = "[\n" + join( values, ",\n" ) + "\n" + indent + "]"; - } - else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { - QByteArray indent = buildIndent(indentLevel); - str = "[\n" + join( values, ",\n" ) + "\n" + indent + "]"; - } - else if (indentMode == QJson::IndentCompact) { - str = "[" + join( values, "," ) + "]"; - } - else { - str = "[ " + join( values, ", " ) + " ]"; - } - - } else if ( v.type() == QVariant::Map ) { // variant is a map? - const QVariantMap vmap = v.toMap(); - QMapIterator it( vmap ); - - if (indentMode == QJson::IndentMinimum) { - QByteArray indent = buildIndent(indentLevel); - str = indent + "{ "; - } - else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { - QByteArray indent = buildIndent(indentLevel); - QByteArray nextindent = buildIndent(indentLevel + 1); - str = indent + "{\n" + nextindent; - } - else if (indentMode == QJson::IndentCompact) { - str = "{"; - } - else { - str = "{ "; - } - - QList pairs; - while ( it.hasNext() ) { - it.next(); - indentLevel++; - QByteArray serializedValue = serialize( it.value(), ok, indentLevel); - indentLevel--; - if ( !*ok ) { - break; - } - QByteArray key = sanitizeString( it.key() ).toUtf8(); - QByteArray value = serializedValue; - if (indentMode == QJson::IndentCompact) { - pairs << key + ":" + value; - } else { - pairs << key + " : " + value; - } - } - - if (indentMode == QJson::IndentFull) { - QByteArray indent = buildIndent(indentLevel + 1); - str += join( pairs, ",\n" + indent); - } - else if (indentMode == QJson::IndentCompact) { - str += join( pairs, "," ); - } - else { - str += join( pairs, ", " ); - } - - if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { - QByteArray indent = buildIndent(indentLevel); - str += "\n" + indent + "}"; - } - else if (indentMode == QJson::IndentCompact) { - str += "}"; - } - else { - str += " }"; - } - - } else if ( v.type() == QVariant::Hash ) { // variant is a hash? - const QVariantHash vhash = v.toHash(); - QHashIterator it( vhash ); - - if (indentMode == QJson::IndentMinimum) { - QByteArray indent = buildIndent(indentLevel); - str = indent + "{ "; - } - else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { - QByteArray indent = buildIndent(indentLevel); - QByteArray nextindent = buildIndent(indentLevel + 1); - str = indent + "{\n" + nextindent; - } - else if (indentMode == QJson::IndentCompact) { - str = "{"; - } - else { - str = "{ "; - } - - QList pairs; - while ( it.hasNext() ) { - it.next(); - indentLevel++; - QByteArray serializedValue = serialize( it.value(), ok, indentLevel); - indentLevel--; - if ( !*ok ) { - break; - } - QByteArray key = sanitizeString( it.key() ).toUtf8(); - QByteArray value = serializedValue; - if (indentMode == QJson::IndentCompact) { - pairs << key + ":" + value; - } else { - pairs << key + " : " + value; - } - } - - if (indentMode == QJson::IndentFull) { - QByteArray indent = buildIndent(indentLevel + 1); - str += join( pairs, ",\n" + indent); - } - else if (indentMode == QJson::IndentCompact) { - str += join( pairs, "," ); - } - else { - str += join( pairs, ", " ); - } - - if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { - QByteArray indent = buildIndent(indentLevel); - str += "\n" + indent + "}"; - } - else if (indentMode == QJson::IndentCompact) { - str += "}"; - } - else { - str += " }"; - } - - } else if (( v.type() == QVariant::String ) || ( v.type() == QVariant::ByteArray )) { // a string or a byte array? - str = sanitizeString( v.toString() ).toUtf8(); - } else if (( v.type() == QVariant::Double) || ((QMetaType::Type)v.type() == QMetaType::Float)) { // a double or a float? - const double value = v.toDouble(); -#if defined _WIN32 && !defined(Q_OS_SYMBIAN) - const bool special = _isnan(value) || !_finite(value); -#elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) - const bool special = isnan(value) || isinf(value); -#else - const bool special = std::isnan(value) || std::isinf(value); -#endif - if (special) { - if (specialNumbersAllowed) { -#if defined _WIN32 && !defined(Q_OS_SYMBIAN) - if (_isnan(value)) { -#elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) - if (isnan(value)) { -#else - if (std::isnan(value)) { -#endif - str += "NaN"; - } else { - if (value<0) { - str += '-'; - } - str += "Infinity"; - } - } else { - errorMessage += QLatin1String("Attempt to write NaN or infinity, which is not supported by json\n"); - *ok = false; - } - } else { - str = QByteArray::number( value , 'g', doublePrecision); - if( ! str.contains( "." ) && ! str.contains( "e" ) ) { - str += ".0"; - } - } - } else if ( v.type() == QVariant::Bool ) { // boolean value? - str = ( v.toBool() ? "true" : "false" ); - } else if ( v.type() == QVariant::ULongLong ) { // large unsigned number? - str = QByteArray::number( v.value() ); - } else if ( v.type() == QVariant::UInt ) { // unsigned int number? - str = QByteArray::number( v.value() ); - } else if ( v.canConvert() ) { // any signed number? - str = QByteArray::number( v.value() ); - } else if ( v.canConvert() ) { // unsigned short number? - str = QByteArray::number( v.value() ); - } else if ( v.canConvert() ){ // can value be converted to string? - // this will catch QDate, QDateTime, QUrl, ... - str = sanitizeString( v.toString() ).toUtf8(); - //TODO: catch other values like QImage, QRect, ... - } else { - *ok = false; - errorMessage += QLatin1String("Cannot serialize "); - errorMessage += v.toString(); - errorMessage += QLatin1String(" because type "); - errorMessage += QLatin1String(v.typeName()); - errorMessage += QLatin1String(" is not supported by QJson\n"); - } - if ( *ok ) - { - return str; - } - else - return QByteArray(); -} - -QByteArray Serializer::SerializerPrivate::buildIndent(int spaces) -{ - QByteArray indent; - if (spaces < 0) { - spaces = 0; - } - for (int i = 0; i < spaces; i++ ) { - indent += " "; - } - return indent; -} - -QString Serializer::SerializerPrivate::sanitizeString( QString str ) -{ - str.replace( QLatin1String( "\\" ), QLatin1String( "\\\\" ) ); - - // escape unicode chars - QString result; - const ushort* unicode = str.utf16(); - unsigned int i = 0; - - while ( unicode[ i ] ) { - if ( unicode[ i ] < 128 ) { - result.append( QChar( unicode[ i ] ) ); - } - else { - QString hexCode = QString::number( unicode[ i ], 16 ).rightJustified( 4, - QLatin1Char('0') ); - - result.append( QLatin1String ("\\u") ).append( hexCode ); - } - ++i; - } - str = result; - - str.replace( QLatin1String( "\"" ), QLatin1String( "\\\"" ) ); - str.replace( QLatin1String( "\b" ), QLatin1String( "\\b" ) ); - str.replace( QLatin1String( "\f" ), QLatin1String( "\\f" ) ); - str.replace( QLatin1String( "\n" ), QLatin1String( "\\n" ) ); - str.replace( QLatin1String( "\r" ), QLatin1String( "\\r" ) ); - str.replace( QLatin1String( "\t" ), QLatin1String( "\\t" ) ); - - return QString( QLatin1String( "\"%1\"" ) ).arg( str ); -} - -Serializer::Serializer() - : d( new SerializerPrivate ) -{ -} - -Serializer::~Serializer() { - delete d; -} - -void Serializer::serialize( const QVariant& v, QIODevice* io, bool* ok) -{ - Q_ASSERT( io ); - *ok = true; - - if (!io->isOpen()) { - if (!io->open(QIODevice::WriteOnly)) { - d->errorMessage = QLatin1String("Error opening device"); - *ok = false; - return; - } - } - - if (!io->isWritable()) { - d->errorMessage = QLatin1String("Device is not readable"); - io->close(); - *ok = false; - return; - } - - const QByteArray str = serialize( v, ok); - if (*ok && (io->write(str) != str.count())) { - *ok = false; - d->errorMessage = QLatin1String("Something went wrong while writing to IO device"); - } -} - -QByteArray Serializer::serialize( const QVariant &v) -{ - bool ok; - - return serialize(v, &ok); -} - -QByteArray Serializer::serialize( const QVariant &v, bool *ok) -{ - bool _ok = true; - d->errorMessage.clear(); - - if (ok) { - *ok = true; - } else { - ok = &_ok; - } - - return d->serialize(v, ok); -} - -void QJson::Serializer::allowSpecialNumbers(bool allow) { - d->specialNumbersAllowed = allow; -} - -bool QJson::Serializer::specialNumbersAllowed() const { - return d->specialNumbersAllowed; -} - -void QJson::Serializer::setIndentMode(IndentMode mode) { - d->indentMode = mode; -} - -void QJson::Serializer::setDoublePrecision(int precision) { - d->doublePrecision = precision; -} - -IndentMode QJson::Serializer::indentMode() const { - return d->indentMode; -} - -QString QJson::Serializer::errorMessage() const { - return d->errorMessage; -} - diff --git a/src/http/qjson/serializer.h b/src/http/qjson/serializer.h deleted file mode 100644 index af4ce49d2..000000000 --- a/src/http/qjson/serializer.h +++ /dev/null @@ -1,191 +0,0 @@ -/* This file is part of qjson - * - * Copyright (C) 2009 Till Adam - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QJSON_SERIALIZER_H -#define QJSON_SERIALIZER_H - -#include "qjson_export.h" - -QT_BEGIN_NAMESPACE -class QIODevice; -class QString; -class QVariant; -QT_END_NAMESPACE - -namespace QJson { - /** - @brief How the indentation should work. - \verbatim - none (default) : { "foo" : 0, "foo1" : 1, "foo2" : [ { "foo3" : 3, "foo4" : 4 } ] } - - compact : {"foo":0,"foo1":1,"foo2":[{"foo3":3,"foo4":4}]} - - minimum : { "foo" : 0, "foo1" : 1, "foo2" : [ - { "foo3" : 3, "foo4" : 4 } - ] } - - medium : { - "foo" : 0, "foo1" : 1, "foo2" : [ - { - "foo3" : 3, "foo4" : 4 - } - ] - } - full : { - "foo" : 0, - "foo1" : 1, - "foo2" : [ - { - "foo3" : 3, - "foo4" : 4 - } - ] - } - - \endverbatim - */ - enum IndentMode { - IndentNone, - IndentCompact, - IndentMinimum, - IndentMedium, - IndentFull - }; - /** - * @brief Main class used to convert QVariant objects to JSON data. - * - * QVariant objects are converted to a string containing the JSON data. - * - * - * Usage: - * - * \code - * QVariantList people; - * - * QVariantMap bob; - * bob.insert("Name", "Bob"); - * bob.insert("Phonenumber", 123); - * - * QVariantMap alice; - * alice.insert("Name", "Alice"); - * alice.insert("Phonenumber", 321); - * - * people << bob << alice; - * - * QJson::Serializer serializer; - * bool ok; - * QByteArray json = serializer.serialize(people, &ok); - * - * if (ok) { - * qDebug() << json; - * } else { - * qCritical() << "Something went wrong:" << serializer.errorMessage(); - * } - * \endcode - * - * The output will be: - * - * \code - * "[ { "Name" : "Bob", "Phonenumber" : 123 }, - * { "Name" : "Alice", "Phonenumber" : 321 } ]" - * \endcode - * - * It's possible to tune the indentation level of the resulting string. \sa setIndentMode - */ - class QJSON_EXPORT Serializer { - public: - Serializer(); - ~Serializer(); - - /** - * This method generates a textual JSON representation and outputs it to the - * passed in I/O Device. - * @param variant The JSON document in its in-memory representation as generated by the - * parser. - * @param out Input output device - * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true - */ - void serialize( const QVariant& variant, QIODevice* out, bool* ok); - - /** - * This is a method provided for convenience. It turns the passed in in-memory - * representation of the JSON document into a textual one, which is returned. - * If the returned string is empty, the document was empty. If it was null, there - * was a parsing error. - * - * @param variant The JSON document in its in-memory representation as generated by the - * parser. - * - * \deprecated This method is going to be removed with the next major release of QJson. - */ - QByteArray serialize( const QVariant& variant); - - /** - * This is a method provided for convenience. It turns the passed in in-memory - * representation of the JSON document into a textual one, which is returned. - * If the returned string is empty, the document was empty. If it was null, there - * was a parsing error. - * - * @param variant The JSON document in its in-memory representation as generated by the - * parser. - * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true - */ - QByteArray serialize( const QVariant& variant, bool *ok); - - /** - * Allow or disallow writing of NaN and/or Infinity (as an extension to QJson) - */ - void allowSpecialNumbers(bool allow); - - /** - * Is Nan and/or Infinity allowed? - */ - bool specialNumbersAllowed() const; - - /** - * set output indentation mode as defined in QJson::IndentMode - */ - void setIndentMode(IndentMode mode = QJson::IndentNone); - - - /** - * set double precision used while converting Double - * \sa QByteArray::number - */ - void setDoublePrecision(int precision); - - /** - * Returns one of the indentation modes defined in QJson::IndentMode - */ - IndentMode indentMode() const; - - /** - * Returns the error message - */ - QString errorMessage() const; - - private: - Q_DISABLE_COPY(Serializer) - class SerializerPrivate; - SerializerPrivate* const d; - }; -} - -#endif // QJSON_SERIALIZER_H diff --git a/src/http/qjson/serializerrunnable.cpp b/src/http/qjson/serializerrunnable.cpp deleted file mode 100644 index b1894a238..000000000 --- a/src/http/qjson/serializerrunnable.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "serializerrunnable.h" - -/* This file is part of qjson - * - * Copyright (C) 2009 Flavio Castelli - * 2009 Frank Osterfeld - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "parserrunnable.h" -#include "serializer.h" - -#include -#include - -using namespace QJson; - -class SerializerRunnable::Private -{ -public: - QVariant json; -}; - -SerializerRunnable::SerializerRunnable(QObject* parent) - : QObject(parent), - QRunnable(), - d(new Private) -{ - qRegisterMetaType("QVariant"); -} - -SerializerRunnable::~SerializerRunnable() -{ - delete d; -} - -void SerializerRunnable::setJsonObject( const QVariant& json ) -{ - d->json = json; -} - -void SerializerRunnable::run() -{ - Serializer serializer; - bool ok; - const QByteArray serialized = serializer.serialize( d->json, &ok); - emit parsingFinished( serialized, ok, serializer.errorMessage() ); -} diff --git a/src/http/qjson/serializerrunnable.h b/src/http/qjson/serializerrunnable.h deleted file mode 100644 index 1a3df7c1c..000000000 --- a/src/http/qjson/serializerrunnable.h +++ /dev/null @@ -1,71 +0,0 @@ -/* This file is part of qjson - * - * Copyright (C) 2009 Frank Osterfeld - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SERIALIZERRUNNABLE_H -#define SERIALIZERRUNNABLE_H - -#include "qjson_export.h" - -#include -#include - -QT_BEGIN_NAMESPACE -class QByteArray; -class QString; -class QVariant; -QT_END_NAMESPACE - -namespace QJson { - /** - * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread - */ - class QJSON_EXPORT SerializerRunnable : public QObject, public QRunnable - { - Q_OBJECT - public: - explicit SerializerRunnable(QObject* parent = 0); - ~SerializerRunnable(); - - /** - * Sets the json object to serialize. - * - * @param json QVariant containing the json representation to be serialized - */ - void setJsonObject( const QVariant& json ); - - /* reimp */ void run(); - - Q_SIGNALS: - /** - * This signal is emitted when the serialization process has been completed - * @param serialized contains the result of the serialization - * @param ok if a serialization error occurs ok is set to false, otherwise it's set to true. - * @param error_msg contains a string explaining the failure reason - **/ - void parsingFinished(const QByteArray& serialized, bool ok, const QString& error_msg); - - private: - Q_DISABLE_COPY(SerializerRunnable) - class Private; - Private* const d; - }; -} - -#endif // SERIALIZERRUNNABLE_H diff --git a/src/http/qjson/stack.hh b/src/http/qjson/stack.hh deleted file mode 100644 index 590accbaf..000000000 --- a/src/http/qjson/stack.hh +++ /dev/null @@ -1,133 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.7. */ - -/* Stack handling for Bison parsers in C++ - - Copyright (C) 2002-2012 Free Software Foundation, Inc. - - 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 3 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, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/** - ** \file stack.hh - ** Define the yy::stack class. - */ - -#ifndef YY_YY_STACK_HH_INCLUDED -# define YY_YY_STACK_HH_INCLUDED - -# include - - -namespace yy { -/* Line 34 of stack.hh */ -#line 47 "stack.hh" - template > - class stack - { - public: - // Hide our reversed order. - typedef typename S::reverse_iterator iterator; - typedef typename S::const_reverse_iterator const_iterator; - - stack () : seq_ () - { - } - - stack (unsigned int n) : seq_ (n) - { - } - - inline - T& - operator [] (unsigned int i) - { - return seq_[i]; - } - - inline - const T& - operator [] (unsigned int i) const - { - return seq_[i]; - } - - inline - void - push (const T& t) - { - seq_.push_front (t); - } - - inline - void - pop (unsigned int n = 1) - { - for (; n; --n) - seq_.pop_front (); - } - - inline - unsigned int - height () const - { - return seq_.size (); - } - - inline const_iterator begin () const { return seq_.rbegin (); } - inline const_iterator end () const { return seq_.rend (); } - - private: - S seq_; - }; - - /// Present a slice of the top of a stack. - template > - class slice - { - public: - slice (const S& stack, unsigned int range) - : stack_ (stack) - , range_ (range) - { - } - - inline - const T& - operator [] (unsigned int i) const - { - return stack_[range_ - i]; - } - - private: - const S& stack_; - unsigned int range_; - }; - -} // yy -/* Line 116 of stack.hh */ -#line 132 "stack.hh" - -#endif /* !YY_YY_STACK_HH_INCLUDED */ From 5c71260c12798afe3c331d08477bb241acdb78ca Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 17:05:45 +0000 Subject: [PATCH 33/51] Squashed 'src/http/qjson/' content from commit c6d92ba git-subtree-dir: src/http/qjson git-subtree-split: c6d92bada76be2c46dcf6f585f03b2fba47f9da3 --- .gitignore | 7 + CMakeLists.txt | 121 + COPYING.lib | 504 +++ ChangeLog | 103 + QJSONConfig.cmake.in | 6 + QJSONConfigVersion.cmake.in | 9 + QJson.pc.in | 11 + README.license | 89 + README.md | 44 + cmake_uninstall.cmake.in | 17 + doc/Doxyfile | 1851 +++++++++ doc/footer.html | 32 + doc/header.html | 13 + doc/qjson.dox | 87 + include/QJson/Parser | 1 + include/QJson/QObjectHelper | 1 + include/QJson/Serializer | 1 + src/.gitignore | 3 + src/CMakeLists.txt | 61 + src/FlexLexer.h | 206 + src/json_parser.cc | 1103 +++++ src/json_parser.hh | 300 ++ src/json_parser.yy | 162 + src/json_scanner.cc | 4513 +++++++++++++++++++++ src/json_scanner.cpp | 82 + src/json_scanner.h | 66 + src/json_scanner.yy | 254 ++ src/location.hh | 181 + src/parser.cpp | 141 + src/parser.h | 99 + src/parser_p.h | 57 + src/parserrunnable.cpp | 68 + src/parserrunnable.h | 64 + src/position.hh | 172 + src/qjson_debug.h | 34 + src/qjson_export.h | 35 + src/qobjecthelper.cpp | 85 + src/qobjecthelper.h | 147 + src/serializer.cpp | 444 ++ src/serializer.h | 230 ++ src/serializerrunnable.cpp | 62 + src/serializerrunnable.h | 71 + src/stack.hh | 133 + tests/.gitignore | 1 + tests/CMakeLists.txt | 15 + tests/benchmarks/CMakeLists.txt | 38 + tests/benchmarks/parsingbenchmark.cpp | 55 + tests/benchmarks/qlocalevsstrtod_l.cpp | 70 + tests/cmdline_tester/.gitignore | 4 + tests/cmdline_tester/CMakeLists.txt | 35 + tests/cmdline_tester/cmdline_tester.cpp | 99 + tests/cmdline_tester/cmdlineparser.cpp | 170 + tests/cmdline_tester/cmdlineparser.h | 64 + tests/cmdline_tester/example.txt | 22 + tests/parser/.gitignore | 4 + tests/parser/CMakeLists.txt | 46 + tests/parser/testparser.cpp | 456 +++ tests/qobjecthelper/.gitignore | 5 + tests/qobjecthelper/CMakeLists.txt | 55 + tests/qobjecthelper/person.cpp | 75 + tests/qobjecthelper/person.h | 73 + tests/qobjecthelper/testqobjecthelper.cpp | 126 + tests/scanner/CMakeLists.txt | 47 + tests/scanner/testscanner.cpp | 256 ++ tests/serializer/.gitignore | 4 + tests/serializer/CMakeLists.txt | 46 + tests/serializer/testserializer.cpp | 542 +++ 67 files changed, 13978 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 COPYING.lib create mode 100644 ChangeLog create mode 100644 QJSONConfig.cmake.in create mode 100644 QJSONConfigVersion.cmake.in create mode 100644 QJson.pc.in create mode 100644 README.license create mode 100644 README.md create mode 100644 cmake_uninstall.cmake.in create mode 100644 doc/Doxyfile create mode 100644 doc/footer.html create mode 100644 doc/header.html create mode 100644 doc/qjson.dox create mode 100644 include/QJson/Parser create mode 100644 include/QJson/QObjectHelper create mode 100644 include/QJson/Serializer create mode 100644 src/.gitignore create mode 100644 src/CMakeLists.txt create mode 100644 src/FlexLexer.h create mode 100644 src/json_parser.cc create mode 100644 src/json_parser.hh create mode 100644 src/json_parser.yy create mode 100644 src/json_scanner.cc create mode 100644 src/json_scanner.cpp create mode 100644 src/json_scanner.h create mode 100644 src/json_scanner.yy create mode 100644 src/location.hh create mode 100644 src/parser.cpp create mode 100644 src/parser.h create mode 100644 src/parser_p.h create mode 100644 src/parserrunnable.cpp create mode 100644 src/parserrunnable.h create mode 100644 src/position.hh create mode 100644 src/qjson_debug.h create mode 100644 src/qjson_export.h create mode 100644 src/qobjecthelper.cpp create mode 100644 src/qobjecthelper.h create mode 100644 src/serializer.cpp create mode 100644 src/serializer.h create mode 100644 src/serializerrunnable.cpp create mode 100644 src/serializerrunnable.h create mode 100644 src/stack.hh create mode 100644 tests/.gitignore create mode 100644 tests/CMakeLists.txt create mode 100644 tests/benchmarks/CMakeLists.txt create mode 100644 tests/benchmarks/parsingbenchmark.cpp create mode 100644 tests/benchmarks/qlocalevsstrtod_l.cpp create mode 100644 tests/cmdline_tester/.gitignore create mode 100644 tests/cmdline_tester/CMakeLists.txt create mode 100644 tests/cmdline_tester/cmdline_tester.cpp create mode 100644 tests/cmdline_tester/cmdlineparser.cpp create mode 100644 tests/cmdline_tester/cmdlineparser.h create mode 100644 tests/cmdline_tester/example.txt create mode 100644 tests/parser/.gitignore create mode 100644 tests/parser/CMakeLists.txt create mode 100644 tests/parser/testparser.cpp create mode 100644 tests/qobjecthelper/.gitignore create mode 100644 tests/qobjecthelper/CMakeLists.txt create mode 100644 tests/qobjecthelper/person.cpp create mode 100644 tests/qobjecthelper/person.h create mode 100644 tests/qobjecthelper/testqobjecthelper.cpp create mode 100644 tests/scanner/CMakeLists.txt create mode 100644 tests/scanner/testscanner.cpp create mode 100644 tests/serializer/.gitignore create mode 100644 tests/serializer/CMakeLists.txt create mode 100644 tests/serializer/testserializer.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..a3ed5a764 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +lib +Makefile +doc/html + +# -- kdevelop +.kdev4 +*.kdev4 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..2e7d7258e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,121 @@ +PROJECT(qjson) + +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII" ) + +# Force cmake 2.8.8 in order to have a decent support of Qt5 +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) +CMAKE_POLICY(SET CMP0003 NEW) + +# Do not link against qtmain on Windows +cmake_policy(SET CMP0020 OLD) + +set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR}) + +IF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*") + ADD_DEFINITIONS("-DQT_NO_DEBUG_OUTPUT") +ENDIF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*") + +# Ability to disable verbose debug output +IF(QJSON_VERBOSE_DEBUG_OUTPUT) + ADD_DEFINITIONS("-DQJSON_VERBOSE_DEBUG_OUTPUT") +endif(QJSON_VERBOSE_DEBUG_OUTPUT) + +# On Windows debug library should have 'd' postfix. +IF (WIN32) + SET(CMAKE_DEBUG_POSTFIX "d") +ENDIF (WIN32) + +OPTION(OSX_FRAMEWORK "Build a Mac OS X Framework") +SET(FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/Library/Frameworks" + CACHE PATH "Where to place qjson.framework if OSX_FRAMEWORK is selected") + +# Don't use absolute path in qjson-targets-*.cmake +# (This will have no effect with CMake < 2.8) +SET(QT_USE_IMPORTED_TARGETS TRUE) + +option(QT4_BUILD "Force building with Qt4 even if Qt5 is found") +IF (NOT QT4_BUILD) + FIND_PACKAGE( Qt5Core QUIET ) +ENDIF() + +IF (Qt5Core_FOUND) + MESSAGE ("Qt5 found") + + INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS}) + ADD_DEFINITIONS(${Qt5Core_DEFINITIONS}) + + # Tell CMake to run moc when necessary: + set(CMAKE_AUTOMOC ON) + # As moc files are generated in the binary dir, tell CMake + # to always look for includes there: + set(CMAKE_INCLUDE_CURRENT_DIR ON) +ELSE() + MESSAGE ("Qt5 not found, searching for Qt4") + # Find Qt4 + FIND_PACKAGE( Qt4 REQUIRED ) + + # Include the cmake file needed to use qt4 + INCLUDE( ${QT_USE_FILE} ) + +ENDIF() + +IF (NOT WIN32) + SET( QT_DONT_USE_QTGUI TRUE ) +ENDIF() + + +#add extra search paths for libraries and includes +SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) +SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Directory where lib will install") +SET (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in") +SET (CMAKECONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${CMAKE_PROJECT_NAME}" CACHE PATH "Directory where to install QJSONConfig.cmake") + +set(QJSON_LIB_MAJOR_VERSION "0") +set(QJSON_LIB_MINOR_VERSION "8") +set(QJSON_LIB_PATCH_VERSION "1") + +set(QJSON_LIB_VERSION_STRING "${QJSON_LIB_MAJOR_VERSION}.${QJSON_LIB_MINOR_VERSION}.${QJSON_LIB_PATCH_VERSION}") + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) + +# pkg-config +IF (NOT WIN32) + CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/QJson.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/QJson.pc + @ONLY) + INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/QJson.pc + DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +ENDIF (NOT WIN32) + +# Subdirs +ADD_SUBDIRECTORY(src) +IF (KDE4_BUILD_TESTS OR QJSON_BUILD_TESTS) + enable_testing() + ADD_SUBDIRECTORY(tests) +ENDIF (KDE4_BUILD_TESTS OR QJSON_BUILD_TESTS) + +CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + +INSTALL(EXPORT qjson-export DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE QJSONTargets.cmake) + +# figure out the relative path from the installed Config.cmake file to the install prefix (which may be at +# runtime different from the chosen CMAKE_INSTALL_PREFIX if under Windows the package was installed anywhere) +# This relative path will be configured into the QJSONConfig.cmake +file(RELATIVE_PATH relInstallDir ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX} ) + +# cmake-modules +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/QJSONConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfig.cmake + @ONLY) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/QJSONConfigVersion.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfigVersion.cmake + @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfigVersion.cmake + DESTINATION "${CMAKECONFIG_INSTALL_DIR}") + +ADD_CUSTOM_TARGET(uninstall + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") diff --git a/COPYING.lib b/COPYING.lib new file mode 100644 index 000000000..08f25cd2f --- /dev/null +++ b/COPYING.lib @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1, as published by the Free Software Foundation. + + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 000000000..817d5849d --- /dev/null +++ b/ChangeLog @@ -0,0 +1,103 @@ +Mon Jan 28 23:01:40 CET 2013 Flavio Castelli + + * Fix compilation on BlackBerry 10. + +Tue Nov 27 11:04:12 CET 2012 Flavio Castelli + + * Relase 0.8.1: + - ensure API and ABI compatibility with 0.7.1 + +Thu Nov 22 21:20:11 CET 2012 Flavio Castelli + + * Fix unsafe pointer usage in Serializer::serialize() + +---------------------------------------------------------------------- +Wed Nov 21 22:01:51 CET 2012 Flavio Castelli + + * Version 0.8.0 released + +Tue Nov 20 11:19:49 CET 2012 Flavio Castelli + + * Serializer: handle QVariantHash + +Tue Oct 30 15:50:10 CET 2012 Flavio Castelli + + * Improve error handling inside of Serializer + * Serializer: handle quint16. + +Tue Jan 31 10:15:06 CET 2012 Flavio Castelli + + * Make possible to build qjson as an OS X framework. + +Fri Nov 04 16:50:56 CET 2011 Flavio Castelli + + * Make possible to set double precision during serialization. + +Wed Aug 24 17:58:56 CEST 2011 Flavio Castelli + + * Buildsystem adjustments, fix issues mentioned here: + - http://lists.kde.org/?l=kde-buildsystem&m=130947194605100&w=3 + - http://lists.kde.org/?l=kde-buildsystem&m=128835747626464&w=3 + The biggest difference now is that FindQJSON.cmake is not provided + anymore. Instead, QJSONConfig.cmake and QJSONConfigVersion.cmake are + installed and can be used in find_package(QJSON) calls. Applications + using QJson can write their own FindQJSON.cmake files if they need to. + +Fri Apr 23:04:29 CEST 2011 Flavio Castelli + + * Fixed QVariant de-serialization. QVariant properties were ignored + during QVariant -> QObject conversion. + +Sun Dec 18:59:28 CET 2010 Flavio Castelli + + * It's now possible to indent the output produced by the Serializer. + +Mon Sep 06 18:53:02 CEST 2010 Flavio Castelli + + * 50% performance improvement when parsing numbers. + +Sun Jul 04 15:41:08 CEST 2010 Flavio Castelli + + * fix make install when not installing as root + * provide "make uninstall" + +Tue Jun 15 13:16:57 CEST 2010 Flavio Castelli + + * Allow top level values + +---------------------------------------------------------------------- +Sat Mar 13 23:57:00 CEST 2009 - flavio@castelli.name + + * Merged the symbian branch into master, + +---------------------------------------------------------------------- +Sun Oct 11 19:18:00 CEST 2009 - flavio@castelli.name + + * Updated to 0.6.3: fixed a bug affecting ulonglong numbers serialization. + +------------------------------------------------------------------- +Wed Sep 15 19:21:00 CEST 2009 - flavio@castelli.name + + * Updated to 0.6.2: fixed a bug affecting ulonglong numbers parsing. + +------------------------------------------------------------------- +Wed Sep 09 09:55:00 CEST 2009 - flavio@castelli.name + + * Updated to 0.6.1: relevant bugs fixed. + * Moved the SerializerRunnable class inside QJson namespace. + * Fixed a bug in cmdline_tester. + +------------------------------------------------------------------- +Mon Jul 20 15:24:32 CEST 2009 - prusnak@suse.cz + + * Updated to 0.6.0 (KDE SVN rev 999750). + +------------------------------------------------------------------- +Mon Apr 07 00:00:00 UTC 2009 - flavio@castelli.name + + * Released 0.5.1 - added unicode support. + +------------------------------------------------------------------- +Mon Apr 03 00:00:00 UTC 2009 - flavio@castelli.name + + * First release. diff --git a/QJSONConfig.cmake.in b/QJSONConfig.cmake.in new file mode 100644 index 000000000..def072cbb --- /dev/null +++ b/QJSONConfig.cmake.in @@ -0,0 +1,6 @@ +GET_FILENAME_COMPONENT(myDir ${CMAKE_CURRENT_LIST_FILE} PATH) + +SET(QJSON_LIBRARIES qjson) +SET(QJSON_INCLUDE_DIR "@INCLUDE_INSTALL_DIR@") + +include(${myDir}/QJSONTargets.cmake) diff --git a/QJSONConfigVersion.cmake.in b/QJSONConfigVersion.cmake.in new file mode 100644 index 000000000..6005d2dc8 --- /dev/null +++ b/QJSONConfigVersion.cmake.in @@ -0,0 +1,9 @@ +SET(PACKAGE_VERSION "@QJSON_LIB_VERSION_STRING@") +IF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + SET(PACKAGE_VERSION_EXACT TRUE) +ENDIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) +IF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) + SET(PACKAGE_VERSION_COMPATIBLE TRUE) +ELSE (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) + SET(PACKAGE_VERSION_UNSUITABLE TRUE) +ENDIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) diff --git a/QJson.pc.in b/QJson.pc.in new file mode 100644 index 000000000..e4704bda7 --- /dev/null +++ b/QJson.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@LIB_INSTALL_DIR@ +includedir=@INCLUDE_INSTALL_DIR@ + +Name: QJson +Description: QJson is a qt-based library that maps JSON data to QVariant objects +Version: @QJSON_LIB_MAJOR_VERSION@.@QJSON_LIB_MINOR_VERSION@.@QJSON_LIB_PATCH_VERSION@ +Requires: QtCore +Libs: -L${libdir} -lqjson +Cflags: -I${includedir} \ No newline at end of file diff --git a/README.license b/README.license new file mode 100644 index 000000000..3ede31323 --- /dev/null +++ b/README.license @@ -0,0 +1,89 @@ +Qjson version xxxx, Date + +The following files are licensed under LGPL V2.1: +------------------------------------------------ +src/json_parser.yy +src/json_scanner.cpp +src/json_scanner.h +src/parser.cpp +src/parser.h +src/parser_p.h +src/parserrunnable.cpp +src/parserrunnable.h +src/qjson_debug.h +src/qjson_export.h +src/qobjecthelper.cpp +src/serializer.cpp +src/qobjecthelper.h +src/serializer.h +src/serializerrunnable.cpp +src/serializerrunnable.h +tests/cmdline_tester/cmdline_tester.cpp +tests/cmdline_tester/cmdlineparser.cpp +tests/cmdline_tester/cmdlineparser.h +tests/parser/testparser.cpp +tests/qobjecthelper/person.h +tests/qobjecthelper/testqobjecthelper.cpp +tests/serializer/testserializer.cpp + + +The following files are licensed under GPL V2 with Bison Exception: +-------------------------------------------------------------------- +/src/json_parser.cc +/src/stack.hh +/src/location.hh +/src/position.hh +/src/json_parser.hh + + +Copyrights: +---------- +Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +Copyright (C) 2009 Flavio Castelli 2009 Frank Osterfeld +Copyright (C) 2008 Flavio Castelli +Copyright (C) 2009 Till Adam +Copyright (C) 2009 Michael Leupold +Copyright (C) 2009 Flavio Castelli +Copyright (C) 2009 Frank Osterfeld +Copyright (C) 2009 Pino Toscano +Copyright (C) 2010 Flavio Castelli + + +GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999: +------------------------------------------------------------- + +Checkout COPYING.lib + + +GPL V2 with Bison Exception: +---------------------------- +Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + +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, 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. + +As a special exception, you may create a larger work that contains +part or all of the Bison parser skeleton and distribute that work +under terms of your choice, so long as that work isn't itself a +parser generator using the skeleton or a modified version thereof +as a parser skeleton. Alternatively, if you modify or redistribute +the parser skeleton itself, you may (at your option) remove this +special exception, which will cause the skeleton and the resulting +Bison output files to be licensed under the GNU General Public +License without this special exception. + +This special exception was added by the Free Software Foundation in +version 2.2 of Bison. + diff --git a/README.md b/README.md new file mode 100644 index 000000000..80ff3e9a2 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# QJson +JSON (JavaScript Object Notation) is a lightweight data-interchange format. +It can represents integer, real number, string, an ordered sequence of value, and a collection of name/value pairs. + +QJson is a qt-based library that maps JSON data to QVariant objects. +JSON arrays will be mapped to QVariantList instances, while JSON's objects will be mapped to QVariantMap. + +# Install + +QJson requires: + - Qt 4.0 or greater + - cmake 2.6 or greater + +Some possible cmake options: + - `-DCMAKE_BUILD_TYPE=DEBUG`: enables some debug output (other than making + easier to debug the code) + - `-DQJSON_BUILD_TESTS=yes` or `-DKDE4_BUILD_TESTS=yes`: builds the unit tests + - `-DCMAKE_INSTALL_PREFIX=${HOME}/testinstall`: install qjson in a custom directory + - `-DCMAKE_INCLUDE_PATH=${HOME}/testinstall/include`: include a custom include directory + - `-DCMAKE_LIBRARY_PATH=${HOME}/testinstall/lib`: include a custom library directory + - `-DLIB_DESTINATION=lib64`: if you have a 64 bit system with separate + libraries for 64 bit libraries + - `-DQJSON_VERBOSE_DEBUG_OUTPUT:BOOL=ON`: more debugging statements are + generated by the parser. It's useful only if you are trying to fix + the bison grammar. + +For Unix/Linux/Mac: + + mkdir build + cd build + cmake -DCMAKE_INSTALL_PREFIX=_preferred_path_ .. + make + make install + /sbin/ldconfig #if necessary + +# License + This library is licensed under the Lesser GNU General Public License version 2.1. + See the COPYING.lib file for more information. + +# Resources + +* [Website](http://qjson.sourceforge.net/) +* [Mailing List](https://lists.sourceforge.net/mailman/listinfo/qjson-devel) +* Project Lead/Maintainer (2008-current): [Flavio Castelli](mailto:flavio@castelli.name). diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 000000000..776e9c965 --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,17 @@ +IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +STRING(REGEX REPLACE "\n" ";" files "${files}") +FOREACH(file ${files}) + MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + IF(NOT "${rm_retval}" STREQUAL 0) + MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + ENDIF(NOT "${rm_retval}" STREQUAL 0) +ENDFOREACH(file) diff --git a/doc/Doxyfile b/doc/Doxyfile new file mode 100644 index 000000000..85c630c2b --- /dev/null +++ b/doc/Doxyfile @@ -0,0 +1,1851 @@ +# Doxyfile 1.8.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = QJson + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 0.8.1 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = the easiest way to manage JSON objects with Qt + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = ./ + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = YES + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = YES + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ./qjson.dox \ + ../src + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.vhd \ + *.vhdl \ + *.C \ + *.CC \ + *.C++ \ + *.II \ + *.I++ \ + *.H \ + *.HH \ + *.H++ \ + *.CS \ + *.PHP \ + *.PHP3 \ + *.M \ + *.MM \ + *.PY \ + *.F90 \ + *.F \ + *.VHD \ + *.VHDL + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = ./header.html + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = ./footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# style sheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = NO + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 1000 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = YES + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/doc/footer.html b/doc/footer.html new file mode 100644 index 000000000..fe2e2a770 --- /dev/null +++ b/doc/footer.html @@ -0,0 +1,32 @@ +
+ + + + + + + +
+ + SourceForge Logo + + hosts this site. + + + Send comments to:
+ QJson Developers +
+ + + + + + diff --git a/doc/header.html b/doc/header.html new file mode 100644 index 000000000..d0ca99369 --- /dev/null +++ b/doc/header.html @@ -0,0 +1,13 @@ + + + +QJson - a Qt based library for mapping JSON data to QVariant objects + + + + + + + QJson home page + +
diff --git a/doc/qjson.dox b/doc/qjson.dox new file mode 100644 index 000000000..ea84e7554 --- /dev/null +++ b/doc/qjson.dox @@ -0,0 +1,87 @@ +/** +\mainpage +\section _intro Introduction + +JSON (JavaScript Object Notation) + is a lightweight data-interchange format. +It can represents integer, real number, string, an ordered sequence of value, and +a collection of name/value pairs. + +QJson is a qt-based library that maps JSON data to QVariant objects. + +JSON arrays will be mapped to QVariantList instances, while JSON's objects will +be mapped to QVariantMap. + +\section _usage Usage +Converting JSON's data to QVariant instance is really simple: +\code +// create a JSonDriver instance +QJson::Parser parser; + +bool ok; + +// json is a QString containing the data to convert +QVariant result = parser.parse (json, &ok); +\endcode + +Suppose you're going to convert this JSON data: +\verbatim +{ + "encoding" : "UTF-8", + "plug-ins" : [ + "python", + "c++", + "ruby" + ], + "indent" : { "length" : 3, "use_space" : true } +} +\endverbatim + +The following code would convert the JSON data and parse it: +\code +QJson::Parser parser; +bool ok; + +QVariantMap result = parser.parse (json, &ok).toMap(); +if (!ok) { + qFatal("An error occured during parsing"); + exit (1); +} + +qDebug() << "encoding:" << result["encoding"].toString(); +qDebug() << "plugins:"; + +foreach (QVariant plugin, result["plug-ins"].toList()) { + qDebug() << "\t-" << plugin.toString(); +} + +QVariantMap nestedMap = result["indent"].toMap(); +qDebug() << "length:" << nestedMap["length"].toInt(); +qDebug() << "use_space:" << nestedMap["use_space"].toBool(); +\endcode +The output would be: +\verbatim +encoding: "UTF-8" +plugins: + - "python" + - "c++" + - "ruby" +length: 3 +use_space: true +\endverbatim + +The QJson::QObjectHelper class permits to serialize QObject instances into JSON. QJson::QObjectHelper also allows to +initialize a QObject using the values stored inside of a JSON object. + +\section _build Build instructions +QJson build system is based on cmake. Download QJson sources, extract them, move inside the sources directory and then: +\code +mkdir build +cd build +cmake .. +make +sudo make install +\endcode + +\author Flavio Castelli +*/ diff --git a/include/QJson/Parser b/include/QJson/Parser new file mode 100644 index 000000000..68f06e432 --- /dev/null +++ b/include/QJson/Parser @@ -0,0 +1 @@ +#include "../../src/parser.h" diff --git a/include/QJson/QObjectHelper b/include/QJson/QObjectHelper new file mode 100644 index 000000000..1b72c2e0a --- /dev/null +++ b/include/QJson/QObjectHelper @@ -0,0 +1 @@ +#include "../../src/qobjecthelper.h" diff --git a/include/QJson/Serializer b/include/QJson/Serializer new file mode 100644 index 000000000..2b7fe7a9e --- /dev/null +++ b/include/QJson/Serializer @@ -0,0 +1 @@ +#include "../../src/serializer.h" diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 000000000..04ec50a55 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,3 @@ +moc_* +*.o +Makefile diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..d2f2ebe66 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,61 @@ +# add_custom_command (OUTPUT ${qjson_SOURCE_DIR}/lib/json_parser.cc +# PRE_BUILD +# COMMAND bison -t -o json_parser.cc -d json_parser.yy +# DEPENDS json_parser.yy +# WORKING_DIRECTORY ${qjson_SOURCE_DIR}/lib/ +# ) + +# To regenerate json_scanner.cc use: +# flex json_scanner.yy + +set(qjson_MOC_HDRS + parserrunnable.h + serializerrunnable.h +) + +IF (NOT Qt5Core_FOUND) + qt4_wrap_cpp(qjson_MOC_SRCS ${qjson_MOC_HDRS}) +ENDIF() + +set (qjson_SRCS parser.cpp qobjecthelper.cpp json_scanner.cpp json_parser.cc parserrunnable.cpp serializer.cpp serializerrunnable.cpp) +set (qjson_HEADERS parser.h parserrunnable.h qobjecthelper.h serializer.h serializerrunnable.h qjson_export.h) + +# Required to use the intree copy of FlexLexer.h +INCLUDE_DIRECTORIES(.) + +add_library (qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS}) +IF (Qt5Core_FOUND) + target_link_libraries( qjson ${Qt5Core_LIBRARIES}) +ELSE() + target_link_libraries( qjson ${QT_LIBRARIES}) +ENDIF() + +if(NOT android) + set_target_properties(qjson PROPERTIES + VERSION ${QJSON_LIB_MAJOR_VERSION}.${QJSON_LIB_MINOR_VERSION}.${QJSON_LIB_PATCH_VERSION} + SOVERSION ${QJSON_LIB_MAJOR_VERSION} + ) +endif() +set_target_properties(qjson PROPERTIES + DEFINE_SYMBOL QJSON_MAKEDLL + PUBLIC_HEADER "${qjson_HEADERS}" + FRAMEWORK ${OSX_FRAMEWORK} + ) + +INSTALL(TARGETS qjson EXPORT qjson-export + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} + FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR} + PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/qjson +) + +if(MSVC) + get_target_property(LOCATION qjson LOCATION_DEBUG) + string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}") + install(FILES ${LOCATION} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin CONFIGURATIONS Debug) + + get_target_property(LOCATION qjson LOCATION_RELWITHDEBINFO) + string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}") + install(FILES ${LOCATION} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin CONFIGURATIONS RelWithDebInfo) +endif(MSVC) diff --git a/src/FlexLexer.h b/src/FlexLexer.h new file mode 100644 index 000000000..bad4ce03f --- /dev/null +++ b/src/FlexLexer.h @@ -0,0 +1,206 @@ +// -*-C++-*- +// FlexLexer.h -- define interfaces for lexical analyzer classes generated +// by flex + +// Copyright (c) 1993 The Regents of the University of California. +// All rights reserved. +// +// This code is derived from software contributed to Berkeley by +// Kent Williams and Tom Epperly. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: + +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. + +// Neither the name of the University nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE. + +// This file defines FlexLexer, an abstract class which specifies the +// external interface provided to flex C++ lexer objects, and yyFlexLexer, +// which defines a particular lexer class. +// +// If you want to create multiple lexer classes, you use the -P flag +// to rename each yyFlexLexer to some other xxFlexLexer. You then +// include in your other sources once per lexer class: +// +// #undef yyFlexLexer +// #define yyFlexLexer xxFlexLexer +// #include +// +// #undef yyFlexLexer +// #define yyFlexLexer zzFlexLexer +// #include +// ... + +#ifndef __FLEX_LEXER_H +// Never included before - need to define base class. +#define __FLEX_LEXER_H + +#include +# ifndef FLEX_STD +# define FLEX_STD std:: +# endif + +extern "C++" { + +struct yy_buffer_state; +typedef int yy_state_type; + +class FlexLexer { +public: + virtual ~FlexLexer() { } + + const char* YYText() const { return yytext; } + int YYLeng() const { return yyleng; } + + virtual void + yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; + virtual struct yy_buffer_state* + yy_create_buffer( FLEX_STD istream* s, int size ) = 0; + virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; + virtual void yyrestart( FLEX_STD istream* s ) = 0; + + virtual int yylex() = 0; + + // Call yylex with new input/output sources. + int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ) + { + switch_streams( new_in, new_out ); + return yylex(); + } + + // Switch to new input/output streams. A nil stream pointer + // indicates "keep the current one". + virtual void switch_streams( FLEX_STD istream* new_in = 0, + FLEX_STD ostream* new_out = 0 ) = 0; + + int lineno() const { return yylineno; } + + int debug() const { return yy_flex_debug; } + void set_debug( int flag ) { yy_flex_debug = flag; } + +protected: + char* yytext; + int yyleng; + int yylineno; // only maintained if you use %option yylineno + int yy_flex_debug; // only has effect with -d or "%option debug" +}; + +} +#endif // FLEXLEXER_H + +#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) +// Either this is the first time through (yyFlexLexerOnce not defined), +// or this is a repeated include to define a different flavor of +// yyFlexLexer, as discussed in the flex manual. +#define yyFlexLexerOnce + +extern "C++" { + +class yyFlexLexer : public FlexLexer { +public: + // arg_yyin and arg_yyout default to the cin and cout, but we + // only make that assignment when initializing in yylex(). + yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 ); + + virtual ~yyFlexLexer(); + + void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); + struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size ); + void yy_delete_buffer( struct yy_buffer_state* b ); + void yyrestart( FLEX_STD istream* s ); + + void yypush_buffer_state( struct yy_buffer_state* new_buffer ); + void yypop_buffer_state(); + + virtual int yylex(); + virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ); + virtual int yywrap(); + +protected: + virtual int LexerInput( char* buf, int max_size ); + virtual void LexerOutput( const char* buf, int size ); + virtual void LexerError( const char* msg ); + + void yyunput( int c, char* buf_ptr ); + int yyinput(); + + void yy_load_buffer_state(); + void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s ); + void yy_flush_buffer( struct yy_buffer_state* b ); + + int yy_start_stack_ptr; + int yy_start_stack_depth; + int* yy_start_stack; + + void yy_push_state( int new_state ); + void yy_pop_state(); + int yy_top_state(); + + yy_state_type yy_get_previous_state(); + yy_state_type yy_try_NUL_trans( yy_state_type current_state ); + int yy_get_next_buffer(); + + FLEX_STD istream* yyin; // input source for default LexerInput + FLEX_STD ostream* yyout; // output sink for default LexerOutput + + // yy_hold_char holds the character lost when yytext is formed. + char yy_hold_char; + + // Number of characters read into yy_ch_buf. + int yy_n_chars; + + // Points to current character in buffer. + char* yy_c_buf_p; + + int yy_init; // whether we need to initialize + int yy_start; // start state number + + // Flag which is used to allow yywrap()'s to do buffer switches + // instead of setting up a fresh yyin. A bit of a hack ... + int yy_did_buffer_switch_on_eof; + + + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ + void yyensure_buffer_stack(void); + + // The following are not always needed, but may be depending + // on use of certain flex features (like REJECT or yymore()). + + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + yy_state_type* yy_state_buf; + yy_state_type* yy_state_ptr; + + char* yy_full_match; + int* yy_full_state; + int yy_full_lp; + + int yy_lp; + int yy_looking_for_trail_begin; + + int yy_more_flag; + int yy_more_len; + int yy_more_offset; + int yy_prev_more_offset; +}; + +} + +#endif // yyFlexLexer || ! yyFlexLexerOnce + diff --git a/src/json_parser.cc b/src/json_parser.cc new file mode 100644 index 000000000..84fdfac73 --- /dev/null +++ b/src/json_parser.cc @@ -0,0 +1,1103 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Skeleton implementation for Bison LALR(1) parsers in C++ + + Copyright (C) 2002-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* First part of user declarations. */ + +/* Line 279 of lalr1.cc */ +#line 38 "json_parser.cc" + + +#include "json_parser.hh" + +/* User implementation prologue. */ + +/* Line 285 of lalr1.cc */ +#line 46 "json_parser.cc" + + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* FIXME: INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +# ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).begin = YYRHSLOC (Rhs, 1).begin; \ + (Current).end = YYRHSLOC (Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ + } \ + while (/*CONSTCOND*/ false) +# endif + + +/* Suppress unused-variable warnings by "using" E. */ +#define YYUSE(e) ((void) (e)) + +/* Enable debugging if requested. */ +#if YYDEBUG + +/* A pseudo ostream that takes yydebug_ into account. */ +# define YYCDEBUG if (yydebug_) (*yycdebug_) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug_) \ + { \ + *yycdebug_ << Title << ' '; \ + yy_symbol_print_ ((Type), (Value), (Location)); \ + *yycdebug_ << std::endl; \ + } \ +} while (false) + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug_) \ + yy_reduce_print_ (Rule); \ +} while (false) + +# define YY_STACK_PRINT() \ +do { \ + if (yydebug_) \ + yystack_print_ (); \ +} while (false) + +#else /* !YYDEBUG */ + +# define YYCDEBUG if (false) std::cerr +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type) +# define YY_REDUCE_PRINT(Rule) static_cast(0) +# define YY_STACK_PRINT() static_cast(0) + +#endif /* !YYDEBUG */ + +#define yyerrok (yyerrstatus_ = 0) +#define yyclearin (yychar = yyempty_) + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab +#define YYRECOVERING() (!!yyerrstatus_) + + +namespace yy { +/* Line 353 of lalr1.cc */ +#line 141 "json_parser.cc" + + /* Return YYSTR after stripping away unnecessary quotes and + backslashes, so that it's suitable for yyerror. The heuristic is + that double-quoting is unnecessary unless the string contains an + apostrophe, a comma, or backslash (other than backslash-backslash). + YYSTR is taken from yytname. */ + std::string + json_parser::yytnamerr_ (const char *yystr) + { + if (*yystr == '"') + { + std::string yyr = ""; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + yyr += *yyp; + break; + + case '"': + return yyr; + } + do_not_strip_quotes: ; + } + + return yystr; + } + + + /// Build a parser object. + json_parser::json_parser (QJson::ParserPrivate* driver_yyarg) + : +#if YYDEBUG + yydebug_ (false), + yycdebug_ (&std::cerr), +#endif + driver (driver_yyarg) + { + } + + json_parser::~json_parser () + { + } + +#if YYDEBUG + /*--------------------------------. + | Print this symbol on YYOUTPUT. | + `--------------------------------*/ + + inline void + json_parser::yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yyvaluep); + std::ostream& yyo = debug_stream (); + std::ostream& yyoutput = yyo; + YYUSE (yyoutput); + switch (yytype) + { + default: + break; + } + } + + + void + json_parser::yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") + << ' ' << yytname_[yytype] << " (" + << *yylocationp << ": "; + yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); + *yycdebug_ << ')'; + } +#endif + + void + json_parser::yydestruct_ (const char* yymsg, + int yytype, semantic_type* yyvaluep, location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yymsg); + YYUSE (yyvaluep); + + if (yymsg) + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } + } + + void + json_parser::yypop_ (unsigned int n) + { + yystate_stack_.pop (n); + yysemantic_stack_.pop (n); + yylocation_stack_.pop (n); + } + +#if YYDEBUG + std::ostream& + json_parser::debug_stream () const + { + return *yycdebug_; + } + + void + json_parser::set_debug_stream (std::ostream& o) + { + yycdebug_ = &o; + } + + + json_parser::debug_level_type + json_parser::debug_level () const + { + return yydebug_; + } + + void + json_parser::set_debug_level (debug_level_type l) + { + yydebug_ = l; + } +#endif + + inline bool + json_parser::yy_pact_value_is_default_ (int yyvalue) + { + return yyvalue == yypact_ninf_; + } + + inline bool + json_parser::yy_table_value_is_error_ (int yyvalue) + { + return yyvalue == yytable_ninf_; + } + + int + json_parser::parse () + { + /// Lookahead and lookahead in internal form. + int yychar = yyempty_; + int yytoken = 0; + + // State. + int yyn; + int yylen = 0; + int yystate = 0; + + // Error handling. + int yynerrs_ = 0; + int yyerrstatus_ = 0; + + /// Semantic value of the lookahead. + static semantic_type yyval_default; + semantic_type yylval = yyval_default; + /// Location of the lookahead. + location_type yylloc; + /// The locations where the error started and ended. + location_type yyerror_range[3]; + + /// $$. + semantic_type yyval; + /// @$. + location_type yyloc; + + int yyresult; + + // FIXME: This shoud be completely indented. It is not yet to + // avoid gratuitous conflicts when merging into the master branch. + try + { + YYCDEBUG << "Starting parse" << std::endl; + + + /* Initialize the stacks. The initial state will be pushed in + yynewstate, since the latter expects the semantical and the + location values to have been already stored, initialize these + stacks with a primary value. */ + yystate_stack_ = state_stack_type (0); + yysemantic_stack_ = semantic_stack_type (0); + yylocation_stack_ = location_stack_type (0); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); + + /* New state. */ + yynewstate: + yystate_stack_.push (yystate); + YYCDEBUG << "Entering state " << yystate << std::endl; + + /* Accept? */ + if (yystate == yyfinal_) + goto yyacceptlab; + + goto yybackup; + + /* Backup. */ + yybackup: + + /* Try to take a decision without lookahead. */ + yyn = yypact_[yystate]; + if (yy_pact_value_is_default_ (yyn)) + goto yydefault; + + /* Read a lookahead token. */ + if (yychar == yyempty_) + { + YYCDEBUG << "Reading a token: "; + yychar = yylex (&yylval, &yylloc, driver); + } + + /* Convert token to internal form. */ + if (yychar <= yyeof_) + { + yychar = yytoken = yyeof_; + YYCDEBUG << "Now at end of input." << std::endl; + } + else + { + yytoken = yytranslate_ (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) + goto yydefault; + + /* Reduce or error. */ + yyn = yytable_[yyn]; + if (yyn <= 0) + { + if (yy_table_value_is_error_ (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the token being shifted. */ + yychar = yyempty_; + + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus_) + --yyerrstatus_; + + yystate = yyn; + goto yynewstate; + + /*-----------------------------------------------------------. + | yydefault -- do the default action for the current state. | + `-----------------------------------------------------------*/ + yydefault: + yyn = yydefact_[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + /*-----------------------------. + | yyreduce -- Do a reduction. | + `-----------------------------*/ + yyreduce: + yylen = yyr2_[yyn]; + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. Otherwise, use the top of the stack. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. */ + if (yylen) + yyval = yysemantic_stack_[yylen - 1]; + else + yyval = yysemantic_stack_[0]; + + // Compute the default @$. + { + slice slice (yylocation_stack_, yylen); + YYLLOC_DEFAULT (yyloc, slice, yylen); + } + + // Perform the reduction. + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +/* Line 670 of lalr1.cc */ +#line 82 "json_parser.yy" + { + driver->m_result = (yysemantic_stack_[(1) - (1)]); + qjsonDebug() << "json_parser - parsing finished"; + } + break; + + case 3: +/* Line 670 of lalr1.cc */ +#line 87 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(1) - (1)]); } + break; + + case 4: +/* Line 670 of lalr1.cc */ +#line 89 "json_parser.yy" + { + qCritical()<< "json_parser - syntax error found, " + << "forcing abort, Line" << (yyloc).begin.line << "Column" << (yyloc).begin.column; + YYABORT; + } + break; + + case 6: +/* Line 670 of lalr1.cc */ +#line 96 "json_parser.yy" + { + (yyval) = QVariant(QVariantMap()); + } + break; + + case 7: +/* Line 670 of lalr1.cc */ +#line 99 "json_parser.yy" + { + QVariantMap* map = (yysemantic_stack_[(3) - (2)]).value(); + (yyval) = QVariant(*map); + delete map; + } + break; + + case 8: +/* Line 670 of lalr1.cc */ +#line 105 "json_parser.yy" + { + QVariantMap* pair = new QVariantMap(); + pair->insert((yysemantic_stack_[(3) - (1)]).toString(), (yysemantic_stack_[(3) - (3)])); + (yyval).setValue(pair); + } + break; + + case 9: +/* Line 670 of lalr1.cc */ +#line 110 "json_parser.yy" + { + (yyval).value()->insert((yysemantic_stack_[(5) - (3)]).toString(), (yysemantic_stack_[(5) - (5)])); + } + break; + + case 10: +/* Line 670 of lalr1.cc */ +#line 114 "json_parser.yy" + { + (yyval) = QVariant(QVariantList()); + } + break; + + case 11: +/* Line 670 of lalr1.cc */ +#line 117 "json_parser.yy" + { + QVector* list = (yysemantic_stack_[(3) - (2)]).value* >(); + (yyval) = QVariant(list->toList()); + delete list; + } + break; + + case 12: +/* Line 670 of lalr1.cc */ +#line 123 "json_parser.yy" + { + QVector* list = new QVector(1); + list->replace(0, (yysemantic_stack_[(1) - (1)])); + (yyval).setValue(list); + } + break; + + case 13: +/* Line 670 of lalr1.cc */ +#line 128 "json_parser.yy" + { + (yyval).value* >()->append((yysemantic_stack_[(3) - (3)])); + } + break; + + +/* Line 670 of lalr1.cc */ +#line 549 "json_parser.cc" + default: + break; + } + + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action + invokes YYABORT, YYACCEPT, or YYERROR immediately after altering + yychar. In the case of YYABORT or YYACCEPT, an incorrect + destructor might then be invoked immediately. In the case of + YYERROR, subsequent parser actions might lead to an incorrect + destructor call or verbose syntax error message before the + lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); + + yypop_ (yylen); + yylen = 0; + YY_STACK_PRINT (); + + yysemantic_stack_.push (yyval); + yylocation_stack_.push (yyloc); + + /* Shift the result of the reduction. */ + yyn = yyr1_[yyn]; + yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; + if (0 <= yystate && yystate <= yylast_ + && yycheck_[yystate] == yystate_stack_[0]) + yystate = yytable_[yystate]; + else + yystate = yydefgoto_[yyn - yyntokens_]; + goto yynewstate; + + /*------------------------------------. + | yyerrlab -- here on detecting error | + `------------------------------------*/ + yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yytranslate_ (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus_) + { + ++yynerrs_; + if (yychar == yyempty_) + yytoken = yyempty_; + error (yylloc, yysyntax_error_ (yystate, yytoken)); + } + + yyerror_range[1] = yylloc; + if (yyerrstatus_ == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + if (yychar <= yyeof_) + { + /* Return failure if at end of input. */ + if (yychar == yyeof_) + YYABORT; + } + else + { + yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); + yychar = yyempty_; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + + /*---------------------------------------------------. + | yyerrorlab -- error raised explicitly by YYERROR. | + `---------------------------------------------------*/ + yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (false) + goto yyerrorlab; + + yyerror_range[1] = yylocation_stack_[yylen - 1]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + yypop_ (yylen); + yylen = 0; + yystate = yystate_stack_[0]; + goto yyerrlab1; + + /*-------------------------------------------------------------. + | yyerrlab1 -- common code for both syntax error and YYERROR. | + `-------------------------------------------------------------*/ + yyerrlab1: + yyerrstatus_ = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact_[yystate]; + if (!yy_pact_value_is_default_ (yyn)) + { + yyn += yyterror_; + if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) + { + yyn = yytable_[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yystate_stack_.height () == 1) + YYABORT; + + yyerror_range[1] = yylocation_stack_[0]; + yydestruct_ ("Error: popping", + yystos_[yystate], + &yysemantic_stack_[0], &yylocation_stack_[0]); + yypop_ (); + yystate = yystate_stack_[0]; + YY_STACK_PRINT (); + } + + yyerror_range[2] = yylloc; + // Using YYLLOC is tempting, but would change the location of + // the lookahead. YYLOC is available though. + YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yyloc); + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], + &yysemantic_stack_[0], &yylocation_stack_[0]); + + yystate = yyn; + goto yynewstate; + + /* Accept. */ + yyacceptlab: + yyresult = 0; + goto yyreturn; + + /* Abort. */ + yyabortlab: + yyresult = 1; + goto yyreturn; + + yyreturn: + if (yychar != yyempty_) + { + /* Make sure we have latest lookahead translation. See comments + at user semantic actions for why this is necessary. */ + yytoken = yytranslate_ (yychar); + yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, + &yylloc); + } + + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + yypop_ (yylen); + while (1 < yystate_stack_.height ()) + { + yydestruct_ ("Cleanup: popping", + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); + } + + return yyresult; + } + catch (...) + { + YYCDEBUG << "Exception caught: cleaning lookahead and stack" + << std::endl; + // Do not try to display the values of the reclaimed symbols, + // as their printer might throw an exception. + if (yychar != yyempty_) + { + /* Make sure we have latest lookahead translation. See + comments at user semantic actions for why this is + necessary. */ + yytoken = yytranslate_ (yychar); + yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc); + } + + while (1 < yystate_stack_.height ()) + { + yydestruct_ (YY_NULL, + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); + } + throw; + } + } + + // Generate an error message. + std::string + json_parser::yysyntax_error_ (int yystate, int yytoken) + { + std::string yyres; + // Number of reported tokens (one for the "unexpected", one per + // "expected"). + size_t yycount = 0; + // Its maximum. + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + // Arguments of yyformat. + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yytoken) is + if this state is a consistent state with a default action. + Thus, detecting the absence of a lookahead is sufficient to + determine that there is no unexpected or expected token to + report. In that case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is + a consistent state with a default action. There might have + been a previous inconsistent state, consistent state with a + non-default action, or user semantic action that manipulated + yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state + merging (from LALR or IELR) and default reductions corrupt the + expected token list. However, the list is correct for + canonical LR with one exception: it will still contain any + token that will not be accepted due to an error action in a + later state. + */ + if (yytoken != yyempty_) + { + yyarg[yycount++] = yytname_[yytoken]; + int yyn = yypact_[yystate]; + if (!yy_pact_value_is_default_ (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + for (int yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ + && !yy_table_value_is_error_ (yytable_[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + break; + } + else + yyarg[yycount++] = yytname_[yyx]; + } + } + } + + char const* yyformat = YY_NULL; + switch (yycount) + { +#define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +#undef YYCASE_ + } + + // Argument number. + size_t yyi = 0; + for (char const* yyp = yyformat; *yyp; ++yyp) + if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) + { + yyres += yytnamerr_ (yyarg[yyi++]); + ++yyp; + } + else + yyres += *yyp; + return yyres; + } + + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ + const signed char json_parser::yypact_ninf_ = -5; + const signed char + json_parser::yypact_[] = + { + 1, -5, -5, 3, 18, -5, -5, -5, -5, -5, + 8, -5, -5, -5, -5, -5, 2, 11, -5, -3, + -5, -5, 29, -5, 4, -5, 29, -5, 13, -5, + 29, -5 + }; + + /* YYDEFACT[S] -- default reduction number in state S. Performed when + YYTABLE doesn't specify something else to do. Zero means the + default is an error. */ + const unsigned char + json_parser::yydefact_[] = + { + 0, 5, 4, 0, 0, 15, 16, 17, 18, 14, + 0, 2, 19, 20, 3, 6, 0, 0, 10, 0, + 12, 1, 0, 7, 0, 11, 0, 8, 0, 13, + 0, 9 + }; + + /* YYPGOTO[NTERM-NUM]. */ + const signed char + json_parser::yypgoto_[] = + { + -5, -5, -5, -5, -5, -5, -5, -4 + }; + + /* YYDEFGOTO[NTERM-NUM]. */ + const signed char + json_parser::yydefgoto_[] = + { + -1, 10, 11, 12, 17, 13, 19, 14 + }; + + /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF_, syntax error. */ + const signed char json_parser::yytable_ninf_ = -1; + const unsigned char + json_parser::yytable_[] = + { + 20, 1, 2, 25, 3, 26, 4, 15, 21, 22, + 5, 6, 7, 8, 9, 23, 16, 28, 27, 24, + 30, 3, 29, 4, 18, 0, 31, 5, 6, 7, + 8, 9, 3, 0, 4, 0, 0, 0, 5, 6, + 7, 8, 9 + }; + + /* YYCHECK. */ + const signed char + json_parser::yycheck_[] = + { + 4, 0, 1, 6, 3, 8, 5, 4, 0, 7, + 9, 10, 11, 12, 13, 4, 13, 13, 22, 8, + 7, 3, 26, 5, 6, -1, 30, 9, 10, 11, + 12, 13, 3, -1, 5, -1, -1, -1, 9, 10, + 11, 12, 13 + }; + + /* STOS_[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ + const unsigned char + json_parser::yystos_[] = + { + 0, 0, 1, 3, 5, 9, 10, 11, 12, 13, + 16, 17, 18, 20, 22, 4, 13, 19, 6, 21, + 22, 0, 7, 4, 8, 6, 8, 22, 13, 22, + 7, 22 + }; + +#if YYDEBUG + /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding + to YYLEX-NUM. */ + const unsigned short int + json_parser::yytoken_number_[] = + { + 0, 256, 257, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12 + }; +#endif + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ + const unsigned char + json_parser::yyr1_[] = + { + 0, 15, 16, 17, 17, 17, 18, 18, 19, 19, + 20, 20, 21, 21, 22, 22, 22, 22, 22, 22, + 22 + }; + + /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ + const unsigned char + json_parser::yyr2_[] = + { + 0, 2, 1, 1, 1, 1, 2, 3, 3, 5, + 2, 3, 1, 3, 1, 1, 1, 1, 1, 1, + 1 + }; + + + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at \a yyntokens_, nonterminals. */ + const char* + const json_parser::yytname_[] = + { + "\"end of file\"", "error", "$undefined", "\"{\"", "\"}\"", "\"[\"", + "\"]\"", "\":\"", "\",\"", "\"number\"", "\"true\"", "\"false\"", + "\"null\"", "\"string\"", "\"invalid\"", "$accept", "start", "data", + "object", "members", "array", "values", "value", YY_NULL + }; + +#if YYDEBUG + /* YYRHS -- A `-1'-separated list of the rules' RHS. */ + const json_parser::rhs_number_type + json_parser::yyrhs_[] = + { + 16, 0, -1, 17, -1, 22, -1, 1, -1, 0, + -1, 3, 4, -1, 3, 19, 4, -1, 13, 7, + 22, -1, 19, 8, 13, 7, 22, -1, 5, 6, + -1, 5, 21, 6, -1, 22, -1, 21, 8, 22, + -1, 13, -1, 9, -1, 10, -1, 11, -1, 12, + -1, 18, -1, 20, -1 + }; + + /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ + const unsigned char + json_parser::yyprhs_[] = + { + 0, 0, 3, 5, 7, 9, 11, 14, 18, 22, + 28, 31, 35, 37, 41, 43, 45, 47, 49, 51, + 53 + }; + + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ + const unsigned char + json_parser::yyrline_[] = + { + 0, 82, 82, 87, 88, 94, 96, 99, 105, 110, + 114, 117, 123, 128, 132, 133, 134, 135, 136, 137, + 138 + }; + + // Print the state stack on the debug stream. + void + json_parser::yystack_print_ () + { + *yycdebug_ << "Stack now"; + for (state_stack_type::const_iterator i = yystate_stack_.begin (); + i != yystate_stack_.end (); ++i) + *yycdebug_ << ' ' << *i; + *yycdebug_ << std::endl; + } + + // Report on the debug stream that the rule \a yyrule is going to be reduced. + void + json_parser::yy_reduce_print_ (int yyrule) + { + unsigned int yylno = yyrline_[yyrule]; + int yynrhs = yyr2_[yyrule]; + /* Print the symbols being reduced, and their result. */ + *yycdebug_ << "Reducing stack by rule " << yyrule - 1 + << " (line " << yylno << "):" << std::endl; + /* The symbols being reduced. */ + for (int yyi = 0; yyi < yynrhs; yyi++) + YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", + yyrhs_[yyprhs_[yyrule] + yyi], + &(yysemantic_stack_[(yynrhs) - (yyi + 1)]), + &(yylocation_stack_[(yynrhs) - (yyi + 1)])); + } +#endif // YYDEBUG + + /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ + json_parser::token_number_type + json_parser::yytranslate_ (int t) + { + static + const token_number_type + translate_table[] = + { + 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2 + }; + if ((unsigned int) t <= yyuser_token_number_max_) + return translate_table[t]; + else + return yyundef_token_; + } + + const int json_parser::yyeof_ = 0; + const int json_parser::yylast_ = 42; + const int json_parser::yynnts_ = 8; + const int json_parser::yyempty_ = -2; + const int json_parser::yyfinal_ = 21; + const int json_parser::yyterror_ = 1; + const int json_parser::yyerrcode_ = 256; + const int json_parser::yyntokens_ = 15; + + const unsigned int json_parser::yyuser_token_number_max_ = 257; + const json_parser::token_number_type json_parser::yyundef_token_ = 2; + + +} // yy +/* Line 1141 of lalr1.cc */ +#line 1079 "json_parser.cc" +/* Line 1142 of lalr1.cc */ +#line 140 "json_parser.yy" + + +int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) +{ + JSonScanner* scanner = driver->m_scanner; + yylval->clear(); + int ret = scanner->yylex(yylval, yylloc); + + qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" + << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; + + return ret; +} + +void yy::json_parser::error (const yy::location& yyloc, const std::string& error) +{ + /*qjsonDebug() << yyloc.begin.line; + qjsonDebug() << yyloc.begin.column; + qjsonDebug() << yyloc.end.line; + qjsonDebug() << yyloc.end.column;*/ + qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; + driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); +} diff --git a/src/json_parser.hh b/src/json_parser.hh new file mode 100644 index 000000000..25e00fa1b --- /dev/null +++ b/src/json_parser.hh @@ -0,0 +1,300 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Skeleton interface for Bison LALR(1) parsers in C++ + + Copyright (C) 2002-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file json_parser.hh + ** Define the yy::parser class. + */ + +/* C++ LALR(1) parser skeleton written by Akim Demaille. */ + +#ifndef YY_YY_JSON_PARSER_HH_INCLUDED +# define YY_YY_JSON_PARSER_HH_INCLUDED + +/* "%code requires" blocks. */ +/* Line 33 of lalr1.cc */ +#line 26 "json_parser.yy" + + #include "parser_p.h" + #include "json_scanner.h" + #include "qjson_debug.h" + + #include + #include + #include + #include + + #include + + class JSonScanner; + + namespace QJson { + class Parser; + } + + #define YYERROR_VERBOSE 1 + + Q_DECLARE_METATYPE(QVector*) + Q_DECLARE_METATYPE(QVariantMap*) + + +/* Line 33 of lalr1.cc */ +#line 72 "json_parser.hh" + + +#include +#include +#include "stack.hh" +#include "location.hh" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif + + +namespace yy { +/* Line 33 of lalr1.cc */ +#line 88 "json_parser.hh" + + /// A Bison parser. + class json_parser + { + public: + /// Symbol semantic values. +#ifndef YYSTYPE + typedef int semantic_type; +#else + typedef YYSTYPE semantic_type; +#endif + /// Symbol locations. + typedef location location_type; + /// Tokens. + struct token + { + /* Tokens. */ + enum yytokentype { + END = 0, + CURLY_BRACKET_OPEN = 1, + CURLY_BRACKET_CLOSE = 2, + SQUARE_BRACKET_OPEN = 3, + SQUARE_BRACKET_CLOSE = 4, + COLON = 5, + COMMA = 6, + NUMBER = 7, + TRUE_VAL = 8, + FALSE_VAL = 9, + NULL_VAL = 10, + STRING = 11, + INVALID = 12 + }; + + }; + /// Token type. + typedef token::yytokentype token_type; + + /// Build a parser object. + json_parser (QJson::ParserPrivate* driver_yyarg); + virtual ~json_parser (); + + /// Parse. + /// \returns 0 iff parsing succeeded. + virtual int parse (); + +#if YYDEBUG + /// The current debugging stream. + std::ostream& debug_stream () const; + /// Set the current debugging stream. + void set_debug_stream (std::ostream &); + + /// Type for debugging levels. + typedef int debug_level_type; + /// The current debugging level. + debug_level_type debug_level () const; + /// Set the current debugging level. + void set_debug_level (debug_level_type l); +#endif + + private: + /// Report a syntax error. + /// \param loc where the syntax error is found. + /// \param msg a description of the syntax error. + virtual void error (const location_type& loc, const std::string& msg); + + /// Generate an error message. + /// \param state the state where the error occurred. + /// \param tok the lookahead token. + virtual std::string yysyntax_error_ (int yystate, int tok); + +#if YYDEBUG + /// \brief Report a symbol value on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); + /// \brief Report a symbol on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); +#endif + + + /// State numbers. + typedef int state_type; + /// State stack type. + typedef stack state_stack_type; + /// Semantic value stack type. + typedef stack semantic_stack_type; + /// location stack type. + typedef stack location_stack_type; + + /// The state stack. + state_stack_type yystate_stack_; + /// The semantic value stack. + semantic_stack_type yysemantic_stack_; + /// The location stack. + location_stack_type yylocation_stack_; + + /// Whether the given \c yypact_ value indicates a defaulted state. + /// \param yyvalue the value to check + static bool yy_pact_value_is_default_ (int yyvalue); + + /// Whether the given \c yytable_ value indicates a syntax error. + /// \param yyvalue the value to check + static bool yy_table_value_is_error_ (int yyvalue); + + /// Internal symbol numbers. + typedef unsigned char token_number_type; + /* Tables. */ + /// For a state, the index in \a yytable_ of its portion. + static const signed char yypact_[]; + static const signed char yypact_ninf_; + + /// For a state, default reduction number. + /// Unless\a yytable_ specifies something else to do. + /// Zero means the default is an error. + static const unsigned char yydefact_[]; + + static const signed char yypgoto_[]; + static const signed char yydefgoto_[]; + + /// What to do in a state. + /// \a yytable_[yypact_[s]]: what to do in state \a s. + /// - if positive, shift that token. + /// - if negative, reduce the rule which number is the opposite. + /// - if zero, do what YYDEFACT says. + static const unsigned char yytable_[]; + static const signed char yytable_ninf_; + + static const signed char yycheck_[]; + + /// For a state, its accessing symbol. + static const unsigned char yystos_[]; + + /// For a rule, its LHS. + static const unsigned char yyr1_[]; + /// For a rule, its RHS length. + static const unsigned char yyr2_[]; + + /// Convert the symbol name \a n to a form suitable for a diagnostic. + static std::string yytnamerr_ (const char *n); + + + /// For a symbol, its name in clear. + static const char* const yytname_[]; +#if YYDEBUG + /// A type to store symbol numbers and -1. + typedef signed char rhs_number_type; + /// A `-1'-separated list of the rules' RHS. + static const rhs_number_type yyrhs_[]; + /// For each rule, the index of the first RHS symbol in \a yyrhs_. + static const unsigned char yyprhs_[]; + /// For each rule, its source line number. + static const unsigned char yyrline_[]; + /// For each scanner token number, its symbol number. + static const unsigned short int yytoken_number_[]; + /// Report on the debug stream that the rule \a r is going to be reduced. + virtual void yy_reduce_print_ (int r); + /// Print the state stack on the debug stream. + virtual void yystack_print_ (); + + /* Debugging. */ + int yydebug_; + std::ostream* yycdebug_; +#endif + + /// Convert a scanner token number \a t to a symbol number. + token_number_type yytranslate_ (int t); + + /// \brief Reclaim the memory associated to a symbol. + /// \param yymsg Why this token is reclaimed. + /// If null, do not display the symbol, just free it. + /// \param yytype The symbol type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + inline void yydestruct_ (const char* yymsg, + int yytype, + semantic_type* yyvaluep, + location_type* yylocationp); + + /// Pop \a n symbols the three stacks. + inline void yypop_ (unsigned int n = 1); + + /* Constants. */ + static const int yyeof_; + /* LAST_ -- Last index in TABLE_. */ + static const int yylast_; + static const int yynnts_; + static const int yyempty_; + static const int yyfinal_; + static const int yyterror_; + static const int yyerrcode_; + static const int yyntokens_; + static const unsigned int yyuser_token_number_max_; + static const token_number_type yyundef_token_; + + /* User arguments. */ + QJson::ParserPrivate* driver; + }; + +} // yy +/* Line 33 of lalr1.cc */ +#line 297 "json_parser.hh" + + + +#endif /* !YY_YY_JSON_PARSER_HH_INCLUDED */ diff --git a/src/json_parser.yy b/src/json_parser.yy new file mode 100644 index 000000000..fa4656bab --- /dev/null +++ b/src/json_parser.yy @@ -0,0 +1,162 @@ +/* This file is part of QJSon + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +%skeleton "lalr1.cc" +%defines +%define "parser_class_name" "json_parser" + +%code requires{ + #include "parser_p.h" + #include "json_scanner.h" + #include "qjson_debug.h" + + #include + #include + #include + #include + + #include + + class JSonScanner; + + namespace QJson { + class Parser; + } + + #define YYERROR_VERBOSE 1 + + Q_DECLARE_METATYPE(QVector*) + Q_DECLARE_METATYPE(QVariantMap*) +} + +%parse-param { QJson::ParserPrivate* driver } +%lex-param { QJson::ParserPrivate* driver } + +%locations + +%debug +%error-verbose + +%token END 0 "end of file" + +%token CURLY_BRACKET_OPEN 1 "{" +%token CURLY_BRACKET_CLOSE 2 "}" +%token SQUARE_BRACKET_OPEN 3 "[" +%token SQUARE_BRACKET_CLOSE 4 "]" +%token COLON 5 ":" +%token COMMA 6 "," + +%token NUMBER 7 "number" +%token TRUE_VAL 8 "true" +%token FALSE_VAL 9 "false" +%token NULL_VAL 10 "null" +%token STRING 11 "string" + +%token INVALID 12 "invalid" + +// define the initial token +%start start + +%% + +// grammar rules + +start: data { + driver->m_result = $1; + qjsonDebug() << "json_parser - parsing finished"; + }; + +data: value { $$ = $1; } + | error + { + qCritical()<< "json_parser - syntax error found, " + << "forcing abort, Line" << @$.begin.line << "Column" << @$.begin.column; + YYABORT; + } + | END; + +object: CURLY_BRACKET_OPEN CURLY_BRACKET_CLOSE { + $$ = QVariant(QVariantMap()); + } + | CURLY_BRACKET_OPEN members CURLY_BRACKET_CLOSE { + QVariantMap* map = $2.value(); + $$ = QVariant(*map); + delete map; + }; + +members: STRING COLON value { + QVariantMap* pair = new QVariantMap(); + pair->insert($1.toString(), $3); + $$.setValue(pair); + } + | members COMMA STRING COLON value { + $$.value()->insert($3.toString(), $5); + }; + +array: SQUARE_BRACKET_OPEN SQUARE_BRACKET_CLOSE { + $$ = QVariant(QVariantList()); + } + | SQUARE_BRACKET_OPEN values SQUARE_BRACKET_CLOSE { + QVector* list = $2.value* >(); + $$ = QVariant(list->toList()); + delete list; + }; + +values: value { + QVector* list = new QVector(1); + list->replace(0, $1); + $$.setValue(list); + } + | values COMMA value { + $$.value* >()->append($3); + }; + +value: STRING + | NUMBER + | TRUE_VAL + | FALSE_VAL + | NULL_VAL + | object + | array; + +%% + +int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) +{ + JSonScanner* scanner = driver->m_scanner; + yylval->clear(); + int ret = scanner->yylex(yylval, yylloc); + + qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" + << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; + + return ret; +} + +void yy::json_parser::error (const yy::location& yyloc, const std::string& error) +{ + /*qjsonDebug() << yyloc.begin.line; + qjsonDebug() << yyloc.begin.column; + qjsonDebug() << yyloc.end.line; + qjsonDebug() << yyloc.end.column;*/ + qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; + driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); +} diff --git a/src/json_scanner.cc b/src/json_scanner.cc new file mode 100644 index 000000000..d148b0cd6 --- /dev/null +++ b/src/json_scanner.cc @@ -0,0 +1,4513 @@ +#line 2 "json_scanner.cc" + +#line 4 "json_scanner.cc" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 37 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer yyFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } +int yyFlexLexer::yylex() + { + LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" ); + return 0; + } + +#define YY_DECL int JSonScanner::yylex() +static yyconst flex_int16_t yy_nxt[][256] = + { + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 15, 16, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 10, 10, 10, 10, 10, + 23, 10, 10, 10, 10, 10, 24, 10, 10, 10, + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 15, 16, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 10, 10, 10, 10, 10, + 23, 10, 10, 10, 10, 10, 24, 10, 10, 10, + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + 9, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 29, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27 + }, + + { + 9, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 29, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27 + + }, + + { + 9, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, + 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, + 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, + + 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30 + }, + + { + 9, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, + 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, + 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, + 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 15, 32, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 33, 10, 10, 10, 10, 34, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 33, 10, 10, 10, 10, + 35, 10, 10, 10, 10, 10, 24, 10, 10, 10, + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 15, 32, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 33, 10, 10, 10, 10, 34, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 33, 10, 10, 10, 10, + 35, 10, 10, 10, 10, 10, 24, 10, 10, 10, + + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9 + + }, + + { + 9, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10 + }, + + { + 9, -11, -11, -11, -11, -11, -11, -11, -11, 36, + -11, 36, 36, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, 36, -11, -11, -11, -11, -11, -11, -11, + + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11 + }, + + { + 9, -12, -12, -12, -12, -12, -12, -12, -12, -12, + 37, -12, -12, 37, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12 + }, + + { + 9, -13, -13, -13, -13, -13, -13, -13, -13, -13, + 37, -13, -13, 37, -13, -13, -13, -13, -13, -13, + + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13 + }, + + { + 9, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14 + + }, + + { + 9, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15 + }, + + { + 9, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + + -16, -16, -16, -16, -16, -16, -16, -16, 38, 39, + 39, 39, 39, 39, 39, 39, 39, 39, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16 + }, + + { + 9, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, 40, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, 41, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, 41, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17 + }, + + { + 9, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, 40, -18, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, 41, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, 41, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18 + }, + + { + 9, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19 + + }, + + { + 9, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20 + }, + + { + 9, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21 + }, + + { + 9, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, 43, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22 + }, + + { + 9, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, 44, -23, -23, + + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23 + }, + + { + 9, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, 45, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24 + + }, + + { + 9, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25 + }, + + { + 9, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26 + }, + + { + 9, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, -27, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, -27, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46 + }, + + { + 9, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28 + }, + + { + 9, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, 47, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, 48, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, 49, -29, -29, -29, -29, -29, 50, -29, + -29, -29, 51, -29, -29, -29, -29, -29, -29, -29, + 52, -29, -29, -29, 53, -29, 54, 55, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29 + + }, + + { + 9, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30 + }, + + { + 9, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + + -31, -31, -31, -31, -31, -31, -31, -31, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, -31, -31, + -31, -31, -31, -31, -31, 56, 56, 56, 56, 56, + 56, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, 56, 56, 56, + 56, 56, 56, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31 + }, + + { + 9, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, 38, 39, + 39, 39, 39, 39, 39, 39, 39, 39, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, 57, -32, -32, -32, -32, -32, -32, + + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, 57, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32 + }, + + { + 9, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + 58, -33, -33, -33, -33, -33, -33, -33, -33, -33, + + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33 + }, + + { + 9, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + + -34, -34, -34, -34, -34, 59, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, 59, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34 + + }, + + { + 9, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, 59, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, 59, -35, -35, + + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, 44, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35 + }, + + { + 9, -36, -36, -36, -36, -36, -36, -36, -36, 36, + -36, 36, 36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, 36, -36, -36, -36, -36, -36, -36, -36, + + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36 + }, + + { + 9, -37, -37, -37, -37, -37, -37, -37, -37, -37, + 37, -37, -37, 37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37 + }, + + { + 9, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, 40, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, 41, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, 41, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38 + }, + + { + 9, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, 40, -39, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, -39, -39, + + -39, -39, -39, -39, -39, -39, -39, -39, -39, 41, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, 41, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39 + + }, + + { + 9, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40 + }, + + { + 9, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + + -41, -41, -41, 62, -41, 62, -41, -41, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41 + }, + + { + 9, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, 40, -42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, 41, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, 41, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42 + }, + + { + 9, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, 64, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43 + }, + + { + 9, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, 65, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44 + + }, + + { + 9, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, 66, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45 + }, + + { + 9, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, -46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, -46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46 + }, + + { + 9, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47 + }, + + { + 9, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48 + }, + + { + 9, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49 + + }, + + { + 9, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50 + }, + + { + 9, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51 + }, + + { + 9, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52 + }, + + { + 9, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53 + }, + + { + 9, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54 + + }, + + { + 9, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55 + }, + + { + 9, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + + -56, -56, -56, -56, -56, -56, -56, -56, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, -56, -56, + -56, -56, -56, -56, -56, 67, 67, 67, 67, 67, + 67, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, 67, 67, 67, + 67, 67, 67, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56 + }, + + { + 9, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + 68, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57 + }, + + { + 9, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, 69, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58 + }, + + { + 9, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, 70, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + 70, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59 + + }, + + { + 9, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, 40, -60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, 41, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + + -60, 41, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60 + }, + + { + 9, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + + -61, -61, -61, -61, -61, -61, -61, -61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, 41, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, 41, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61 + }, + + { + 9, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62 + }, + + { + 9, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63 + }, + + { + 9, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, 71, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64 + + }, + + { + 9, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + + -65, -65, -65, -65, -65, -65, -65, -65, 72, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65 + }, + + { + 9, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, 73, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66 + }, + + { + 9, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, 74, 74, + 74, 74, 74, 74, 74, 74, 74, 74, -67, -67, + -67, -67, -67, -67, -67, 74, 74, 74, 74, 74, + 74, -67, -67, -67, -67, -67, -67, -67, -67, -67, + + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, 74, 74, 74, + 74, 74, 74, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67 + }, + + { + 9, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, 75, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68 + }, + + { + 9, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, 76, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69 + + }, + + { + 9, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70 + }, + + { + 9, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, 77, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71 + }, + + { + 9, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72 + }, + + { + 9, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73 + }, + + { + 9, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74 + + }, + + { + 9, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + + -75, -75, -75, -75, -75, 78, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75 + }, + + { + 9, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + 79, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76 + }, + + { + 9, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77 + }, + + { + 9, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + 80, -78, -78, -78, -78, -78, -78, -78, -78, -78, + + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78 + }, + + { + 9, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, 81, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79 + + }, + + { + 9, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + + -80, -80, -80, -80, -80, 82, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80 + }, + + { + 9, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, 83, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81 + }, + + { + 9, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, 84, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82 + }, + + { + 9, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + + -83, 85, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83 + }, + + { + 9, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, 86, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84 + + }, + + { + 9, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85 + }, + + { + 9, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86 + }, + + } ; + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 36 +#define YY_END_OF_BUFFER 37 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[87] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 37, 35, + 1, 2, 2, 11, 27, 35, 6, 6, 26, 28, + 29, 35, 35, 35, 30, 31, 21, 23, 22, 25, + 25, 35, 35, 35, 35, 1, 2, 8, 8, 0, + 0, 7, 0, 0, 0, 21, 12, 14, 13, 15, + 16, 17, 18, 19, 20, 0, 0, 0, 0, 9, + 10, 0, 10, 0, 0, 0, 0, 0, 0, 32, + 0, 5, 3, 24, 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 33, 34 + } ; + +static yyconst yy_state_type yy_NUL_trans[87] = + { 0, + 10, 10, 27, 27, 30, 30, 10, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "json_scanner.yy" +/* This file is part of QJson + * + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110yy::json_parser::token::INVALID301, USA. + */ +/* Flex output settings */ +#define YY_NO_UNISTD_H 1 +#define YY_NO_INPUT 1 +#line 29 "json_scanner.yy" + #include "json_scanner.h" + #include "json_parser.hh" + + #if defined(_WIN32) && !defined(__MINGW32__) + #define strtoll _strtoi64 + #define strtoull _strtoui64 + #endif + + #define YY_USER_INIT if(m_allowSpecialNumbers) { \ + BEGIN(ALLOW_SPECIAL_NUMBERS); \ + } +/* Exclusive subscanners for strings and escaped hex sequences */ + +/* Extra-JSON rules active iff m_allowSpecialNumbers is true */ + +#line 3168 "json_scanner.cc" + +#define INITIAL 0 +#define QUOTMARK_OPEN 1 +#define HEX_OPEN 2 +#define ALLOW_SPECIAL_NUMBERS 3 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 48 "json_scanner.yy" + + + /* Whitespace */ +#line 3275 "json_scanner.cc" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + while ( (yy_current_state = yy_nxt[yy_current_state][ YY_SC_TO_UI(*yy_cp) ]) > 0 ) + { + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + + ++yy_cp; + } + + yy_current_state = -yy_current_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos) + 1; + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 51 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + } + YY_BREAK +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 55 "json_scanner.yy" +{ + m_yylloc->lines(yyleng); + } + YY_BREAK +/* Special values */ +case 3: +YY_RULE_SETUP +#line 61 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(true); + return yy::json_parser::token::TRUE_VAL; + } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 67 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(false); + return yy::json_parser::token::FALSE_VAL; + } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 73 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(); + return yy::json_parser::token::NULL_VAL; + } + YY_BREAK +/* Numbers */ +case 6: +#line 82 "json_scanner.yy" +case 7: +YY_RULE_SETUP +#line 82 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoull(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 8: +#line 93 "json_scanner.yy" +case 9: +YY_RULE_SETUP +#line 93 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoll(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 103 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + bool ok; + *m_yylval = QVariant(m_C_locale.toDouble(QLatin1String(yytext),&ok)); + if (!ok) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + YY_BREAK +/* Strings */ +case 11: +YY_RULE_SETUP +#line 115 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + BEGIN(QUOTMARK_OPEN); + } + YY_BREAK + +case 12: +YY_RULE_SETUP +#line 121 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\"")); + } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 125 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\\")); + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 129 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("/")); + } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 133 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\b")); + } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 137 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\f")); + } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 141 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\n")); + } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 145 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\r")); + } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 149 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\t")); + } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 153 "json_scanner.yy" +{ + BEGIN(HEX_OPEN); + } + YY_BREAK +case 21: +/* rule 21 can match eol */ +YY_RULE_SETUP +#line 157 "json_scanner.yy" +{ + m_currentString.append(QString::fromUtf8(yytext)); + } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 161 "json_scanner.yy" +{ + // ignore + } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 165 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(m_currentString); + m_currentString.clear(); + BEGIN(INITIAL); + return yy::json_parser::token::STRING; + } + YY_BREAK + + +case 24: +YY_RULE_SETUP +#line 175 "json_scanner.yy" +{ + QString hexDigits = QString::fromUtf8(yytext, yyleng); + bool ok; + ushort hexDigit1 = hexDigits.left(2).toShort(&ok, 16); + ushort hexDigit2 = hexDigits.right(2).toShort(&ok, 16); + m_currentString.append(QChar(hexDigit2, hexDigit1)); + BEGIN(QUOTMARK_OPEN); + } + YY_BREAK +case 25: +/* rule 25 can match eol */ +YY_RULE_SETUP +#line 184 "json_scanner.yy" +{ + qCritical() << "Invalid hex string"; + m_yylloc->columns(yyleng); + *m_yylval = QVariant(QLatin1String("")); + BEGIN(QUOTMARK_OPEN); + return yy::json_parser::token::INVALID; + } + YY_BREAK + +/* "Compound type" related tokens */ +case 26: +YY_RULE_SETUP +#line 196 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::COLON; + } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 201 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::COMMA; + } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 206 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_OPEN; + } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 211 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_CLOSE; + } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 216 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_OPEN; + } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 221 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_CLOSE; + } + YY_BREAK +/* Extra-JSON numbers */ + +case 32: +YY_RULE_SETUP +#line 229 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::quiet_NaN()); + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 235 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 241 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(-std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } + YY_BREAK + +/* If all else fails */ +case 35: +YY_RULE_SETUP +#line 249 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::INVALID; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(QUOTMARK_OPEN): +case YY_STATE_EOF(HEX_OPEN): +case YY_STATE_EOF(ALLOW_SPECIAL_NUMBERS): +#line 254 "json_scanner.yy" +return yy::json_parser::token::END; + YY_BREAK +case 36: +YY_RULE_SETUP +#line 255 "json_scanner.yy" +ECHO; + YY_BREAK +#line 3660 "json_scanner.cc" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + yyfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + yyfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) +#else +int yyFlexLexer::LexerInput( char* buf, int max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, int size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + if ( *yy_cp ) + { + yy_current_state = yy_nxt[yy_current_state][YY_SC_TO_UI(*yy_cp)]; + } + else + yy_current_state = yy_NUL_trans[yy_current_state]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + yy_current_state = yy_NUL_trans[yy_current_state]; + yy_is_jam = (yy_current_state == 0); + + if ( ! yy_is_jam ) + { + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + } + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ); + + yyfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 255 "json_scanner.yy" diff --git a/src/json_scanner.cpp b/src/json_scanner.cpp new file mode 100644 index 000000000..eb4ec8357 --- /dev/null +++ b/src/json_scanner.cpp @@ -0,0 +1,82 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#include "json_scanner.cc" + +#include "qjson_debug.h" +#include "json_scanner.h" +#include "json_parser.hh" + +#include + +#include +#include + +#include + + +JSonScanner::JSonScanner(QIODevice* io) + : m_allowSpecialNumbers(false), + m_io (io), + m_criticalError(false), + m_C_locale(QLocale::C) +{ + +} + +JSonScanner::~JSonScanner() +{ +} + +void JSonScanner::allowSpecialNumbers(bool allow) { + m_allowSpecialNumbers = allow; +} + +int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc) { + m_yylval = yylval; + m_yylloc = yylloc; + m_yylloc->step(); + int result = yylex(); + + if (m_criticalError) { + return -1; + } + + return result; +} + +int JSonScanner::LexerInput(char* buf, int max_size) { + if (!m_io->isOpen()) { + qCritical() << "JSonScanner::yylex - io device is not open"; + m_criticalError = true; + return 0; + } + + int readBytes = m_io->read(buf, max_size); + if(readBytes < 0) { + qCritical() << "JSonScanner::yylex - error while reading from io device"; + m_criticalError = true; + return 0; + } + + return readBytes; +} + + diff --git a/src/json_scanner.h b/src/json_scanner.h new file mode 100644 index 000000000..6a0e97b6f --- /dev/null +++ b/src/json_scanner.h @@ -0,0 +1,66 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _JSON_SCANNER +#define _JSON_SCANNER + +#include +#include +#include + +#define YYSTYPE QVariant + +// Only include FlexLexer.h if it hasn't been already included +#if ! defined(yyFlexLexerOnce) +#include +#endif + +#include "parser_p.h" + + + +namespace yy { + class location; + int yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver); +} + +class JSonScanner : public yyFlexLexer +{ + public: + explicit JSonScanner(QIODevice* io); + ~JSonScanner(); + + void allowSpecialNumbers(bool allow); + + int yylex(YYSTYPE* yylval, yy::location *yylloc); + int yylex(); + int LexerInput(char* buf, int max_size); + protected: + bool m_allowSpecialNumbers; + QIODevice* m_io; + + YYSTYPE* m_yylval; + yy::location* m_yylloc; + bool m_criticalError; + QString m_currentString; + QLocale m_C_locale; +}; + +#endif diff --git a/src/json_scanner.yy b/src/json_scanner.yy new file mode 100644 index 000000000..27104b28e --- /dev/null +++ b/src/json_scanner.yy @@ -0,0 +1,254 @@ +/* This file is part of QJson + * + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110yy::json_parser::token::INVALID301, USA. + */ + +/* Flex output settings */ +%option 8bit c++ full warn +%option noyywrap nounistd +%option noinput nounput noyy_push_state noyy_pop_state noyy_top_state noyy_scan_buffer noyy_scan_bytes noyy_scan_string noyyget_extra noyyset_extra noyyget_leng noyyget_text noyyget_lineno noyyset_lineno noyyget_in noyyset_in noyyget_out noyyset_out noyyget_lval noyyset_lval noyyget_lloc noyyset_lloc noyyget_debug noyyset_debug +%option yyclass="JSonScanner" +%option outfile="json_scanner.cc" + +%{ + #include "json_scanner.h" + #include "json_parser.hh" + + #if defined(_WIN32) && !defined(__MINGW32__) + #define strtoll _strtoi64 + #define strtoull _strtoui64 + #endif + + #define YY_USER_INIT if(m_allowSpecialNumbers) { \ + BEGIN(ALLOW_SPECIAL_NUMBERS); \ + } +%} + +/* Exclusive subscanners for strings and escaped hex sequences */ +%x QUOTMARK_OPEN HEX_OPEN + +/* Extra-JSON rules active iff m_allowSpecialNumbers is true */ +%s ALLOW_SPECIAL_NUMBERS + +%% + + /* Whitespace */ +[\v\f\t ]+ { + m_yylloc->columns(yyleng); + } + +[\r\n]+ { + m_yylloc->lines(yyleng); + } + + + /* Special values */ +true { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(true); + return yy::json_parser::token::TRUE_VAL; + } + +false { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(false); + return yy::json_parser::token::FALSE_VAL; + } + +null { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(); + return yy::json_parser::token::NULL_VAL; + } + + + /* Numbers */ +[0-9] | +[1-9][0-9]+ { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoull(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + +-[0-9] | +-[1-9][0-9]+ { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoll(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + +-?(([0-9])|([1-9][0-9]+))(\.[0-9]+)?([Ee][+\-]?[0-9]+)? { + m_yylloc->columns(yyleng); + bool ok; + *m_yylval = QVariant(m_C_locale.toDouble(QLatin1String(yytext),&ok)); + if (!ok) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + + /* Strings */ +\" { + m_yylloc->columns(yyleng); + BEGIN(QUOTMARK_OPEN); + } + +{ + \\\" { + m_currentString.append(QLatin1String("\"")); + } + + \\\\ { + m_currentString.append(QLatin1String("\\")); + } + + \\\/ { + m_currentString.append(QLatin1String("/")); + } + + \\b { + m_currentString.append(QLatin1String("\b")); + } + + \\f { + m_currentString.append(QLatin1String("\f")); + } + + \\n { + m_currentString.append(QLatin1String("\n")); + } + + \\r { + m_currentString.append(QLatin1String("\r")); + } + + \\t { + m_currentString.append(QLatin1String("\t")); + } + + \\u { + BEGIN(HEX_OPEN); + } + + [^\"\\]+ { + m_currentString.append(QString::fromUtf8(yytext)); + } + + \\ { + // ignore + } + + \" { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(m_currentString); + m_currentString.clear(); + BEGIN(INITIAL); + return yy::json_parser::token::STRING; + } +} + +{ + [0-9A-Fa-f]{4} { + QString hexDigits = QString::fromUtf8(yytext, yyleng); + bool ok; + ushort hexDigit1 = hexDigits.left(2).toShort(&ok, 16); + ushort hexDigit2 = hexDigits.right(2).toShort(&ok, 16); + m_currentString.append(QChar(hexDigit2, hexDigit1)); + BEGIN(QUOTMARK_OPEN); + } + + .|\n { + qCritical() << "Invalid hex string"; + m_yylloc->columns(yyleng); + *m_yylval = QVariant(QLatin1String("")); + BEGIN(QUOTMARK_OPEN); + return yy::json_parser::token::INVALID; + } +} + + + + /* "Compound type" related tokens */ +: { + m_yylloc->columns(yyleng); + return yy::json_parser::token::COLON; + } + +, { + m_yylloc->columns(yyleng); + return yy::json_parser::token::COMMA; + } + +\[ { + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_OPEN; + } + +\] { + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_CLOSE; + } + +\{ { + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_OPEN; + } + +\} { + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_CLOSE; + } + + + /* Extra-JSON numbers */ +{ + (?i:nan) { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::quiet_NaN()); + return yy::json_parser::token::NUMBER; + } + + [Ii]nfinity { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } + + -[Ii]nfinity { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(-std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } +} + + /* If all else fails */ +. { + m_yylloc->columns(yyleng); + return yy::json_parser::token::INVALID; + } + +<> return yy::json_parser::token::END; diff --git a/src/location.hh b/src/location.hh new file mode 100644 index 000000000..0bf1a74e8 --- /dev/null +++ b/src/location.hh @@ -0,0 +1,181 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Locations for Bison parsers in C++ + + Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file location.hh + ** Define the yy::location class. + */ + +#ifndef YY_YY_LOCATION_HH_INCLUDED +# define YY_YY_LOCATION_HH_INCLUDED + +# include "position.hh" + + +namespace yy { +/* Line 166 of location.cc */ +#line 47 "location.hh" + + /// Abstract a location. + class location + { + public: + + /// Construct a location from \a b to \a e. + location (const position& b, const position& e) + : begin (b) + , end (e) + { + } + + /// Construct a 0-width location in \a p. + explicit location (const position& p = position ()) + : begin (p) + , end (p) + { + } + + /// Construct a 0-width location in \a f, \a l, \a c. + explicit location (std::string* f, + unsigned int l = 1u, + unsigned int c = 1u) + : begin (f, l, c) + , end (f, l, c) + { + } + + + /// Initialization. + void initialize (std::string* f = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + { + begin.initialize (f, l, c); + end = begin; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// Reset initial location to final location. + void step () + { + begin = end; + } + + /// Extend the current location to the COUNT next columns. + void columns (unsigned int count = 1) + { + end += count; + } + + /// Extend the current location to the COUNT next lines. + void lines (unsigned int count = 1) + { + end.lines (count); + } + /** \} */ + + + public: + /// Beginning of the located region. + position begin; + /// End of the located region. + position end; + }; + + /// Join two location objects to create a location. + inline const location operator+ (const location& begin, const location& end) + { + location res = begin; + res.end = end.end; + return res; + } + + /// Add two location objects. + inline const location operator+ (const location& begin, unsigned int width) + { + location res = begin; + res.columns (width); + return res; + } + + /// Add and assign a location. + inline location& operator+= (location& res, unsigned int width) + { + res.columns (width); + return res; + } + + /// Compare two location objects. + inline bool + operator== (const location& loc1, const location& loc2) + { + return loc1.begin == loc2.begin && loc1.end == loc2.end; + } + + /// Compare two location objects. + inline bool + operator!= (const location& loc1, const location& loc2) + { + return !(loc1 == loc2); + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param loc a reference to the location to redirect + ** + ** Avoid duplicate information. + */ + template + inline std::basic_ostream& + operator<< (std::basic_ostream& ostr, const location& loc) + { + position last = loc.end - 1; + ostr << loc.begin; + if (last.filename + && (!loc.begin.filename + || *loc.begin.filename != *last.filename)) + ostr << '-' << last; + else if (loc.begin.line != last.line) + ostr << '-' << last.line << '.' << last.column; + else if (loc.begin.column != last.column) + ostr << '-' << last.column; + return ostr; + } + + +} // yy +/* Line 296 of location.cc */ +#line 180 "location.hh" + +#endif /* !YY_YY_LOCATION_HH_INCLUDED */ diff --git a/src/parser.cpp b/src/parser.cpp new file mode 100644 index 000000000..73de8ceae --- /dev/null +++ b/src/parser.cpp @@ -0,0 +1,141 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parser.h" +#include "parser_p.h" +#include "json_parser.hh" +#include "json_scanner.h" + +#include +#include +#include +#include + +using namespace QJson; + +ParserPrivate::ParserPrivate() : + m_scanner(0) +{ + m_specialNumbersAllowed = false; + reset(); +} + +ParserPrivate::~ParserPrivate() +{ + if (m_scanner) + delete m_scanner; +} + +void ParserPrivate::setError(QString errorMsg, int errorLine) { + m_error = true; + m_errorMsg = errorMsg; + m_errorLine = errorLine; +} + +void ParserPrivate::reset() +{ + m_error = false; + m_errorLine = 0; + m_errorMsg.clear(); + if (m_scanner) { + delete m_scanner; + m_scanner = 0; + } +} + +Parser::Parser() : + d(new ParserPrivate) +{ +} + +Parser::~Parser() +{ + delete d; +} + +QVariant Parser::parse (QIODevice* io, bool* ok) +{ + d->reset(); + + if (!io->isOpen()) { + if (!io->open(QIODevice::ReadOnly)) { + if (ok != 0) + *ok = false; + qCritical ("Error opening device"); + return QVariant(); + } + } + + if (!io->isReadable()) { + if (ok != 0) + *ok = false; + qCritical ("Device is not readable"); + io->close(); + return QVariant(); + } + + if (io->atEnd()) { + if (ok != 0) + *ok = false; + d->setError(QLatin1String("No data"), 0); + io->close(); + return QVariant(); + } + + d->m_scanner = new JSonScanner (io); + d->m_scanner->allowSpecialNumbers(d->m_specialNumbersAllowed); + yy::json_parser parser(d); + parser.parse(); + + delete d->m_scanner; + d->m_scanner = 0; + + if (ok != 0) + *ok = !d->m_error; + + io->close(); + return d->m_result; +} + +QVariant Parser::parse(const QByteArray& jsonString, bool* ok) { + QBuffer buffer; + buffer.open(QBuffer::ReadWrite); + buffer.write(jsonString); + buffer.seek(0); + return parse (&buffer, ok); +} + +QString Parser::errorString() const +{ + return d->m_errorMsg; +} + +int Parser::errorLine() const +{ + return d->m_errorLine; +} + +void QJson::Parser::allowSpecialNumbers(bool allowSpecialNumbers) { + d->m_specialNumbersAllowed = allowSpecialNumbers; +} + +bool Parser::specialNumbersAllowed() const { + return d->m_specialNumbersAllowed; +} diff --git a/src/parser.h b/src/parser.h new file mode 100644 index 000000000..c3132f506 --- /dev/null +++ b/src/parser.h @@ -0,0 +1,99 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_PARSER_H +#define QJSON_PARSER_H + +#include "qjson_export.h" + +QT_BEGIN_NAMESPACE +class QIODevice; +class QVariant; +QT_END_NAMESPACE + +/** + * Namespace used by QJson + */ +namespace QJson { + + class ParserPrivate; + + /** + * @brief Main class used to convert JSON data to QVariant objects + */ + class QJSON_EXPORT Parser + { + public: + Parser(); + ~Parser(); + + /** + * Read JSON string from the I/O Device and converts it to a QVariant object + * @param io Input output device + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. + * @returns a QVariant object generated from the JSON string + */ + QVariant parse(QIODevice* io, bool* ok = 0); + + /** + * This is a method provided for convenience. + * @param jsonData data containing the JSON object representation + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. + * @returns a QVariant object generated from the JSON string + * @sa errorString + * @sa errorLine + */ + QVariant parse(const QByteArray& jsonData, bool* ok = 0); + + /** + * This method returns the error message + * @returns a QString object containing the error message of the last parse operation + * @sa errorLine + */ + QString errorString() const; + + /** + * This method returns line number where the error occurred + * @returns the line number where the error occurred + * @sa errorString + */ + int errorLine() const; + + /** + * Sets whether special numbers (Infinity, -Infinity, NaN) are allowed as an extension to + * the standard + * @param allowSpecialNumbers new value of whether special numbers are allowed + * @sa specialNumbersAllowed + */ + void allowSpecialNumbers(bool allowSpecialNumbers); + + /** + * @returns whether special numbers (Infinity, -Infinity, NaN) are allowed + * @sa allowSpecialNumbers + */ + bool specialNumbersAllowed() const; + + private: + Q_DISABLE_COPY(Parser) + ParserPrivate* const d; + }; +} + +#endif // QJSON_PARSER_H diff --git a/src/parser_p.h b/src/parser_p.h new file mode 100644 index 000000000..de98b9b6b --- /dev/null +++ b/src/parser_p.h @@ -0,0 +1,57 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2009 Michael Leupold + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_PARSER_P_H +#define QJSON_PARSER_P_H + +#include "parser.h" + +#include +#include + +class JSonScanner; + +namespace yy { + class json_parser; +} + +namespace QJson { + + class ParserPrivate + { + public: + ParserPrivate(); + ~ParserPrivate(); + + void reset(); + + void setError(QString errorMsg, int line); + + JSonScanner* m_scanner; + bool m_error; + int m_errorLine; + QString m_errorMsg; + QVariant m_result; + bool m_specialNumbersAllowed; + }; +} + +#endif // QJSON_PARSER_H diff --git a/src/parserrunnable.cpp b/src/parserrunnable.cpp new file mode 100644 index 000000000..88baf4cf6 --- /dev/null +++ b/src/parserrunnable.cpp @@ -0,0 +1,68 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parserrunnable.h" + +#include "parser.h" + +#include +#include + +using namespace QJson; + +class QJson::ParserRunnable::Private +{ + public: + QByteArray m_data; +}; + +ParserRunnable::ParserRunnable(QObject* parent) + : QObject(parent), + QRunnable(), + d(new Private) +{ + qRegisterMetaType("QVariant"); +} + +ParserRunnable::~ParserRunnable() +{ + delete d; +} + +void ParserRunnable::setData( const QByteArray& data ) { + d->m_data = data; +} + +void ParserRunnable::run() +{ + qDebug() << Q_FUNC_INFO; + + bool ok; + Parser parser; + QVariant result = parser.parse (d->m_data, &ok); + if (ok) { + qDebug() << "successfully converted json item to QVariant object"; + emit parsingFinished(result, true, QString()); + } else { + const QString errorText = tr("An error occurred while parsing json: %1").arg(parser.errorString()); + qCritical() << errorText; + emit parsingFinished(QVariant(), false, errorText); + } +} diff --git a/src/parserrunnable.h b/src/parserrunnable.h new file mode 100644 index 000000000..fddcacd3f --- /dev/null +++ b/src/parserrunnable.h @@ -0,0 +1,64 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef PARSERRUNNABLE_H +#define PARSERRUNNABLE_H + +#include "qjson_export.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QVariant; +QT_END_NAMESPACE + +namespace QJson { + /** + * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread + */ + class QJSON_EXPORT ParserRunnable : public QObject, public QRunnable + { + Q_OBJECT + public: + explicit ParserRunnable(QObject* parent = 0); + ~ParserRunnable(); + + void setData( const QByteArray& data ); + + void run(); + + Q_SIGNALS: + /** + * This signal is emitted when the parsing process has been completed + * @param json contains the result of the parsing + * @param ok if a parsing error occurs ok is set to false, otherwise it's set to true. + * @param error_msg contains a string explaining the failure reason + **/ + void parsingFinished(const QVariant& json, bool ok, const QString& error_msg); + + private: + Q_DISABLE_COPY(ParserRunnable) + class Private; + Private* const d; + }; +} + +#endif // PARSERRUNNABLE_H diff --git a/src/position.hh b/src/position.hh new file mode 100644 index 000000000..3b33c2734 --- /dev/null +++ b/src/position.hh @@ -0,0 +1,172 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Positions for Bison parsers in C++ + + Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file position.hh + ** Define the yy::position class. + */ + +#ifndef YY_YY_POSITION_HH_INCLUDED +# define YY_YY_POSITION_HH_INCLUDED + +# include // std::max +# include +# include + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif + + +namespace yy { +/* Line 36 of location.cc */ +#line 57 "position.hh" + /// Abstract a position. + class position + { + public: + + /// Construct a position. + explicit position (std::string* f = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + : filename (f) + , line (l) + , column (c) + { + } + + + /// Initialization. + void initialize (std::string* fn = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + { + filename = fn; + line = l; + column = c; + } + + /** \name Line and Column related manipulators + ** \{ */ + /// (line related) Advance to the COUNT next lines. + void lines (int count = 1) + { + column = 1u; + line += count; + } + + /// (column related) Advance to the COUNT next columns. + void columns (int count = 1) + { + column = std::max (1u, column + count); + } + /** \} */ + + /// File name to which this position refers. + std::string* filename; + /// Current line number. + unsigned int line; + /// Current column number. + unsigned int column; + }; + + /// Add and assign a position. + inline position& + operator+= (position& res, const int width) + { + res.columns (width); + return res; + } + + /// Add two position objects. + inline const position + operator+ (const position& begin, const int width) + { + position res = begin; + return res += width; + } + + /// Add and assign a position. + inline position& + operator-= (position& res, const int width) + { + return res += -width; + } + + /// Add two position objects. + inline const position + operator- (const position& begin, const int width) + { + return begin + -width; + } + + /// Compare two position objects. + inline bool + operator== (const position& pos1, const position& pos2) + { + return (pos1.line == pos2.line + && pos1.column == pos2.column + && (pos1.filename == pos2.filename + || (pos1.filename && pos2.filename + && *pos1.filename == *pos2.filename))); + } + + /// Compare two position objects. + inline bool + operator!= (const position& pos1, const position& pos2) + { + return !(pos1 == pos2); + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param pos a reference to the position to redirect + */ + template + inline std::basic_ostream& + operator<< (std::basic_ostream& ostr, const position& pos) + { + if (pos.filename) + ostr << *pos.filename << ':'; + return ostr << pos.line << '.' << pos.column; + } + + +} // yy +/* Line 148 of location.cc */ +#line 172 "position.hh" +#endif /* !YY_YY_POSITION_HH_INCLUDED */ diff --git a/src/qjson_debug.h b/src/qjson_debug.h new file mode 100644 index 000000000..6036b2268 --- /dev/null +++ b/src/qjson_debug.h @@ -0,0 +1,34 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Michael Leupold + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_DEBUG_H +#define QJSON_DEBUG_H + +#include + +// define qjsonDebug() +#ifdef QJSON_VERBOSE_DEBUG_OUTPUT + inline QDebug qjsonDebug() { return QDebug(QtDebugMsg); } +#else + #define qjsonDebug() if(false) QDebug(QtDebugMsg) +#endif + +#endif diff --git a/src/qjson_export.h b/src/qjson_export.h new file mode 100644 index 000000000..9a807b91b --- /dev/null +++ b/src/qjson_export.h @@ -0,0 +1,35 @@ +/* This file is part of the KDE project + Copyright (C) 2009 Pino Toscano + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1, as published by the Free Software Foundation. + + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef QJSON_EXPORT_H +#define QJSON_EXPORT_H + +#include + +#ifndef QJSON_EXPORT +# if defined(QJSON_MAKEDLL) + /* We are building this library */ +# define QJSON_EXPORT Q_DECL_EXPORT +# else + /* We are using this library */ +# define QJSON_EXPORT Q_DECL_IMPORT +# endif +#endif + +#endif diff --git a/src/qobjecthelper.cpp b/src/qobjecthelper.cpp new file mode 100644 index 000000000..4f8daf722 --- /dev/null +++ b/src/qobjecthelper.cpp @@ -0,0 +1,85 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + + +#include "qobjecthelper.h" + +#include +#include +#include + +using namespace QJson; + +class QObjectHelper::QObjectHelperPrivate { +}; + +QObjectHelper::QObjectHelper() + : d (new QObjectHelperPrivate) +{ +} + +QObjectHelper::~QObjectHelper() +{ + delete d; +} + +QVariantMap QObjectHelper::qobject2qvariant( const QObject* object, + const QStringList& ignoredProperties) +{ + QVariantMap result; + const QMetaObject *metaobject = object->metaObject(); + int count = metaobject->propertyCount(); + for (int i=0; iproperty(i); + const char *name = metaproperty.name(); + + if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable())) + continue; + + QVariant value = object->property(name); + result[QLatin1String(name)] = value; + } + return result; +} + +void QObjectHelper::qvariant2qobject(const QVariantMap& variant, QObject* object) +{ + const QMetaObject *metaobject = object->metaObject(); + + QVariantMap::const_iterator iter; + for (iter = variant.constBegin(); iter != variant.constEnd(); ++iter) { + int pIdx = metaobject->indexOfProperty( iter.key().toLatin1() ); + + if ( pIdx < 0 ) { + continue; + } + + QMetaProperty metaproperty = metaobject->property( pIdx ); + QVariant::Type type = metaproperty.type(); + QVariant v( iter.value() ); + if ( v.canConvert( type ) ) { + v.convert( type ); + metaproperty.write( object, v ); + } else if (QString(QLatin1String("QVariant")).compare(QLatin1String(metaproperty.typeName())) == 0) { + metaproperty.write( object, v ); + } + } +} diff --git a/src/qobjecthelper.h b/src/qobjecthelper.h new file mode 100644 index 000000000..e4dfed0c8 --- /dev/null +++ b/src/qobjecthelper.h @@ -0,0 +1,147 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QOBJECTHELPER_H +#define QOBJECTHELPER_H + +#include "qjson_export.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QObject; +QT_END_NAMESPACE + +namespace QJson { + /** + * @brief Class used to convert QObject into QVariant and vivce-versa. + * During these operations only the class attributes defined as properties will + * be considered. + * Properties marked as 'non-stored' will be ignored. + * + * Suppose the declaration of the Person class looks like this: + * \code + * class Person : public QObject + { + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber) + Q_PROPERTY(Gender gender READ gender WRITE setGender) + Q_PROPERTY(QDate dob READ dob WRITE setDob) + Q_ENUMS(Gender) + + public: + Person(QObject* parent = 0); + ~Person(); + + QString name() const; + void setName(const QString& name); + + int phoneNumber() const; + void setPhoneNumber(const int phoneNumber); + + enum Gender {Male, Female}; + void setGender(Gender gender); + Gender gender() const; + + QDate dob() const; + void setDob(const QDate& dob); + + private: + QString m_name; + int m_phoneNumber; + Gender m_gender; + QDate m_dob; + }; + \endcode + + The following code will serialize an instance of Person to JSON : + + \code + Person person; + person.setName("Flavio"); + person.setPhoneNumber(123456); + person.setGender(Person::Male); + person.setDob(QDate(1982, 7, 12)); + + QVariantMap variant = QObjectHelper::qobject2qvariant(&person); + Serializer serializer; + qDebug() << serializer.serialize( variant); + \endcode + + The generated output will be: + \code + { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } + \endcode + + It's also possible to initialize a QObject using the values stored inside of + a QVariantMap. + + Suppose you have the following JSON data stored into a QString: + \code + { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } + \endcode + + The following code will initialize an already allocated instance of Person + using the JSON values: + \code + Parser parser; + QVariant variant = parser.parse(json); + + Person person; + QObjectHelper::qvariant2qobject(variant.toMap(), &person); + \endcode + + \sa Parser + \sa Serializer + */ + class QJSON_EXPORT QObjectHelper { + public: + QObjectHelper(); + ~QObjectHelper(); + + /** + * This method converts a QObject instance into a QVariantMap. + * + * @param object The QObject instance to be converted. + * @param ignoredProperties Properties that won't be converted. + */ + static QVariantMap qobject2qvariant( const QObject* object, + const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName")))); + + /** + * This method converts a QVariantMap instance into a QObject + * + * @param variant Attributes to assign to the object. + * @param object The QObject instance to update. + */ + static void qvariant2qobject(const QVariantMap& variant, QObject* object); + + private: + Q_DISABLE_COPY(QObjectHelper) + class QObjectHelperPrivate; + QObjectHelperPrivate* const d; + }; +} + +#endif // QOBJECTHELPER_H diff --git a/src/serializer.cpp b/src/serializer.cpp new file mode 100644 index 000000000..25f9bb981 --- /dev/null +++ b/src/serializer.cpp @@ -0,0 +1,444 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "serializer.h" + +#include +#include +#include + +#include + +#ifdef Q_OS_SOLARIS +# ifndef isinf +# include +# define isinf(x) (!finite((x)) && (x)==(x)) +# endif +#endif + +#ifdef _MSC_VER // using MSVC compiler +#include +#endif + +using namespace QJson; + +class Serializer::SerializerPrivate { + public: + SerializerPrivate() : + specialNumbersAllowed(false), + indentMode(QJson::IndentNone), + doublePrecision(6) { + errorMessage.clear(); + } + QString errorMessage; + bool specialNumbersAllowed; + IndentMode indentMode; + int doublePrecision; + QByteArray buildIndent(int spaces); + QByteArray serialize( const QVariant &v, bool *ok, int indentLevel = 0); + QString sanitizeString( QString str ); + QByteArray join( const QList& list, const QByteArray& sep ); +}; + +QByteArray Serializer::SerializerPrivate::join( const QList& list, const QByteArray& sep ) { + QByteArray res; + Q_FOREACH( const QByteArray& i, list ) { + if ( !res.isEmpty() ) + res += sep; + res += i; + } + return res; +} + +QByteArray Serializer::SerializerPrivate::serialize( const QVariant &v, bool *ok, int indentLevel) +{ + QByteArray str; + + if ( ! v.isValid() ) { // invalid or null? + str = "null"; + } else if (( v.type() == QVariant::List ) || ( v.type() == QVariant::StringList )){ // an array or a stringlist? + const QVariantList list = v.toList(); + QList values; + Q_FOREACH( const QVariant& var, list ) + { + QByteArray serializedValue; + + serializedValue = serialize( var, ok, indentLevel+1); + + if ( !*ok ) { + break; + } + switch(indentMode) { + case QJson::IndentFull : + case QJson::IndentMedium : + case QJson::IndentMinimum : + values << serializedValue; + break; + case QJson::IndentCompact : + case QJson::IndentNone : + default: + values << serializedValue.trimmed(); + break; + } + } + + if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull ) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "[\n" + join( values, ",\n" ) + "\n" + indent + "]"; + } + else if (indentMode == QJson::IndentMinimum) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "[\n" + join( values, ",\n" ) + "\n" + indent + "]"; + } + else if (indentMode == QJson::IndentCompact) { + str = "[" + join( values, "," ) + "]"; + } + else { + str = "[ " + join( values, ", " ) + " ]"; + } + + } else if ( v.type() == QVariant::Map ) { // variant is a map? + const QVariantMap vmap = v.toMap(); + QMapIterator it( vmap ); + + if (indentMode == QJson::IndentMinimum) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "{ "; + } + else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + QByteArray nextindent = buildIndent(indentLevel + 1); + str = indent + "{\n" + nextindent; + } + else if (indentMode == QJson::IndentCompact) { + str = "{"; + } + else { + str = "{ "; + } + + QList pairs; + while ( it.hasNext() ) { + it.next(); + indentLevel++; + QByteArray serializedValue = serialize( it.value(), ok, indentLevel); + indentLevel--; + if ( !*ok ) { + break; + } + QByteArray key = sanitizeString( it.key() ).toUtf8(); + QByteArray value = serializedValue.trimmed(); + if (indentMode == QJson::IndentCompact) { + pairs << key + ":" + value; + } else { + pairs << key + " : " + value; + } + } + + if (indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel + 1); + str += join( pairs, ",\n" + indent); + } + else if (indentMode == QJson::IndentCompact) { + str += join( pairs, "," ); + } + else { + str += join( pairs, ", " ); + } + + if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + str += "\n" + indent + "}"; + } + else if (indentMode == QJson::IndentCompact) { + str += "}"; + } + else { + str += " }"; + } + + } else if ( v.type() == QVariant::Hash ) { // variant is a hash? + const QVariantHash vhash = v.toHash(); + QHashIterator it( vhash ); + + if (indentMode == QJson::IndentMinimum) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "{ "; + } + else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + QByteArray nextindent = buildIndent(indentLevel + 1); + str = indent + "{\n" + nextindent; + } + else if (indentMode == QJson::IndentCompact) { + str = "{"; + } + else { + str = "{ "; + } + + QList pairs; + while ( it.hasNext() ) { + it.next(); + + QByteArray serializedValue = serialize( it.value(), ok, indentLevel + 1); + + if ( !*ok ) { + break; + } + QByteArray key = sanitizeString( it.key() ).toUtf8(); + QByteArray value = serializedValue.trimmed(); + if (indentMode == QJson::IndentCompact) { + pairs << key + ":" + value; + } else { + pairs << key + " : " + value; + } + } + + if (indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel + 1); + str += join( pairs, ",\n" + indent); + } + else if (indentMode == QJson::IndentCompact) { + str += join( pairs, "," ); + } + else { + str += join( pairs, ", " ); + } + + if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + str += "\n" + indent + "}"; + } + else if (indentMode == QJson::IndentCompact) { + str += "}"; + } + else { + str += " }"; + } + + } else { + // Add indent, we may need to remove it later for some layouts + switch(indentMode) { + case QJson::IndentFull : + case QJson::IndentMedium : + case QJson::IndentMinimum : + str += buildIndent(indentLevel); + break; + case QJson::IndentCompact : + case QJson::IndentNone : + default: + break; + } + + if (( v.type() == QVariant::String ) || ( v.type() == QVariant::ByteArray )) { // a string or a byte array? + str = sanitizeString( v.toString() ).toUtf8(); + } else if (( v.type() == QVariant::Double) || ((QMetaType::Type)v.type() == QMetaType::Float)) { // a double or a float? + const double value = v.toDouble(); + #if defined _WIN32 && !defined(Q_OS_SYMBIAN) + const bool special = _isnan(value) || !_finite(value); + #elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_SOLARIS) + const bool special = isnan(value) || isinf(value); + #else + const bool special = std::isnan(value) || std::isinf(value); + #endif + if (special) { + if (specialNumbersAllowed) { + #if defined _WIN32 && !defined(Q_OS_SYMBIAN) + if (_isnan(value)) { + #elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_SOLARIS) + if (isnan(value)) { + #else + if (std::isnan(value)) { + #endif + str += "NaN"; + } else { + if (value<0) { + str += '-'; + } + str += "Infinity"; + } + } else { + errorMessage += QLatin1String("Attempt to write NaN or infinity, which is not supported by json\n"); + *ok = false; + } + } else { + str = QByteArray::number( value , 'g', doublePrecision); + if( ! str.contains( "." ) && ! str.contains( "e" ) ) { + str += ".0"; + } + } + } else if ( v.type() == QVariant::Bool ) { // boolean value? + str += ( v.toBool() ? "true" : "false" ); + } else if ( v.type() == QVariant::ULongLong ) { // large unsigned number? + str += QByteArray::number( v.value() ); + } else if ( v.type() == QVariant::UInt ) { // unsigned int number? + str += QByteArray::number( v.value() ); + } else if ( v.canConvert() ) { // any signed number? + str += QByteArray::number( v.value() ); + } else if ( v.canConvert() ) { // unsigned short number? + str += QByteArray::number( v.value() ); + } else if ( v.canConvert() ){ // can value be converted to string? + // this will catch QDate, QDateTime, QUrl, ... + str += sanitizeString( v.toString() ).toUtf8(); + //TODO: catch other values like QImage, QRect, ... + } else { + *ok = false; + errorMessage += QLatin1String("Cannot serialize "); + errorMessage += v.toString(); + errorMessage += QLatin1String(" because type "); + errorMessage += QLatin1String(v.typeName()); + errorMessage += QLatin1String(" is not supported by QJson\n"); + } + } + if ( *ok ) + { + return str; + } + else + return QByteArray(); +} + +QByteArray Serializer::SerializerPrivate::buildIndent(int spaces) +{ + QByteArray indent; + if (spaces < 0) { + spaces = 0; + } + for (int i = 0; i < spaces; i++ ) { + indent += " "; + } + return indent; +} + +QString Serializer::SerializerPrivate::sanitizeString( QString str ) +{ + str.replace( QLatin1String( "\\" ), QLatin1String( "\\\\" ) ); + + // escape unicode chars + QString result; + const ushort* unicode = str.utf16(); + unsigned int i = 0; + + while ( unicode[ i ] ) { + if ( unicode[ i ] < 128 ) { + result.append( QChar( unicode[ i ] ) ); + } + else { + QString hexCode = QString::number( unicode[ i ], 16 ).rightJustified( 4, + QLatin1Char('0') ); + + result.append( QLatin1String ("\\u") ).append( hexCode ); + } + ++i; + } + str = result; + + str.replace( QLatin1String( "\"" ), QLatin1String( "\\\"" ) ); + str.replace( QLatin1String( "\b" ), QLatin1String( "\\b" ) ); + str.replace( QLatin1String( "\f" ), QLatin1String( "\\f" ) ); + str.replace( QLatin1String( "\n" ), QLatin1String( "\\n" ) ); + str.replace( QLatin1String( "\r" ), QLatin1String( "\\r" ) ); + str.replace( QLatin1String( "\t" ), QLatin1String( "\\t" ) ); + + return QString( QLatin1String( "\"%1\"" ) ).arg( str ); +} + +Serializer::Serializer() + : d( new SerializerPrivate ) +{ +} + +Serializer::~Serializer() { + delete d; +} + +void Serializer::serialize( const QVariant& v, QIODevice* io, bool* ok) +{ + Q_ASSERT( io ); + *ok = true; + + if (!io->isOpen()) { + if (!io->open(QIODevice::WriteOnly)) { + d->errorMessage = QLatin1String("Error opening device"); + *ok = false; + return; + } + } + + if (!io->isWritable()) { + d->errorMessage = QLatin1String("Device is not readable"); + io->close(); + *ok = false; + return; + } + + const QByteArray str = serialize( v, ok); + if (*ok && (io->write(str) != str.count())) { + *ok = false; + d->errorMessage = QLatin1String("Something went wrong while writing to IO device"); + } +} + +QByteArray Serializer::serialize( const QVariant &v) +{ + bool ok; + + return serialize(v, &ok); +} + +QByteArray Serializer::serialize( const QVariant &v, bool *ok) +{ + bool _ok = true; + d->errorMessage.clear(); + + if (ok) { + *ok = true; + } else { + ok = &_ok; + } + + return d->serialize(v, ok); +} + +void QJson::Serializer::allowSpecialNumbers(bool allow) { + d->specialNumbersAllowed = allow; +} + +bool QJson::Serializer::specialNumbersAllowed() const { + return d->specialNumbersAllowed; +} + +void QJson::Serializer::setIndentMode(IndentMode mode) { + d->indentMode = mode; +} + +void QJson::Serializer::setDoublePrecision(int precision) { + d->doublePrecision = precision; +} + +IndentMode QJson::Serializer::indentMode() const { + return d->indentMode; +} + +QString QJson::Serializer::errorMessage() const { + return d->errorMessage; +} + diff --git a/src/serializer.h b/src/serializer.h new file mode 100644 index 000000000..48dc9ae98 --- /dev/null +++ b/src/serializer.h @@ -0,0 +1,230 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_SERIALIZER_H +#define QJSON_SERIALIZER_H + +#include "qjson_export.h" + +QT_BEGIN_NAMESPACE +class QIODevice; +class QString; +class QVariant; +QT_END_NAMESPACE + +namespace QJson { + /** + @brief How the indentation should work. + \verbatim + none (default) : + { "foo" : 0, "foo1" : 1, "foo2" : [ { "bar" : 1, "foo" : 0, "foobar" : 0 }, { "bar" : 1, "foo" : 1, "foobar" : 1 } ], "foo3" : [ 1, 2, 3, 4, 5, 6 ] } + + compact : + {"foo":0,"foo1":1,"foo2":[{"bar":1,"foo":0,"foobar":0},{"bar":1,"foo":1,"foobar":1}],"foo3":[1,2,3,4,5,6]} + + minimum : + { "foo" : 0, "foo1" : 1, "foo2" : [ + { "bar" : 1, "foo" : 0, "foobar" : 0 }, + { "bar" : 1, "foo" : 1, "foobar" : 1 } + ], "foo3" : [ + 1, + 2, + 3, + 4, + 5, + 6 + ] } + + medium : + { + "foo" : 0, "foo1" : 1, "foo2" : [ + { + "bar" : 1, "foo" : 0, "foobar" : 0 + }, + { + "bar" : 1, "foo" : 1, "foobar" : 1 + } + ], "foo3" : [ + 1, + 2, + 3, + 4, + 5, + 6 + ] + } + + full : + { + "foo" : 0, + "foo1" : 1, + "foo2" : [ + { + "bar" : 1, + "foo" : 0, + "foobar" : 0 + }, + { + "bar" : 1, + "foo" : 1, + "foobar" : 1 + } + ], + "foo3" : [ + 1, + 2, + 3, + 4, + 5, + 6 + ] + } + + + \endverbatim + */ + enum IndentMode { + IndentNone, + IndentCompact, + IndentMinimum, + IndentMedium, + IndentFull + }; + /** + * @brief Main class used to convert QVariant objects to JSON data. + * + * QVariant objects are converted to a string containing the JSON data. + * + * + * Usage: + * + * \code + * QVariantList people; + * + * QVariantMap bob; + * bob.insert("Name", "Bob"); + * bob.insert("Phonenumber", 123); + * + * QVariantMap alice; + * alice.insert("Name", "Alice"); + * alice.insert("Phonenumber", 321); + * + * people << bob << alice; + * + * QJson::Serializer serializer; + * bool ok; + * QByteArray json = serializer.serialize(people, &ok); + * + * if (ok) { + * qDebug() << json; + * } else { + * qCritical() << "Something went wrong:" << serializer.errorMessage(); + * } + * \endcode + * + * The output will be: + * + * \code + * "[ { "Name" : "Bob", "Phonenumber" : 123 }, + * { "Name" : "Alice", "Phonenumber" : 321 } ]" + * \endcode + * + * It's possible to tune the indentation level of the resulting string. \sa setIndentMode + */ + class QJSON_EXPORT Serializer { + public: + Serializer(); + ~Serializer(); + + /** + * This method generates a textual JSON representation and outputs it to the + * passed in I/O Device. + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * @param out Input output device + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true + */ + void serialize( const QVariant& variant, QIODevice* out, bool* ok); + + /** + * This is a method provided for convenience. It turns the passed in in-memory + * representation of the JSON document into a textual one, which is returned. + * If the returned string is empty, the document was empty. If it was null, there + * was a parsing error. + * + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * + * \deprecated This method is going to be removed with the next major release of QJson. + */ + QByteArray serialize( const QVariant& variant); + + /** + * This is a method provided for convenience. It turns the passed in in-memory + * representation of the JSON document into a textual one, which is returned. + * If the returned string is empty, the document was empty. If it was null, there + * was a parsing error. + * + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true + */ + QByteArray serialize( const QVariant& variant, bool *ok); + + /** + * Allow or disallow writing of NaN and/or Infinity (as an extension to QJson) + */ + void allowSpecialNumbers(bool allow); + + /** + * Is Nan and/or Infinity allowed? + */ + bool specialNumbersAllowed() const; + + /** + * set output indentation mode as defined in QJson::IndentMode + */ + void setIndentMode(IndentMode mode = QJson::IndentNone); + + + /** + * set double precision used while converting Double + * \sa QByteArray::number + */ + void setDoublePrecision(int precision); + + /** + * Returns one of the indentation modes defined in QJson::IndentMode + */ + IndentMode indentMode() const; + + /** + * Returns the error message + */ + QString errorMessage() const; + + private: + Q_DISABLE_COPY(Serializer) + class SerializerPrivate; + SerializerPrivate* const d; + }; +} + +#endif // QJSON_SERIALIZER_H diff --git a/src/serializerrunnable.cpp b/src/serializerrunnable.cpp new file mode 100644 index 000000000..b1894a238 --- /dev/null +++ b/src/serializerrunnable.cpp @@ -0,0 +1,62 @@ +#include "serializerrunnable.h" + +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * 2009 Frank Osterfeld + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parserrunnable.h" +#include "serializer.h" + +#include +#include + +using namespace QJson; + +class SerializerRunnable::Private +{ +public: + QVariant json; +}; + +SerializerRunnable::SerializerRunnable(QObject* parent) + : QObject(parent), + QRunnable(), + d(new Private) +{ + qRegisterMetaType("QVariant"); +} + +SerializerRunnable::~SerializerRunnable() +{ + delete d; +} + +void SerializerRunnable::setJsonObject( const QVariant& json ) +{ + d->json = json; +} + +void SerializerRunnable::run() +{ + Serializer serializer; + bool ok; + const QByteArray serialized = serializer.serialize( d->json, &ok); + emit parsingFinished( serialized, ok, serializer.errorMessage() ); +} diff --git a/src/serializerrunnable.h b/src/serializerrunnable.h new file mode 100644 index 000000000..1a3df7c1c --- /dev/null +++ b/src/serializerrunnable.h @@ -0,0 +1,71 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Frank Osterfeld + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SERIALIZERRUNNABLE_H +#define SERIALIZERRUNNABLE_H + +#include "qjson_export.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QByteArray; +class QString; +class QVariant; +QT_END_NAMESPACE + +namespace QJson { + /** + * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread + */ + class QJSON_EXPORT SerializerRunnable : public QObject, public QRunnable + { + Q_OBJECT + public: + explicit SerializerRunnable(QObject* parent = 0); + ~SerializerRunnable(); + + /** + * Sets the json object to serialize. + * + * @param json QVariant containing the json representation to be serialized + */ + void setJsonObject( const QVariant& json ); + + /* reimp */ void run(); + + Q_SIGNALS: + /** + * This signal is emitted when the serialization process has been completed + * @param serialized contains the result of the serialization + * @param ok if a serialization error occurs ok is set to false, otherwise it's set to true. + * @param error_msg contains a string explaining the failure reason + **/ + void parsingFinished(const QByteArray& serialized, bool ok, const QString& error_msg); + + private: + Q_DISABLE_COPY(SerializerRunnable) + class Private; + Private* const d; + }; +} + +#endif // SERIALIZERRUNNABLE_H diff --git a/src/stack.hh b/src/stack.hh new file mode 100644 index 000000000..590accbaf --- /dev/null +++ b/src/stack.hh @@ -0,0 +1,133 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Stack handling for Bison parsers in C++ + + Copyright (C) 2002-2012 Free Software Foundation, Inc. + + 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 3 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, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file stack.hh + ** Define the yy::stack class. + */ + +#ifndef YY_YY_STACK_HH_INCLUDED +# define YY_YY_STACK_HH_INCLUDED + +# include + + +namespace yy { +/* Line 34 of stack.hh */ +#line 47 "stack.hh" + template > + class stack + { + public: + // Hide our reversed order. + typedef typename S::reverse_iterator iterator; + typedef typename S::const_reverse_iterator const_iterator; + + stack () : seq_ () + { + } + + stack (unsigned int n) : seq_ (n) + { + } + + inline + T& + operator [] (unsigned int i) + { + return seq_[i]; + } + + inline + const T& + operator [] (unsigned int i) const + { + return seq_[i]; + } + + inline + void + push (const T& t) + { + seq_.push_front (t); + } + + inline + void + pop (unsigned int n = 1) + { + for (; n; --n) + seq_.pop_front (); + } + + inline + unsigned int + height () const + { + return seq_.size (); + } + + inline const_iterator begin () const { return seq_.rbegin (); } + inline const_iterator end () const { return seq_.rend (); } + + private: + S seq_; + }; + + /// Present a slice of the top of a stack. + template > + class slice + { + public: + slice (const S& stack, unsigned int range) + : stack_ (stack) + , range_ (range) + { + } + + inline + const T& + operator [] (unsigned int i) const + { + return stack_[range_ - i]; + } + + private: + const S& stack_; + unsigned int range_; + }; + +} // yy +/* Line 116 of stack.hh */ +#line 132 "stack.hh" + +#endif /* !YY_YY_STACK_HH_INCLUDED */ diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000000000..f3c7a7c5d --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +Makefile diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..dab0cdca8 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,15 @@ +IF (Qt5Core_FOUND) + FIND_PACKAGE( Qt5Test REQUIRED ) + + INCLUDE_DIRECTORIES(${Qt5Test_INCLUDE_DIRS}) + ADD_DEFINITIONS(${Qt5Test_DEFINITIONS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Test_EXECUTABLE_COMPILE_FLAGS}") + + SET (TEST_LIBRARIES ${Qt5Test_LIBRARIES}) +ENDIF() + +ADD_SUBDIRECTORY(cmdline_tester) +ADD_SUBDIRECTORY(parser) +ADD_SUBDIRECTORY(scanner) +ADD_SUBDIRECTORY(qobjecthelper) +ADD_SUBDIRECTORY(serializer) diff --git a/tests/benchmarks/CMakeLists.txt b/tests/benchmarks/CMakeLists.txt new file mode 100644 index 000000000..824b56ec3 --- /dev/null +++ b/tests/benchmarks/CMakeLists.txt @@ -0,0 +1,38 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( UNIT_TESTS + parsingbenchmark + qlocalevsstrtod_l +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/benchmarks/parsingbenchmark.cpp b/tests/benchmarks/parsingbenchmark.cpp new file mode 100644 index 000000000..51cbd8606 --- /dev/null +++ b/tests/benchmarks/parsingbenchmark.cpp @@ -0,0 +1,55 @@ +/* This file is part of QJson + * + * Copyright (C) 2014 Sune Vuorela + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include + +class ParsingBenchmark: public QObject { + Q_OBJECT + private Q_SLOTS: + void benchmark(); +}; + +void ParsingBenchmark::benchmark() { + QString path = QFINDTESTDATA("largefile.json"); + + QVERIFY(QFile::exists(path)); + + QFile f(path); + QVERIFY(f.open(QIODevice::ReadOnly)); + + QByteArray data = f.readAll(); + + QVariant result; + + QJson::Parser parser; + QBENCHMARK { + result = parser.parse(data); + } + + Q_UNUSED(result); +} + + +QTEST_MAIN(ParsingBenchmark) + +#include "parsingbenchmark.moc" diff --git a/tests/benchmarks/qlocalevsstrtod_l.cpp b/tests/benchmarks/qlocalevsstrtod_l.cpp new file mode 100644 index 000000000..9bda9d454 --- /dev/null +++ b/tests/benchmarks/qlocalevsstrtod_l.cpp @@ -0,0 +1,70 @@ +/* This file is part of QJson + * + * Copyright (C) 2014 Sune Vuorela + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include + +class QLocaleVsStrtod_l : public QObject { + Q_OBJECT + private Q_SLOTS: + void benchmark(); + void benchmark_data(); + +}; + +void QLocaleVsStrtod_l::benchmark() { + QFETCH(bool, useQLocale); + QList l; + l << strdup("0.123") << strdup("0.947834") << strdup("8.8373") << strdup("884.82921"); + + double result; + + if(useQLocale) { + QLocale c(QLocale::C); + QBENCHMARK { + Q_FOREACH(const char* str, l) { + result = c.toDouble(QString(str)); + } + } + } else { + locale_t c = newlocale(LC_NUMERIC_MASK, "C", NULL); + QBENCHMARK { + Q_FOREACH(const char* str, l) { + result = strtod_l(str, NULL, c); + } + } + } + + + Q_FOREACH(char* str, l) { + free(str); + } +} + +void QLocaleVsStrtod_l::benchmark_data() { + QTest::addColumn("useQLocale"); + + QTest::newRow("using QLocale") << true; + QTest::newRow("using strtod_l") << false; +} + +QTEST_MAIN(QLocaleVsStrtod_l); +#include "qlocalevsstrtod_l.moc" diff --git a/tests/cmdline_tester/.gitignore b/tests/cmdline_tester/.gitignore new file mode 100644 index 000000000..1347175f2 --- /dev/null +++ b/tests/cmdline_tester/.gitignore @@ -0,0 +1,4 @@ +Makefile +*.o +*.moc +cmdline_tester diff --git a/tests/cmdline_tester/CMakeLists.txt b/tests/cmdline_tester/CMakeLists.txt new file mode 100644 index 000000000..c7cf4cd0b --- /dev/null +++ b/tests/cmdline_tester/CMakeLists.txt @@ -0,0 +1,35 @@ +##### Probably don't want to edit below this line ##### + +IF (WIN32 AND Qt5Core_FOUND) + FIND_PACKAGE( Qt5Widgets REQUIRED ) + + INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) + ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") +ENDIF() + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +ADD_EXECUTABLE( + cmdline_tester + cmdline_tester.cpp + cmdlineparser.cpp +) + +TARGET_LINK_LIBRARIES( + cmdline_tester + ${QT_LIBRARIES} + ${Qt5Widgets_LIBRARIES} + qjson +) diff --git a/tests/cmdline_tester/cmdline_tester.cpp b/tests/cmdline_tester/cmdline_tester.cpp new file mode 100644 index 000000000..81289f12d --- /dev/null +++ b/tests/cmdline_tester/cmdline_tester.cpp @@ -0,0 +1,99 @@ +/* This file is part of QJson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "cmdlineparser.h" + +using namespace QJson; + +int main(int argc, char *argv[]) { + QCoreApplication app (argc, argv); + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + QTextCodec *codec = QTextCodec::codecForName("UTF-8"); + QTextCodec::setCodecForCStrings(codec); +#endif + + QTime time; + int duration; + + + CmdLineParser cmd (app.arguments()); + CmdLineParser::Result res = cmd.parse(); + if (res == CmdLineParser::Help) + return 0; + else if (res == CmdLineParser::Error) + return -1; + + QString filename = cmd.file(); + if (!QFile::exists ( filename )) { + qCritical ("The file you specified doesn't exist!"); + exit (1); + } + + Parser parser; + bool ok; + + QFile file (filename); + time.start(); + QVariant data = parser.parse (&file, &ok); + duration = time.elapsed(); + if (!ok) { + qCritical("%s:%i - Error: %s", filename.toLatin1().data(), parser.errorLine(), qPrintable(parser.errorString())); + exit (1); + } + else { + qDebug() << "Parsing of" << filename << "took" << duration << "ms"; + if (!cmd.quiet()) + qDebug() << data; + } + + if (cmd.serialize()) { + // serializer tests + qDebug() << "Serializing... "; + QJson::Serializer serializer; + serializer.setIndentMode(cmd.indentationMode()); + time.start(); + QByteArray b = serializer.serialize(data, &ok); + if (!ok) { + qCritical() << "Serialization failed:" << serializer.errorMessage(); + exit(1); + } else { + duration = time.elapsed(); + qDebug() << "Serialization took:" << duration << "ms"; + if (!cmd.quiet()) + qDebug() << b; + } + } + + qDebug() << "JOB DONE, BYE"; + return 0; +} + diff --git a/tests/cmdline_tester/cmdlineparser.cpp b/tests/cmdline_tester/cmdlineparser.cpp new file mode 100644 index 000000000..289fe0d4a --- /dev/null +++ b/tests/cmdline_tester/cmdlineparser.cpp @@ -0,0 +1,170 @@ +/* This file is part of qjson + * + * Copyright (C) 2010 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include +#ifdef Q_OS_WIN +//using Qt5 +#ifdef QT_WIDGETS_LIB +#include +#else +//using Qt4 +#include +#endif +#endif + +#include "cmdlineparser.h" + +using namespace QJson; + +const QString CmdLineParser::m_helpMessage = QLatin1String( + "Usage: cmdline_tester [options] file\n\n" + "This program converts the json data read from 'file' to a QVariant object.\n" + "--quiet Do not print output generated by parser and serializer.\n" + "--serialize Parses the QVariant object back to json.\n" + "--indent Sets the indentation level used by the 'serialize' option.\n" + " Allowed values:\n" + " - none [default]\n" + " - compact\n" + " - minimum\n" + " - medium\n" + " - full\n" + "--help Displays this help.\n" + ); + + +CmdLineParser::CmdLineParser(const QStringList &arguments) + : m_pos(0), + m_indentationMode(IndentNone), + m_serialize(false), + m_quiet(false) +{ + for (int i = 1; i < arguments.count(); ++i) { + const QString &arg = arguments.at(i); + m_arguments.append(arg); + } +} + +CmdLineParser::Result CmdLineParser::parse() +{ + bool showHelp = false; + + while (m_error.isEmpty() && hasMoreArgs()) { + const QString &arg = nextArg(); + if (arg.toLower() == QLatin1String("--indent")) + handleSetIndentationMode(); + else if (arg.toLower() == QLatin1String("--help")) + showHelp = true; + else if (arg.toLower() == QLatin1String("--serialize")) + m_serialize = true; + else if (arg.toLower() == QLatin1String("--quiet")) + m_quiet = true; + else if (!arg.startsWith(QLatin1String("--"))) + m_file = arg; + else + m_error = QString(QLatin1String("Unknown option: %1")).arg(arg); + } + + if (m_file.isEmpty()) { + m_error = QLatin1String("You have to specify the file containing the json data."); + } + + if (!m_error.isEmpty()) { + showMessage(m_error + QLatin1String("\n\n\n") + m_helpMessage, true); + return Error; + } else if (showHelp) { + showMessage(m_helpMessage, false); + return Help; + } + return Ok; +} + +bool CmdLineParser::hasMoreArgs() const +{ + return m_pos < m_arguments.count(); +} + +const QString &CmdLineParser::nextArg() +{ + Q_ASSERT(hasMoreArgs()); + return m_arguments.at(m_pos++); +} + +void CmdLineParser::handleSetIndentationMode() +{ + if (hasMoreArgs()) { + const QString &indentationMode = nextArg(); + if (indentationMode.compare(QLatin1String("none"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentNone; + else if (indentationMode.compare(QLatin1String("compact"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentCompact; + else if (indentationMode.compare(QLatin1String("minimum"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentMinimum; + else if (indentationMode.compare(QLatin1String("medium"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentMedium; + else if (indentationMode.compare(QLatin1String("full"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentFull; + else + m_error = QString(QLatin1String("Unknown indentation mode '%1'.")). + arg(indentationMode); + } else { + m_error = QLatin1String("Missing indentation level."); + } +} + +void CmdLineParser::showMessage(const QString &msg, bool error) +{ +#ifdef Q_OS_WIN + QString message = QLatin1String("
") % msg % QLatin1String("
"); + if (error) + QMessageBox::critical(0, QLatin1String("Error"), message); + else + QMessageBox::information(0, QLatin1String("Notice"), message); +#else + fprintf(error ? stderr : stdout, "%s\n", qPrintable(msg)); +#endif +} + +void CmdLineParser::setIndentationMode(const IndentMode &mode) +{ + m_indentationMode = mode; +} + +IndentMode CmdLineParser::indentationMode() const +{ + return m_indentationMode; +} + +QString CmdLineParser::file() const +{ + return m_file; +} + +bool CmdLineParser::serialize() +{ + return m_serialize; +} + +bool CmdLineParser::quiet() +{ + return m_quiet; +} + diff --git a/tests/cmdline_tester/cmdlineparser.h b/tests/cmdline_tester/cmdlineparser.h new file mode 100644 index 000000000..994a2692f --- /dev/null +++ b/tests/cmdline_tester/cmdlineparser.h @@ -0,0 +1,64 @@ +/* This file is part of qjson + * + * Copyright (C) 2010 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef CMDLINEPARSER_H +#define CMDLINEPARSER_H + +#include +#include + +#include + +namespace QJson { + class CmdLineParser + { + public: + enum Result {Ok, Help, Error}; + + CmdLineParser(const QStringList &arguments); + Result parse(); + + void setIndentationMode(const IndentMode &mode); + IndentMode indentationMode() const; + QString helpFile() const; + QString file() const; + bool serialize(); + bool quiet(); + + void showMessage(const QString &msg, bool error); + + private: + bool hasMoreArgs() const; + const QString &nextArg(); + void handleSetIndentationMode(); + + QStringList m_arguments; + int m_pos; + IndentMode m_indentationMode; + QString m_file; + bool m_serialize; + bool m_quiet; + static const QString m_helpMessage; + QString m_error; + }; +} + +#endif + diff --git a/tests/cmdline_tester/example.txt b/tests/cmdline_tester/example.txt new file mode 100644 index 000000000..eacfbf5e6 --- /dev/null +++ b/tests/cmdline_tester/example.txt @@ -0,0 +1,22 @@ +{ + "glossary": { + "title": "example glossary", + "GlossDiv": { + "title": "S", + "GlossList": { + "GlossEntry": { + "ID": "SGML", + "SortAs": "SGML", + "GlossTerm": "Standard Generalized Markup Language", + "Acronym": "SGML", + "Abbrev": "ISO 8879:1986", + "GlossDef": { + "para": "A meta-markup language, used to create markup languages such as DocBook.", + "GlossSeeAlso": ["GML", "XML"] + }, + "GlossSee": "markup" + } + } + } + } +} diff --git a/tests/parser/.gitignore b/tests/parser/.gitignore new file mode 100644 index 000000000..46e5733e2 --- /dev/null +++ b/tests/parser/.gitignore @@ -0,0 +1,4 @@ +Makefile +*.o +*.moc +parser diff --git a/tests/parser/CMakeLists.txt b/tests/parser/CMakeLists.txt new file mode 100644 index 000000000..bd86cee9b --- /dev/null +++ b/tests/parser/CMakeLists.txt @@ -0,0 +1,46 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( UNIT_TESTS + testparser +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(MOC_SOURCE ${test}.cpp) + ENDIF() + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + ADD_FILE_DEPENDENCIES(${test}.cpp ${MOC_SOURCE}) + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/parser/testparser.cpp b/tests/parser/testparser.cpp new file mode 100644 index 000000000..e1923a7f3 --- /dev/null +++ b/tests/parser/testparser.cpp @@ -0,0 +1,456 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include + +#include + +#include +#include + +#include + +class TestParser: public QObject +{ + Q_OBJECT + private slots: + void parseNonAsciiString(); + void parseSimpleObject(); + void parseEmptyObject(); + void parseEmptyValue(); + void parseUrl(); + void parseMultipleObject(); + + void parseSimpleArray(); + void parseInvalidObject(); + void parseInvalidObject_data(); + void parseMultipleArray(); + + void reuseSameParser(); + + void testTrueFalseNullValues(); + void testEscapeChars(); + void testNumbers(); + void testNumbers_data(); + void testDoubleParsingWithDifferentLocale(); + void testTopLevelValues(); + void testTopLevelValues_data(); + void testReadWrite(); + void testReadWrite_data(); +}; + +Q_DECLARE_METATYPE(QVariant) +Q_DECLARE_METATYPE(QVariant::Type) + +using namespace QJson; + +void TestParser::parseSimpleObject() { + QByteArray json = "{\"foo\":\"bar\"}"; + QVariantMap map; + map.insert (QLatin1String("foo"), QLatin1String("bar")); + QVariant expected(map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::parseEmptyObject() { + QByteArray json = "{}"; + QVariantMap map; + QVariant expected (map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::parseEmptyValue() { + QByteArray json = "{\"value\": \"\"}"; + + QVariantMap map; + map.insert (QLatin1String("value"), QString(QLatin1String(""))); + QVariant expected (map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); + QVERIFY (result.toMap().value(QLatin1String("value")).type() == QVariant::String); + + QString value = result.toMap().value(QLatin1String("value")).toString(); + QVERIFY (value.isEmpty()); +} + +void TestParser::parseInvalidObject() { + QFETCH(QByteArray, json); + + Parser parser; + bool ok; + parser.parse (json, &ok); + QVERIFY (!ok); + QVERIFY(!parser.errorString().isEmpty()); +} + +void TestParser::parseInvalidObject_data() { + QTest::addColumn("json"); + + QTest::newRow("unclosed object") << QByteArray("{\"foo\":\"bar\""); + QTest::newRow("infinum (disallow") << QByteArray("Infinum"); + QTest::newRow("Nan (disallow") << QByteArray("NaN"); + QTest::newRow("no data") << QByteArray(""); +} + + +void TestParser::parseNonAsciiString() { + QByteArray json = "{\"artist\":\"Queensr\\u00ffche\"}"; + QVariantMap map; + + QChar unicode_char (0x00ff); + QString unicode_string; + unicode_string.setUnicode(&unicode_char, 1); + unicode_string = QLatin1String("Queensr") + unicode_string + QLatin1String("che"); + + map.insert (QLatin1String("artist"), unicode_string); + QVariant expected (map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::parseMultipleObject() { + //put also some extra spaces inside the json string + QByteArray json = "{ \"foo\":\"bar\",\n\"number\" : 51.3 , \"array\":[\"item1\", 123]}"; + QVariantMap map; + map.insert (QLatin1String("foo"), QLatin1String("bar")); + map.insert (QLatin1String("number"), 51.3); + QVariantList list; + list.append (QLatin1String("item1")); + list.append (QLatin1String("123")); + map.insert (QLatin1String("array"), list); + QVariant expected (map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); + QVERIFY (result.toMap().value(QLatin1String("number")).canConvert()); + QVERIFY (result.toMap().value(QLatin1String("array")).canConvert()); +} + +void TestParser::parseUrl(){ + //"http:\/\/www.last.fm\/venue\/8926427" + QByteArray json = "[\"http:\\/\\/www.last.fm\\/venue\\/8926427\"]"; + QVariantList list; + list.append (QVariant(QLatin1String("http://www.last.fm/venue/8926427"))); + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + + void TestParser::parseSimpleArray() { + QByteArray json = "[\"foo\",\"bar\"]"; + QVariantList list; + list.append (QLatin1String("foo")); + list.append (QLatin1String("bar")); + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::parseMultipleArray() { + //put also some extra spaces inside the json string + QByteArray json = "[ {\"foo\":\"bar\"},\n\"number\",51.3 , [\"item1\", 123]]"; + QVariantMap map; + map.insert (QLatin1String("foo"), QLatin1String("bar")); + + QVariantList array; + array.append (QLatin1String("item1")); + array.append (123); + + QVariantList list; + list.append (map); + list.append (QLatin1String("number")); + list.append (QLatin1String("51.3")); + list.append ((QVariant) array); + + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::testTrueFalseNullValues() { + QByteArray json = "[true,false, null, {\"foo\" : true}]"; + QVariantList list; + list.append (QVariant(true)); + list.append (QVariant(false)); + list.append (QVariant()); + QVariantMap map; + map.insert (QLatin1String("foo"), true); + list.append (map); + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); + QCOMPARE (result.toList().at(0).toBool(), true); + QCOMPARE (result.toList().at(1).toBool(), false); + QVERIFY (result.toList().at(2).isNull()); +} + +void TestParser::testEscapeChars() { + QByteArray json = "[\"\\b \\f \\n \\r \\t \", \" \\\\ \\/ \\\\\", \"http:\\/\\/foo.com\"]"; + + QVariantList list; + list.append (QLatin1String("\b \f \n \r \t ")); + list.append (QLatin1String(" \\ / \\")); + list.append (QLatin1String("http://foo.com")); + + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result.toList().size(), expected.toList().size() ); + QCOMPARE(result, expected); +} + +void TestParser::testNumbers() { + QFETCH(QByteArray, input); + QFETCH(QVariant, expected); + QFETCH(QVariant::Type, type); + + Parser parser; + bool ok; + QVariant result = parser.parse ('[' + input + ']', &ok); + QVERIFY (ok); + + QVariant value = result.toList().at(0); + QCOMPARE(value, expected); + QCOMPARE( value.type(), type); +} + +void TestParser::testNumbers_data() { + QTest::addColumn( "input" ); + QTest::addColumn( "expected" ); + QTest::addColumn( "type" ); + + QByteArray input; + QVariant output; + + // simple ulonglong + input = QByteArray("1"); + output = QVariant(QVariant::ULongLong); + output.setValue(1); + + QTest::newRow("simple ulonglong") << input << output << QVariant::ULongLong; + + // big number + input = QByteArray("12345678901234567890"); + output = QVariant(QVariant::ULongLong); + output.setValue(12345678901234567890ull); + + QTest::newRow("big number") << input << output << QVariant::ULongLong; + + // simple double + input = QByteArray("2.004"); + output = QVariant(QVariant::Double); + output.setValue(2.004); + + QTest::newRow("simple double") << input << output << QVariant::Double; + + // negative int + input = QByteArray("-100"); + output = QVariant(QVariant::LongLong); + output.setValue(-100); + + QTest::newRow("negative int") << input << output << QVariant::LongLong; + + // negative double + input = QByteArray("-3.4"); + output = QVariant(QVariant::Double); + output.setValue(-3.4); + + QTest::newRow("negative double") << input << output << QVariant::Double; +} + +void TestParser::testTopLevelValues() { + QFETCH(QByteArray, input); + QFETCH(QVariant, expected); + QFETCH(QVariant::Type, type); + + Parser parser; + bool ok; + QVariant result = parser.parse (input, &ok); + QVERIFY (ok); + + QCOMPARE(result, expected); + QCOMPARE(result.type(), type); +} + +void TestParser::testTopLevelValues_data() { + QTest::addColumn( "input" ); + QTest::addColumn( "expected" ); + QTest::addColumn( "type" ); + + QByteArray input; + QVariant output; + + // string + input = QByteArray("\"foo bar\""); + output = QVariant(QLatin1String("foo bar")); + QTest::newRow("string") << input << output << QVariant::String; + + // number + input = QByteArray("2.4"); + output = QVariant(QVariant::Double); + output.setValue(2.4); + QTest::newRow("simple double") << input << output << QVariant::Double; + + // boolean + input = QByteArray("true"); + output = QVariant(QVariant::Bool); + output.setValue(true); + QTest::newRow("bool") << input << output << QVariant::Bool; + + // null + input = QByteArray("null"); + output = QVariant(); + QTest::newRow("null") << input << output << QVariant::Invalid; + + // array + input = QByteArray("[1,2,3]"); + QVariantList list; + list << QVariant(1) << QVariant(2) << QVariant(3); + output = QVariant(QVariant::List); + output.setValue(list); + QTest::newRow("array") << input << output << QVariant::List; + + // object + input = QByteArray("{\"foo\" : \"bar\"}"); + QVariantMap map; + map.insert(QLatin1String("foo"), QLatin1String("bar")); + output = QVariant(QVariant::Map); + output.setValue(map); + QTest::newRow("object") << input << output << QVariant::Map; +} + +void TestParser::testDoubleParsingWithDifferentLocale() { + QLocale oldLocale; + QLocale itLocale(QLatin1String("it_IT.utf8")); + + QCOMPARE(itLocale.name(), QLatin1String("it_IT") ); + + // the Italian locale uses ',' as digit separator. + QLocale::setDefault(itLocale); + + Parser parser; + bool ok; + QVariant result = parser.parse ("12.3", &ok); + QVERIFY (ok); + + QCOMPARE(result.toDouble(), 12.3); + + QLocale::setDefault(oldLocale); +} + +void TestParser::testReadWrite() +{ + QFETCH( QVariant, variant ); + Serializer serializer; + bool ok; + + QByteArray json = serializer.serialize(variant, &ok); + QVERIFY(ok); + + Parser parser; + QVariant result = parser.parse( json, &ok ); + QVERIFY(ok); + QCOMPARE( result, variant ); +} + +void TestParser::testReadWrite_data() +{ + QTest::addColumn( "variant" ); + + // array tests + QTest::newRow( "empty array" ) << QVariant(QVariantList()); + + // basic array + QVariantList list; + list << QString(QLatin1String("hello")); + list << 12; + QTest::newRow( "basic array" ) << QVariant(list); + + // simple map + QVariantMap map; + map[QString(QLatin1String("Name"))] = 32; + QTest::newRow( "complicated array" ) << QVariant(map); +} + +void TestParser::reuseSameParser() +{ + Parser parser; + bool ok; + + parser.parse ("12.3", &ok); + QVERIFY (ok); + + parser.parse ("wrong entry", &ok); + QVERIFY (!ok); + + parser.parse ("12.3", &ok); + QVERIFY (ok); +} + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +// using Qt4 rather then Qt5 +QTEST_MAIN(TestParser) +#include "moc_testparser.cxx" +#else +QTEST_GUILESS_MAIN(TestParser) +#include "testparser.moc" +#endif diff --git a/tests/qobjecthelper/.gitignore b/tests/qobjecthelper/.gitignore new file mode 100644 index 000000000..e64e23248 --- /dev/null +++ b/tests/qobjecthelper/.gitignore @@ -0,0 +1,5 @@ +Makefile +*.o +*.moc +moc_* +qobjecthelper diff --git a/tests/qobjecthelper/CMakeLists.txt b/tests/qobjecthelper/CMakeLists.txt new file mode 100644 index 000000000..d1636e6fb --- /dev/null +++ b/tests/qobjecthelper/CMakeLists.txt @@ -0,0 +1,55 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET (qjson_test_support_SRCS person.cpp) +IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(qjson_test_support_MOC_SRCS person.h) +ENDIF() + +ADD_LIBRARY (qjson_test_support STATIC ${qjson_test_support_SRCS} + ${qjson_test_support_MOC_SRCS}) + +SET( UNIT_TESTS + testqobjecthelper +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(MOC_SOURCE ${test}.cpp) + ENDIF() + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + ADD_FILE_DEPENDENCIES(${test}.cpp ${MOC_SOURCE}) + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + qjson_test_support + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/qobjecthelper/person.cpp b/tests/qobjecthelper/person.cpp new file mode 100644 index 000000000..23291798b --- /dev/null +++ b/tests/qobjecthelper/person.cpp @@ -0,0 +1,75 @@ +#include "person.h" + +Person::Person(QObject* parent) + : QObject(parent), + m_name(), + m_phoneNumber(0), + m_gender(Female), + m_luckyNumber(0) +{ +} + +Person::~Person() +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString& name) +{ + m_name = name; +} + +int Person::phoneNumber() const +{ + return m_phoneNumber; +} + +void Person::setPhoneNumber(const int phoneNumber) +{ + m_phoneNumber = phoneNumber; +} + +void Person::setGender(Gender gender) +{ + m_gender = gender; +} + +Person::Gender Person::gender() const +{ + return m_gender; +} + +QDate Person::dob() const +{ + return m_dob; +} + +void Person::setDob(const QDate& dob) +{ + m_dob = dob; +} + +QVariant Person::customField() const +{ + return m_customField; +} + +void Person::setCustomField(const QVariant& customField) +{ + m_customField = customField; +} + +const quint16 Person::luckyNumber() const +{ + return m_luckyNumber; +} + +void Person::setLuckyNumber(const quint16 luckyNumber) +{ + m_luckyNumber = luckyNumber; +} + diff --git a/tests/qobjecthelper/person.h b/tests/qobjecthelper/person.h new file mode 100644 index 000000000..3026bf782 --- /dev/null +++ b/tests/qobjecthelper/person.h @@ -0,0 +1,73 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef PERSON_H +#define PERSON_H + +#include +#include +#include +#include + +class Person : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber) + Q_PROPERTY(Gender gender READ gender WRITE setGender) + Q_PROPERTY(QDate dob READ dob WRITE setDob) + Q_PROPERTY(QVariant customField READ customField WRITE setCustomField) + Q_PROPERTY(quint16 luckyNumber READ luckyNumber WRITE setLuckyNumber) + Q_ENUMS(Gender) + + public: + Person(QObject* parent = 0); + ~Person(); + + QString name() const; + void setName(const QString& name); + + int phoneNumber() const; + void setPhoneNumber(const int phoneNumber); + + enum Gender {Male, Female}; + void setGender(Gender gender); + Gender gender() const; + + QDate dob() const; + void setDob(const QDate& dob); + + QVariant customField() const; + void setCustomField(const QVariant& customField); + + const quint16 luckyNumber() const; + void setLuckyNumber(const quint16 luckyNumber); + + private: + QString m_name; + int m_phoneNumber; + Gender m_gender; + QDate m_dob; + QVariant m_customField; + quint16 m_luckyNumber; +}; + +#endif diff --git a/tests/qobjecthelper/testqobjecthelper.cpp b/tests/qobjecthelper/testqobjecthelper.cpp new file mode 100644 index 000000000..2abb9e91e --- /dev/null +++ b/tests/qobjecthelper/testqobjecthelper.cpp @@ -0,0 +1,126 @@ + +/* This file is part of QJson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include + +#include + +#include +#include +#include + +#include "person.h" + +class TestQObjectHelper: public QObject +{ + Q_OBJECT + private slots: + void testQObject2QVariant(); + void testQVariant2QObject(); +}; + +using namespace QJson; + +void TestQObjectHelper::testQObject2QVariant() +{ + QString name = QLatin1String("Flavio Castelli"); + int phoneNumber = 123456; + Person::Gender gender = Person::Male; + QDate dob (1982, 7, 12); + QVariantList nicknames; + nicknames << QLatin1String("nickname1") << QLatin1String("nickname2"); + quint16 luckyNumber = 123; + + Person person; + person.setName(name); + person.setPhoneNumber(phoneNumber); + person.setGender(gender); + person.setDob(dob); + person.setCustomField(nicknames); + person.setLuckyNumber(luckyNumber); + + QVariantMap expected; + expected[QLatin1String("name")] = QVariant(name); + expected[QLatin1String("phoneNumber")] = QVariant(phoneNumber); + expected[QLatin1String("gender")] = QVariant(gender); + expected[QLatin1String("dob")] = QVariant(dob); + expected[QLatin1String("customField")] = nicknames; + expected[QLatin1String("luckyNumber")] = luckyNumber; + + QVariantMap result = QObjectHelper::qobject2qvariant(&person); + QCOMPARE(result, expected); +} + +void TestQObjectHelper::testQVariant2QObject() +{ + bool ok; + QString name = QLatin1String("Flavio Castelli"); + int phoneNumber = 123456; + Person::Gender gender = Person::Male; + QDate dob (1982, 7, 12); + QVariantList nicknames; + nicknames << QLatin1String("nickname1") << QLatin1String("nickname2"); + quint16 luckyNumber = 123; + + Person expected_person; + expected_person.setName(name); + expected_person.setPhoneNumber(phoneNumber); + expected_person.setGender(gender); + expected_person.setDob(dob); + expected_person.setCustomField(nicknames); + expected_person.setLuckyNumber(luckyNumber); + + QVariantMap variant = QObjectHelper::qobject2qvariant(&expected_person); + + Serializer serializer; + QByteArray json = serializer.serialize(variant, &ok); + qDebug() << "json is" << json; + QVERIFY(ok); + + Parser parser; + QVariant parsedVariant = parser.parse(json,&ok); + QVERIFY(ok); + qDebug() << parsedVariant; + QVERIFY(parsedVariant.canConvert(QVariant::Map)); + + Person person; + QCOMPARE(Person::Female, person.gender()); + QObjectHelper::qvariant2qobject(parsedVariant.toMap(), &person); + + QCOMPARE(person.name(), name); + QCOMPARE(person.phoneNumber(), phoneNumber); + QCOMPARE(person.gender(), gender); + QCOMPARE(person.dob(), dob); + QCOMPARE(person.customField(), QVariant(nicknames)); + QCOMPARE(person.luckyNumber(), luckyNumber); +} + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +// using Qt4 rather then Qt5 +QTEST_MAIN(TestQObjectHelper) +#include "moc_testqobjecthelper.cxx" +#else +QTEST_GUILESS_MAIN(TestQObjectHelper) +#include "testqobjecthelper.moc" +#endif diff --git a/tests/scanner/CMakeLists.txt b/tests/scanner/CMakeLists.txt new file mode 100644 index 000000000..185231e6b --- /dev/null +++ b/tests/scanner/CMakeLists.txt @@ -0,0 +1,47 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../src + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( UNIT_TESTS + testscanner +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(MOC_SOURCE ${test}.cpp) + ENDIF() + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + ADD_FILE_DEPENDENCIES(${test}.cpp ${MOC_SOURCE}) + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/scanner/testscanner.cpp b/tests/scanner/testscanner.cpp new file mode 100644 index 000000000..456c12fe7 --- /dev/null +++ b/tests/scanner/testscanner.cpp @@ -0,0 +1,256 @@ +/* This file is part of QJson + * + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include + +#include + +#include "json_scanner.h" +#include "json_parser.hh" +#include "location.hh" + +#define TOKEN(type) (int)yy::json_parser::token::type + +class TestScanner: public QObject +{ + Q_OBJECT + private slots: + void scanClosedDevice(); + void scanTokens(); + void scanTokens_data(); + void scanSpecialNumbers(); + void scanSpecialNumbers_data(); +}; + +Q_DECLARE_METATYPE(QVariant) +Q_DECLARE_METATYPE(QVariant::Type) + +using namespace QJson; + +void TestScanner::scanClosedDevice() { + QBuffer buffer; + int expectedResult = -1; + + JSonScanner scanner(&buffer); + QVariant yylval; + yy::location location; + int result = scanner.yylex(&yylval, &location); + QCOMPARE(result, expectedResult); +} + +void TestScanner::scanTokens() { + QFETCH(QByteArray, input); + QFETCH(bool, allowSpecialNumbers); + QFETCH(bool, skipFirstToken); + QFETCH(int, expectedResult); + QFETCH(QVariant, expectedYylval); + QFETCH(int, expectedLocationBeginLine); + QFETCH(int, expectedLocationBeginColumn); + QFETCH(int, expectedLocationEndLine); + QFETCH(int, expectedLocationEndColumn); + + QBuffer buffer; + buffer.open(QBuffer::ReadWrite); + buffer.write(input); + buffer.seek(0); + JSonScanner scanner(&buffer); + scanner.allowSpecialNumbers(allowSpecialNumbers); + + QVariant yylval; + yy::position position(YY_NULL, 1, 0); + yy::location location(position, position); + int result = scanner.yylex(&yylval, &location); + + if (skipFirstToken) { + result = scanner.yylex(&yylval, &location); + } + + QCOMPARE(result, expectedResult); + QCOMPARE(yylval, expectedYylval); + QCOMPARE(location.begin.line, (uint)expectedLocationBeginLine); + QCOMPARE(location.begin.column, (uint)expectedLocationBeginColumn); + QCOMPARE(location.end.line, (uint)expectedLocationEndLine); + QCOMPARE(location.end.column, (uint)expectedLocationEndColumn); +} + +void TestScanner::scanTokens_data() { + QTest::addColumn("input"); + QTest::addColumn("allowSpecialNumbers"); + QTest::addColumn("skipFirstToken"); + QTest::addColumn("expectedResult"); + QTest::addColumn("expectedYylval"); + QTest::addColumn("expectedLocationBeginLine"); + QTest::addColumn("expectedLocationBeginColumn"); + QTest::addColumn("expectedLocationEndLine"); + QTest::addColumn("expectedLocationEndColumn"); + + QTest::newRow("empty string") << QByteArray("") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 0; + + QTest::newRow("carriage return") << QByteArray("\r") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 2 << 1; + QTest::newRow("new line") << QByteArray("\n") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 2 << 1; + QTest::newRow("formfeed") << QByteArray("\f") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("vertical tab") << QByteArray("\v") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("space") << QByteArray(" ") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("tab") << QByteArray("\t") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("all spaces") << QByteArray("\r\n\f\v \t") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 3 << 5; + + QTest::newRow("true") << QByteArray("true") << true << false << TOKEN(TRUE_VAL) << QVariant(true) << 1 << 0 << 1 << 4; + QTest::newRow("false") << QByteArray("false") << true << false << TOKEN(FALSE_VAL) << QVariant(false) << 1 << 0 << 1 << 5; + QTest::newRow("null") << QByteArray("null") << true << false << TOKEN(NULL_VAL) << QVariant() << 1 << 0 << 1 << 4; + + QTest::newRow("alphabetic string") << QByteArray("\"abcde\"") << true << false << TOKEN(STRING) << QVariant(QLatin1String("abcde")) << 1 << 0 << 1 << 2; + QTest::newRow("ecaped string") << QByteArray("\"abcde\\b\\f\\n\\r\\t\"") << true << false << TOKEN(STRING) << QVariant(QLatin1String("abcde\b\f\n\r\t")) << 1 << 0 << 1 << 2; + QTest::newRow("invalid ecaped string") << QByteArray("\"\\x\"") << true << false << TOKEN(STRING) << QVariant(QLatin1String("x")) << 1 << 0 << 1 << 2; + QTest::newRow("escaped unicode sequence") << QByteArray("\"\\u005A\"") << true << false << TOKEN(STRING) << QVariant(QLatin1String("Z")) << 1 << 0 << 1 << 2; + QTest::newRow("invalid unicode sequence") << QByteArray("\"\\u005Z\"") << true << false << TOKEN(INVALID) << QVariant(QLatin1String("")) << 1 << 0 << 1 << 2; + QTest::newRow("empty string") << QByteArray("\"") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + + QTest::newRow("single digit") << QByteArray("0") << true << false << TOKEN(NUMBER) << QVariant(0u) << 1 << 0 << 1 << 1; + QTest::newRow("multiple digits") << QByteArray("123456789") << true << false << TOKEN(NUMBER) << QVariant(123456789u) << 1 << 0 << 1 << 9; + QTest::newRow("negative single digit") << QByteArray("-0") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 2; + QTest::newRow("negative multiple digits") << QByteArray("-123456789") << true << false << TOKEN(NUMBER) << QVariant(-123456789) << 1 << 0 << 1 << 10; + QTest::newRow("fractional single digit") << QByteArray("0.1") << true << false << TOKEN(NUMBER) << QVariant(0.1) << 1 << 0 << 1 << 3; + QTest::newRow("fractional multiple digits") << QByteArray("123456789.12") << true << false << TOKEN(NUMBER) << QVariant(123456789.12) << 1 << 0 << 1 << 12; + QTest::newRow("fractional negative single digit") << QByteArray("-0.3") << true << false << TOKEN(NUMBER) << QVariant(-0.3) << 1 << 0 << 1 << 4; + QTest::newRow("fractional negative multiple digits") << QByteArray("-123456789.23") << true << false << TOKEN(NUMBER) << QVariant(-123456789.23) << 1 << 0 << 1 << 13; + QTest::newRow("exponential single digit") << QByteArray("10e2") << true << false << TOKEN(NUMBER) << QVariant(1000) << 1 << 0 << 1 << 4; + QTest::newRow("exponential multiple digits") << QByteArray("10e23") << true << false << TOKEN(NUMBER) << QVariant(10e23) << 1 << 0 << 1 << 5; + QTest::newRow("exponential zero") << QByteArray("0e23") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 4; + QTest::newRow("exponential fractional") << QByteArray("0.12354e23") << true << false << TOKEN(NUMBER) << QVariant(0.12354e23) << 1 << 0 << 1 << 10; + QTest::newRow("exponential fractional multiple digits") << QByteArray("120.12354e23") << true << false << TOKEN(NUMBER) << QVariant(120.12354e23) << 1 << 0 << 1 << 12; + QTest::newRow("uppercase exponential") << QByteArray("120.12354E23") << true << false << TOKEN(NUMBER) << QVariant(120.12354E23) << 1 << 0 << 1 << 12; + QTest::newRow("negative exponential single digit") << QByteArray("-10e2") << true << false << TOKEN(NUMBER) << QVariant(-1000) << 1 << 0 << 1 << 5; + QTest::newRow("negative exponential multiple digits") << QByteArray("-10e23") << true << false << TOKEN(NUMBER) << QVariant(-10e23) << 1 << 0 << 1 << 6; + QTest::newRow("negative exponential zero") << QByteArray("-0e23") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 5; + QTest::newRow("negative exponential fractional") << QByteArray("-0.12354e23") << true << false << TOKEN(NUMBER) << QVariant(-0.12354e23) << 1 << 0 << 1 << 11; + QTest::newRow("negative exponential fractional multiple digits") << QByteArray("-120.12354e23") << true << false << TOKEN(NUMBER) << QVariant(-120.12354e23) << 1 << 0 << 1 << 13; + QTest::newRow("negative exponent") << QByteArray("10e-2") << true << false << TOKEN(NUMBER) << QVariant(10e-2) << 1 << 0 << 1 << 5; + QTest::newRow("positive exponent with plus") << QByteArray("10e+2") << true << false << TOKEN(NUMBER) << QVariant(1000) << 1 << 0 << 1 << 5; + + QTest::newRow("invalid multiple digits") << QByteArray("001") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 1; + QTest::newRow("invalid negative multiple digits") << QByteArray("-001") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 2; + QTest::newRow("invalid fractional") << QByteArray("12.") << true << true << TOKEN(INVALID) << QVariant(12) << 1 << 2 << 1 << 3; + QTest::newRow("invalid exponential 1") << QByteArray("-5e+") << true << true << TOKEN(INVALID) << QVariant(-5) << 1 << 2 << 1 << 3; + QTest::newRow("invalid exponential 2") << QByteArray("2e") << true << true << TOKEN(INVALID) << QVariant(2) << 1 << 1 << 1 << 2; + QTest::newRow("invalid exponential 3") << QByteArray("3e+") << true << true << TOKEN(INVALID) << QVariant(3) << 1 << 1 << 1 << 2; + QTest::newRow("invalid exponential 4") << QByteArray("4.3E") << true << true << TOKEN(INVALID) << QVariant(4.3) << 1 << 3 << 1 << 4; + QTest::newRow("invalid exponential 5") << QByteArray("5.4E-") << true << true << TOKEN(INVALID) << QVariant(5.4) << 1 << 3 << 1 << 4; + + QTest::newRow("colon") << QByteArray(":") << true << false << TOKEN(COLON) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("comma") << QByteArray(",") << true << false << TOKEN(COMMA) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("square bracket open") << QByteArray("[") << true << false << TOKEN(SQUARE_BRACKET_OPEN) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("square bracket close") << QByteArray("]") << true << false << TOKEN(SQUARE_BRACKET_CLOSE) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("curly bracket open") << QByteArray("{") << true << false << TOKEN(CURLY_BRACKET_OPEN) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("curly bracket close") << QByteArray("}") << true << false << TOKEN(CURLY_BRACKET_CLOSE) << QVariant() << 1 << 0 << 1 << 1; + + QTest::newRow("too large unsinged number") << QByteArray("18446744073709551616") << false << false << TOKEN(INVALID) << QVariant(ULLONG_MAX) << 1 << 0 << 1 << 20; + QTest::newRow("too large signed number") << QByteArray("-9223372036854775808") << false << false << TOKEN(INVALID) << QVariant(LLONG_MIN) << 1 << 0 << 1 << 20; + QTest::newRow("too large exponential") << QByteArray("1.7976931348623157e309") << false << false << TOKEN(INVALID) << QVariant(0) << 1 << 0 << 1 << 22; + QTest::newRow("not allowed nan") << QByteArray("nan") << false << false << TOKEN(INVALID) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("not allowed infinity") << QByteArray("Infinity") << false << false << TOKEN(INVALID) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("unknown") << QByteArray("*") << true << false << TOKEN(INVALID) << QVariant() << 1 << 0 << 1 << 1; +} + + +void TestScanner::scanSpecialNumbers() { + QFETCH(QByteArray, input); + QFETCH(bool, isInfinity); + QFETCH(bool, isNegative); + QFETCH(bool, isNan); + QFETCH(int, expectedLocationBeginLine); + QFETCH(int, expectedLocationBeginColumn); + QFETCH(int, expectedLocationEndLine); + QFETCH(int, expectedLocationEndColumn); + + QBuffer buffer; + buffer.open(QBuffer::ReadWrite); + buffer.write(input); + buffer.seek(0); + JSonScanner scanner(&buffer); + scanner.allowSpecialNumbers(true); + + QVariant yylval; + yy::position position(YY_NULL, 1, 0); + yy::location location(position, position); + int result = scanner.yylex(&yylval, &location); + + QCOMPARE(result, TOKEN(NUMBER)); + QVERIFY(yylval.type() == QVariant::Double); + + double doubleResult = yylval.toDouble(); + + #if defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) + QCOMPARE(bool(isinf(doubleResult)), isInfinity); + #else + // skip this test for MSVC, because there is no "isinf" function. + #ifndef Q_CC_MSVC + QCOMPARE(bool(std::isinf(doubleResult)), isInfinity); + #endif + #endif + + QCOMPARE(doubleResult<0, isNegative); + + #if defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) + QCOMPARE(bool(isnan(doubleResult)), isNan); + #else + // skip this test for MSVC, because there is no "isinf" function. + #ifndef Q_CC_MSVC + QCOMPARE(bool(std::isnan(doubleResult)), isNan); + #endif + #endif + + QCOMPARE(location.begin.line, (uint)expectedLocationBeginLine); + QCOMPARE(location.begin.column, (uint)expectedLocationBeginColumn); + QCOMPARE(location.end.line, (uint)expectedLocationEndLine); + QCOMPARE(location.end.column, (uint)expectedLocationEndColumn); +} + +void TestScanner::scanSpecialNumbers_data() { + QTest::addColumn("input"); + QTest::addColumn("isInfinity"); + QTest::addColumn("isNegative"); + QTest::addColumn("isNan"); + QTest::addColumn("expectedLocationBeginLine"); + QTest::addColumn("expectedLocationBeginColumn"); + QTest::addColumn("expectedLocationEndLine"); + QTest::addColumn("expectedLocationEndColumn"); + + QTest::newRow("nan") << QByteArray("nan") << false << false << true << 1 << 0 << 1 << 3; + QTest::newRow("NAN") << QByteArray("NAN") << false << false << true << 1 << 0 << 1 << 3; + QTest::newRow("NaN") << QByteArray("NaN") << false << false << true << 1 << 0 << 1 << 3; + + QTest::newRow("infinity") << QByteArray("infinity") << true << false << false << 1 << 0 << 1 << 8; + QTest::newRow("Infinity") << QByteArray("infinity") << true << false << false << 1 << 0 << 1 << 8; + + QTest::newRow("-infinity") << QByteArray("-infinity") << true << true << false << 1 << 0 << 1 << 9; + QTest::newRow("-Infinity") << QByteArray("-Infinity") << true << true << false << 1 << 0 << 1 << 9; +} + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +// using Qt4 rather then Qt5 +QTEST_MAIN(TestScanner) +#include "moc_testscanner.cxx" +#else +QTEST_GUILESS_MAIN(TestScanner) +#include "testscanner.moc" +#endif diff --git a/tests/serializer/.gitignore b/tests/serializer/.gitignore new file mode 100644 index 000000000..4a080f160 --- /dev/null +++ b/tests/serializer/.gitignore @@ -0,0 +1,4 @@ +Makefile +*.o +*.moc +serializer diff --git a/tests/serializer/CMakeLists.txt b/tests/serializer/CMakeLists.txt new file mode 100644 index 000000000..c3411bc75 --- /dev/null +++ b/tests/serializer/CMakeLists.txt @@ -0,0 +1,46 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( UNIT_TESTS + testserializer +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(MOC_SOURCE ${test}.cpp) + ENDIF() + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + ADD_FILE_DEPENDENCIES(${test}.cpp ${MOC_SOURCE}) + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/serializer/testserializer.cpp b/tests/serializer/testserializer.cpp new file mode 100644 index 000000000..9a6e8fb34 --- /dev/null +++ b/tests/serializer/testserializer.cpp @@ -0,0 +1,542 @@ +/* This file is part of QJson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include + +#include + +#include +#include + +class TestSerializer: public QObject +{ + Q_OBJECT + private slots: + void testReadWriteEmptyDocument(); + void testReadWrite(); + void testReadWrite_data(); + void testValueNull(); + void testValueString(); + void testValueString_data(); + void testValueStringList(); + void testValueStringList_data(); + void testValueHashMap(); + void testValueInteger(); + void testValueInteger_data(); + void testValueDouble(); + void testValueDouble_data(); + void testSetDoublePrecision(); + void testValueFloat(); + void testValueFloat_data(); + void testValueBoolean(); + void testValueBoolean_data(); + void testSpecialNumbers(); + void testSpecialNumbers_data(); + void testIndentation(); + void testIndentation_data(); + void testSerializetoQIODevice(); + void testSerializeWithoutOkParam(); + + private: + void valueTest( const QVariant& value, const QString& expectedRegExp, bool errorExpected = false ); + void valueTest( const QObject* object, const QString& expectedRegExp ); +}; + +Q_DECLARE_METATYPE(QVariant) + +using namespace QJson; + +void TestSerializer::testReadWriteEmptyDocument() +{ + QByteArray json = ""; + Parser parser; + bool ok; + QVariant result = parser.parse( json, &ok ); + QVERIFY(!ok); + QVERIFY( ! result.isValid() ); + Serializer serializer; + const QByteArray serialized = serializer.serialize( result, &ok); + QVERIFY( ok ); + QByteArray expected = "null"; + QCOMPARE(expected, serialized); +} + +void TestSerializer::testReadWrite() +{ + QFETCH( QByteArray, json ); + Parser parser; + bool ok; + QVariant result = parser.parse( json, &ok ); + QVERIFY(ok); + Serializer serializer; + const QByteArray serialized = serializer.serialize( result, &ok); + QVERIFY(ok); + QVariant writtenThenRead = parser.parse( serialized, &ok ); + QVERIFY(ok); + QCOMPARE( result, writtenThenRead ); +} + +void TestSerializer::testReadWrite_data() +{ + QTest::addColumn( "json" ); + + // array tests + QTest::newRow( "empty array" ) << QByteArray("[]"); + QTest::newRow( "basic array" ) << QByteArray("[\"person\",\"bar\"]"); + QTest::newRow( "single int array" ) << QByteArray("[6]"); + QTest::newRow( "int array" ) << QByteArray("[6,5,6,7]"); + const QByteArray json = "[1,2.4, -100, -3.4, -5e+0, 2e0,3e+0,4.3E0,5.4E-0]"; + QTest::newRow( QByteArray("array of various numbers") ) << json; + + // document tests + QTest::newRow( "empty object" ) << QByteArray("{}"); + QTest::newRow( "basic document" ) << QByteArray("{\"person\":\"bar\"}"); + QTest::newRow( "object with ints" ) << QByteArray("{\"person\":6}"); + const QByteArray json2 = "{ \"person\":\"bar\",\n\"number\" : 51.3 , \"array\":[\"item1\", 123]}"; + QTest::newRow( "complicated document" ) << json2; + + // more complex cases + const QByteArray json3 = "[ {\"person\":\"bar\"},\n\"number\",51.3 , [\"item1\", 123]]"; + QTest::newRow( "complicated array" ) << json3; +} + +void TestSerializer::testIndentation() +{ + QFETCH( QByteArray, json ); + QFETCH( QByteArray, expected_compact ); + QFETCH( QByteArray, expected_min ); + QFETCH( QByteArray, expected_med ); + QFETCH( QByteArray, expected_full ); + + // parse + Parser parser; + bool ok; + QVariant parsed = parser.parse( json, &ok ); + QVERIFY(ok); + + Serializer serializer; + QVariant reparsed; + QByteArray serialized; + + // serialize with indent compact and reparse + serializer.setIndentMode(QJson::IndentCompact); + serialized = serializer.serialize( parsed, &ok); + QVERIFY(ok); + QCOMPARE( serialized, expected_compact); + reparsed = parser.parse( serialized, &ok); + QVERIFY(ok); + QCOMPARE( parsed, reparsed); + + // serialize with indent minimum and reparse + serializer.setIndentMode(QJson::IndentMinimum); + serialized = serializer.serialize( parsed, &ok); + QVERIFY(ok); + QCOMPARE( serialized, expected_min); + reparsed = parser.parse( serialized, &ok); + QVERIFY(ok); + QCOMPARE( parsed, reparsed); + + // serialize with indent medium and reparse + serializer.setIndentMode(QJson::IndentMedium); + serialized = serializer.serialize( parsed, &ok); + QVERIFY(ok); + QCOMPARE( serialized, expected_med); + reparsed = parser.parse( serialized, &ok ); + QVERIFY(ok); + QCOMPARE( parsed, reparsed); + + // serialize with indent full and reparse + serializer.setIndentMode(QJson::IndentFull); + serialized = serializer.serialize( parsed, &ok); + QVERIFY(ok); + QCOMPARE( serialized, expected_full); + reparsed = parser.parse( serialized, &ok ); + QVERIFY(ok); + QCOMPARE( parsed, reparsed); +} + +void TestSerializer::testIndentation_data() +{ + QTest::addColumn( "json" ); + QTest::addColumn( "expected_compact" ); + QTest::addColumn( "expected_min" ); + QTest::addColumn( "expected_med" ); + QTest::addColumn( "expected_full" ); + const QByteArray json = " { \"foo\" : 0, \"foo1\" : 1, \"foo2\" : [ { \"bar\" : 1, \"foo\" : 0, \"foobar\" : 0 }, { \"bar\" : 1, \"foo\" : 1, \"foobar\" : 1 } ], \"foo3\" : [ 1, 2, 3, 4, 5, 6 ] }"; + const QByteArray ex_compact = "{\"foo\":0,\"foo1\":1,\"foo2\":[{\"bar\":1,\"foo\":0,\"foobar\":0},{\"bar\":1,\"foo\":1,\"foobar\":1}],\"foo3\":[1,2,3,4,5,6]}"; + const QByteArray ex_min = "{ \"foo\" : 0, \"foo1\" : 1, \"foo2\" : [\n { \"bar\" : 1, \"foo\" : 0, \"foobar\" : 0 },\n { \"bar\" : 1, \"foo\" : 1, \"foobar\" : 1 }\n ], \"foo3\" : [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ] }"; + const QByteArray ex_med = "{\n \"foo\" : 0, \"foo1\" : 1, \"foo2\" : [\n {\n \"bar\" : 1, \"foo\" : 0, \"foobar\" : 0\n },\n {\n \"bar\" : 1, \"foo\" : 1, \"foobar\" : 1\n }\n ], \"foo3\" : [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ]\n}"; + const QByteArray ex_full = "{\n \"foo\" : 0,\n \"foo1\" : 1,\n \"foo2\" : [\n {\n \"bar\" : 1,\n \"foo\" : 0,\n \"foobar\" : 0\n },\n {\n \"bar\" : 1,\n \"foo\" : 1,\n \"foobar\" : 1\n }\n ],\n \"foo3\" : [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ]\n}"; + QTest::newRow( "test indents" ) << json << ex_compact << ex_min << ex_med << ex_full; +} + +void TestSerializer::valueTest( const QVariant& value, const QString& expectedRegExp, bool errorExpected ) +{ + Serializer serializer; + bool ok; + const QByteArray serialized = serializer.serialize( value, &ok); + QCOMPARE(ok, !errorExpected); + QCOMPARE(serialized.isNull(), errorExpected); + const QString serializedUnicode = QString::fromUtf8( serialized ); + if (!errorExpected) { + QRegExp expected( expectedRegExp ); + QVERIFY( expected.isValid() ); + QVERIFY2( expected.exactMatch( serializedUnicode ), + qPrintable( QString( QLatin1String( "Expected regexp \"%1\" but got \"%2\"." ) ) + .arg( expectedRegExp ).arg( serializedUnicode ) ) ); + } else { + QVERIFY(!serializer.errorMessage().isEmpty()); + } +} + +void TestSerializer::valueTest( const QObject* object, const QString& expectedRegExp ) +{ + Serializer serializer; + bool ok; + const QByteArray serialized = serializer.serialize( object, &ok); + QVERIFY(ok); + const QString serializedUnicode = QString::fromUtf8( serialized ); + QRegExp expected( expectedRegExp ); + QVERIFY( expected.isValid() ); + QVERIFY2( expected.exactMatch( serializedUnicode ), + qPrintable( QString( QLatin1String( "Expected regexp \"%1\" but got \"%2\"." ) ) + .arg( expectedRegExp ).arg( serializedUnicode ) ) ); +} + +void TestSerializer::testValueNull() +{ + valueTest( QVariant(), QLatin1String( "\\s*null\\s*" ) ); + QVariantMap map; + map[QLatin1String("value")] = QVariant(); + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:\\s*null\\s*\\}\\s*" ) ); +} + +void TestSerializer::testValueString() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + valueTest( value, expected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ) ); +} + +void TestSerializer::testValueString_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + QTest::newRow( "null string" ) << QVariant( QString() ) << QString( QLatin1String( "\\s*\"\"\\s*" ) ); + QTest::newRow( "empty string" ) << QVariant( QString( QLatin1String( "" ) ) ) << QString( QLatin1String( "\\s*\"\"\\s*" ) ); + QTest::newRow( "Simple String" ) << QVariant( QString( QLatin1String( "simpleString" ) ) ) << QString( QLatin1String( "\\s*\"simpleString\"\\s*" ) ); + QTest::newRow( "string with tab" ) << QVariant( QString( QLatin1String( "string\tstring" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\tstring\"\\s*" ) ); + QTest::newRow( "string with newline" ) << QVariant( QString( QLatin1String( "string\nstring" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\nstring\"\\s*" ) ); + QTest::newRow( "string with bell" ) << QVariant( QString( QLatin1String( "string\bstring" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\bstring\"\\s*" ) ); + QTest::newRow( "string with return" ) << QVariant( QString( QLatin1String( "string\rstring" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\rstring\"\\s*" ) ); + QTest::newRow( "string with double quote" ) << QVariant( QString( QLatin1String( "string\"string" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\\"string\"\\s*" ) ); + QTest::newRow( "string with backslash" ) << QVariant( QString( QLatin1String( "string\\string" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\\\\\string\"\\s*" ) ); + QString testStringWithUnicode = QString( QLatin1String( "string" ) ) + QChar( 0x2665 ) + QLatin1String( "string" ); + QString testEscapedString = QString( QLatin1String( "string" ) ) + QLatin1String("\\\\u2665") + QLatin1String( "string" ); + QTest::newRow( "string with unicode" ) << QVariant( testStringWithUnicode ) << QLatin1String( "\\s*\"" ) + testEscapedString + QLatin1String( "\"\\s*" ); +} + +void TestSerializer::testValueStringList() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + valueTest( value, expected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ) ); +} + +void TestSerializer::testValueStringList_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + + QStringList stringlist; + QString expected; + + // simple QStringList + stringlist << QLatin1String("hello") << QLatin1String("world"); + expected = QLatin1String( "\\s*\\[\\s*\"hello\"\\s*,\\s*\"world\"\\s*\\]\\s*" ); + QTest::newRow( "simple QStringList" ) << QVariant( stringlist) << expected; +} + +void TestSerializer::testValueInteger() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + valueTest( value, expected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ) ); +} + +void TestSerializer::testValueInteger_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + + QTest::newRow( "int 0" ) << QVariant( static_cast( 0 ) ) << QString( QLatin1String( "\\s*0\\s*" ) ); + QTest::newRow( "uint 0" ) << QVariant( static_cast( 0 ) ) << QString( QLatin1String( "\\s*0\\s*" ) ); + QTest::newRow( "int -1" ) << QVariant( static_cast( -1 ) ) << QString( QLatin1String( "\\s*-1\\s*" ) ); + QTest::newRow( "int 2133149800" ) << QVariant( static_cast(2133149800) ) << QString( QLatin1String( "\\s*2133149800\\s*" ) ); + QTest::newRow( "uint 4133149800" ) << QVariant( static_cast(4133149800u) ) << QString( QLatin1String( "\\s*4133149800\\s*" ) ); + QTest::newRow( "uint64 932838457459459" ) << QVariant( Q_UINT64_C(932838457459459) ) << QString( QLatin1String( "\\s*932838457459459\\s*" ) ); + QTest::newRow( "max unsigned long long" ) << QVariant( std::numeric_limits::max() ) << QString( QLatin1String( "\\s*%1\\s*" ) ).arg(std::numeric_limits::max()); +} + +void TestSerializer::testValueDouble() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + QFETCH( bool, errorExpected ); + valueTest( value, expected, errorExpected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ), errorExpected ); +} + +void TestSerializer::testValueDouble_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + QTest::addColumn( "errorExpected" ); + + QTest::newRow( "double 0" ) << QVariant( 0.0 ) << QString( QLatin1String( "\\s*0.0\\s*" ) ) << false; + QTest::newRow( "double -1" ) << QVariant( -1.0 ) << QString( QLatin1String( "\\s*-1.0\\s*" ) ) << false; + QTest::newRow( "double 1.5E-20" ) << QVariant( 1.5e-20 ) << QString( QLatin1String( "\\s*1.5[Ee]-20\\s*" ) ) << false; + QTest::newRow( "double -1.5E-20" ) << QVariant( -1.5e-20 ) << QString( QLatin1String( "\\s*-1.5[Ee]-20\\s*" ) ) << false; + QTest::newRow( "double 2.0E-20" ) << QVariant( 2.0e-20 ) << QString( QLatin1String( "\\s*2(?:.0)?[Ee]-20\\s*" ) ) << false; + QTest::newRow( "double infinity" ) << QVariant( std::numeric_limits< double >::infinity() ) << QString( ) << true; + QTest::newRow( "double -infinity" ) << QVariant( -std::numeric_limits< double >::infinity() ) << QString( ) << true; + QTest::newRow( "double NaN" ) << QVariant( std::numeric_limits< double >::quiet_NaN() ) << QString( ) << true; +} + +void TestSerializer::testSetDoublePrecision() +{ + bool ok; + Serializer serializer; + QByteArray actual; + QString expected, actualUnicode; + + double num = 0.12345678; + + // Set 1 as double precision + serializer.setDoublePrecision(1); + expected = QString(QLatin1String("0.1")); + actual = serializer.serialize( QVariant(num), &ok); + QVERIFY(ok); + actualUnicode = QString::fromUtf8(actual); + + QVERIFY2( QString::compare(expected, actualUnicode ) == 0, + qPrintable( QString( QLatin1String( "Expected \"%1\" but got \"%2\"." ) ) + .arg( expected ).arg( actualUnicode ) ) ); + + // Set 2 as double precision + serializer.setDoublePrecision(2); + expected = QString(QLatin1String("0.12")); + actual = serializer.serialize( QVariant(num), &ok); + QVERIFY(ok); + actualUnicode = QString::fromUtf8(actual); + + QVERIFY2( QString::compare(expected, actualUnicode ) == 0, + qPrintable( QString( QLatin1String( "Expected \"%1\" but got \"%2\"." ) ) + .arg( expected ).arg( actualUnicode ) ) ); + + // Set 4 as double precision + serializer.setDoublePrecision(4); + expected = QString(QLatin1String("0.1235")); + actual = serializer.serialize( QVariant(num), &ok); + QVERIFY(ok); + actualUnicode = QString::fromUtf8(actual); + + QVERIFY2( QString::compare(expected, actualUnicode ) == 0, + qPrintable( QString( QLatin1String( "Expected \"%1\" but got \"%2\"." ) ) + .arg( expected ).arg( actualUnicode ) ) ); + + // Set 14 as double precision + serializer.setDoublePrecision(14); + expected = QString(QLatin1String("0.12345678")); + actual = serializer.serialize( QVariant(num), &ok); + QVERIFY(ok); + actualUnicode = QString::fromUtf8(actual); + + QVERIFY2( QString::compare(expected, actualUnicode ) == 0, + qPrintable( QString( QLatin1String( "Expected \"%1\" but got \"%2\"." ) ) + .arg( expected ).arg( actualUnicode ) ) ); +} + +void TestSerializer::testValueFloat() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + QFETCH( bool, errorExpected ); + valueTest( value, expected, errorExpected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ), errorExpected ); +} + +void TestSerializer::testValueFloat_data() +{ + QVariant v; + float value; + + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + QTest::addColumn( "errorExpected" ); + + value = 0; + v.setValue(value); + QTest::newRow( "float 0" ) << v << QString( QLatin1String( "\\s*0.0\\s*" ) ) << false; + + value = -1; + v.setValue(value); + QTest::newRow( "float -1" ) << v << QString( QLatin1String( "\\s*-1.0\\s*" ) ) << false; + + value = 1.12f; + v.setValue(value); + QTest::newRow( "float 1.12" ) << v << QString( QLatin1String( "\\s*1.12\\s*" ) ) << false; +} + +void TestSerializer::testValueBoolean() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + valueTest( value, expected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ) ); +} + +void TestSerializer::testValueBoolean_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + + QTest::newRow( "bool false" ) << QVariant( false ) << QString( QLatin1String( "\\s*false\\s*" ) ); + QTest::newRow( "bool true" ) << QVariant( true ) << QString( QLatin1String( "\\s*true\\s*" ) ); +} + +void TestSerializer::testSpecialNumbers() { + bool ok; + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + Serializer specialSerializer; + QVERIFY(!specialSerializer.specialNumbersAllowed()); + specialSerializer.allowSpecialNumbers(true); + QVERIFY(specialSerializer.specialNumbersAllowed()); + QByteArray serialized = specialSerializer.serialize(value, &ok); + QVERIFY(ok); + QCOMPARE(QString::fromLocal8Bit(serialized), expected); +} + +void TestSerializer::testSpecialNumbers_data() { + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + + QTest::newRow( "Infinity" ) << QVariant( std::numeric_limits< double >::infinity() ) << QString::fromLocal8Bit("Infinity"); + QTest::newRow( "-Infinity" ) << QVariant( -std::numeric_limits< double >::infinity() ) << QString::fromLocal8Bit("-Infinity"); + QTest::newRow( "Infinity" ) << QVariant( std::numeric_limits< double >::quiet_NaN() ) << QString::fromLocal8Bit("NaN"); +} + +void TestSerializer::testSerializetoQIODevice() { + QBuffer buffer; + QVariantList variant; + variant << QVariant(QLatin1String("Hello")); + variant << QVariant(QLatin1String("world!")); + + Serializer serializer; + bool ok; + + serializer.serialize(variant, &buffer, &ok); + + QCOMPARE(QString(QLatin1String(buffer.data())), + QString(QLatin1String("[ \"Hello\", \"world!\" ]"))); + QVERIFY(ok); +} + +void TestSerializer::testSerializeWithoutOkParam() { + QBuffer buffer; + QVariantList variant; + variant << QVariant(QLatin1String("Hello")); + variant << QVariant(QLatin1String("world!")); + + Serializer serializer; + + const QByteArray serialized = serializer.serialize(variant); + const QByteArray expected = "[ \"Hello\", \"world!\" ]"; + QCOMPARE(expected, serialized); + + + // test a serialization which produces an error + QVariant brokenVariant ( std::numeric_limits< double >::quiet_NaN() ); + QVERIFY(serializer.serialize(brokenVariant).isEmpty()); +} + +void TestSerializer::testValueHashMap() +{ + Serializer serializer; + bool ok; + + QVariantHash hash; + hash[QLatin1String("one")] = 1; + hash[QLatin1String("three")] = 3; + hash[QLatin1String("seven")] = 7; + + QByteArray json = serializer.serialize(hash, &ok); + QVERIFY(ok); + + Parser parser; + QVariant var = parser.parse(json, &ok); + QVERIFY(ok); + + QVariantMap vmap = var.toMap(); + QHashIterator hIt( hash ); + while ( hIt.hasNext() ) { + hIt.next(); + QString key = hIt.key(); + QVariant value = hIt.value(); + + QMap::const_iterator mIt = vmap.constFind(key); + QVERIFY(mIt != vmap.constEnd()); + QCOMPARE(mIt.value(), value); + } + +} + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +// using Qt4 rather then Qt5 +QTEST_MAIN(TestSerializer) +#include "moc_testserializer.cxx" +#else +QTEST_GUILESS_MAIN(TestSerializer) +#include "testserializer.moc" +#endif From 21204971ffd768fa305f941b5a94822f91d74844 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Thu, 11 Apr 2013 20:42:00 +0200 Subject: [PATCH 34/51] re-apply: Cleaner qobject2qvariant(). --- src/http/qjson/src/qobjecthelper.cpp | 13 +++++++++++-- src/http/qjson/src/qobjecthelper.h | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/http/qjson/src/qobjecthelper.cpp b/src/http/qjson/src/qobjecthelper.cpp index 4f8daf722..0ea440522 100644 --- a/src/http/qjson/src/qobjecthelper.cpp +++ b/src/http/qjson/src/qobjecthelper.cpp @@ -41,8 +41,8 @@ QObjectHelper::~QObjectHelper() delete d; } -QVariantMap QObjectHelper::qobject2qvariant( const QObject* object, - const QStringList& ignoredProperties) +QVariantMap QObjectHelper::qobject2qvariant(const QObject* object, Flags flags, + const QStringList& ignoredProperties) { QVariantMap result; const QMetaObject *metaobject = object->metaObject(); @@ -55,11 +55,20 @@ QVariantMap QObjectHelper::qobject2qvariant( const QObject* object, continue; QVariant value = object->property(name); + if (value.isNull() && !flags.testFlag(Flag_StoreNullVariants)) + continue; + if (!value.isValid() && !flags.testFlag(Flag_StoreInvalidVariants)) + continue; result[QLatin1String(name)] = value; } return result; } +QVariantMap QObjectHelper::qobject2qvariant(const QObject *object, const QStringList &ignoredProperties) + { + return qobject2qvariant(object, Flag_All, ignoredProperties); + } + void QObjectHelper::qvariant2qobject(const QVariantMap& variant, QObject* object) { const QMetaObject *metaobject = object->metaObject(); diff --git a/src/http/qjson/src/qobjecthelper.h b/src/http/qjson/src/qobjecthelper.h index e4dfed0c8..9a819b448 100644 --- a/src/http/qjson/src/qobjecthelper.h +++ b/src/http/qjson/src/qobjecthelper.h @@ -120,14 +120,24 @@ namespace QJson { QObjectHelper(); ~QObjectHelper(); + enum Flag { + Flag_None, + Flag_StoreNullVariants, + Flag_StoreInvalidVariants, + Flag_All = Flag_StoreNullVariants | Flag_StoreInvalidVariants + }; + Q_DECLARE_FLAGS(Flags, Flag) + /** * This method converts a QObject instance into a QVariantMap. * * @param object The QObject instance to be converted. * @param ignoredProperties Properties that won't be converted. */ - static QVariantMap qobject2qvariant( const QObject* object, - const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName")))); + static QVariantMap qobject2qvariant(const QObject* object, Flags flags = Flag_All, + const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName")))); + static QVariantMap qobject2qvariant(const QObject* object, + const QStringList& ignoredProperties); /** * This method converts a QVariantMap instance into a QObject From 2cd6787141f8704caa028b3de15ca92c59f1dbfd Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Fri, 14 Mar 2014 17:57:04 +0000 Subject: [PATCH 35/51] Fixed compilation using qjson subtree. --- src/http/EntryConfig.cpp | 6 +++--- src/http/Protocol.cpp | 6 +++--- src/http/qjson/src/CMakeLists.txt | 4 +++- src/http/qjson/src/parserrunnable.cpp | 4 ++-- src/http/qjson/src/serializerrunnable.cpp | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/http/EntryConfig.cpp b/src/http/EntryConfig.cpp index d5a518755..6dbbf63b0 100644 --- a/src/http/EntryConfig.cpp +++ b/src/http/EntryConfig.cpp @@ -14,9 +14,9 @@ #include "EntryConfig.h" #include "core/Entry.h" #include "core/EntryAttributes.h" -#include "qjson/parser.h" -#include "qjson/qobjecthelper.h" -#include "qjson/serializer.h" +#include "qjson/src/parser.h" +#include "qjson/src/qobjecthelper.h" +#include "qjson/src/serializer.h" static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings"; //TODO: duplicated string (also in Service.cpp) diff --git a/src/http/Protocol.cpp b/src/http/Protocol.cpp index 2c9b4d1b1..018050294 100644 --- a/src/http/Protocol.cpp +++ b/src/http/Protocol.cpp @@ -17,9 +17,9 @@ #include #include -#include "qjson/parser.h" -#include "qjson/qobjecthelper.h" -#include "qjson/serializer.h" +#include "qjson/src/parser.h" +#include "qjson/src/qobjecthelper.h" +#include "qjson/src/serializer.h" #include "crypto/Random.h" #include "crypto/SymmetricCipher.h" diff --git a/src/http/qjson/src/CMakeLists.txt b/src/http/qjson/src/CMakeLists.txt index d2f2ebe66..82ba6a6a3 100644 --- a/src/http/qjson/src/CMakeLists.txt +++ b/src/http/qjson/src/CMakeLists.txt @@ -23,7 +23,7 @@ set (qjson_HEADERS parser.h parserrunnable.h qobjecthelper.h serializer.h serial # Required to use the intree copy of FlexLexer.h INCLUDE_DIRECTORIES(.) -add_library (qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS}) +add_library (qjson STATIC ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS}) IF (Qt5Core_FOUND) target_link_libraries( qjson ${Qt5Core_LIBRARIES}) ELSE() @@ -42,6 +42,8 @@ set_target_properties(qjson PROPERTIES FRAMEWORK ${OSX_FRAMEWORK} ) +add_gcc_compiler_cxxflags("-fexceptions") + INSTALL(TARGETS qjson EXPORT qjson-export LIBRARY DESTINATION ${LIB_INSTALL_DIR} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin diff --git a/src/http/qjson/src/parserrunnable.cpp b/src/http/qjson/src/parserrunnable.cpp index 88baf4cf6..5eb92883b 100644 --- a/src/http/qjson/src/parserrunnable.cpp +++ b/src/http/qjson/src/parserrunnable.cpp @@ -59,10 +59,10 @@ void ParserRunnable::run() QVariant result = parser.parse (d->m_data, &ok); if (ok) { qDebug() << "successfully converted json item to QVariant object"; - emit parsingFinished(result, true, QString()); + Q_EMIT parsingFinished(result, true, QString()); } else { const QString errorText = tr("An error occurred while parsing json: %1").arg(parser.errorString()); qCritical() << errorText; - emit parsingFinished(QVariant(), false, errorText); + Q_EMIT parsingFinished(QVariant(), false, errorText); } } diff --git a/src/http/qjson/src/serializerrunnable.cpp b/src/http/qjson/src/serializerrunnable.cpp index b1894a238..1af03c366 100644 --- a/src/http/qjson/src/serializerrunnable.cpp +++ b/src/http/qjson/src/serializerrunnable.cpp @@ -58,5 +58,5 @@ void SerializerRunnable::run() Serializer serializer; bool ok; const QByteArray serialized = serializer.serialize( d->json, &ok); - emit parsingFinished( serialized, ok, serializer.errorMessage() ); + Q_EMIT parsingFinished( serialized, ok, serializer.errorMessage() ); } From b27ba03d4219dda1929ed81e170e42a8ad210592 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 16:45:36 +0000 Subject: [PATCH 36/51] Replaced qhttpserver with libmicrohttp. The qhttpserver seems to be riddled with memory leaks and was continuously crashing. I don't know Qt well enough to fix it so I have replaced it with libmicrohttp. This is not nearly as elegant but it is much more stable. --- CMakeLists.txt | 2 + cmake/FindLibMicroHTTPD.cmake | 9 ++ src/CMakeLists.txt | 3 +- src/gui/MainWindow.cpp | 10 +- src/http/Server.cpp | 274 +++++++++++++++++++++++----------- src/http/Server.h | 50 ++++--- 6 files changed, 234 insertions(+), 114 deletions(-) create mode 100644 cmake/FindLibMicroHTTPD.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f0c2d025b..92ade41df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,6 +172,8 @@ if(NOT (${GCRYPT_VERSION_STRING} VERSION_LESS "1.6.0")) set(GCRYPT_HAS_SALSA20 1) endif() +find_package(LibMicroHTTPD REQUIRED) + find_package(ZLIB REQUIRED) check_cxx_source_compiles(" diff --git a/cmake/FindLibMicroHTTPD.cmake b/cmake/FindLibMicroHTTPD.cmake new file mode 100644 index 000000000..f31928043 --- /dev/null +++ b/cmake/FindLibMicroHTTPD.cmake @@ -0,0 +1,9 @@ + +find_path(MHD_INCLUDE_DIR microhttpd.h) + +find_library(MHD_LIBRARIES microhttpd) + +mark_as_advanced(MHD_LIBRARIES MHD_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibMicroHTTPD DEFAULT_MSG MHD_LIBRARIES MHD_INCLUDE_DIR) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 35bc888cc..84cc6a48d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -237,7 +237,6 @@ add_library(keepassx_core STATIC ${keepassx_SOURCES}) set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE) add_subdirectory(gui/qocoa) -add_subdirectory(http/qhttpserver) add_subdirectory(http/qjson) add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE}) @@ -245,7 +244,7 @@ target_link_libraries(${PROGNAME} keepassx_core Qocoa qjson - qhttpserver + ${MHD_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 2e2827401..7c11d5b13 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -42,17 +42,19 @@ class HttpPlugin: public ISettingsPage { public: - HttpPlugin(DatabaseTabWidget * tabWidget): m_service(new Service(tabWidget)) { + HttpPlugin(DatabaseTabWidget * tabWidget) { + m_service = new Service(tabWidget); } virtual ~HttpPlugin() { + //delete m_service; } virtual QString name() { return QObject::tr("Http"); } virtual QWidget * createWidget() { OptionDialog * dlg = new OptionDialog(); - QObject::connect(dlg, SIGNAL(removeSharedEncryptionKeys()), m_service.data(), SLOT(removeSharedEncryptionKeys())); - QObject::connect(dlg, SIGNAL(removeStoredPermissions()), m_service.data(), SLOT(removeStoredPermissions())); + QObject::connect(dlg, SIGNAL(removeSharedEncryptionKeys()), m_service, SLOT(removeSharedEncryptionKeys())); + QObject::connect(dlg, SIGNAL(removeStoredPermissions()), m_service, SLOT(removeStoredPermissions())); return dlg; } virtual void loadSettings(QWidget * widget) { @@ -66,7 +68,7 @@ public: m_service->stop(); } private: - QScopedPointer m_service; + Service *m_service; }; const QString MainWindow::BaseWindowTitle = "KeePassX"; diff --git a/src/http/Server.cpp b/src/http/Server.cpp index 9725e56f3..dedbd221c 100644 --- a/src/http/Server.cpp +++ b/src/http/Server.cpp @@ -12,37 +12,17 @@ */ #include "Server.h" -#include "qhttpserver/qhttpserver.h" -#include "qhttpserver/qhttprequest.h" -#include "qhttpserver/qhttpresponse.h" +#include #include "Protocol.h" #include "crypto/Crypto.h" #include #include #include +#include using namespace KeepassHttpProtocol; -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// Request -//////////////////////////////////////////////////////////////////////////////////////////////////// - -RequestHandler::RequestHandler(QHttpRequest *request, QHttpResponse *response): m_request(request), m_response(response) -{ - m_request->storeBody(); - connect(m_request, SIGNAL(end()), this, SLOT(onEnd())); - connect(m_response, SIGNAL(done()), this, SLOT(deleteLater())); -} - -RequestHandler::~RequestHandler() -{ - delete m_request; -} - -void RequestHandler::onEnd() -{ - Q_EMIT requestComplete(m_request, m_response); -} +using namespace KeepassHttpProtocol; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -51,71 +31,14 @@ void RequestHandler::onEnd() Server::Server(QObject *parent) : QObject(parent), - m_httpServer(new QHttpServer(this)), m_started(false) { - connect(m_httpServer, SIGNAL(newRequest(QHttpRequest*,QHttpResponse*)), this, SLOT(handleRequest(QHttpRequest*,QHttpResponse*))); + connect(this, SIGNAL(emitRequest(const QByteArray, QByteArray*)), + this, SLOT(handleRequest(const QByteArray, QByteArray*))); + connect(this, SIGNAL(emitOpenDatabase(bool*)), + this, SLOT(handleOpenDatabase(bool*))); } -void Server::start() -{ - if (m_started) - return; - - static const int PORT = 19455; - m_started = m_httpServer->listen(QHostAddress::LocalHost, PORT) - || m_httpServer->listen(QHostAddress::LocalHostIPv6, PORT); -} - -void Server::stop() -{ - if (!m_started) - return; - m_httpServer->close(); - m_started = false; -} - -void Server::handleRequest(QHttpRequest *request, QHttpResponse *response) -{ - RequestHandler * h = new RequestHandler(request, response); - connect(h, SIGNAL(requestComplete(QHttpRequest*,QHttpResponse*)), this, SLOT(handleRequestComplete(QHttpRequest*,QHttpResponse*))); -} - -void Server::handleRequestComplete(QHttpRequest *request, QHttpResponse *response) -{ - Request r; - if (!isDatabaseOpened() && !openDatabase()) { - response->writeHead(QHttpResponse::STATUS_SERVICE_UNAVAILABLE); - response->end(); - } else if (request->header("content-type").compare("application/json", Qt::CaseInsensitive) == 0 && - r.fromJson(request->body())) { - - QByteArray hash = QCryptographicHash::hash((getDatabaseRootUuid() + getDatabaseRecycleBinUuid()).toUtf8(), - QCryptographicHash::Sha1).toHex(); - - Response protocolResp(r, QString::fromAscii(hash)); - switch(r.requestType()) { - case INVALID: break; - case TEST_ASSOCIATE: testAssociate(r, &protocolResp); break; - case ASSOCIATE: associate(r, &protocolResp); break; - case GET_LOGINS: getLogins(r, &protocolResp); break; - case GET_LOGINS_COUNT: getLoginsCount(r, &protocolResp); break; - case GET_ALL_LOGINS: getAllLogins(r, &protocolResp); break; - case SET_LOGIN: setLogin(r, &protocolResp); break; - case GENERATE_PASSWORD: generatePassword(r, &protocolResp); break; - } - - QByteArray s = protocolResp.toJson().toUtf8(); - response->setHeader("Content-Type", "application/json"); - response->setHeader("Content-Length", QString::number(s.size())); - response->writeHead(QHttpResponse::STATUS_OK); - response->write(s); - response->end(); - } else { - response->writeHead(QHttpResponse::STATUS_BAD_REQUEST); - response->end(); - } -} void Server::testAssociate(const Request& r, Response * protocolResp) { @@ -202,6 +125,39 @@ void Server::setLogin(const Request &r, Response *protocolResp) protocolResp->setVerifier(key); } + +int Server::send_response(struct MHD_Connection *connection, const char *page) +{ + int ret; + struct MHD_Response *response; + + response = MHD_create_response_from_buffer( + strlen(page), static_cast(const_cast(page)), + MHD_RESPMEM_PERSISTENT); + if (!response) return MHD_NO; + + MHD_add_response_header (response, "Content-Type", "application/json"); + ret = MHD_queue_response (connection, MHD_HTTP_OK, response); + MHD_destroy_response (response); + + return ret; +} + + +int Server::send_unavailable(struct MHD_Connection *connection) +{ + int ret; + struct MHD_Response *response; + + response = MHD_create_response_from_buffer(0, NULL, MHD_RESPMEM_PERSISTENT); + if (!response) return MHD_NO; + + ret = MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, response); + MHD_destroy_response (response); + + return ret; +} + void Server::generatePassword(const Request &r, Response *protocolResp) { QString key = getKey(r.id()); @@ -217,3 +173,153 @@ void Server::generatePassword(const Request &r, Response *protocolResp) memset(password.data(), 0, password.length()); } + + +int Server::request_handler_wrapper(void *me, struct MHD_Connection *connection, + const char *url, const char *method, const char *version, + const char *upload_data, size_t *upload_data_size, void **con_cls) +{ + Server *myself = static_cast(me); + + if (myself) + return myself->request_handler(connection, url, method, version, + upload_data, upload_data_size, con_cls); + else + return MHD_NO; +} + + +void Server::handleRequest(const QByteArray in, QByteArray *out) +{ + *out = QByteArray(); + + Request r; + if (!r.fromJson(in)) + return; + + QByteArray hash = QCryptographicHash::hash( + (getDatabaseRootUuid() + getDatabaseRecycleBinUuid()).toUtf8(), + QCryptographicHash::Sha1).toHex(); + + Response protocolResp(r, QString::fromAscii(hash)); + switch(r.requestType()) { + case INVALID: break; + case TEST_ASSOCIATE: testAssociate(r, &protocolResp); break; + case ASSOCIATE: associate(r, &protocolResp); break; + case GENERATE_PASSWORD: generatePassword(r, &protocolResp); break; + case GET_LOGINS: getLogins(r, &protocolResp); break; + case GET_LOGINS_COUNT: getLoginsCount(r, &protocolResp); break; + case GET_ALL_LOGINS: getAllLogins(r, &protocolResp); break; + case SET_LOGIN: setLogin(r, &protocolResp); break; + } + + *out = protocolResp.toJson().toUtf8(); + Q_EMIT donewrk(); +} + + +void Server::handleOpenDatabase(bool *success) +{ + *success = openDatabase(); + Q_EMIT donewrk(); +} + + +int Server::request_handler(struct MHD_Connection *connection, + const char *, const char *method, const char *, + const char *upload_data, size_t *upload_data_size, void **con_cls) +{ + struct Server::connection_info_struct *con_info = + static_cast(*con_cls); + + if (!isDatabaseOpened()) { + bool success; + QEventLoop loop1; + loop1.connect(this, SIGNAL(donewrk()), SLOT(quit())); + Q_EMIT emitOpenDatabase(&success); + loop1.exec(); + + if (!success) + return send_unavailable(connection); + } + + if (con_info == NULL) { + *con_cls = calloc(1, sizeof(*con_info)); + return MHD_YES; + } + + if (strcmp (method, MHD_HTTP_METHOD_POST) != 0) + return MHD_NO; + + if (*upload_data_size == 0) { + if (con_info && con_info->response) + return send_response(connection, con_info->response); + else + return MHD_NO; + } + + QString type = MHD_lookup_connection_value(connection, + MHD_HEADER_KIND, "Content-Type"); + if (!type.contains("application/json", Qt::CaseInsensitive)) + return MHD_NO; + + // Now process the POST request + + QByteArray post = QByteArray(upload_data, *upload_data_size); + + QByteArray s; + QEventLoop loop; + loop.connect(this, SIGNAL(donewrk()), SLOT(quit())); + Q_EMIT emitRequest(post, &s); + loop.exec(); + + if (s.size() == 0) + return MHD_NO; + + con_info->response = static_cast(calloc(1, s.size()+1)); + memcpy(con_info->response, s.data(), s.size()); + + *upload_data_size = 0; + + return MHD_YES; +} + + +void Server::request_completed(void *, struct MHD_Connection *, + void **con_cls, enum MHD_RequestTerminationCode) +{ + struct Server::connection_info_struct *con_info = + static_cast(*con_cls); + + if (con_info == NULL) + return; + + if (con_info->response) free(con_info->response); + free(con_info); + *con_cls = NULL; +} + + +void Server::start(void) +{ + if (m_started) return; + + static const int PORT = 19455; + + daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, + &this->request_handler_wrapper, this, + MHD_OPTION_NOTIFY_COMPLETED, + this->request_completed, NULL, + MHD_OPTION_END); + m_started = true; +} + + +void Server::stop(void) +{ + if (!m_started) + return; + + MHD_stop_daemon(daemon); + m_started = false; +} diff --git a/src/http/Server.h b/src/http/Server.h index 563ecae07..c093556a5 100644 --- a/src/http/Server.h +++ b/src/http/Server.h @@ -16,10 +16,8 @@ #include #include +#include -class QHttpServer; -class QHttpRequest; -class QHttpResponse; namespace KeepassHttpProtocol { @@ -27,24 +25,6 @@ class Request; class Response; class Entry; -class RequestHandler: public QObject { - Q_OBJECT - -public: - RequestHandler(QHttpRequest *request, QHttpResponse *response); - ~RequestHandler(); - -private Q_SLOTS: - void onEnd(); - -Q_SIGNALS: - void requestComplete(QHttpRequest *request, QHttpResponse *response); - -private: - QHttpRequest * m_request; - QHttpResponse *m_response; -}; - class Server : public QObject { Q_OBJECT @@ -70,8 +50,13 @@ public Q_SLOTS: void stop(); private Q_SLOTS: - void handleRequest(QHttpRequest * request, QHttpResponse* response); - void handleRequestComplete(QHttpRequest * request, QHttpResponse* response); + void handleRequest(const QByteArray in, QByteArray *out); + void handleOpenDatabase(bool *success); + +Q_SIGNALS: + void emitRequest(const QByteArray in, QByteArray *out); + void emitOpenDatabase(bool *success); + void donewrk(); private: void testAssociate(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); @@ -82,8 +67,25 @@ private: void setLogin(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); void generatePassword(const KeepassHttpProtocol::Request &r, KeepassHttpProtocol::Response *protocolResp); - QHttpServer * const m_httpServer; + static int request_handler_wrapper(void *me, + struct MHD_Connection *connection, + const char *url, const char *method, const char *version, + const char *upload_data, size_t *upload_data_size, void **con_cls); + static void request_completed(void *, struct MHD_Connection *, + void **con_cls, enum MHD_RequestTerminationCode); + + int request_handler(struct MHD_Connection *connection, + const char *, const char *method, const char *, + const char *upload_data, size_t *upload_data_size, void **con_cls); + int send_response(struct MHD_Connection *connection, const char *page); + int send_unavailable(struct MHD_Connection *connection); + bool m_started; + struct MHD_Daemon *daemon; + + struct connection_info_struct { + char *response; + }; }; } /*namespace KeepassHttpProtocol*/ From fae4f69b8cf09129444a513238daa53ab9713294 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 14:01:44 +0000 Subject: [PATCH 37/51] Quieten compilation warnings. --- src/autotype/AutoTypeAction.cpp | 2 +- src/http/Service.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/autotype/AutoTypeAction.cpp b/src/autotype/AutoTypeAction.cpp index cc751abe0..c448ef74c 100644 --- a/src/autotype/AutoTypeAction.cpp +++ b/src/autotype/AutoTypeAction.cpp @@ -87,7 +87,7 @@ void AutoTypeExecutor::execDelay(AutoTypeDelay* action) Tools::wait(action->delayMs); } -void AutoTypeExecutor::execClearField(AutoTypeClearField* action) +void AutoTypeExecutor::execClearField(AutoTypeClearField*) { // TODO: implement } diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 3342ef15b..eea204df8 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -403,12 +403,12 @@ QList Service::findMatchingEntries(const QString& /* return result; } -int Service::countMatchingEntries(const QString &id, const QString &url, const QString &submitUrl, const QString &realm) +int Service::countMatchingEntries(const QString &, const QString &url, const QString &, const QString &) { return searchEntries(url).count(); } -QList Service::searchAllEntries(const QString &id) +QList Service::searchAllEntries(const QString &) { QList result; if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) @@ -442,7 +442,7 @@ Group * Service::findCreateAddEntryGroup() return NULL; } -void Service::addEntry(const QString &id, const QString &login, const QString &password, const QString &url, const QString &submitUrl, const QString &realm) +void Service::addEntry(const QString &, const QString &login, const QString &password, const QString &url, const QString &submitUrl, const QString &realm) { if (Group * group = findCreateAddEntryGroup()) { Entry * entry = new Entry(); @@ -466,7 +466,7 @@ void Service::addEntry(const QString &id, const QString &login, const QString &p } } -void Service::updateEntry(const QString &id, const QString &uuid, const QString &login, const QString &password, const QString &url) +void Service::updateEntry(const QString &, const QString &uuid, const QString &login, const QString &password, const QString &url) { if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) if (Database * db = dbWidget->database()) From a627870bbb067996f3995513c2cff5b088cc27b2 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 14:03:05 +0000 Subject: [PATCH 38/51] Added a new DatabaseWidget modal state. Commit d8857bf4 attempted to fix currentMode() while the DB had not yet been opened. However, the fix meant that the title bar always displayed the state as being "locked". This change works around the issue by introducing a new modal state for when the DB is not yet open. --- src/gui/DatabaseTabWidget.cpp | 14 ++++++++++---- src/gui/DatabaseWidget.cpp | 6 ++++-- src/gui/DatabaseWidget.h | 1 + src/gui/MainWindow.cpp | 1 + src/http/Service.cpp | 2 ++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 5c364f3c9..545a2bd82 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -229,7 +229,8 @@ void DatabaseTabWidget::checkReloadDatabases() ReloadBehavior reloadBehavior = ReloadBehavior(config()->get("ReloadBehavior").toInt()); if ( (reloadBehavior == AlwaysAsk) - || (reloadBehavior == ReloadUnmodified && mode == DatabaseWidget::EditMode) + || (reloadBehavior == ReloadUnmodified && (mode == DatabaseWidget::EditMode + || mode == DatabaseWidget::OpenMode)) || (reloadBehavior == ReloadUnmodified && dbStruct.modified)) { int res = QMessageBox::warning(this, fi.exists() ? tr("Database file changed") : tr("Database file removed"), tr("Do you want to discard your changes and reload?"), @@ -296,7 +297,8 @@ bool DatabaseTabWidget::closeDatabase(Database* db) if (dbName.right(1) == "*") { dbName.chop(1); } - if (dbStruct.dbWidget->currentMode() == DatabaseWidget::EditMode && db->hasKey()) { + if ((dbStruct.dbWidget->currentMode() == DatabaseWidget::EditMode || + dbStruct.dbWidget->currentMode() == DatabaseWidget::OpenMode) && db->hasKey()) { QMessageBox::StandardButton result = MessageBox::question( this, tr("Close?"), @@ -631,7 +633,9 @@ bool DatabaseTabWidget::hasLockableDatabases() i.next(); DatabaseWidget::Mode mode = i.value().dbWidget->currentMode(); - if ((mode == DatabaseWidget::ViewMode || mode == DatabaseWidget::EditMode) + if ((mode == DatabaseWidget::ViewMode || + mode == DatabaseWidget::EditMode || + mode == DatabaseWidget::OpenMode) && i.value().dbWidget->dbHasKey()) { return true; } @@ -647,7 +651,9 @@ void DatabaseTabWidget::lockDatabases() i.next(); DatabaseWidget::Mode mode = i.value().dbWidget->currentMode(); - if ((mode == DatabaseWidget::ViewMode || mode == DatabaseWidget::EditMode) + if ((mode == DatabaseWidget::ViewMode || + mode == DatabaseWidget::EditMode || + mode == DatabaseWidget::OpenMode) && i.value().dbWidget->dbHasKey()) { i.value().dbWidget->lock(); updateTabName(i.key()); diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 9ddbddd7e..5202611a0 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -173,10 +173,12 @@ DatabaseWidget::Mode DatabaseWidget::currentMode() else if (currentWidget() == m_mainWidget) { return DatabaseWidget::ViewMode; } - else if (currentWidget() == m_unlockDatabaseWidget || - currentWidget() == m_databaseOpenWidget) { + else if (currentWidget() == m_unlockDatabaseWidget) { return DatabaseWidget::LockedMode; } + else if (currentWidget() == m_databaseOpenWidget) { + return DatabaseWidget::OpenMode; + } else { return DatabaseWidget::EditMode; } diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index 894d9811c..a6b06348c 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -55,6 +55,7 @@ public: None, ViewMode, EditMode, + OpenMode, LockedMode }; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 7c11d5b13..aa7330950 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -394,6 +394,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) } case DatabaseWidget::EditMode: case DatabaseWidget::LockedMode: + case DatabaseWidget::OpenMode: Q_FOREACH (QAction* action, m_ui->menuEntries->actions()) { action->setEnabled(false); } diff --git a/src/http/Service.cpp b/src/http/Service.cpp index eea204df8..7de986df6 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -76,6 +76,7 @@ bool Service::isDatabaseOpened() const switch(dbWidget->currentMode()) { case DatabaseWidget::None: case DatabaseWidget::LockedMode: + case DatabaseWidget::OpenMode: break; case DatabaseWidget::ViewMode: @@ -93,6 +94,7 @@ bool Service::openDatabase() switch(dbWidget->currentMode()) { case DatabaseWidget::None: case DatabaseWidget::LockedMode: + case DatabaseWidget::OpenMode: break; case DatabaseWidget::ViewMode: From 612ef0ef9b19006d0805782b176dcf3689d65feb Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 14:07:50 +0000 Subject: [PATCH 39/51] Fixed a typo. --- src/http/EntryConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/EntryConfig.cpp b/src/http/EntryConfig.cpp index 6dbbf63b0..b737cf3e9 100644 --- a/src/http/EntryConfig.cpp +++ b/src/http/EntryConfig.cpp @@ -85,7 +85,7 @@ bool EntryConfig::load(const Entry *entry) bool isOk = false; QVariant v = QJson::Parser().parse(s.toUtf8(), &isOk); - if (!isOk || !v.type() == QVariant::Map) + if (!isOk || v.type() != QVariant::Map) return false; QJson::QObjectHelper::qvariant2qobject(v.toMap(), this); From a9a724714f74ec366b13633c81528911d2736ee4 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 15:54:57 +0000 Subject: [PATCH 40/51] Stop qsearchfield from swallowing keypresses. --- src/gui/qocoa/qsearchfield_mac.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/qocoa/qsearchfield_mac.mm b/src/gui/qocoa/qsearchfield_mac.mm index 01d55937c..c4d320347 100644 --- a/src/gui/qocoa/qsearchfield_mac.mm +++ b/src/gui/qocoa/qsearchfield_mac.mm @@ -103,26 +103,26 @@ public: if (keyCode == KEYCODE_A) { [self performSelector:@selector(selectText:)]; - return YES; + return NO; } else if (keyCode == KEYCODE_C) { QClipboard* clipboard = QApplication::clipboard(); clipboard->setText(toQString([self stringValue])); - return YES; + return NO; } else if (keyCode == KEYCODE_V) { QClipboard* clipboard = QApplication::clipboard(); [self setStringValue:fromQString(clipboard->text())]; - return YES; + return NO; } else if (keyCode == KEYCODE_X) { QClipboard* clipboard = QApplication::clipboard(); clipboard->setText(toQString([self stringValue])); [self setStringValue:@""]; - return YES; + return NO; } } From 61ada66e3adc8378c4abd284e129477ff7a422d1 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 16:23:23 +0000 Subject: [PATCH 41/51] Updated keepasshttp version number. --- src/http/Protocol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/Protocol.cpp b/src/http/Protocol.cpp index 018050294..c8e2669dd 100644 --- a/src/http/Protocol.cpp +++ b/src/http/Protocol.cpp @@ -33,7 +33,7 @@ static const char * const STR_SET_LOGIN = "set-login"; static const char * const STR_ASSOCIATE = "associate"; static const char * const STR_TEST_ASSOCIATE = "test-associate"; static const char * const STR_GENERATE_PASSWORD = "generate-password"; -static const char * const STR_VERSION = "1.7.0.0"; +static const char * const STR_VERSION = "1.8.3.0"; }/*namespace KeepassHttpProtocol*/ From b953ea90420403fe93bb2cf303d9130c7e0c0bd3 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 16:24:11 +0000 Subject: [PATCH 42/51] Tidied up layout of the search field. --- src/gui/MainWindow.cpp | 4 +++- src/gui/MainWindow.ui | 39 +++++++++++---------------------------- src/gui/SearchWidget.ui | 6 +----- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index aa7330950..8a993d33d 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -128,6 +128,7 @@ MainWindow::MainWindow() ? QKeySequence::Find : QKeySequence(Qt::CTRL + Qt::Key_F); connect(new QShortcut(seq, this), SIGNAL(activated()), m_ui->searchField, SLOT(setFocus())); + m_ui->searchField->setContentsMargins(5,0,5,0); m_ui->actionEntryNew->setShortcut(Qt::CTRL + Qt::Key_N); m_ui->actionEntryEdit->setShortcut(Qt::CTRL + Qt::Key_E); m_ui->actionEntryDelete->setShortcut(Qt::CTRL + Qt::Key_D); @@ -248,7 +249,8 @@ MainWindow::MainWindow() m_ui->searchField->setPlaceholderText(tr("Type to search")); m_ui->searchField->setEnabled(false); - m_ui->toolBar->addWidget(m_ui->searchPanel); + m_ui->toolBar->addWidget(m_ui->mySpacer); + m_ui->toolBar->addWidget(m_ui->searchField); m_actionMultiplexer.connect(m_ui->searchField, SIGNAL(textChanged(QString)), SLOT(search(QString))); QMenu* searchMenu = new QMenu(this); diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index cd40a86fd..7585a7549 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -55,34 +55,6 @@ - - - - - 0 - 0 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - @@ -214,6 +186,17 @@ + + + + 0 + 0 + + + + + + diff --git a/src/gui/SearchWidget.ui b/src/gui/SearchWidget.ui index 0e2121617..9f3348074 100644 --- a/src/gui/SearchWidget.ui +++ b/src/gui/SearchWidget.ui @@ -7,7 +7,7 @@ 0 0 630 - 34 + 16 @@ -32,10 +32,6 @@ closeSearchButton - searchEdit - caseSensitiveCheckBox - searchCurrentRadioButton - searchRootRadioButton From 6ef5f34070059287605cf0b1c916793dee953b87 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 16:25:00 +0000 Subject: [PATCH 43/51] Split the new association message across multiple lines. --- src/http/Service.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 7de986df6..9daf9c018 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -146,11 +146,14 @@ QString Service::storeKey(const QString &key) do { bool ok; //Indicate who wants to associate, and request user to enter the 'name' of association key - id = QInputDialog::getText(0, tr("KeyPassX/Http: New key association request"), - tr("You have received an association request for the above key. If you would like to " - "allow it access to your KeePassX database give it a unique name to identify and" - "accept it."), - QLineEdit::Normal, QString(), &ok); + id = QInputDialog::getText(0, + tr("KeyPassX/Http: New key association request"), + tr("You have received an association " + "request for the above key.\n" + "If you would like to allow it access " + "to your KeePassX database\n" + "give it a unique name to identify and accept it."), + QLineEdit::Normal, QString(), &ok); if (!ok || id.isEmpty()) return QString(); From b87097a7abbc676c46ff0a84c341e381506a9fcc Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 16:29:16 +0000 Subject: [PATCH 44/51] Added global autotype support for OSX. --- src/autotype/CMakeLists.txt | 4 + src/autotype/mac/AutoTypeMac.cpp | 551 +++++++++++++++++++++++++++++++ src/autotype/mac/AutoTypeMac.h | 105 ++++++ src/autotype/mac/CMakeLists.txt | 18 + 4 files changed, 678 insertions(+) create mode 100644 src/autotype/mac/AutoTypeMac.cpp create mode 100644 src/autotype/mac/AutoTypeMac.h create mode 100644 src/autotype/mac/CMakeLists.txt diff --git a/src/autotype/CMakeLists.txt b/src/autotype/CMakeLists.txt index 0bf5fc252..37cb2f917 100644 --- a/src/autotype/CMakeLists.txt +++ b/src/autotype/CMakeLists.txt @@ -9,6 +9,10 @@ if(Q_WS_X11) endif() endif() +if(Q_WS_MAC) + add_subdirectory(mac) +endif() + if(WITH_TESTS) add_subdirectory(test) endif() diff --git a/src/autotype/mac/AutoTypeMac.cpp b/src/autotype/mac/AutoTypeMac.cpp new file mode 100644 index 000000000..d6f83b569 --- /dev/null +++ b/src/autotype/mac/AutoTypeMac.cpp @@ -0,0 +1,551 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * 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 or (at your option) + * version 3 of the License. + * + * 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, see . + */ + +#include "AutoTypeMac.h" +#include + +static pid_t keepassxPID2; + +#define UNICODE_BUFFER_SIZE 1 +static UniChar unicodeBuffer[UNICODE_BUFFER_SIZE]; +static UniCharCount unicodePtr = 0; +// reusable events +static CGEventRef unicodeEvent = CGEventCreateKeyboardEvent(NULL, 0, true); +CGEventRef AutoTypePlatformMac::keyEvent = + CGEventCreateKeyboardEvent(NULL, 0, true); + +bool AutoTypePlatformMac::inHotKeyEvent = false; + +static const KeycodeWithMods NoKeycodeWithMods = + (KeycodeWithMods){ NoKeycode, 0 }; + +static uint orderedModifiers[] = { + 0, + ( shiftKey ) >> 8, + (controlKey ) >> 8, + ( optionKey ) >> 8, + ( cmdKey ) >> 8, + ( shiftKey | controlKey ) >> 8, + ( shiftKey | optionKey ) >> 8, + ( shiftKey | cmdKey ) >> 8, + (controlKey | optionKey ) >> 8, + (controlKey | cmdKey ) >> 8, + ( optionKey | cmdKey ) >> 8, + ( shiftKey | controlKey | optionKey ) >> 8, + ( shiftKey | controlKey | cmdKey ) >> 8, + ( shiftKey | optionKey | cmdKey ) >> 8, + (controlKey | optionKey | cmdKey ) >> 8, + ( shiftKey | controlKey | optionKey | cmdKey) >> 8 +}; + +static std::map unicodeToKeycodeWithModsMap; + + +AutoTypePlatformMac::AutoTypePlatformMac() : first(true), keepassxPID(0) +{ + globalKey = 0; + globalMod = 0; + inGlobalAutoType = false; + + // initialize hot key handling + hotKeyRef = NULL; + hotKeyID.signature = 'kpsx'; + hotKeyID.id = 1; + EventTypeSpec eventType; + eventType.eventClass = kEventClassKeyboard; + eventType.eventKind = kEventHotKeyPressed; + InstallApplicationEventHandler(&hotKeyHandler, 1, &eventType, this, NULL); + AutoTypePlatformMac::initUnicodeToKeycodeWithModsMap(); +} + + +QStringList AutoTypePlatformMac::windowTitles() +{ + pid_t pid; + return getTargetWindowInfo(&pid, NULL); +} + + +WId AutoTypePlatformMac::activeWindow() +{ + WId mid; + pid_t pid; + getTargetWindowInfo(&pid, &mid); + AutoTypePlatformMac::processToFront(pid); + if (first) + first = false; + + return mid; +} + + +QString AutoTypePlatformMac::activeWindowTitle() +{ + QStringList sl = getTargetWindowInfo(NULL, NULL); + return sl[0]; +} + + +bool AutoTypePlatformMac::registerGlobalShortcut(Qt::Key key, + Qt::KeyboardModifiers modifiers) +{ + if (key == 0) + return false; + + //KeycodeWithMods kc = keyToKeycodeWithMods(key); + KeycodeWithMods kc = AutoTypePlatformMac::keysymToKeycodeWithMods2(static_cast(key)); + int code = kc.keycode; + uint mod = qtToNativeModifiers(modifiers); + + if (code==globalKey && mod==globalMod) + return true; + + // need to unregister old before registering new + unregisterGlobalShortcut(key, modifiers); + OSStatus status = RegisterEventHotKey(code, mod, hotKeyID, + GetApplicationEventTarget(), 0, &hotKeyRef); + + if (noErr == status) { + globalKey = code; + globalMod = mod; + return true; + } else { + qWarning("Error registering global shortcut: %d", status); + RegisterEventHotKey(globalKey, globalMod, hotKeyID, + GetApplicationEventTarget(), 0, &hotKeyRef); + return false; + } +} + + +void AutoTypePlatformMac::unregisterGlobalShortcut(Qt::Key, + Qt::KeyboardModifiers) +{ + globalKey = 0; + globalMod = 0; + UnregisterEventHotKey(hotKeyRef); +} + + +int AutoTypePlatformMac::platformEventFilter(void* event) +{ + return -1; +} + + +int AutoTypePlatformMac::initialTimeout() +{ + first = true; + return 500; +} + + +AutoTypeExecutor* AutoTypePlatformMac::createExecutor() +{ + return new AutoTypeExecturorMac(this); +} + + +void AutoTypePlatformMac::sendUnicode(KeySym keysym) +{ + if (onlySendKeycodes) { + KeycodeWithMods keycodeWithMods = + AutoTypePlatformMac::keysymToKeycodeWithMods2(keysym); + if (NoKeycode == keycodeWithMods.keycode) return; + sendKeycode(keycodeWithMods); + return; + } + unicodeBuffer[unicodePtr++] = keysym; + if (UNICODE_BUFFER_SIZE == unicodePtr) flushUnicode(); +} + + +void AutoTypePlatformMac::sendKeycode(KeycodeWithMods keycodeWithMods) +{ + flushUnicode(); + uint keycode = keycodeWithMods.keycode; + uint mods = keycodeWithMods.mods << 8; + uint flags = 0; + if (0 != ( shiftKey & mods)) flags |= kCGEventFlagMaskShift; + if (0 != (controlKey & mods)) flags |= kCGEventFlagMaskControl; + if (0 != ( optionKey & mods)) flags |= kCGEventFlagMaskAlternate; + if (0 != ( cmdKey & mods)) flags |= kCGEventFlagMaskCommand; + CGEventSetIntegerValueField(keyEvent, kCGKeyboardEventKeycode, keycode); + CGEventSetFlags(AutoTypePlatformMac::keyEvent, flags); + keyDownUp(AutoTypePlatformMac::keyEvent); + sleepKeyStrokeDelay(); +} + + +KeycodeWithMods AutoTypePlatformMac::keyToKeycodeWithMods(Qt::Key key) +{ + KeycodeWithMods kc; + kc.mods = 0; + + switch (key) { + case Qt::Key_Tab: + kc.keycode = kVK_Tab; + break; + case Qt::Key_Enter: + kc.keycode = kVK_Return; + break; + case Qt::Key_Up: + kc.keycode = kVK_UpArrow; + break; + case Qt::Key_Down: + kc.keycode = kVK_DownArrow; + break; + case Qt::Key_Left: + kc.keycode = kVK_LeftArrow; + break; + case Qt::Key_Right: + kc.keycode = kVK_RightArrow; + break; + case Qt::Key_Insert: + kc.keycode = kVK_Help; + break; + case Qt::Key_Delete: + kc.keycode = kVK_ForwardDelete; + break; + case Qt::Key_Home: + kc.keycode = kVK_Home; + break; + case Qt::Key_End: + kc.keycode = kVK_End; + break; + case Qt::Key_PageUp: + kc.keycode = kVK_PageUp; + break; + case Qt::Key_PageDown: + kc.keycode = kVK_PageDown; + break; + case Qt::Key_Backspace: + kc.keycode = kVK_Delete; + break; + //case Qt::Key_Pause: + // return XK_Break; + case Qt::Key_CapsLock: + kc.keycode = kVK_CapsLock; + break; + case Qt::Key_Escape: + kc.keycode = kVK_Escape; + break; + case Qt::Key_Help: + kc.keycode = kVK_Help; + break; + case Qt::Key_NumLock: + kc.keycode = kVK_ANSI_KeypadClear; + break; + case Qt::Key_Print: + kc.keycode = kVK_F13; + break; + //case Qt::Key_ScrollLock: + // return XK_Scroll_Lock; + default: + if (key >= Qt::Key_F1 && key <= Qt::Key_F16) + kc.keycode = kVK_F1 + key - Qt::Key_F1; + else + kc.keycode = NoSymbol; + } + + return kc; +} + +// Private + +QStringList AutoTypePlatformMac::getTargetWindowInfo(pid_t *pidPtr, + WId *windowNumberPtr) +{ + QStringList titles; + + const int maxWindowNameSize = 512; + char windowName[maxWindowNameSize]; + + onlySendKeycodes = false; + + CFArrayRef windowInfo = CGWindowListCopyWindowInfo( + kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, + 0); + CFIndex windowCount = CFArrayGetCount(windowInfo); + + for (CFIndex i = 0; i < windowCount; i++) { + CFDictionaryRef window = static_cast + (CFArrayGetValueAtIndex(windowInfo, i)); + + // only want windows in layer 0 + CFNumberRef windowLayerRef = static_cast + (CFDictionaryGetValue(window, kCGWindowLayer)); + + int windowLayer = -1; + CFNumberGetValue(windowLayerRef, kCFNumberIntType, &windowLayer); + if (0 != windowLayer) continue; + + // get the pid owning this window + CFNumberRef pidRef = static_cast + (CFDictionaryGetValue(window, kCGWindowOwnerPID)); + pid_t pid = -1; + CFNumberGetValue(pidRef, kCFNumberIntType, &pid); + + // skip KeePassX windows + if (getKeepassxPID() == pid) continue; + + // get window name; continue if no name + CFStringRef windowNameRef = static_cast + (CFDictionaryGetValue(window, kCGWindowName)); + if (!windowNameRef) continue; + + windowName[0] = 0; + if (!CFStringGetCString(windowNameRef, windowName, + maxWindowNameSize, kCFStringEncodingUTF8) || + (0 == windowName[0])) continue; + + if (NULL != pidPtr) + *pidPtr = pid; + + if (NULL != windowNumberPtr) { + CGWindowID wid; + CFNumberRef windowNumberRef = static_cast + (CFDictionaryGetValue(window, kCGWindowNumber)); + CFNumberGetValue(windowNumberRef, kCGWindowIDCFNumberType, &wid); + *windowNumberPtr = wid; + return titles; + } + titles.append(QString(windowName)); + } + + return titles; +} + + +uint AutoTypePlatformMac::qtToNativeModifiers(Qt::KeyboardModifiers modifiers) +{ + uint nativeModifiers = 0; + + if (modifiers & Qt::ShiftModifier) { + nativeModifiers |= shiftKey; + } + if (modifiers & Qt::ControlModifier) { + nativeModifiers |= controlKey; + } + if (modifiers & Qt::AltModifier) { + nativeModifiers |= optionKey; + } + if (modifiers & Qt::MetaModifier) { + nativeModifiers |= cmdKey; + } + + return nativeModifiers; +} + + +void AutoTypePlatformMac::flushUnicode() +{ + if (0 == unicodePtr) return; + CGEventKeyboardSetUnicodeString(unicodeEvent, unicodePtr, unicodeBuffer); + keyDownUp(unicodeEvent); + unicodePtr = 0; + sleepKeyStrokeDelay(); +} + + +void AutoTypePlatformMac::keyDownUp(CGEventRef theEvent) +{ + // posting Key Down/Up events also annoyingly sets mouse location so mus + // current mouse location and set it in the event + CGEventRef eventLocation = CGEventCreate(NULL); + CGEventSetLocation(theEvent, CGEventGetLocation(eventLocation)); + CFRelease(eventLocation); + + CGEventSetType(theEvent, kCGEventKeyDown); + CGEventPost(kCGHIDEventTap, theEvent); + CGEventSetType(theEvent, kCGEventKeyUp); + CGEventPost(kCGHIDEventTap, theEvent); +} + + +void AutoTypePlatformMac::sleepTime(int msec) +{ + if (msec == 0) return; + + timespec timeOut, remains; + timeOut.tv_sec = msec/1000; + timeOut.tv_nsec = (msec%1000)*1000000; + nanosleep(&timeOut, &remains); +} + + +OSStatus AutoTypePlatformMac::hotKeyHandler(EventHandlerCallRef, EventRef, + void *userData) +{ + // ignore nextHandler - should not be called + if ((inHotKeyEvent) || + AutoTypePlatformMac::isFrontProcess(AutoTypePlatformMac::getKeepassxPID2())) return noErr; + + AutoTypePlatformMac::inHotKeyEvent = true; + Q_EMIT static_cast(userData)->globalShortcutTriggered(); + AutoTypePlatformMac::inHotKeyEvent = false; + return noErr; +} + + +pid_t AutoTypePlatformMac::getKeepassxPID() { + + if (0 == keepassxPID) { + ProcessSerialNumber processSerialNumber; + GetCurrentProcess(&processSerialNumber); + GetProcessPID(&processSerialNumber, &keepassxPID); + } + + return keepassxPID; +} + + +Boolean AutoTypePlatformMac::isFrontProcess(pid_t pid) +{ + Boolean result; + ProcessSerialNumber pidPSN; + ProcessSerialNumber frontPSN; + OSStatus status = GetProcessForPID(pid, &pidPSN); + if (noErr != status) { + qWarning("AutoTypePlatformMac::isFrontProcess: GetProcessForPID " + "error for pid %d: %d", pid, status); + return false; + } + GetFrontProcess(&frontPSN); + SameProcess(&pidPSN, &frontPSN, &result); + return result; +} + + +void AutoTypePlatformMac::initUnicodeToKeycodeWithModsMap() +{ + unicodeToKeycodeWithModsMap.clear(); + TISInputSourceRef inputSourceRef = TISCopyCurrentKeyboardInputSource(); + + if (NULL == inputSourceRef) { + qWarning("AutoTypePlatformMac::initUnicodeToKeycodeWithModsMap: " + "inputSourceRef is NULL"); + return; + } + + CFDataRef unicodeKeyLayoutDataRef = static_cast + (TISGetInputSourceProperty(inputSourceRef, + kTISPropertyUnicodeKeyLayoutData)); + + if (NULL == unicodeKeyLayoutDataRef) { + qWarning("AutoTypePlatformMac::initUnicodeToKeycodeWithModsMap: " + "unicodeKeyLayoutDataRef is NULL"); + return; + } + const UCKeyboardLayout *unicodeKeyLayoutDataPtr = + reinterpret_cast + (CFDataGetBytePtr(unicodeKeyLayoutDataRef)); + + UInt32 deadKeyState; + UniChar unicodeString[8]; + UniCharCount len; + for (int m = 0; m < 16; m++) { + uint mods = orderedModifiers[m]; + for (uint keycode = 0; keycode < 0x80; keycode++) { + deadKeyState = 0; + len = 0; + OSStatus status = UCKeyTranslate(unicodeKeyLayoutDataPtr, keycode, + kUCKeyActionDown, mods, LMGetKbdType(), + kUCKeyTranslateNoDeadKeysMask, &deadKeyState, + sizeof(unicodeString), &len, unicodeString); + + if (noErr != status) { + qWarning("AutoTypePlatformMac::initUnicodeToKeycodeWithModsMap: " + "UCKeyTranslate error: %d keycode 0x%02X modifiers 0x%02X", + status, keycode, mods); + continue; + } + + // store if only one char and not already in store + if ((1 != len) || + (0 < unicodeToKeycodeWithModsMap.count(unicodeString[0]))) + continue; + + KeycodeWithMods kc; + kc.keycode = keycode; + kc.mods = mods; + unicodeToKeycodeWithModsMap[unicodeString[0]] = kc; + } + } +} + + +void AutoTypePlatformMac::processToFront(pid_t pid) +{ + OSStatus status; + ProcessSerialNumber processSerialNumber; + status = GetProcessForPID(pid, &processSerialNumber); + + if (noErr != status) { + qWarning("AutoTypePlatformMac::processToFront: GetProcessForPID " + "error for pid %d: %d", pid, status); + return; + } + + status = SetFrontProcessWithOptions(&processSerialNumber, + kSetFrontProcessFrontWindowOnly); + + if (noErr != status) { + qWarning("AutoTypePlatformMac::processToFront: " + "SetFrontProcessWithOptions for pid %d: %d", pid, status); + return; + } +} + + +KeycodeWithMods AutoTypePlatformMac::keysymToKeycodeWithMods2(KeySym keysym) +{ + return 0 == unicodeToKeycodeWithModsMap.count(keysym) + ? NoKeycodeWithMods : unicodeToKeycodeWithModsMap[keysym]; +} + + +pid_t AutoTypePlatformMac::getKeepassxPID2() +{ + if (0 == keepassxPID2) { + ProcessSerialNumber processSerialNumber; + GetCurrentProcess(&processSerialNumber); + GetProcessPID(&processSerialNumber, &keepassxPID2); + } + return keepassxPID2; +} + + +AutoTypeExecturorMac::AutoTypeExecturorMac(AutoTypePlatformMac* platform) + : m_platform(platform) +{ +} + + +void AutoTypeExecturorMac::execChar(AutoTypeChar* action) +{ + m_platform->sendUnicode(action->character.unicode()); +} + + +void AutoTypeExecturorMac::execKey(AutoTypeKey* action) +{ + m_platform->sendKeycode(m_platform->keyToKeycodeWithMods(action->key)); +} + + +Q_EXPORT_PLUGIN2(keepassx-autotype-mac, AutoTypePlatformMac) diff --git a/src/autotype/mac/AutoTypeMac.h b/src/autotype/mac/AutoTypeMac.h new file mode 100644 index 000000000..28eee1dcd --- /dev/null +++ b/src/autotype/mac/AutoTypeMac.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * 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 or (at your option) + * version 3 of the License. + * + * 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, see . + */ + +#ifndef KEEPASSX_AUTOTYPEMAC_H +#define KEEPASSX_AUTOTYPEMAC_H + +#include +#include + +#include "autotype/AutoTypePlatformPlugin.h" +#include "autotype/AutoTypeAction.h" +#include "core/Global.h" + +typedef quint32 KeySym; +#define NoSymbol static_cast(0) +#define NoKeycode static_cast(-1) + +struct KeycodeWithMods { + uint16 keycode; + uint16 mods; +}; + +class AutoTypePlatformMac : public QObject, public AutoTypePlatformInterface +{ + Q_OBJECT + Q_INTERFACES(AutoTypePlatformInterface) + +public: + AutoTypePlatformMac(); + + QStringList windowTitles(); + WId activeWindow(); + QString activeWindowTitle(); + bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers); + void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers); + int platformEventFilter(void* event); + int initialTimeout(); + AutoTypeExecutor* createExecutor(); + + void sendUnicode(KeySym keysym); + void sendKeycode(KeycodeWithMods keycodeWithMods); + KeycodeWithMods keyToKeycodeWithMods(Qt::Key key); + +Q_SIGNALS: + void globalShortcutTriggered(); + +private: + QStringList getTargetWindowInfo(pid_t *pidPtr, WId *windowNumberPtr); + uint qtToNativeModifiers(Qt::KeyboardModifiers modifiers); + void flushUnicode(); + void keyDownUp(CGEventRef theEvent); + void sleepTime(int msec); + inline void sleepKeyStrokeDelay(){ sleepTime(5); }; + static OSStatus hotKeyHandler(EventHandlerCallRef, + EventRef, void *userData); + pid_t getKeepassxPID(); + + bool first; + bool onlySendKeycodes; + bool inGlobalAutoType; + int globalKey; + uint globalMod; + pid_t keepassxPID; + EventHotKeyRef hotKeyRef; + EventHotKeyID hotKeyID; + + static bool inHotKeyEvent; + static CGEventRef keyEvent; + +private: + static void initUnicodeToKeycodeWithModsMap(); + static void processToFront(pid_t pid); + static KeycodeWithMods keysymToKeycodeWithMods2(KeySym keysym); + static Boolean isFrontProcess(pid_t pid); + static pid_t getKeepassxPID2(); +}; + + +class AutoTypeExecturorMac : public AutoTypeExecutor +{ +public: + explicit AutoTypeExecturorMac(AutoTypePlatformMac* platform); + + void execChar(AutoTypeChar* action); + void execKey(AutoTypeKey* action); + +private: + AutoTypePlatformMac* const m_platform; +}; + +#endif // KEEPASSX_AUTOTYPEMAC_H diff --git a/src/autotype/mac/CMakeLists.txt b/src/autotype/mac/CMakeLists.txt new file mode 100644 index 000000000..c85e40e17 --- /dev/null +++ b/src/autotype/mac/CMakeLists.txt @@ -0,0 +1,18 @@ +set(autotype_mac_SOURCES + AutoTypeMac.cpp +) + +set(autotype_mac_MOC + AutoTypeMac.h +) + +qt4_wrap_cpp(autotype_mac_SOURCES ${autotype_mac_MOC}) + +add_library(keepassx-autotype-mac MODULE ${autotype_mac_SOURCES}) +if(APPLE) + set_target_properties(keepassx-autotype-mac PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit -framework Carbon") +endif() +target_link_libraries(keepassx-autotype-mac testautotype ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) +install(TARGETS keepassx-autotype-mac + BUNDLE DESTINATION . COMPONENT Runtime + LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime) From 75564c8fb584df73fbcfff978aa44e8396a32591 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 22:07:43 +0000 Subject: [PATCH 45/51] Fixed password generation for keepasshttp --- src/CMakeLists.txt | 3 + src/http/HttpPasswordGeneratorWidget.cpp | 148 +++++++++++++++ src/http/HttpPasswordGeneratorWidget.h | 60 ++++++ src/http/HttpPasswordGeneratorWidget.ui | 227 +++++++++++++++++++++++ src/http/HttpSettings.cpp | 40 ++-- src/http/HttpSettings.h | 4 + src/http/OptionDialog.cpp | 4 + src/http/OptionDialog.ui | 96 ++-------- src/http/Service.cpp | 2 +- 9 files changed, 487 insertions(+), 97 deletions(-) create mode 100644 src/http/HttpPasswordGeneratorWidget.cpp create mode 100644 src/http/HttpPasswordGeneratorWidget.h create mode 100644 src/http/HttpPasswordGeneratorWidget.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84cc6a48d..e9bbbc17e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -104,6 +104,7 @@ set(keepassx_SOURCES gui/group/GroupView.cpp http/AccessControlDialog.cpp http/EntryConfig.cpp + http/HttpPasswordGeneratorWidget.cpp http/HttpSettings.cpp http/OptionDialog.cpp http/Protocol.cpp @@ -189,6 +190,7 @@ set(keepassx_MOC gui/group/GroupView.h http/AccessControlDialog.h http/EntryConfig.h + http/HttpPasswordGeneratorWidget.h http/OptionDialog.h http/Protocol.h http/Server.h @@ -221,6 +223,7 @@ set(keepassx_FORMS gui/entry/EditEntryWidgetMain.ui gui/group/EditGroupWidgetMain.ui http/AccessControlDialog.ui + http/HttpPasswordGeneratorWidget.ui http/OptionDialog.ui ) diff --git a/src/http/HttpPasswordGeneratorWidget.cpp b/src/http/HttpPasswordGeneratorWidget.cpp new file mode 100644 index 000000000..30e4f71e7 --- /dev/null +++ b/src/http/HttpPasswordGeneratorWidget.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2013 Felix Geyer + * + * 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 or (at your option) + * version 3 of the License. + * + * 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, see . + */ + +#include "HttpPasswordGeneratorWidget.h" +#include "ui_HttpPasswordGeneratorWidget.h" + +#include + +#include "core/Config.h" +#include "core/PasswordGenerator.h" +#include "core/FilePath.h" + +HttpPasswordGeneratorWidget::HttpPasswordGeneratorWidget(QWidget* parent) + : QWidget(parent) + , m_updatingSpinBox(false) + , m_generator(new PasswordGenerator()) + , m_ui(new Ui::HttpPasswordGeneratorWidget()) +{ + m_ui->setupUi(this); + + connect(m_ui->buttonApply, SIGNAL(clicked()), SLOT(saveSettings())); + + connect(m_ui->sliderLength, SIGNAL(valueChanged(int)), SLOT(sliderMoved())); + connect(m_ui->spinBoxLength, SIGNAL(valueChanged(int)), SLOT(spinBoxChanged())); + + connect(m_ui->optionButtons, SIGNAL(buttonClicked(int)), SLOT(updateGenerator())); + m_ui->buttonApply->setEnabled(true); + + loadSettings(); + reset(); +} + +HttpPasswordGeneratorWidget::~HttpPasswordGeneratorWidget() +{ +} + +void HttpPasswordGeneratorWidget::loadSettings() +{ + m_ui->checkBoxLower->setChecked(config()->get("Http/generator/LowerCase", true).toBool()); + m_ui->checkBoxUpper->setChecked(config()->get("Http/generator/UpperCase", true).toBool()); + m_ui->checkBoxNumbers->setChecked(config()->get("Http/generator/Numbers", true).toBool()); + m_ui->checkBoxSpecialChars->setChecked(config()->get("Http/generator/SpecialChars", false).toBool()); + + m_ui->checkBoxExcludeAlike->setChecked(config()->get("Http/generator/ExcludeAlike", true).toBool()); + m_ui->checkBoxEnsureEvery->setChecked(config()->get("Http/generator/EnsureEvery", true).toBool()); + + m_ui->spinBoxLength->setValue(config()->get("Http/generator/Length", 16).toInt()); +} + +void HttpPasswordGeneratorWidget::saveSettings() +{ + config()->set("Http/generator/LowerCase", m_ui->checkBoxLower->isChecked()); + config()->set("Http/generator/UpperCase", m_ui->checkBoxUpper->isChecked()); + config()->set("Http/generator/Numbers", m_ui->checkBoxNumbers->isChecked()); + config()->set("Http/generator/SpecialChars", m_ui->checkBoxSpecialChars->isChecked()); + + config()->set("Http/generator/ExcludeAlike", m_ui->checkBoxExcludeAlike->isChecked()); + config()->set("Http/generator/EnsureEvery", m_ui->checkBoxEnsureEvery->isChecked()); + + config()->set("Http/generator/Length", m_ui->spinBoxLength->value()); +} + +void HttpPasswordGeneratorWidget::reset() +{ + updateGenerator(); +} + +void HttpPasswordGeneratorWidget::sliderMoved() +{ + if (m_updatingSpinBox) { + return; + } + + m_ui->spinBoxLength->setValue(m_ui->sliderLength->value()); + + updateGenerator(); +} + +void HttpPasswordGeneratorWidget::spinBoxChanged() +{ + // Interlock so that we don't update twice - this causes issues as the spinbox can go higher than slider + m_updatingSpinBox = true; + + m_ui->sliderLength->setValue(m_ui->spinBoxLength->value()); + + m_updatingSpinBox = false; + + updateGenerator(); +} + +PasswordGenerator::CharClasses HttpPasswordGeneratorWidget::charClasses() +{ + PasswordGenerator::CharClasses classes; + + if (m_ui->checkBoxLower->isChecked()) { + classes |= PasswordGenerator::LowerLetters; + } + + if (m_ui->checkBoxUpper->isChecked()) { + classes |= PasswordGenerator::UpperLetters; + } + + if (m_ui->checkBoxNumbers->isChecked()) { + classes |= PasswordGenerator::Numbers; + } + + if (m_ui->checkBoxSpecialChars->isChecked()) { + classes |= PasswordGenerator::SpecialCharacters; + } + + return classes; +} + +PasswordGenerator::GeneratorFlags HttpPasswordGeneratorWidget::generatorFlags() +{ + PasswordGenerator::GeneratorFlags flags; + + if (m_ui->checkBoxExcludeAlike->isChecked()) { + flags |= PasswordGenerator::ExcludeLookAlike; + } + + if (m_ui->checkBoxEnsureEvery->isChecked()) { + flags |= PasswordGenerator::CharFromEveryGroup; + } + + return flags; +} + +void HttpPasswordGeneratorWidget::updateGenerator() +{ + m_generator->setLength(m_ui->spinBoxLength->value()); + m_generator->setCharClasses(charClasses()); + m_generator->setFlags(generatorFlags()); +} diff --git a/src/http/HttpPasswordGeneratorWidget.h b/src/http/HttpPasswordGeneratorWidget.h new file mode 100644 index 000000000..5766a6e7f --- /dev/null +++ b/src/http/HttpPasswordGeneratorWidget.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2013 Felix Geyer + * + * 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 or (at your option) + * version 3 of the License. + * + * 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, see . + */ + +#ifndef KEEPASSX_PASSWORDGENERATORWIDGET_H +#define KEEPASSX_PASSWORDGENERATORWIDGET_H + +#include +#include + +#include "core/Global.h" +#include "core/PasswordGenerator.h" + +namespace Ui { + class HttpPasswordGeneratorWidget; +} + +class PasswordGenerator; + +class HttpPasswordGeneratorWidget : public QWidget +{ + Q_OBJECT + +public: + explicit HttpPasswordGeneratorWidget(QWidget* parent = Q_NULLPTR); + ~HttpPasswordGeneratorWidget(); + void loadSettings(); + void reset(); + +private Q_SLOTS: + void saveSettings(); + void sliderMoved(); + void spinBoxChanged(); + + void updateGenerator(); + +private: + bool m_updatingSpinBox; + + PasswordGenerator::CharClasses charClasses(); + PasswordGenerator::GeneratorFlags generatorFlags(); + + const QScopedPointer m_generator; + const QScopedPointer m_ui; +}; + +#endif // KEEPASSX_PASSWORDGENERATORWIDGET_H diff --git a/src/http/HttpPasswordGeneratorWidget.ui b/src/http/HttpPasswordGeneratorWidget.ui new file mode 100644 index 000000000..29399bcd6 --- /dev/null +++ b/src/http/HttpPasswordGeneratorWidget.ui @@ -0,0 +1,227 @@ + + + HttpPasswordGeneratorWidget + + + + 0 + 0 + 434 + 250 + + + + + + + + + + + + Length: + + + + + + + + + 1 + + + 64 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 8 + + + + + + + 1 + + + 999 + + + + + + + + + + + Character Types + + + + + + + + Upper Case Letters + + + A-Z + + + true + + + optionButtons + + + + + + + Lower Case Letters + + + a-z + + + true + + + optionButtons + + + + + + + Numbers + + + 0-9 + + + true + + + optionButtons + + + + + + + Special Characters + + + /*_& ... + + + true + + + optionButtons + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Exclude look-alike characters + + + optionButtons + + + + + + + Ensure that the password contains characters from every group + + + optionButtons + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Accept + + + + + + + + + + PasswordComboBox + QComboBox +
gui/PasswordComboBox.h
+
+
+ + sliderLength + spinBoxLength + checkBoxUpper + checkBoxLower + checkBoxNumbers + checkBoxSpecialChars + checkBoxExcludeAlike + checkBoxEnsureEvery + buttonApply + + + + + + + false + + + +
diff --git a/src/http/HttpSettings.cpp b/src/http/HttpSettings.cpp index 15cd962bd..f98fcb7e2 100644 --- a/src/http/HttpSettings.cpp +++ b/src/http/HttpSettings.cpp @@ -14,6 +14,8 @@ #include "HttpSettings.h" #include "core/Config.h" +PasswordGenerator HttpSettings::m_generator; + bool HttpSettings::isEnabled() { return config()->get("Http/Enabled", true).toBool(); @@ -126,72 +128,73 @@ void HttpSettings::setSupportKphFields(bool supportKphFields) bool HttpSettings::passwordUseNumbers() { - return config()->get("Http/PasswordUseNumbers", true).toBool(); + return config()->get("Http/generator/Numbers", true).toBool(); } void HttpSettings::setPasswordUseNumbers(bool useNumbers) { - config()->set("Http/PasswordUseNumbers", useNumbers); + config()->set("Http/generator/Numbers", useNumbers); } bool HttpSettings::passwordUseLowercase() { - return config()->get("Http/PasswordUseLowercase", true).toBool(); + return config()->get("Http/generator/LowerCase", true).toBool(); } void HttpSettings::setPasswordUseLowercase(bool useLowercase) { - config()->set("Http/PasswordUseLowercase", useLowercase); + config()->set("Http/generator/LowerCase", useLowercase); } bool HttpSettings::passwordUseUppercase() { - return config()->get("Http/PasswordUseUppercase", true).toBool(); + return config()->get("Http/generator/UpperCase", true).toBool(); } void HttpSettings::setPasswordUseUppercase(bool useUppercase) { - config()->set("Http/PasswordUseUppercase", useUppercase); + config()->set("Http/generator/UpperCase", useUppercase); } bool HttpSettings::passwordUseSpecial() { - return config()->get("Http/PasswordUseSpecial", false).toBool(); + return config()->get("Http/generator/SpecialChars", false).toBool(); } void HttpSettings::setPasswordUseSpecial(bool useSpecial) { - config()->set("Http/PasswordUseSpecial", useSpecial); + config()->set("Http/generator/SpecialChars", useSpecial); } bool HttpSettings::passwordEveryGroup() { - return config()->get("Http/PasswordEveryGroup", true).toBool(); + return config()->get("Http/generator/EnsureEvery", true).toBool(); } void HttpSettings::setPasswordEveryGroup(bool everyGroup) { - config()->get("Http/PasswordEveryGroup", everyGroup); + config()->get("Http/generator/EnsureEvery", everyGroup); } bool HttpSettings::passwordExcludeAlike() { - return config()->get("Http/PasswordExcludeAlike", true).toBool(); + return config()->get("Http/generator/ExcludeAlike", true).toBool(); } void HttpSettings::setPasswordExcludeAlike(bool excludeAlike) { - config()->set("Http/PasswordExcludeAlike", excludeAlike); + config()->set("Http/generator/ExcludeAlike", excludeAlike); } int HttpSettings::passwordLength() { - return config()->get("Http/PasswordLength", 20).toInt(); + return config()->get("Http/generator/Length", 20).toInt(); } void HttpSettings::setPasswordLength(int length) { - config()->set("Http/PasswordLength", length); + config()->set("Http/generator/Length", length); + m_generator.setLength(length); } PasswordGenerator::CharClasses HttpSettings::passwordCharClasses() @@ -217,3 +220,12 @@ PasswordGenerator::GeneratorFlags HttpSettings::passwordGeneratorFlags() flags |= PasswordGenerator::CharFromEveryGroup; return flags; } + +QString HttpSettings::generatePassword() +{ + m_generator.setLength(passwordLength()); + m_generator.setCharClasses(passwordCharClasses()); + m_generator.setFlags(passwordGeneratorFlags()); + + return m_generator.generatePassword(); +} diff --git a/src/http/HttpSettings.h b/src/http/HttpSettings.h index 67a998eec..5f2577c39 100644 --- a/src/http/HttpSettings.h +++ b/src/http/HttpSettings.h @@ -59,6 +59,10 @@ public: static void setPasswordLength(int length); static PasswordGenerator::CharClasses passwordCharClasses(); static PasswordGenerator::GeneratorFlags passwordGeneratorFlags(); + static QString generatePassword(); + +private: + static PasswordGenerator m_generator; }; #endif // HTTPSETTINGS_H diff --git a/src/http/OptionDialog.cpp b/src/http/OptionDialog.cpp index 29ebeaa1a..63222947a 100644 --- a/src/http/OptionDialog.cpp +++ b/src/http/OptionDialog.cpp @@ -43,6 +43,7 @@ void OptionDialog::loadSettings() else ui->sortByTitle->setChecked(true); +/* ui->checkBoxLower->setChecked(settings.passwordUseLowercase()); ui->checkBoxNumbers->setChecked(settings.passwordUseNumbers()); ui->checkBoxUpper->setChecked(settings.passwordUseUppercase()); @@ -50,6 +51,7 @@ void OptionDialog::loadSettings() ui->checkBoxEnsureEvery->setChecked(settings.passwordEveryGroup()); ui->checkBoxExcludeAlike->setChecked(settings.passwordExcludeAlike()); ui->spinBoxLength->setValue(settings.passwordLength()); +*/ ui->alwaysAllowAccess->setChecked(settings.alwaysAllowAccess()); ui->alwaysAllowUpdate->setChecked(settings.alwaysAllowUpdate()); @@ -67,6 +69,7 @@ void OptionDialog::saveSettings() settings.setMatchUrlScheme(ui->matchUrlScheme->isChecked()); settings.setSortByUsername(ui->sortByUsername->isChecked()); +/* settings.setPasswordUseLowercase(ui->checkBoxLower->isChecked()); settings.setPasswordUseNumbers(ui->checkBoxNumbers->isChecked()); settings.setPasswordUseUppercase(ui->checkBoxUpper->isChecked()); @@ -74,6 +77,7 @@ void OptionDialog::saveSettings() settings.setPasswordEveryGroup(ui->checkBoxEnsureEvery->isChecked()); settings.setPasswordExcludeAlike(ui->checkBoxExcludeAlike->isChecked()); settings.setPasswordLength(ui->spinBoxLength->value()); +*/ settings.setAlwaysAllowAccess(ui->alwaysAllowAccess->isChecked()); settings.setAlwaysAllowUpdate(ui->alwaysAllowUpdate->isChecked()); diff --git a/src/http/OptionDialog.ui b/src/http/OptionDialog.ui index 621b94836..9563fd04a 100644 --- a/src/http/OptionDialog.ui +++ b/src/http/OptionDialog.ui @@ -114,88 +114,7 @@ Only entries with the same scheme (http://, https://, ftp://, ...) are returned< - - - - - - - Lower letters - - - - - - - Numbers - - - - - - - Upper letters - - - - - - - Special characters - - - - - - - - - - - Ensure that the password contains characters from every group - - - - - - - Exclude look-alike characters - - - - - - - - - Length: - - - - - - - 1 - - - 999 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + @@ -300,6 +219,19 @@ Only entries with the same scheme (http://, https://, ftp://, ...) are returned< + + + HttpPasswordGeneratorWidget + QWidget +
http/HttpPasswordGeneratorWidget.h
+ 1 +
+ + PasswordEdit + QLineEdit +
gui/PasswordEdit.h
+
+
diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 9daf9c018..525b28778 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -494,7 +494,7 @@ void Service::updateEntry(const QString &, const QString &uuid, const QString &l QString Service::generatePassword() { - return QString("nonrandompassword"); + return HttpSettings::generatePassword(); } void Service::removeSharedEncryptionKeys() From b432103b82c434bbcf2160a4fcc118ea3b88dfc5 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sun, 23 Mar 2014 01:13:27 +0000 Subject: [PATCH 46/51] Return password quality to keepasshttp client. --- src/core/PasswordGenerator.cpp | 16 ++++++++++++++++ src/core/PasswordGenerator.h | 1 + src/http/HttpSettings.cpp | 5 +++++ src/http/HttpSettings.h | 1 + src/http/Server.cpp | 4 +++- 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/core/PasswordGenerator.cpp b/src/core/PasswordGenerator.cpp index 5915ba898..52f124786 100644 --- a/src/core/PasswordGenerator.cpp +++ b/src/core/PasswordGenerator.cpp @@ -89,6 +89,22 @@ QString PasswordGenerator::generatePassword() const return password; } +int PasswordGenerator::getbits() const +{ + QVector groups = passwordGroups(); + + int bits = 0; + QVector passwordChars; + Q_FOREACH (const PasswordGroup& group, groups) { + bits += group.size(); + } + + bits *= m_length; + + return bits; +} + + bool PasswordGenerator::isValid() const { if (m_classes == 0) { diff --git a/src/core/PasswordGenerator.h b/src/core/PasswordGenerator.h index 6a9d21245..54982ac9c 100644 --- a/src/core/PasswordGenerator.h +++ b/src/core/PasswordGenerator.h @@ -55,6 +55,7 @@ public: bool isValid() const; QString generatePassword() const; + int getbits() const; private: QVector passwordGroups() const; diff --git a/src/http/HttpSettings.cpp b/src/http/HttpSettings.cpp index f98fcb7e2..4692023d1 100644 --- a/src/http/HttpSettings.cpp +++ b/src/http/HttpSettings.cpp @@ -229,3 +229,8 @@ QString HttpSettings::generatePassword() return m_generator.generatePassword(); } + +int HttpSettings::getbits() +{ + return m_generator.getbits(); +} diff --git a/src/http/HttpSettings.h b/src/http/HttpSettings.h index 5f2577c39..ba430c672 100644 --- a/src/http/HttpSettings.h +++ b/src/http/HttpSettings.h @@ -60,6 +60,7 @@ public: static PasswordGenerator::CharClasses passwordCharClasses(); static PasswordGenerator::GeneratorFlags passwordGeneratorFlags(); static QString generatePassword(); + static int getbits(); private: static PasswordGenerator m_generator; diff --git a/src/http/Server.cpp b/src/http/Server.cpp index dedbd221c..1afdd5051 100644 --- a/src/http/Server.cpp +++ b/src/http/Server.cpp @@ -14,6 +14,7 @@ #include "Server.h" #include #include "Protocol.h" +#include "HttpSettings.h" #include "crypto/Crypto.h" #include #include @@ -165,11 +166,12 @@ void Server::generatePassword(const Request &r, Response *protocolResp) return; QString password = generatePassword(); + QString bits = QString::number(HttpSettings::getbits()); protocolResp->setSuccess(); protocolResp->setId(r.id()); protocolResp->setVerifier(key); - protocolResp->setEntries(QList() << Entry("generate-password", "generate-password", password, "generate-password")); + protocolResp->setEntries(QList() << Entry("generate-password", bits, password, "generate-password")); memset(password.data(), 0, password.length()); } From 86a01b69841131a747510eef1326007e4cbee18e Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sat, 22 Mar 2014 17:16:44 +0000 Subject: [PATCH 47/51] Ensure that external DB changes are always detected. QFileSystemWatcher seems to reset itself occasionally. This patch works around the issue by re-applying the QFileSystemWatcher whenever a change is handled. --- src/gui/DatabaseTabWidget.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 545a2bd82..d96156cff 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -182,6 +182,14 @@ void DatabaseTabWidget::fileChanged(const QString &fileName) { const bool wasEmpty = m_changedFiles.isEmpty(); m_changedFiles.insert(fileName); + bool found = false; + Q_FOREACH (QString f, m_fileWatcher->files()) { + if (f == fileName) { + found = true; + break; + } + } + if (!found) m_fileWatcher->addPath(fileName); if (wasEmpty && !m_changedFiles.isEmpty()) QTimer::singleShot(200, this, SLOT(checkReloadDatabases())); } From b28cb19ae39ec8dd9cef876369109c7e065862d9 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sun, 23 Mar 2014 16:51:30 +0000 Subject: [PATCH 48/51] Added keybinding for copy URL --- src/gui/MainWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 8a993d33d..a0ae5aacc 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -135,6 +135,7 @@ MainWindow::MainWindow() m_ui->actionEntryClone->setShortcut(Qt::CTRL + Qt::Key_K); m_ui->actionEntryCopyUsername->setShortcut(Qt::CTRL + Qt::Key_B); m_ui->actionEntryCopyPassword->setShortcut(Qt::CTRL + Qt::Key_C); + m_ui->actionEntryCopyURL->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_U); setShortcut(m_ui->actionEntryAutoType, QKeySequence::Paste, Qt::CTRL + Qt::Key_V); m_ui->actionEntryOpenUrl->setShortcut(Qt::CTRL + Qt::Key_U); From c7158234dcf04b6fe8256a0edd108d787e3927fa Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sun, 23 Mar 2014 16:51:41 +0000 Subject: [PATCH 49/51] Removed assert test for indexFromEntry. When no row is selected, row equals -1. Some operations call indexFromEntry when there is no row selected and these should be allowed to succeed. --- src/gui/entry/EntryModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/entry/EntryModel.cpp b/src/gui/entry/EntryModel.cpp index 369a4abb0..734ba7633 100644 --- a/src/gui/entry/EntryModel.cpp +++ b/src/gui/entry/EntryModel.cpp @@ -41,7 +41,7 @@ Entry* EntryModel::entryFromIndex(const QModelIndex& index) const QModelIndex EntryModel::indexFromEntry(Entry* entry) const { int row = m_entries.indexOf(entry); - Q_ASSERT(row != -1); + //Q_ASSERT(row != -1); return index(row, 1); } From 54306473f3774115f00b0d7a9d7f03b9d904b6d3 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Sun, 23 Mar 2014 19:25:15 +0000 Subject: [PATCH 50/51] Added README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..d7483c6ca --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# KeePassX + keepasshttp + autotype + +This code extends the brilliant [KeePassX](https://www.keepassx.org/) program +which accesses [KeePass](http://keepass.info/) password databases. + +I have merged the latest version of the code with Francois Ferrand's +[keepassx-http](https://gitorious.org/keepassx/keepassx-http/) repository. +This adds support for the [keepasshttp](https://github.com/pfn/keepasshttp/) +protocol, enabling automatic form-filling in web browsers. This is accomplished +via a compatible browser plugin such as +[PassIFox](https://passifox.appspot.com/passifox.xpi) for Mozilla Firefox and +[chromeIPass](https://chrome.google.com/webstore/detail/chromeipass/ompiailgknfdndiefoaoiligalphfdae) +for Google Chrome. + +I have also added global autotype for OSX machines and added a few other minor +tweaks and bugfixes. + From e2d446e4460f2c167862ba07d5fd7d43f6b6c703 Mon Sep 17 00:00:00 2001 From: Keith Bennett Date: Mon, 24 Mar 2014 19:26:55 +0000 Subject: [PATCH 51/51] Added back missing copyright notices. --- src/autotype/mac/AutoTypeMac.cpp | 4 +++- src/autotype/mac/AutoTypeMac.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/autotype/mac/AutoTypeMac.cpp b/src/autotype/mac/AutoTypeMac.cpp index d6f83b569..6840850eb 100644 --- a/src/autotype/mac/AutoTypeMac.cpp +++ b/src/autotype/mac/AutoTypeMac.cpp @@ -1,4 +1,6 @@ /* + * Copyright (C) 2009-2010 Jeff Gibbons + * Copyright (C) 2005-2008 by Tarek Saidi * Copyright (C) 2012 Felix Geyer * * This program is free software: you can redistribute it and/or modify @@ -20,7 +22,7 @@ static pid_t keepassxPID2; -#define UNICODE_BUFFER_SIZE 1 +#define UNICODE_BUFFER_SIZE 20 static UniChar unicodeBuffer[UNICODE_BUFFER_SIZE]; static UniCharCount unicodePtr = 0; // reusable events diff --git a/src/autotype/mac/AutoTypeMac.h b/src/autotype/mac/AutoTypeMac.h index 28eee1dcd..e43d33cf0 100644 --- a/src/autotype/mac/AutoTypeMac.h +++ b/src/autotype/mac/AutoTypeMac.h @@ -1,4 +1,6 @@ /* + * Copyright (C) 2009-2010 Jeff Gibbons + * Copyright (C) 2005-2008 Tarek Saidi * Copyright (C) 2012 Felix Geyer * * This program is free software: you can redistribute it and/or modify