/* Declarations for internal libc locale interfaces
   Copyright (C) 1995-2014 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library 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
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <http://www.gnu.org/licenses/>.  */

#ifndef THIRD_PARTY_GLIBC_LOCALES_COMMON_LOCALEINFO_H
#define THIRD_PARTY_GLIBC_LOCALES_COMMON_LOCALEINFO_H

#define __need_NULL
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <time.h>

#include "third_party/glibc_locales/glibc_locales.h"

/* Definition of category symbol values, from glibc's bits/locale.h.  */
#define GOOGLE_LC_CTYPE 0
#define GOOGLE_LC_COLLATE 1
#define GOOGLE_LC_LAST 2

/* Structure for storing locales, from glibc's locale/xlocale.h.  */
struct google_locale_struct {
  /* Per-category data for this locale.  */
  struct google_locale_data *category_data[GOOGLE_LC_LAST];

  /* To increase the speed of this solution we add some special members.  */
  const unsigned short int *ctype_b;
  const int *ctype_tolower;
  const int *ctype_toupper;

  /* A pointer to an accompanying glibc locale, if we have one.  We store
     this as an opaque pointer to avoid needing to pull locale.h into
     everything that uses this header.  */
  void *glibc_locale;
};

/* Magic number at the beginning of a locale data file for CATEGORY.  */
#define LIMAGIC(category)                                             \
  (category == LC_COLLATE ? ((unsigned int)(0x20051014 ^ (category))) \
   : category == LC_CTYPE ? ((unsigned int)(0x20090720 ^ (category))) \
                          : ((unsigned int)(0x20031115 ^ (category))))

/* Two special weight constants for the collation data.  */
#define IGNORE_CHAR 2

/* Structure describing locale data in core for a category.  */
struct google_locale_data {
  char *name;            /* The locale name that this struct represents.  */
  unsigned int nstrings; /* Number of values below.  */
  union locale_data_value {
    const uint32_t *wstr;
    const char *string;
    unsigned int word; /* Note endian issues vs 64-bit pointers.  */
  } values[];          /* Items, usually pointers into `filedata'.  */
};

/* This alignment is used for 32-bit integers in locale files, both
   those that are explicitly int32_t or uint32_t and those that are
   wchar_t, regardless of the (possibly smaller) alignment required
   for such integers on a particular host.  */
#define LOCFILE_ALIGN sizeof(int32_t)
#define LOCFILE_ALIGN_MASK (LOCFILE_ALIGN - 1)
#define LOCFILE_ALIGN_UP(x) (((x) + LOCFILE_ALIGN - 1) & ~LOCFILE_ALIGN_MASK)
#define LOCFILE_ALIGNED_P(x) (((x) & LOCFILE_ALIGN_MASK) == 0)

/* We know three kinds of collation sorting rules.  */
enum coll_sort_rule {
  illegal_0__,
  sort_forward,
  sort_backward,
  illegal_3__,
  sort_position,
  sort_forward_position,
  sort_backward_position,
  sort_mask
};

/* We can map the types of the entries into a few categories.  */
enum value_type {
  none,
  string,
  stringarray,
  byte,
  bytearray,
  word,
  stringlist,
  wordarray,
  wstring,
  wstringarray,
  wstringlist
};

/* LC_CTYPE specific:
   Hardwired indices for standard wide character translation mappings.  */
enum { GOOGLE_TOW_toupper = 0, GOOGLE_TOW_tolower = 1 };

/* LC_CTYPE specific:
   Access a wide character class with a single character index.
   _ISCTYPE (c, desc) = iswctype (btowc (c), desc).
   c must be an `unsigned char'.  desc must be a nonzero wctype_t.  */
#define _ISCTYPE(c, desc) \
  (((((const uint32_t *)(desc)) - 8)[(c) >> 5] >> ((c) & 0x1f)) & 1)

/* In-archive data structure containing all information for a locale.  */
struct locrecent {
  uint32_t refs; /* # of namehashent records that point here */
  struct {
    uint32_t offset;
    uint32_t len;
  } record[GOOGLE_LC_LAST];
};

/* Locate the archived locale data for a given name.  Returns NULL
   if the data cannot be found.  */
struct locrecent *google_find_locale_data(const char *archive_data,
                                          const char *name);

/* Validate the contents of a locale file and set up the in-core
   data structure to point into the data.  */
extern struct google_locale_data *google_load_locale_data(const char *name,
                                                          int category,
                                                          const void *data,
                                                          size_t datasize);

/* Add the codeset into a locale name, if it does not already contain one,
   to ensure that glibc loads the same locale that we do.  */
char *google_add_codeset_to_locale_name(const char *archive_data,
                                        const char *name);

#endif /* THIRD_PARTY_GLIBC_LOCALES_SRC_LOCALE_LOCALEINFO_H  */
