text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  <meta name="google-site-verification" content="MxsMq6bdLOx0KSuz1MY6yG9ZTIJ7_7DVRfl5NCAT5Yg"/>
  <title>ImageMagick: Magick++, C++ API for ImageMagick</title>
  <meta http-equiv="content-language" content="en-US"/>
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  <meta http-equiv="reply-to" content="magick-users@imagemagick.org"/>
  <meta name="application-name" content="ImageMagick"/>
  <meta name="description" content="Use ImageMagick to convert, edit, or compose bitmap images in a variety of formats.  In addition resize, rotate, shear, distort and transform images automagically."/>
  <meta name="application-url" content="http://www.imagemagick.org"/>
  <meta name="generator" content="PHP"/>
  <meta name="keywords" content="magick++, c++, api, for, imagemagick, ImageMagick, PerlMagick, image processing, OpenMP, software development library, image, photo, software, Magick++, MagickWand"/>
  <meta name="rating" content="GENERAL"/>
  <meta name="robots" content="INDEX, FOLLOW"/>
  <meta name="generator" content="ImageMagick Studio LLC"/>
  <meta name="author" content="ImageMagick Studio LLC"/>
  <meta name="revisit-after" content="2 DAYS"/>
  <meta name="resource-type" content="document"/>
  <meta name="copyright" content="Copyright (c) 1999-2013 ImageMagick Studio LLC"/>
  <meta name="distribution" content="Global"/>
  <link rel="icon" href="../images/wand.png"/>
  <link rel="shortcut icon" href="../images/wand.ico"  type="images/x-icon"/>
  <link rel="canonical" href="http://www.imagemagick.org" />
  <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"/>

  <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/jquery.fancybox.css?v=2.0.4" type="text/css" media="screen" />

  <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-buttons.css?v=2.0.4" type="text/css" media="screen" />

  <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-thumbs.css?v=2.0.4" type="text/css" media="screen" />

  <link rel="stylesheet" href="http://www.localhost/cse/style/look/default.css" type="text/css" />

  About ImageMagick

  Binary Releases

    Unix

    Mac OS X

    iOS

    Windows

  Command-line Tools

    Processing

    Options

    Usage

  Program Interfaces

    MagickWand

    MagickCore

    PerlMagick

    Magick++

   Install from Source

    Unix

    Windows

  Resources

  Architecture

  Download

  Search

  Site Map

  Links

  Sponsors:

  The Fastest & Easiest Way to Find Images

  VPS

  Werbebanner Werbeplane

  Entertainment News & Photos

  LED24

  Best Website Hosting

  Android Tablet

  Web Site Hosting

   Premium Quality Stock Photos

   Druckerei

  Managed Server

  Druckerei

   Names List

   Web Hosting

Magick++ C++ API

[Introduction to Magick++ • Documentation • Obtaining Magick++ • Installation • Reporting Bugs]

Magick++ is the object-oriented C++ API to the ImageMagick image-processing library.

Magick++ supports an object model which is inspired by PerlMagick.
Images support implicit reference counting so that copy constructors
and assignment incur almost no cost. The cost of actually copying an
image (if necessary) is done just before modification and this copy
is managed automagically by Magick++. De-referenced copies are
automagically deleted. The image objects support value (rather than
pointer) semantics so it is trivial to support multiple generations
of an image in memory at one time.

Magick++ provides integrated support for the Standard
Template Library (STL) so that the powerful containers available
(e.g. deque,
vector, list,
and map)  can
be used to write programs similar to those possible with PERL &
PerlMagick. STL-compatible template versions of ImageMagick's
list-style operations are provided so that operations may be
performed on multiple images stored in STL containers.

Documentation

Detailed documentation is
provided for all Magick++ classes, class methods, and template
functions which comprise the API.  See a   Gentle Introduction to Magick++ for an introductory tutorial to Magick++.  We include the source if you want to correct, enhance, or expand the tutorial.

Obtaining Magick++

Magick++ is included as part of ImageMagick
source releases and may be retrieved via ftp
or Subversion.

Installation

Once you have the Magick++ sources available, follow these detailed
installation instructions for UNIX and
Windows.

Usage

A helper script named Magick++-config is installed
under Unix which assists with recalling compilation options required
to compile and link programs which use Magick++. For example, the
following command will compile and link the source file demo.cpp
to produce the executable demo (notice that quotes are
backward quotes):

c++ `Magick++-config --cxxflags --cppflags` -O2 -o demo demo.cpp \
  `Magick++-config --ldflags --libs`

Windows users may get started by manually editing a project file
for one of the Magick++ demo programs.

Note, under Windows (and possibly the Mac) it may be necessary to initialize the ImageMagick library prior to using the Magick++ library. This initialization is performed by passing the path to the ImageMagick DLLs (assumed to be in the same directory as your program) to the InitializeMagick() function call. This is commonly performed by providing the path to your program (argv[0]) as shown in the following example:

int main( int argc, char ** argv) {
  InitializeMagick(*argv);
  ...

This initialization step is not required under Unix, Linux,
Cygwin, or any other operating environment that supports the notion
of installing ImageMagick in a known location.

Reporting Bugs

Questions regarding usage should be directed to or to report any bugs go to
Magick++ bug tracking forum.

      Discourse Server •
      Studio

    © 1999-2013 ImageMagick Studio LLC
     Contact the Wizards


text:
@interface TPAAddTripPlanViewController : UIViewController

@property (nonatomic, strong) PFObject *planEntry;

@end

redpajama_set_name: RedPajamaGithub


text:
layout: post
title: Typograhy example
date: 2014-03-19
comments: true
archive: false
---
Lorem ipsum dolor sit amet Id, aliquam magni et officiis nemo nihil aliquid placeat alias. Eum voluptates ducimus, nobis ex illum laboriosam quidem corrupti impedit ratione in voluptatum amet beatae facilis temporibus voluptate praesentium voluptatibus! At ab, iusto error amet eveniet debitis ipsa recusandae possimus minima sunt itaque, nulla ducimus officia, consequatur ipsum laudantium magnam hic fuga vero incidunt nostrum. Commodi, perspiciatis ut nostrum fugit nulla cumque voluptate harum nemo accusamus?

## This is a h2

### h3, h4, h5 and h6 have the same style.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptas sed quo atque *perspiciatis*. Eius cum possimus, maxime unde, asperiores neque blanditiis molestiae ipsa odit. **Laboriosam**, error! Ipsa officia magnam at ratione commodi porro nulla consequuntur eum quia nisi officiis cupiditate reprehenderit provident facilis rem, nobis quidem fugiat, et! Tempore maiores reprehenderit laboriosam rerum?

> This is a blockquote

### Unordered list
- list 1
- list 2
- list 3
- list 4

### Ordered list
1. one
2. two
3. three
4. four


text:
(function() {
	"use strict";

	var childProcess = require('child_process');
	var readline = require('readline');

	exports.launchServiceProcess = function (configuration, done) {
		var serviceProcess = launchProcess(configuration);

		serviceProcess.on('error', function (error) {
			console.log(error);
		});

		serviceProcess.on('message', function (message) {
			console.log(message);
		});

		registerCleanupOnExit(configuration.name, serviceProcess);
        ensureServiceReadyToOperate(serviceProcess, configuration, done);
	};

	function launchProcess(configuration) {
		return childProcess.spawn(
            configuration.executable,
            configuration.arguments,
            {
                env: configuration.env
            });
	}

	function registerCleanupOnExit(serviceName, serviceProcess) {
        process.on("exit", function () {
            console.log("Stopping background service: " + serviceName);
            serviceProcess.kill();
        });
  }

	function ensureServiceReadyToOperate(serviceProcess, configuration, serviceReadyCallback) {
        var serviceReady = false;
        var serviceName = configuration.name;

        serviceProcess.on('exit', function (code) {
            if (serviceReady) {
                console.log("Process " + serviceName + " exited");
            } else {
                serviceReady = true;
                serviceReadyCallback(new Error("Process " + serviceName + " exited with code " + code));
            }
        });

        onEachLogMessage(serviceProcess, function (logMessage) {
            if (shouldLogMessages(logMessage)) {
                console.log(logMessage);
            }

            if (!serviceReady && announcingServiceReady(logMessage, configuration)) {
                serviceReady = true;
                serviceReadyCallback();
            }
        });

        ensureFailOnTimeout(serviceProcess, checkStarted, serviceReadyCallback);

        function checkStarted() {
            return serviceReady;
        }

        function shouldLogMessages(logMessage) {
            if (!serviceReady) {
                return true;
            }

            if (configuration.alwaysLog) {
                return true;
            }

            if (logMessage.match(/(ERROR)|(WARN)/)) {
                return true;
            }

            return false;
        }
    }

    function ensureFailOnTimeout(serviceProcess, checkStarted, serviceReadyCallback) {
        var maxStartupTimeMs = 60 * 1000;

        setTimeout(function () {
            if (!checkStarted()) {
                serviceProcess.kill();

                console.log("Service timed out during startup");
                serviceReadyCallback(false);
            }
        }, maxStartupTimeMs);
    }

    function onEachLogMessage(serviceProcess, lineCallback) {
        var lineReader = readline.createInterface({
            input: serviceProcess.stdout,
            output: serviceProcess.stdin
        });

        lineReader.on('line', lineCallback);
    }

	function announcingServiceReady(logMessage, configuration) {
        return configuration.readyPattern.test(logMessage);
    }
}());


text:
BoneInstance::BoneInstance(void)
{
}

BoneInstance::~BoneInstance(void)
{
}

void BoneInstance::Transform( const Matrix44f& aParentMatrix )
{
	myTransformedMatrix=GetBoneLocalTransform();
	myTransformedMatrix*=aParentMatrix;
}

void BoneInstance::ApplyBindPose()
{
	Matrix44f test1=myBone->GetInversedBindPose();
	test1*=myTransformedMatrix;
	myTransformedMatrix=test1;
}

const Matrix44f BoneInstance::GetBoneLocalTransform()
{
	if(myTransformationInstance->GetTransformationNode())
	{
		Matrix44f trans;
		trans=myTransformationInstance->GetTransformation();
		return(trans);
	}
	else
	{
		return(myBone->myOriginalBindPoseOrientation);
	}
}

const Matrix44f BoneInstance::GetTransformed()
{
	return myTransformedMatrix;
}

void BoneInstance::SetBoneAnimationInstance( TransformationNodeInstance* aTransformationInstance )
{
	myTransformationInstance = aTransformationInstance;
}

void BoneInstance::SetBone( Bone* aBone )
{
	myBone = aBone;
}


text:
<?php

/**
 * Plugin Name: Wordpress Multisite External API Authentication
 * Plugin URI: https://github.com/antriver/wordpress-external-api-auth-multisite
 * Description: Used to authenticate Wordpress logins via an external REST API.
 * Version: 2015042900
 * Author: Anthony Kuske
 * Author URI: http://www.anthonykuske.com
 */

function wp_api_auth_get_options()
{
    // Return an array of options and their default value
    return array(
        'wp_api_auth_url' => '',
        'wp_api_auth_method' => 'POST',
        'wp_api_auth_username_field' => 'username',
        'wp_api_auth_password_field' => 'password',

        'wp_api_auth_first_name_field' => '',
        'wp_api_auth_last_name_field' => '',
        'wp_api_auth_user_url_field' => '',
        'wp_api_auth_user_email_field' => '',
        'wp_api_auth_description_field' => '',
        'wp_api_auth_aim_field' => '',
        'wp_api_auth_yim_field' => '',
        'wp_api_auth_jabber_field' => '',

        'wp_api_auth_login_message' => '',
        'wp_api_auth_lost_password_message' => '',
    );
}

function wp_api_auth_admin_init()
{
    $options = wp_api_auth_get_options();
    foreach ($options as $key => $defaultValue) {
        add_site_option($key, $defaultValue);
    }
}

/**
 * Add link to the settings page to the nework admin menu
 */
function wp_api_auth_network_admin_menu()
{
    add_submenu_page(
        'settings.php', // parent_slug
        'API Authentication Settings', // page_title
        'API Authentication', // menu_title
        'manage_options', // capability
        'wp_api_auth_settings', // menu_slug
        'wp_api_auth_display_options' // function
    );
}

 /**
  * Display the settings page
  */
function wp_api_auth_display_options()
{
    // Kill magic quotes if necessary
    if (get_magic_quotes_gpc()) {
        foreach ($_POST as $key => &$value) {
            $value = stripslashes($value);
        }
    }

    // Save changes
    if (!empty($_POST)) {
        $options = wp_api_auth_get_options();
        foreach ($options as $key => $defaultValue) {
            if (isset($_POST[$key])) {
                update_site_option($key, $_POST[$key]);
            }
        }
    }

    ?>

<?php _e('External API Authentication Settings'); ?>

        <form method="post" action="settings.php?page=wp_api_auth_settings">

            <?php settings_fields('wp_api_auth'); ?>

<?php _e('API Settings'); ?>

<?php _e('Make sure your Wordpress admin account exists on the external API prior to saving these settings or you will be unable to login!'); ?>

                    <?php _e('API URL'); ?>

                        <input type="text" class="regular-text" name="wp_api_auth_url" value="<?php echo get_site_option('wp_api_auth_url'); ?>" />

<?php _e('Required'); ?>

                    <?php _e('Request Method'); ?>

                        <fieldset>
                            <input type="radio" name="wp_api_auth_method" value="GET" <?php echo (get_site_option('wp_api_auth_method') === 'GET' ? 'checked="checked"' : ''); ?> /> GET

                            <input type="radio" name="wp_api_auth_method" value="POST" <?php echo (get_site_option('wp_api_auth_method') === 'POST' ? 'checked="checked"' : ''); ?> /> POST
                        </fieldset>

                    <?php _e('Username Field'); ?>

                        <input type="text" class="regular-text" name="wp_api_auth_username_field" value="<?php echo get_site_option('wp_api_auth_username_field'); ?>" />

<?php _e('Required'); ?>

                    <?php _e('Password Field'); ?>

                        <input type="text" class="regular-text" name="wp_api_auth_password_field" value="<?php echo get_site_option('wp_api_auth_password_field'); ?>" />

<?php _e('Required'); ?>

<?php _e('Response Fields'); ?>

<?php _e('Enter these optional field names returned in the response that will be mapped to the user\'s Wordpress account.'); ?>

                    <?php _e('First name'); ?>
                    <input type="text" class="regular-text" name="wp_api_auth_first_name_field" value="<?php echo get_site_option('wp_api_auth_first_name_field'); ?>" />

                    <?php _e('Last name'); ?>
                    <input type="text" class="regular-text" name="wp_api_auth_last_name_field" value="<?php echo get_site_option('wp_api_auth_last_name_field'); ?>" />

                    <?php _e('Homepage'); ?>
                    <input type="text" class="regular-text" name="wp_api_auth_user_url_field" value="<?php echo get_site_option('wp_api_auth_user_url_field'); ?>" />

                    <?php _e('Email'); ?>
                    <input type="text" class="regular-text" name="wp_api_auth_user_email_field" value="<?php echo get_site_option('wp_api_auth_user_email_field'); ?>" />

                    <?php _e('Bio/Description'); ?>
                    <input type="text" class="regular-text" name="wp_api_auth_description_field" value="<?php echo get_site_option('wp_api_auth_description_field'); ?>" />

                    <?php _e('AIM screen name'); ?>
                    <input type="text" class="regular-text" name="wp_api_auth_aim_field" value="<?php echo get_site_option('wp_api_auth_aim_field'); ?>" />

                    <?php _e('YIM screen name'); ?>
                    <input type="text" class="regular-text" name="wp_api_auth_yim_field" value="<?php echo get_site_option('wp_api_auth_yim_field'); ?>" />

                    <?php _e('JABBER screen name'); ?>
                    <input type="text" class="regular-text" name="wp_api_auth_jabber_field" value="<?php echo get_site_option('wp_api_auth_jabber_field'); ?>" />

<?php _e('Other'); ?>

                    <?php _e('Custom Login Form Message'); ?>

                        <textarea class="large-text" rows="5" name="wp_api_auth_login_message"><?php echo htmlspecialchars(get_site_option('wp_api_auth_login_message'));?></textarea>

<?php _e('Shows on the login form. e.g. To tell users where to create an account. You can use HTML in this text.'); ?>

                    <?php _e('Lost Password Form Message'); ?>

                        <textarea class="large-text" rows="5" name="wp_api_auth_lost_password_message"><?php echo htmlspecialchars(get_site_option('wp_api_auth_lost_password_message'));?></textarea>

<?php _e('Shows on the forgotten password page. If you enter something in this box the reset password form is disabled and this message is shown.'); ?>

                <input type="submit" name="Submit" value="Save changes" />

        </form>

    <?php
}

// actual meat of plugin - essentially, you're setting $username and $password to pass on to the system.
// You check from your external system and insert/update users into the WP system just before WP actually
// authenticates with its own database.
function wp_api_auth_wp_authenticate($username, $password)
{
    //var_dump($username, $password);

    require_once './wp-includes/user.php';
    require_once './wp-includes/pluggable.php';

    $response = wp_api_auth_get_response($username, $password);

    if ($response->success) {
        $externalUser = $response->user;
    } else {
        if ($response->error) {
            global $wp_api_auth_error;
            $wp_api_auth_error = $response->error;
            return;
        }
    }

    // Set the mapping of fields from the external db to the wordpress db
    $fieldMappings = array(
        'first_name' => get_site_option('wp_api_auth_first_name_field'),
        'last_name' => get_site_option('wp_api_auth_last_name_field'),
        'user_url' => get_site_option('wp_api_auth_user_url_field'),
        'user_email' => get_site_option('wp_api_auth_user_email_field'),
        'description' => get_site_option('wp_api_auth_description_field'),
        'aim' => get_site_option('wp_api_auth_aim_field'),
        'yim' => get_site_option('wp_api_auth_yim_field'),
        'jabber' => get_site_option('wp_api_auth_jabber_field'),
    );

    // Insert or update the user in wordpress
    $wordpressUser = array(
        'user_login' => $username,
        'user_pass' => $password,
        'first_name' => !empty($fieldMappings['first_name']) ? $externalUser->{$fieldMappings['first_name']} : '',
        'last_name' => !empty($fieldMappings['last_name']) ? $externalUser->{$fieldMappings['last_name']} : '',
        'user_url' => !empty($fieldMappings['user_url']) ? $externalUser->{$fieldMappings['user_url']} : '',
        'user_email' => !empty($fieldMappings['user_email']) ? $externalUser->{$fieldMappings['user_email']} : '',
        'description' => !empty($fieldMappings['description']) ? $externalUser->{$fieldMappings['description']} : '',
        'aim' => !empty($fieldMappings['aim']) ? $externalUser->{$fieldMappings['aim']} : '',
        'yim' => !empty($fieldMappings['yim']) ? $externalUser->{$fieldMappings['yim']} : '',
        'jabber' => !empty($fieldMappings['jabber']) ? $externalUser->{$fieldMappings['jabber']} : '',
    );

    if (!empty($fieldMappings['first_name']) || !empty($fieldMappings['last_name'])) {
        $wordpressUser['display_name'] = $externalUser->{$fieldMappings['first_name']} . ' ' . $externalUser->{$fieldMappings['last_name']};
    }

    if (empty($wordpressUser['display_name'])) {
        $wordpressUser['display_name'] = $username;
    }

    if ($id = username_exists($username)) {
        // If user is already in wordpress, update
        $wordpressUser['ID'] = $id;
        wp_update_user($wordpressUser);
    } else {
        // Otherwise create a new user
        $id = wp_insert_user($wordpressUser);
    }

    return new WP_User($id);

    //return $wordpressUser;
}

function wp_api_auth_get_response($username, $password)
{
    if (!$username || !$password) {
        return false;
    }

    $url = get_site_option('wp_api_auth_url');
    $method = get_site_option('wp_api_auth_method');
    $post = $method === 'POST'; // otherwise GET

    $params = array();
    $params[get_site_option('wp_api_auth_username_field')] = $username;
    $params[get_site_option('wp_api_auth_password_field')] = $password;

    $params = http_build_query($params);

    if ($additionalParams = get_site_option('wp_api_auth_additional_params')) {
        $params .= $additionalParam;
    }

    $ch = curl_init();

    if ($post) {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    } else {
        $url .= '?' . $params;
    }

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    // Makes self-signed certificates work
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    $response = curl_exec($ch);
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    curl_close($ch);

    $jsonResponse = @json_decode($response);

    $return = (object)array(
        'success' => false,
        'error' => null,
        'user' => null
    );

    if ($httpcode === 200) {
        $return->success = true;
        if (!empty($jsonResponse)) {
            if (isset($jsonResponse->user)) {
                $return->user = $jsonResponse->user;
            }
        }
    } else {
        if (!empty($jsonResponse)) {
            if (isset($jsonResponse->error)) {
                $return->error = $jsonResponse->error;
            }
        }
    }

    return $return;
}

/**
 * Displays informational message on login form
 */
function wp_api_auth_login_message($message)
{
    if ($message = get_site_option('wp_api_auth_login_message')) {
        echo '
' . $message . '
';
    } elseif ($message) {
        echo '
' . $message . '
';
    }
}

function wp_auth_api_lost_password()
{
    if ($message = get_site_option('wp_api_auth_lost_password_message')) {
        $errors = new WP_Error();
        $errors->add('registerdisabled', $message);
        login_header(__('Log In'), '', $errors);
        ?>

<a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display')); ?>

        <?php
        exit();
    }
}

/**
 * Display errors on the login page
 */
function wp_api_auth_login_errors($errors)
{
    global $wp_api_auth_error;
    if ($wp_api_auth_error) {
        return $wp_api_auth_error;
    } elseif ($errors) {
        return $errors;
    }
}

/**
 * Disables the password reset option in wp-admin/profile.php
 */
function wp_api_auth_show_password_fields()
{
    return false;
}

/*
 * Disable functions.  Idea taken from http auth plugin.
 */
function wp_auth_api_disable_function_register()
{
    $errors = new WP_Error();
    $errors->add('registerdisabled', __('User registration is not available from this site, so you can\'t create an account or retrieve your password from here. See the message above.'));
    ?></form>

<?php _e('User registration is not available from this site, so you can\'t create an account or retrieve your password from here. See the message above.'); ?>

<a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display')); ?>

    <?php
    exit();
}

function wp_auth_api_disable_function()
{
    $errors = new WP_Error();
    $errors->add('registerdisabled', __('User registration is not available from this site, so you can\'t create an account or retrieve your password from here. See the message above.'));
    login_header(__('Log In'), '', $errors);
    ?>

<a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display')); ?>

    <?php
    exit();
}

/**
 * There doesn't seen to be a way to disable editing name fields,
 * so just hide them instead.
 */
function wp_auth_api_profile_personal_options()
{
    ?>

    <?php
}

// Add settings page
add_action('admin_init', 'wp_api_auth_admin_init');
add_action('network_admin_menu', 'wp_api_auth_network_admin_menu');

// On login
add_action('wp_authenticate', 'wp_api_auth_wp_authenticate', 1, 2);

// Login form
add_filter('login_message', 'wp_api_auth_login_message');
add_filter('login_errors', 'wp_api_auth_login_errors');

// Lost password frorm
add_action('lost_password', 'wp_auth_api_lost_password');

// Disable changing passwords
add_filter('show_password_fields', 'wp_api_auth_show_password_fields');

add_action('retrieve_password', 'wp_auth_api_disable_function');
add_action('password_reset', 'wp_auth_api_disable_function');
add_action('register_form', 'wp_auth_api_disable_function_register');

add_action('profile_personal_options', 'wp_auth_api_profile_personal_options');

register_activation_hook(__FILE__, 'wp_api_auth_activate');


text:
package com.andretrindade.batatas.helpers;

import android.text.TextUtils;

import com.andretrindade.batatas.persistence.BatatasClientProvider;
import com.andretrindade.batatas.persistence.Product;

import java.util.HashMap;
import java.util.List;

import javax.inject.Inject;

public class Finder {
    @Inject
    public BatatasClientProvider.BatatasClient batatas;

    public Finder(BatatasClientProvider.BatatasClient _batatas) {
        batatas = _batatas;
    }

    // Return products array for each matching eanCode
    public HashMap<String, List<String>> FindByEanCodes(List<String> values) {
        HashMap<String, List<String>> cache = Utils.readProductsFromCsv();
        final HashMap<String, List<String>> result = new HashMap<>();
        final List<String> eanCodes = values;

        // Find in cache
        List<String> matchProductsNames;
        for (String eanCode : eanCodes) {
            if ((matchProductsNames = cache.get(eanCode)) != null) {
                Utils.addItemToHash(result, eanCode, matchProductsNames);
                eanCodes.remove(eanCode);
            }
        }

        // Find in online database
        if (result.size() < eanCodes.size()) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        List<Product> matchingProducts = batatas.getProducts_byEanCodes(TextUtils.join(",", eanCodes.toArray()));

                        // Schedule to remove because it's possible N products : 1 eanCode
                        // and we want to avoid getting just first occurrence

                        for (Product product : matchingProducts) {
                            if (eanCodes.contains(product.getEanCode()) && product.getEanCode() != null) {
                                Utils.addItemToHash(result, product.getEanCode(), product.getName());
                                eanCodes.set(eanCodes.indexOf(product.getEanCode()), null);
                                (new CacheManager()).addProducts(product.getEanCode(), product.getName());
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
            thread.start();
            try {
                thread.join();
            } catch (InterruptedException e) {
            }
        }

        return result;
    }

// --Commented out by Inspection START (5/24/15 4:08 AM):
//    public List<ListItem> FindByName(String[] values) {
//        cache = Utils.readProductsFromCsv();
//
//        // TODO: Use simmetrics to match by names
//
//        return new ArrayList<ListItem>();
//    }
// --Commented out by Inspection STOP (5/24/15 4:08 AM)
}


text:
A generic Icon class

Copyright (C) 2012 Nikolay Nemshilov

```coffee-aside
class Icon extends Element
```

Basic constructor

@param {String} icon name/type
@param {Object} html options if necessary
@return {Icon} self

```coffee-aside
  constructor: (name, options)->
    options or= {}
    options['class'] or= ''
    options['class'] += ' ' if options['class'] isnt ''
    options['class'] += 'lui-icon-'+ name

    super('i', options)

    @on 'mousedown', (event)-> event.preventDefault()
```


text:
package com.byteperceptions.require.strategy.scenario.starthotel;

import com.byteperceptions.require.model.HotelChain;
import com.byteperceptions.require.model.Player;
import com.byteperceptions.require.strategy.scenario.playtile.HotelValue;

/**
 * @author Ryan Ylitalo
 *
 */
public class StartHotelScenarioExistingShares implements StartHotelScenario
{

	/**
	 * @see com.byteperceptions.require.strategy.scenario.starthotel.StartHotelScenario#calculateValue(com.byteperceptions.require.model.Player, com.byteperceptions.require.model.HotelChain)
	 */
	@Override
	public int calculateValue(Player player, HotelChain hotelChain)
	{
		return HotelValue.getMaxHotelValueForPlayerByNumberOfStocks(player)
		.getValue();
	}

	/**
	 * @see com.byteperceptions.require.strategy.scenario.starthotel.StartHotelScenario#isPlayerInScenario(com.byteperceptions.require.model.Player, com.byteperceptions.require.model.HotelChain)
	 */
	@Override
	public boolean isPlayerInScenario(Player player, HotelChain hotelChain)
	{
		//Do nothing here... Logic all in calculate
		return false;
	}

}


text:
<?php

namespace hrupin\blog\models;

use Yii;

/**
 * This is the model class for table "blogSeo".
 *
 * @property int $id
 * @property int $id_seo
 * @property string $lang
 * @property string $tag
 * @property string $value
 * @property int $dateCreated
 * @property int $dateUpdated
 */
class BlogSeo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'blogSeo';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id_seo', 'lang', 'tag', 'dateCreated', 'dateUpdated'], 'required'],
            [['id_seo', 'dateCreated', 'dateUpdated'], 'integer'],
            [['value'], 'string'],
            [['lang'], 'string', 'max' => 6],
            [['tag'], 'string', 'max' => 15],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('blog', 'ID'),
            'id_seo' => Yii::t('blog', 'Id Seo'),
            'lang' => Yii::t('blog', 'Lang'),
            'tag' => Yii::t('blog', 'Tag'),
            'value' => Yii::t('blog', 'Value'),
            'dateCreated' => Yii::t('blog', 'Date Created'),
            'dateUpdated' => Yii::t('blog', 'Date Updated'),
        ];
    }

    /**
     * @inheritdoc
     * @return \frontend\models\BlogSeoQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \frontend\models\BlogSeoQuery(get_called_class());
    }
}


text:
namespace blink {

class CompositorWorkerTest : public testing::Test {
public:
    CompositorWorkerTest()
        : m_baseURL("http://www.test.com/")
    {
        RuntimeEnabledFeatures::setCompositorWorkerEnabled(true);
        m_helper.initialize(true, 0, &m_mockWebViewClient, &configureSettings);
        webViewImpl()->resize(IntSize(320, 240));
    }

    ~CompositorWorkerTest() override
    {
        Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
    }

    void navigateTo(const String& url)
    {
        FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url.utf8().data());
    }

    void forceFullCompositingUpdate()
    {
        webViewImpl()->updateAllLifecyclePhases();
    }

    void registerMockedHttpURLLoad(const std::string& fileName)
    {
        URLTestHelpers::registerMockedURLFromBaseURL(m_baseURL, WebString::fromUTF8(fileName.c_str()));
    }

    WebLayer* getRootScrollLayer()
    {
        PaintLayerCompositor* compositor = frame()->contentLayoutObject()->compositor();
        ASSERT(compositor);
        ASSERT(compositor->scrollLayer());

        WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer();
        return webScrollLayer;
    }

    WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); }
    LocalFrame* frame() const { return m_helper.webViewImpl()->mainFrameImpl()->frame(); }

protected:
    String m_baseURL;
    FrameTestHelpers::TestWebViewClient m_mockWebViewClient;

private:
    static void configureSettings(WebSettings* settings)
    {
        settings->setJavaScriptEnabled(true);
        settings->setAcceleratedCompositingEnabled(true);
        settings->setPreferCompositingToLCDTextEnabled(true);
    }

    FrameTestHelpers::WebViewHelper m_helper;
    FrameTestHelpers::UseMockScrollbarSettings m_mockScrollbarSettings;
};

static CompositedLayerMapping* mappingFromElement(Element* element)
{
    if (!element)
        return nullptr;
    LayoutObject* layoutObject = element->layoutObject();
    if (!layoutObject || !layoutObject->isBoxModelObject())
        return nullptr;
    PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer();
    if (!layer)
        return nullptr;
    if (!layer->hasCompositedLayerMapping())
        return nullptr;
    return layer->compositedLayerMapping();
}

static WebLayer* webLayerFromGraphicsLayer(GraphicsLayer* graphicsLayer)
{
    if (!graphicsLayer)
        return nullptr;
    return graphicsLayer->platformLayer();
}

static WebLayer* scrollingWebLayerFromElement(Element* element)
{
    CompositedLayerMapping* compositedLayerMapping = mappingFromElement(element);
    if (!compositedLayerMapping)
        return nullptr;
    return webLayerFromGraphicsLayer(compositedLayerMapping->scrollingContentsLayer());
}

static WebLayer* webLayerFromElement(Element* element)
{
    CompositedLayerMapping* compositedLayerMapping = mappingFromElement(element);
    if (!compositedLayerMapping)
        return nullptr;
    return webLayerFromGraphicsLayer(compositedLayerMapping->mainGraphicsLayer());
}

TEST_F(CompositorWorkerTest, plumbingElementIdAndMutableProperties)
{
    registerMockedHttpURLLoad("compositor-proxy-basic.html");
    navigateTo(m_baseURL + "compositor-proxy-basic.html");

    forceFullCompositingUpdate();

    Document* document = frame()->document();

    Element* tallElement = document->getElementById("tall");
    WebLayer* tallLayer = webLayerFromElement(tallElement);
    EXPECT_TRUE(!tallLayer);

    Element* proxiedElement = document->getElementById("proxied");
    WebLayer* proxiedLayer = webLayerFromElement(proxiedElement);
    EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & WebCompositorMutablePropertyTransform);
    EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (WebCompositorMutablePropertyScrollLeft | WebCompositorMutablePropertyScrollTop | WebCompositorMutablePropertyOpacity));
    EXPECT_NE(0UL, proxiedLayer->elementId());

    Element* scrollElement = document->getElementById("proxied-scroller");
    WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement);
    EXPECT_TRUE(scrollLayer->compositorMutableProperties() & (WebCompositorMutablePropertyScrollLeft | WebCompositorMutablePropertyScrollTop));
    EXPECT_FALSE(scrollLayer->compositorMutableProperties() & (WebCompositorMutablePropertyTransform | WebCompositorMutablePropertyOpacity));
    EXPECT_NE(0UL, scrollLayer->elementId());

    WebLayer* rootScrollLayer = getRootScrollLayer();
    EXPECT_TRUE(rootScrollLayer->compositorMutableProperties() & (WebCompositorMutablePropertyScrollLeft | WebCompositorMutablePropertyScrollTop));
    EXPECT_FALSE(rootScrollLayer->compositorMutableProperties() & (WebCompositorMutablePropertyTransform | WebCompositorMutablePropertyOpacity));

    EXPECT_NE(0UL, rootScrollLayer->elementId());
}

TEST_F(CompositorWorkerTest, noProxies)
{
    // This case is identical to compositor-proxy-basic, but no proxies have
    // actually been created.
    registerMockedHttpURLLoad("compositor-proxy-plumbing-no-proxies.html");
    navigateTo(m_baseURL + "compositor-proxy-plumbing-no-proxies.html");

    forceFullCompositingUpdate();

    Document* document = frame()->document();

    Element* tallElement = document->getElementById("tall");
    WebLayer* tallLayer = webLayerFromElement(tallElement);
    EXPECT_TRUE(!tallLayer);

    Element* proxiedElement = document->getElementById("proxied");
    WebLayer* proxiedLayer = webLayerFromElement(proxiedElement);
    EXPECT_TRUE(!proxiedLayer);

    Element* scrollElement = document->getElementById("proxied-scroller");
    WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement);
    EXPECT_FALSE(!!scrollLayer->compositorMutableProperties());
    EXPECT_EQ(0UL, scrollLayer->elementId());

    WebLayer* rootScrollLayer = getRootScrollLayer();
    EXPECT_FALSE(!!rootScrollLayer->compositorMutableProperties());
    EXPECT_EQ(0UL, rootScrollLayer->elementId());
}

TEST_F(CompositorWorkerTest, disconnectedProxies)
{
    // This case is identical to compositor-proxy-basic, but the proxies are
    // disconnected (the result should be the same as compositor-proxy-plumbing-no-proxies).
    registerMockedHttpURLLoad("compositor-proxy-basic-disconnected.html");
    navigateTo(m_baseURL + "compositor-proxy-basic-disconnected.html");

    forceFullCompositingUpdate();

    Document* document = frame()->document();

    Element* tallElement = document->getElementById("tall");
    WebLayer* tallLayer = webLayerFromElement(tallElement);
    EXPECT_TRUE(!tallLayer);

    Element* proxiedElement = document->getElementById("proxied");
    WebLayer* proxiedLayer = webLayerFromElement(proxiedElement);
    EXPECT_TRUE(!proxiedLayer);

    Element* scrollElement = document->getElementById("proxied-scroller");
    WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement);
    EXPECT_FALSE(!!scrollLayer->compositorMutableProperties());
    EXPECT_EQ(0UL, scrollLayer->elementId());

    WebLayer* rootScrollLayer = getRootScrollLayer();
    EXPECT_FALSE(!!rootScrollLayer->compositorMutableProperties());
    EXPECT_EQ(0UL, rootScrollLayer->elementId());
}

} // namespace blink


text:
package com.seachangesimulations.osp.teamscores;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.usip.osp.baseobjects.CustomizeableSection;
import org.usip.osp.baseobjects.core.Customizer;
import org.usip.osp.networking.SessionObjectBase;

public class TeamScoresCustomizer  extends Customizer{

	public static final String KEY_FOR_PAGETITLE = "teamscores_page_title"; //$NON-NLS-1$

	@Override
	public void handleCustomizeSection(HttpServletRequest request,
			SessionObjectBase afso, CustomizeableSection cs) {

		Logger.getRootLogger().debug("TeamScoresCustomizer.handleCustomizeSection"); //$NON-NLS-1$

		String save_results = request.getParameter("save_results"); //$NON-NLS-1$

		if ((save_results != null) && (save_results.equalsIgnoreCase("true"))) { //$NON-NLS-1$

			Logger.getRootLogger().debug("GridDocCustomizer.handleCustomizeSection.save_results"); //$NON-NLS-1$

			cs.setBigString(request.getParameter("cs_bigstring"));

			cs.getContents().put(KEY_FOR_PAGETITLE, request.getParameter(KEY_FOR_PAGETITLE));

			cs.saveMe(afso.schema);

		}

	}

	@Override
	public void loadSimCustomizeSection(HttpServletRequest request,
			SessionObjectBase pso, CustomizeableSection cs) {
		// TODO Auto-generated method stub

	}

	@Override
	public void loadSimCustomSectionForEditing(HttpServletRequest request,
			SessionObjectBase pso, CustomizeableSection cs) {
		// TODO Auto-generated method stub

	}

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.IO;
using System.Net.Sockets;

using ProtoBuf;
using MetaLinkProtobuf = edu.vanderbilt.isis.meta;

namespace CyPhyMetaLinkBridgeClient
{
    class FrameReader {

        private Socket _socket;
        private NetworkStream _networkStream;
        private BufferedStream _bufferedStream;

        private MemoryStream _memoryStream = new MemoryStream();

        private long _mark = 0;

        public FrameReader(Socket socket) {
            _socket = socket;
            _networkStream = new NetworkStream(_socket);
            _bufferedStream = new BufferedStream(_networkStream);
        }

        public void enQueue(long count) {
            if (count <= 0)
                return;
            long memoryStreamReadPointer = _memoryStream.Position;
            _memoryStream.Seek(0, SeekOrigin.End);
            byte[] buffer = new byte[1024 * 4];
            while (count > 0)
            {
                int bytesRead = _bufferedStream.Read(buffer, 0, Math.Min((int)Math.Min(Int32.MaxValue, count), buffer.Length));
                _memoryStream.Write(buffer, 0, bytesRead);
                count -= bytesRead;
            }
            _memoryStream.Seek(memoryStreamReadPointer, SeekOrigin.Begin);
        }

        public void Read(byte[] buffer, int offset, int count) {
            enQueue(count - (_memoryStream.Length - _memoryStream.Position));
            _memoryStream.Read(buffer, offset, count);
        }

        public int ReadByte() {
            enQueue(1L - (_memoryStream.Length - _memoryStream.Position));

            return _memoryStream.ReadByte();
        }

        public void getBytes(int memoryStreamOffset, byte[] buffer) {
            Array.Copy(_memoryStream.GetBuffer(), _mark + memoryStreamOffset, buffer, 0, buffer.Length);
        }

        public long Length {
            get { return _memoryStream.Length - _mark; }
        }

        private void rewind() {
            _memoryStream.Seek(_mark, SeekOrigin.Begin);
        }

        private void drop() {
            if (_mark < 1024) return;
            if (_memoryStream.Length < _mark) return;

            long newLength = _memoryStream.Length - _mark;
            long newPosition = _memoryStream.Position - _mark;

            byte[] swapper = new byte[ newLength ];
            Array.Copy(_memoryStream.GetBuffer(), _mark, swapper, 0, newLength);

            _memoryStream = new MemoryStream();
            _memoryStream.Write(swapper, 0, (int)newLength);
            _memoryStream.Seek(newPosition, SeekOrigin.Begin);

            _mark = 0;
        }

        private void dropRelative( int offset ) {
            _mark += offset;
            drop();
        }

        private void dropAbsolute( long position ) {
            _mark = position;
            drop();
        }

        private void dropMagic() {
            dropRelative(4);
            rewind();
        }

        private void dropToCurrent() {
            dropAbsolute(_memoryStream.Position);
        }

        private void getMagic() {
            int state = 0;
            while (true) {
                int byte_var = ReadByte();
                switch (state) {
                    case 0: {
                        if (byte_var == 0xDE) state = 1;
                        else dropRelative(1);
                        break;
                    }
                    case 1: {
                        if (byte_var == 0xAD) {
                            state = 2;
                        } else {
                            state = 0;
                            dropRelative(2);
                        }
                        break;
                    }
                    case 2: {
                        if (byte_var == 0xBE) {
                            state = 3;
                        } else {
                            state = 0;
                            dropRelative(3);
                        }
                        break;
                    }
                    case 3: {
                        if (byte_var == 0xEF) return;
                        state = 0;
                        dropRelative(4);
                        break;
                    }
                }
            }
        }

        private byte[] getCrc32(byte[] data, long dataLength) {
            CRC32 crc32 = new CRC32();
            crc32.Initialize();
            byte[] hash = crc32.ComputeHash(data, 0, (int)dataLength);
            Array.Reverse(hash);
            return hash;
        }

        public MetaLinkProtobuf.Edit getMessage()
        {

            while (true) {

                getMagic();

                byte[] sizeBuf = new byte[4];
                byte[] reserved = new byte[2];
                byte[] payloadHashBuf = new byte[4];
                byte[] headerHashBuf = new byte[4];

                enQueue(4 + 1 + 1 + 2 + 4 + 4);
                Read(sizeBuf, 0, 4);

                ReadByte();
                ReadByte();
                Read(reserved, 0, 2);

                Read(payloadHashBuf, 0, 4);
                Read(headerHashBuf, 0, 4);

                if (BitConverter.IsLittleEndian) {
                    Array.Reverse(sizeBuf);
                    Array.Reverse(payloadHashBuf);
                    Array.Reverse(headerHashBuf);
                }
                int size = BitConverter.ToInt32(sizeBuf, 0);
                int payloadHash = BitConverter.ToInt32(payloadHashBuf, 0);
                int headerHash = BitConverter.ToInt32(headerHashBuf, 0);

                byte[] payload = new byte[size];
                Read(payload, 0, size);

                byte[] finalPayloadHashBuf = new byte[4];
                Read(finalPayloadHashBuf, 0, 4);
                if (BitConverter.IsLittleEndian) {
                    Array.Reverse(finalPayloadHashBuf);
                }
                int finalPayloadHash = BitConverter.ToInt32(finalPayloadHashBuf, 0);

                byte[] frame = new byte[16];
                getBytes(0, frame);

                byte[] expectedPayloadHashBuf = getCrc32(payload, size);
                byte[] expectedFrameHashBuf = getCrc32(frame, frame.Length);
                if (BitConverter.IsLittleEndian) {
                    Array.Reverse(expectedPayloadHashBuf);
                    Array.Reverse(expectedFrameHashBuf);
                }
                int expectedPayloadHash = BitConverter.ToInt32(expectedPayloadHashBuf, 0);
                int expectedFrameHash = BitConverter.ToInt32(expectedFrameHashBuf, 0);

                if (expectedPayloadHash != payloadHash) {
                    dropMagic();
                    continue;
                }

                if (expectedFrameHash != headerHash) {
                    dropMagic();
                    continue;
                }

                if (finalPayloadHash != payloadHash) {
                    dropMagic();
                    continue;
                }
                dropAbsolute((int)_memoryStream.Position);

                MemoryStream payloadMemoryStream = new MemoryStream(payload);

                MetaLinkProtobuf.Edit message = Serializer.Deserialize<MetaLinkProtobuf.Edit>(payloadMemoryStream);
                return message;
            }

        }
    }
}


text:
set(IMPALA_TOOLCHAIN ON)

# Set the root directory for the toolchain
set(TOOLCHAIN_ROOT $ENV{IMPALA_TOOLCHAIN})

# If Impala is built with the toolchain, change compiler and link paths
set(GCC_ROOT $ENV{IMPALA_TOOLCHAIN}/gcc-$ENV{IMPALA_GCC_VERSION})

# Use LLVM Trunk to build asan
set(LLVM_TRUNK_ROOT $ENV{IMPALA_TOOLCHAIN}/llvm-trunk)

set(CMAKE_C_COMPILER ${LLVM_TRUNK_ROOT}/bin/clang)
set(CMAKE_CXX_COMPILER ${LLVM_TRUNK_ROOT}/bin/clang++)

# Add the GCC root location to the compiler flags
# TODO: remove no-c++11-extensions when we enable c++11
set(CXX_COMMON_FLAGS "-Wno-unused-local-typedef -Wno-c++11-extensions --gcc-toolchain=${GCC_ROOT}")

# The rpath is needed to be able to run the binaries produced by the toolchain without
# specifying an LD_LIBRARY_PATH
set(TOOLCHAIN_LINK_FLAGS "-Wl,-rpath,${GCC_ROOT}/lib64")
set(TOOLCHAIN_LINK_FLAGS "${TOOLCHAIN_LINK_FLAGS} -L${GCC_ROOT}/lib64")

message(STATUS "Setup toolchain link flags ${TOOLCHAIN_LINK_FLAGS}")


text:
package com.google.cloud.bigquery;

import com.google.api.services.bigquery.model.UserDefinedFunctionResource;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;

import java.io.Serializable;
import java.util.Objects;

/**
 * Google BigQuery User Defined Function. BigQuery supports user-defined functions (UDFs) written in
 * JavaScript. A UDF is similar to the "Map" function in a MapReduce: it takes a single row as input
 * and produces zero or more rows as output. The output can potentially have a different schema than
 * the input.
 *
 * @see <a href="https://cloud.google.com/bigquery/user-defined-functions">User-Defined Functions
 *     </a>
 */
public abstract class UserDefinedFunction implements Serializable {

  static final Function<UserDefinedFunctionResource, UserDefinedFunction> FROM_PB_FUNCTION =
      new Function<UserDefinedFunctionResource, UserDefinedFunction>() {
        @Override
        public UserDefinedFunction apply(UserDefinedFunctionResource userDefinedFunctionPb) {
          return UserDefinedFunction.fromPb(userDefinedFunctionPb);
        }
      };
  static final Function<UserDefinedFunction, UserDefinedFunctionResource> TO_PB_FUNCTION =
      new Function<UserDefinedFunction, UserDefinedFunctionResource>() {
        @Override
        public UserDefinedFunctionResource apply(UserDefinedFunction userDefinedFunction) {
          return userDefinedFunction.toPb();
        }
      };

  private static final long serialVersionUID = 8704260561787440287L;

  /**
   * Type of user-defined function. User defined functions can be provided inline as code blobs
   * ({@link #INLINE}) or as a Google Cloud Storage URI ({@link #FROM_URI}).
   */
  public enum Type {
    INLINE,
    FROM_URI
  }

  private final Type type;
  private final String content;

  UserDefinedFunction(Type type, String content) {
    this.type = type;
    this.content = content;
  }

  /**
   * Returns the type of user defined function.
   */
  @Deprecated
  public Type type() {
    return getType();
  }

  /**
   * Returns the type of user defined function.
   */
  public Type getType() {
    return type;
  }

  /**
   * If {@link #type()} is {@link Type#INLINE} this method returns a code blob. If {@link #type()}
   * is {@link Type#FROM_URI} the method returns a Google Cloud Storage URI (e.g. gs://bucket/path).
   */
  @Deprecated
  public String content() {
    return getContent();
  }

  /**
   * If {@link #type()} is {@link Type#INLINE} this method returns a code blob. If {@link #type()}
   * is {@link Type#FROM_URI} the method returns a Google Cloud Storage URI (e.g. gs://bucket/path).
   */
  public String getContent() {
    return content;
  }

  /**
   * A Google Cloud BigQuery user-defined function, as a code blob.
   */
  static final class InlineFunction extends UserDefinedFunction {

    private static final long serialVersionUID = 1083672109192091686L;

    InlineFunction(String inlineCode) {
      super(Type.INLINE, inlineCode);
    }

    @Override
    public String toString() {
      return MoreObjects.toStringHelper(this).add("inlineCode", getContent()).toString();
    }

    @Override
    public com.google.api.services.bigquery.model.UserDefinedFunctionResource toPb() {
      return new com.google.api.services.bigquery.model.UserDefinedFunctionResource()
          .setInlineCode(getContent());
    }
  }

  /**
   * A Google Cloud BigQuery user-defined function, as an URI to Google Cloud Storage.
   */
  static final class UriFunction extends UserDefinedFunction {

    private static final long serialVersionUID = 4660331691852223839L;

    UriFunction(String functionUri) {
      super(Type.FROM_URI, functionUri);
    }

    @Override
    public String toString() {
      return MoreObjects.toStringHelper(this).add("functionUri", getContent()).toString();
    }

    @Override
    public com.google.api.services.bigquery.model.UserDefinedFunctionResource toPb() {
      return new com.google.api.services.bigquery.model.UserDefinedFunctionResource()
          .setResourceUri(getContent());
    }
  }

  @Override
  public int hashCode() {
    return Objects.hash(type, content);
  }

  @Override
  public boolean equals(Object obj) {
    return obj instanceof UserDefinedFunction
        && Objects.equals(toPb(), ((UserDefinedFunction) obj).toPb());
  }

  public abstract com.google.api.services.bigquery.model.UserDefinedFunctionResource toPb();

  /**
   * Creates a Google Cloud BigQuery user-defined function given a code blob.
   */
  public static UserDefinedFunction inline(String functionDefinition) {
    return new InlineFunction(functionDefinition);
  }

  /**
   * Creates a Google Cloud BigQuery user-defined function given a Google Cloud Storage URI (e.g.
   * gs://bucket/path).
   */
  public static UserDefinedFunction fromUri(String functionDefinition) {
    return new UriFunction(functionDefinition);
  }

  static UserDefinedFunction fromPb(
      com.google.api.services.bigquery.model.UserDefinedFunctionResource pb) {
    if (pb.getInlineCode() != null) {
      return new InlineFunction(pb.getInlineCode());
    }
    if (pb.getResourceUri() != null) {
      return new UriFunction(pb.getResourceUri());
    }
    throw new IllegalArgumentException("Invalid user-defined function");
  }
}


text:
..  BSD LICENSE
    Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:

    * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in
    the documentation and/or other materials provided with the
    distribution.
    * Neither the name of Intel Corporation nor the names of its
    contributors may be used to endorse or promote products derived
    from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

.. _building_from_source:

Compiling the DPDK Target from Source
=====================================

System Requirements
-------------------

The DPDK and its applications require the GNU make system (gmake)
to build on FreeBSD. Optionally, gcc may also be used in place of clang
to build the DPDK, in which case it too must be installed prior to
compiling the DPDK. The installation of these tools is covered in this
section.

Compiling the DPDK requires the FreeBSD kernel sources, which should be
included during the installation of FreeBSD on the development platform.
The DPDK also requires the use of FreeBSD ports to compile and function.

To use the FreeBSD ports system, it is required to update and extract the FreeBSD
ports tree by issuing the following commands:

.. code-block:: console

    portsnap fetch
    portsnap extract

If the environment requires proxies for external communication, these can be set
using:

.. code-block:: console

    setenv http_proxy <my_proxy_host>:<port>
    setenv ftp_proxy <my_proxy_host>:<port>

The FreeBSD ports below need to be installed prior to building the DPDK.
In general these can be installed using the following set of commands::

   cd /usr/ports/<port_location>

   make config-recursive

   make install

   make clean

Each port location can be found using::

   whereis <port_name>

The ports required and their locations are as follows:

* dialog4ports: ``/usr/ports/ports-mgmt/dialog4ports``

* GNU make(gmake): ``/usr/ports/devel/gmake``

* coreutils: ``/usr/ports/sysutils/coreutils``

For compiling and using the DPDK with gcc, the compiler must be installed
from the ports collection:

* gcc: version 4.8 is recommended ``/usr/ports/lang/gcc48``.
  Ensure that ``CPU_OPTS`` is selected (default is OFF).

When running the make config-recursive command, a dialog may be presented to the
user. For the installation of the DPDK, the default options were used.

.. note::

    To avoid multiple dialogs being presented to the user during make install,
    it is advisable before running the make install command to re-run the
    make config-recursive command until no more dialogs are seen.

Install the DPDK and Browse Sources
-----------------------------------

First, uncompress the archive and move to the DPDK source directory:

.. code-block:: console

    unzip DPDK-<version>.zip
    cd DPDK-<version>

    ls
    app/ config/ examples/ lib/ LICENSE.GPL LICENSE.LGPL Makefile
    mk/ scripts/ tools/

The DPDK is composed of several directories:

*   lib: Source code of DPDK libraries

*   app: Source code of DPDK applications (automatic tests)

*   examples: Source code of DPDK applications

*   config, tools, scripts, mk: Framework-related makefiles, scripts and configuration

Installation of the DPDK Target Environments
--------------------------------------------

The format of a DPDK target is::

   ARCH-MACHINE-EXECENV-TOOLCHAIN

Where:

* ``ARCH`` is: ``x86_64``

* ``MACHINE`` is: ``native``

* ``EXECENV`` is: ``bsdapp``

* ``TOOLCHAIN`` is: ``gcc`` | ``clang``

The configuration files for the DPDK targets can be found in the DPDK/config
directory in the form of::

    defconfig_ARCH-MACHINE-EXECENV-TOOLCHAIN

.. note::

   Configuration files are provided with the ``RTE_MACHINE`` optimization level set.
   Within the configuration files, the ``RTE_MACHINE`` configuration value is set
   to native, which means that the compiled software is tuned for the platform
   on which it is built.  For more information on this setting, and its
   possible values, see the *DPDK Programmers Guide*.

To make the target, use ``gmake install T=<target>``.

For example to compile for FreeBSD use:

.. code-block:: console

    gmake install T=x86_64-native-bsdapp-clang

.. note::

   If the compiler binary to be used does not correspond to that given in the
   TOOLCHAIN part of the target, the compiler command may need to be explicitly
   specified. For example, if compiling for gcc, where the gcc binary is called
   gcc4.8, the command would need to be ``gmake install T=<target> CC=gcc4.8``.

Browsing the Installed DPDK Environment Target
----------------------------------------------

Once a target is created, it contains all the libraries and header files for the
DPDK environment that are required to build customer applications.
In addition, the test and testpmd applications are built under the build/app
directory, which may be used for testing.  A kmod directory is also present that
contains the kernel modules to install:

.. code-block:: console

    ls x86_64-native-bsdapp-gcc

    app build hostapp include kmod lib Makefile

.. _loading_contigmem:

Loading the DPDK contigmem Module
---------------------------------

To run a DPDK application, physically contiguous memory is required.
In the absence of non-transparent superpages, the included sources for the
contigmem kernel module provides the ability to present contiguous blocks of
memory for the DPDK to use. The contigmem module must be loaded into the
running kernel before any DPDK is run.  The module is found in the kmod
sub-directory of the DPDK target directory.

The amount of physically contiguous memory along with the number of physically
contiguous blocks to be reserved by the module can be set at runtime prior to
module loading using:

.. code-block:: console

    kenv hw.contigmem.num_buffers=n
    kenv hw.contigmem.buffer_size=m

The kernel environment variables can also be specified during boot by placing the
following in ``/boot/loader.conf``::

    hw.contigmem.num_buffers=n hw.contigmem.buffer_size=m

The variables can be inspected using the following command:

.. code-block:: console

    sysctl -a hw.contigmem

Where n is the number of blocks and m is the size in bytes of each area of
contiguous memory.  A default of two buffers of size 1073741824 bytes (1 Gigabyte)
each is set during module load if they are not specified in the environment.

The module can then be loaded using kldload (assuming that the current directory
is the DPDK target directory):

.. code-block:: console

    kldload ./kmod/contigmem.ko

It is advisable to include the loading of the contigmem module during the boot
process to avoid issues with potential memory fragmentation during later system
up time.  This can be achieved by copying the module to the ``/boot/kernel/``
directory and placing the following into ``/boot/loader.conf``::

    contigmem_load="YES"

.. note::

    The contigmem_load directive should be placed after any definitions of
    ``hw.contigmem.num_buffers`` and ``hw.contigmem.buffer_size`` if the default values
    are not to be used.

An error such as:

.. code-block:: console

    kldload: can't load ./x86_64-native-bsdapp-gcc/kmod/contigmem.ko:
             Exec format error

is generally attributed to not having enough contiguous memory
available and can be verified via dmesg or ``/var/log/messages``:

.. code-block:: console

    kernel: contigmalloc failed for buffer <n>

To avoid this error, reduce the number of buffers or the buffer size.

.. _loading_nic_uio:

Loading the DPDK nic_uio Module
-------------------------------

After loading the contigmem module, the ``nic_uio must`` also be loaded into the
running kernel prior to running any DPDK application.  This module must
be loaded using the kldload command as shown below (assuming that the current
directory is the DPDK target directory).

.. code-block:: console

    kldload ./kmod/nic_uio.ko

.. note::

    If the ports to be used are currently bound to a existing kernel driver
    then the ``hw.nic_uio.bdfs sysctl`` value will need to be set before loading the
    module. Setting this value is described in the next section below.

Currently loaded modules can be seen by using the ``kldstat`` command and a module
can be removed from the running kernel by using ``kldunload <module_name>``.

To load the module during boot, copy the ``nic_uio`` module to ``/boot/kernel``
and place the following into ``/boot/loader.conf``::

    nic_uio_load="YES"

.. note::

    ``nic_uio_load="YES"`` must appear after the contigmem_load directive, if it exists.

By default, the ``nic_uio`` module will take ownership of network ports if they are
recognized DPDK devices and are not owned by another module. However, since
the FreeBSD kernel includes support, either built-in, or via a separate driver
module, for most network card devices, it is likely that the ports to be used are
already bound to a driver other than ``nic_uio``. The following sub-section describe
how to query and modify the device ownership of the ports to be used by
DPDK applications.

.. _binding_network_ports:

Binding Network Ports to the nic_uio Module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Device ownership can be viewed using the pciconf -l command. The example below shows
four Intel® 82599 network ports under ``if_ixgbe`` module ownership.

.. code-block:: console

    pciconf -l
    ix0@pci0:1:0:0: class=0x020000 card=0x00038086 chip=0x10fb8086 rev=0x01 hdr=0x00
    ix1@pci0:1:0:1: class=0x020000 card=0x00038086 chip=0x10fb8086 rev=0x01 hdr=0x00
    ix2@pci0:2:0:0: class=0x020000 card=0x00038086 chip=0x10fb8086 rev=0x01 hdr=0x00
    ix3@pci0:2:0:1: class=0x020000 card=0x00038086 chip=0x10fb8086 rev=0x01 hdr=0x00

The first column constitutes three components:

#. Device name: ``ixN``

#. Unit name: ``pci0``

#. Selector (Bus:Device:Function): ``1:0:0``

Where no driver is associated with a device, the device name will be ``none``.

By default, the FreeBSD kernel will include built-in drivers for the most common
devices; a kernel rebuild would normally be required to either remove the drivers
or configure them as loadable modules.

To avoid building a custom kernel, the ``nic_uio`` module can detach a network port
from its current device driver. This is achieved by setting the ``hw.nic_uio.bdfs``
kernel environment variable prior to loading ``nic_uio``, as follows::

    hw.nic_uio.bdfs="b:d:f,b:d:f,..."

Where a comma separated list of selectors is set, the list must not contain any
whitespace.

For example to re-bind ``ix2@pci0:2:0:0`` and ``ix3@pci0:2:0:1`` to the ``nic_uio`` module
upon loading, use the following command::

    kenv hw.nic_uio.bdfs="2:0:0,2:0:1"

The variable can also be specified during boot by placing the following into
``/boot/loader.conf``, before the previously-described ``nic_uio_load`` line - as
shown::

    hw.nic_uio.bdfs="2:0:0,2:0:1"
    nic_uio_load="YES"

Binding Network Ports Back to their Original Kernel Driver
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If the original driver for a network port has been compiled into the kernel,
it is necessary to reboot FreeBSD to restore the original device binding. Before
doing so, update or remove the ``hw.nic_uio.bdfs`` in ``/boot/loader.conf``.

If rebinding to a driver that is a loadable module, the network port binding can
be reset without rebooting. To do so, unload both the target kernel module and the
``nic_uio`` module, modify or clear the ``hw.nic_uio.bdfs`` kernel environment (kenv)
value, and reload the two drivers - first the original kernel driver, and then
the ``nic_uio driver``. Note: the latter does not need to be reloaded unless there are
ports that are still to be bound to it.

Example commands to perform these steps are shown below:

.. code-block:: console

    kldunload nic_uio
    kldunload <original_driver>

    # To clear the value completely:
    kenv -u hw.nic_uio.bdfs

    # To update the list of ports to bind:
    kenv hw.nic_uio.bdfs="b:d:f,b:d:f,..."

    kldload <original_driver>

    kldload nic_uio  # optional


text:
/*
 * $Id$
 */

/*

Copyright (c) 2000-2016 Board of Trustees of Leland Stanford Jr. University,
all rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the \"Software\"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
STANFORD UNIVERSITY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of Stanford University shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Stanford University.

*/

package org.lockss.plugin.atypon.wageningen;

import java.io.*;

import junit.framework.Test;

import org.lockss.util.*;
import org.lockss.config.ConfigManager;
import org.lockss.config.Configuration;
import org.lockss.daemon.PluginException;
import org.lockss.plugin.ArchivalUnit;
import org.lockss.plugin.FilterFactory;
import org.lockss.plugin.PluginManager;
import org.lockss.plugin.PluginTestUtil;
import org.lockss.test.*;

public class TestWageningenJournalsHtmlFilterFactory extends LockssTestCase {

  FilterFactory variantFact;
  ArchivalUnit wau;
  String tempDirPath;
  MockLockssDaemon daemon;
  PluginManager pluginMgr;

  private static final String PLUGIN_ID =
      "org.lockss.plugin.atypon.wageningen.ClockssWageningenJournalsPlugin";

  private static final String filteredStr =
      "

";

  // breadcrumbs
  private static final String withBreadcrumbs =
      "
" +
      "
" +
      "
Home" +
      ">
" +
      "
ABC Journals" +
      ">
" +
      "
issues" +
      ">
" +
      "
Volume 9, Issue 9" +
      ">
" +
      "
The development of blah
" +
      "
" +
      "
";

  private static final String withAriaRelevant =
      "
" +
      "
" +
      "
" +
      "
" +
      "
" +
      "
" +
      "
" +
      "
" +
      "
" +
      "
" +
      "

" +
      "Canada blah blah" +
      "
" +
      "
" +
      "
" +
      "Tim Ra" +
      "

" +
      "

" +
      "

" +
      "
";

  private static final String withRelatedContent =
      "
" +
      "

" +
      "
";

  // for testcrawl
  // from abs - all Articles Options and Tools except Download Citation
  private static final String withArticleToolsExceptDownloadCitation1 =
      "
" +
      "
" +
      "
" +
      "
Add to Fav
" +
      "
Email friends
" +
      "
" +
      "" +
      "Send to Citation Mgr" +
      "

" +
      "
";

  // id tag also got filtered
  private static final String articleToolsFilteredStr1 =
      "
" +
      "
" +
      "
" +
      "
" +
      "" +
      "Send to Citation Mgr" +
      "

" +
      "
";

  private static final String withPublicationToolContainer =
      "
" +
      "
" +
      "
" +
      "<fieldset class=\"tocListWidgetContainer\">" +
      "
" +
      "
" +
      "<input type=\"checkbox\" name=\"markall\" id=\"markall\" " +
      "onclick=\"onClickMarkAll(frmAbs,'')\">Select All" +
      "
" +
      "
" +
      "" +
      "For selected items:" +
      "" +
      "<select name=\"articleTool\" class=\"items-choice " +
      "publicationToolSelect\" title=\"Article Tools\">" +
      "<option value=\"\">Please select</option>" +
      "<option value=\"/addfav\">Add to Favorites</option>" +
      "<option value=\"/trackcit\">Track Citation</option>" +
      "<option value=\"/showcit\">Download Citation</option>" +
      "<option value=\"/emailto\">Email</option>" +
      "</select>" +
      "
" +
      "
" +
      "</fieldset>" +
      "
" +
      "
" +
      "
";

  // attributes separated by 1 space
  private static final String publicationToolContainerFilteredStr =
      "
" +
      "
" +
      " <fieldset class=\"tocListWidgetContainer\">" +
      " </fieldset>" +
      "
" +
      "
";

  private static final String withArticleMetaDrop =
       "
" +
      "
" +
      "
" +
      "
" +
      "
";

  private static final String articleMetaDropFilteredStr =
      "
" +
      "
";

   private static final String withArticleToolsExceptDownloadCitation2 =
       "
" +
       "
" +
       "
" +
       "
" +
       "
" +
       "Add to Fav
" +
       "
Email friends
" +
       "
" +
       "" +
       "Send to Citation Mgr" +
       "

" +
       "
" +
       "
";

  private static final String articleToolsFilteredStr2 =
      "
" +
      "
" +
      "
" +
      "
" +
      " " +
      "Send to Citation Mgr

";

  private static final String tooltipHtml =
      "
" +
      " X. Ya" +
      "" +
      "Related information" +
      "
" +
      "1Laboratory of Study, " +
      "College of Study, " +
      "China University, Beijing 100083, China P.R.

, " +
      "
";
  private static final String tooltipFiltered =
      "
" +
      "  X. Ya " +
      ", " +
      "
";

  private static final String toolsTab =
      "
" +
          "
" +
          "
" +
          "
" +
          "Tools" +
          "
" +
          "
" +
          "Most Read" +
          "
" +
          "
" +
          "Most Cited" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
Site Tools
" +
          "
" +
          "
" +
          "Sign up for e-alerts" +
          "
" +
          "
" +
          "" +
          "" +
          "(What is this?)" +
          "" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "Add to Favorites" +
          "
" +
          "
" +
          "Email a Friend" +
          "
" +
          "
" +
          "Download Citation Data" +
          "
" +
          "
" +
          "Track Citations" +
          "
" +
          "
" +
          "</div" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "

" +
          "
" +
          "See More" +
          "
" +
          "</section" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "

" +
          "</section" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
";
// remove everything except for the tree to the one piece we need
  private static final String toolsTabCrawlFiltered =
      "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
Download Citation Data" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
" +
          "
";

// ?? use this block when manifest pages are up
//    private static final String manifestList =
//        "
" +
//            "
" +
//            "" +
//            "2012 (Vol. 123 Issue 4 Page 456-789)" +
//            "
" +
//            "
";
//    private static final String manifestListFilteredStr =
//        "" +
//            "2012 (Vol. 123 Issue 4 Page 456-789)";
//
//    private static final String nonManifestList1 =
//        "
" +
//            "
" +
//            "Volume 123, Issue 4" +
//            "
" +
//            "
";
//  private static final String nonManifestList1FilteredStr = "";
//
//  private static final String nonManifestList2 =
//      "
" +
//          "
" +
//          "EarlyCite" +
//          "
" +
//          "
" +
//          "Current Issue" +
//          "
" +
//          "
";
//  private static final String nonManifestList2FilteredStr = "";

  protected ArchivalUnit createAu()
      throws ArchivalUnit.ConfigurationException {
    return PluginTestUtil.createAndStartAu(PLUGIN_ID,  wageningenAuConfig());
  }

  private Configuration wageningenAuConfig() {
    Configuration conf = ConfigManager.newConfiguration();
    conf.put("base_url", "http://www.example.com/");
    conf.put("journal_id", "abc");
    conf.put("volume_name", "99");
    return conf;
  }

  private static void doFilterTest(ArchivalUnit au,
      FilterFactory fact, String nameToHash, String expectedStr)
          throws PluginException, IOException {
    InputStream actIn;
    actIn = fact.createFilteredInputStream(au,
        new StringInputStream(nameToHash), Constants.DEFAULT_ENCODING);
    //for debug
    //String actualStr = StringUtil.fromInputStream(actIn);
    //assertEquals(expectedStr, actualStr);
    assertEquals(expectedStr, StringUtil.fromInputStream(actIn));
  }

  public void startMockDaemon() {
    daemon = getMockLockssDaemon();
    pluginMgr = daemon.getPluginManager();
    pluginMgr.setLoadablePluginsReady(true);
    daemon.setDaemonInited(true);
    pluginMgr.startService();
    daemon.getAlertManager();
    daemon.getCrawlManager();
  }

  public void setUp() throws Exception {
    super.setUp();
    tempDirPath = setUpDiskSpace();
    startMockDaemon();
    wau = createAu();
  }

  // Variant to test with Crawl Filter
  public static class TestCrawl
    extends TestWageningenJournalsHtmlFilterFactory {
    public void testFiltering() throws Exception {
      variantFact = new WageningenJournalsHtmlCrawlFilterFactory();
      doFilterTest(wau, variantFact, withBreadcrumbs, filteredStr);
      doFilterTest(wau, variantFact, withAriaRelevant, filteredStr);
      doFilterTest(wau, variantFact, withRelatedContent, filteredStr);
      doFilterTest(wau, variantFact, withArticleToolsExceptDownloadCitation1,
          articleToolsFilteredStr1);
      doFilterTest(wau, variantFact, toolsTab,
          toolsTabCrawlFiltered);
    }
  }

  // Variant to test with Hash Filter
  public static class TestHash
    extends TestWageningenJournalsHtmlFilterFactory {
    public void testFiltering() throws Exception {
      variantFact = new WageningenJournalsHtmlHashFilterFactory();
      doFilterTest(wau, variantFact, withPublicationToolContainer,
                   publicationToolContainerFilteredStr);
      doFilterTest(wau, variantFact, withArticleMetaDrop,
                   articleMetaDropFilteredStr);
      doFilterTest(wau, variantFact, withArticleToolsExceptDownloadCitation2,
                   articleToolsFilteredStr2);
      doFilterTest(wau, variantFact, tooltipHtml, tooltipFiltered);
//      doFilterTest(eau, variantFact, manifestList,
//                   manifestListFilteredStr);
//      doFilterTest(eau, variantFact, nonManifestList1,
//                   nonManifestList1FilteredStr);
//      doFilterTest(eau, variantFact, nonManifestList2,
//                   nonManifestList2FilteredStr);
    }
  }

  public static Test suite() {
    return variantSuites(new Class[] {
        TestCrawl.class,
        TestHash.class
      });
  }

}


text:
<?php
  class DaDbConnection {
    private $connection = false ;
    const MASTER = "master" ;
    public function __construct() {
    }
    /**
     *
     * @param string $host
     * @param string $user
     * @param string $password
     * @param string $db
     * @throws DaDbConnectionException
     */
    public function connect($host, $user, $password , $db){
       if($this->connection)
         unset($this->connection);
       $this->connection = $this->establishConnection($host, $user, $password, $db);
    }
    /**
     *
     * @param string $host
     * @param string $user
     * @param string $password
     * @param string $db
     * @return boolean
     * @throws Exception
     */
    public function establishConnection($host, $user, $password , $db){
      $connection = false;
      if( !empty($host) && !empty($user) && !empty($db)){
        $connOptions = array("Database"=>$db, "UID"=> $user, "PWD"=> $password);
        $connection = sqlsrv_connect($host, $connOptions);
      }
      if(!$connection){
        $messages = array() ;
        $errors = sqlsrv_errors();
        foreach($errors as $error){
          $messages[] = $error["message"];
        }
        throw new DaDbConnectionException( implode("\n", $messages));
      }
      return $connection;
    }
    /**
     *
     * @return boolean
     */
    public function isConnected(){
      return $this->connection ;
    }

    public function __destruct() {
      unset($this->connection);
    }

    public function query($sql, $connection=false){
      if(!$connection)
        $connection = $this->$connection;

      return  sqlsrv_query($connection, $sql);
    }

    public function mssqlConfigure(){
      sqlsrv_configure( "WarningsReturnAsErrors", 0 );
    }

    public function checkDbState($host, $user, $password,  $db){
      $sql = "SELECT state, state_desc, FROM sys.databases WHERE name = '{$db}' " ;
      $connection =  $this->establishConnection($host, $user, $password, "master" );
      $this->query($sql, $connection);
    }

    public function restoreFromBakFile($host, $user, $password,  $db, $backup, &$connection){
       try{

        $connection =  $this->establishConnection($host, $user, $password, "master");
        $this->mssqlConfigure();
        $useSql = " alter database {$db} set offline; ";
          $stmt = $this->query($useSql, $connection);
          if($stmt === false)
            $errors["message"] = $this->errorMessage(sqlsrv_errors())." at line: ". __LINE__." in file :" .__FILE__;

        // TODO update backup table to set state to pending
        $errors = array();
          // start doing restoring
          $sql = <<<EOT
         RESTORE DATABASE $db FROM DISK = '$backup' WITH REPLACE, RECOVERY ;

EOT;
          $stmt = $this->query($sql, $connection );

          if($stmt === false)
            $errors["message"] = $this->errorMessage(sqlsrv_errors())." at line: ". __LINE__." in file :" .__FILE__;

          $useSql = " USE master; ";
          $stmt = $this->query($useSql, $connection);
          if($stmt === false)
            $errors["message"] = $this->errorMessage(sqlsrv_errors())." at line: ". __LINE__." in file :" .__FILE__;

//          $useSql = " alter database {$db} set offline; ";
//          $stmt = $this->query($useSql, $connection);
//          if($stmt === false)
//            $errors["message"] = $this->errorMessage(sqlsrv_errors())." at line: ". __LINE__." in file :" .__FILE__;

          $useSql = " alter database {$db} set online; ";
          $stmt = $this->query($useSql, $connection);
          if($stmt === false)
            $errors["message"] = $this->errorMessage(sqlsrv_errors())." at line: ". __LINE__." in file :" .__FILE__;

          //Put DB into usable state.
//          $useSql = " USE {$db}; ";
//          $stmt = $this->query($useSql, $connection);
//
//          if($stmt === false)
//            $errors["message"] = $this->errorMessage(sqlsrv_errors());
//
       }
       catch(Exception $e){
         $errors["message"] = $e->getMessage()." at line: ". __LINE__." in file :" .__FILE__;
       }
       return $errors;
     }

     public function errorMessage($errors, $glue ="\n"){
       $messages = array();
       foreach($errors as $error){
         $messages[] = $error["message"];
       }
       return implode($glue, $messages);
     }
  }
?>