text:
namespace mojo {

// Represents a moveable array with contents of type |T|. The array can be null,
// meaning that no value has been assigned to it. Null is distinct from empty.
template <typename T>
class Array {
  MOVE_ONLY_TYPE_FOR_CPP_03(Array);
 public:
  using ConstRefType = typename std::vector<T>::const_reference;
  using RefType = typename std::vector<T>::reference;

  using Element = T;
  using Data_ = internal::Array_Data<
      typename internal::GetDataTypeAsArrayElement<T>::Data>;

  using iterator = typename std::vector<T>::iterator;
  using const_iterator = typename std::vector<T>::const_iterator;

  // Constructs an empty array.
  Array() : is_null_(false) {}
  // Constructs a null array.
  Array(std::nullptr_t null_pointer) : is_null_(true) {}

  // Constructs a new non-null array of the specified size. The elements will
  // be value-initialized (meaning that they will be initialized by their
  // default constructor, if any, or else zero-initialized).
  explicit Array(size_t size) : vec_(size), is_null_(false) {}
  ~Array() {}

  // Moves the contents of |other| into this array.
  Array(std::vector<T>&& other) : vec_(std::move(other)), is_null_(false) {}
  Array(Array&& other) : is_null_(true) { Take(&other); }

  Array& operator=(std::vector<T>&& other) {
    vec_ = std::move(other);
    is_null_ = false;
    return *this;
  }
  Array& operator=(Array&& other) {
    Take(&other);
    return *this;
  }

  Array& operator=(std::nullptr_t null_pointer) {
    is_null_ = true;
    vec_.clear();
    return *this;
  }

  // Creates a non-null array of the specified size. The elements will be
  // value-initialized (meaning that they will be initialized by their default
  // constructor, if any, or else zero-initialized).
  static Array New(size_t size) { return Array(size); }

  // Creates a new array with a copy of the contents of |other|.
  template <typename U>
  static Array From(const U& other) {
    return TypeConverter<Array, U>::Convert(other);
  }

  // Copies the contents of this array to a new object of type |U|.
  template <typename U>
  U To() const {
    return TypeConverter<U, Array>::Convert(*this);
  }

  // Indicates whether the array is null (which is distinct from empty).
  bool is_null() const { return is_null_; }

  // Indicates whether the array is empty (which is distinct from null).
  bool empty() const { return vec_.empty() && !is_null_; }

  // Returns a reference to the first element of the array. Calling this on a
  // null or empty array causes undefined behavior.
  ConstRefType front() const { return vec_.front(); }
  RefType front() { return vec_.front(); }

  iterator begin() { return vec_.begin(); }
  const_iterator begin() const { return vec_.begin(); }
  iterator end() { return vec_.end(); }
  const_iterator end() const { return vec_.end(); }

  // Returns the size of the array, which will be zero if the array is null.
  size_t size() const { return vec_.size(); }

  // Returns a reference to the element at zero-based |offset|. Calling this on
  // an array with size less than |offset|+1 causes undefined behavior.
  ConstRefType at(size_t offset) const { return vec_.at(offset); }
  ConstRefType operator[](size_t offset) const { return at(offset); }
  RefType at(size_t offset) { return vec_.at(offset); }
  RefType operator[](size_t offset) { return at(offset); }

  // Pushes |value| onto the back of the array. If this array was null, it will
  // become non-null with a size of 1.
  void push_back(const T& value) {
    is_null_ = false;
    vec_.push_back(value);
  }
  void push_back(T&& value) {
    is_null_ = false;
    vec_.push_back(std::move(value));
  }

  // Resizes the array to |size| and makes it non-null. Otherwise, works just
  // like the resize method of |std::vector|.
  void resize(size_t size) {
    is_null_ = false;
    vec_.resize(size);
  }

  // Sets the array to empty (even if previously it was null.)
  void SetToEmpty() { resize(0); }

  // Returns a const reference to the |std::vector| managed by this class. If
  // the array is null, this will be an empty vector.
  const std::vector<T>& storage() const { return vec_; }

  // Passes the underlying storage and resets this array to null.
  //
  // TODO(yzshen): Consider changing this to a rvalue-ref-qualified conversion
  // to std::vector<T> after we move to MSVC 2015.
  std::vector<T> PassStorage() {
    is_null_ = true;
    return std::move(vec_);
  }

  void Swap(Array* other) {
    std::swap(is_null_, other->is_null_);
    vec_.swap(other->vec_);
  }

  // Swaps the contents of this array with the specified vector, making this
  // array non-null. Since the vector cannot represent null, it will just be
  // made empty if this array is null.
  void Swap(std::vector<T>* other) {
    is_null_ = false;
    vec_.swap(*other);
  }

  // Returns a copy of the array where each value of the new array has been
  // "cloned" from the corresponding value of this array. If this array contains
  // primitive data types, this is equivalent to simply copying the contents.
  // However, if the array contains objects, then each new element is created by
  // calling the |Clone| method of the source element, which should make a copy
  // of the element.
  //
  // Please note that calling this method will fail compilation if the element
  // type cannot be cloned (which usually means that it is a Mojo handle type or
  // a type contains Mojo handles).
  Array Clone() const {
    Array result;
    result.is_null_ = is_null_;
    CloneTraits<T>::Clone(vec_, &result.vec_);
    return std::move(result);
  }

  // Indicates whether the contents of this array are equal to |other|. A null
  // array is only equal to another null array. Elements are compared using the
  // |ValueTraits::Equals| method, which in most cases calls the |Equals| method
  // of the element.
  bool Equals(const Array& other) const {
    if (is_null() != other.is_null())
      return false;
    if (size() != other.size())
      return false;
    for (size_t i = 0; i < size(); ++i) {
      if (!internal::ValueTraits<T>::Equals(at(i), other.at(i)))
        return false;
    }
    return true;
  }

 private:
  typedef std::vector<T> Array::*Testable;

 public:
  operator Testable() const { return is_null_ ? 0 : &Array::vec_; }

 private:
  // Forbid the == and != operators explicitly, otherwise Array will be
  // converted to Testable to do == or != comparison.
  template <typename U>
  bool operator==(const Array<U>& other) const = delete;
  template <typename U>
  bool operator!=(const Array<U>& other) const = delete;

  template <typename U,
            bool is_move_only_type = internal::IsMoveOnlyType<U>::value>
  struct CloneTraits {};

  template <typename U>
  struct CloneTraits<U, false> {
    static inline void Clone(const std::vector<T>& src_vec,
                             std::vector<T>* dest_vec) {
      dest_vec->assign(src_vec.begin(), src_vec.end());
    }
  };

  template <typename U>
  struct CloneTraits<U, true> {
    static inline void Clone(const std::vector<T>& src_vec,
                             std::vector<T>* dest_vec) {
      DCHECK(dest_vec->empty());
      dest_vec->reserve(src_vec.size());
      for (const auto& element : src_vec)
        dest_vec->push_back(element.Clone());
    }
  };

  void Take(Array* other) {
    operator=(nullptr);
    Swap(other);
  }

  std::vector<T> vec_;
  bool is_null_;
};

// A |TypeConverter| that will create an |Array<T>| containing a copy of the
// contents of an |std::vector<E>|, using |TypeConverter<T, E>| to copy each
// element. The returned array will always be non-null.
template <typename T, typename E>
struct TypeConverter<Array<T>, std::vector<E>> {
  static Array<T> Convert(const std::vector<E>& input) {
    Array<T> result(input.size());
    for (size_t i = 0; i < input.size(); ++i)
      result[i] = TypeConverter<T, E>::Convert(input[i]);
    return std::move(result);
  }
};

// A |TypeConverter| that will create an |std::vector<E>| containing a copy of
// the contents of an |Array<T>|, using |TypeConverter<E, T>| to copy each
// element. If the input array is null, the output vector will be empty.
template <typename E, typename T>
struct TypeConverter<std::vector<E>, Array<T>> {
  static std::vector<E> Convert(const Array<T>& input) {
    std::vector<E> result;
    if (!input.is_null()) {
      result.resize(input.size());
      for (size_t i = 0; i < input.size(); ++i)
        result[i] = TypeConverter<E, T>::Convert(input[i]);
    }
    return result;
  }
};

// A |TypeConverter| that will create an |Array<T>| containing a copy of the
// contents of an |std::set<E>|, using |TypeConverter<T, E>| to copy each
// element. The returned array will always be non-null.
template <typename T, typename E>
struct TypeConverter<Array<T>, std::set<E>> {
  static Array<T> Convert(const std::set<E>& input) {
    Array<T> result;
    for (auto i : input)
      result.push_back(TypeConverter<T, E>::Convert(i));
    return std::move(result);
  }
};

// A |TypeConverter| that will create an |std::set<E>| containing a copy of
// the contents of an |Array<T>|, using |TypeConverter<E, T>| to copy each
// element. If the input array is null, the output set will be empty.
template <typename E, typename T>
struct TypeConverter<std::set<E>, Array<T>> {
  static std::set<E> Convert(const Array<T>& input) {
    std::set<E> result;
    if (!input.is_null()) {
      for (size_t i = 0; i < input.size(); ++i)
        result.insert(TypeConverter<E, T>::Convert(input[i]));
    }
    return result;
  }
};

// Less than operator to allow Arrays as keys in std maps and sets.
template <typename T>
inline bool operator<(const Array<T>& a, const Array<T>& b) {
  if (a.is_null())
    return !b.is_null();
  if (b.is_null())
    return false;
  return a.storage() < b.storage();
}

}  // namespace mojo

#endif  // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_


text:
using System;
using System.IO;
using Encog.App.Analyst.CSV.Process;
using Encog.App.Analyst.Script.Prop;
using Encog.App.Analyst.Util;
using Encog.Util.CSV;
using Encog.Util.Logging;

namespace Encog.App.Analyst.Commands
{
    /// <summary>
    ///     This command is used to preprocess a CSV file.
    /// </summary>
    public class CmdProcess : Cmd
    {
        /// <summary>
        ///     The name of the command.
        /// </summary>
        public static String COMMAND_NAME = "PROCESS";

        /// <summary>
        ///     Construct the randomize command.
        /// </summary>
        /// <param name="analyst">The analyst to use.</param>
        public CmdProcess(EncogAnalyst analyst)
            : base(analyst)
        {
        }

        /// <inheritdoc />
        public override String Name
        {
            get { return COMMAND_NAME; }
        }

        /// <inheritdoc />
        public override bool ExecuteCommand(String args)
        {
            // get filenames
            String sourceID = Prop.GetPropertyString(
                ScriptProperties.PROCESS_CONFIG_SOURCE_FILE);
            String targetID = Prop.GetPropertyString(
                ScriptProperties.PROCESS_CONFIG_TARGET_FILE);

            int forwardSize = Prop.GetPropertyInt(
                ScriptProperties.PROCESS_CONFIG_FORWARD_SIZE);
            int backwardSize = Prop.GetPropertyInt(
                ScriptProperties.PROCESS_CONFIG_BACKWARD_SIZE);

            EncogLogging.Log(EncogLogging.LevelDebug, "Beginning randomize");
            EncogLogging.Log(EncogLogging.LevelDebug, "source file:" + sourceID);
            EncogLogging.Log(EncogLogging.LevelDebug, "target file:" + targetID);

            FileInfo sourceFile = Script.ResolveFilename(sourceID);
            FileInfo targetFile = Script.ResolveFilename(targetID);

            // get formats
            CSVFormat format = Script.DetermineFormat();

            // mark generated
            Script.MarkGenerated(targetID);

            // prepare to transform
            var process = new AnalystProcess(Analyst, backwardSize, forwardSize);
            process.Script = Script;
            Analyst.CurrentQuantTask = process;
            process.Report = new AnalystReportBridge(Analyst);
            bool headers = Script.ExpectInputHeaders(sourceID);
            process.Analyze(sourceFile, headers, format);
            process.Process(targetFile);
            Analyst.CurrentQuantTask = null;
            return process.ShouldStop();
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
/* -------------------------------------------------------------------- */
/*  ACCORDS PLATFORM                                                    */
/*  (C) 2011 by Iain James Marshall (Prologue) <ijm667@hotmail.com>     */
/* -------------------------------------------------------------------- */
/* Licensed under the Apache License, Version 2.0 (the "License"); 	*/
/* you may not use this file except in compliance with the License. 	*/
/* You may obtain a copy of the License at 				*/
/*  									*/
/*  http://www.apache.org/licenses/LICENSE-2.0 				*/
/*  									*/
/* Unless required by applicable law or agreed to in writing, software 	*/
/* distributed under the License is distributed on an "AS IS" BASIS, 	*/
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 	*/
/* implied. 								*/
/* See the License for the specific language governing permissions and 	*/
/* limitations under the License. 					*/
/* -------------------------------------------------------------------- */

/* STRUKT WARNING : this file has been generated and should not be modified by hand */
#ifndef _occicontrol_c_
#define _occicontrol_c_

#include "control.h"

/*	------------------------------------	*/
/*	o c c i _ c o r d s _ c o n t r o l 	*/
/*	------------------------------------	*/

/*	--------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   m a n a g e m e n t   s t r u c t u r e 	*/
/*	--------------------------------------------------------------------	*/
struct cords_control * allocate_cords_control();
struct cords_control * liberate_cords_control(struct cords_control * optr);
private pthread_mutex_t list_cords_control_control=PTHREAD_MUTEX_INITIALIZER;
private struct occi_kind_node * cords_control_first = (struct occi_kind_node *) 0;
private struct occi_kind_node * cords_control_last  = (struct occi_kind_node *) 0;
public struct  occi_kind_node * occi_first_cords_control_node() { return( cords_control_first ); }
public struct  occi_kind_node * occi_last_cords_control_node() { return( cords_control_last ); }

/*	----------------------------------------------	*/
/*	o c c i   c a t e g o r y   d r o p   n o d e 	*/
/*	----------------------------------------------	*/
private struct occi_kind_node * ll_drop_cords_control_node(struct occi_kind_node * nptr) {
	if ( nptr ) {
	if (!( nptr->previous ))
		cords_control_first = nptr->next;
	else	nptr->previous->next = nptr->next;
	if (!( nptr->next ))
		cords_control_last = nptr->previous;
	else	nptr->next->previous = nptr->previous;
		liberate_occi_kind_node( nptr );
		}
	return((struct occi_kind_node *)0);
}
private struct occi_kind_node * drop_cords_control_node(struct occi_kind_node * nptr) {
	pthread_mutex_lock( &list_cords_control_control );
	nptr = ll_drop_cords_control_node( nptr );
	pthread_mutex_unlock( &list_cords_control_control );
	return(nptr);
}

/*	--------------------------------------------------	*/
/*	o c c i   c a t e g o r y   l o c a t e   n o d e 	*/
/*	--------------------------------------------------	*/
private struct occi_kind_node * ll_locate_cords_control_node(char * id) {
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	for ( nptr = cords_control_first;
		nptr != (struct occi_kind_node *) 0;
		nptr = nptr->next ) {
		if (!( pptr = nptr->contents )) continue;
		else if (!( pptr->id )) continue;
		else if (!( strcmp(pptr->id,id) )) break;
		}
	return( nptr );
}
private struct occi_kind_node * locate_cords_control_node(char * id) {
	struct occi_kind_node * nptr;
	pthread_mutex_lock( &list_cords_control_control );
	nptr = ll_locate_cords_control_node(id);
	pthread_mutex_unlock( &list_cords_control_control );
	return( nptr );
}

/*	--------------------------------------------	*/
/*	o c c i   c a t e g o r y   a d d   n o d e 	*/
/*	--------------------------------------------	*/
private struct occi_kind_node * ll_add_cords_control_node(int mode) {
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	if (!( nptr = allocate_occi_kind_node() ))
		return( nptr );
	else	{
		if (!( nptr->contents = allocate_cords_control()))
			return( liberate_occi_kind_node(nptr) );
		if (!( pptr = nptr->contents ))
			return( liberate_occi_kind_node(nptr) );
		else if (( mode != 0 ) && (!( pptr->id = occi_allocate_uuid())))
			return( liberate_occi_kind_node(nptr) );
		else	{
			if (!( nptr->previous = cords_control_last ))
				cords_control_first = nptr;
			else	nptr->previous->next = nptr;
			cords_control_last = nptr;
			return( nptr );
			}
		}
}
private struct occi_kind_node * add_cords_control_node(int mode) {
	struct occi_kind_node * nptr;
	pthread_mutex_lock( &list_cords_control_control );
	nptr = ll_add_cords_control_node( mode );
	pthread_mutex_unlock( &list_cords_control_control );
	return(nptr);
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   a u t o   l o a d 	*/
/*	------------------------------------------------------------------------------------------	*/
private char*autosave_cords_control_name="cords_control.xml";
private void autoload_cords_control_nodes() {
	char * fn=autosave_cords_control_name;	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	struct xml_element * document;
	struct xml_element * eptr;
	struct xml_element * vptr;
	struct xml_atribut  * aptr;
	if (!( document = document_parse_file(fn)))
		return;
	if ((eptr = document_element(document,"cords_controls")) != (struct xml_element *) 0) {
		for (vptr=eptr->first; vptr != (struct xml_element *) 0; vptr=vptr->next) {
			if (!( vptr->name )) continue;
			else if ( strcmp( vptr->name, "cords_control" ) ) continue;
			else if (!( nptr = add_cords_control_node(0))) break;
			else if (!( pptr = nptr->contents )) break;
			if ((aptr = document_atribut( vptr, "id" )) != (struct xml_atribut *) 0)
				pptr->id = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "name" )) != (struct xml_atribut *) 0)
				pptr->name = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "contract" )) != (struct xml_atribut *) 0)
				pptr->contract = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "agreement" )) != (struct xml_atribut *) 0)
				pptr->agreement = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "property" )) != (struct xml_atribut *) 0)
				pptr->property = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "condition" )) != (struct xml_atribut *) 0)
				pptr->condition = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "objective" )) != (struct xml_atribut *) 0)
				pptr->objective = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "reference" )) != (struct xml_atribut *) 0)
				pptr->reference = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "importance" )) != (struct xml_atribut *) 0)
				pptr->importance = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "obligated" )) != (struct xml_atribut *) 0)
				pptr->obligated = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "scope" )) != (struct xml_atribut *) 0)
				pptr->scope = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "session" )) != (struct xml_atribut *) 0)
				pptr->session = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "account" )) != (struct xml_atribut *) 0)
				pptr->account = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "monitor" )) != (struct xml_atribut *) 0)
				pptr->monitor = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "connection" )) != (struct xml_atribut *) 0)
				pptr->connection = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "metric" )) != (struct xml_atribut *) 0)
				pptr->metric = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "probe" )) != (struct xml_atribut *) 0)
				pptr->probe = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "process" )) != (struct xml_atribut *) 0)
				pptr->process = document_atribut_value(aptr);
			if ((aptr = document_atribut( vptr, "state" )) != (struct xml_atribut *) 0)
				pptr->state = document_atribut_value(aptr);
			}
		}
	document = document_drop( document );
	return;
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   a u t o   s a v e 	*/
/*	------------------------------------------------------------------------------------------	*/
public  void set_autosave_cords_control_name(char * fn) {
	autosave_cords_control_name = fn;	return;
}
public  void autosave_cords_control_nodes() {
	char * fn=autosave_cords_control_name;	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	FILE * h;
	pthread_mutex_lock( &list_cords_control_control );
	if (( h = fopen(fn,"w")) != (FILE *) 0) {
	fprintf(h,"<cords_controls>\n");
	for ( nptr = cords_control_first;
		nptr != (struct occi_kind_node *) 0;
		nptr = nptr->next ) {
		if (!( pptr = nptr->contents )) continue;
		fprintf(h,"<cords_control\n");
		fprintf(h," id=%c",0x0022);
		fprintf(h,"%s",(pptr->id?pptr->id:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," name=%c",0x0022);
		fprintf(h,"%s",(pptr->name?pptr->name:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," contract=%c",0x0022);
		fprintf(h,"%s",(pptr->contract?pptr->contract:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," agreement=%c",0x0022);
		fprintf(h,"%s",(pptr->agreement?pptr->agreement:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," property=%c",0x0022);
		fprintf(h,"%s",(pptr->property?pptr->property:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," condition=%c",0x0022);
		fprintf(h,"%s",(pptr->condition?pptr->condition:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," objective=%c",0x0022);
		fprintf(h,"%s",(pptr->objective?pptr->objective:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," reference=%c",0x0022);
		fprintf(h,"%s",(pptr->reference?pptr->reference:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," importance=%c",0x0022);
		fprintf(h,"%s",(pptr->importance?pptr->importance:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," obligated=%c",0x0022);
		fprintf(h,"%s",(pptr->obligated?pptr->obligated:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," scope=%c",0x0022);
		fprintf(h,"%s",(pptr->scope?pptr->scope:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," session=%c",0x0022);
		fprintf(h,"%s",(pptr->session?pptr->session:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," account=%c",0x0022);
		fprintf(h,"%s",(pptr->account?pptr->account:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," monitor=%c",0x0022);
		fprintf(h,"%s",(pptr->monitor?pptr->monitor:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," connection=%c",0x0022);
		fprintf(h,"%s",(pptr->connection?pptr->connection:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," metric=%c",0x0022);
		fprintf(h,"%s",(pptr->metric?pptr->metric:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," probe=%c",0x0022);
		fprintf(h,"%s",(pptr->probe?pptr->probe:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," process=%c",0x0022);
		fprintf(h,"%u",pptr->process);
		fprintf(h,"%c",0x0022);
		fprintf(h," state=%c",0x0022);
		fprintf(h,"%u",pptr->state);
		fprintf(h,"%c",0x0022);
		fprintf(h," />\n");
		}
	fprintf(h,"</cords_controls>\n");
	fclose(h);
	}
	pthread_mutex_unlock( &list_cords_control_control );
	return;
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   s e t   f i e l d 	*/
/*	------------------------------------------------------------------------------------------	*/
private void set_cords_control_field(
	struct occi_category * cptr,void * optr, char * nptr, char * vptr)
{
	struct cords_control * pptr;
	char prefix[1024];
	if (!( pptr = optr )) return;
	sprintf(prefix,"%s.%s.",cptr->domain,cptr->id);
	if (!( strncmp( nptr, prefix, strlen(prefix) ) )) {
		nptr += strlen(prefix);
		if (!( strcmp( nptr, "name" ) ))
			pptr->name = allocate_string(vptr);
		if (!( strcmp( nptr, "contract" ) ))
			pptr->contract = allocate_string(vptr);
		if (!( strcmp( nptr, "agreement" ) ))
			pptr->agreement = allocate_string(vptr);
		if (!( strcmp( nptr, "property" ) ))
			pptr->property = allocate_string(vptr);
		if (!( strcmp( nptr, "condition" ) ))
			pptr->condition = allocate_string(vptr);
		if (!( strcmp( nptr, "objective" ) ))
			pptr->objective = allocate_string(vptr);
		if (!( strcmp( nptr, "reference" ) ))
			pptr->reference = allocate_string(vptr);
		if (!( strcmp( nptr, "importance" ) ))
			pptr->importance = allocate_string(vptr);
		if (!( strcmp( nptr, "obligated" ) ))
			pptr->obligated = allocate_string(vptr);
		if (!( strcmp( nptr, "scope" ) ))
			pptr->scope = allocate_string(vptr);
		if (!( strcmp( nptr, "session" ) ))
			pptr->session = allocate_string(vptr);
		if (!( strcmp( nptr, "account" ) ))
			pptr->account = allocate_string(vptr);
		if (!( strcmp( nptr, "monitor" ) ))
			pptr->monitor = allocate_string(vptr);
		if (!( strcmp( nptr, "connection" ) ))
			pptr->connection = allocate_string(vptr);
		if (!( strcmp( nptr, "metric" ) ))
			pptr->metric = allocate_string(vptr);
		if (!( strcmp( nptr, "probe" ) ))
			pptr->probe = allocate_string(vptr);
		if (!( strcmp( nptr, "process" ) ))
			pptr->process = atoi(vptr);
		if (!( strcmp( nptr, "state" ) ))
			pptr->state = atoi(vptr);
		}
	return;
}

/*	--------------------------------------------------	*/
/*	o c c i   c a t e g o r y   f i l t e r   i n f o 	*/
/*	--------------------------------------------------	*/
private struct cords_control * filter_cords_control_info(
	struct occi_category * optr,
	struct rest_request  * rptr,
	struct rest_response * aptr) {
	struct cords_control * pptr;
		if (!( pptr = allocate_cords_control()))
		return( pptr );
	else if (!( occi_process_atributs(optr, rptr, aptr, pptr, set_cords_control_field) ))
		return( liberate_cords_control(pptr));
	else	return( pptr );
}

/*	--------------------------------------------------	*/
/*	o c c i   c a t e g o r y   f i l t e r   p a s s 	*/
/*	--------------------------------------------------	*/
private int pass_cords_control_filter(
	struct cords_control * pptr,struct cords_control * fptr) {
	if (( fptr->id )
	&&  (strlen( fptr->id ) != 0)) {
		if (!( pptr->id ))
			return(0);
		else if ( strcmp(pptr->id,fptr->id) != 0)
			return(0);
		}
	if (( fptr->name )
	&&  (strlen( fptr->name ) != 0)) {
		if (!( pptr->name ))
			return(0);
		else if ( strcmp(pptr->name,fptr->name) != 0)
			return(0);
		}
	if (( fptr->contract )
	&&  (strlen( fptr->contract ) != 0)) {
		if (!( pptr->contract ))
			return(0);
		else if ( strcmp(pptr->contract,fptr->contract) != 0)
			return(0);
		}
	if (( fptr->agreement )
	&&  (strlen( fptr->agreement ) != 0)) {
		if (!( pptr->agreement ))
			return(0);
		else if ( strcmp(pptr->agreement,fptr->agreement) != 0)
			return(0);
		}
	if (( fptr->property )
	&&  (strlen( fptr->property ) != 0)) {
		if (!( pptr->property ))
			return(0);
		else if ( strcmp(pptr->property,fptr->property) != 0)
			return(0);
		}
	if (( fptr->condition )
	&&  (strlen( fptr->condition ) != 0)) {
		if (!( pptr->condition ))
			return(0);
		else if ( strcmp(pptr->condition,fptr->condition) != 0)
			return(0);
		}
	if (( fptr->objective )
	&&  (strlen( fptr->objective ) != 0)) {
		if (!( pptr->objective ))
			return(0);
		else if ( strcmp(pptr->objective,fptr->objective) != 0)
			return(0);
		}
	if (( fptr->reference )
	&&  (strlen( fptr->reference ) != 0)) {
		if (!( pptr->reference ))
			return(0);
		else if ( strcmp(pptr->reference,fptr->reference) != 0)
			return(0);
		}
	if (( fptr->importance )
	&&  (strlen( fptr->importance ) != 0)) {
		if (!( pptr->importance ))
			return(0);
		else if ( strcmp(pptr->importance,fptr->importance) != 0)
			return(0);
		}
	if (( fptr->obligated )
	&&  (strlen( fptr->obligated ) != 0)) {
		if (!( pptr->obligated ))
			return(0);
		else if ( strcmp(pptr->obligated,fptr->obligated) != 0)
			return(0);
		}
	if (( fptr->scope )
	&&  (strlen( fptr->scope ) != 0)) {
		if (!( pptr->scope ))
			return(0);
		else if ( strcmp(pptr->scope,fptr->scope) != 0)
			return(0);
		}
	if (( fptr->session )
	&&  (strlen( fptr->session ) != 0)) {
		if (!( pptr->session ))
			return(0);
		else if ( strcmp(pptr->session,fptr->session) != 0)
			return(0);
		}
	if (( fptr->account )
	&&  (strlen( fptr->account ) != 0)) {
		if (!( pptr->account ))
			return(0);
		else if ( strcmp(pptr->account,fptr->account) != 0)
			return(0);
		}
	if (( fptr->monitor )
	&&  (strlen( fptr->monitor ) != 0)) {
		if (!( pptr->monitor ))
			return(0);
		else if ( strcmp(pptr->monitor,fptr->monitor) != 0)
			return(0);
		}
	if (( fptr->connection )
	&&  (strlen( fptr->connection ) != 0)) {
		if (!( pptr->connection ))
			return(0);
		else if ( strcmp(pptr->connection,fptr->connection) != 0)
			return(0);
		}
	if (( fptr->metric )
	&&  (strlen( fptr->metric ) != 0)) {
		if (!( pptr->metric ))
			return(0);
		else if ( strcmp(pptr->metric,fptr->metric) != 0)
			return(0);
		}
	if (( fptr->probe )
	&&  (strlen( fptr->probe ) != 0)) {
		if (!( pptr->probe ))
			return(0);
		else if ( strcmp(pptr->probe,fptr->probe) != 0)
			return(0);
		}
	if (( fptr->process ) && ( pptr->process != fptr->process )) return(0);
	if (( fptr->state ) && ( pptr->state != fptr->state )) return(0);
	return(1);
}

/*	----------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   r e s p o n s e 	*/
/*	----------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_occi_response(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,
	struct cords_control * pptr)
{
	struct rest_header * hptr;
	sprintf(cptr->buffer,"occi.core.id=%s",pptr->id);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.name=%s",optr->domain,optr->id,pptr->name);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.contract=%s",optr->domain,optr->id,pptr->contract);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.agreement=%s",optr->domain,optr->id,pptr->agreement);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.property=%s",optr->domain,optr->id,pptr->property);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.condition=%s",optr->domain,optr->id,pptr->condition);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.objective=%s",optr->domain,optr->id,pptr->objective);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.reference=%s",optr->domain,optr->id,pptr->reference);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.importance=%s",optr->domain,optr->id,pptr->importance);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.obligated=%s",optr->domain,optr->id,pptr->obligated);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.scope=%s",optr->domain,optr->id,pptr->scope);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.session=%s",optr->domain,optr->id,pptr->session);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.account=%s",optr->domain,optr->id,pptr->account);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.monitor=%s",optr->domain,optr->id,pptr->monitor);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.connection=%s",optr->domain,optr->id,pptr->connection);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.metric=%s",optr->domain,optr->id,pptr->metric);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.probe=%s",optr->domain,optr->id,pptr->probe);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.process=%u",optr->domain,optr->id,pptr->process);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.state=%u",optr->domain,optr->id,pptr->state);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	if ( occi_render_links( aptr, pptr->id ) != 0)
		return( rest_html_response( aptr, 500, "Server Link Failure" ) );
	else	if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	----------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   g e t   i t e m 	*/
/*	----------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_get_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr, char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	iptr = optr->callback;
	if (!( nptr = locate_cords_control_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	if (( iptr ) && (iptr->retrieve)) (*iptr->retrieve)(optr,nptr);
	autosave_cords_control_nodes();
	return( cords_control_occi_response(optr,cptr,rptr,aptr,pptr));
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t   l i n k 	*/
/*	------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_post_link(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	char * reqhost;
	if (!( nptr = locate_cords_control_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	--------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t   m i x i n 	*/
/*	--------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_post_mixin(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	char * reqhost;
	if (!( nptr = locate_cords_control_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	else	return( rest_html_response( aptr, 400, "Bad Request"));
}

/*	----------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t   a c t i o n 	*/
/*	----------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_post_action(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_action * fptr;
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	char * reqhost;
	char * mptr;
	if (!( nptr = locate_cords_control_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	mptr = (rptr->parameters+strlen("action="));
	for ( fptr=optr->firstact;
		fptr != (struct occi_action *) 0;
		fptr = fptr->next )
		if (!( strncmp( mptr, fptr->name, strlen( fptr->name )) ))
			return( occi_invoke_action(fptr,optr,cptr,rptr,aptr,pptr) );
	return( rest_html_response( aptr, 400, "Incorrect Action Request"));
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t   i t e m 	*/
/*	------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_post_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	char * reqhost;
	iptr = optr->callback;
	if (!( reqhost = rest_request_host( rptr ) ))
		return( rest_html_response( aptr, 400, "Bad Request" ) );
	if (!( nptr = add_cords_control_node(1)))
		return( rest_html_response( aptr, 500, "Server Failure") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 500, "Server Failure") );
	if (!( occi_process_atributs( optr, rptr,aptr, pptr, set_cords_control_field ) ))
		return( rest_html_response( aptr, 500, "Server Failure") );
	if (( iptr ) && (iptr->create)) (*iptr->create)(optr,nptr);
	autosave_cords_control_nodes();
	sprintf(cptr->buffer,"%s%s%s",reqhost,optr->location,pptr->id);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Location",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	else if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	----------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p u t   i t e m 	*/
/*	----------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_put_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	iptr = optr->callback;
	if (!( nptr = locate_cords_control_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	if (!( occi_process_atributs(optr,rptr,aptr, pptr, set_cords_control_field ) ))
		return( rest_html_response( aptr, 500, "Server Failure") );
	if (( iptr ) && (iptr->update)) (*iptr->update)(optr,nptr);
	autosave_cords_control_nodes();
	return( cords_control_occi_response(optr,cptr,rptr,aptr,pptr));
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   h e a d   i t e m 	*/
/*	------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_head_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	if (!( nptr = locate_cords_control_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	----------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   d e l e t e   i t e m 	*/
/*	----------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_delete_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr, char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_control * pptr;
	iptr = optr->callback;
	if (!( nptr = locate_cords_control_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	if (( iptr ) && (iptr->delete)) (*iptr->delete)(optr,nptr);
	drop_cords_control_node( nptr );
	autosave_cords_control_nodes();
	if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	----------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   g e t   l i s t 	*/
/*	----------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_get_list(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr)
{
	struct rest_header * hptr;
	struct occi_kind_node * sptr;
	struct cords_control * pptr;
	struct cords_control * fptr;
	char * reqhost;
	if (!( reqhost = rest_request_host( rptr ) ))
		return( rest_html_response( aptr, 400, "Bad Request" ) );
	else if (!( fptr = filter_cords_control_info( optr, rptr, aptr ) ))
		return( rest_html_response( aptr, 400, "Bad Request" ) );
	for ( sptr = cords_control_first;
		sptr != (struct occi_kind_node *) 0;
		sptr = sptr->next ) {
		if (!( pptr = sptr->contents ))
			continue;
		if (!( pass_cords_control_filter( pptr, fptr ) ))
			continue;
		sprintf(cptr->buffer,"%s%s%s",reqhost,optr->location,pptr->id);
		if (!( hptr = rest_response_header( aptr, "X-OCCI-Location",cptr->buffer) ))
			return( rest_html_response( aptr, 500, "Server Failure" ) );
		}
	if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	--------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   d e l e t e   a l l 	*/
/*	--------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_control_delete_all(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct occi_kind_node * sptr;
	struct cords_control * pptr;
	struct cords_control * fptr;
	iptr = optr->callback;
	if (!( fptr = filter_cords_control_info( optr, rptr, aptr ) ))
		return( rest_html_response( aptr, 400, "Bad Request" ) );
	nptr=cords_control_first;
	while (nptr != (struct occi_kind_node *) 0) {
		if ((!( pptr = nptr->contents ))
		||  (!( pass_cords_control_filter( pptr, fptr ) ))) {
			nptr = nptr->next;
			continue;
			}
		else	{
			if (( iptr ) && (iptr->delete)) { (*iptr->delete)(optr,nptr); }
			sptr = nptr->next;
			drop_cords_control_node( nptr );
			nptr = sptr;
			}
		}
	autosave_cords_control_nodes();
	if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   g e t 	*/
/*	------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_control_get(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!(strcmp( rptr->object, optr->location ) ))
		return( cords_control_get_list( optr, cptr, rptr, aptr ) );
	else if (!(strncmp( rptr->object, optr->location, strlen(optr->location) ) ))
		return( cords_control_get_item( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	--------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   h e a d 	*/
/*	--------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_control_head(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!(strncmp( rptr->object, optr->location, strlen(optr->location) ) ))
		return( cords_control_head_item( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	--------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t 	*/
/*	--------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_control_post(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!( strcmp( rptr->object, optr->location ) ))
		return( cords_control_post_item( optr, cptr, rptr, aptr ) );
	else if ( strncmp( rptr->object, optr->location,strlen(optr->location)) != 0)
		return( rest_html_response( aptr, 400, "Bad Request") );
	else if (!( rptr->parameters ))
		return( rest_html_response( aptr, 400, "Bad Request") );
	else if (!( strncmp( rptr->parameters, "action=", strlen("action=")) ))
		return( cords_control_post_action( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else if (!( strncmp( rptr->parameters, "mixin=", strlen("mixin=")) ))
		return( cords_control_post_mixin( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else if (!( strncmp( rptr->parameters, "link=", strlen("link=")) ))
		return( cords_control_post_link( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p u t 	*/
/*	------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_control_put(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!(strncmp( rptr->object, optr->location, strlen(optr->location) ) ))
		return( cords_control_put_item( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   d e l e t e 	*/
/*	------------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_control_delete(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!(strcmp( rptr->object, optr->location ) ))
		return( cords_control_delete_all( optr, cptr, rptr, aptr ) );
	else if (!(strncmp( rptr->object, optr->location, strlen(optr->location) ) ))
		return( cords_control_delete_item( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	--------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   r e d i r e c t i o n 	*/
/*	--------------------------------------------------------------------------------	*/
private void	redirect_occi_cords_control_mt( struct rest_interface * iptr )
{
	iptr->get = occi_cords_control_get;
	iptr->post = occi_cords_control_post;
	iptr->put = occi_cords_control_put;
	iptr->delete = occi_cords_control_delete;
	iptr->head = occi_cords_control_head;
	return;
}

/*	------------------------------------	*/
/*	c r u d   d e l e t e   a c t i o n 	*/
/*	------------------------------------	*/
private struct rest_response * delete_action_cords_control(struct occi_category * optr,
struct rest_client * cptr,
struct rest_request * rptr,
struct rest_response * aptr,
void * vptr )
{
	aptr = liberate_rest_response( aptr );
	return( occi_cords_control_delete(optr,cptr,rptr));
}

/*	------------------------------------------	*/
/*	o c c i   c a t e g o r y   b u i l d e r 	*/
/*	------------------------------------------	*/
/* occi category rest instance builder for : occi_cords_control */
public struct occi_category * occi_cords_control_builder(char * a,char * b) {
	char * c="http://scheme.compatibleone.fr/scheme/compatible#";
	char * d="kind";
	char * e="http://scheme.ogf.org/occi/resource#";
	char * f="CompatibleOne OCCI resource cords_control";
	struct occi_category * optr;
	if (!( optr = occi_create_category(a,b,c,d,e,f) )) { return(optr); }
	else {
		redirect_occi_cords_control_mt(optr->interface);
		if (!( optr = occi_add_attribute(optr, "name",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "contract",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "agreement",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "property",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "condition",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "objective",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "reference",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "importance",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "obligated",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "scope",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "session",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "account",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "monitor",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "connection",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "metric",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "probe",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "process",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "state",0,0) ))
			return(optr);
		if (!( optr = occi_add_action( optr,"DELETE","",delete_action_cords_control)))
			return( optr );
		autoload_cords_control_nodes();
		return(optr);
	}

}

/*	----------------------------------------------------	*/
/*	c o r d s _ c o n t r o l _ o c c i _ h e a d e r s 	*/
/*	----------------------------------------------------	*/
public struct rest_header *  cords_control_occi_headers(struct cords_control * sptr)
{
	struct rest_header * first=(struct rest_header *) 0;
	struct rest_header * last=(struct rest_header *) 0;
	struct rest_header * hptr=(struct rest_header *) 0;
	char buffer[8192];
	if (!( sptr )) return(0);
	if (!( hptr = allocate_rest_header()))
		return(hptr);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("Category")))
		return(first);
	sprintf(buffer,"cords_control; scheme='http://scheme.compatibleone.fr/scheme/compatible#'; class='kind';\r\n");
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.name='%s'\r\n",(sptr->name?sptr->name:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.contract='%s'\r\n",(sptr->contract?sptr->contract:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.agreement='%s'\r\n",(sptr->agreement?sptr->agreement:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.property='%s'\r\n",(sptr->property?sptr->property:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.condition='%s'\r\n",(sptr->condition?sptr->condition:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.objective='%s'\r\n",(sptr->objective?sptr->objective:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.reference='%s'\r\n",(sptr->reference?sptr->reference:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.importance='%s'\r\n",(sptr->importance?sptr->importance:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.obligated='%s'\r\n",(sptr->obligated?sptr->obligated:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.scope='%s'\r\n",(sptr->scope?sptr->scope:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.session='%s'\r\n",(sptr->session?sptr->session:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.account='%s'\r\n",(sptr->account?sptr->account:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.monitor='%s'\r\n",(sptr->monitor?sptr->monitor:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.connection='%s'\r\n",(sptr->connection?sptr->connection:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.metric='%s'\r\n",(sptr->metric?sptr->metric:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.probe='%s'\r\n",(sptr->probe?sptr->probe:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.process='%u'\r\n",sptr->process);
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_control.state='%u'\r\n",sptr->state);
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	return(first);

}

#endif	/* _occicontrol_c_ */


text:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Blog1729 - Trading Strategies Involving options</title>
        <link rel="stylesheet" type="text/css" href="../css/default.css" />

                Blog1729

                Home
                About
                Contact
                Archive

Trading Strategies Involving options

    Posted on April 13, 2015

If a portfolio consists of a long position in a stock plus a short position in a call option, then this is known as writing a covered call. The long stock position covers or protects the investor from payoff on the short call that becomes necessary if there is a sharp rise in the stock price.

A spread trading strategy involves taking a position in two or more options of the same type (i.e., two or more calls or two or more puts).

Bull Spreads

Image courtesy: https://upload.wikimedia.org/wikipedia/commons/thumb/0/06/Bull_spread_using_calls.png/300px-Bull_spread_using_calls.png

The above diagram represents what the profit function of a Bull spread looks like.

One can construct a bull spread using Call options.

Long a call option with strike price \(K_2\),

Short a call option with strike price \(K1 < K_2\). (Note: Since \(K_1<K_2\), \(C_E(K_1)>C_E(K_2)\).

The Bull spread strategy limits the investors upside as well as downside risk.

One can also construct the bull spread using two put options in a similar way.

An investor who enters into a bull spread is hoping that the stock price will increase.

Bear Spreads

Image courtesy: https://upload.wikimedia.org/wikipedia/commons/0/0f/Bear_spread_using_puts.png

The above diagram represents the profit function of a Bear spread.

An investor who enters into a bear spread is hoping that the stock price will decrease.

One can construct a bear spread using two put options

Long a put option with strike price \(K_2\)

Short a call option with strike price \(K_1<K_2\). (Note: Since \(K_2<K_2\), \(P_E(K_1)<P_E(K_2)\))

Box spread

Box spread is a combination of bull call spread with strike price \(K_1\) and \(K_2\) and bear call spread with the same strike prices. The payoff of a box spread is always going to be \(K_2 - K_1\).

Butterfly spreads

Image courtesy: https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Butterfly_spread_with_calls.png/400px-Butterfly_spread_with_calls.png

The above diagram represents the profit function in a Butterfly spread.

A butterfly spread involves positions of options in three different strike prices.

The butterfly spread can be modelled with the help of following strategy

A long call option at strike price \(K_1\)

Two short call option at strike price \(K_1 < K_2\)

A long call option at strike price \(K_3\) (Note: Since \(K_1 < K_2 < K_3\), \(C_E(K_1)>C_E(K_2)>C_E(K_3)\), also one may choose \(K_2 = (K_1+K_3)/2\))

The butterfly spread is usually used when the investor thinks that the stock price is going to be relatively stable.

Note: Using the put call parity, one can easily convert spreads modelled via calls into puts and vice-versa.

References. Chapter 10, Trading strategies involving options, Options futures and other derivatives 7ed; John C. Hull.

            Site proudly generated by
            Hakyll


text:
namespace CodeGenerator.Example
{
    using System;
    using System.Collections.Generic;

    public partial class News
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Author { get; set; }
        public string Source { get; set; }
        public string Content { get; set; }
        public bool IsVisible { get; set; }
        public bool IsDeleted { get; set; }
        public Nullable<System.DateTime> DeletedOn { get; set; }
        public System.DateTime CreatedOn { get; set; }
        public Nullable<System.DateTime> ModifiedOn { get; set; }
    }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Bull. mens. Soc. linn. Lyon 43(Num. spec. ): 216 (1974)

#### Original name
Lepiota jubilaei Joss.

### Remarks
null


text:
package android.support.v4.media.session;

import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.media.AudioManager;
import android.media.RemoteControlClient;
import android.util.Log;
import android.os.SystemClock;

class MediaSessionCompatApi18 {
    private static final String TAG = "MediaSessionCompatApi18";

    /***** PlaybackState actions *****/
    private static final long ACTION_SEEK_TO = 1 << 8;

    private static boolean sIsMbrPendingIntentSupported = true;

    public static Object createPlaybackPositionUpdateListener(Callback callback) {
        return new OnPlaybackPositionUpdateListener<Callback>(callback);
    }

    public static void registerMediaButtonEventReceiver(Context context, PendingIntent pi,
            ComponentName cn) {
        AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

        // Some Android implementations are not able to register a media button event receiver
        // using a PendingIntent but need a ComponentName instead. These will raise a
        // NullPointerException.
        if (sIsMbrPendingIntentSupported) {
            try {
                am.registerMediaButtonEventReceiver(pi);
            } catch (NullPointerException e) {
                Log.w(TAG, "Unable to register media button event receiver with "
                        + "PendingIntent, falling back to ComponentName.");
                sIsMbrPendingIntentSupported = false;
            }
        }

        if (!sIsMbrPendingIntentSupported) {
          am.registerMediaButtonEventReceiver(cn);
        }
    }

    public static void unregisterMediaButtonEventReceiver(Context context, PendingIntent pi,
            ComponentName cn) {
        AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        if (sIsMbrPendingIntentSupported) {
            am.unregisterMediaButtonEventReceiver(pi);
        } else {
            am.unregisterMediaButtonEventReceiver(cn);
        }
    }

    public static void setState(Object rccObj, int state, long position, float speed,
            long updateTime) {
        long currTime = SystemClock.elapsedRealtime();
        if (state == MediaSessionCompatApi14.STATE_PLAYING && position > 0) {
            long diff = 0;
            if (updateTime > 0) {
                diff = currTime - updateTime;
                if (speed > 0 && speed != 1f) {
                    diff *= speed;
                }
            }
            position += diff;
        }
        state = MediaSessionCompatApi14.getRccStateFromState(state);
        ((RemoteControlClient) rccObj).setPlaybackState(state, position, speed);
    }

    public static void setTransportControlFlags(Object rccObj, long actions) {
        ((RemoteControlClient) rccObj).setTransportControlFlags(
                getRccTransportControlFlagsFromActions(actions));
    }

    public static void setOnPlaybackPositionUpdateListener(Object rccObj,
            Object onPositionUpdateObj) {
        ((RemoteControlClient) rccObj).setPlaybackPositionUpdateListener(
                (RemoteControlClient.OnPlaybackPositionUpdateListener) onPositionUpdateObj);
    }

    static int getRccTransportControlFlagsFromActions(long actions) {
        int transportControlFlags =
                MediaSessionCompatApi14.getRccTransportControlFlagsFromActions(actions);
        if ((actions & ACTION_SEEK_TO) != 0) {
            transportControlFlags |= RemoteControlClient.FLAG_KEY_MEDIA_POSITION_UPDATE;
        }
        return transportControlFlags;
    }

    static class OnPlaybackPositionUpdateListener<T extends Callback>
            implements RemoteControlClient.OnPlaybackPositionUpdateListener {
        protected final T mCallback;

        public OnPlaybackPositionUpdateListener(T callback) {
            mCallback = callback;
        }

        @Override
        public void onPlaybackPositionUpdate(long newPositionMs) {
            mCallback.onSeekTo(newPositionMs);
        }
    }

    interface Callback {
        public void onSeekTo(long pos);
    }
}


text:
/* This file was generated by upbc (the upb compiler) from the input
 * file:
 *
 *     envoy/config/trace/v3/opencensus.proto
 *
 * Do not edit -- your changes will be discarded when the file is
 * regenerated. */

#ifndef ENVOY_CONFIG_TRACE_V3_OPENCENSUS_PROTO_UPBDEFS_H_
#define ENVOY_CONFIG_TRACE_V3_OPENCENSUS_PROTO_UPBDEFS_H_

#include "upb/def.h"
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif

#include "upb/def.h"

#include "upb/port_def.inc"

extern _upb_DefPool_Init envoy_config_trace_v3_opencensus_proto_upbdefinit;

UPB_INLINE const upb_MessageDef *envoy_config_trace_v3_OpenCensusConfig_getmsgdef(upb_DefPool *s) {
  _upb_DefPool_LoadDefInit(s, &envoy_config_trace_v3_opencensus_proto_upbdefinit);
  return upb_DefPool_FindMessageByName(s, "envoy.config.trace.v3.OpenCensusConfig");
}

#ifdef __cplusplus
}  /* extern "C" */
#endif

#include "upb/port_undef.inc"

#endif  /* ENVOY_CONFIG_TRACE_V3_OPENCENSUS_PROTO_UPBDEFS_H_ */


text:
<?php

namespace app\modules\Admin\Course\controllers;
use app\modules\AppBase\base\appbase\BaseController;
use app\modules\AppBase\base\HintConst;
use Yii;
use yii\db\Query;

class CourseController extends BaseController{

    /**
     * 保存和更新课程表条目
     * @return string
     * @throws \yii\db\Exception
     */
    public function actionSave(){
        $id = Yii::$app->request->post('id',0);
        $week = Yii::$app->request->post('week',0);
        $type = Yii::$app->request->post('type',0);
        $section = Yii::$app->request->post('section',0);
        $text = Yii::$app->request->post('text',0);
        $class_id = Yii::$app->request->post('class_id',Yii::$app->session['custominfo']->custom->class_id);

        if($week<1 || $week >7){
            return json_encode(['ErrCode'=>HintConst::$ParmaWrong,'Message'=>'week error']);
        }
        if($type != 0 && $type != 1 && $type != 2){
            return json_encode(['ErrCode'=>HintConst::$ParmaWrong,'Message'=>'type error']);
        }

        $query = new Query();
        $exist = $query->select('*')->from('course')->where([
            'class_id'=>$class_id,
            'week'=>$week,
            'type'=>$type,
            'section'=>$section
        ])->one();

        $connection = Yii::$app->db;
        if($exist){
            $n = $connection->createCommand()->update('course',[
                'text'=>$text,
                'update_time'=>time()
            ],['id'=>$id])->execute();
            if($n > 0)
                return json_encode(['ErrCode'=>0,'Content'=>$id]);
            else
                return json_encode(['ErrCode'=>HintConst::$DATA_NOT_FOUND,'Message'=>'not found']);
        }
        $now = time();
        $connection->createCommand()->insert('course',[
            'class_id'=>$class_id,
            'week'=>$week,
            'type'=>$type,
            'section'=>$section,
            'text'=>$text,
            'create_time'=>$now,
            'update_time'=>$now
        ])->execute();

        $new_id = $connection->getLastInsertID();
        return json_encode(['ErrCode'=>0,'Content'=>$new_id]);
    }

    /**
     * 删除课程表条目
     * @return string
     * @throws \yii\db\Exception
     */
    public function actionDel(){
        $id = Yii::$app->request->post('id',0);
        $query = new Query();
        $exist = $query->select('*')->from('course')->where(['id'=>$id])->one();
        if(!$exist){
            return json_encode(['ErrCode'=>HintConst::$DATA_NOT_FOUND,'Message'=>'not found']);
        }

        if(Yii::$app->session['custominfo']->custom->cat_default_id != HintConst::$ROLE_TEACHER
            || $exist['class_id'] != Yii::$app->session['custominfo']->custom->class_id){
            return json_encode(['ErrCode'=>HintConst::$NO_PERMISION,'Message'=>'no permission']);
        }
        $connection = Yii::$app->db;
        $connection->createCommand()->delete('course',['id'=>$id])->execute();
        return json_encode(['ErrCode'=>0]);
    }

    /**
     * 班级一周全部课程表
     * @return string
     */
    public function actionTable(){
        $class_id = Yii::$app->request->get('class_id',Yii::$app->session['custominfo']->custom->class_id);

        $query = new Query();
        $list = $query->select('*')->from('course')->where(['class_id'=>$class_id])->all();
        return json_encode(['ErrCode'=>0,'Content'=>$list]);
    }

    /**
     * 班级一天课程表
     * @return string
     */
    public function actionWeek(){
        $week = Yii::$app->request->get('week',0);
        $class_id = Yii::$app->request->get('class_id',Yii::$app->session['custominfo']->custom->class_id);
        $query = new Query();
        $list = $query->select('*')->from('course')->where([
            'class_id'=>$class_id,
            'week'=>$week
        ])->all();
        return json_encode(['ErrCode'=>0,'Content'=>$list]);
    }

}


text:
package org.elasticsearch.search.aggregations.metrics.valuecount;

import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.common.inject.internal.Nullable;
import org.elasticsearch.common.lease.Releasables;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.LongArray;
import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
import org.elasticsearch.search.aggregations.Aggregator;
import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.LeafBucketCollector;
import org.elasticsearch.search.aggregations.LeafBucketCollectorBase;
import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.support.AggregationContext;
import org.elasticsearch.search.aggregations.support.ValuesSource;
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * A field data based aggregator that counts the number of values a specific field has within the aggregation context.
 *
 * This aggregator works in a multi-bucket mode, that is, when serves as a sub-aggregator, a single aggregator instance aggregates the
 * counts for all buckets owned by the parent aggregator)
 */
public class ValueCountAggregator extends NumericMetricsAggregator.SingleValue {

    final ValuesSource valuesSource;
    final ValueFormatter formatter;

    // a count per bucket
    LongArray counts;

    public ValueCountAggregator(String name, ValuesSource valuesSource, @Nullable ValueFormatter formatter,
            AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators,
            Map<String, Object> metaData)
            throws IOException {
        super(name, aggregationContext, parent, pipelineAggregators, metaData);
        this.valuesSource = valuesSource;
        this.formatter = formatter;
        if (valuesSource != null) {
            counts = context.bigArrays().newLongArray(1, true);
        }
    }

    @Override
    public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
            final LeafBucketCollector sub) throws IOException {
        if (valuesSource == null) {
            return LeafBucketCollector.NO_OP_COLLECTOR;
        }
        final BigArrays bigArrays = context.bigArrays();
        final SortedBinaryDocValues values = valuesSource.bytesValues(ctx);
        return new LeafBucketCollectorBase(sub, values) {

            @Override
            public void collect(int doc, long bucket) throws IOException {
                counts = bigArrays.grow(counts, bucket + 1);
                values.setDocument(doc);
                counts.increment(bucket, values.count());
            }

        };
    }

    @Override
    public double metric(long owningBucketOrd) {
        return valuesSource == null ? 0 : counts.get(owningBucketOrd);
    }

    @Override
    public InternalAggregation buildAggregation(long bucket) {
        if (valuesSource == null || bucket >= counts.size()) {
            return buildEmptyAggregation();
        }
        return new InternalValueCount(name, counts.get(bucket), formatter, pipelineAggregators(), metaData());
    }

    @Override
    public InternalAggregation buildEmptyAggregation() {
        return new InternalValueCount(name, 0l, formatter, pipelineAggregators(), metaData());
    }

    @Override
    public void doClose() {
        Releasables.close(counts);
    }

    public static class Factory<VS extends ValuesSource> extends ValuesSourceAggregatorFactory.LeafOnly<VS> {

        public Factory(String name, ValuesSourceConfig<VS> config) {
            super(name, InternalValueCount.TYPE.name(), config);
        }

        @Override
        protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent,
                List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {
            return new ValueCountAggregator(name, null, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData);
        }

        @Override
        protected Aggregator doCreateInternal(VS valuesSource, AggregationContext aggregationContext, Aggregator parent,
                boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData)
                throws IOException {
            return new ValueCountAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, pipelineAggregators,
                    metaData);
        }

    }

}


text:
<?php

namespace Wesnick\Infusionsoft\Proxy;

use Wesnick\Infusionsoft\Remote\BaseObject;

/**
 * class CProgram
 * Continuity Programs
 * SubscriptionPlan
 * INNER JOIN Product ON Product.Id=SubscriptionPlan.ProductId
 */
class CProgram extends BaseObject
{

    /**
     * Id
     *
     * @var int $Id
     */
    public $Id;
    /**
     * String
     *
     * @var string $ProgramName
     */
    public $ProgramName;
    /**
     * Double
     *
     * @var float $DefaultPrice
     */
    public $DefaultPrice;
    /**
     * String
     *
     * @var string $DefaultCycle
     */
    public $DefaultCycle;
    /**
     * Integer
     *
     * @var string $DefaultFrequency
     */
    public $DefaultFrequency;
    /**
     * String
     *
     * @var string $Sku
     */
    public $Sku;
    /**
     * String
     *
     * @var string $ShortDescription
     */
    public $ShortDescription;
    /**
     * String
     *
     * @var string $BillingType
     */
    public $BillingType;
    /**
     * String
     *
     * @var string $Description
     */
    public $Description;
    /**
     * Integer
     *
     * @var string $HideInStore
     */
    public $HideInStore;
    /**
     * Integer
     *
     * @var string $Status
     */
    public $Status;
    /**
     * Boolean
     *
     * @var bool $Active
     */
    public $Active;
    /**
     * Blob
     *
     * @var string $LargeImage
     */
    public $LargeImage;
    /**
     * Integer
     *
     * @var string $Taxable
     */
    public $Taxable;
    /**
     * String
     *
     * @var string $Family
     */
    public $Family;
    /**
     * Id
     *
     * @var int $ProductId
     */
    public $ProductId;
    /**
     * @var array $propertyMap
     */
    protected static $propertyMap = array('Id' => 'int', 'ProgramName' => 'string', 'DefaultPrice' => 'float', 'DefaultCycle' => 'string', 'DefaultFrequency' => 'string', 'Sku' => 'string', 'ShortDescription' => 'string', 'BillingType' => 'string', 'Description' => 'string', 'HideInStore' => 'string', 'Status' => 'string', 'Active' => 'bool', 'LargeImage' => 'string', 'Taxable' => 'string', 'Family' => 'string', 'ProductId' => 'int');

}


text:
/**
 * @author Anas Nashif
 * @author Eugene Yarmosh
 */
#ifndef XML_BINDING_LIBXML2_H_
#define XML_BINDING_LIBXML2_H_

struct __internalWsNode {
	char *valText;
};
typedef struct __internalWsNode iWsNode;

void xml_parser_initialize(void);

void xml_parser_destroy(void);

int xml_parser_create_doc(WsXmlDocH Doc, const char *rootName);

void xml_parser_destroy_doc(WsXmlDocH Doc);

WsXmlDocH xml_parser_get_doc(WsXmlNodeH node);

WsXmlNodeH xml_parser_get_root(WsXmlDocH doc);

WsXmlDocH xml_parser_memory_to_doc( const char *buf, size_t size,
				   const char *encoding,
				   unsigned long options);

char *xml_parser_node_query(WsXmlNodeH node, int what);

int xml_parser_node_set(WsXmlNodeH node, int what, const char *str);

WsXmlNodeH xml_parser_node_get(WsXmlNodeH node, int which);

WsXmlNsH xml_parser_ns_find(WsXmlNodeH node, const char *uri,
			    const char *prefix, int bWalkUpTree,
			    int bAddAtRootIfNotFound);

char *xml_parser_ns_query(WsXmlNsH ns, int what);

WsXmlNsH xml_parser_ns_add(WsXmlNodeH node, const char *uri,
			   const char *prefix);

int xml_parser_ns_remove(WsXmlNodeH node, const char *nsUri);

WsXmlNsH xml_parser_ns_get(WsXmlNodeH node, int which);

int xml_parser_get_count(WsXmlNodeH node, int what, int bWalkUpTree);

WsXmlNodeH xml_parser_node_add(WsXmlNodeH base, int where,
			       const char *nsUri, const char *localName,
			       const char *value, int xmlescape);

int xml_parser_node_remove(WsXmlNodeH node);

WsXmlAttrH xml_parser_attr_add(WsXmlNodeH node, const char *uri,
			       const char *name, const char *value);

int xml_parser_attr_remove(WsXmlAttrH attr);

WsXmlDocH xml_parser_file_to_doc( const char *filename,
				 const char *encoding,
				 unsigned long options);

char *xml_parser_attr_query(WsXmlAttrH attr, int what);

WsXmlAttrH xml_parser_attr_get(WsXmlNodeH node, int which);

void xml_parser_free_memory(void *ptr);

void xml_parser_doc_to_memory(WsXmlDocH doc, char **buf,
			      int *ptrSize, const char *encoding);

void xml_parser_doc_dump(FILE * f, WsXmlDocH doc);

void xml_parser_doc_dump_memory(WsXmlDocH doc, char **buf, int *ptrSize);

void xml_parser_doc_dump_memory_enc(WsXmlDocH doc, char **buf, int *ptrSize, const char *encoding);

void xml_parser_element_dump(FILE * f, WsXmlDocH doc, WsXmlNodeH node);

int xml_parser_check_xpath(WsXmlDocH doc, const char *xpath_expr);

int xml_parser_utf8_strlen(char *buf);

char *xml_parser_get_xpath_value(WsXmlDocH doc, const char *expression);

int xml_parser_create_doc_by_import(WsXmlDocH wsDoc, WsXmlNodeH node);

void xml_parser_unlink_node(WsXmlNodeH node);

void xml_parser_set_ns(WsXmlNodeH r, WsXmlNsH ns, const char* prefix);
void xml_parser_node_set_lang(WsXmlNodeH node,  const char *lang);

void xml_parser_copy_node(WsXmlNodeH src, WsXmlNodeH dst);

#endif				/*XML_BINDING_LIBXML2_H_ */


text:
@cd %~dp0
@cd ..
call heroku logs --tail | node -e process.stdin.pipe(process.stdout);
pause


text:
package com.jfehr.jug.iot.simulator;

import java.io.IOException;
import java.io.InputStream;
import java.net.BindException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Arrays;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfehr.jug.iot.mediator.RemoteBoardCommandEnum;

/**
 * This class was originally intended to be a stand-in for a remote arduino board during integration testing.  However,
 * it has evolved to being used for regular development and shakeout testing.  It's been cobbled together to approximate
 * the functionality of an arduino.  Translation: the code might get ugly.
 */
public class ArduinoSimulator extends Thread {

	private static final Logger LOGGER = LoggerFactory.getLogger(ArduinoSimulator.class);
	private static final int BIND_PORT = 51420;

	private final Integer listenPort;

	public ArduinoSimulator(Integer listenPort) {
		this.listenPort = listenPort;
	}

	@Override
	public void run() {
		ServerSocket socket = null;

		try{
			Socket client;
			InputStream is;
			byte command;
			int numDataBytes = -1;
			int numResponseBytes = -1;
			byte[] input;
			int readCount;

			LOGGER.debug("attempting to open a listening {} on port {}", ServerSocket.class.getSimpleName(), this.listenPort);
			socket = new ServerSocket(51420);
			LOGGER.debug("listening on port {}", this.listenPort);

			client = socket.accept();
			LOGGER.info("succesfully established communication with {}", ((InetSocketAddress) client.getRemoteSocketAddress()).getHostString());
			is = client.getInputStream();

			//identify which command was sent
			command = (byte)is.read();
			LOGGER.debug("got command [{}]", command);
			for(RemoteBoardCommandEnum e : RemoteBoardCommandEnum.values()){
				if(e.getCommandNumber().byteValue() == command){
					numDataBytes = e.getNumberOfDataBytes();
					numResponseBytes = e.getNumberOfResponseBytes();
					break;
				}
			}

			if(numDataBytes == -1 || numResponseBytes == -1){
				throw new SimulatorException("could not identify command with number [" + command + "]");
			}

			//read the input data bytes
			Thread.sleep(500); //TODO fix this cheater way of ensuring all bytes are received
			input = new byte[numDataBytes];
			readCount = is.read(input);
			if(readCount != numDataBytes){
				throw new SimulatorException("expected [" + numDataBytes + "] but only read [" + readCount + "]");
			}
			LOGGER.debug("received [{}] data bytes: {}", readCount, Arrays.toString(input));

			//write back dummy bytes starting with the command byte
			LOGGER.debug("writing to output stream");
			client.getOutputStream().write(command);
			Thread.sleep(500); //sleep to simulate network delay
			for(int i=1; i<numResponseBytes; i++){
				client.getOutputStream().write(i);
			}
			client.getOutputStream().flush();
		}catch(IOException e) {
			SimulatorException simEx = new SimulatorException(e);

			LOGGER.error("failed to communicate with the client", simEx);

			throw simEx;
		}catch(InterruptedException e){
			throw new SimulatorException(e);
		}finally{
			if(socket != null){
				try {
					LOGGER.debug("attempting to close the connection");
					socket.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				LOGGER.info("connection successfully closed");
			}
		}
	}

	public static void main(String[] args) {
		while(true){
			try{
				ArduinoSimulator sim = new ArduinoSimulator(BIND_PORT);
				sim.run();
				sim.join();
			}catch(Exception e){
				if (e.getCause() instanceof BindException){
					System.err.println("Could not open socket on port " + BIND_PORT);
					System.err.println("Shutting down");
					e.printStackTrace();
					return;
				}else{
					e.printStackTrace();
				}
			}
		}
	}

}


text:
namespace mstsc.Aries.Antis
{
sealed class Sandbox
    {
        public Sandbox()
        {
            System.Security.Principal.WindowsPrincipal wp = new
                System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent());

            CheckProcess proc = new CheckProcess();
            if ((Util.GetModuleHandle("SbieDll.dll").ToInt32() != 0)
                         || (proc.IsProcessRunning("npfmsg"))
                        || (Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\", false)
                        .GetValue("ProductID").ToString() == "76487-640-1457236-23837")
                        || (System.Windows.Forms.Application.StartupPath == "C:\\analyzer\\scan") ||
                        (proc.IsProcessRunning("joeboxserver")) || (proc.IsProcessRunning("joeboxcontrol")) ||
                        (wp.Identity.Name == "HANS\\Hanuele Baser") ||
                        (wp.Identity.Name == "Sepp-PC\\Sepp") ||
                        (wp.Identity.Name == "John-PC\\John"))
            {
                new AntiFound();
            }
            //System.GC.Collect();
        }
    }
}


text:
package me.wener.telletsj.neo;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

public class MapDelegater<K, V> implements Map<K, V>
{
    protected Map<K, V> internal;

    public MapDelegater(Map<K, V> internal)
    {
        this.internal = internal;
    }

    @Override
    public int size() {return internal.size();}

    @Override
    public boolean isEmpty() {return internal.isEmpty();}

    @Override
    public boolean containsKey(Object key) {return internal.containsKey(key);}

    @Override
    public boolean containsValue(Object value) {return internal.containsValue(value);}

    @Override
    public V get(Object key) {return internal.get(key);}

    @Override
    public V put(K key, V value) {return internal.put(key, value);}

    @Override
    public V remove(Object key) {return internal.remove(key);}

    @Override
    public void putAll(Map<? extends K, ? extends V> m) {internal.putAll(m);}

    @Override
    public void clear() {internal.clear();}

    @Override
    public Set<K> keySet() {return internal.keySet();}

    @Override
    public Collection<V> values() {return internal.values();}

    @Override
    public Set<Entry<K, V>> entrySet() {return internal.entrySet();}

    @Override
    public boolean equals(Object o) {return internal.equals(o);}

    @Override
    public int hashCode() {return internal.hashCode();}
}


text:
import logging

from pywps import ComplexInput, ComplexOutput
from pywps import Format
from pywps import LiteralInput
from pywps import Process
from pywps.app.Common import Metadata
from pywps.ext_autodoc import MetadataUrl

from flyingpigeon import plt_ncdata
from flyingpigeon.utils import extract_archive
from flyingpigeon.nc_utils import get_variable
# from flyingpigeon.utils import rename_complexinputs
# from flyingpigeon.log import init_process_logger

LOGGER = logging.getLogger("PYWPS")

class PlottimeseriesProcess(Process):
    def __init__(self):
        inputs = [
            ComplexInput('resource', 'Resource',
                         abstract='NetCDF Files or archive (tar/zip) containing NetCDF files.',
                         metadata=[Metadata('Info')],
                         min_occurs=1,
                         max_occurs=1000,
                         supported_formats=[
                             Format('application/x-netcdf'),
                             Format('application/x-tar'),
                             Format('application/zip'),
                         ]),

            LiteralInput("variable", "Variable",
                         abstract="Variable to be expected in the input files (variable will be detected if not set)",
                         default=None,
                         data_type='string',
                         min_occurs=0,
                         max_occurs=1,
                         ),
        ]

        outputs = [
            # ComplexOutput('output_log', 'Logging information',
            #               abstract="Collected logs during process run.",
            #               as_reference=True,
            #               supported_formats=[Format('text/plain')]
            #               ),

            ComplexOutput("plotout_spagetti", "Visualisation, Spaghetti plot",
                          abstract="Visualisation of single variables as a spaghetti plot",
                          supported_formats=[Format("image/png")],
                          as_reference=True,
                          ),

            ComplexOutput("plotout_uncertainty", "Visualisation Uncertainty plot",
                          abstract="Visualisation of single variables ensemble mean with uncertainty",
                          supported_formats=[Format("image/png")],
                          as_reference=True,
                          )
        ]

        super(PlottimeseriesProcess, self).__init__(
            self._handler,
            identifier="plot_timeseries",
            title="Graphics (timeseries)",
            version="0.11",
            metadata=[
                MetadataUrl('Doc',
                            'https://flyingpigeon.readthedocs.io/en/latest/processes_des.html#data-visualization',
                            anonymous=True),
            ],
            abstract="Outputs some timeseries of the file field means. Spaghetti and uncertainty plot",
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True,
        )

    def _handler(self, request, response):
        # init_process_logger('log.txt')
        # response.outputs['output_log'].file = 'log.txt'

        ncfiles = extract_archive(
            resources=[inpt.file for inpt in request.inputs['resource']],
            dir_output=self.workdir)

        if 'variable' in request.inputs:
            var = request.inputs['variable'][0].data
        else:
            var = get_variable(ncfiles[0])
            #  var = ncfiles[0].split("_")[0]

        response.update_status('plotting variable {}'.format(var), 10)

        try:
            plotout_spagetti_file = plt_ncdata.plot_ts_spaghetti(ncfiles,
                                                                 variable=var,
                                                                 title='Field mean of {}'.format(var),
                                                                 dir_output=self.workdir)
            LOGGER.info("spagetti plot done")
            response.update_status('Spagetti plot for %s %s files done' % (len(ncfiles), var), 50)
            response.outputs['plotout_spagetti'].file = plotout_spagetti_file
        except Exception as e:
            raise Exception("spagetti plot failed : {}".format(e))

        try:
            plotout_uncertainty_file = plt_ncdata.plot_ts_uncertainty(ncfiles,
                                                                      variable=var,
                                                                      title='Ensemble uncertainty for {}'.format(var),
                                                                      dir_output=self.workdir)

            response.update_status('Uncertainty plot for {} {} files done'.format(len(ncfiles), var), 90)
            response.outputs['plotout_uncertainty'].file = plotout_uncertainty_file
            LOGGER.info("uncertainty plot done")
        except Exception as err:
            raise Exception("uncertainty plot failed {}".format(err.message))

        response.update_status('visualisation done', 100)
        return response


text:
typedef void *MidiDevice;

// Listeners inherit from this. Pass them into MidiInStart.
class MidiListener
{
public:
  virtual ~MidiListener() {}
  virtual void midiEvent(const uint8_t *cmd) = 0;
};

// Gets the names of the devices in a vector. The device identifier is the index in the vector.
std::vector<std::string> MidiInGetDevices();

MidiDevice MidiInStart(int deviceID, MidiListener *listener);
void MidiInStop(MidiDevice device);