text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>JobStatus</title>
<meta name="date" content="2014-07-04">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

jrigby.openstack_queue.server

Class JobStatus

java.lang.Object

jrigby.openstack_queue.server.JobStatus

All Implemented Interfaces:

java.lang.Comparable<JobStatus>

public class JobStatus
extends java.lang.Object
implements java.lang.Comparable<JobStatus>

Defines a submitted job's status in the queue

Author:

jason

Field Summary

Fields

Modifier and Type
Field and Description

private java.lang.Integer
id

private java.lang.String
name

private java.lang.Long
startTime

private java.lang.String
status

private java.lang.Long
timeLimit

Constructor Summary

Constructors

Constructor and Description

JobStatus()

Method Summary

Methods

Modifier and Type
Method and Description

int
compareTo(JobStatus arg0)

Comparator that is based on job ID.

java.lang.Integer
getId()

Get a numeric identifier for this job

java.lang.String
getName()

Gets the name of the job

java.lang.Long
getStartTime()

Gets the start time of this job

java.lang.String
getStatus()

Gets the status of this job (e.g.

java.lang.Long
getTimeLimit()

Gets the time limit of this job.

void
setId(java.lang.Integer id)

Sets the job ID

void
setName(java.lang.String name)

Sets the name of the job

void
setStartTime(java.lang.Long startTime)

Sets the start time of this job

void
setStatus(java.lang.String status)

Sets the current status of this job

void
setTimeLimit(java.lang.Long timeLimit)

Set the time limit for this job.

boolean
timeLimitExceeded()

Checks if the job is running overtime

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

id

private java.lang.Integer id

name

private java.lang.String name

startTime

private java.lang.Long startTime

timeLimit

private java.lang.Long timeLimit

status

private java.lang.String status

Constructor Detail

JobStatus

public JobStatus()

Method Detail

getId

public java.lang.Integer getId()

Get a numeric identifier for this job

Returns:

job ID

setId

public void setId(java.lang.Integer id)

Sets the job ID

Parameters:

id -

getName

public java.lang.String getName()

Gets the name of the job

Returns:

name of job

setName

public void setName(java.lang.String name)

Sets the name of the job

Parameters:

name -

getStartTime

public java.lang.Long getStartTime()

Gets the start time of this job

Returns:

start time of job in milliseconds

setStartTime

public void setStartTime(java.lang.Long startTime)

Sets the start time of this job

Parameters:

startTime - job start time in milliseconds

getTimeLimit

public java.lang.Long getTimeLimit()

Gets the time limit of this job. Setting to zero results in
 an unlimited run time.

Returns:

time limit in milliseconds

setTimeLimit

public void setTimeLimit(java.lang.Long timeLimit)

Set the time limit for this job. Setting to zero results in
 an unlimited run time.

Parameters:

timeLimit - job time limit in milliseconds

getStatus

public java.lang.String getStatus()

Gets the status of this job (e.g. WAITING, RUNNING, etc.)

Returns:

current status

setStatus

public void setStatus(java.lang.String status)

Sets the current status of this job

Parameters:

status -

timeLimitExceeded

public boolean timeLimitExceeded()

Checks if the job is running overtime

Returns:

true if time has been exceeded

compareTo

public int compareTo(JobStatus arg0)

Comparator that is based on job ID. Used for
 collections implementing SortedSet or
 are otherwise sorted.

Specified by:

compareTo in interface java.lang.Comparable<JobStatus>

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method


text:
#ifndef __MINGW32__
#define HAVE_STRSEP
#endif

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#ifndef __MINGW32__
#include <pwd.h>
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/types.h>

#include <cutils/list.h>
#include <log/log.h>
#include <log/logprint.h>

#include "log_portability.h"

/* M3E: Add */
#if defined(__APPLE__) || defined(__linux__)
#include <limits.h>  // INT_MAX
#endif // M3E

#define MS_PER_NSEC 1000000
#define US_PER_NSEC 1000

#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif

typedef struct FilterInfo_t {
  char* mTag;
  android_LogPriority mPri;
  struct FilterInfo_t* p_next;
} FilterInfo;

struct AndroidLogFormat_t {
  android_LogPriority global_pri;
  FilterInfo* filters;
  AndroidLogPrintFormat format;
  bool colored_output;
  bool usec_time_output;
  bool nsec_time_output;
  bool printable_output;
  bool year_output;
  bool zone_output;
  bool epoch_output;
  bool monotonic_output;
  bool uid_output;
  bool descriptive_output;
};

/*
 * API issues prevent us from exposing "descriptive" in AndroidLogFormat_t
 * during android_log_processBinaryLogBuffer(), so we break layering.
 */
static bool descriptive_output = false;

/*
 *  gnome-terminal color tags
 *    See http://misc.flogisoft.com/bash/tip_colors_and_formatting
 *    for ideas on how to set the forground color of the text for xterm.
 *    The color manipulation character stream is defined as:
 *      ESC [ 3 8 ; 5 ; <color#> m
 */
#define ANDROID_COLOR_BLUE 75
#define ANDROID_COLOR_DEFAULT 231
#define ANDROID_COLOR_GREEN 40
#define ANDROID_COLOR_ORANGE 166
#define ANDROID_COLOR_RED 196
#define ANDROID_COLOR_YELLOW 226

static FilterInfo* filterinfo_new(const char* tag, android_LogPriority pri) {
  FilterInfo* p_ret;

  p_ret = (FilterInfo*)calloc(1, sizeof(FilterInfo));
  p_ret->mTag = strdup(tag);
  p_ret->mPri = pri;

  return p_ret;
}

/* balance to above, filterinfo_free left unimplemented */

/*
 * Note: also accepts 0-9 priorities
 * returns ANDROID_LOG_UNKNOWN if the character is unrecognized
 */
static android_LogPriority filterCharToPri(char c) {
  android_LogPriority pri;

  c = tolower(c);

  if (c >= '0' && c <= '9') {
    if (c >= ('0' + ANDROID_LOG_SILENT)) {
      pri = ANDROID_LOG_VERBOSE;
    } else {
      pri = (android_LogPriority)(c - '0');
    }
  } else if (c == 'v') {
    pri = ANDROID_LOG_VERBOSE;
  } else if (c == 'd') {
    pri = ANDROID_LOG_DEBUG;
  } else if (c == 'i') {
    pri = ANDROID_LOG_INFO;
  } else if (c == 'w') {
    pri = ANDROID_LOG_WARN;
  } else if (c == 'e') {
    pri = ANDROID_LOG_ERROR;
  } else if (c == 'f') {
    pri = ANDROID_LOG_FATAL;
  } else if (c == 's') {
    pri = ANDROID_LOG_SILENT;
  } else if (c == '*') {
    pri = ANDROID_LOG_DEFAULT;
  } else {
    pri = ANDROID_LOG_UNKNOWN;
  }

  return pri;
}

static char filterPriToChar(android_LogPriority pri) {
  switch (pri) {
    /* clang-format off */
    case ANDROID_LOG_VERBOSE: return 'V';
    case ANDROID_LOG_DEBUG:   return 'D';
    case ANDROID_LOG_INFO:    return 'I';
    case ANDROID_LOG_WARN:    return 'W';
    case ANDROID_LOG_ERROR:   return 'E';
    case ANDROID_LOG_FATAL:   return 'F';
    case ANDROID_LOG_SILENT:  return 'S';

    case ANDROID_LOG_DEFAULT:
    case ANDROID_LOG_UNKNOWN:
    default:                  return '?';
      /* clang-format on */
  }
}

static int colorFromPri(android_LogPriority pri) {
  switch (pri) {
    /* clang-format off */
    case ANDROID_LOG_VERBOSE: return ANDROID_COLOR_DEFAULT;
    case ANDROID_LOG_DEBUG:   return ANDROID_COLOR_BLUE;
    case ANDROID_LOG_INFO:    return ANDROID_COLOR_GREEN;
    case ANDROID_LOG_WARN:    return ANDROID_COLOR_ORANGE;
    case ANDROID_LOG_ERROR:   return ANDROID_COLOR_RED;
    case ANDROID_LOG_FATAL:   return ANDROID_COLOR_RED;
    case ANDROID_LOG_SILENT:  return ANDROID_COLOR_DEFAULT;

    case ANDROID_LOG_DEFAULT:
    case ANDROID_LOG_UNKNOWN:
    default:                  return ANDROID_COLOR_DEFAULT;
      /* clang-format on */
  }
}

static android_LogPriority filterPriForTag(AndroidLogFormat* p_format, const char* tag) {
  FilterInfo* p_curFilter;

  for (p_curFilter = p_format->filters; p_curFilter != NULL; p_curFilter = p_curFilter->p_next) {
    if (0 == strcmp(tag, p_curFilter->mTag)) {
      if (p_curFilter->mPri == ANDROID_LOG_DEFAULT) {
        return p_format->global_pri;
      } else {
        return p_curFilter->mPri;
      }
    }
  }

  return p_format->global_pri;
}

/**
 * returns 1 if this log line should be printed based on its priority
 * and tag, and 0 if it should not
 */
int android_log_shouldPrintLine(AndroidLogFormat* p_format, const char* tag,
                                android_LogPriority pri) {
  return pri >= filterPriForTag(p_format, tag);
}

AndroidLogFormat* android_log_format_new() {
  AndroidLogFormat* p_ret;

  p_ret = static_cast<AndroidLogFormat*>(calloc(1, sizeof(AndroidLogFormat)));

  p_ret->global_pri = ANDROID_LOG_VERBOSE;
  p_ret->format = FORMAT_BRIEF;
  p_ret->colored_output = false;
  p_ret->usec_time_output = false;
  p_ret->nsec_time_output = false;
  p_ret->printable_output = false;
  p_ret->year_output = false;
  p_ret->zone_output = false;
  p_ret->epoch_output = false;
#ifdef __ANDROID__
  p_ret->monotonic_output = android_log_clockid() == CLOCK_MONOTONIC;
#else
  p_ret->monotonic_output = false;
#endif
  p_ret->uid_output = false;
  p_ret->descriptive_output = false;
  descriptive_output = false;

  return p_ret;
}

static list_declare(convertHead);

void android_log_format_free(AndroidLogFormat* p_format) {
  FilterInfo *p_info, *p_info_old;

  p_info = p_format->filters;

  while (p_info != NULL) {
    p_info_old = p_info;
    p_info = p_info->p_next;

    free(p_info_old);
  }

  free(p_format);

  /* Free conversion resource, can always be reconstructed */
  while (!list_empty(&convertHead)) {
    struct listnode* node = list_head(&convertHead);
    list_remove(node);
    LOG_ALWAYS_FATAL_IF(node == list_head(&convertHead), "corrupted list");
    free(node);
  }
}

int android_log_setPrintFormat(AndroidLogFormat* p_format, AndroidLogPrintFormat format) {
  switch (format) {
    case FORMAT_MODIFIER_COLOR:
      p_format->colored_output = true;
      return 0;
    case FORMAT_MODIFIER_TIME_USEC:
      p_format->usec_time_output = true;
      return 0;
    case FORMAT_MODIFIER_TIME_NSEC:
      p_format->nsec_time_output = true;
      return 0;
    case FORMAT_MODIFIER_PRINTABLE:
      p_format->printable_output = true;
      return 0;
    case FORMAT_MODIFIER_YEAR:
      p_format->year_output = true;
      return 0;
    case FORMAT_MODIFIER_ZONE:
      p_format->zone_output = !p_format->zone_output;
      return 0;
    case FORMAT_MODIFIER_EPOCH:
      p_format->epoch_output = true;
      return 0;
    case FORMAT_MODIFIER_MONOTONIC:
      p_format->monotonic_output = true;
      return 0;
    case FORMAT_MODIFIER_UID:
      p_format->uid_output = true;
      return 0;
    case FORMAT_MODIFIER_DESCRIPT:
      p_format->descriptive_output = true;
      descriptive_output = true;
      return 0;
    default:
      break;
  }
  p_format->format = format;
  return 1;
}

static const char tz[] = "TZ";
static const char utc[] = "UTC";

/**
 * Returns FORMAT_OFF on invalid string
 */
AndroidLogPrintFormat android_log_formatFromString(const char* formatString) {
  static AndroidLogPrintFormat format;

  /* clang-format off */
  if (!strcmp(formatString, "brief")) format = FORMAT_BRIEF;
  else if (!strcmp(formatString, "process")) format = FORMAT_PROCESS;
  else if (!strcmp(formatString, "tag")) format = FORMAT_TAG;
  else if (!strcmp(formatString, "thread")) format = FORMAT_THREAD;
  else if (!strcmp(formatString, "raw")) format = FORMAT_RAW;
  else if (!strcmp(formatString, "time")) format = FORMAT_TIME;
  else if (!strcmp(formatString, "threadtime")) format = FORMAT_THREADTIME;
  else if (!strcmp(formatString, "long")) format = FORMAT_LONG;
  else if (!strcmp(formatString, "color")) format = FORMAT_MODIFIER_COLOR;
  else if (!strcmp(formatString, "colour")) format = FORMAT_MODIFIER_COLOR;
  else if (!strcmp(formatString, "usec")) format = FORMAT_MODIFIER_TIME_USEC;
  else if (!strcmp(formatString, "nsec")) format = FORMAT_MODIFIER_TIME_NSEC;
  else if (!strcmp(formatString, "printable")) format = FORMAT_MODIFIER_PRINTABLE;
  else if (!strcmp(formatString, "year")) format = FORMAT_MODIFIER_YEAR;
  else if (!strcmp(formatString, "zone")) format = FORMAT_MODIFIER_ZONE;
  else if (!strcmp(formatString, "epoch")) format = FORMAT_MODIFIER_EPOCH;
  else if (!strcmp(formatString, "monotonic")) format = FORMAT_MODIFIER_MONOTONIC;
  else if (!strcmp(formatString, "uid")) format = FORMAT_MODIFIER_UID;
  else if (!strcmp(formatString, "descriptive")) format = FORMAT_MODIFIER_DESCRIPT;
    /* clang-format on */

#ifndef __MINGW32__
  else {
    extern char* tzname[2];
    static const char gmt[] = "GMT";
    char* cp = getenv(tz);
    if (cp) {
      cp = strdup(cp);
    }
    setenv(tz, formatString, 1);
    /*
     * Run tzset here to determine if the timezone is legitimate. If the
     * zone is GMT, check if that is what was asked for, if not then
     * did not match any on the system; report an error to caller.
     */
    tzset();
    if (!tzname[0] ||
        ((!strcmp(tzname[0], utc) || !strcmp(tzname[0], gmt))                  /* error? */
         && strcasecmp(formatString, utc) && strcasecmp(formatString, gmt))) { /* ok */
      if (cp) {
        setenv(tz, cp, 1);
      } else {
        unsetenv(tz);
      }
      tzset();
      format = FORMAT_OFF;
    } else {
      format = FORMAT_MODIFIER_ZONE;
    }
    free(cp);
  }
#endif

  return format;
}

/**
 * filterExpression: a single filter expression
 * eg "AT:d"
 *
 * returns 0 on success and -1 on invalid expression
 *
 * Assumes single threaded execution
 */

int android_log_addFilterRule(AndroidLogFormat* p_format, const char* filterExpression) {
  size_t tagNameLength;
  android_LogPriority pri = ANDROID_LOG_DEFAULT;

  tagNameLength = strcspn(filterExpression, ":");

  if (tagNameLength == 0) {
    goto error;
  }

  if (filterExpression[tagNameLength] == ':') {
    pri = filterCharToPri(filterExpression[tagNameLength + 1]);

    if (pri == ANDROID_LOG_UNKNOWN) {
      goto error;
    }
  }

  if (0 == strncmp("*", filterExpression, tagNameLength)) {
    /*
     * This filter expression refers to the global filter
     * The default level for this is DEBUG if the priority
     * is unspecified
     */
    if (pri == ANDROID_LOG_DEFAULT) {
      pri = ANDROID_LOG_DEBUG;
    }

    p_format->global_pri = pri;
  } else {
    /*
     * for filter expressions that don't refer to the global
     * filter, the default is verbose if the priority is unspecified
     */
    if (pri == ANDROID_LOG_DEFAULT) {
      pri = ANDROID_LOG_VERBOSE;
    }

    char* tagName;

/*
 * Presently HAVE_STRNDUP is never defined, so the second case is always taken
 * Darwin doesn't have strndup, everything else does
 */
#ifdef HAVE_STRNDUP
    tagName = strndup(filterExpression, tagNameLength);
#else
    /* a few extra bytes copied... */
    tagName = strdup(filterExpression);
    tagName[tagNameLength] = '\0';
#endif /*HAVE_STRNDUP*/

    FilterInfo* p_fi = filterinfo_new(tagName, pri);
    free(tagName);

    p_fi->p_next = p_format->filters;
    p_format->filters = p_fi;
  }

  return 0;
error:
  return -1;
}

#ifndef HAVE_STRSEP
/* KISS replacement helper for below */
static char* strsep(char** stringp, const char* delim) {
  char* token;
  char* ret = *stringp;

  if (!ret || !*ret) {
    return NULL;
  }
  token = strpbrk(ret, delim);
  if (token) {
    *token = '\0';
    ++token;
  } else {
    token = ret + strlen(ret);
  }
  *stringp = token;
  return ret;
}
#endif

/**
 * filterString: a comma/whitespace-separated set of filter expressions
 *
 * eg "AT:d *:i"
 *
 * returns 0 on success and -1 on invalid expression
 *
 * Assumes single threaded execution
 *
 */
int android_log_addFilterString(AndroidLogFormat* p_format, const char* filterString) {
  char* filterStringCopy = strdup(filterString);
  char* p_cur = filterStringCopy;
  char* p_ret;
  int err;

  /* Yes, I'm using strsep */
  while (NULL != (p_ret = strsep(&p_cur, " \t,"))) {
    /* ignore whitespace-only entries */
    if (p_ret[0] != '\0') {
      err = android_log_addFilterRule(p_format, p_ret);

      if (err < 0) {
        goto error;
      }
    }
  }

  free(filterStringCopy);
  return 0;
error:
  free(filterStringCopy);
  return -1;
}

/**
 * Splits a wire-format buffer into an AndroidLogEntry
 * entry allocated by caller. Pointers will point directly into buf
 *
 * Returns 0 on success and -1 on invalid wire format (entry will be
 * in unspecified state)
 */
int android_log_processLogBuffer(struct logger_entry* buf, AndroidLogEntry* entry) {
  entry->message = NULL;
  entry->messageLen = 0;

  entry->tv_sec = buf->sec;
  entry->tv_nsec = buf->nsec;
  entry->uid = -1;
  entry->pid = buf->pid;
  entry->tid = buf->tid;

  /*
   * format: <priority:1><tag:N>\0<message:N>\0
   *
   * tag str
   *   starts at buf->msg+1
   * msg
   *   starts at buf->msg+1+len(tag)+1
   *
   * The message may have been truncated by the kernel log driver.
   * When that happens, we must null-terminate the message ourselves.
   */
  if (buf->len < 3) {
    /*
     * An well-formed entry must consist of at least a priority
     * and two null characters
     */
    fprintf(stderr, "+++ LOG: entry too small\n");
    return -1;
  }

  int msgStart = -1;
  int msgEnd = -1;

  int i;
  char* msg = buf->msg;
  struct logger_entry_v2* buf2 = (struct logger_entry_v2*)buf;
  if (buf2->hdr_size) {
    if ((buf2->hdr_size < sizeof(((struct log_msg*)NULL)->entry_v1)) ||
        (buf2->hdr_size > sizeof(((struct log_msg*)NULL)->entry))) {
      fprintf(stderr, "+++ LOG: entry illegal hdr_size\n");
      return -1;
    }
    msg = ((char*)buf2) + buf2->hdr_size;
    if (buf2->hdr_size >= sizeof(struct logger_entry_v4)) {
      entry->uid = ((struct logger_entry_v4*)buf)->uid;
    }
  }
  for (i = 1; i < buf->len; i++) {
    if (msg[i] == '\0') {
      if (msgStart == -1) {
        msgStart = i + 1;
      } else {
        msgEnd = i;
        break;
      }
    }
  }

  if (msgStart == -1) {
    /* +++ LOG: malformed log message, DYB */
    for (i = 1; i < buf->len; i++) {
      /* odd characters in tag? */
      if ((msg[i] <= ' ') || (msg[i] == ':') || (msg[i] >= 0x7f)) {
        msg[i] = '\0';
        msgStart = i + 1;
        break;
      }
    }
    if (msgStart == -1) {
      msgStart = buf->len - 1; /* All tag, no message, print truncates */
    }
  }
  if (msgEnd == -1) {
    /* incoming message not null-terminated; force it */
    msgEnd = buf->len - 1; /* may result in msgEnd < msgStart */
    msg[msgEnd] = '\0';
  }

  entry->priority = static_cast<android_LogPriority>(msg[0]);
  entry->tag = msg + 1;
  entry->tagLen = msgStart - 1;
  entry->message = msg + msgStart;
  entry->messageLen = (msgEnd < msgStart) ? 0 : (msgEnd - msgStart);

  return 0;
}

/*
 * Extract a 4-byte value from a byte stream.
 */
static inline uint32_t get4LE(const uint8_t* src) {
  return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
}

/*
 * Extract an 8-byte value from a byte stream.
 */
static inline uint64_t get8LE(const uint8_t* src) {
  uint32_t low, high;

  low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
  high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
  return ((uint64_t)high << 32) | (uint64_t)low;
}

static bool findChar(const char** cp, size_t* len, int c) {
  while ((*len) && isspace(*(*cp))) {
    ++(*cp);
    --(*len);
  }
  if (c == INT_MAX) return *len;
  if ((*len) && (*(*cp) == c)) {
    ++(*cp);
    --(*len);
    return true;
  }
  return false;
}

/*
 * Recursively convert binary log data to printable form.
 *
 * This needs to be recursive because you can have lists of lists.
 *
 * If we run out of room, we stop processing immediately.  It's important
 * for us to check for space on every output element to avoid producing
 * garbled output.
 *
 * Returns 0 on success, 1 on buffer full, -1 on failure.
 */
enum objectType {
  TYPE_OBJECTS = '1',
  TYPE_BYTES = '2',
  TYPE_MILLISECONDS = '3',
  TYPE_ALLOCATIONS = '4',
  TYPE_ID = '5',
  TYPE_PERCENT = '6',
  TYPE_MONOTONIC = 's'
};

static int android_log_printBinaryEvent(const unsigned char** pEventData, size_t* pEventDataLen,
                                        char** pOutBuf, size_t* pOutBufLen, const char** fmtStr,
                                        size_t* fmtLen) {
  const unsigned char* eventData = *pEventData;
  size_t eventDataLen = *pEventDataLen;
  char* outBuf = *pOutBuf;
  char* outBufSave = outBuf;
  size_t outBufLen = *pOutBufLen;
  size_t outBufLenSave = outBufLen;
  unsigned char type;
  size_t outCount = 0;
  int result = 0;
  const char* cp;
  size_t len;
  int64_t lval;

  if (eventDataLen < 1) return -1;

  type = *eventData++;
  eventDataLen--;

  cp = NULL;
  len = 0;
  if (fmtStr && *fmtStr && fmtLen && *fmtLen && **fmtStr) {
    cp = *fmtStr;
    len = *fmtLen;
  }
  /*
   * event.logtag format specification:
   *
   * Optionally, after the tag names can be put a description for the value(s)
   * of the tag. Description are in the format
   *    (<name>|data type[|data unit])
   * Multiple values are separated by commas.
   *
   * The data type is a number from the following values:
   * 1: int
   * 2: long
   * 3: string
   * 4: list
   * 5: float
   *
   * The data unit is a number taken from the following list:
   * 1: Number of objects
   * 2: Number of bytes
   * 3: Number of milliseconds
   * 4: Number of allocations
   * 5: Id
   * 6: Percent
   * s: Number of seconds (monotonic time)
   * Default value for data of type int/long is 2 (bytes).
   */
  if (!cp || !findChar(&cp, &len, '(')) {
    len = 0;
  } else {
    char* outBufLastSpace = NULL;

    findChar(&cp, &len, INT_MAX);
    while (len && *cp && (*cp != '|') && (*cp != ')')) {
      if (outBufLen <= 0) {
        /* halt output */
        goto no_room;
      }
      outBufLastSpace = isspace(*cp) ? outBuf : NULL;
      *outBuf = *cp;
      ++outBuf;
      ++cp;
      --outBufLen;
      --len;
    }
    if (outBufLastSpace) {
      outBufLen += outBuf - outBufLastSpace;
      outBuf = outBufLastSpace;
    }
    if (outBufLen <= 0) {
      /* halt output */
      goto no_room;
    }
    if (outBufSave != outBuf) {
      *outBuf = '=';
      ++outBuf;
      --outBufLen;
    }

    if (findChar(&cp, &len, '|') && findChar(&cp, &len, INT_MAX)) {
      static const unsigned char typeTable[] = {EVENT_TYPE_INT, EVENT_TYPE_LONG, EVENT_TYPE_STRING,
                                                EVENT_TYPE_LIST, EVENT_TYPE_FLOAT};

      if ((*cp >= '1') && (*cp < (char)('1' + (sizeof(typeTable) / sizeof(typeTable[0])))) &&
          (type != typeTable[(size_t)(*cp - '1')]))
        len = 0;

      if (len) {
        ++cp;
        --len;
      } else {
        /* reset the format */
        outBuf = outBufSave;
        outBufLen = outBufLenSave;
      }
    }
  }
  outCount = 0;
  lval = 0;
  switch (type) {
    case EVENT_TYPE_INT:
      /* 32-bit signed int */
      {
        int32_t ival;

        if (eventDataLen < 4) return -1;
        ival = get4LE(eventData);
        eventData += 4;
        eventDataLen -= 4;

        lval = ival;
      }
      goto pr_lval;
    case EVENT_TYPE_LONG:
      /* 64-bit signed long */
      if (eventDataLen < 8) return -1;
      lval = get8LE(eventData);
      eventData += 8;
      eventDataLen -= 8;
    pr_lval:
      outCount = snprintf(outBuf, outBufLen, "%" PRId64, lval);
      if (outCount < outBufLen) {
        outBuf += outCount;
        outBufLen -= outCount;
      } else {
        /* halt output */
        goto no_room;
      }
      break;
    case EVENT_TYPE_FLOAT:
      /* float */
      {
        uint32_t ival;
        float fval;

        if (eventDataLen < 4) return -1;
        ival = get4LE(eventData);
        fval = *(float*)&ival;
        eventData += 4;
        eventDataLen -= 4;

        outCount = snprintf(outBuf, outBufLen, "%f", fval);
        if (outCount < outBufLen) {
          outBuf += outCount;
          outBufLen -= outCount;
        } else {
          /* halt output */
          goto no_room;
        }
      }
      break;
    case EVENT_TYPE_STRING:
      /* UTF-8 chars, not NULL-terminated */
      {
        unsigned int strLen;

        if (eventDataLen < 4) return -1;
        strLen = get4LE(eventData);
        eventData += 4;
        eventDataLen -= 4;

        if (eventDataLen < strLen) {
          result = -1; /* mark truncated */
          strLen = eventDataLen;
        }

        if (cp && (strLen == 0)) {
          /* reset the format if no content */
          outBuf = outBufSave;
          outBufLen = outBufLenSave;
        }
        if (strLen < outBufLen) {
          memcpy(outBuf, eventData, strLen);
          outBuf += strLen;
          outBufLen -= strLen;
        } else {
          if (outBufLen > 0) {
            /* copy what we can */
            memcpy(outBuf, eventData, outBufLen);
            outBuf += outBufLen;
            outBufLen -= outBufLen;
          }
          if (!result) result = 1; /* if not truncated, return no room */
        }
        eventData += strLen;
        eventDataLen -= strLen;
        if (result != 0) goto bail;
        break;
      }
    case EVENT_TYPE_LIST:
      /* N items, all different types */
      {
        unsigned char count;
        int i;

        if (eventDataLen < 1) return -1;

        count = *eventData++;
        eventDataLen--;

        if (outBufLen <= 0) goto no_room;

        *outBuf++ = '[';
        outBufLen--;

        for (i = 0; i < count; i++) {
          result = android_log_printBinaryEvent(&eventData, &eventDataLen, &outBuf, &outBufLen,
                                                fmtStr, fmtLen);
          if (result != 0) goto bail;

          if (i < (count - 1)) {
            if (outBufLen <= 0) goto no_room;
            *outBuf++ = ',';
            outBufLen--;
          }
        }

        if (outBufLen <= 0) goto no_room;

        *outBuf++ = ']';
        outBufLen--;
      }
      break;
    default:
      fprintf(stderr, "Unknown binary event type %d\n", type);
      return -1;
  }
  if (cp && len) {
    if (findChar(&cp, &len, '|') && findChar(&cp, &len, INT_MAX)) {
      switch (*cp) {
        case TYPE_OBJECTS:
          outCount = 0;
          /* outCount = snprintf(outBuf, outBufLen, " objects"); */
          break;
        case TYPE_BYTES:
          if ((lval != 0) && ((lval % 1024) == 0)) {
            /* repaint with multiplier */
            static const char suffixTable[] = {'K', 'M', 'G', 'T'};
            size_t idx = 0;
            outBuf -= outCount;
            outBufLen += outCount;
            do {
              lval /= 1024;
              if ((lval % 1024) != 0) break;
            } while (++idx < ((sizeof(suffixTable) / sizeof(suffixTable[0])) - 1));
            outCount = snprintf(outBuf, outBufLen, "%" PRId64 "%cB", lval, suffixTable[idx]);
          } else {
            outCount = snprintf(outBuf, outBufLen, "B");
          }
          break;
        case TYPE_MILLISECONDS:
          if (((lval <= -1000) || (1000 <= lval)) && (outBufLen || (outBuf[-1] == '0'))) {
            /* repaint as (fractional) seconds, possibly saving space */
            if (outBufLen) outBuf[0] = outBuf[-1];
            outBuf[-1] = outBuf[-2];
            outBuf[-2] = outBuf[-3];
            outBuf[-3] = '.';
            while ((outBufLen == 0) || (*outBuf == '0')) {
              --outBuf;
              ++outBufLen;
            }
            if (*outBuf != '.') {
              ++outBuf;
              --outBufLen;
            }
            outCount = snprintf(outBuf, outBufLen, "s");
          } else {
            outCount = snprintf(outBuf, outBufLen, "ms");
          }
          break;
        case TYPE_MONOTONIC: {
          static const uint64_t minute = 60;
          static const uint64_t hour = 60 * minute;
          static const uint64_t day = 24 * hour;

          /* Repaint as unsigned seconds, minutes, hours ... */
          outBuf -= outCount;
          outBufLen += outCount;
          uint64_t val = lval;
          if (val >= day) {
            outCount = snprintf(outBuf, outBufLen, "%" PRIu64 "d ", val / day);
            if (outCount >= outBufLen) break;
            outBuf += outCount;
            outBufLen -= outCount;
            val = (val % day) + day;
          }
          if (val >= minute) {
            if (val >= hour) {
              outCount = snprintf(outBuf, outBufLen, "%" PRIu64 ":", (val / hour) % (day / hour));
              if (outCount >= outBufLen) break;
              outBuf += outCount;
              outBufLen -= outCount;
            }
            outCount =
                snprintf(outBuf, outBufLen, (val >= hour) ? "%02" PRIu64 ":" : "%" PRIu64 ":",
                         (val / minute) % (hour / minute));
            if (outCount >= outBufLen) break;
            outBuf += outCount;
            outBufLen -= outCount;
          }
          outCount = snprintf(outBuf, outBufLen, (val >= minute) ? "%02" PRIu64 : "%" PRIu64 "s",
                              val % minute);
        } break;
        case TYPE_ALLOCATIONS:
          outCount = 0;
          /* outCount = snprintf(outBuf, outBufLen, " allocations"); */
          break;
        case TYPE_ID:
          outCount = 0;
          break;
        case TYPE_PERCENT:
          outCount = snprintf(outBuf, outBufLen, "%%");
          break;
        default: /* ? */
          outCount = 0;
          break;
      }
      ++cp;
      --len;
      if (outCount < outBufLen) {
        outBuf += outCount;
        outBufLen -= outCount;
      } else if (outCount) {
        /* halt output */
        goto no_room;
      }
    }
    if (!findChar(&cp, &len, ')')) len = 0;
    if (!findChar(&cp, &len, ',')) len = 0;
  }

bail:
  *pEventData = eventData;
  *pEventDataLen = eventDataLen;
  *pOutBuf = outBuf;
  *pOutBufLen = outBufLen;
  if (cp) {
    *fmtStr = cp;
    *fmtLen = len;
  }
  return result;

no_room:
  result = 1;
  goto bail;
}

/**
 * Convert a binary log entry to ASCII form.
 *
 * For convenience we mimic the processLogBuffer API.  There is no
 * pre-defined output length for the binary data, since we're free to format
 * it however we choose, which means we can't really use a fixed-size buffer
 * here.
 */
int android_log_processBinaryLogBuffer(
    struct logger_entry* buf, AndroidLogEntry* entry,
    [[maybe_unused]] const EventTagMap* map, /* only on !__ANDROID__ */
    char* messageBuf, int messageBufLen) {
  size_t inCount;
  uint32_t tagIndex;
  const unsigned char* eventData;

  entry->message = NULL;
  entry->messageLen = 0;

  entry->tv_sec = buf->sec;
  entry->tv_nsec = buf->nsec;
  entry->priority = ANDROID_LOG_INFO;
  entry->uid = -1;
  entry->pid = buf->pid;
  entry->tid = buf->tid;

  /*
   * Pull the tag out, fill in some additional details based on incoming
   * buffer version (v3 adds lid, v4 adds uid).
   */
  eventData = (const unsigned char*)buf->msg;
  struct logger_entry_v2* buf2 = (struct logger_entry_v2*)buf;
  if (buf2->hdr_size) {
    if ((buf2->hdr_size < sizeof(((struct log_msg*)NULL)->entry_v1)) ||
        (buf2->hdr_size > sizeof(((struct log_msg*)NULL)->entry))) {
      fprintf(stderr, "+++ LOG: entry illegal hdr_size\n");
      return -1;
    }
    eventData = ((unsigned char*)buf2) + buf2->hdr_size;
    if ((buf2->hdr_size >= sizeof(struct logger_entry_v3)) &&
        (((struct logger_entry_v3*)buf)->lid == LOG_ID_SECURITY)) {
      entry->priority = ANDROID_LOG_WARN;
    }
    if (buf2->hdr_size >= sizeof(struct logger_entry_v4)) {
      entry->uid = ((struct logger_entry_v4*)buf)->uid;
    }
  }
  inCount = buf->len;
  if (inCount < 4) return -1;
  tagIndex = get4LE(eventData);
  eventData += 4;
  inCount -= 4;

  entry->tagLen = 0;
  entry->tag = NULL;
#ifdef __ANDROID__
  if (map != NULL) {
    entry->tag = android_lookupEventTag_len(map, &entry->tagLen, tagIndex);
  }
#endif

  /*
   * If we don't have a map, or didn't find the tag number in the map,
   * stuff a generated tag value into the start of the output buffer and
   * shift the buffer pointers down.
   */
  if (entry->tag == NULL) {
    size_t tagLen;

    tagLen = snprintf(messageBuf, messageBufLen, "[%" PRIu32 "]", tagIndex);
    if (tagLen >= (size_t)messageBufLen) {
      tagLen = messageBufLen - 1;
    }
    entry->tag = messageBuf;
    entry->tagLen = tagLen;
    messageBuf += tagLen + 1;
    messageBufLen -= tagLen + 1;
  }

  /*
   * Format the event log data into the buffer.
   */
  const char* fmtStr = NULL;
  size_t fmtLen = 0;
#ifdef __ANDROID__
  if (descriptive_output && map) {
    fmtStr = android_lookupEventFormat_len(map, &fmtLen, tagIndex);
  }
#endif

  char* outBuf = messageBuf;
  size_t outRemaining = messageBufLen - 1; /* leave one for nul byte */
  int result = 0;

  if ((inCount > 0) || fmtLen) {
    result = android_log_printBinaryEvent(&eventData, &inCount, &outBuf, &outRemaining, &fmtStr,
                                          &fmtLen);
  }
  if ((result == 1) && fmtStr) {
    /* We overflowed :-(, let's repaint the line w/o format dressings */
    eventData = (const unsigned char*)buf->msg;
    if (buf2->hdr_size) {
      eventData = ((unsigned char*)buf2) + buf2->hdr_size;
    }
    eventData += 4;
    outBuf = messageBuf;
    outRemaining = messageBufLen - 1;
    result = android_log_printBinaryEvent(&eventData, &inCount, &outBuf, &outRemaining, NULL, NULL);
  }
  if (result < 0) {
    fprintf(stderr, "Binary log entry conversion failed\n");
  }
  if (result) {
    if (!outRemaining) {
      /* make space to leave an indicator */
      --outBuf;
      ++outRemaining;
    }
    *outBuf++ = (result < 0) ? '!' : '^'; /* Error or Truncation? */
    outRemaining--;
    /* pretend we ate all the data to prevent log stutter */
    inCount = 0;
    if (result > 0) result = 0;
  }

  /* eat the silly terminating '\n' */
  if (inCount == 1 && *eventData == '\n') {
    eventData++;
    inCount--;
  }

  if (inCount != 0) {
    fprintf(stderr, "Warning: leftover binary log data (%zu bytes)\n", inCount);
  }

  /*
   * Terminate the buffer.  The NUL byte does not count as part of
   * entry->messageLen.
   */
  *outBuf = '\0';
  entry->messageLen = outBuf - messageBuf;
  assert(entry->messageLen == (messageBufLen - 1) - outRemaining);

  entry->message = messageBuf;

  return result;
}

/*
 * One utf8 character at a time
 *
 * Returns the length of the utf8 character in the buffer,
 * or -1 if illegal or truncated
 *
 * Open coded from libutils/Unicode.cpp, borrowed from utf8_length(),
 * can not remove from here because of library circular dependencies.
 * Expect one-day utf8_character_length with the same signature could
 * _also_ be part of libutils/Unicode.cpp if its usefullness needs to
 * propagate globally.
 */
LIBLOG_WEAK ssize_t utf8_character_length(const char* src, size_t len) {
  const char* cur = src;
  const char first_char = *cur++;
  static const uint32_t kUnicodeMaxCodepoint = 0x0010FFFF;
  int32_t mask, to_ignore_mask;
  size_t num_to_read;
  uint32_t utf32;

  if ((first_char & 0x80) == 0) { /* ASCII */
    return first_char ? 1 : -1;
  }

  /*
   * (UTF-8's character must not be like 10xxxxxx,
   *  but 110xxxxx, 1110xxxx, ... or 1111110x)
   */
  if ((first_char & 0x40) == 0) {
    return -1;
  }

  for (utf32 = 1, num_to_read = 1, mask = 0x40, to_ignore_mask = 0x80;
       num_to_read < 5 && (first_char & mask); num_to_read++, to_ignore_mask |= mask, mask >>= 1) {
    if (num_to_read > len) {
      return -1;
    }
    if ((*cur & 0xC0) != 0x80) { /* can not be 10xxxxxx? */
      return -1;
    }
    utf32 = (utf32 << 6) + (*cur++ & 0b00111111);
  }
  /* "first_char" must be (110xxxxx - 11110xxx) */
  if (num_to_read >= 5) {
    return -1;
  }
  to_ignore_mask |= mask;
  utf32 |= ((~to_ignore_mask) & first_char) << (6 * (num_to_read - 1));
  if (utf32 > kUnicodeMaxCodepoint) {
    return -1;
  }
  return num_to_read;
}

/*
 * Convert to printable from message to p buffer, return string length. If p is
 * NULL, do not copy, but still return the expected string length.
 */
static size_t convertPrintable(char* p, const char* message, size_t messageLen) {
  char* begin = p;
  bool print = p != NULL;

  while (messageLen) {
    char buf[6];
    ssize_t len = sizeof(buf) - 1;
    if ((size_t)len > messageLen) {
      len = messageLen;
    }
    len = utf8_character_length(message, len);

    if (len < 0) {
      snprintf(buf, sizeof(buf), ((messageLen > 1) && isdigit(message[1])) ? "\\%03o" : "\\%o",
               *message & 0377);
      len = 1;
    } else {
      buf[0] = '\0';
      if (len == 1) {
        if (*message == '\a') {
          strcpy(buf, "\\a");
        } else if (*message == '\b') {
          strcpy(buf, "\\b");
        } else if (*message == '\t') {
          strcpy(buf, "\t"); /* Do not escape tabs */
        } else if (*message == '\v') {
          strcpy(buf, "\\v");
        } else if (*message == '\f') {
          strcpy(buf, "\\f");
        } else if (*message == '\r') {
          strcpy(buf, "\\r");
        } else if (*message == '\\') {
          strcpy(buf, "\\\\");
        } else if ((*message < ' ') || (*message & 0x80)) {
          snprintf(buf, sizeof(buf), "\\%o", *message & 0377);
        }
      }
      if (!buf[0]) {
        strncpy(buf, message, len);
        buf[len] = '\0';
      }
    }
    if (print) {
      strcpy(p, buf);
    }
    p += strlen(buf);
    message += len;
    messageLen -= len;
  }
  return p - begin;
}

static char* readSeconds(char* e, struct timespec* t) {
  unsigned long multiplier;
  char* p;
  t->tv_sec = strtoul(e, &p, 10);
  if (*p != '.') {
    return NULL;
  }
  t->tv_nsec = 0;
  multiplier = NS_PER_SEC;
  while (isdigit(*++p) && (multiplier /= 10)) {
    t->tv_nsec += (*p - '0') * multiplier;
  }
  return p;
}

static struct timespec* sumTimespec(struct timespec* left, struct timespec* right) {
  left->tv_nsec += right->tv_nsec;
  left->tv_sec += right->tv_sec;
  if (left->tv_nsec >= (long)NS_PER_SEC) {
    left->tv_nsec -= NS_PER_SEC;
    left->tv_sec += 1;
  }
  return left;
}

static struct timespec* subTimespec(struct timespec* result, struct timespec* left,
                                    struct timespec* right) {
  result->tv_nsec = left->tv_nsec - right->tv_nsec;
  result->tv_sec = left->tv_sec - right->tv_sec;
  if (result->tv_nsec < 0) {
    result->tv_nsec += NS_PER_SEC;
    result->tv_sec -= 1;
  }
  return result;
}

static long long nsecTimespec(struct timespec* now) {
  return (long long)now->tv_sec * NS_PER_SEC + now->tv_nsec;
}

#ifdef __ANDROID__
static void convertMonotonic(struct timespec* result, const AndroidLogEntry* entry) {
  struct listnode* node;
  struct conversionList {
    struct listnode node; /* first */
    struct timespec time;
    struct timespec convert;
  } * list, *next;
  struct timespec time, convert;

  /* If we do not have a conversion list, build one up */
  if (list_empty(&convertHead)) {
    bool suspended_pending = false;
    struct timespec suspended_monotonic = {0, 0};
    struct timespec suspended_diff = {0, 0};

    /*
     * Read dmesg for _some_ synchronization markers and insert
     * Anything in the Android Logger before the dmesg logging span will
     * be highly suspect regarding the monotonic time calculations.
     */
    FILE* p = popen("/system/bin/dmesg", "re");
    if (p) {
      char* line = NULL;
      size_t len = 0;
      while (getline(&line, &len, p) > 0) {
        static const char suspend[] = "PM: suspend entry ";
        static const char resume[] = "PM: suspend exit ";
        static const char healthd[] = "healthd";
        static const char battery[] = ": battery ";
        static const char suspended[] = "Suspended for ";
        struct timespec monotonic;
        struct tm tm;
        char *cp, *e = line;
        bool add_entry = true;

        if (*e == '<') {
          while (*e && (*e != '>')) {
            ++e;
          }
          if (*e != '>') {
            continue;
          }
        }
        if (*e != '[') {
          continue;
        }
        while (*++e == ' ') {
          ;
        }
        e = readSeconds(e, &monotonic);
        if (!e || (*e != ']')) {
          continue;
        }

        if ((e = strstr(e, suspend))) {
          e += sizeof(suspend) - 1;
        } else if ((e = strstr(line, resume))) {
          e += sizeof(resume) - 1;
        } else if (((e = strstr(line, healthd))) &&
                   ((e = strstr(e + sizeof(healthd) - 1, battery)))) {
          /* NB: healthd is roughly 150us late, worth the price to
           * deal with ntp-induced or hardware clock drift. */
          e += sizeof(battery) - 1;
        } else if ((e = strstr(line, suspended))) {
          e += sizeof(suspended) - 1;
          e = readSeconds(e, &time);
          if (!e) {
            continue;
          }
          add_entry = false;
          suspended_pending = true;
          suspended_monotonic = monotonic;
          suspended_diff = time;
        } else {
          continue;
        }
        if (add_entry) {
          /* look for "????-??-?? ??:??:??.????????? UTC" */
          cp = strstr(e, " UTC");
          if (!cp || ((cp - e) < 29) || (cp[-10] != '.')) {
            continue;
          }
          e = cp - 29;
          cp = readSeconds(cp - 10, &time);
          if (!cp) {
            continue;
          }
          cp = strptime(e, "%Y-%m-%d %H:%M:%S.", &tm);
          if (!cp) {
            continue;
          }
          cp = getenv(tz);
          if (cp) {
            cp = strdup(cp);
          }
          setenv(tz, utc, 1);
          time.tv_sec = mktime(&tm);
          if (cp) {
            setenv(tz, cp, 1);
            free(cp);
          } else {
            unsetenv(tz);
          }
          list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
          list_init(&list->node);
          list->time = time;
          subTimespec(&list->convert, &time, &monotonic);
          list_add_tail(&convertHead, &list->node);
        }
        if (suspended_pending && !list_empty(&convertHead)) {
          list = node_to_item(list_tail(&convertHead), struct conversionList, node);
          if (subTimespec(&time, subTimespec(&time, &list->time, &list->convert),
                          &suspended_monotonic)
                  ->tv_sec > 0) {
            /* resume, what is convert factor before? */
            subTimespec(&convert, &list->convert, &suspended_diff);
          } else {
            /* suspend */
            convert = list->convert;
          }
          time = suspended_monotonic;
          sumTimespec(&time, &convert);
          /* breakpoint just before sleep */
          list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
          list_init(&list->node);
          list->time = time;
          list->convert = convert;
          list_add_tail(&convertHead, &list->node);
          /* breakpoint just after sleep */
          list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
          list_init(&list->node);
          list->time = time;
          sumTimespec(&list->time, &suspended_diff);
          list->convert = convert;
          sumTimespec(&list->convert, &suspended_diff);
          list_add_tail(&convertHead, &list->node);
          suspended_pending = false;
        }
      }
      pclose(p);
    }
    /* last entry is our current time conversion */
    list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
    list_init(&list->node);
    clock_gettime(CLOCK_REALTIME, &list->time);
    clock_gettime(CLOCK_MONOTONIC, &convert);
    clock_gettime(CLOCK_MONOTONIC, &time);
    /* Correct for instant clock_gettime latency (syscall or ~30ns) */
    subTimespec(&time, &convert, subTimespec(&time, &time, &convert));
    /* Calculate conversion factor */
    subTimespec(&list->convert, &list->time, &time);
    list_add_tail(&convertHead, &list->node);
    if (suspended_pending) {
      /* manufacture a suspend @ point before */
      subTimespec(&convert, &list->convert, &suspended_diff);
      time = suspended_monotonic;
      sumTimespec(&time, &convert);
      /* breakpoint just after sleep */
      list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
      list_init(&list->node);
      list->time = time;
      sumTimespec(&list->time, &suspended_diff);
      list->convert = convert;
      sumTimespec(&list->convert, &suspended_diff);
      list_add_head(&convertHead, &list->node);
      /* breakpoint just before sleep */
      list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
      list_init(&list->node);
      list->time = time;
      list->convert = convert;
      list_add_head(&convertHead, &list->node);
    }
  }

  /* Find the breakpoint in the conversion list */
  list = node_to_item(list_head(&convertHead), struct conversionList, node);
  next = NULL;
  list_for_each(node, &convertHead) {
    next = node_to_item(node, struct conversionList, node);
    if (entry->tv_sec < next->time.tv_sec) {
      break;
    } else if (entry->tv_sec == next->time.tv_sec) {
      if (entry->tv_nsec < next->time.tv_nsec) {
        break;
      }
    }
    list = next;
  }

  /* blend time from one breakpoint to the next */
  convert = list->convert;
  if (next) {
    unsigned long long total, run;

    total = nsecTimespec(subTimespec(&time, &next->time, &list->time));
    time.tv_sec = entry->tv_sec;
    time.tv_nsec = entry->tv_nsec;
    run = nsecTimespec(subTimespec(&time, &time, &list->time));
    if (run < total) {
      long long crun;

      float f = nsecTimespec(subTimespec(&time, &next->convert, &convert));
      f *= run;
      f /= total;
      crun = f;
      convert.tv_sec += crun / (long long)NS_PER_SEC;
      if (crun < 0) {
        convert.tv_nsec -= (-crun) % NS_PER_SEC;
        if (convert.tv_nsec < 0) {
          convert.tv_nsec += NS_PER_SEC;
          convert.tv_sec -= 1;
        }
      } else {
        convert.tv_nsec += crun % NS_PER_SEC;
        if (convert.tv_nsec >= (long)NS_PER_SEC) {
          convert.tv_nsec -= NS_PER_SEC;
          convert.tv_sec += 1;
        }
      }
    }
  }

  /* Apply the correction factor */
  result->tv_sec = entry->tv_sec;
  result->tv_nsec = entry->tv_nsec;
  subTimespec(result, result, &convert);
}
#endif

/**
 * Formats a log message into a buffer
 *
 * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer
 * If return value != defaultBuffer, caller must call free()
 * Returns NULL on malloc error
 */

char* android_log_formatLogLine(AndroidLogFormat* p_format, char* defaultBuffer,
                                size_t defaultBufferSize, const AndroidLogEntry* entry,
                                size_t* p_outLength) {
#if !defined(_WIN32)
  struct tm tmBuf;
#endif
  struct tm* ptm;
  /* good margin, 23+nul for msec, 26+nul for usec, 29+nul to nsec */
  char timeBuf[64];
  char prefixBuf[128], suffixBuf[128];
  char priChar;
  int prefixSuffixIsHeaderFooter = 0;
  char* ret;
  time_t now;
  unsigned long nsec;

  priChar = filterPriToChar(entry->priority);
  size_t prefixLen = 0, suffixLen = 0;
  size_t len;

  /*
   * Get the current date/time in pretty form
   *
   * It's often useful when examining a log with "less" to jump to
   * a specific point in the file by searching for the date/time stamp.
   * For this reason it's very annoying to have regexp meta characters
   * in the time stamp.  Don't use forward slashes, parenthesis,
   * brackets, asterisks, or other special chars here.
   *
   * The caller may have affected the timezone environment, this is
   * expected to be sensitive to that.
   */
  now = entry->tv_sec;
  nsec = entry->tv_nsec;
#if __ANDROID__
  if (p_format->monotonic_output) {
    /* prevent convertMonotonic from being called if logd is monotonic */
    if (android_log_clockid() != CLOCK_MONOTONIC) {
      struct timespec time;
      convertMonotonic(&time, entry);
      now = time.tv_sec;
      nsec = time.tv_nsec;
    }
  }
#endif
  if (now < 0) {
    nsec = NS_PER_SEC - nsec;
  }
  if (p_format->epoch_output || p_format->monotonic_output) {
    ptm = NULL;
    snprintf(timeBuf, sizeof(timeBuf), p_format->monotonic_output ? "%6lld" : "%19lld",
             (long long)now);
  } else {
#if !defined(_WIN32)
    ptm = localtime_r(&now, &tmBuf);
#else
    ptm = localtime(&now);
#endif
    strftime(timeBuf, sizeof(timeBuf), &"%Y-%m-%d %H:%M:%S"[p_format->year_output ? 0 : 3], ptm);
  }
  len = strlen(timeBuf);
  if (p_format->nsec_time_output) {
    len += snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%09ld", nsec);
  } else if (p_format->usec_time_output) {
    len += snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%06ld", nsec / US_PER_NSEC);
  } else {
    len += snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%03ld", nsec / MS_PER_NSEC);
  }
  if (p_format->zone_output && ptm) {
    strftime(timeBuf + len, sizeof(timeBuf) - len, " %z", ptm);
  }

  /*
   * Construct a buffer containing the log header and log message.
   */
  if (p_format->colored_output) {
    prefixLen =
        snprintf(prefixBuf, sizeof(prefixBuf), "\x1B[38;5;%dm", colorFromPri(entry->priority));
    prefixLen = MIN(prefixLen, sizeof(prefixBuf));

    const char suffixContents[] = "\x1B[0m";
    strcpy(suffixBuf, suffixContents);
    suffixLen = strlen(suffixContents);
  }

  char uid[16];
  uid[0] = '\0';
  if (p_format->uid_output) {
    if (entry->uid >= 0) {
/*
 * This code is Android specific, bionic guarantees that
 * calls to non-reentrant getpwuid() are thread safe.
 */
#if !defined(__MINGW32__)
#if (FAKE_LOG_DEVICE == 0)
#ifndef __BIONIC__
#warning "This code assumes that getpwuid is thread safe, only true with Bionic!"
#endif
#endif
      struct passwd* pwd = getpwuid(entry->uid);
      if (pwd && (strlen(pwd->pw_name) <= 5)) {
        snprintf(uid, sizeof(uid), "%5s:", pwd->pw_name);
      } else
#endif
      {
        /* Not worth parsing package list, names all longer than 5 */
        snprintf(uid, sizeof(uid), "%5d:", entry->uid);
      }
    } else {
      snprintf(uid, sizeof(uid), "      ");
    }
  }

  switch (p_format->format) {
    case FORMAT_TAG:
      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%c/%-8.*s: ", priChar,
                     (int)entry->tagLen, entry->tag);
      strcpy(suffixBuf + suffixLen, "\n");
      ++suffixLen;
      break;
    case FORMAT_PROCESS:
      len = snprintf(suffixBuf + suffixLen, sizeof(suffixBuf) - suffixLen, "  (%.*s)\n",
                     (int)entry->tagLen, entry->tag);
      suffixLen += MIN(len, sizeof(suffixBuf) - suffixLen);
      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%c(%s%5d) ", priChar,
                     uid, entry->pid);
      break;
    case FORMAT_THREAD:
      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%c(%s%5d:%5d) ",
                     priChar, uid, entry->pid, entry->tid);
      strcpy(suffixBuf + suffixLen, "\n");
      ++suffixLen;
      break;
    case FORMAT_RAW:
      prefixBuf[prefixLen] = 0;
      len = 0;
      strcpy(suffixBuf + suffixLen, "\n");
      ++suffixLen;
      break;
    case FORMAT_TIME:
      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
                     "%s %c/%-8.*s(%s%5d): ", timeBuf, priChar, (int)entry->tagLen, entry->tag, uid,
                     entry->pid);
      strcpy(suffixBuf + suffixLen, "\n");
      ++suffixLen;
      break;
    case FORMAT_THREADTIME:
      ret = strchr(uid, ':');
      if (ret) {
        *ret = ' ';
      }
      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
                     "%s %s%5d %5d %c %-8.*s: ", timeBuf, uid, entry->pid, entry->tid, priChar,
                     (int)entry->tagLen, entry->tag);
      strcpy(suffixBuf + suffixLen, "\n");
      ++suffixLen;
      break;
    case FORMAT_LONG:
      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
                     "[ %s %s%5d:%5d %c/%-8.*s ]\n", timeBuf, uid, entry->pid, entry->tid, priChar,
                     (int)entry->tagLen, entry->tag);
      strcpy(suffixBuf + suffixLen, "\n\n");
      suffixLen += 2;
      prefixSuffixIsHeaderFooter = 1;
      break;
    case FORMAT_BRIEF:
    default:
      len =
          snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
                   "%c/%-8.*s(%s%5d): ", priChar, (int)entry->tagLen, entry->tag, uid, entry->pid);
      strcpy(suffixBuf + suffixLen, "\n");
      ++suffixLen;
      break;
  }

  /* snprintf has a weird return value.   It returns what would have been
   * written given a large enough buffer.  In the case that the prefix is
   * longer then our buffer(128), it messes up the calculations below
   * possibly causing heap corruption.  To avoid this we double check and
   * set the length at the maximum (size minus null byte)
   */
  prefixLen += len;
  if (prefixLen >= sizeof(prefixBuf)) {
    prefixLen = sizeof(prefixBuf) - 1;
    prefixBuf[sizeof(prefixBuf) - 1] = '\0';
  }
  if (suffixLen >= sizeof(suffixBuf)) {
    suffixLen = sizeof(suffixBuf) - 1;
    suffixBuf[sizeof(suffixBuf) - 2] = '\n';
    suffixBuf[sizeof(suffixBuf) - 1] = '\0';
  }

  /* the following code is tragically unreadable */

  size_t numLines;
  char* p;
  size_t bufferSize;
  const char* pm;

  if (prefixSuffixIsHeaderFooter) {
    /* we're just wrapping message with a header/footer */
    numLines = 1;
  } else {
    pm = entry->message;
    numLines = 0;

    /*
     * The line-end finding here must match the line-end finding
     * in for ( ... numLines...) loop below
     */
    while (pm < (entry->message + entry->messageLen)) {
      if (*pm++ == '\n') numLines++;
    }
    /* plus one line for anything not newline-terminated at the end */
    if (pm > entry->message && *(pm - 1) != '\n') numLines++;
  }

  /*
   * this is an upper bound--newlines in message may be counted
   * extraneously
   */
  bufferSize = (numLines * (prefixLen + suffixLen)) + 1;
  if (p_format->printable_output) {
    /* Calculate extra length to convert non-printable to printable */
    bufferSize += convertPrintable(NULL, entry->message, entry->messageLen);
  } else {
    bufferSize += entry->messageLen;
  }

  if (defaultBufferSize >= bufferSize) {
    ret = defaultBuffer;
  } else {
    ret = (char*)malloc(bufferSize);

    if (ret == NULL) {
      return ret;
    }
  }

  ret[0] = '\0'; /* to start strcat off */

  p = ret;
  pm = entry->message;

  if (prefixSuffixIsHeaderFooter) {
    strcat(p, prefixBuf);
    p += prefixLen;
    if (p_format->printable_output) {
      p += convertPrintable(p, entry->message, entry->messageLen);
    } else {
      strncat(p, entry->message, entry->messageLen);
      p += entry->messageLen;
    }
    strcat(p, suffixBuf);
    p += suffixLen;
  } else {
    do {
      const char* lineStart;
      size_t lineLen;
      lineStart = pm;

      /* Find the next end-of-line in message */
      while (pm < (entry->message + entry->messageLen) && *pm != '\n') pm++;
      lineLen = pm - lineStart;

      strcat(p, prefixBuf);
      p += prefixLen;
      if (p_format->printable_output) {
        p += convertPrintable(p, lineStart, lineLen);
      } else {
        strncat(p, lineStart, lineLen);
        p += lineLen;
      }
      strcat(p, suffixBuf);
      p += suffixLen;

      if (*pm == '\n') pm++;
    } while (pm < (entry->message + entry->messageLen));
  }

  if (p_outLength != NULL) {
    *p_outLength = p - ret;
  }

  return ret;
}

/**
 * Either print or do not print log line, based on filter
 *
 * Returns count bytes written
 */

int android_log_printLogLine(AndroidLogFormat* p_format, int fd, const AndroidLogEntry* entry) {
  int ret;
  char defaultBuffer[512];
  char* outBuffer = NULL;
  size_t totalLen;

  outBuffer =
      android_log_formatLogLine(p_format, defaultBuffer, sizeof(defaultBuffer), entry, &totalLen);

  if (!outBuffer) return -1;

  do {
    ret = write(fd, outBuffer, totalLen);
  } while (ret < 0 && errno == EINTR);

  if (ret < 0) {
    fprintf(stderr, "+++ LOG: write failed (errno=%d)\n", errno);
    ret = 0;
    goto done;
  }

  if (((size_t)ret) < totalLen) {
    fprintf(stderr, "+++ LOG: write partial (%d of %d)\n", ret, (int)totalLen);
    goto done;
  }

done:
  if (outBuffer != defaultBuffer) {
    free(outBuffer);
  }

  return ret;
}

redpajama_set_name: RedPajamaGithub


text:
<?php
/**
 * @author Nikolay Ermin <nikolay@ermin.ru>
 * @link   http://ermin.ru
 */

namespace Module\Market\Form;

class ManufacturerEditForm extends \Sfcms\Form\Form
{
    public function __construct()
    {
        // @todo Не работает javascript модуль в админке
        parent::__construct(
            array(
                 'name' => 'manufacturers',
                 'action'    => \App::cms()->get('router')->generate('manufacturers/save'),
                 'fields' => array(
                     'id'   => array('type'=>'hidden'),
                     'name' => array('type'=>'text', 'label' => 'Name', 'required'),
                     'email' => array('type'=>'text', 'label' => 'Email', 'filter' => 'email'),
                     'site'  => array('type'=>'text', 'label' => 'Site', 'filter' => 'url'),
                     'phone' => array('type'=>'text', 'label' => 'Phone', 'filter' => 'phone'),
                     'address' => array('type'=>'textarea', 'label' => 'Address', 'class' => 'plain'),
                     'image' => array('type'=>'text', 'label' => 'Image', 'class'=>'image',
                                       'notice'=>'Double-click to select the image'
                                ),
                     'description' => array('type'=>'textarea', 'label' => 'Description'),

                     'submit'    => array( 'type'=>'submit', 'value'=>'Save'),
                 ),
            )
        );
    }

}


text:
package com.creativewidgetworks.goldparser.parser;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)

/**
 * ProcessRule
 *
 * Annotation definition that tags an instance of a rule handler to
 * describe which rules the class handles.
 *
 * Dependencies: None
 *
 * @author Ralph Iden (http://www.creativewidgetworks.com)
 * @version 5.0.0
 */
public @interface ProcessRule {
    String[] rule();
}


text:
CREATE TABLE [dbo].[Role]
(
	--This table represent all available roles that can be assigned to any users.
	RoleID uniqueidentifier primary key,
	RoleName nvarchar(100) not null,
	RoleDescription nvarchar(300) not null

)


text:
package com.github.bjansen.javel.translator.functions;

import com.github.bjansen.javel.language.Function;
import com.github.bjansen.javel.language.JavelParser;
import com.github.bjansen.javel.translator.JavaTranslator;

public class Hello implements Function<JavaTranslator> {
    @Override
    public String getName() {
        return "hello";
    }

    @Override
    public void call(JavelParser.MethodCallContext ctx, JavaTranslator translator) {
        translator.writeLine("System.out.println(\"Hello, world!\");");
    }
}


text:
<?php

namespace G4\CleanCore\Factory;

use G4\CleanCore\Request\Request;

class UseCase
{
    /**
     * @var \G4\CleanCore\Request\Request
     */
    private $request;

    /**
     * @var \G4\CleanCore\Response\Response
     */
    private $response;

    /**
     * @var \G4\CleanCore\UseCase\UseCaseAbstract
     */
    private $useCase;

    /**
     * @var string
     */
    private $useCaseName;

    /**
     * @throws \Exception
     */
    public function getRequest(): \G4\CleanCore\Request\Request
    {
        if (!$this->request instanceof \G4\CleanCore\Request\Request) {
            throw new \Exception('Request must be instance of \G4\CleanCore\Request\Request');
        }
        return $this->request;
    }

    /**
     * @param string $part
     * @return mixed
     */
    public function getResource($part = null)
    {
        return $part === null
            ? $this->getResponse()->getResponseObject()
            : $this->getResponse()->getResponseObjectPart($part);
    }

    public function getResponse(): \G4\CleanCore\Response\Response
    {
        if (!$this->response instanceof \G4\CleanCore\Response\Response) {
            $this->setResponse();
        }
        return $this->response;
    }

    /**
     * @throws \Exception
     */
    public function getUseCase(): \G4\CleanCore\UseCase\UseCaseAbstract
    {
        if (!$this->useCase instanceof \G4\CleanCore\UseCase\UseCaseAbstract) {
            $this->factory();
        }
        return $this->useCase;
    }

    public function setRequest(Request $request): self
    {
        $this->request = $request;
        return $this;
    }

    public function setUseCaseName(string $useCaseName): self
    {
        $this->useCaseName = $useCaseName;
        return $this;
    }

    private function factory(): self
    {
        $useCaseName    = $this->useCaseName;
        $this->useCase = new $useCaseName();
        $this->useCase
            ->setRequest($this->getRequest());
        return $this;
    }

    private function setResponse(): self
    {
        $this->getUseCase()->run();
        $this->response = $this->getUseCase()->getResponse();
        return $this;
    }
}


text:
define(function(require, exports, module) {
"use strict";

var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Range = require("./range").Range;
var Anchor = require("./anchor").Anchor;

/**
 * class Document
 *
 * Contains the text of the document. Document can be attached to several [[EditSession `EditSession`]]s. At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index.
 *
 *
 **/

 /**
 * new Document([text])
 * - text (String | Array): The starting text
 *
 * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
 *
 **/
var Document = function(text) {
    this.$lines = [];

    // There has to be one line at least in the document. If you pass an empty
    // string to the insert function, nothing will happen. Workaround.
    if (text.length == 0) {
        this.$lines = [""];
    } else if (Array.isArray(text)) {
        this.insertLines(0, text);
    } else {
        this.insert({row: 0, column:0}, text);
    }
};

(function() {

    oop.implement(this, EventEmitter);

    /**
    * Document.setValue(text) -> Void
    * - text (String): The text to use
    *
    * Replaces all the lines in the current `Document` with the value of `text`.
    **/
    this.setValue = function(text) {
        var len = this.getLength();
        this.remove(new Range(0, 0, len, this.getLine(len-1).length));
        this.insert({row: 0, column:0}, text);
    };

    /**
    * Document.getValue() -> String
    *
    * Returns all the lines in the document as a single string, split by the new line character.
    **/
    this.getValue = function() {
        return this.getAllLines().join(this.getNewLineCharacter());
    };

    /**
    * Document.createAnchor(row, column) -> Anchor
    * - row (Number): The row number to use
    * - column (Number): The column number to use
    *
    * Creates a new `Anchor` to define a floating point in the document.
    **/
    this.createAnchor = function(row, column) {
        return new Anchor(this, row, column);
    };

    /** internal, hide
    * Document.$split(text) -> [String]
    * - text (String): The text to work with
    * + ([String]): A String array, with each index containing a piece of the original `text` string.
    *
    * Splits a string of text on any newline (`\n`) or carriage-return ('\r') characters.
    *
    *
    **/

    // check for IE split bug
    if ("aaa".split(/a/).length == 0)
        this.$split = function(text) {
            return text.replace(/\r\n|\r/g, "\n").split("\n");
        }
    else
        this.$split = function(text) {
            return text.split(/\r\n|\r|\n/);
        };

    /** internal, hide
    * Document.$detectNewLine(text) -> Void
    *
    *
    **/
    this.$detectNewLine = function(text) {
        var match = text.match(/^.*?(\r\n|\r|\n)/m);
        if (match) {
            this.$autoNewLine = match[1];
        } else {
            this.$autoNewLine = "\n";
        }
    };

    /**
    * Document.getNewLineCharacter() -> String
    * + (String): If `newLineMode == windows`, `\r\n` is returned.

    *  If `newLineMode == unix`, `\n` is returned.

    *  If `newLineMode == auto`, the value of `autoNewLine` is returned.
    *
    * Returns the newline character that's being used, depending on the value of `newLineMode`.
    *
    *
    *
    **/
    this.getNewLineCharacter = function() {
      switch (this.$newLineMode) {
          case "windows":
              return "\r\n";

          case "unix":
              return "\n";

          case "auto":
              return this.$autoNewLine;
      }
    };

    this.$autoNewLine = "\n";
    this.$newLineMode = "auto";
    /**
     * Document.setNewLineMode(newLineMode) -> Void
     * - newLineMode(String): [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param}
     *
     * [Sets the new line mode.]{: #Document.setNewLineMode.desc}
     **/
    this.setNewLineMode = function(newLineMode) {
        if (this.$newLineMode === newLineMode)
            return;

        this.$newLineMode = newLineMode;
    };

    /**
    * Document.getNewLineMode() -> String
    *
    * [Returns the type of newlines being used; either `windows`, `unix`, or `auto`]{: #Document.getNewLineMode}
    *
    **/
    this.getNewLineMode = function() {
        return this.$newLineMode;
    };

    /**
    * Document.isNewLine(text) -> Boolean
    * - text (String): The text to check
    *
    * Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`).
    *
    **/
    this.isNewLine = function(text) {
        return (text == "\r\n" || text == "\r" || text == "\n");
    };

    /**
    * Document.getLine(row) -> String
    * - row (Number): The row index to retrieve
    *
    * Returns a verbatim copy of the given line as it is in the document
    *
    **/
    this.getLine = function(row) {
        return this.$lines[row] || "";
    };

    /**
    * Document.getLines(firstRow, lastRow) -> [String]
    * - firstRow (Number): The first row index to retrieve
    * - lastRow (Number): The final row index to retrieve
    *
    * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`.
    *
    **/
    this.getLines = function(firstRow, lastRow) {
        return this.$lines.slice(firstRow, lastRow + 1);
    };

    /**
    * Document.getAllLines() -> [String]
    *
    * Returns all lines in the document as string array. Warning: The caller should not modify this array!
    **/
    this.getAllLines = function() {
        return this.getLines(0, this.getLength());
    };

    /**
    * Document.getLength() -> Number
    *
    * Returns the number of rows in the document.
    **/
    this.getLength = function() {
        return this.$lines.length;
    };

    /**
    * Document.getTextRange(range) -> String
    * - range (Range): The range to work with
    *
    * [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc}
    **/
    this.getTextRange = function(range) {
        if (range.start.row == range.end.row) {
            return this.$lines[range.start.row].substring(range.start.column,
                                                         range.end.column);
        }
        else {
            var lines = this.getLines(range.start.row+1, range.end.row-1);
            lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column));
            lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column));
            return lines.join(this.getNewLineCharacter());
        }
    };

    /** internal, hide
    * Document.$clipPosition(position) -> Number
    *
    *
    **/
    this.$clipPosition = function(position) {
        var length = this.getLength();
        if (position.row >= length) {
            position.row = Math.max(0, length - 1);
            position.column = this.getLine(length-1).length;
        }
        return position;
    };

    /**
    * Document.insert(position, text) -> Number
    * - position (Number): The position to start inserting at
    * - text (String): A chunk of text to insert
    * + (Number): The position of the last line of `text`. If the length of `text` is 0, this function simply returns `position`.
    * Inserts a block of `text` and the indicated `position`.
    *
    *
    **/
    this.insert = function(position, text) {
        if (!text || text.length === 0)
            return position;

        position = this.$clipPosition(position);

        // only detect new lines if the document has no line break yet
        if (this.getLength() <= 1)
            this.$detectNewLine(text);

        var lines = this.$split(text);
        var firstLine = lines.splice(0, 1)[0];
        var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];

        position = this.insertInLine(position, firstLine);
        if (lastLine !== null) {
            position = this.insertNewLine(position); // terminate first line
            position = this.insertLines(position.row, lines);
            position = this.insertInLine(position, lastLine || "");
        }
        return position;
    };

    /**
    * Document.insertLines(row, lines) -> Object
    * - row (Number): The index of the row to insert at
    * - lines (Array): An array of strings
    * + (Object): Returns an object containing the final row and column, like this:

    *   ```{row: endRow, column: 0}```

    *   If `lines` is empty, this function returns an object containing the current row, and column, like this:

    *   ```{row: row, column: 0}```
    *
    * Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
    *
    *
    **/
    this.insertLines = function(row, lines) {
        if (lines.length == 0)
            return {row: row, column: 0};

        // apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF)
        // to circumvent that we have to break huge inserts into smaller chunks here
        if (lines.length > 0xFFFF) {
            var end = this.insertLines(row, lines.slice(0xFFFF));
            lines = lines.slice(0, 0xFFFF);
        }

        var args = [row, 0];
        args.push.apply(args, lines);
        this.$lines.splice.apply(this.$lines, args);

        var range = new Range(row, 0, row + lines.length, 0);
        var delta = {
            action: "insertLines",
            range: range,
            lines: lines
        };
        this._emit("change", { data: delta });
        return end || range.end;
    };

    /**
    * Document.insertNewLine(position) -> Object
    * - position (String): The position to insert at
    * + (Object): Returns an object containing the final row and column, like this:

    *    ```{row: endRow, column: 0}```
    *
    * Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event.
    *
    *
    *
    **/
    this.insertNewLine = function(position) {
        position = this.$clipPosition(position);
        var line = this.$lines[position.row] || "";

        this.$lines[position.row] = line.substring(0, position.column);
        this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));

        var end = {
            row : position.row + 1,
            column : 0
        };

        var delta = {
            action: "insertText",
            range: Range.fromPoints(position, end),
            text: this.getNewLineCharacter()
        };
        this._emit("change", { data: delta });

        return end;
    };

    /**
    * Document.insertInLine(position, text) -> Object | Number
    * - position (Number): The position to insert at
    * - text (String): A chunk of text
    * + (Object): Returns an object containing the final row and column, like this:

    *     ```{row: endRow, column: 0}```
    * + (Number): If `text` is empty, this function returns the value of `position`
    *
    * Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
    *
    *
    *
    **/
    this.insertInLine = function(position, text) {
        if (text.length == 0)
            return position;

        var line = this.$lines[position.row] || "";

        this.$lines[position.row] = line.substring(0, position.column) + text
                + line.substring(position.column);

        var end = {
            row : position.row,
            column : position.column + text.length
        };

        var delta = {
            action: "insertText",
            range: Range.fromPoints(position, end),
            text: text
        };
        this._emit("change", { data: delta });

        return end;
    };

    /**
    * Document.remove(range) -> Object
    * - range (Range): A specified Range to remove
    * + (Object): Returns the new `start` property of the range, which contains `startRow` and `startColumn`. If `range` is empty, this function returns the unmodified value of `range.start`.
    *
    * Removes the `range` from the document.
    *
    *
    **/
    this.remove = function(range) {
        // clip to document
        range.start = this.$clipPosition(range.start);
        range.end = this.$clipPosition(range.end);

        if (range.isEmpty())
            return range.start;

        var firstRow = range.start.row;
        var lastRow = range.end.row;

        if (range.isMultiLine()) {
            var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
            var lastFullRow = lastRow - 1;

            if (range.end.column > 0)
                this.removeInLine(lastRow, 0, range.end.column);

            if (lastFullRow >= firstFullRow)
                this.removeLines(firstFullRow, lastFullRow);

            if (firstFullRow != firstRow) {
                this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
                this.removeNewLine(range.start.row);
            }
        }
        else {
            this.removeInLine(firstRow, range.start.column, range.end.column);
        }
        return range.start;
    };

    /**
    * Document.removeInLine(row, startColumn, endColumn) -> Object
    * - row (Number): The row to remove from
    * - startColumn (Number): The column to start removing at
    * - endColumn (Number): The column to stop removing at
    * + (Object): Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.
If `startColumn` is equal to `endColumn`, this function returns nothing.
    *
    * Removes the specified columns from the `row`. This method also triggers the `'change'` event.
    *
    *
    **/
    this.removeInLine = function(row, startColumn, endColumn) {
        if (startColumn == endColumn)
            return;

        var range = new Range(row, startColumn, row, endColumn);
        var line = this.getLine(row);
        var removed = line.substring(startColumn, endColumn);
        var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
        this.$lines.splice(row, 1, newLine);

        var delta = {
            action: "removeText",
            range: range,
            text: removed
        };
        this._emit("change", { data: delta });
        return range.start;
    };

    /**
    * Document.removeLines(firstRow, lastRow) -> [String]
    * - firstRow (Number): The first row to be removed
    * - lastRow (Number): The last row to be removed
    * + ([String]): Returns all the removed lines.
    *
    * Removes a range of full lines. This method also triggers the `'change'` event.
    *
    *
    **/
    this.removeLines = function(firstRow, lastRow) {
        var range = new Range(firstRow, 0, lastRow + 1, 0);
        var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);

        var delta = {
            action: "removeLines",
            range: range,
            nl: this.getNewLineCharacter(),
            lines: removed
        };
        this._emit("change", { data: delta });
        return removed;
    };

    /**
    * Document.removeNewLine(row) -> Void
    * - row (Number): The row to check
    *
    * Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
    *
    **/
    this.removeNewLine = function(row) {
        var firstLine = this.getLine(row);
        var secondLine = this.getLine(row+1);

        var range = new Range(row, firstLine.length, row+1, 0);
        var line = firstLine + secondLine;

        this.$lines.splice(row, 2, line);

        var delta = {
            action: "removeText",
            range: range,
            text: this.getNewLineCharacter()
        };
        this._emit("change", { data: delta });
    };

    /**
    * Document.replace(range, text) -> Object
    * - range (Range): A specified Range to replace
    * - text (String): The new text to use as a replacement
    * + (Object): Returns an object containing the final row and column, like this:
    *     {row: endRow, column: 0}
    * If the text and range are empty, this function returns an object containing the current `range.start` value.
    * If the text is the exact same as what currently exists, this function returns an object containing the current `range.end` value.
    *
    * Replaces a range in the document with the new `text`.
    *
    **/
    this.replace = function(range, text) {
        if (text.length == 0 && range.isEmpty())
            return range.start;

        // Shortcut: If the text we want to insert is the same as it is already
        // in the document, we don't have to replace anything.
        if (text == this.getTextRange(range))
            return range.end;

        this.remove(range);
        if (text) {
            var end = this.insert(range.start, text);
        }
        else {
            end = range.start;
        }

        return end;
    };

    /**
    * Document.applyDeltas(deltas) -> Void
    *
    * Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
    **/
    this.applyDeltas = function(deltas) {
        for (var i=0; i<deltas.length; i++) {
            var delta = deltas[i];
            var range = Range.fromPoints(delta.range.start, delta.range.end);

            if (delta.action == "insertLines")
                this.insertLines(range.start.row, delta.lines);
            else if (delta.action == "insertText")
                this.insert(range.start, delta.text);
            else if (delta.action == "removeLines")
                this.removeLines(range.start.row, range.end.row - 1);
            else if (delta.action == "removeText")
                this.remove(range);
        }
    };

    /**
    * Document.revertDeltas(deltas) -> Void
    *
    * Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
    **/
    this.revertDeltas = function(deltas) {
        for (var i=deltas.length-1; i>=0; i--) {
            var delta = deltas[i];

            var range = Range.fromPoints(delta.range.start, delta.range.end);

            if (delta.action == "insertLines")
                this.removeLines(range.start.row, range.end.row - 1);
            else if (delta.action == "insertText")
                this.remove(range);
            else if (delta.action == "removeLines")
                this.insertLines(range.start.row, delta.lines);
            else if (delta.action == "removeText")
                this.insert(range.start, delta.text);
        }
    };

}).call(Document.prototype);

exports.Document = Document;
});


text:
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "AssetUserData.generated.h"

/**
 * Object that can be subclassed to store custom data on Unreal asset objects.
 */
UCLASS(DefaultToInstanced)
class ENGINE_API UAssetUserData
	: public UObject
{
	GENERATED_UCLASS_BODY()

	/** used for debugging UAssetUserData data in editor */
	virtual void Draw(class FPrimitiveDrawInterface* PDI, const class FSceneView* View) const {}
};


text:
/*
 *
 * University of Luxembourg
 * Laboratory of Algorithmics, Cryptology and Security (LACS)
 *
 * FELICS - Fair Evaluation of Lightweight Cryptographic Systems
 *
 * Copyright (C) 2015 University of Luxembourg
 *
 * Written in 2015 by Daniel Dinu <dumitru-daniel.dinu@uni.lu>
 *
 * This file is part of FELICS.
 *
 * FELICS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * FELICS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <stdint.h>

#include "test_vectors.h"

/*
 *
 * Test vectors
 *
 */
const uint8_t expectedPlaintext[BLOCK_SIZE] =
{
    0xb8, 0x23, 0x28, 0x26,
    0xfd, 0x5e, 0x40, 0x5e,
    0x69, 0xa3, 0x01, 0xa9,
    0x78, 0xea, 0x7a, 0xd8
};

const uint8_t expectedKey[KEY_SIZE] =
{
    0x56, 0x09, 0xe9, 0x68,
    0x5f, 0x58, 0xe3, 0x29,
    0x40, 0xec, 0xec, 0x98,
    0xc5, 0x22, 0x98, 0x2f
};

const uint8_t expectedCiphertext[BLOCK_SIZE] =
{
	0xd5, 0x60, 0x8d, 0x4d,
	0xa2, 0xbf, 0x34, 0x7b,
	0xab, 0xf8, 0x77, 0x2f,
	0xdf, 0xed, 0xde, 0x07
};


text:
import { Gain } from "../../core/context/Gain";
import { ToneAudioNode, ToneAudioNodeOptions } from "../../core/context/ToneAudioNode";
import { Frequency, Positive } from "../../core/type/Units";
import { optionsFromArguments } from "../../core/util/Defaults";
import { readOnly, writable } from "../../core/util/Interface";
import { Signal } from "../../signal/Signal";
import { Filter } from "../filter/Filter";

interface MultibandSplitOptions extends ToneAudioNodeOptions {
	Q: Positive;
	lowFrequency: Frequency;
	highFrequency: Frequency;
}

/**
 * Split the incoming signal into three bands (low, mid, high)
 * with two crossover frequency controls.
 * ```
 *            +----------------------+
 *          +-> input < lowFrequency +------------------> low
 *          | +----------------------+
 *          |
 *          | +--------------------------------------+
 * input ---+-> lowFrequency < input < highFrequency +--> mid
 *          | +--------------------------------------+
 *          |
 *          | +-----------------------+
 *          +-> highFrequency < input +-----------------> high
 *            +-----------------------+
 * ```
 * @category Component
 */
export class MultibandSplit extends ToneAudioNode<MultibandSplitOptions> {

	readonly name: string = "MultibandSplit";

	/**
	 * the input
	 */
	readonly input = new Gain({ context: this.context });

	/**
	 * no output node, use either low, mid or high outputs
	 */
	readonly output = undefined;

	/**
	 * The low band.
	 */
	readonly low = new Filter({
		context: this.context,
		frequency: 0,
		type: "lowpass",
	});

	/**
	 * the lower filter of the mid band
	 */
	private _lowMidFilter = new Filter({
		context: this.context,
		frequency: 0,
		type: "highpass",
	});

	/**
	 * The mid band output.
	 */
	readonly mid = new Filter({
		context: this.context,
		frequency: 0,
		type: "lowpass",
	});

	/**
	 * The high band output.
	 */
	readonly high = new Filter({
		context: this.context,
		frequency: 0,
		type: "highpass",
	});

	/**
	 * The low/mid crossover frequency.
	 */
	readonly lowFrequency: Signal<"frequency">;

	/**
	 * The mid/high crossover frequency.
	 */
	readonly highFrequency: Signal<"frequency">;

	protected _internalChannels = [this.low, this.mid, this.high];

	/**
	 * The Q or Quality of the filter
	 */
	readonly Q: Signal<"positive">;

	/**
	 * @param lowFrequency the low/mid crossover frequency
	 * @param highFrequency the mid/high crossover frequency
	 */
	constructor(lowFrequency?: Frequency, highFrequency?: Frequency);
	constructor(options?: Partial<MultibandSplitOptions>);
	constructor() {
		super(optionsFromArguments(MultibandSplit.getDefaults(), arguments, ["lowFrequency", "highFrequency"]));
		const options = optionsFromArguments(MultibandSplit.getDefaults(), arguments, ["lowFrequency", "highFrequency"]);

		this.lowFrequency = new Signal({
			context: this.context,
			units: "frequency",
			value: options.lowFrequency,
		});

		this.highFrequency = new Signal({
			context: this.context,
			units: "frequency",
			value: options.highFrequency,
		});

		this.Q = new Signal({
			context: this.context,
			units: "positive",
			value: options.Q,
		});

		this.input.fan(this.low, this.high);
		this.input.chain(this._lowMidFilter, this.mid);
		// the frequency control signal
		this.lowFrequency.fan(this.low.frequency, this._lowMidFilter.frequency);
		this.highFrequency.fan(this.mid.frequency, this.high.frequency);
		// the Q value
		this.Q.connect(this.low.Q);
		this.Q.connect(this._lowMidFilter.Q);
		this.Q.connect(this.mid.Q);
		this.Q.connect(this.high.Q);

		readOnly(this, ["high", "mid", "low", "highFrequency", "lowFrequency"]);
	}

	static getDefaults(): MultibandSplitOptions {
		return Object.assign(ToneAudioNode.getDefaults(), {
			Q: 1,
			highFrequency: 2500,
			lowFrequency: 400,
		});
	}

	/**
	 * Clean up.
	 */
	dispose(): this {
		super.dispose();
		writable(this, ["high", "mid", "low", "highFrequency", "lowFrequency"]);
		this.low.dispose();
		this._lowMidFilter.dispose();
		this.mid.dispose();
		this.high.dispose();
		this.lowFrequency.dispose();
		this.highFrequency.dispose();
		this.Q.dispose();
		return this;
	}

}


text:
#include "lib.h"

pool_t default_pool = &static_system_pool;

void *i_malloc(size_t size)
{
	return p_malloc(default_pool, size);
}

void *i_realloc(void *mem, size_t old_size, size_t new_size)
{
	return p_realloc(default_pool, mem, old_size, new_size);
}

char *i_strdup(const char *str)
{
	return p_strdup(default_pool, str);
}

char *i_strdup_empty(const char *str)
{
	return p_strdup_empty(default_pool, str);
}

char *i_strdup_until(const void *str, const void *end)
{
	return p_strdup_until(default_pool, str, end);
}

char *i_strndup(const void *str, size_t max_chars)
{
	return p_strndup(default_pool, str, max_chars);
}

char *i_strdup_printf(const char *format, ...)
{
	va_list args;
	char *ret;

	va_start(args, format);
	ret = p_strdup_vprintf(default_pool, format, args);
	va_end(args);
	return ret;
}

char *i_strdup_vprintf(const char *format, va_list args)
{
	return p_strdup_vprintf(default_pool, format, args);
}

char *i_strconcat(const char *str1, ...)
{
	va_list args;
	char *ret;
	size_t len;

	va_start(args, str1);

	T_BEGIN {
		const char *temp = vstrconcat(str1, args, &len);

		if (temp == NULL)
			ret = NULL;
		else {
			t_buffer_alloc(len);
			ret = p_malloc(default_pool, len);
			memcpy(ret, temp, len);
		}
	} T_END;

	va_end(args);
	return ret;
}


text:
FactoryGirl.define do
  factory :course_user_achievement, class: Course::UserAchievement.name do
    course_user
    achievement
    obtained_at '2015-10-11 23:20:07'
  end
end


text:
require 'eschaton/game'

describe Eschaton::Game do

	before do
		@eschaton = Eschaton::Game.new
	end

	# context "being played" do
	# 	before do
	# 		@combatant = Eschaton.combatants.sample
	# 	end

	# 	it "critical hit if higher accuracy" do
	# 		GameMaster.stub(:accuracy) {19}
	# 		@eschaton.play(2)
	# 		expect(combatant.inddir).to eq((inddir + 50) * 2)
	# 	end

	# 	it "normal damage if medium accuracy" do
	# 		GameMaster.stub(:accuracy) {10}
	# 		@eschaton.play(2)
	# 		expect(@combatant.inddir).to eq((@inddir + 30) * 2)
	# 	end

	# 	it "misses if a low accuracy" do
	# 		GameMaster.stub(:accuracy) {3}
	# 		@eschaton.play(2)
	# 		expect(@combatant.inddir).to eq(0)
	# 	end
	# end

	# context "all Combatants at DEFCON 1" do

	# 	before do
	# 		@eschaton.combatants.map! { |c| c.defcon = 1 }
	# 	end

	# 	it "changes game beanie status to 'UTTER GLOBAL CRISIS'" do
	# 		expect(@eschaton.beanie_status).to eq('UTTER GLOBAL CRISIS')
	# 	end

	# end

	# it "should have a minimum of 3 rounds"

	# it "should have a maximum of 400 5-megaton warheads to distribute"

	# it "should distribute megatonnage to combatants"

	# it "should have a beanie status to start the game"

	# "eschaton beanie status at 'Cessation of Hostilities'"

	# "eschaton beanie status at 'Utter Global Crisis'"

	# 	it "should raise all combatants DEFCON levels to 1"

end


text:
I'm in the winter of my December moon
Where Little Spirit Moon, Mnid-ooGii-zoons
The Twelfth moon of Creation lives
Into the long night and short day
Where I say Miigwetch to my season
Diminishing into the West
And my life turns again into beginnings
As she the East Direction blows away my cycle
And my seeds become an empty mask of what went before
Pass on through the West Door
Little Spirit Moon knows the cold of my season
With my children grown and growing all around my directions
Eagle protects and carries messages and prayers down the Blue way
So I know the turns of this Earth will see many more creations
Along my Red Road
Beyond the sweet ones who once grew inside my belly.

LauraLee K. Harris


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>info.cukes</groupId>
        <artifactId>java-wicket-selenium</artifactId>
        <version>1.1.2-SNAPSHOT</version>
    </parent>
    <artifactId>java-wicket-test</artifactId>
    <name>Examples: A Selenium WebDriver example testing a Wicket application</name>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.12.4</version>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>1.3.0</version>
                <executions>
                    <execution>
                        <id>start-servlet-engine</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-servlet-engine</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <container>
                        <containerId>jetty9x</containerId>
                        <type>embedded</type>
                    </container>
                    <deployables>
                        <deployable>
                            <groupId>info.cukes</groupId>
                            <artifactId>java-wicket-main</artifactId>
                            <type>war</type>
                        </deployable>
                    </deployables>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>java-wicket-main</artifactId>
            <version>1.1.2-SNAPSHOT</version>
            <type>war</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.26.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>


text:
class NewsDataManager {
public:
  NewsDataManager();
  ~NewsDataManager();

  // Initialize news database manager.
  // "sitedata_manager" is the manager used to manage site database.
  // "dir" is a sub-directory of site data directory.
  bool Initialize(SiteDataManager* sitedata_manager, const std::string& dir);

  // Update news database.
  bool UpdateData();

  // Get file containing latest URL information.
  std::string GetDataFile();

  // Get directory (full path) containing the news database.
  std::string GetDirectory();

private:
  // Constants for file name.
  static const std::string kFprintFile;
  static const std::string kDataFile;
  static const int kMaxNewsEntry;

  // Comparer used to sort news records.
  class RecordComparer {
  public:
    bool operator()(const VisitingRecord& a, const VisitingRecord& b) const {
      return std::min<time_t>(a.first_appear, a.last_change) >
        std::min<time_t>(b.first_appear, b.last_change);
    }
  };

  typedef std::priority_queue<VisitingRecord, std::vector<VisitingRecord>,
                              RecordComparer> Heap;

  // Add url records in file to heap.
  bool AddRecordToHeap(const std::string& file, Heap* heap);

  // Write url records in heap to file.
  // The heap should be cleared after saving.
  bool SaveHeap(Heap* heap, const std::string& file);

  // Merge Url fingerprint.
  // "newentry" will contain detailed new url information.
  // "new_fp" is the new fingerprint file.
  // "old_fp" is the old fingerprint file.
  // "srcs" are the temporary site data file.
  bool MergeUrlFprint(const std::string& newentry, const std::string& new_fp,
                      const std::string& old_fp,
                      const std::vector<std::string> srcs);

  SiteDataManager* sitedata_manager_;

  // The directory used to hold news database.
  std::string data_dir_;

  // The last update time of news database.
  time_t last_update_;
};

#endif // SITEMAPSERVICE_NEWSDATAMANAGER_H__


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Flora Bohemiae et Moraviae Exsiccata 43: no. 2119 (1925)

#### Original name
Sphaerella gypsophilicola Hollós

### Remarks
null