text:
extern "C" {
#endif

//  @generated
// --------------------------------------------------------------------------
// clang-format off
//  Generated section start.
// --------------------------------------------------------------------------

//
//  Handle 'signed data info' context.
//
typedef struct vscf_signed_data_info_t vscf_signed_data_info_t;

//
//  Return size of 'vscf_signed_data_info_t'.
//
VSCF_PUBLIC size_t
vscf_signed_data_info_ctx_size(void);

//
//  Perform initialization of pre-allocated context.
//
VSCF_PUBLIC void
vscf_signed_data_info_init(vscf_signed_data_info_t *self);

//
//  Release all inner resources including class dependencies.
//
VSCF_PUBLIC void
vscf_signed_data_info_cleanup(vscf_signed_data_info_t *self);

//
//  Allocate context and perform it's initialization.
//
VSCF_PUBLIC vscf_signed_data_info_t *
vscf_signed_data_info_new(void);

//
//  Release all inner resources and deallocate context if needed.
//  It is safe to call this method even if the context was statically allocated.
//
VSCF_PUBLIC void
vscf_signed_data_info_delete(vscf_signed_data_info_t *self);

//
//  Delete given context and nullifies reference.
//  This is a reverse action of the function 'vscf_signed_data_info_new ()'.
//
VSCF_PUBLIC void
vscf_signed_data_info_destroy(vscf_signed_data_info_t **self_ref);

//
//  Copy given class context by increasing reference counter.
//
VSCF_PUBLIC vscf_signed_data_info_t *
vscf_signed_data_info_shallow_copy(vscf_signed_data_info_t *self);

//
//  Set information about algorithm that was used to produce data digest.
//
VSCF_PRIVATE void
vscf_signed_data_info_set_hash_alg_info(vscf_signed_data_info_t *self, vscf_impl_t **hash_alg_info_ref);

//
//  Return information about algorithm that was used to produce data digest.
//
VSCF_PUBLIC const vscf_impl_t *
vscf_signed_data_info_hash_alg_info(const vscf_signed_data_info_t *self);

// --------------------------------------------------------------------------
//  Generated section end.
// clang-format on
// --------------------------------------------------------------------------
//  @end

#ifdef __cplusplus
}
#endif

//  @footer
#endif // VSCF_SIGNED_DATA_INFO_H_INCLUDED
//  @end

redpajama_set_name: RedPajamaGithub


text:
<?php

class NotificationCore
{
	public $types;

	public function __construct()
	{
		$this->types = array('order', 'customer_message', 'customer');
	}

	/**
	 * getLastElements return all the notifications (new order, new customer registration, and new customer message)
	 * Get all the notifications
	 *
	 * @return array containing the notifications
	 */
	public function getLastElements()
	{
		global $cookie;

		$notifications = array();
		$employee_infos = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
		SELECT id_last_order, id_last_customer_message, id_last_customer
		FROM `'._DB_PREFIX_.'employee`
		WHERE `id_employee` = '.(int)$cookie->id_employee);

		foreach ($this->types as $type)
			$notifications[$type] = Notification::getLastElementsIdsByType($type, $employee_infos['id_last_'.$type]);

		return $notifications;
	}

	/**
	 * getLastElementsIdsByType return all the element ids to show (order, customer registration, and customer message)
	 * Get all the element ids
	 *
	 * @param string $type contains the field name of the Employee table
	 * @param integer $id_last_element contains the id of the last seen element
	 * @return array containing the notifications
	 */
	public static function getLastElementsIdsByType($type, $id_last_element)
	{
		switch ($type)
		{
			case 'order':
				$sql = '
					SELECT SQL_CALC_FOUND_ROWS o.`id_order`, o.`id_customer`, o.`total_paid`, o.`id_currency`, o.`date_upd`, c.`firstname`, c.`lastname`
					FROM `'._DB_PREFIX_.'orders` as o
					LEFT JOIN `'._DB_PREFIX_.'customer` as c ON (c.`id_customer` = o.`id_customer`)
					WHERE `id_order` > '.(int)$id_last_element.
					Shop::addSqlRestriction(false, 'o').'
					ORDER BY `id_order` DESC
					LIMIT 5';
				break;

			case 'customer_message':
				$sql = '
					SELECT SQL_CALC_FOUND_ROWS c.`id_customer_message`, ct.`id_customer`, ct.`id_customer_thread`, ct.`email`, c.`date_add` as date_upd
					FROM `'._DB_PREFIX_.'customer_message` as c
					LEFT JOIN `'._DB_PREFIX_.'customer_thread` as ct ON (c.`id_customer_thread` = ct.`id_customer_thread`)
					WHERE c.`id_customer_message` > '.(int)$id_last_element.'
						AND c.`id_employee` = 0
						AND ct.id_shop IN ('.implode(', ', Shop::getContextListShopID()).')
					ORDER BY c.`id_customer_message` DESC
					LIMIT 5';
				break;
			default:
				$sql = '
					SELECT SQL_CALC_FOUND_ROWS t.`id_'.bqSQL($type).'`, t.*
					FROM `'._DB_PREFIX_.bqSQL($type).'` t
					WHERE t.`deleted` = 0 AND t.`id_'.bqSQL($type).'` > '.(int)$id_last_element.
					Shop::addSqlRestriction(false, 't').'
					ORDER BY t.`id_'.bqSQL($type).'` DESC
					LIMIT 5';
				break;
		}

		$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, true, false);
		$total = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()', false);
		$json = array('total' => $total, 'results' => array());
		foreach ($result as $value)
		{
			$customer_name = '';
			if (isset($value['firstname']) && isset($value['lastname']))
				$customer_name = Tools::safeOutput($value['firstname'].' '.$value['lastname']);
			else if (isset($value['email']))
				$customer_name = Tools::safeOutput($value['email']);

			$json['results'][] = array(
				'id_order' => ((!empty($value['id_order'])) ? (int)$value['id_order'] : 0),
				'id_customer' => ((!empty($value['id_customer'])) ? (int)$value['id_customer'] : 0),
				'id_customer_message' => ((!empty($value['id_customer_message'])) ? (int)$value['id_customer_message'] : 0),
				'id_customer_thread' => ((!empty($value['id_customer_thread'])) ? (int)$value['id_customer_thread'] : 0),
				'total_paid' => ((!empty($value['total_paid'])) ? Tools::displayPrice((float)$value['total_paid'], (int)$value['id_currency'], false) : 0),
				'customer_name' => $customer_name,
				'update_date' => isset($value['date_upd']) ? (int)strtotime($value['date_upd']) * 1000 : 0, // x1000 because of moment.js (see: http://momentjs.com/docs/#/parsing/unix-timestamp/)
			);
		}

		return $json;
	}

	/**
	 * updateEmployeeLastElement return 0 if the field doesn't exists in Employee table.
	 * Updates the last seen element by the employee
	 *
	 * @param string $type contains the field name of the Employee table
	 * @return boolean if type exists or not
	 */
	public function updateEmployeeLastElement($type)
	{
		global $cookie;

		if (in_array($type, $this->types))
			// We update the last item viewed
			return Db::getInstance()->execute('
			UPDATE `'._DB_PREFIX_.'employee`
			SET `id_last_'.bqSQL($type).'` = (
				SELECT IFNULL(MAX(`id_'.$type.'`), 0)
				FROM `'._DB_PREFIX_.(($type == 'order') ? bqSQL($type).'s' : bqSQL($type)).'`
			)
			WHERE `id_employee` = '.(int)$cookie->id_employee);
		return false;
	}
}


text:
{% extends "feedback/base.html" %}

{% block page_title %}{{ _('Select A Product') }}{% endblock %}

{% block site_js %}
  {% javascript 'singlecard' %}
{% endblock %}

{% block content %}

{{ _('Select a product') }}

          {% if not products %}

{{ _('No products available.') }}

          {% else %}

                  {% trans %}
                    JavaScript is required to leave feedback. Please enable JavaScript in your browser and refresh this page.
                  {% endtrans %}

              {% trans %}
                Select a product to leave feedback for.
              {% endtrans %}

                {% for prod in products %}

                      {{ prod.display_name }}
                      {{ prod.display_description }}

                {% endfor %}

          {% endif %}

{% endblock %}


text:
package com.kakao.cuesheet.examples

import com.kakao.cuesheet.CueSheet
import com.kakao.cuesheet.examples.util.{ExampleData, Row}
import org.apache.spark.rdd.RDD

/** splitTo will split tab-separated values into case classes */
object SplitToCaseClassExample extends CueSheet {{

  val file = sc.textFile(ExampleData.path)

  val rows: RDD[Row] = file.splitTo[Row]

  rows.collect().foreach {
    case Row(id, key, score) => println(s"[$id] $key => $score")
  }

  sc.stop()

}}


text:
#if defined(UNIX)
#include <unistd.h>
#endif

#ifdef _WINDOWS
#include "windows.h"
#endif

#if defined(_WinIO)
#include "winio.h"
#else
#include <stdio.h>
#endif
/* #include <stdlib.h> */
#include <string.h>

#if defined(_WINDLL) && !defined(WIN32) && !defined(STATICLINK)
#include "ccmalloc.h"
#else
#if defined(UNIX)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#endif

#if !defined(UNIX)
#include <io.h>
#endif
#if defined(UNIX)
#include "wtype.h"
#endif
#include "cc.h"
#include "c8type.h"
#if defined(_WINDOWS) || defined(UNIXSHAREDLIB)
#include "cctio.h"
#endif
#ifndef min
#define min(x,y) ((x<y)?x:y)	/* return smaller of x and y */
#endif
#if defined(_WINDOWS) || defined(UNIXSHAREDLIB)
#define xgetc(x) wgetc(x)
#define xungetc(x,y) wungetc(x,y)
#define xfeof(x) wfeof(x)
#else
#define xgetc(x) getc(x)
#define xungetc(x,y) ungetc(x,y)
#define xfeof(x) feof(x)
#endif

/* Static variables */
static char *names[4] =
    {
        "Stores:  ",
        "Switches:",
        "Groups:  ",
        "Defines: "
    };

/* Static functions defined in this module */
static void check_symbol_table(void);
static void dump_symbol_table(void);
static void discard_symbol_table(void);
static void fontmsg(void);
static bool goes_before(tbltype, tbltype);

/*****************************************************************************/
static void check_symbol_table() /* Check symbol table for possible typos */
/*****************************************************************************/

/*
 * Description:
 *						Check the symbol table for symbols which were referenced
 *						  but not defined, which usually indicates a
 *						  misspelled name.
 *
 * Return values: none
 *
 * Globals input:
 *						 sym_table -- symbol table array
 *
 * Globals output: none
 *
 * Error conditions: If a symbol is found that is referenced but not
 *							  defined, an appropriate warning message will be
 *							  displayed on the screen.
 *
 * Other procedures called: none
 *
 */

{
    int i;  /* Loop index */
    register CC_SYMBOL *sym_pntr;  /* Pointer for traversing the lists */

    for (i = 0; i < 4; i++ )
    {
        if ( (sym_pntr = sym_table[i].list_head) != NULL )
        {
            while ( sym_pntr != NULL )				/* Check the symbol table */
            {
                if ( sym_pntr->use == REFERENCED )
                {
                    switch( i )
                    {
                    case STORE_HEAD:
                        // do not print warning message if we are looking at an
                        // out command with a predefined store
                        if (( storepre[sym_pntr->number] != 0 ) &&
                                (strncmp(sym_pntr->name, "cccurrentdate", 13) == 0 ))
                            break;
                        if (( storepre[sym_pntr->number] != 0 ) &&
                                (strncmp(sym_pntr->name, "cccurrenttime", 13) == 0 ))
                            break;
                        if (( storepre[sym_pntr->number] != 0 ) &&
                                (strncmp(sym_pntr->name, "ccversionmajor", 14) == 0))
                            break;
                        if (( storepre[sym_pntr->number] != 0 ) &&
                                (strncmp(sym_pntr->name, "ccversionminor", 14) == 0))
                            break;
                        Process_msg(errorFunction, 32, 0,
                                    (long unsigned) sym_pntr->name);
                        break;
                    case SWITCH_HEAD:
                        Process_msg(errorFunction, 33, 0,
                                    (long unsigned) sym_pntr->name);
                        break;
                    case GROUP_HEAD:
                        Process_msg(errorFunction, 34, 0,
                                    (long unsigned) sym_pntr->name);
                        break;
                    case DEFINE_HEAD:
                        Process_msg(errorFunction, 35, 0,
                                    (long unsigned) sym_pntr->name);
                        break;
                    } /* End--switch */

                } /* End--if (referenced-but-undefined symbol) */

                sym_pntr = sym_pntr->next;
            } /* End--traverse the symbol table */

        } /* End--if non-empty symbol table */

    } /* End--for */

} /* End--check_symbol_table */

int get_symbol_number(char * symbol_name, int iSymbolTable)
{
    register CC_SYMBOL *sym_pntr;  /* Pointer for traversing the lists */

    for (sym_pntr= sym_table[iSymbolTable].list_head; sym_pntr != NULL; sym_pntr = sym_pntr->next)
        if (strcmp(symbol_name, sym_pntr->name) == 0)
            break;

    if (sym_pntr)
        return sym_pntr->number;
    else
        return -1;
}

/*****************************************************************************/
static void dump_symbol_table()	  /* Dump symbol table for debug display */
/*****************************************************************************/

/*
 * Description:
 *						Write the symbol table to the screen.	If a table-header
 *							(i.e.--stores, switches, groups, or defines) is empty
 *							say that there are "None" of that category.
 *
 * Return values: none
 *
 * Globals input:
 *						 sym_table -- symbol table array
 *
 * Globals output: none
 *
 * Error conditions: none
 *
 * Other procedures called: none
 *
 */

{
    int i;  /* Loop index */
    register CC_SYMBOL *sym_pntr;  /* Pointer for traversing the lists */
    int  echo_to_stdout;			/* Boolean, TRUE == echo debug info to stdout */

    echo_to_stdout = !isatty( fileno( msgfile ));

    for (i = 0; i < 4; i++ )
    {
        if ( (sym_pntr = sym_table[i].list_head) != NULL )
        {
            msg_printf("%s  Number  Name\n", names[i]);  /* Column headings */
            if ( echo_to_stdout )
                fprintf( msgfile, "%s  Number  Name\n", names[i] );

            while ( sym_pntr != NULL )				/* Print the symbol table */
            {
                msg_printf("\t   %3d     %s\n",
                           sym_pntr->number, sym_pntr->name );
                if ( echo_to_stdout )
                    fprintf(msgfile, "\t   %3d     %s\n",
                            sym_pntr->number, sym_pntr->name );

                sym_pntr = sym_pntr->next;
            } /* End--traverse the symbol table */
        } /* End--if non-empty symbol table */
        else
        {
            msg_printf("%s\tNone\n", names[i]);		  /* Nothing there */
            if ( echo_to_stdout )
                fprintf(msgfile, "%s\tNone\n", names[i] );
        }
    } /* End--for */

} /* End--dump_symbol_table */

/*****************************************************************************/
static void discard_symbol_table()	  /* Discard symbol table */
/*****************************************************************************/

/*
 * Description:	Free symbol table
 *
 * Return values: none
 *
 * Globals input:
 *						 sym_table -- symbol table array
 *
 * Globals output:	none
 *
 * Error conditions: none
 *
 * Other procedures called: none
 *
 */

{
    int i;  /* Loop index */
    register CC_SYMBOL *sym_pntr;  /* Pointer for traversing the lists */
    register CC_SYMBOL *temp_pntr;

    /* For all 4 symbol tables, loop through freeing all entries */
    for (i = 0; i < 4; i++ )
    {
        sym_pntr = sym_table[i].list_head;
        while ( sym_pntr != NULL )
        {
            free(sym_pntr->name);
            temp_pntr = sym_pntr;
            sym_pntr = sym_pntr->next;
            free(temp_pntr);
        }
        sym_table[i].list_head = NULL;
    } /* End--for */

} /* End--discard_symbol_table */

/****************************************************************************/
void *tblalloc(count, size)						/* Allocate tables */
/****************************************************************************/
unsigned count,	/* # of objects in the requested table */
size;		/* Length of the objects in bytes */

/* Description -- Try to allocate the requested table.
 *						If unsuccessful
 *							Display an error message.
 *							Exit with exit code = BADEXIT.
 *
 *						Return a pointer to the table.
 *
 * Return values: Return a pointer to requested table.
 *
 * Globals input: none
 *
 * Globals output: none
 *
 * Error conditions:  If malloc fails we will be unable to continue,
 *								so display an informative message and exit
 *								to the operating system.
 *
 * Other functions called: none
 *
 */

{
    void *mp;  /* Pointer to the table (returned by malloc) */
#ifdef DEBUG
    fprintf(msgfile,"tblalloc -- count = %u, size = %u\n", count, size);
#endif
    mp = malloc( (unsigned) (count * size));	/* Try to allocate the table */

    if ( mp == NULL )
    {
        Process_msg(errorFunction, 36, 0, 0);
        bailout(BADEXIT, FALSE);				/*  and bail out		 */
    }
    return(mp);			/* Return a pointer to the table */

} /* End--tblalloc */

/****************************************************************************/
void tblcreate()													 /* Create tables */
/****************************************************************************/

/* Description:
 *						Allocate the tables, using tblalloc (above).
 *
 * Return values: All dynamically allocated tables allocated.
 *
 * Globals input: backbuf -- ring buffer for backup
 *						cngpointers -- pointers to changes in table
 *						match -- match area for searching
 *  (MS only)		tabs -- tabs array
 *
 * Globals output: All of those input, pointing to actual data areas
 *
 * Error conditions: If we encounter an error allocating anything but
 *							  table, tblalloc will exit to the OS for us.
 *
 * Other functions called: tblalloc -- allocate a table
 *
 */

{
#if defined(_WINDOWS) || defined(UNIXSHAREDLIB)
    //these should work well for DOS EXE or FUNC versions
    // perhaps we should replace the older code after memory alloc testing
    if (backbuf == NULL)										//7.4.15
        backbuf = (SSINT *) tblalloc(BACKBUFMAX, sizeof(*backbuf));
    if (cngpointers == NULL)
        cngpointers = (tbltype *) tblalloc(MAXCHANGES+1, sizeof(*cngpointers));
    if (match == NULL)
        match = (SSINT *) tblalloc(MAXMATCH, sizeof(*match));
#else
    //this is the older DOS EXE code
    backbuf = (SSINT *) tblalloc(BACKBUFMAX, sizeof(*backbuf));
    cngpointers = (tbltype *) tblalloc(MAXCHANGES+1, sizeof(*cngpointers));
    match = (SSINT *) tblalloc(MAXMATCH, sizeof(*match));
#endif

} /* End--tblcreate */

#if defined(_WINDOWS) || defined(UNIXSHAREDLIB)
/****************************************************************************/
void tblfree()					/* Free all memory used by tables */ //7.4.15
/****************************************************************************/

/* Description:
 *				Free all memory used by various tables, allocated by
 *					tblcreate() and compilecc() and symbol table compilation
 *
 * All the malloc/free code needs to be tested by a memory debugger
 *
 * Return values: none
 *
 * Globals input:	backbuf -- ring buffer for backup
 *					cngpointers -- pointers to changes in table
 *					match -- match area for searching
 *                  table -- compiled CC table
 *					sym_table --
 *
 * Globals output: Global pointers to the former tables are set to NULL
 *
 * Error conditions: none
 *
 * Other functions called: symb
 *
 */

{
    //allocated by tblcreate()
    if (backbuf != NULL)										//7.4.15
    {
        free (backbuf);
        backbuf = NULL;
    }
    if (cngpointers != NULL)
    {
        free (cngpointers);
        cngpointers = NULL;
    }
    if (match != NULL)
    {
        free (match);
        match = NULL;
    }

    //allocated by compilecc()
    if (table != NULL)
    {
        free (table);
        table = NULL;
    }

    //allocated by symbol table compilation
    discard_symbol_table();

} /* End--tblfree */
#endif

/************************************************************************/
unsigned int max_heap()		/* Compute size of remaining heap space */
/************************************************************************/
/*
 * DESCRIPTION: Repeatedly calls 'malloc' and 'free' until it has found
 * the largest malloc-able buffer.  The size of this buffer is
 * returned.  The buffer is freed.
 *
 * RETURN VALUES: Returns an UNSIGNED int containing size (in bytes) of
 * largest malloc-able buffer.
 *
 * GLOBALS INPUT:		none
 * GLOBALS OUTPUT:		none
 * ERROR CONDITIONS:	none
 */
/************************************************************************/
{
    char *buffer;                    /* buffer pointer */
    unsigned int high, low, t;       /* loop controls  */

#if defined(_WINDOWS) || defined(_WindowsExe)  || defined(UNIXSHAREDLIB)
    //for computers of the 1990's, try MAX_ALLOC (nearly 64K) first,
    // and use that size if successful
    if (
        (buffer = (char *) malloc((size_t)MAX_ALLOC)) != NULL)			//7.4.15
    {
        free (buffer);
        return MAX_ALLOC;
    }
#endif
    //try various smaller sizes
    high = MAX_ALLOC;           /* Highest amount to request */
    low = 0;                    /* Lowest amount */
    while ( low < (high-1) )    /* Loop until only 1-byte difference */
    {
        t = low + (high-low)/ 2; /* Compute trial buffer size */
        if ((buffer = (char *)malloc(t)) != NULL) /* Attempt to allocate that size */
        {						/* If successful... */
            free(buffer);		/* ...free the buffer and... */
            low = t;				/* ...raise the 'low' value */
        }
        else						/* else... */
            high = t;			/* ...lower the 'high' value */
    }

    /* When finished, the 'low' value is the largest malloc-able buffer */
    /* Subtract out RESERVEDSPACE so as not to totally exhaust heap. Bail out
    if there is too little heap space available. */
    if ( low > (unsigned) RESERVEDSPACE )
        low -= RESERVEDSPACE;	/* Leave space for file buffers */
    /*  and prntr's tables */
    else
    {
        Process_msg(errorFunction, 37, 0, (unsigned long) low);
        bailout(BADEXIT, FALSE);
    }

    return(low);
} /* End--max_heap */

/****************************************************************************/
void storechar(ch)					/* Store a char in the internal table */
/****************************************************************************/
SSINT ch;

/* Description -- If there is room in the table
 *							Store ch in the table.
 *						Else
 *							Set the boolean tblfull to TRUE.
 *
 * Return values: none
 *
 * Globals input: tloadpointer -- pointer for storing into table
 *                tablelimit -- address of last element of table
 *						tblfull -- boolean indicating whether there's room
 *										 left in table
 *
 * Globals output: tloadpointer -- if character was successfully stored,
 *												 it will point to the next position
 *												 in table, otherwise it will be unchanged
 *
 *						 tblfull -- if the table fills up, it will be set to TRUE.
 *
 * Error conditions: if table fills up, tblfull will be set to TRUE
 *
 * Other functions called: none
 *
 */

{
    if ( tloadpointer < tablelimit )
        *tloadpointer++ = ch;			/* Store the char in the table */
    else
        tblfull = TRUE;					/* Set error flag */
} /* End--storechar */

/****************************************************************************/
int srchlen(register tbltype tp1)									/* Get length of match of change */
/****************************************************************************/

/* Description -- Go through the table, starting at tp1, until we find
 *						a wedge, return the length from tp1 to the wedge. Count
 *						each full character as SRCHLEN_FACTOR, count any() as
 *						SRCHLEN_FACTOR, count prec() or fol() as 1, and count wd()
 *						and cont() as 2.
 *
 * Return values: returns length of the match.
 *
 * Globals input: none
 *
 * Globals output: none
 *
 * Error conditions: none
 *
 * Other functions called: none
 *
 */

{
    register tbltype tp2;  /* Pointer for going through the table */
    register int length;   /* Length to be returned */

    length = 0;

    for ( tp2 = tp1; *tp2 != SPECWEDGE; tp2++)  /* Find a wedge */
    {
        switch (*tp2)
        {
        case FOLCMD:		/* fol(): count as 1, skip parameter byte */
        case PRECCMD:		/* prec(): count as 1, skip parameter byte */
        case FOLUCMD:		/* folu(): count as 1, skip parameter byte */
        case PRECUCMD:		/* precu(): count as 1, skip parameter byte */
            length++;
            tp2++;
            break;

        case TOPBITCMD:   /* Top bit set: count as 1 full element */
        case ANYCMD:		/* any(): count as 1 full char, skip param. byte */
        case ANYUCMD:		/* anyu(): count as 1 full char, skip param. byte */
            length+=SRCHLEN_FACTOR;
            tp2++;
            break;

        case CONTCMD:		/* cont(): count as 2, skip parameter byte */
        case WDCMD:			/* wd(): count as 2, skip parameter byte */
        case WDUCMD:			/* wd(): count as 2, skip parameter byte */
            length+=2;
            tp2++;
            break;

        default:				/* ordinary character: count as 1 full character */
            length+=SRCHLEN_FACTOR;
        }
    }

    return( length );  /* Return the length from tp1 to the wedge */

} /* End--srchlen */

/****************************************************************************/
bool chk_prec_cmd(void)
/****************************************************************************/
/* Function: chk_prec_cmd
 *
 * Parameters:  none
 *
 * Description -- handle occurences of prec() command before match string
 *				If a prec() command is found at the beginning of a line,
 *				we wait until after the string or any() command before compiling
 *				the prec() command(s) into memory.
 *
 * Globals input: parsepntr parse2pntr precparse
 *
 * Globals output: parse2pntr precparse
 *
 * Error conditions: none
 *
 * Other functions called: none
 *
 * Return values: TRUE if str points to prec() command
 * Function added 2/95 by BJY for 7.4.30
 */

{
    char *saveparse2;

    if (!strncmp( parsepntr, "prec(", 5))
    {
        if (!precparse)
            precparse = parsepntr;	// Save position of first prec() command for later compilation
        return TRUE;
    }
    else
    {
        storeelement(TRUE);
        if (precparse)
        {
            saveparse2 = parse2pntr;	// Save pointer for later restoration
            parse2pntr = precparse;
            while (1)				// go store prec() command(s) now
            {
                parse( &parsepntr, &parse2pntr, TRUE);
                if (parse2pntr >= saveparse2)
                    break;
                storeelement(TRUE);
            }
            parse2pntr = saveparse2;	// restore position in line
        }
        return FALSE;
    }
}

/****************************************************************************/
void compilecc()									 /* Initialize CC part of program */
/****************************************************************************/

/* This procedure is the initialization of the Consistent Change part of the
program. */

/* Description:
 *						Initialize the Consistent Change part of the program,
 *					including loading the change table if there is one and
 *					compiling it if necessary.
 *
 * Return values: none
 *
 * Globals input:
 *						sym_table -- table used for symbolic names within the
 *												change table
 *						tablelimit -- highest valid address in table
 *						fontsection -- boolean: TRUE == compiling font section
 *																	 of table
 * (MS only)		mandisplay -- boolean: TRUE == echo MS code to screen
 *						uppercase -- boolean:
 *						caseless -- boolean: TRUE == ignore case on input text
 *						debug -- boolean: TRUE == give debug display
 *						mydebug -- boolean:
 *						tablefile -- pointer to CC table input file,
 *											also used for compiled output file
 *						filenm -- file name buffer
 *						namelen -- length of contents of filenm
 *						tblarg -- table name if input on command line
 *						notable -- boolean: TRUE == no change table
 *						parsepntr -- pointer into input line
 *						parse2pntr -- pointer into input line
 *						was_math -- boolean: TRUE == last command parsed was a
 *																 math operator
 *																(add, sub, mul, div)
 *
 * Globals output:  All booleans set.
 *						  Pointers in unknown state.
 *
 * Error conditions: If a file is not found or is too small,
 *							  the user will be given another chance.
 *							If there is an error while compiling the table,
 *							  an appropriate error message will be displayed.
 *
 * Other functions called:
 *                         storechar -- store an element in the table
 *									inputaline -- read a line of input from
 *														the table file
 *									wedgeinline -- is there a > in the input line?
 *									parse -- find the next logical group in
 *												  the input line
 *									storeelement -- store an element in the internal
 *															change table
 *									cctsetup -- set up the pointers for the
 *													  internal change table
 *									cctsort -- sort the array of pointers into the
 *													 change table
 *									fontmsg -- display an appropriate message because
 *													 we found a font section
 *  (debugging only)			cctdump -- dump the internal change table to the
 *													 screen
 *
 */

{
    unsigned tablemax;		  /* largest valid subscript +1 for table */
    unsigned tablesize = 0;		  /* actual loaded size of table */
    SSINT ch;
    int i;		/* Miscellaneous loop index */
    int before;
    int after;
#if !defined(_WINDOWS) && !defined(UNIXSHAREDLIB)
    char *optptr;					/* pointer to option strings */
#endif
    int check_prec;		// 7.4.30 BJY
    char *errPtr;

    /* Allocate space for compiled CC table (freeing the old one first
    if necessary) */
    if (table != NULL)
        free(table);
#ifdef _WINDLL
    // in DLL mode just go for the maximum size, don't mess around
    tablemax = MAX_ALLOC / sizeof(SSINT);
#else
    tablemax = max_heap() / sizeof(SSINT);  /* Get as much space as available */
#endif
    table = (SSINT *) tblalloc(tablemax, (sizeof(SSINT)));
    tablelimit = table + tablemax;		/* Initialize limits */

    /* Initialize internal booleans */
    fontsection = FALSE;
    was_math = FALSE;
    was_string = FALSE;
    uppercase = FALSE;
    caseless = FALSE;
    debug = mydebug = 0;			 /* init debugs false */
    pstrBuffer= strBuffer;
#if defined(_WINDLL)
    memset(TableLineIndexes, 0, sizeof(TableLineIndexes));
#endif
    /* Initialize the symbol table */
    for ( i = 0; i < 4; i++ )
    {
        sym_table[i].list_head = NULL;
        sym_table[i].next_number = MAXARG;
    }

    bytset(storepre, 0, NUMSTORES+1);   // do this before processing cc table

    errors = FALSE;			 /* initialize */
    tblfull = FALSE;
    doublebyte_mode = FALSE;       /* initialize doublebyte due to early scan  */
    doublebyte_recursion = FALSE;
    doublebyte1st = doublebyte2nd = 0;
    utf8encoding= FALSE;
    tloadpointer = table;
    cngpend = cngpointers;

#if defined(_WINDOWS) || defined(UNIXSHAREDLIB)
    if (lpszCCTableBuffer)
    {
        tablefile= NULL;
    }
    else
    {
        strcpy( filenm, tblarg );           /* copy name from command line */
        namelen = strlen( filenm );

        if ((tablefile= wfopen(filenm,BINREAD)) == NULL)
        {
            if ( (strchr(filenm, '.') == NULL)
                    || (strrchr( filenm, '.') == (strchr(filenm, DIRSEP) - 1)) )
            {
                strcat( filenm, ".CCT" );	/* Try an extension of .CCT */
                tablefile= wfopen(filenm,BINREAD);
            }

            if (tablefile == NULL)
            {
#if !defined(UNIX)
                upcase_str( filenm );		/* force output arg to upper case */
#endif
                errPtr = &filenm[0];
                Process_msg(errorFunction, 55, 0, (long unsigned) errPtr);
                errors = TRUE;                                      //7.4.15
                return;
            }

        }
    }
    notable = FALSE;
#else
    strcpy( filenm, tblarg );           /* copy name from command line */
    namelen = strlen( filenm );
    do
    {

        tablefile = NULL;
        if (namelen != 0)		  /* check for no table */
        {
#if !defined(UNIX)
            optptr = strchr( filenm, '/' );		/* look for slash option */
            if ( optptr )
            {
                if ( tolower( *(optptr+1) ) == 'd' )
                {
                    debug = TRUE;					/* set debug option */
                    single_step = TRUE;
                }
                else
                {
                    Process_msg(errorFunction, 54, 0, (long unsigned) optptr);
                }
                *optptr = '\0';			/* terminate file name before option */
            }
#endif
            if ( (tablefile=fopen(filenm,BINREAD)) == NULL )
            {
                if ( (strchr(filenm, '.') == NULL)
                        || (strrchr( filenm, '.') == (strchr(filenm, DIRSEP) - 1)) )
                {
                    strcat( filenm, ".CCT" );	/* Try an extension of .CCT */
                    tablefile = fopen( filenm, BINREAD);
                }
            }
            if ( tablefile == NULL )
            {
#if !defined(UNIX)
                upcase_str( filenm );		/* force output arg to upper case */
#endif
                errPtr = &filenm[0];
                Process_msg(errorFunction, 55, 0, (long unsigned) errPtr);
#if !defined(NO_QUESTIONS)
                getname("Enter CC Table name : ", filenm);
                namelen = strlen( filenm );
#else
                bailout( BADEXIT, FALSE );
#endif
            }
        }
    } while ( (tablefile == NULL) && (namelen != 0) );

    if ( tablefile == NULL || namelen == 0 )
        bailout( BADEXIT, FALSE );

    if (namelen == 0)
    {
        notable = TRUE;
        storechar(SPECPERIOD);
    }
    else
        notable = FALSE;
#endif

    ch = xgetc(tablefile);

    if (ch == EOF)
        storechar(SPECPERIOD);
    else
    {
        /* see if we have precompiled table (by looking at first byte)   */
        if ((ch & 0x80) && ((ch & 0xFF) != 0xEF))
            /* precompiled tables have one byte per value, if high bit is
            	on then it was a command, so turn on high half of it       */
        {                             /* precompiled table            */
            ch = ch | 0xff00;             /* turn this back into command  */
            storechar(ch);                /* read it directly             */

            while ( (ch = xgetc(tablefile)) != EOF )   /* into table area  */
            {
                if ( ch & 0x80 )           /* if meant to be a command     */
                    ch = ch | 0xff00;       /* turn this back into command  */
                else                       /* old compiled tables had      */
                    if ( ch == CTRLZ )      /*  control Z, make that into   */
                        ch = ENDFILECMD;     /*   the new ENDFILECMD instead */
                storechar(ch);
            }
        }
        else										/* table not precompiled */
        {
			/* Check for Byte Order Mark and ignore if necessary */
			if ((ch & 0xFF) == 0xEF)
			{
				SSINT ch1=xgetc(tablefile);
				if ((ch1 & 0xFF) == 0xBB)
				{
					SSINT ch2= xgetc(tablefile);
					if ((ch2 & 0xFF) != 0xBF)
					{
						xungetc(ch2, tablefile);
						xungetc(ch1, tablefile);
						xungetc(ch, tablefile);
					}

				} else {
					xungetc(ch1, tablefile);
					xungetc(ch, tablefile);
				}
			} else {
				xungetc(ch, tablefile);
			}
#if defined(_WINDLL)
            iCurrentLine= 0;
#endif

            while (!xfeof(tablefile))
            {											/* compile table */
                inputaline();
#if defined(_WINDLL)
                iCurrentLine++;
#endif

#ifdef DEBUG
                if ( debug == 1 )
                    fprintf(msgfile, "%s\n", line);
#endif
                parse2pntr = line;

                if (!wedgeinline())
                {
                    flushstringbuffer(FALSE);
#if defined(_WINDLL)
                    if (TableLineIndexes[iCurrentLine - 1] == 0)
                    {
                        if (strlen(line) > 0)
                            TableLineIndexes[iCurrentLine - 1]= (unsigned)((long)tloadpointer - (long)table) / sizeof(SSINT);
                        else
                            TableLineIndexes[iCurrentLine - 1]= ~0u;	// Neil Mayhew - 6 Nov 98
                    }
#endif
                }
                else
                {										/* search parse */
                    flushstringbuffer(FALSE);
                    storechar( SPECPERIOD);
                    check_prec = TRUE;		// 7.4.30 BJY
                    precparse = NULL;       // 7.4.30
#if defined(_WINDLL)
                    TableLineIndexes[iCurrentLine - 1]= (unsigned)((long)tloadpointer - (long)table) / sizeof(SSINT);
#endif

                    for (;;)
                    {
                        parse( &parsepntr, &parse2pntr, TRUE);
                        if ( !*parsepntr || *parsepntr == WEDGE )
                            break;
                        if (check_prec)		// 7.4.30 BJY Handle prec() command(s) before string
                            check_prec = chk_prec_cmd();
                        else
                            storeelement( TRUE);
                        if ( parsepntr > parse2pntr )
                            parse2pntr = parsepntr;	/*The parse may have gone
                        						* beyond the current element
                        						*/
                    }
                    flushstringbuffer(TRUE);
                    storechar( SPECWEDGE);
                }
                for (;;)
                {									/* replacement parse */
                    parse( &parsepntr, &parse2pntr, TRUE);
                    if ( !*parsepntr )
                        break;
                    storeelement( FALSE);
                    if ( parsepntr > parse2pntr )
                        parse2pntr = parsepntr;		/*The parse may have gone
                    							* beyond the current element
                    							*/
                }
                if (fontsection)
                    break;
            }
            flushstringbuffer(FALSE);
            storechar(SPECPERIOD);
        }
    }
#if defined(_WINDOWS) || defined(UNIXSHAREDLIB)
    if (tablefile)
    {
        wfclose(tablefile);						/* recover file BUFFER */
        tablefile= NULL;
    }
#else
    fclose(tablefile);						/* recover file BUFFER */
#endif
#if defined(_WINDLL)
    TableLineIndexes[iCurrentLine]= (unsigned)((long)tloadpointer - (long)table) / sizeof(SSINT);

    for (i= iCurrentLine; i > 0;)
    {
        i--;

        if (TableLineIndexes[i] == -1)
            TableLineIndexes[i]= TableLineIndexes[i + 1];
    }
#endif
    if ( fontsection )					/* Old style fonts */
        fontmsg();

    if (tblfull)
    {
        Process_msg(errorFunction, 56, 0, 0);
        errors = TRUE;		/* Mark this as a fatal error */
    }

    if (errors)
    {
        //      Process_msg(errorFunction, 57, 0, 0);
    }
    else
    {														/* error flag check */

        /* Now shrink allocation for 'table' down to miminum */
        tablesize = tloadpointer - table;
        table = realloc(table, tablesize * sizeof(SSINT));
        tablelimit = table + tablesize;
        tloadpointer= tablelimit; // ADDED 7-31-95 DAR

        /* Check for symbols that were referenced, but not defined */
        check_symbol_table();

        /* Setup pointers into table[] and sort cngpointers */
        if ( cctsetup() )
            cctsort();
    }
    if ( debug == 1 )
    {
        dump_symbol_table();							/* Dump the symbol table for
        													*	 symbolic names
        													*/
        msg_printf("%d changes, %d maximum\n",
                   cngpend-cngpointers, MAXCHANGES);
        msg_printf("%u total bytes, %u total elements, %u maximum\n",
                   tablesize, tablesize / 2, tablemax);

#ifdef DEBUG
        cctdump();
#endif
        before = (BEFORE_CNT - 6) / 2;
        after = BEFORE_CNT - before - 6;
        for (i = before; i > 0; i--)
            msg_putc('-');
        msg_puts("OUTPUT");
        for (i = after; i > 0; i--)
            msg_putc('-');
        msg_putc('v');
        before = (AFTER_CNT - 6) / 2;
        after = AFTER_CNT - before - 6;
        for (i = before; i > 0; i--)
            msg_putc('-');
        msg_puts("INPUT");
        for (i = after; i > 0; i--)
            msg_putc('-');
        msg_putc('\n');
    }
#if !defined( _WINDOWS) && !defined(UNIXSHAREDLIB)
    else		/* If not in debug mode, discard the symbol table */
        discard_symbol_table();
#endif

} /* End--compilecc */

/****************************************************************************/
int cctsetup()										/* Set up pointers into table */
/****************************************************************************/
{
    /* Description:
     *						Go through and set up the internal representation of the
     *					changes table.
     *
     * Return values:  TRUE == everything is set up OK
     *						FALSE == there was a problem somewhere
     *
     * Globals input:
     *						errors -- Boolean: TRUE == table contains errors
     *						fontstart -- table of pointers to the start of fonts
     *						fontsection -- Boolean: TRUE == table contains old-style
     *																	 fonts
     *						maintablend -- pointer to the end of the changes
     *											  part of the table
     *						tloadpointer -- pointer to the end of what was read
     *												into table
     *						table -- storage area for changes and fonts
     *						defarray -- table of pointers to DEFINEs
     *						cngpend -- pointer to the end of the table of
     *										 change pointers
     *						cngpointers -- table of pointers to changes
     *						groupbeg -- table of pointers to the beginning of groups
     *						maxsrch -- length of longest search string
     *						groupend -- table of pointers to the end of groups
     *
     * Globals output: if there were no problems, everybody is set up.
     *						 if there was a serious problem, errors is set to TRUE.
     *
     * Error conditions: if the table was too big, FALSE will be returned.
     *							if group one was missing or a group is multiply defined,
     *							  FALSE will be returned and
     *							  errors will be set to TRUE, indicating a major error.
     *							Other errors, such as a font section when running CC,
     *							  will only generate warning messages for the user.
     *
     * Other functions called: fontmsg -- display an appropriate message because
     *													 we found a font section in the table
     *
     */

    register tbltype tp;
    register tbltype *ptp;
    cngtype cp;
    int group, i, j;

    /* Look for 'unsorted' and 'binary' and 'doublebyte' commands in 'begin'
    section.  Set global flags accordingly */
    unsorted = FALSE;
    binary_mode = FALSE;
    doublebyte_mode = FALSE;
    utf8encoding = FALSE;
    if (table[0] == SPECWEDGE)		/* If there is a begin section */
    {									/* scan through it */
        for (tp = table+1; *tp != SPECPERIOD; tp++)
        {
            if (*tp == UNSORTCMD)
                unsorted = TRUE;
            else if (*tp == BINCMD)
                binary_mode = TRUE;
            else if (*tp == UTF8CMD)
                utf8encoding = TRUE;
            else if (*tp == DOUBLECMD)
            {
                tp++;                      /* point to doublebyte argument */
                *tp = *tp & 0x00ff;        /* turn off any possible high bits */
                doublebyte_mode = TRUE;
                doublebytestore(*tp);      /* pass argument */
                tp--;                      /* restore tp    */
            }
        }
        // binary is incompatible and not needed with doublebyte mode
        if (( binary_mode == TRUE ) && ( doublebyte_mode == TRUE ))
        {
            binary_mode = FALSE;
            Process_msg(errorFunction, 99, 0, 0);
        }

    }

    maintablend = tloadpointer;							/* set main table end */
    for ( tp = table; tp < tloadpointer; tp++ )
    {
        if (*tp == FONTCMD)			/* Set table end to beginning of font section */
        {
            fontmsg();						/* We have old-style fonts */
            maintablend = tp;
            break;
        }
    }

    for (ptp = defarray; ptp <= defarray+MAXARG; )		/* clear define array */
        *ptp++ = NULL;

    cngpend = cngpointers;								/* build changepointers array */

    for ( tp = table; tp < maintablend-1; )
    {
        if ( *tp++ == SPECPERIOD )
        {
            if ( *tp == DEFINECMD )				/* It's a define, so save its addr */
                defarray[*(tp+1)] = tp + 2;	 /*  in define array */
            else
            {
                if ( cngpend - cngpointers < MAXCHANGES )  /* Must be a change */
                    *cngpend++ = tp;								/*  so save its addr */
                else
                {
                    Process_msg(errorFunction, 38, 0, (long unsigned) MAXCHANGES);
                    return( FALSE);						/* Error */
                }
            } /* End--else */
        } /* End--if */
    } /* End--for */

    for (i = 1; i <= MAXGROUPS; i++)  /* Initialize group array */
        groupbeg[i] = NULL;

    group = 0;

    maxsrch = 0;

    for ( cp = cngpointers; cp < cngpend; cp++)
    {
        tp = *cp;							/* Find length of longest search */
        j = srchlen( tp ) / SRCHLEN_FACTOR;
        if ( j > maxsrch )
            maxsrch = j;

        if ( (tp >= table+3) && (*(tp-3) == GROUPCMD) )  /* Valid group start? */
        {
            *(tp-3) = SPECPERIOD;	 /* Eff remove GROUPCMD */

            if ( group != 0 )
            {
                groupend[group] = cp;	/* Close previous group */
            }
            else
            {
                groupbeg[1] = cngpointers;			/* First group is implied group 1 */
                groupend[1] = cp;
            }

            /* If the group has already been defined */
            /*  AND it's non-empty, squawk */

            group = *(tp-2);
            if ( (groupbeg[group] != NULL) && (groupend[group] != groupbeg[group]) )
            {
                Process_msg(errorFunction, 39, 0,
                            (long unsigned) sym_name(group, GROUP_HEAD));
                errors = TRUE;												/* Major error */
                return(FALSE);
            }
            else
                groupbeg[group] = cp;		/* Save the start of the current group */
        }
    }

    if ( group == 0 )					/* If no groups, set up group 1 */
    {
        group = 1;
        groupbeg[1] = cngpointers;
    }
    groupend[group] = cngpend;			/* Close last group */

    // increase maxsrch so debug display window will display at least 500 characters
    if (maxsrch < MINMATCH)
        maxsrch= MINMATCH;

    return( TRUE);		/* No errors detected */

} /* End--cctsetup */

/****************************************************************************/
static void fontmsg()	  /* Handle font section appropriately */
/****************************************************************************/

/* Description -- If CC or MS and only doing CC
 *							Display "...ignored..." message.
 *						Else
 *							Display "...not supported..." message.
 *
 *							Set global errors to TRUE.
 *
 * Globals output: errors -- set to TRUE if MS and running full MS
 *
 */
{
    Process_msg(errorFunction, 40, 0, 0);
}

/****************************************************************************/
void cctsort()														/* Sort CC table */
/****************************************************************************/

/* Description -- Go through the changes table, group by group and sort
 *						the changes primarily in ascending order of first letter
 *						of match and secondarily in descending order of length
 *						of match.
 *
 *						Find the beginning of left-executes for the group
 *						by going through the group, using j, until
 *						either the first letter of a change has the
 *						high bit set or we hit the end of the group.
 *
 *						Save the beginning of left-executes in groupexeq[group].
 *
 * Return values: none
 *
 * Globals input: groupbeg -- table of pointers to the beginning of groups
 *						groupxeq -- table of pointers to the beginning of
 *										  the left-execute portions of groups
 *
 * Globals output: groupbeg -- the changes within each group will be sorted
 *											numerically by ASCII sequence for
 *											constant match strings and by length
 *											with longest match first within each
 *											character, and any left-executes at the end
 *											of the group.
 *						 groupxeq -- each non-NULL element of groupxeq will point
 *											to the first left-execute for the
 *											corresponding group.
 *
 * Error conditions: there shouldn't be any
 *
 * Other functions called: goes_before -- compares two changes and returns
 *										TRUE if first should go before second
 *
 */

{

    register cngtype k;	/* Inner loop pointer */
    register cngtype j;	/* Outer loop pointer */
    tbltype hold;			/* Pointer to change pointer be inserted */
    int group;  			/* Current group # */

    for ( group = 1; group <= MAXGROUPS; group++ )
    {
        if ( groupbeg[group] != NULL)		/* If group exists... */
        {										/* ...sort the changes */
            /* NOTE: The following is a simple insertion sort. It has the
            	desirable property that is is stable -- that is, changes
            	with matching keys are maintained in the order in which
            	they were found */
            for (j = groupbeg[group] + 1; j < groupend[group]; j++)
            {
                hold = *j;			/* Save pointer to insert */
                for (	k = j - 1;
                        k >= groupbeg[group] && goes_before(hold, *k);
                        k--)
                {
                    *(k+1) = *k;	/* Move other pointers up as needed */
                }
                *(k+1) = hold;		/* Insert the saved pointer */
            }

            /* Set up pointer to the first left-execute */

            for (j = groupbeg[group]; j < groupend[group]; j++)
                if ( **j & HIGHBIT )
                    break;				/* Found one! */
            groupxeq[group] = j;

        } /* End--group exists */
    } /* End--loop through group table */
} /* End--cctsort */

/************************************************************************/
char *sym_name(number, type)	/* Return symbolic name for a given number */
/************************************************************************/
int number;			/* Number of store, switch, group or define */
int type;			/* 0,1,2 or 3 to indicate which store, switch, group */
/* or define, respectively */
{
    static char name_buffer[20];	/* Buffer used if no symbolic name exists */
    register CC_SYMBOL *sym_pntr;	/* Pointer for traversing the list */

    /* Search appropriate symbol table for a matching number */
    sym_pntr = sym_table[type].list_head;
    while ( sym_pntr != NULL )
    {
        if (sym_pntr->number == number)		/* If matching number found... */
            return( sym_pntr->name );			/* return pointer to name */
        else
            sym_pntr = sym_pntr->next;			/* try next in list */
    }

    /* If number was not found, then return number converted to a string */
    sprintf(name_buffer, "%d", number);
    return( name_buffer );
}

/****************************************************************************/
static bool goes_before(x,y)		/* Compare two changes */
/****************************************************************************/
tbltype x;			/* first change */
tbltype y;			/* second change */

/* Description -- Compares two changes and returns TRUE if x should sort
 *						before y in the table. NOTE: This function is
 *
 * Return values: TRUE if x goes before y, FALSE otherwise
 *
 * Globals input:	unsorted -- if TRUE then compare only first letter,
 *										otherwise compare first letter, then length
 *										of match.
 *
 * Globals output: none
 *
 * Error conditions: none
 *
 * Other functions called:	srchlen -- how long is the match?
 *
 */
{
    unsigned int xltr;      /* First letter of change x */
    unsigned int yltr;      /* First letter of change y */

    /* Compute first letter of each change. If change starts with a command
    	(e.g., any(1) "xyz" > ...) then the first letter code is HIGHBIT */
    /* Following 2 lines changed by DAR/DRC 4/24/96 and 5/8/96.
       Changed to do sorting correctly, and then to be unsigned.     */
	/* if *x or *y is SPECWEDGE, then we have a zero length string on the left side and it
	   always be sorted at the end */
	xltr = min( (unsigned) (*x & 0xFFFF), (unsigned) HIGHBIT);
	yltr = min( (unsigned) (*y & 0xFFFF), (unsigned) HIGHBIT);

    /* If first letters match, then compare search lengths */
    if (xltr == yltr && !unsorted)
        return( srchlen(x) > srchlen(y) );
    else
        return( xltr < yltr );
}

#ifdef DEBUG
/****************************************************************************/
void dumpchar(ch)  /* (Debugging routine) */ /* Dump one character */
/****************************************************************************/
char ch;
{
    /* dump one character */
    if ( ch <= 32 || ch >= 127 )
        fprintf( msgfile, "%d ", ch);
    else
        fprintf( msgfile, "%c ", ch);
}

/****************************************************************************/
void cctdump()						  /* (Debugging routine) */ /* Dump CC table */
/****************************************************************************/
{
    /* diagnostic printout of changes table */

    tbltype tp;
    tbltype *ptp;
    cngtype cp;
    int group;

    fprintf( msgfile, "Dump of changes table:\n");
    fprintf( msgfile,
             "table=%u maintablend=%u tloadpointer=%u maxsrch=%u MAXMATCH=%u\n",
             table, maintablend, tloadpointer, maxsrch, MAXMATCH);

    if ( *table = SPECWEDGE )
    {									/* Dump the "begin" statement */
        fprintf( msgfile, " begin: " );
        tp = table;
        do
        {
            dumpchar( *tp );
        } while ( *tp++ != SPECPERIOD );
        fprintf(msgfile, "\n" );
    } /* End--dump the "begin" statement */

    for ( ptp = defarray; ptp <= (defarray + MAXARG); ptp++)
    {
        if ( *ptp != NULL )
        {
            fprintf( msgfile, "define(%d): ", ptp-defarray );
            tp = *ptp;
            do
            {
                dumpchar( *tp );
            } while ( *tp++ != SPECPERIOD );
            fprintf( msgfile, "\n");
        } /* End--dump a define */
    } /* End--dump the define array */

    for ( cp=cngpointers; cp < cngpend; cp++ )
    {
        tp = *cp;
        fprintf( msgfile, "%3d %6u: ", cp-cngpointers, tp);
        do
        {
            dumpchar( *tp);
        } while ( *tp++ != SPECPERIOD );
        fprintf( msgfile, "\n");
    }

    for (ptp = defarray; ptp <= defarray+MAXARG; ptp++)
        if ( *ptp != NULL )
            fprintf( msgfile, "define(%d) start=%u:\n", ptp-defarray, *ptp);

    for (group = 1; group <= MAXGROUPS; group++)
        if (groupbeg[group]!=NULL)
            fprintf( msgfile, "group(%d): start=%u xeq=%u end=%u\n",
                     group, groupbeg[group]-cngpointers,
                     groupxeq[group]-cngpointers,
                     groupend[group]-cngpointers);

    fflush( msgfile );			/* Just in case the dump was all we wanted */
} /* End--cctdump */

#endif /* DEBUG */

/* END */


text:
namespace {

std::string RandASCIIString(size_t length) {
  std::string result;
  const int kMin = static_cast<int>(' ');
  const int kMax = static_cast<int>('~');
  for (size_t i = 0; i < length; ++i)
    result.push_back(static_cast<char>(base::RandInt(kMin, kMax)));
  return result;
}

std::string DeleteDirectiveToString(
    const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) {
  scoped_ptr<base::DictionaryValue> value(
      syncer::HistoryDeleteDirectiveSpecificsToValue(delete_directive));
  std::string str;
  base::JSONWriter::Write(*value, &str);
  return str;
}

// Compare time range directives first by start time, then by end time.
bool TimeRangeLessThan(const syncer::SyncData& data1,
                       const syncer::SyncData& data2) {
  const sync_pb::TimeRangeDirective& range1 =
      data1.GetSpecifics().history_delete_directive().time_range_directive();
  const sync_pb::TimeRangeDirective& range2 =
      data2.GetSpecifics().history_delete_directive().time_range_directive();
  if (range1.start_time_usec() < range2.start_time_usec())
    return true;
  if (range1.start_time_usec() > range2.start_time_usec())
    return false;
  return range1.end_time_usec() < range2.end_time_usec();
}

// Converts a Unix timestamp in microseconds to a base::Time value.
base::Time UnixUsecToTime(int64 usec) {
  return base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(usec);
}

// Converts a base::Time value to a Unix timestamp in microseconds.
int64 TimeToUnixUsec(base::Time time) {
  DCHECK(!time.is_null());
  return (time - base::Time::UnixEpoch()).InMicroseconds();
}

// Converts global IDs in |global_id_directive| to times.
void GetTimesFromGlobalIds(
    const sync_pb::GlobalIdDirective& global_id_directive,
    std::set<base::Time>* times) {
  for (int i = 0; i < global_id_directive.global_id_size(); ++i) {
    times->insert(
        base::Time::FromInternalValue(global_id_directive.global_id(i)));
  }
}

#if !defined(NDEBUG)
// Checks that the given delete directive is properly formed.
void CheckDeleteDirectiveValid(
    const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) {
  if (delete_directive.has_global_id_directive()) {
    const sync_pb::GlobalIdDirective& global_id_directive =
        delete_directive.global_id_directive();

    DCHECK(!delete_directive.has_time_range_directive());
    DCHECK_NE(global_id_directive.global_id_size(), 0);
    if (global_id_directive.has_start_time_usec())
      DCHECK_GE(global_id_directive.start_time_usec(), 0);
    if (global_id_directive.has_end_time_usec()) {
      DCHECK_GT(global_id_directive.end_time_usec(), 0);

      if (global_id_directive.has_start_time_usec()) {
        DCHECK_LE(global_id_directive.start_time_usec(),
                  global_id_directive.end_time_usec());
      }
    }

  } else if (delete_directive.has_time_range_directive()) {
    const sync_pb::TimeRangeDirective& time_range_directive =
        delete_directive.time_range_directive();

    DCHECK(!delete_directive.has_global_id_directive());
    DCHECK(time_range_directive.has_start_time_usec());
    DCHECK(time_range_directive.has_end_time_usec());
    DCHECK_GE(time_range_directive.start_time_usec(), 0);
    DCHECK_GT(time_range_directive.end_time_usec(), 0);
    DCHECK_GT(time_range_directive.end_time_usec(),
              time_range_directive.start_time_usec());
  } else {
    NOTREACHED() << "Delete directive has no time range or global ID directive";
  }
}
#endif  // !defined(NDEBUG)

}  // anonymous namespace

namespace history {

class DeleteDirectiveHandler::DeleteDirectiveTask : public HistoryDBTask {
 public:
  DeleteDirectiveTask(
      base::WeakPtr<DeleteDirectiveHandler> delete_directive_handler,
      const syncer::SyncDataList& delete_directive,
      DeleteDirectiveHandler::PostProcessingAction post_processing_action)
      : delete_directive_handler_(delete_directive_handler),
        delete_directives_(delete_directive),
        post_processing_action_(post_processing_action) {}

  // Implements HistoryDBTask.
  bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db) override;
  void DoneRunOnMainThread() override;

 private:
  ~DeleteDirectiveTask() override {}

  // Process a list of global Id directives. Delete all visits to a URL in
  // time ranges of directives if the timestamp of one visit matches with one
  // global id.
  void ProcessGlobalIdDeleteDirectives(
      HistoryBackend* history_backend,
      const syncer::SyncDataList& global_id_directives);

  // Process a list of time range directives, all history entries within the
  // time ranges are deleted. |time_range_directives| should be sorted by
  // |start_time_usec| and |end_time_usec| already.
  void ProcessTimeRangeDeleteDirectives(
      HistoryBackend* history_backend,
      const syncer::SyncDataList& time_range_directives);

  base::WeakPtr<DeleteDirectiveHandler> delete_directive_handler_;
  syncer::SyncDataList delete_directives_;
  DeleteDirectiveHandler::PostProcessingAction post_processing_action_;
};

bool DeleteDirectiveHandler::DeleteDirectiveTask::RunOnDBThread(
    HistoryBackend* backend,
    HistoryDatabase* db) {
  syncer::SyncDataList global_id_directives;
  syncer::SyncDataList time_range_directives;
  for (syncer::SyncDataList::const_iterator it = delete_directives_.begin();
       it != delete_directives_.end(); ++it) {
    DCHECK_EQ(it->GetDataType(), syncer::HISTORY_DELETE_DIRECTIVES);
    const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive =
        it->GetSpecifics().history_delete_directive();
    if (delete_directive.has_global_id_directive()) {
      global_id_directives.push_back(*it);
    } else {
      time_range_directives.push_back(*it);
    }
  }

  ProcessGlobalIdDeleteDirectives(backend, global_id_directives);
  std::sort(time_range_directives.begin(), time_range_directives.end(),
            TimeRangeLessThan);
  ProcessTimeRangeDeleteDirectives(backend, time_range_directives);
  return true;
}

void DeleteDirectiveHandler::DeleteDirectiveTask::DoneRunOnMainThread() {
  if (delete_directive_handler_.get()) {
    delete_directive_handler_->FinishProcessing(post_processing_action_,
                                                delete_directives_);
  }
}

void DeleteDirectiveHandler::DeleteDirectiveTask::
    ProcessGlobalIdDeleteDirectives(
        HistoryBackend* history_backend,
        const syncer::SyncDataList& global_id_directives) {
  if (global_id_directives.empty())
    return;

  // Group times represented by global IDs by time ranges of delete directives.
  // It's more efficient for backend to process all directives with same time
  // range at once.
  typedef std::map<std::pair<base::Time, base::Time>, std::set<base::Time>>
      GlobalIdTimesGroup;
  GlobalIdTimesGroup id_times_group;
  for (size_t i = 0; i < global_id_directives.size(); ++i) {
    DVLOG(1) << "Processing delete directive: "
             << DeleteDirectiveToString(global_id_directives[i]
                                            .GetSpecifics()
                                            .history_delete_directive());

    const sync_pb::GlobalIdDirective& id_directive =
        global_id_directives[i]
            .GetSpecifics()
            .history_delete_directive()
            .global_id_directive();
    if (id_directive.global_id_size() == 0 ||
        !id_directive.has_start_time_usec() ||
        !id_directive.has_end_time_usec()) {
      DLOG(ERROR) << "Invalid global id directive.";
      continue;
    }
    GetTimesFromGlobalIds(id_directive,
                          &id_times_group[std::make_pair(
                              UnixUsecToTime(id_directive.start_time_usec()),
                              UnixUsecToTime(id_directive.end_time_usec()))]);
  }

  if (id_times_group.empty())
    return;

  // Call backend to expire history of directives in each group.
  for (GlobalIdTimesGroup::const_iterator group_it = id_times_group.begin();
       group_it != id_times_group.end(); ++group_it) {
    // Add 1us to cover history entries visited at the end time because time
    // range in directive is inclusive.
    history_backend->ExpireHistoryForTimes(
        group_it->second, group_it->first.first,
        group_it->first.second + base::TimeDelta::FromMicroseconds(1));
  }
}

void DeleteDirectiveHandler::DeleteDirectiveTask::
    ProcessTimeRangeDeleteDirectives(
        HistoryBackend* history_backend,
        const syncer::SyncDataList& time_range_directives) {
  if (time_range_directives.empty())
    return;

  // Iterate through time range directives. Expire history in combined
  // time range for multiple directives whose time ranges overlap.
  base::Time current_start_time;
  base::Time current_end_time;
  for (size_t i = 0; i < time_range_directives.size(); ++i) {
    const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive =
        time_range_directives[i].GetSpecifics().history_delete_directive();
    DVLOG(1) << "Processing time range directive: "
             << DeleteDirectiveToString(delete_directive);

    const sync_pb::TimeRangeDirective& time_range_directive =
        delete_directive.time_range_directive();
    if (!time_range_directive.has_start_time_usec() ||
        !time_range_directive.has_end_time_usec() ||
        time_range_directive.start_time_usec() >=
            time_range_directive.end_time_usec()) {
      DLOG(ERROR) << "Invalid time range directive.";
      continue;
    }

    base::Time directive_start_time =
        UnixUsecToTime(time_range_directive.start_time_usec());
    base::Time directive_end_time =
        UnixUsecToTime(time_range_directive.end_time_usec());
    if (directive_start_time > current_end_time) {
      if (!current_start_time.is_null()) {
        // Add 1us to cover history entries visited at the end time because
        // time range in directive is inclusive.
        history_backend->ExpireHistoryBetween(
            std::set<GURL>(), current_start_time,
            current_end_time + base::TimeDelta::FromMicroseconds(1));
      }
      current_start_time = directive_start_time;
    }
    if (directive_end_time > current_end_time)
      current_end_time = directive_end_time;
  }

  if (!current_start_time.is_null()) {
    history_backend->ExpireHistoryBetween(
        std::set<GURL>(), current_start_time,
        current_end_time + base::TimeDelta::FromMicroseconds(1));
  }
}

DeleteDirectiveHandler::DeleteDirectiveHandler() : weak_ptr_factory_(this) {
}

DeleteDirectiveHandler::~DeleteDirectiveHandler() {
  weak_ptr_factory_.InvalidateWeakPtrs();
}

void DeleteDirectiveHandler::Start(
    HistoryService* history_service,
    const syncer::SyncDataList& initial_sync_data,
    scoped_ptr<syncer::SyncChangeProcessor> sync_processor) {
  DCHECK(thread_checker_.CalledOnValidThread());
  sync_processor_ = sync_processor.Pass();
  if (!initial_sync_data.empty()) {
    // Drop processed delete directives during startup.
    history_service->ScheduleDBTask(
        scoped_ptr<HistoryDBTask>(
            new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(),
                                    initial_sync_data, DROP_AFTER_PROCESSING)),
        &internal_tracker_);
  }
}

void DeleteDirectiveHandler::Stop() {
  DCHECK(thread_checker_.CalledOnValidThread());
  sync_processor_.reset();
}

bool DeleteDirectiveHandler::CreateDeleteDirectives(
    const std::set<int64>& global_ids,
    base::Time begin_time,
    base::Time end_time) {
  base::Time now = base::Time::Now();
  sync_pb::HistoryDeleteDirectiveSpecifics delete_directive;

  // Delete directives require a non-null begin time, so use 1 if it's null.
  int64 begin_time_usecs =
      begin_time.is_null() ? 0 : TimeToUnixUsec(begin_time);

  // Determine the actual end time -- it should not be null or in the future.
  // TODO(dubroy): Use sane time (crbug.com/146090) here when it's available.
  base::Time end = (end_time.is_null() || end_time > now) ? now : end_time;
  // -1 because end time in delete directives is inclusive.
  int64 end_time_usecs = TimeToUnixUsec(end) - 1;

  if (global_ids.empty()) {
    sync_pb::TimeRangeDirective* time_range_directive =
        delete_directive.mutable_time_range_directive();
    time_range_directive->set_start_time_usec(begin_time_usecs);
    time_range_directive->set_end_time_usec(end_time_usecs);
  } else {
    for (std::set<int64>::const_iterator it = global_ids.begin();
         it != global_ids.end(); ++it) {
      sync_pb::GlobalIdDirective* global_id_directive =
          delete_directive.mutable_global_id_directive();
      global_id_directive->add_global_id(*it);
      global_id_directive->set_start_time_usec(begin_time_usecs);
      global_id_directive->set_end_time_usec(end_time_usecs);
    }
  }
  syncer::SyncError error = ProcessLocalDeleteDirective(delete_directive);
  return !error.IsSet();
}

syncer::SyncError DeleteDirectiveHandler::ProcessLocalDeleteDirective(
    const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) {
  DCHECK(thread_checker_.CalledOnValidThread());
  if (!sync_processor_) {
    return syncer::SyncError(FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
                             "Cannot send local delete directive to sync",
                             syncer::HISTORY_DELETE_DIRECTIVES);
  }
#if !defined(NDEBUG)
  CheckDeleteDirectiveValid(delete_directive);
#endif

  // Generate a random sync tag since history delete directives don't
  // have a 'built-in' ID.  8 bytes should suffice.
  std::string sync_tag = RandASCIIString(8);
  sync_pb::EntitySpecifics entity_specifics;
  entity_specifics.mutable_history_delete_directive()->CopyFrom(
      delete_directive);
  syncer::SyncData sync_data =
      syncer::SyncData::CreateLocalData(sync_tag, sync_tag, entity_specifics);
  syncer::SyncChange change(FROM_HERE, syncer::SyncChange::ACTION_ADD,
                            sync_data);
  syncer::SyncChangeList changes(1, change);
  return sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
}

syncer::SyncError DeleteDirectiveHandler::ProcessSyncChanges(
    HistoryService* history_service,
    const syncer::SyncChangeList& change_list) {
  DCHECK(thread_checker_.CalledOnValidThread());
  if (!sync_processor_) {
    return syncer::SyncError(FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
                             "Sync is disabled.",
                             syncer::HISTORY_DELETE_DIRECTIVES);
  }

  syncer::SyncDataList delete_directives;
  for (syncer::SyncChangeList::const_iterator it = change_list.begin();
       it != change_list.end(); ++it) {
    switch (it->change_type()) {
      case syncer::SyncChange::ACTION_ADD:
        delete_directives.push_back(it->sync_data());
        break;
      case syncer::SyncChange::ACTION_DELETE:
        // TODO(akalin): Keep track of existing delete directives.
        break;
      default:
        NOTREACHED();
        break;
    }
  }

  if (!delete_directives.empty()) {
    // Don't drop real-time delete directive so that sync engine can detect
    // redelivered delete directives to avoid processing them again and again
    // in one chrome session.
    history_service->ScheduleDBTask(
        scoped_ptr<HistoryDBTask>(
            new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(),
                                    delete_directives, KEEP_AFTER_PROCESSING)),
        &internal_tracker_);
  }
  return syncer::SyncError();
}

void DeleteDirectiveHandler::FinishProcessing(
    PostProcessingAction post_processing_action,
    const syncer::SyncDataList& delete_directives) {
  DCHECK(thread_checker_.CalledOnValidThread());

  // If specified, drop processed delete directive in sync model because they
  // only need to be applied once.
  if (sync_processor_.get() &&
      post_processing_action == DROP_AFTER_PROCESSING) {
    syncer::SyncChangeList change_list;
    for (size_t i = 0; i < delete_directives.size(); ++i) {
      change_list.push_back(syncer::SyncChange(
          FROM_HERE, syncer::SyncChange::ACTION_DELETE, delete_directives[i]));
    }
    sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
  }
}

}  // namespace history


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.facebook.presto</groupId>
        <artifactId>presto-root</artifactId>
        <version>0.50-SNAPSHOT</version>
    </parent>

    <artifactId>presto-hive-cdh4</artifactId>
    <name>presto-hive-cdh4</name>
    <description>Presto - Hive Connector - CDH4</description>

    <properties>
        <air.main.basedir>${project.parent.basedir}</air.main.basedir>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.facebook.presto</groupId>
            <artifactId>presto-spi</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.facebook.presto</groupId>
            <artifactId>presto-hive</artifactId>
        </dependency>

        <dependency>
            <groupId>com.facebook.presto.hadoop</groupId>
            <artifactId>hadoop-cdh4</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/main/assembly/plugin.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>


text:
package org.dom4j.dtd;

/**
 *

 * AttributeDecl represents an element declaration in a DTD.
 *

 *
 * @author James Strachan
 * @version $Revision: 1.6 $
 */
public class ElementDecl {
    /** Holds value of property name. */
    private String name;

    /** Holds value of property model. */
    private String model;

    public ElementDecl() {
    }

    public ElementDecl(String name, String model) {
        this.name = name;
        this.model = model;
    }

    /**
     * Getter for property name.
     *
     * @return Value of property name.
     */
    public String getName() {
        return name;
    }

    /**
     * Setter for property name.
     *
     * @param name
     *            New value of property name.
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Getter for property model.
     *
     * @return Value of property model.
     */
    public String getModel() {
        return model;
    }

    /**
     * Setter for property model.
     *
     * @param model
     *            New value of property model.
     */
    public void setModel(String model) {
        this.model = model;
    }

    public String toString() {
        return "<!ELEMENT " + name + " " + model + ">";
    }
}

/*
 * Redistribution and use of this software and associated documentation
 * ("Software"), with or without modification, are permitted provided that the
 * following conditions are met:
 *
 * 1. Redistributions of source code must retain copyright statements and
 * notices. Redistributions must also contain a copy of this document.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. The name "DOM4J" must not be used to endorse or promote products derived
 * from this Software without prior written permission of MetaStuff, Ltd. For
 * written permission, please contact dom4j-info@metastuff.com.
 *
 * 4. Products derived from this Software may not be called "DOM4J" nor may
 * "DOM4J" appear in their names without prior written permission of MetaStuff,
 * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
 *
 * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
 *
 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
 */


text:
![Markdown](https://github.com/tipassim/MoonDrive-Documentation/blob/master/images/moondrive.png?raw=true)

---

# Documentation

---


text:
package com.sharepast.jms.producer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

/**
 * Created by IntelliJ IDEA.
 * User: Kostya
 * Date: 2/15/11
 * Time: 10:49 PM
 * To change this template use File | Settings | File Templates.
 */

@Component("mailQueueSender")
public class MailQueueSender
{
    private final JmsTemplate jmsTemplate;

    @Autowired
    public MailQueueSender(final JmsTemplate jmsTemplate)
    {
        this.jmsTemplate = jmsTemplate;
    }

    public void send( final String message )
    {
        jmsTemplate.convertAndSend( "mailQueue", message );
    }
}


text:
//
//  YouTubeSampleAppController.m
//

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif

#import "YouTubeSampleAppController.h"
#import "YouTubeSampleWindowController.h"

@implementation YouTubeSampleAppController

- (void)applicationWillFinishLaunching:(NSNotification *)notification {
  YouTubeSampleWindowController* windowController
    = [YouTubeSampleWindowController sharedWindowController];
  [windowController showWindow:self];
}

- (void)applicationWillTerminate:(NSNotification *)notification {
  // Ensure any defaults are flushed out.
  [[NSUserDefaults standardUserDefaults] synchronize];
}

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
  return YES;
}

@end


text:
<?php

/* DesymfonyBundle:Ponencia:meApunto.html.twig */
class __TwigTemplate_8c9e76bc561d7f87501ab8e040ec41aa extends Twig_Template
{
    protected function doDisplay(array $context, array $blocks = array())
    {
        $context = array_merge($this->env->getGlobals(), $context);

        // line 1
        if ($this->env->getExtension('security')->isGranted("ROLE_USER")) {
            // line 2
            echo "    ";
            if ($this->getAttribute($this->getAttribute($this->getContext($context, 'app'), "user", array(), "any", false), "hasPonencia", array($this->getContext($context, 'ponencia'), ), "method", false)) {
                // line 3
                echo "        ✔ Apuntado
    ";
            } else {
                // line 5
                echo "        env, $this->env->getExtension('routing')->getPath("apuntarse", array("slug" => $this->getAttribute($this->getContext($context, 'ponencia'), "slug", array(), "any", false))), "html");
                echo "\" class=\"btn me_apunto\">Me apunto
    ";
            }
        }
    }

    public function getTemplateName()
    {
        return "DesymfonyBundle:Ponencia:meApunto.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }
}