text:
<?php

namespace Magento\Catalog\Model\Product\Type;

use Magento\Catalog\Model\Product;
use Magento\Customer\Api\GroupManagementInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Store\Model\Store;

/**
 * Detail type price model
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class Price
{
    /**
     * Detail price cache tag
     */
    const CACHE_TAG = 'PRODUCT_PRICE';

    /**
     * @var array
     */
    protected static $attributeCache = [];

    /**
     * Core event manager proxy
     *
     * @var \Magento\Framework\Event\ManagerInterface
     */
    protected $_eventManager;

    /**
     * Customer session
     *
     * @var \Magento\Customer\Model\Session
     */
    protected $_customerSession;

    /**
     * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
     */
    protected $_localeDate;

    /**
     * Store manager
     *
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    protected $_storeManager;

    /**
     * Rule factory
     *
     * @var \Magento\CatalogRule\Model\ResourceModel\RuleFactory
     */
    protected $_ruleFactory;

    /**
     * @var PriceCurrencyInterface
     */
    protected $priceCurrency;

    /**
     * @var GroupManagementInterface
     */
    protected $_groupManagement;

    /**
     * @var \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory
     */
    protected $tierPriceFactory;

    /**
     * @var \Magento\Framework\App\Config\ScopeConfigInterface
     */
    protected $config;

    /**
     * Price constructor.
     * @param \Magento\CatalogRule\Model\ResourceModel\RuleFactory $ruleFactory
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
     * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
     * @param \Magento\Customer\Model\Session $customerSession
     * @param \Magento\Framework\Event\ManagerInterface $eventManager
     * @param PriceCurrencyInterface $priceCurrency
     * @param GroupManagementInterface $groupManagement
     * @param \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
     *
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
     */
    public function __construct(
        \Magento\CatalogRule\Model\ResourceModel\RuleFactory $ruleFactory,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Framework\Event\ManagerInterface $eventManager,
        PriceCurrencyInterface $priceCurrency,
        GroupManagementInterface $groupManagement,
        \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory,
        \Magento\Framework\App\Config\ScopeConfigInterface $config
    ) {
        $this->_ruleFactory = $ruleFactory;
        $this->_storeManager = $storeManager;
        $this->_localeDate = $localeDate;
        $this->_customerSession = $customerSession;
        $this->_eventManager = $eventManager;
        $this->priceCurrency = $priceCurrency;
        $this->_groupManagement = $groupManagement;
        $this->tierPriceFactory = $tierPriceFactory;
        $this->config = $config;
    }

    /**
     * Default action to get price of product
     *
     * @param Product $product
     * @return float
     */
    public function getPrice($product)
    {
        return $product->getData('price');
    }

    /**
     * Get base price with apply Group, Tier, Special prises
     *
     * @param Product $product
     * @param float|null $qty
     *
     * @return float
     */
    public function getBasePrice($product, $qty = null)
    {
        $price = (float) $product->getPrice();
        return min(
            $this->_applyTierPrice($product, $qty, $price),
            $this->_applySpecialPrice($product, $price)
        );
    }

    /**
     * Retrieve product final price
     *
     * @param float|null $qty
     * @param Product $product
     * @return float
     */
    public function getFinalPrice($qty, $product)
    {
        if ($qty === null && $product->getCalculatedFinalPrice() !== null) {
            return $product->getCalculatedFinalPrice();
        }

        $finalPrice = $this->getBasePrice($product, $qty);
        $product->setFinalPrice($finalPrice);

        $this->_eventManager->dispatch('catalog_product_get_final_price', ['product' => $product, 'qty' => $qty]);

        $finalPrice = $product->getData('final_price');
        $finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
        $finalPrice = max(0, $finalPrice);
        $product->setFinalPrice($finalPrice);

        return $finalPrice;
    }

    /**
     * @param Product $product
     * @param float $productQty
     * @param Product $childProduct
     * @param float $childProductQty
     * @return float
     *
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function getChildFinalPrice($product, $productQty, $childProduct, $childProductQty)
    {
        return $this->getFinalPrice($childProductQty, $childProduct);
    }

    /**
     * Gets the 'tear_price' array from the product
     *
     * @param Product $product
     * @param string $key
     * @param bool $returnRawData
     * @return array
     */
    protected function getExistingPrices($product, $key, $returnRawData = false)
    {
        $prices = $product->getData($key);

        if ($prices === null) {
            $attribute = $product->getResource()->getAttribute($key);
            if ($attribute) {
                $attribute->getBackend()->afterLoad($product);
                $prices = $product->getData($key);
            }
        }

        if ($prices === null || !is_array($prices)) {
            return ($returnRawData ? $prices : []);
        }

        return $prices;
    }

    /**
     * Returns the website to use for group or tier prices, based on the price scope setting
     *
     * @return int|mixed
     */
    protected function getWebsiteForPriceScope()
    {
        $websiteId = 0;
        $value = $this->config->getValue('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE);
        if ($value != 0) {
            // use the website associated with the current store
            $websiteId = $this->_storeManager->getWebsite()->getId();
        }
        return $websiteId;
    }

    /**
     * Apply tier price for product if not return price that was before
     *
     * @param   Product $product
     * @param   float $qty
     * @param   float $finalPrice
     * @return  float
     */
    protected function _applyTierPrice($product, $qty, $finalPrice)
    {
        if ($qty === null) {
            return $finalPrice;
        }

        $tierPrice = $product->getTierPrice($qty);
        if (is_numeric($tierPrice)) {
            $finalPrice = min($finalPrice, $tierPrice);
        }
        return $finalPrice;
    }

    /**
     * Get product tier price by qty
     *
     * @param   float $qty
     * @param   Product $product
     * @return  float|array
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     */
    public function getTierPrice($qty, $product)
    {
        $allGroupsId = $this->getAllCustomerGroupsId();

        $prices = $this->getExistingPrices($product, 'tier_price', true);
        if ($prices === null || !is_array($prices)) {
            if ($qty !== null) {
                return $product->getPrice();
            } else {
                return [
                    [
                        'price' => $product->getPrice(),
                        'website_price' => $product->getPrice(),
                        'price_qty' => 1,
                        'cust_group' => $allGroupsId,
                    ]
                ];
            }
        }

        $custGroup = $this->_getCustomerGroupId($product);
        if ($qty) {
            $prevQty = 1;
            $prevPrice = $product->getPrice();
            $prevGroup = $allGroupsId;

            foreach ($prices as $price) {
                if ($price['cust_group'] != $custGroup && $price['cust_group'] != $allGroupsId) {
                    // tier not for current customer group nor is for all groups
                    continue;
                }
                if ($qty < $price['price_qty']) {
                    // tier is higher than product qty
                    continue;
                }
                if ($price['price_qty'] < $prevQty) {
                    // higher tier qty already found
                    continue;
                }
                if ($price['price_qty'] == $prevQty &&
                    $prevGroup != $allGroupsId &&
                    $price['cust_group'] == $allGroupsId) {
                    // found tier qty is same as current tier qty but current tier group is ALL_GROUPS
                    continue;
                }
                if ($price['website_price'] < $prevPrice) {
                    $prevPrice = $price['website_price'];
                    $prevQty = $price['price_qty'];
                    $prevGroup = $price['cust_group'];
                }
            }
            return $prevPrice;
        } else {
            $qtyCache = [];
            foreach ($prices as $priceKey => $price) {
                if ($price['cust_group'] != $custGroup && $price['cust_group'] != $allGroupsId) {
                    unset($prices[$priceKey]);
                } elseif (isset($qtyCache[$price['price_qty']])) {
                    $priceQty = $qtyCache[$price['price_qty']];
                    if ($prices[$priceQty]['website_price'] > $price['website_price']) {
                        unset($prices[$priceQty]);
                        $qtyCache[$price['price_qty']] = $priceKey;
                    } else {
                        unset($prices[$priceKey]);
                    }
                } else {
                    $qtyCache[$price['price_qty']] = $priceKey;
                }
            }
        }

        return $prices ? $prices : [];
    }

    /**
     * Gets the CUST_GROUP_ALL id
     *
     * @return int
     */
    protected function getAllCustomerGroupsId()
    {
        // ex: 32000
        return $this->_groupManagement->getAllCustomersGroup()->getId();
    }

    /**
     * Gets list of product tier prices
     *
     * @param Product $product
     * @return \Magento\Catalog\Api\Data\ProductTierPriceInterface[]
     */
    public function getTierPrices($product)
    {
        $prices = [];
        $tierPrices = $this->getExistingPrices($product, 'tier_price');
        foreach ($tierPrices as $price) {
            /** @var \Magento\Catalog\Api\Data\ProductTierPriceInterface $tierPrice */
            $tierPrice = $this->tierPriceFactory->create();
            $tierPrice->setCustomerGroupId($price['cust_group']);
            if (array_key_exists('website_price', $price)) {
                $value = $price['website_price'];
            } else {
                $value = $price['price'];
            }
            $tierPrice->setValue($value);
            $tierPrice->setQty($price['price_qty']);
            $prices[] = $tierPrice;
        }
        return $prices;
    }

    /**
     * Sets list of product tier prices
     *
     * @param Product $product
     * @param \Magento\Catalog\Api\Data\ProductTierPriceInterface[] $tierPrices
     * @return $this
     */
    public function setTierPrices($product, array $tierPrices = null)
    {
        // null array means leave everything as is
        if ($tierPrices === null) {
            return $this;
        }

        $websiteId = $this->getWebsiteForPriceScope();
        $allGroupsId = $this->getAllCustomerGroupsId();

        // build the new array of tier prices
        $prices = [];
        foreach ($tierPrices as $price) {
            $prices[] = [
                'website_id' => $websiteId,
                'cust_group' => $price->getCustomerGroupId(),
                'website_price' => $price->getValue(),
                'price' => $price->getValue(),
                'all_groups' => ($price->getCustomerGroupId() == $allGroupsId),
                'price_qty' => $price->getQty()
            ];
        }
        $product->setData('tier_price', $prices);

        return $this;
    }

    /**
     * @param Product $product
     * @return int
     */
    protected function _getCustomerGroupId($product)
    {
        if ($product->getCustomerGroupId() !== null) {
            return $product->getCustomerGroupId();
        }
        return $this->_customerSession->getCustomerGroupId();
    }

    /**
     * Apply special price for product if not return price that was before
     *
     * @param   Product $product
     * @param   float $finalPrice
     * @return  float
     */
    protected function _applySpecialPrice($product, $finalPrice)
    {
        return $this->calculateSpecialPrice(
            $finalPrice,
            $product->getSpecialPrice(),
            $product->getSpecialFromDate(),
            $product->getSpecialToDate(),
            $product->getStore()
        );
    }

    /**
     * Count how many tier prices we have for the product
     *
     * @param   Product $product
     * @return  int
     */
    public function getTierPriceCount($product)
    {
        $price = $product->getTierPrice();
        return count($price);
    }

    /**
     * Get formatted by currency tier price
     *
     * @param   float $qty
     * @param   Product $product
     * @return  array|float
     */
    public function getFormatedTierPrice($qty, $product)
    {
        $price = $product->getTierPrice($qty);
        if (is_array($price)) {
            foreach (array_keys($price) as $index) {
                $price[$index]['formated_price'] = $this->priceCurrency->convertAndFormat(
                    $price[$index]['website_price']
                );
            }
        } else {
            $price = $this->priceCurrency->format($price);
        }

        return $price;
    }

    /**
     * Get formatted by currency product price
     *
     * @param   Product $product
     * @return  array || float
     */
    public function getFormatedPrice($product)
    {
        return $this->priceCurrency->format($product->getFinalPrice());
    }

    /**
     * Apply options price
     *
     * @param Product $product
     * @param int $qty
     * @param float $finalPrice
     * @return float
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    protected function _applyOptionsPrice($product, $qty, $finalPrice)
    {
        $optionIds = $product->getCustomOption('option_ids');
        if ($optionIds) {
            $basePrice = $finalPrice;
            foreach (explode(',', $optionIds->getValue()) as $optionId) {
                if ($option = $product->getOptionById($optionId)) {
                    $confItemOption = $product->getCustomOption('option_' . $option->getId());

                    $group = $option->groupFactory($option->getType())
                        ->setOption($option)
                        ->setConfigurationItemOption($confItemOption);
                    $finalPrice += $group->getOptionPrice($confItemOption->getValue(), $basePrice);
                }
            }
        }

        return $finalPrice;
    }

    /**
     * Calculate product price based on special price data and price rules
     *
     * @param   float $basePrice
     * @param   float $specialPrice
     * @param   string $specialPriceFrom
     * @param   string $specialPriceTo
     * @param   bool|float|null $rulePrice
     * @param   mixed|null $wId
     * @param   integer|null $gId
     * @param   int|null $productId
     * @return  float
     */
    public function calculatePrice(
        $basePrice,
        $specialPrice,
        $specialPriceFrom,
        $specialPriceTo,
        $rulePrice = false,
        $wId = null,
        $gId = null,
        $productId = null
    ) {
        \Magento\Framework\Profiler::start('__PRODUCT_CALCULATE_PRICE__');
        if ($wId instanceof Store) {
            $sId = $wId->getId();
            $wId = $wId->getWebsiteId();
        } else {
            $sId = $this->_storeManager->getWebsite($wId)->getDefaultGroup()->getDefaultStoreId();
        }

        $finalPrice = $basePrice;

        $finalPrice = $this->calculateSpecialPrice(
            $finalPrice,
            $specialPrice,
            $specialPriceFrom,
            $specialPriceTo,
            $sId
        );

        if ($rulePrice === false) {
            $date = $this->_localeDate->scopeDate($sId);
            $rulePrice = $this->_ruleFactory->create()->getRulePrice($date, $wId, $gId, $productId);
        }

        if ($rulePrice !== null && $rulePrice !== false) {
            $finalPrice = min($finalPrice, $rulePrice);
        }

        $finalPrice = max($finalPrice, 0);
        \Magento\Framework\Profiler::stop('__PRODUCT_CALCULATE_PRICE__');
        return $finalPrice;
    }

    /**
     * Calculate and apply special price
     *
     * @param float $finalPrice
     * @param float $specialPrice
     * @param string $specialPriceFrom
     * @param string $specialPriceTo
     * @param int|string|Store $store
     * @return float
     */
    public function calculateSpecialPrice(
        $finalPrice,
        $specialPrice,
        $specialPriceFrom,
        $specialPriceTo,
        $store = null
    ) {
        if ($specialPrice !== null && $specialPrice != false) {
            if ($this->_localeDate->isScopeDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
                $finalPrice = min($finalPrice, $specialPrice);
            }
        }
        return $finalPrice;
    }

    /**
     * Check is tier price value fixed or percent of original price
     *
     * @return bool
     */
    public function isTierPriceFixed()
    {
        return true;
    }
}


text:
module Fog
  module Compute
    class Cloudstack

      class Real
        # Lists all available disk offerings.
        #
        # {CloudStack API Reference}[http://cloudstack.apache.org/docs/api/apidocs-4.4/root_admin/listDiskOfferings.html]
        def list_disk_offerings(*args)
          options = {}
          if args[0].is_a? Hash
            options = args[0]
            options.merge!('command' => 'listDiskOfferings')
          else
            options.merge!('command' => 'listDiskOfferings')
          end
          request(options)
        end
      end

      class Mock
        # TODO: add id, name filters and paging params
        def list_disk_offerings(options={})
          disk_offerings = self.data[:disk_offerings]
          { "listdiskofferingsresponse" => { "count"=> disk_offerings.count, "diskoffering"=> disk_offerings.values } }
        end

      end
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
using Magenic.MaqsFramework.BaseSeleniumTest;
using Magenic.MaqsFramework.Utilities.Helper;
using Magenic.MaqsFramework.Utilities.ResponseTime;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Models.WebPage;
using OpenQA.Selenium;
using System;
using System.Collections.Generic;

namespace Models
{
    /// <summary>
    /// Page object for the landing page
    /// </summary>
    public class LandingPage : MyVoteBasePageModel
    {
        /// <summary>
        /// The page URL
        /// </summary>
        private static string pageUrl = Config.GetValue("WebSiteBase") + "#/landing";

        #region Accessors

        // Twitter SSO button
        private static By twitterSignIn = By.CssSelector("img[ng-src='/Content/twitter.png']");

        // FaceBook SSO button
        private static By facebookSignIn = By.CssSelector("img[ng-src='/Content/fb.png']");

        // Twitter SSO button
        private static By microsoftSignIn= By.CssSelector("img[ng-src='/Content/ms.png']");

        // Twitter SSO button
        private static By googleSignIn = By.CssSelector("img[ng-src='/Content/google.png']");

        // Error message
        private static By errorMessage = By.CssSelector(".topbar.topbar-error");

        // Landing Menu table
        private static By menu = By.ClassName("landing-hmenu");
        #endregion

        #region Methods
        // Selenium Web Driver
       // private IWebDriver webDriver;

        /// <summary>
        /// Initializes a new instance of the LandingPage
        /// </summary>
        /// <param name="webDriver"></param>
        public LandingPage(IWebDriver webDriver) : base(webDriver)
        {
        }

        /// <summary>
        /// Open the MyVote Landing page
        /// </summary>
        public void OpenPage()
        {
            this.webDriver.Navigate().GoToUrl(pageUrl);
            this.AssertPageLoaded();
            this.webDriver.WaitForVisibleElement(menu);
        }

        /// <summary>
        /// Verify we are on the correct page
        /// </summary>
        public override void AssertPageLoaded()
        {
            Assert.IsTrue(
                this.webDriver.Url.Equals(pageUrl, System.StringComparison.CurrentCultureIgnoreCase),
                "Expected to be on '{0}', but was on '{1}' instead",
                pageUrl,
                this.webDriver.Url);
        }

        /// <summary>
        /// Click to sign in through Twitter
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public RegistrationPage SignInNewTwitter(string username, string password, ResponseTimes response = null)
        {
            SignInTwitter(username, password, response);

            return new RegistrationPage(this.webDriver);
        }

        /// <summary>
        /// Click to sign in through Twitter
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public PollsPage SignInExistingTwitter(string username, string password, ResponseTimes response = null)
        {
            SignInTwitter(username, password, response);

            return new PollsPage(this.webDriver);
        }

        /// <summary>
        /// Click to sign in through Twitter
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        private void SignInTwitter(string username, string password, ResponseTimes response = null)
        {
            //Open the twitter Login
            this.webDriver.FindElement(twitterSignIn).Click();

            // Get the current Window so you can switch back later
            string myVoteWindow = this.webDriver.CurrentWindowHandle;

            // Method To Find and Switch to new window
            SwitchWindow(myVoteWindow);

            //Login to twitter
            TwitterLogin TP = new TwitterLogin(this.webDriver);
            TP.AssertPageLoaded();

            if (response != null)
            {
                response.StartTimer("Twitter Login");
            }

            TP.EnterCredentials(username, password);

            //Switch back to the main window
            this.webDriver.SwitchTo().Window(myVoteWindow);
        }

        /// <summary>
        /// Click to sign in through Facebook
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public PollsPage SignInFacebook(string username, string password, ResponseTimes response = null)
        {
            //Open the Facebook Login
            this.webDriver.FindElement(facebookSignIn).Click();

            // Get the current Window so you can switch back later
            string myVoteWindow = this.webDriver.CurrentWindowHandle;

            // Method To Find and Switch to new window
            SwitchWindow(myVoteWindow);

            //Login to Facebook
            FacebookLogin TP = new FacebookLogin(this.webDriver);
            TP.AssertPageLoaded();

            if (response != null)
            {
                response.StartTimer("Facebook Login");
            }

            TP.EnterCredentials(username, password);

            //Switch back to the main window
            this.webDriver.SwitchTo().Window(myVoteWindow);

            return new PollsPage(this.webDriver);
        }

        /// <summary>
        /// Click to sign in through Microsoft
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public PollsPage SignInMicrosoft(string username, string password, ResponseTimes response = null)
        {
            //Open the Microsoft Login
            this.webDriver.FindElement(microsoftSignIn).Click();

            // Get the current Window so you can switch back later
            string myVoteWindow = this.webDriver.CurrentWindowHandle;

            // Method To Find and Switch to new window
            SwitchWindow(myVoteWindow);

            //Login to Microsoft
            MSLogin microsoft = new MSLogin(this.webDriver);
            microsoft.AssertPageLoaded();

            if (response != null)
            {
                response.StartTimer("Microsoft Login");
            }

            microsoft.EnterCredentials(username, password);

            //Switch back to the main window
            this.webDriver.SwitchTo().Window(myVoteWindow);

            return new PollsPage(this.webDriver);
        }

        /// <summary>
        /// Click to sign in through Google+
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public PollsPage SignInGoogle(string username, string password, ResponseTimes response = null)
        {
            //Open the Google+ Login
            this.webDriver.FindElement(googleSignIn).Click();

            // Get the current Window so you can switch back later
            string myVoteWindow = this.webDriver.CurrentWindowHandle;

            // Method To Find and Switch to new window
            SwitchWindow(myVoteWindow);

            //Login to Google+
            GoogleLogin google = new GoogleLogin(this.webDriver);

            google.AssertPageLoaded();

            if (response != null)
            {
                response.StartTimer("Google Login");
            }

            google.EnterCredentials(username, password);

            //Switch back to the main window
            this.webDriver.SwitchTo().Window(myVoteWindow);

            return new PollsPage(this.webDriver);
        }

        /// <summary>
        /// Find and switch to the new window
        /// </summary>
        /// <param name="MyVoteWindow"></param>
        public void SwitchWindow(string MyVoteWindow)
        {
            // Get new window
            IList<string> windowHandles = this.webDriver.WindowHandles;
            string ssoWindow = string.Empty;
            foreach (string w in windowHandles)
            {
                if (MyVoteWindow != w)
                {
                    ssoWindow = w;
                }
            }

            // Switch to new window
            this.webDriver.SwitchTo().Window(ssoWindow);
        }

        /// <summary>
        /// Close the sign in window without signing in
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        public void SignInBadCredentials(string username, string password, ResponseTimes response = null)
        {
            //Open the Facebook Login
            this.webDriver.FindElement(facebookSignIn).Click();

            // Get the current Window so you can switch back later
            string myVoteWindow = this.webDriver.CurrentWindowHandle;

            // Method To Find and Switch to new window
            SwitchWindow(myVoteWindow);
            this.webDriver.Close();

            //Switch back to the main window
            this.webDriver.SwitchTo().Window(myVoteWindow);
        }

        /// <summary>
        /// Find if the error message is showing
        /// </summary>
        public bool AssertFailShows()
        {
            //try catch to see if the value banner is showing
            try
            {
                this.webDriver.FindElement(errorMessage).Click();
                return true;
            }
            catch
            {
                return false;
            }
        }

            #endregion
        }
    }


text:
package com.ddiehl.android.htn.listings.comments;

import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.view.ContextMenu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;

import com.ddiehl.android.htn.R;
import com.ddiehl.android.htn.utils.ThemeUtilsKt;
import com.ddiehl.android.htn.view.ColorSwapTextView;
import com.ddiehl.android.htn.view.markdown.HtmlParser;
import com.ddiehl.timesincetextview.TimeSinceTextView;

import rxreddit.model.Comment;
import rxreddit.model.Link;

public class ThreadCommentViewHolder extends RecyclerView.ViewHolder
        implements View.OnCreateContextMenuListener {

    private final Context context;
    private final LinkCommentsView linkCommentsView;
    private final LinkCommentsPresenter linkCommentsPresenter;
    private final HtmlParser htmlParser;
    private Comment comment;

    private ColorSwapTextView authorView;
    private ViewGroup scoreViewLayout;
    private TextView scoreView;
    private TimeSinceTextView timestampView;
    private View savedView;
    private TextView bodyView;
    private TextView gildedText;
    private View controversialityIndicator;
    private View commentMetadata;

    public ThreadCommentViewHolder(View view, LinkCommentsView linkCommentsView, LinkCommentsPresenter presenter) {
        super(view);

        this.context = view.getContext();
        this.linkCommentsView = linkCommentsView;
        this.linkCommentsPresenter = presenter;
        this.htmlParser = new HtmlParser(context);

        authorView = view.findViewById(R.id.comment_author);
        scoreViewLayout = view.findViewById(R.id.comment_score_layout);
        scoreView = view.findViewById(R.id.comment_score);
        timestampView = view.findViewById(R.id.comment_timestamp);
        savedView = view.findViewById(R.id.comment_saved_icon);
        bodyView = view.findViewById(R.id.comment_body);
        gildedText = view.findViewById(R.id.comment_gilded_text_view);
        controversialityIndicator = view.findViewById(R.id.comment_controversiality_indicator);
        commentMetadata = view.findViewById(R.id.comment_metadata);

        commentMetadata.setOnClickListener(this::onClickMetadata);
        bodyView.setOnClickListener(this::onClickBody);

        this.itemView.setOnCreateContextMenuListener(this);
    }

    private void onClickMetadata(View v) {
        linkCommentsPresenter.toggleThreadVisible(comment);
    }

    private void onClickBody(View v) {
        v.showContextMenu();
    }

    public void bind(final Link link, final Comment comment, boolean showControversiality) {
        this.comment = comment;
        addPaddingViews(comment);
        showAuthor(link, comment);
        showBody(comment);
        showScore(comment);
        showTimestamp(comment);
        showEdited(comment);
        setCollapsed(comment);
        showLiked(comment);
        showSaved(comment);
        showGilded(comment);
        showControversiality(comment, showControversiality);
    }

    public void bind(final Comment comment, boolean showControversiality) {
        bind(null, comment, showControversiality);
    }

    // Add padding views to indentation_wrapper based on depth of comment
    private void addPaddingViews(Comment comment) {
        int viewMargin = (comment.getDepth() - 2)
                * (int) context.getResources().getDimension(R.dimen.comment_indentation_margin);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) itemView.getLayoutParams();
        Configuration config = context.getResources().getConfiguration();
        if (Build.VERSION.SDK_INT >= 17 && config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
            params.setMargins(0, 0, viewMargin, 0);
        } else {
            params.setMargins(viewMargin, 0, 0, 0);
        }
    }

    private void showAuthor(Link link, Comment comment) {
        String author = comment.getAuthor();
        authorView.setVisibility(View.VISIBLE);
        authorView.setText(author);
        String authorType = null;
        String distinguished = comment.getDistinguished();
        if (distinguished != null && !distinguished.equals("")) {
            authorType = distinguished;
        }
        if (link != null && author.equals(link.getAuthor())) {
            authorType = "op";
        }
        if (authorType != null) {
            switch (authorType) {
                case "op":
                    authorView.setBackgroundResource(R.drawable.author_op_bg);
                    final int opTextColor = ThemeUtilsKt.getColorFromAttr(context, R.attr.authorDecoratedTextColor);
                    authorView.setTextColor(opTextColor);
                    break;
                case "moderator":
                    authorView.setBackgroundResource(R.drawable.author_moderator_bg);
                    final int moderatorTextColor = ThemeUtilsKt.getColorFromAttr(context, R.attr.authorDecoratedTextColor);
                    authorView.setTextColor(moderatorTextColor);
                    break;
                case "admin":
                    authorView.setBackgroundResource(R.drawable.author_admin_bg);
                    final int adminTextColor = ThemeUtilsKt.getColorFromAttr(context, R.attr.authorDecoratedTextColor);
                    authorView.setTextColor(adminTextColor);
                    break;
                default:
            }
        } else {
            //noinspection deprecation
            authorView.setBackgroundDrawable(authorView.getOriginalBackground());
            final int defaultTextColor = ThemeUtilsKt.getColorFromAttr(context, R.attr.textColorSecondary);
            authorView.setTextColor(defaultTextColor);
        }
    }

    private void showBody(Comment comment) {
        bodyView.setMovementMethod(LinkMovementMethod.getInstance());
        Spanned formatted = htmlParser.convert(comment.getBodyHtml());
        bodyView.setText(formatted);
    }

    private void showScore(Comment comment) {
        String text;
        if (comment.getScore() == null) {
            text = context.getString(R.string.hidden_score_placeholder);
        } else text = String.format(context.getString(R.string.comment_score), comment.getScore());
        scoreView.setText(text);
    }

    private void showTimestamp(Comment comment) {
        timestampView.setDate(comment.getCreateUtc().longValue());
    }

    private void showEdited(Comment comment) {
        if (comment.isEdited() != null) {
            switch (comment.isEdited()) {
                case "":
                case "0":
                case "false":
                    setEdited(false);
                    break;
                default:
                    setEdited(true);
            }
        }
    }

    private void setEdited(boolean edited) {
        CharSequence text = timestampView.getText();
        timestampView.setText(edited ? text + "*" : text.toString().replace("*", ""));
    }

    private void setCollapsed(Comment comment) {
        bodyView.setVisibility(comment.isCollapsed() ? View.GONE : View.VISIBLE);
    }

    // Set background tint based on isLiked
    private void showLiked(Comment comment) {
        if (comment.getLiked() == null) {
            final int neutralTextColor = ThemeUtilsKt.getColorFromAttr(context, R.attr.textColorSecondary);
            scoreView.setTextColor(neutralTextColor);
        } else if (comment.getLiked()) {
            final int upvoteColor = ThemeUtilsKt.getColorFromAttr(context, R.attr.contentLikedColor);
            scoreView.setTextColor(upvoteColor);
        } else {
            final int downvoteColor = ThemeUtilsKt.getColorFromAttr(context, R.attr.contentDislikedColor);
            scoreView.setTextColor(downvoteColor);
        }
    }

    private void showSaved(Comment comment) {
        savedView.setVisibility(comment.isSaved() ? View.VISIBLE : View.GONE);
    }

    // Show gilding view if appropriate, else hide
    private void showGilded(Comment comment) {
        Integer gilded = comment.getGilded();
        if (gilded != null && gilded > 0) {
            gildedText.setText(String.format(context.getString(R.string.link_gilded_text), gilded));
            gildedText.setVisibility(View.VISIBLE);
        } else {
            gildedText.setVisibility(View.GONE);
        }
    }

    private void showControversiality(Comment comment, boolean showControversiality) {
        controversialityIndicator.setVisibility(showControversiality
                ? (comment.getControversiality() > 0 ? View.VISIBLE : View.GONE)
                : View.GONE);
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
        linkCommentsPresenter.onContextMenuShownForComment(comment);
        CommentMenuHelper.showCommentContextMenu((FragmentActivity) view.getContext(), menu, comment);
    }
}


text:
require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-plugin/check/cli'
require 'json'
require 'rest-client'

class CheckRabbitMQNode < Sensu::Plugin::Check::CLI
  option :host,
         description: 'RabbitMQ host',
         short: '-w',
         long: '--host HOST',
         default: 'localhost'

  option :username,
         description: 'RabbitMQ username',
         short: '-u',
         long: '--username USERNAME',
         default: 'guest'

  option :password,
         description: 'RabbitMQ password',
         short: '-p',
         long: '--password PASSWORD',
         default: 'guest'

  option :port,
         description: 'RabbitMQ API port',
         short: '-P',
         long: '--port PORT',
         default: '15672'

  option :memwarn,
         description: 'Warning % of mem usage vs high watermark',
         short: '-m',
         long: '--mwarn PERCENT',
         proc: proc(&:to_f),
         default: 80

  option :memcrit,
         description: 'Critical % of mem usage vs high watermark',
         short: '-c',
         long: '--mcrit PERCENT',
         proc: proc(&:to_f),
         default: 90

  option :fdwarn,
         description: 'Warning % of file descriptor usage vs high watermark',
         short: '-m',
         long: '--mwarn PERCENT',
         proc: proc(&:to_f),
         default: 80

  option :fdcrit,
         description: 'Critical % of file descriptor usage vs high watermark',
         short: '-c',
         long: '--mcrit PERCENT',
         proc: proc(&:to_f),
         default: 90

  option :socketwarn,
         description: 'Warning % of socket usage vs high watermark',
         short: '-m',
         long: '--mwarn PERCENT',
         proc: proc(&:to_f),
         default: 80

  option :socketcrit,
         description: 'Critical % of socket usage vs high watermark',
         short: '-c',
         long: '--mcrit PERCENT',
         proc: proc(&:to_f),
         default: 90

  option :watchalarms,
         description: 'Sound critical if one or more alarms are triggered',
         short: '-a BOOLEAN',
         long: '--alarms BOOLEAN',
         default: 'true'

  def run
    res = node_healthy?

    if res['status'] == 'ok'
      ok res['message']
    elsif res['status'] == 'warning'
      warning res['message']
    elsif res['status'] == 'critical'
      critical res['message']
    else
      unknown res['message']
    end
  end

  def node_healthy?
    host     = config[:host]
    port     = config[:port]
    username = config[:username]
    password = config[:password]

    begin
      resource = RestClient::Resource.new "http://#{host}:#{port}/api/nodes", username, password
      # Parse our json data
      nodeinfo = JSON.parse(resource.get)[0]

      # Determine % memory consumed
      pmem = sprintf('%.2f', nodeinfo['mem_used'].fdiv(nodeinfo['mem_limit']) * 100)
      # Determine % sockets consumed
      psocket = sprintf('%.2f', nodeinfo['sockets_used'].fdiv(nodeinfo['sockets_total']) * 100)
      # Determine % file descriptors consumed
      pfd = sprintf('%.2f', nodeinfo['fd_used'].fdiv(nodeinfo['fd_total']) * 100)

      # build status and message
      status = 'ok'
      message = 'Server is healthy'

      # criticals
      if pmem.to_f >= config[:memcrit]
        message = "Memory usage is critical: #{pmem}%"
        status = 'critical'
      elsif psocket.to_f >= config[:socketcrit]
        message = "Socket usage is critical: #{psocket}%"
        status = 'critical'
      elsif pfd.to_f >= config[:fdcrit]
        message = "Socket usage is critical: #{pfd}%"
        status = 'critical'
      # warnings
      elsif pmem.to_f >= config[:memwarn]
        message = "Memory usage is at warning: #{pmem}%"
        status = 'warning'
      elsif psocket.to_f >= config[:socketwarn]
        message = "Socket usage is at warning: #{psocket}%"
        status = 'warning'
      elsif pfd.to_f >= config[:fdwarn]
        message = "Socket usage is at warning: #{pfd}%"
        status = 'warning'
      end

      # If we are set to watch alarms then watch those and set status and messages accordingly
      if config[:watchalarms] == 'true'
        if nodeinfo['mem_alarm'] == true
          status = 'critical'
          message += ' Memory Alarm ON'
        end

        if nodeinfo['disk_free_alarm'] == true
          status = 'critical'
          message += ' Disk Alarm ON'
        end
      end

      { 'status' => status, 'message' => message }
    rescue Errno::ECONNREFUSED => e
      { 'status' => 'critical', 'message' => e.message }
    rescue => e
      { 'status' => 'unknown', 'message' => e.message }
    end
  end
end


text:
var valArray = [ 'inches',
'centimeters',
'ounces',
'milliliters',
'miles',
'kilometers',
'pounds',
'kilograms',
'standard shit-tons',
'metric shit-tons'];

function buttonHandler(e) {
  var targetEl = e.target;
  e.preventDefault();

  switch (e.target.id) {
  case 'convert-button':
    converter(document.getElementById('enter-number').value, valArray.indexOf(document.getElementById('select-conv').value));
    break;
  case 'clear-conv':
    document.getElementById('post-results').innerHTML = '';
    break;
  }
};

document.getElementById('convert-button').addEventListener('click', buttonHandler, false);
document.getElementById('clear-conv').addEventListener('click', buttonHandler, false);

var conversionNumbers = [
  2.54, // inches to cm
  .394, // cm to inches
  29.574, //fluid oz to ml
  0.0338135, //ml to fl
  1.6, //miles to km
  .625, //km to miles
  .455, // pounds to kg
  2.2, // kg to pounds
  0.907185,//std shit tone
  1.10231//metric shit ton
];

var userInput = document.getElementById('enter-number').value;
var post = document.getElementById('post-results');

function converter(userInput, rateIndex){
  'use strict';
  console.log('rate: ' + rateIndex + 'user Input :' + userInput);
  var output = conversionNumbers[rateIndex] * userInput;
  console.log(userInput + ' ' + valArray[rateIndex] + ' ' + output);
  var li = document.createElement('li');

  //1 inch equals 2.540 centimeters"
  var myPluralEnding = rateIndex === 0 ? 2 : 1; // drop two characters for convertFrom Units if rateIndex is 0 (inches)
  console.log('convert from: ' + myPluralEnding);
  var convertFromString = userInput <= 1 ? valArray[rateIndex].substr(0, valArray[rateIndex].length - myPluralEnding) : valArray[rateIndex];

  myPluralEnding = (rateIndex % 2 === 0 ? rateIndex + 1 : rateIndex - 1) === 0 ? 2 : 1;
  console.log('convert to: ' + myPluralEnding);//drop 2 characters from convertTo Units if conerting to previous item in array
  var convertToString = output <= 1 ? valArray[(rateIndex % 2 === 0) ? rateIndex + 1 : rateIndex - 1].substr(0, valArray[(rateIndex % 2 === 0) ? rateIndex + 1 : rateIndex - 1].length - myPluralEnding) : valArray[(rateIndex % 2 === 0) ? rateIndex + 1 : rateIndex - 1];

  li.textContent = userInput + ' ' + convertFromString + ' equals ' + output.toFixed(3) + ' ' + convertToString;
  post.appendChild(li);
}


text:
#include <ntddk.h>
#include <ntstrsafe.h>
#include <stdlib.h>
#include <xen.h>
#include <util.h>

#include "gnttab.h"
#include "fdo.h"
#include "range_set.h"
#include "dbg_print.h"
#include "assert.h"

#define GNTTAB_MAXIMUM_FRAME_COUNT  32
#define GNTTAB_ENTRY_PER_FRAME      (PAGE_SIZE / sizeof (grant_entry_v1_t))

// Xen requires that we avoid the first 8 entries of the table and
// we also reserve extra entries for the crash kernel
#define GNTTAB_RESERVED_ENTRY_COUNT 32

#define GNTTAB_DESCRIPTOR_MAGIC 'DTNG'

#define MAXNAMELEN  128

struct _XENBUS_GNTTAB_CACHE {
    PXENBUS_GNTTAB_CONTEXT  Context;
    CHAR                    Name[MAXNAMELEN];
    VOID                    (*AcquireLock)(PVOID);
    VOID                    (*ReleaseLock)(PVOID);
    PVOID                   Argument;
    PXENBUS_CACHE           Cache;
};

struct _XENBUS_GNTTAB_DESCRIPTOR {
    ULONG               Magic;
    ULONG               Reference;
    grant_entry_v1_t    Entry;
};

struct _XENBUS_GNTTAB_CONTEXT {
    LONG                        References;
    PFN_NUMBER                  Pfn;
    LONG                        FrameIndex;
    grant_entry_v1_t            *Entry;
    PXENBUS_RANGE_SET           RangeSet;
    PXENBUS_CACHE_INTERFACE     CacheInterface;
    PXENBUS_SUSPEND_INTERFACE   SuspendInterface;
    PXENBUS_SUSPEND_CALLBACK    SuspendCallbackEarly;
    PXENBUS_DEBUG_INTERFACE     DebugInterface;
    PXENBUS_DEBUG_CALLBACK      DebugCallback;
};

#define GNTTAB_TAG  'TTNG'

static FORCEINLINE PVOID
__GnttabAllocate(
    IN  ULONG   Length
    )
{
    return __AllocateNonPagedPoolWithTag(Length, GNTTAB_TAG);
}

static FORCEINLINE VOID
__GnttabFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, GNTTAB_TAG);
}

static FORCEINLINE NTSTATUS
__GnttabExpand(
    IN  PXENBUS_GNTTAB_CONTEXT  Context
    )
{
    LONG                        FrameIndex;
    PFN_NUMBER                  Pfn;
    LONGLONG                    Start;
    LONGLONG                    End;
    NTSTATUS                    status;

    FrameIndex = InterlockedIncrement(&Context->FrameIndex);

    status = STATUS_INSUFFICIENT_RESOURCES;
    ASSERT3U(FrameIndex, <=, GNTTAB_MAXIMUM_FRAME_COUNT);
    if (FrameIndex == GNTTAB_MAXIMUM_FRAME_COUNT)
        goto fail1;

    Pfn = Context->Pfn + FrameIndex;

    status = MemoryAddToPhysmap(Pfn,
                                XENMAPSPACE_grant_table,
                                FrameIndex);
    ASSERT(NT_SUCCESS(status));

    Start = __max(GNTTAB_RESERVED_ENTRY_COUNT, FrameIndex * GNTTAB_ENTRY_PER_FRAME);
    End = ((FrameIndex + 1) * GNTTAB_ENTRY_PER_FRAME) - 1;

    Info("adding refrences [%08llx - %08llx]\n", Start, End);

    RangeSetPut(Context->RangeSet, Start, End);

    return STATUS_SUCCESS;

fail1:
    Error("fail1 (%08x)\n", status);

    return status;
}

static FORCEINLINE VOID
__GnttabShrink(
    IN  PXENBUS_GNTTAB_CONTEXT  Context
    )
{
    LONGLONG                    Entry;

    for (Entry = GNTTAB_RESERVED_ENTRY_COUNT;
         Entry < (LONGLONG)((Context->FrameIndex + 1) * GNTTAB_ENTRY_PER_FRAME);
         Entry++) {
        NTSTATUS    status;

        status = RangeSetGet(Context->RangeSet, Entry);
        ASSERT(NT_SUCCESS(status));
    }

    Context->FrameIndex = -1;
}

static NTSTATUS
GnttabDescriptorCtor(
    IN  PVOID                   Argument,
    IN  PVOID                   Object
    )
{
    PXENBUS_GNTTAB_CACHE        Cache = Argument;
    PXENBUS_GNTTAB_CONTEXT      Context = Cache->Context;
    PXENBUS_GNTTAB_DESCRIPTOR   Descriptor = Object;
    LONGLONG                    Reference;
    NTSTATUS                    status;

    if (!RangeSetIsEmpty(Context->RangeSet))
        goto done;

    status = __GnttabExpand(Context);
    if (!NT_SUCCESS(status))
        goto fail1;

done:
    status = RangeSetPop(Context->RangeSet, &Reference);
    if (!NT_SUCCESS(status))
        goto fail2;

    Descriptor->Magic = GNTTAB_DESCRIPTOR_MAGIC;
    Descriptor->Reference = (ULONG)Reference;

    return STATUS_SUCCESS;

fail2:
    Error("fail2\n");

fail1:
    Error("fail1 (%08x)\n", status);

    return status;
}

static VOID
GnttabDescriptorDtor(
    IN  PVOID                   Argument,
    IN  PVOID                   Object
    )
{
    PXENBUS_GNTTAB_CACHE        Cache = Argument;
    PXENBUS_GNTTAB_CONTEXT      Context = Cache->Context;
    PXENBUS_GNTTAB_DESCRIPTOR   Descriptor = Object;
    NTSTATUS                    status;

    status = RangeSetPut(Context->RangeSet,
                         (LONGLONG)Descriptor->Reference,
                         (LONGLONG)Descriptor->Reference);
    ASSERT(NT_SUCCESS(status));
}

static VOID
GnttabAcquireLock(
    IN  PVOID                   Argument
    )
{
    PXENBUS_GNTTAB_CACHE        Cache = Argument;

    Cache->AcquireLock(Cache->Argument);
}

static VOID
GnttabReleaseLock(
    IN  PVOID                   Argument
    )
{
    PXENBUS_GNTTAB_CACHE        Cache = Argument;

    Cache->ReleaseLock(Cache->Argument);
}

static NTSTATUS
GnttabCreateCache(
    IN  PXENBUS_GNTTAB_CONTEXT  Context,
    IN  const CHAR              *Name,
    IN  ULONG                   Reservation,
    IN  VOID                    (*AcquireLock)(PVOID),
    IN  VOID                    (*ReleaseLock)(PVOID),
    IN  PVOID                   Argument,
    OUT PXENBUS_GNTTAB_CACHE    *Cache
    )
{
    NTSTATUS                    status;

    *Cache = __GnttabAllocate(sizeof (XENBUS_GNTTAB_CACHE));

    status = STATUS_NO_MEMORY;
    if (*Cache == NULL)
        goto fail1;

    (*Cache)->Context = Context;

    status = RtlStringCbPrintfA((*Cache)->Name,
                                sizeof ((*Cache)->Name),
                                "%s_gnttab",
                                Name);
    if (!NT_SUCCESS(status))
        goto fail2;

    (*Cache)->AcquireLock = AcquireLock;
    (*Cache)->ReleaseLock = ReleaseLock;
    (*Cache)->Argument = Argument;

    status = CACHE(Create,
                   Context->CacheInterface,
                   (*Cache)->Name,
                   sizeof (XENBUS_GNTTAB_DESCRIPTOR),
                   Reservation,
                   GnttabDescriptorCtor,
                   GnttabDescriptorDtor,
                   GnttabAcquireLock,
                   GnttabReleaseLock,
                   *Cache,
                   &(*Cache)->Cache);
    if (!NT_SUCCESS(status))
        goto fail3;

    return STATUS_SUCCESS;

fail3:
    Error("fail3\n");

    (*Cache)->Argument = NULL;
    (*Cache)->ReleaseLock = NULL;
    (*Cache)->AcquireLock = NULL;

    RtlZeroMemory((*Cache)->Name, sizeof ((*Cache)->Name));

fail2:
    Error("fail2\n");

    (*Cache)->Context = NULL;

    ASSERT(IsZeroMemory(*Cache, sizeof (XENBUS_GNTTAB_CACHE)));
    __GnttabFree(*Cache);

fail1:
    Error("fail1 (%08x)\n", status);

    return status;
}

static VOID
GnttabDestroyCache(
    IN  PXENBUS_GNTTAB_CONTEXT  Context,
    IN  PXENBUS_GNTTAB_CACHE    Cache
    )
{
    CACHE(Destroy,
          Context->CacheInterface,
          Cache->Cache);
    Cache->Cache = NULL;

    Cache->Argument = NULL;
    Cache->ReleaseLock = NULL;
    Cache->AcquireLock = NULL;

    RtlZeroMemory(Cache->Name, sizeof (Cache->Name));

    Cache->Context = NULL;

    ASSERT(IsZeroMemory(Cache, sizeof (XENBUS_GNTTAB_CACHE)));
    __GnttabFree(Cache);
}

static NTSTATUS
GnttabPermitForeignAccess(
    IN  PXENBUS_GNTTAB_CONTEXT      Context,
    IN  PXENBUS_GNTTAB_CACHE        Cache,
    IN  BOOLEAN                     Locked,
    IN  USHORT                      Domain,
    IN  PFN_NUMBER                  Pfn,
    IN  BOOLEAN                     ReadOnly,
    OUT PXENBUS_GNTTAB_DESCRIPTOR   *Descriptor
    )
{
    grant_entry_v1_t                *Entry;
    NTSTATUS                        status;

    *Descriptor = CACHE(Get,
                        Context->CacheInterface,
                        Cache->Cache,
                        Locked);

    status = STATUS_INSUFFICIENT_RESOURCES;
    if (*Descriptor == NULL)
        goto fail1;

    (*Descriptor)->Entry.flags = (ReadOnly) ? GTF_readonly : 0;
    (*Descriptor)->Entry.domid = Domain;

    (*Descriptor)->Entry.frame = (uint32_t)Pfn;
    ASSERT3U((*Descriptor)->Entry.frame, ==, Pfn);

    Entry = &Context->Entry[(*Descriptor)->Reference];

    *Entry = (*Descriptor)->Entry;
    KeMemoryBarrier();

    Entry->flags |= GTF_permit_access;
    KeMemoryBarrier();

    return STATUS_SUCCESS;

fail1:
    Error("fail1 (%08x)\n", status);

    return status;
}

static NTSTATUS
GnttabRevokeForeignAccess(
    IN  PXENBUS_GNTTAB_CONTEXT      Context,
    IN  PXENBUS_GNTTAB_CACHE        Cache,
    IN  BOOLEAN                     Locked,
    IN  PXENBUS_GNTTAB_DESCRIPTOR   Descriptor
    )
{
    grant_entry_v1_t                *Entry;
    volatile SHORT                  *Flags;
    ULONG                           Attempt;
    NTSTATUS                        status;

    ASSERT3U(Descriptor->Magic, ==, GNTTAB_DESCRIPTOR_MAGIC);
    ASSERT3U(Descriptor->Reference, >=, GNTTAB_RESERVED_ENTRY_COUNT);
    ASSERT3U(Descriptor->Reference, <, (Context->FrameIndex + 1) * GNTTAB_ENTRY_PER_FRAME);

    Entry = &Context->Entry[Descriptor->Reference];
    Flags = (volatile SHORT *)&Entry->flags;

    Attempt = 0;
    while (Attempt++ < 100) {
        uint16_t    Old;
        uint16_t    New;

        Old = *Flags;
        Old &= ~(GTF_reading | GTF_writing);

        New = Old & ~GTF_permit_access;

        if (InterlockedCompareExchange16(Flags, New, Old) == Old)
            break;

        SchedYield();
    }

    status = STATUS_UNSUCCESSFUL;
    if (Attempt == 100)
        goto fail1;

    RtlZeroMemory(Entry, sizeof (grant_entry_v1_t));
    RtlZeroMemory(&Descriptor->Entry, sizeof (grant_entry_v1_t));

    CACHE(Put,
          Context->CacheInterface,
          Cache->Cache,
          Descriptor,
          Locked);

    return STATUS_SUCCESS;

fail1:
    Error("fail1 (%08x)\n", status);

    return status;
}

static ULONG
GnttabReference(
    IN  PXENBUS_GNTTAB_CONTEXT      Context,
    IN  PXENBUS_GNTTAB_DESCRIPTOR   Descriptor
    )
{
    UNREFERENCED_PARAMETER(Context);

    ASSERT3U(Descriptor->Magic, ==, GNTTAB_DESCRIPTOR_MAGIC);

    return (ULONG)Descriptor->Reference;
}

static VOID
GnttabAcquire(
    IN  PXENBUS_GNTTAB_CONTEXT  Context
    )
{
    InterlockedIncrement(&Context->References);
}

static VOID
GnttabRelease(
    IN  PXENBUS_GNTTAB_CONTEXT  Context
    )
{
    ASSERT(Context->References != 0);
    InterlockedDecrement(&Context->References);
}

#define GNTTAB_OPERATION(_Type, _Name, _Arguments) \
        Gnttab ## _Name,

static XENBUS_GNTTAB_OPERATIONS  Operations = {
    DEFINE_GNTTAB_OPERATIONS
};

#undef GNTTAB_OPERATION

static FORCEINLINE VOID
__GnttabMap(
    IN  PXENBUS_GNTTAB_CONTEXT  Context
    )
{
    LONG                        Index;
    PFN_NUMBER                  Pfn;
    NTSTATUS                    status;

    Pfn = Context->Pfn;

    for (Index = 0; Index <= Context->FrameIndex; Index++) {
        status = MemoryAddToPhysmap(Pfn,
                                    XENMAPSPACE_grant_table,
                                    Index);
        ASSERT(NT_SUCCESS(status));

        Pfn++;
    }
}

static FORCEINLINE VOID
__GnttabUnmap(
    IN  PXENBUS_GNTTAB_CONTEXT  Context
    )
{
    ASSERT3S(Context->FrameIndex, ==, -1);

    // Not clear what to do here
}

static VOID
GnttabSuspendCallbackEarly(
    IN  PVOID               Argument
    )
{
    PXENBUS_GNTTAB_CONTEXT  Context = Argument;

    __GnttabMap(Context);
}

static VOID
GnttabDebugCallback(
    IN  PVOID               Argument,
    IN  BOOLEAN             Crashing
    )
{
    PXENBUS_GNTTAB_CONTEXT  Context = Argument;

    UNREFERENCED_PARAMETER(Crashing);

    DEBUG(Printf,
          Context->DebugInterface,
          Context->DebugCallback,
          "Pfn = %p\n",
          (PVOID)Context->Pfn);

    DEBUG(Printf,
          Context->DebugInterface,
          Context->DebugCallback,
          "FrameIndex = %d\n",
          Context->FrameIndex);
}

NTSTATUS
GnttabInitialize(
    IN  PXENBUS_FDO                 Fdo,
    OUT PXENBUS_GNTTAB_INTERFACE    Interface
    )
{
    PXENBUS_RESOURCE                Memory;
    PHYSICAL_ADDRESS                Address;
    PXENBUS_GNTTAB_CONTEXT          Context;
    NTSTATUS                        status;

    Trace("====>\n");

    Context = __GnttabAllocate(sizeof (XENBUS_GNTTAB_CONTEXT));

    status = STATUS_NO_MEMORY;
    if (Context == NULL)
        goto fail1;

    Memory = FdoGetResource(Fdo, MEMORY_RESOURCE);
    Context->Pfn = (PFN_NUMBER)(Memory->Translated.u.Memory.Start.QuadPart >> PAGE_SHIFT);
    Context->FrameIndex = -1;

    __GnttabMap(Context);

    Memory->Translated.u.Memory.Start.QuadPart += (GNTTAB_MAXIMUM_FRAME_COUNT * PAGE_SIZE);

    ASSERT3U(Memory->Translated.u.Memory.Length, >=, (GNTTAB_MAXIMUM_FRAME_COUNT * PAGE_SIZE));
    Memory->Translated.u.Memory.Length -= (GNTTAB_MAXIMUM_FRAME_COUNT * PAGE_SIZE);

    Address.QuadPart = (ULONGLONG)Context->Pfn << PAGE_SHIFT;
    Context->Entry = (grant_entry_v1_t *)MmMapIoSpace(Address,
                                                      GNTTAB_MAXIMUM_FRAME_COUNT * PAGE_SIZE,
                                                      MmCached);
    status = STATUS_UNSUCCESSFUL;
    if (Context->Entry == NULL)
        goto fail2;

    Info("grant_entry_v1_t *: %p\n", Context->Entry);

    status = RangeSetInitialize(&Context->RangeSet);
    if (!NT_SUCCESS(status))
        goto fail3;

    Context->CacheInterface = FdoGetCacheInterface(Fdo);

    CACHE(Acquire, Context->CacheInterface);

    Context->SuspendInterface = FdoGetSuspendInterface(Fdo);

    SUSPEND(Acquire, Context->SuspendInterface);

    status = SUSPEND(Register,
                     Context->SuspendInterface,
                     SUSPEND_CALLBACK_EARLY,
                     GnttabSuspendCallbackEarly,
                     Context,
                     &Context->SuspendCallbackEarly);
    if (!NT_SUCCESS(status))
        goto fail4;

    Context->DebugInterface = FdoGetDebugInterface(Fdo);

    DEBUG(Acquire, Context->DebugInterface);

    status = DEBUG(Register,
                   Context->DebugInterface,
                   __MODULE__ "|GNTTAB",
                   GnttabDebugCallback,
                   Context,
                   &Context->DebugCallback);
    if (!NT_SUCCESS(status))
        goto fail5;

    Interface->Context = Context;
    Interface->Operations = &Operations;

    Trace("<====\n");

    return STATUS_SUCCESS;

fail5:
    Error("fail5\n");

    DEBUG(Release, Context->DebugInterface);
    Context->DebugInterface = NULL;

    SUSPEND(Deregister,
            Context->SuspendInterface,
            Context->SuspendCallbackEarly);
    Context->SuspendCallbackEarly = NULL;

fail4:
    Error("fail4\n");

    SUSPEND(Release, Context->SuspendInterface);
    Context->SuspendInterface = NULL;

    CACHE(Release, Context->CacheInterface);
    Context->CacheInterface = NULL;

    RangeSetTeardown(Context->RangeSet);

fail3:
    Error("fail3\n");

    Context->Entry = NULL;

fail2:
    Error("fail2\n");

    __GnttabUnmap(Context);

    ASSERT3S(Context->FrameIndex, ==, -1);
    Context->FrameIndex = 0;
    Context->Pfn = 0;

    ASSERT(IsZeroMemory(Context, sizeof (XENBUS_GNTTAB_CONTEXT)));
    __GnttabFree(Context);

fail1:
    Error("fail1 (%08x)\n", status);

    RtlZeroMemory(Interface, sizeof (XENBUS_GNTTAB_INTERFACE));

    return status;
}

VOID
GnttabTeardown(
    IN OUT  PXENBUS_GNTTAB_INTERFACE    Interface
    )
{
    PXENBUS_GNTTAB_CONTEXT              Context = Interface->Context;

    Trace("====>\n");

    DEBUG(Deregister,
          Context->DebugInterface,
          Context->DebugCallback);
    Context->DebugCallback = NULL;

    DEBUG(Release, Context->DebugInterface);
    Context->DebugInterface = NULL;

    SUSPEND(Deregister,
            Context->SuspendInterface,
            Context->SuspendCallbackEarly);
    Context->SuspendCallbackEarly = NULL;

    SUSPEND(Release, Context->SuspendInterface);
    Context->SuspendInterface = NULL;

    CACHE(Release, Context->CacheInterface);
    Context->CacheInterface = NULL;

    __GnttabShrink(Context);
    RangeSetTeardown(Context->RangeSet);

    Context->Entry = NULL;

    __GnttabUnmap(Context);

    ASSERT3S(Context->FrameIndex, ==, -1);
    Context->FrameIndex = 0;
    Context->Pfn = 0;

    ASSERT(IsZeroMemory(Context, sizeof (XENBUS_GNTTAB_CONTEXT)));
    __GnttabFree(Context);

    RtlZeroMemory(Interface, sizeof (XENBUS_GNTTAB_INTERFACE));

    Trace("<====\n");
}


text:
class PayoneConnect
  VERSION = "0.3.2"
end


text:
#ifndef __SIMULATION_H__
#define __SIMULATION_H__

#include "genekit.h"

typedef float(*gk_fitness_function)(gk_chromosome *);
typedef void(*gk_log_function)(gk_population *, int);

gk_fitness_function gk_simulation_fitness(gk_simulation *);
gk_log_function gk_simulation_log(gk_simulation *);

void gk_simulation_set_population_size(gk_simulation *, int);
void gk_simulation_set_max_depth(gk_simulation *, int);
void gk_simulation_set_fitness(gk_simulation *, gk_fitness_function);

int gk_simulation_get_population_size(gk_simulation *);
int gk_simulation_get_max_depth(gk_simulation *);

gk_simulation *gk_simulation_alloc();
void gk_simulation_free(gk_simulation *);

int gk_simulation_get_max_generations(gk_simulation *sim);
void gk_simulation_set_max_generations(gk_simulation *sim, int max_generations);

#endif


text:
require 'spec_helper'

RSpec.describe FifthedSim::Actor do
  context "with a semi-standard peasant" do
    subject do
      described_class.define "Peasant" do
        base_ac 10
        stats do
          str 10
          dex 10 do
            mod_bonus 1
            save_mod_bonus 2
          end
          wis 10
          cha 10
          con 10
          int 10
        end
        attack "club" do
          to_hit 2
          damage do
            bludgeoning 1.d(4)
          end
        end
      end
    end
    it "works" do
      expect{subject}.to_not raise_error
    end
  end
end


text:
FOUNDATION_EXPORT double Pods_Top_CompaniesVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_Top_CompaniesVersionString[];


text:
using System;
using System.Linq;
using System.Security.Cryptography;

namespace Apollo.Utilities
{
    public interface IPasswordHasher
    {
        string GenerateHash(string password);
        bool CheckHash(string hash, string password);
    }

    public class PasswordHasher : IPasswordHasher
    {
        private readonly IBase64Converter base64Converter;
        private const int SaltByteSize = 64;
        private const int HashByteSize = 128;
        private const int HasingIterationsCount = 4242;

        public PasswordHasher()
        {
            this.base64Converter = new Base64Converter();
        }

        public string GenerateHash(string password)
        {
            var salt = GenerateSalt();
            var hash = ComputeHash(password, salt);
            return hash;
        }

        public bool CheckHash(string hash, string password)
        {
            var hashBytes = this.base64Converter.Decode(hash);
            var salt = ExtractSalt(hashBytes);
            var checkHash = ComputeHash(password, salt);
            return hash == checkHash;
        }

        private static byte[] ExtractSalt(byte[] hashBytes)
        {
            var salt = new byte[SaltByteSize];
            Array.Copy(hashBytes, 0, salt, 0, SaltByteSize);
            return salt;
        }

        private static byte[] GenerateSalt()
        {
            using (var saltGenerator = RandomNumberGenerator.Create())
            {
                var salt = new byte[SaltByteSize];
                saltGenerator.GetBytes(salt);
                return salt;
            }
        }

        private string ComputeHash(string password, byte[] salt)
        {
            using (var hashGenerator = new Rfc2898DeriveBytes(password, salt))
            {
                hashGenerator.IterationCount = HasingIterationsCount;
                var hashed = hashGenerator.GetBytes(HashByteSize);
                var fullarray = salt.Concat(hashed);
                return this.base64Converter.Encode(fullarray.ToArray());
            }
        }
    }
}


text:
namespace fplbase {

/// @file
/// @addtogroup fplbase_texture_atlas
/// @{
using mathfu::vec4;

class Texture;

/// @class TextureAtlas
/// @brief Texture coordinate dictionary.
///
/// A TextureAtlas supports sprite sheets by containing one texture and a list
/// of subtexture bounding boxes, which can also be indexed by name using the
/// index_map. Subtexture bounding boxes are returned in normalized texture
/// coordinates, and take the form (u, v, width, height).
///
/// @warning This is will very likely be refactored.
class TextureAtlas : public Asset {
 public:
  TextureAtlas() : atlas_texture_(nullptr) {}
  ~TextureAtlas() { Delete(); }

  /// @brief Delete the texture associated with this atlas.
  void Delete() {
    atlas_texture_->Delete();
    atlas_texture_ = nullptr;
  }

  /// @brief Get the bounds of a subtexture associated with name.
  ///
  /// @param name Name of the subtexture to lookup.
  /// @returns Bounds of the subtexture or nullptr if the specified name isn't
  /// found.
  const vec4 *GetBounds(const std::string &name) {
    auto index_iter = index_map_.find(name);
    if (index_iter != index_map_.end()) {
      return &subtexture_bounds_[index_iter->second];
    }
    return nullptr;
  }

  /// @brief Get the texture associated with this atlas.
  /// @return Pointer to the texture associated with this atlas.
  const Texture *atlas_texture() const { return atlas_texture_; }
  /// @brief Get the texture associated with this atlas.
  /// @return Pointer to the texture associated with this atlas.
  Texture *atlas_texture() { return atlas_texture_; }
  /// @brief Set the texture associated with this atlas.
  void set_atlas_texture(Texture *atlas_texture) {
    atlas_texture_ = atlas_texture;
  }

  /// @brief Get a vector of the bounds of each subtexture in this atlas.
  ///
  /// Each element of the vector consists of (offsetx, offsety, sizex, sizey)
  /// where offsetx / offsety are coordinates relative to the underlying
  /// atlased texture and sizex / sizey are the dimensions of the subtexture.
  ///
  /// @returns Vector of subtexture bounds.
  const std::vector<vec4> &subtexture_bounds() const {
    return subtexture_bounds_;
  }

  /// @brief Get a vector of the bounds of each subtexture in this atlas.
  ///
  /// Each element of the vector consists of (offsetx, offsety, sizex, sizey)
  /// where offsetx / offsety are coordinates relative to the underlying
  /// atlased texture and sizex / sizey are the dimensions of the subtexture.
  ///
  /// @returns Vector of subtexture bounds.
  std::vector<vec4> &subtexture_bounds() { return subtexture_bounds_; }

  /// @brief Get a map of subtexture names to subtexture offsets.
  ///
  /// Each entry in the map can be used to lookup the subtexture bounds in
  /// the vector returned by @ref subtexture_bounds().
  ///
  /// @return A map of subtexture names to indices in vector returned by
  /// @ref subtexture_bounds().
  const std::map<std::string, size_t> &index_map() const { return index_map_; }

  /// @brief Get a map of subtexture names to subtexture offsets.
  ///
  /// Each entry in the map can be used to lookup the subtexture bounds in
  /// the vector returned by @ref subtexture_bounds().
  ///
  /// @return A map of subtexture names to indices in vector returned by
  /// @ref subtexture_bounds().
  std::map<std::string, size_t> &index_map() { return index_map_; }

  /// @brief Load a texture atlas file. Used by the more convenient AssetManager
  /// interface, but can be used without it.
  static TextureAtlas *LoadTextureAtlas(const char *filename,
                                        TextureFormat format,
                                        TextureFlags flags,
                                        const TextureLoaderFn &tlf);
 private:
  // Texture being used by this atlas.
  Texture *atlas_texture_;
  // List of bounds (offsetx, offsety, sizex, sizey) of each subtexture.
  std::vector<vec4> subtexture_bounds_;
  // Map of subtexture names to indices into subtexture_bounds_.
  std::map<std::string, size_t> index_map_;
};

/// @}
}  // namespace fplbase

#endif  // FPLBASE_TEXTURE_ATLAS_H


text:
/* pkcs11f.h include file for PKCS #11. */
/* $Revision: 1.4 $ */

/* License to copy and use this software is granted provided that it is
 * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface
 * (Cryptoki)" in all material mentioning or referencing this software.

 * License is also granted to make and use derivative works provided that
 * such works are identified as "derived from the RSA Security Inc. PKCS #11
 * Cryptographic Token Interface (Cryptoki)" in all material mentioning or
 * referencing the derived work.

 * RSA Security Inc. makes no representations concerning either the
 * merchantability of this software or the suitability of this software for
 * any particular purpose. It is provided "as is" without express or implied
 * warranty of any kind.
 */

/* This header file contains pretty much everything about all the */
/* Cryptoki function prototypes.  Because this information is */
/* used for more than just declaring function prototypes, the */
/* order of the functions appearing herein is important, and */
/* should not be altered. */

/* General-purpose */

/* C_Initialize initializes the Cryptoki library. */
CK_PKCS11_FUNCTION_INFO(C_Initialize)
#ifdef CK_NEED_ARG_LIST
(
  CK_VOID_PTR   pInitArgs  /* if this is not NULL_PTR, it gets
                            * cast to CK_C_INITIALIZE_ARGS_PTR
                            * and dereferenced */
);
#endif

/* C_Finalize indicates that an application is done with the
 * Cryptoki library. */
CK_PKCS11_FUNCTION_INFO(C_Finalize)
#ifdef CK_NEED_ARG_LIST
(
  CK_VOID_PTR   pReserved  /* reserved.  Should be NULL_PTR */
);
#endif

/* C_GetInfo returns general information about Cryptoki. */
CK_PKCS11_FUNCTION_INFO(C_GetInfo)
#ifdef CK_NEED_ARG_LIST
(
  CK_INFO_PTR   pInfo  /* location that receives information */
);
#endif

/* C_GetFunctionList returns the function list. */
CK_PKCS11_FUNCTION_INFO(C_GetFunctionList)
#ifdef CK_NEED_ARG_LIST
(
  CK_FUNCTION_LIST_PTR_PTR ppFunctionList  /* receives pointer to
                                            * function list */
);
#endif

/* Slot and token management */

/* C_GetSlotList obtains a list of slots in the system. */
CK_PKCS11_FUNCTION_INFO(C_GetSlotList)
#ifdef CK_NEED_ARG_LIST
(
  CK_BBOOL       tokenPresent,  /* only slots with tokens? */
  CK_SLOT_ID_PTR pSlotList,     /* receives array of slot IDs */
  CK_ULONG_PTR   pulCount       /* receives number of slots */
);
#endif

/* C_GetSlotInfo obtains information about a particular slot in
 * the system. */
CK_PKCS11_FUNCTION_INFO(C_GetSlotInfo)
#ifdef CK_NEED_ARG_LIST
(
  CK_SLOT_ID       slotID,  /* the ID of the slot */
  CK_SLOT_INFO_PTR pInfo    /* receives the slot information */
);
#endif

/* C_GetTokenInfo obtains information about a particular token
 * in the system. */
CK_PKCS11_FUNCTION_INFO(C_GetTokenInfo)
#ifdef CK_NEED_ARG_LIST
(
  CK_SLOT_ID        slotID,  /* ID of the token's slot */
  CK_TOKEN_INFO_PTR pInfo    /* receives the token information */
);
#endif

/* C_GetMechanismList obtains a list of mechanism types
 * supported by a token. */
CK_PKCS11_FUNCTION_INFO(C_GetMechanismList)
#ifdef CK_NEED_ARG_LIST
(
  CK_SLOT_ID            slotID,          /* ID of token's slot */
  CK_MECHANISM_TYPE_PTR pMechanismList,  /* gets mech. array */
  CK_ULONG_PTR          pulCount         /* gets # of mechs. */
);
#endif

/* C_GetMechanismInfo obtains information about a particular
 * mechanism possibly supported by a token. */
CK_PKCS11_FUNCTION_INFO(C_GetMechanismInfo)
#ifdef CK_NEED_ARG_LIST
(
  CK_SLOT_ID            slotID,  /* ID of the token's slot */
  CK_MECHANISM_TYPE     type,    /* type of mechanism */
  CK_MECHANISM_INFO_PTR pInfo    /* receives mechanism info */
);
#endif

/* C_InitToken initializes a token. */
CK_PKCS11_FUNCTION_INFO(C_InitToken)
#ifdef CK_NEED_ARG_LIST
/* pLabel changed from CK_CHAR_PTR to CK_UTF8CHAR_PTR for v2.10 */
(
  CK_SLOT_ID      slotID,    /* ID of the token's slot */
  CK_UTF8CHAR_PTR pPin,      /* the SO's initial PIN */
  CK_ULONG        ulPinLen,  /* length in bytes of the PIN */
  CK_UTF8CHAR_PTR pLabel     /* 32-byte token label (blank padded) */
);
#endif

/* C_InitPIN initializes the normal user's PIN. */
CK_PKCS11_FUNCTION_INFO(C_InitPIN)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_UTF8CHAR_PTR   pPin,      /* the normal user's PIN */
  CK_ULONG          ulPinLen   /* length in bytes of the PIN */
);
#endif

/* C_SetPIN modifies the PIN of the user who is logged in. */
CK_PKCS11_FUNCTION_INFO(C_SetPIN)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_UTF8CHAR_PTR   pOldPin,   /* the old PIN */
  CK_ULONG          ulOldLen,  /* length of the old PIN */
  CK_UTF8CHAR_PTR   pNewPin,   /* the new PIN */
  CK_ULONG          ulNewLen   /* length of the new PIN */
);
#endif

/* Session management */

/* C_OpenSession opens a session between an application and a
 * token. */
CK_PKCS11_FUNCTION_INFO(C_OpenSession)
#ifdef CK_NEED_ARG_LIST
(
  CK_SLOT_ID            slotID,        /* the slot's ID */
  CK_FLAGS              flags,         /* from CK_SESSION_INFO */
  CK_VOID_PTR           pApplication,  /* passed to callback */
  CK_NOTIFY             Notify,        /* callback function */
  CK_SESSION_HANDLE_PTR phSession      /* gets session handle */
);
#endif

/* C_CloseSession closes a session between an application and a
 * token. */
CK_PKCS11_FUNCTION_INFO(C_CloseSession)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession  /* the session's handle */
);
#endif

/* C_CloseAllSessions closes all sessions with a token. */
CK_PKCS11_FUNCTION_INFO(C_CloseAllSessions)
#ifdef CK_NEED_ARG_LIST
(
  CK_SLOT_ID     slotID  /* the token's slot */
);
#endif

/* C_GetSessionInfo obtains information about the session. */
CK_PKCS11_FUNCTION_INFO(C_GetSessionInfo)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE   hSession,  /* the session's handle */
  CK_SESSION_INFO_PTR pInfo      /* receives session info */
);
#endif

/* C_GetOperationState obtains the state of the cryptographic operation
 * in a session. */
CK_PKCS11_FUNCTION_INFO(C_GetOperationState)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,             /* session's handle */
  CK_BYTE_PTR       pOperationState,      /* gets state */
  CK_ULONG_PTR      pulOperationStateLen  /* gets state length */
);
#endif

/* C_SetOperationState restores the state of the cryptographic
 * operation in a session. */
CK_PKCS11_FUNCTION_INFO(C_SetOperationState)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,            /* session's handle */
  CK_BYTE_PTR      pOperationState,      /* holds state */
  CK_ULONG         ulOperationStateLen,  /* holds state length */
  CK_OBJECT_HANDLE hEncryptionKey,       /* en/decryption key */
  CK_OBJECT_HANDLE hAuthenticationKey    /* sign/verify key */
);
#endif

/* C_Login logs a user into a token. */
CK_PKCS11_FUNCTION_INFO(C_Login)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_USER_TYPE      userType,  /* the user type */
  CK_UTF8CHAR_PTR   pPin,      /* the user's PIN */
  CK_ULONG          ulPinLen   /* the length of the PIN */
);
#endif

/* C_Logout logs a user out from a token. */
CK_PKCS11_FUNCTION_INFO(C_Logout)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession  /* the session's handle */
);
#endif

/* Object management */

/* C_CreateObject creates a new object. */
CK_PKCS11_FUNCTION_INFO(C_CreateObject)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,    /* the session's handle */
  CK_ATTRIBUTE_PTR  pTemplate,   /* the object's template */
  CK_ULONG          ulCount,     /* attributes in template */
  CK_OBJECT_HANDLE_PTR phObject  /* gets new object's handle. */
);
#endif

/* C_CopyObject copies an object, creating a new object for the
 * copy. */
CK_PKCS11_FUNCTION_INFO(C_CopyObject)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE    hSession,    /* the session's handle */
  CK_OBJECT_HANDLE     hObject,     /* the object's handle */
  CK_ATTRIBUTE_PTR     pTemplate,   /* template for new object */
  CK_ULONG             ulCount,     /* attributes in template */
  CK_OBJECT_HANDLE_PTR phNewObject  /* receives handle of copy */
);
#endif

/* C_DestroyObject destroys an object. */
CK_PKCS11_FUNCTION_INFO(C_DestroyObject)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_OBJECT_HANDLE  hObject    /* the object's handle */
);
#endif

/* C_GetObjectSize gets the size of an object in bytes. */
CK_PKCS11_FUNCTION_INFO(C_GetObjectSize)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_OBJECT_HANDLE  hObject,   /* the object's handle */
  CK_ULONG_PTR      pulSize    /* receives size of object */
);
#endif

/* C_GetAttributeValue obtains the value of one or more object
 * attributes. */
CK_PKCS11_FUNCTION_INFO(C_GetAttributeValue)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,   /* the session's handle */
  CK_OBJECT_HANDLE  hObject,    /* the object's handle */
  CK_ATTRIBUTE_PTR  pTemplate,  /* specifies attrs; gets vals */
  CK_ULONG          ulCount     /* attributes in template */
);
#endif

/* C_SetAttributeValue modifies the value of one or more object
 * attributes */
CK_PKCS11_FUNCTION_INFO(C_SetAttributeValue)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,   /* the session's handle */
  CK_OBJECT_HANDLE  hObject,    /* the object's handle */
  CK_ATTRIBUTE_PTR  pTemplate,  /* specifies attrs and values */
  CK_ULONG          ulCount     /* attributes in template */
);
#endif

/* C_FindObjectsInit initializes a search for token and session
 * objects that match a template. */
CK_PKCS11_FUNCTION_INFO(C_FindObjectsInit)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,   /* the session's handle */
  CK_ATTRIBUTE_PTR  pTemplate,  /* attribute values to match */
  CK_ULONG          ulCount     /* attrs in search template */
);
#endif

/* C_FindObjects continues a search for token and session
 * objects that match a template, obtaining additional object
 * handles. */
CK_PKCS11_FUNCTION_INFO(C_FindObjects)
#ifdef CK_NEED_ARG_LIST
(
 CK_SESSION_HANDLE    hSession,          /* session's handle */
 CK_OBJECT_HANDLE_PTR phObject,          /* gets obj. handles */
 CK_ULONG             ulMaxObjectCount,  /* max handles to get */
 CK_ULONG_PTR         pulObjectCount     /* actual # returned */
);
#endif

/* C_FindObjectsFinal finishes a search for token and session
 * objects. */
CK_PKCS11_FUNCTION_INFO(C_FindObjectsFinal)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession  /* the session's handle */
);
#endif

/* Encryption and decryption */

/* C_EncryptInit initializes an encryption operation. */
CK_PKCS11_FUNCTION_INFO(C_EncryptInit)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,    /* the session's handle */
  CK_MECHANISM_PTR  pMechanism,  /* the encryption mechanism */
  CK_OBJECT_HANDLE  hKey         /* handle of encryption key */
);
#endif

/* C_Encrypt encrypts single-part data. */
CK_PKCS11_FUNCTION_INFO(C_Encrypt)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,            /* session's handle */
  CK_BYTE_PTR       pData,               /* the plaintext data */
  CK_ULONG          ulDataLen,           /* bytes of plaintext */
  CK_BYTE_PTR       pEncryptedData,      /* gets ciphertext */
  CK_ULONG_PTR      pulEncryptedDataLen  /* gets c-text size */
);
#endif

/* C_EncryptUpdate continues a multiple-part encryption
 * operation. */
CK_PKCS11_FUNCTION_INFO(C_EncryptUpdate)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,           /* session's handle */
  CK_BYTE_PTR       pPart,              /* the plaintext data */
  CK_ULONG          ulPartLen,          /* plaintext data len */
  CK_BYTE_PTR       pEncryptedPart,     /* gets ciphertext */
  CK_ULONG_PTR      pulEncryptedPartLen /* gets c-text size */
);
#endif

/* C_EncryptFinal finishes a multiple-part encryption
 * operation. */
CK_PKCS11_FUNCTION_INFO(C_EncryptFinal)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,                /* session handle */
  CK_BYTE_PTR       pLastEncryptedPart,      /* last c-text */
  CK_ULONG_PTR      pulLastEncryptedPartLen  /* gets last size */
);
#endif

/* C_DecryptInit initializes a decryption operation. */
CK_PKCS11_FUNCTION_INFO(C_DecryptInit)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,    /* the session's handle */
  CK_MECHANISM_PTR  pMechanism,  /* the decryption mechanism */
  CK_OBJECT_HANDLE  hKey         /* handle of decryption key */
);
#endif

/* C_Decrypt decrypts encrypted data in a single part. */
CK_PKCS11_FUNCTION_INFO(C_Decrypt)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,           /* session's handle */
  CK_BYTE_PTR       pEncryptedData,     /* ciphertext */
  CK_ULONG          ulEncryptedDataLen, /* ciphertext length */
  CK_BYTE_PTR       pData,              /* gets plaintext */
  CK_ULONG_PTR      pulDataLen          /* gets p-text size */
);
#endif

/* C_DecryptUpdate continues a multiple-part decryption
 * operation. */
CK_PKCS11_FUNCTION_INFO(C_DecryptUpdate)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,            /* session's handle */
  CK_BYTE_PTR       pEncryptedPart,      /* encrypted data */
  CK_ULONG          ulEncryptedPartLen,  /* input length */
  CK_BYTE_PTR       pPart,               /* gets plaintext */
  CK_ULONG_PTR      pulPartLen           /* p-text size */
);
#endif

/* C_DecryptFinal finishes a multiple-part decryption
 * operation. */
CK_PKCS11_FUNCTION_INFO(C_DecryptFinal)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,       /* the session's handle */
  CK_BYTE_PTR       pLastPart,      /* gets plaintext */
  CK_ULONG_PTR      pulLastPartLen  /* p-text size */
);
#endif

/* Message digesting */

/* C_DigestInit initializes a message-digesting operation. */
CK_PKCS11_FUNCTION_INFO(C_DigestInit)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,   /* the session's handle */
  CK_MECHANISM_PTR  pMechanism  /* the digesting mechanism */
);
#endif

/* C_Digest digests data in a single part. */
CK_PKCS11_FUNCTION_INFO(C_Digest)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,     /* the session's handle */
  CK_BYTE_PTR       pData,        /* data to be digested */
  CK_ULONG          ulDataLen,    /* bytes of data to digest */
  CK_BYTE_PTR       pDigest,      /* gets the message digest */
  CK_ULONG_PTR      pulDigestLen  /* gets digest length */
);
#endif

/* C_DigestUpdate continues a multiple-part message-digesting
 * operation. */
CK_PKCS11_FUNCTION_INFO(C_DigestUpdate)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_BYTE_PTR       pPart,     /* data to be digested */
  CK_ULONG          ulPartLen  /* bytes of data to be digested */
);
#endif

/* C_DigestKey continues a multi-part message-digesting
 * operation, by digesting the value of a secret key as part of
 * the data already digested. */
CK_PKCS11_FUNCTION_INFO(C_DigestKey)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_OBJECT_HANDLE  hKey       /* secret key to digest */
);
#endif

/* C_DigestFinal finishes a multiple-part message-digesting
 * operation. */
CK_PKCS11_FUNCTION_INFO(C_DigestFinal)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,     /* the session's handle */
  CK_BYTE_PTR       pDigest,      /* gets the message digest */
  CK_ULONG_PTR      pulDigestLen  /* gets byte count of digest */
);
#endif

/* Signing and MACing */

/* C_SignInit initializes a signature (private key encryption)
 * operation, where the signature is (will be) an appendix to
 * the data, and plaintext cannot be recovered from the
 *signature. */
CK_PKCS11_FUNCTION_INFO(C_SignInit)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,    /* the session's handle */
  CK_MECHANISM_PTR  pMechanism,  /* the signature mechanism */
  CK_OBJECT_HANDLE  hKey         /* handle of signature key */
);
#endif

/* C_Sign signs (encrypts with private key) data in a single
 * part, where the signature is (will be) an appendix to the
 * data, and plaintext cannot be recovered from the signature. */
CK_PKCS11_FUNCTION_INFO(C_Sign)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,        /* the session's handle */
  CK_BYTE_PTR       pData,           /* the data to sign */
  CK_ULONG          ulDataLen,       /* count of bytes to sign */
  CK_BYTE_PTR       pSignature,      /* gets the signature */
  CK_ULONG_PTR      pulSignatureLen  /* gets signature length */
);
#endif

/* C_SignUpdate continues a multiple-part signature operation,
 * where the signature is (will be) an appendix to the data,
 * and plaintext cannot be recovered from the signature. */
CK_PKCS11_FUNCTION_INFO(C_SignUpdate)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_BYTE_PTR       pPart,     /* the data to sign */
  CK_ULONG          ulPartLen  /* count of bytes to sign */
);
#endif

/* C_SignFinal finishes a multiple-part signature operation,
 * returning the signature. */
CK_PKCS11_FUNCTION_INFO(C_SignFinal)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,        /* the session's handle */
  CK_BYTE_PTR       pSignature,      /* gets the signature */
  CK_ULONG_PTR      pulSignatureLen  /* gets signature length */
);
#endif

/* C_SignRecoverInit initializes a signature operation, where
 * the data can be recovered from the signature. */
CK_PKCS11_FUNCTION_INFO(C_SignRecoverInit)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,   /* the session's handle */
  CK_MECHANISM_PTR  pMechanism, /* the signature mechanism */
  CK_OBJECT_HANDLE  hKey        /* handle of the signature key */
);
#endif

/* C_SignRecover signs data in a single operation, where the
 * data can be recovered from the signature. */
CK_PKCS11_FUNCTION_INFO(C_SignRecover)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,        /* the session's handle */
  CK_BYTE_PTR       pData,           /* the data to sign */
  CK_ULONG          ulDataLen,       /* count of bytes to sign */
  CK_BYTE_PTR       pSignature,      /* gets the signature */
  CK_ULONG_PTR      pulSignatureLen  /* gets signature length */
);
#endif

/* Verifying signatures and MACs */

/* C_VerifyInit initializes a verification operation, where the
 * signature is an appendix to the data, and plaintext cannot
 *  cannot be recovered from the signature (e.g. DSA). */
CK_PKCS11_FUNCTION_INFO(C_VerifyInit)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,    /* the session's handle */
  CK_MECHANISM_PTR  pMechanism,  /* the verification mechanism */
  CK_OBJECT_HANDLE  hKey         /* verification key */
);
#endif

/* C_Verify verifies a signature in a single-part operation,
 * where the signature is an appendix to the data, and plaintext
 * cannot be recovered from the signature. */
CK_PKCS11_FUNCTION_INFO(C_Verify)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,       /* the session's handle */
  CK_BYTE_PTR       pData,          /* signed data */
  CK_ULONG          ulDataLen,      /* length of signed data */
  CK_BYTE_PTR       pSignature,     /* signature */
  CK_ULONG          ulSignatureLen  /* signature length*/
);
#endif

/* C_VerifyUpdate continues a multiple-part verification
 * operation, where the signature is an appendix to the data,
 * and plaintext cannot be recovered from the signature. */
CK_PKCS11_FUNCTION_INFO(C_VerifyUpdate)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_BYTE_PTR       pPart,     /* signed data */
  CK_ULONG          ulPartLen  /* length of signed data */
);
#endif

/* C_VerifyFinal finishes a multiple-part verification
 * operation, checking the signature. */
CK_PKCS11_FUNCTION_INFO(C_VerifyFinal)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,       /* the session's handle */
  CK_BYTE_PTR       pSignature,     /* signature to verify */
  CK_ULONG          ulSignatureLen  /* signature length */
);
#endif

/* C_VerifyRecoverInit initializes a signature verification
 * operation, where the data is recovered from the signature. */
CK_PKCS11_FUNCTION_INFO(C_VerifyRecoverInit)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,    /* the session's handle */
  CK_MECHANISM_PTR  pMechanism,  /* the verification mechanism */
  CK_OBJECT_HANDLE  hKey         /* verification key */
);
#endif

/* C_VerifyRecover verifies a signature in a single-part
 * operation, where the data is recovered from the signature. */
CK_PKCS11_FUNCTION_INFO(C_VerifyRecover)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,        /* the session's handle */
  CK_BYTE_PTR       pSignature,      /* signature to verify */
  CK_ULONG          ulSignatureLen,  /* signature length */
  CK_BYTE_PTR       pData,           /* gets signed data */
  CK_ULONG_PTR      pulDataLen       /* gets signed data len */
);
#endif

/* Dual-function cryptographic operations */

/* C_DigestEncryptUpdate continues a multiple-part digesting
 * and encryption operation. */
CK_PKCS11_FUNCTION_INFO(C_DigestEncryptUpdate)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,            /* session's handle */
  CK_BYTE_PTR       pPart,               /* the plaintext data */
  CK_ULONG          ulPartLen,           /* plaintext length */
  CK_BYTE_PTR       pEncryptedPart,      /* gets ciphertext */
  CK_ULONG_PTR      pulEncryptedPartLen  /* gets c-text length */
);
#endif

/* C_DecryptDigestUpdate continues a multiple-part decryption and
 * digesting operation. */
CK_PKCS11_FUNCTION_INFO(C_DecryptDigestUpdate)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,            /* session's handle */
  CK_BYTE_PTR       pEncryptedPart,      /* ciphertext */
  CK_ULONG          ulEncryptedPartLen,  /* ciphertext length */
  CK_BYTE_PTR       pPart,               /* gets plaintext */
  CK_ULONG_PTR      pulPartLen           /* gets plaintext len */
);
#endif

/* C_SignEncryptUpdate continues a multiple-part signing and
 * encryption operation. */
CK_PKCS11_FUNCTION_INFO(C_SignEncryptUpdate)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,            /* session's handle */
  CK_BYTE_PTR       pPart,               /* the plaintext data */
  CK_ULONG          ulPartLen,           /* plaintext length */
  CK_BYTE_PTR       pEncryptedPart,      /* gets ciphertext */
  CK_ULONG_PTR      pulEncryptedPartLen  /* gets c-text length */
);
#endif

/* C_DecryptVerifyUpdate continues a multiple-part decryption and
 * verify operation. */
CK_PKCS11_FUNCTION_INFO(C_DecryptVerifyUpdate)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,            /* session's handle */
  CK_BYTE_PTR       pEncryptedPart,      /* ciphertext */
  CK_ULONG          ulEncryptedPartLen,  /* ciphertext length */
  CK_BYTE_PTR       pPart,               /* gets plaintext */
  CK_ULONG_PTR      pulPartLen           /* gets p-text length */
);
#endif

/* Key management */

/* C_GenerateKey generates a secret key, creating a new key
 * object. */
CK_PKCS11_FUNCTION_INFO(C_GenerateKey)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE    hSession,    /* the session's handle */
  CK_MECHANISM_PTR     pMechanism,  /* key generation mech. */
  CK_ATTRIBUTE_PTR     pTemplate,   /* template for new key */
  CK_ULONG             ulCount,     /* # of attrs in template */
  CK_OBJECT_HANDLE_PTR phKey        /* gets handle of new key */
);
#endif

/* C_GenerateKeyPair generates a public-key/private-key pair,
 * creating new key objects. */
CK_PKCS11_FUNCTION_INFO(C_GenerateKeyPair)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE    hSession,                    /* session
                                                     * handle */
  CK_MECHANISM_PTR     pMechanism,                  /* key-gen
                                                     * mech. */
  CK_ATTRIBUTE_PTR     pPublicKeyTemplate,          /* template
                                                     * for pub.
                                                     * key */
  CK_ULONG             ulPublicKeyAttributeCount,   /* # pub.
                                                     * attrs. */
  CK_ATTRIBUTE_PTR     pPrivateKeyTemplate,         /* template
                                                     * for priv.
                                                     * key */
  CK_ULONG             ulPrivateKeyAttributeCount,  /* # priv.
                                                     * attrs. */
  CK_OBJECT_HANDLE_PTR phPublicKey,                 /* gets pub.
                                                     * key
                                                     * handle */
  CK_OBJECT_HANDLE_PTR phPrivateKey                 /* gets
                                                     * priv. key
                                                     * handle */
);
#endif

/* C_WrapKey wraps (i.e., encrypts) a key. */
CK_PKCS11_FUNCTION_INFO(C_WrapKey)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,        /* the session's handle */
  CK_MECHANISM_PTR  pMechanism,      /* the wrapping mechanism */
  CK_OBJECT_HANDLE  hWrappingKey,    /* wrapping key */
  CK_OBJECT_HANDLE  hKey,            /* key to be wrapped */
  CK_BYTE_PTR       pWrappedKey,     /* gets wrapped key */
  CK_ULONG_PTR      pulWrappedKeyLen /* gets wrapped key size */
);
#endif

/* C_UnwrapKey unwraps (decrypts) a wrapped key, creating a new
 * key object. */
CK_PKCS11_FUNCTION_INFO(C_UnwrapKey)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE    hSession,          /* session's handle */
  CK_MECHANISM_PTR     pMechanism,        /* unwrapping mech. */
  CK_OBJECT_HANDLE     hUnwrappingKey,    /* unwrapping key */
  CK_BYTE_PTR          pWrappedKey,       /* the wrapped key */
  CK_ULONG             ulWrappedKeyLen,   /* wrapped key len */
  CK_ATTRIBUTE_PTR     pTemplate,         /* new key template */
  CK_ULONG             ulAttributeCount,  /* template length */
  CK_OBJECT_HANDLE_PTR phKey              /* gets new handle */
);
#endif

/* C_DeriveKey derives a key from a base key, creating a new key
 * object. */
CK_PKCS11_FUNCTION_INFO(C_DeriveKey)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE    hSession,          /* session's handle */
  CK_MECHANISM_PTR     pMechanism,        /* key deriv. mech. */
  CK_OBJECT_HANDLE     hBaseKey,          /* base key */
  CK_ATTRIBUTE_PTR     pTemplate,         /* new key template */
  CK_ULONG             ulAttributeCount,  /* template length */
  CK_OBJECT_HANDLE_PTR phKey              /* gets new handle */
);
#endif

/* Random number generation */

/* C_SeedRandom mixes additional seed material into the token's
 * random number generator. */
CK_PKCS11_FUNCTION_INFO(C_SeedRandom)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,  /* the session's handle */
  CK_BYTE_PTR       pSeed,     /* the seed material */
  CK_ULONG          ulSeedLen  /* length of seed material */
);
#endif

/* C_GenerateRandom generates random data. */
CK_PKCS11_FUNCTION_INFO(C_GenerateRandom)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession,    /* the session's handle */
  CK_BYTE_PTR       RandomData,  /* receives the random data */
  CK_ULONG          ulRandomLen  /* # of bytes to generate */
);
#endif

/* Parallel function management */

/* C_GetFunctionStatus is a legacy function; it obtains an
 * updated status of a function running in parallel with an
 * application. */
CK_PKCS11_FUNCTION_INFO(C_GetFunctionStatus)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession  /* the session's handle */
);
#endif

/* C_CancelFunction is a legacy function; it cancels a function
 * running in parallel. */
CK_PKCS11_FUNCTION_INFO(C_CancelFunction)
#ifdef CK_NEED_ARG_LIST
(
  CK_SESSION_HANDLE hSession  /* the session's handle */
);
#endif

/* Functions added in for Cryptoki Version 2.01 or later */

/* C_WaitForSlotEvent waits for a slot event (token insertion,
 * removal, etc.) to occur. */
CK_PKCS11_FUNCTION_INFO(C_WaitForSlotEvent)
#ifdef CK_NEED_ARG_LIST
(
  CK_FLAGS flags,        /* blocking/nonblocking flag */
  CK_SLOT_ID_PTR pSlot,  /* location that receives the slot ID */
  CK_VOID_PTR pRserved   /* reserved.  Should be NULL_PTR */
);
#endif