text:
    <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" />
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" />
    <title>RendererMap Property</title>
    <xml>
    </xml>
    <link rel="stylesheet" type="text/css" href="MSDN.css" />

            log4net SDK Documentation - Microsoft .NET Framework 4.0

LoggerRepositorySkeleton.RendererMap Property

 RendererMap accesses the object renderer map for this repository.

        [Visual Basic]

Overridable Public ReadOnly Property RendererMap As RendererMap _
    Implements ILoggerRepository.RendererMap

        [C#]

public virtual log4net.ObjectRenderer.RendererMap RendererMap {get;}

Property Value

 RendererMap accesses the object renderer map for this repository.

Implements

        ILoggerRepository.RendererMap

Remarks

 RendererMap accesses the object renderer map for this repository.

 The RendererMap holds a mapping between types and IObjectRenderer objects.

See Also

LoggerRepositorySkeleton Class | log4net.Repository Namespace
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e" viewastext="true" style="display: none;"><param name="Keyword" value="RendererMap property"></param><param name="Keyword" value="RendererMap property, LoggerRepositorySkeleton class"></param><param name="Keyword" value="LoggerRepositorySkeleton.RendererMap property"></param></object>

Copyright 2004-2011 The Apache Software Foundation.


text:
<?php
namespace TYPO3\CMS\Fluid\View\Exception;

/*                                                                        *
 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid".   *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License, either version 3   *
 *  of the License, or (at your option) any later version.                *
 *                                                                        *
 * The TYPO3 project - inspiring people to share!                         *
 *                                                                        */
/**
 * An "Invalid Section" exception
 *
 * @api
 */
class InvalidSectionException extends \TYPO3\CMS\Fluid\View\Exception
{
}

redpajama_set_name: RedPajamaGithub


text:
<?php
namespace TaSurvey\DefaultBundle\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;

/**
 * 考试.
 *
 * @ORM\Entity(repositoryClass="TaSurvey\DefaultBundle\Entity\Repository\ExamRepository")
 * @ORM\Table(name="exam")
 *
 * @author wendell.zheng <wxzheng@ustc.edu.cn>
 */
class Exam
{
    /**
     * ID.
     *
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * 名称.
     *
     * @ORM\Column(type="string")
     * @Assert\NotBlank()
     */
    protected $title;

    /**
     * 截止日期.
     *
     * @ORM\Column(type="date", nullable=true)
     * @Assert\Date()
     */
    protected $deadline;

    /**
     * @ORM\ManyToOne(targetEntity="Paper", inversedBy="exams")
     * @ORM\JoinColumn(name="paper_id", referencedColumnName="id")
     */
    protected $paper;

    /**
     * @ORM\OneToMany(targetEntity="ExamStudent", mappedBy="exam")
     */
    protected $examStudents;

    /**
     * Constructor.
     */
    public function __construct()
    {
        $this->examStudents = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id.
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set title.
     *
     * @param string $title
     *
     * @return Exam
     */
    public function setTitle($title)
    {
        $this->title = $title;

        return $this;
    }

    /**
     * Get title.
     *
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set deadline.
     *
     * @param \DateTime $deadline
     *
     * @return Exam
     */
    public function setDeadline($deadline)
    {
        $this->deadline = $deadline;

        return $this;
    }

    /**
     * Get deadline.
     *
     * @return \DateTime
     */
    public function getDeadline()
    {
        return $this->deadline;
    }

    /**
     * Set paper.
     *
     * @param \TaSurvey\DefaultBundle\Entity\Paper $paper
     *
     * @return Exam
     */
    public function setPaper(\TaSurvey\DefaultBundle\Entity\Paper $paper = null)
    {
        $this->paper = $paper;

        return $this;
    }

    /**
     * Get paper.
     *
     * @return \TaSurvey\DefaultBundle\Entity\Paper
     */
    public function getPaper()
    {
        return $this->paper;
    }

    /**
     * Add examStudents.
     *
     * @param \TaSurvey\DefaultBundle\Entity\ExamStudent $examStudents
     *
     * @return Exam
     */
    public function addExamStudent(\TaSurvey\DefaultBundle\Entity\ExamStudent $examStudents)
    {
        $this->examStudents[] = $examStudents;

        return $this;
    }

    /**
     * Remove examStudents.
     *
     * @param \TaSurvey\DefaultBundle\Entity\ExamStudent $examStudents
     */
    public function removeExamStudent(\TaSurvey\DefaultBundle\Entity\ExamStudent $examStudents)
    {
        $this->examStudents->removeElement($examStudents);
    }

    /**
     * Get examStudents.
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getExamStudents()
    {
        return $this->examStudents;
    }

    public function getValidExamStudents()
    {
        return array_filter($this->examStudents->toArray(), function ($examStudent) {
            return $examStudent->getStatus() == ExamStudent::STATUS_DONE;
        });
    }

    public function getValidExamStudentCount()
    {
        return count($this->getValidExamStudents());
    }
}


text:
using namespace std;

void EnsureWalletIsUnlocked();
bool EnsureWalletIsAvailable(bool avoidException);

std::string static EncodeDumpTime(int64_t nTime) {
    return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime);
}

int64_t static DecodeDumpTime(const std::string &str) {
    static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t(0);
    static const std::locale loc(std::locale::classic(),
        new boost::posix_time::time_input_facet("%Y-%m-%dT%H:%M:%SZ"));
    std::istringstream iss(str);
    iss.imbue(loc);
    boost::posix_time::ptime ptime(boost::date_time::not_a_date_time);
    iss >> ptime;
    if (ptime.is_not_a_date_time())
        return 0;
    return (ptime - epoch).total_seconds();
}

std::string static EncodeDumpString(const std::string &str) {
    std::stringstream ret;
    for(unsigned char c: str) {
        if (c <= 32 || c >= 128 || c == '%') {
            ret << '%' << HexStr(&c, &c + 1);
        } else {
            ret << c;
        }
    }
    return ret.str();
}

std::string DecodeDumpString(const std::string &str) {
    std::stringstream ret;
    for (unsigned int pos = 0; pos < str.length(); pos++) {
        unsigned char c = str[pos];
        if (c == '%' && pos+2 < str.length()) {
            c = (((str[pos+1]>>6)*9+((str[pos+1]-'0')&15)) << 4) |
                ((str[pos+2]>>6)*9+((str[pos+2]-'0')&15));
            pos += 2;
        }
        ret << c;
    }
    return ret.str();
}

UniValue importprivkey(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() < 1 || params.size() > 3)
        throw runtime_error(
            "importprivkey \"navcoinprivkey\" ( \"label\" rescan )\n"
            "\nAdds a private key (as returned by dumpprivkey) to your wallet.\n"
            "\nArguments:\n"
            "1. \"navcoinprivkey\"   (string, required) The private key (see dumpprivkey)\n"
            "2. \"label\"            (string, optional, default=\"\") An optional label\n"
            "3. rescan               (boolean, optional, default=true) Rescan the wallet for transactions\n"
            "\nNote: This call can take minutes to complete if rescan is true.\n"
            "\nExamples:\n"
            "\nDump a private key\n"
            + HelpExampleCli("dumpprivkey", "\"myaddress\"") +
            "\nImport the private key with rescan\n"
            + HelpExampleCli("importprivkey", "\"mykey\"") +
            "\nImport using a label and without rescan\n"
            + HelpExampleCli("importprivkey", "\"mykey\" \"testing\" false") +
            "\nAs a JSON-RPC call\n"
            + HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false")
        );

    LOCK2(cs_main, pwalletMain->cs_wallet);

    EnsureWalletIsUnlocked();

    string strSecret = params[0].get_str();
    string strLabel = "";
    if (params.size() > 1)
        strLabel = params[1].get_str();

    // Whether to perform rescan after import
    bool fRescan = true;
    if (params.size() > 2)
        fRescan = params[2].get_bool();

    if (fRescan && fPruneMode)
        throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");

    CNavCoinSecret vchSecret;
    bool fGood = vchSecret.SetString(strSecret);

    if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key encoding");

    CKey key = vchSecret.GetKey();
    if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range");

    CPubKey pubkey = key.GetPubKey();
    assert(key.VerifyPubKey(pubkey));
    CKeyID vchAddress = pubkey.GetID();
    {
        pwalletMain->MarkDirty();
        pwalletMain->SetAddressBook(vchAddress, strLabel, "receive");

        // Don't throw error in case a key is already there
        if (pwalletMain->HaveKey(vchAddress))
            return NullUniValue;

        pwalletMain->mapKeyMetadata[vchAddress].nCreateTime = 1;

        if (!pwalletMain->AddKeyPubKey(key, pubkey))
            throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");

        // whenever a key is imported, we need to scan the whole chain
        pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value'

        if (fRescan) {
            pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true);
        }
    }

    return NullUniValue;
}

void ImportAddress(const CNavCoinAddress& address, const string& strLabel);
void ImportScript(const CScript& script, const string& strLabel, bool isRedeemScript)
{
    if (!isRedeemScript && ::IsMine(*pwalletMain, script) == ISMINE_SPENDABLE)
        throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");

    pwalletMain->MarkDirty();

    if (!pwalletMain->HaveWatchOnly(script) && !pwalletMain->AddWatchOnly(script))
        throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");

    if (isRedeemScript) {
        if (!pwalletMain->HaveCScript(script) && !pwalletMain->AddCScript(script))
            throw JSONRPCError(RPC_WALLET_ERROR, "Error adding p2sh redeemScript to wallet");
        ImportAddress(CNavCoinAddress(CScriptID(script)), strLabel);
    } else {
        CTxDestination destination;
        if (ExtractDestination(script, destination)) {
            pwalletMain->SetAddressBook(destination, strLabel, "receive");
        }
    }
}

void ImportAddress(const CNavCoinAddress& address, const string& strLabel)
{
    CScript script = GetScriptForDestination(address.Get());
    ImportScript(script, strLabel, false);
    // add to address book or update label
    if (address.IsValid())
        pwalletMain->SetAddressBook(address.Get(), strLabel, "receive");
}

UniValue importaddress(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() < 1 || params.size() > 4)
        throw runtime_error(
            "importaddress \"address\" ( \"label\" rescan p2sh )\n"
            "\nAdds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend.\n"
            "\nArguments:\n"
            "1. \"script\"           (string, required) The hex-encoded script (or address)\n"
            "2. \"label\"            (string, optional, default=\"\") An optional label\n"
            "3. rescan               (boolean, optional, default=true) Rescan the wallet for transactions\n"
            "4. p2sh                 (boolean, optional, default=false) Add the P2SH version of the script as well\n"
            "\nNote: This call can take minutes to complete if rescan is true.\n"
            "If you have the full public key, you should call importpubkey instead of this.\n"
            "\nNote: If you import a non-standard raw script in hex form, outputs sending to it will be treated\n"
            "as change, and not show up in many RPCs.\n"
            "\nExamples:\n"
            "\nImport a script with rescan\n"
            + HelpExampleCli("importaddress", "\"myscript\"") +
            "\nImport using a label without rescan\n"
            + HelpExampleCli("importaddress", "\"myscript\" \"testing\" false") +
            "\nAs a JSON-RPC call\n"
            + HelpExampleRpc("importaddress", "\"myscript\", \"testing\", false")
        );

    string strLabel = "";
    if (params.size() > 1)
        strLabel = params[1].get_str();

    // Whether to perform rescan after import
    bool fRescan = true;
    if (params.size() > 2)
        fRescan = params[2].get_bool();

    if (fRescan && fPruneMode)
        throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");

    // Whether to import a p2sh version, too
    bool fP2SH = false;
    if (params.size() > 3)
        fP2SH = params[3].get_bool();

    LOCK2(cs_main, pwalletMain->cs_wallet);

    CNavCoinAddress address(params[0].get_str());
    if (address.IsValid()) {
        if (fP2SH)
            throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Cannot use the p2sh flag with an address - use a script instead");
        ImportAddress(address, strLabel);
    } else if (IsHex(params[0].get_str())) {
        std::vector<unsigned char> data(ParseHex(params[0].get_str()));
        ImportScript(CScript(data.begin(), data.end()), strLabel, fP2SH);
    } else {
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NavCoin address or script");
    }

    pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value'

    if (fRescan)
    {
        pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true);
        pwalletMain->ReacceptWalletTransactions();
    }

    return NullUniValue;
}

UniValue importprunedfunds(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() < 2 || params.size() > 3)
        throw runtime_error(
            "importprunedfunds\n"
            "\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.\n"
            "\nArguments:\n"
            "1. \"rawtransaction\" (string, required) A raw transaction in hex funding an already-existing address in wallet\n"
            "2. \"txoutproof\"     (string, required) The hex output from gettxoutproof that contains the transaction\n"
            "3. \"label\"          (string, optional) An optional label\n"
        );

    CTransaction tx;
    if (!DecodeHexTx(tx, params[0].get_str()))
        throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
    uint256 hashTx = tx.GetHash();
    CWalletTx wtx(pwalletMain,tx);

    CDataStream ssMB(ParseHexV(params[1], "proof"), SER_NETWORK, PROTOCOL_VERSION);
    CMerkleBlock merkleBlock;
    ssMB >> merkleBlock;

    string strLabel = "";
    if (params.size() == 3)
        strLabel = params[2].get_str();

    //Search partial merkle tree in proof for our transaction and index in valid block
    vector<uint256> vMatch;
    vector<unsigned int> vIndex;
    unsigned int txnIndex = 0;
    if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) == merkleBlock.header.hashMerkleRoot) {

        LOCK(cs_main);

        if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()]))
            throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");

        vector<uint256>::const_iterator it;
        if ((it = std::find(vMatch.begin(), vMatch.end(), hashTx))==vMatch.end()) {
            throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction given doesn't exist in proof");
        }

        txnIndex = vIndex[it - vMatch.begin()];
    }
    else {
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Something wrong with merkleblock");
    }

    wtx.nIndex = txnIndex;
    wtx.hashBlock = merkleBlock.header.GetHash();

    LOCK2(cs_main, pwalletMain->cs_wallet);

    if (pwalletMain->IsMine(tx)) {
        CWalletDB walletdb(pwalletMain->strWalletFile, "r+", false);
        pwalletMain->AddToWallet(wtx, false, &walletdb);
        return NullUniValue;
    }

    throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No addresses in wallet correspond to included transaction");
}

UniValue removeprunedfunds(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() != 1)
        throw runtime_error(
            "removeprunedfunds \"txid\"\n"
            "\nDeletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will effect wallet balances.\n"
            "\nArguments:\n"
            "1. \"txid\"           (string, required) The hex-encoded id of the transaction you are deleting\n"
            "\nExamples:\n"
            + HelpExampleCli("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"") +
            "\nAs a JSON-RPC call\n"
            + HelpExampleRpc("removprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"")
        );

    LOCK2(cs_main, pwalletMain->cs_wallet);

    uint256 hash;
    hash.SetHex(params[0].get_str());
    vector<uint256> vHash;
    vHash.push_back(hash);
    vector<uint256> vHashOut;

    if(pwalletMain->ZapSelectTx(vHash, vHashOut) != DB_LOAD_OK) {
        throw JSONRPCError(RPC_INTERNAL_ERROR, "Could not properly delete the transaction.");
    }

    if(vHashOut.empty()) {
        throw JSONRPCError(RPC_INTERNAL_ERROR, "Transaction does not exist in wallet.");
    }

    ThreadFlushWalletDB(pwalletMain->strWalletFile);

    return NullUniValue;
}

UniValue importpubkey(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() < 1 || params.size() > 4)
        throw runtime_error(
            "importpubkey \"pubkey\" ( \"label\" rescan )\n"
            "\nAdds a public key (in hex) that can be watched as if it were in your wallet but cannot be used to spend.\n"
            "\nArguments:\n"
            "1. \"pubkey\"           (string, required) The hex-encoded public key\n"
            "2. \"label\"            (string, optional, default=\"\") An optional label\n"
            "3. rescan               (boolean, optional, default=true) Rescan the wallet for transactions\n"
            "\nNote: This call can take minutes to complete if rescan is true.\n"
            "\nExamples:\n"
            "\nImport a public key with rescan\n"
            + HelpExampleCli("importpubkey", "\"mypubkey\"") +
            "\nImport using a label without rescan\n"
            + HelpExampleCli("importpubkey", "\"mypubkey\" \"testing\" false") +
            "\nAs a JSON-RPC call\n"
            + HelpExampleRpc("importpubkey", "\"mypubkey\", \"testing\", false")
        );

    string strLabel = "";
    if (params.size() > 1)
        strLabel = params[1].get_str();

    // Whether to perform rescan after import
    bool fRescan = true;
    if (params.size() > 2)
        fRescan = params[2].get_bool();

    if (fRescan && fPruneMode)
        throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");

    if (!IsHex(params[0].get_str()))
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey must be a hex string");
    std::vector<unsigned char> data(ParseHex(params[0].get_str()));
    CPubKey pubKey(data.begin(), data.end());
    if (!pubKey.IsFullyValid())
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey is not a valid public key");

    LOCK2(cs_main, pwalletMain->cs_wallet);

    ImportAddress(CNavCoinAddress(pubKey.GetID()), strLabel);
    ImportScript(GetScriptForRawPubKey(pubKey), strLabel, false);

    if (fRescan)
    {
        pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true);
        pwalletMain->ReacceptWalletTransactions();
    }

    return NullUniValue;
}

UniValue importwallet(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() != 1)
        throw runtime_error(
            "importwallet \"filename\"\n"
            "\nImports keys from a wallet dump file (see dumpwallet).\n"
            "\nArguments:\n"
            "1. \"filename\"    (string, required) The wallet file\n"
            "\nExamples:\n"
            "\nDump the wallet\n"
            + HelpExampleCli("dumpwallet", "\"test\"") +
            "\nImport the wallet\n"
            + HelpExampleCli("importwallet", "\"test\"") +
            "\nImport using the json rpc call\n"
            + HelpExampleRpc("importwallet", "\"test\"")
        );

    if (fPruneMode)
        throw JSONRPCError(RPC_WALLET_ERROR, "Importing wallets is disabled in pruned mode");

    LOCK2(cs_main, pwalletMain->cs_wallet);

    EnsureWalletIsUnlocked();

    ifstream file;
    file.open(params[0].get_str().c_str(), std::ios::in | std::ios::ate);
    if (!file.is_open())
        throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");

    int64_t nTimeBegin = chainActive.Tip()->GetBlockTime();

    bool fGood = true;

    int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg());
    file.seekg(0, file.beg);

    pwalletMain->ShowProgress(_("Importing..."), 0); // show progress dialog in GUI
    while (file.good()) {
        pwalletMain->ShowProgress("", std::max(1, std::min(99, (int)(((double)file.tellg() / (double)nFilesize) * 100))));
        std::string line;
        std::getline(file, line);
        if (line.empty() || line[0] == '#')
            continue;

        std::vector<std::string> vstr;
        boost::split(vstr, line, boost::is_any_of(" "));
        if (vstr.size() < 2)
            continue;
        CNavCoinSecret vchSecret;
        if (!vchSecret.SetString(vstr[0]))
            continue;
        CKey key = vchSecret.GetKey();
        CPubKey pubkey = key.GetPubKey();
        assert(key.VerifyPubKey(pubkey));
        CKeyID keyid = pubkey.GetID();
        if (pwalletMain->HaveKey(keyid)) {
            LogPrintf("Skipping import of %s (key already present)\n", CNavCoinAddress(keyid).ToString());
            continue;
        }
        int64_t nTime = DecodeDumpTime(vstr[1]);
        std::string strLabel;
        bool fLabel = true;
        for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) {
            if (boost::algorithm::starts_with(vstr[nStr], "#"))
                break;
            if (vstr[nStr] == "change=1")
                fLabel = false;
            if (vstr[nStr] == "reserve=1")
                fLabel = false;
            if (boost::algorithm::starts_with(vstr[nStr], "label=")) {
                strLabel = DecodeDumpString(vstr[nStr].substr(6));
                fLabel = true;
            }
        }
        LogPrintf("Importing %s...\n", CNavCoinAddress(keyid).ToString());
        if (!pwalletMain->AddKeyPubKey(key, pubkey)) {
            fGood = false;
            continue;
        }
        pwalletMain->mapKeyMetadata[keyid].nCreateTime = nTime;
        if (fLabel)
            pwalletMain->SetAddressBook(keyid, strLabel, "receive");
        nTimeBegin = std::min(nTimeBegin, nTime);
    }
    file.close();
    pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI

    CBlockIndex *pindex = chainActive.Tip();
    while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
        pindex = pindex->pprev;

    if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey)
        pwalletMain->nTimeFirstKey = nTimeBegin;

    LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->nHeight + 1);
    pwalletMain->ScanForWalletTransactions(pindex);
    pwalletMain->MarkDirty();

    if (!fGood)
        throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet");

    return NullUniValue;
}

UniValue dumpprivkey(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() != 1)
        throw runtime_error(
            "dumpprivkey \"navcoinaddress\"\n"
            "\nReveals the private key corresponding to 'navcoinaddress'.\n"
            "Then the importprivkey can be used with this output\n"
            "\nArguments:\n"
            "1. \"navcoinaddress\"   (string, required) The navcoin address for the private key\n"
            "\nResult:\n"
            "\"key\"                (string) The private key\n"
            "\nExamples:\n"
            + HelpExampleCli("dumpprivkey", "\"myaddress\"")
            + HelpExampleCli("importprivkey", "\"mykey\"")
            + HelpExampleRpc("dumpprivkey", "\"myaddress\"")
        );

    LOCK2(cs_main, pwalletMain->cs_wallet);

    EnsureWalletIsUnlocked();

    string strAddress = params[0].get_str();
    CNavCoinAddress address;
    if (!address.SetString(strAddress))
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NavCoin address");
    CKeyID keyID;
    if (!address.GetKeyID(keyID))
        throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key");
    CKey vchSecret;
    if (!pwalletMain->GetKey(keyID, vchSecret))
        throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known");
    return CNavCoinSecret(vchSecret).ToString();
}

UniValue dumpwallet(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() != 1)
        throw runtime_error(
            "dumpwallet \"filename\"\n"
            "\nDumps all wallet keys in a human-readable format.\n"
            "\nArguments:\n"
            "1. \"filename\"    (string, required) The filename\n"
            "\nExamples:\n"
            + HelpExampleCli("dumpwallet", "\"test\"")
            + HelpExampleRpc("dumpwallet", "\"test\"")
        );

    LOCK2(cs_main, pwalletMain->cs_wallet);

    EnsureWalletIsUnlocked();

    ofstream file;
    file.open(params[0].get_str().c_str());
    if (!file.is_open())
        throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");

    std::map<CKeyID, int64_t> mapKeyBirth;
    std::set<CKeyID> setKeyPool;
    pwalletMain->GetKeyBirthTimes(mapKeyBirth);
    pwalletMain->GetAllReserveKeys(setKeyPool);

    // sort time/key pairs
    std::vector<std::pair<int64_t, CKeyID> > vKeyBirth;
    for (std::map<CKeyID, int64_t>::const_iterator it = mapKeyBirth.begin(); it != mapKeyBirth.end(); it++) {
        vKeyBirth.push_back(std::make_pair(it->second, it->first));
    }
    mapKeyBirth.clear();
    std::sort(vKeyBirth.begin(), vKeyBirth.end());

    // produce output
    file << strprintf("# Wallet dump created by NavCoin %s\n", CLIENT_BUILD);
    file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime()));
    file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString());
    file << strprintf("#   mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime()));
    file << "\n";

    // add the base58check encoded extended master if the wallet uses HD
    CKeyID masterKeyID = pwalletMain->GetHDChain().masterKeyID;
    if (!masterKeyID.IsNull())
    {
        CKey key;
        if (pwalletMain->GetKey(masterKeyID, key))
        {
            CExtKey masterKey;
            masterKey.SetMaster(key.begin(), key.size());

            CNavCoinExtKey b58extkey;
            b58extkey.SetKey(masterKey);

            file << "# extended private masterkey: " << b58extkey.ToString() << "\n\n";
        }
    }
    for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) {
        const CKeyID &keyid = it->second;
        std::string strTime = EncodeDumpTime(it->first);
        std::string strAddr = CNavCoinAddress(keyid).ToString();
        CKey key;
        if (pwalletMain->GetKey(keyid, key)) {
            file << strprintf("%s %s ", CNavCoinSecret(key).ToString(), strTime);
            if (pwalletMain->mapAddressBook.count(keyid)) {
                file << strprintf("label=%s", EncodeDumpString(pwalletMain->mapAddressBook[keyid].name));
            } else if (keyid == masterKeyID) {
                file << "hdmaster=1";
            } else if (setKeyPool.count(keyid)) {
                file << "reserve=1";
            } else if (pwalletMain->mapKeyMetadata[keyid].hdKeypath == "m") {
                file << "inactivehdmaster=1";
            } else {
                file << "change=1";
            }
            file << strprintf(" # addr=%s%s\n", strAddr, (pwalletMain->mapKeyMetadata[keyid].hdKeypath.size() > 0 ? " hdkeypath="+pwalletMain->mapKeyMetadata[keyid].hdKeypath : ""));
        }
    }
    file << "\n";
    file << "# End of dump\n";
    file.close();
    return NullUniValue;
}

UniValue dumpmasterprivkey(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() != 0)
        throw runtime_error(
                "dumpmasterprivkey\n"
                "\nReveals the current master private key.\n"
                "\nResult:\n"
                " \"key\"                 (string) The HD master private key\n"
                "\nExamples:\n"
                + HelpExampleCli("dumpmasterprivkey", "")
                );

    LOCK2(cs_main, pwalletMain->cs_wallet);

    EnsureWalletIsUnlocked();

    CKeyID masterKeyID = pwalletMain->GetHDChain().masterKeyID;
    if (!pwalletMain->IsHDEnabled())
    {
        throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is not a HD wallet.");
    }
    CKey key;
    if (pwalletMain->GetKey(masterKeyID, key))
    {
        CExtKey masterKey;
        masterKey.SetMaster(key.begin(), key.size());

        CNavCoinExtKey b58extkey;
        b58extkey.SetKey(masterKey);

        return b58extkey.ToString();
    }
    else
    {
        throw JSONRPCError(RPC_WALLET_ERROR, "Unable to retrieve HD master private key");
        return NullUniValue;
    }
}

UniValue dumpmnemonic(const UniValue& params, bool fHelp)
{
    if (!EnsureWalletIsAvailable(fHelp))
        return NullUniValue;

    if (fHelp || params.size() > 1)
        throw runtime_error(
                "dumpmnemonic ( \"language\" )\n"
                "\nReveals the mnemonic for the current master private key.\n"
                "\nSupported languages:\n"
                "\n - english, spanish, italian, japanese, french, russian, czech, ukrainian, simplified chinese and traditional chinese\n"
                "\nArguments:\n"
                "1. \"language\"          (string, optional, english by default) The language for generating the mnemonic\n"
                "\nExamples:\n"
                + HelpExampleCli("dumpmnemonic", "")
                + HelpExampleCli("dumpmnemonic", "spanish")
                );

    LOCK2(cs_main, pwalletMain->cs_wallet);

    EnsureWalletIsUnlocked();

    CKeyID masterKeyID = pwalletMain->GetHDChain().masterKeyID;
    if (!pwalletMain->IsHDEnabled())
    {
        throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is not a HD wallet.");
    }
    CKey key;
    if (pwalletMain->GetKey(masterKeyID, key))
    {
        std::vector<unsigned char> keyData;
        const unsigned char* ptrKeyData = key.begin();
        for (int i = 0; ptrKeyData != key.end(); i++) {
            unsigned char byte = *ptrKeyData;
            keyData.push_back(byte);
            ptrKeyData++;
        }

        std::string mnemonic;
        word_list mnemonic_words = create_mnemonic(keyData, string_to_lexicon(params.size() == 1 ? params[0].get_str() : "english"));
        for (auto it = mnemonic_words.begin(); it != mnemonic_words.end();) {
            const auto word = *it;
            mnemonic += word;
            ++it;
            if (it == mnemonic_words.end())
                break;
            mnemonic += " ";
        }

        return mnemonic;
    }
    else
    {
        throw JSONRPCError(RPC_WALLET_ERROR, "Unable to retrieve HD master private key");
        return NullUniValue;
    }
}


text:
@extends('master')

@section('content')

<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
	@include('steamid.form')
</div>

@stop


text: Tests for the module system.


text:
'use strict';

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _getIterator2 = require('babel-runtime/core-js/get-iterator');

var _getIterator3 = _interopRequireDefault(_getIterator2);

var _set = require('babel-runtime/core-js/set');

var _set2 = _interopRequireDefault(_set);

var _fs = require('fs');

var _fs2 = _interopRequireDefault(_fs);

var _path2 = require('path');

var _path3 = _interopRequireDefault(_path2);

var _module = require('module');

var _module2 = _interopRequireDefault(_module);

var _log = require('./tools/log');

var _log2 = _interopRequireDefault(_log);

var _helpers = require('./helpers');

var _serializeJavascript = require('./tools/serialize-javascript');

var _serializeJavascript2 = _interopRequireDefault(_serializeJavascript);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// Hacking too much time

// Based on Node.js Module class sources:
// https://github.com/nodejs/node/blob/master/lib/module.js

var require_hacker = {
	preceding_path_resolvers: [],
	path_resolvers: [],

	global_hook_resolved_modules: {},

	global_hooks_enabled: true,

	occupied_file_extensions: new _set2.default(),

	// logging
	log: new _log2.default('require-hacker', { debug: false }), // this.options.debug

	// installs a require() path resolver
	//
	// resolve - a function which takes two parameters:
	//
	//             the path to be resolved
	//             the module in which the require() call was originated
	//
	//           must return either a new path to the require()d module
	//           or it can return nothing to fall back to the original require()d module path
	//
	// returns an object with an .unmount() method
	//
	resolver: function resolver(resolve) {
		validate.resolve(resolve);

		var resolver = function resolver(path, module) {
			// resolve the path for this require() call
			var resolved_path = resolve(path, module);

			// if no path was resolved - do nothing
			if (!(0, _helpers.exists)(resolved_path)) {
				return;
			}

			// return the path to be require()d
			return resolved_path;
		};

		require_hacker.preceding_path_resolvers.push(resolver);

		var result = {
			unmount: function unmount() {
				// javascript arrays still have no .remove() method in the XXI-st century
				require_hacker.preceding_path_resolvers = require_hacker.preceding_path_resolvers.filter(function (x) {
					return x !== resolver;
				});
			}
		};

		return result;
	},

	// installs a global require() hook for all paths
	//
	// (if these paths are certain to exist in the filesystem
	//  and if you need only a specific file extension
	//  then use the .hook(extension, resolve) method instead)
	//
	// id - a meaningful textual identifier
	//
	// resolve - a function which takes two parameters:
	//
	//             the path to be resolved
	//             the module in which the require() call was originated
	//
	//           must return either a javascript CommonJS module source code
	//           (i.e. "module.exports = ...", etc)
	//           or it can return nothing to fall back to the original Node.js loader
	//
	// returns an object with an .unmount() method
	//
	// options:
	//
	//   precede_node_loader:
	//
	//     true  - this require() hook will intercept all require() calls
	//             before they go into the original Node.js loader
	//
	//     false - this require() hook will only intercept those require() calls
	//             which failed to be resolved by the original Node.js loader
	//
	//     default value: true
	//
	global_hook: function global_hook(id, resolve) {
		var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

		validate.global_hook(id, resolve);

		var resolver = function resolver(path, module) {
			// log.debug(`Global require() hook "${id}" fired`)

			// get CommonJS module source code for this require() call
			var source = resolve(path, module);

			// if no CommonJS module source code returned - skip this require() hook
			if (!(0, _helpers.exists)(source)) {
				return;
			}

			// CommonJS module source code returned,
			// so put it into a hash for a corresponding key

			var resolved_path = path + '.' + id;

			// flush require() cache
			delete require.cache[resolved_path];

			// put the CommonJS module source code into the hash
			require_hacker.global_hook_resolved_modules[resolved_path] = source;

			// return the path to be require()d
			// in order to get the CommonJS module source code
			return resolved_path;
		};

		if (options.precede_node_loader === false) {
			require_hacker.path_resolvers.push(resolver);
		} else {
			require_hacker.preceding_path_resolvers.push(resolver);
		}

		var hook = this.hook(id, function (path) {
			var source = require_hacker.global_hook_resolved_modules[path];
			delete require_hacker.global_hook_resolved_modules[path];
			return source;
		});

		var result = {
			unmount: function unmount() {
				// javascript arrays still have no .remove() method in the XXI-st century
				require_hacker.preceding_path_resolvers = require_hacker.preceding_path_resolvers.filter(function (x) {
					return x !== resolver;
				});
				require_hacker.path_resolvers = require_hacker.path_resolvers.filter(function (x) {
					return x !== resolver;
				});
				hook.unmount();
			}
		};

		return result;
	},

	// installs a require() hook for the extension
	//
	// extension - a file extension to hook into require()s of
	//             (examples: 'css', 'jpg', 'js')
	//
	// resolve   - a function that takes two parameters:
	//
	//               the path requested in the require() call
	//               the module in which the require() call was originated
	//
	//             must return either a javascript CommonJS module source code
	//             (i.e. "module.exports = ...", etc)
	//             or it can return nothing to fall back to the original Node.js loader
	//
	hook: function hook(extension, resolve) {
		var _this = this;

		this.log.debug('Hooking into *.' + extension + ' files loading');

		// validation
		validate.extension(extension);
		validate.resolve(resolve);

		// occupy file extension
		this.occupied_file_extensions.add(extension);

		// dotted extension
		var dot_extension = '.' + extension;

		// keep original extension loader
		var original_loader = _module2.default._extensions[dot_extension];

		// display a warning in case of extension loader override
		if (original_loader) {
			// output a debug message in case of extension loader override,
			// not a warning, so that it doesn't scare people
			this.log.debug('-----------------------------------------------');
			this.log.debug('Overriding an already existing require() hook ');
			this.log.debug('for file extension ' + dot_extension);
			this.log.debug('-----------------------------------------------');
		}

		// the list of cached modules
		var cached_modules = new _set2.default();

		// Node.js inner API check
		/* istanbul ignore if */
		if (!_module2.default._extensions) {
			throw new Error('Incompatilbe Node.js version detected: "Module._extensions" array is missing. File an issue on GitHub.');
		}

		// set new loader for this extension
		_module2.default._extensions[dot_extension] = function (module, filename) {
			_this.log.debug('require() hook fired for ' + filename);

			// var source = fs.readFileSync(filename, 'utf8')
			var source = resolve(filename, module);

			if (!(0, _helpers.exists)(source)) {
				_this.log.debug('Fallback to original loader');

				// this message would appear if there was no loader
				// for the extension of the filename
				if (_path3.default.extname(filename) !== dot_extension) {
					_this.log.info('Trying to load "' + _path3.default.basename(filename) + '" as a "*' + dot_extension + '"');
				}

				// load the file with the original loader
				return (original_loader || _module2.default._extensions['.js'])(module, filename);
			}

			// add this file path to the list of cached modules
			cached_modules.add(filename);

			// Node.js inner API check
			/* istanbul ignore if */
			if (!module._compile) {
				throw new Error('Incompatilbe Node.js version detected: "Module.prototype._compile" function is missing. File an issue on GitHub.');
			}

			// compile javascript module from its source
			// https://github.com/nodejs/node/blob/master/lib/module.js#L379
			module._compile(source, filename);
		};

		var result = {
			// uninstall the hook
			unmount: function unmount() {
				// clear require() cache for this file extension
				var _iteratorNormalCompletion = true;
				var _didIteratorError = false;
				var _iteratorError = undefined;

				try {
					for (var _iterator = (0, _getIterator3.default)(cached_modules), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
						var _path = _step.value;

						delete require.cache[_path];
					}

					// mount the original loader for this file extension
				} catch (err) {
					_didIteratorError = true;
					_iteratorError = err;
				} finally {
					try {
						if (!_iteratorNormalCompletion && _iterator.return) {
							_iterator.return();
						}
					} finally {
						if (_didIteratorError) {
							throw _iteratorError;
						}
					}
				}

				_module2.default._extensions[dot_extension] = original_loader;

				// free file extension
				_this.occupied_file_extensions.delete(extension);
			}
		};

		return result;
	},

	// returns a CommonJS modules source.
	to_javascript_module_source: function to_javascript_module_source(anything) {
		// if the asset source wasn't found - return an empty CommonJS module
		if (!(0, _helpers.exists)(anything)) {
			return 'module.exports = undefined';
		}

		// if it's already a common js module source
		if (typeof anything === 'string' && is_a_module_declaration(anything)) {
			return anything;
		}

		// generate javascript module source code based on the `source` variable
		return 'module.exports = ' + (0, _serializeJavascript2.default)(anything);
	},

	// resolves a requireable `path` to a real filesystem path relative to the `module`
	// (resolves `npm link`, etc)
	resolve: function resolve(path_to_resolve, module) {
		// Module._resolveFilename existence check is perfomed outside of this method
		try {
			require_hacker.global_hooks_enabled = false;
			return original_resolveFilename(path_to_resolve, module);
		} finally {
			require_hacker.global_hooks_enabled = true;
		}
	}
};

// validation
var validate = {
	extension: function extension(_extension) {
		// if (typeof extension !== 'string')
		// {
		// 	throw new Error(`Expected string extension. Got ${extension}`)
		// }

		if (_path3.default.extname('test.' + _extension) !== '.' + _extension) {
			throw new Error('Invalid file extension "' + _extension + '"');
		}

		// check if the file extension is already occupied
		if (require_hacker.occupied_file_extensions.has(_extension)) {
			throw new Error('File extension "' + _extension + '" is already occupied by require-hacker');
		}
	},
	resolve: function resolve(_resolve) {
		if (typeof _resolve !== 'function') {
			throw new Error('Resolve should be a function. Got "' + _resolve + '"');
		}
	},
	global_hook: function global_hook(id, resolver) {
		if (!id) {
			throw new Error('You must specify global hook id');
		}

		if (_path3.default.extname('test.' + id) !== '.' + id) {
			throw new Error('Invalid global hook id "' + id + '". Expected a valid file extension.');
		}

		// check if the file extension is already occupied
		if (require_hacker.occupied_file_extensions.has(id)) {
			throw new Error('File extension "' + id + '" is already occupied by require-hacker');
		}

		validate.resolve(resolver);
	}
};

// Node.js inner API check
/* istanbul ignore if */
if (!_module2.default._resolveFilename) {
	throw new Error('Incompatilbe Node.js version detected: "Module._resolveFilename" function is missing. File an issue on GitHub.');
}

// Node.js inner API check
/* istanbul ignore if */
if (!_module2.default._findPath) {
	throw new Error('Incompatilbe Node.js version detected: "Module._findPath" function is missing. File an issue on GitHub.');
}

// the module in which the require() call originated
var require_caller = void 0;

// instrument Module._resolveFilename
// https://github.com/nodejs/node/blob/master/lib/module.js#L322
//
// `arguments` would conflict with Babel, therefore `...parameters`
//
// const native_module = require('native_module')
var original_resolveFilename = _module2.default._resolveFilename;
_module2.default._resolveFilename = function () {
	for (var _len = arguments.length, parameters = Array(_len), _key = 0; _key < _len; _key++) {
		parameters[_key] = arguments[_key];
	}

	var request = parameters[0];
	var parent = parameters[1];

	// take note of the require() caller
	// (the module in which this require() call originated)
	require_caller = parent;

	return original_resolveFilename.apply(this, parameters);
};

// instrument Module._findPath
// https://github.com/nodejs/node/blob/master/lib/module.js#L335-L341
//
// `arguments` would conflict with Babel, therefore `...parameters`
//
var original_findPath = _module2.default._findPath;
_module2.default._findPath = function () {
	for (var _len2 = arguments.length, parameters = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
		parameters[_key2] = arguments[_key2];
	}

	var request = parameters[0];
	// const paths = parameters[1]

	// preceeding resolvers
	if (require_hacker.global_hooks_enabled) {
		var _iteratorNormalCompletion2 = true;
		var _didIteratorError2 = false;
		var _iteratorError2 = undefined;

		try {
			for (var _iterator2 = (0, _getIterator3.default)(require_hacker.preceding_path_resolvers), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
				var resolver = _step2.value;

				var resolved_path = resolver(request, require_caller);
				if ((0, _helpers.exists)(resolved_path)) {
					return resolved_path;
				}
			}
		} catch (err) {
			_didIteratorError2 = true;
			_iteratorError2 = err;
		} finally {
			try {
				if (!_iteratorNormalCompletion2 && _iterator2.return) {
					_iterator2.return();
				}
			} finally {
				if (_didIteratorError2) {
					throw _iteratorError2;
				}
			}
		}
	}

	// original Node.js loader
	var filename = original_findPath.apply(undefined, parameters);
	if (filename !== false) {
		return filename;
	}

	// rest resolvers
	if (require_hacker.global_hooks_enabled) {
		var _iteratorNormalCompletion3 = true;
		var _didIteratorError3 = false;
		var _iteratorError3 = undefined;

		try {
			for (var _iterator3 = (0, _getIterator3.default)(require_hacker.path_resolvers), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
				var _resolver = _step3.value;

				var resolved = _resolver.resolve(request, require_caller);
				if ((0, _helpers.exists)(resolved)) {
					return resolved;
				}
			}
		} catch (err) {
			_didIteratorError3 = true;
			_iteratorError3 = err;
		} finally {
			try {
				if (!_iteratorNormalCompletion3 && _iterator3.return) {
					_iterator3.return();
				}
			} finally {
				if (_didIteratorError3) {
					throw _iteratorError3;
				}
			}
		}
	}

	return false;
};

// detect if it is a CommonJS module declaration
function is_a_module_declaration(text) {
	return text.indexOf('module.exports = ') === 0 || /\s+module\.exports = .+/.test(text);
}

exports.default = require_hacker;
module.exports = exports['default'];
//# sourceMappingURL=require hacker.js.map


text:
@interface DHLevelSegmentInThree : DHLevel <DHLevel>

@end


text:
<?php

namespace Steelbot\Protocol;

interface OutgoingPayloadInterface
{
}


text:
class ConcurrentMultiQueue;
class ImageDownloader;

class DownloadQueue : public QObject
{
	Q_OBJECT

	public:
		enum Queue
		{
			Manual = 0,
			Batch = 1,
			Background = 2,
		};

		explicit DownloadQueue(int maxConcurrency, QObject *parent = nullptr);
		void add(Queue queue, ImageDownloader *downloader);

	signals:
		void finished();

	protected slots:
		void dequeued(const QVariant &item);

	private:
		ConcurrentMultiQueue *m_queue;
};

#endif // DOWNLOAD_QUEUE_H


text:
$(function() {

	// Hide the Preview Box header and footer on page load
	$('.msgOptions, .panel-heading').hide();

	// Get the PM Page we are on
	var pmPage = $(this).find('#pmPage').val();

	$('.msgLink').click( function() {
		$('.msgQuip').hide();
		$('.panel-heading').show();

		var fromName = $(this).find('.name').html();
		var dateSent = $(this).find('.time').html();
		var msgSubject = $(this).find('.subject').html();
		var msgText = $(this).find('[name="msgTxt"]').val();
		var msgId = $(this).find('[name="messageId"]').val();
		var isRead = $(this).find('[name="toRead"]').val();

		$('.theSubject').show().html('
'+msgSubject+'
');
		$('.msgContent').show().html(msgText.replace(/\\r\\n/g, "
"));

		// Inbox
		if (pmPage === 'inbox') {
			$('.whoFrom').show().html('From: '+fromName+'  on: '+dateSent+'');
			if (isRead === '0') {
				$('.msgOptions').show().html('<form action="" method="post"><input name="messageId" value="'+msgId+'" type="hidden" /> Reply <button type="input" name="submit" value="markRead" class="btn btn-success btn-sm btn-icon"> Mark as Read</button>  Delete</form>');
				$('.msgContent').addClass('contentMargin');
			} else {
				$('.msgOptions').show().html('<form action="" method="post"><input name="messageId" value="'+msgId+'" type="hidden" /> Reply <button type="input" name="submit" value="archive" class="btn btn-warning btn-sm btn-icon"> Archive</button>  Delete</form>');
				$('.msgContent').addClass('contentMargin');
			}
		}
		// Sent Messages
		if (pmPage === 'sent') {
			$('.whoTo').show().html('Sent to: '+fromName+'  on: '+dateSent+'');
			$('.msgOptions').show().html(' Delete');
			$('.msgContent').addClass('contentMargin');
		}
		// Archived Messages
		if (pmPage === 'archive') {
			$('.whoFrom').show().html('From: '+fromName+'  on: '+dateSent+'');
			$('.msgOptions').show().html('<form action="" method="post"><input name="messageId" value="'+msgId+'" type="hidden" /><button type="input" name="submit" value="sendInbox" class="btn btn-info btn-sm btn-icon"> Send to Inbox</button>  Delete</form>');
			$('.msgContent').addClass('contentMargin');
		}
	});

	$('.compose').click( function() {
		$('.msgOptions, .panel-default').hide();
		$('.msgContent').removeClass('contentMargin');
	});

	$('.showinbox').click( function() {
		$('.panel-default, .msgQuip').show();
		$('.msgOptions, .panel-heading, .whoFrom, .msgContent').hide();
	});

	$('.showsent').click( function() {
		$('.panel-default, .msgQuip').show();
		$('.msgOptions, .panel-heading, .whoTo, .msgContent').hide();
	});

	$('.showarchive').click( function() {
		$('.panel-default, .msgQuip').show();
		$('.msgOptions, .panel-heading, .whoFrom, .msgContent').hide();
	});

	// Set the Selects based on who the PM is sent to
	$('#toMgr').change(function() {
		$('#toClt option:first').prop('selected',  true);
	});

	$('#toClt').change(function() {
		$('#toMgr option:first').prop('selected',  true);
	});

});


text:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="database0" class="com.dianping.zebra.group.jdbc.GroupDataSource"  init-method="init" destroy-method="close">
        <property name="jdbcRef" value="multisk-gds0"/>
        <property name="driverClass" value="org.h2.Driver"/>
        <property name="configManagerType" value="local"/>
        <property name="minPoolSize" value="2"/>
        <property name="maxPoolSize" value="4"/>
        <property name="initialPoolSize" value="2"/>
    </bean>
    <bean id="database1" class="com.dianping.zebra.group.jdbc.GroupDataSource"  init-method="init" destroy-method="close">
        <property name="jdbcRef" value="multisk-gds1"/>
        <property name="driverClass" value="org.h2.Driver"/>
        <property name="configManagerType" value="local"/>
        <property name="minPoolSize" value="2"/>
        <property name="maxPoolSize" value="4"/>
        <property name="initialPoolSize" value="2"/>
    </bean>

    <bean id="zebraDS" class="com.dianping.zebra.shard.jdbc.ShardDataSource" init-method="init">
        <property name="dataSourcePool">
            <map>
                <entry key="database0" value-ref="database0"/>
                <entry key="database1" value-ref="database1"/>
            </map>
        </property>
        <property name="routerFactory">
            <bean class="com.dianping.zebra.shard.router.builder.XmlResourceRouterBuilder">
                <constructor-arg value="mockdb-config/testMultiShardKey/router-multidb-multisk.xml"/>
            </bean>
        </property>
    </bean>

</beans>


text:
#ifndef TIME_HPP
	#define TIME_HPP

	#include <string>

	#ifdef _MSC_VER
		#include <windows.h>
		typedef __int64		mstime;		// microsecond time = 8 byte integer
		typedef __int64		sjtime;		// scaled julian times = 8 byte integer

		#define MSEC_SCALAR		1000000i64
		#define SEC_SCALAR		1000000000i64
		#define MIN_SCALAR		60000000000i64
		#define HR_SCALAR		3600000000000i64
		#define	DAY_SCALAR		86400000000000i64

		#pragma warning ( disable : 4522 )
		#pragma warning ( disable : 4996 )		// sprintf warning
	#endif

	#ifdef __linux__
        #include <linux/types.h>
        typedef __s64       mstime;
        typedef __s64       sjtime;

		#define MSEC_SCALAR		1000000LL
		#define SEC_SCALAR		1000000000LL
		#define MIN_SCALAR		60000000000LL
		#define HR_SCALAR		3600000000000LL
		#define	DAY_SCALAR		86400000000000LL
	#endif

	#ifdef __CYGWIN__
		#include <largeint.h>			// found in \cygwin\usr\include\w32api
        typedef __int64       mstime;
        typedef __int64       sjtime;

		#define MSEC_SCALAR		1000000LL
		#define SEC_SCALAR		1000000000LL
		#define MIN_SCALAR		60000000000LL
		#define HR_SCALAR		3600000000000LL
		#define	DAY_SCALAR		86400000000000LL
	#endif

	#define ACC_SEC			0
	#define ACC_MSEC		1
	#define ACC_NSEC		2

	#define NSEC_SCALAR		1

    // Time Class
	// R. Hoetzlein
	//
	// Overview:
	//  There is a need in many systems to represent both very small (nanoseconds) and
	//  very large (millenia) timescales accurately. Modified Julian Date accurate represents
	//  individual days over +/- about 30,000 yrs. However, MJD represents fractions of a day
	//  as a floating point fraction. This is inaccurate for any timing-critical applications.
	//  The Time class here uses an 8-byte (64 bit) integer called SJT, Scaled Julian Time.
	//      SJT = MJD * DAY_SCALAR + UT (nanoseconds).
	//  SJT is the Modified Julian Date scaled by a integer factor, and added to Universal Time
	//  represented in nanoseconds.
	//
	// Features:
	// - Accurately represents individual nanoseconds over +/- 30,000 yrs.
	// - Correct rollover of tiny time scales on month, day, year boundaries.
	//     e.g. Set date/time to 11:59:59.9999, on Feb 28th,
	// - Accurately gives day of the week for any date
	// - Accurately compares two dates (days elapsed) even across leap-years.
	// - Adjust sec/nsec independently from month/day/year (work at scale you desire)
	//
	// Implementation Notes:
	// JD = Julian Day is the number of days elapsed since Jan 1, 4713 BC in the proleptic Julian calendar.
	//     http://en.wikipedia.org/wiki/Julian_day
	// MJD = Modified Julian Date. Most modern dates, after 19th c., have Julian Date which are greater
	//       than 2400000.5. MJD is an offset. MJD = JD - 2400000.5
	//       It shifts the epoch date (start date) to Nov 17, 1858.
	// UT = Universal Time. This is the time of day in hours as measured from Greenwich England.
	//       For non-astronomic uses, this is: UT = Local Time + Time Zone.
	// SJT = Scaled Julian Time = MJD * DAY_SCALAR + UT (in nanoseconds).
	//
	// Julian Dates (and their MJD and SJT equivalents)
	// ------------
	// Jan 1,  4713 BC = JD 0			= MJD -2400000	= SJT
	// Jan 1,  1500 AD = JD 2268933.5	= MJD -131067	= SJT
	// Nov 16, 1858 AD = JD 2400000.5	= MJD 0			= SJT 0
	// Jan 1,  1960 AD = JD 2436935.5	= MJD 36935		= SJT 3,191,184,000,000
	// Jan 1,  2005 AD = JD 2453372.5	= MJD 53372		= SJT 4,611,340,800,000
	// Jan 1,  2100 AD = JD 2488070.5	= MJD 88070		= SJT 7,609,248,000,000
	//
	//
	//
	// 32/64-Bit Integer Ranges
	//    32-bit Integer Min:              –2,147,483,648   ( 4 bytes )
	//    32-bit Integer Max:               2,147,483,647
	//    SJT 2005:                     4,611,340,800,000
	//    64-bit Integer Min:  –9,223,372,036,854,775,808
	//    64-bit Integer Max:   9,223,372,036,854,775,807	( 8 bytes )
	//
	// SJT Range
	// ---------
	//   * USING DAY_SCALAR = 86,400,000 (millisec accuracy)
	//   SJT Range = (+/-9,223,372,036,854,775,807 SJT / 86,400,000 DAY_SCALAR)
	//   SJT Range (in Julian Days) = +2400000.5 + (+/-106,751,991,167 MJD)
	//   SJT Range (in Julian Days) = +/- 292278883 years, with 1 millisecond accuracy.
	//
	//   * USING DAY_SCALAR = 86,400,000,000,000 (nanosec accuracy)
	//   SJT Range = (+/-9,223,372,036,854,775,807 SJT / 86,400,000,000,000 DAY_SCALAR)
	//   SJT Range (in Julian Days) = +2400000.5 + (+/-106,751 MJD)
	//   SJT Range (in Julian Days) = 1566 AD to 2151 AD, with 1 nanosecond accuracy.

	namespace mint {

	class Time {
	public:
		Time ();
		Time ( sjtime t )			{ m_CurrTime = t; }
		Time ( int sec, int msec )	{ m_CurrTime = 0; SetTime ( sec, msec ); }

		// Set time
		bool SetTime ( int sec );									// Set seconds
		bool SetTime ( int sec, int msec );							// Set seconds, msecs
		bool SetTime ( int hr, int min, int m, int d, int y);		// Set hr/min, month, day, year
		bool SetTime ( int hr, int min, int m, int d, int y, int s, int ms, int ns);	// Set hr/min, month, day, year, sec, ms, ns
		bool SetTime ( Time& t )	{ m_CurrTime = t.GetSJT(); return true;} // Set to another Time object
		bool SetTime ( std::string line );							// Set time from string (hr,min,sec)
		bool SetDate ( std::string line );							// Set date from string (mo,day,yr)
		void SetSystemTime ();										// Set date/time to system clock
		void SetSystemTime ( int accuracy );						// Set date/time to system clock
		void SetSJT ( sjtime t )	{ m_CurrTime = t ;}		// Set Scaled Julian Time directly

		// Get time
		void GetTime (int& sec, int& msec, int& nsec );
		void GetTime (int& hr, int& min, int& m, int& d, int& y);
		void GetTime (int& hr, int& min, int& m, int& d, int& y, int& s, int& ms, int& ns);
		double GetSec ();
		int GetMSec ();
		std::string GetReadableDate ();
		std::string GetReadableTime ();
		std::string GetReadableTime ( int fmt );
		std::string GetReadableSJT ();
		std::string GetDayOfWeekName ();
		sjtime GetSJT ()			{ return m_CurrTime; }

		// Advance Time
		void Advance ( Time& t );
		void AdvanceMinutes ( int n);
		void AdvanceHours ( int n );
		void AdvanceDays ( int n );
		void AdvanceSec ( int n );
		void AdvanceMins ( int n);
		void AdvanceMSec ( int n );

		// Utility functions
		// (these do the actual work, but should not be private as they may be useful to user)
		sjtime GetScaledJulianTime ( int hr, int min, int m, int d, int y );
		sjtime GetScaledJulianTime ( int hr, int min, int m, int d, int y, int s, int ms, int ns );
		void GetTime ( sjtime t, int& hr, int& min, int& m, int& d, int& y);
		void GetTime ( sjtime t, int& hr, int& min, int& m, int& d, int& y, int& s, int& ms, int& ns);

		// Get/Set Julian Date and Modified Julain Date
		void SetJD ( double jd );
		void SetMJD ( int jd );
		double GetJD ();
		int GetMJD ();

		// Time operators
		Time& operator= ( const Time& op );
		Time& operator= ( Time& op );
		bool operator< ( const Time& op );
		bool operator< ( Time& op );
		bool operator> ( const Time& op );
		bool operator> ( Time& op );
		bool operator<= ( const Time& op );
		bool operator<= ( Time& op );
		bool operator>= ( const Time& op );
		bool operator>= ( Time& op );
		bool operator== ( const Time& op );
		bool operator!= ( Time& op );
		Time operator- ( Time& op );
		Time operator+ ( Time& op );

		// Elapsed Times
		int GetElapsedDays ( Time& base );
		int GetElapsedWeeks ( Time& base );
		int GetElapsedMonths ( Time& base );
		int GetElapsedYears ( Time& base );
		int GetFracDay ( Time& base );			// Return Unit = 5 mins
		int GetFracWeek ( Time& base );			// Return Unit = 1 hr
		int GetFracMonth ( Time& base );		// Return Unit = 4 hrs
		int GetFracYear ( Time& base );			// Return Unit = 1 day
		int GetDayOfWeek ();
		int GetWeekOfYear ();

		void RegressionTest ();

	private:
		static const int	m_DaysInMonth[13];
		static bool			m_Started;

		sjtime				m_CurrTime;
	};

	// Used for precise system time (Win32)
	void start_timing ( sjtime base );

	}
#endif


text:
import stix2
import re

for obj in bundle.objects:
    if obj == threat_actor:
        print("------------------")
        print("== THREAT ACTOR ==")
        print("------------------")
        print("ID: " + obj.id)
        print("Created: " + str(obj.created))
        print("Modified: " + str(obj.modified))
        print("Name: " + obj.name)
        print("Threat Actor Types: " + str(obj.threat_actor_types))
        print("Roles: " + str(obj.roles))
        print("Goals: " + str(obj.goals))
        print("Sophistication: " + obj.sophistication)
        print("Resource Level: " + obj.resource_level)
        print("Primary Motivation: " + obj.primary_motivation)
        print("Secondary Motivations: " + str(obj.secondary_motivations))

    elif obj == identity1:
        print("------------------")
        print("== IDENTITY ==")
        print("------------------")
        print("ID: " + obj.id)
        print("Created: " + str(obj.created))
        print("Modified: " + str(obj.modified))
        print("Name: " + obj.name)
        print("Identity Class: " + obj.identity_class)

    elif obj == identity2:
        print("------------------")
        print("== IDENTITY ==")
        print("------------------")
        print("ID: " + obj.id)
        print("Created: " + str(obj.created))
        print("Modified: " + str(obj.modified))
        print("Name: " + obj.name)
        print("Identity Class: " + obj.identity_class)

    elif obj == attack_pattern1:
        print("------------------")
        print("== ATTACK PATTERN ==")
        print("------------------")
        print("ID: " + obj.id)
        print("Created: " + str(obj.created))
        print("Modified: " + str(obj.modified))
        print("Name: " + obj.name)
        print("Type: " + obj.type)
        print("External References: " + str(obj.external_references))

    elif obj == attack_pattern2:
        print("------------------")
        print("== ATTACK PATTERN ==")
        print("------------------")
        print("ID: " + obj.id)
        print("Created: " + str(obj.created))
        print("Modified: " + str(obj.modified))
        print("Name: " + obj.name)
        print("Type: " + obj.type)
        print("External References: " + str(obj.external_references))

    elif obj == campaign1:
        print("------------------")
        print("== CAMPAIGN ==")
        print("------------------")
        print("ID: " + obj.id)
        print("Created: " + str(obj.created))
        print("Modified: " + str(obj.modified))
        print("Name: " + obj.name)
        print("Description: " + obj.description)
        print("Type: " + obj.type)
        print("Aliases: " + str(obj.aliases))
        print("First Seen: " + str(obj.first_seen))
        print("Objective: " + obj.objective)

    elif obj == campaign2:
        print("------------------")
        print("== CAMPAIGN ==")
        print("------------------")
        print("ID: " + obj.id)
        print("Created: " + str(obj.created))
        print("Modified: " + str(obj.modified))
        print("Name: " + obj.name)
        print("Description: " + obj.description)
        print("Type: " + obj.type)
        print("Aliases: " + str(obj.aliases))
        print("First Seen: " + str(obj.first_seen))
        print("Objective: " + obj.objective)

    elif obj == intrusionset:
        print("------------------")
        print("== INTRUSION SET ==")
        print("------------------")
        print("ID: " + obj.id)
        print("Created: " + str(obj.created))
        print("Modified: " + str(obj.modified))
        print("Name: " + obj.name)
        print("Description: " + obj.name)
        print("Type: " + obj.type)
        print("Aliases: " + str(obj.aliases))
        print("First Seen: " + str(obj.first_seen))
        print("Goals: " + str(obj.goals))
        print("Resource Level: " + obj.resource_level)
        print("Primary Motivation: " + obj.primary_motivation)
        print("Secondary Motivations: " + str(obj.secondary_motivations))

    elif re.search('relationship*', str(obj)):
        print("------------------")
        print("== RELATIONSHIP ==")
        print("------------------")
        print("ID: " + obj.id)
        print("Created: " + str(obj.created))
        print("Modified: " + str(obj.modified))
        print("Type: " + obj.type)
        print("Relationship Type: " + obj.relationship_type)
        print("Source Ref: " + obj.source_ref)
        print("Target Ref: " + obj.target_ref)


text:
Your first step is to establish a public repository from which i can pull your work into the master repository.

 1. Setup a GitHub account (https://github.com/), if you haven't yet
 2. Fork the bookdown-bootswatch-templates repository (https://github.com/tobiju/bookdown-bootswatch-templates)
 3. Clone your fork locally and enter it (use your own GitHub username in the statement below)

    ```sh
    % git clone git@github.com:<username>/bookdown-bootswatch-templates.git
    % cd bookdown-bootswatch-templates
    ```

 4. Add a remote to the canonical bookdown-bootswatch-templates repository, so you can keep your fork
    up-to-date:

    ```sh
    % git remote add upstream https://github.com/tobiju/bookdown-bootswatch-templates.git
    % git fetch upstream
    ```

## Keeping Up-to-Date

Periodically, you should update your fork to match the canonical bookdown-bootswatch-templates repository. we have
added a remote to the bookdown-bootswatch-templates repository, which allows you to do the following:

```sh
% git checkout master
% git pull upstream master
- OPTIONALLY, to keep your remote up-to-date -
% git push origin
```

If you're tracking other branches -- for example, the "develop" branch, where new feature development occurs --
you'll want to do the same operations for that branch; simply substitute  "develop" for "master".

## Working on bookdown-bootswatch-templates

When working on bookdown-bootswatch-templates, we recommend you do each new feature or bugfix in a new branch. This simplifies the
task of code review as well as of merging your changes into the canonical repository.

A typical work flow will then consist of the following:

 1. Create a new local branch based off your master branch.
 2. Switch to your new local branch. (This step can be combined with the previous step with the use of `git checkout -b`.)
 3. Do some work, commit, repeat as necessary.
 4. Push the local branch to your remote repository.
 5. Send a pull request.

The mechanics of this process are actually quite trivial. Below, we will create a branch for fixing an issue in the tracker.

```sh
% git checkout -b 3452
Switched to a new branch '3452'
```
... do some work ...

```sh
% git commit
```
... write your log message ...

```sh
% git push origin HEAD:3452
Counting objects: 38, done.
Delta compression using up to 2 threads.
Compression objects: 100% (18/18), done.
Writing objects: 100% (20/20), 8.19KiB, done.
Total 20 (delta 12), reused 0 (delta 0)
To ssh://git@github.com/tobiju/bookdown-bootswatch-templates.git
   g5342..9k3532  HEAD -> master
```

You can do the pull request from github. Navigate to your repository, select the branch you just created, and then
select the "Pull Request" button in the upper right. Select the user "tobiju" as the recipient.

### What branch to issue the pull request against?

Which branch should you issue a pull request against?

- For fixes against the stable release, issue the pull request against the "master" branch.
- For new features, or fixes that introduce new elements to the public API
  (such as new public methods or properties), issue the pull request against the "develop" branch.

## Branch Cleanup

As you might imagine, if you are a frequent contributor, you'll start to get a ton of branches both locally and on
your remote.

Once you know that your changes have been accepted to the master repository, we suggest doing some cleanup of these
branches.

 -  Local branch cleanup

    ```sh
    % git branch -d <branchname>
    ```

 -  Remote branch removal

    ```sh
    % git push origin :<branchname>
    ```

## FEEDS AND EMAILS

RSS feeds may be found at:

`https://github.com/tobiju/bookdown-bootswatch-templates/commits/<branch>.atom`

where <branch> is a branch in the repository.

To subscribe to git email notifications, simply watch or fork the bookdown-bootswatch-templates repository on GitHub.


text:
/* $Id: ccmsg.h,v 1.11 2007/08/28 07:20:43 tbox Exp $ */

#ifndef ISCCC_CCMSG_H
#define ISCCC_CCMSG_H 1

/*! \file isccc/ccmsg.h */

#include <isc/buffer.h>
#include <isc/lang.h>
#include <isc/socket.h>

/*% ISCCC Message Structure */
typedef struct isccc_ccmsg {
	/* private (don't touch!) */
	unsigned int		magic;
	isc_uint32_t		size;
	isc_buffer_t		buffer;
	unsigned int		maxsize;
	isc_mem_t	       *mctx;
	isc_socket_t	       *sock;
	isc_task_t	       *task;
	isc_taskaction_t	action;
	void		       *arg;
	isc_event_t		event;
	/* public (read-only) */
	isc_result_t		result;
	isc_sockaddr_t		address;
} isccc_ccmsg_t;

ISC_LANG_BEGINDECLS

void
isccc_ccmsg_init(isc_mem_t *mctx, isc_socket_t *sock, isccc_ccmsg_t *ccmsg);
/*%
 * Associate a cc message state with a given memory context and
 * TCP socket.
 *
 * Requires:
 *
 *\li	"mctx" and "sock" be non-NULL and valid types.
 *
 *\li	"sock" be a read/write TCP socket.
 *
 *\li	"ccmsg" be non-NULL and an uninitialized or invalidated structure.
 *
 * Ensures:
 *
 *\li	"ccmsg" is a valid structure.
 */

void
isccc_ccmsg_setmaxsize(isccc_ccmsg_t *ccmsg, unsigned int maxsize);
/*%
 * Set the maximum packet size to "maxsize"
 *
 * Requires:
 *
 *\li	"ccmsg" be valid.
 *
 *\li	512 <= "maxsize" <= 4294967296
 */

isc_result_t
isccc_ccmsg_readmessage(isccc_ccmsg_t *ccmsg,
		       isc_task_t *task, isc_taskaction_t action, void *arg);
/*%
 * Schedule an event to be delivered when a command channel message is
 * readable, or when an error occurs on the socket.
 *
 * Requires:
 *
 *\li	"ccmsg" be valid.
 *
 *\li	"task", "taskaction", and "arg" be valid.
 *
 * Returns:
 *
 *\li	#ISC_R_SUCCESS		-- no error
 *\li	Anything that the isc_socket_recv() call can return.  XXXMLG
 *
 * Notes:
 *
 *\li	The event delivered is a fully generic event.  It will contain no
 *	actual data.  The sender will be a pointer to the isccc_ccmsg_t.
 *	The result code inside that structure should be checked to see
 *	what the final result was.
 */

void
isccc_ccmsg_cancelread(isccc_ccmsg_t *ccmsg);
/*%
 * Cancel a readmessage() call.  The event will still be posted with a
 * CANCELED result code.
 *
 * Requires:
 *
 *\li	"ccmsg" be valid.
 */

void
isccc_ccmsg_invalidate(isccc_ccmsg_t *ccmsg);
/*%
 * Clean up all allocated state, and invalidate the structure.
 *
 * Requires:
 *
 *\li	"ccmsg" be valid.
 *
 * Ensures:
 *
 *\li	"ccmsg" is invalidated and disassociated with all memory contexts,
 *	sockets, etc.
 */

ISC_LANG_ENDDECLS

#endif /* ISCCC_CCMSG_H */


text:
namespace {

bool GetTokens(const InputFile* input, std::vector<Token>* result) {
  result->clear();
  Err err;
  *result = Tokenizer::Tokenize(input, &err);
  return !err.has_error();
}

bool IsIdentifierEqual(const ParseNode* node, const char* val) {
  if (!node)
    return false;
  const IdentifierNode* ident = node->AsIdentifier();
  if (!ident)
    return false;
  return ident->value().value() == val;
}

bool IsLiteralEqual(const ParseNode* node, const char* val) {
  if (!node)
    return false;
  const LiteralNode* lit = node->AsLiteral();
  if (!lit)
    return false;
  return lit->value().value() == val;
}

// Returns true if the given node as a simple assignment to a given value.
bool IsAssignment(const ParseNode* node, const char* ident, const char* value) {
  if (!node)
    return false;
  const BinaryOpNode* binary = node->AsBinaryOp();
  if (!binary)
    return false;
  return binary->op().IsOperatorEqualTo("=") &&
         IsIdentifierEqual(binary->left(), ident) &&
         IsLiteralEqual(binary->right(), value);
}

// Returns true if the given node is a block with one assignment statement.
bool IsBlockWithAssignment(const ParseNode* node,
                           const char* ident, const char* value) {
  if (!node)
    return false;
  const BlockNode* block = node->AsBlock();
  if (!block)
    return false;
  if (block->statements().size() != 1)
    return false;
  return IsAssignment(block->statements()[0], ident, value);
}

void DoParserPrintTest(const char* input, const char* expected) {
  std::vector<Token> tokens;
  InputFile input_file(SourceFile("/test"));
  input_file.SetContents(input);
  ASSERT_TRUE(GetTokens(&input_file, &tokens));

  Err err;
  scoped_ptr<ParseNode> result = Parser::Parse(tokens, &err);
  ASSERT_TRUE(result);

  std::ostringstream collector;
  result->Print(collector, 0);

  EXPECT_EQ(expected, collector.str());
}

// Expects the tokenizer or parser to identify an error at the given line and
// character.
void DoParserErrorTest(const char* input, int err_line, int err_char) {
  InputFile input_file(SourceFile("/test"));
  input_file.SetContents(input);

  Err err;
  std::vector<Token> tokens = Tokenizer::Tokenize(&input_file, &err);
  if (!err.has_error()) {
    scoped_ptr<ParseNode> result = Parser::Parse(tokens, &err);
    ASSERT_FALSE(result);
    ASSERT_TRUE(err.has_error());
  }

  EXPECT_EQ(err_line, err.location().line_number());
  EXPECT_EQ(err_char, err.location().char_offset());
}

}  // namespace

TEST(Parser, BinaryOp) {
  std::vector<Token> tokens;

  // Simple set expression.
  InputFile expr_input(SourceFile("/test"));
  expr_input.SetContents("a=2");
  ASSERT_TRUE(GetTokens(&expr_input, &tokens));
  Err err;
  Parser set(tokens, &err);
  scoped_ptr<ParseNode> expr = set.ParseExpression();
  ASSERT_TRUE(expr);

  const BinaryOpNode* binary_op = expr->AsBinaryOp();
  ASSERT_TRUE(binary_op);

  EXPECT_TRUE(binary_op->left()->AsIdentifier());

  EXPECT_TRUE(binary_op->op().type() == Token::OPERATOR);
  EXPECT_TRUE(binary_op->op().value() == "=");

  EXPECT_TRUE(binary_op->right()->AsLiteral());
}

TEST(Parser, Condition) {
  std::vector<Token> tokens;

  InputFile cond_input(SourceFile("/test"));
  cond_input.SetContents("if(1) { a = 2 }");
  ASSERT_TRUE(GetTokens(&cond_input, &tokens));
  Err err;
  Parser simple_if(tokens, &err);
  scoped_ptr<ConditionNode> cond = simple_if.ParseCondition();
  ASSERT_TRUE(cond);

  EXPECT_TRUE(IsLiteralEqual(cond->condition(), "1"));
  EXPECT_FALSE(cond->if_false());  // No else block.
  EXPECT_TRUE(IsBlockWithAssignment(cond->if_true(), "a", "2"));

  // Now try a complicated if/else if/else one.
  InputFile complex_if_input(SourceFile("/test"));
  complex_if_input.SetContents(
      "if(1) { a = 2 } else if (0) { a = 3 } else { a = 4 }");
  ASSERT_TRUE(GetTokens(&complex_if_input, &tokens));
  Parser complex_if(tokens, &err);
  cond = complex_if.ParseCondition();
  ASSERT_TRUE(cond);

  EXPECT_TRUE(IsLiteralEqual(cond->condition(), "1"));
  EXPECT_TRUE(IsBlockWithAssignment(cond->if_true(), "a", "2"));

  ASSERT_TRUE(cond->if_false());
  const ConditionNode* nested_cond = cond->if_false()->AsConditionNode();
  ASSERT_TRUE(nested_cond);
  EXPECT_TRUE(IsLiteralEqual(nested_cond->condition(), "0"));
  EXPECT_TRUE(IsBlockWithAssignment(nested_cond->if_true(), "a", "3"));
  EXPECT_TRUE(IsBlockWithAssignment(nested_cond->if_false(), "a", "4"));
}

TEST(Parser, FunctionCall) {
  const char* input = "foo(a, 1, 2,) bar()";
  const char* expected =
      "BLOCK\n"
      " FUNCTION(foo)\n"
      "  LIST\n"
      "   IDENTIFIER(a)\n"
      "   LITERAL(1)\n"
      "   LITERAL(2)\n"
      " FUNCTION(bar)\n"
      "  LIST\n";
  DoParserPrintTest(input, expected);
}

TEST(Parser, ParenExpression) {
  const char* input = "(foo(1)) + (a + b)";
  const char* expected =
      "BLOCK\n"
      " BINARY(+)\n"
      "  FUNCTION(foo)\n"
      "   LIST\n"
      "    LITERAL(1)\n"
      "  BINARY(+)\n"
      "   IDENTIFIER(a)\n"
      "   IDENTIFIER(b)\n";
  DoParserPrintTest(input, expected);
  DoParserErrorTest("(a +", 1, 4);
}

TEST(Parser, UnaryOp) {
  std::vector<Token> tokens;

  InputFile ident_input(SourceFile("/test"));
  ident_input.SetContents("!foo");
  ASSERT_TRUE(GetTokens(&ident_input, &tokens));
  Err err;
  Parser ident(tokens, &err);
  scoped_ptr<UnaryOpNode> op = ident.ParseUnaryOp();

  ASSERT_TRUE(op);
  EXPECT_TRUE(op->op().type() == Token::OPERATOR);
  EXPECT_TRUE(op->op().value() == "!");
}

TEST(Parser, CompleteFunction) {
  const char* input =
      "cc_test(\"foo\") {\n"
      "  sources = [\n"
      "    \"foo.cc\",\n"
      "    \"foo.h\"\n"
      "  ]\n"
      "  dependencies = [\n"
      "    \"base\"\n"
      "  ]\n"
      "}\n";
  const char* expected =
      "BLOCK\n"
      " FUNCTION(cc_test)\n"
      "  LIST\n"
      "   LITERAL(\"foo\")\n"
      "  BLOCK\n"
      "   BINARY(=)\n"
      "    IDENTIFIER(sources)\n"
      "    LIST\n"
      "     LITERAL(\"foo.cc\")\n"
      "     LITERAL(\"foo.h\")\n"
      "   BINARY(=)\n"
      "    IDENTIFIER(dependencies)\n"
      "    LIST\n"
      "     LITERAL(\"base\")\n";
  DoParserPrintTest(input, expected);
}

TEST(Parser, FunctionWithConditional) {
  const char* input =
      "cc_test(\"foo\") {\n"
      "  sources = [\"foo.cc\"]\n"
      "  if (OS == \"mac\") {\n"
      "    sources += \"bar.cc\"\n"
      "  } else if (OS == \"win\") {\n"
      "    sources -= [\"asd.cc\", \"foo.cc\"]\n"
      "  } else {\n"
      "    dependencies += [\"bar.cc\"]\n"
      "  }\n"
      "}\n";
  const char* expected =
      "BLOCK\n"
      " FUNCTION(cc_test)\n"
      "  LIST\n"
      "   LITERAL(\"foo\")\n"
      "  BLOCK\n"
      "   BINARY(=)\n"
      "    IDENTIFIER(sources)\n"
      "    LIST\n"
      "     LITERAL(\"foo.cc\")\n"
      "   CONDITION\n"
      "    BINARY(==)\n"
      "     IDENTIFIER(OS)\n"
      "     LITERAL(\"mac\")\n"
      "    BLOCK\n"
      "     BINARY(+=)\n"
      "      IDENTIFIER(sources)\n"
      "      LITERAL(\"bar.cc\")\n"
      "    CONDITION\n"
      "     BINARY(==)\n"
      "      IDENTIFIER(OS)\n"
      "      LITERAL(\"win\")\n"
      "     BLOCK\n"
      "      BINARY(-=)\n"
      "       IDENTIFIER(sources)\n"
      "       LIST\n"
      "        LITERAL(\"asd.cc\")\n"
      "        LITERAL(\"foo.cc\")\n"
      "     BLOCK\n"
      "      BINARY(+=)\n"
      "       IDENTIFIER(dependencies)\n"
      "       LIST\n"
      "        LITERAL(\"bar.cc\")\n";
  DoParserPrintTest(input, expected);
}

TEST(Parser, NestedBlocks) {
  const char* input = "{cc_test(\"foo\") {{foo=1}{}}}";
  const char* expected =
      "BLOCK\n"
      " BLOCK\n"
      "  FUNCTION(cc_test)\n"
      "   LIST\n"
      "    LITERAL(\"foo\")\n"
      "   BLOCK\n"
      "    BLOCK\n"
      "     BINARY(=)\n"
      "      IDENTIFIER(foo)\n"
      "      LITERAL(1)\n"
      "    BLOCK\n";
  DoParserPrintTest(input, expected);
}

TEST(Parser, List) {
  const char* input = "[] a = [1,asd,] b = [1, 2+3 - foo]";
  const char* expected =
      "BLOCK\n"
      " LIST\n"
      " BINARY(=)\n"
      "  IDENTIFIER(a)\n"
      "  LIST\n"
      "   LITERAL(1)\n"
      "   IDENTIFIER(asd)\n"
      " BINARY(=)\n"
      "  IDENTIFIER(b)\n"
      "  LIST\n"
      "   LITERAL(1)\n"
      "   BINARY(+)\n"
      "    LITERAL(2)\n"
      "    BINARY(-)\n"
      "     LITERAL(3)\n"
      "     IDENTIFIER(foo)\n";
  DoParserPrintTest(input, expected);

  DoParserErrorTest("[a, 2+,]", 1, 7);
  DoParserErrorTest("[,]", 1, 2);
  DoParserErrorTest("[a,,]", 1, 4);
}

TEST(Parser, UnterminatedBlock) {
  DoParserErrorTest("hello {", 1, 7);
}

TEST(Parser, BadlyTerminatedNumber) {
  DoParserErrorTest("1234z", 1, 5);
}


text:
'use strict';

var React = require('react');
var mui = require('material-ui');
var SvgIcon = mui.SvgIcon;

var ActionViewColumn = React.createClass({
  displayName: 'ActionViewColumn',

  render: function render() {
    return React.createElement(
      SvgIcon,
      this.props,
      React.createElement('path', { d: 'M10 18h5V5h-5v13zm-6 0h5V5H4v13zM16 5v13h5V5h-5z' })
    );
  }

});

module.exports = ActionViewColumn;