1// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef _FXCRT_EXTENSION_
8#define _FXCRT_EXTENSION_
9#ifndef _FX_BASIC_H_
10#include "fx_basic.h"
11#endif
12#ifndef _FXCRT_COORDINATES_
13#include "fx_coordinates.h"
14#endif
15#ifndef _FX_XML_H_
16#include "fx_xml.h"
17#endif
18#ifndef _FX_UNICODE_
19#include "fx_ucd.h"
20#endif
21#ifndef _FX_ARABIC_
22#include "fx_arb.h"
23#endif
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28
29FX_FLOAT		FXSYS_tan(FX_FLOAT a);
30FX_FLOAT		FXSYS_logb(FX_FLOAT b, FX_FLOAT x);
31FX_FLOAT		FXSYS_strtof(FX_LPCSTR pcsStr, FX_INT32 iLength = -1, FX_INT32 *pUsedLen = NULL);
32FX_FLOAT		FXSYS_wcstof(FX_LPCWSTR pwsStr, FX_INT32 iLength = -1, FX_INT32 *pUsedLen = NULL);
33FX_LPWSTR		FXSYS_wcsncpy(FX_LPWSTR dstStr, FX_LPCWSTR srcStr, size_t count);
34FX_INT32		FXSYS_wcsnicmp(FX_LPCWSTR s1, FX_LPCWSTR s2, size_t count);
35FX_INT32		FXSYS_strnicmp(FX_LPCSTR s1, FX_LPCSTR s2, size_t count);
36inline FX_BOOL	FXSYS_islower(FX_INT32 ch)
37{
38    return ch >= 'a' && ch <= 'z';
39}
40inline FX_BOOL	FXSYS_isupper(FX_INT32 ch)
41{
42    return ch >= 'A' && ch <= 'Z';
43}
44inline FX_INT32	FXSYS_tolower(FX_INT32 ch)
45{
46    return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20);
47}
48inline FX_INT32 FXSYS_toupper(FX_INT32 ch)
49{
50    return ch < 'a' || ch > 'z' ? ch : (ch - 0x20);
51}
52
53
54
55FX_DWORD	FX_HashCode_String_GetA(FX_LPCSTR pStr, FX_INT32 iLength, FX_BOOL bIgnoreCase = FALSE);
56FX_DWORD	FX_HashCode_String_GetW(FX_LPCWSTR pStr, FX_INT32 iLength, FX_BOOL bIgnoreCase = FALSE);
57
58#ifdef __cplusplus
59}
60#endif
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65FX_LPVOID	FX_Random_MT_Start(FX_DWORD dwSeed);
66
67FX_DWORD	FX_Random_MT_Generate(FX_LPVOID pContext);
68
69void		FX_Random_MT_Close(FX_LPVOID pContext);
70
71void		FX_Random_GenerateBase(FX_LPDWORD pBuffer, FX_INT32 iCount);
72
73void		FX_Random_GenerateMT(FX_LPDWORD pBuffer, FX_INT32 iCount);
74
75void		FX_Random_GenerateCrypto(FX_LPDWORD pBuffer, FX_INT32 iCount);
76#ifdef __cplusplus
77}
78#endif
79template<class baseType>
80class CFX_SSortTemplate
81{
82public:
83    void ShellSort(baseType *pArray, FX_INT32 iCount)
84    {
85        FXSYS_assert(pArray != NULL && iCount > 0);
86        FX_INT32 i, j, gap;
87        baseType v1, v2;
88        gap = iCount >> 1;
89        while (gap > 0) {
90            for (i = gap; i < iCount; i ++) {
91                j = i - gap;
92                v1 = pArray[i];
93                while (j > -1 && (v2 = pArray[j]) > v1) {
94                    pArray[j + gap] = v2;
95                    j -= gap;
96                }
97                pArray[j + gap] = v1;
98            }
99            gap >>= 1;
100        }
101    }
102};
103#endif
104