text:
(function () {
  var ns = $.namespace('pskl.controller');

  var PRIMARY_COLOR_CLASSNAME = 'palettes-list-primary-color';
  var SECONDARY_COLOR_CLASSNAME = 'palettes-list-secondary-color';

  ns.PalettesListController = function (usedColorService) {
    this.usedColorService = usedColorService;
    this.paletteService = pskl.app.paletteService;
  };

  ns.PalettesListController.prototype.init = function () {
    this.paletteColorTemplate_ = pskl.utils.Template.get('palette-color-template');

    this.colorListContainer_ = document.querySelector('.palettes-list-colors');
    this.colorPaletteSelect_ = document.querySelector('.palettes-list-select');

    var createPaletteButton_ = document.querySelector('.create-palette-button');
    var editPaletteButton_ = document.querySelector('.edit-palette-button');

    this.colorPaletteSelect_.addEventListener('change', this.onPaletteSelected_.bind(this));
    this.colorListContainer_.addEventListener('mouseup', this.onColorContainerMouseup.bind(this));
    this.colorListContainer_.addEventListener('contextmenu', this.onColorContainerContextMenu.bind(this));

    createPaletteButton_.addEventListener('click', this.onCreatePaletteClick_.bind(this));
    editPaletteButton_.addEventListener('click', this.onEditPaletteClick_.bind(this));

    $.subscribe(Events.PALETTE_LIST_UPDATED, this.onPaletteListUpdated.bind(this));
    $.subscribe(Events.CURRENT_COLORS_UPDATED, this.fillColorListContainer.bind(this));
    $.subscribe(Events.PRIMARY_COLOR_SELECTED, this.highlightSelectedColors.bind(this));
    $.subscribe(Events.SECONDARY_COLOR_SELECTED, this.highlightSelectedColors.bind(this));
    $.subscribe(Events.USER_SETTINGS_CHANGED, $.proxy(this.onUserSettingsChange_, this));

    var shortcuts = pskl.service.keyboard.Shortcuts;
    pskl.app.shortcutService.registerShortcut(shortcuts.COLOR.PREVIOUS_COLOR, this.selectPreviousColor_.bind(this));
    pskl.app.shortcutService.registerShortcut(shortcuts.COLOR.NEXT_COLOR, this.selectNextColor_.bind(this));
    pskl.app.shortcutService.registerShortcut(shortcuts.COLOR.SELECT_COLOR, this.selectColorForKey_.bind(this));

    this.fillPaletteList();
    this.updateFromUserSettings();
    this.fillColorListContainer();
  };

  ns.PalettesListController.prototype.fillPaletteList = function () {
    var palettes = this.paletteService.getPalettes();

    var html = palettes.map(function (palette) {
      return pskl.utils.Template.replace('<option value="{{id}}">{{name}}</option>', palette);
    }).join('');
    this.colorPaletteSelect_.innerHTML = html;
  };

  ns.PalettesListController.prototype.fillColorListContainer = function () {
    var colors = this.getSelectedPaletteColors_();

    if (colors.length > 0) {
      var html = colors.filter(function (color) {
        return !!color;
      }).map(function (color, index) {
        return pskl.utils.Template.replace(this.paletteColorTemplate_, {
          color : color,
          index : index + 1,
          title : color.toUpperCase()
        });
      }.bind(this)).join('');
      this.colorListContainer_.innerHTML = html;

      this.highlightSelectedColors();
    } else {
      this.colorListContainer_.innerHTML = pskl.utils.Template.get('palettes-list-no-colors-partial');
    }

    // If we have more than 10 colors, use tiny mode, where 10 colors will fit on the same
    // line.
    this.colorListContainer_.classList.toggle('tiny', colors.length > 10);
  };

  ns.PalettesListController.prototype.selectPalette = function (paletteId) {
    pskl.UserSettings.set(pskl.UserSettings.SELECTED_PALETTE, paletteId);
  };

  ns.PalettesListController.prototype.getSelectedPaletteColors_ = function () {
    var colors = [];
    var palette = this.getSelectedPalette_();
    if (palette) {
      colors = palette.getColors();
    }

    if (colors.length > Constants.MAX_PALETTE_COLORS) {
      colors = colors.slice(0, Constants.MAX_PALETTE_COLORS);
    }

    return colors;
  };

  ns.PalettesListController.prototype.getSelectedPalette_ = function () {
    var paletteId = pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE);
    return this.paletteService.getPaletteById(paletteId);
  };

  ns.PalettesListController.prototype.selectNextColor_ = function () {
    this.selectColor_(this.getCurrentColorIndex_() + 1);
  };

  ns.PalettesListController.prototype.selectPreviousColor_ = function () {
    this.selectColor_(this.getCurrentColorIndex_() - 1);
  };

  ns.PalettesListController.prototype.getCurrentColorIndex_ = function () {
    var currentIndex = 0;
    var selectedColor = document.querySelector('.' + PRIMARY_COLOR_CLASSNAME);
    if (selectedColor) {
      currentIndex = parseInt(selectedColor.dataset.colorIndex, 10) - 1;
    }
    return currentIndex;
  };

  ns.PalettesListController.prototype.selectColorForKey_ = function (key) {
    var index = parseInt(key, 10);
    index = (index + 9) % 10;
    this.selectColor_(index);
  };

  ns.PalettesListController.prototype.selectColor_ = function (index) {
    var colors = this.getSelectedPaletteColors_();
    var color = colors[index];
    if (color) {
      $.publish(Events.SELECT_PRIMARY_COLOR, [color]);
    }
  };

  ns.PalettesListController.prototype.onUserSettingsChange_ = function (evt, name, value) {
    if (name == pskl.UserSettings.SELECTED_PALETTE) {
      this.updateFromUserSettings();
    }
  };

  ns.PalettesListController.prototype.updateFromUserSettings = function () {
    var paletteId = pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE);
    this.fillColorListContainer();
    this.colorPaletteSelect_.value = paletteId;
  };

  ns.PalettesListController.prototype.onPaletteSelected_ = function (evt) {
    var paletteId = this.colorPaletteSelect_.value;
    this.selectPalette(paletteId);
    this.colorPaletteSelect_.blur();
  };

  ns.PalettesListController.prototype.onCreatePaletteClick_ = function (evt) {
    $.publish(Events.DIALOG_SHOW, {
      dialogId : 'create-palette'
    });
  };

  ns.PalettesListController.prototype.onEditPaletteClick_ = function (evt) {
    var paletteId = this.colorPaletteSelect_.value;
    $.publish(Events.DIALOG_SHOW, {
      dialogId : 'create-palette',
      initArgs : paletteId
    });
  };

  ns.PalettesListController.prototype.onColorContainerContextMenu = function (event) {
    event.preventDefault();
  };

  ns.PalettesListController.prototype.onColorContainerMouseup = function (event) {
    var target = event.target;
    var color = target.dataset.color;

    if (color) {
      if (event.button == Constants.LEFT_BUTTON) {
        $.publish(Events.SELECT_PRIMARY_COLOR, [color]);
      } else if (event.button == Constants.RIGHT_BUTTON) {
        $.publish(Events.SELECT_SECONDARY_COLOR, [color]);
      }
    }
  };

  ns.PalettesListController.prototype.highlightSelectedColors = function () {
    this.removeClass_(PRIMARY_COLOR_CLASSNAME);
    this.removeClass_(SECONDARY_COLOR_CLASSNAME);

    var colorContainer = this.getColorContainer_(pskl.app.selectedColorsService.getSecondaryColor());
    if (colorContainer) {
      colorContainer.classList.remove(PRIMARY_COLOR_CLASSNAME);
      colorContainer.classList.add(SECONDARY_COLOR_CLASSNAME);
    }

    colorContainer = this.getColorContainer_(pskl.app.selectedColorsService.getPrimaryColor());
    if (colorContainer) {
      colorContainer.classList.remove(SECONDARY_COLOR_CLASSNAME);
      colorContainer.classList.add(PRIMARY_COLOR_CLASSNAME);
    }
  };

  ns.PalettesListController.prototype.getColorContainer_ = function (color) {
    return this.colorListContainer_.querySelector('.palettes-list-color[data-color="' + color + '"]');
  };

  ns.PalettesListController.prototype.removeClass_ = function (cssClass) {
    var element = document.querySelector('.' + cssClass);
    if (element) {
      element.classList.remove(cssClass);
    }
  };

  ns.PalettesListController.prototype.onPaletteListUpdated = function () {
    this.fillPaletteList();
    this.updateFromUserSettings();
  };
})();


text:
#include <pal.h>

#include <stddef.h>
#include <stdio.h>
#include "pal_base.h"
#include "pal_base_private.h"

/**
 *
 * Dynamically allocates contiguous memory buffer on the local node.
 *
 * @param team  A pointer to the object defining the team structure.
 *              The team contains a set of compute nodes with each node having
 *              a finite amount of memory.
 *
 * @param size  Total amount of memory to allocate
 *
 * @return      Returns a pointer to the memory buffer
 *              Returns NULL on error
 */
p_mem_t p_malloc(p_team_t team, size_t size)
{

    printf("Running p_malloc(%p,%d)\n", team, (int)size);
#if 0
    p_mem_t *mem;

    switch (0) {   // FIX!
    case P_DEV_EPIPHANY: // shared memory model
        break;
    case P_DEV_FPGA: // shared memory model
        break;
    case P_DEV_GPU: // shared memory model
        break;
    case P_DEV_SMP: // heap (thread model)
    /*
    mem=malloc(sizeof(p_mem_t));
    mem->mutex  = 23;
    mem->takeit = 0;
    mem->gotit  = 0;
    mem->size   = size;
    mem->memptr = malloc(size);
    break;
    */
    case P_DEV_GRID: // file+IP (rcp?)
        break;
    default:
        return (1);
    }
#endif
    return p_ref_err(ENOSYS);
}

redpajama_set_name: RedPajamaGithub


text:
layout: post
date: '2015-05-19'
title: "QUINCEANERA DRESSES Vizcaya by Mori Lee Quinceanera Dress 88047"
category: QUINCEANERA DRESSES
tags: [QUINCEANERA DRESSES]
---
### QUINCEANERA DRESSES Vizcaya by Mori Lee Quinceanera Dress 88047
Just **$577.99**
###

Style 88047 Beaded Two Tone Ruffled Tulle skirt Quinceanera dress. Comes with matching bolero jacket. Lace up back.

Available in sizes 0-28.

Buy it: [https://www.eudances.com/en/quinceanera-dresses/1636-vizcaya-by-mori-lee-quinceanera-dress-88047.html](https://www.eudances.com/en/quinceanera-dresses/1636-vizcaya-by-mori-lee-quinceanera-dress-88047.html)


text:
if defined?(Raven) && ENV["VCAP_APPLICATION"].present?
  tags = JSON.parse(ENV["VCAP_APPLICATION"])
             .except('application_uris', 'host', 'application_name', 'space_id', 'port', 'uris', 'application_version')
             .merge({ server_name: ENV["GOVUK_APP_DOMAIN"] })
  Raven.configure do |config|
    config.tags = tags
  end
end


text:
//-------------
// <copyright file="PodCastRepositoryTests.cs" company="Uncas">
//     Copyright (c) Ole Lynge Sørensen. All rights reserved.
// </copyright>
//-------------

namespace Uncas.PodCastPlayer.Tests.RepositoryTests
{
    using System;
    using System.Diagnostics;
    using NUnit.Framework;
    using Uncas.PodCastPlayer.Model;
    using Uncas.PodCastPlayer.Repository;
    using Uncas.PodCastPlayer.ViewModel;

    /// <summary>
    /// Tests pod cast repository.
    /// </summary>
    [TestFixture]
    public class PodCastRepositoryTests : BaseTest
    {
        /// <summary>
        /// The pod cast repository.
        /// </summary>
        private readonly IPodCastRepository repository
            = TestApp.Repositories.PodCastRepository;

        /// <summary>
        /// Initializes a new instance of the <see cref="PodCastRepositoryTests"/> class.
        /// </summary>
        public PodCastRepositoryTests()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="PodCastRepositoryTests"/> class.
        /// </summary>
        /// <param name="repositories">The repositories.</param>
        public PodCastRepositoryTests(
            IRepositoryFactory repositories)
            : base(repositories)
        {
        }

        /// <summary>
        /// Deletes the pod cast_0_ OK.
        /// </summary>
        [Test]
        public void DeletePodCast_0_OK()
        {
            // Arrange:

            // Act:
            this.PodCastRepository.DeletePodCast(0);

            // Assert:
        }

        /// <summary>
        /// Gets the pod cast_1_ OK.
        /// </summary>
        [Test]
        public void GetPodCast_1_OK()
        {
            // Arrange:

            // Act:
            this.PodCastRepository.GetPodCast(1);

            // Assert:
        }

        /// <summary>
        /// Gets the pod casts.
        /// </summary>
        [Test]
        public virtual void GetPodCasts_All_OK()
        {
            // Act:
            var podCasts
                = this.PodCastRepository.GetPodCasts();

            // Assert:
            foreach (var podCast in podCasts)
            {
                Trace.WriteLine(podCast.Name);
                Trace.WriteLine(podCast.Url);
                Assert.IsNotNull(podCast.Name);
                Assert.IsNotNull(podCast.Url);
            }
        }

        /// <summary>
        /// Gets the pod cast details_1_ OK.
        /// </summary>
        [Test]
        public void GetPodCastDetails_1_OK()
        {
            // Arrange:

            // Act:
            this.PodCastRepository.GetPodCastDetails(1);

            // Assert:
        }

        /// <summary>
        /// Saves the pod cast_ non existing_ OK.
        /// </summary>
        [Test]
        public void SavePodCast_NonExisting_OK()
        {
            // Arrange:
            var podCast = new PodCast(
                null,
                "x",
                new Uri("http://test.dxxxxx"),
                "x",
                "x");

            // Act:
            this.PodCastRepository.SavePodCast(podCast);

            // Assert:
            Assert.IsNotNull(podCast.Id);
        }

        /// <summary>
        /// Saves the pod cast_ existing_ OK.
        /// </summary>
        [Test]
        public void SavePodCast_Existing_OK()
        {
            // Arrange:
            var podCast = new PodCastDetailsViewModel(
                1,
                "X",
                new Uri("http://test.asdweqwe"),
                "x",
                "x");

            // Act:
            this.PodCastRepository.SavePodCast(podCast);

            // Assert:
        }
    }
}


text:
#include <aws/route53domains/model/GetDomainDetailRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>

#include <utility>

using namespace Aws::Route53Domains::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;

GetDomainDetailRequest::GetDomainDetailRequest() :
    m_domainNameHasBeenSet(false)
{
}

Aws::String GetDomainDetailRequest::SerializePayload() const
{
  JsonValue payload;

  if(m_domainNameHasBeenSet)
  {
   payload.WithString("DomainName", m_domainName);

  }

  return payload.WriteReadable();
}

Aws::Http::HeaderValueCollection GetDomainDetailRequest::GetRequestSpecificHeaders() const
{
  Aws::Http::HeaderValueCollection headers;
  headers.insert(Aws::Http::HeaderValuePair("X-Amz-Target", "Route53Domains_v20140515.GetDomainDetail"));
  return headers;

}


text:
#ifndef _my_sys_h
#define _my_sys_h
C_MODE_START

#ifdef HAVE_AIOWAIT
#include <sys/asynch.h>			/* Used by record-cache */
typedef struct my_aio_result {
  aio_result_t result;
  int	       pending;
} my_aio_result;
#endif

#ifndef THREAD
extern int NEAR my_errno;		/* Last error in mysys */
#else
#include <my_pthread.h>
#endif

#ifndef _m_ctype_h
#include <m_ctype.h>                    /* for CHARSET_INFO */
#endif

#include <stdarg.h>
#include <typelib.h>

#define MYSYS_PROGRAM_USES_CURSES()  { error_handler_hook = my_message_curses;	mysys_uses_curses=1; }
#define MYSYS_PROGRAM_DONT_USE_CURSES()  { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
#define MY_INIT(name);		{ my_progname= name; my_init(); }

#define MAXMAPS		(4)	/* Number of error message maps */
#define ERRMOD		(1000)	/* Max number of errors in a map */
#define ERRMSGSIZE	(SC_MAXWIDTH)	/* Max length of a error message */
#define NRERRBUFFS	(2)	/* Buffers for parameters */
#define MY_FILE_ERROR	((uint) ~0)

	/* General bitmaps for my_func's */
#define MY_FFNF		1	/* Fatal if file not found */
#define MY_FNABP	2	/* Fatal if not all bytes read/writen */
#define MY_NABP		4	/* Error if not all bytes read/writen */
#define MY_FAE		8	/* Fatal if any error */
#define MY_WME		16	/* Write message on error */
#define MY_WAIT_IF_FULL 32	/* Wait and try again if disk full error */
#define MY_RAID         64      /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
#define MY_FULL_IO     512      /* For my_read - loop intil I/O
				   is complete
				*/
#define MY_DONT_CHECK_FILESIZE 128	/* Option to init_io_cache() */
#define MY_LINK_WARNING 32	/* my_redel() gives warning if links */
#define MY_COPYTIME	64	/* my_redel() copys time */
#define MY_DELETE_OLD	256	/* my_create_with_symlink() */
#define MY_RESOLVE_LINK 128	/* my_realpath(); Only resolve links */
#define MY_HOLD_ORIGINAL_MODES 128  /* my_copy() holds to file modes */
#define MY_REDEL_MAKE_BACKUP 256
#define MY_SEEK_NOT_DONE 32	/* my_lock may have to do a seek */
#define MY_DONT_WAIT	64	/* my_lock() don't wait if can't lock */
#define MY_ZEROFILL	32	/* my_malloc(), fill array with zero */
#define MY_ALLOW_ZERO_PTR 64	/* my_realloc() ; zero ptr -> malloc */
#define MY_FREE_ON_ERROR 128	/* my_realloc() ; Free old ptr on error */
#define MY_HOLD_ON_ERROR 256	/* my_realloc() ; Return old ptr on error */
#define MY_THREADSAFE	128	/* pread/pwrite:  Don't allow interrupts */
#define MY_DONT_OVERWRITE_FILE 1024	/* my_copy; Don't overwrite file */

#define MY_CHECK_ERROR	1	/* Params to my_end; Check open-close */
#define MY_GIVE_INFO	2	/* Give time info about process*/

#define ME_HIGHBYTE	8	/* Shift for colours */
#define ME_NOCUR	1	/* Don't use curses message */
#define ME_OLDWIN	2	/* Use old window */
#define ME_BELL		4	/* Ring bell then printing message */
#define ME_HOLDTANG	8	/* Don't delete last keys */
#define ME_WAITTOT	16	/* Wait for errtime secs of for a action */
#define ME_WAITTANG	32	/* Wait for a user action  */
#define ME_NOREFRESH	64	/* Dont refresh screen */
#define ME_NOINPUT	128	/* Dont use the input libary */
#define ME_COLOUR1	((1 << ME_HIGHBYTE))	/* Possibly error-colours */
#define ME_COLOUR2	((2 << ME_HIGHBYTE))
#define ME_COLOUR3	((3 << ME_HIGHBYTE))

	/* Bits in last argument to fn_format */
#define MY_REPLACE_DIR		1	/* replace dir in name with 'dir' */
#define MY_REPLACE_EXT		2	/* replace extension with 'ext' */
#define MY_UNPACK_FILENAME	4	/* Unpack name (~ -> home) */
#define MY_PACK_FILENAME	8	/* Pack name (home -> ~) */
#define MY_RESOLVE_SYMLINKS	16	/* Resolve all symbolic links */
#define MY_RETURN_REAL_PATH	32	/* return full path for file */
#define MY_SAFE_PATH		64	/* Return NULL if too long path */
#define MY_RELATIVE_PATH	128	/* name is relative to 'dir' */

	/* My seek flags */
#define MY_SEEK_SET	0
#define MY_SEEK_CUR	1
#define MY_SEEK_END	2

	/* Some constants */
#define MY_WAIT_FOR_USER_TO_FIX_PANIC	60	/* in seconds */
#define MY_WAIT_GIVE_USER_A_MESSAGE	10	/* Every 10 times of prev */
#define MIN_COMPRESS_LENGTH		50	/* Don't compress small bl. */
#define DFLT_INIT_HITS  3

	/* root_alloc flags */
#define MY_KEEP_PREALLOC	1
#define MY_MARK_BLOCKS_FREE     2  /* move used to free list and reuse them */

	/* Internal error numbers (for assembler functions) */
#define MY_ERRNO_EDOM		33
#define MY_ERRNO_ERANGE		34

	/* defines when allocating data */
#ifdef SAFEMALLOC
#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG )
#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG )
#define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG )
#define my_checkmalloc() _sanity( __FILE__, __LINE__ )
#define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG)
#define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C)
#define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C)
#define my_strdup_with_length(A,B,C) _my_strdup_with_length((A),(B),__FILE__,__LINE__,C)
#define QUICK_SAFEMALLOC sf_malloc_quick=1
#define NORMAL_SAFEMALLOC sf_malloc_quick=0
extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
extern ulonglong sf_malloc_mem_limit;

#define CALLER_INFO_PROTO   , const char *sFile, uint uLine
#define CALLER_INFO         , __FILE__, __LINE__
#define ORIG_CALLER_INFO    , sFile, uLine
#else
#define my_checkmalloc()
#undef TERMINATE
#define TERMINATE(A) {}
#define QUICK_SAFEMALLOC
#define NORMAL_SAFEMALLOC
extern gptr my_malloc(uint Size,myf MyFlags);
#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);
extern void my_no_flags_free(gptr ptr);
extern gptr my_memdup(const byte *from,uint length,myf MyFlags);
extern char *my_strdup(const char *from,myf MyFlags);
extern char *my_strdup_with_length(const byte *from, uint length,
				   myf MyFlags);
#define my_free(PTR,FG) my_no_flags_free(PTR)
#define CALLER_INFO_PROTO   /* nothing */
#define CALLER_INFO         /* nothing */
#define ORIG_CALLER_INFO    /* nothing */
#endif

#ifdef HAVE_ALLOCA
#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
#pragma alloca
#endif /* _AIX */
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
#define alloca __builtin_alloca
#endif /* GNUC */
#define my_alloca(SZ) alloca((size_t) (SZ))
#define my_afree(PTR) {}
#else
#define my_alloca(SZ) my_malloc(SZ,MYF(0))
#define my_afree(PTR) my_free(PTR,MYF(MY_WME))
#endif /* HAVE_ALLOCA */

#ifdef MSDOS
#ifdef __ZTC__
void * __CDECL halloc(long count,size_t length);
void   __CDECL hfree(void *ptr);
#endif
#if defined(USE_HALLOC)
#if defined(_VCM_) || defined(M_IC80386)
#undef USE_HALLOC
#endif
#endif
#ifdef USE_HALLOC
#define malloc(a) halloc((long) (a),1)
#define free(a) hfree(a)
#endif
#endif /* MSDOS */

#ifdef HAVE_ERRNO_AS_DEFINE
#include <errno.h>			/* errno is a define */
#else
extern int errno;			/* declare errno */
#endif
extern const char ** NEAR my_errmsg[];
extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
extern char *home_dir;			/* Home directory for user */
extern char *my_progname;		/* program-name (printed in errors) */
extern char NEAR curr_dir[];		/* Current directory for user */
extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
				       myf MyFlags);
extern uint my_file_limit;

/* charsets */
extern CHARSET_INFO *default_charset_info;
extern CHARSET_INFO *all_charsets[256];
extern CHARSET_INFO compiled_charsets[];

/* statistics */
extern ulong	my_cache_w_requests, my_cache_write, my_cache_r_requests,
		my_cache_read;
extern ulong	my_blocks_used, my_blocks_changed;
extern ulong	my_file_opened,my_stream_opened, my_tmp_file_created;
extern my_bool	my_init_done;

					/* Point to current my_message() */
extern void (*my_sigtstp_cleanup)(void),
					/* Executed before jump to shell */
	    (*my_sigtstp_restart)(void),
	    (*my_abort_hook)(int);
					/* Executed when comming from shell */
extern int NEAR my_umask,		/* Default creation mask  */
	   NEAR my_umask_dir,
	   NEAR my_recived_signals,	/* Signals we have got */
	   NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
	   NEAR my_dont_interrupt;	/* call remember_intr when set */
extern my_bool NEAR mysys_uses_curses, my_use_symdir;
extern ulong sf_malloc_cur_memory, sf_malloc_max_memory;

extern ulong	my_default_record_cache_size;
extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
               NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks;
extern char	wild_many,wild_one,wild_prefix;
extern const char *charsets_dir;
extern char *defaults_extra_file;

typedef struct wild_file_pack	/* Struct to hold info when selecting files */
{
  uint		wilds;		/* How many wildcards */
  uint		not_pos;	/* Start of not-theese-files */
  my_string	*wild;		/* Pointer to wildcards */
} WF_PACK;

enum loglevel {
   ERROR_LEVEL,
   WARNING_LEVEL,
   INFORMATION_LEVEL
};

enum cache_type
{
  READ_CACHE,WRITE_CACHE,
  SEQ_READ_APPEND		/* sequential read or append */,
  READ_FIFO, READ_NET,WRITE_NET};

enum flush_type
{
  FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE
};

typedef struct st_record_cache	/* Used when cacheing records */
{
  File file;
  int	rc_seek,error,inited;
  uint	rc_length,read_length,reclength;
  my_off_t rc_record_pos,end_of_file;
  byte	*rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
#ifdef HAVE_AIOWAIT
  int	use_async_io;
  my_aio_result aio_result;
#endif
  enum cache_type type;
} RECORD_CACHE;

enum file_type
{
  UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN,
  FILE_BY_MKSTEMP, FILE_BY_DUP
};

struct st_my_file_info
{
  my_string		name;
  enum file_type	type;
#if defined(THREAD) && !defined(HAVE_PREAD)
  pthread_mutex_t	mutex;
#endif
};

extern struct st_my_file_info *my_file_info;

typedef struct st_my_tmpdir
{
  char **list;
  uint cur, max;
#ifdef THREAD
  pthread_mutex_t mutex;
#endif
} MY_TMPDIR;

typedef struct st_dynamic_array
{
  char *buffer;
  uint elements,max_element;
  uint alloc_increment;
  uint size_of_element;
} DYNAMIC_ARRAY;

typedef struct st_dynamic_string
{
  char *str;
  uint length,max_length,alloc_increment;
} DYNAMIC_STRING;

struct st_io_cache;
typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);

#ifdef THREAD
typedef struct st_io_cache_share
{
  /* to sync on reads into buffer */
  pthread_mutex_t mutex;
  pthread_cond_t  cond;
  int             count, total;
  /* actual IO_CACHE that filled the buffer */
  struct st_io_cache *active;
#ifdef NOT_YET_IMPLEMENTED
  /* whether the structure should be free'd */
  my_bool alloced;
#endif
} IO_CACHE_SHARE;
#endif

typedef struct st_io_cache		/* Used when cacheing files */
{
  /* Offset in file corresponding to the first byte of byte* buffer. */
  my_off_t pos_in_file;
  /*
    The offset of end of file for READ_CACHE and WRITE_CACHE.
    For SEQ_READ_APPEND it the maximum of the actual end of file and
    the position represented by read_end.
  */
  my_off_t end_of_file;
  /* Points to current read position in the buffer */
  byte	*read_pos;
  /* the non-inclusive boundary in the buffer for the currently valid read */
  byte  *read_end;
  byte  *buffer;				/* The read buffer */
  /* Used in ASYNC_IO */
  byte  *request_pos;

  /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
  byte  *write_buffer;
  /*
    Only used in SEQ_READ_APPEND, and points to the current read position
    in the write buffer. Note that reads in SEQ_READ_APPEND caches can
    happen from both read buffer (byte* buffer) and write buffer
    (byte* write_buffer).
  */
  byte *append_read_pos;
  /* Points to current write position in the write buffer */
  byte *write_pos;
  /* The non-inclusive boundary of the valid write area */
  byte *write_end;

  /*
    Current_pos and current_end are convenience variables used by
    my_b_tell() and other routines that need to know the current offset
    current_pos points to &write_pos, and current_end to &write_end in a
    WRITE_CACHE, and &read_pos and &read_end respectively otherwise
  */
  byte  **current_pos, **current_end;
#ifdef THREAD
  /*
    The lock is for append buffer used in SEQ_READ_APPEND cache
    need mutex copying from append buffer to read buffer.
  */
  pthread_mutex_t append_buffer_lock;
  /*
    The following is used when several threads are reading the
    same file in parallel. They are synchronized on disk
    accesses reading the cached part of the file asynchronously.
    It should be set to NULL to disable the feature.  Only
    READ_CACHE mode is supported.
  */
  IO_CACHE_SHARE *share;
#endif
  /*
    A caller will use my_b_read() macro to read from the cache
    if the data is already in cache, it will be simply copied with
    memcpy() and internal variables will be accordinging updated with
    no functions invoked. However, if the data is not fully in the cache,
    my_b_read() will call read_function to fetch the data. read_function
    must never be invoked directly.
  */
  int (*read_function)(struct st_io_cache *,byte *,uint);
  /*
    Same idea as in the case of read_function, except my_b_write() needs to
    be replaced with my_b_append() for a SEQ_READ_APPEND cache
  */
  int (*write_function)(struct st_io_cache *,const byte *,uint);
  /*
    Specifies the type of the cache. Depending on the type of the cache
    certain operations might not be available and yield unpredicatable
    results. Details to be documented later
  */
  enum cache_type type;
  /*
    Callbacks when the actual read I/O happens. These were added and
    are currently used for binary logging of LOAD DATA INFILE - when a
    block is read from the file, we create a block create/append event, and
    when IO_CACHE is closed, we create an end event. These functions could,
    of course be used for other things
  */
  IO_CACHE_CALLBACK pre_read;
  IO_CACHE_CALLBACK post_read;
  IO_CACHE_CALLBACK pre_close;
  /*
    Counts the number of times, when we were forced to use disk. We use it to
    increase the binlog_cache_disk_use status variable.
  */
  ulong disk_writes;
  void* arg;				/* for use by pre/post_read */
  char *file_name;			/* if used with 'open_cached_file' */
  char *dir,*prefix;
  File file; /* file descriptor */
  /*
    seek_not_done is set by my_b_seek() to inform the upcoming read/write
    operation that a seek needs to be preformed prior to the actual I/O
    error is 0 if the cache operation was successful, -1 if there was a
    "hard" error, and the actual number of I/O-ed bytes if the read/write was
    partial.
  */
  int	seek_not_done,error;
  /* buffer_length is memory size allocated for buffer or write_buffer */
  uint	buffer_length;
  /* read_length is the same as buffer_length except when we use async io */
  uint  read_length;
  myf	myflags;			/* Flags used to my_read/my_write */
  /*
    alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
    0 if it was supplied by the user.
    Currently READ_NET is the only one that will use a buffer allocated
    somewhere else
  */
  my_bool alloced_buffer;
#ifdef HAVE_AIOWAIT
  /*
    As inidicated by ifdef, this is for async I/O, which is not currently
    used (because it's not reliable on all systems)
  */
  uint inited;
  my_off_t aio_read_pos;
  my_aio_result aio_result;
#endif
} IO_CACHE;

typedef int (*qsort2_cmp)(const void *, const void *, const void *);

	/* defines for mf_iocache */

	/* Test if buffer is inited */
#define my_b_clear(info) (info)->buffer=0
#define my_b_inited(info) (info)->buffer
#define my_b_EOF INT_MIN

#define my_b_read(info,Buffer,Count) \
  ((info)->read_pos + (Count) <= (info)->read_end ?\
   (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \
    ((info)->read_pos+=(Count)),0) :\
   (*(info)->read_function)((info),Buffer,Count))

#define my_b_write(info,Buffer,Count) \
 ((info)->write_pos + (Count) <=(info)->write_end ?\
  (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
   ((info)->write_pos+=(Count)),0) : \
   (*(info)->write_function)((info),(Buffer),(Count)))

#define my_b_get(info) \
  ((info)->read_pos != (info)->read_end ?\
   ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\
   _my_b_get(info))

	/* my_b_write_byte dosn't have any err-check */
#define my_b_write_byte(info,chr) \
  (((info)->write_pos < (info)->write_end) ?\
   ((*(info)->write_pos++)=(chr)) :\
   (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr))))

#define my_b_fill_cache(info) \
  (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0))

#define my_b_tell(info) ((info)->pos_in_file + \
			 (uint) (*(info)->current_pos - (info)->request_pos))

/* tell write offset in the SEQ_APPEND cache */
my_off_t my_b_append_tell(IO_CACHE* info);

#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \
					  *(info)->current_pos)

typedef uint32 ha_checksum;

#include <my_alloc.h>

	/* Prototypes for mysys and my_func functions */

extern int my_copy(const char *from,const char *to,myf MyFlags);
extern int my_append(const char *from,const char *to,myf MyFlags);
extern int my_delete(const char *name,myf MyFlags);
extern int my_getwd(my_string buf,uint size,myf MyFlags);
extern int my_setwd(const char *dir,myf MyFlags);
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
extern gptr my_once_alloc(uint Size,myf MyFlags);
extern void my_once_free(void);
extern char *my_once_strdup(const char *src,myf myflags);
extern char *my_once_memdup(const char *src, uint len, myf myflags);
extern my_string my_tempnam(const char *dir,const char *pfx,myf MyFlags);
extern File my_open(const char *FileName,int Flags,myf MyFlags);
extern File my_register_filename(File fd, const char *FileName,
				 enum file_type type_of_file,
				 uint error_message_number, myf MyFlags);
extern File my_create(const char *FileName,int CreateFlags,
		      int AccsesFlags, myf MyFlags);
extern int my_close(File Filedes,myf MyFlags);
extern File my_dup(File file, myf MyFlags);
extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
extern int my_readlink(char *to, const char *filename, myf MyFlags);
extern int my_realpath(char *to, const char *filename, myf MyFlags);
extern File my_create_with_symlink(const char *linkname, const char *filename,
				   int createflags, int access_flags,
				   myf MyFlags);
extern int my_delete_with_symlink(const char *name, myf MyFlags);
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags);
extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset,
		     myf MyFlags);
extern int my_rename(const char *from,const char *to,myf MyFlags);
extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_tell(File fd,myf MyFlags);
extern uint my_write(File Filedes,const byte *Buffer,uint Count,
		     myf MyFlags);
extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count,
		      my_off_t offset,myf MyFlags);
extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags);
extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count,
		      myf MyFlags);
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
extern gptr _mymalloc(uint uSize,const char *sFile,
		      uint uLine, myf MyFlag);
extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
		       uint uLine, myf MyFlag);
extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
extern int _sanity(const char *sFile,unsigned int uLine);
extern gptr _my_memdup(const byte *from,uint length,
		       const char *sFile, uint uLine,myf MyFlag);
extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
			    myf MyFlag);
extern char *_my_strdup_with_length(const byte *from, uint length,
				    const char *sFile, uint uLine,
				    myf MyFlag);

#ifndef TERMINATE
extern void TERMINATE(FILE *file);
#endif
extern void init_glob_errs(void);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern int my_fclose(FILE *fd,myf MyFlags);
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
extern int my_sync(File fd, myf my_flags);
extern int my_error _VARARGS((int nr,myf MyFlags, ...));
extern int my_printf_error _VARARGS((uint my_err, const char *format,
				     myf MyFlags, ...)
				    __attribute__ ((format (printf, 2, 4))));
extern int my_message(uint my_err, const char *str,myf MyFlags);
extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
extern my_bool my_init(void);
extern void my_end(int infoflag);
extern int my_redel(const char *from, const char *to, int MyFlags);
extern int my_copystat(const char *from, const char *to, int MyFlags);
extern my_string my_filename(File fd);

#ifndef THREAD
extern void dont_break(void);
extern void allow_break(void);
#else
#define dont_break()
#define allow_break()
#endif

extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
extern char *my_tmpdir(MY_TMPDIR *tmpdir);
extern void free_tmpdir(MY_TMPDIR *tmpdir);

extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
extern uint dirname_part(my_string to,const char *name);
extern uint dirname_length(const char *name);
#define base_name(A) (A+dirname_length(A))
extern int test_if_hard_path(const char *dir_name);
extern char *convert_dirname(char *to, const char *from, const char *from_end);
extern void to_unix_path(my_string name);
extern my_string fn_ext(const char *name);
extern my_string fn_same(my_string toname,const char *name,int flag);
extern my_string fn_format(my_string to,const char *name,const char *dir,
			   const char *form, uint flag);
extern size_s strlength(const char *str);
extern void pack_dirname(my_string to,const char *from);
extern uint unpack_dirname(my_string to,const char *from);
extern uint cleanup_dirname(my_string to,const char *from);
extern uint system_filename(my_string to,const char *from);
extern uint unpack_filename(my_string to,const char *from);
extern my_string intern_filename(my_string to,const char *from);
extern my_string directory_file_name(my_string dst, const char *src);
extern int pack_filename(my_string to, const char *name, size_s max_length);
extern my_string my_path(my_string to,const char *progname,
			 const char *own_pathname_part);
extern my_string my_load_path(my_string to, const char *path,
			      const char *own_path_prefix);
extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern);
extern WF_PACK *wf_comp(my_string str);
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
extern void wf_end(struct wild_file_pack *buffer);
extern size_s strip_sp(my_string str);
extern void get_date(my_string to,int timeflag,time_t use_time);
extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage);
extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
			     uint reclength,enum cache_type type,
			     pbool use_async_io);
extern int read_cache_record(RECORD_CACHE *info,byte *to);
extern int end_record_cache(RECORD_CACHE *info);
extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
			      const byte *record,uint length);
extern int flush_write_cache(RECORD_CACHE *info);
extern long my_clock(void);
extern sig_handler sigtstp_handler(int signal_number);
extern void handle_recived_signals(void);

extern sig_handler my_set_alarm_variable(int signo);
extern void my_string_ptr_sort(void *base,uint items,size_s size);
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
				  size_s size_of_element,uchar *buffer[]);
extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
		      qsort2_cmp cmp, void *cmp_argument);
extern qsort2_cmp get_ptr_compare(uint);
extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
			 enum cache_type type,my_off_t seek_offset,
			 pbool use_async_io, myf cache_myflags);
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
			       my_off_t seek_offset,pbool use_async_io,
			       pbool clear_cache);
extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count);
#ifdef THREAD
extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count);
extern void init_io_cache_share(IO_CACHE *info,
				IO_CACHE_SHARE *s, uint num_threads);
extern void remove_io_thread(IO_CACHE *info);
#endif
extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_get(IO_CACHE *info);
extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count);
extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count);
extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count);

extern int my_block_write(IO_CACHE *info, const byte *Buffer,
			  uint Count, my_off_t pos);
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);

#define flush_io_cache(info) my_b_flush_io_cache((info),1)

extern int end_io_cache(IO_CACHE *info);
extern uint my_b_fill(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
extern my_off_t my_b_filelength(IO_CACHE *info);
extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
				 const char *prefix, uint cache_size,
				 myf cache_myflags);
extern my_bool real_open_cached_file(IO_CACHE *cache);
extern void close_cached_file(IO_CACHE *cache);
File create_temp_file(char *to, const char *dir, const char *pfx,
		      int mode, myf MyFlags);
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO)
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO)
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
	  uint init_alloc,uint alloc_increment CALLER_INFO_PROTO);
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
extern byte *alloc_dynamic(DYNAMIC_ARRAY *array);
extern byte *pop_dynamic(DYNAMIC_ARRAY*);
extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
extern void delete_dynamic(DYNAMIC_ARRAY *array);
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
extern void freeze_size(DYNAMIC_ARRAY *array);
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
#define push_dynamic(A,B) insert_dynamic(A,B)
#define reset_dynamic(array) ((array)->elements= 0)

extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
				   uint init_alloc,uint alloc_increment);
extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
			  uint length);
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
extern void dynstr_free(DYNAMIC_STRING *str);
#ifdef HAVE_MLOCK
extern byte *my_malloc_lock(uint length,myf flags);
extern void my_free_lock(byte *ptr,myf flags);
#else
#define my_malloc_lock(A,B) my_malloc((A),(B))
#define my_free_lock(A,B) my_free((A),(B))
#endif
#define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
			    uint pre_alloc_size);
extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
                                uint prealloc_size);
extern char *strdup_root(MEM_ROOT *root,const char *str);
extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
extern int load_defaults(const char *conf_file, const char **groups,
			 int *argc, char ***argv);
extern void free_defaults(char **argv);
extern void print_defaults(const char *conf_file, const char **groups);
extern my_bool my_compress(byte *, ulong *, ulong *);
extern my_bool my_uncompress(byte *, ulong *, ulong *);
extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count);
extern uint my_bit_log2(ulong value);
extern uint my_count_bits(ulonglong v);
extern void my_sleep(ulong m_seconds);
extern ulong crc32(ulong crc, const uchar *buf, uint len);
extern uint my_set_max_open_files(uint files);
void my_free_open_file_info(void);

ulonglong my_getsystime(void);
my_bool my_gethwaddr(uchar *to);

/* character sets */
extern uint get_charset_number(const char *cs_name, uint cs_flags);
extern uint get_collation_number(const char *name);
extern const char *get_charset_name(uint cs_number);

extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
					   uint cs_flags, myf my_flags);
extern void free_charsets(void);
extern char *get_charsets_dir(char *buf);
extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
extern my_bool init_compiled_charsets(myf flags);
extern void add_compiled_collation(CHARSET_INFO *cs);
extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
                                     const char *from, ulong length);

#ifdef __WIN__
extern my_bool have_tcpip;		/* Is set if tcpip is used */
#endif
#ifdef __NETWARE__
void netware_reg_user(const char *ip, const char *user,
		      const char *application);
#endif

C_MODE_END
#include "raid.h"
#endif /* _my_sys_h */


text:
package io.seata.console.config;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author liuqiufeng
 */
@Configuration(proxyBeanMethods = false)
public class JacksonConfig {

    /**
     * convert long to string for return to the front end
     */
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer longToStringCustomizer() {
        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.serializerByType(Long.class, new JsonSerializer<Long>() {
            @Override
            public void serialize(Long value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
                if (value == null) {
                    jsonGenerator.writeString("");
                } else {
                    jsonGenerator.writeString(value.toString());
                }
            }
        });
    }
}


text:
package com.intellij.psi.search;

import com.intellij.psi.PsiFile;

@FunctionalInterface
public interface PsiNonJavaFileReferenceProcessor {
  boolean process(PsiFile file, int startOffset, int endOffset);
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="MaterialNavigationDrawerTheme" parent="Theme.AppCompat.NoActionBar" >
        <item name="drawerType">@integer/DRAWERTYPE_ACCOUNTS</item>
        <item name="drawerColor">#ff303030</item>
        <item name="rippleBackport">false</item>
        <item name="uniqueToolbarColor">false</item>
        <item name="singleAccount">false</item>
        <item name="sectionStyle">@style/MaterialSectionTheme</item>
        <item name="subheaderStyle">@style/MaterialSubheaderTheme</item>
        <item name="accountStyle">@style/MaterialAccountTheme</item>
        <item name="multipaneSupport">false</item>
        <item name="defaultSectionLoaded">0</item>
        <item name="learningPattern">true</item>
        <item name="toolbarElevation">false</item>
    </style>

    <style name="MaterialNavigationDrawerTheme.Light" parent="Theme.AppCompat.Light.NoActionBar" >
        <item name="drawerType">@integer/DRAWERTYPE_ACCOUNTS</item>
        <item name="drawerColor">#ffeeeeee</item>
        <item name="rippleBackport">false</item>
        <item name="uniqueToolbarColor">false</item>
        <item name="singleAccount">false</item>
        <item name="sectionStyle">@style/MaterialSectionTheme.Light</item>
        <item name="subheaderStyle">@style/MaterialSubheaderTheme.Light</item>
        <item name="accountStyle">@style/MaterialAccountTheme</item>
        <item name="multipaneSupport">false</item>
        <item name="defaultSectionLoaded">0</item>
        <item name="learningPattern">true</item>
        <item name="toolbarElevation">false</item>
    </style>

    <style name="MaterialNavigationDrawerTheme.Light.DarkActionBar" parent="Theme.AppCompat.Light.NoActionBar" >
        <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
        <item name="popupTheme">@style/Base.V21.Theme.AppCompat.Light.Dialog</item>
        <item name="drawerType">@integer/DRAWERTYPE_ACCOUNTS</item>
        <item name="drawerColor">#ffeeeeee</item>
        <item name="rippleBackport">false</item>
        <item name="uniqueToolbarColor">false</item>
        <item name="singleAccount">false</item>
        <item name="sectionStyle">@style/MaterialSectionTheme.Light</item>
        <item name="subheaderStyle">@style/MaterialSubheaderTheme.Light</item>
        <item name="accountStyle">@style/MaterialAccountTheme</item>
        <item name="multipaneSupport">false</item>
        <item name="defaultSectionLoaded">0</item>
        <item name="learningPattern">true</item>
        <item name="toolbarElevation">false</item>
    </style>

    <style name="MaterialNavigationDrawerTheme.Light.TranslucentKitKatStatusBar" parent="MaterialNavigationDrawerTheme.Light" />

    <style name="MaterialNavigationDrawerTheme.TranslucentKitKatStatusBar" parent="MaterialNavigationDrawerTheme" />

    <style name="MaterialNavigationDrawerTheme.Light.DarkActionBar.TranslucentKitKatStatusBar" parent="MaterialNavigationDrawerTheme.Light.DarkActionBar" />

    <style name="MaterialSectionTheme" >
        <item name="sectionColorIcon">#FFF</item>
        <item name="sectionColorText">#FFF</item>
        <item name="sectionColorNotification">#FFF</item>
        <item name="sectionBackgroundColorPressed">#16FFFFFF</item>
        <item name="sectionBackgroundColorSelected">#0AFFFFFF</item>
        <item name="sectionBackgroundColor">#00FFFFFF</item>
    </style>

    <style name="MaterialSectionTheme.Light" >
        <item name="sectionColorIcon">#000000</item>
        <item name="sectionColorText">#000000</item>
        <item name="sectionColorNotification">#000000</item>
        <item name="sectionBackgroundColorPressed">#16000000</item>
        <item name="sectionBackgroundColorSelected">#0A000000</item>
        <item name="sectionBackgroundColor">#00FFFFFF</item>
    </style>

    <style name="MaterialSubheaderTheme">
        <item name="subheaderTitleColor">#FFF</item>
    </style>

    <style name="MaterialSubheaderTheme.Light">
        <item name="subheaderTitleColor">#000</item>
    </style>

    <style name="MaterialAccountTheme">
        <item name="titleColor">#FFF</item>
        <item name="subtitleColor">#FFF</item>
    </style>

</resources>


text:
package com.wenchao.cardstack;

import android.content.Context;
import android.support.v4.view.GestureDetectorCompat;
import android.support.v4.view.MotionEventCompat;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;

//detect both tap and drag
public class DragGestureDetector {
    public static String DEBUG_TAG = "DragGestureDetector";
    GestureDetectorCompat mGestrueDetector;
    DragListener mListener;
    private boolean mStarted = false;
    private MotionEvent mOriginalEvent;
    public static interface DragListener {
        public boolean onDragStart(MotionEvent e1, MotionEvent e2, float distanceX,
                                float distanceY);
        public boolean onDragContinue(MotionEvent e1, MotionEvent e2, float distanceX,
                                   float distanceY);
        public boolean onDragEnd(MotionEvent e1, MotionEvent e2);

        public boolean onTapUp();
    }

    public DragGestureDetector(Context context, DragListener myDragListener){
        mGestrueDetector = new GestureDetectorCompat(context,new MyGestureListener());
        mListener = myDragListener;
    }

    public void onTouchEvent(MotionEvent event){
        mGestrueDetector.onTouchEvent(event);
        int action = MotionEventCompat.getActionMasked(event);
        switch(action) {
            case (MotionEvent.ACTION_UP) :
                Log.d(DEBUG_TAG,"Action was UP");
                if(mStarted) {
                    mListener.onDragEnd(mOriginalEvent, event);
                }
                mStarted = false;
            case (MotionEvent.ACTION_DOWN) :
                //need to set this, quick tap will not generate drap event, so the
                //originalEvent may be null for case action_up
                //which lead to null pointer
                mOriginalEvent = event;
        }
    }

    class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
                                float distanceY) {
            if(mListener == null) return true;
            if( mStarted == false){
                mListener.onDragStart(e1,e2,distanceX,distanceY);
                mStarted = true;
            }
            else{
                mListener.onDragContinue(e1,e2,distanceX,distanceY);
            }
            mOriginalEvent = e1;
            return true;
        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {

            return mListener.onTapUp();
        }
    }

}


text:
using namespace Toast::Concurrent;

#ifdef OS_WIN
static int pthread_mutex_init(pthread_mutex_t *mutex, void *unused) {
	(void)unused;
	*mutex = CreateMutex(NULL, FALSE, NULL);
	return *mutex == NULL ? -1 : 0;
}

static int pthread_mutex_destroy(pthread_mutex_t *mutex) {
	return CloseHandle(*mutex) == 0 ? -1 : 0;
}

static int pthread_mutex_lock(pthread_mutex_t *mutex) {
	return WaitForSingleObject(*mutex, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
}

static int pthread_mutex_unlock(pthread_mutex_t *mutex) {
	return ReleaseMutex(*mutex) == 0 ? -1 : 0;
}
#endif

Mutex::Mutex() {
#ifdef OS_WIN
	InitializeCriticalSection(&_cs);
#else
	_mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
	pthread_mutex_init(_mutex, NULL);
#endif
}

Mutex::~Mutex() {
#ifdef OS_WIN
	DeleteCriticalSection(&_cs);
#else
	pthread_mutex_destroy(_mutex);
	free(_mutex);
#endif
}

void Mutex::lock() {
#ifdef OS_WIN
	EnterCriticalSection(&_cs);
#else
	pthread_mutex_lock(_mutex);
#endif
}

void Mutex::unlock() {
#ifdef OS_WIN
	LeaveCriticalSection(&_cs);
#else
	pthread_mutex_unlock(_mutex);
#endif
}

bool Mutex::try_lock() {
	// Don't you love OS consistency?
#ifdef OS_WIN
	return TryEnterCriticalSection(&_cs) != 0;		// 0 = Already Locked
#else
	return pthread_mutex_trylock(_mutex) == 0;		// 0 = Not already locked
#endif
}

IPCMutex::IPCMutex(std::string name, int size, bool owner) {
	_size = size;
	_name = name;
	if (owner) {
#ifdef OS_WIN
		_mutex_ptr = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t) * size);
		for (int id = 0; id < size; id++)
			*(_mutex_ptr + id) = CreateMutex(NULL, FALSE, ("Global\\TOAST_IPC_MUTEX_" + name + "_" + std::to_string(id)).c_str());
#else
		handle = Toast::Internal::SHM::create_shm_file("IPC_MUTEX_" + name, size * sizeof(pthread_mutex_t));
		_mutex_ptr = (pthread_mutex_t *)Toast::Internal::SHM::map_shm_file(handle, size * sizeof(pthread_mutex_t));

		for (int id = 0; id < size; id++) {
			pthread_mutexattr_t mutex_attr;
			pthread_mutexattr_init(&mutex_attr);
			pthread_mutexattr_setpshared(&mutex_attr, PTHREAD_PROCESS_SHARED);
			pthread_mutex_init(_mutex_ptr + id, &mutex_attr);
		}
#endif
	}
	else {
#ifdef OS_WIN
		_mutex_ptr = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t) * size);
		for (int id = 0; id < size; id++)
			*(_mutex_ptr + id) = OpenMutex(SYNCHRONIZE, FALSE, ("Global\\TOAST_IPC_MUTEX_" + name + "_" + std::to_string(id)).c_str());
#else
		handle = Toast::Internal::SHM::open_shm_file("IPC_MUTEX_" + name);
		_mutex_ptr = (pthread_mutex_t *)Toast::Internal::SHM::map_shm_file(handle, size * sizeof(pthread_mutex_t));
#endif
	}
}

IPCMutex::~IPCMutex() {
	free();
}

void IPCMutex::free() {
#ifdef OS_WIN
	for (int id = 0; id < _size; id++)
		CloseHandle(*(_mutex_ptr + id));
#else
	Toast::Internal::SHM::close_shm_file("IPC_MUTEX_" + _name, handle);
#endif
}

void IPCMutex::lock(int id) {
	pthread_mutex_lock(_mutex_ptr + id);
}

void IPCMutex::unlock(int id) {
	pthread_mutex_unlock(_mutex_ptr + id);
}


text:
Additional header content

Gets the input Uri.

**Namespace:** iTin.Export.ComponentModel
**Assembly:** iTin.Export.Core (in iTin.Export.Core.dll) Version: 2.0.0.0 (2.0.0.0)

## Syntax

**C#**

``` C#
Uri InputUri { get; }
```

**VB**

``` VB
ReadOnly Property InputUri As Uri
	Get
```

#### Property Value
Type: Uri
Reference to the input file.

## Remarks
\[Missing <remarks> documentation for "P:iTin.Export.ComponentModel.ISettings.InputUri"\]

## See Also

#### Reference
ISettings Interface
iTin.Export.ComponentModel Namespace


text:
import java.io.IOException;
import java.util.Map;

import com.google.cloud.genomics.dockerflow.args.ArgsBuilder;
import com.google.cloud.genomics.dockerflow.args.WorkflowArgs;
import com.google.cloud.genomics.dockerflow.task.Task;
import com.google.cloud.genomics.dockerflow.task.TaskBuilder;
import com.google.cloud.genomics.dockerflow.workflow.Workflow;
import com.google.cloud.genomics.dockerflow.workflow.Workflow.Branch;
import com.google.cloud.genomics.dockerflow.workflow.Workflow.Steps;
import com.google.cloud.genomics.dockerflow.workflow.WorkflowDefn;

/**
 * As an example of running a real-world workflow with Dockerflow, this is a translation
 * of the Broad Institute's
 *
 * GATK WDL file.
 */
public class GatkPairedSingleSample implements WorkflowDefn {
  static final String GATK_IMAGE = "broadinstitute/genomes-in-the-cloud:2.2.3-1469027018";

  // Get version of BWA
  static Task BwaVersion = TaskBuilder.named("BwaVersion")
      .docker(GATK_IMAGE)
      .script("/usr/gitc/bwa 2>&1 | grep -e '^Version' | sed 's/Version: //'")
      .build();

  // Read unmapped BAM, convert on-the-fly to FASTQ and stream to BWA MEM for alignment
  static Task SamToFastqAndBwaMem = TaskBuilder.named("SamToFastqAndBwaMem")
      .inputFile("input_bam").scatterBy("input_bam")
      .input("bwa_commandline", "${bwa_commandline}")
      .input("output_bam_basename")
      .inputFile("ref_fasta", "${ref_fasta}")
      .inputFile("ref_fasta_index", "${ref_fasta_index}")
      .inputFile("ref_alt", "${ref_alt}")
      .inputFile("ref_amb", "${ref_amb}")
      .inputFile("ref_ann", "${ref_ann}")
      .inputFile("ref_bwt", "${ref_bwt}")
      .inputFile("ref_pac", "${ref_pac}")
      .inputFile("ref_sa", "${ref_sa}")
      .outputFile("output_bam", "${output_bam_basename}.bam")
      .outputFile("bwa_stderr_log", "${output_bam_basename}.bwa.stderr.log")
      .preemptible(true)
      .diskSize("${flowcell_medium_disk}")
      .memory(14)
      .cpu(16)
      .docker(GATK_IMAGE)
      .script(
        "set -o pipefail\n" +
        "# set the bash variable needed for the command-line\n" +
        "# bash_ref_fasta=${ref_fasta}\n" + // moved from here in WDL to bwa CLI below
        "# if ref_alt has data in it, \n" +
        "if [ -s ${ref_alt} ]; then\n" +
        "  java -Xmx3000m -jar /usr/gitc/picard.jar \\\n" +
        "  SamToFastq \\\n" +
        "  INPUT=${input_bam} \\\n" +
        "  FASTQ=/dev/stdout \\\n" +
        "  INTERLEAVE=true \\\n" +
        "  NON_PF=true |\\\n" +
        "  /usr/gitc/${bwa_commandline} ${ref_fasta} /dev/stdin -  2> >(tee ${bwa_stderr_log} >&2) | \\\n" +
        "  samtools view -1 - > ${output_bam} && \\\n" +
        "  grep -m1 \"read .* ALT contigs\" ${bwa_stderr_log} | \\\n" +
        "  grep -v \"read 0 ALT contigs\"\n" +
        "# else ref_alt is empty or could not be found\n" +
        "else\n" +
        "  exit 1;\n" +
        "fi")
      .build();

  // Merge original input uBAM file with BWA-aligned BAM file
  static Task MergeBamAlignment = TaskBuilder.named("MergeBamAlignment")
      .inputFile("unmapped_bam")
      .input("bwa_commandline", "${bwa_commandline}")
      .input("bwa_version")
      .inputFile("aligned_bam")
      .input("output_bam_basename")
      .inputFile("ref_fasta", "${ref_fasta}")
      .inputFile("ref_fasta_index", "${ref_fasta_index}")
      .inputFile("ref_dict", "${ref_dict}")
      .outputFile("output_bam", "${output_bam_basename}.bam")
      .memory(3.5)
      .preemptible(true)
      .diskSize("${flowcell_medium_disk}")
       .docker(GATK_IMAGE)
       .script(
        "# set the bash variable needed for the command-line\n" +
        "bash_ref_fasta=${ref_fasta}\n" +
        "java -Xmx3000m -jar /usr/gitc/picard.jar \\\n" +
        "  MergeBamAlignment \\\n" +
        "  VALIDATION_STRINGENCY=SILENT \\\n" +
        "  EXPECTED_ORIENTATIONS=FR \\\n" +
        "  ATTRIBUTES_TO_RETAIN=X0 \\\n" +
        "  ALIGNED_BAM=${aligned_bam} \\\n" +
        "  UNMAPPED_BAM=${unmapped_bam} \\\n" +
        "  OUTPUT=${output_bam} \\\n" +
        "  REFERENCE_SEQUENCE=${ref_fasta} \\\n" +
        "  PAIRED_RUN=true \\\n" +
        "  SORT_ORDER=\"unsorted\" \\\n" +
        "  IS_BISULFITE_SEQUENCE=false \\\n" +
        "  ALIGNED_READS_ONLY=false \\\n" +
        "  CLIP_ADAPTERS=false \\\n" +
        "  MAX_RECORDS_IN_RAM=2000000 \\\n" +
        "  ADD_MATE_CIGAR=true \\\n" +
        "  MAX_INSERTIONS_OR_DELETIONS=-1 \\\n" +
        "  PRIMARY_ALIGNMENT_STRATEGY=MostDistant \\\n" +
        "  PROGRAM_RECORD_ID=\"bwamem\" \\\n" +
        "  PROGRAM_GROUP_VERSION=\"${bwa_version}\" \\\n" +
        "  PROGRAM_GROUP_COMMAND_LINE=\"${bwa_commandline} ${ref_fasta}\" \\\n" +
        "  PROGRAM_GROUP_NAME=\"bwamem\" \\\n" +
        "  UNMAP_CONTAMINANT_READS=true")
      .build();

  // Sort BAM file by coordinate order and fix tag values for NM and UQ
  static Task SortAndFixReadGroupBam = TaskBuilder.named("SortAndFixReadGroupBam")
      .inputFile("input_bam")
      .input("output_bam_basename")
      .inputFile("ref_dict", "${ref_dict}")
      .inputFile("ref_fasta", "${ref_fasta}")
      .inputFile("ref_fasta_index", "${ref_fasta_index}")
      .outputFile("output_bam", "${output_bam_basename}.bam")
      .outputFile("output_bam_index", "${output_bam_basename}.bai")
      .outputFile("output_bam_md5",  "${output_bam_basename}.bam.md5")
      .memory(5)
      .preemptible(true)
      .diskSize("${flowcell_medium_disk}")
      .docker(GATK_IMAGE)
      .script(
        "java -Xmx4000m -jar /usr/gitc/picard.jar \\\n" +
        "  SortSam \\\n" +
        "  INPUT=${input_bam} \\\n" +
        "  OUTPUT=/dev/stdout \\\n" +
        "  SORT_ORDER=\"coordinate\" \\\n" +
        "  CREATE_INDEX=false \\\n" +
        "  CREATE_MD5_FILE=false | java -Xmx500m -jar /usr/gitc/picard.jar \\\n" +
        "  SetNmAndUqTags \\\n" +
        "  INPUT=/dev/stdin \\\n" +
        "  OUTPUT=${output_bam} \\\n" +
        "  CREATE_INDEX=true \\\n" +
        "  CREATE_MD5_FILE=true \\\n" +
        "  REFERENCE_SEQUENCE=${ref_fasta}")
      .input("pipeline_run", "${workflow.index}").gatherBy("pipeline_run")
      .build();

  // Mark duplicate reads to avoid counting non-independent observations
  static Task MarkDuplicates = TaskBuilder.named("MarkDuplicates")
      .inputFileArray("input_bams", " INPUT=")
      .input("output_bam_basename")
      .input("metrics_filename")
      .outputFile("output_bam", "${output_bam_basename}.bam")
      .outputFile("duplicate_metrics", "${metrics_filename}")
      .memory(7)
      .preemptible(true)
      .diskSize("${agg_large_disk}")
      .docker(GATK_IMAGE)
      .script(
        "java -Xmx4000m -jar /usr/gitc/picard.jar \\\n" +
        "  MarkDuplicates \\\n" +
        "  INPUT=${input_bams} \\\n" +
        "  OUTPUT=${output_bam} \\\n" +
        "  METRICS_FILE=${duplicate_metrics} \\\n" +
        "  VALIDATION_STRINGENCY=SILENT \\\n" +
        "  OPTICAL_DUPLICATE_PIXEL_DISTANCE=2500 \\\n" +
        "  ASSUME_SORT_ORDER=\"queryname\"\\\n" +
        "  CREATE_MD5_FILE=true")
      .build();

  static Task SortAndFixSampleBam = TaskBuilder.fromTask(SortAndFixReadGroupBam, "SortAndFixSampleBam")
      .gatherBy(null)
      .diskSize("${agg_large_disk}")
      .build();

  // Generate sets of intervals for scatter-gathering over chromosomes
  static Task CreateSequenceGroupingTSV = TaskBuilder.named("CreateSequenceGroupingTSV")
      .inputFile("ref_dict", "${ref_dict}")
      .memory(2)
      .preemptible(true)
      .docker("python:2.7")
      // Use python to create the Sequencing Groupings used for BQSR and
      //PrintReads Scatter.  It outputs to stdout
      // where it is parsed into a wdl Array[Array[String]]
      // e.g. [["1"], ["2"], ["3", "4"], ["5"], ["6", "7", "8"]]
      .script(
        "python <<CODE\n" +
        "with open(\"${ref_dict}\", \"r\") as ref_dict_file:\n" +
        "  sequence_tuple_list = []\n" +
        "  longest_sequence = 0\n" +
        "  for line in ref_dict_file:\n" +
        "    if line.startswith(\"@SQ\"):\n" +
        "      line_split = line.split(\"\\t\")\n" +
        "      # (Sequence_Name, Sequence_Length)\n" +
        "      sequence_tuple_list.append((line_split[1].split(\"SN:\")[1], int(line_split[2].split(\"LN:\")[1])))\n" +
        "  longest_sequence = sorted(sequence_tuple_list, key=lambda x: x[1], reverse=True)[0][1]\n" +

        "# We are adding this to the intervals because hg38 has contigs named with embedded colons and a bug in GATK strips off\n" +
        "# the last element after a :, so we add this as a sacrificial element.\n" +
        "hg38_protection_tag = \":1+\"\n" +
        "# initialize the tsv string with the first sequence\n" +
        "tsv_string = sequence_tuple_list[0][0] + hg38_protection_tag\n" +
        "temp_size = sequence_tuple_list[0][1]\n" +
        "for sequence_tuple in sequence_tuple_list[1:]:\n" +
        "  if temp_size + sequence_tuple[1] <= longest_sequence:\n" +
        "    temp_size += sequence_tuple[1]\n" +
        "    tsv_string += \"\\t\" + sequence_tuple[0] + hg38_protection_tag\n" +
        "  else:\n" +
        "    tsv_string += \"\\n\" + sequence_tuple[0] + hg38_protection_tag\n" +
        "    temp_size = sequence_tuple[1]\n" +

        "print tsv_string\n" +
        "CODE")
      .build();

  // Generate Base Quality Score Recalibration (BQSR) model
  static Task BaseRecalibrator = TaskBuilder.named("BaseRecalibrator")
      .inputFile("input_bam")
      .inputFile("input_bam_index")
      .input("recalibration_report_filename")
      .inputArray("sequence_group_interval", " -L ").scatterBy("sequence_group_interval")
      .inputFile("dbSNP_vcf", "${dbSNP_vcf}")
      .inputFile("dbSNP_vcf_index", "${dbSNP_vcf_index}")
      .inputFile("known_snps_sites_vcf", "${known_snps_sites_vcf}")
      .inputFile("known_snps_sites_vcf_index", "${known_snps_sites_vcf_index}")
      .inputFile("known_indels_sites_vcf", "${known_indels_sites_vcf}")
      .inputFile("known_indels_sites_vcf_index", "${known_indels_sites_vcf_index}")
      .inputFile("ref_dict", "${ref_dict}")
      .inputFile("ref_fasta", "${ref_fasta}")
      .inputFile("ref_fasta_index", "${ref_fasta_index}")
      .outputFile("recalibration_report", "${recalibration_report_filename}")
      .memory(6)
      .preemptible(true)
      .diskSize("${agg_small_disk}")
      .docker(GATK_IMAGE)
      .script(
        "java -XX:GCTimeLimit=50 -XX:GCHeapFreeLimit=10 -XX:+PrintFlagsFinal \\\n" +
        "  -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCDetails \\\n" +
        "  -Xloggc:gc_log.log -Dsamjdk.use_async_io=false -Xmx4000m \\\n" +
        "  -jar /usr/gitc/GATK4.jar \\\n" +
        "  BaseRecalibrator \\\n" +
        "  -R ${ref_fasta} \\\n" +
        "  -I ${input_bam} \\\n" +
        "  --useOriginalQualities \\\n" +
        "  -O ${recalibration_report} \\\n" +
        "  -knownSites ${dbSNP_vcf} \\\n" +
        "  -knownSites ${known_snps_sites_vcf} \\\n" +
        "  -knownSites ${known_indels_sites_vcf} \\\n" +
        "  -L ${sequence_group_interval}")
      .build();

  // Apply Base Quality Score Recalibration (BQSR) model
  static Task ApplyBQSR = TaskBuilder.named("ApplyBQSR")
      .inputFile("input_bam")
      .inputFile("input_bam_index")
      .input("output_bam_basename")
      .inputFile("recalibration_report")
      .inputArray("sequence_group_interval", " -L ")
      .inputFile("ref_dict", "${ref_dict}")
      .inputFile("ref_fasta", "${ref_fasta}")
      .inputFile("ref_fasta_index", "${ref_fasta_index}")
      .outputFile("recalibrated_bam", "${output_bam_basename}.bam")
      .outputFile("recalibrated_bam_checksum", "${output_bam_basename}.bam.md5")
      .memory(3.5)
      .preemptible(true)
      .diskSize("${agg_small_disk}")
      .docker(GATK_IMAGE)
      .script(
        "java -XX:+PrintFlagsFinal -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps \\\n" +
        "  -XX:+PrintGCDetails -Xloggc:gc_log.log -Dsamjdk.use_async_io=false \\\n" +
        "  -XX:GCTimeLimit=50 -XX:GCHeapFreeLimit=10 -Xmx3000m \\\n" +
        "  -jar /usr/gitc/GATK4.jar \\\n" +
        "  ApplyBQSR \\\n" +
        "  --createOutputBamMD5 \\\n" +
        "  --addOutputSAMProgramRecord \\\n" +
        "  -R ${ref_fasta} \\\n" +
        "  -I ${input_bam} \\\n" +
        "  --useOriginalQualities \\\n" +
        "  -O ${recalibrated_bam} \\\n" +
        "  -bqsr ${recalibration_report} \\\n" +
        "  -SQQ 10 -SQQ 20 -SQQ 30 -SQQ 40 \\\n" +
        "  --emit_original_quals \\\n" +
        "  -L ${sequence_group_interval}")
      .input("pipeline_run", "${workflow.index}").gatherBy("pipeline_run")
      .build();

  // Combine multiple recalibration tables from scattered BaseRecalibrator runs
  static Task GatherBqsrReports = TaskBuilder.named("GatherBqsrReports")
      .inputFileArray("input_bqsr_reports", " -I ")
      .input("output_report_filename")
      .outputFile("output_bqsr_report", "${output_report_filename}")
      .memory(3.5)
      .preemptible(true)
      .diskSize("${flowcell_small_disk}")
      .docker(GATK_IMAGE)
      .script(
        "java -Xmx3000m -jar /usr/gitc/GATK4.jar \\\n"+
        "  GatherBQSRReports \\\n"+
        "  -I ${input_bqsr_reports} \\\n"+
        "  -O ${output_bqsr_report}")
      .build();

  static Task ApplyBQSRToUnmappedReads = TaskBuilder.fromTask(ApplyBQSR, "ApplyBQSRToUnmappedReads")
      .diskSize("${agg_small_disk}")
      .build();

  // Combine multiple recalibrated BAM files from scattered ApplyRecalibration runs
  static Task GatherBamFiles = TaskBuilder.named("GatherBamFiles")
      .inputFileArray("input_bams", " INPUT=")
      .inputFile("input_unmapped_reads_bam")
      .input("output_bam_basename")
      .outputFile("output_bam", "${output_bam_basename}.bam")
      .outputFile("output_bam_index", "${output_bam_basename}.bai")
      .outputFile("output_bam_md5", "${output_bam_basename}.bam.md5")
      .memory(3)
      .preemptible(true)
      .diskSize("${agg_large_disk}")
      .docker(GATK_IMAGE)
      .script(
        "java -Xmx2000m -jar /usr/gitc/picard.jar \\\n" +
        "  GatherBamFiles \\\n" +
        "  INPUT=${input_bams} \\\n" +
        "  INPUT=${input_unmapped_reads_bam} \\\n" +
        "  OUTPUT=${output_bam} \\\n" +
        "  CREATE_INDEX=true \\\n" +
        "  CREATE_MD5_FILE=true")
      .build();

  // Convert BAM file to CRAM format
  static Task ConvertToCram = TaskBuilder.named("ConvertToCram")
      .inputFile("input_bam")
      .inputFile("ref_fasta", "${ref_fasta}")
      .inputFile("ref_fasta_index", "${ref_fasta_index}")
      .input("output_bam_basename")
      .outputFile("output_cram", "${output_bam_basename}.cram")
      .outputFile("output_cram_index", "${output_bam_basename}.crai")
      .memory(3)
      .diskSize("${agg_medium_disk}")
      .docker(GATK_IMAGE)
      // Note that we are not activating preemptible instances for this step yet,
      // but we should if it ends up being fairly quick
      .script(
        "samtools view -C -T ${ref_fasta} ${input_bam} | \\\n" +
        "tee ${output_cram} | \\\n" +
        "md5sum > ${output_cram}.md5 && \\\n" +
        "seq_cache_populate.pl -root ./ref/cache ${ref_fasta} && \\\n" +
        "REF_PATH=: REF_CACHE=./ref/cache/%2s/%2s/%s \\\n" +
        "samtools index ${output_cram} && \\\n" +
        "mv ${output_cram}.crai ${output_cram_index}")
      .build();

  // Call variants on a single sample with HaplotypeCaller to produce a GVCF
  static Task HaplotypeCaller = TaskBuilder.named("HaplotypeCaller")
      .inputFile("input_bam")
      .inputFile("input_bam_index")
      .inputFile("interval_list").scatterBy("interval_list")
      .input("gvcf_basename")
      .input("contamination", "0")
      .inputFile("ref_dict", "${ref_dict}")
      .inputFile("ref_fasta", "${ref_fasta}")
      .inputFile("ref_fasta_index", "${ref_fasta_index}")
      .outputFile("output_gvcf", "${gvcf_basename}.vcf.gz")
      .outputFile("output_gvcf_index", "${gvcf_basename}.vcf.gz.tbi")
      .memory(10)
      .preemptible(true)
      .diskSize("${agg_small_disk}")
      .docker(GATK_IMAGE)
      .script(
        "java -XX:GCTimeLimit=50 -XX:GCHeapFreeLimit=10 -Xmx8000m \\\n" +
        "  -jar /usr/gitc/GATK35.jar \\\n" +
        "  -T HaplotypeCaller \\\n" +
        "  -R ${ref_fasta} \\\n" +
        "  -o ${output_gvcf} \\\n" +
        "  -I ${input_bam} \\\n" +
        "  -L ${interval_list} \\\n" +
        "  -ERC GVCF \\\n" +
        "  --max_alternate_alleles 3 \\\n" +
        "  -variant_index_parameter 128000 \\\n" +
        "  -variant_index_type LINEAR \\\n" +
        "  -contamination ${contamination} \\\n" +
        "  --read_filter OverclippedRead")
      .input("pipeline_run", "${workflow.index}").gatherBy("pipeline_run")
      .build();

  // Combine multiple VCFs or GVCFs from scattered HaplotypeCaller runs
  static Task GatherVCFs = TaskBuilder.named("GatherVCFs")
      .inputFileArray("input_vcfs", " INPUT=")
      .inputFileArray("input_vcfs_indexes", " ")
      .input("output_vcf_name")
      .outputFile("output_vcf", "${output_vcf_name}")
      .outputFile("output_vcf_index", "${output_vcf_name}.tbi")
      .memory(3)
      .preemptible(true)
      .diskSize("${agg_small_disk}")
      .docker(GATK_IMAGE)
      // using MergeVcfs instead of GatherVcfs so we can create indices
      // WARNING  2015-10-28 15:01:48  GatherVcfs  Index creation not
      // currently supported when gathering block compressed VCFs.
      .script(
        "java -Xmx2g -jar /usr/gitc/picard.jar \\\n" +
        "MergeVcfs \\\n" +
        "INPUT=${input_vcfs} \\\n" +
        "OUTPUT=${output_vcf}")
      .build();

  // Declarations and defaults, in addition to the user-provided parameters file
  static WorkflowArgs workflowArgs = ArgsBuilder.of()
      .input("bwa_commandline", "bwa mem -K 100000000 -p -v 3 -t 16") // $bash_ref_fasta")
      .input("recalibrated_bam_basename", "${sample_name}.aligned.duplicates_marked.recalibrated")

      .input("SamToFastqAndBwaMem.input_bam", "${flowcell_unmapped_bams}")
      .input("SamToFastqAndBwaMem.output_bam_basename",
          "${= '${input_bam}'.replace(/gs:.*\\//, '').replace(/.bam/, '.unmerged'); }")

      .input("MergeBamAlignment.unmapped_bam", "${SamToFastqAndBwaMem.input_bam}")
      .inputFromFile("MergeBamAlignment.bwa_version", "${BwaVersion.task.stdout}")
      .input("MergeBamAlignment.aligned_bam", "${SamToFastqAndBwaMem.output_bam}")
      .input("MergeBamAlignment.output_bam_basename",
          "${= '${SamToFastqAndBwaMem.input_bam}'.replace(/gs:.*\\//, '').replace(/.bam/, '.aligned.unsorted'); }")

      .input("SortAndFixReadGroupBam.input_bam", "${MergeBamAlignment.output_bam}")
      .input("SortAndFixReadGroupBam.output_bam_basename",
          "${= '${SamToFastqAndBwaMem.input_bam}'.replace(/gs:.*\\//, '').replace(/.bam/, '.sorted'); }")

      .input("MarkDuplicates.input_bams", "${MergeBamAlignment.output_bam}")
      .input("MarkDuplicates.output_bam_basename", "${sample_name}.aligned.unsorted.duplicates_marked")
      .input("MarkDuplicates.metrics_filename", "${sample_name}.duplicate_metrics")

      .input("SortAndFixSampleBam.input_bam", "${MarkDuplicates.output_bam}")
      .input("SortAndFixSampleBam.output_bam_basename", "${sample_name}.aligned.duplicate_marked.sorted")

      .input("BaseRecalibrator.input_bam", "${SortAndFixSampleBam.output_bam}")
      .input("BaseRecalibrator.input_bam_index", "${SortAndFixSampleBam.output_bam_index}")
      .input("BaseRecalibrator.recalibration_report_filename", "${sample_name}.recal_data.csv")
      .inputFromFile("BaseRecalibrator.sequence_group_interval", "${CreateSequenceGroupingTSV.task.stdout}")

      .input("ApplyBQSR.input_bam", "${SortAndFixSampleBam.output_bam}")
      .input("ApplyBQSR.input_bam_index", "${SortAndFixSampleBam.output_bam_index}")
      .input("ApplyBQSR.output_bam_basename", "${recalibrated_bam_basename}")
      .input("ApplyBQSR.recalibration_report", "${BaseRecalibrator.recalibration_report}")
      .input("ApplyBQSR.sequence_group_interval", "${BaseRecalibrator.sequence_group_interval}")

      .input("GatherBqsrReports.input_bqsr_reports", "${BaseRecalibrator.recalibration_report}")
      .input("GatherBqsrReports.output_report_filename", "${sample_name}.recal_data.csv")

      .input("ApplyBQSRToUnmappedReads.input_bam", "${SortAndFixSampleBam.output_bam}")
      .input("ApplyBQSRToUnmappedReads.input_bam_index", "${SortAndFixSampleBam.output_bam_index}")
      .input("ApplyBQSRToUnmappedReads.output_bam_basename", "${recalibrated_bam_basename}")
      .input("ApplyBQSRToUnmappedReads.recalibration_report", "${GatherBqsrReports.output_bqsr_report}")
      .input("ApplyBQSRToUnmappedReads.sequence_group_interval", "unmapped")

      .input("GatherBamFiles.input_bams", "${ApplyBQSR.recalibrated_bam}")
      .input("GatherBamFiles.input_unmapped_reads_bam", "${ApplyBQSRToUnmappedReads.recalibrated_bam}")
      .input("GatherBamFiles.output_bam_basename", "${sample_name}")

      .input("ConvertToCram.input_bam", "${GatherBamFiles.output_bam}")
      .input("ConvertToCram.output_bam_basename", "${sample_name}")

      .input("HaplotypeCaller.input_bam", "${GatherBamFiles.output_bam}")
      .input("HaplotypeCaller.input_bam_index", "${GatherBamFiles.output_bam_index}")
      .input("HaplotypeCaller.interval_list", "${scattered_calling_intervals}")
      .input("HaplotypeCaller.gvcf_basename", "${sample_name}")

      .input("GatherVCFs.input_vcfs", "${HaplotypeCaller.output_gvcf}")
      .input("GatherVCFs.input_vcfs_indexes", "${HaplotypeCaller.output_gvcf_index}")
      .input("GatherVCFs.output_vcf_name", "${final_gvcf_name}")

      .output("duplicate_metrics", "${MarkDuplicates.duplicate_metrics}")
      .output("bqsr_report", "${GatherBqsrReports.output_bqsr_report}")
      .output("cram", "${ConvertToCram.output_cram}")
      .output("cram_index", "${ConvertToCram.output_cram_index}")
      .output("vcf", "${GatherVCFs.output_vcf}")
      .output("vcf_index", "${GatherVCFs.output_vcf_index}")
      .build();

  @Override
  public Workflow createWorkflow(String[] args) throws IOException {
    return TaskBuilder.named(GatkPairedSingleSample.class.getSimpleName())
        .steps(
            Steps.of(
                Branch.of(
                    CreateSequenceGroupingTSV,
                    Steps.of(
                        BwaVersion,
                        SamToFastqAndBwaMem,
                        MergeBamAlignment,
                        SortAndFixReadGroupBam,
                        MarkDuplicates,
                        SortAndFixSampleBam)),
                BaseRecalibrator,
                ApplyBQSR,
                GatherBqsrReports,
                ApplyBQSRToUnmappedReads,
                GatherBamFiles,
                Branch.of(
                    ConvertToCram,
                    Steps.of(
                        HaplotypeCaller,
                        GatherVCFs))))
        .args(workflowArgs).build();
  }
}


text:
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace Kudu.Contracts.Tracing
{
    public interface ITracer
    {
        TraceLevel TraceLevel { get; }
        IDisposable Step(string message, IDictionary<string, string> attributes);
        void Trace(string message, IDictionary<string, string> attributes);
    }
}


text:
FROM ubuntu:16.04
LABEL maintainer="Michael Lodder <redmike7@gmail.com>"

ARG target_arch
ARG target_api
ARG cross_compile

ENV TARGET_ARCH ${target_arch}
ENV TARGET_API ${target_api}
ENV CROSS_COMPILE ${cross_compile}
ENV ANDROID_NDK_ROOT /home/openssl_user/android-ndk-r16b
ENV TOOLCHAIN_DIR /home/openssl_user/${target_arch}

RUN DEBIAN_FRONTEND=noninteractive apt-get -qq update -y && apt-get -qq install -y zip unzip autoconf cmake wget python3 2>&1 > /dev/null
RUN useradd -m -d /home/openssl_user -s /bin/bash openssl_user && mkdir -p /etc/sudoers.d/
RUN echo "openssl_user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/openssl_user
RUN chmod 0440 /etc/sudoers.d/openssl_user

USER openssl_user
WORKDIR /home/openssl_user
COPY make_openssl.sh /home/openssl_user/
COPY android-ndk-r16b-linux-x86_64.zip /home/openssl_user/
COPY openssl-1.1.0h.tar.gz /home/openssl_user/
RUN unzip -qq /home/openssl_user/android-ndk-r16b-linux-x86_64.zip -d /home/openssl_user/
RUN tar xf /home/openssl_user/openssl-1.1.0h.tar.gz -C /home/openssl_user/
RUN python3 ${ANDROID_NDK_ROOT}/build/tools/make_standalone_toolchain.py --arch ${TARGET_ARCH} --api ${TARGET_API} --install-dir ${TOOLCHAIN_DIR}
RUN bash make_openssl.sh


text:
package org.kie.workbench.common.screens.examples.client.wizard.pages;

import javax.enterprise.event.Event;

import org.jboss.errai.common.client.api.Caller;
import org.jboss.errai.ui.client.local.spi.TranslationService;
import org.kie.workbench.common.screens.examples.client.wizard.model.ExamplesWizardModel;
import org.kie.workbench.common.screens.examples.service.ExamplesService;
import org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent;

public abstract class BaseExamplesWizardPage implements ExamplesWizardPage {

    protected TranslationService translator;
    protected Caller<ExamplesService> examplesService;
    protected Event<WizardPageStatusChangeEvent> pageStatusChangedEvent;

    protected ExamplesWizardModel model;

    protected BaseExamplesWizardPage() {
        //Zero-argument constructor for CDI proxies
    }

    public BaseExamplesWizardPage( final TranslationService translator,
                                   final Caller<ExamplesService> examplesService,
                                   final Event<WizardPageStatusChangeEvent> pageStatusChangedEvent ) {
        this.translator = translator;
        this.examplesService = examplesService;
        this.pageStatusChangedEvent = pageStatusChangedEvent;
    }

    @Override
    public void setModel( final ExamplesWizardModel model ) {
        this.model = model;
    }

    @Override
    public void destroy() {
        //Do nothing by default
    }
}


text:
<securityConfig xmlns="http://www.globus.org">
 <method name="noAuth">
   <auth-method>
    <none/>
   </auth-method>
 </method>
 <method name="gsiSecConvDeleg">
   <auth-method>
    <GSISecureConversation/>
   </auth-method>
   <run-as>
    <caller-identity/>
   </run-as>
 </method>
  <method name="gsiTransportIntegrity">
   <auth-method>
    <GSITransport>
     <protection-level>
       <integrity/>
      </protection-level>
    </GSITransport>
   </auth-method>
  </method>
  <method name="gsiTransportPrivacy">
   <auth-method>
    <GSITransport>
     <protection-level>
       <privacy/>
      </protection-level>
    </GSITransport>
   </auth-method>
  </method>
  <method name="gsiTransportOnly">
   <auth-method>
    <GSITransport/>
   </auth-method>
  </method>
  <method name="gsiSecConvIntegrity">
   <auth-method>
    <GSISecureConversation>
     <protection-level>
       <integrity/>
      </protection-level>
    </GSISecureConversation>
   </auth-method>
  </method>
  <method name="gsiSecConvPrivacy">
   <auth-method>
    <GSISecureConversation>
     <protection-level>
       <privacy/>
      </protection-level>
    </GSISecureConversation>
   </auth-method>
  </method>
  <method name="gsiSecConvOnly">
   <auth-method>
    <GSISecureConversation/>
   </auth-method>
  </method>
  <method name="gsiSecMsgOnly">
   <auth-method>
    <GSISecureMessage/>
   </auth-method>
  </method>
  <method name="gsiSecMsgPrivacy">
   <auth-method>
    <GSISecureMessage>
     <protection-level>
       <privacy/>
      </protection-level>
    </GSISecureMessage>
   </auth-method>
  </method>
  <method name="gsiSecMsgIntegrity">
   <auth-method>
    <GSISecureMessage>
     <protection-level>
       <integrity/>
      </protection-level>
    </GSISecureMessage>
   </auth-method>
  </method>
  <method name="gsiSec">
   <auth-method>
    <GSISecureMessage/>
    <GSISecureConversation/>
   </auth-method>
  </method>
  <method name="setNoAuthz">
   <run-as>
     <caller-identity/>
   </run-as>
   <auth-method>
    <GSISecureConversation/>
   </auth-method>
  </method>
  <method name="alterSecurityDesc">
   <auth-method>
    <GSISecureConversation/>
   </auth-method>
  </method>
   <method name="subscribe">
    <auth-method>
     <GSISecureMessage/>
     <GSISecureConversation/>
    </auth-method>
   </method>
  <authz value="self"/>
  <auth-method>
    <none/>
  </auth-method>
</securityConfig>


text:
package inet.ipaddr.mac;

import inet.ipaddr.Address.SegmentValueProvider;

import java.io.Serializable;

import inet.ipaddr.AddressNetwork;
import inet.ipaddr.HostIdentifierString;
import inet.ipaddr.PrefixLenException;
import inet.ipaddr.format.standard.AddressCreator;

/**
 * Provides methods and types associated with all MAC addresses.
 *
 * @author scfoley
 *
 */
public class MACAddressNetwork extends AddressNetwork<MACAddressSegment> {

	private static final long serialVersionUID = 4L;

	private static PrefixConfiguration defaultPrefixConfiguration = AddressNetwork.getDefaultPrefixConfiguration();

	private static final MACAddressSegment EMPTY_SEGMENTS[] = {};

	public static class MACAddressCreator extends AddressCreator<MACAddress, MACAddressSection, MACAddressSection, MACAddressSegment> implements AddressSegmentCreator<MACAddressSegment> {
		private static final long serialVersionUID = 4L;

		static class Cache implements Serializable {

			private static final long serialVersionUID = 1L;

			private transient MACAddressSegment ALL_RANGE_SEGMENT;

			private transient MACAddressSegment segmentCache[];

			void clear() {
				segmentCache = null;
				ALL_RANGE_SEGMENT = null;
			}
		}

		Cache cache;

		private final MACAddressNetwork owner;

		MACAddressCreator(MACAddressNetwork owner) {
			this.owner = owner;
			this.cache = new Cache();
		}

		MACAddressCreator(MACAddressNetwork owner, Cache cache) {
			this.owner = owner;
			this.cache = cache;
		}

		@Override
		public void clearCaches() {
			super.clearCaches();
			cache.clear();
			//segmentCache = null;
		}

		@Override
		public MACAddressNetwork getNetwork() {
			return owner;
		}

		@Override
		public int getMaxValuePerSegment() {
			return MACAddress.MAX_VALUE_PER_SEGMENT;
		}

		@Override
		public MACAddressSegment[] createSegmentArray(int length) {
			if(length == 0) {
				return EMPTY_SEGMENTS;
			}
			return new MACAddressSegment[length];
		}

		@Override
		public MACAddressSegment createSegment(int value) {
			if(value >= 0 && value <= MACAddress.MAX_VALUE_PER_SEGMENT) {
				MACAddressSegment result, cache[] = this.cache.segmentCache;
				if(cache == null) {
					this.cache.segmentCache = cache = new MACAddressSegment[MACAddress.MAX_VALUE_PER_SEGMENT + 1];
					cache[value] = result = new MACAddressSegment(value);
				} else {
					result = cache[value];
					if(result == null) {
						cache[value] = result = new MACAddressSegment(value);
					}
				}
				return result;
			}
			return new MACAddressSegment(value);//this will throw, but call it to throw the correct exception
		}

		@Override
		public MACAddressSegment createSegment(int value, Integer segmentPrefixLength) {
			//On ipvx side we have prefix as part of segment, but not here
			//On ipvx side, the address creator for sections defers the prefix handling to the segments creator,
			//which defers the prefix handling to the segment constructor, and then the prefix is applied in the super constructor.
			//Here, we do the same, but when the prefix gets to here, we cannot pass to the segment, so we apply the prefix here
			//But this also gives more caching opportunities
			if(segmentPrefixLength != null) {
				if(segmentPrefixLength < 0) {
					throw new PrefixLenException(segmentPrefixLength);
				}
				if(segmentPrefixLength > MACAddress.EXTENDED_UNIQUE_IDENTIFIER_64_BIT_COUNT) {
					throw new PrefixLenException(segmentPrefixLength);
				}
				if(getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets()) {
					if(segmentPrefixLength == 0) {
						MACAddressSegment result = cache.ALL_RANGE_SEGMENT;
						if(result == null) {
							cache.ALL_RANGE_SEGMENT = result = new MACAddressSegment(0, MACAddress.MAX_VALUE_PER_SEGMENT);
						}
						return result;
					}
					int mask = ~0 << (MACAddress.BITS_PER_SEGMENT - segmentPrefixLength);
					int newLower = value & mask;
					int newUpper = value | ~mask;
					return createRangeSegment(newLower, newUpper);
				}
			}
			return createSegment(value);
		}

		//different name to avoid confusion with createSegment(int, Integer)
		public MACAddressSegment createRangeSegment(int lower, int upper) {
			if(lower != upper) {
				if(lower == 0 && upper == MACAddress.MAX_VALUE_PER_SEGMENT) {
					MACAddressSegment result = cache.ALL_RANGE_SEGMENT;
					if(result == null) {
						cache.ALL_RANGE_SEGMENT = result = new MACAddressSegment(0, upper);
					}
					return result;
				}
				return new MACAddressSegment(lower, upper);
			}
			return createSegment(lower);
		}

		@Override
		public MACAddressSegment createSegment(int lower, int upper, Integer segmentPrefixLength) {
			if(segmentPrefixLength == null) {
				return createRangeSegment(lower, upper);
			}
			if(segmentPrefixLength < 0) {
				throw new PrefixLenException(segmentPrefixLength);
			}
			if(segmentPrefixLength > MACAddress.EXTENDED_UNIQUE_IDENTIFIER_64_BIT_COUNT) {
				throw new PrefixLenException(segmentPrefixLength);
			}
			if(getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets()) {
				if(segmentPrefixLength == 0) {
					MACAddressSegment result = cache.ALL_RANGE_SEGMENT;
					if(result == null) {
						cache.ALL_RANGE_SEGMENT = result = new MACAddressSegment(0, MACAddress.MAX_VALUE_PER_SEGMENT);
					}
					return result;
				}
				int max = MACAddress.MAX_VALUE_PER_SEGMENT;
				int mask = (~0 << (MACAddress.BITS_PER_SEGMENT - segmentPrefixLength)) & max;
				int newLower = lower & mask;
				int newUpper = upper | (~mask  & max);
				return createRangeSegment(newLower, newUpper);
			}
			return createRangeSegment(lower, upper);
		}

		@Override
		protected MACAddressSegment createSegmentInternal(int value, Integer segmentPrefixLength, CharSequence addressStr,
				int originalVal, boolean isStandardString, int lowerStringStartIndex, int lowerStringEndIndex) {
			MACAddressSegment segment = createSegment(value, segmentPrefixLength);
			segment.setString(addressStr, isStandardString, lowerStringStartIndex, lowerStringEndIndex, originalVal);
			return segment;
		}

		@Override
		protected MACAddressSegment createRangeSegmentInternal(int lower, int upper, Integer segmentPrefixLength,
				CharSequence addressStr, int originalLower, int originalUpper, boolean isStandardString,
				boolean isStandardRangeString, int lowerStringStartIndex, int lowerStringEndIndex,
				int upperStringEndIndex) {
			MACAddressSegment segment = createSegment(lower, upper, segmentPrefixLength);
			segment.setString(addressStr, isStandardRangeString, lowerStringStartIndex, upperStringEndIndex, originalLower, originalUpper);
			return segment;
		}

		MACAddressSection createSection(long bytes, int startIndex, boolean extended, Integer prefixLength) {
			MACAddressSection result = new MACAddressSection(bytes, startIndex, extended);
			result.assignPrefixLength(prefixLength);
			return result;
		}

		MACAddressSection createSection(long bytes, int startIndex, boolean extended) {
			return new MACAddressSection(bytes, startIndex, extended);
		}

		MACAddressSection createSection(byte bytes[], int startIndex, boolean extended, Integer prefixLength) {
			MACAddressSection result = new MACAddressSection(bytes, startIndex, extended);
			result.assignPrefixLength(prefixLength);
			return result;
		}

		MACAddressSection createSection(byte bytes[], int startIndex, boolean extended) {
			return new MACAddressSection(bytes, startIndex, extended);
		}

		MACAddressSection createSection(byte bytes[], int startIndex, int segmentCount, boolean extended, Integer prefixLength) {
			MACAddressSection result = new MACAddressSection(bytes, 0, bytes.length, segmentCount, startIndex, extended, true);
			result.assignPrefixLength(prefixLength);
			return result;
		}

		MACAddressSection createSection(byte bytes[], int startIndex, int segmentCount, boolean extended) {
			return new MACAddressSection(bytes, 0, bytes.length, segmentCount, startIndex, extended, true);
		}

		MACAddressSection createSection(SegmentValueProvider lowerValueProvider, SegmentValueProvider upperValueProvider, int startIndex, boolean extended, Integer prefixLength) {
			MACAddressSection result = new MACAddressSection(lowerValueProvider, upperValueProvider, startIndex, extended);
			result.assignPrefixLength(prefixLength);
			return result;
		}

		MACAddressSection createSection(SegmentValueProvider lowerValueProvider, SegmentValueProvider upperValueProvider, int startIndex, boolean extended) {
			return new MACAddressSection(lowerValueProvider, upperValueProvider, startIndex, extended);
		}

		@Override
		protected MACAddressSection createSectionInternal(MACAddressSegment[] segments) {
			return new MACAddressSection(false, segments, 0, segments.length > MACAddress.EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT);
		}

		@Override
		protected MACAddressSection createPrefixedSectionInternal(MACAddressSegment[] segments, Integer prefixLength, boolean singleOnly) {
			return createPrefixedSectionInternal(segments, prefixLength);
		}

		@Override
		protected MACAddressSection createPrefixedSectionInternal(MACAddressSegment[] segments, Integer prefixLength) {
			MACAddressSection result = new MACAddressSection(false, segments, 0, segments.length > MACAddress.EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT);
			result.assignPrefixLength(prefixLength);
			return result;
		}

		protected MACAddressSection createSectionInternal(MACAddressSegment[] segments, boolean extended) {
			return new MACAddressSection(false, segments, 0, extended);
		}

		@Override
		protected MACAddressSection createSectionInternal(MACAddressSegment[] segments, int startIndex, boolean extended) {
			return new MACAddressSection(false, segments, startIndex, extended);
		}

		MACAddressSection createSection(MACAddressSegment[] segments, boolean extended) {
			return new MACAddressSection(segments, 0, extended);
		}

		MACAddressSection createSection(MACAddressSegment[] segments, boolean extended, Integer prefixLength) {
			MACAddressSection result = new MACAddressSection(segments, 0, extended);
			result.assignPrefixLength(prefixLength);
			return result;
		}

		@Override
		protected MACAddressSection createSectionInternal(byte bytes[], int segmentCount, Integer prefixLength, boolean singleOnly) {
			MACAddressSection result = new MACAddressSection(bytes, segmentCount, 0, segmentCount > MACAddress.EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT, false);
			result.assignPrefixLength(prefixLength);
			return result;
		}

		@Override
		protected MACAddress createAddressInternal(byte[] bytes, CharSequence zone) {
			MACAddressSection section = new MACAddressSection(bytes, bytes.length, 0, bytes.length > MACAddress.EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT, false);
			return createAddress(section);
		}

		@Override
		protected MACAddress createAddressInternal(MACAddressSegment[] segments) {
			return createAddress(createSectionInternal(segments));
		}

		@Override
		protected MACAddress createAddressInternal(MACAddressSegment segments[], Integer prefix) {
			return createAddress(createPrefixedSectionInternal(segments, prefix));
		}

		@Override
		protected MACAddress createAddressInternal(MACAddressSegment[] segments, Integer prefix, boolean singleOnly) {
			return createAddressInternal(segments, prefix);
		}

		@Override
		protected MACAddress createAddressInternal(MACAddressSection section, HostIdentifierString from) {
			MACAddress result = createAddress(section);
			result.cache(from);
			return result;
		}

		@Override
		protected MACAddress createAddressInternal(MACAddressSection section, CharSequence zone, HostIdentifierString from) {
			MACAddress result = createAddress(section);
			result.cache(from);
			return result;
		}

		@Override
		protected MACAddress createAddressInternal(MACAddressSection section, CharSequence zone, HostIdentifierString from, MACAddress lower, MACAddress upper) {
			MACAddress result = createAddressInternal(section, zone, from);
			//result.cache(lower, upper); this createAddressInternal method not called for MAC, so we do implement the caching here
			return result;
		}

		@Override
		public MACAddress createAddress(MACAddressSection section) {
			return new MACAddress(section);
		}
	}

	protected MACAddressNetwork.MACAddressCreator createAddressCreator() {
		return new MACAddressCreator(this);
	}

	@Override
	public MACAddressNetwork.MACAddressCreator getAddressCreator() {
		return creator;
	}

	private MACAddressNetwork.MACAddressCreator creator;

	public MACAddressNetwork() {
		this.creator = createAddressCreator();
	}

	@Override
	protected boolean isCompatible(AddressNetwork<?> other) {
		return super.isCompatible(other);
	}

	@Override
	public PrefixConfiguration getPrefixConfiguration() {
		return defaultPrefixConfiguration;
	}

	/**
	 * Sets the default prefix configuration used by this network.
	 *
	 * @see #getDefaultPrefixConfiguration()
	 * @see #getPrefixConfiguration()
	 * @see PrefixConfiguration
	 */
	public static void setDefaultPrefixConfiguration(PrefixConfiguration config) {
		defaultPrefixConfiguration = config;
	}

	/**
	 * Gets the default prefix configuration used by this network type and version.
	 *
	 * @see AddressNetwork#getDefaultPrefixConfiguration()
	 * @see PrefixConfiguration
	 */
	public static PrefixConfiguration getDefaultPrefixConfiguration() {
		return defaultPrefixConfiguration;
	}
}