Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
fx_memcpy_wrappers.h
Go to the documentation of this file.
1// Copyright 2023 The PDFium Authors
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 CORE_FXCRT_FX_MEMCPY_WRAPPERS_H_
8#define CORE_FXCRT_FX_MEMCPY_WRAPPERS_H_
9
10#include <stddef.h>
11#include <stdint.h>
12#include <string.h>
13#include <wchar.h>
14
15// Wrappers to avoid the zero-length w/NULL arg gotchas in C spec. Use these
16// if there is a possibility of a NULL arg (or a bad arg) that is to be ignored
17// when the length is zero, otherwise just call the C Run Time Library function
18// itself.
19inline int FXSYS_memcmp(const void* ptr1, const void* ptr2, size_t len) {
20 return len ? memcmp(ptr1, ptr2, len) : 0;
21}
22
23inline int FXSYS_wmemcmp(const wchar_t* ptr1, const wchar_t* ptr2, size_t len) {
24 return len ? wmemcmp(ptr1, ptr2, len) : 0;
25}
26
27inline void* FXSYS_memcpy(void* ptr1, const void* ptr2, size_t len) {
28 return len ? memcpy(ptr1, ptr2, len) : ptr1;
29}
30
31inline wchar_t* FXSYS_wmemcpy(wchar_t* ptr1, const wchar_t* ptr2, size_t len) {
32 return len ? wmemcpy(ptr1, ptr2, len) : ptr1;
33}
34
35inline void* FXSYS_memmove(void* ptr1, const void* ptr2, size_t len) {
36 return len ? memmove(ptr1, ptr2, len) : ptr1;
37}
38
39inline wchar_t* FXSYS_wmemmove(wchar_t* ptr1, const wchar_t* ptr2, size_t len) {
40 return len ? wmemmove(ptr1, ptr2, len) : ptr1;
41}
42
43inline void* FXSYS_memset(void* ptr1, int val, size_t len) {
44 return len ? memset(ptr1, val, len) : ptr1;
45}
46
47inline wchar_t* FXSYS_wmemset(wchar_t* ptr1, int val, size_t len) {
48 return len ? wmemset(ptr1, val, len) : ptr1;
49}
50
51inline const void* FXSYS_memchr(const void* ptr1, int val, size_t len) {
52 return len ? memchr(ptr1, val, len) : nullptr;
53}
54
55inline const wchar_t* FXSYS_wmemchr(const wchar_t* ptr1,
56 wchar_t val,
57 size_t len) {
58 return len ? wmemchr(ptr1, val, len) : nullptr;
59}
60
61// Overloaded functions for C++ templates
62inline size_t FXSYS_len(const char* ptr) {
63 return strlen(ptr);
64}
65
66inline size_t FXSYS_len(const wchar_t* ptr) {
67 return wcslen(ptr);
68}
69
70inline int FXSYS_cmp(const char* ptr1, const char* ptr2, size_t len) {
71 return FXSYS_memcmp(ptr1, ptr2, len);
72}
73
74inline int FXSYS_cmp(const wchar_t* ptr1, const wchar_t* ptr2, size_t len) {
75 return FXSYS_wmemcmp(ptr1, ptr2, len);
76}
77
78inline const char* FXSYS_chr(const char* ptr, char ch, size_t len) {
79 return reinterpret_cast<const char*>(FXSYS_memchr(ptr, ch, len));
80}
81
82inline const wchar_t* FXSYS_chr(const wchar_t* ptr, wchar_t ch, size_t len) {
83 return FXSYS_wmemchr(ptr, ch, len);
84}
85
86#endif // CORE_FXCRT_FX_MEMCPY_WRAPPERS_H_
void CRYPT_MD5Finish(CRYPT_md5_context *context, uint8_t digest[16])
Definition fx_crypt.cpp:214
#define P(a, b, c, d, k, s, t)
#define GET_UINT32(n, b, i)
Definition fx_crypt.cpp:13
#define S(x, n)
void CRYPT_ArcFourCryptBlock(pdfium::span< uint8_t > data, pdfium::span< const uint8_t > key)
Definition fx_crypt.cpp:169
void CRYPT_ArcFourSetup(CRYPT_rc4_context *context, pdfium::span< const uint8_t > key)
Definition fx_crypt.cpp:143
void CRYPT_MD5Update(CRYPT_md5_context *context, pdfium::span< const uint8_t > data)
Definition fx_crypt.cpp:187
#define PUT_UINT32(n, b, i)
Definition fx_crypt.cpp:20
void CRYPT_ArcFourCrypt(CRYPT_rc4_context *context, pdfium::span< uint8_t > data)
Definition fx_crypt.cpp:158
CRYPT_md5_context CRYPT_MD5Start()
Definition fx_crypt.cpp:176
void CRYPT_MD5Generate(pdfium::span< const uint8_t > data, uint8_t digest[16])
Definition fx_crypt.cpp:228
void CRYPT_AESSetIV(CRYPT_aes_context *context, const uint8_t *iv)
void CRYPT_SHA1Finish(CRYPT_sha1_context *context, uint8_t digest[20])
void CRYPT_SHA384Finish(CRYPT_sha2_context *context, uint8_t digest[48])
void CRYPT_SHA512Update(CRYPT_sha2_context *context, const uint8_t *data, uint32_t size)
void CRYPT_AESEncrypt(CRYPT_aes_context *context, uint8_t *dest, const uint8_t *src, uint32_t size)
void CRYPT_AESSetKey(CRYPT_aes_context *context, const uint8_t *key, uint32_t keylen)
void CRYPT_SHA1Generate(const uint8_t *data, uint32_t size, uint8_t digest[20])
void CRYPT_SHA256Generate(const uint8_t *data, uint32_t size, uint8_t digest[32])
void CRYPT_SHA384Start(CRYPT_sha2_context *context)
void CRYPT_SHA512Generate(const uint8_t *data, uint32_t size, uint8_t digest[64])
void CRYPT_SHA512Finish(CRYPT_sha2_context *context, uint8_t digest[64])
void CRYPT_SHA256Update(CRYPT_sha2_context *context, const uint8_t *data, uint32_t size)
void CRYPT_SHA1Update(CRYPT_sha1_context *context, const uint8_t *data, uint32_t size)
void CRYPT_SHA384Update(CRYPT_sha2_context *context, const uint8_t *data, uint32_t size)
void CRYPT_SHA512Start(CRYPT_sha2_context *context)
void CRYPT_SHA256Finish(CRYPT_sha2_context *context, uint8_t digest[32])
void CRYPT_SHA256Start(CRYPT_sha2_context *context)
void CRYPT_SHA1Start(CRYPT_sha1_context *context)
void CRYPT_AESDecrypt(CRYPT_aes_context *context, uint8_t *dest, const uint8_t *src, uint32_t size)
void CRYPT_SHA384Generate(const uint8_t *data, uint32_t size, uint8_t digest[48])
const void * FXSYS_memchr(const void *ptr1, int val, size_t len)
const wchar_t * FXSYS_chr(const wchar_t *ptr, wchar_t ch, size_t len)
wchar_t * FXSYS_wmemcpy(wchar_t *ptr1, const wchar_t *ptr2, size_t len)
size_t FXSYS_len(const wchar_t *ptr)
int FXSYS_memcmp(const void *ptr1, const void *ptr2, size_t len)
int FXSYS_wmemcmp(const wchar_t *ptr1, const wchar_t *ptr2, size_t len)
void * FXSYS_memset(void *ptr1, int val, size_t len)
int FXSYS_cmp(const wchar_t *ptr1, const wchar_t *ptr2, size_t len)
wchar_t * FXSYS_wmemset(wchar_t *ptr1, int val, size_t len)
wchar_t * FXSYS_wmemmove(wchar_t *ptr1, const wchar_t *ptr2, size_t len)
const char * FXSYS_chr(const char *ptr, char ch, size_t len)
const wchar_t * FXSYS_wmemchr(const wchar_t *ptr1, wchar_t val, size_t len)
void * FXSYS_memcpy(void *ptr1, const void *ptr2, size_t len)
void * FXSYS_memmove(void *ptr1, const void *ptr2, size_t len)
size_t FXSYS_len(const char *ptr)
int FXSYS_cmp(const char *ptr1, const char *ptr2, size_t len)
pdfium::span< T > reinterpret_span(pdfium::span< U > s) noexcept
Definition span_util.h:50
void spanclr(pdfium::span< T > dst)
Definition span_util.h:42
void spancpy(pdfium::span< T > dst, pdfium::span< U > src)
Definition span_util.h:20
void spanset(pdfium::span< T > dst, uint8_t val)
Definition span_util.h:36
void spanmove(pdfium::span< T > dst, pdfium::span< U > src)
Definition span_util.h:29
unsigned int iv[kMaxNb]
Definition fx_crypt.h:31
unsigned int keysched[kSchedSize]
Definition fx_crypt.h:29
static constexpr int kMaxNr
Definition fx_crypt.h:24
unsigned int invkeysched[kSchedSize]
Definition fx_crypt.h:30
static constexpr int kSchedSize
Definition fx_crypt.h:25
static constexpr int kMaxNb
Definition fx_crypt.h:23
uint8_t buffer[64]
Definition fx_crypt.h:37
uint32_t state[4]
Definition fx_crypt.h:36
uint32_t total[2]
Definition fx_crypt.h:35
static constexpr int32_t kPermutationLength
Definition fx_crypt.h:15
int32_t m[kPermutationLength]
Definition fx_crypt.h:19
uint64_t total_bytes
Definition fx_crypt.h:41
uint8_t block[64]
Definition fx_crypt.h:44
uint32_t h[5]
Definition fx_crypt.h:43
uint32_t blkused
Definition fx_crypt.h:42
uint64_t state[8]
Definition fx_crypt.h:49
uint64_t total_bytes
Definition fx_crypt.h:48
uint8_t buffer[128]
Definition fx_crypt.h:50