/*
 * Copyright (c) 2016, Eistec AB.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holder 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 HOLDER 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 HOLDER 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.
 */

/**
 * \addtogroup oma-lwm2m
 * @{
 */

/**
 * \file
 *         Implementation of the Contiki OMA LWM2M JSON writer
 * \author
 *         Joakim Nohlgård <joakim.nohlgard@eistec.se>
 */

#include "lwm2m-object.h"
#include "lwm2m-json.h"
#include "lwm2m-plain-text.h"
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <inttypes.h>

#define DEBUG 0
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif

/*---------------------------------------------------------------------------*/
static size_t
write_boolean(const lwm2m_context_t *ctx, uint8_t *outbuf, size_t outlen,
              int value)
{
  int len = snprintf((char *)outbuf, outlen, "{\"e\":[{\"n\":\"%u\",\"bv\":%s}]}\n", ctx->resource_id, value ? "true" : "false");
  if((len < 0) || (len >= outlen)) {
    return 0;
  }
  return len;
}
/*---------------------------------------------------------------------------*/
static size_t
write_int(const lwm2m_context_t *ctx, uint8_t *outbuf, size_t outlen,
          int32_t value)
{
  int len = snprintf((char *)outbuf, outlen, "{\"e\":[{\"n\":\"%u\",\"v\":%" PRId32 "}]}\n", ctx->resource_id, value);
  if((len < 0) || (len >= outlen)) {
    return 0;
  }
  return len;
}
/*---------------------------------------------------------------------------*/
static size_t
write_float32fix(const lwm2m_context_t *ctx, uint8_t *outbuf, size_t outlen,
                 int32_t value, int bits)
{
  size_t len = 0;
  int res;
  res = snprintf((char *)outbuf, outlen, "{\"e\":[{\"n\":\"%u\",\"v\":", ctx->resource_id);
  if(res <= 0 || res >= outlen) {
    return 0;
  }
  len += res;
  outlen -= res;
  res = lwm2m_plain_text_write_float32fix(&outbuf[len], outlen, value, bits);
  if((res <= 0) || (res >= outlen)) {
    return 0;
  }
  len += res;
  outlen -= res;
  res = snprintf((char *)&outbuf[len], outlen, "}]}\n");
  if((res <= 0) || (res >= outlen)) {
    return 0;
  }
  len += res;
  return len;
}
/*---------------------------------------------------------------------------*/
static size_t
write_string(const lwm2m_context_t *ctx, uint8_t *outbuf, size_t outlen,
             const char *value, size_t stringlen)
{
  size_t i;
  size_t len = 0;
  int res;
  PRINTF("{\"e\":[{\"n\":\"%u\",\"sv\":\"", ctx->resource_id);
  res = snprintf((char *)outbuf, outlen, "{\"e\":[{\"n\":\"%u\",\"sv\":\"", ctx->resource_id);
  if(res < 0 || res >= outlen) {
    return 0;
  }
  len += res;
  for (i = 0; i < stringlen && len < outlen; ++i) {
    /* Escape special characters */
    /* TODO: Handle UTF-8 strings */
    if(value[i] < '\x20') {
      PRINTF("\\x%x", value[i]);
      res = snprintf((char *)&outbuf[len], outlen - len, "\\x%x", value[i]);
      if((res < 0) || (res >= (outlen - len))) {
        return 0;
      }
      len += res;
      continue;
    } else if(value[i] == '"' || value[i] == '\\') {
      PRINTF("\\");
      outbuf[len] = '\\';
      ++len;
      if(len >= outlen) {
        return 0;
      }
    }
    PRINTF("%c", value[i]);
    outbuf[len] = value[i];
    ++len;
    if(len >= outlen) {
      return 0;
    }
  }
  PRINTF("\"}]}\n");
  res = snprintf((char *)&outbuf[len], outlen - len, "\"}]}\n");
  if((res < 0) || (res >= (outlen - len))) {
    return 0;
  }
  len += res;
  return len;
}
/*---------------------------------------------------------------------------*/
const lwm2m_writer_t lwm2m_json_writer = {
  write_int,
  write_string,
  write_float32fix,
  write_boolean
};
/*---------------------------------------------------------------------------*/
/** @} */


23
12
21
16
15
10
15
16
5
20
8
19
15
14
13
20
13
21
9
16
7
14
28
17
18
18
34
22
18
13
11
10
15
26
19
14
21
9
13
15
12
16
15
18
9
17
7
19
12
12
7
12
14
13
9
27
12
32
11
20
16
17
11
27
11
10
18
17
11
18
24
23
25
5
11
19
10
9
9
14
14
18
18
19
19
14
12
12
14
10
12
16
10
15
12
18
9
23
12
13
11
12
19
20
13
17
17
13
17
16
13
16
9
10
14
15
9
14
16
14
12
15
14
12
11
11
12
10
14
16
18
19
11
7
9
9
16
10
12
10
11
12
16
16
12
6
10
13
10
13
7
12
10
19
20
24
16
13
17
20
21
14
11
18
15
16
18
10
21
20
12
3
14
13
11
10
12
11
15
17
16
6
9
10
6
19
18
19
10
19
20
21
13
15
8
23
14
13
13
19
9
16
27
22
25
8
11
9
11
15
14
14
22
16
21
10
16
17
16
9
12
17
22
25
13
16
24
18
10
4
13
9
25
23
20
9
15
22
20
9
19
2
14
10
11
16
13
10
15
21
21
14
13
13
14
23
15
14
17
19
9
8
16
11
34
18
15
10
12
9
16
10
12
12
21
18
13
11
10
10
7
12
16
12
9
16
34
20


class B19950219 {
  @Override
  String normalizeWord(String word) {
    return Ascii.toLowerCase(word);
  }

  @Override
  String convert(CaseFormat format, String s) {}
}


class CryptoApi
  BASE_URL = ENV['CRYPTO_API_URL']
  DEFAULT_HEADERS = {'Content-Type' => 'application/json', 'api_key' => ENV['CRYPTO_API_SECRET']}

  class MissingIssueAddressError < StandardError; end
  class CryptoPayOutFailed < StandardError; end
  class RefundTransactionError < StandardError; end

  def self.generate_address(issue_id)
    url = "#{BASE_URL}issues/#{issue_id}/issue_address"
    response = RestClient.post(url, {id: issue_id, category: 1}.to_json, DEFAULT_HEADERS)
    raise MissingIssueAddressError unless response.code == 200
  end

  def self.refresh_bounties(issue_id)
    url = "#{BASE_URL}issues/#{issue_id}/bounties/refresh"
    response = RestClient.get(url, DEFAULT_HEADERS)
  end

  def self.verify_wallet(wallet, signed_txn)
    url = "#{BASE_URL}wallets/#{wallet.id}/verify"

    params = {
      signedTxn: signed_txn,
      personId: wallet.person_id,
      walletAddrs: wallet.eth_addr
    }
    response = RestClient.post(url, params.to_json, DEFAULT_HEADERS )

    if response.code == 201
      true
    else
      false
    end
  end

  def self.refund_transaction(issue_id, transaction_hash)
    url = "#{BASE_URL}issues/#{issue_id}/refund/#{transaction_hash}"

    response = RestClient.get(url, DEFAULT_HEADERS )

    raise RefundTransactionError unless response.code == 200
  end

  def self.send_crypto_pay_out(issue_id)
    url = "#{BASE_URL}issues/#{issue_id}/bounties/pay-out"

    response = RestClient.get(url, DEFAULT_HEADERS)

    raise CryptoPayOutFailed unless response.code == 200
  end
end


// Copyright 2009 the V8 project authors. 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 Google Inc. 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.

// Test Unicode character ranges in regexps.

// Cyrillic.
var cyrillic = {
  FIRST: "\u0410",   // A
  first: "\u0430",   // a
  LAST: "\u042f",    // YA
  last: "\u044f",    // ya
  MIDDLE: "\u0427",  // CHE
  middle: "\u0447",   // che
  // Actually no characters are between the cases in Cyrillic.
  BetweenCases: false};

var SIGMA = "\u03a3";
var sigma = "\u03c3";
var alternative_sigma = "\u03c2";

// Greek.
var greek = {
  FIRST: "\u0391",     // ALPHA
  first: "\u03b1",     // alpha
  LAST: "\u03a9",      // OMEGA
  last: "\u03c9",      // omega
  MIDDLE: SIGMA,       // SIGMA
  middle: sigma,       // sigma
  // Epsilon acute is between ALPHA-OMEGA and alpha-omega, ie it
  // is between OMEGA and alpha.
  BetweenCases: "\u03ad"};

function Range(from, to, flags) {
  return new RegExp("[" + from + "-" + to + "]", flags);
}

// Test Cyrillic and Greek separately.
for (var lang = 0; lang < 2; lang++) {
  var chars = (lang == 0) ? cyrillic : greek;

  for (var i = 0; i < 2; i++) {
    var lc = (i == 0);  // Lower case.
    var first = lc ? chars.first : chars.FIRST;
    var middle = lc ? chars.middle : chars.MIDDLE;
    var last = lc ? chars.last : chars.LAST;
    var first_other_case = lc ? chars.FIRST : chars.first;
    var middle_other_case = lc ? chars.MIDDLE : chars.middle;
    var last_other_case = lc ? chars.LAST : chars.last;

    assertTrue(Range(first, last).test(first), 1);
    assertTrue(Range(first, last).test(middle), 2);
    assertTrue(Range(first, last).test(last), 3);

    assertFalse(Range(first, last).test(first_other_case), 4);
    assertFalse(Range(first, last).test(middle_other_case), 5);
    assertFalse(Range(first, last).test(last_other_case), 6);

    assertTrue(Range(first, last, "i").test(first), 7);
    assertTrue(Range(first, last, "i").test(middle), 8);
    assertTrue(Range(first, last, "i").test(last), 9);

    assertTrue(Range(first, last, "i").test(first_other_case), 10);
    assertTrue(Range(first, last, "i").test(middle_other_case), 11);
    assertTrue(Range(first, last, "i").test(last_other_case), 12);

    if (chars.BetweenCases) {
      assertFalse(Range(first, last).test(chars.BetweenCases), 13);
      assertFalse(Range(first, last, "i").test(chars.BetweenCases), 14);
    }
  }
  if (chars.BetweenCases) {
    assertTrue(Range(chars.FIRST, chars.last).test(chars.BetweenCases), 15);
    assertTrue(Range(chars.FIRST, chars.last, "i").test(chars.BetweenCases), 16);
  }
}

// Test range that covers both greek and cyrillic characters.
for (key in greek) {
  assertTrue(Range(greek.FIRST, cyrillic.last).test(greek[key]), 17 + key);
  if (cyrillic[key]) {
    assertTrue(Range(greek.FIRST, cyrillic.last).test(cyrillic[key]), 18 + key);
  }
}

for (var i = 0; i < 2; i++) {
  var ignore_case = (i == 0);
  var flag = ignore_case ? "i" : "";
  assertTrue(Range(greek.first, cyrillic.LAST, flag).test(greek.first), 19);
  assertTrue(Range(greek.first, cyrillic.LAST, flag).test(greek.middle), 20);
  assertTrue(Range(greek.first, cyrillic.LAST, flag).test(greek.last), 21);

  assertTrue(Range(greek.first, cyrillic.LAST, flag).test(cyrillic.FIRST), 22);
  assertTrue(Range(greek.first, cyrillic.LAST, flag).test(cyrillic.MIDDLE), 23);
  assertTrue(Range(greek.first, cyrillic.LAST, flag).test(cyrillic.LAST), 24);

  // A range that covers the lower case greek letters and the upper case cyrillic
  // letters.
  assertEquals(ignore_case, Range(greek.first, cyrillic.LAST, flag).test(greek.FIRST), 25);
  assertEquals(ignore_case, Range(greek.first, cyrillic.LAST, flag).test(greek.MIDDLE), 26);
  assertEquals(ignore_case, Range(greek.first, cyrillic.LAST, flag).test(greek.LAST), 27);

  assertEquals(ignore_case, Range(greek.first, cyrillic.LAST, flag).test(cyrillic.first), 28);
  assertEquals(ignore_case, Range(greek.first, cyrillic.LAST, flag).test(cyrillic.middle), 29);
  assertEquals(ignore_case, Range(greek.first, cyrillic.LAST, flag).test(cyrillic.last), 30);
}

// Sigma is special because there are two lower case versions of the same upper
// case character.  JS requires that case independence means that you should
// convert everything to upper case, so the two sigma variants are equal to each
// other in a case independt comparison.
for (var i = 0; i < 2; i++) {
  var simple = (i != 0);
  var name = simple ? "" : "[]";
  var regex = simple ? SIGMA : "[" + SIGMA + "]";

  assertFalse(new RegExp(regex).test(sigma), 31 + name);
  assertFalse(new RegExp(regex).test(alternative_sigma), 32 + name);
  assertTrue(new RegExp(regex).test(SIGMA), 33 + name);

  assertTrue(new RegExp(regex, "i").test(sigma), 34 + name);
  // JSC and Tracemonkey fail this one.
  assertTrue(new RegExp(regex, "i").test(alternative_sigma), 35 + name);
  assertTrue(new RegExp(regex, "i").test(SIGMA), 36 + name);

  regex = simple ? sigma : "[" + sigma + "]";

  assertTrue(new RegExp(regex).test(sigma), 41 + name);
  assertFalse(new RegExp(regex).test(alternative_sigma), 42 + name);
  assertFalse(new RegExp(regex).test(SIGMA), 43 + name);

  assertTrue(new RegExp(regex, "i").test(sigma), 44 + name);
  // JSC and Tracemonkey fail this one.
  assertTrue(new RegExp(regex, "i").test(alternative_sigma), 45 + name);
  assertTrue(new RegExp(regex, "i").test(SIGMA), 46 + name);

  regex = simple ? alternative_sigma : "[" + alternative_sigma + "]";

  assertFalse(new RegExp(regex).test(sigma), 51 + name);
  assertTrue(new RegExp(regex).test(alternative_sigma), 52 + name);
  assertFalse(new RegExp(regex).test(SIGMA), 53 + name);

  // JSC and Tracemonkey fail this one.
  assertTrue(new RegExp(regex, "i").test(sigma), 54 + name);
  assertTrue(new RegExp(regex, "i").test(alternative_sigma), 55 + name);
  // JSC and Tracemonkey fail this one.
  assertTrue(new RegExp(regex, "i").test(SIGMA), 56 + name);
}

for (var add_non_ascii_character_to_subject = 0;
     add_non_ascii_character_to_subject < 2;
     add_non_ascii_character_to_subject++) {
  var suffix = add_non_ascii_character_to_subject ? "\ufffe" : "";
  // A range that covers both ASCII and non-ASCII.
  for (var i = 0; i < 2; i++) {
    var full = (i != 0);
    var mixed = full ? "[a-\uffff]" : "[a-" + cyrillic.LAST + "]";
    var f = full ? "f" : "c";
    for (var j = 0; j < 2; j++) {
      var ignore_case = (j == 0);
      var flag = ignore_case ? "i" : "";
      var re = new RegExp(mixed, flag);
      var expected =
          ignore_case || (full && !!add_non_ascii_character_to_subject);
      assertEquals(expected, re.test("A" + suffix), 58 + flag + f);
      assertTrue(re.test("a" + suffix), 59 + flag + f);
      assertTrue(re.test("~" + suffix), 60 + flag + f);
      assertTrue(re.test(cyrillic.MIDDLE), 61 + flag + f);
      assertEquals(ignore_case || full, re.test(cyrillic.middle), 62 + flag + f);
    }
  }
}


# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.

from __future__ import absolute_import, division, print_function

from cryptography import utils
from cryptography.exceptions import (
    AlreadyFinalized, UnsupportedAlgorithm, _Reasons
)

class Poly1305(object):
    def __init__(self, key):
        from cryptography.hazmat.backends.openssl.backend import backend
        if not backend.poly1305_supported():
            raise UnsupportedAlgorithm(
                "poly1305 is not supported by this version of OpenSSL.",
                _Reasons.UNSUPPORTED_MAC
            )
        self._ctx = backend.create_poly1305_ctx(key)

    def update(self, data):
        if self._ctx is None:
            raise AlreadyFinalized("Context was already finalized.")
        utils._check_byteslike("data", data)
        self._ctx.update(data)

    def finalize(self):
        if self._ctx is None:
            raise AlreadyFinalized("Context was already finalized.")
        mac = self._ctx.finalize()
        self._ctx = None
        return mac

    def verify(self, tag):
        utils._check_bytes("tag", tag)
        if self._ctx is None:
            raise AlreadyFinalized("Context was already finalized.")

        ctx, self._ctx = self._ctx, None
        ctx.verify(tag)

    @classmethod
    def generate_tag(cls, key, data):
        p = Poly1305(key)
        p.update(data)
        return p.finalize()

    @classmethod
    def verify_tag(cls, key, data, tag):
        p = Poly1305(key)
        p.update(data)
        p.verify(tag)


#! /usr/bin/env perl
##**************************************************************
##
## Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
## University of Wisconsin-Madison, WI.
##
## Licensed under the Apache License, Version 2.0 (the "License"); you
## may not use this file except in compliance with the License.  You may
## obtain a copy of the License at
##
##    http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
##**************************************************************
##
## This test check availability and usage contol of the new
## local, resources in both a static configuration and in psolts.
## It is model after what we did to test concurrency limits
## as we are checking the same sorts of things. bt
##
##**************************************************************

use CondorTest;
use CondorUtils;
use Check::SimpleJob;
use Check::CondorLog;

my $ClusterId = 0;
my $expect_return = 0;

my $firstappend_condor_config = '
	DAEMON_LIST = MASTER,SCHEDD,COLLECTOR,NEGOTIATOR,STARTD
	WANT_SUSPEND = FALSE
	KILLING_TIMEOUT = 1
	MachineMaxVacateTime = 5
	NEGOTIATION_INTERVAL = 10
	KILL = FALSE
	START = TRUE
	TOOL_DEBUG = D_FULLDEBUG
	ALL_DEBUG = D_ALWAYS
	NUM_CPUS = 4
	STARTD_SLOT_ATTRS = activity,state,memory
	SLOT_TYPE_1 = cpus=25%,mem=500
	SLOT_TYPE_1_PARTITIONABLE = FALSE
	NUM_SLOTS_TYPE_1 = 1
	SLOT_TYPE_2 = cpus=25%,mem=200
	SLOT_TYPE_2_PARTITIONABLE = FALSE
	NUM_SLOTS_TYPE_2 = 1
	SLOT_TYPE_3 = cpus=25%,mem=700
	SLOT_TYPE_3_PARTITIONABLE = FALSE
	NUM_SLOTS_TYPE_3 = 1
	SLOT_TYPE_4 = cpus=25%,mem=300
	SLOT_TYPE_4_PARTITIONABLE = FALSE
	NUM_SLOTS_TYPE_4 = 1
';

my %memoryhash = (
	slot1 => 500,
	slot2 => 200,
	slot3 => 700,
	slot4 => 300,
);

my $testname = "basic_startd_slot_attrs";

$configfile = CondorTest::CreateLocalConfig($firstappend_condor_config,"startdslotattrs");

CondorTest::StartCondorWithParams(
	condor_name => "startdslotattrs",
	fresh_local => "TRUE",
	condorlocalsrc => "$configfile",
);

my $on_abort = sub {
	CondorTest::debug("Abort from removing trap signal job.\n",1);
};

my %startdslotattrs = ();
my $return = "";
my $executecount = 0;
my $namelist = "";
my $result = 1;
my $on_execute = sub {
	print "********************************** OnExecute *****************************\n";
	$namelist = GetSlotNames(4);
	print "SlotNames:<$namelist>\n";
	GetStartdSlotAttrs($namelist);
	system("condor_rm $ClusterId");
};

my $on_evictedwithoutcheckpoint = sub {
	print "Evicted Without Checkpoint\n";
};

my $GetClusterId = sub {
	my $cid = shift;
	$ClusterId = $cid;
	print "Resquestd Cluster Got $ClusterId\n";
	##########################
	#
	# Convoluted: This function is paased to RunCheck which uses it in RunTest in the fourth
	# position which is always an undefined variable EXCEPT when it is a call back routine
	# to pass out the cluster Id.
	#
	##########################
	#runcmd("condor_q",{emit_output => 1});
};

#Do a job before setting tesing exit codes
print "First test basic job\n";
$result = SimpleJob::RunCheck(); # jobid 1

$expect_return = 0;
$result = SimpleJob::RunCheck(
	test_name => "$testname",
	on_abort => $on_abort,
	on_evictedwithoutcheckpoint => $on_evictedwithoutcheckpoint,
	on_execute => $on_execute,
	timeout => 120,
	queue_sz => 1,
	duration => $expect_return,
	GetClusterId => $GetClusterId,
);
print "******************** Test for startd slot attrs/publishing\n";
if($result == 1) {
	print "ok\n\n\n";
} else {
	print "bad\n\n\n";
}

CondorTest::EndTest();

sub GetSlotNames
{
	my $target = shift;
	my $line = "";
	my $names = "";
	my $count = 0;

	my @name = ();
	runCondorTool("condor_status -af name",\@name,2,{emit_output=>0});
	foreach my $try (@name) {
		CondorUtils::fullchomp($try);
		if($count == 0) {
			$names = $try;
		} else {
			$names = $names . ",$try"
		}
		$count += 1;
		#print "$names\n";
		if($count == $target) {
			last;
		}
	}
	return($names);
}

# stash expected atrributs into hash and expect the counts of all
# to match count of slots passed  %stardslotattrs

sub GetStartdSlotAttrs
{
	my $names = shift;
	my @namearray = split /,/, $names;
	my $namecount = @namearray;
	my @fullslot1 = ();
	my $cmdstatus = 1;
	my $simpleslot = "";

	foreach my $slot (@namearray) {
		# extract simple slot name for access to memory hash
		if($slot =~ /^(slot\d).*$/) {
			print "looking at $1 information\n";
			$simpleslot = $1;
		} else {
			die "Something horribly wrong. Could not extract simple slot name\n";
		}
		# get slot memmory from condor_status
		$cmdstatus = runCondorTool("condor_status $slot -af memory ",\@fullslot1,2,{emit_output=>0});
		if(!$cmdstatus) {
			print "This:condor_status $slot -af memory : should not have failed\n";
		}
		# there is but one line for memory
		my $mem = "";
		CondorUtils::fullchomp($fullslot1[0]);
		$mem = $fullslot1[0];
		if($mem == $memoryhash{$simpleslot}) {
			print "condor status for $simpleslot reporting config requested memory\n";
			CondorTest::RegisterResult(1,test_name,$testname);
		} else {
			print "condor status for $simpleslot NOT reporting config requested memory\n";
			print "Configured:$memoryhash{$simpleslot} Reported:$mem\n";
			CondorTest::RegisterResult(0,test_name,$testname);
		}

		my @results = ();
		# TODO: This used to have "-debug" and it would be nifty if it did again. However
		# the IPv4/6 mixed-mode work seems to break that case. NEEDS TO BE INVESTIGATED.
		$cmdstatus = runCondorTool("condor_status -l $slot ",\@results, 2,{emit_output=>0});
			if(!$cmdstatus) {
				print "This:condor_status -l $slot should not have failed\n";
			}
		my $statusres = @results;
		#print "condor_status for slot <$slot> returned <$statusres> lines\n";
		foreach my $item (@results) {
			CondorUtils::fullchomp($item);
			#print "$slot: $item\n";
			if($item =~ /(slot\d_memory)\s*=\s*(\d+).*/) {
				#ensure reported slot memory matches configured memory
				my $memory = $2;
				my $attr = $1;
				# dig out simple slot for hash comparison
				my $sslot = "";
				if($attr =~ /(slot\d)/) { # does by definition
					$sslot = $1;
					if($memory == $memoryhash{$sslot}) {
						print "$attr memory being advertised correctly to $slot\n";
						CondorTest::RegisterResult(1,test_name,$testname);
					} else {
						print "$attr memory NOT being advertised correctly to $slot\n";
						print "Configured:$memoryhash{$simpleslot} Reported:$memory\n";
						CondorTest::RegisterResult(0,test_name,$testname);
					}
				}
				#print "*************** $attr *********************\n";
				if(exists $stardslotattrs{$attr}) {
					$stardslotattrs{$attr} += 1;
				} else {
					$stardslotattrs{$attr} = 1;
				}
			} elsif($item =~ /(slot\d_state)\s.*/) {
				#print "*************** $1 *********************\n";
				if(exists $stardslotattrs{$1}) {
					$stardslotattrs{$1} += 1;
				} else {
					$stardslotattrs{$1} = 1;
				}
			} elsif($item =~ /(slot\d_activity)\s.*/) {
				#print "*************** $1 *********************\n";
				if(exists $stardslotattrs{$1}) {
					$stardslotattrs{$1} += 1;
				} else {
					$stardslotattrs{$1} = 1;
				}
			}

		}
	}
	foreach my $key(sort keys %stardslotattrs) {
		if($stardslotattrs{$key} != $namecount) {
			die "Ad<$key> has $stardslotattrs{$key} and should be $namecount\n";
		}
	}
	print "Slot attributes equally advertised across all slots\n";
	CondorTest::RegisterResult(1,test_name,$testname);
}


Ruby annotation

Method of adding pronunciation or other annotations using ruby elements (primarily used in East Asian typography).

HTML5 Doctor article

WebPlatform Docs

Add-on "XHTML Ruby Support" for Firefox

Addon "HTML Ruby" for Firefox support

CSS specification

IE and Firefox do not appear to have support for nested ruby structures [see testcase](http://jsfiddle.net/tabletguy/49412u7r/)

Browsers without native support can still simulate support using CSS. Partial support refers to only supporting basic ruby, may still be missing writing-mode, Complex ruby and CSS3 Ruby.

IE9+ supports [properties](https://msdn.microsoft.com/en-us/library/hh772055%28v=vs.85%29.aspx) of an older version of the CSS Ruby specification.


// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if V8_TARGET_ARCH_X64

#include "src/codegen/interface-descriptors.h"

#include "src/execution/frames.h"

namespace v8 {
namespace internal {

const Register CallInterfaceDescriptor::ContextRegister() { return rsi; }

void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
    CallInterfaceDescriptorData* data, int register_parameter_count) {
  const Register default_stub_registers[] = {rax, rbx, rcx, rdx, rdi};
  CHECK_LE(static_cast<size_t>(register_parameter_count),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(register_parameter_count,
                                   default_stub_registers);
}

void RecordWriteDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  const Register default_stub_registers[] = {arg_reg_1, arg_reg_2, arg_reg_3,
                                             arg_reg_4, kReturnRegister0};

  data->RestrictAllocatableRegisters(default_stub_registers,
                                     arraysize(default_stub_registers));

  CHECK_LE(static_cast<size_t>(kParameterCount),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}

void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  const Register default_stub_registers[] = {arg_reg_1, arg_reg_2, arg_reg_3,
                                             arg_reg_4, kReturnRegister0};

  data->RestrictAllocatableRegisters(default_stub_registers,
                                     arraysize(default_stub_registers));

  CHECK_LE(static_cast<size_t>(kParameterCount),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}

const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
  return rdi;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return rax; }

const Register LoadDescriptor::ReceiverRegister() { return rdx; }
const Register LoadDescriptor::NameRegister() { return rcx; }
const Register LoadDescriptor::SlotRegister() { return rax; }

const Register LoadWithVectorDescriptor::VectorRegister() { return rbx; }

const Register StoreDescriptor::ReceiverRegister() { return rdx; }
const Register StoreDescriptor::NameRegister() { return rcx; }
const Register StoreDescriptor::ValueRegister() { return rax; }
const Register StoreDescriptor::SlotRegister() { return rdi; }

const Register StoreWithVectorDescriptor::VectorRegister() { return rbx; }

const Register StoreTransitionDescriptor::SlotRegister() { return rdi; }
const Register StoreTransitionDescriptor::VectorRegister() { return rbx; }
const Register StoreTransitionDescriptor::MapRegister() { return r11; }

const Register ApiGetterDescriptor::HolderRegister() { return rcx; }
const Register ApiGetterDescriptor::CallbackRegister() { return rbx; }

const Register GrowArrayElementsDescriptor::ObjectRegister() { return rax; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; }

void TypeofDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

// static
const Register TypeConversionDescriptor::ArgumentRegister() { return rax; }

void CallTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments
  // rdi : the target to call
  Register registers[] = {rdi, rax};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void CallVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments (on the stack, not including receiver)
  // rdi : the target to call
  // rcx : arguments list length (untagged)
  // rbx : arguments list (FixedArray)
  Register registers[] = {rdi, rax, rcx, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void CallForwardVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments
  // rcx : start index (to support rest parameters)
  // rdi : the target to call
  Register registers[] = {rdi, rax, rcx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void CallFunctionTemplateDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rdx: the function template info
  // rcx: number of arguments (on the stack, not including receiver)
  Register registers[] = {rdx, rcx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void CallWithSpreadDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments (on the stack, not including receiver)
  // rdi : the target to call
  // rbx : the object to spread
  Register registers[] = {rdi, rax, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rdi : the target to call
  // rbx : the arguments list
  Register registers[] = {rdi, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ConstructVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments (on the stack, not including receiver)
  // rdi : the target to call
  // rdx : the new target
  // rcx : arguments list length (untagged)
  // rbx : arguments list (FixedArray)
  Register registers[] = {rdi, rdx, rax, rcx, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments
  // rdx : the new target
  // rcx : start index (to support rest parameters)
  // rdi : the target to call
  Register registers[] = {rdi, rdx, rax, rcx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ConstructWithSpreadDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments (on the stack, not including receiver)
  // rdi : the target to call
  // rdx : the new target
  // rbx : the object to spread
  Register registers[] = {rdi, rdx, rax, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rdi : the target to call
  // rdx : the new target
  // rbx : the arguments list
  Register registers[] = {rdi, rdx, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ConstructStubDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments
  // rdx : the new target
  // rdi : the target to call
  // rbx : allocation site or undefined
  Register registers[] = {rdi, rdx, rax, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void AbortDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {rdx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  data->InitializePlatformSpecific(0, nullptr);
}

void CompareDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {rdx, rax};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void BinaryOpDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {rdx, rax};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      rdi,  // JSFunction
      rdx,  // the new target
      rax,  // actual number of arguments
      rbx,  // expected number of arguments
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ApiCallbackDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      rdx,  // api function address
      rcx,  // argument count (not including receiver)
      rbx,  // call data
      rdi,  // holder
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void InterpreterDispatchDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
      kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      rax,  // argument count (not including receiver)
      rbx,  // address of first argument
      rdi   // the target callable to be call
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      rax,  // argument count (not including receiver)
      rcx,  // address of first argument
      rdi,  // constructor to call
      rdx,  // new target
      rbx,  // allocation site feedback if available, undefined otherwise
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ResumeGeneratorDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      rax,  // the value to pass to the generator
      rdx   // the JSGeneratorObject / JSAsyncGeneratorObject to resume
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      rbx,  // loaded new FP
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void RunMicrotasksEntryDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {arg_reg_1, arg_reg_2};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

}  // namespace internal
}  // namespace v8

#endif  // V8_TARGET_ARCH_X64


#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include <iostream>

using namespace rapidjson;
using namespace std;

int main() {
    StringBuffer s;
    Writer<StringBuffer> writer(s);

    writer.StartObject();               // Between StartObject()/EndObject(),
    writer.Key("hello");                // output a key,
    writer.String("world");             // follow by a value.
    writer.Key("t");
    writer.Bool(true);
    writer.Key("f");
    writer.Bool(false);
    writer.Key("n");
    writer.Null();
    writer.Key("i");
    writer.Uint(123);
    writer.Key("pi");
    writer.Double(3.1416);
    writer.Key("a");
    writer.StartArray();                // Between StartArray()/EndArray(),
    for (unsigned i = 0; i < 4; i++)
        writer.Uint(i);                 // all values are elements of the array.
    writer.EndArray();
    writer.EndObject();

    // {"hello":"world","t":true,"f":false,"n":null,"i":123,"pi":3.1416,"a":[0,1,2,3]}
    cout << s.GetString() << endl;

    return 0;
}


// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_SRC_ZONE_ZONE_CONTAINERS_H_
#define V8_SRC_ZONE_ZONE_CONTAINERS_H_

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

#include "src/zone/zone-allocator.h"

namespace v8 {
namespace internal {

// A wrapper subclass for std::vector to make it easy to construct one
// that uses a zone allocator.
template <typename T>
class ZoneVector : public std::vector<T, ZoneAllocator<T>> {
 public:
  // Constructs an empty vector.
  explicit ZoneVector(Zone* zone)
      : std::vector<T, ZoneAllocator<T>>(ZoneAllocator<T>(zone)) {}

  // Constructs a new vector and fills it with {size} elements, each
  // constructed via the default constructor.
  ZoneVector(size_t size, Zone* zone)
      : std::vector<T, ZoneAllocator<T>>(size, T(), ZoneAllocator<T>(zone)) {}

  // Constructs a new vector and fills it with {size} elements, each
  // having the value {def}.
  ZoneVector(size_t size, T def, Zone* zone)
      : std::vector<T, ZoneAllocator<T>>(size, def, ZoneAllocator<T>(zone)) {}

  // Constructs a new vector and fills it with the contents of the range
  // [first, last).
  template <class InputIt>
  ZoneVector(InputIt first, InputIt last, Zone* zone)
      : std::vector<T, ZoneAllocator<T>>(first, last, ZoneAllocator<T>(zone)) {}
};

// A wrapper subclass std::deque to make it easy to construct one
// that uses a zone allocator.
template <typename T>
class ZoneDeque : public std::deque<T, RecyclingZoneAllocator<T>> {
 public:
  // Constructs an empty deque.
  explicit ZoneDeque(Zone* zone)
      : std::deque<T, RecyclingZoneAllocator<T>>(
            RecyclingZoneAllocator<T>(zone)) {}
};

// A wrapper subclass std::list to make it easy to construct one
// that uses a zone allocator.
// TODO(mstarzinger): This should be renamed to ZoneList once we got rid of our
// own home-grown ZoneList that actually is a ZoneVector.
template <typename T>
class ZoneLinkedList : public std::list<T, ZoneAllocator<T>> {
 public:
  // Constructs an empty list.
  explicit ZoneLinkedList(Zone* zone)
      : std::list<T, ZoneAllocator<T>>(ZoneAllocator<T>(zone)) {}
};

// A wrapper subclass std::priority_queue to make it easy to construct one
// that uses a zone allocator.
template <typename T, typename Compare = std::less<T>>
class ZonePriorityQueue
    : public std::priority_queue<T, ZoneVector<T>, Compare> {
 public:
  // Constructs an empty list.
  explicit ZonePriorityQueue(Zone* zone)
      : std::priority_queue<T, ZoneVector<T>, Compare>(Compare(),
                                                       ZoneVector<T>(zone)) {}
};

// A wrapper subclass for std::queue to make it easy to construct one
// that uses a zone allocator.
template <typename T>
class ZoneQueue : public std::queue<T, ZoneDeque<T>> {
 public:
  // Constructs an empty queue.
  explicit ZoneQueue(Zone* zone)
      : std::queue<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {}
};

// A wrapper subclass for std::stack to make it easy to construct one that uses
// a zone allocator.
template <typename T>
class ZoneStack : public std::stack<T, ZoneDeque<T>> {
 public:
  // Constructs an empty stack.
  explicit ZoneStack(Zone* zone)
      : std::stack<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {}
};

// A wrapper subclass for std::set to make it easy to construct one that uses
// a zone allocator.
template <typename K, typename Compare = std::less<K>>
class ZoneSet : public std::set<K, Compare, ZoneAllocator<K>> {
 public:
  // Constructs an empty set.
  explicit ZoneSet(Zone* zone)
      : std::set<K, Compare, ZoneAllocator<K>>(Compare(),
                                               ZoneAllocator<K>(zone)) {}
};

// A wrapper subclass for std::map to make it easy to construct one that uses
// a zone allocator.
template <typename K, typename V, typename Compare = std::less<K>>
class ZoneMap
    : public std::map<K, V, Compare, ZoneAllocator<std::pair<const K, V>>> {
 public:
  // Constructs an empty map.
  explicit ZoneMap(Zone* zone)
      : std::map<K, V, Compare, ZoneAllocator<std::pair<const K, V>>>(
            Compare(), ZoneAllocator<std::pair<const K, V>>(zone)) {}
};

// A wrapper subclass for std::multimap to make it easy to construct one that
// uses a zone allocator.
template <typename K, typename V, typename Compare = std::less<K>>
class ZoneMultimap
    : public std::multimap<K, V, Compare,
                           ZoneAllocator<std::pair<const K, V>>> {
 public:
  // Constructs an empty multimap.
  explicit ZoneMultimap(Zone* zone)
      : std::multimap<K, V, Compare, ZoneAllocator<std::pair<const K, V>>>(
            Compare(), ZoneAllocator<std::pair<const K, V>>(zone)) {}
};

// Typedefs to shorten commonly used vectors.
typedef ZoneVector<bool> BoolVector;
typedef ZoneVector<int> IntVector;

}  // namespace internal
}  // namespace v8

#endif  // V8_SRC_ZONE_ZONE_CONTAINERS_H_


using System;
using System.IO;
using System.Security.Principal;
using Trinet.Core.IO.Ntfs;

namespace HidWizards.UCR.Utilities
{
    public static class FileUnblockManager
    {

        public static bool IsAdmin()
        {
            return new WindowsPrincipal
                (WindowsIdentity.GetCurrent()).IsInRole
                (WindowsBuiltInRole.Administrator);
        }

        public static bool UnblockAllProgramFiles(string directory)
        {
            var success = true;
            foreach (var file in Directory.GetFiles(directory, "*", SearchOption.AllDirectories))
            {
                success &= UnblockFile(file);
            }

            return success;
        }

        private static bool UnblockFile(string path)
        {
            var file = new FileInfo(path);
            if (!file.AlternateDataStreamExists("Zone.Identifier")) return true;

            return file.DeleteAlternateDataStream("Zone.Identifier");
        }
    }
}


/* Datepicker
----------------------------------*/
.ui-datepicker { width: 17em; padding: .2em .2em 0; }
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
.ui-datepicker .ui-datepicker-prev { left:2px; }
.ui-datepicker .ui-datepicker-next { right:2px; }
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px;  }
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
.ui-datepicker .ui-datepicker-title select { float:left; font-size:1em; margin:1px 0; }
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select.ui-datepicker-year { width: 49%;}
.ui-datepicker .ui-datepicker-title select.ui-datepicker-year { float: right; }
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0;  }
.ui-datepicker td { border: 0; padding: 1px; }
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }

/* with multiple calendars */
.ui-datepicker.ui-datepicker-multi { width:auto; }
.ui-datepicker-multi .ui-datepicker-group { float:left; }
.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
.ui-datepicker-row-break { clear:both; width:100%; }

/* RTL support */
.ui-datepicker-rtl { direction: rtl; }
.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
.ui-datepicker-rtl .ui-datepicker-group { float:right; }
.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }

/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
.ui-datepicker-cover {
    display: none; /*sorry for IE5*/
    display/**/: block; /*sorry for IE5*/
    position: absolute; /*must have*/
    z-index: -1; /*must have*/
    filter: mask(); /*must have*/
    top: -4px; /*must have*/
    left: -4px; /*must have*/
    width: 200px; /*must have*/
    height: 200px; /*must have*/
}


# -*- coding:utf-8 -*-


import type { CovariantF, CovariantK } from "../Covariant"
import type { URIS } from "../HKT"
import type { IdentityBothF, IdentityBothK } from "../IdentityBoth"

export type ApplicativeF<F, TL0 = any, TL1 = any, TL2 = any, TL3 = any> = IdentityBothF<
  F,
  TL0,
  TL1,
  TL2,
  TL3
> &
  CovariantF<F, TL0, TL1, TL2, TL3>

export type ApplicativeK<
  F extends URIS,
  TL0 = any,
  TL1 = any,
  TL2 = any,
  TL3 = any
> = IdentityBothK<F, TL0, TL1, TL2, TL3> & CovariantK<F, TL0, TL1, TL2, TL3>


version: 1
n_points: 4
{
120.960 112.646
120.960 266.354
290.040 266.354
290.040 112.646
}


org.hibernate.ogm.boot.impl.OgmSessionFactoryBuilderFactory


{% rendercontent "docs/note" title: "Top Top: Adding Concurrently Processes" %}
Want to run even more background processes or change up your build tools? Take a look
at the provided `sync.js` script and read up on the
[Concurrently](https://github.com/kimmobrunfeldt/concurrently#readme) documentation to
see which options are available.
{% endrendercontent %}


// +build !go1.7

package request

import "github.com/aws/aws-sdk-go/aws"

// setContext updates the Request to use the passed in context for cancellation.
// Context will also be used for request retry delay.
//
// Creates shallow copy of the http.Request with the WithContext method.
func setRequestContext(r *Request, ctx aws.Context) {
	r.context = ctx
	r.HTTPRequest.Cancel = ctx.Done()
}


// nonetwork, break standard network functions using LD_PRELOAD
// Source: https://github.com/starius/nonetwork
// Copyright (C) 2015 Boris Nagaev
// License: MIT

#include <errno.h>
#include <stdio.h>

static void print_message() {
    fflush(stderr);
    fprintf(stderr, "\nDon't use network from MXE build rules!\n");
    fflush(stderr);
}

int connect(int sock, const void *addr, unsigned int len) {
    print_message();
    errno = 13; // EACCES, Permission denied
    return -1;
}

void *gethostbyname(const char *name) {
    print_message();
    return 0;
}

int getaddrinfo(const char *node, const char *service,
                const void *hints,
                void **res) {
    print_message();
    return -4; // EAI_FAIL
}

void freeaddrinfo(void *res) {
    print_message();
}

int getnameinfo(const void * sa,
                unsigned int salen, char * host,
                unsigned int hostlen, char * serv,
                unsigned int servlen, int flags) {
    print_message();
    return -4; // EAI_FAIL
}

struct hostent *gethostbyaddr(const void *addr, unsigned int len,
                              int type) {
    print_message();
    return 0;
}


//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2019 Jiang Yin. All rights reserved.
// Homepage: http://gameframework.cn/
// Feedback: mailto:jiangyin@gameframework.cn
//------------------------------------------------------------

using System.IO;

namespace UnityGameFramework.Editor.DataTableTools
{
    public sealed partial class DataTableProcessor
    {
        private sealed class SByteProcessor : GenericDataProcessor<sbyte>
        {
            public override bool IsSystem
            {
                get
                {
                    return true;
                }
            }

            public override string LanguageKeyword
            {
                get
                {
                    return "sbyte";
                }
            }

            public override string[] GetTypeStrings()
            {
                return new string[]
                {
                    "sbyte",
                    "system.sbyte"
                };
            }

            public override sbyte Parse(string value)
            {
                return sbyte.Parse(value);
            }

            public override void WriteToStream(BinaryWriter stream, string value)
            {
                stream.Write(Parse(value));
            }
        }
    }
}


class Lancamento {
    constructor(nome = 'Genérico', valor = 0) {
        this.nome = nome
        this.valor = valor
    }
}

class CicloFinanceiro {
    constructor(mes, ano) {
        this.mes = mes
        this.ano = ano
        this.lancamentos = []
    }

    addLancamentos(...lancamentos) {
        lancamentos.forEach(l => this.lancamentos.push(l))
    }

    sumario() {
        let valorConsolidado = 0
        this.lancamentos.forEach(l => {
            valorConsolidado += l.valor
        })
        return valorConsolidado
    }
}

const salario = new Lancamento('Salario', 45000)
const contaDeLuz = new Lancamento('Luz', -220)

const contas = new CicloFinanceiro(6, 2018)
contas.addLancamentos(salario, contaDeLuz)
console.log(contas.sumario())


/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2008 Blender Foundation
 */

/** \file
 * \ingroup edanimation
 */

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#include "MEM_guardedalloc.h"

#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_lasso_2d.h"
#include "BLI_math.h"

#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"

#include "BKE_fcurve.h"
#include "BKE_nla.h"

#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
#include "ED_markers.h"

/* This file defines an API and set of callback-operators for
 * non-destructive editing of keyframe data.
 *
 * Two API functions are defined for actually performing the operations on the data:
 * ANIM_fcurve_keyframes_loop()
 * which take the data they operate on, a few callbacks defining what operations to perform.
 *
 * As operators which work on keyframes usually apply the same operation on all BezTriples in
 * every channel, the code has been optimized providing a set of functions which will get the
 * appropriate bezier-modify function to set. These functions (ANIM_editkeyframes_*) will need
 * to be called before getting any channels.
 *
 * A set of 'validation' callbacks are provided for checking if a BezTriple should be operated on.
 * These should only be used when using a 'general' BezTriple editor (i.e. selection setters which
 * don't check existing selection status).
 *
 * - Joshua Leung, Dec 2008
 */

/* ************************************************************************** */
/* Keyframe Editing Loops - Exposed API */

/* --------------------------- Base Functions ------------------------------------ */

/* This function is used to loop over BezTriples in the given F-Curve, applying a given
 * operation on them, and optionally applies an F-Curve validation function afterwards.
 */
// TODO: make this function work on samples too...
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
                                 FCurve *fcu,
                                 KeyframeEditFunc key_ok,
                                 KeyframeEditFunc key_cb,
                                 FcuEditFunc fcu_cb)
{
  BezTriple *bezt;
  short ok = 0;
  unsigned int i;

  /* sanity check */
  if (ELEM(NULL, fcu, fcu->bezt)) {
    return 0;
  }

  /* set the F-Curve into the editdata so that it can be accessed */
  if (ked) {
    ked->fcu = fcu;
    ked->curIndex = 0;
    ked->curflags = ok;
  }

  /* if function to apply to bezier curves is set, then loop through executing it on beztriples */
  if (key_cb) {
    /* if there's a validation func, include that check in the loop
     * (this is should be more efficient than checking for it in every loop)
     */
    if (key_ok) {
      for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
        if (ked) {
          /* advance the index, and reset the ok flags (to not influence the result) */
          ked->curIndex = i;
          ked->curflags = 0;
        }

        /* Only operate on this BezTriple if it fulfills the criteria of the validation func */
        if ((ok = key_ok(ked, bezt))) {
          if (ked) {
            ked->curflags = ok;
          }

          /* Exit with return-code '1' if function returns positive
           * This is useful if finding if some BezTriple satisfies a condition.
           */
          if (key_cb(ked, bezt)) {
            return 1;
          }
        }
      }
    }
    else {
      for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
        if (ked) {
          ked->curIndex = i;
        }

        /* Exit with return-code '1' if function returns positive
         * This is useful if finding if some BezTriple satisfies a condition.
         */
        if (key_cb(ked, bezt)) {
          return 1;
        }
      }
    }
  }

  /* unset the F-Curve from the editdata now that it's done */
  if (ked) {
    ked->fcu = NULL;
    ked->curIndex = 0;
    ked->curflags = 0;
  }

  /* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */
  if (fcu_cb) {
    fcu_cb(fcu);
  }

  /* done */
  return 0;
}

/* --------------------- Further Abstracted (Not Exposed Directly) ----------------------------- */

/* This function is used to loop over the keyframe data in an Action Group */
static short agrp_keyframes_loop(KeyframeEditData *ked,
                                 bActionGroup *agrp,
                                 KeyframeEditFunc key_ok,
                                 KeyframeEditFunc key_cb,
                                 FcuEditFunc fcu_cb)
{
  FCurve *fcu;

  /* sanity check */
  if (agrp == NULL) {
    return 0;
  }

  /* only iterate over the F-Curves that are in this group */
  for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
    if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) {
      return 1;
    }
  }

  return 0;
}

/* This function is used to loop over the keyframe data in an Action */
static short act_keyframes_loop(KeyframeEditData *ked,
                                bAction *act,
                                KeyframeEditFunc key_ok,
                                KeyframeEditFunc key_cb,
                                FcuEditFunc fcu_cb)
{
  FCurve *fcu;

  /* sanity check */
  if (act == NULL) {
    return 0;
  }

  /* just loop through all F-Curves */
  for (fcu = act->curves.first; fcu; fcu = fcu->next) {
    if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) {
      return 1;
    }
  }

  return 0;
}

/* This function is used to loop over the keyframe data in an Object */
static short ob_keyframes_loop(KeyframeEditData *ked,
                               bDopeSheet *ads,
                               Object *ob,
                               KeyframeEditFunc key_ok,
                               KeyframeEditFunc key_cb,
                               FcuEditFunc fcu_cb)
{
  bAnimContext ac = {NULL};
  ListBase anim_data = {NULL, NULL};
  bAnimListElem *ale;
  int filter;
  int ret = 0;

  bAnimListElem dummychan = {NULL};
  Base dummybase = {NULL};

  if (ob == NULL) {
    return 0;
  }

  /* create a dummy wrapper data to work with */
  dummybase.object = ob;

  dummychan.type = ANIMTYPE_OBJECT;
  dummychan.data = &dummybase;
  dummychan.id = &ob->id;
  dummychan.adt = ob->adt;

  ac.ads = ads;
  ac.data = &dummychan;
  ac.datatype = ANIMCONT_CHANNEL;

  /* get F-Curves to take keyframes from */
  filter = ANIMFILTER_DATA_VISIBLE;  // curves only
  ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);

  /* Loop through each F-Curve, applying the operation as required,
   * but stopping on the first one. */
  for (ale = anim_data.first; ale; ale = ale->next) {
    if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) {
      ret = 1;
      break;
    }
  }

  ANIM_animdata_freelist(&anim_data);

  /* return return code - defaults to zero if nothing happened */
  return ret;
}

/* This function is used to loop over the keyframe data in a Scene */
static short scene_keyframes_loop(KeyframeEditData *ked,
                                  bDopeSheet *ads,
                                  Scene *sce,
                                  KeyframeEditFunc key_ok,
                                  KeyframeEditFunc key_cb,
                                  FcuEditFunc fcu_cb)
{
  bAnimContext ac = {NULL};
  ListBase anim_data = {NULL, NULL};
  bAnimListElem *ale;
  int filter;
  int ret = 0;

  bAnimListElem dummychan = {NULL};

  if (sce == NULL) {
    return 0;
  }

  /* create a dummy wrapper data to work with */
  dummychan.type = ANIMTYPE_SCENE;
  dummychan.data = sce;
  dummychan.id = &sce->id;
  dummychan.adt = sce->adt;

  ac.ads = ads;
  ac.data = &dummychan;
  ac.datatype = ANIMCONT_CHANNEL;

  /* get F-Curves to take keyframes from */
  filter = ANIMFILTER_DATA_VISIBLE;  // curves only
  ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);

  /* Loop through each F-Curve, applying the operation as required,
   * but stopping on the first one. */
  for (ale = anim_data.first; ale; ale = ale->next) {
    if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) {
      ret = 1;
      break;
    }
  }

  ANIM_animdata_freelist(&anim_data);

  /* return return code - defaults to zero if nothing happened */
  return ret;
}

/* This function is used to loop over the keyframe data in a DopeSheet summary */
static short summary_keyframes_loop(KeyframeEditData *ked,
                                    bAnimContext *ac,
                                    KeyframeEditFunc key_ok,
                                    KeyframeEditFunc key_cb,
                                    FcuEditFunc fcu_cb)
{
  ListBase anim_data = {NULL, NULL};
  bAnimListElem *ale;
  int filter, ret_code = 0;

  /* sanity check */
  if (ac == NULL) {
    return 0;
  }

  /* get F-Curves to take keyframes from */
  filter = ANIMFILTER_DATA_VISIBLE;
  ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);

  /* loop through each F-Curve, working on the keyframes until the first curve aborts */
  for (ale = anim_data.first; ale; ale = ale->next) {
    switch (ale->datatype) {
      case ALE_MASKLAY:
      case ALE_GPFRAME:
        break;

      case ALE_FCURVE:
      default: {
        if (ked && ked->iterflags) {
          /* make backups of the current values, so that a localized fix
           * (e.g. NLA time remapping) can be applied to these values
           */
          float f1 = ked->f1;
          float f2 = ked->f2;

          if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) {
            AnimData *adt = ANIM_nla_mapping_get(ac, ale);

            if (ked->iterflags & KED_F1_NLA_UNMAP) {
              ked->f1 = BKE_nla_tweakedit_remap(adt, f1, NLATIME_CONVERT_UNMAP);
            }
            if (ked->iterflags & KED_F2_NLA_UNMAP) {
              ked->f2 = BKE_nla_tweakedit_remap(adt, f2, NLATIME_CONVERT_UNMAP);
            }
          }

          /* now operate on the channel as per normal */
          ret_code = ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb);

          /* reset */
          ked->f1 = f1;
          ked->f2 = f2;
        }
        else {
          /* no special handling required... */
          ret_code = ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb);
        }
        break;
      }
    }

    if (ret_code) {
      break;
    }
  }

  ANIM_animdata_freelist(&anim_data);

  return ret_code;
}

/* --- */

/* This function is used to apply operation to all keyframes, regardless of the type */
short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked,
                                      bDopeSheet *ads,
                                      bAnimListElem *ale,
                                      KeyframeEditFunc key_ok,
                                      KeyframeEditFunc key_cb,
                                      FcuEditFunc fcu_cb)
{
  /* sanity checks */
  if (ale == NULL) {
    return 0;
  }

  /* method to use depends on the type of keyframe data */
  switch (ale->datatype) {
    /* direct keyframe data (these loops are exposed) */
    case ALE_FCURVE: /* F-Curve */
      return ANIM_fcurve_keyframes_loop(ked, ale->key_data, key_ok, key_cb, fcu_cb);

    /* indirect 'summaries' (these are not exposed directly)
     * NOTE: must keep this code in sync with the drawing code and also the filtering code!
     */
    case ALE_GROUP: /* action group */
      return agrp_keyframes_loop(ked, (bActionGroup *)ale->data, key_ok, key_cb, fcu_cb);
    case ALE_ACT: /* action */
      return act_keyframes_loop(ked, (bAction *)ale->key_data, key_ok, key_cb, fcu_cb);

    case ALE_OB: /* object */
      return ob_keyframes_loop(ked, ads, (Object *)ale->key_data, key_ok, key_cb, fcu_cb);
    case ALE_SCE: /* scene */
      return scene_keyframes_loop(ked, ads, (Scene *)ale->data, key_ok, key_cb, fcu_cb);
    case ALE_ALL: /* 'all' (DopeSheet summary) */
      return summary_keyframes_loop(ked, (bAnimContext *)ale->data, key_ok, key_cb, fcu_cb);
  }

  return 0;
}

/* This function is used to apply operation to all keyframes,
 * regardless of the type without needed an AnimListElem wrapper */
short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked,
                                          bDopeSheet *ads,
                                          void *data,
                                          int keytype,
                                          KeyframeEditFunc key_ok,
                                          KeyframeEditFunc key_cb,
                                          FcuEditFunc fcu_cb)
{
  /* sanity checks */
  if (data == NULL) {
    return 0;
  }

  /* method to use depends on the type of keyframe data */
  switch (keytype) {
    /* direct keyframe data (these loops are exposed) */
    case ALE_FCURVE: /* F-Curve */
      return ANIM_fcurve_keyframes_loop(ked, data, key_ok, key_cb, fcu_cb);

    /* indirect 'summaries' (these are not exposed directly)
     * NOTE: must keep this code in sync with the drawing code and also the filtering code!
     */
    case ALE_GROUP: /* action group */
      return agrp_keyframes_loop(ked, (bActionGroup *)data, key_ok, key_cb, fcu_cb);
    case ALE_ACT: /* action */
      return act_keyframes_loop(ked, (bAction *)data, key_ok, key_cb, fcu_cb);

    case ALE_OB: /* object */
      return ob_keyframes_loop(ked, ads, (Object *)data, key_ok, key_cb, fcu_cb);
    case ALE_SCE: /* scene */
      return scene_keyframes_loop(ked, ads, (Scene *)data, key_ok, key_cb, fcu_cb);
    case ALE_ALL: /* 'all' (DopeSheet summary) */
      return summary_keyframes_loop(ked, (bAnimContext *)data, key_ok, key_cb, fcu_cb);
  }

  return 0;
}

/* ************************************************************************** */
/* Keyframe Integrity Tools */

/* Rearrange keyframes if some are out of order */
// used to be recalc_*_ipos() where * was object or action
void ANIM_editkeyframes_refresh(bAnimContext *ac)
{
  ListBase anim_data = {NULL, NULL};
  bAnimListElem *ale;
  int filter;

  /* filter animation data */
  filter = ANIMFILTER_DATA_VISIBLE;
  ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);

  /* Loop over F-Curves that are likely to have been edited, and tag them to
   * ensure the keyframes are in order and handles are in a valid position. */
  for (ale = anim_data.first; ale; ale = ale->next) {
    ale->update |= ANIM_UPDATE_DEPS | ANIM_UPDATE_HANDLES | ANIM_UPDATE_ORDER;
  }

  /* free temp data */
  ANIM_animdata_update(ac, &anim_data);
  ANIM_animdata_freelist(&anim_data);
}

/* ************************************************************************** */
/* BezTriple Validation Callbacks */

/* ------------------------ */
/* Some macros to make this easier... */

/* run the given check on the 3 handles:
 * - Check should be a macro, which takes the handle index as its single arg,
 *   which it substitutes later.
 * - Requires that a var, of type short, is named 'ok',
 *   and has been initialized to 0.
 */
#define KEYFRAME_OK_CHECKS(check) \
  { \
    CHECK_TYPE(ok, short); \
    if (check(1)) \
      ok |= KEYFRAME_OK_KEY; \
\
    if (ked && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) { \
      if (check(0)) \
        ok |= KEYFRAME_OK_H1; \
      if (check(2)) \
        ok |= KEYFRAME_OK_H2; \
    } \
  } \
  (void)0

/* ------------------------ */

static short ok_bezier_frame(KeyframeEditData *ked, BezTriple *bezt)
{
  short ok = 0;

  /* frame is stored in f1 property (this float accuracy check may need to be dropped?) */
#define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][0], ked->f1)
  KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK

  /* return ok flags */
  return ok;
}

static short ok_bezier_framerange(KeyframeEditData *ked, BezTriple *bezt)
{
  short ok = 0;

  /* frame range is stored in float properties */
#define KEY_CHECK_OK(_index) ((bezt->vec[_index][0] > ked->f1) && (bezt->vec[_index][0] < ked->f2))
  KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK

  /* return ok flags */
  return ok;
}

static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  /* this macro checks all beztriple handles for selection...
   * only one of the verts has to be selected for this to be ok...
   */
  if (BEZT_ISSEL_ANY(bezt)) {
    return KEYFRAME_OK_ALL;
  }
  else {
    return 0;
  }
}

static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
{
  short ok = 0;

  /* Value is stored in f1 property:
   * - This float accuracy check may need to be dropped?
   * - Should value be stored in f2 instead
   *   so that we won't have conflicts when using f1 for frames too?
   */
#define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][1], ked->f1)
  KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK

  /* return ok flags */
  return ok;
}

static short ok_bezier_valuerange(KeyframeEditData *ked, BezTriple *bezt)
{
  short ok = 0;

  /* value range is stored in float properties */
#define KEY_CHECK_OK(_index) ((bezt->vec[_index][1] > ked->f1) && (bezt->vec[_index][1] < ked->f2))
  KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK

  /* return ok flags */
  return ok;
}

static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt)
{
  /* rect is stored in data property (it's of type rectf, but may not be set) */
  if (ked->data) {
    short ok = 0;

#define KEY_CHECK_OK(_index) BLI_rctf_isect_pt_v(ked->data, bezt->vec[_index])
    KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK

    /* return ok flags */
    return ok;
  }
  else {
    return 0;
  }
}

/**
 * Called from #ok_bezier_region_lasso and #ok_bezier_channel_lasso
 */
bool keyframe_region_lasso_test(const KeyframeEdit_LassoData *data_lasso, const float xy[2])
{
  if (BLI_rctf_isect_pt_v(data_lasso->rectf_scaled, xy)) {
    float xy_view[2];

    BLI_rctf_transform_pt_v(data_lasso->rectf_view, data_lasso->rectf_scaled, xy_view, xy);

    if (BLI_lasso_is_point_inside(
            data_lasso->mcords, data_lasso->mcords_tot, xy_view[0], xy_view[1], INT_MAX)) {
      return true;
    }
  }

  return false;
}

static short ok_bezier_region_lasso(KeyframeEditData *ked, BezTriple *bezt)
{
  /* check for lasso customdata (KeyframeEdit_LassoData) */
  if (ked->data) {
    short ok = 0;

#define KEY_CHECK_OK(_index) keyframe_region_lasso_test(ked->data, bezt->vec[_index])
    KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK

    /* return ok flags */
    return ok;
  }
  else {
    return 0;
  }
}

static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
{
  /* check for lasso customdata (KeyframeEdit_LassoData) */
  if (ked->data) {
    KeyframeEdit_LassoData *data = ked->data;
    float pt[2];

    /* late-binding remap of the x values (for summary channels) */
    /* XXX: Ideally we reset, but it should be fine just leaving it as-is
     * as the next channel will reset it properly, while the next summary-channel
     * curve will also reset by itself...
     */
    if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) {
      data->rectf_scaled->xmin = ked->f1;
      data->rectf_scaled->xmax = ked->f2;
    }

    /* only use the x-coordinate of the point; the y is the channel range... */
    pt[0] = bezt->vec[1][0];
    pt[1] = ked->channel_y;

    if (keyframe_region_lasso_test(data, pt)) {
      return KEYFRAME_OK_KEY;
    }
  }
  return 0;
}

/**
 * Called from #ok_bezier_region_circle and #ok_bezier_channel_circle
 */
bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, const float xy[2])
{
  if (BLI_rctf_isect_pt_v(data_circle->rectf_scaled, xy)) {
    float xy_view[2];

    BLI_rctf_transform_pt_v(data_circle->rectf_view, data_circle->rectf_scaled, xy_view, xy);

    xy_view[0] = xy_view[0] - data_circle->mval[0];
    xy_view[1] = xy_view[1] - data_circle->mval[1];
    return len_squared_v2(xy_view) < data_circle->radius_squared;
  }

  return false;
}

static short ok_bezier_region_circle(KeyframeEditData *ked, BezTriple *bezt)
{
  /* check for circle select customdata (KeyframeEdit_CircleData) */
  if (ked->data) {
    short ok = 0;

#define KEY_CHECK_OK(_index) keyframe_region_circle_test(ked->data, bezt->vec[_index])
    KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK

    /* return ok flags */
    return ok;
  }
  else {
    return 0;
  }
}

static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
{
  /* check for circle select customdata (KeyframeEdit_CircleData) */
  if (ked->data) {
    KeyframeEdit_CircleData *data = ked->data;
    float pt[2];

    /* late-binding remap of the x values (for summary channels) */
    /* XXX: Ideally we reset, but it should be fine just leaving it as-is
     * as the next channel will reset it properly, while the next summary-channel
     * curve will also reset by itself...
     */
    if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) {
      data->rectf_scaled->xmin = ked->f1;
      data->rectf_scaled->xmax = ked->f2;
    }

    /* only use the x-coordinate of the point; the y is the channel range... */
    pt[0] = bezt->vec[1][0];
    pt[1] = ked->channel_y;

    if (keyframe_region_circle_test(data, pt)) {
      return KEYFRAME_OK_KEY;
    }
  }
  return 0;
}

KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
{
  /* eEditKeyframes_Validate */
  switch (mode) {
    case BEZT_OK_FRAME:
      /* only if bezt falls on the right frame (float) */
      return ok_bezier_frame;
    case BEZT_OK_FRAMERANGE:
      /* only if bezt falls within the specified frame range (floats) */
      return ok_bezier_framerange;
    case BEZT_OK_SELECTED:
      /* only if bezt is selected (self) */
      return ok_bezier_selected;
    case BEZT_OK_VALUE:
      /* only if bezt value matches (float) */
      return ok_bezier_value;
    case BEZT_OK_VALUERANGE:
      /* only if bezier falls within the specified value range (floats) */
      return ok_bezier_valuerange;
    case BEZT_OK_REGION:
      /* only if bezier falls within the specified rect (data -> rectf) */
      return ok_bezier_region;
    case BEZT_OK_REGION_LASSO:
      /* only if the point falls within KeyframeEdit_LassoData defined data */
      return ok_bezier_region_lasso;
    case BEZT_OK_REGION_CIRCLE:
      /* only if the point falls within KeyframeEdit_CircleData defined data */
      return ok_bezier_region_circle;
    case BEZT_OK_CHANNEL_LASSO:
      /* same as BEZT_OK_REGION_LASSO, but we're only using the x-value of the points */
      return ok_bezier_channel_lasso;
    case BEZT_OK_CHANNEL_CIRCLE:
      /* same as BEZT_OK_REGION_CIRCLE, but we're only using the x-value of the points */
      return ok_bezier_channel_circle;
    default: /* nothing was ok */
      return NULL;
  }
}

/* ******************************************* */
/* Assorted Utility Functions */

/**
 * Helper callback for <animeditor>_cfrasnap_exec() ->
 * used to help get the average time of all selected beztriples
 */
short bezt_calc_average(KeyframeEditData *ked, BezTriple *bezt)
{
  /* only if selected */
  if (bezt->f2 & SELECT) {
    /* store average time in float 1 (only do rounding at last step) */
    ked->f1 += bezt->vec[1][0];

    /* store average value in float 2 (only do rounding at last step)
     * - this isn't always needed, but some operators may also require this
     */
    ked->f2 += bezt->vec[1][1];

    /* increment number of items */
    ked->i1++;
  }

  return 0;
}

/* helper callback for columnselect_<animeditor>_keys() -> populate
 * list CfraElems with frame numbers from selected beztriples */
short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt)
{
  /* only if selected */
  if (bezt->f2 & SELECT) {
    CfraElem *ce = MEM_callocN(sizeof(CfraElem), "cfraElem");
    BLI_addtail(&ked->list, ce);

    ce->cfra = bezt->vec[1][0];
  }

  return 0;
}

/* used to remap times from one range to another
 * requires:  ked->data = KeyframeEditCD_Remap
 */
void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
{
  KeyframeEditCD_Remap *rmap = (KeyframeEditCD_Remap *)ked->data;
  const float scale = (rmap->newMax - rmap->newMin) / (rmap->oldMax - rmap->oldMin);

  /* perform transform on all three handles unless indicated otherwise */
  // TODO: need to include some checks for that

  bezt->vec[0][0] = scale * (bezt->vec[0][0] - rmap->oldMin) + rmap->newMin;
  bezt->vec[1][0] = scale * (bezt->vec[1][0] - rmap->oldMin) + rmap->newMin;
  bezt->vec[2][0] = scale * (bezt->vec[2][0] - rmap->oldMin) + rmap->newMin;
}

/* ******************************************* */
/* Transform */

/* snaps the keyframe to the nearest frame */
static short snap_bezier_nearest(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->vec[1][0] = (float)(floorf(bezt->vec[1][0] + 0.5f));
  }
  return 0;
}

/* snaps the keyframe to the nearest second */
static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
{
  const Scene *scene = ked->scene;
  const float secf = (float)FPS;

  if (bezt->f2 & SELECT) {
    bezt->vec[1][0] = (floorf(bezt->vec[1][0] / secf + 0.5f) * secf);
  }
  return 0;
}

/* snaps the keyframe to the current frame */
static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
{
  const Scene *scene = ked->scene;
  if (bezt->f2 & SELECT) {
    bezt->vec[1][0] = (float)CFRA;
  }
  return 0;
}

/* snaps the keyframe time to the nearest marker's frame */
static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->vec[1][0] = (float)ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]);
  }
  return 0;
}

/* make the handles have the same value as the key */
static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1];

    if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
      bezt->h1 = HD_ALIGN;
    }
    if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
      bezt->h2 = HD_ALIGN;
    }
  }
  return 0;
}

/* frame to snap to is stored in the custom data -> first float value slot */
static short snap_bezier_time(KeyframeEditData *ked, BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->vec[1][0] = ked->f1;
  }
  return 0;
}

/* value to snap to is stored in the custom data -> first float value slot */
static short snap_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->vec[1][1] = ked->f1;
  }
  return 0;
}

KeyframeEditFunc ANIM_editkeyframes_snap(short type)
{
  /* eEditKeyframes_Snap */
  switch (type) {
    case SNAP_KEYS_NEARFRAME: /* snap to nearest frame */
      return snap_bezier_nearest;
    case SNAP_KEYS_CURFRAME: /* snap to current frame */
      return snap_bezier_cframe;
    case SNAP_KEYS_NEARMARKER: /* snap to nearest marker */
      return snap_bezier_nearmarker;
    case SNAP_KEYS_NEARSEC: /* snap to nearest second */
      return snap_bezier_nearestsec;
    case SNAP_KEYS_HORIZONTAL: /* snap handles to same value */
      return snap_bezier_horizontal;
    case SNAP_KEYS_TIME: /* snap to given frame/time */
      return snap_bezier_time;
    case SNAP_KEYS_VALUE: /* snap to given value */
      return snap_bezier_value;
    default: /* just in case */
      return snap_bezier_nearest;
  }
}

/* --------- */

static void mirror_bezier_xaxis_ex(BezTriple *bezt, const float center)
{
  float diff;
  int i;

  for (i = 0; i < 3; i++) {
    diff = (center - bezt->vec[i][0]);
    bezt->vec[i][0] = (center + diff);
  }
  swap_v3_v3(bezt->vec[0], bezt->vec[2]);

  SWAP(char, bezt->h1, bezt->h2);
  SWAP(char, bezt->f1, bezt->f3);
}

static void mirror_bezier_yaxis_ex(BezTriple *bezt, const float center)
{
  float diff;
  int i;

  for (i = 0; i < 3; i++) {
    diff = (center - bezt->vec[i][1]);
    bezt->vec[i][1] = (center + diff);
  }
}

static short mirror_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
{
  const Scene *scene = ked->scene;

  if (bezt->f2 & SELECT) {
    mirror_bezier_xaxis_ex(bezt, CFRA);
  }

  return 0;
}

static short mirror_bezier_yaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    /* Yes, names are inverted, we are mirroring across y axis, hence along x axis... */
    mirror_bezier_xaxis_ex(bezt, 0.0f);
  }

  return 0;
}

static short mirror_bezier_xaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    /* Yes, names are inverted, we are mirroring across x axis, hence along y axis... */
    mirror_bezier_yaxis_ex(bezt, 0.0f);
  }

  return 0;
}

static short mirror_bezier_marker(KeyframeEditData *ked, BezTriple *bezt)
{
  /* mirroring time stored in f1 */
  if (bezt->f2 & SELECT) {
    mirror_bezier_xaxis_ex(bezt, ked->f1);
  }

  return 0;
}

static short mirror_bezier_time(KeyframeEditData *ked, BezTriple *bezt)
{
  /* value to mirror over is stored in f1 */
  if (bezt->f2 & SELECT) {
    mirror_bezier_xaxis_ex(bezt, ked->f1);
  }

  return 0;
}

static short mirror_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
{
  /* value to mirror over is stored in the custom data -> first float value slot */
  if (bezt->f2 & SELECT) {
    mirror_bezier_yaxis_ex(bezt, ked->f1);
  }

  return 0;
}

/* Note: for markers and 'value', the values to use must be supplied as the first float value */
// calchandles_fcurve
KeyframeEditFunc ANIM_editkeyframes_mirror(short type)
{
  switch (type) {
    case MIRROR_KEYS_CURFRAME: /* mirror over current frame */
      return mirror_bezier_cframe;
    case MIRROR_KEYS_YAXIS: /* mirror over frame 0 */
      return mirror_bezier_yaxis;
    case MIRROR_KEYS_XAXIS: /* mirror over value 0 */
      return mirror_bezier_xaxis;
    case MIRROR_KEYS_MARKER: /* mirror over marker */
      return mirror_bezier_marker;
    case MIRROR_KEYS_TIME: /* mirror over frame/time */
      return mirror_bezier_time;
    case MIRROR_KEYS_VALUE: /* mirror over given value */
      return mirror_bezier_value;
    default: /* just in case */
      return mirror_bezier_yaxis;
  }
}

/* ******************************************* */
/* Settings */

/**
 * Standard validation step for a few of these
 * (implemented as macro for inlining without fn-call overhead):
 * "if the handles are not of the same type, set them to type free".
 */
#define ENSURE_HANDLES_MATCH(bezt) \
  if (bezt->h1 != bezt->h2) { \
    if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) \
      bezt->h1 = HD_FREE; \
    if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) \
      bezt->h2 = HD_FREE; \
  } \
  (void)0

/* Sets the selected bezier handles to type 'auto' */
static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
    if (bezt->f1 & SELECT) {
      bezt->h1 = HD_AUTO;
    }
    if (bezt->f3 & SELECT) {
      bezt->h2 = HD_AUTO;
    }

    ENSURE_HANDLES_MATCH(bezt);
  }
  return 0;
}

/* Sets the selected bezier handles to type 'auto-clamped'
 * NOTE: this is like auto above, but they're handled a bit different
 */
static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
    if (bezt->f1 & SELECT) {
      bezt->h1 = HD_AUTO_ANIM;
    }
    if (bezt->f3 & SELECT) {
      bezt->h2 = HD_AUTO_ANIM;
    }

    ENSURE_HANDLES_MATCH(bezt);
  }
  return 0;
}

/* Sets the selected bezier handles to type 'vector'  */
static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f1 & SELECT) {
    bezt->h1 = HD_VECT;
  }
  if (bezt->f3 & SELECT) {
    bezt->h2 = HD_VECT;
  }
  return 0;
}

/* Queries if the handle should be set to 'free' or 'align' */
// NOTE: this was used for the 'toggle free/align' option
//      currently this isn't used, but may be restored later
static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if ((bezt->f1 & SELECT) && (bezt->h1)) {
    return 1;
  }
  if ((bezt->f3 & SELECT) && (bezt->h2)) {
    return 1;
  }
  return 0;
}

/* Sets selected bezier handles to type 'align' */
static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f1 & SELECT) {
    bezt->h1 = HD_ALIGN;
  }
  if (bezt->f3 & SELECT) {
    bezt->h2 = HD_ALIGN;
  }
  return 0;
}

/* Sets selected bezier handles to type 'free'  */
static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f1 & SELECT) {
    bezt->h1 = HD_FREE;
  }
  if (bezt->f3 & SELECT) {
    bezt->h2 = HD_FREE;
  }
  return 0;
}

/* Set all selected Bezier Handles to a single type */
// calchandles_fcurve
KeyframeEditFunc ANIM_editkeyframes_handles(short code)
{
  switch (code) {
    case HD_AUTO: /* auto */
      return set_bezier_auto;
    case HD_AUTO_ANIM: /* auto clamped */
      return set_bezier_auto_clamped;

    case HD_VECT: /* vector */
      return set_bezier_vector;
    case HD_FREE: /* free */
      return set_bezier_free;
    case HD_ALIGN: /* align */
      return set_bezier_align;

    default: /* check for toggle free or align? */
      return bezier_isfree;
  }
}

/* ------- */

static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_CONST;
  }
  return 0;
}

static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_LIN;
  }
  return 0;
}

static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_BEZ;
  }
  return 0;
}

static short set_bezt_back(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_BACK;
  }
  return 0;
}

static short set_bezt_bounce(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_BOUNCE;
  }
  return 0;
}

static short set_bezt_circle(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_CIRC;
  }
  return 0;
}

static short set_bezt_cubic(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_CUBIC;
  }
  return 0;
}

static short set_bezt_elastic(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_ELASTIC;
  }
  return 0;
}

static short set_bezt_expo(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_EXPO;
  }
  return 0;
}

static short set_bezt_quad(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_QUAD;
  }
  return 0;
}

static short set_bezt_quart(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_QUART;
  }
  return 0;
}

static short set_bezt_quint(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_QUINT;
  }
  return 0;
}

static short set_bezt_sine(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->ipo = BEZT_IPO_SINE;
  }
  return 0;
}

/* Set the interpolation type of the selected BezTriples in each F-Curve to the specified one */
// ANIM_editkeyframes_ipocurve_ipotype() !
KeyframeEditFunc ANIM_editkeyframes_ipo(short code)
{
  switch (code) {
    /* interpolation */
    case BEZT_IPO_CONST: /* constant */
      return set_bezt_constant;
    case BEZT_IPO_LIN: /* linear */
      return set_bezt_linear;

    /* easing */
    case BEZT_IPO_BACK:
      return set_bezt_back;
    case BEZT_IPO_BOUNCE:
      return set_bezt_bounce;
    case BEZT_IPO_CIRC:
      return set_bezt_circle;
    case BEZT_IPO_CUBIC:
      return set_bezt_cubic;
    case BEZT_IPO_ELASTIC:
      return set_bezt_elastic;
    case BEZT_IPO_EXPO:
      return set_bezt_expo;
    case BEZT_IPO_QUAD:
      return set_bezt_quad;
    case BEZT_IPO_QUART:
      return set_bezt_quart;
    case BEZT_IPO_QUINT:
      return set_bezt_quint;
    case BEZT_IPO_SINE:
      return set_bezt_sine;

    default: /* bezier */
      return set_bezt_bezier;
  }
}

/* ------- */

static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    BEZKEYTYPE(bezt) = BEZT_KEYTYPE_KEYFRAME;
  }
  return 0;
}

static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    BEZKEYTYPE(bezt) = BEZT_KEYTYPE_BREAKDOWN;
  }
  return 0;
}

static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    BEZKEYTYPE(bezt) = BEZT_KEYTYPE_EXTREME;
  }
  return 0;
}

static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    BEZKEYTYPE(bezt) = BEZT_KEYTYPE_JITTER;
  }
  return 0;
}

static short set_keytype_moving_hold(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    BEZKEYTYPE(bezt) = BEZT_KEYTYPE_MOVEHOLD;
  }
  return 0;
}

/* Set the interpolation type of the selected BezTriples in each F-Curve to the specified one */
KeyframeEditFunc ANIM_editkeyframes_keytype(short code)
{
  switch (code) {
    case BEZT_KEYTYPE_BREAKDOWN: /* breakdown */
      return set_keytype_breakdown;

    case BEZT_KEYTYPE_EXTREME: /* extreme keyframe */
      return set_keytype_extreme;

    case BEZT_KEYTYPE_JITTER: /* jitter keyframe */
      return set_keytype_jitter;

    case BEZT_KEYTYPE_MOVEHOLD: /* moving hold */
      return set_keytype_moving_hold;

    case BEZT_KEYTYPE_KEYFRAME: /* proper keyframe */
    default:
      return set_keytype_keyframe;
  }
}

/* ------- */

static short set_easingtype_easein(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->easing = BEZT_IPO_EASE_IN;
  }
  return 0;
}

static short set_easingtype_easeout(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->easing = BEZT_IPO_EASE_OUT;
  }
  return 0;
}

static short set_easingtype_easeinout(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->easing = BEZT_IPO_EASE_IN_OUT;
  }
  return 0;
}

static short set_easingtype_easeauto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  if (bezt->f2 & SELECT) {
    bezt->easing = BEZT_IPO_EASE_AUTO;
  }
  return 0;
}

/* Set the easing type of the selected BezTriples in each F-Curve to the specified one */
KeyframeEditFunc ANIM_editkeyframes_easing(short mode)
{
  switch (mode) {
    case BEZT_IPO_EASE_IN: /* ease in */
      return set_easingtype_easein;

    case BEZT_IPO_EASE_OUT: /* ease out */
      return set_easingtype_easeout;

    case BEZT_IPO_EASE_IN_OUT: /* both */
      return set_easingtype_easeinout;

    default: /* auto */
      return set_easingtype_easeauto;
  }
}

/* ******************************************* */
/* Selection */

static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt)
{
  /* if we've got info on what to select, use it, otherwise select all */
  if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
    if (ked->curflags & KEYFRAME_OK_KEY) {
      bezt->f2 |= SELECT;
    }
    if (ked->curflags & KEYFRAME_OK_H1) {
      bezt->f1 |= SELECT;
    }
    if (ked->curflags & KEYFRAME_OK_H2) {
      bezt->f3 |= SELECT;
    }
  }
  else {
    BEZT_SEL_ALL(bezt);
  }

  return 0;
}

static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt)
{
  /* if we've got info on what to deselect, use it, otherwise deselect all */
  if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
    if (ked->curflags & KEYFRAME_OK_KEY) {
      bezt->f2 &= ~SELECT;
    }
    if (ked->curflags & KEYFRAME_OK_H1) {
      bezt->f1 &= ~SELECT;
    }
    if (ked->curflags & KEYFRAME_OK_H2) {
      bezt->f3 &= ~SELECT;
    }
  }
  else {
    BEZT_DESEL_ALL(bezt);
  }

  return 0;
}

static short select_bezier_invert(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
  /* Invert the selection for the whole bezier triple */
  bezt->f2 ^= SELECT;
  if (bezt->f2 & SELECT) {
    bezt->f1 |= SELECT;
    bezt->f3 |= SELECT;
  }
  else {
    bezt->f1 &= ~SELECT;
    bezt->f3 &= ~SELECT;
  }
  return 0;
}

KeyframeEditFunc ANIM_editkeyframes_select(short selectmode)
{
  switch (selectmode) {
    case SELECT_ADD: /* add */
      return select_bezier_add;
    case SELECT_SUBTRACT: /* subtract */
      return select_bezier_subtract;
    case SELECT_INVERT: /* invert */
      return select_bezier_invert;
    default: /* replace (need to clear all, then add) */
      return select_bezier_add;
  }
}

/* ******************************************* */
/* Selection Maps */

/* Selection maps are simply fancy names for char arrays that store on/off
 * info for whether the selection status. The main purpose for these is to
 * allow extra info to be tagged to the keyframes without influencing their
 * values or having to be removed later.
 */

/* ----------- */

static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt)
{
  FCurve *fcu = ked->fcu;
  char *map = ked->data;
  int i = ked->curIndex;

  /* if current is selected, just make sure it stays this way */
  if (BEZT_ISSEL_ANY(bezt)) {
    map[i] = 1;
    return 0;
  }

  /* if previous is selected, that means that selection should extend across */
  if (i > 0) {
    BezTriple *prev = bezt - 1;

    if (BEZT_ISSEL_ANY(prev)) {
      map[i] = 1;
      return 0;
    }
  }

  /* if next is selected, that means that selection should extend across */
  if (i < (fcu->totvert - 1)) {
    BezTriple *next = bezt + 1;

    if (BEZT_ISSEL_ANY(next)) {
      map[i] = 1;
      return 0;
    }
  }

  return 0;
}

static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
{
  FCurve *fcu = ked->fcu;
  char *map = ked->data;
  int i = ked->curIndex;

  /* if current is selected, check the left/right keyframes
   * since it might need to be deselected (but otherwise no)
   */
  if (BEZT_ISSEL_ANY(bezt)) {
    /* if previous is not selected, we're on the tip of an iceberg */
    if (i > 0) {
      BezTriple *prev = bezt - 1;

      if (BEZT_ISSEL_ANY(prev) == 0) {
        return 0;
      }
    }
    else if (i == 0) {
      /* current keyframe is selected at an endpoint, so should get deselected */
      return 0;
    }

    /* if next is not selected, we're on the tip of an iceberg */
    if (i < (fcu->totvert - 1)) {
      BezTriple *next = bezt + 1;

      if (BEZT_ISSEL_ANY(next) == 0) {
        return 0;
      }
    }
    else if (i == (fcu->totvert - 1)) {
      /* current keyframe is selected at an endpoint, so should get deselected */
      return 0;
    }

    /* if we're still here, that means that keyframe should remain untouched */
    map[i] = 1;
  }

  return 0;
}

/* Get callback for building selection map */
KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode)
{
  switch (mode) {
    case SELMAP_LESS: /* less */
      return selmap_build_bezier_less;

    case SELMAP_MORE: /* more */
    default:
      return selmap_build_bezier_more;
  }
}

/* ----------- */

/* flush selection map values to the given beztriple */
short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt)
{
  const char *map = ked->data;
  short on = map[ked->curIndex];

  /* select or deselect based on whether the map allows it or not */
  if (on) {
    BEZT_SEL_ALL(bezt);
  }
  else {
    BEZT_DESEL_ALL(bezt);
  }

  return 0;
}


<?php

namespace OAuth\OAuth1\Token;

use OAuth\Common\Token\TokenInterface as BaseTokenInterface;

/**
 * OAuth1 specific token interface
 */
interface TokenInterface extends BaseTokenInterface
{

    /**
     * @return string
     */
    public function getAccessTokenSecret();

    /**
     * @param string $accessTokenSecret
     */
    public function setAccessTokenSecret($accessTokenSecret);

    /**
     * @return string
     */
    public function getRequestTokenSecret();

    /**
     * @param string $requestTokenSecret
     */
    public function setRequestTokenSecret($requestTokenSecret);

    /**
     * @return string
     */
    public function getRequestToken();

    /**
     * @param string $requestToken
     */
    public function setRequestToken($requestToken);
}