<?xml version="1.0" encoding="UTF-8"?>
<!-- THIS IS AN OLD VERSION OF DMN EXAMPLE/TEST, PLEASE USE THE MORE RECENT VERSION -->
<!--
  ~ 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.
  -->

<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd"
             xmlns:feel="http://www.omg.org/spec/FEEL/20140401"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             id="_edbd2d8e-a5a8-4660-9bb9-adaa792d900c"
             namespace="https://github.com/kiegroup/kie-dmn"
             name="building-structure-rules"
             xsi:schemaLocation="http://www.omg.org/spec/DMN/20151101/dmn.xsd"
             expressionLanguage="http://www.omg.org/spec/FEEL/20140401"
             typeLanguage="http://www.omg.org/spec/FEEL/20140401">

  <decision id="_building_structure_province_notifications" name="Notification Status">
    <variable name="Notification Status" typeRef="feel:string"/>
    <informationRequirement>
      <requiredInput href="#_existingActivityApplicability"/>
    </informationRequirement>
    <informationRequirement>
      <requiredInput href="#_Distance"/>
    </informationRequirement>
    <informationRequirement>
      <requiredInput href="#_willIncreaseTraffic"/>
    </informationRequirement>
    <decisionTable hitPolicy="UNIQUE" outputLabel="Notification Status" preferredOrientation="Rule-as-Row">
      <input id="_iexistingActivityApplicability" label="existingActivityApplicability">
        <inputExpression typeRef="feel:boolean">
          <text>existingActivityApplicability</text>
        </inputExpression>
      </input>
      <input id="_iDistance" label="Distance">
        <inputExpression typeRef="feel:number">
          <text>Distance</text>
        </inputExpression>
      </input>
      <input id="_iwillIncreaseTraffic" label="willIncreaseTraffic">
        <inputExpression typeRef="feel:boolean">
          <text>willIncreaseTraffic</text>
        </inputExpression>
      </input>
      <output id="_oNotificationStatus">
        <outputValues>
          <text>"Notification to Province Approved", "Notification to Province Declined"</text>
        </outputValues>
      </output>
      <rule id="rule1">
        <inputEntry id="rule1-0">
          <text>true</text>
        </inputEntry>
        <inputEntry id="rule1-1">
          <text><=10000</text>
        </inputEntry>
        <inputEntry id="rule1-2">
          <text>true</text>
        </inputEntry>
        <outputEntry id="rule1-3">
          <text>"Notification to Province Approved"</text>
        </outputEntry>
      </rule>
      <rule id="rule2">
        <inputEntry id="rule2-0">
          <text>true</text>
        </inputEntry>
        <inputEntry id="rule2-1">
          <text>>10000</text>
        </inputEntry>
        <inputEntry id="rule2-2">
          <text>true</text>
        </inputEntry>
        <outputEntry id="rule2-3">
          <text>"Notification to Province Declined"</text>
        </outputEntry>
      </rule>
    </decisionTable>
  </decision>
  <inputData id="_existingActivityApplicability" name="existingActivityApplicability">
    <variable name="existingActivityApplicability" typeRef="feel:boolean"/>
  </inputData>
  <inputData id="_Distance" name="Distance">
    <variable name="Distance" typeRef="feel:number"/>
  </inputData>
  <inputData id="_willIncreaseTraffic" name="willIncreaseTraffic">
    <variable name="willIncreaseTraffic" typeRef="feel:boolean"/>
  </inputData>

  <decision name="Permit Status" id="_building_structure_permit">
    <variable name="Permit Status" typeRef="feel:string"/>
    <informationRequirement>
      <requiredDecision href="#_building_structure_province_notifications"/>
    </informationRequirement>
    <decisionTable hitPolicy="UNIQUE" outputLabel="Permit Status" preferredOrientation="Rule-as-Row">
      <input id="_iexistingNotification" label="Notification Status">
        <inputExpression typeRef="feel:string">
          <text>Notification Status</text>
        </inputExpression>
      </input>
      <output id="_oPermitStatus">
        <outputValues>
          <text>"Building Activity Province Permit Required"</text>
        </outputValues>
      </output>

      <rule id="xrule1">
        <inputEntry id="xrule1-0">
          <text>"Notification to Province Approved"</text>
        </inputEntry>
        <outputEntry id="xrule1-1">
          <text>"Building Activity Province Permit Required"</text>
        </outputEntry>
      </rule>
    </decisionTable>
  </decision>
</definitions>

{'repo_name': 'kiegroup/drools', 'stars': '3079', 'repo_language': 'Java', 'file_name': 'Edge.java', 'mime_type': 'text/plain', 'hash': 3732848180289691493, 'source_dataset': 'data'}


=pod

=head1 NAME

pkeyutl - public key algorithm utility

=head1 SYNOPSIS

B<openssl> B<pkeyutl>
[B<-in file>]
[B<-out file>]
[B<-sigfile file>]
[B<-inkey file>]
[B<-keyform PEM|DER>]
[B<-passin arg>]
[B<-peerkey file>]
[B<-peerform PEM|DER>]
[B<-pubin>]
[B<-certin>]
[B<-rev>]
[B<-sign>]
[B<-verify>]
[B<-verifyrecover>]
[B<-encrypt>]
[B<-decrypt>]
[B<-derive>]
[B<-pkeyopt opt:value>]
[B<-hexdump>]
[B<-asn1parse>]
[B<-engine id>]

=head1 DESCRIPTION

The B<pkeyutl> command can be used to perform public key operations using
any supported algorithm.

=head1 COMMAND OPTIONS

=over 4

=item B<-in filename>

This specifies the input filename to read data from or standard input
if this option is not specified.

=item B<-out filename>

specifies the output filename to write to or standard output by
default.

=item B<-inkey file>

the input key file, by default it should be a private key.

=item B<-keyform PEM|DER>

the key format PEM, DER or ENGINE.

=item B<-passin arg>

the input key password source. For more information about the format of B<arg>
see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.

=item B<-peerkey file>

the peer key file, used by key derivation (agreement) operations.

=item B<-peerform PEM|DER>

the peer key format PEM, DER or ENGINE.

=item B<-engine id>

specifying an engine (by its unique B<id> string) will cause B<pkeyutl>
to attempt to obtain a functional reference to the specified engine,
thus initialising it if needed. The engine will then be set as the default
for all available algorithms.

=item B<-pubin>

the input file is a public key.

=item B<-certin>

the input is a certificate containing a public key.

=item B<-rev>

reverse the order of the input buffer. This is useful for some libraries
(such as CryptoAPI) which represent the buffer in little endian format.

=item B<-sign>

sign the input data and output the signed result. This requires
a private key.

=item B<-verify>

verify the input data against the signature file and indicate if the
verification succeeded or failed.

=item B<-verifyrecover>

verify the input data and output the recovered data.

=item B<-encrypt>

encrypt the input data using a public key.

=item B<-decrypt>

decrypt the input data using a private key.

=item B<-derive>

derive a shared secret using the peer key.

=item B<-hexdump>

hex dump the output data.

=item B<-asn1parse>

asn1parse the output data, this is useful when combined with the
B<-verifyrecover> option when an ASN1 structure is signed.

=back

=head1 NOTES

The operations and options supported vary according to the key algorithm
and its implementation. The OpenSSL operations and options are indicated below.

Unless otherwise mentioned all algorithms support the B<digest:alg> option
which specifies the digest in use for sign, verify and verifyrecover operations.
The value B<alg> should represent a digest name as used in the
EVP_get_digestbyname() function for example B<sha1>.

=head1 RSA ALGORITHM

The RSA algorithm supports encrypt, decrypt, sign, verify and verifyrecover
operations in general. Some padding modes only support some of these
operations however.

=over 4

=item -B<rsa_padding_mode:mode>

This sets the RSA padding mode. Acceptable values for B<mode> are B<pkcs1> for
PKCS#1 padding, B<sslv23> for SSLv23 padding, B<none> for no padding, B<oaep>
for B<OAEP> mode, B<x931> for X9.31 mode and B<pss> for PSS.

In PKCS#1 padding if the message digest is not set then the supplied data is
signed or verified directly instead of using a B<DigestInfo> structure. If a
digest is set then the a B<DigestInfo> structure is used and its the length
must correspond to the digest type.

For B<oeap> mode only encryption and decryption is supported.

For B<x931> if the digest type is set it is used to format the block data
otherwise the first byte is used to specify the X9.31 digest ID. Sign,
verify and verifyrecover are can be performed in this mode.

For B<pss> mode only sign and verify are supported and the digest type must be
specified.

=item B<rsa_pss_saltlen:len>

For B<pss> mode only this option specifies the salt length. Two special values
are supported: -1 sets the salt length to the digest length. When signing -2
sets the salt length to the maximum permissible value. When verifying -2 causes
the salt length to be automatically determined based on the B<PSS> block
structure.

=back

=head1 DSA ALGORITHM

The DSA algorithm supports signing and verification operations only. Currently
there are no additional options other than B<digest>. Only the SHA1
digest can be used and this digest is assumed by default.

=head1 DH ALGORITHM

The DH algorithm only supports the derivation operation and no additional
options.

=head1 EC ALGORITHM

The EC algorithm supports sign, verify and derive operations. The sign and
verify operations use ECDSA and derive uses ECDH. Currently there are no
additional options other than B<digest>. Only the SHA1 digest can be used and
this digest is assumed by default.

=head1 EXAMPLES

Sign some data using a private key:

 openssl pkeyutl -sign -in file -inkey key.pem -out sig

Recover the signed data (e.g. if an RSA key is used):

 openssl pkeyutl -verifyrecover -in sig -inkey key.pem

Verify the signature (e.g. a DSA key):

 openssl pkeyutl -verify -in file -sigfile sig -inkey key.pem

Sign data using a message digest value (this is currently only valid for RSA):

 openssl pkeyutl -sign -in file -inkey key.pem -out sig -pkeyopt digest:sha256

Derive a shared secret value:

 openssl pkeyutl -derive -inkey key.pem -peerkey pubkey.pem -out secret

=head1 SEE ALSO

L<genpkey(1)|genpkey(1)>, L<pkey(1)|pkey(1)>, L<rsautl(1)|rsautl(1)>
L<dgst(1)|dgst(1)>, L<rsa(1)|rsa(1)>, L<genrsa(1)|genrsa(1)>

{'repo_name': 'higepon/mona', 'stars': '157', 'repo_language': 'C', 'file_name': 'pink.css', 'mime_type': 'text/plain', 'hash': 2049853061069769791, 'source_dataset': 'data'}


stderr of test 'merge-statement-aliases.Bug-6715` in directory 'sql/test/BugTracker-2019` itself:

# 10:27:54 >
# 10:27:54 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=31635" "--set" "mapi_usock=/var/tmp/mtest-18243/.s.monetdb.31635" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019" "--set" "embedded_c=true"
# 10:27:54 >

# builtin opt 	gdk_dbpath = /home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/monetdb5/dbfarm/demo
# builtin opt 	monet_prompt = >
# builtin opt 	monet_daemon = no
# builtin opt 	mapi_port = 50000
# builtin opt 	mapi_open = false
# builtin opt 	mapi_autosense = false
# builtin opt 	sql_optimizer = default_pipe
# builtin opt 	sql_debug = 0
# cmdline opt 	gdk_nr_threads = 0
# cmdline opt 	mapi_open = true
# cmdline opt 	mapi_port = 31635
# cmdline opt 	mapi_usock = /var/tmp/mtest-18243/.s.monetdb.31635
# cmdline opt 	monet_prompt =
# cmdline opt 	gdk_dbpath = /home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019
# cmdline opt 	embedded_c = true
#main thread:!ERROR:MALException:client.quit:Server stopped

# 10:27:55 >
# 10:27:55 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-18243" "--port=31635"
# 10:27:55 >

MAPI  = (monetdb) /var/tmp/mtest-25315/.s.monetdb.33017
QUERY = MERGE INTO ProductTarget T USING ProductSource S ON S.ProductID = T.ProductID WHEN MATCHED THEN UPDATE SET T.Name = S.Name, ProductTarget.ProductNumber = S.ProductNumber, ProductTarget.Color = S.Color;
ERROR = !syntax error, unexpected '.', expecting '=' in: "merge into producttarget t using productsource s on s.productid = t.productid wh"
CODE  = 42000
MAPI  = (monetdb) /var/tmp/mtest-25315/.s.monetdb.33017
QUERY = MERGE INTO ProductTarget T USING ProductSource S ON S.ProductID = T.ProductID WHEN NOT MATCHED THEN INSERT (T.ProductID, ProductTarget.ProductNumber, ProductTarget.Color, T.Name) VALUES (S.ProductID, S.ProductNumber, S.Color, S.Name);
ERROR = !syntax error, unexpected '.', expecting ')' or ',' in: "merge into producttarget t using productsource s on s.productid = t.productid wh"
CODE  = 42000
MAPI  = (monetdb) /var/tmp/mtest-25315/.s.monetdb.33017
QUERY = MERGE INTO ProductTarget T USING ProductSource S ON S.ProductID = T.ProductID
         WHEN MATCHED     THEN UPDATE SET ProductTarget.Name = S.Name, ProductTarget.ProductNumber = S.ProductNumber, T.Color = S.Color
         WHEN NOT MATCHED THEN INSERT (T.ProductID, ProductTarget.ProductNumber, ProductTarget.Color, T.Name) VALUES (ProductID, S.ProductNumber, S.Color, Name);
ERROR = !syntax error, unexpected '.', expecting '=' in: "merge into producttarget t using productsource s on s.productid = t.productid
        ! w"
CODE  = 42000
MAPI  = (monetdb) /var/tmp/mtest-25315/.s.monetdb.33017
QUERY = MERGE INTO ProductTarget T USING ProductSource S ON T.ProductID = S.ProductID
         WHEN MATCHED     THEN UPDATE SET T.Name = S.Name, T.ProductNumber = ProductNumber, T.Color = Color
         WHEN NOT MATCHED THEN INSERT (T.ProductID, T.ProductNumber, T.Color, T.Name) VALUES (ProductID, S.ProductNumber, S.Color, Name);
ERROR = !syntax error, unexpected '.', expecting '=' in: "merge into producttarget t using productsource s on t.productid = s.productid
        ! w"
CODE  = 42000

# 10:27:55 >
# 10:27:55 >  "Done."
# 10:27:55 >

{'repo_name': 'MonetDB/MonetDB', 'stars': '296', 'repo_language': 'TSQL', 'file_name': 'mkodbcwxs.py', 'mime_type': 'text/x-python', 'hash': 8540547364867756739, 'source_dataset': 'data'}


# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This exposes the Chrome branding as GN variables for use in build files.
#
# PREFER NOT TO USE THESE. The GYP build uses this kind of thing extensively.
# However, it is far better to write an action to generate a file at
# build-time with the information you need. This allows better dependency
# checking and GN will run faster.
#
# These values should only be used if you REALLY need to depend on them at
# build-time, for example, in the computation of output file names.

import("//build/config/chrome_build.gni")

_branding_dictionary_template =
    "full_name = \"@PRODUCT_FULLNAME@\" " +
    "short_name = \"@PRODUCT_SHORTNAME@\" " +
    "bundle_id = \"@MAC_BUNDLE_ID@\" " +
    "creator_code = \"@MAC_CREATOR_CODE@\" " +
    "installer_full_name = \"@PRODUCT_INSTALLER_FULLNAME@\" " +
    "installer_short_name = \"@PRODUCT_INSTALLER_SHORTNAME@\" " +
    "team_id = \"@MAC_TEAM_ID@\" "

_result = exec_script("version.py",
                      [
                        "-f",
                        rebase_path(branding_file_path, root_build_dir),
                        "-t",
                        _branding_dictionary_template,
                      ],
                      "scope",
                      [ branding_file_path ])

chrome_product_full_name = _result.full_name
chrome_product_short_name = _result.short_name
chrome_product_installer_full_name = _result.installer_full_name
chrome_product_installer_short_name = _result.installer_short_name

if (is_mac) {
  chrome_mac_bundle_id = _result.bundle_id
  chrome_mac_creator_code = _result.creator_code
  chrome_mac_team_id = _result.team_id
}

{'repo_name': 'klzgrad/naiveproxy', 'stars': '737', 'repo_language': 'C++', 'file_name': 'f123c08d0a46b72fa8989296e82e7aa25ebf16f8', 'mime_type': 'text/plain', 'hash': -4274118806979846316, 'source_dataset': 'data'}


/var/log/kibana/kibana5.log {
    daily
    rotate 7
    copytruncate
    compress
    delaycompress
    missingok
    notifempty
}

{'repo_name': 'spujadas/elk-docker', 'stars': '1732', 'repo_language': 'Shell', 'file_name': 'index.html', 'mime_type': 'text/html', 'hash': 4940297493458976057, 'source_dataset': 'data'}


# Copyright 2019, The TensorFlow Federated Authors.
#
# 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.

import warnings

from absl.testing import parameterized
import numpy as np
import tensorflow as tf

from tensorflow_federated.python.common_libs import test
from tensorflow_federated.python.core.api import computation_types
from tensorflow_federated.python.core.api import computations
from tensorflow_federated.python.core.api import placements
from tensorflow_federated.python.core.backends.native import execution_contexts
from tensorflow_federated.python.core.impl.types import type_conversions
from tensorflow_federated.python.core.templates.measured_process import MeasuredProcess
from tensorflow_federated.python.core.utils import encoding_utils
from tensorflow_federated.python.core.utils.computation_utils import StatefulAggregateFn
from tensorflow_federated.python.core.utils.computation_utils import StatefulBroadcastFn
from tensorflow_model_optimization.python.core.internal import tensor_encoding as te

_bad_encoder_named_parameters = [('float', 1.0), ('string', 'str'),
                                 ('object', object),
                                 ('encoder', te.encoders.identity())]

class EncodedBroadcastTest(test.TestCase, parameterized.TestCase):
  """Tests for build_encoded_broadcast method."""

  def test_build_encoded_broadcast_raise_warning(self):
    value = tf.constant(np.random.rand(20))
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    encoder = te.encoders.as_simple_encoder(te.encoders.identity(), value_spec)

    with warnings.catch_warnings(record=True):
      warnings.simplefilter('error', DeprecationWarning)
      with self.assertRaisesRegex(DeprecationWarning,
                                  'tff.utils.build_encoded_broadcast()'):
        encoding_utils.build_encoded_broadcast(value, encoder)

  @parameterized.named_parameters(
      ('tf_constant_identity', tf.constant, te.encoders.identity),
      ('tf_constant_uniform_quantization', tf.constant,
       lambda: te.encoders.uniform_quantization(8)),
      ('numpy_identity', lambda x: x, te.encoders.identity),
      ('numpy_uniform_quantization', lambda x: x,
       lambda: te.encoders.uniform_quantization(8)),
  )
  def test_build_encoded_broadcast(self, value_constructor,
                                   encoder_constructor):
    value = value_constructor(np.random.rand(20))
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    value_type = computation_types.to_type(value_spec)
    encoder = te.encoders.as_simple_encoder(encoder_constructor(), value_spec)
    broadcast_fn = encoding_utils.build_encoded_broadcast(value, encoder)
    state_type = broadcast_fn._initialize_fn.type_signature.result
    broadcast_signature = computations.federated_computation(
        broadcast_fn._next_fn,
        computation_types.FederatedType(state_type, placements.SERVER),
        computation_types.FederatedType(value_type,
                                        placements.SERVER)).type_signature

    self.assertIsInstance(broadcast_fn, StatefulBroadcastFn)
    self.assertEqual(state_type, broadcast_signature.result[0].member)
    self.assertEqual(placements.SERVER, broadcast_signature.result[0].placement)
    self.assertEqual(value_type, broadcast_signature.result[1].member)
    self.assertEqual(placements.CLIENTS,
                     broadcast_signature.result[1].placement)

  @parameterized.named_parameters(*_bad_encoder_named_parameters)
  def test_build_encoded_broadcast_raises_bad_encoder(self, bad_encoder):
    value = tf.constant([0.0, 1.0])
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_broadcast(value, bad_encoder)

  def test_build_encoded_broadcast_raises_incompatible_encoder(self):
    value = tf.constant([0.0, 1.0])
    incompatible_encoder = te.encoders.as_simple_encoder(
        te.encoders.identity(), tf.TensorSpec((3,)))
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_broadcast(value, incompatible_encoder)

  def test_build_encoded_broadcast_raises_bad_structure(self):
    value = [tf.constant([0.0, 1.0]), tf.constant([0.0, 1.0])]
    encoder = te.encoders.as_simple_encoder(te.encoders.identity(),
                                            tf.TensorSpec((2,)))
    with self.assertRaises(ValueError):
      encoding_utils.build_encoded_broadcast(value, encoder)

class EncodedBroadcastProcessTest(test.TestCase, parameterized.TestCase):
  """Tests for build_encoded_broadcast_process method."""

  @parameterized.named_parameters(
      ('tf_constant_identity', tf.constant, te.encoders.identity),
      ('tf_constant_uniform_quantization', tf.constant,
       lambda: te.encoders.uniform_quantization(8)),
      ('numpy_identity', lambda x: x, te.encoders.identity),
      ('numpy_uniform_quantization', lambda x: x,
       lambda: te.encoders.uniform_quantization(8)),
  )
  def test_build_encoded_broadcast_process(self, value_constructor,
                                           encoder_constructor):
    value = value_constructor(np.random.rand(20))
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    value_type = computation_types.to_type(value_spec)
    encoder = te.encoders.as_simple_encoder(encoder_constructor(), value_spec)
    broadcast_process = encoding_utils.build_encoded_broadcast_process(
        value_type, encoder)
    state_type = broadcast_process._initialize_fn.type_signature.result
    broadcast_signature = broadcast_process._next_fn.type_signature

    self.assertIsInstance(broadcast_process, MeasuredProcess)
    self.assertEqual(state_type, broadcast_signature.result[0])
    self.assertEqual(placements.SERVER, broadcast_signature.result[0].placement)
    self.assertEqual(value_type, broadcast_signature.result[1].member)
    self.assertEqual(placements.CLIENTS,
                     broadcast_signature.result[1].placement)

  @parameterized.named_parameters(*_bad_encoder_named_parameters)
  def test_build_encoded_broadcast_process_raises_bad_encoder(
      self, bad_encoder):
    value_type = computation_types.TensorType(tf.float32, shape=[2])
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_broadcast_process(value_type, bad_encoder)

  def test_build_encoded_broadcast_process_raises_incompatible_encoder(self):
    value_type = computation_types.TensorType(tf.float32, shape=[2])
    incompatible_encoder = te.encoders.as_simple_encoder(
        te.encoders.identity(), tf.TensorSpec((3,)))
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_broadcast_process(value_type,
                                                     incompatible_encoder)

  def test_build_encoded_broadcast_process_raises_bad_structure(self):
    value_type = computation_types.StructType([
        computation_types.TensorType(tf.float32, shape=[2]),
        computation_types.TensorType(tf.float32, shape=[2])
    ])
    encoder = te.encoders.as_simple_encoder(te.encoders.identity(),
                                            tf.TensorSpec((2,)))
    with self.assertRaises(ValueError):
      encoding_utils.build_encoded_broadcast_process(value_type, encoder)

class EncodedSumTest(test.TestCase, parameterized.TestCase):
  """Tests for build_encoded_sum method."""

  def test_build_encoded_sum_raise_warning(self):
    value = tf.constant(np.random.rand(20))
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(), value_spec)

    with warnings.catch_warnings(record=True):
      warnings.simplefilter('error', DeprecationWarning)
      with self.assertRaisesRegex(DeprecationWarning,
                                  'tff.utils.build_encoded_sum()'):
        encoding_utils.build_encoded_sum(value, encoder)

  @parameterized.named_parameters(
      ('tf_constant_identity', tf.constant, te.encoders.identity),
      ('tf_constant_uniform_quantization', tf.constant,
       lambda: te.encoders.uniform_quantization(8)),
      ('numpy_identity', lambda x: x, te.encoders.identity),
      ('numpy_uniform_quantization', lambda x: x,
       lambda: te.encoders.uniform_quantization(8)),
  )
  def test_build_encoded_sum(self, value_constructor, encoder_constructor):
    value = value_constructor(np.random.rand(20))
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    value_type = computation_types.to_type(value_spec)
    encoder = te.encoders.as_gather_encoder(encoder_constructor(), value_spec)
    gather_fn = encoding_utils.build_encoded_sum(value, encoder)
    self.assertIsInstance(gather_fn, StatefulAggregateFn)

    state_type = gather_fn._initialize_fn.type_signature.result

    @computations.federated_computation(
        computation_types.FederatedType(state_type, placements.SERVER),
        computation_types.FederatedType(value_type, placements.CLIENTS),
        computation_types.FederatedType(
            computation_types.to_type(tf.float32), placements.CLIENTS))
    def gather_computation(state, value, weight):
      return gather_fn._next_fn(state, value, weight)

    gather_result_type = gather_computation.type_signature.result

    self.assertEqual(state_type, gather_result_type[0].member)
    self.assertEqual(placements.SERVER, gather_result_type[0].placement)
    self.assertEqual(value_type, gather_result_type[1].member)
    self.assertEqual(placements.SERVER, gather_result_type[1].placement)

  def test_run_encoded_sum(self):
    value = np.array([0.0, 1.0, 2.0, -1.0])
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    value_type = computation_types.to_type(value_spec)
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(), value_spec)
    gather_fn = encoding_utils.build_encoded_sum(value, encoder)
    initial_state = gather_fn.initialize()

    @computations.federated_computation(
        computation_types.FederatedType(
            gather_fn._initialize_fn.type_signature.result, placements.SERVER),
        computation_types.FederatedType(value_type, placements.CLIENTS))
    def call_gather(state, value):
      return gather_fn(state, value)

    _, value_sum = call_gather(initial_state, [value, value])
    self.assertAllClose(2 * value, value_sum)

    _, value_sum = call_gather(initial_state, [value, -value])
    self.assertAllClose(0 * value, value_sum)

    _, value_sum = call_gather(initial_state, [value, 2 * value])
    self.assertAllClose(3 * value, value_sum)

  @parameterized.named_parameters(*_bad_encoder_named_parameters)
  def test_build_encoded_sum_raises_bad_encoder(self, bad_encoder):
    value = tf.constant([0.0, 1.0])
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_sum(value, bad_encoder)

  def test_build_encoded_sum_raises_incompatible_encoder(self):
    value = tf.constant([0.0, 1.0])
    incompatible_encoder = te.encoders.as_gather_encoder(
        te.encoders.identity(), tf.TensorSpec((3,)))
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_sum(value, incompatible_encoder)

  def test_build_encoded_sum_raises_bad_structure(self):
    value = [tf.constant([0.0, 1.0]), tf.constant([0.0, 1.0])]
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(),
                                            tf.TensorSpec((2,)))
    with self.assertRaises(ValueError):
      encoding_utils.build_encoded_sum(value, encoder)

class EncodedSumProcessTest(test.TestCase, parameterized.TestCase):
  """Tests for build_encoded_sum_process method."""

  @parameterized.named_parameters(
      ('tf_constant_identity', tf.constant, te.encoders.identity),
      ('tf_constant_uniform_quantization', tf.constant,
       lambda: te.encoders.uniform_quantization(8)),
      ('numpy_identity', lambda x: x, te.encoders.identity),
      ('numpy_uniform_quantization', lambda x: x,
       lambda: te.encoders.uniform_quantization(8)),
  )
  def test_build_encoded_sum_process(self, value_constructor,
                                     encoder_constructor):
    value = value_constructor(np.random.rand(20))
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    value_type = computation_types.to_type(value_spec)
    encoder = te.encoders.as_gather_encoder(encoder_constructor(), value_spec)
    gather_process = encoding_utils.build_encoded_sum_process(
        value_type, encoder)
    state_type = gather_process._initialize_fn.type_signature.result
    gather_signature = gather_process._next_fn.type_signature

    self.assertIsInstance(gather_process, MeasuredProcess)
    self.assertEqual(state_type, gather_signature.result[0])
    self.assertEqual(placements.SERVER, gather_signature.result[0].placement)
    self.assertEqual(value_type, gather_signature.result[1].member)
    self.assertEqual(placements.SERVER, gather_signature.result[1].placement)

  def test_run_encoded_sum_process(self):
    value = np.array([0.0, 1.0, 2.0, -1.0])
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(), value_spec)
    value_type = type_conversions.type_from_tensors(value)
    gather_process = encoding_utils.build_encoded_sum_process(
        value_type, encoder)
    initial_state = gather_process.initialize()
    call_gather = gather_process._next_fn

    output = call_gather(initial_state, [value, value])
    self.assertAllClose(2 * value, output.result)

    output = call_gather(initial_state, [value, -value])
    self.assertAllClose(0 * value, output.result)

    output = call_gather(initial_state, [value, 2 * value])
    self.assertAllClose(3 * value, output.result)

  @parameterized.named_parameters(*_bad_encoder_named_parameters)
  def test_build_encoded_sum_process_raises_bad_encoder(self, bad_encoder):
    value_type = computation_types.TensorType(tf.float32, shape=[2])
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_sum_process(value_type, bad_encoder)

  def test_build_encoded_sum_process_raises_incompatible_encoder(self):
    value_type = computation_types.TensorType(tf.float32, shape=[2])
    incompatible_encoder = te.encoders.as_gather_encoder(
        te.encoders.identity(), tf.TensorSpec((3,)))
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_sum_process(value_type, incompatible_encoder)

  def test_build_encoded_sum_process_raises_bad_structure(self):
    value_type = computation_types.StructType([
        computation_types.TensorType(tf.float32, shape=[2]),
        computation_types.TensorType(tf.float32, shape=[2])
    ])
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(),
                                            tf.TensorSpec((2,)))
    with self.assertRaises(ValueError):
      encoding_utils.build_encoded_sum_process(value_type, encoder)

class EncodedMeanTest(test.TestCase, parameterized.TestCase):
  """Tests for build_encoded_mean method."""

  def test_build_encoded_mean_raise_warning(self):
    value = tf.constant(np.random.rand(20))
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(), value_spec)

    with warnings.catch_warnings(record=True):
      warnings.simplefilter('error', DeprecationWarning)
      with self.assertRaisesRegex(DeprecationWarning,
                                  'tff.utils.build_encoded_mean()'):
        encoding_utils.build_encoded_mean(value, encoder)

  @parameterized.named_parameters(
      ('tf_constant_identity', tf.constant, te.encoders.identity),
      ('tf_constant_uniform_quantization', tf.constant,
       lambda: te.encoders.uniform_quantization(8)),
      ('numpy_identity', lambda x: x, te.encoders.identity),
      ('numpy_uniform_quantization', lambda x: x,
       lambda: te.encoders.uniform_quantization(8)),
  )
  def test_build_encoded_mean(self, value_constructor, encoder_constructor):
    value = value_constructor(np.random.rand(20))
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    value_type = computation_types.to_type(value_spec)
    encoder = te.encoders.as_gather_encoder(encoder_constructor(), value_spec)
    gather_fn = encoding_utils.build_encoded_mean(value, encoder)
    state_type = gather_fn._initialize_fn.type_signature.result
    gather_signature = computations.federated_computation(
        gather_fn._next_fn,
        computation_types.FederatedType(state_type, placements.SERVER),
        computation_types.FederatedType(value_type, placements.CLIENTS),
        computation_types.FederatedType(
            computation_types.to_type(tf.float32),
            placements.CLIENTS)).type_signature

    self.assertIsInstance(gather_fn, StatefulAggregateFn)
    self.assertEqual(state_type, gather_signature.result[0].member)
    self.assertEqual(placements.SERVER, gather_signature.result[0].placement)
    self.assertEqual(value_type, gather_signature.result[1].member)
    self.assertEqual(placements.SERVER, gather_signature.result[1].placement)

  def test_run_encoded_mean(self):
    value = np.array([0.0, 1.0, 2.0, -1.0])
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    value_type = computation_types.to_type(value_spec)
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(), value_spec)
    gather_fn = encoding_utils.build_encoded_mean(value, encoder)
    initial_state = gather_fn.initialize()

    @computations.federated_computation(
        computation_types.FederatedType(
            gather_fn._initialize_fn.type_signature.result, placements.SERVER),
        computation_types.FederatedType(value_type, placements.CLIENTS),
        computation_types.FederatedType(
            computation_types.to_type(tf.float32), placements.CLIENTS))
    def call_gather(state, value, weight):
      return gather_fn(state, value, weight)

    _, value_mean = call_gather(initial_state, [value, value], [1.0, 1.0])
    self.assertAllClose(1 * value, value_mean)

    _, value_mean = call_gather(initial_state, [value, value], [0.3, 0.7])
    self.assertAllClose(1 * value, value_mean)

    _, value_mean = call_gather(initial_state, [value, 2 * value], [1.0, 2.0])
    self.assertAllClose(5 / 3 * value, value_mean)

  @parameterized.named_parameters(*_bad_encoder_named_parameters)
  def test_build_encoded_mean_raises_bad_encoder(self, bad_encoder):
    value = tf.constant([0.0, 1.0])
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_mean(value, bad_encoder)

  def test_build_encoded_mean_raises_incompatible_encoder(self):
    value = tf.constant([0.0, 1.0])
    incompatible_encoder = te.encoders.as_gather_encoder(
        te.encoders.identity(), tf.TensorSpec((3,)))
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_mean(value, incompatible_encoder)

  def test_build_encoded_mean_raises_bad_structure(self):
    value = [tf.constant([0.0, 1.0]), tf.constant([0.0, 1.0])]
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(),
                                            tf.TensorSpec((2,)))
    with self.assertRaises(ValueError):
      encoding_utils.build_encoded_mean(value, encoder)

class EncodedMeanProcessTest(test.TestCase, parameterized.TestCase):
  """Tests for build_encoded_mean_process method."""

  @parameterized.named_parameters(
      ('tf_constant_identity', tf.constant, te.encoders.identity),
      ('tf_constant_uniform_quantization', tf.constant,
       lambda: te.encoders.uniform_quantization(8)),
      ('numpy_identity', lambda x: x, te.encoders.identity),
      ('numpy_uniform_quantization', lambda x: x,
       lambda: te.encoders.uniform_quantization(8)),
  )
  def test_build_encoded_mean_process(self, value_constructor,
                                      encoder_constructor):
    value = value_constructor(np.random.rand(20))
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    value_type = computation_types.to_type(value_spec)
    encoder = te.encoders.as_gather_encoder(encoder_constructor(), value_spec)
    gather_process = encoding_utils.build_encoded_mean_process(
        value_type, encoder)
    state_type = gather_process._initialize_fn.type_signature.result
    gather_signature = gather_process._next_fn.type_signature

    self.assertIsInstance(gather_process, MeasuredProcess)
    self.assertEqual(state_type, gather_signature.result[0])
    self.assertEqual(placements.SERVER, gather_signature.result[0].placement)
    self.assertEqual(value_type, gather_signature.result[1].member)
    self.assertEqual(placements.SERVER, gather_signature.result[1].placement)

  def test_run_encoded_mean_process(self):
    value = np.array([0.0, 1.0, 2.0, -1.0])
    value_spec = tf.TensorSpec(value.shape, tf.dtypes.as_dtype(value.dtype))
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(), value_spec)
    value_type = type_conversions.type_from_tensors(value)
    gather_process = encoding_utils.build_encoded_mean_process(
        value_type, encoder)
    initial_state = gather_process.initialize()
    call_gather = gather_process._next_fn

    output = call_gather(initial_state, [value, value], [1.0, 1.0])
    self.assertAllClose(1 * value, output.result)

    output = call_gather(initial_state, [value, value], [0.3, 0.7])
    self.assertAllClose(1 * value, output.result)

    output = call_gather(initial_state, [value, 2 * value], [1.0, 2.0])
    self.assertAllClose(5 / 3 * value, output.result)

  @parameterized.named_parameters(*_bad_encoder_named_parameters)
  def test_build_encoded_mean_process_raises_bad_encoder(self, bad_encoder):
    value_type = computation_types.TensorType(tf.float32, shape=[2])
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_mean_process(value_type, bad_encoder)

  def test_build_encoded_mean_process_raises_incompatible_encoder(self):
    value_type = computation_types.TensorType(tf.float32, shape=[2])
    incompatible_encoder = te.encoders.as_gather_encoder(
        te.encoders.identity(), tf.TensorSpec((3,)))
    with self.assertRaises(TypeError):
      encoding_utils.build_encoded_mean_process(value_type,
                                                incompatible_encoder)

  def test_build_encoded_mean_process_raises_bad_structure(self):
    value_type = computation_types.StructType([
        computation_types.TensorType(tf.float32, shape=[2]),
        computation_types.TensorType(tf.float32, shape=[2])
    ])
    encoder = te.encoders.as_gather_encoder(te.encoders.identity(),
                                            tf.TensorSpec((2,)))
    with self.assertRaises(ValueError):
      encoding_utils.build_encoded_mean_process(value_type, encoder)

class EncodingUtilsTest(test.TestCase, parameterized.TestCase):
  """Tests for utilities for building StatefulFns."""

  @parameterized.named_parameters(
      ('identity', te.encoders.identity),
      ('uniform', lambda: te.encoders.uniform_quantization(8)),
      ('hadamard', lambda: te.encoders.hadamard_quantization(8)),
      (
          'one_over_n',
          lambda: te.core.EncoderComposer(  # pylint: disable=g-long-lambda
              te.testing.PlusOneOverNEncodingStage()).make()),
      (
          'state_update',
          lambda: te.core.EncoderComposer(  # pylint: disable=g-long-lambda
              StateUpdateTensorsEncodingStage()).make()),
  )
  def test_build_encode_decode_tf_computations_for_broadcast(
      self, encoder_constructor):
    value_spec = tf.TensorSpec((20,), tf.float32)
    encoder = te.encoders.as_simple_encoder(encoder_constructor(), value_spec)

    _, state_type = encoding_utils._build_initial_state_tf_computation(encoder)
    value_type = computation_types.to_type(value_spec)
    encode_fn, decode_fn = (
        encoding_utils._build_encode_decode_tf_computations_for_broadcast(
            state_type, value_type, encoder))

    self.assertEqual(state_type, encode_fn.type_signature.parameter[0])
    self.assertEqual(state_type, encode_fn.type_signature.result[0])
    # Output of encode should be the input to decode.
    self.assertEqual(encode_fn.type_signature.result[1],
                     decode_fn.type_signature.parameter)
    # Decode should return the same type as input to encode - value_type.
    self.assertEqual(value_type, encode_fn.type_signature.parameter[1])
    self.assertEqual(value_type, decode_fn.type_signature.result)

  @parameterized.named_parameters(
      ('identity', te.encoders.identity),
      ('uniform', lambda: te.encoders.uniform_quantization(8)),
      ('hadamard', lambda: te.encoders.hadamard_quantization(8)),
      (
          'one_over_n',
          lambda: te.core.EncoderComposer(  # pylint: disable=g-long-lambda
              te.testing.PlusOneOverNEncodingStage()).make()),
      (
          'state_update',
          lambda: te.core.EncoderComposer(  # pylint: disable=g-long-lambda
              StateUpdateTensorsEncodingStage()).make()),
  )
  def test_build_tf_computations_for_sum(self, encoder_constructor):
    # Tests that the partial computations have matching relevant input-output
    # signatures.
    value_spec = tf.TensorSpec((20,), tf.float32)
    encoder = te.encoders.as_gather_encoder(encoder_constructor(), value_spec)

    _, state_type = encoding_utils._build_initial_state_tf_computation(encoder)
    value_type = computation_types.to_type(value_spec)
    nest_encoder = encoding_utils._build_tf_computations_for_gather(
        state_type, value_type, encoder)

    self.assertEqual(state_type,
                     nest_encoder.get_params_fn.type_signature.parameter)
    encode_params_type = nest_encoder.get_params_fn.type_signature.result[0]
    decode_before_sum_params_type = nest_encoder.get_params_fn.type_signature.result[
        1]
    decode_after_sum_params_type = nest_encoder.get_params_fn.type_signature.result[
        2]

    self.assertEqual(value_type,
                     nest_encoder.encode_fn.type_signature.parameter[0])
    self.assertEqual(encode_params_type,
                     nest_encoder.encode_fn.type_signature.parameter[1])
    self.assertEqual(decode_before_sum_params_type,
                     nest_encoder.encode_fn.type_signature.parameter[2])
    state_update_tensors_type = nest_encoder.encode_fn.type_signature.result[2]

    accumulator_type = nest_encoder.zero_fn.type_signature.result
    self.assertEqual(state_update_tensors_type,
                     accumulator_type.state_update_tensors)

    self.assertEqual(accumulator_type,
                     nest_encoder.accumulate_fn.type_signature.parameter[0])
    self.assertEqual(nest_encoder.encode_fn.type_signature.result,
                     nest_encoder.accumulate_fn.type_signature.parameter[1])
    self.assertEqual(accumulator_type,
                     nest_encoder.accumulate_fn.type_signature.result)
    self.assertEqual(accumulator_type,
                     nest_encoder.merge_fn.type_signature.parameter[0])
    self.assertEqual(accumulator_type,
                     nest_encoder.merge_fn.type_signature.parameter[1])
    self.assertEqual(accumulator_type,
                     nest_encoder.merge_fn.type_signature.result)
    self.assertEqual(accumulator_type,
                     nest_encoder.report_fn.type_signature.parameter)
    self.assertEqual(accumulator_type,
                     nest_encoder.report_fn.type_signature.result)

    self.assertEqual(
        accumulator_type.values,
        nest_encoder.decode_after_sum_fn.type_signature.parameter[0])
    self.assertEqual(
        decode_after_sum_params_type,
        nest_encoder.decode_after_sum_fn.type_signature.parameter[1])
    self.assertEqual(value_type,
                     nest_encoder.decode_after_sum_fn.type_signature.result)

    self.assertEqual(state_type,
                     nest_encoder.update_state_fn.type_signature.parameter[0])
    self.assertEqual(state_update_tensors_type,
                     nest_encoder.update_state_fn.type_signature.parameter[1])
    self.assertEqual(state_type,
                     nest_encoder.update_state_fn.type_signature.result)

@te.core.tf_style_adaptive_encoding_stage
class StateUpdateTensorsEncodingStage(te.core.AdaptiveEncodingStageInterface):
  """Test encoding stage using supported state aggregation modes.

  This implementation does not use `encoding_stage.StateAggregationMode.STACK`
  which is currently not supported by the implementation.
  """

  ENCODED_VALUES_KEY = 'state_update_tensors_identity'
  SUM_STATE_UPDATE_KEY = 'state_update_tensors_update_sum'
  MIN_STATE_UPDATE_KEY = 'state_update_tensors_update_min'
  MAX_STATE_UPDATE_KEY = 'state_update_tensors_update_max'
  LAST_SUM_STATE_KEY = 'state_update_tensors_state_sum'
  LAST_MIN_STATE_KEY = 'state_update_tensors_state_min'
  LAST_MAX_STATE_KEY = 'state_update_tensors_state_max'

  @property
  def name(self):
    """See base class."""
    return 'state_update_tensors'

  @property
  def compressible_tensors_keys(self):
    """See base class."""
    return [self.ENCODED_VALUES_KEY]

  @property
  def commutes_with_sum(self):
    """See base class."""
    return True

  @property
  def decode_needs_input_shape(self):
    """See base class."""
    return False

  @property
  def state_update_aggregation_modes(self):
    """See base class."""
    return {
        self.SUM_STATE_UPDATE_KEY: te.core.StateAggregationMode.SUM,
        self.MIN_STATE_UPDATE_KEY: te.core.StateAggregationMode.MIN,
        self.MAX_STATE_UPDATE_KEY: te.core.StateAggregationMode.MAX,
    }

  def initial_state(self):
    """See base class."""
    return {
        self.LAST_SUM_STATE_KEY: tf.constant(0.0),
        self.LAST_MIN_STATE_KEY: tf.constant(0.0),
        self.LAST_MAX_STATE_KEY: tf.constant(0.0),
    }

  def update_state(self, state, state_update_tensors):
    """See base class."""
    del state  # Unused.
    return {
        self.LAST_SUM_STATE_KEY:
            tf.reduce_sum(state_update_tensors[self.SUM_STATE_UPDATE_KEY]),
        self.LAST_MIN_STATE_KEY:
            tf.reduce_min(state_update_tensors[self.MIN_STATE_UPDATE_KEY]),
        self.LAST_MAX_STATE_KEY:
            tf.reduce_max(state_update_tensors[self.MAX_STATE_UPDATE_KEY])
    }

  def get_params(self, state):
    """See base class."""
    del state  # Unused.
    return {}, {}

  def encode(self, x, encode_params):
    """See base class."""
    del encode_params  # Unused.
    x = tf.identity(x)
    return {
        self.ENCODED_VALUES_KEY: x
    }, {
        self.SUM_STATE_UPDATE_KEY: tf.reduce_sum(x),
        self.MIN_STATE_UPDATE_KEY: tf.reduce_min(x),
        self.MAX_STATE_UPDATE_KEY: tf.reduce_max(x),
    }

  def decode(self,
             encoded_tensors,
             decode_params,
             num_summands=None,
             shape=None):
    """See base class."""
    del decode_params, num_summands, shape  # Unused.
    return tf.identity(encoded_tensors[self.ENCODED_VALUES_KEY])

if __name__ == '__main__':
  execution_contexts.set_local_execution_context()
  test.main()

{'repo_name': 'tensorflow/federated', 'stars': '1159', 'repo_language': 'Python', 'file_name': 'backend.md', 'mime_type': 'text/plain', 'hash': -3348363643369127010, 'source_dataset': 'data'}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.IIS.Administration.WebServer.RequestFiltering
{
    using Core;
    using Core.Utils;
    using Web.Administration;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    public class HeaderLimitsHelper
    {
        public static List<HeaderLimit> GetHeaderLimits(Site site, string path, string configPath = null)
        {
            // Get request filtering section
            RequestFilteringSection requestFilteringSection = RequestFilteringHelper.GetRequestFilteringSection(site, path, configPath);

            var collection = requestFilteringSection.RequestLimits.HeaderLimits;
            if (collection != null) {
                return collection.ToList();
            }
            return new List<HeaderLimit>();
        }

        public static HeaderLimit CreateHeaderLimit(dynamic model, RequestFilteringSection section)
        {
            if (model == null) {
                throw new ApiArgumentException("model");
            }

            string header = DynamicHelper.Value(model.header);
            if (string.IsNullOrEmpty(header)) {
                throw new ApiArgumentException("header");
            }

            HeaderLimit headerLimit = section.RequestLimits.HeaderLimits.CreateElement();

            headerLimit.Header = header;

            UpdateHeaderLimit(headerLimit, model);

            return headerLimit;
        }

        public static void AddHeaderLimit(HeaderLimit headerLimit, RequestFilteringSection section)
        {
            if (headerLimit == null) {
                throw new ArgumentNullException("headerLimit");
            }
            if (headerLimit.Header == null) {
                throw new ArgumentNullException("headerLimit.Header");
            }

            HeaderLimitCollection collection = section.RequestLimits.HeaderLimits;

            if (collection.Any(h => h.Header.Equals(headerLimit.Header))) {
                throw new AlreadyExistsException("headerLimit");
            }

            try {
                collection.Add(headerLimit);
            }
            catch (FileLoadException e) {
                throw new LockedException(section.SectionPath, e);
            }
            catch (DirectoryNotFoundException e) {
                throw new ConfigScopeNotFoundException(e);
            }
        }

        public static HeaderLimit UpdateHeaderLimit(HeaderLimit headerLimit, dynamic model)
        {
            if (model == null) {
                throw new ApiArgumentException("model");
            }
            if (headerLimit == null) {
                throw new ApiArgumentException("headerLimit");
            }
            string header = DynamicHelper.Value(model.header);
            if(header == string.Empty)
            {
                throw new ApiArgumentException("header");
            }

            try {
                headerLimit.Header = DynamicHelper.Value(model.header) ?? headerLimit.Header;
                headerLimit.SizeLimit = DynamicHelper.To(model.size_limit, 0, uint.MaxValue) ?? headerLimit.SizeLimit;
            }
            catch (FileLoadException e) {
                throw new LockedException(RequestFilteringGlobals.RequestFilteringSectionName, e);
            }

            return headerLimit;

        }

        public static void DeleteHeaderLimit(HeaderLimit headerLimit, RequestFilteringSection section)
        {
            if (headerLimit == null) {
                return;
            }

            HeaderLimitCollection collection = section.RequestLimits.HeaderLimits;

            // To utilize the remove functionality we must pull the element directly from the collection
            headerLimit = collection.FirstOrDefault(h => h.Header.Equals(headerLimit.Header));

            if (headerLimit != null) {
                try {
                    collection.Remove(headerLimit);
                }
                catch (FileLoadException e) {
                    throw new LockedException(section.SectionPath, e);
                }
                catch (DirectoryNotFoundException e) {
                    throw new ConfigScopeNotFoundException(e);
                }
            }
        }

        internal static object ToJsonModel(HeaderLimit headerLimit, Site site, string path)
        {
            if (headerLimit == null) {
                return null;
            }

            HeaderLimitId id = new HeaderLimitId(site?.Id, path, headerLimit.Header);

            var obj = new {
                header = headerLimit.Header,
                id = id.Uuid,
                size_limit = headerLimit.SizeLimit,
                request_filtering = RequestFilteringHelper.ToJsonModelRef(site, path)
            };

            return Core.Environment.Hal.Apply(Defines.HeaderLimitsResource.Guid, obj);
        }

        public static object ToJsonModelRef(HeaderLimit headerLimit, Site site, string path)
        {
            if (headerLimit == null) {
                return null;
            }

            HeaderLimitId id = new HeaderLimitId(site?.Id, path, headerLimit.Header);

            var obj = new {
                header = headerLimit.Header,
                id = id.Uuid,
                size_limit = headerLimit.SizeLimit
            };

            return Core.Environment.Hal.Apply(Defines.HeaderLimitsResource.Guid, obj, false);
        }

        public static string GetLocation(string id) {
            return $"/{Defines.HEADER_LIMITS_PATH}/{id}";
        }
    }
}

{'repo_name': 'microsoft/IIS.Administration', 'stars': '398', 'repo_language': 'C#', 'file_name': 'license.rtf', 'mime_type': 'text/rtf', 'hash': 4489972291047249618, 'source_dataset': 'data'}


/* ocsp.h */
/*
 * Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
 * project.
 */

/*
 * History: This file was transfered to Richard Levitte from CertCo by Kathy
 * Weinhold in mid-spring 2000 to be included in OpenSSL or released as a
 * patch kit.
 */

/* ====================================================================
 * Copyright (c) 1998-2000 The OpenSSL Project.  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. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 OpenSSL PROJECT OR
 * ITS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_OCSP_H
# define HEADER_OCSP_H

# include <openssl/ossl_typ.h>
# include <openssl/x509.h>
# include <openssl/x509v3.h>
# include <openssl/safestack.h>

#ifdef  __cplusplus
extern "C" {
#endif

/* Various flags and values */

# define OCSP_DEFAULT_NONCE_LENGTH       16

# define OCSP_NOCERTS                    0x1
# define OCSP_NOINTERN                   0x2
# define OCSP_NOSIGS                     0x4
# define OCSP_NOCHAIN                    0x8
# define OCSP_NOVERIFY                   0x10
# define OCSP_NOEXPLICIT                 0x20
# define OCSP_NOCASIGN                   0x40
# define OCSP_NODELEGATED                0x80
# define OCSP_NOCHECKS                   0x100
# define OCSP_TRUSTOTHER                 0x200
# define OCSP_RESPID_KEY                 0x400
# define OCSP_NOTIME                     0x800

/*-  CertID ::= SEQUENCE {
 *       hashAlgorithm            AlgorithmIdentifier,
 *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN
 *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
 *       serialNumber       CertificateSerialNumber }
 */
typedef struct ocsp_cert_id_st {
    X509_ALGOR *hashAlgorithm;
    ASN1_OCTET_STRING *issuerNameHash;
    ASN1_OCTET_STRING *issuerKeyHash;
    ASN1_INTEGER *serialNumber;
} OCSP_CERTID;

DECLARE_STACK_OF(OCSP_CERTID)

/*-  Request ::=     SEQUENCE {
 *       reqCert                    CertID,
 *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }
 */
typedef struct ocsp_one_request_st {
    OCSP_CERTID *reqCert;
    STACK_OF(X509_EXTENSION) *singleRequestExtensions;
} OCSP_ONEREQ;

DECLARE_STACK_OF(OCSP_ONEREQ)
DECLARE_ASN1_SET_OF(OCSP_ONEREQ)

/*-  TBSRequest      ::=     SEQUENCE {
 *       version             [0] EXPLICIT Version DEFAULT v1,
 *       requestorName       [1] EXPLICIT GeneralName OPTIONAL,
 *       requestList             SEQUENCE OF Request,
 *       requestExtensions   [2] EXPLICIT Extensions OPTIONAL }
 */
typedef struct ocsp_req_info_st {
    ASN1_INTEGER *version;
    GENERAL_NAME *requestorName;
    STACK_OF(OCSP_ONEREQ) *requestList;
    STACK_OF(X509_EXTENSION) *requestExtensions;
} OCSP_REQINFO;

/*-  Signature       ::=     SEQUENCE {
 *       signatureAlgorithm   AlgorithmIdentifier,
 *       signature            BIT STRING,
 *       certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
 */
typedef struct ocsp_signature_st {
    X509_ALGOR *signatureAlgorithm;
    ASN1_BIT_STRING *signature;
    STACK_OF(X509) *certs;
} OCSP_SIGNATURE;

/*-  OCSPRequest     ::=     SEQUENCE {
 *       tbsRequest                  TBSRequest,
 *       optionalSignature   [0]     EXPLICIT Signature OPTIONAL }
 */
typedef struct ocsp_request_st {
    OCSP_REQINFO *tbsRequest;
    OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
} OCSP_REQUEST;

/*-  OCSPResponseStatus ::= ENUMERATED {
 *       successful            (0),      --Response has valid confirmations
 *       malformedRequest      (1),      --Illegal confirmation request
 *       internalError         (2),      --Internal error in issuer
 *       tryLater              (3),      --Try again later
 *                                       --(4) is not used
 *       sigRequired           (5),      --Must sign the request
 *       unauthorized          (6)       --Request unauthorized
 *   }
 */
# define OCSP_RESPONSE_STATUS_SUCCESSFUL          0
# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1
# define OCSP_RESPONSE_STATUS_INTERNALERROR        2
# define OCSP_RESPONSE_STATUS_TRYLATER             3
# define OCSP_RESPONSE_STATUS_SIGREQUIRED          5
# define OCSP_RESPONSE_STATUS_UNAUTHORIZED         6

/*-  ResponseBytes ::=       SEQUENCE {
 *       responseType   OBJECT IDENTIFIER,
 *       response       OCTET STRING }
 */
typedef struct ocsp_resp_bytes_st {
    ASN1_OBJECT *responseType;
    ASN1_OCTET_STRING *response;
} OCSP_RESPBYTES;

/*-  OCSPResponse ::= SEQUENCE {
 *      responseStatus         OCSPResponseStatus,
 *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }
 */
struct ocsp_response_st {
    ASN1_ENUMERATED *responseStatus;
    OCSP_RESPBYTES *responseBytes;
};

/*-  ResponderID ::= CHOICE {
 *      byName   [1] Name,
 *      byKey    [2] KeyHash }
 */
# define V_OCSP_RESPID_NAME 0
# define V_OCSP_RESPID_KEY  1
struct ocsp_responder_id_st {
    int type;
    union {
        X509_NAME *byName;
        ASN1_OCTET_STRING *byKey;
    } value;
};

DECLARE_STACK_OF(OCSP_RESPID)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)

/*-  KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
 *                            --(excluding the tag and length fields)
 */

/*-  RevokedInfo ::= SEQUENCE {
 *       revocationTime              GeneralizedTime,
 *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
 */
typedef struct ocsp_revoked_info_st {
    ASN1_GENERALIZEDTIME *revocationTime;
    ASN1_ENUMERATED *revocationReason;
} OCSP_REVOKEDINFO;

/*-  CertStatus ::= CHOICE {
 *       good                [0]     IMPLICIT NULL,
 *       revoked             [1]     IMPLICIT RevokedInfo,
 *       unknown             [2]     IMPLICIT UnknownInfo }
 */
# define V_OCSP_CERTSTATUS_GOOD    0
# define V_OCSP_CERTSTATUS_REVOKED 1
# define V_OCSP_CERTSTATUS_UNKNOWN 2
typedef struct ocsp_cert_status_st {
    int type;
    union {
        ASN1_NULL *good;
        OCSP_REVOKEDINFO *revoked;
        ASN1_NULL *unknown;
    } value;
} OCSP_CERTSTATUS;

/*-  SingleResponse ::= SEQUENCE {
 *      certID                       CertID,
 *      certStatus                   CertStatus,
 *      thisUpdate                   GeneralizedTime,
 *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,
 *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }
 */
typedef struct ocsp_single_response_st {
    OCSP_CERTID *certId;
    OCSP_CERTSTATUS *certStatus;
    ASN1_GENERALIZEDTIME *thisUpdate;
    ASN1_GENERALIZEDTIME *nextUpdate;
    STACK_OF(X509_EXTENSION) *singleExtensions;
} OCSP_SINGLERESP;

DECLARE_STACK_OF(OCSP_SINGLERESP)
DECLARE_ASN1_SET_OF(OCSP_SINGLERESP)

/*-  ResponseData ::= SEQUENCE {
 *      version              [0] EXPLICIT Version DEFAULT v1,
 *      responderID              ResponderID,
 *      producedAt               GeneralizedTime,
 *      responses                SEQUENCE OF SingleResponse,
 *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
 */
typedef struct ocsp_response_data_st {
    ASN1_INTEGER *version;
    OCSP_RESPID *responderId;
    ASN1_GENERALIZEDTIME *producedAt;
    STACK_OF(OCSP_SINGLERESP) *responses;
    STACK_OF(X509_EXTENSION) *responseExtensions;
} OCSP_RESPDATA;

/*-  BasicOCSPResponse       ::= SEQUENCE {
 *      tbsResponseData      ResponseData,
 *      signatureAlgorithm   AlgorithmIdentifier,
 *      signature            BIT STRING,
 *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
 */
  /*
   * Note 1: The value for "signature" is specified in the OCSP rfc2560 as
   * follows: "The value for the signature SHALL be computed on the hash of
   * the DER encoding ResponseData." This means that you must hash the
   * DER-encoded tbsResponseData, and then run it through a crypto-signing
   * function, which will (at least w/RSA) do a hash-'n'-private-encrypt
   * operation.  This seems a bit odd, but that's the spec.  Also note that
   * the data structures do not leave anywhere to independently specify the
   * algorithm used for the initial hash. So, we look at the
   * signature-specification algorithm, and try to do something intelligent.
   * -- Kathy Weinhold, CertCo
   */
  /*
   * Note 2: It seems that the mentioned passage from RFC 2560 (section
   * 4.2.1) is open for interpretation.  I've done tests against another
   * responder, and found that it doesn't do the double hashing that the RFC
   * seems to say one should.  Therefore, all relevant functions take a flag
   * saying which variant should be used.  -- Richard Levitte, OpenSSL team
   * and CeloCom
   */
typedef struct ocsp_basic_response_st {
    OCSP_RESPDATA *tbsResponseData;
    X509_ALGOR *signatureAlgorithm;
    ASN1_BIT_STRING *signature;
    STACK_OF(X509) *certs;
} OCSP_BASICRESP;

/*-
 *   CRLReason ::= ENUMERATED {
 *        unspecified             (0),
 *        keyCompromise           (1),
 *        cACompromise            (2),
 *        affiliationChanged      (3),
 *        superseded              (4),
 *        cessationOfOperation    (5),
 *        certificateHold         (6),
 *        removeFromCRL           (8) }
 */
# define OCSP_REVOKED_STATUS_NOSTATUS               -1
# define OCSP_REVOKED_STATUS_UNSPECIFIED             0
# define OCSP_REVOKED_STATUS_KEYCOMPROMISE           1
# define OCSP_REVOKED_STATUS_CACOMPROMISE            2
# define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED      3
# define OCSP_REVOKED_STATUS_SUPERSEDED              4
# define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION    5
# define OCSP_REVOKED_STATUS_CERTIFICATEHOLD         6
# define OCSP_REVOKED_STATUS_REMOVEFROMCRL           8

/*-
 * CrlID ::= SEQUENCE {
 *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,
 *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,
 *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }
 */
typedef struct ocsp_crl_id_st {
    ASN1_IA5STRING *crlUrl;
    ASN1_INTEGER *crlNum;
    ASN1_GENERALIZEDTIME *crlTime;
} OCSP_CRLID;

/*-
 * ServiceLocator ::= SEQUENCE {
 *      issuer    Name,
 *      locator   AuthorityInfoAccessSyntax OPTIONAL }
 */
typedef struct ocsp_service_locator_st {
    X509_NAME *issuer;
    STACK_OF(ACCESS_DESCRIPTION) *locator;
} OCSP_SERVICELOC;

# define PEM_STRING_OCSP_REQUEST "OCSP REQUEST"
# define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"

# define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)

# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)

# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
     (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)

# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\
     (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)

# define PEM_write_bio_OCSP_REQUEST(bp,o) \
    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
                        bp,(char *)o, NULL,NULL,0,NULL,NULL)

# define PEM_write_bio_OCSP_RESPONSE(bp,o) \
    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
                        bp,(char *)o, NULL,NULL,0,NULL,NULL)

# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)

# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)

# define OCSP_REQUEST_sign(o,pkey,md) \
        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\
                o->optionalSignature->signatureAlgorithm,NULL,\
                o->optionalSignature->signature,o->tbsRequest,pkey,md)

# define OCSP_BASICRESP_sign(o,pkey,md,d) \
        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\
                o->signature,o->tbsResponseData,pkey,md)

# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\
        a->optionalSignature->signatureAlgorithm,\
        a->optionalSignature->signature,a->tbsRequest,r)

# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\
        a->signatureAlgorithm,a->signature,a->tbsResponseData,r)

# define ASN1_BIT_STRING_digest(data,type,md,len) \
        ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)

# define OCSP_CERTSTATUS_dup(cs)\
                (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
                (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))

OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);

OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);
OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,
                               int maxline);
int OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx);
int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
OCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline);
void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
void OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);
int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,
                     ASN1_VALUE *val);
int OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,
                          const ASN1_ITEM *it);
BIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);
int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,
                     ASN1_VALUE *val);
int OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);
int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
                             const char *name, const char *value);

OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);

OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,
                              X509_NAME *issuerName,
                              ASN1_BIT_STRING *issuerKey,
                              ASN1_INTEGER *serialNumber);

OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);

int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);

int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);

int OCSP_request_sign(OCSP_REQUEST *req,
                      X509 *signer,
                      EVP_PKEY *key,
                      const EVP_MD *dgst,
                      STACK_OF(X509) *certs, unsigned long flags);

int OCSP_response_status(OCSP_RESPONSE *resp);
OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);

int OCSP_resp_count(OCSP_BASICRESP *bs);
OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
                            ASN1_GENERALIZEDTIME **revtime,
                            ASN1_GENERALIZEDTIME **thisupd,
                            ASN1_GENERALIZEDTIME **nextupd);
int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
                          int *reason,
                          ASN1_GENERALIZEDTIME **revtime,
                          ASN1_GENERALIZEDTIME **thisupd,
                          ASN1_GENERALIZEDTIME **nextupd);
int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
                        ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);

int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
                        X509_STORE *store, unsigned long flags);

int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
                   int *pssl);

int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);

int OCSP_request_onereq_count(OCSP_REQUEST *req);
OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
                      ASN1_OCTET_STRING **pikeyHash,
                      ASN1_INTEGER **pserial, OCSP_CERTID *cid);
int OCSP_request_is_signed(OCSP_REQUEST *req);
OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,
                                        OCSP_CERTID *cid,
                                        int status, int reason,
                                        ASN1_TIME *revtime,
                                        ASN1_TIME *thisupd,
                                        ASN1_TIME *nextupd);
int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
int OCSP_basic_sign(OCSP_BASICRESP *brsp,
                    X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
                    STACK_OF(X509) *certs, unsigned long flags);

X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);

X509_EXTENSION *OCSP_accept_responses_new(char **oids);

X509_EXTENSION *OCSP_archive_cutoff_new(char *tim);

X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, char **urls);

int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj,
                                int lastpos);
int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);
X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit,
                                int *idx);
int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,
                              unsigned long flags);
int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);

int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);
int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
                             unsigned long flags);
int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);

int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj,
                                  int lastpos);
int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,
                                       int lastpos);
X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,
                                  int *idx);
int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,
                                int crit, unsigned long flags);
int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);

int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);
int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj,
                                   int lastpos);
int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,
                                        int lastpos);
X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,
                                   int *idx);
int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,
                                 int crit, unsigned long flags);
int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);

DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)

const char *OCSP_response_status_str(long s);
const char *OCSP_cert_status_str(long s);
const char *OCSP_crl_reason_str(long s);

int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags);
int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags);

int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
                      X509_STORE *st, unsigned long flags);

/* BEGIN ERROR CODES */
/*
 * The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_OCSP_strings(void);

/* Error codes for the OCSP functions. */

/* Function codes. */
# define OCSP_F_ASN1_STRING_ENCODE                        100
# define OCSP_F_D2I_OCSP_NONCE                            102
# define OCSP_F_OCSP_BASIC_ADD1_STATUS                    103
# define OCSP_F_OCSP_BASIC_SIGN                           104
# define OCSP_F_OCSP_BASIC_VERIFY                         105
# define OCSP_F_OCSP_CERT_ID_NEW                          101
# define OCSP_F_OCSP_CHECK_DELEGATED                      106
# define OCSP_F_OCSP_CHECK_IDS                            107
# define OCSP_F_OCSP_CHECK_ISSUER                         108
# define OCSP_F_OCSP_CHECK_VALIDITY                       115
# define OCSP_F_OCSP_MATCH_ISSUERID                       109
# define OCSP_F_OCSP_PARSE_URL                            114
# define OCSP_F_OCSP_REQUEST_SIGN                         110
# define OCSP_F_OCSP_REQUEST_VERIFY                       116
# define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111
# define OCSP_F_OCSP_SENDREQ_BIO                          112
# define OCSP_F_OCSP_SENDREQ_NBIO                         117
# define OCSP_F_PARSE_HTTP_LINE1                          118
# define OCSP_F_REQUEST_VERIFY                            113

/* Reason codes. */
# define OCSP_R_BAD_DATA                                  100
# define OCSP_R_CERTIFICATE_VERIFY_ERROR                  101
# define OCSP_R_DIGEST_ERR                                102
# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD                 122
# define OCSP_R_ERROR_IN_THISUPDATE_FIELD                 123
# define OCSP_R_ERROR_PARSING_URL                         121
# define OCSP_R_MISSING_OCSPSIGNING_USAGE                 103
# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE              124
# define OCSP_R_NOT_BASIC_RESPONSE                        104
# define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  105
# define OCSP_R_NO_CONTENT                                106
# define OCSP_R_NO_PUBLIC_KEY                             107
# define OCSP_R_NO_RESPONSE_DATA                          108
# define OCSP_R_NO_REVOKED_TIME                           109
# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE    110
# define OCSP_R_REQUEST_NOT_SIGNED                        128
# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      111
# define OCSP_R_ROOT_CA_NOT_TRUSTED                       112
# define OCSP_R_SERVER_READ_ERROR                         113
# define OCSP_R_SERVER_RESPONSE_ERROR                     114
# define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               115
# define OCSP_R_SERVER_WRITE_ERROR                        116
# define OCSP_R_SIGNATURE_FAILURE                         117
# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              118
# define OCSP_R_STATUS_EXPIRED                            125
# define OCSP_R_STATUS_NOT_YET_VALID                      126
# define OCSP_R_STATUS_TOO_OLD                            127
# define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    119
# define OCSP_R_UNKNOWN_NID                               120
# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE            129

#ifdef  __cplusplus
}
#endif
#endif

{'repo_name': 'cocos2d/cocos2d-x-3rd-party-libs-bin', 'stars': '146', 'repo_language': 'C', 'file_name': 'misc.c', 'mime_type': 'text/x-c', 'hash': -8460017839082586655, 'source_dataset': 'data'}


(*
 *
 * $Log: constraints.fun,v $
 * Revision 1.2  1998/06/03 12:18:16  jont
 * Automatic checkin:
 * changed attribute _comment to ' * '
 *
 *
 *)
(* Copyright (c) 1991,1994 by Carnegie Mellon University *)
(* Author: Frank Pfenning <fp@cs.cmu.edu>           *)

(* Constraint management *)
(* Printing should be fixed to use formatter !!! *)
(* Added unify_failure  -er *)
(* Added verbose constraint printing *)

functor Constraints (structure Term : TERM
		     structure ConstraintsDataTypes : CONSTRAINTS_DATATYPES
			sharing ConstraintsDataTypes.Term = Term
		     structure Print : PRINT
		        sharing Print.Term = Term
		     structure PrintVarVerbose : PRINT_VAR
			sharing PrintVarVerbose.Term = Term
		     structure Sb : SB
		        sharing Sb.Term = Term
		     structure Reduce : REDUCE
		        sharing Reduce.Term = Term) : CONSTRAINTS =
struct

open ConstraintsDataTypes

structure Term = Term
structure F = Print.F
structure S = Print.S

local open Term
in
  datatype unify_failure
   = FailArgs
   | FailOccursCheck of term
   | FailFuntype of occurs * term
   | FailClash of term * term
   | FailDependency of term * term * term list * term list

  exception Nonunifiable of unify_failure

  fun bare_term (Gvar(M,_)) = M
    | bare_term (Flex(M,_)) = M
    | bare_term (Abstraction(M)) = M
    | bare_term (Rigid(M,_)) = M
    | bare_term (Quant(M)) = M
    | bare_term (Any(M)) = M

  fun makestring_eqterm (Gvar(M,_)) = "[G]" ^ Print.makestring_term M
    | makestring_eqterm (Flex(M,_)) = "[F]" ^ Print.makestring_term M
    | makestring_eqterm (Abstraction(M)) = "[L]" ^ Print.makestring_term M
    | makestring_eqterm (Rigid(M,_)) = "[R]" ^ Print.makestring_term M
    | makestring_eqterm (Quant(M)) = "[Q]" ^ Print.makestring_term M
    | makestring_eqterm (Any(M)) = "[A]" ^ Print.makestring_term M

  val mkDpair = Dpair

  fun makestring_dpair (Dpair(eqM,eqN)) =
      "(" ^ makestring_eqterm eqM ^ ", "
      ^ makestring_eqterm eqN ^ ")"

  fun makestring_dset ds =
      " [[ "
      ^ (let fun ms nil = ""
		  | ms (dpair :: rest) =
		       makestring_dpair dpair
		       ^ (case rest of nil => "" | _ => ",\n    ") ^ ms rest
	      in ms ds end)
      ^ " ]] \n"

  (* This might still miss opportunities (head-normalization, eta conv.) *)

  fun eq_uvar_or_non_uvar stamp1 (Uvar(_,stamp2)) = (stamp1 = stamp2)
    | eq_uvar_or_non_uvar stamp1 (Evar(_,_,_,ref(SOME(M0)))) =
	 eq_uvar_or_non_uvar stamp1 M0
    | eq_uvar_or_non_uvar stamp1 _ = true

  fun dominates_all depends_on nil = true
    | dominates_all depends_on (Uvar(_,stamp)::rest) =
	 if exists (eq_uvar_or_non_uvar stamp) rest
	      orelse exists (Sb.eq_uvar stamp) depends_on
	    then false
	    else dominates_all depends_on rest
    | dominates_all depends_on _ = false  (* first arg is not a Uvar *)

  fun anno_norm (M as (Abst _)) = Abstraction(M)
    | anno_norm (Evar(_,_,_,ref(SOME(M0)))) = anno_norm M0
    | anno_norm (M as Type) = Rigid(M,(M,nil))
    | anno_norm (M as Pi _ ) = Quant(M)
    | anno_norm M =
	let fun anorm (head as Const _) args = Rigid(M,(head,args))
	      | anorm (head as Uvar _) args = Rigid(M,(head,args))
	      | anorm (Evar(_,_,_,ref(SOME(M0)))) args = anorm M0 args
	      | anorm (head as Evar(_,_,uvars,_)) args =
		   if dominates_all uvars args
		      then Gvar(M,(head,args))
		      else Flex(M,head)
	      | anorm (Appl(M1,N1)) args = anorm M1 (N1::args)
	      | anorm (Abst _) args = anno_norm (Reduce.head_norm M)
	      | anorm (head as Fvar _) args = Rigid(M,(head,args))
	      | anorm M _ = raise Print.subtype("anorm",M,"illegal argument.")
	 in anorm M nil end

  (* fun anno M = anno_norm (Reduce.head_norm M) *)
  val anno = anno_norm

  fun reclassify M = anno_norm (Reduce.head_args_norm M)

  val empty_constraint = Con(nil)
  fun is_empty_constraint (Con(nil)) = true
    | is_empty_constraint _ = false

  fun collect_sorted_vars vars nil = vars
    | collect_sorted_vars vars (Dpair(eqM,eqN) :: rest) =
      collect_sorted_vars (csv (csv vars (bare_term eqM)) (bare_term eqN)) rest
  and csv vars (Bvar _) = vars
    | csv vars (Evar(_,_,_,ref(SOME M0))) = csv vars M0
    | csv vars (M as Evar(Varbind(x,A),_,uvars,ref(NONE))) =
      if (exists (fn v => eq_var(M,v)) vars)
	  then vars
      else M :: (csv' (csv vars A) uvars)
    | csv vars (M as Fvar(Varbind(x,A))) =
      if (exists (fn v => eq_var(M,v)) vars)
	  then vars
      else M :: (csv vars A)
    | csv vars (M as Uvar(Varbind(x,A),_)) =
      if (exists (fn v => eq_var(M,v)) vars)
	  then vars
      else M :: (csv vars A)
    | csv vars (Const _) = vars
    | csv vars (Appl(M1,M2)) =
      csv (csv vars M1) M2
    | csv vars (Abst(Varbind(x,A),M1)) =
      csv (csv vars A) M1
    | csv vars (Pi((Varbind(x,A),B),_)) =
      csv (csv vars A) B
    | csv vars (Type) = vars
    | csv vars (HasType(M,A)) =
      csv (csv vars A) M
    | csv vars (M as Wild) = raise Print.subtype("csv",M,"illegal wildcard")
    | csv vars (M as Mark _) = raise Print.subtype("csv",M,"illegal marked term")
  and csv' vars nil = vars
    | csv' vars ((M as Uvar(Varbind(x,A),_))::varlist) =
      csv' (if (exists (fn v => eq_var(M,v)) vars)
		then vars
	    else M::csv vars A)
           varlist
    | csv' vars (M::varlist) = raise Print.subtype("csv'",M,"is not a Uvar")

  fun makeformat_dpair (Dpair(eqM,eqN)) =
      F.HOVbox [Print.makeformat_term (bare_term eqM), F.Break,
		F.String S.equal, F.Space,
		Print.makeformat_term (bare_term eqN)]

  fun makeformat_dset nil = nil
    | makeformat_dset (dpair :: rest) =
	 (makeformat_dpair dpair
	  :: (case rest of nil => [] | _ => [F.String S.comma, F.Break]))
	 @ makeformat_dset rest

  fun makeformat_varlist nil fmts = fmts
    | makeformat_varlist (v :: varlist) fmts =
         makeformat_varlist varlist (F.String (PrintVarVerbose.makestring_var (fn _ => false) v)
				     :: F.String S.comma :: F.Break :: fmts)

  fun makeformat_constraint (Con(dset)) =
      let val sorted_vars = collect_sorted_vars nil dset
      in
	  F.Hbox [F.String S.lparen, F.String S.lparen, F.Space,
		  F.Vbox0 0 1 (makeformat_varlist sorted_vars nil @ makeformat_dset dset),
		  F.Space, F.String S.rparen, F.String S.rparen,
		  F.Newline ()]
      end
  val makestring_constraint = F.makestring_fmt o makeformat_constraint

  local
      val S = F.String o S.string
  in
      fun makeformat_unify_failure (FailArgs) =
	  S ("Unification failure due to differing numbers of arguments")
	| makeformat_unify_failure (FailOccursCheck(ev)) =
	  F.HVbox [S "Unification failure due to occurs-check on variable", F.Break,
		   Print.makeformat_term ev, F.Newline ()]
	| makeformat_unify_failure (FailFuntype(occ,M)) =
	  F.HVbox [S "Unification failure due to clash:", F.Break,
		   S (if (occ = Maybe) then "{...}" else "->"), F.Break,
		   S "<>", F.Break,
		   Print.makeformat_term M, F.Newline ()]
	| makeformat_unify_failure (FailClash(M,N)) =
	  F.HVbox [S "Unification failure due to clash:", F.Break,
		   Print.makeformat_term M, F.Break,
		   S "<>", F.Break,
		   Print.makeformat_term N, F.Newline ()]
	| makeformat_unify_failure (FailDependency(ev,M,args,uvars)) =
	  F.HVbox [S "Unification failure due to dependency of", F.Break,
		   Print.makeformat_term ev, F.Break, S "on", F.Break,
		   Print.makeformat_term M, F.Break,
		   S "which may depend only on [",
		   F.HVbox (fold (fn (M,r) => (Print.makeformat_term M::F.Break::r)) args nil),
		   S "]", F.Break, S "and", F.Break, S "[",
		   F.HVbox (fold (fn (M,r) => (Print.makeformat_term M::F.Break::r)) uvars nil),
		   S "]", F.Newline ()]
  end

  val makestring_unify_failure = F.makestring_fmt o makeformat_unify_failure

end  (* local ... *)
end  (* functor Constraints *)

{'repo_name': 'Ravenbrook/mlworks', 'stars': '146', 'repo_language': 'Standard ML', 'file_name': 'rebinding_constructors.doc', 'mime_type': 'text/plain', 'hash': -5906881963640870605, 'source_dataset': 'data'}


$NetBSD: patch-af,v 1.1 2006/01/12 22:17:41 joerg Exp $

--- source/system.c.orig	2006-01-12 22:07:17.000000000 +0000
+++ source/system.c
@@ -36,10 +36,6 @@
 static char sccsid[] = "@(#)system.c	2.1 02/22/96";

-/* Systemvariable: letzter aufgetretener Fehlercode oder 0 */
-extern int errno;
-
-
 /* Struktur, in der der Timerzustand gerettet werden kann */
 struct timer_zustand
 {

{'repo_name': 'NetBSD/pkgsrc', 'stars': '152', 'repo_language': 'None', 'file_name': 'patch-CoinMP-configure', 'mime_type': 'text/x-diff', 'hash': -5870398694812799009, 'source_dataset': 'data'}