text:
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE cref SYSTEM "cref.dtd">

<cref>

    <copyright>
      <year>2001</year><year>2011</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.

      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.

    </legalnotice>

    <title>erl_nif</title>
    <prepared>Sverker Eriksson</prepared>
    <responsible>Sverker Eriksson</responsible>
    <docno>1</docno>
    <approved></approved>
    <checked></checked>
    <date>2009-11-17</date>
    <rev>PA1</rev>
    <file>erl_nif.xml</file>

  <lib>erl_nif</lib>
  <libsummary>API functions for an Erlang NIF library</libsummary>
  <description>
     <note>
The NIF concept is officially supported from R14B. NIF source code
     written for earlier experimental versions might need adaption to run on R14B.

No incompatible changes between R14B and R14A.

Incompatible changes between R14A and R13B04:

  <list>
    <item>Environment argument removed for <c>enif_alloc</c>,
    <c>enif_realloc</c>, <c>enif_free</c>, <c>enif_alloc_binary</c>,
    <c>enif_realloc_binary</c>, <c>enif_release_binary</c>,
    <c>enif_alloc_resource</c>, <c>enif_release_resource</c>,
    <c>enif_is_identical</c> and <c>enif_compare</c>.</item>
    <item>Character encoding argument added to <c>enif_get_atom</c>
    and <c>enif_make_existing_atom</c>.</item>
    <item>Module argument added to <c>enif_open_resource_type</c>
      while changing name spaces of resource types from global to module local.</item>
  </list>

Incompatible changes between R13B04 and R13B03:

  <list>
    <item>The function prototypes of the NIFs have  changed to expect <c>argc</c> and <c>argv</c>
	  arguments. The arity of a NIF is by that no longer limited to 3.</item>
    <item><c>enif_get_data</c> renamed as <c>enif_priv_data</c>.</item>
    <item><c>enif_make_string</c> got a third argument for character encoding.</item>
  </list>
  </note>

A NIF library contains native implementation of some functions
    of an Erlang module. The native implemented functions (NIFs) are
    called like any other functions without any difference to the
    caller. Each NIF must also have an implementation in Erlang that
    will be invoked if the function is called before the NIF library
    has been successfully loaded. A typical such stub implementation
    is to throw an exception. But it can also be used as a fallback
    implementation if the NIF library is not implemented for some
    architecture.

A minimal example of a NIF library can look like this:

/* niftest.c */
#include "erl_nif.h"

static ERL_NIF_TERM hello(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    return enif_make_string(env, "Hello world!", ERL_NIF_LATIN1);
}

static ErlNifFunc nif_funcs[] =
{
    {"hello", 0, hello}
};

ERL_NIF_INIT(niftest,nif_funcs,NULL,NULL,NULL,NULL)

and the Erlang module would have to look something like
    this:

-module(niftest).

-export([init/0, hello/0]).

init() ->
      erlang:load_nif("./niftest", 0).

hello() ->
      "NIF library not loaded".

and compile and test something like this (on Linux):

$> gcc -fPIC -shared -o niftest.so niftest.c -I $ERL_ROOT/usr/include/
$> erl

1> c(niftest).
{ok,niftest}
2> niftest:hello().
"NIF library not loaded"
3> niftest:init().
ok
4> niftest:hello().
"Hello world!"

A better solution for a real module is to take advantage of
     the new directive <seealso
     marker="doc/reference_manual:code_loading#on_load">on_load</seealso> to automatically
     load the NIF library when the module is loaded.

     <note>
A NIF does not have to be exported, it can be local to the module.
     Note however that unused local stub functions will be optimized
     away by the compiler causing loading of the NIF library to fail.

    </note>

A loaded NIF library is tied to the Erlang module code version
     that loaded it. If the module is upgraded with a new version, the
     new Erlang code will have to load its own NIF library (or maybe choose not
     to). The new code version can however choose to load the exact
     same NIF library as the old code if it wants to. Sharing the same
     dynamic library will mean that static data defined by the library
     will be shared as well. To avoid unintentionally shared static
     data, each Erlang module code can keep its own private data. This
     private data can be set when the NIF library is loaded and
     then retrieved by calling <seealso marker="#enif_priv_data">enif_priv_data</seealso>.

There is no way to explicitly unload a NIF library. A library will be
     automatically unloaded when the module code that it belongs to is purged
     by the code server. A NIF library will also be unloaded if it is replaced
     by another version of the library by a second call to
     <c>erlang:load_nif/2</c> from the same module code.

  </description>

  <title>FUNCTIONALITY</title>

All functions that a NIF library needs to do with Erlang are
      performed through the NIF API functions. There are functions
      for the following functionality:

    <taglist>
      <tag>Read and write Erlang terms</tag>
      <item>
Any Erlang terms can be passed to a NIF as function arguments and
      be returned as function return values. The terms are of C-type
      <seealso marker="#ERL_NIF_TERM">ERL_NIF_TERM</seealso>
      and can only be read or written using API functions. Most functions to read
      the content of a term are prefixed <c>enif_get_</c> and usually return
      true (or false) if the term was of the expected type (or not).
      The functions to write terms are all prefixed <c>enif_make_</c> and usually
      return the created <c>ERL_NIF_TERM</c>. There are also some functions
      to query terms, like <c>enif_is_atom</c>, <c>enif_is_identical</c> and
      <c>enif_compare</c>.

All terms of type <c>ERL_NIF_TERM</c> belong to an environment of type
      <seealso marker="#ErlNifEnv">ErlNifEnv</seealso>. The lifetime of a term is
      controlled by the lifetime of its environment object. All API functions that read
      or write terms has the environment, that the term belongs to, as the first
      function argument.
</item>
      <tag>Binaries</tag>
      <item>
Terms of type binary are accessed with the help of the struct type
      <seealso marker="#ErlNifBinary">ErlNifBinary</seealso>
      that contains a pointer (<c>data</c>) to the raw binary data and the length
      (<c>size</c>) of the data in bytes. Both <c>data</c> and <c>size</c> are
      read-only and should only be written using calls to API functions.
      Instances of <c>ErlNifBinary</c> are however always allocated by the user
      (usually as local variables).

The raw data pointed to by <c>data</c> is only mutable after a call to
      <seealso marker="#enif_alloc_binary">enif_alloc_binary</seealso> or
      <seealso marker="#enif_realloc_binary">enif_realloc_binary</seealso>.
      All other functions that operates on a binary will leave the data as read-only.
      A mutable binary must in the end either be freed with
      <seealso marker="#enif_release_binary">enif_release_binary</seealso>
      or made read-only by transferring it to an Erlang term with
      <seealso marker="#enif_make_binary">enif_make_binary</seealso>.
      But it does not have to happen in the same NIF call. Read-only binaries
      do not have to be released.

<seealso marker="#enif_make_new_binary">enif_make_new_binary</seealso>
      can be used as a shortcut to allocate and return a binary in the same NIF call.

Binaries are sequences of whole bytes. Bitstrings with an arbitrary
      bit length have no support yet.

       </item>
      <tag>Resource objects</tag>
      <item>
The use of resource objects is a way to return pointers to
      native data structures from a NIF in a safe way. A resource object is
      just a block of memory allocated with
      <seealso marker="#enif_alloc_resource">enif_alloc_resource</seealso>.
      A handle ("safe pointer") to this memory block can then be returned to Erlang by the use of
      <seealso marker="#enif_make_resource">enif_make_resource</seealso>.
      The term returned by <c>enif_make_resource</c>
      is totally opaque in nature. It can be stored and passed between processes
      on the same node, but the only real end usage is to pass it back as an argument to a NIF.
      The NIF can then call <seealso marker="#enif_get_resource">enif_get_resource</seealso>
      and get back a pointer to the memory block that is guaranteed to still be
      valid. A resource object will not be deallocated until the last handle term
      has been garbage collected by the VM and the resource has been
      released with <seealso marker="#enif_release_resource">enif_release_resource</seealso>
      (not necessarily in that order).

All resource objects are created as instances of some resource type.
      This makes resources from different modules to be distinguishable.
      A resource type is created by calling
      <seealso marker="#enif_open_resource_type">enif_open_resource_type</seealso>
      when a library is loaded. Objects of that resource type can then later be allocated
      and <c>enif_get_resource</c> verifies that the resource is of the expected type.
      A resource type can have a user supplied destructor function that is
      automatically called when resources of that type are released (by either
      the garbage collector or <c>enif_release_resource</c>). Resource types
      are uniquely identified by a supplied name string and the name of the
      implementing module.

      <marker id="enif_resource_example"/>
Here is a template example of how to create and return a resource object.

    ERL_NIF_TERM term;
    MyStruct* ptr = enif_alloc_resource(my_resource_type, sizeof(MyStruct));

    /* initialize struct ... */

    term = enif_make_resource(env, ptr);

    if (keep_a_reference_of_our_own) {
        /* store 'ptr' in static variable, private data or other resource object */
    }
    else {
        enif_release_resource(obj);
        /* resource now only owned by "Erlang" */
    }
    return term;

Note that once <c>enif_make_resource</c> creates the term to
      return to Erlang, the code can choose to either keep its own
      native pointer to the allocated struct and release it later, or
      release it immediately and rely solely on the garbage collector
      to eventually deallocate the resource object when it collects
      the term.

Another usage of resource objects is to create binary terms with
      user defined memory management.
      <seealso marker="#enif_make_resource_binary">enif_make_resource_binary</seealso>
      will create a binary term that is connected to a resource object. The
      destructor of the resource will be called when the binary is garbage
      collected, at which time the binary data can be released. An example of
      this can be a binary term consisting of data from a <c>mmap</c>'ed file.
      The destructor can then do <c>munmap</c> to release the memory
      region.

Resource types support upgrade in runtime by allowing a loaded NIF
      library to takeover an already existing resource type and thereby
      "inherit" all existing objects of that type. The destructor of the new
      library will thereafter be called for the inherited objects and the
      library with the old destructor function can be safely unloaded. Existing
      resource objects, of a module that is upgraded, must either be deleted
      or taken over by the new NIF library. The unloading of a library will be
      postponed as long as there exist resource objects with a destructor
      function in the library.

      </item>
      <tag>Threads and concurrency</tag>
      <item>
A NIF is thread-safe without any explicit synchronization as
      long as it acts as a pure function and only reads the supplied
      arguments. As soon as you write towards a shared state either through
      static variables or <seealso marker="#enif_priv_data">enif_priv_data</seealso>
      you need to supply your own explicit synchronization. This includes terms
      in process independent environments that are shared between threads.
      Resource objects will also require synchronization if you treat them as
      mutable.

The library initialization callbacks <c>load</c>, <c>reload</c> and
      <c>upgrade</c> are all thread-safe even for shared state data.

Avoid doing lengthy work in NIF calls as that may degrade the
      responsiveness of the VM. NIFs are called directly by the same scheduler
      thread that executed the calling Erlang code. The calling scheduler will thus
      be blocked from doing any other work until the NIF returns.

      </item>
    </taglist>

    <title>INITIALIZATION</title>
    <taglist>
      <tag><marker id="ERL_NIF_INIT"/>ERL_NIF_INIT(MODULE, ErlNifFunc funcs[], load, reload, upgrade, unload)</tag>
      <item>
This is the magic macro to initialize a NIF library. It
      should be evaluated in global file scope.

<c>MODULE</c> is the name of the Erlang module as an
      identifier without string quotations. It will be stringified by
      the macro.

<c>funcs</c> is a static array of function descriptors for
      all the implemented NIFs in this library.

<c>load</c>, <c>reload</c>, <c>upgrade</c> and <c>unload</c>
      are pointers to functions. One of <c>load</c>, <c>reload</c> or
      <c>upgrade</c> will be called to initialize the library.
      <c>unload</c> is called to release the library. They are all
      described individually below.

      </item>

      <tag><marker id="load"/>int (*load)(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)</tag>
       <item>
<c>load</c> is called when the NIF library is loaded
        and there is no previously loaded library for this module.

<c>*priv_data</c> can be set to point to some private data
           that the library needs in order to keep a state between NIF
           calls. <c>enif_priv_data</c> will return this pointer.
           <c>*priv_data</c> will be initialized to NULL when <c>load</c> is
           called.

<c>load_info</c> is the second argument to <seealso
           marker="erlang#load_nif-2">erlang:load_nif/2</seealso>.

The library will fail to load if <c>load</c> returns
           anything other than 0. <c>load</c> can be NULL in case no
           initialization is needed.

       </item>

      <tag><marker id="reload"/>int (*reload)(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)</tag>
       <item>
<c>reload</c> is called when the NIF library is loaded
        and there is already a previously loaded library for this
        module code.

Works the same as <c>load</c>. The only difference is that
        <c>*priv_data</c> already contains the value set by the
        previous call to <c>load</c> or <c>reload</c>.

The library will fail to load if <c>reload</c> returns
           anything other than 0 or if <c>reload</c> is NULL.

      </item>

      <tag><marker id="upgrade"/>int (*upgrade)(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM load_info)</tag>
       <item>
<c>upgrade</c> is called when the NIF library is loaded
        and there is no previously loaded library for this module
        code, BUT there is old code of this module with a loaded NIF library.

Works the same as <c>load</c>. The only difference is that
        <c>*old_priv_data</c> already contains the value set by the
         last call to <c>load</c> or <c>reload</c> for the old module
         code. <c>*priv_data</c> will be initialized to NULL when <c>upgrade</c>
         is called. It is allowed to write to both *priv_data and *old_priv_data.

The library will fail to load if <c>upgrade</c> returns
           anything other than 0 or if <c>upgrade</c> is NULL.

      </item>

      <tag><marker id="unload"/>void (*unload)(ErlNifEnv* env, void* priv_data)</tag>
       <item>
<c>unload</c> is called when the module code that
       the NIF library belongs to is purged as old. New code
       of the same module may or may not exist. Note that <c>unload</c> is not
       called for a replaced library as a consequence of <c>reload</c>.

      </item>

    </taglist>

    <title>DATA TYPES</title>

    <taglist>
      <tag><marker id="ERL_NIF_TERM"/>ERL_NIF_TERM</tag>
       <item>

Variables of type <c>ERL_NIF_TERM</c> can refer to any Erlang term.
        This is an opaque type and values of it can only by used either as
        arguments to API functions or as return values from NIFs. All
        <c>ERL_NIF_TERM</c>'s belong to an environment
        (<seealso marker="#ErlNifEnv">ErlNifEnv</seealso>). A term can not be
        destructed individually, it is valid until its environment is destructed.

      </item>
     <tag><marker id="ErlNifEnv"/>ErlNifEnv</tag>
      <item>

<c>ErlNifEnv</c> represents an environment that can host Erlang terms.
        All terms in an environment are valid as long as the environment is valid.
        <c>ErlNifEnv</c> is an opaque type and pointers to it can only be passed
        on to API functions. There are two types of environments; process
        bound and process independent.

A process bound environment is passed as the first argument to all NIFs.
        All function arguments passed to a NIF will belong to that environment.
        The return value from a NIF must also be a term belonging to the same
        environment.
        In addition a process bound environment contains transient information
        about the calling Erlang process. The environment is only valid in the
        thread where it was supplied as argument until the NIF returns. It is
        thus useless and dangerous to store pointers to process bound
        environments between NIF calls.

A process independent environment is created by calling
        <seealso marker="#enif_alloc_env">enif_alloc_env</seealso>. It can be
        used to store terms between NIF calls and to send terms with
        <seealso marker="#enif_send">enif_send</seealso>. A process
        independent environment with all its terms is valid until you explicitly
        invalidates it with <seealso marker="#enif_free_env">enif_free_env</seealso>
        or <c>enif_send</c>.

All elements of a list/tuple must belong to the same environment as the
        list/tuple itself. Terms can be copied between environments with
        <seealso marker="#enif_make_copy">enif_make_copy</seealso>.

      </item>
    <tag><marker id="ErlNifFunc"/>ErlNifFunc</tag>
     <item>

typedef struct {
    const char* name;
    unsigned arity;
    ERL_NIF_TERM (*fptr)(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
} ErlNifFunc;

Describes a NIF by its name, arity and implementation.
        <c>fptr</c> is a pointer to the function that implements the
        NIF. The argument <c>argv</c> of a NIF will contain the
        function arguments passed to the NIF and <c>argc</c> is the
        length of the array, i.e. the function arity. <c>argv[N-1]</c>
        will thus denote the Nth argument to the NIF. Note that the
        <c>argc</c> argument allows for the same C function to
        implement several Erlang functions with different arity (but
        same name probably).

      </item>
    <tag><marker id="ErlNifBinary"/>ErlNifBinary</tag>
     <item>

typedef struct {
    unsigned size;
    unsigned char* data;
} ErlNifBinary;

<c>ErlNifBinary</c> contains transient information about an
          inspected binary term. <c>data</c> is a pointer to a buffer
          of <c>size</c> bytes with the raw content of the binary.

Note that <c>ErlNifBinary</c> is a semi-opaque type and you are
          only allowed to read fields <c>size</c> and <c>data</c>.

      </item>
      <tag><marker id="ErlNifPid"/>ErlNifPid</tag>
       <item>

<c>ErlNifPid</c> is a process identifier (pid). In contrast to
          pid terms (instances of <c>ERL_NIF_TERM</c>), <c>ErlNifPid</c>'s are self
          contained and not bound to any
          <seealso marker="#ErlNifEnv">environment</seealso>. <c>ErlNifPid</c>
          is an opaque type.

        </item>

      <tag><marker id="ErlNifResourceType"/>ErlNifResourceType</tag>
       <item>

Each instance of <c>ErlNifResourceType</c> represent a class of
          memory managed resource objects that can be garbage collected.
          Each resource type has a unique name and a destructor function that
          is called when objects of its type are released.

        </item>
        <tag><marker id="ErlNifResourceDtor"/>ErlNifResourceDtor</tag>
         <item>

typedef void ErlNifResourceDtor(ErlNifEnv* env, void* obj);

The function prototype of a resource destructor function.
            A destructor function is not allowed to call any term-making functions.

          </item>
          <tag><marker id="ErlNifCharEncoding"/>ErlNifCharEncoding</tag>
           <item>

typedef enum {
    ERL_NIF_LATIN1
}ErlNifCharEncoding;

The character encoding used in strings and atoms. The only
              supported encoding is currently <c>ERL_NIF_LATIN1</c> for
              iso-latin-1 (8-bit ascii).

            </item>
            <tag><marker id="ErlNifSysInfo"/>ErlNifSysInfo</tag>
             <item>

Used by <seealso marker="#enif_system_info">enif_system_info</seealso>
                to return information about the runtime system. Contains currently
                the exact same content as <seealso marker="erl_driver#ErlDrvSysInfo">ErlDrvSysInfo</seealso>.

              </item>
              <tag><marker id="ErlNifSInt64"/>ErlNifSInt64</tag>
               <item>
A native signed 64-bit integer type.
</item>
              <tag><marker id="ErlNifUInt64"/>ErlNifUInt64</tag>
               <item>
A native unsigned 64-bit integer type.
</item>

    </taglist>

  <funcs>
    <func><name><ret>void*</ret><nametext>enif_alloc(size_t size)</nametext></name>
      <fsummary>Allocate dynamic memory.</fsummary>
      <desc>
Allocate memory of <c>size</c> bytes. Return NULL if allocation failed.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_alloc_binary(size_t size, ErlNifBinary* bin)</nametext></name>
      <fsummary>Create a new binary.</fsummary>
      <desc>
Allocate a new binary of size <c>size</c>
      bytes. Initialize the structure pointed to by <c>bin</c> to
      refer to the allocated binary. The binary must either be released by
      <seealso marker="#enif_release_binary">enif_release_binary</seealso>
      or ownership transferred to an Erlang term with
      <seealso marker="#enif_make_binary">enif_make_binary</seealso>.
      An allocated (and owned) <c>ErlNifBinary</c> can be kept between NIF
      calls.

Return true on success or false if allocation failed.

      </desc>
    </func>
    <func><name><ret>ErlNifEnv*</ret><nametext>enif_alloc_env()</nametext></name>
      <fsummary>Create a new environment</fsummary>
      <desc>
Allocate a new process independent environment. The environment can
      be used to hold terms that is not bound to any process. Such terms can
      later be copied to a process environment with
      <seealso marker="#enif_make_copy">enif_make_copy</seealso>
      or be sent to a process as a message with <seealso marker="#enif_send">enif_send</seealso>.

Return pointer to the new environment.

      </desc>
    </func>
    <func><name><ret>void*</ret><nametext>enif_alloc_resource(ErlNifResourceType* type, unsigned size)</nametext></name>
      <fsummary>Allocate a memory managed resource object</fsummary>
      <desc>
Allocate a memory managed resource object of type <c>type</c> and size <c>size</c> bytes.
</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_clear_env(ErlNifEnv* env)</nametext></name>
      <fsummary>Clear an environment for reuse.</fsummary>
      <desc>
Free all terms in an environment and clear it for reuse. The environment must
      have been allocated with <seealso marker="#enif_alloc_env">enif_alloc_env</seealso>.

</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_compare(ERL_NIF_TERM lhs, ERL_NIF_TERM rhs)</nametext></name>
      <fsummary>Compare two terms</fsummary>
      <desc>
Return an integer less than, equal to, or greater than
      zero if <c>lhs</c> is found, respectively, to be less than,
      equal, or greater than <c>rhs</c>. Corresponds to the Erlang
      operators <c>==</c>, <c>/=</c>, <c>=<</c>, <c><</c>,
      <c>>=</c> and <c>></c> (but not <c>=:=</c> or <c>=/=</c>).
</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_cond_broadcast(ErlNifCond *cnd)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_cond_broadcast">erl_drv_cond_broadcast</seealso>.

</desc>
    </func>
    <func><name><ret>ErlNifCond*</ret><nametext>enif_cond_create(char *name)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_cond_create">erl_drv_cond_create</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_cond_destroy(ErlNifCond *cnd)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_cond_destroy">erl_drv_cond_destroy</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_cond_signal(ErlNifCond *cnd)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_cond_signal">erl_drv_cond_signal</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_cond_wait(ErlNifCond *cnd, ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_cond_wait">erl_drv_cond_wait</seealso>.

</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_equal_tids(ErlNifTid tid1, ErlNifTid tid2)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_equal_tids">erl_drv_equal_tids</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_free(void* ptr)</nametext></name>
      <fsummary>Free dynamic memory</fsummary>
      <desc>
Free memory allocated by <c>enif_alloc</c>.
</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_free_env(ErlNifEnv* env)</nametext></name>
      <fsummary>Free an environment allocated with enif_alloc_env</fsummary>
      <desc>
Free an environment allocated with <seealso marker="#enif_alloc_env">enif_alloc_env</seealso>.
      All terms created in the environment will be freed as well.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_atom(ErlNifEnv* env, ERL_NIF_TERM term, char* buf, unsigned size, ErlNifCharEncoding encode)</nametext></name>
      <fsummary>Get the text representation of an atom term</fsummary>
      <desc>
Write a null-terminated string, in the buffer pointed to by
              <c>buf</c> of size <c>size</c>, consisting of the string
              representation of the atom <c>term</c> with encoding
              <seealso marker="#ErlNifCharEncoding">encode</seealso>. Return
              the number of bytes written (including terminating null character) or 0 if
              <c>term</c> is not an atom with maximum length of
              <c>size-1</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_atom_length(ErlNifEnv* env, ERL_NIF_TERM term, unsigned* len, ErlNifCharEncoding encode)</nametext></name>
      <fsummary>Get the length of atom <c>term</c>.</fsummary>
      <desc>
Set <c>*len</c> to the length (number of bytes excluding
      terminating null character) of the atom <c>term</c> with encoding
      <c>encode</c>. Return true on success or false if <c>term</c> is not an
      atom.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_double(ErlNifEnv* env, ERL_NIF_TERM term, double* dp)</nametext></name>
      <fsummary>Read a floating-point number term.</fsummary>
      <desc>
Set <c>*dp</c> to the floating point value of
      <c>term</c>. Return true on success or false if <c>term</c> is not a float.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_int(ErlNifEnv* env, ERL_NIF_TERM term, int* ip)</nametext></name>
      <fsummary>Read an integer term</fsummary>
      <desc>
Set <c>*ip</c> to the integer value of
      <c>term</c>. Return true on success or false if <c>term</c> is not an
      integer or is outside the bounds of type <c>int</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_int64(ErlNifEnv* env, ERL_NIF_TERM term, ErlNifSInt64* ip)</nametext></name>
      <fsummary>Read a 64-bit integer term</fsummary>
      <desc>
Set <c>*ip</c> to the integer value of
      <c>term</c>. Return true on success or false if <c>term</c> is not an
      integer or is outside the bounds of a signed 64-bit integer.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_local_pid(ErlNifEnv* env, ERL_NIF_TERM term, ErlNifPid* pid)</nametext></name>
    <fsummary>Read an local pid term</fsummary>
    <desc>
If <c>term</c> is the pid of a node local process, initialize the
    pid variable <c>*pid</c> from it and return true. Otherwise return false.
    No check if the process is alive is done.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_list_cell(ErlNifEnv* env, ERL_NIF_TERM list, ERL_NIF_TERM* head, ERL_NIF_TERM* tail)</nametext></name>
      <fsummary>Get head and tail from a list</fsummary>
      <desc>
Set <c>*head</c> and <c>*tail</c> from
      <c>list</c> and return true, or return false if <c>list</c> is not a
      non-empty list.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_list_length(ErlNifEnv* env, ERL_NIF_TERM term, unsigned* len)</nametext></name>
      <fsummary>Get the length of list <c>term</c>.</fsummary>
      <desc>
Set <c>*len</c> to the length of list <c>term</c> and return true,
      or return false if <c>term</c> is not a list.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_long(ErlNifEnv* env, ERL_NIF_TERM term, long int* ip)</nametext></name>
      <fsummary>Read an long integer term.</fsummary>
      <desc>
Set <c>*ip</c> to the long integer value of <c>term</c> and
      return true, or return false if <c>term</c> is not an integer or is
      outside the bounds of type <c>long int</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_resource(ErlNifEnv* env, ERL_NIF_TERM term, ErlNifResourceType* type, void** objp)</nametext></name>
      <fsummary>Get the pointer to a resource object</fsummary>
      <desc>
Set <c>*objp</c> to point to the resource object referred to by <c>term</c>.

Return true on success or false if <c>term</c> is not a handle to a resource object
      of type <c>type</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_string(ErlNifEnv* env,
                                ERL_NIF_TERM list, char* buf, unsigned size,
                                ErlNifCharEncoding encode)</nametext></name>
      <fsummary>Get a C-string from a list.</fsummary>
      <desc>
Write a null-terminated string, in the buffer pointed to by
              <c>buf</c> with size <c>size</c>, consisting of the characters
              in the string <c>list</c>. The characters are written using encoding
              <seealso marker="#ErlNifCharEncoding">encode</seealso>.
              Return the number of bytes written (including terminating null
              character), or <c>-size</c> if the string was truncated due to
              buffer space, or 0 if <c>list</c> is not a string that can be
              encoded with <c>encode</c> or if <c>size</c> was less than 1.
              The written string is always null-terminated unless buffer
              <c>size</c> is less than 1.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_tuple(ErlNifEnv* env, ERL_NIF_TERM term, int* arity, const ERL_NIF_TERM** array)</nametext></name>
      <fsummary>Inspect the elements of a tuple.</fsummary>
      <desc>
If <c>term</c> is a tuple, set <c>*array</c> to point
      to an array containing the elements of the tuple and set
      <c>*arity</c> to the number of elements. Note that the array
      is read-only and <c>(*array)[N-1]</c> will be the Nth element of
      the tuple. <c>*array</c> is undefined if the arity of the tuple
      is zero.

Return true on success or false if <c>term</c> is not a
      tuple.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_uint(ErlNifEnv* env, ERL_NIF_TERM term, unsigned int* ip)</nametext></name>
      <fsummary>Read an unsigned integer term.</fsummary>
      <desc>
Set <c>*ip</c> to the unsigned integer value of <c>term</c> and
      return true, or return false if <c>term</c> is not an unsigned integer or
      is outside the bounds of type <c>unsigned int</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_uint64(ErlNifEnv* env, ERL_NIF_TERM term, ErlNifUInt64* ip)</nametext></name>
      <fsummary>Read an unsigned 64-bit integer term.</fsummary>
      <desc>
Set <c>*ip</c> to the unsigned integer value of <c>term</c> and
      return true, or return false if <c>term</c> is not an unsigned integer or
      is outside the bounds of an unsigned 64-bit integer.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_ulong(ErlNifEnv* env, ERL_NIF_TERM term, unsigned long* ip)</nametext></name>
      <fsummary>Read an unsigned integer term.</fsummary>
      <desc>
Set <c>*ip</c> to the unsigned long integer value of <c>term</c>
      and return true, or return false if <c>term</c> is not an unsigned integer or is
      outside the bounds of type <c>unsigned long</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_inspect_binary(ErlNifEnv* env, ERL_NIF_TERM bin_term, ErlNifBinary* bin)</nametext></name>
      <fsummary>Inspect the content of a binary</fsummary>
      <desc>
Initialize the structure pointed to by <c>bin</c> with
              information about the binary term
      <c>bin_term</c>. Return true on success or false if <c>bin_term</c> is not a binary.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_inspect_iolist_as_binary(ErlNifEnv*
                                env, ERL_NIF_TERM term, ErlNifBinary* bin)
                              </nametext></name>
      <fsummary>Inspect the content of an iolist</fsummary>
      <desc>
Initialize the structure pointed to by <c>bin</c> with one
      continuous buffer with the same byte content as <c>iolist</c>. As with
      inspect_binary, the data pointed to by <c>bin</c> is transient and does
      not need to be released. Return true on success or false if <c>iolist</c> is not an
      iolist.

      </desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_atom(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is an atom</fsummary>
      <desc>
Return true if <c>term</c> is an atom.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_binary(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a binary</fsummary>
      <desc>
Return true if <c>term</c> is a binary
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_empty_list(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is an empty list</fsummary>
      <desc>
Return true if <c>term</c> is an empty list.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_fun(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a fun</fsummary>
      <desc>
Return true if <c>term</c> is a fun.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_identical(ERL_NIF_TERM lhs, ERL_NIF_TERM rhs)</nametext></name>
      <fsummary>Erlang operator =:=</fsummary>
      <desc>
Return true if the two terms are identical. Corresponds to the
      Erlang operators <c>=:=</c> and
      <c>=/=</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_pid(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a pid</fsummary>
      <desc>
Return true if <c>term</c> is a pid.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_port(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a port</fsummary>
      <desc>
Return true if <c>term</c> is a port.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_ref(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a reference</fsummary>
      <desc>
Return true if <c>term</c> is a reference.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_tuple(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a tuple</fsummary>
      <desc>
Return true if <c>term</c> is a tuple.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_list(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a list</fsummary>
      <desc>
Return true if <c>term</c> is a list.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_keep_resource(void* obj)</nametext></name>
      <fsummary>Add a reference to a resource object</fsummary>
      <desc>
Add a reference to resource object <c>obj</c> obtained from
      <seealso marker="#enif_alloc_resource">enif_alloc_resource</seealso>.
      Each call to <c>enif_keep_resource</c> for an object must be balanced by
      a call to <seealso marker="#enif_release_resource">enif_release_resource</seealso>
      before the object will be destructed.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_atom(ErlNifEnv* env, const char* name)</nametext></name>
      <fsummary>Create an atom term</fsummary>
      <desc>
Create an atom term from the null-terminated C-string <c>name</c>
      with iso-latin-1 encoding.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_atom_len(ErlNifEnv* env, const char* name, size_t len)</nametext></name>
      <fsummary>Create an atom term</fsummary>
      <desc>
Create an atom term from the string <c>name</c> with length <c>len</c>.
      Null-characters are treated as any other characters.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_badarg(ErlNifEnv* env)</nametext></name>
      <fsummary>Make a badarg exception.</fsummary>
      <desc>
Make a badarg exception to be returned from a NIF.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_binary(ErlNifEnv* env, ErlNifBinary* bin)</nametext></name>
      <fsummary>Make a binary term.</fsummary>
      <desc>
Make a binary term from <c>bin</c>. Any ownership of
              the binary data will be transferred to the created term and
              <c>bin</c> should be considered read-only for the rest of the NIF
              call and then as released.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_copy(ErlNifEnv* dst_env, ERL_NIF_TERM src_term)</nametext></name>
      <fsummary>Make a copy of a term.</fsummary>
      <desc>
Make a copy of term <c>src_term</c>. The copy will be created in
      environment <c>dst_env</c>. The source term may be located in any
      environment.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_double(ErlNifEnv* env, double d)</nametext></name>
      <fsummary>Create a floating-point term</fsummary>
      <desc>
Create a floating-point term from a <c>double</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_make_existing_atom(ErlNifEnv* env, const char* name, ERL_NIF_TERM* atom, ErlNifCharEncoding encode)</nametext></name>
      <fsummary>Create an existing atom term</fsummary>
      <desc>
Try to create the term of an already existing atom from
      the null-terminated C-string <c>name</c> with encoding
      <seealso marker="#ErlNifCharEncoding">encode</seealso>. If the atom
      already exists store the term in <c>*atom</c> and return true, otherwise
      return false.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_make_existing_atom_len(ErlNifEnv* env, const char* name, size_t len, ERL_NIF_TERM* atom, ErlNifCharEncoding encoding)</nametext></name>
      <fsummary>Create an existing atom term</fsummary>
      <desc>
Try to create the term of an already existing atom from the
      string <c>name</c> with length <c>len</c> and encoding
      <seealso marker="#ErlNifCharEncoding">encode</seealso>. Null-characters
      are treated as any other characters. If the atom already exists store the term
      in <c>*atom</c> and return true, otherwise return false.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_int(ErlNifEnv* env, int i)</nametext></name>
      <fsummary>Create an integer term</fsummary>
      <desc>
Create an integer term.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_int64(ErlNifEnv* env, ErlNifSInt64 i)</nametext></name>
      <fsummary>Create an integer term</fsummary>
      <desc>
Create an integer term from a signed 64-bit integer.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list(ErlNifEnv* env, unsigned cnt, ...)</nametext></name>
      <fsummary>Create a list term.</fsummary>
      <desc>
Create an ordinary list term of length <c>cnt</c>. Expects
      <c>cnt</c> number of arguments (after <c>cnt</c>) of type ERL_NIF_TERM as the
      elements of the list. An empty list is returned if <c>cnt</c> is 0.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list1(ErlNifEnv* env, ERL_NIF_TERM e1)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list2(ErlNifEnv* env, ERL_NIF_TERM e1, ERL_NIF_TERM e2)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list3(ErlNifEnv* env, ERL_NIF_TERM e1, ERL_NIF_TERM e2, ERL_NIF_TERM e3)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list4(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e4)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list5(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e5)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list6(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e6)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list7(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e7)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list8(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e8)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list9(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e9)</nametext></name>
      <fsummary>Create a list term.</fsummary>
      <desc>
Create an ordinary list term with length indicated by the
      function name. Prefer these functions (macros) over the variadic
      <c>enif_make_list</c>  to get a compile time error if the number of
      arguments does not match.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list_cell(ErlNifEnv* env, ERL_NIF_TERM head, ERL_NIF_TERM tail)</nametext></name>
      <fsummary>Create a list cell.</fsummary>
      <desc>
Create a list cell <c>[head | tail]</c>.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list_from_array(ErlNifEnv* env, const ERL_NIF_TERM arr[], unsigned cnt)</nametext></name>
      <fsummary>Create a list term from an array.</fsummary>
      <desc>
Create an ordinary list containing the elements of array <c>arr</c>
      of length <c>cnt</c>. An empty list is returned if <c>cnt</c> is 0.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_long(ErlNifEnv* env, long int i)</nametext></name>
      <fsummary>Create an integer term from a long int</fsummary>
      <desc>
Create an integer term from a <c>long int</c>.
</desc>
    </func>
    <func><name><ret>unsigned char*</ret><nametext>enif_make_new_binary(ErlNifEnv* env, size_t size, ERL_NIF_TERM* termp)</nametext></name>
      <fsummary>Allocate and create a new binary term</fsummary>
      <desc>
Allocate a binary of size <c>size</c> bytes and create an owning
      term. The binary data is mutable until the calling NIF returns. This is a
      quick way to create a new binary without having to use
      <seealso marker="#ErlNifBinary">ErlNifBinary</seealso>. The drawbacks are
      that the binary can not be kept between NIF calls and it can not be
      reallocated.

Return a pointer to the raw binary data and set
      <c>*termp</c> to the binary term.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_pid(ErlNifEnv* env, const ErlNifPid* pid)</nametext></name>
      <fsummary>Make a pid term</fsummary>
      <desc>
Make a pid term from <c>*pid</c>.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_ref(ErlNifEnv* env)</nametext></name>
      <fsummary>Create a reference.</fsummary>
      <desc>
Create a reference like <seealso marker="erlang#make_ref-0">erlang:make_ref/0</seealso>.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_resource(ErlNifEnv* env, void* obj)</nametext></name>
      <fsummary>Create an opaque handle to a resource object</fsummary>
      <desc>
Create an opaque handle to a memory managed resource object
      obtained by <seealso marker="#enif_alloc_resource">enif_alloc_resource</seealso>.
      No ownership transfer is done, as the resource object still needs to be released by
      <seealso marker="#enif_release_resource">enif_release_resource</seealso>,
      but note that the call to <c>enif_release_resource</c> can occur
      immediately after obtaining the term from <c>enif_make_resource</c>,
      in which case the resource object will be deallocated when the
      term is garbage collected. See the
      <seealso marker="#enif_resource_example">example of creating and
      returning a resource object</seealso> for more details.

Note that the only defined behaviour of using a resource term in
      an Erlang program is to store it and send it between processes on the
      same node. Other operations such as matching or <c>term_to_binary</c>
      will have unpredictable (but harmless) results.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_resource_binary(ErlNifEnv* env, void* obj, const void* data, size_t size)</nametext></name>
      <fsummary>Create a custom binary term</fsummary>
      <desc>
Create a binary term that is memory managed by a resource object
      <c>obj</c> obtained by <seealso marker="#enif_alloc_resource">enif_alloc_resource</seealso>.
      The returned binary term will consist of <c>size</c> bytes pointed to
      by <c>data</c>. This raw binary data must be kept readable and unchanged
      until the destructor of the resource is called. The binary data may be
      stored external to the resource object in which case it is the responsibility
      of the destructor to release the data.

Several binary terms may be managed by the same resource object. The
      destructor will not be called until the last binary is garbage collected.
      This can be useful as a way to return different parts of a larger binary
      buffer.

As with <seealso marker="#enif_make_resource">enif_make_resource</seealso>,
      no ownership transfer is done. The resource still needs to be released with
      <seealso marker="#enif_release_resource">enif_release_resource</seealso>.

      </desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_string(ErlNifEnv* env, const char* string, ErlNifCharEncoding encoding)</nametext></name>
      <fsummary>Create a string.</fsummary>
      <desc>
Create a list containing the characters of the
      null-terminated string <c>string</c> with encoding <seealso marker="#ErlNifCharEncoding">encoding</seealso>.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_string_len(ErlNifEnv* env, const char* string, size_t len, ErlNifCharEncoding encoding)</nametext></name>
      <fsummary>Create a string.</fsummary>
      <desc>
Create a list containing the characters of the string <c>string</c> with
      length <c>len</c> and encoding <seealso marker="#ErlNifCharEncoding">encoding</seealso>.
      Null-characters are treated as any other characters.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_sub_binary(ErlNifEnv*
      env, ERL_NIF_TERM bin_term, size_t pos, size_t size)</nametext></name>
      <fsummary>Make a subbinary term.</fsummary>
      <desc>
Make a subbinary of binary <c>bin_term</c>, starting at
              zero-based position <c>pos</c> with a length of <c>size</c> bytes.
              <c>bin_term</c> must be a binary or bitstring and
              <c>pos+size</c> must be less or equal to the number of whole
              bytes in <c>bin_term</c>.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple(ErlNifEnv* env, unsigned cnt, ...)</nametext></name>
      <fsummary>Create a tuple term.</fsummary>
      <desc>
Create a tuple term of arity <c>cnt</c>. Expects
      <c>cnt</c> number of arguments (after <c>cnt</c>) of type ERL_NIF_TERM as the
      elements of the tuple.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple1(ErlNifEnv* env, ERL_NIF_TERM e1)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple2(ErlNifEnv* env, ERL_NIF_TERM e1, ERL_NIF_TERM e2)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple3(ErlNifEnv* env, ERL_NIF_TERM e1, ERL_NIF_TERM e2, ERL_NIF_TERM e3)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple4(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e4)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple5(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e5)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple6(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e6)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple7(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e7)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple8(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e8)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple9(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e9)</nametext></name>
      <fsummary>Create a tuple term.</fsummary>
      <desc>
Create a tuple term with length indicated by the
      function name. Prefer these functions (macros) over the variadic
      <c>enif_make_tuple</c>  to get a compile time error if the number of
      arguments does not match.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple_from_array(ErlNifEnv* env, const ERL_NIF_TERM arr[], unsigned cnt)</nametext></name>
      <fsummary>Create a tuple term from an array.</fsummary>
      <desc>
Create a tuple containing the elements of array <c>arr</c>
      of length <c>cnt</c>.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_uint(ErlNifEnv* env, unsigned int i)</nametext></name>
      <fsummary>Create an unsigned integer term</fsummary>
      <desc>
Create an integer term from an <c>unsigned int</c>.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_uint64(ErlNifEnv* env, ErlNifUInt64 i)</nametext></name>
      <fsummary>Create an unsigned integer term</fsummary>
      <desc>
Create an integer term from an unsigned 64-bit integer.
</desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_ulong(ErlNifEnv* env, unsigned long i)</nametext></name>
      <fsummary>Create an integer term from an unsigned long int</fsummary>
      <desc>
Create an integer term from an <c>unsigned long int</c>.
</desc>
    </func>
    <func><name><ret>ErlNifMutex*</ret><nametext>enif_mutex_create(char *name)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_mutex_create">erl_drv_mutex_create</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_mutex_destroy(ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_mutex_destroy">erl_drv_mutex_destroy</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_mutex_lock(ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_mutex_lock">erl_drv_mutex_lock</seealso>.

</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_mutex_trylock(ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_mutex_trylock">erl_drv_mutex_trylock</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_mutex_unlock(ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_mutex_unlock">erl_drv_mutex_unlock</seealso>.

</desc>
    </func>
    <func><name><ret>ErlNifResourceType*</ret><nametext>enif_open_resource_type(ErlNifEnv* env,
                             const char* module_str, const char* name,
                             ErlNifResourceDtor* dtor, ErlNifResourceFlags flags, ErlNifResourceFlags* tried)</nametext></name>
      <fsummary>Create or takeover a resource type</fsummary>
      <desc>
Create or takeover a resource type identified by the string
      <c>name</c> and give it the destructor function pointed to by <seealso marker="#ErlNifResourceDtor">dtor</seealso>.
      Argument <c>flags</c> can have the following values:

      <taglist>
        <tag><c>ERL_NIF_RT_CREATE</c></tag>
              <item>Create a new resource type that does not already exist.</item>
        <tag><c>ERL_NIF_RT_TAKEOVER</c></tag>
              <item>Open an existing resource type and take over ownership of all its instances.
               The supplied destructor <c>dtor</c> will be called both for existing instances
               as well as new instances not yet created by the calling NIF library.</item>
      </taglist>

The two flag values can be combined with bitwise-or. The name of the
      resource type is local to the calling module. Argument <c>module_str</c>
      is not (yet) used and must be NULL. The <c>dtor</c> may  be <c>NULL</c>
      in case no destructor is needed.

On success, return a pointer to the resource type and <c>*tried</c>
      will be set to either <c>ERL_NIF_RT_CREATE</c> or
      <c>ERL_NIF_RT_TAKEOVER</c> to indicate what was actually done.
       On failure, return <c>NULL</c> and set <c>*tried</c> to <c>flags</c>.
       It is allowed to set <c>tried</c> to <c>NULL</c>.

Note that <c>enif_open_resource_type</c> is only allowed to be called in the three callbacks
       <seealso marker="#load">load</seealso>, <seealso marker="#reload">reload</seealso>
       and <seealso marker="#upgrade">upgrade</seealso>.

      </desc>
    </func>
    <func><name><ret>void*</ret><nametext>enif_priv_data(ErlNifEnv* env)</nametext></name>
      <fsummary>Get the private data of a NIF library</fsummary>
      <desc>
Return the pointer to the private data that was set by <c>load</c>,
      <c>reload</c> or <c>upgrade</c>.

Was previously named <c>enif_get_data</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_realloc_binary(ErlNifBinary* bin, size_t size)</nametext></name>
      <fsummary>Change the size of a binary.</fsummary>
      <desc>
Change the size of a binary <c>bin</c>. The source binary
      may be read-only, in which case it will be left untouched and
      a mutable copy is allocated and assigned to <c>*bin</c>. Return true on success,
      false if memory allocation failed.
</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_release_binary(ErlNifBinary* bin)</nametext></name>
      <fsummary>Release a binary.</fsummary>
      <desc>
Release a binary obtained from <c>enif_alloc_binary</c>.
</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_release_resource(void* obj)</nametext></name>
      <fsummary>Release a resource object.</fsummary>
      <desc>
Remove a reference to resource object <c>obj</c>obtained from
      <seealso marker="#enif_alloc_resource">enif_alloc_resource</seealso>.
      The resource object will be destructed when the last reference is removed.
      Each call to <c>enif_release_resource</c> must correspond to a previous
      call to <c>enif_alloc_resource</c> or
      <seealso marker="#enif_keep_resource">enif_keep_resource</seealso>.
      References made by <seealso marker="#enif_make_resource">enif_make_resource</seealso>
      can only be removed by the garbage collector.
</desc>
    </func>
    <func><name><ret>ErlNifRWLock*</ret><nametext>enif_rwlock_create(char *name)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_rwlock_create">erl_drv_rwlock_create</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_destroy(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_rwlock_destroy">erl_drv_rwlock_destroy</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_rlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_rwlock_rlock">erl_drv_rwlock_rlock</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_runlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_rwlock_runlock">erl_drv_rwlock_runlock</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_rwlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_rwlock_rwlock">erl_drv_rwlock_rwlock</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_rwunlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_rwlock_rwunlock">erl_drv_rwlock_rwunlock</seealso>.

</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_rwlock_tryrlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_rwlock_tryrlock">erl_drv_rwlock_tryrlock</seealso>.

</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_rwlock_tryrwlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_rwlock_tryrwlock">erl_drv_rwlock_tryrwlock</seealso>.

</desc>
    </func>
    <func><name><ret>ErlNifPid*</ret><nametext>enif_self(ErlNifEnv* caller_env, ErlNifPid* pid)</nametext></name>
      <fsummary>Get the pid of the calling process.</fsummary>
      <desc>
Initialize the pid variable <c>*pid</c> to represent the
      calling process. Return <c>pid</c>.
</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_send(ErlNifEnv* env, ErlNifPid* to_pid, ErlNifEnv* msg_env, ERL_NIF_TERM msg)</nametext></name>
      <fsummary>Send a message to a process.</fsummary>
      <desc>
Send a message to a process.

      <taglist>
        <tag><c>env</c></tag>
              <item>The environment of the calling process. Must be NULL if and
              only if calling from a created thread.</item>
        <tag><c>*to_pid</c></tag>
              <item>The pid of the receiving process. The pid should refer to a process on the local node.</item>
        <tag><c>msg_env</c></tag>
              <item>The environment of the message term. Must be a process
              independent environment allocated with
               <seealso marker="#enif_alloc_env">enif_alloc_env</seealso>.</item>
        <tag><c>msg</c></tag>
              <item>The message term to send.</item>
      </taglist>

Return true on success, or false if <c>*to_pid</c> does not refer to an alive local process.

The message environment <c>msg_env</c> with all its terms (including
      <c>msg</c>) will be invalidated by a successful call to <c>enif_send</c>. The environment
      should either be freed with <seealso marker="#enif_free_env">enif_free_env</seealso>
      of cleared for reuse with <seealso marker="#enif_clear_env">enif_clear_env</seealso>.

This function is only thread-safe when the emulator with SMP support is used.
      It can only be used in a non-SMP emulator from a NIF-calling thread.

      </desc>
    </func>
    <func><name><ret>unsigned</ret><nametext>enif_sizeof_resource(void* obj)</nametext></name>
      <fsummary>Get the byte size of a resource object</fsummary>
      <desc>
Get the byte size of a resource object <c>obj</c> obtained by
      <seealso marker="#enif_alloc_resource">enif_alloc_resource</seealso>.
</desc>
    </func>
    <func>
      <name><ret>void</ret><nametext>enif_system_info(ErlNifSysInfo *sys_info_ptr, size_t size)</nametext></name>
      <fsummary>Get information about the Erlang runtime system</fsummary>
      <desc>
Same as <seealso marker="erl_driver#driver_system_info">driver_system_info</seealso>.

</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_thread_create(char *name,ErlNifTid *tid,void * (*func)(void *),void *args,ErlNifThreadOpts *opts)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_thread_create">erl_drv_thread_create</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_thread_exit(void *resp)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_thread_exit">erl_drv_thread_exit</seealso>.

</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_thread_join(ErlNifTid, void **respp)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_thread_join">erl_drv_thread_join </seealso>.

</desc>
    </func>
    <func><name><ret>ErlNifThreadOpts*</ret><nametext>enif_thread_opts_create(char *name)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_thread_opts_create">erl_drv_thread_opts_create</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_thread_opts_destroy(ErlNifThreadOpts *opts)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_thread_opts_destroy">erl_drv_thread_opts_destroy</seealso>.

</desc>
    </func>
    <func><name><ret>ErlNifTid</ret><nametext>enif_thread_self(void)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_thread_self">erl_drv_thread_self</seealso>.

</desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_tsd_key_create(char *name, ErlNifTSDKey *key)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_tsd_key_create">erl_drv_tsd_key_create</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_tsd_key_destroy(ErlNifTSDKey key)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_tsd_key_destroy">erl_drv_tsd_key_destroy</seealso>.

</desc>
    </func>
    <func><name><ret>void*</ret><nametext>enif_tsd_get(ErlNifTSDKey key)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_tsd_get">erl_drv_tsd_get</seealso>.

</desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_tsd_set(ErlNifTSDKey key, void *data)</nametext></name>
    <fsummary></fsummary>
    <desc>
Same as <seealso marker="erl_driver#erl_drv_tsd_set">erl_drv_tsd_set</seealso>.

</desc>
    </func>
  </funcs>

    <title>SEE ALSO</title>

<seealso marker="erlang#load_nif-2">erlang:load_nif/2</seealso>

</cref>


text:
package com.wfu.modules.weixin.front;

import com.wfu.common.config.Global;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by tepusoft on 2017/3/25.
 */
public class WXPathUtils {
    public static String getWXPath(String code,String state){
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+ Global.getConfig("subDomain")
               /* +":"+request.getServerPort()*/
                +path+Global.getFrontPath()+"/wx/index"+"?code="+code+"&state="+state;
        return basePath;
    }

    public static String getWXEnterprisePath(String code,String state){
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+ Global.getConfig("subDomain")
               /* +":"+request.getServerPort()*/
                +path+Global.getFrontPath()+"/wx/indexEnterprise"+"?code="+code+"&state="+state;
        return basePath;
    }

    public static String getWXSuccessPath(){
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+ Global.getConfig("subDomain")
               /* +":"+request.getServerPort()*/
                +path+Global.getFrontPath()+"/wx/success/index";
        return basePath;
    }

}

redpajama_set_name: RedPajamaGithub


text:
using UnityEngine;
using System.Collections;

public class MirrorHuman : MonoBehaviour {

  public Transform t_Head;
  public Transform t_HandL;
  public Transform t_HandR;

  public GameObject Head;
  public GameObject HandL;
  public GameObject HandR;

	void Start () {

	}

	// Update is called once per frame
	void Update () {

    Head.transform.position = transform.TransformPoint( t_Head.position );
    Head.transform.eulerAngles = transform.TransformDirection( t_Head.eulerAngles );

    HandL.transform.position = transform.TransformPoint( t_HandL.position );
    HandL.transform.eulerAngles = transform.TransformDirection( t_HandL.eulerAngles );
   // HandL.transform.localScale = new Vector3( v1.y * .06f ,  v1.y * .06f , v1.y * .06f );

    HandR.transform.position = transform.TransformPoint( t_HandR.position );
    HandR.transform.eulerAngles = transform.TransformDirection( t_HandR.eulerAngles );

	}
}


text:
module Riddle
  class Configuration
    class Searchd < Riddle::Configuration::Section
      self.settings = [:listen, :address, :port, :log, :query_log,
        :query_log_format, :read_timeout, :client_timeout, :max_children,
        :pid_file, :max_matches, :seamless_rotate, :preopen_indexes,
        :unlink_old, :attr_flush_period, :ondisk_dict_default, :max_packet_size,
        :mva_updates_pool, :crash_log_path, :max_filters, :max_filter_values,
        :listen_backlog, :read_buffer, :read_unhinted, :max_batch_queries,
        :subtree_docs_cache, :subtree_hits_cache, :workers, :dist_threads,
        :binlog_path, :binlog_flush, :binlog_max_log_size, :collation_server,
        :collation_libc_locale, :plugin_dir, :mysql_version_string,
        :rt_flush_period, :thread_stack, :expansion_limit,
        :compat_sphinxql_magics, :watchdog, :client_key]

      attr_accessor *self.settings

      def render
        raise ConfigurationError unless valid?

        (
          ["searchd", "{"] +
          settings_body +
          ["}", ""]
        ).join("\n")
      end

      def valid?
        !( @port.nil? || @pid_file.nil? )
      end
    end
  end
end


text:
<?php

namespace English\SlideshowBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use English\SlideshowBundle\Entity\Slideshow;
use English\SlideshowBundle\Form\SlideshowType;

/**
 * Slideshow controller.
 *
 * @Route("/slideshow")
 */
class SlideshowController extends Controller
{
    /**
     * Lists all Slideshow entities.
     *
     * @Route("/", name="slideshow")
     * @Template()
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();

        $slideshow = $em->getRepository('EnglishSlideshowBundle:Slideshow')->findAllOrdered();

        return array('slideshow' => $slideshow);
    }

    /**
     * Finds and displays a Slideshow entity.
     *
     * @Route("/{id}/show", name="slideshow_show")
     * @Template()
     */
    public function showAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $slide = $em->getRepository('EnglishSlideshowBundle:Slideshow')->find($id);

        if (!$slide) {
            throw $this->createNotFoundException('Unable to find Slideshow entity.');
        }

        $deleteForm = $this->createDeleteForm($id);

        return array(
            'slide'      => $slide,
            'delete_form' => $deleteForm->createView(),        );
    }

    /**
     * Displays a form to create a new Slideshow entity.
     *
     * @Route("/new", name="slideshow_new")
     * @Template()
     */
    public function newAction()
    {
        $slide = new Slideshow();
        $form   = $this->createForm(new SlideshowType(), $slide);

        return array(
            'slide' => $slide,
            'form'   => $form->createView()
        );
    }

    /**
     * Creates a new Slideshow entity.
     *
     * @Route("/create", name="slideshow_create")
     * @Method("post")
     * @Template("EnglishSlideshowBundle:Slideshow:new.html.twig")
     */
    public function createAction()
    {
        $username = $this->get('security.context')->getToken()->getUsername();
        $userid = $this->getDoctrine()->getManager()->getRepository('EnglishPeopleBundle:People')->findOneByUsername($username)->getId();

        $slide  = new Slideshow();

        $slide->setUserid($userid);

        $request = $this->getRequest();
        $form    = $this->createForm(new SlideshowType(), $slide);
        $form->submit($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($slide);
            $em->flush();

            return $this->redirect($this->generateUrl('slideshow'));

        }

        return array(
            'slide' => $slide,
            'form'   => $form->createView()
        );
    }

    /**
     * Displays a form to edit an existing Slideshow entity.
     *
     * @Route("/{id}/edit", name="slideshow_edit")
     * @Template()
     */
    public function editAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $slide = $em->getRepository('EnglishSlideshowBundle:Slideshow')->find($id);

        if (!$slide) {
            throw $this->createNotFoundException('Unable to find Slideshow entity.');
        }

        $editForm = $this->createForm(new SlideshowType(), $slide);
        $deleteForm = $this->createDeleteForm($id);

        return array(
            'slide'      => $slide,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }

    /**
     * Edits an existing Slideshow entity.
     *
     * @Route("/{id}/update", name="slideshow_update")
     * @Method("post")
     * @Template("EnglishSlideshowBundle:Slideshow:edit.html.twig")
     */
    public function updateAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $slide = $em->getRepository('EnglishSlideshowBundle:Slideshow')->find($id);

        if (!$slide) {
            throw $this->createNotFoundException('Unable to find Slideshow entity.');
        }

        $editForm   = $this->createForm(new SlideshowType(), $slide);
        $deleteForm = $this->createDeleteForm($id);

        $request = $this->getRequest();

        $editForm->submit($request);

        if ($editForm->isValid()) {
            $em->persist($slide);
            $em->flush();

            return $this->redirect($this->generateUrl('slideshow'));
        }

        return array(
            'slide'      => $slide,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }

    /**
     * Deletes a Slideshow entity.
     *
     * @Route("/{id}/delete", name="slideshow_delete")
     * @Method("post")
     */
    public function deleteAction($id)
    {
        $form = $this->createDeleteForm($id);
        $request = $this->getRequest();

        $form->submit($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $slide = $em->getRepository('EnglishSlideshowBundle:Slideshow')->find($id);

            if (!$slide) {
                throw $this->createNotFoundException('Unable to find Slideshow entity.');
            }

            $em->remove($slide);
            $em->flush();
        }

        return $this->redirect($this->generateUrl('slideshow'));
    }

    private function createDeleteForm($id)
    {
        return $this->createFormBuilder(array('id' => $id))
            ->add('id', 'hidden')
            ->getForm()
        ;
    }
}


text:
You will *not* need to do this for a fresh checkout, since the project
policy is to include the generated javascript as a checked-in file.

## Ingredients

 - Python 2.x
 - a recent Emscripten, which in turn has dependencies on:
    - LLVM 3.2
    - Clang 3.2
    - Node.js 0.6.12 or newer
    - Python 2.7.3

Within the `js-nacl` directory,

 - [`import.py`](import.py) massages an unpacked `nacl` tarball,
   extracting just the reference implementations of the various
   algorithms. (See its
   [origin](https://github.com/warner/pynacl/blob/minimal/import.py)
   in Brian Warner's `minimal` branch of pynacl.)

 - [`keys.c`](keys.c) extends core `nacl` with a pynacl-compatible
   implementation of `crypto_sign_keypair_from_raw_sk`, the foundation
   for `nacl.crypto_sign_keypair_from_seed`.

 - [`nacl_cooked.js`](nacl_cooked.js) is the high-level Javascript
   interface to the low-level code.

 - [`nacl_cooked_prefix.js`](nacl_cooked_prefix.js) and
   [`nacl_cooked_suffix.js`](nacl_cooked_suffix.js) are wrapped
   around `nacl_cooked.js` and `nacl_raw.js` to create
   `lib/nacl.js`.

 - [`nacl_randombytes_emscripten.js`](nacl_randombytes_emscripten.js) is
   infrastructure for making the Emscripten-compiled library
   parameterized in its source of randomness.

 - [`test_nacl_browser.html`](test_nacl_browser.html) is a simple
   example/test of the code running in the browser.

 - [`test_nacl_node.js`](test_nacl_node.js) is a simple example/test
   for running in node.js: `node test_nacl_node.js`.

 - Both of the previous two depend upon
   [`test_nacl.js`](test_nacl.js), which contains the actual test
   script.

 - [`benchmark.html`](benchmark.html) and
   [`benchmark.js`](benchmark.js) are trivial speed measurements for
   running in the browser.

## Method

Follow the instructions from the [Emscripten
tutorial](http://emscripten.org/Tutorial) to get Emscripten ready to
run.

Once `emcc` is on your `$PATH` somewhere, use the `js-nacl` Makefile.

To rebuild everything:

    make veryclean all

This will completely remove any compilation products, and recompile
everything.

Other Makefile targets:

 - `make clean`: removes generated Javascript, but does not remove the
   unpacked and pre-processed `nacl` tarball contents.

 - `make veryclean`: as `make clean`, but also removes the `subnacl`
   directory and the contents of the `nacl` tarball.

 - `make` or `make all`: performs all the build steps.

If you for some reason need to use a different python than `python`,
set the `PYTHON` makefile variable; for example,

    make all PYTHON=python2.7

Similarly, set `EMCC` to the path to your `emcc` binary if it's not on
your `$PATH`.

## Serves three

The build products will be in

 - [`node_raw.js`](node_raw.js): output from Emscripten

 - `lib/*`: Javascript for use in the browser and in node.js

 - `subnacl/*`: Unpacked `nacl` tarball, after processing by `import.py`


text:
require "spree_avalara_calc/engine"

module SpreeAvalaraCalc
end


text:
from twisted.plugin import IPlugin
from txircd.module_interface import IModuleData, ModuleData
from zope.interface import implements

class SnoRemoteConnect(ModuleData):
	implements(IPlugin, IModuleData)

	name = "ServerNoticeRemoteConnect"

	def actions(self):
		return [ ("remoteregister", 1, self.sendRemoteConnectNotice),
		         ("servernoticetype", 1, self.checkSnoType)]

	def sendRemoteConnectNotice(self, user, *params):
		server = self.ircd.servers[user.uuid[:3]].name
		message =  "Client connected on {}: {} ({}) [{}]".format(server, user.hostmaskWithRealHost(), user.ip, user.gecos)
		snodata = {
			"mask": "connect",
			"message": message
		}
		self.ircd.runActionProcessing("sendservernotice", snodata)

	def checkSnoType(self, user, typename):
		return typename == "remoteconnect"

snoRemoteConnect = SnoRemoteConnect()


text:
import React from 'react';
import styled from 'styled-components';
import PropTypes from 'prop-types';

const Image = styled.div`
  background: url('${(props) => props.src}');
  background-position: center;
  background-size: cover;
  height: calc(100vh - 30px);
`;

const Hero = ({ src }) => (
  <Image
    src={src}
  />
);

Hero.propTypes = {
  src: PropTypes.string.isRequired,
};

export default Hero;


text:
# -*- coding: utf-8 -*-
#!D:\Python32\python.exe
import sys
import os
import re
import shutil

from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter, process_pdf
from pdfminer.pdfparser import PDFDocument, PDFParser
#from pdfminer.pdfdevice import TagExtractor
from pdfminer.converter import HTMLConverter
from pdfminer.layout import LAParams

g_count = 0

def main(argv):
	import getopt
	def usage():
		print(('usage: %s [-i input_dir] [-o output_dir]' % argv[0]))
	try:
		(opts, args) = getopt.getopt(argv[1:], 'i:o:')
	except getopt.GetoptError:
		return usage()
	if len(argv) == 1 and run_test(): return
	if not opts: return usage()

	idir = None
	odir = None
	for (k, v) in opts:
		if k == '-i': idir = v
		elif k == '-o': odir = v

	if idir and odir and os.path.exists(idir):
		folder_process(idir, odir)

def folder_process(idir, odir, reserve=False):
	names = []
	if not os.path.exists(odir):
		print(('create output dir: %s' % odir))
		os.makedirs(odir)
	for root, dirs, files in os.walk(idir):
		for file in files:
			if file.lower().endswith('.pdf'):
				#try:
					path = os.path.join(root, file)
					outfile = pdf_process(path, reserve)
					if len(outfile) > 255: outfile = outfile[:64]+'.pdf'
					names.append(outfile)
					print(('copy from %s to %s' % (file, outfile)))
					npath = os.path.join(odir, root[len(idir)+1:])
					if not os.path.exists(npath): os.mkdir(npath)
					shutil.copy(path, os.path.join(npath, outfile))
				#except Exception as e:
				#	print(('error: %s -> %s' % (file, str(e))))
	return names

def pdf_gettext(filepath, reserve):
	# debug option
	debug = 0
	# input option
	password = ''
	pagenos = set()
	maxpages = 0
	# output option
	outfile = 'output.html'
	imagewriter = None
	layoutmode = 'normal'
	codec = 'utf-8'
	scale = 1
	caching = True
	laparams = LAParams()
	firstout = 'firstout.html'
	lastout = 'lastout.html'
	firstpage = None
	lastpage = None
	first = []
	last = []

	if False:
		firstout = filepath[:-3] + firstout
		lastout = filepath[:-3] + lastout
		if os.path.exists(firstout):
			html_textparser(firstout, first)
			if os.path.exists(lastout):
				html_textparser(lastout, last)
			return first, last

	rsrcmgr = PDFResourceManager(caching=caching)

	#import io
	#outfp = io.StringIO()
	#outfp = io.open(outfile, 'w+t', encoding=codec, errors='ignore')
	import tempfile
	outfp = tempfile.TemporaryFile(mode='w+t', encoding=codec)

	device = HTMLConverter(rsrcmgr, outfp, scale=scale, layoutmode=layoutmode, laparams=laparams)

	with open(filepath, 'rb') as fp:
		#process_pdf(rsrcmgr, device, fp, pagenos, maxpages=maxpages, password=password,
        #            caching=caching, check_extractable=True)

		parser = PDFParser(fp)
		doc = PDFDocument(caching=caching)
		parser.set_document(doc)
		doc.set_parser(parser)
		doc.initialize(password)
		if not doc.is_extractable:
			raise Exception('Text extraction is not allowed: %s' % filepath)

		interpreter = PDFPageInterpreter(rsrcmgr, device)
		for page in doc.get_pages():
			if not firstpage:
				firstpage = page
			else:
				lastpage = page

		if firstpage:
			interpreter.process_page(firstpage)
			with open(firstout, 'w', encoding=codec) as f:
				outfp.seek(0)
				f.write(outfp.read())
			html_textparser(firstout, first)
		if lastpage:
			outfp.truncate(0)
			interpreter.process_page(lastpage)
			with open(lastout, 'w', encoding=codec) as f:
				outfp.seek(0)
				f.write(outfp.read())
			html_textparser(lastout, last)

	device.close()
	outfp.close()

	return first, last

def html_textparser(filename, list):
	div = re.compile(r'
(.*?)
', re.DOTALL)
	span = re.compile(r'(.*?)', re.DOTALL)
	lowc = re.compile(r'[a-z]')
	with open(filename, 'rt', encoding='utf-8') as f:
		for d in div.findall(f.read()):
			mg = span.findall(d[3])
			tlen = sum([len(m[1]) for m in mg]) if len(mg) > 1 else -1
			tcur, tcap = 0, False
			for m in mg:
				update = False
				t = m[1].replace('\n
', ' ').strip()
				if t != '':
					left = int(d[0])
					if tlen != -1:
						left = int(float(d[2])*tcur/tlen) + int(d[0])
						tcur += len(m[1])
					if len(t) == 1:	tcap = not t.islower()
					elif tcap:
						update = tcap = lowc.search(t) == None
					if update:
						list[-1] = ( list[-1][0] + t, list[-1][1], list[-1][2], list[-1][3] )
					else:
						list.append( (t, int(m[0]), left, int(d[1])) )

def pdf_process(filepath, reserve):
	first, last = pdf_gettext(filepath, reserve)
	if is_NEJM(first):
		return NEJM_process(first, last)
	elif is_Spine(first):
		return Spine_process(first, last)
	elif is_semss(first):
		return semss_process(first, last)
	elif is_clineuro(first):
		return clineuro_process(first, last)
	elif is_wneu(first):
		return wneu_process(first, last)
	elif is_lancet(first):
		return lancet_process(first, last)
	elif is_ncna(first):
		return ncna_process(first, last)
	elif is_neurosurg(first):
		return neurosurg_process(first, last)
	elif is_cn(first):
		return cn_process(first, last)
	elif is_neurosurgery(first):
		return neurosurgery_process(first, last)
	elif is_nf(first):
		return nf_process(first, last)
	elif is_surg(first):
		return surg_process(first, last)
	else:
		print('treat as general')
		return general_process(first, last)

def text_gettitle(list, h1=0, h2=900, exclude=()):
	l = sorted(list, key=lambda l : l[1], reverse=True)
	title = 'no-title'
	for i in l:
		if i[3] >= h1 and i[3] <= h2 and i[0] not in exclude:
			w = i[0].split(' ')
			if [c for c in w if len(c) >= 2] != []:
				title = i[0]
				break

	t = None
	for i, p in enumerate(list):
		if t != None:
			if t[1] != p[1] or t[3]-p[3] > 20: break
			title += ' ' + p[0]
		if not t and title == p[0]:
			t = p

	#get valid title:
	title = re.sub(r'[\/:*?"<>|]', '--', title)

	return title

def text_getnum(list, default, footer=True):
	r = -20 if footer else 20
	l = sorted(list, key=lambda l : l[3], reverse=footer)
	lc, top, num = [], -1, default
	for i in l:
		if top != -1 and i[3] < top+r:
			break
		if i[0].isdigit():
			if top == -1: top = i[3]
			lc.append(i)
	edge = -1
	for i in lc:
		if edge < abs(i[2]-300):
			edge = abs(i[2]-300)
			num = i[0]
	return num

def general_process(first, last):
	title = text_gettitle(first)
	if title == 'no-title':
		global g_count
		g_count += 1
		return 'FFFF-LLL.TITLE[Failed-%d].pdf' % g_count
	else:
		start = text_getnum(first, 'FFFF').zfill(4)
		end = text_getnum(last, 'LLL').zfill(3)
		return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_NEJM(list):
	pattern = [[0, 'new england journal'], [0, 'www.nejm.org']]
	for p in list:
		for i in pattern:
			if i[1] in p[0].lower():
				print((i[1]))
				return True
	return False

def NEJM_process(first, last):
	#get the title
	title = text_gettitle(first, exclude=('Special Article', 'Review Article', 'ABSTRACT'))

	#get the first pagenum
	start = text_getnum(first, 'FFFF').zfill(4)

	#get the last pagenum
	end = text_getnum(last, 'LLL').zfill(3)

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_Spine(list):
	pattern = 'The Spine Journal'
	for p in list:
		if pattern in p[0]:
			print(pattern)
			return True
	return False

def Spine_process(first, last):
	title = text_gettitle(first)

	digit = re.compile(r'(\d+)')
	start, end = 'FFFF', 'LLL'
	pattern = 'The Spine Journal'
	for p in first:
		if pattern in p[0]:
			mg = digit.findall(p[0])
			if len(mg) >= 2:
				start, end = mg[-2].zfill(4), mg[-1].zfill(3)
			break

	if not last: start = end.zfill(4)

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_semss(list):
	pattern = [[0, 'seminars in spine surgery'], [0, 'j.semss']]
	for p in list:
		for i in pattern:
			if i[1] in p[0].lower():
				print((i[1]))
				return True
	return False

def semss_process(first, last):
	title = text_gettitle(first)

	digit = re.compile(r'(\d+)')
	start, end = 'FFFF', 'LLL'
	pattern = 'S E M I N A R S I N S P I N E S U R G E R Y'
	for p in first:
		if pattern in p[0]:
			mg = digit.findall(p[0].translate(None, ' '))
			if len(mg) >= 2:
				start, end = mg[-2].zfill(4), mg[-1].zfill(3)
			break

	if start == 'FFFF':
		start = text_getnum(first, start).zfill(4)
		end = text_getnum(last, end, False).zfill(3)

	if not last: end = start

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_clineuro(list):
	pattern = 'j.clineuro'#[[0, 'Clinical Neurology and Neurosurgery'], [0, 'j.clineuro']]
	for p in list:
		if pattern in p[0].lower():
			print(pattern)
			return True
	return False

def clineuro_process(first, last):
	pattern = 'c l i n e u r o'
	h1, h2 = 0, 300
	for p in first:
		if pattern in p[0]:
			h1 = p[3]
			break
	title = text_gettitle(first, h1, h2)

	nc = []
	digit = re.compile(r'(\d+)')
	start, end = 'FFFF', 'LLL'
	for p in first:
		if p[3]
= 2:
		start, end = nc[-2].zfill(4), nc[-1].zfill(3)

	if start == 'FFFF':
		start = text_getnum(first, start, False).zfill(4)
		end = text_getnum(last, end, False).zfill(3)

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_wneu(list):
	pattern = 'j.wneu'
	for p in list:
		if pattern in p[0].lower():
			print(pattern)
			return True
	return False

def wneu_process(first, last):
	title = text_gettitle(first, exclude=('Perspectives', 'Peer-Review Reports', 'Education & Training'))

	digit = re.compile(r':e?(\d+).*?(\d+)[.]')
	start, end = 'FFFF', 'LLL'
	pattern = 'World Neurosurg'
	nc = []
	for p in first:
		if pattern in p[0]:
			mg = digit.search(p[0])
			if mg:
				start, end = mg.group(1).zfill(4), mg.group(2).zfill(3)
				break
	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_lancet(list):
	pattern = [[0, 'the lancet'], [0, 'www.thelancet.com']]
	for p in list:
		for i in pattern:
			if i[1] in p[0].lower():
				print((i[1]))
				return True
	return False

def lancet_process(first, last):
	title = text_gettitle(first, exclude=('CORRESPONDENCE'))

	start = text_getnum(first, 'FFFF').zfill(4)

	end = text_getnum(last, 'LLL').zfill(3)

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_ncna(list):
	pattern = 'Neurosurg Clin N Am'
	for p in list:
		if pattern in p[0]:
			print(pattern)
			return True
	return False

def ncna_process(first, last):
	title = text_gettitle(first)

	digit = re.compile(r'(\d+)')
	start, end = 'FFFF', 'LLL'
	pattern = 'Neurosurg Clin N Am'
	for p in first:
		if pattern in p[0]:
			mg = digit.findall(p[0].translate(None, ' '))
			if len(mg) >= 4:
				start, end = mg[-2].zfill(4), mg[-1].zfill(3)
			break

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_neurosurg(list):
	pattern = 'J Neurosurg'
	for p in list:
		if pattern in p[0]:
			print(pattern)
			return True
	return False

def neurosurg_process(first, last):
	title = text_gettitle(first)

	start = text_getnum(first, 'FFFF').zfill(4)

	end = text_getnum(last, 'LLL').zfill(3)

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_cn(list):
	pattern = 'Clinical Neurosurgery'
	for p in list:
		if pattern in p[0]:
			print(pattern)
			return True
	return False

def cn_process(first, last):
	title = text_gettitle(first)

	start = text_getnum(first, 'FFFF').zfill(4)

	end = text_getnum(last, 'LLL').zfill(3)

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_neurosurgery(list):
	pattern = 'neurosurgery-online'
	ptstart = 'Neurosurgery'
	for p in list:
		if pattern in p[0] or p[0].startswith(ptstart):
			print(pattern)
			return True
	return False

def neurosurgery_process(first, last):
	title = text_gettitle(first, exclude=('TECHNIQUE ASSESSMENTS', 'OPERATIVE NUANCES'))

	digit = re.compile(r'Neurosurgery.*?:.*?(\d+).*?(\d+),')
	start, end = 'FFFF', 'LLL'
	for p in first:
		mg = digit.search(p[0])
		if mg:
			start, end = mg.group(1).zfill(4), mg.group(2).zfill(3)
			break

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_nf(list):
	pattern = 'Neurosurg Focus'
	for p in list:
		if pattern in p[0].lower():
			print(pattern)
			return True
	return False

def nf_process(first, last):
	title = text_gettitle(first)

	start = text_getnum(first, 'FFFF').zfill(4)

	end = text_getnum(last, 'LLL').zfill(3)

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def is_surg(list):
	pattern = 'Surg Neurol'
	for p in list:
		if pattern in p[0]:
			print(pattern)
			return True
	return False

def surg_process(first, last):
	title = text_gettitle(first)

	digit = re.compile(r'(\d+)')
	start, end = 'FFFF', 'LLL'
	pattern = 'Surg Neurol'
	for p in first:
		if pattern in p[0]:
			mg = digit.findall(p[0].translate(None, ' '))
			if len(mg) >= 4:
				start, end = mg[-2].zfill(4), str(int(mg[-2])+int(mg[-1])).zfill(3)
			break

	return '%s-%s.%s.pdf'%(start, end[-3:], title)

def run_test():
	names = []
	path = r'C:\Users\jzhang\Downloads'
	test = path + r'\run_test'
	if os.path.exists(test):
		for i in range(1, 2):
			p = path + r'\input' + str(i)
			if os.path.exists(p):
				names += folder_process(p, p+'_O', True)
		update = False
		with open(test, 'rt', encoding='utf-8') as f:
			all = f.read()
			for n in names:
				if n not in all:
					update = True
					print(('differ from last: ' + n))
		if update:
			with open(test, 'w+', encoding='utf-8') as f:
				for n in names:
					f.write(n + '\n')

	return names != []

if __name__ == '__main__':
	main(sys.argv)


text:
#ifndef RES_H
#define RES_H 1

#include "../bee/util.hpp"
#include "../bee/all.hpp"

#include "extras.hpp"

// BEEF auto-generated the below code and will overwrite all changes

// Define textures
extern bee::Texture* spr_none;

{textureDefines}

// Define sounds
{soundDefines}

// Define fonts
{fontDefines}

// Define paths
{pathDefines}

// Define timelines
{timelineDefines}

// Define meshes
{meshDefines}

// Define lights
{lightDefines}

// Define objects
{objectDefines}

// Define rooms
{roomDefines}

namespace bee {{
	int init_resources();
	int close_resources();
}}

#endif // RES_H


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

namespace MaterialChartPlugin.Models.Utilities
{
    static class ChartDataExtensions
    {
        /// <summary>
        /// チャート描画のパフォーマンスを改善するため、データの間引きを行います。
        /// </summary>
        /// <param name="log">資材の時系列データ</param>
        /// <param name="period">描画対象期間</param>
        /// <returns></returns>
        public static IEnumerable<TimeMaterialsPair> ThinOut(this IEnumerable<TimeMaterialsPair> log, DisplayedPeriod period)
        {
            if (log.Count() == 0)
                yield break;

            TimeSpan minimumTimeStep = GetMinimumTimeStep(period);
            double minimumMaterialRatio = GetMinimumMaterialRatio(period);

            // 最初のデータは必ず返す
            yield return log.First();
            TimeMaterialsPair lastData = log.First();

            foreach (var data in log.Skip(1))
            {
                // 前のデータから時刻あるいは資材量が十分離れているデータであれば値を返す
                if (HasSeriouslyChanged(lastData, data, minimumTimeStep, minimumMaterialRatio))
                {
                    yield return data;
                    lastData = data;
                }
            }

            // 直近のデータは必ず返す
            if (!lastData.Equals(log.Last()))
            {
                yield return log.Last();
            }
        }

        private static TimeSpan GetMinimumTimeStep(DisplayedPeriod period)
        {
            // x方向の解像度は150分割くらいにしておく(わりと適当)
            switch (period)
            {
                case DisplayedPeriod.OneDay:
                    return TimeSpan.FromMinutes(10);
                case DisplayedPeriod.OneWeek:
                    return TimeSpan.FromHours(1);
                case DisplayedPeriod.OneMonth:
                    return TimeSpan.FromHours(4);
                case DisplayedPeriod.ThreeMonths:
                    return TimeSpan.FromHours(12);
                case DisplayedPeriod.OneYear:
                    return TimeSpan.FromDays(2);
                case DisplayedPeriod.ThreeYears:
                    return TimeSpan.FromDays(6);
                default:
                    throw new ArgumentException("periodの値が不正です");
            }
        }

        private static double GetMinimumMaterialRatio(DisplayedPeriod period)
        {
            switch (period)
            {
                case DisplayedPeriod.OneDay:
                case DisplayedPeriod.OneWeek:
                    return 0.02;
                case DisplayedPeriod.OneMonth:
                    return 0.05;
                case DisplayedPeriod.ThreeMonths:
                    return 0.08;
                case DisplayedPeriod.OneYear:
                    return 0.12;
                case DisplayedPeriod.ThreeYears:
                    return 0.25;
                default:
                    throw new ArgumentException("periodの値が不正です");
            }
        }

        private static bool HasSeriouslyChanged(TimeMaterialsPair oldData, TimeMaterialsPair newData, TimeSpan minimumTimeStep, double minimumMaterialRatio)
        {
            // 5%くらい変化したら大きく変わったとみてよい
            return newData.DateTime - oldData.DateTime >= minimumTimeStep
                || Math.Abs(newData.Fuel - oldData.Fuel) >= oldData.Fuel * minimumMaterialRatio
                || Math.Abs(newData.Ammunition - oldData.Ammunition) >= oldData.Fuel * minimumMaterialRatio
                || Math.Abs(newData.Steel - oldData.Steel) >= oldData.Steel * minimumMaterialRatio
                || Math.Abs(newData.Bauxite - oldData.Bauxite) >= oldData.Bauxite * minimumMaterialRatio
                || Math.Abs(newData.RepairTool - oldData.RepairTool) >= oldData.RepairTool * minimumMaterialRatio;
        }

        /// <summary>
        /// 指定された期間内のデータのみをフィルタリングします。
        /// </summary>
        /// <param name="log">資材の時系列データ</param>
        /// <param name="period">描画対象期間</param>
        /// <returns></returns>
        public static IEnumerable<TimeMaterialsPair> Within(this IEnumerable<TimeMaterialsPair> log, DisplayedPeriod period)
        {
            if (log.Count() == 0)
                yield break;

            TimeSpan periodSpan = period.ToTimeSpan();

            // 期間の直前のデータはとっておく
            if (log.Any(d => DateTime.Now - d.DateTime > periodSpan))
            {
                yield return log.Last(d => DateTime.Now - d.DateTime > periodSpan);
            }

            if (log.Any(d => DateTime.Now - d.DateTime <= periodSpan))
            {
                foreach (var data in log.Where(d => DateTime.Now - d.DateTime <= periodSpan))
                {
                    yield return data;
                }
            }
        }

        public static TimeSpan ToTimeSpan(this DisplayedPeriod period)
        {
            switch (period)
            {
                case DisplayedPeriod.OneDay:
                    return TimeSpan.FromDays(1);
                case DisplayedPeriod.OneWeek:
                    return TimeSpan.FromDays(7);
                case DisplayedPeriod.OneMonth:
                    return TimeSpan.FromDays(30);
                case DisplayedPeriod.ThreeMonths:
                    return TimeSpan.FromDays(90);
                case DisplayedPeriod.OneYear:
                    return TimeSpan.FromDays(365);
                case DisplayedPeriod.ThreeYears:
                    return TimeSpan.FromDays(365 * 3);
                default:
                    throw new ArgumentException("periodの値が不正です");
            }
        }
    }
}


text:
define([
    'preact',
    'htm',

    'bootstrap',
    'css!./ErrorAlert.css',
], (
    preact,
    htm,
) => {

    const {h, Component} = preact;
    const html = htm.bind(h);

    class ErrorAlert extends Component {
        render() {
            const content = (() => {
                if (this.props.render) {
                    return this.props.render();
                }
                return this.props.message || this.props.children;
            })();
            return html`

                        ${this.props.title || 'Error'}

                    ${content}

            `;
        }
    }

    return ErrorAlert;
});


text:
@class ZXBitArray, ZXResult;

/**
 * @see UPCEANExtension2Support
 */
@interface ZXUPCEANExtension5Support : NSObject

- (ZXResult *)decodeRow:(int)rowNumber row:(ZXBitArray *)row extensionStartRange:(NSRange)extensionStartRange error:(NSError **)error;
- (int)decodeMiddle:(ZXBitArray *)row startRange:(NSRange)startRange result:(NSMutableString *)result error:(NSError **)error;

@end