localelistfree(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

localelistfree(3c)

localelist(3C)           Standard C Library Functions           localelist(3C)

NAME
       localelist, localelistfree - query installed locales

SYNOPSIS
       #include <locale.h>

       int localelist(lclist_t **list, int flag);


       void localelistfree(lclist_t *list);

DESCRIPTION
       The  localelist()  function  checks on the current system and returns a
       list of installed locales by allocating a memory for the list and  data
       field of lclist_t type components as needed.


       The  localelist()  function is always guaranteed to return at least the
       "C" locale in the list, unless there is an error.


       When there is no memory that can be allocated, the  localelist()  func‐
       tion deallocates any memory blocks so far allocated in the list and in‐
       stead  sets  the  corresponding pointers to NULL, as needed, before re‐
       turning -1 and setting errno to ENOMEM.


       The data field of lclist_t type is like the following:

       char *locale    Locale name as a string that can be used  to  set  LANG
                       environment variable.



       The  following values can be bitwise-inclusive-OR combined and provided
       to the function via flag argument:

       LCLIST_QUERY

           Check on the current system and return the list  of  installed  lo‐
           cales.

           By default, "C" and "POSIX" are always included in the list.

           The  list  returned will be in ascending order based on 7-bit ASCII
           character codes of the locale name.


       LCLIST_VALIDATE

           Normally, when a locale is found from file system hierarchy, by de‐
           fault, it is not validated and added to the list of  installed  lo‐
           cales.

           If  this  flag  value  is specified, however, the function actually
           validates the locale to find out if the locale is  actually  usable
           or  not  and  add  to the list only if it is actually usable. (This
           prevents any possible bogus locales being added to the list.)


       LCLIST_KEEP

           When LCLIST_VALIDATE is used, after a locale is validated, the  lo‐
           cale  loaded  into  system memory is marked to be unloaded from the
           memory. However, if this flag value is specified, the function does
           not do that so that the locale can be reused later.

           When you're calling localelist() multiple times  with  LCLIST_VALI‐
           DATE and if you have enough memory space, using this flag may yield
           a better performance in the subsequent calls to the function.

           When LCLIST_VALIDATE is not specified, this flag is ignored.


       LCLIST_DO_NOT_INCLUDE_POSIX

           If this flag is set, "POSIX" locale is not included in the list.


       LCLIST_EXCLUDE_SYMBOLIC_LINKS

           Occasionally,  locales  are  presented  by using a symbolic link to
           other locales as an alias. When this flag value is specified,  such
           locales are excluded from the list.


       LCLIST_INCLUDE_LC_MESSAGES

           If this flag is set, the function also includes locales in the list
           that  do  not  have complete locale database components but have an
           LC_MESSAGES directory in the locale database  directory  hierarchy.
           In this case, setlocale(3C) with LC_MESSAGES can be successful.



       The  localelistfree()  deallocates  any allocated and associated memory
       blocks with the list by the localelist() function.

RETURN VALUES
       Upon successful completion, the localelist() function returns the  num‐
       ber  of  locales  in the list. Otherwise, the localelist() function re‐
       turns -1 and sets errno to indicate  the  error.  The  localelistfree()
       function neither returns a specific value nor sets errno.

ERRORS
       The localelist() function will fail if:

       ENOMEM    Cannot allocate memory.


EXAMPLES
       Example 1 Query and print installed locales



       This example shows how to query and print installed locales.


         #include <locale.h>

                 :
         lclist_t *lclp;
         int count;
         int i;
                 :

         count = localelist(&lclp, LCLIST_QUERY);

         if (count > 0) {
                 for (i = 0; i < count; i++)
                         printf("Locale name = %s\n", lclp[i].locale);
         }

         localelistfree(lclp);



       Example 2 Query installed locales with LC_MESSAGES directories



       This  example  shows how to query and print installed locales including
       locales that do not have a locale shared object but do have  a  LC_MES‐
       SAGES directory.


         #include <locale.h>

                 :
         lclist_t *lclp;
         int count;
         int i;
                 :

         count = localelist(&lclp, LCLIST_QUERY | LCLIST_INCLUDE_LC_MESSAGES);

         if (count > 0) {
                 for (i = 0; i < count; i++)
                         printf("Locale name = %s\n", lclp[i].locale);
         }

         localelistfree(lclp);


       Example 3 Query installed locales excluding symbolic links



       This  example  shows  how to query and print installed locales, but ex‐
       cludes any locales that are symbolic links to other locales.


         #include <locale.h>

                 :
         lclist_t *lclp;
         int count;
         int i;
                 :

         count = localelist(&lclp, LCLIST_QUERY | LCLIST_EXCLUDE_SYMBOLIC_LINKS);

         if (count > 0) {
                 for (i = 0; i < count; i++)
                         printf("Locale name = %s\n", lclp[i].locale);
         }

         localelistfree(lclp);


       Example 4 Query installed locales with locale validations



       This example shows how to query and print installed locales, with vali‐
       dation that the locales found are usable.


         #include <locale.h>

                 :
         lclist_t *lclp;
         int count;
         int i;
                 :

         count = localelist(&lclp, LCLIST_QUERY | LCLIST_VALIDATE);

         if (count > 0) {
                 for (i = 0; i < count; i++)
                         printf("Locale name = %s\n", lclp[i].locale);
         }

         localelistfree(lclp);


FILES
       /usr/lib/locale/locale    locale database directory for locale


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:

       tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE  TYPEAT‐
       TRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelMT-Safe


SEE ALSO
       locale(1),  locale_fallback(3C),  newlocale(3C), setlocale(3C), attrib‐
       utes(7), environ(7), locale(7), standards(7)


       Managing System Locales in Internationalizing and  Localizing  Applica‐
       tions in Oracle Solaris

HISTORY
       The  localelist() and localelistfree() functions were introduced in the
       Oracle Solaris 11.0.0 release.

Oracle Solaris 11.4               25 Nov 2024                   localelist(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3