Back to index

courier  0.68.2
Classes | Defines | Functions
loadinfo.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  loaded_l10nfile

Defines

#define internal_function
#define LIBINTL_DLL_EXPORTED
#define __builtin_expect(expr, val)   (expr)
#define PATH_SEPARATOR   ':'
#define XPG_NORM_CODESET   1
#define XPG_CODESET   2
#define XPG_TERRITORY   4
#define XPG_MODIFIER   8

Functions

const char * _nl_normalize_codeset (const char *codeset, size_t name_len)
struct loaded_l10nfile_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, const char *dirlist, size_t dirlist_len, int mask, const char *language, const char *territory, const char *codeset, const char *normalized_codeset, const char *modifier, const char *filename, int do_allocate)
LIBINTL_DLL_EXPORTED const char * _nl_expand_alias (const char *name)
int _nl_explode_name (char *name, const char **language, const char **modifier, const char **territory, const char **codeset, const char **normalized_codeset)

Class Documentation

struct loaded_l10nfile

Definition at line 65 of file loadinfo.h.

Collaboration diagram for loaded_l10nfile:
Class Members
const void * data
int decided
const char * filename
struct loaded_l10nfile * next
struct loaded_l10nfile * successor

Define Documentation

#define __builtin_expect (   expr,
  val 
)    (expr)

Definition at line 46 of file loadinfo.h.

Definition at line 36 of file loadinfo.h.

Definition at line 40 of file loadinfo.h.

#define PATH_SEPARATOR   ':'

Definition at line 55 of file loadinfo.h.

#define XPG_CODESET   2

Definition at line 60 of file loadinfo.h.

#define XPG_MODIFIER   8

Definition at line 62 of file loadinfo.h.

#define XPG_NORM_CODESET   1

Definition at line 59 of file loadinfo.h.

#define XPG_TERRITORY   4

Definition at line 61 of file loadinfo.h.


Function Documentation

LIBINTL_DLL_EXPORTED const char* _nl_expand_alias ( const char *  name)

Definition at line 156 of file localealias.c.

{
  static const char *locale_alias_path;
  struct alias_map *retval;
  const char *result = NULL;
  size_t added;

  __libc_lock_lock (lock);

  if (locale_alias_path == NULL)
    locale_alias_path = LOCALE_ALIAS_PATH;

  do
    {
      struct alias_map item;

      item.alias = name;

      if (nmap > 0)
       retval = (struct alias_map *) bsearch (&item, map, nmap,
                                          sizeof (struct alias_map),
                                          (int (*) (const void *,
                                                  const void *)
                                          ) alias_compare);
      else
       retval = NULL;

      /* We really found an alias.  Return the value.  */
      if (retval != NULL)
       {
         result = retval->value;
         break;
       }

      /* Perhaps we can find another alias file.  */
      added = 0;
      while (added == 0 && locale_alias_path[0] != '\0')
       {
         const char *start;

         while (locale_alias_path[0] == PATH_SEPARATOR)
           ++locale_alias_path;
         start = locale_alias_path;

         while (locale_alias_path[0] != '\0'
               && locale_alias_path[0] != PATH_SEPARATOR)
           ++locale_alias_path;

         if (start < locale_alias_path)
           added = read_alias_file (start, locale_alias_path - start);
       }
    }
  while (added != 0);

  __libc_lock_unlock (lock);

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int _nl_explode_name ( char *  name,
const char **  language,
const char **  modifier,
const char **  territory,
const char **  codeset,
const char **  normalized_codeset 
)

Definition at line 56 of file explodename.c.

{
  char *cp;
  int mask;

  *modifier = NULL;
  *territory = NULL;
  *codeset = NULL;
  *normalized_codeset = NULL;

  /* Now we determine the single parts of the locale name.  First
     look for the language.  Termination symbols are `_', '.', and `@'.  */
  mask = 0;
  *language = cp = name;
  cp = _nl_find_language (*language);

  if (*language == cp)
    /* This does not make sense: language has to be specified.  Use
       this entry as it is without exploding.  Perhaps it is an alias.  */
    cp = strchr (*language, '\0');
  else
    {
      if (cp[0] == '_')
       {
         /* Next is the territory.  */
         cp[0] = '\0';
         *territory = ++cp;

         while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@')
           ++cp;

         mask |= XPG_TERRITORY;
       }

      if (cp[0] == '.')
       {
         /* Next is the codeset.  */
         cp[0] = '\0';
         *codeset = ++cp;

         while (cp[0] != '\0' && cp[0] != '@')
           ++cp;

         mask |= XPG_CODESET;

         if (*codeset != cp && (*codeset)[0] != '\0')
           {
             *normalized_codeset = _nl_normalize_codeset (*codeset,
                                                    cp - *codeset);
             if (*normalized_codeset == NULL)
              return -1;
             else if (strcmp (*codeset, *normalized_codeset) == 0)
              free ((char *) *normalized_codeset);
             else
              mask |= XPG_NORM_CODESET;
           }
       }
    }

  if (cp[0] == '@')
    {
      /* Next is the modifier.  */
      cp[0] = '\0';
      *modifier = ++cp;

      if (cp[0] != '\0')
       mask |= XPG_MODIFIER;
    }

  if (*territory != NULL && (*territory)[0] == '\0')
    mask &= ~XPG_TERRITORY;

  if (*codeset != NULL && (*codeset)[0] == '\0')
    mask &= ~XPG_CODESET;

  return mask;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct loaded_l10nfile* _nl_make_l10nflist ( struct loaded_l10nfile **  l10nfile_list,
const char *  dirlist,
size_t  dirlist_len,
int  mask,
const char *  language,
const char *  territory,
const char *  codeset,
const char *  normalized_codeset,
const char *  modifier,
const char *  filename,
int  do_allocate 
) [read]

Definition at line 175 of file l10nflist.c.

{
  char *abs_filename;
  struct loaded_l10nfile **lastp;
  struct loaded_l10nfile *retval;
  char *cp;
  size_t dirlist_count;
  size_t entries;
  int cnt;

  /* If LANGUAGE contains an absolute directory specification, we ignore
     DIRLIST.  */
  if (IS_ABSOLUTE_PATH (language))
    dirlist_len = 0;

  /* Allocate room for the full file name.  */
  abs_filename = (char *) malloc (dirlist_len
                              + strlen (language)
                              + ((mask & XPG_TERRITORY) != 0
                                 ? strlen (territory) + 1 : 0)
                              + ((mask & XPG_CODESET) != 0
                                 ? strlen (codeset) + 1 : 0)
                              + ((mask & XPG_NORM_CODESET) != 0
                                 ? strlen (normalized_codeset) + 1 : 0)
                              + ((mask & XPG_MODIFIER) != 0
                                 ? strlen (modifier) + 1 : 0)
                              + 1 + strlen (filename) + 1);

  if (abs_filename == NULL)
    return NULL;

  /* Construct file name.  */
  cp = abs_filename;
  if (dirlist_len > 0)
    {
      memcpy (cp, dirlist, dirlist_len);
      __argz_stringify (cp, dirlist_len, PATH_SEPARATOR);
      cp += dirlist_len;
      cp[-1] = '/';
    }

  cp = stpcpy (cp, language);

  if ((mask & XPG_TERRITORY) != 0)
    {
      *cp++ = '_';
      cp = stpcpy (cp, territory);
    }
  if ((mask & XPG_CODESET) != 0)
    {
      *cp++ = '.';
      cp = stpcpy (cp, codeset);
    }
  if ((mask & XPG_NORM_CODESET) != 0)
    {
      *cp++ = '.';
      cp = stpcpy (cp, normalized_codeset);
    }
  if ((mask & XPG_MODIFIER) != 0)
    {
      *cp++ = '@';
      cp = stpcpy (cp, modifier);
    }

  *cp++ = '/';
  stpcpy (cp, filename);

  /* Look in list of already loaded domains whether it is already
     available.  */
  lastp = l10nfile_list;
  for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
    if (retval->filename != NULL)
      {
       int compare = strcmp (retval->filename, abs_filename);
       if (compare == 0)
         /* We found it!  */
         break;
       if (compare < 0)
         {
           /* It's not in the list.  */
           retval = NULL;
           break;
         }

       lastp = &retval->next;
      }

  if (retval != NULL || do_allocate == 0)
    {
      free (abs_filename);
      return retval;
    }

  dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1);

  /* Allocate a new loaded_l10nfile.  */
  retval =
    (struct loaded_l10nfile *)
    malloc (sizeof (*retval)
           + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
              * sizeof (struct loaded_l10nfile *)));
  if (retval == NULL)
    {
      free (abs_filename);
      return NULL;
    }

  retval->filename = abs_filename;

  /* We set retval->data to NULL here; it is filled in later.
     Setting retval->decided to 1 here means that retval does not
     correspond to a real file (dirlist_count > 1) or is not worth
     looking up (if an unnormalized codeset was specified).  */
  retval->decided = (dirlist_count > 1
                   || ((mask & XPG_CODESET) != 0
                      && (mask & XPG_NORM_CODESET) != 0));
  retval->data = NULL;

  retval->next = *lastp;
  *lastp = retval;

  entries = 0;
  /* Recurse to fill the inheritance list of RETVAL.
     If the DIRLIST is a real list (i.e. DIRLIST_COUNT > 1), the RETVAL
     entry does not correspond to a real file; retval->filename contains
     colons.  In this case we loop across all elements of DIRLIST and
     across all bit patterns dominated by MASK.
     If the DIRLIST is a single directory or entirely redundant (i.e.
     DIRLIST_COUNT == 1), we loop across all bit patterns dominated by
     MASK, excluding MASK itself.
     In either case, we loop down from MASK to 0.  This has the effect
     that the extra bits in the locale name are dropped in this order:
     first the modifier, then the territory, then the codeset, then the
     normalized_codeset.  */
  for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt)
    if ((cnt & ~mask) == 0
       && !((cnt & XPG_CODESET) != 0 && (cnt & XPG_NORM_CODESET) != 0))
      {
       if (dirlist_count > 1)
         {
           /* Iterate over all elements of the DIRLIST.  */
           char *dir = NULL;

           while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
                 != NULL)
             retval->successor[entries++]
              = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1,
                                  cnt, language, territory, codeset,
                                  normalized_codeset, modifier, filename,
                                  1);
         }
       else
         retval->successor[entries++]
           = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
                              cnt, language, territory, codeset,
                              normalized_codeset, modifier, filename, 1);
      }
  retval->successor[entries] = NULL;

  return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* _nl_normalize_codeset ( const char *  codeset,
size_t  name_len 
)

Definition at line 347 of file l10nflist.c.

{
  size_t len = 0;
  int only_digit = 1;
  char *retval;
  char *wp;
  size_t cnt;

  for (cnt = 0; cnt < name_len; ++cnt)
    if (isalnum ((unsigned char) codeset[cnt]))
      {
       ++len;

       if (isalpha ((unsigned char) codeset[cnt]))
         only_digit = 0;
      }

  retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);

  if (retval != NULL)
    {
      if (only_digit)
       wp = stpcpy (retval, "iso");
      else
       wp = retval;

      for (cnt = 0; cnt < name_len; ++cnt)
       if (isalpha ((unsigned char) codeset[cnt]))
         *wp++ = tolower ((unsigned char) codeset[cnt]);
       else if (isdigit ((unsigned char) codeset[cnt]))
         *wp++ = codeset[cnt];

      *wp = '\0';
    }

  return (const char *) retval;
}

Here is the call graph for this function:

Here is the caller graph for this function: