| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../include/fxcrt/fx_basic.h" | 7 #include "../../include/fxcrt/fx_basic.h" |
| 8 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 8 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <dirent.h> | 10 #include <dirent.h> |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 va_end(ap); | 177 va_end(ap); |
| 178 } | 178 } |
| 179 void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap) { | 179 void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap) { |
| 180 (void)_vsnprintf(str, size, fmt, ap); | 180 (void)_vsnprintf(str, size, fmt, ap); |
| 181 if (size) { | 181 if (size) { |
| 182 str[size - 1] = 0; | 182 str[size - 1] = 0; |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 #endif // _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900 | 185 #endif // _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900 |
| 186 | 186 |
| 187 static FX_BOOL FX_IsDigit(uint8_t ch) { | |
| 188 return (ch >= '0' && ch <= '9') ? TRUE : FALSE; | |
| 189 } | |
| 190 static FX_BOOL FX_IsXDigit(uint8_t ch) { | |
| 191 return (FX_IsDigit(ch) || (ch >= 'A' && ch <= 'F') || | |
| 192 (ch >= 'a' && ch <= 'f')) | |
| 193 ? TRUE | |
| 194 : FALSE; | |
| 195 } | |
| 196 static uint8_t FX_MakeUpper(uint8_t ch) { | |
| 197 if (ch < 'a' || ch > 'z') { | |
| 198 return ch; | |
| 199 } | |
| 200 return ch - 32; | |
| 201 } | |
| 202 static int FX_HexToI(uint8_t ch) { | |
| 203 ch = FX_MakeUpper(ch); | |
| 204 return FX_IsDigit(ch) ? (ch - '0') : (ch - 55); | |
| 205 } | |
| 206 static const unsigned char url_encodeTable[128] = { | |
| 207 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
| 208 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, | |
| 209 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, | |
| 210 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 211 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, | |
| 213 }; | |
| 214 CFX_ByteString FX_UrlEncode(const CFX_WideString& wsUrl) { | |
| 215 const char arDigits[] = "0123456789ABCDEF"; | |
| 216 CFX_ByteString rUrl; | |
| 217 int nLength = wsUrl.GetLength(); | |
| 218 for (int i = 0; i < nLength; i++) { | |
| 219 FX_DWORD word = wsUrl.GetAt(i); | |
| 220 if (word > 0x7F || url_encodeTable[word] == 1) { | |
| 221 CFX_ByteString bsUri = CFX_ByteString::FromUnicode((FX_WORD)word); | |
| 222 int nByte = bsUri.GetLength(); | |
| 223 for (int j = 0; j < nByte; j++) { | |
| 224 rUrl += '%'; | |
| 225 uint8_t code = bsUri.GetAt(j); | |
| 226 rUrl += arDigits[code >> 4]; | |
| 227 rUrl += arDigits[code & 0x0F]; | |
| 228 } | |
| 229 } else { | |
| 230 rUrl += CFX_ByteString::FromUnicode((FX_WORD)word); | |
| 231 } | |
| 232 } | |
| 233 return rUrl; | |
| 234 } | |
| 235 CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl) { | |
| 236 CFX_ByteString rUrl; | |
| 237 int nLength = bsUrl.GetLength(); | |
| 238 for (int i = 0; i < nLength; i++) { | |
| 239 if (i < nLength - 2 && bsUrl[i] == '%' && FX_IsXDigit(bsUrl[i + 1]) && | |
| 240 FX_IsXDigit(bsUrl[i + 2])) { | |
| 241 rUrl += (FX_HexToI(bsUrl[i + 1]) << 4 | FX_HexToI(bsUrl[i + 2])); | |
| 242 i += 2; | |
| 243 } else { | |
| 244 rUrl += bsUrl[i]; | |
| 245 } | |
| 246 } | |
| 247 return CFX_WideString::FromLocal(rUrl); | |
| 248 } | |
| 249 CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI) { | |
| 250 const char arDigits[] = "0123456789ABCDEF"; | |
| 251 CFX_ByteString rURI; | |
| 252 CFX_ByteString bsUri = wsURI.UTF8Encode(); | |
| 253 int nLength = bsUri.GetLength(); | |
| 254 for (int i = 0; i < nLength; i++) { | |
| 255 uint8_t code = bsUri.GetAt(i); | |
| 256 if (code > 0x7F || url_encodeTable[code] == 1) { | |
| 257 rURI += '%'; | |
| 258 rURI += arDigits[code >> 4]; | |
| 259 rURI += arDigits[code & 0x0F]; | |
| 260 } else { | |
| 261 rURI += code; | |
| 262 } | |
| 263 } | |
| 264 return rURI; | |
| 265 } | |
| 266 CFX_WideString FX_DecodeURI(const CFX_ByteString& bsURI) { | |
| 267 CFX_ByteString rURI; | |
| 268 int nLength = bsURI.GetLength(); | |
| 269 for (int i = 0; i < nLength; i++) { | |
| 270 if (i < nLength - 2 && bsURI[i] == '%' && FX_IsXDigit(bsURI[i + 1]) && | |
| 271 FX_IsXDigit(bsURI[i + 2])) { | |
| 272 rURI += (FX_HexToI(bsURI[i + 1]) << 4 | FX_HexToI(bsURI[i + 2])); | |
| 273 i += 2; | |
| 274 } else { | |
| 275 rURI += bsURI[i]; | |
| 276 } | |
| 277 } | |
| 278 return CFX_WideString::FromUTF8(rURI, rURI.GetLength()); | |
| 279 } | |
| 280 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 187 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 281 class CFindFileData { | 188 class CFindFileData { |
| 282 public: | 189 public: |
| 283 virtual ~CFindFileData() {} | 190 virtual ~CFindFileData() {} |
| 284 HANDLE m_Handle; | 191 HANDLE m_Handle; |
| 285 FX_BOOL m_bEnd; | 192 FX_BOOL m_bEnd; |
| 286 }; | 193 }; |
| 287 class CFindFileDataA : public CFindFileData { | 194 class CFindFileDataA : public CFindFileData { |
| 288 public: | 195 public: |
| 289 virtual ~CFindFileDataA() {} | 196 virtual ~CFindFileDataA() {} |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 d * m.b + e * m.e + f * m.h, d * m.c + e * m.f + f * m.i, | 364 d * m.b + e * m.e + f * m.h, d * m.c + e * m.f + f * m.i, |
| 458 g * m.a + h * m.d + i * m.g, g * m.b + h * m.e + i * m.h, | 365 g * m.a + h * m.d + i * m.g, g * m.b + h * m.e + i * m.h, |
| 459 g * m.c + h * m.f + i * m.i); | 366 g * m.c + h * m.f + i * m.i); |
| 460 } | 367 } |
| 461 | 368 |
| 462 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1& v) { | 369 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1& v) { |
| 463 return CFX_Vector_3by1(a * v.a + b * v.b + c * v.c, | 370 return CFX_Vector_3by1(a * v.a + b * v.b + c * v.c, |
| 464 d * v.a + e * v.b + f * v.c, | 371 d * v.a + e * v.b + f * v.c, |
| 465 g * v.a + h * v.b + i * v.c); | 372 g * v.a + h * v.b + i * v.c); |
| 466 } | 373 } |
| OLD | NEW |