ReactOS  0.4.14-dev-583-g2a1ba2c
xsltlocale.h File Reference
#include <libxml/xmlstring.h>
#include "xsltexports.h"
Include dependency graph for xsltlocale.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XSLT_LOCALE_NONE
 

Typedefs

typedef voidxsltLocale
 
typedef xmlChar xsltLocaleChar
 

Functions

XSLTPUBFUN xsltLocale XSLTCALL xsltNewLocale (const xmlChar *langName)
 
XSLTPUBFUN void XSLTCALL xsltFreeLocale (xsltLocale locale)
 
XSLTPUBFUN xsltLocaleChar *XSLTCALL xsltStrxfrm (xsltLocale locale, const xmlChar *string)
 
XSLTPUBFUN int XSLTCALL xsltLocaleStrcmp (xsltLocale locale, const xsltLocaleChar *str1, const xsltLocaleChar *str2)
 
XSLTPUBFUN void XSLTCALL xsltFreeLocales (void)
 

Macro Definition Documentation

◆ XSLT_LOCALE_NONE

#define XSLT_LOCALE_NONE

Definition at line 61 of file xsltlocale.h.

Typedef Documentation

◆ xsltLocale

typedef void* xsltLocale

Definition at line 63 of file xsltlocale.h.

◆ xsltLocaleChar

Definition at line 64 of file xsltlocale.h.

Function Documentation

◆ xsltFreeLocale()

XSLTPUBFUN void XSLTCALL xsltFreeLocale ( xsltLocale  locale)

xsltFreeLocale: @locale: the locale to free

Frees a locale created with xsltNewLocale

Definition at line 342 of file xsltlocale.c.

342  {
343 #ifdef XSLT_LOCALE_POSIX
344  freelocale(locale);
345 #endif
346 }
Definition: _locale.h:75

Referenced by xsltFreeStylePreComp().

◆ xsltFreeLocales()

XSLTPUBFUN void XSLTCALL xsltFreeLocales ( void  )

xsltFreeLocales:

Cleanup function for the locale support on shutdown

Definition at line 63 of file xsltlocale.c.

63  {
64 #ifdef XSLT_LOCALE_WINAPI
65  xmlRMutexLock(xsltLocaleMutex);
66  xmlFree(xsltLocaleList);
67  xsltLocaleList = NULL;
68  xmlRMutexUnlock(xsltLocaleMutex);
69 #endif
70 }
XMLPUBFUN void XMLCALL xmlRMutexLock(xmlRMutexPtr tok)
Definition: threads.c:343
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN void XMLCALL xmlRMutexUnlock(xmlRMutexPtr tok)
Definition: threads.c:388

Referenced by xsltCleanupGlobals().

◆ xsltLocaleStrcmp()

XSLTPUBFUN int XSLTCALL xsltLocaleStrcmp ( xsltLocale  locale,
const xsltLocaleChar str1,
const xsltLocaleChar str2 
)

xsltLocaleStrcmp: @locale: a locale identifier @str1: a string transformed with xsltStrxfrm @str2: a string transformed with xsltStrxfrm

Compares two strings transformed with xsltStrxfrm

Returns a value < 0 if str1 sorts before str2, a value > 0 if str1 sorts after str2, 0 if str1 and str2 are equal wrt sorting

Definition at line 422 of file xsltlocale.c.

422  {
423  (void)locale;
424 #ifdef XSLT_LOCALE_WINAPI
425 {
426  int ret;
427  if (str1 == str2) return(0);
428  if (str1 == NULL) return(-1);
429  if (str2 == NULL) return(1);
430  ret = CompareStringW(locale, 0, str1, -1, str2, -1);
431  if (ret == 0) {
432  xsltTransformError(NULL, NULL, NULL, "xsltLocaleStrcmp : CompareStringW fail\n");
433  return(0);
434  }
435  return(ret - 2);
436 }
437 #else
438  return(xmlStrcmp(str1, str2));
439 #endif
440 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
Definition: _locale.h:75
smooth NULL
Definition: ftsmooth.c:416
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2275
int ret
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
XMLPUBFUN int XMLCALL xmlStrcmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:132

Referenced by xsltDefaultSortFunction().

◆ xsltNewLocale()

XSLTPUBFUN xsltLocale XSLTCALL xsltNewLocale ( const xmlChar languageTag)

xsltNewLocale: @languageTag: RFC 3066 language tag

Creates a new locale of an opaque system dependent type based on the language tag.

Returns the locale or NULL on error or if no matching locale was found

Definition at line 82 of file xsltlocale.c.

82  {
83 #ifdef XSLT_LOCALE_POSIX
85  char localeName[XSLTMAX_LANGTAGLEN+6]; /* 6 chars for ".utf8\0" */
86  const xmlChar *p = languageTag;
87  const char *region = NULL;
88  char *q = localeName;
89  int i, llen;
90 
91  /* Convert something like "pt-br" to "pt_BR.utf8" */
92 
93  if (languageTag == NULL)
94  return(NULL);
95 
96  for (i=0; i<XSLTMAX_ISO639LANGLEN && ISALPHA(*p); ++i)
97  *q++ = TOLOWER(*p++);
98 
99  if (i == 0)
100  return(NULL);
101 
102  llen = i;
103 
104  if (*p) {
105  if (*p++ != '-')
106  return(NULL);
107  *q++ = '_';
108 
109  for (i=0; i<XSLTMAX_ISO3166CNTRYLEN && ISALPHA(*p); ++i)
110  *q++ = TOUPPER(*p++);
111 
112  if (i == 0 || *p)
113  return(NULL);
114 
115  memcpy(q, ".utf8", 6);
116  locale = newlocale(LC_COLLATE_MASK, localeName, NULL);
117  if (locale != NULL)
118  return(locale);
119 
120  /* Continue without using country code */
121 
122  q = localeName + llen;
123  }
124 
125  /* Try locale without territory, e.g. for Esperanto (eo) */
126 
127  memcpy(q, ".utf8", 6);
128  locale = newlocale(LC_COLLATE_MASK, localeName, NULL);
129  if (locale != NULL)
130  return(locale);
131 
132  /* Try to find most common country for language */
133 
134  if (llen != 2)
135  return(NULL);
136 
137  region = (char *)xsltDefaultRegion((xmlChar *)localeName);
138  if (region == NULL)
139  return(NULL);
140 
141  q = localeName + llen;
142  *q++ = '_';
143  *q++ = region[0];
144  *q++ = region[1];
145  memcpy(q, ".utf8", 6);
146  locale = newlocale(LC_COLLATE_MASK, localeName, NULL);
147 
148  return(locale);
149 #endif
150 
151 #ifdef XSLT_LOCALE_WINAPI
152 {
154  xmlChar localeName[XSLTMAX_LANGTAGLEN+1];
155  xmlChar *q = localeName;
156  const xmlChar *p = languageTag;
157  int i, llen;
158  const xmlChar *region = NULL;
159 
160  if (languageTag == NULL) goto end;
161 
162  xsltEnumSupportedLocales();
163 
164  for (i=0; i<XSLTMAX_ISO639LANGLEN && ISALPHA(*p); ++i)
165  *q++ = TOLOWER(*p++);
166  if (i == 0) goto end;
167 
168  llen = i;
169  *q++ = '-';
170  if (*p) { /*if country tag is given*/
171  if (*p++ != '-') goto end;
172 
173  for (i=0; i<XSLTMAX_ISO3166CNTRYLEN && ISALPHA(*p); ++i)
174  *q++ = TOUPPER(*p++);
175  if (i == 0 || *p) goto end;
176 
177  *q = '\0';
178  locale = xslt_locale_WINAPI(localeName);
179  if (locale != (xsltLocale)0) goto end;
180  }
181  /* Try to find most common country for language */
182  region = xsltDefaultRegion(localeName);
183  if (region == NULL) goto end;
184 
185  strcpy((char *) localeName + llen + 1, (char *) region);
186  locale = xslt_locale_WINAPI(localeName);
187 end:
188  return(locale);
189 }
190 #endif
191 
192 #ifdef XSLT_LOCALE_NONE
193  return(NULL);
194 #endif
195 }
#define TOLOWER(c)
Definition: xsltlocale.c:18
#define TOUPPER(c)
Definition: xsltlocale.c:17
void * xsltLocale
Definition: xsltlocale.h:63
GLuint GLuint end
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: _locale.h:75
smooth NULL
Definition: ftsmooth.c:416
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
#define XSLTMAX_ISO3166CNTRYLEN
Definition: xsltlocale.c:23
unsigned char xmlChar
Definition: xmlstring.h:28
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const wchar_t void * locale
Definition: printf.c:79
#define XSLTMAX_ISO639LANGLEN
Definition: xsltlocale.c:22
#define XSLTMAX_LANGTAGLEN
Definition: xsltlocale.c:25
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLfloat GLfloat p
Definition: glext.h:8902
#define ISALPHA(c)
Definition: xsltlocale.c:19
static const xmlChar * xsltDefaultRegion(const xmlChar *localeName)
Definition: xsltlocale.c:198

Referenced by xsltSortComp().

◆ xsltStrxfrm()

XSLTPUBFUN xsltLocaleChar* XSLTCALL xsltStrxfrm ( xsltLocale  locale,
const xmlChar string 
)

xsltStrxfrm: @locale: locale created with xsltNewLocale @string: UTF-8 string to transform

Transforms a string according to locale. The transformed string must then be compared with xsltLocaleStrcmp and freed with xmlFree.

Returns the transformed string or NULL on error

Definition at line 359 of file xsltlocale.c.

360 {
361 #ifdef XSLT_LOCALE_NONE
362  return(NULL);
363 #else
364  size_t xstrlen, r;
365  xsltLocaleChar *xstr;
366 
367 #ifdef XSLT_LOCALE_POSIX
368  xstrlen = strxfrm_l(NULL, (const char *)string, 0, locale) + 1;
369  xstr = (xsltLocaleChar *) xmlMalloc(xstrlen);
370  if (xstr == NULL) {
372  "xsltStrxfrm : out of memory error\n");
373  return(NULL);
374  }
375 
376  r = strxfrm_l((char *)xstr, (const char *)string, xstrlen, locale);
377 #endif
378 
379 #ifdef XSLT_LOCALE_WINAPI
380  xstrlen = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, NULL, 0);
381  if (xstrlen == 0) {
382  xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar check failed\n");
383  return(NULL);
384  }
385  xstr = (xsltLocaleChar*) xmlMalloc(xstrlen * sizeof(xsltLocaleChar));
386  if (xstr == NULL) {
387  xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : out of memory\n");
388  return(NULL);
389  }
390  r = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, xstr, xstrlen);
391  if (r == 0) {
392  xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar failed\n");
393  xmlFree(xstr);
394  return(NULL);
395  }
396  return(xstr);
397 #endif /* XSLT_LOCALE_WINAPI */
398 
399  if (r >= xstrlen) {
400  xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : strxfrm failed\n");
401  xmlFree(xstr);
402  return(NULL);
403  }
404 
405  return(xstr);
406 #endif /* XSLT_LOCALE_NONE */
407 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define CP_UTF8
Definition: nls.h:20
Definition: _locale.h:75
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlChar xsltLocaleChar
Definition: xsltlocale.h:64
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
#define MultiByteToWideChar
Definition: compat.h:100
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

Referenced by xsltComputeSortResult().