<?xml version="1.0"?>
<!DOCTYPE resource-action-mapping PUBLIC "-//Liferay//DTD Resource Action Mapping 6.2.0//EN" "http://www.liferay.com/dtd/liferay-resource-action-mapping_6_2_0.dtd">

<resource-action-mapping>
	<model-resource>
		<model-name>org.oep.dossiermgt.model.PaymentFile</model-name>
		<portlet-ref>
			<portlet-name>oep-core-dossiermgt</portlet-name>
		</portlet-ref>
		<weight>2</weight>
		<permissions>
			<supports>
				<action-key>CREATE_PAYMENTFILE</action-key>
				<action-key>PERMISSIONS</action-key>
				<action-key>UPDATE_PAYMENTFILE</action-key>
			</supports>
			<site-member-defaults>
				<action-key>CREATE_PAYMENTFILE</action-key>
			</site-member-defaults>
			<guest-defaults />
			<guest-unsupported>
				<action-key>PERMISSIONS</action-key>
				<action-key>UPDATE_PAYMENTFILE</action-key>
			</guest-unsupported>
		</permissions>
	</model-resource>
</resource-action-mapping>


package com.tutorialspoint.abstraction;

public class AbstractDemo {
  public static void main(String[] args) {
    /* Following is not allowed and would raise error */
    // Employee e = new Employee("George W.", "Houston, TX", 43); // Compile time error
    Salary s = new Salary("Mohd Mohtashim", "Ambehta, UP", 3, 3600.00);
    Employee e = new Salary("John Adams", "Boston, MA", 2, 2400.00);

    System.out.println("Call mailCheck using Salary reference --");
    s.mailCheck();

    System.out.println("\nCall mailCheck using Employee reference--");
    e.mailCheck();
  }
}


using System;
using System.Net;
using System.Net.Fakes;
using System.Net.Http;
using System.Net.Http.Fakes;
using System.Threading.Tasks;
using Microsoft.QualityTools.Testing.Fakes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Xciles.Uncommon.Net;

namespace Xciles.Uncommon.Tests.Net
{
    [TestClass]
    public class UncommonRequestHelperExceptionTests
    {
        private readonly Person _person = new Person
        {
            DateOfBirth = DateTime.Now.Subtract(new TimeSpan(800, 1, 1, 1)),
            Firstname = "First",
            Lastname = "Person",
            PhoneNumber = "0123456789",
            SomeString = "This is just a string"
        };

        [TestMethod]
        public void ProcessGetRequestWebExceptionTest()
        {
            ProcessGetRequestWebExceptionTestAsync().Wait();
        }

        private async Task ProcessGetRequestWebExceptionTestAsync()
        {
            var exceptionObject = new ExceptionObject()
            {
                Description = "This is a test Exception Description",
                Message = "This is a test Exception Message",
                Type = EType.WrongHeaders
            };

            using (ShimsContext.Create())
            {

                ShimHttpClient.AllInstances.SendAsyncHttpRequestMessageCancellationToken = (client, message, arg3) =>
                {
                    return Task.FromResult(new HttpResponseMessage()
                    {
                        Content = new StringContent(JsonConvert.SerializeObject(exceptionObject)),
                        StatusCode = HttpStatusCode.BadRequest
                    });
                };

                try
                {
                    var result = await UncommonRequestHelper.ProcessGetRequestAsync<Person>("http://www.xciles.com/");
                    Assert.Fail("Should not be able to be here...");
                }
                catch (UncommonRequestException ex)
                {
                    Assert.IsTrue(ex.RequestExceptionStatus == EUncommonRequestExceptionStatus.ServiceError);
                    Assert.IsTrue(ex.StatusCode == HttpStatusCode.BadRequest);

                    var responseResult = ex.ConvertExceptionResponseToObject<ExceptionObject>();
                    Assert.IsTrue(responseResult != null);
                    Assert.IsTrue(responseResult.Description == exceptionObject.Description);
                    Assert.IsTrue(responseResult.Message == exceptionObject.Message);
                    Assert.IsTrue(responseResult.Type == exceptionObject.Type);
                }
            }
        }

        [TestMethod]
        public void ProcessGetRequestHttpRequestExceptionTest()
        {
            ProcessGetRequestHttpRequestExceptionTestAsync().Wait();
        }

        private async Task ProcessGetRequestHttpRequestExceptionTestAsync()
        {
            var exceptionObject = new ExceptionObject()
            {
                Description = "This is a test Exception Description",
                Message = "This is a test Exception Message",
                Type = EType.WrongHeaders
            };

            using (ShimsContext.Create())
            {

                ShimHttpClient.AllInstances.SendAsyncHttpRequestMessageCancellationToken = (client, message, arg3) =>
                {
                    //var webEx = new WebException("", WebExceptionStatus.UnknownError, )
                    throw new HttpRequestException();
                };

                ShimHttpWebResponse.AllInstances.ResponseStreamGet = (response) =>
                {
                    return ShimsContext.ExecuteWithoutShims(() => response.GetResponseStream());
                };

                try
                {
                    var result = await UncommonRequestHelper.ProcessGetRequestAsync<Person>("http://www.xciles.com/");
                    Assert.Fail("Should not be able to be here...");
                }
                catch (UncommonRequestException ex)
                {
                    Assert.IsTrue(ex.RequestExceptionStatus == EUncommonRequestExceptionStatus.ServiceError);
                    Assert.IsTrue(ex.StatusCode == HttpStatusCode.BadRequest);

                    //var responseResult = ex.ConvertExceptionResponseToObject<ExceptionObject>();
                    //Assert.IsTrue(responseResult != null);
                    //Assert.IsTrue(responseResult.Description == exceptionObject.Description);
                    //Assert.IsTrue(responseResult.Message == exceptionObject.Message);
                    //Assert.IsTrue(responseResult.Type == exceptionObject.Type);
                }
            }
        }
    }
}


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="20dp"
    android:gravity="center"
    android:background="#333"
    android:orientation="vertical">

    <TextView android:id="@+id/textview_alias_input"
        android:layout_marginTop="10dp"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:text="@string/alias"
        android:textColor="#fff"
        android:textSize="18dp"
        />

    <EditText android:id="@+id/edittext_alias_input"
        android:layout_marginTop="10dp"
        android:layout_width="200dp"
        android:layout_height="44dp"
        />

</LinearLayout>


<!DOCTYPE html>

	<meta charset="utf-8">
	<title>jQuery UI Datepicker Demos</title>
	<link rel="stylesheet" href="../demos.css">

Examples

Default functionality

Format date

Restrict date range

Localize calendar

Populate alternate field

Display inline

Display button bar

Display month & year menus

Dates in other months

Show week of the year

Display multiple months

Icon trigger

Animations

Event Search


package dilawar

type Type string

const (
	TypeCredit Type = "credit"
	TypeDebit  Type = "debit"
)

type Storable interface {
	Create(*Transaction) error
	Read(int) *Transaction
	List() []Transaction
}


extern "C" {
#include "third_party/py/scipy/optimize/Zeros/zeros.h"
}

namespace logistic_hd {

// Integrands for the equations defined in Eq. 5 from Sur and Candès
// (PNAS, 2019). These are called by the bivariate integration over Z1 and Z2
// in `asymp_system_solve.py`.
double integrand(double Z1, double Z2, double kappa, double gamma, double b0,
                 double alpha, double lambda, double sigma, double beta0,
                 int eq_num);

// Computes the derivative of the objective that defines the proximal operator.
// The prox operator is the value of z that makes this zero.
double prox_deriv(double z, void *args);

double sigmoid(double z);

// Computes the derivative of the prox operator for the logistic regression
// log likelihood.
double prox_impl(double lambda, double x, double xtol = 1e-8,
                 double rtol = 1e-8, int maxiters = 1000);

// Computes the pdf of the bivariate normal without any input validation
// because this is called many times during optimization.
double pdf(double x1, double x2);

// Helper function to pass values between our code and the scipy.optimize API.
double scipy_zeros_functions_func(double x, void *params);

typedef struct prox_params {
  double lambda;
  double x;
} prox_params;

}  // namespace logistic_hd

#endif  // MLE_PARAM_INTEGRANDS_H_


// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
// http://github.com/jskeet/dotnet-protobufs/
// Original C++/Java/Python code:
// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using Google.ProtocolBuffers.Descriptors;

//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
#pragma warning disable 3010

namespace Google.ProtocolBuffers
{
    /// <summary>
    /// Provides an interface that is used write a message.  Most often proto buffers are written
    /// in their binary form by creating a instance via the CodedOutputStream.CreateInstance
    /// static factory.
    /// </summary>
    public interface ICodedOutputStream
    {
        /// <summary>
        /// Writes any message initialization data needed to the output stream
        /// </summary>
        /// <remarks>
        /// This is primarily used by text formats and unnecessary for protobuffers' own
        /// binary format.  The API for MessageStart/End was added for consistent handling
        /// of output streams regardless of the actual writer implementation.
        /// </remarks>
        void WriteMessageStart();
        /// <summary>
        /// Writes any message finalization data needed to the output stream
        /// </summary>
        /// <remarks>
        /// This is primarily used by text formats and unnecessary for protobuffers' own
        /// binary format.  The API for MessageStart/End was added for consistent handling
        /// of output streams regardless of the actual writer implementation.
        /// </remarks>
        void WriteMessageEnd();
        /// <summary>
        /// Indicates that all temporary buffers be written to the final output.
        /// </summary>
        void Flush();
        /// <summary>
        /// Writes an unknown message as a group
        /// </summary>
        [Obsolete]
        void WriteUnknownGroup(int fieldNumber, IMessageLite value);
        /// <summary>
        /// Writes an unknown field value of bytes
        /// </summary>
        void WriteUnknownBytes(int fieldNumber, ByteString value);
        /// <summary>
        /// Writes an unknown field of a primitive type
        /// </summary>
        [CLSCompliant(false)]
        void WriteUnknownField(int fieldNumber, WireFormat.WireType wireType, ulong value);
        /// <summary>
        /// Writes an extension as a message-set group
        /// </summary>
        void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessageLite value);
        /// <summary>
        /// Writes an unknown extension as a message-set group
        /// </summary>
        void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value);

        /// <summary>
        /// Writes a field value, including tag, to the stream.
        /// </summary>
        void WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value);

        /// <summary>
        /// Writes a double field value, including tag, to the stream.
        /// </summary>
        void WriteDouble(int fieldNumber, string fieldName, double value);

        /// <summary>
        /// Writes a float field value, including tag, to the stream.
        /// </summary>
        void WriteFloat(int fieldNumber, string fieldName, float value);

        /// <summary>
        /// Writes a uint64 field value, including tag, to the stream.
        /// </summary>
        [CLSCompliant(false)]
        void WriteUInt64(int fieldNumber, string fieldName, ulong value);

        /// <summary>
        /// Writes an int64 field value, including tag, to the stream.
        /// </summary>
        void WriteInt64(int fieldNumber, string fieldName, long value);

        /// <summary>
        /// Writes an int32 field value, including tag, to the stream.
        /// </summary>
        void WriteInt32(int fieldNumber, string fieldName, int value);

        /// <summary>
        /// Writes a fixed64 field value, including tag, to the stream.
        /// </summary>
        [CLSCompliant(false)]
        void WriteFixed64(int fieldNumber, string fieldName, ulong value);

        /// <summary>
        /// Writes a fixed32 field value, including tag, to the stream.
        /// </summary>
        [CLSCompliant(false)]
        void WriteFixed32(int fieldNumber, string fieldName, uint value);

        /// <summary>
        /// Writes a bool field value, including tag, to the stream.
        /// </summary>
        void WriteBool(int fieldNumber, string fieldName, bool value);

        /// <summary>
        /// Writes a string field value, including tag, to the stream.
        /// </summary>
        void WriteString(int fieldNumber, string fieldName, string value);

        /// <summary>
        /// Writes a group field value, including tag, to the stream.
        /// </summary>
        void WriteGroup(int fieldNumber, string fieldName, IMessageLite value);

        /// <summary>
        /// Writes a message field value, including tag, to the stream.
        /// </summary>
        void WriteMessage(int fieldNumber, string fieldName, IMessageLite value);

        /// <summary>
        /// Writes a byte array field value, including tag, to the stream.
        /// </summary>
        void WriteBytes(int fieldNumber, string fieldName, ByteString value);

        /// <summary>
        /// Writes a UInt32 field value, including tag, to the stream.
        /// </summary>
        [CLSCompliant(false)]
        void WriteUInt32(int fieldNumber, string fieldName, uint value);

        /// <summary>
        /// Writes an enum field value, including tag, to the stream.
        /// </summary>
        void WriteEnum(int fieldNumber, string fieldName, int value, object rawValue);

        /// <summary>
        /// Writes a fixed 32-bit field value, including tag, to the stream.
        /// </summary>
        void WriteSFixed32(int fieldNumber, string fieldName, int value);

        /// <summary>
        /// Writes a signed fixed 64-bit field value, including tag, to the stream.
        /// </summary>
        void WriteSFixed64(int fieldNumber, string fieldName, long value);

        /// <summary>
        /// Writes a signed 32-bit field value, including tag, to the stream.
        /// </summary>
        void WriteSInt32(int fieldNumber, string fieldName, int value);

        /// <summary>
        /// Writes a signed 64-bit field value, including tag, to the stream.
        /// </summary>
        void WriteSInt64(int fieldNumber, string fieldName, long value);

        /// <summary>
        /// Writes a repeated field value, including tag(s), to the stream.
        /// </summary>
        void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);

        /// <summary>
        /// Writes a repeated group value, including tag(s), to the stream.
        /// </summary>
        void WriteGroupArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
            where T : IMessageLite;

        /// <summary>
        /// Writes a repeated message value, including tag(s), to the stream.
        /// </summary>
        void WriteMessageArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
            where T : IMessageLite;

        /// <summary>
        /// Writes a repeated string value, including tag(s), to the stream.
        /// </summary>
        void WriteStringArray(int fieldNumber, string fieldName, IEnumerable<string> list);

        /// <summary>
        /// Writes a repeated ByteString value, including tag(s), to the stream.
        /// </summary>
        void WriteBytesArray(int fieldNumber, string fieldName, IEnumerable<ByteString> list);

        /// <summary>
        /// Writes a repeated boolean value, including tag(s), to the stream.
        /// </summary>
        void WriteBoolArray(int fieldNumber, string fieldName, IEnumerable<bool> list);

        /// <summary>
        /// Writes a repeated Int32 value, including tag(s), to the stream.
        /// </summary>
        void WriteInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);

        /// <summary>
        /// Writes a repeated SInt32 value, including tag(s), to the stream.
        /// </summary>
        void WriteSInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);

        /// <summary>
        /// Writes a repeated UInt32 value, including tag(s), to the stream.
        /// </summary>
        void WriteUInt32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);

        /// <summary>
        /// Writes a repeated Fixed32 value, including tag(s), to the stream.
        /// </summary>
        void WriteFixed32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);

        /// <summary>
        /// Writes a repeated SFixed32 value, including tag(s), to the stream.
        /// </summary>
        void WriteSFixed32Array(int fieldNumber, string fieldName, IEnumerable<int> list);

        /// <summary>
        /// Writes a repeated Int64 value, including tag(s), to the stream.
        /// </summary>
        void WriteInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);

        /// <summary>
        /// Writes a repeated SInt64 value, including tag(s), to the stream.
        /// </summary>
        void WriteSInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);

        /// <summary>
        /// Writes a repeated UInt64 value, including tag(s), to the stream.
        /// </summary>
        void WriteUInt64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);

        /// <summary>
        /// Writes a repeated Fixed64 value, including tag(s), to the stream.
        /// </summary>
        void WriteFixed64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);

        /// <summary>
        /// Writes a repeated SFixed64 value, including tag(s), to the stream.
        /// </summary>
        void WriteSFixed64Array(int fieldNumber, string fieldName, IEnumerable<long> list);

        /// <summary>
        /// Writes a repeated Double value, including tag(s), to the stream.
        /// </summary>
        void WriteDoubleArray(int fieldNumber, string fieldName, IEnumerable<double> list);

        /// <summary>
        /// Writes a repeated Float value, including tag(s), to the stream.
        /// </summary>
        void WriteFloatArray(int fieldNumber, string fieldName, IEnumerable<float> list);

        /// <summary>
        /// Writes a repeated enumeration value of type T, including tag(s), to the stream.
        /// </summary>
        [CLSCompliant(false)]
        void WriteEnumArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
            where T : struct, IComparable, IFormattable;

        /// <summary>
        /// Writes a packed repeated primitive, including tag and length, to the stream.
        /// </summary>
        void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);

        /// <summary>
        /// Writes a packed repeated boolean, including tag and length, to the stream.
        /// </summary>
        void WritePackedBoolArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<bool> list);

        /// <summary>
        /// Writes a packed repeated Int32, including tag and length, to the stream.
        /// </summary>
        void WritePackedInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);

        /// <summary>
        /// Writes a packed repeated SInt32, including tag and length, to the stream.
        /// </summary>
        void WritePackedSInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);

        /// <summary>
        /// Writes a packed repeated UInt32, including tag and length, to the stream.
        /// </summary>
        void WritePackedUInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);

        /// <summary>
        /// Writes a packed repeated Fixed32, including tag and length, to the stream.
        /// </summary>
        void WritePackedFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);

        /// <summary>
        /// Writes a packed repeated SFixed32, including tag and length, to the stream.
        /// </summary>
        void WritePackedSFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);

        /// <summary>
        /// Writes a packed repeated Int64, including tag and length, to the stream.
        /// </summary>
        void WritePackedInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);

        /// <summary>
        /// Writes a packed repeated SInt64, including tag and length, to the stream.
        /// </summary>
        void WritePackedSInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);

        /// <summary>
        /// Writes a packed repeated UInt64, including tag and length, to the stream.
        /// </summary>
        void WritePackedUInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);

        /// <summary>
        /// Writes a packed repeated Fixed64, including tag and length, to the stream.
        /// </summary>
        void WritePackedFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);

        /// <summary>
        /// Writes a packed repeated SFixed64, including tag and length, to the stream.
        /// </summary>
        void WritePackedSFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);

        /// <summary>
        /// Writes a packed repeated Double, including tag and length, to the stream.
        /// </summary>
        void WritePackedDoubleArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<double> list);

        /// <summary>
        /// Writes a packed repeated Float, including tag and length, to the stream.
        /// </summary>
        void WritePackedFloatArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<float> list);

        /// <summary>
        /// Writes a packed repeated enumeration of type T, including tag and length, to the stream.
        /// </summary>
        [CLSCompliant(false)]
        void WritePackedEnumArray<T>(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<T> list)
            where T : struct, IComparable, IFormattable;
    }
}


#include <linux/firmware.h>
#include <linux/module.h>
#include <linux/bitrev.h>
#include <linux/kernel.h>

#include "firmware.h"
#include "chip.h"

MODULE_FIRMWARE("6fire/dmx6firel2.ihx");
MODULE_FIRMWARE("6fire/dmx6fireap.ihx");
MODULE_FIRMWARE("6fire/dmx6firecf.bin");

enum {
	FPGA_BUFSIZE = 512, FPGA_EP = 2
};

/*
 * wMaxPacketSize of pcm endpoints.
 * keep synced with rates_in_packet_size and rates_out_packet_size in pcm.c
 * fpp: frames per isopacket
 *
 * CAUTION: keep sizeof <= buffer[] in usb6fire_fw_init
 */
static const u8 ep_w_max_packet_size[] = {
	0xe4, 0x00, 0xe4, 0x00, /* alt 1: 228 EP2 and EP6 (7 fpp) */
	0xa4, 0x01, 0xa4, 0x01, /* alt 2: 420 EP2 and EP6 (13 fpp)*/
	0x94, 0x01, 0x5c, 0x02  /* alt 3: 404 EP2 and 604 EP6 (25 fpp) */
};

static const u8 known_fw_versions[][2] = {
	{ 0x03, 0x01 }
};

struct ihex_record {
	u16 address;
	u8 len;
	u8 data[256];
	char error; /* true if an error occurred parsing this record */

	u8 max_len; /* maximum record length in whole ihex */

	/* private */
	const char *txt_data;
	unsigned int txt_length;
	unsigned int txt_offset; /* current position in txt_data */
};

static u8 usb6fire_fw_ihex_hex(const u8 *data, u8 *crc)
{
	u8 val = 0;
	int hval;

	hval = hex_to_bin(data[0]);
	if (hval >= 0)
		val |= (hval << 4);

	hval = hex_to_bin(data[1]);
	if (hval >= 0)
		val |= hval;

	*crc += val;
	return val;
}

/*
 * returns true if record is available, false otherwise.
 * iff an error occurred, false will be returned and record->error will be true.
 */
static bool usb6fire_fw_ihex_next_record(struct ihex_record *record)
{
	u8 crc = 0;
	u8 type;
	int i;

	record->error = false;

	/* find begin of record (marked by a colon) */
	while (record->txt_offset < record->txt_length
			&& record->txt_data[record->txt_offset] != ':')
		record->txt_offset++;
	if (record->txt_offset == record->txt_length)
		return false;

	/* number of characters needed for len, addr and type entries */
	record->txt_offset++;
	if (record->txt_offset + 8 > record->txt_length) {
		record->error = true;
		return false;
	}

	record->len = usb6fire_fw_ihex_hex(record->txt_data +
			record->txt_offset, &crc);
	record->txt_offset += 2;
	record->address = usb6fire_fw_ihex_hex(record->txt_data +
			record->txt_offset, &crc) << 8;
	record->txt_offset += 2;
	record->address |= usb6fire_fw_ihex_hex(record->txt_data +
			record->txt_offset, &crc);
	record->txt_offset += 2;
	type = usb6fire_fw_ihex_hex(record->txt_data +
			record->txt_offset, &crc);
	record->txt_offset += 2;

	/* number of characters needed for data and crc entries */
	if (record->txt_offset + 2 * (record->len + 1) > record->txt_length) {
		record->error = true;
		return false;
	}
	for (i = 0; i < record->len; i++) {
		record->data[i] = usb6fire_fw_ihex_hex(record->txt_data
				+ record->txt_offset, &crc);
		record->txt_offset += 2;
	}
	usb6fire_fw_ihex_hex(record->txt_data + record->txt_offset, &crc);
	if (crc) {
		record->error = true;
		return false;
	}

	if (type == 1 || !record->len) /* eof */
		return false;
	else if (type == 0)
		return true;
	else {
		record->error = true;
		return false;
	}
}

static int usb6fire_fw_ihex_init(const struct firmware *fw,
		struct ihex_record *record)
{
	record->txt_data = fw->data;
	record->txt_length = fw->size;
	record->txt_offset = 0;
	record->max_len = 0;
	/* read all records, if loop ends, record->error indicates,
	 * whether ihex is valid. */
	while (usb6fire_fw_ihex_next_record(record))
		record->max_len = max(record->len, record->max_len);
	if (record->error)
		return -EINVAL;
	record->txt_offset = 0;
	return 0;
}

static int usb6fire_fw_ezusb_write(struct usb_device *device,
		int type, int value, char *data, int len)
{
	int ret;

	ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), type,
			USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
			value, 0, data, len, HZ);
	if (ret < 0)
		return ret;
	else if (ret != len)
		return -EIO;
	return 0;
}

static int usb6fire_fw_ezusb_read(struct usb_device *device,
		int type, int value, char *data, int len)
{
	int ret = usb_control_msg(device, usb_rcvctrlpipe(device, 0), type,
			USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value,
			0, data, len, HZ);
	if (ret < 0)
		return ret;
	else if (ret != len)
		return -EIO;
	return 0;
}

static int usb6fire_fw_fpga_write(struct usb_device *device,
		char *data, int len)
{
	int actual_len;
	int ret;

	ret = usb_bulk_msg(device, usb_sndbulkpipe(device, FPGA_EP), data, len,
			&actual_len, HZ);
	if (ret < 0)
		return ret;
	else if (actual_len != len)
		return -EIO;
	return 0;
}

static int usb6fire_fw_ezusb_upload(
		struct usb_interface *intf, const char *fwname,
		unsigned int postaddr, u8 *postdata, unsigned int postlen)
{
	int ret;
	u8 data;
	struct usb_device *device = interface_to_usbdev(intf);
	const struct firmware *fw = NULL;
	struct ihex_record *rec = kmalloc(sizeof(struct ihex_record),
			GFP_KERNEL);

	if (!rec)
		return -ENOMEM;

	ret = request_firmware(&fw, fwname, &device->dev);
	if (ret < 0) {
		kfree(rec);
		snd_printk(KERN_ERR PREFIX "error requesting ezusb "
				"firmware %s.\n", fwname);
		return ret;
	}
	ret = usb6fire_fw_ihex_init(fw, rec);
	if (ret < 0) {
		kfree(rec);
		release_firmware(fw);
		snd_printk(KERN_ERR PREFIX "error validating ezusb "
				"firmware %s.\n", fwname);
		return ret;
	}
	/* upload firmware image */
	data = 0x01; /* stop ezusb cpu */
	ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1);
	if (ret < 0) {
		kfree(rec);
		release_firmware(fw);
		snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
				"firmware %s: begin message.\n", fwname);
		return ret;
	}

	while (usb6fire_fw_ihex_next_record(rec)) { /* write firmware */
		ret = usb6fire_fw_ezusb_write(device, 0xa0, rec->address,
				rec->data, rec->len);
		if (ret < 0) {
			kfree(rec);
			release_firmware(fw);
			snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
					"firmware %s: data urb.\n", fwname);
			return ret;
		}
	}

	release_firmware(fw);
	kfree(rec);
	if (postdata) { /* write data after firmware has been uploaded */
		ret = usb6fire_fw_ezusb_write(device, 0xa0, postaddr,
				postdata, postlen);
		if (ret < 0) {
			snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
					"firmware %s: post urb.\n", fwname);
			return ret;
		}
	}

	data = 0x00; /* resume ezusb cpu */
	ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1);
	if (ret < 0) {
		snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
				"firmware %s: end message.\n", fwname);
		return ret;
	}
	return 0;
}

static int usb6fire_fw_fpga_upload(
		struct usb_interface *intf, const char *fwname)
{
	int ret;
	int i;
	struct usb_device *device = interface_to_usbdev(intf);
	u8 *buffer = kmalloc(FPGA_BUFSIZE, GFP_KERNEL);
	const char *c;
	const char *end;
	const struct firmware *fw;

	if (!buffer)
		return -ENOMEM;

	ret = request_firmware(&fw, fwname, &device->dev);
	if (ret < 0) {
		snd_printk(KERN_ERR PREFIX "unable to get fpga firmware %s.\n",
				fwname);
		kfree(buffer);
		return -EIO;
	}

	c = fw->data;
	end = fw->data + fw->size;

	ret = usb6fire_fw_ezusb_write(device, 8, 0, NULL, 0);
	if (ret < 0) {
		kfree(buffer);
		release_firmware(fw);
		snd_printk(KERN_ERR PREFIX "unable to upload fpga firmware: "
				"begin urb.\n");
		return ret;
	}

	while (c != end) {
		for (i = 0; c != end && i < FPGA_BUFSIZE; i++, c++)
			buffer[i] = byte_rev_table[(u8) *c];

		ret = usb6fire_fw_fpga_write(device, buffer, i);
		if (ret < 0) {
			release_firmware(fw);
			kfree(buffer);
			snd_printk(KERN_ERR PREFIX "unable to upload fpga "
					"firmware: fw urb.\n");
			return ret;
		}
	}
	release_firmware(fw);
	kfree(buffer);

	ret = usb6fire_fw_ezusb_write(device, 9, 0, NULL, 0);
	if (ret < 0) {
		snd_printk(KERN_ERR PREFIX "unable to upload fpga firmware: "
				"end urb.\n");
		return ret;
	}
	return 0;
}

/* check, if the firmware version the devices has currently loaded
 * is known by this driver. 'version' needs to have 4 bytes version
 * info data. */
static int usb6fire_fw_check(u8 *version)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(known_fw_versions); i++)
		if (!memcmp(version, known_fw_versions + i, 2))
			return 0;

	snd_printk(KERN_ERR PREFIX "invalid fimware version in device: %*ph. "
			"please reconnect to power. if this failure "
			"still happens, check your firmware installation.",
			4, version);
	return -EINVAL;
}

int usb6fire_fw_init(struct usb_interface *intf)
{
	int i;
	int ret;
	struct usb_device *device = interface_to_usbdev(intf);
	/* buffer: 8 receiving bytes from device and
	 * sizeof(EP_W_MAX_PACKET_SIZE) bytes for non-const copy */
	u8 buffer[12];

	ret = usb6fire_fw_ezusb_read(device, 1, 0, buffer, 8);
	if (ret < 0) {
		snd_printk(KERN_ERR PREFIX "unable to receive device "
				"firmware state.\n");
		return ret;
	}
	if (buffer[0] != 0xeb || buffer[1] != 0xaa || buffer[2] != 0x55) {
		snd_printk(KERN_ERR PREFIX "unknown device firmware state "
				"received from device: ");
		for (i = 0; i < 8; i++)
			snd_printk("%02x ", buffer[i]);
		snd_printk("\n");
		return -EIO;
	}
	/* do we need fpga loader ezusb firmware? */
	if (buffer[3] == 0x01) {
		ret = usb6fire_fw_ezusb_upload(intf,
				"6fire/dmx6firel2.ihx", 0, NULL, 0);
		if (ret < 0)
			return ret;
		return FW_NOT_READY;
	}
	/* do we need fpga firmware and application ezusb firmware? */
	else if (buffer[3] == 0x02) {
		ret = usb6fire_fw_check(buffer + 4);
		if (ret < 0)
			return ret;
		ret = usb6fire_fw_fpga_upload(intf, "6fire/dmx6firecf.bin");
		if (ret < 0)
			return ret;
		memcpy(buffer, ep_w_max_packet_size,
				sizeof(ep_w_max_packet_size));
		ret = usb6fire_fw_ezusb_upload(intf, "6fire/dmx6fireap.ihx",
				0x0003,	buffer, sizeof(ep_w_max_packet_size));
		if (ret < 0)
			return ret;
		return FW_NOT_READY;
	}
	/* all fw loaded? */
	else if (buffer[3] == 0x03)
		return usb6fire_fw_check(buffer + 4);
	/* unknown data? */
	else {
		snd_printk(KERN_ERR PREFIX "unknown device firmware state "
				"received from device: ");
		for (i = 0; i < 8; i++)
			snd_printk("%02x ", buffer[i]);
		snd_printk("\n");
		return -EIO;
	}
	return 0;
}


/**
 * @file
 * @brief
 *  This file defines the OpenThread crypto C APIs.
 */

#ifndef OPENTHREAD_CRYPTO_H_
#define OPENTHREAD_CRYPTO_H_

#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @addtogroup api-crypto
 *
 * @brief
 *   This module includes cryptographic functions.
 *
 * @{
 *
 */

#define OT_CRYPTO_HMAC_SHA_HASH_SIZE   32   ///< Length of HMAC SHA (in bytes).

/**
 * This function performs HMAC computation.
 *
 * @param[in]     aKey           A pointer to the key.
 * @param[in]     aKeyLength     The key length in bytes.
 * @param[in]     aBuf           A pointer to the input buffer.
 * @param[in]     aBufLength     The length of @p aBuf in bytes.
 * @param[out]    aHash          A pointer to the output hash buffer.
 *
 */
void otCryptoHmacSha256(
    const uint8_t *aKey, uint16_t aKeyLength,
    const uint8_t *aBuf, uint16_t aBufLength,
    uint8_t *aHash);

/**
 * This method performs AES CCM computation.
 *
 * @param[in]     aKey           A pointer to the key.
 * @param[in]     aKeyLength     Length of the key in bytes.
 * @param[in]     aTagLength     Length of tag in bytes.
 * @param[in]     aNonce         A pointer to the nonce.
 * @param[in]     aNonceLength   Length of nonce in bytes.
 *
 * @param[in]     aHeader        A pointer to the header.
 * @param[in]     aHeaderLength  Length of header in bytes.
 *
 * @param[inout]  aPlainText     A pointer to the plaintext.
 * @param[inout]  aCipherText    A pointer to the ciphertext.
 * @param[in]     aLength        Plaintext length in bytes.
 * @param[in]     aEncrypt       `true` on encrypt and `false` on decrypt.
 *
 * @param[out]    aTag           A pointer to the tag.
 *
 */
void otCryptoAesCcm(
    const uint8_t *aKey, uint16_t aKeyLength,
    uint8_t aTagLength,
    const void *aNonce, uint8_t aNonceLength,
    const void *aHeader, uint32_t aHeaderLength,
    void *aPlainText, void *aCipherText, uint32_t aLength, bool aEncrypt,
    void *aTag);

/**
 * @}
 *
 */

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

#endif  // OPENTHREAD_CRYPTO_H_


<!DOCTYPE html>

  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1"/>

  <title>Eterno Amor</title>
  <meta name="author" content="" />
  <meta name="description"
        content="Um misto de remorso pelas agruras da guerra com a energia de uma investigação guiada unicamente pela fé (ou pelo amor). A beleza da fotografia fria e triste do front se contrapõe aos horizontes..."/>

  <meta name="yandex-verification" content="48a8210fc043c5e8" />

  <meta name="generator" content="Hugo 0.54.0" />

  <meta itemprop="name" content="Eterno Amor"/>
  <meta itemprop="description"
        content="Um misto de remorso pelas agruras da guerra com a energia de uma investigação guiada unicamente pela fé (ou pelo amor). A beleza da fotografia fria e triste do front se contrapõe aos horizontes..."/>
  <meta itemprop="image"
        content="/img/logo.svg"/>

  <meta property="og:title" content="Eterno Amor"/>
  <meta property="og:type"
        content="article"/>
  <meta property="og:url" content="http://www.cinetenisverde.com.br/eterno-amor/"/>
  <meta property="og:image"
        content="/img/logo.svg"/>
  <meta property="og:description"
        content="Um misto de remorso pelas agruras da guerra com a energia de uma investigação guiada unicamente pela fé (ou pelo amor). A beleza da fotografia fria e triste do front se contrapõe aos horizontes..."/>
  <meta property="og:site_name" content="Cine Tênis Verde"/>
  <meta property="article:published_time"
        content="2016-01-06T00:00:00+00:00"/>
  <meta property="article:section" content="post"/>

  <meta name="twitter:card" content="summary"/>
  <meta name="twitter:site"
        content=""/>
  <meta name="twitter:title" content="Eterno Amor"/>
  <meta name="twitter:description"
        content="Um misto de remorso pelas agruras da guerra com a energia de uma investigação guiada unicamente pela fé (ou pelo amor). A beleza da fotografia fria e triste do front se contrapõe aos horizontes..."/>
  <meta name="twitter:creator"
        content=""/>
  <meta name="twitter:image:src"
        content="/img/logo.svg"/>

  <link rel="stylesheet" type="text/css" href="/css/capsule.min.css"/>
  <link rel="stylesheet" type="text/css" href="/css/custom.css"/>

  <link rel="apple-touch-icon" href="/img/apple-touch-icon.png"/>
  <link rel="icon" href="/img/favicon.ico"/>

 Cine Tênis Verde

    <input type="checkbox" id="navbar-burger-state"/>

      search

      twitter

      rss

Eterno Amor

    ★★★★☆

 Wanderley Caloni, January 6, 2016

Um misto de remorso pelas agruras da guerra com a energia de uma investigação guiada unicamente pela fé (ou pelo amor). A beleza da fotografia fria e triste do front se contrapõe aos horizontes oníricos do presente nostálgico, que clama pela elucidação completa de um passado nebuloso que separou um casal apaixonado prestes a se casar. Eterno Amor é pura poesia na forma de criatividade narrativa. Um Pierre Jeunet que retrabalha sua Amélie Poulain em traços mais cruéis e menos esperançosos, e que tenta soar como um romance épico em torno de personagens com pouca alma e muita persistência.

Utilizando novamente Audrey Tautou, a namoradinha da França, o diretor Jean-Pierre Jeunet mais uma vez aplica a belíssima fotografia de seu colaborador Bruno Delbonnel (Harry Potter e o Enigma do Príncipe, Inside Llewyn Davis: Balada de um Homem Comum, Amélie Poulain) e a dinâmica e inventiva montagem de seu editor Hervé Schneid (Micmacs - Um Plano Complicado) para contar uma história cheia de poder criativo, mas que encontra em seu núcleo um drama intransponível para o estilo do diretor.

Sua busca incessante, no entanto, em tentar juntar todas as pistas que a bela mas manca Mathilde (Tatou) vai acumulando, testemunho após testemunho, em busca da verdade definitiva a respeito do paradeiro de seu amor, Manech (Gaspard Ulliel), é tão contagiante que o mundo que se cria em torno acaba compensando a total falta de realismo nesse conto quase-surrealista.

Com aspectos técnicos impressionantes a cada cena – exceto talvez pela música de Angelo Badalamenti, repetitiva e monótona, mas ainda assim condizente com a proposta do filme – e com um ritmo que vai se formando pela repetição (a insistência do carteiro em espalhar o cascalho da entrada da casa de Mathilde, só pelo bem da “entrada triunfal”), o roteiro da dupla Guillaume Laurant e do próprio Pierre Jeunet, baseados no romance de Sébastien Japrisot, não consegue se desvencilhar da sua complexidade em utilizar diferentes personagens que se parecem em situações que se embaralham, o que se por um lado acaba contribuindo para a atmosfera de desorientação de Mathilde, vai aos poucos se tornando uma distração incômoda para o espectador, que já não espera encontrar qualquer conexão memorável entre as pistas.

Até mesmo a dualidade de cores frias da guerra com as cores sempre aquecidas do presente da protagonista, fascinante no começo, também vai se esvaecendo com a cada vez mais distante capacidade de atribuir significado naquele emaranhado de símbolos. Jeunet se deixa sabotar pela sua própria obsessão de detalhes, e assim como seu mais recente trabalho, Uma Viagem Extraordinária, se esquece das emoções primárias de seus personagens para focar unicamente nas idiossincrasias de sua complexa história.

O que acaba por fim em tornar tudo aquilo uma imensa espiral de eventos que revela uma estrutura tal qual as escadas do farol onde o casal se encontrava: aparentemente infinita, mas se encarada com dedicação e empenho, alcançável até por uma manca que deseja enxergar além de suas limitações físicas. É o metafísico celebrado em vida. A mágica de usar o cinema como cornucópia de simbolismos visuais.

           Imagens e créditos no IMDB.

    ★★★★☆

 Eterno Amor ● Eterno Amor. Un long dimanche de fiançailles (France, 2004). Dirigido por Jean-Pierre Jeunet. Escrito por Sébastien Japrisot, Jean-Pierre Jeunet, Guillaume Laurant, Guillaume Laurant. Com Audrey Tautou, Gaspard Ulliel, Dominique Pinon, Chantal Neuwirth, André Dussollier, Ticky Holgado, Marion Cotillard, Dominique Bettenfeld, Jodie Foster. ● Nota: 4/5. Categoria: movies.  Publicado em 2016-01-06.  Texto escrito por Wanderley Caloni.

Quer comentar?

      Share


function toggle_visibility(id) {
					var e = document.getElementById(id);
					if(e.style.display == 'block')
						e.style.display = 'none';
					else
						e.style.display = 'block';
}

jQuery(document).ready(function($) {

                    $(".scroll").click(function(event){
                    	event.preventDefault();
                            $('body').animate({scrollTop:$(this.hash).offset().top}, 1500);
                    });
});


package com.intellij.refactoring.move.moveInstanceMethod;

import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.refactoring.move.MoveCallback;
import com.intellij.refactoring.move.MoveHandlerDelegate;
import com.intellij.refactoring.move.moveClassesOrPackages.JavaMoveClassesOrPackagesHandler;
import org.jetbrains.annotations.Nullable;

public class MoveInstanceMethodHandlerDelegate extends MoveHandlerDelegate {
  @Override
  public boolean canMove(final PsiElement[] elements, @Nullable final PsiElement targetContainer) {
    if (elements.length != 1) return false;
    PsiElement element = elements [0];
    if (!(element instanceof PsiMethod)) return false;
    if (element instanceof SyntheticElement) return false;
    PsiMethod method = (PsiMethod) element;
    if (method.hasModifierProperty(PsiModifier.STATIC)) return false;
    return targetContainer == null || super.canMove(elements, targetContainer);
  }

  @Override
  public boolean isValidTarget(final PsiElement targetElement, PsiElement[] sources) {
    for (PsiElement source : sources) {
      if (JavaMoveClassesOrPackagesHandler.invalid4Move(source)) return false;
    }
    return targetElement instanceof PsiClass && !(targetElement instanceof PsiAnonymousClass);
  }

  @Override
  public boolean tryToMove(final PsiElement element, final Project project, final DataContext dataContext, final PsiReference reference,
                           final Editor editor) {
    if (element instanceof PsiMethod) {
      PsiMethod method = (PsiMethod) element;
      if (!method.hasModifierProperty(PsiModifier.STATIC))  {
        new MoveInstanceMethodHandler().invoke(project, new PsiElement[]{method}, dataContext);
        return true;
      }
    }
    return false;
  }

  @Override
  public void doMove(final Project project, final PsiElement[] elements, final PsiElement targetContainer, final MoveCallback callback) {
    new MoveInstanceMethodHandler().invoke(project, elements, null);
  }
}


/* A Bison parser, made by GNU Bison 3.0.4.  */

/* Bison interface for Yacc-like parsers in C

   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/* As a special exception, you may create a larger work that contains
   part or all of the Bison parser skeleton and distribute that work
   under terms of your choice, so long as that work isn't itself a
   parser generator using the skeleton or a modified version thereof
   as a parser skeleton.  Alternatively, if you modify or redistribute
   the parser skeleton itself, you may (at your option) remove this
   special exception, which will cause the skeleton and the resulting
   Bison output files to be licensed under the GNU General Public
   License without this special exception.

   This special exception was added by the Free Software Foundation in
   version 2.2 of Bison.  */

#ifndef YY_YY_PARSE_H_INCLUDED
# define YY_YY_PARSE_H_INCLUDED
/* Debug traces.  */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif

/* Token type.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
  enum yytokentype
  {
    CHAR = 258,
    NUMBER = 259,
    SECTEND = 260,
    SCDECL = 261,
    XSCDECL = 262,
    NAME = 263,
    PREVCCL = 264,
    EOF_OP = 265,
    OPTION_OP = 266,
    OPT_OUTFILE = 267,
    OPT_PREFIX = 268,
    OPT_YYCLASS = 269,
    OPT_HEADER = 270,
    OPT_EXTRA_TYPE = 271,
    OPT_TABLES = 272,
    CCE_ALNUM = 273,
    CCE_ALPHA = 274,
    CCE_BLANK = 275,
    CCE_CNTRL = 276,
    CCE_DIGIT = 277,
    CCE_GRAPH = 278,
    CCE_LOWER = 279,
    CCE_PRINT = 280,
    CCE_PUNCT = 281,
    CCE_SPACE = 282,
    CCE_UPPER = 283,
    CCE_XDIGIT = 284,
    CCE_NEG_ALNUM = 285,
    CCE_NEG_ALPHA = 286,
    CCE_NEG_BLANK = 287,
    CCE_NEG_CNTRL = 288,
    CCE_NEG_DIGIT = 289,
    CCE_NEG_GRAPH = 290,
    CCE_NEG_LOWER = 291,
    CCE_NEG_PRINT = 292,
    CCE_NEG_PUNCT = 293,
    CCE_NEG_SPACE = 294,
    CCE_NEG_UPPER = 295,
    CCE_NEG_XDIGIT = 296,
    CCL_OP_DIFF = 297,
    CCL_OP_UNION = 298,
    BEGIN_REPEAT_POSIX = 299,
    END_REPEAT_POSIX = 300,
    BEGIN_REPEAT_FLEX = 301,
    END_REPEAT_FLEX = 302
  };
#endif
/* Tokens.  */
#define CHAR 258
#define NUMBER 259
#define SECTEND 260
#define SCDECL 261
#define XSCDECL 262
#define NAME 263
#define PREVCCL 264
#define EOF_OP 265
#define OPTION_OP 266
#define OPT_OUTFILE 267
#define OPT_PREFIX 268
#define OPT_YYCLASS 269
#define OPT_HEADER 270
#define OPT_EXTRA_TYPE 271
#define OPT_TABLES 272
#define CCE_ALNUM 273
#define CCE_ALPHA 274
#define CCE_BLANK 275
#define CCE_CNTRL 276
#define CCE_DIGIT 277
#define CCE_GRAPH 278
#define CCE_LOWER 279
#define CCE_PRINT 280
#define CCE_PUNCT 281
#define CCE_SPACE 282
#define CCE_UPPER 283
#define CCE_XDIGIT 284
#define CCE_NEG_ALNUM 285
#define CCE_NEG_ALPHA 286
#define CCE_NEG_BLANK 287
#define CCE_NEG_CNTRL 288
#define CCE_NEG_DIGIT 289
#define CCE_NEG_GRAPH 290
#define CCE_NEG_LOWER 291
#define CCE_NEG_PRINT 292
#define CCE_NEG_PUNCT 293
#define CCE_NEG_SPACE 294
#define CCE_NEG_UPPER 295
#define CCE_NEG_XDIGIT 296
#define CCL_OP_DIFF 297
#define CCL_OP_UNION 298
#define BEGIN_REPEAT_POSIX 299
#define END_REPEAT_POSIX 300
#define BEGIN_REPEAT_FLEX 301
#define END_REPEAT_FLEX 302

/* Value type.  */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif

extern YYSTYPE yylval;

int yyparse (void);

#endif /* !YY_YY_PARSE_H_INCLUDED  */


class CreateBodyParts < ActiveRecord::Migration
  def change
    create_table :body_parts do |t|
      t.string :name
      t.string :slug

      t.timestamps
    end
  end
end


Making a formula is easy. Just `brew create URL` and then `brew install $FORMULA` (perhaps with `--debug --verbose`). Basically, a formula is a Ruby file. You can place it anywhere you want (local or remote) and install it by pointing to the file or URL.

We want your formula to be awesome, and the cookbook will tell you how.

## Terminology - Homebrew speak

      Formula
      The package definition
      /usr/local/Library/Formula/foo.rb

      Keg
      The installation prefix of a Formula
      /usr/local/Cellar/foo/0.1

      opt prefix
      A symlink to the active version of a keg
      /usr/local/opt/foo

      Cellar
      All kegs are installed here
      /usr/local/Cellar

      Tap
      An optional repository (git) of Formulae
      /usr/local/Library/Taps

      Bottle
      Pre-built (binary) Keg that can be unpacked
      qt-4.8.4.mountain_lion.bottle.1.tar.gz

_More general: `brew --prefix` and `brew --repository` instead of `/usr/local` but lets KISS._

## An Introduction

Did you see `/usr/local/.git`? Homebrew is built on Git. This means you can just do your work in `/usr/local` and merge in upstream changes as you go.

Homebrew installs to the `Cellar`, it then symlinks some of the installation into `/usr/local` so that other programs can see what's going on. We suggest you `brew ls` a few of the kegs in your Cellar to see how it is all arranged.

Packages are installed according to their formulae, which live in `$(brew --repository)/Library/Formula`. Check some out. You can view any formula at anytime; e.g. `brew edit wget`.

# Basic Instructions

Make sure you run `brew update` before you start. This turns your Homebrew installation into a Git repository.

Before contributing, make sure your package:

*   meets all our [Acceptable Formulae](Acceptable-Formulae.md) requirements
*   isn't already in Homebrew (check `brew search $FORMULA`)
*   isn't in another [Homebrew tap](https://github.com/Homebrew)
*   isn't already waiting to be merged (check the [issue tracker](https://github.com/Homebrew/homebrew/issues))
*   is still supported by upstream
*   has a stable, tagged version (i.e. not just a GitHub repository with no versions). See [Interesting-Taps-&-Branches](Interesting-Taps-&-Branches.md) for where pre-release and head-only versions belong.

Make sure you search thoroughly (all aliases!). We don’t want you to waste your time.

Be sure to look over the [contributing guidelines](https://github.com/Homebrew/homebrew/blob/master/CONTRIBUTING.md) as well.

## Will we merge your formula?

Probably. But we have rules to keep the quality and goals of Homebrew intact: Please read [Acceptable Formulae](Acceptable-Formulae.md).

## Some Quick Examples Before You Get Started

Formulae aren’t that complicated. [etl](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/etl.rb) is as simple as it gets.

And then [Git](https://github.com/Homebrew/homebrew/tree/master/Library/Formula/git.rb) and [flac](https://github.com/Homebrew/homebrew/tree/master/Library/Formula/flac.rb) show more advanced functionality.

A more complete example-formula [cheat-sheet](https://github.com/Homebrew/homebrew/blob/master/Library/Contributions/example-formula.rb) shows almost all the stuff you can use in a Formula.

## Grab the URL

All you need to make a formula is a URL to the tarball.

    brew create http://example.com/foo-0.1.tar.gz

This creates:

`$HOMEBREW_REPOSITORY/Library/Formula/foo.rb`

And opens it in your `$EDITOR`. It'll look like:

```ruby
class Foo < Formula
  url "http://example.com/foo-0.1.tar.gz"
  homepage ""
  sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7"

  # depends_on "cmake" => :build

  def install
    system "./configure", "--prefix=#{prefix}", "--disable-debug", "--disable-dependency-tracking"
#   system "cmake", ".", *std_cmake_args
    system "make", "install"
  end
end
```

**Note:**  If `brew` said `Warning: Version cannot be determined from URL` when doing the `create` step, you’ll need to explicitly add the correct version to the formula with `version "foo"` **and then save the formula**. `brew install` should then proceed without any trouble.

**Note:** If `brew` said `No formula found for "php54-timezonedb". Searching open pull requests...` and you are writing a Tap, you should run `brew tap --repair`.

## Fill in the Homepage

**We don’t accept formulae without homepages!**

Homebrew now has a description field (`desc`). Try and summarize this from the homepage.

## Check the build system

    brew install -i foo

You’re now at new prompt with the tarball extracted to a temporary sandbox.

Check the package’s `README`. Does the package install with `autotools`, `cmake`, or something else? Delete the commented out cmake lines if the package uses autotools (i.e. if it has a `configure` script).

## Check for dependencies

The `README` probably tells you about dependencies. Homebrew or OS X probably already has them. You can check for Homebrew deps with `brew search`. These are the common deps that OS X comes with:

* `libexpat`
* `libGL`
* `libiconv`
* `libpcap`
* `libxml2`
* `Python`
* `Ruby`

There are plenty of others. Check `/usr/lib` to see.

We try to not duplicate libraries and complicated tools in core Homebrew. We dupe some common tools though. But generally, we avoid dupes because it’s one of Homebrew’s foundations. (And it causes build and usage problems!)

The one special exception is OpenSSL. Anything that uses OpenSSL *should* be built using Homebrew’s shipped OpenSSL and our test bot's post-install audit will warn of this when it is detected. (*Of course, there are exceptions to the exception. Not everything can be forced onto our OpenSSL)*.

Because Homebrew’s OpenSSL is `keg_only` to avoid conflicting with the system sometimes formulae need to have environmental variables set or special configuration flags passed to locate our preferred OpenSSL; you can see this mechanism in the [clamav](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/clamav.rb#L28) formula. Usually this is unnecessary because when OpenSSL is specified as a dependency Homebrew temporarily prepends the $PATH with that prefix.

Homebrew maintains a special [tap that provides other useful dupes](https://github.com/Homebrew/homebrew-dupes).

*Important:* Since the introduction of `superenv`, `brew --prefix`/bin is NOT on the `$PATH` during formula installation. If you have dependencies at build time, you must specify them and brew will add them to the `$PATH`. You can test around this with `--env=std`.

## Specifying other formulae as dependencies

```ruby
class Foo < Formula
  depends_on "jpeg"
  depends_on "gtk+" => :optional
  depends_on "readline" => :recommended
  depends_on "boost" => "with-icu"
  depends_on :x11 => :optional
end
```

A String specifies a formula dependency.

A Symbol specifies a special conditional dependency, such as X11.

A Hash specifies a formula dependency with some additional information. Given a single string key, the value can take several forms:
*   a Symbol (currently one of `:build`, `:optional`, `:recommended`).
    -   `:build` tags that dependency as a build-time only dependency, meaning it can be safely ignored
        when installing from a bottle and when listing missing dependencies using `brew missing`.
    -   `:optional` generates an implicit `with-foo` option for the formula. This means that, given
        `depends_on "foo" => :optional`, the user must pass `--with-foo` in order to enable the dependency.
    -   `:recommended` generates an implicit `without-foo` option, meaning that the dependency is enabled
        by default and the user must pass `--without-foo` to disable this dependency. The default
        description can be overridden using the normal option syntax (in this case, the option declaration must precede the dependency):

    ```ruby
    option "with-foo", "Compile with foo bindings" # This overrides the generated description if you want to
    depends_on "foo" => :optional # Generated description is "Build with foo support"
    ```

*   a String or an Array
    String values are interpreted as options to be passed to the dependency. You can also pass
    an array of strings, or an array of symbols and strings, in which case the symbols are
    interpreted as described above, and the strings are passed to the dependency as options.

    ```ruby
    depends_on "foo" => "with-bar"
    depends_on "foo" => %w{with-bar with-baz}
    depends_on "foo" => [:optional, "with-bar"]
    ```

## Specifying other formulae as conflicts

Sometimes there’s hard conflict between formulae, and it can’t be avoided or circumvented with `keg_only`.

PolarSSL is a good [example](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/polarssl.rb#L36-L37) formula for minor conflict.

PolarSSL ship GNU’s Hello, and compiles a `hello` binary. This is obviously non-essential to PolarSSL’s functionality, and conflict with the `hello` formula would be overkill, so we just remove it.

However, also in the PolarSSL formulae is a [firm conflict](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/polarssl.rb#L19) with `md5sha1sum`, because both `md5sha1sum` and `polarssl` compile identically-named binaries that *are* important for core functionality.

As a general rule, `conflicts_with` should be a last-resort option. It’s a fairly blunt instrument.

The syntax for conflict that can’t be worked around is

```ruby
conflicts_with "blueduck", :because => "yellowduck also ships a duck binary"
```

## Formulae Revisions

In Homebrew we sometimes accept formulae updates that don’t include a version bump. These include homepage changes, resource updates, new patches or fixing a security issue with a formula.

Occasionally, these updates require a forced-recompile of the formula itself or its dependents to either ensure formulae continue to function as expected or to close a security issue. This forced-recompile is known as a `revision` and inserted underneath the homepage/url/sha block.

Where a dependent of a formula fails against a new version of that dependency it must receive a `revision`. An example of such failure can be seen [here](https://github.com/Homebrew/homebrew/issues/31195) and the fix [here](https://github.com/Homebrew/homebrew/pull/31207).

`Revisions` are also used for formulae that move from the system OpenSSL to the Homebrew-shipped OpenSSL without any other changes to that formula. This ensures users aren’t left exposed to the potential security issues of the outdated OpenSSL. An example of this can be seen in [this commit](https://github.com/Homebrew/homebrew/commit/6b9d60d474d72b1848304297d91adc6120ea6f96).

## Double-check for dependencies

When you already have a lot of brews installed, its easy to miss a common dependency like `glib` or `gettext`.

You can double-check which libraries a binary links to with the `otool` command (perhaps you need to use `xcrun otool`):

    $ otool -L /usr/local/bin/ldapvi
    /usr/local/bin/ldapvi:
	/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/local/lib/libglib-2.0.0.dylib (compatibility version 4201.0.0, current version 4201.0.0)
	/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.2.0)
	/usr/local/opt/readline/lib/libreadline.6.dylib (compatibility version 6.0.0, current version 6.3.0)
	/usr/local/lib/libpopt.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
	/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
	/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

## Specifying gems, Python modules, Go projects, etc. as dependencies

Homebrew doesn’t package already packaged language-specific libraries. These should be installed directly from `gem`/`cpan`/`pip` etc.

If you're installing an application then please locally vendor all the language-specific dependencies:

```ruby
class Foo < Formula
  resource "pycrypto" do
    url "https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.tar.gz"
    sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7"
  end

  def install
    resource("pycrypto").stage { system "python", *Language::Python.setup_install_args(libexec/"vendor") }
  end
end
```

[jrnl](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/jrnl.rb) is an example of a formula that does this well. The end-result means the user doesn't have to faff with `pip` or Python and can just run `jrnl`.

[homebrew-pypi-poet](https://github.com/tdsmith/homebrew-pypi-poet) can help you generate resource stanzas for the dependencies of your Python application.

Similarly, [homebrew-go-resources](https://github.com/samertm/homebrew-go-resources) can help you generate go\_resource stanzas for the dependencies of your go application.

If your formula needs a gem or python module and it can't be made into a resource you’ll need to check for these external dependencies:

```ruby
class Foo < Formula
  depends_on "mg" => :ruby
  depends_on "json" => :python
  depends_on "Authen::NTLM" => :perl
end
```

Note that we probably won't accept the formulae in this case; it's a far worse user experience than vendoring libraries with resources.

## Test the formula

Exit out of the interactive shell.

    brew install --verbose --debug foo

Debug will ask you to open an interactive shell when the build fails so you can try to figure out what went wrong.

Check the top of the `./configure` output (if applicable)! Some configure scripts do not recognize `--disable-debug`. If you see a warning about it, remove the option from the formula.

## Add a test to the formula

Please add a `test do` block to the formula. This will be run by `brew test foo` and the [Brew Test Bot](Brew-Test-Bot.md).

The `test do` block automatically creates and changes to a temporary directory which is deleted after run. You can access this Pathname with the `testpath` function.

We want tests that don't require any user input and test the basic functionality of the application. For example `foo build-foo input.foo` is a good test and (despite their widespread use) `foo --version` and `foo --help` are bad tests. However, a bad test is better than no test at all.

See [cmake](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/cmake.rb) for an example of a formula with a good test. A basic `CMakeLists.txt` file is written CMake uses it to generate Makefiles. This test checks that CMake doesn't e.g. segfault during basic operation.

## Manuals

Homebrew expects to find man pages in `[prefix]/share/man/...`, and not in `[prefix]/man/...`.

Some software installs to man instead of `share/man`, so check the output and add a `"--mandir=#{man}"` to the `./configure` line if needed.

## A Quick Word on Naming

**THE NAME IS VERY IMPORTANT!**

Name the formula like the project markets the product. So it’s `pkg-config`, not `pkgconfig`; `sdl_mixer`, not `sdl-mixer` or `sdlmixer`.

The only exception is stuff like “Apache Ant”. Apache sticks “Apache” in front of everything, but we use the formula name `ant`. We only include the prefix in cases like *GNUplot* (because it’s part of the name) and *GNU Go* (because everyone calls it “GNU go”—nobody just calls it “Go”). The word “Go” is too common and there are too many implementations of it.

If you’re not sure about the name check the homepage, and check the Wikipedia page.

[ALSO CHECK WHAT DEBIAN CALLS IT!](https://www.debian.org/distrib/packages)

Where Homebrew already has a formula called `foo` we typically do not accept requests to replace that formula with something else also named `foo`. This is to avoid both confusing and surprising users’ expectation.

When two formulae share an upstream name, e.g. [`AESCrypt`](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/aescrypt.rb) and [`AESCrypt`](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/aescrypt-packetizer.rb) the newer formula must typically adapt the name to avoid conflict with the current formula.

If you’re *still* not sure, just commit. We’ll apply some arbitrary rule and make a decision ;)

When importing classes, Homebrew will require the formula and then create an instance of the class. It does this by assuming the formula name can be directly converted to the class name using a `regexp`. The rules are simple:

*   `foo-bar.rb` => `FooBar`
*   `foobar.rb` => `Foobar`

Thus, if you change the name of the class, you must also rename the file. Filenames should be all lowercase.

Add aliases by creating symlinks in `Library/Aliases`.

## Audit the formula

You can run `brew audit` to test formulae for adherence to Homebrew house style. This includes warnings for trailing whitespace, preferred URLs for certain source hosts, and a lot of other style issues. Fixing these warnings before committing will make the process a lot smoother for us.

Use `brew info` and check if the version guessed by Homebrew from the URL is
correct. Add an explicit `version` if not.

## Commit

Everything is built on Git, so contribution is easy:

    brew install git # if you already have git installed, skip this command
    brew update # required in more ways than you think (initializes the brew git repository if you don't already have it)
    cd `brew --repository`
    # Create a new git branch for your formula so your pull request is easy to
    # modify if any changes come up during review.
    git checkout -b <some-descriptive-name>
    git add Library/Formula/foo.rb
    git commit

The established standard for Git commit messages is:

* the first line is a commit summary of *50 characters or less*, then
* two (2) newlines, then
* explain the commit throughly

At Homebrew, we like to put the name of the formula upfront like so "foobar 7.3 (new formula)".
This may seem crazy short, but you’ll find that forcing yourself to summarise the commit encourages you to be atomic and concise. If you can’t summarise it in 50-80 characters, you’re probably trying to commit two commits as one. For a more thorough explanation, please read Tim Pope’s excellent blog post, [A Note About Git Commit Messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

The preferred commit message format for simple version updates is "foobar 7.3".

Ensure you reference any relevant GitHub issue `#12345` in the commit message. Homebrew’s history is the first thing future contributors will look to when trying to understand the current state of formulae they’re interested in.

## Push

Now you just need to push back to GitHub.

If you haven’t forked Homebrew yet, [go to the repo and hit the fork button](https://github.com/Homebrew/homebrew).

If you have already forked Homebrew on GitHub, then you can manually push (just make sure you have been pulling from the Homebrew/homebrew master):

    git push git@github.com:myname/homebrew.git <what-you-called-your-branch>

Now, please open a Pull Request (on your GitHub repo page) for new and updated brews.

*   One formula per commit; one commit per formula
*   Keep merge commits out of the request
*   If you have any merge or mixup commits, please [squash](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) them.

If a commit touches multiple files, or isn’t one logical bug fix, or a file is touched in multiple commits, we’ll probably ask you to `rebase` and `squash` your commits. For this reason, you should avoid pushing to your `master` branch. Note, after rebase and/or squash, you'll need to push with `--force` to your remote.

# Overview of the Formula Install Process

*   The result of `Formula.download_strategy` is instantiated.
*   `DownloadStrategy.fetch` is called (downloads tarball, checks out git repository, etc.)
*   A temporary sandbox is created in `/tmp/$formulaname`
*   `DownloadStrategy.stage` is called (extracts tarball to above sandbox, exports git repository to sandbox, etc.)
*   Patches are applied
*   Current directory is changed to the stage root (so when you `system make`, it works)
*   `Formula.install` is called
*   Anything installed to the keg is cleaned (see later)
*   The keg is symlinked into Homebrew’s prefix
*   Caveats are displayed

# Convenience Tools

## Messaging

Three commands are provided for displaying informational messages to the user:

*   `ohai` for general info
*   `opoo` for warning messages
*   `onoe` for error messages

In particular, when a test needs to be performed before installation use `onoe` to bail out gracefully. For example:

```ruby
if some_test?
  system "make", "install"
else
  onoe "Error! Something is wrong."
end
```

## bin.install "foo"

You’ll see stuff like that in other formulae. This installs the file foo into the Formula’s `bin` directory (`/usr/local/Cellar/pkg/0.1/bin`) and makes it executable (`chmod 0555 foo`).

## inreplace

A convenience function that can edit files in-place. For example:

`inreplace "path", before, after`

`before` and `after` can be strings or regexps. You can also use the block form:

```ruby
inreplace "path" do |s|
  s.gsub! /foo/, "bar"
end
```

Make sure you modify `s`! This block ignores the returned value.

`inreplace` should be used instead of patches when it is patching something that will never be accepted upstream e.g. make the software’s build system respect Homebrew’s installation hierarchy. If it's Homebrew and MacPorts or OS X specific it should be turned into a patch instead.

If you need modify variables in a Makefile, rather than using `inreplace`, pass them as arguments to make:

```rb
system "make", "target", "VAR2=value1", "VAR2=value2", "VAR3=values can have spaces"
```

```rb
args = %W[
  CC=#{ENV.cc}
  PREFIX=#{prefix}
]

system "make", *args
```

Note that values *can* contain unescaped spaces if you use the multiple-argument form of `system`.

## Patches

While patches should generally be avoided, sometimes they are necessary.

When patching (i.e. fixing header file inclusion, fixing compiler warnings, etc.) the first thing to do is check whether or not the upstream project is aware of the issue. If not, file a bug report and/or submit your patch for inclusion. We may sometimes still accept your patch before it was submitted upstream but by getting the ball rolling on fixing the upstream issue you reduce the length of time we have to carry the patch around.

*Always, always, always justify a patch with a code comment!* Otherwise, nobody will know when it is safe to remove the patch, or safe to leave it in when updating the formula. The comment should include a link to the relevant upstream issue(s).

External patches can be declared using resource-style blocks:

```rb
patch do
  url "https://example.com/example_patch.diff"
  sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7"
end
```

A strip level of -p1 is assumed. It can be overridden using a symbol argument:

```rb
patch :p0 do
  url "https://example.com/example_patch.diff"
  sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7"
end
```

Patches can be declared in stable, devel, and head blocks. NOTE: always use a block instead of a conditional, i.e. `stable do ... end` instead of `if build.stable? then ... end`.

```rb
stable do
  # some other things...

  patch do
    url "https://example.com/example_patch.diff"
    sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7"
  end
end
```

Embedded (__END__) patches can be declared like so:

```rb
patch :DATA
patch :p0, :DATA
```

with the patch data included at the end of the file:

```
__END__
diff --git a/foo/showfigfonts b/foo/showfigfonts
index 643c60b..543379c 100644
--- a/foo/showfigfonts
+++ b/foo/showfigfonts
@@ -14,6 +14,7 @@
…
```

Patches can also be embedded by passing a string. This makes it possible to provide multiple embedded patches while making only some of them conditional.
```rb
patch :p0, "..."
```

In embedded patches, the string `HOMEBREW_PREFIX` is replaced with the value of the constant `HOMEBREW_PREFIX` before the patch is applied.

## Creating the diff

    brew install --interactive --git foo
    …
    (make some edits)
    …
    git diff | pbcopy
    brew edit foo

Now just paste into the formula after `__END__`.
Instead of `git diff | pbcopy`, for some editors `git diff >> path/to/your/formula/foo.rb` might help you that the diff is not touched (e.g. white space removal, indentation, etc.)

# Advanced Formula Tricks

If anything isn’t clear, you can usually figure it out with some `grep` and the `Library/Formula` directory. Please amend this document if you think it will help!

## Unstable versions (`HEAD`, `devel`)

Formulae can specify alternate downloads for the upstream project’s `devel` release (unstable but not `trunk`) or `HEAD` (`master/trunk`).

### HEAD

HEAD URLs (activated by passing `--HEAD`) build the development cutting edge. Specifying it is easy:

```ruby
class Foo < Formula
  head "https://github.com/mxcl/lastfm-cocoa.git"
end
```

Homebrew understands `git`, `svn`, and `hg` URLs, and has a way to specify `cvs` repositories as a URL as well. You can test whether the `HEAD` is being built with `build.head?`.

To use a specific commit, tag, or branch from a repository, specify head with the `:tag` and `:revision`, `:revision`, or `:branch` option, like so:

```ruby
class Foo < Formula
  head "https://github.com/some/package.git", :revision => "090930930295adslfknsdfsdaffnasd13"
                                         # or :branch => "develop"
                                         # or :tag => "1_0_release",
                                         #    :revision => "090930930295adslfknsdfsdaffnasd13"
end
```

Formulae that only have `head` versions should be submitted to [homebrew/headonly](https://github.com/Homebrew/homebrew-headonly) instead of Homebrew/homebrew.

### devel

The "devel" spec (activated by passing `--devel`) is used for a project’s unstable releases. It is specified in a block:

```ruby
devel do
  url "https://foo.com/foo-0.1.tar.gz"
  sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7"
end
```

You can test if the "devel" spec is in use with `build.devel?`.

## Compiler selection

Sometimes a package fails to build when using a certain compiler. Since recent Xcode no longer includes a GCC compiler, we cannot simply force the use of GCC. Instead, the correct way to declare this is the `fails_with` DSL method. A properly constructed `fails_with` block documents the latest compiler build version known to cause compilation to fail, and the cause of the failure. For example:

```ruby
fails_with :llvm do
  build 2335
  cause <<-EOS.undent
    The "cause" field should include a short summary of the error. Include
    the URLs of any relevant information, such as upstream bug reports. Wrap
    the text at a sensible boundary (~72-80 characters), but do not break
    URLs over multiple lines.
    EOS
end
```

`build` takes a Fixnum (you can find this number in your `brew --config` output). `cause` takes a string, and the use of heredocs is encouraged to improve readability and allow for more comprehensive documentation.

`fails_with` declarations can be used with any of `:gcc`, `:llvm`, and `:clang`. Homebrew will use this information to select a working compiler (if one is available).

## Specifying the Download Strategy explicitly

To use one of Homebrew’s built-in download strategies, specify the `:using =>` flag on a `url` or `head`.  For example:

```ruby
class Sip < Formula
  url "http://www.riverbankcomputing.co.uk/hg/sip/archive/4.11"
  md5 "dbafd7101a4e7caee6f529912a1356e5"
  head "http://www.riverbankcomputing.co.uk/hg/sip", :using => :hg
  homepage "http://www.riverbankcomputing.co.uk/software/sip"
```

The downloaders offered by Homebrew are:

      Value of :using
      Corresponds To

      :bzr
      BazaarDownloadStrategy

      :curl
      CurlDownloadStrategy

      :cvs
      CVSDownloadStrategy

      :git
      GitDownloadStrategy

      :hg
      MercurialDownloadStrategy

      :nounzip
      NoUnzipCurlDownloadStrategy

      :post
      CurlPostDownloadStrategy

      :svn
      SubversionDownloadStrategy

If you need more control over the way files are downloaded and staged, you can create a custom download strategy and specify it using the `url` method's `:using` option:

```ruby
class MyDownloadStrategy < SomeHomebrewDownloadStrategy
  # Does something cool
end

class Foo < Formula
  url "something", :using => MyDownloadStrategy
end
```

Specifying download strategies can be useful when used with a local repo, where a plain URL would not let you specify how to access it. For example:

```ruby
class Bar < Formula
  head "/users/abc/src/git.git", :using => :git
end
```

## Just copying some files

When your code in the install function is run, the current working directory is set to the extracted tarball.

So it is easy to just copy some files:

```ruby
prefix.install "file1", "file2"
```

Or everything:

```ruby
prefix.install Dir["output/*"]
```

Generally we'd rather you were specific about what files or directories need to be installed rather than installing everything.

### Variables for directory locations

      Name
      Default
      Example

      HOMEBREW_PREFIX
      /usr/local

      prefix
      #{HOMEBREW_PREFIX}/Cellar/#{name}/#{version}
      /usr/local/Cellar/foo/0.1

      opt_prefix
      #{HOMEBREW_PREFIX}/opt/#{name}
      /usr/local/opt/foo

      bin
      #{prefix}/bin
      /usr/local/Cellar/foo/0.1/bin

      doc
      #{prefix}/share/doc/foo
      /usr/local/Cellar/foo/0.1/share/doc/foo

      include
      #{prefix}/include
      /usr/local/Cellar/foo/0.1/include

      info
      #{prefix}/share/info
      /usr/local/Cellar/foo/0.1/share/info

      lib
      #{prefix}/lib
      /usr/local/Cellar/foo/0.1/lib

      libexec
      #{prefix}/libexec
      /usr/local/Cellar/foo/0.1/libexec

      man
      #{prefix}/share/man
      /usr/local/Cellar/foo/0.1/share/man

      man[1-8]
      #{prefix}/share/man/man[1-8]
      /usr/local/Cellar/foo/0.1/share/man/man[1-8]

      sbin
      #{prefix}/sbin
      /usr/local/Cellar/foo/0.1/sbin

      share
      #{prefix}/share
      /usr/local/Cellar/foo/0.1/share

      etc
      #{HOMEBREW_PREFIX}/etc
      /usr/local/etc

      var
      #{HOMEBREW_PREFIX}/var
      /usr/local/var

      buildpath
      A temporary dir somewhere on your system
      /private/tmp/[formula-name]-0q2b/[formula-name]

These can be used, for instance, in code such as

```ruby
bin.install Dir["output/*"]
```

to install binaries into their correct location into the cellar, and

```ruby
man.mkpath
```

to create the directory structure to the man location.

To install man pages into specific locations, use `man1.install "foo.1", "bar.1"`, `man2.install "foo.2"`, etc.

Note that in the context of Homebrew, `libexec` is reserved for private use by the formula and therefore is not symlinked into `HOMEBREW_PREFIX`.

### Installation without linking into `/usr/local` (keg-only)

If you only need a program for a dependency and it does not need to be linked for public use in `/usr/local`, specify

```ruby
keg_only "This is my rationale."
```

in the Formula class.

## Adding optional steps

If you want to add an option:

```ruby
class Yourformula < Formula
  ...
  option "with-ham", "Description of the option"
  option "without-spam", "Another description"
  depends_on "foo" => :optional  # will automatically add a with-foo option
  ...
```

And then to define the effects the options have:

```ruby
if build.with? "ham"
  # note, no "with" in the option name (it is added by the build.with? method)
end

if build.without? "ham"
  # works as you'd expect. True if `--without-ham` was given.
end

if build.include? "enable-ham"
  # the deprecated style, only useful for options other than `with`/`without` style
end
```

Option names should be prefixed with one of the words `with`, `without`, `no`, or a verb in the imperative tense describing the action to be taken. For example, an option to run a test suite should be named `--with-test` or `--with-check` rather than `--test`, and an option to enable a shared library should be named `--enable-shared` rather than `--shared`.

Note that options that aren’t ` build.with? ` or ` build.without? ` should be actively deprecated where possible. See [wget](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/wget.rb#L27-L31) for an example.

See the [graphviz](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/graphviz.rb) formula for an example.

## File level operations

You can use the file utilities provided by Ruby (`FileUtils`). These are included in the `Formula` class, so you do not need the `FileUtils.` prefix to use them. They are documented [here](http://www.ruby-doc.org/stdlib/libdoc/fileutils/rdoc/index.html).

When creating symlinks, take special care to ensure they are *relative* symlinks. This makes it easier to create a relocatable bottle. For example, to create a symlink in `bin` to an executable in `libexec`, use

```rb
bin.install_symlink libexec/"name"
```

*not*

```rb
ln_s libexec/"name", bin
```

The symlinks created by `install_symlink` are guaranteed to be relative. `ln_s` will only produce a relative symlink when given a relative path.

## Handling files that should persist over formula upgrades

For example, Ruby 1.9’s gems should be installed to `var/lib/ruby/` so that gems don’t need to be reinstalled when upgrading Ruby. You can usually do this with symlink trickery, or *better* a configure option.

### launchd plist files

Homebrew provides two Formula methods for launchd plist files. `plist_name` will return `homebrew.mxcl.<formula>`, and `plist_path` will return, for example, `/usr/local/Cellar/foo/0.1/homebrew.mxcl.foo.plist`.

## Updating formulae

Eventually a new version of the software will be released. In this case you should update the `url` and `sha256`. Please leave the `bottle do ... end`  block as-is; our CI system will update it when we pull your change.

Check if the formula you are updating is a dependency for any other formulae by running `brew uses UPDATED_FORMULA`. If it is a dependency please `brew reinstall` all the dependencies after it is installed and verify they work correctly.

# Style guide

Homebrew wants to maintain a consistent Ruby style across all formulae based on [Ruby Style Guide](https://github.com/styleguide/ruby). Other formulae may not have been updated to match this guide yet but all new ones should. Also:

* The order of methods in a formula should be consistent with other formulae (e.g.: `def patches` goes before `def install`)
* An empty line is required before the `__END__` line

# Troubleshooting for people writing new formulae

### Version detection fails

Homebrew tries to automatically determine the version from the URL in order to save on duplication. If the tarball has a funny name though, you may have to assign the version number:

```ruby
class Foobar
  version "0.7"
end
```

## Bad Makefiles

Not all projects have makefiles that will run in parallel so try to deparallelize:

    brew edit foo

Add all this to the formula (so there will already be a class line, don’t add another or change that, and there’s already an install function, don't add another one, add the lines in the install function below to the top of the problem formula’s install function).

```ruby
class Foo < Formula
  skip_clean :all
  def install
    ENV.deparallelize
    ENV.no_optimization
    system "make"  # separate make and make install steps
    system "make", "install"
  end
end
```

If that fixes it, please open an [issue](https://github.com/Homebrew/homebrew/issues) so that we can fix it for everyone.

## Still won’t work?

Check out what MacPorts and Fink do:

`brew -S --macports foo`

`brew -S --fink foo`

# Superenv Notes

`superenv` is a "super" environment that tries to improve reliability for the general case. But it does make making formula harder.

To not use `superenv`, install with `--env=std`.

Superenv isolates builds by removing `/usr/local/bin` and all user-PATHs that are not determined to be essential to the build. It does this because other PATHs are full of stuff that breaks builds. (We have 15,000 tickets as testament!)

`superenv` tries to remove bad-flags from the commands passed to `clang`/`gcc` and injects others (for example all `keg_only` dependencies are added to the `-I` and `-L` flags. If superenv troubles you, try to `brew install --env=std` and report to us if that fixes it.

# Fortran

Some software requires a Fortran compiler. This can be declared by adding `depends_on :fortran` to a formula. `:fortran` is a special dependency that does several things.

First, it looks to see if you have set the `FC` environment variable. If it is set, Homebrew will use this value during compilation. If it is not set, it will check to see if `gfortran` is found in `PATH`. If it is, Homebrew will use its location as the value of `FC`. Otherwise, the `gcc` formula will be treated as a dependency and installed prior to compilation.

If you have set `FC` to a custom Fortran compiler, you may additionally set `FCFLAGS` and `FFLAGS`. Alternatively, you can pass `--default-fortran-flags` to `brew install` to use Homebrew's standard `CFLAGS`.

When using Homebrew's own gfortran compiler, the standard `CFLAGS` are used and user-supplied values of `FCFLAGS` and `FFLAGS` are ignored for consistency and reproducibility reasons.

# How to start over (reset to `master`)?

Have you created a real mess in git which paralyzes you to create the commit you just want to push?
Then you might consider start from scratch.
Your changes will be discarded in favour of the `master` branch:

`git checkout master`

`git reset --hard FETCH_HEAD`