This commit is contained in:
ldcsaa 2022-04-11 00:30:08 +08:00
parent 85c4d317ff
commit c40ef69633
186 changed files with 1788 additions and 968 deletions

View File

@ -7,6 +7,7 @@ the C# SDK for [HP-Socket](https://github.com/ldcsaa/HP-Socket)
* `.Net Framework 2.0+`
* `.Net Core 2.0+`
* `.Net 5.0`
* `.Net 6.0`
#### Platform supported
* `Windows 7+ x86/x64`
@ -42,7 +43,7 @@ Basic component is the original component provided by HP-Socket. For related usa
+ `ITcpPullClient`
+ `ITcpPackServer`
+ `ITcpPackAgent`
+ `ITcpPacClient`
+ `ITcpPackClient`
##### UDP
+ `IUdpServer`
@ -436,4 +437,12 @@ namespace TcpServerTestEchoAdapter.DataReceiveAdapter
}
}
}
```
```
## Contribute
1. Fork this Repository
2. Create a new Feat_xxx branch
3. Submit code
4. Create a new Pull Request

View File

@ -7,6 +7,7 @@ the C# SDK for [HP-Socket](https://github.com/ldcsaa/HP-Socket)
* `.Net Framework 2.0+`
* `.Net Core 2.0+`
* `.Net 5.0`
* `.Net 6.0`
#### 平台支持
* `Windows 7+ x86/x64`
@ -42,7 +43,7 @@ Nuget软件包中的`libhpsocket4c.dylib`编译自`HP-Socket`的`macOS分支`[HP
+ `ITcpPullClient`
+ `ITcpPackServer`
+ `ITcpPackAgent`
+ `ITcpPacClient`
+ `ITcpPackClient`
##### UDP
+ `IUdpServer`
@ -438,4 +439,12 @@ namespace TcpServerTestEchoAdapter.DataReceiveAdapter
}
}
}
```
```
## 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request

View File

@ -1,4 +1,17 @@
# ======================================== #
HP-Socket v5.8.8 API Update List:
# ======================================== #
--------------------
1、Global:
--------------------
SYS_GbkToUnicodeEx (ADD)
SYS_UnicodeToGbkEx (ADD)
SYS_Utf8ToUnicodeEx (ADD)
SYS_UnicodeToUtf8Ex (ADD)
SYS_GbkToUtf8Ex (ADD)
SYS_Utf8ToGbkEx (ADD)
# ======================================== #
HP-Socket v5.8.6 API Update List:
# ======================================== #
--------------------

View File

@ -1,4 +1,19 @@
==========================================================================================
v5.8.8 Update:
==========================================================================================
> Major Upadate
-----------------
1. Client/Agent components supports specifying host name when connecting to remote server. The format is: '< hostaddress >[^< hostname >]', where '^< hostname >' is optional. One of scenario: pass SSL SNI hostname to target server through proxy server.
2. Add a series of character encoding conversion functions (Reference: Chang-log.txt), which supports specifying the length of the source string.
3. Fix the abnormal problem of SSL Pull/Pack Server/Agent components in the scenario of manual start SSL: 'SetSSLAutoStart(FALSE)'.
> Third-party library Upadate
-----------------
1. zlib upgrade to version 1.2.12.
2. openssl upgrade to version 1.1.1n.
==========================================================================================
v5.8.7 Update:
==========================================================================================

View File

@ -1,5 +1,5 @@
/*
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
*
* Licensed under the OpenSSL license (the "License"). You may not use
@ -722,6 +722,7 @@ typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,
CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \
fns->mem_fns.realloc_fn, \
fns->mem_fns.free_fn); \
OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \
skip_cbs: \
if (!fn(e, id)) return 0; \
return 1; }

View File

@ -2,7 +2,7 @@
* WARNING: do not edit!
* Generated by crypto/objects/objects.pl
*
* Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at

View File

@ -39,8 +39,8 @@ extern "C" {
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
* major minor fix final patch/beta)
*/
# define OPENSSL_VERSION_NUMBER 0x101010dfL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1m 14 Dec 2021"
# define OPENSSL_VERSION_NUMBER 0x101010efL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1n 15 Mar 2022"
/*-
* The macros below are to be used for shared library (.so, .dll, ...)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
*
* Licensed under the OpenSSL license (the "License"). You may not use
@ -722,6 +722,7 @@ typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,
CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \
fns->mem_fns.realloc_fn, \
fns->mem_fns.free_fn); \
OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \
skip_cbs: \
if (!fn(e, id)) return 0; \
return 1; }

View File

@ -2,7 +2,7 @@
* WARNING: do not edit!
* Generated by crypto/objects/objects.pl
*
* Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at

View File

@ -39,8 +39,8 @@ extern "C" {
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
* major minor fix final patch/beta)
*/
# define OPENSSL_VERSION_NUMBER 0x101010dfL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1m 14 Dec 2021"
# define OPENSSL_VERSION_NUMBER 0x101010efL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1n 15 Mar 2022"
/*-
* The macros below are to be used for shared library (.so, .dll, ...)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
*
* Licensed under the OpenSSL license (the "License"). You may not use
@ -722,6 +722,7 @@ typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,
CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \
fns->mem_fns.realloc_fn, \
fns->mem_fns.free_fn); \
OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \
skip_cbs: \
if (!fn(e, id)) return 0; \
return 1; }

View File

@ -2,7 +2,7 @@
* WARNING: do not edit!
* Generated by crypto/objects/objects.pl
*
* Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at

View File

@ -39,8 +39,8 @@ extern "C" {
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
* major minor fix final patch/beta)
*/
# define OPENSSL_VERSION_NUMBER 0x101010dfL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1m 14 Dec 2021"
# define OPENSSL_VERSION_NUMBER 0x101010efL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1n 15 Mar 2022"
/*-
* The macros below are to be used for shared library (.so, .dll, ...)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
*
* Licensed under the OpenSSL license (the "License"). You may not use
@ -722,6 +722,7 @@ typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,
CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \
fns->mem_fns.realloc_fn, \
fns->mem_fns.free_fn); \
OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \
skip_cbs: \
if (!fn(e, id)) return 0; \
return 1; }

View File

@ -2,7 +2,7 @@
* WARNING: do not edit!
* Generated by crypto/objects/objects.pl
*
* Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at

View File

@ -39,8 +39,8 @@ extern "C" {
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
* major minor fix final patch/beta)
*/
# define OPENSSL_VERSION_NUMBER 0x101010dfL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1m 14 Dec 2021"
# define OPENSSL_VERSION_NUMBER 0x101010efL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1n 15 Mar 2022"
/*-
* The macros below are to be used for shared library (.so, .dll, ...)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
*
* Licensed under the OpenSSL license (the "License"). You may not use
@ -722,6 +722,7 @@ typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,
CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \
fns->mem_fns.realloc_fn, \
fns->mem_fns.free_fn); \
OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \
skip_cbs: \
if (!fn(e, id)) return 0; \
return 1; }

View File

@ -2,7 +2,7 @@
* WARNING: do not edit!
* Generated by crypto/objects/objects.pl
*
* Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at

View File

@ -39,8 +39,8 @@ extern "C" {
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
* major minor fix final patch/beta)
*/
# define OPENSSL_VERSION_NUMBER 0x101010dfL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1m 14 Dec 2021"
# define OPENSSL_VERSION_NUMBER 0x101010efL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1n 15 Mar 2022"
/*-
* The macros below are to be used for shared library (.so, .dll, ...)

View File

@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.11, January 15th, 2017
version 1.2.12, March 11th, 2022
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -37,11 +37,11 @@
extern "C" {
#endif
#define ZLIB_VERSION "1.2.11"
#define ZLIB_VERNUM 0x12b0
#define ZLIB_VERSION "1.2.12"
#define ZLIB_VERNUM 0x12c0
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
#define ZLIB_VER_REVISION 11
#define ZLIB_VER_REVISION 12
#define ZLIB_VER_SUBREVISION 0
/*
@ -543,8 +543,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
int strategy));
This is another version of deflateInit with more compression options. The
fields next_in, zalloc, zfree and opaque must be initialized before by the
caller.
fields zalloc, zfree and opaque must be initialized before by the caller.
The method parameter is the compression method. It must be Z_DEFLATED in
this version of the library.
@ -712,11 +711,12 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
used to switch between compression and straight copy of the input data, or
to switch to a different kind of input data requiring a different strategy.
If the compression approach (which is a function of the level) or the
strategy is changed, and if any input has been consumed in a previous
deflate() call, then the input available so far is compressed with the old
level and strategy using deflate(strm, Z_BLOCK). There are three approaches
for the compression levels 0, 1..3, and 4..9 respectively. The new level
and strategy will take effect at the next call of deflate().
strategy is changed, and if there have been any deflate() calls since the
state was initialized or reset, then the input available so far is
compressed with the old level and strategy using deflate(strm, Z_BLOCK).
There are three approaches for the compression levels 0, 1..3, and 4..9
respectively. The new level and strategy will take effect at the next call
of deflate().
If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
not have enough output space to complete, then the parameter change will not
@ -865,9 +865,11 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
detection, or add 16 to decode only the gzip format (the zlib format will
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
below), inflate() will not automatically decode concatenated gzip streams.
inflate() will return Z_STREAM_END at the end of the gzip stream. The state
would need to be reset to continue decoding a subsequent gzip stream.
below), inflate() will *not* automatically decode concatenated gzip members.
inflate() will return Z_STREAM_END at the end of the gzip member. The state
would need to be reset to continue decoding a subsequent gzip member. This
*must* be done if there is more data after a gzip member, in order for the
decompression to be compliant with the gzip standard (RFC 1952).
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
@ -1302,14 +1304,14 @@ typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
/*
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
Opens a gzip (.gz) file for reading or writing. The mode parameter is as
in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
for fixed code compression as in "wb9F". (See the description of
deflateInit2 for more information about the strategy parameter.) 'T' will
request transparent writing or appending with no compression and not using
the gzip format.
Open the gzip (.gz) file at path for reading and decompressing, or
compressing and writing. The mode parameter is as in fopen ("rb" or "wb")
but can also include a compression level ("wb9") or a strategy: 'f' for
filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h",
'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
as in "wb9F". (See the description of deflateInit2 for more information
about the strategy parameter.) 'T' will request transparent writing or
appending with no compression and not using the gzip format.
"a" can be used instead of "w" to request that the gzip stream that will
be written be appended to the file. "+" will result in an error, since
@ -1339,9 +1341,9 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
/*
gzdopen associates a gzFile with the file descriptor fd. File descriptors
are obtained from calls like open, dup, creat, pipe or fileno (if the file
has been previously opened with fopen). The mode parameter is as in gzopen.
Associate a gzFile with the file descriptor fd. File descriptors are
obtained from calls like open, dup, creat, pipe or fileno (if the file has
been previously opened with fopen). The mode parameter is as in gzopen.
The next call of gzclose on the returned gzFile will also close the file
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
@ -1362,13 +1364,13 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
/*
Set the internal buffer size used by this library's functions. The
default buffer size is 8192 bytes. This function must be called after
gzopen() or gzdopen(), and before any other calls that read or write the
file. The buffer memory allocation is always deferred to the first read or
write. Three times that size in buffer space is allocated. A larger buffer
size of, for example, 64K or 128K bytes will noticeably increase the speed
of decompression (reading).
Set the internal buffer size used by this library's functions for file to
size. The default buffer size is 8192 bytes. This function must be called
after gzopen() or gzdopen(), and before any other calls that read or write
the file. The buffer memory allocation is always deferred to the first read
or write. Three times that size in buffer space is allocated. A larger
buffer size of, for example, 64K or 128K bytes will noticeably increase the
speed of decompression (reading).
The new buffer size also affects the maximum length for gzprintf().
@ -1378,9 +1380,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
/*
Dynamically update the compression level or strategy. See the description
of deflateInit2 for the meaning of these parameters. Previously provided
data is flushed before the parameter change.
Dynamically update the compression level and strategy for file. See the
description of deflateInit2 for the meaning of these parameters. Previously
provided data is flushed before applying the parameter changes.
gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
opened for writing, Z_ERRNO if there is an error writing the flushed data,
@ -1389,7 +1391,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
/*
Reads the given number of uncompressed bytes from the compressed file. If
Read and decompress up to len uncompressed bytes from file into buf. If
the input file is not in gzip format, gzread copies the given number of
bytes into the buffer directly from the file.
@ -1420,11 +1422,11 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
gzFile file));
/*
Read up to nitems items of size size from file to buf, otherwise operating
as gzread() does. This duplicates the interface of stdio's fread(), with
size_t request and return types. If the library defines size_t, then
z_size_t is identical to size_t. If not, then z_size_t is an unsigned
integer type that can contain a pointer.
Read and decompress up to nitems items of size size from file into buf,
otherwise operating as gzread() does. This duplicates the interface of
stdio's fread(), with size_t request and return types. If the library
defines size_t, then z_size_t is identical to size_t. If not, then z_size_t
is an unsigned integer type that can contain a pointer.
gzfread() returns the number of full items read of size size, or zero if
the end of the file was reached and a full item could not be read, or if
@ -1443,18 +1445,16 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
file, reseting and retrying on end-of-file, when size is not 1.
*/
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
voidpc buf, unsigned len));
ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));
/*
Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of uncompressed bytes written or 0 in case of
error.
Compress and write the len uncompressed bytes at buf to file. gzwrite
returns the number of uncompressed bytes written or 0 in case of error.
*/
ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
z_size_t nitems, gzFile file));
/*
gzfwrite() writes nitems items of size size from buf to file, duplicating
Compress and write nitems items of size size from buf to file, duplicating
the interface of stdio's fwrite(), with size_t request and return types. If
the library defines size_t, then z_size_t is identical to size_t. If not,
then z_size_t is an unsigned integer type that can contain a pointer.
@ -1467,22 +1467,22 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
/*
Converts, formats, and writes the arguments to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of
Convert, format, compress, and write the arguments (...) to file under
control of the string format, as in fprintf. gzprintf returns the number of
uncompressed bytes actually written, or a negative zlib error code in case
of error. The number of uncompressed bytes written is limited to 8191, or
one less than the buffer size given to gzbuffer(). The caller should assure
that this limit is not exceeded. If it is exceeded, then gzprintf() will
return an error (0) with nothing written. In this case, there may also be a
buffer overflow with unpredictable consequences, which is possible only if
zlib was compiled with the insecure functions sprintf() or vsprintf()
zlib was compiled with the insecure functions sprintf() or vsprintf(),
because the secure snprintf() or vsnprintf() functions were not available.
This can be determined using zlibCompileFlags().
*/
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
/*
Writes the given null-terminated string to the compressed file, excluding
Compress and write the given null-terminated string s to file, excluding
the terminating null character.
gzputs returns the number of characters written, or -1 in case of error.
@ -1490,11 +1490,12 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
/*
Reads bytes from the compressed file until len-1 characters are read, or a
newline character is read and transferred to buf, or an end-of-file
condition is encountered. If any characters are read or if len == 1, the
string is terminated with a null character. If no characters are read due
to an end-of-file or len < 1, then the buffer is left untouched.
Read and decompress bytes from file into buf, until len-1 characters are
read, or until a newline character is read and transferred to buf, or an
end-of-file condition is encountered. If any characters are read or if len
is one, the string is terminated with a null character. If no characters
are read due to an end-of-file or len is less than one, then the buffer is
left untouched.
gzgets returns buf which is a null-terminated string, or it returns NULL
for end-of-file or in case of error. If there was an error, the contents at
@ -1503,13 +1504,13 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
/*
Writes c, converted to an unsigned char, into the compressed file. gzputc
Compress and write c, converted to an unsigned char, into file. gzputc
returns the value that was written, or -1 in case of error.
*/
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
/*
Reads one byte from the compressed file. gzgetc returns this byte or -1
Read and decompress one byte from file. gzgetc returns this byte or -1
in case of end of file or error. This is implemented as a macro for speed.
As such, it does not do all of the checking the other functions do. I.e.
it does not check to see if file is NULL, nor whether the structure file
@ -1518,8 +1519,8 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
/*
Push one character back onto the stream to be read as the first character
on the next read. At least one character of push-back is allowed.
Push c back onto the stream for file to be read as the first character on
the next read. At least one character of push-back is always allowed.
gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
fail if c is -1, and may fail if a character has been pushed but not read
yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
@ -1530,9 +1531,9 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
/*
Flushes all pending output into the compressed file. The parameter flush
is as in the deflate() function. The return value is the zlib error number
(see function gzerror below). gzflush is only permitted when writing.
Flush all pending output to file. The parameter flush is as in the
deflate() function. The return value is the zlib error number (see function
gzerror below). gzflush is only permitted when writing.
If the flush parameter is Z_FINISH, the remaining data is written and the
gzip stream is completed in the output. If gzwrite() is called again, a new
@ -1547,8 +1548,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
z_off_t offset, int whence));
Sets the starting position for the next gzread or gzwrite on the given
compressed file. The offset represents a number of bytes in the
Set the starting position to offset relative to whence for the next gzread
or gzwrite on file. The offset represents a number of bytes in the
uncompressed data stream. The whence parameter is defined as in lseek(2);
the value SEEK_END is not supported.
@ -1565,18 +1566,18 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
/*
Rewinds the given file. This function is supported only for reading.
Rewind file. This function is supported only for reading.
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET).
*/
/*
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
Returns the starting position for the next gzread or gzwrite on the given
compressed file. This position represents a number of bytes in the
uncompressed data stream, and is zero when starting, even if appending or
reading a gzip stream from the middle of a file using gzdopen().
Return the starting position for the next gzread or gzwrite on file.
This position represents a number of bytes in the uncompressed data stream,
and is zero when starting, even if appending or reading a gzip stream from
the middle of a file using gzdopen().
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
*/
@ -1584,22 +1585,22 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
/*
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
Returns the current offset in the file being read or written. This offset
includes the count of bytes that precede the gzip stream, for example when
appending or when using gzdopen() for reading. When reading, the offset
does not include as yet unused buffered input. This information can be used
for a progress indicator. On error, gzoffset() returns -1.
Return the current compressed (actual) read or write offset of file. This
offset includes the count of bytes that precede the gzip stream, for example
when appending or when using gzdopen() for reading. When reading, the
offset does not include as yet unused buffered input. This information can
be used for a progress indicator. On error, gzoffset() returns -1.
*/
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
/*
Returns true (1) if the end-of-file indicator has been set while reading,
false (0) otherwise. Note that the end-of-file indicator is set only if the
read tried to go past the end of the input, but came up short. Therefore,
just like feof(), gzeof() may return false even if there is no more data to
read, in the event that the last read request was for the exact number of
bytes remaining in the input file. This will happen if the input file size
is an exact multiple of the buffer size.
Return true (1) if the end-of-file indicator for file has been set while
reading, false (0) otherwise. Note that the end-of-file indicator is set
only if the read tried to go past the end of the input, but came up short.
Therefore, just like feof(), gzeof() may return false even if there is no
more data to read, in the event that the last read request was for the exact
number of bytes remaining in the input file. This will happen if the input
file size is an exact multiple of the buffer size.
If gzeof() returns true, then the read functions will return no more data,
unless the end-of-file indicator is reset by gzclearerr() and the input file
@ -1608,7 +1609,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file));
ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
/*
Returns true (1) if file is being copied directly while reading, or false
Return true (1) if file is being copied directly while reading, or false
(0) if file is a gzip stream being decompressed.
If the input file is empty, gzdirect() will return true, since the input
@ -1629,8 +1630,8 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
/*
Flushes all pending output if necessary, closes the compressed file and
deallocates the (de)compression state. Note that once file is closed, you
Flush all pending output for file, if necessary, close file and
deallocate the (de)compression state. Note that once file is closed, you
cannot call gzerror with file, since its structures have been deallocated.
gzclose must not be called more than once on the same file, just as free
must not be called more than once on the same allocation.
@ -1654,10 +1655,10 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
/*
Returns the error message for the last error which occurred on the given
compressed file. errnum is set to zlib error number. If an error occurred
in the file system and not in the compression library, errnum is set to
Z_ERRNO and the application may consult errno to get the exact error code.
Return the error message for the last error which occurred on file.
errnum is set to zlib error number. If an error occurred in the file system
and not in the compression library, errnum is set to Z_ERRNO and the
application may consult errno to get the exact error code.
The application must not modify the returned string. Future calls to
this function may invalidate the previously returned string. If file is
@ -1670,7 +1671,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
/*
Clears the error and end-of-file flags for file. This is analogous to the
Clear the error and end-of-file flags for file. This is analogous to the
clearerr() function in stdio. This is useful for continuing to read a gzip
file that is being written concurrently.
*/
@ -1688,8 +1689,9 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
/*
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
return the updated checksum. If buf is Z_NULL, this function returns the
required initial value for the checksum.
return the updated checksum. An Adler-32 value is in the range of a 32-bit
unsigned integer. If buf is Z_NULL, this function returns the required
initial value for the checksum.
An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
much faster.
@ -1722,12 +1724,13 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
negative, the result has no meaning or utility.
*/
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
/*
Update a running CRC-32 with the bytes buf[0..len-1] and return the
updated CRC-32. If buf is Z_NULL, this function returns the required
initial value for the crc. Pre- and post-conditioning (one's complement) is
performed within this function so it shouldn't be done by the application.
updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer.
If buf is Z_NULL, this function returns the required initial value for the
crc. Pre- and post-conditioning (one's complement) is performed within this
function so it shouldn't be done by the application.
Usage example:
@ -1739,7 +1742,7 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
if (crc != original_crc) error();
*/
ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf,
z_size_t len));
/*
Same as crc32(), but with a size_t length.
@ -1755,6 +1758,20 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
len2.
*/
/*
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2));
Return the operator corresponding to length len2, to be used with
crc32_combine_op().
*/
ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op));
/*
Give the same result as crc32_combine(), using op in place of len2. op is
is generated from len2 by crc32_combine_gen(). This will be faster than
crc32_combine() if the generated op is used more than once.
*/
/* various hacks, don't look :) */
@ -1842,6 +1859,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t));
#endif
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
@ -1852,6 +1870,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
# define z_gzoffset z_gzoffset64
# define z_adler32_combine z_adler32_combine64
# define z_crc32_combine z_crc32_combine64
# define z_crc32_combine_gen z_crc32_combine_gen64
# else
# define gzopen gzopen64
# define gzseek gzseek64
@ -1859,6 +1878,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
# define gzoffset gzoffset64
# define adler32_combine adler32_combine64
# define crc32_combine crc32_combine64
# define crc32_combine_gen crc32_combine_gen64
# endif
# ifndef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
@ -1867,6 +1887,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
# endif
#else
ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
@ -1875,12 +1896,14 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
#endif
#else /* Z_SOLO */
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
#endif /* !Z_SOLO */
@ -1893,7 +1916,7 @@ ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
#if defined(_WIN32) && !defined(Z_SOLO)
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
const char *mode));
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
*
* Licensed under the OpenSSL license (the "License"). You may not use
@ -722,6 +722,7 @@ typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,
CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \
fns->mem_fns.realloc_fn, \
fns->mem_fns.free_fn); \
OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \
skip_cbs: \
if (!fn(e, id)) return 0; \
return 1; }

View File

@ -2,7 +2,7 @@
* WARNING: do not edit!
* Generated by crypto/objects/objects.pl
*
* Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at

View File

@ -39,8 +39,8 @@ extern "C" {
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
* major minor fix final patch/beta)
*/
# define OPENSSL_VERSION_NUMBER 0x101010dfL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1m 14 Dec 2021"
# define OPENSSL_VERSION_NUMBER 0x101010efL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1n 15 Mar 2022"
/*-
* The macros below are to be used for shared library (.so, .dll, ...)

View File

@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.11, January 15th, 2017
version 1.2.12, March 11th, 2022
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -37,11 +37,11 @@
extern "C" {
#endif
#define ZLIB_VERSION "1.2.11"
#define ZLIB_VERNUM 0x12b0
#define ZLIB_VERSION "1.2.12"
#define ZLIB_VERNUM 0x12c0
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
#define ZLIB_VER_REVISION 11
#define ZLIB_VER_REVISION 12
#define ZLIB_VER_SUBREVISION 0
/*
@ -543,8 +543,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
int strategy));
This is another version of deflateInit with more compression options. The
fields next_in, zalloc, zfree and opaque must be initialized before by the
caller.
fields zalloc, zfree and opaque must be initialized before by the caller.
The method parameter is the compression method. It must be Z_DEFLATED in
this version of the library.
@ -712,11 +711,12 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
used to switch between compression and straight copy of the input data, or
to switch to a different kind of input data requiring a different strategy.
If the compression approach (which is a function of the level) or the
strategy is changed, and if any input has been consumed in a previous
deflate() call, then the input available so far is compressed with the old
level and strategy using deflate(strm, Z_BLOCK). There are three approaches
for the compression levels 0, 1..3, and 4..9 respectively. The new level
and strategy will take effect at the next call of deflate().
strategy is changed, and if there have been any deflate() calls since the
state was initialized or reset, then the input available so far is
compressed with the old level and strategy using deflate(strm, Z_BLOCK).
There are three approaches for the compression levels 0, 1..3, and 4..9
respectively. The new level and strategy will take effect at the next call
of deflate().
If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
not have enough output space to complete, then the parameter change will not
@ -865,9 +865,11 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
detection, or add 16 to decode only the gzip format (the zlib format will
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
below), inflate() will not automatically decode concatenated gzip streams.
inflate() will return Z_STREAM_END at the end of the gzip stream. The state
would need to be reset to continue decoding a subsequent gzip stream.
below), inflate() will *not* automatically decode concatenated gzip members.
inflate() will return Z_STREAM_END at the end of the gzip member. The state
would need to be reset to continue decoding a subsequent gzip member. This
*must* be done if there is more data after a gzip member, in order for the
decompression to be compliant with the gzip standard (RFC 1952).
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
@ -1302,14 +1304,14 @@ typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
/*
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
Opens a gzip (.gz) file for reading or writing. The mode parameter is as
in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
for fixed code compression as in "wb9F". (See the description of
deflateInit2 for more information about the strategy parameter.) 'T' will
request transparent writing or appending with no compression and not using
the gzip format.
Open the gzip (.gz) file at path for reading and decompressing, or
compressing and writing. The mode parameter is as in fopen ("rb" or "wb")
but can also include a compression level ("wb9") or a strategy: 'f' for
filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h",
'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
as in "wb9F". (See the description of deflateInit2 for more information
about the strategy parameter.) 'T' will request transparent writing or
appending with no compression and not using the gzip format.
"a" can be used instead of "w" to request that the gzip stream that will
be written be appended to the file. "+" will result in an error, since
@ -1339,9 +1341,9 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
/*
gzdopen associates a gzFile with the file descriptor fd. File descriptors
are obtained from calls like open, dup, creat, pipe or fileno (if the file
has been previously opened with fopen). The mode parameter is as in gzopen.
Associate a gzFile with the file descriptor fd. File descriptors are
obtained from calls like open, dup, creat, pipe or fileno (if the file has
been previously opened with fopen). The mode parameter is as in gzopen.
The next call of gzclose on the returned gzFile will also close the file
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
@ -1362,13 +1364,13 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
/*
Set the internal buffer size used by this library's functions. The
default buffer size is 8192 bytes. This function must be called after
gzopen() or gzdopen(), and before any other calls that read or write the
file. The buffer memory allocation is always deferred to the first read or
write. Three times that size in buffer space is allocated. A larger buffer
size of, for example, 64K or 128K bytes will noticeably increase the speed
of decompression (reading).
Set the internal buffer size used by this library's functions for file to
size. The default buffer size is 8192 bytes. This function must be called
after gzopen() or gzdopen(), and before any other calls that read or write
the file. The buffer memory allocation is always deferred to the first read
or write. Three times that size in buffer space is allocated. A larger
buffer size of, for example, 64K or 128K bytes will noticeably increase the
speed of decompression (reading).
The new buffer size also affects the maximum length for gzprintf().
@ -1378,9 +1380,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
/*
Dynamically update the compression level or strategy. See the description
of deflateInit2 for the meaning of these parameters. Previously provided
data is flushed before the parameter change.
Dynamically update the compression level and strategy for file. See the
description of deflateInit2 for the meaning of these parameters. Previously
provided data is flushed before applying the parameter changes.
gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
opened for writing, Z_ERRNO if there is an error writing the flushed data,
@ -1389,7 +1391,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
/*
Reads the given number of uncompressed bytes from the compressed file. If
Read and decompress up to len uncompressed bytes from file into buf. If
the input file is not in gzip format, gzread copies the given number of
bytes into the buffer directly from the file.
@ -1420,11 +1422,11 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
gzFile file));
/*
Read up to nitems items of size size from file to buf, otherwise operating
as gzread() does. This duplicates the interface of stdio's fread(), with
size_t request and return types. If the library defines size_t, then
z_size_t is identical to size_t. If not, then z_size_t is an unsigned
integer type that can contain a pointer.
Read and decompress up to nitems items of size size from file into buf,
otherwise operating as gzread() does. This duplicates the interface of
stdio's fread(), with size_t request and return types. If the library
defines size_t, then z_size_t is identical to size_t. If not, then z_size_t
is an unsigned integer type that can contain a pointer.
gzfread() returns the number of full items read of size size, or zero if
the end of the file was reached and a full item could not be read, or if
@ -1443,18 +1445,16 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
file, reseting and retrying on end-of-file, when size is not 1.
*/
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
voidpc buf, unsigned len));
ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));
/*
Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of uncompressed bytes written or 0 in case of
error.
Compress and write the len uncompressed bytes at buf to file. gzwrite
returns the number of uncompressed bytes written or 0 in case of error.
*/
ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
z_size_t nitems, gzFile file));
/*
gzfwrite() writes nitems items of size size from buf to file, duplicating
Compress and write nitems items of size size from buf to file, duplicating
the interface of stdio's fwrite(), with size_t request and return types. If
the library defines size_t, then z_size_t is identical to size_t. If not,
then z_size_t is an unsigned integer type that can contain a pointer.
@ -1467,22 +1467,22 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
/*
Converts, formats, and writes the arguments to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of
Convert, format, compress, and write the arguments (...) to file under
control of the string format, as in fprintf. gzprintf returns the number of
uncompressed bytes actually written, or a negative zlib error code in case
of error. The number of uncompressed bytes written is limited to 8191, or
one less than the buffer size given to gzbuffer(). The caller should assure
that this limit is not exceeded. If it is exceeded, then gzprintf() will
return an error (0) with nothing written. In this case, there may also be a
buffer overflow with unpredictable consequences, which is possible only if
zlib was compiled with the insecure functions sprintf() or vsprintf()
zlib was compiled with the insecure functions sprintf() or vsprintf(),
because the secure snprintf() or vsnprintf() functions were not available.
This can be determined using zlibCompileFlags().
*/
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
/*
Writes the given null-terminated string to the compressed file, excluding
Compress and write the given null-terminated string s to file, excluding
the terminating null character.
gzputs returns the number of characters written, or -1 in case of error.
@ -1490,11 +1490,12 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
/*
Reads bytes from the compressed file until len-1 characters are read, or a
newline character is read and transferred to buf, or an end-of-file
condition is encountered. If any characters are read or if len == 1, the
string is terminated with a null character. If no characters are read due
to an end-of-file or len < 1, then the buffer is left untouched.
Read and decompress bytes from file into buf, until len-1 characters are
read, or until a newline character is read and transferred to buf, or an
end-of-file condition is encountered. If any characters are read or if len
is one, the string is terminated with a null character. If no characters
are read due to an end-of-file or len is less than one, then the buffer is
left untouched.
gzgets returns buf which is a null-terminated string, or it returns NULL
for end-of-file or in case of error. If there was an error, the contents at
@ -1503,13 +1504,13 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
/*
Writes c, converted to an unsigned char, into the compressed file. gzputc
Compress and write c, converted to an unsigned char, into file. gzputc
returns the value that was written, or -1 in case of error.
*/
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
/*
Reads one byte from the compressed file. gzgetc returns this byte or -1
Read and decompress one byte from file. gzgetc returns this byte or -1
in case of end of file or error. This is implemented as a macro for speed.
As such, it does not do all of the checking the other functions do. I.e.
it does not check to see if file is NULL, nor whether the structure file
@ -1518,8 +1519,8 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
/*
Push one character back onto the stream to be read as the first character
on the next read. At least one character of push-back is allowed.
Push c back onto the stream for file to be read as the first character on
the next read. At least one character of push-back is always allowed.
gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
fail if c is -1, and may fail if a character has been pushed but not read
yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
@ -1530,9 +1531,9 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
/*
Flushes all pending output into the compressed file. The parameter flush
is as in the deflate() function. The return value is the zlib error number
(see function gzerror below). gzflush is only permitted when writing.
Flush all pending output to file. The parameter flush is as in the
deflate() function. The return value is the zlib error number (see function
gzerror below). gzflush is only permitted when writing.
If the flush parameter is Z_FINISH, the remaining data is written and the
gzip stream is completed in the output. If gzwrite() is called again, a new
@ -1547,8 +1548,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
z_off_t offset, int whence));
Sets the starting position for the next gzread or gzwrite on the given
compressed file. The offset represents a number of bytes in the
Set the starting position to offset relative to whence for the next gzread
or gzwrite on file. The offset represents a number of bytes in the
uncompressed data stream. The whence parameter is defined as in lseek(2);
the value SEEK_END is not supported.
@ -1565,18 +1566,18 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
/*
Rewinds the given file. This function is supported only for reading.
Rewind file. This function is supported only for reading.
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET).
*/
/*
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
Returns the starting position for the next gzread or gzwrite on the given
compressed file. This position represents a number of bytes in the
uncompressed data stream, and is zero when starting, even if appending or
reading a gzip stream from the middle of a file using gzdopen().
Return the starting position for the next gzread or gzwrite on file.
This position represents a number of bytes in the uncompressed data stream,
and is zero when starting, even if appending or reading a gzip stream from
the middle of a file using gzdopen().
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
*/
@ -1584,22 +1585,22 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
/*
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
Returns the current offset in the file being read or written. This offset
includes the count of bytes that precede the gzip stream, for example when
appending or when using gzdopen() for reading. When reading, the offset
does not include as yet unused buffered input. This information can be used
for a progress indicator. On error, gzoffset() returns -1.
Return the current compressed (actual) read or write offset of file. This
offset includes the count of bytes that precede the gzip stream, for example
when appending or when using gzdopen() for reading. When reading, the
offset does not include as yet unused buffered input. This information can
be used for a progress indicator. On error, gzoffset() returns -1.
*/
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
/*
Returns true (1) if the end-of-file indicator has been set while reading,
false (0) otherwise. Note that the end-of-file indicator is set only if the
read tried to go past the end of the input, but came up short. Therefore,
just like feof(), gzeof() may return false even if there is no more data to
read, in the event that the last read request was for the exact number of
bytes remaining in the input file. This will happen if the input file size
is an exact multiple of the buffer size.
Return true (1) if the end-of-file indicator for file has been set while
reading, false (0) otherwise. Note that the end-of-file indicator is set
only if the read tried to go past the end of the input, but came up short.
Therefore, just like feof(), gzeof() may return false even if there is no
more data to read, in the event that the last read request was for the exact
number of bytes remaining in the input file. This will happen if the input
file size is an exact multiple of the buffer size.
If gzeof() returns true, then the read functions will return no more data,
unless the end-of-file indicator is reset by gzclearerr() and the input file
@ -1608,7 +1609,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file));
ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
/*
Returns true (1) if file is being copied directly while reading, or false
Return true (1) if file is being copied directly while reading, or false
(0) if file is a gzip stream being decompressed.
If the input file is empty, gzdirect() will return true, since the input
@ -1629,8 +1630,8 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
/*
Flushes all pending output if necessary, closes the compressed file and
deallocates the (de)compression state. Note that once file is closed, you
Flush all pending output for file, if necessary, close file and
deallocate the (de)compression state. Note that once file is closed, you
cannot call gzerror with file, since its structures have been deallocated.
gzclose must not be called more than once on the same file, just as free
must not be called more than once on the same allocation.
@ -1654,10 +1655,10 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
/*
Returns the error message for the last error which occurred on the given
compressed file. errnum is set to zlib error number. If an error occurred
in the file system and not in the compression library, errnum is set to
Z_ERRNO and the application may consult errno to get the exact error code.
Return the error message for the last error which occurred on file.
errnum is set to zlib error number. If an error occurred in the file system
and not in the compression library, errnum is set to Z_ERRNO and the
application may consult errno to get the exact error code.
The application must not modify the returned string. Future calls to
this function may invalidate the previously returned string. If file is
@ -1670,7 +1671,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
/*
Clears the error and end-of-file flags for file. This is analogous to the
Clear the error and end-of-file flags for file. This is analogous to the
clearerr() function in stdio. This is useful for continuing to read a gzip
file that is being written concurrently.
*/
@ -1688,8 +1689,9 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
/*
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
return the updated checksum. If buf is Z_NULL, this function returns the
required initial value for the checksum.
return the updated checksum. An Adler-32 value is in the range of a 32-bit
unsigned integer. If buf is Z_NULL, this function returns the required
initial value for the checksum.
An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
much faster.
@ -1722,12 +1724,13 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
negative, the result has no meaning or utility.
*/
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
/*
Update a running CRC-32 with the bytes buf[0..len-1] and return the
updated CRC-32. If buf is Z_NULL, this function returns the required
initial value for the crc. Pre- and post-conditioning (one's complement) is
performed within this function so it shouldn't be done by the application.
updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer.
If buf is Z_NULL, this function returns the required initial value for the
crc. Pre- and post-conditioning (one's complement) is performed within this
function so it shouldn't be done by the application.
Usage example:
@ -1739,7 +1742,7 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
if (crc != original_crc) error();
*/
ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf,
z_size_t len));
/*
Same as crc32(), but with a size_t length.
@ -1755,6 +1758,20 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
len2.
*/
/*
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2));
Return the operator corresponding to length len2, to be used with
crc32_combine_op().
*/
ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op));
/*
Give the same result as crc32_combine(), using op in place of len2. op is
is generated from len2 by crc32_combine_gen(). This will be faster than
crc32_combine() if the generated op is used more than once.
*/
/* various hacks, don't look :) */
@ -1842,6 +1859,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t));
#endif
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
@ -1852,6 +1870,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
# define z_gzoffset z_gzoffset64
# define z_adler32_combine z_adler32_combine64
# define z_crc32_combine z_crc32_combine64
# define z_crc32_combine_gen z_crc32_combine_gen64
# else
# define gzopen gzopen64
# define gzseek gzseek64
@ -1859,6 +1878,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
# define gzoffset gzoffset64
# define adler32_combine adler32_combine64
# define crc32_combine crc32_combine64
# define crc32_combine_gen crc32_combine_gen64
# endif
# ifndef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
@ -1867,6 +1887,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
# endif
#else
ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
@ -1875,12 +1896,14 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
#endif
#else /* Z_SOLO */
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
#endif /* !Z_SOLO */
@ -1893,7 +1916,7 @@ ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
#if defined(_WIN32) && !defined(Z_SOLO)
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
const char *mode));
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -580,6 +580,20 @@ HPSOCKET_API DWORD SYS_BrotliGuessCompressBound(DWORD dwSrcLen);
// Charset A -> Charset B
HPSOCKET_API BOOL SYS_CharsetConvert(LPCSTR lpszFromCharset, LPCSTR lpszToCharset, LPCSTR lpszInBuf, int iInBufLen, LPSTR lpszOutBuf, int& iOutBufLen);
// GBK -> UNICODE
HPSOCKET_API BOOL SYS_GbkToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int& iDestLength);
// UNICODE -> GBK
HPSOCKET_API BOOL SYS_UnicodeToGbkEx(const WCHAR szSrc[], int iSrcLength, char szDest[], int& iDestLength);
// UTF8 -> UNICODE
HPSOCKET_API BOOL SYS_Utf8ToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int& iDestLength);
// UNICODE -> UTF8
HPSOCKET_API BOOL SYS_UnicodeToUtf8Ex(const WCHAR szSrc[], int iSrcLength, char szDest[], int& iDestLength);
// GBK -> UTF8
HPSOCKET_API BOOL SYS_GbkToUtf8Ex(const char szSrc[], int iSrcLength, char szDest[], int& iDestLength);
// UTF8 -> GBK
HPSOCKET_API BOOL SYS_Utf8ToGbkEx(const char szSrc[], int iSrcLength, char szDest[], int& iDestLength);
// GBK -> UNICODE
HPSOCKET_API BOOL SYS_GbkToUnicode(const char szSrc[], WCHAR szDest[], int& iDestLength);
// UNICODE -> GBK

View File

@ -1788,6 +1788,20 @@ HPSOCKET_API DWORD __HP_CALL SYS_BrotliGuessCompressBound(DWORD dwSrcLen);
// Charset A -> Charset B
HPSOCKET_API BOOL __HP_CALL SYS_CharsetConvert(LPCSTR lpszFromCharset, LPCSTR lpszToCharset, LPCSTR lpszInBuf, int iInBufLen, LPSTR lpszOutBuf, int* piOutBufLen);
// GBK -> UNICODE
HPSOCKET_API BOOL __HP_CALL SYS_GbkToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int* piDestLength);
// UNICODE -> GBK
HPSOCKET_API BOOL __HP_CALL SYS_UnicodeToGbkEx(const WCHAR szSrc[], int iSrcLength, char szDest[], int* piDestLength);
// UTF8 -> UNICODE
HPSOCKET_API BOOL __HP_CALL SYS_Utf8ToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int* piDestLength);
// UNICODE -> UTF8
HPSOCKET_API BOOL __HP_CALL SYS_UnicodeToUtf8Ex(const WCHAR szSrc[], int iSrcLength, char szDest[], int* piDestLength);
// GBK -> UTF8
HPSOCKET_API BOOL __HP_CALL SYS_GbkToUtf8Ex(const char szSrc[], int iSrcLength, char szDest[], int* piDestLength);
// UTF8 -> GBK
HPSOCKET_API BOOL __HP_CALL SYS_Utf8ToGbkEx(const char szSrc[], int iSrcLength, char szDest[], int* piDestLength);
// GBK -> UNICODE
HPSOCKET_API BOOL __HP_CALL SYS_GbkToUnicode(const char szSrc[], WCHAR szDest[], int* piDestLength);
// UNICODE -> GBK

View File

@ -28,7 +28,7 @@
/* HP-Socket 版本号 */
#define HP_VERSION_MAJOR 5 // 主版本号
#define HP_VERSION_MINOR 8 // 子版本号
#define HP_VERSION_REVISE 7 // 修正版本号
#define HP_VERSION_REVISE 8 // 修正版本号
#define HP_VERSION_BUILD 1 // 构建编号
//#define _UDP_DISABLED // 禁用 UDP

View File

@ -4,7 +4,7 @@
<PropertyGroup Label="UserMacros">
<VER_MAJOR>5</VER_MAJOR>
<VER_MINOR>8</VER_MINOR>
<VER_REVISE>7</VER_REVISE>
<VER_REVISE>8</VER_REVISE>
<VER_BUILD>1</VER_BUILD>
<ArmDeptToCopyRemotely>..\..\dependent\arm\include\brotli\decode.h:=$(RemoteRootDir)/dependent/arm/include/brotli/decode.h;..\..\dependent\arm\include\brotli\encode.h:=$(RemoteRootDir)/dependent/arm/include/brotli/encode.h;..\..\dependent\arm\include\brotli\port.h:=$(RemoteRootDir)/dependent/arm/include/brotli/port.h;..\..\dependent\arm\include\brotli\types.h:=$(RemoteRootDir)/dependent/arm/include/brotli/types.h;..\..\dependent\arm\lib\libbrotli.a:=$(RemoteRootDir)/dependent/arm/lib/libbrotli.a;..\..\dependent\arm\lib\libjemalloc_pic.a:=$(RemoteRootDir)/dependent/arm/lib/libjemalloc_pic.a;..\..\dependent\arm\lib\libmimalloc.a:=$(RemoteRootDir)/dependent/arm/lib/libmimalloc.a</ArmDeptToCopyRemotely>
<Arm64DeptToCopyRemotely>..\..\dependent\arm64\include\brotli\decode.h:=$(RemoteRootDir)/dependent/arm64/include/brotli/decode.h;..\..\dependent\arm64\include\brotli\encode.h:=$(RemoteRootDir)/dependent/arm64/include/brotli/encode.h;..\..\dependent\arm64\include\brotli\port.h:=$(RemoteRootDir)/dependent/arm64/include/brotli/port.h;..\..\dependent\arm64\include\brotli\types.h:=$(RemoteRootDir)/dependent/arm64/include/brotli/types.h;..\..\dependent\arm64\lib\libbrotli.a:=$(RemoteRootDir)/dependent/arm64/lib/libbrotli.a;..\..\dependent\arm64\lib\libjemalloc_pic.a:=$(RemoteRootDir)/dependent/arm64/lib/libjemalloc_pic.a;..\..\dependent\arm64\lib\libmimalloc.a:=$(RemoteRootDir)/dependent/arm64/lib/libmimalloc.a</Arm64DeptToCopyRemotely>

View File

@ -490,6 +490,36 @@ HPSOCKET_API BOOL SYS_CharsetConvert(LPCSTR lpszFromCharset, LPCSTR lpszToCharse
return ::CharsetConvert(lpszFromCharset, lpszToCharset, lpszInBuf, iInBufLen, lpszOutBuf, iOutBufLen);
}
HPSOCKET_API BOOL SYS_GbkToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int& iDestLength)
{
return ::GbkToUnicodeEx(szSrc, iSrcLength, szDest, iDestLength);
}
HPSOCKET_API BOOL SYS_UnicodeToGbkEx(const WCHAR szSrc[], int iSrcLength, char szDest[], int& iDestLength)
{
return ::UnicodeToGbkEx(szSrc, iSrcLength, szDest, iDestLength);
}
HPSOCKET_API BOOL SYS_Utf8ToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int& iDestLength)
{
return ::Utf8ToUnicodeEx(szSrc, iSrcLength, szDest, iDestLength);
}
HPSOCKET_API BOOL SYS_UnicodeToUtf8Ex(const WCHAR szSrc[], int iSrcLength, char szDest[], int& iDestLength)
{
return ::UnicodeToUtf8Ex(szSrc, iSrcLength, szDest, iDestLength);
}
HPSOCKET_API BOOL SYS_GbkToUtf8Ex(const char szSrc[], int iSrcLength, char szDest[], int& iDestLength)
{
return ::GbkToUtf8Ex(szSrc, iSrcLength, szDest, iDestLength);
}
HPSOCKET_API BOOL SYS_Utf8ToGbkEx(const char szSrc[], int iSrcLength, char szDest[], int& iDestLength)
{
return ::Utf8ToGbkEx(szSrc, iSrcLength, szDest, iDestLength);
}
HPSOCKET_API BOOL SYS_GbkToUnicode(const char szSrc[], WCHAR szDest[], int& iDestLength)
{
return ::GbkToUnicode(szSrc, szDest, iDestLength);

View File

@ -2355,6 +2355,36 @@ HPSOCKET_API BOOL __HP_CALL SYS_CharsetConvert(LPCSTR lpszFromCharset, LPCSTR lp
return ::CharsetConvert(lpszFromCharset, lpszToCharset, lpszInBuf, iInBufLen, lpszOutBuf, *piOutBufLen);
}
HPSOCKET_API BOOL __HP_CALL SYS_GbkToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int* piDestLength)
{
return ::GbkToUnicodeEx(szSrc, iSrcLength, szDest, *piDestLength);
}
HPSOCKET_API BOOL __HP_CALL SYS_UnicodeToGbkEx(const WCHAR szSrc[], int iSrcLength, char szDest[], int* piDestLength)
{
return ::UnicodeToGbkEx(szSrc, iSrcLength, szDest, *piDestLength);
}
HPSOCKET_API BOOL __HP_CALL SYS_Utf8ToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int* piDestLength)
{
return ::Utf8ToUnicodeEx(szSrc, iSrcLength, szDest, *piDestLength);
}
HPSOCKET_API BOOL __HP_CALL SYS_UnicodeToUtf8Ex(const WCHAR szSrc[], int iSrcLength, char szDest[], int* piDestLength)
{
return ::UnicodeToUtf8Ex(szSrc, iSrcLength, szDest, *piDestLength);
}
HPSOCKET_API BOOL __HP_CALL SYS_GbkToUtf8Ex(const char szSrc[], int iSrcLength, char szDest[], int* piDestLength)
{
return ::GbkToUtf8Ex(szSrc, iSrcLength, szDest, *piDestLength);
}
HPSOCKET_API BOOL __HP_CALL SYS_Utf8ToGbkEx(const char szSrc[], int iSrcLength, char szDest[], int* piDestLength)
{
return ::Utf8ToGbkEx(szSrc, iSrcLength, szDest, *piDestLength);
}
HPSOCKET_API BOOL __HP_CALL SYS_GbkToUnicode(const char szSrc[], WCHAR szDest[], int* piDestLength)
{
return ::GbkToUnicode(szSrc, szDest, *piDestLength);

View File

@ -86,7 +86,7 @@ BOOL CHPThreadPool::Start(DWORD dwThreadCount, DWORD dwMaxQueueSize, EnRejectedP
m_enState = SS_STARTED;
return TRUE;;
return TRUE;
}
BOOL CHPThreadPool::Stop(DWORD dwMaxWait)

View File

@ -257,9 +257,15 @@ template<class T, USHORT default_port> BOOL CHttpSyncClientT<T, default_port>::O
GetRemoteHost(&lpszHost, &usPort2);
if(strHost.CompareNoCase(lpszHost) != 0 || usPort != usPort2)
if(usPort != usPort2)
bNeedStop = TRUE;
else
{
HP_SCOPE_HOST host(CA2T((LPCSTR)strHost));
if(lstricmp(host.name, CA2T(lpszHost)) != 0)
bNeedStop = TRUE;
}
}
if(bNeedStop) Stop();

View File

@ -105,6 +105,7 @@
/* 压缩/解压数据缓冲器长度 */
#define COMPRESS_BUFFER_SIZE (16 * 1024)
#define HOST_SEPARATOR_CHAR '^'
#define PORT_SEPARATOR_CHAR ':'
#define IPV6_ADDR_BEGIN_CHAR '['
#define IPV6_ADDR_END_CHAR ']'

View File

@ -990,7 +990,7 @@ void DestroyDecompressor(IHPDecompressor* pDecompressor)
#ifdef _ZLIB_SUPPORT
CHPZlibCompressor::CHPZlibCompressor(Fn_CompressDataCallback fnCallback, int iWindowBits, int iLevel, int iMethod, int iMemLevel, int iStrategy)
CHPZLibCompressor::CHPZLibCompressor(Fn_CompressDataCallback fnCallback, int iWindowBits, int iLevel, int iMethod, int iMemLevel, int iStrategy)
: m_fnCallback (fnCallback)
, m_bValid (FALSE)
{
@ -1000,17 +1000,17 @@ CHPZlibCompressor::CHPZlibCompressor(Fn_CompressDataCallback fnCallback, int iWi
m_bValid = (::deflateInit2(&m_Stream, iLevel, iMethod, iWindowBits, iMemLevel, iStrategy) == Z_OK);
}
CHPZlibCompressor::~CHPZlibCompressor()
CHPZLibCompressor::~CHPZLibCompressor()
{
if(m_bValid) ::deflateEnd(&m_Stream);
}
BOOL CHPZlibCompressor::Reset()
BOOL CHPZLibCompressor::Reset()
{
return (m_bValid = (::deflateReset(&m_Stream) == Z_OK));
}
BOOL CHPZlibCompressor::Process(const BYTE* pData, int iLength, BOOL bLast, PVOID pContext)
BOOL CHPZLibCompressor::Process(const BYTE* pData, int iLength, BOOL bLast, PVOID pContext)
{
ASSERT(IsValid() && iLength > 0);
@ -1068,7 +1068,7 @@ ZLIB_COMPRESS_END:
return isOK;
}
CHPZlibDecompressor::CHPZlibDecompressor(Fn_DecompressDataCallback fnCallback, int iWindowBits)
CHPZLibDecompressor::CHPZLibDecompressor(Fn_DecompressDataCallback fnCallback, int iWindowBits)
: m_fnCallback (fnCallback)
, m_bValid (FALSE)
{
@ -1078,17 +1078,17 @@ CHPZlibDecompressor::CHPZlibDecompressor(Fn_DecompressDataCallback fnCallback, i
m_bValid = (::inflateInit2(&m_Stream, iWindowBits) == Z_OK);
}
CHPZlibDecompressor::~CHPZlibDecompressor()
CHPZLibDecompressor::~CHPZLibDecompressor()
{
if(m_bValid) ::inflateEnd(&m_Stream);
}
BOOL CHPZlibDecompressor::Reset()
BOOL CHPZLibDecompressor::Reset()
{
return (m_bValid = (::inflateReset(&m_Stream) == Z_OK));
}
BOOL CHPZlibDecompressor::Process(const BYTE* pData, int iLength, PVOID pContext)
BOOL CHPZLibDecompressor::Process(const BYTE* pData, int iLength, PVOID pContext)
{
ASSERT(IsValid() && iLength > 0);
@ -1151,22 +1151,22 @@ ZLIB_DECOMPRESS_END:
IHPCompressor* CreateZLibCompressor(Fn_CompressDataCallback fnCallback, int iWindowBits, int iLevel, int iMethod, int iMemLevel, int iStrategy)
{
return new CHPZlibCompressor(fnCallback, iWindowBits, iLevel, iMethod, iMemLevel, iStrategy);
return new CHPZLibCompressor(fnCallback, iWindowBits, iLevel, iMethod, iMemLevel, iStrategy);
}
IHPCompressor* CreateGZipCompressor(Fn_CompressDataCallback fnCallback, int iLevel, int iMethod, int iMemLevel, int iStrategy)
{
return new CHPZlibCompressor(fnCallback, MAX_WBITS + 16, iLevel, iMethod, iMemLevel, iStrategy);
return new CHPZLibCompressor(fnCallback, MAX_WBITS + 16, iLevel, iMethod, iMemLevel, iStrategy);
}
IHPDecompressor* CreateZLibDecompressor(Fn_DecompressDataCallback fnCallback, int iWindowBits)
{
return new CHPZlibDecompressor(fnCallback, iWindowBits);
return new CHPZLibDecompressor(fnCallback, iWindowBits);
}
IHPDecompressor* CreateGZipDecompressor(Fn_DecompressDataCallback fnCallback)
{
return new CHPZlibDecompressor(fnCallback, MAX_WBITS + 32);
return new CHPZLibDecompressor(fnCallback, MAX_WBITS + 32);
}
int Compress(const BYTE* lpszSrc, DWORD dwSrcLen, BYTE* lpszDest, DWORD& dwDestLen)
@ -1330,7 +1330,7 @@ BOOL CHPBrotliCompressor::Process(const BYTE* pData, int iLength, BOOL bLast, PV
while(iAvlInLen > 0)
{
do
do
{
pNextOutData = szBuff;
iAvlOutLen = COMPRESS_BUFFER_SIZE;
@ -1407,7 +1407,7 @@ BOOL CHPBrotliDecompressor::Process(const BYTE* pData, int iLength, PVOID pConte
do
{
do
do
{
pNextOutData = szBuff;
iAvlOutLen = COMPRESS_BUFFER_SIZE;
@ -1437,7 +1437,7 @@ BOOL CHPBrotliDecompressor::Process(const BYTE* pData, int iLength, PVOID pConte
} while (iAvlOutLen == 0);
if(rs == BROTLI_DECODER_RESULT_SUCCESS)
break;;
break;
} while(rs == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT);
@ -1518,54 +1518,84 @@ BOOL CharsetConvert(LPCSTR lpszFromCharset, LPCSTR lpszToCharset, LPCSTR lpszInB
return !IS_HAS_ERROR(rs);
}
BOOL GbkToUnicode(const char szSrc[], WCHAR szDest[], int& iDestLength)
BOOL GbkToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int& iDestLength)
{
int iInBufLen = (szSrc != nullptr) ? (int)strlen(szSrc) + 1 : 0;
int iOutBufLen = (int)(iDestLength * sizeof(wchar_t));
int iInBufLen = (int)((iSrcLength > 0) ? iSrcLength : ((szSrc != nullptr) ? strlen(szSrc) + 1 : 0));
int iOutBufLen = (int)(iDestLength * sizeof(WCHAR));
BOOL isOK = CharsetConvert(CHARSET_GBK, CHARSET_UTF_32LE, szSrc, iInBufLen, (char*)szDest, iOutBufLen);
iDestLength = (int)(iOutBufLen / sizeof(wchar_t));
BOOL isOK = CharsetConvert(CHARSET_GBK, SYSTEM_CHARSET_UNICODE, szSrc, iInBufLen, (char*)szDest, iOutBufLen);
iDestLength = (int)(iOutBufLen / sizeof(WCHAR));
return isOK;
}
BOOL UnicodeToGbk(const WCHAR szSrc[], char szDest[], int& iDestLength)
BOOL UnicodeToGbkEx(const WCHAR szSrc[], int iSrcLength, char szDest[], int& iDestLength)
{
int iInBufLen = (szSrc != nullptr) ? (int)((wcslen(szSrc) + 1) * sizeof(wchar_t)) : 0;
int iInBufLen = (int)(((iSrcLength > 0) ? iSrcLength : ((szSrc != nullptr) ? wcslen(szSrc) + 1 : 0)) * sizeof(WCHAR));
return CharsetConvert(CHARSET_UTF_32LE, CHARSET_GBK, (LPCSTR)szSrc, iInBufLen, szDest, iDestLength);
return CharsetConvert(SYSTEM_CHARSET_UNICODE, CHARSET_GBK, (LPCSTR)szSrc, iInBufLen, szDest, iDestLength);
}
BOOL Utf8ToUnicode(const char szSrc[], WCHAR szDest[], int& iDestLength)
BOOL Utf8ToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int& iDestLength)
{
int iInBufLen = (szSrc != nullptr) ? (int)strlen(szSrc) + 1 : 0;
int iOutBufLen = (int)(iDestLength * sizeof(wchar_t));
int iInBufLen = (int)((iSrcLength > 0) ? iSrcLength : ((szSrc != nullptr) ? strlen(szSrc) + 1 : 0));
int iOutBufLen = (int)(iDestLength * sizeof(WCHAR));
BOOL isOK = CharsetConvert(CHARSET_UTF_8, CHARSET_UTF_32LE, szSrc, iInBufLen, (char*)szDest, iOutBufLen);
iDestLength = (int)(iOutBufLen / sizeof(wchar_t));
BOOL isOK = CharsetConvert(CHARSET_UTF_8, SYSTEM_CHARSET_UNICODE, szSrc, iInBufLen, (char*)szDest, iOutBufLen);
iDestLength = (int)(iOutBufLen / sizeof(WCHAR));
return isOK;
}
BOOL UnicodeToUtf8(const WCHAR szSrc[], char szDest[], int& iDestLength)
BOOL UnicodeToUtf8Ex(const WCHAR szSrc[], int iSrcLength, char szDest[], int& iDestLength)
{
int iInBufLen = (szSrc != nullptr) ? (int)((wcslen(szSrc) + 1) * sizeof(wchar_t)) : 0;
int iInBufLen = (int)(((iSrcLength > 0) ? iSrcLength : ((szSrc != nullptr) ? wcslen(szSrc) + 1 : 0)) * sizeof(WCHAR));
return CharsetConvert(CHARSET_UTF_32LE, CHARSET_UTF_8, (LPCSTR)szSrc, iInBufLen, szDest, iDestLength);
return CharsetConvert(SYSTEM_CHARSET_UNICODE, CHARSET_UTF_8, (LPCSTR)szSrc, iInBufLen, szDest, iDestLength);
}
BOOL GbkToUtf8(const char szSrc[], char szDest[], int& iDestLength)
BOOL GbkToUtf8Ex(const char szSrc[], int iSrcLength, char szDest[], int& iDestLength)
{
int iInBufLen = (szSrc != nullptr) ? (int)strlen(szSrc) + 1 : 0;
int iInBufLen = (int)((iSrcLength > 0) ? iSrcLength : ((szSrc != nullptr) ? strlen(szSrc) + 1 : 0));
return CharsetConvert(CHARSET_GBK, CHARSET_UTF_8, szSrc, iInBufLen, szDest, iDestLength);
}
BOOL Utf8ToGbk(const char szSrc[], char szDest[], int& iDestLength)
BOOL Utf8ToGbkEx(const char szSrc[], int iSrcLength, char szDest[], int& iDestLength)
{
int iInBufLen = (szSrc != nullptr) ? (int)strlen(szSrc) + 1 : 0;
int iInBufLen = (int)((iSrcLength > 0) ? iSrcLength : ((szSrc != nullptr) ? strlen(szSrc) + 1 : 0));
return CharsetConvert(CHARSET_UTF_8, CHARSET_GBK, szSrc, iInBufLen, szDest, iDestLength);
}
BOOL GbkToUnicode(const char szSrc[], WCHAR szDest[], int& iDestLength)
{
return GbkToUnicodeEx(szSrc, -1, szDest, iDestLength);
}
BOOL UnicodeToGbk(const WCHAR szSrc[], char szDest[], int& iDestLength)
{
return UnicodeToGbkEx(szSrc, -1, szDest, iDestLength);
}
BOOL Utf8ToUnicode(const char szSrc[], WCHAR szDest[], int& iDestLength)
{
return Utf8ToUnicodeEx(szSrc, -1, szDest, iDestLength);
}
BOOL UnicodeToUtf8(const WCHAR szSrc[], char szDest[], int& iDestLength)
{
return UnicodeToUtf8Ex(szSrc, -1, szDest, iDestLength);
}
BOOL GbkToUtf8(const char szSrc[], char szDest[], int& iDestLength)
{
return GbkToUtf8Ex(szSrc, -1, szDest, iDestLength);
}
BOOL Utf8ToGbk(const char szSrc[], char szDest[], int& iDestLength)
{
return Utf8ToGbkEx(szSrc, -1, szDest, iDestLength);
}
#endif

View File

@ -218,6 +218,51 @@ typedef struct hp_sockaddr
} HP_SOCKADDR, *HP_PSOCKADDR;
typedef struct hp_scope_host
{
LPCTSTR addr;
LPCTSTR name;
BOOL bNeedFree;
hp_scope_host(LPCTSTR lpszOriginAddress)
{
ASSERT(lpszOriginAddress != nullptr);
LPCTSTR lpszFind = ::StrChr(lpszOriginAddress, HOST_SEPARATOR_CHAR);
if(lpszFind == nullptr)
{
addr = lpszOriginAddress;
name = lpszOriginAddress;
bNeedFree = FALSE;
}
else
{
int i = (int)(lpszFind - lpszOriginAddress);
int iSize = (int)lstrlen(lpszOriginAddress) + 1;
LPTSTR lpszCopy = new TCHAR[iSize];
::memcpy((PVOID)lpszCopy, (PVOID)lpszOriginAddress, iSize * sizeof(TCHAR));
lpszCopy[i] = 0;
addr = lpszCopy;
name = lpszCopy + i + 1;
bNeedFree = TRUE;
if(::IsStrEmpty(name))
name = addr;
}
}
~hp_scope_host()
{
if(bNeedFree)
delete[] addr;
}
} HP_SCOPE_HOST, *HP_PSCOPE_HOST;
struct TNodeBufferObj : public TItem
{
using __super = TItem;
@ -757,14 +802,34 @@ int ManualCloseSocket(SOCKET sock, int iShutdownFlag = 0xFF, BOOL bGraceful = TR
#ifdef _ICONV_SUPPORT
#define CHARSET_GBK "GBK"
#define CHARSET_UTF_8 "UTF-8"
#define CHARSET_UTF_16LE "UTF-16LE"
#define CHARSET_UTF_32LE "UTF-32LE"
#define CHARSET_GBK "GBK"
#define CHARSET_UTF_8 "UTF-8"
#define CHARSET_UTF_16LE "UTF-16LE"
#define CHARSET_UTF_32LE "UTF-32LE"
#define CHARSET_UTF_16BE "UTF-16BE"
#define CHARSET_UTF_32BE "UTF-32BE"
// 系统 UNICODE 字符集
#define SYSTEM_CHARSET_UNICODE ( (sizeof(WCHAR) == 4) \
? (IsLittleEndian() ? CHARSET_UTF_32LE : CHARSET_UTF_32BE) \
: (IsLittleEndian() ? CHARSET_UTF_16LE : CHARSET_UTF_16BE) )
// Charset A -> Charset B
BOOL CharsetConvert(LPCSTR lpszFromCharset, LPCSTR lpszToCharset, LPCSTR lpszInBuf, int iInBufLen, LPSTR lpszOutBuf, int& iOutBufLen);
// GBK -> UNICODE
BOOL GbkToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int& iDestLength);
// UNICODE -> GBK
BOOL UnicodeToGbkEx(const WCHAR szSrc[], int iSrcLength, char szDest[], int& iDestLength);
// UTF8 -> UNICODE
BOOL Utf8ToUnicodeEx(const char szSrc[], int iSrcLength, WCHAR szDest[], int& iDestLength);
// UNICODE -> UTF8
BOOL UnicodeToUtf8Ex(const WCHAR szSrc[], int iSrcLength, char szDest[], int& iDestLength);
// GBK -> UTF8
BOOL GbkToUtf8Ex(const char szSrc[], int iSrcLength, char szDest[], int& iDestLength);
// UTF8 -> GBK
BOOL Utf8ToGbkEx(const char szSrc[], int iSrcLength, char szDest[], int& iDestLength);
// GBK -> UNICODE
BOOL GbkToUnicode(const char szSrc[], WCHAR szDest[], int& iDestLength);
// UNICODE -> GBK
@ -806,7 +871,7 @@ void DestroyDecompressor(IHPDecompressor* pDecompressor);
#ifdef _ZLIB_SUPPORT
/* ZLib 压缩器 */
class CHPZlibCompressor : public IHPCompressor
class CHPZLibCompressor : public IHPCompressor
{
public:
virtual BOOL Process(const BYTE* pData, int iLength, BOOL bLast, PVOID pContext = nullptr);
@ -814,8 +879,8 @@ public:
virtual BOOL Reset();
public:
CHPZlibCompressor(Fn_CompressDataCallback fnCallback, int iWindowBits = MAX_WBITS, int iLevel = Z_DEFAULT_COMPRESSION, int iMethod = Z_DEFLATED, int iMemLevel = MAX_MEM_LEVEL, int iStrategy = Z_DEFAULT_STRATEGY);
virtual ~CHPZlibCompressor();
CHPZLibCompressor(Fn_CompressDataCallback fnCallback, int iWindowBits = MAX_WBITS, int iLevel = Z_DEFAULT_COMPRESSION, int iMethod = Z_DEFLATED, int iMemLevel = MAX_MEM_LEVEL, int iStrategy = Z_DEFAULT_STRATEGY);
virtual ~CHPZLibCompressor();
private:
Fn_CompressDataCallback m_fnCallback;
@ -824,7 +889,7 @@ private:
};
/* ZLib 解压器 */
class CHPZlibDecompressor : public IHPDecompressor
class CHPZLibDecompressor : public IHPDecompressor
{
public:
virtual BOOL Process(const BYTE* pData, int iLength, PVOID pContext = nullptr);
@ -832,8 +897,8 @@ public:
virtual BOOL Reset();
public:
CHPZlibDecompressor(Fn_DecompressDataCallback fnCallback, int iWindowBits = MAX_WBITS);
virtual ~CHPZlibDecompressor();
CHPZLibDecompressor(Fn_DecompressDataCallback fnCallback, int iWindowBits = MAX_WBITS);
virtual ~CHPZLibDecompressor();
private:
Fn_DecompressDataCallback m_fnCallback;
@ -917,7 +982,6 @@ IHPCompressor* CreateBrotliCompressor(Fn_CompressDataCallback fnCallback, int iQ
/* 创建 Brotli 解压器对象 */
IHPDecompressor* CreateBrotliDecompressor(Fn_DecompressDataCallback fnCallback);
// Brotli 压缩返回值0 -> 成功,-3 -> 输入数据不正确,-5 -> 输出缓冲区不足)
int BrotliCompress(const BYTE* lpszSrc, DWORD dwSrcLen, BYTE* lpszDest, DWORD& dwDestLen);
// Brotli 高级压缩返回值0 -> 成功,-3 -> 输入数据不正确,-5 -> 输出缓冲区不足)

View File

@ -252,7 +252,9 @@ BOOL CTcpAgent::Connect(LPCTSTR lpszRemoteAddress, USHORT usPort, CONNID* pdwCon
result = ERROR_INVALID_STATE;
else
{
result = CreateClientSocket(lpszRemoteAddress, usPort, lpszLocalAddress, usLocalPort, soClient, addr);
HP_SCOPE_HOST host(lpszRemoteAddress);
result = CreateClientSocket(host.addr, usPort, lpszLocalAddress, usLocalPort, soClient, addr);
if(result == NO_ERROR)
{
@ -260,7 +262,7 @@ BOOL CTcpAgent::Connect(LPCTSTR lpszRemoteAddress, USHORT usPort, CONNID* pdwCon
if(result == NO_ERROR)
{
result = ConnectToServer(*pdwConnID, lpszRemoteAddress, soClient, addr, pExtra);
result = ConnectToServer(*pdwConnID, host.name, soClient, addr, pExtra);
soClient = INVALID_SOCKET;
}
}
@ -342,13 +344,13 @@ int CTcpAgent::PrepareConnect(CONNID& dwConnID, SOCKET soClient)
return NO_ERROR;
}
int CTcpAgent::ConnectToServer(CONNID dwConnID, LPCTSTR lpszRemoteAddress, SOCKET soClient, const HP_SOCKADDR& addr, PVOID pExtra)
int CTcpAgent::ConnectToServer(CONNID dwConnID, LPCTSTR lpszRemoteHostName, SOCKET soClient, const HP_SOCKADDR& addr, PVOID pExtra)
{
TAgentSocketObj* pSocketObj = GetFreeSocketObj(dwConnID, soClient);
CReentrantCriSecLock locallock(pSocketObj->csIo);
AddClientSocketObj(dwConnID, pSocketObj, addr, lpszRemoteAddress, pExtra);
AddClientSocketObj(dwConnID, pSocketObj, addr, lpszRemoteHostName, pExtra);
int result = HAS_ERROR;
@ -450,13 +452,13 @@ BOOL CTcpAgent::InvalidSocketObj(TAgentSocketObj* pSocketObj)
return TAgentSocketObj::InvalidSocketObj(pSocketObj);
}
void CTcpAgent::AddClientSocketObj(CONNID dwConnID, TAgentSocketObj* pSocketObj, const HP_SOCKADDR& remoteAddr, LPCTSTR lpszRemoteAddress, PVOID pExtra)
void CTcpAgent::AddClientSocketObj(CONNID dwConnID, TAgentSocketObj* pSocketObj, const HP_SOCKADDR& remoteAddr, LPCTSTR lpszRemoteHostName, PVOID pExtra)
{
ASSERT(FindSocketObj(dwConnID) == nullptr);
pSocketObj->connTime = ::TimeGetTime();
pSocketObj->activeTime = pSocketObj->connTime;
pSocketObj->host = lpszRemoteAddress;
pSocketObj->host = lpszRemoteHostName;
pSocketObj->extra = pExtra;
pSocketObj->SetConnected(CST_CONNECTING);

View File

@ -206,13 +206,13 @@ private:
void DeleteSocketObj (TAgentSocketObj* pSocketObj);
BOOL InvalidSocketObj (TAgentSocketObj* pSocketObj);
void ReleaseGCSocketObj (BOOL bForce = FALSE);
void AddClientSocketObj (CONNID dwConnID, TAgentSocketObj* pSocketObj, const HP_SOCKADDR& remoteAddr, LPCTSTR lpszRemoteAddress, PVOID pExtra);
void AddClientSocketObj (CONNID dwConnID, TAgentSocketObj* pSocketObj, const HP_SOCKADDR& remoteAddr, LPCTSTR lpszRemoteHostName, PVOID pExtra);
void CloseClientSocketObj(TAgentSocketObj* pSocketObj, EnSocketCloseFlag enFlag = SCF_NONE, EnSocketOperation enOperation = SO_UNKNOWN, int iErrorCode = 0, int iShutdownFlag = SHUT_WR);
private:
int CreateClientSocket(LPCTSTR lpszRemoteAddress, USHORT usPort, LPCTSTR lpszLocalAddress, USHORT usLocalPort, SOCKET& soClient, HP_SOCKADDR& addr);
int PrepareConnect (CONNID& dwConnID, SOCKET soClient);
int ConnectToServer (CONNID dwConnID, LPCTSTR lpszRemoteAddress, SOCKET soClient, const HP_SOCKADDR& addr, PVOID pExtra);
int ConnectToServer (CONNID dwConnID, LPCTSTR lpszRemoteHostName, SOCKET soClient, const HP_SOCKADDR& addr, PVOID pExtra);
VOID HandleCmdSend (CONNID dwConnID);
VOID HandleCmdUnpause (CONNID dwConnID);

View File

@ -128,7 +128,9 @@ BOOL CTcpClient::CheckStoping()
BOOL CTcpClient::CreateClientSocket(LPCTSTR lpszRemoteAddress, HP_SOCKADDR& addrRemote, USHORT usPort, LPCTSTR lpszBindAddress, HP_SOCKADDR& addrBind)
{
if(!::GetSockAddrByHostName(lpszRemoteAddress, usPort, addrRemote))
HP_SCOPE_HOST host(lpszRemoteAddress);
if(!::GetSockAddrByHostName(host.addr, usPort, addrRemote))
return FALSE;
if(::IsStrNotEmpty(lpszBindAddress))
@ -153,7 +155,7 @@ BOOL CTcpClient::CreateClientSocket(LPCTSTR lpszRemoteAddress, HP_SOCKADDR& addr
VERIFY(::SSO_ReuseAddress(m_soClient, m_enReusePolicy) == NO_ERROR);
VERIFY(::SSO_NoDelay(m_soClient, m_bNoDelay) == NO_ERROR);
SetRemoteHost(lpszRemoteAddress, usPort);
SetRemoteHost(host.name, usPort);
return TRUE;
}

View File

@ -59,19 +59,29 @@ public:
}
protected:
virtual EnHandleResult DoFireHandShake(TAgentSocketObj* pSocketObj)
virtual EnHandleResult DoFireConnect(TAgentSocketObj* pSocketObj)
{
EnHandleResult result = __super::DoFireHandShake(pSocketObj);
EnHandleResult result = __super::DoFireConnect(pSocketObj);
if(result != HR_ERROR)
{
TBuffer* pBuffer = m_bfPool.PickFreeBuffer(pSocketObj->connID);
VERIFY(SetConnectionReserved(pSocketObj, TBufferPackInfo::Construct(pBuffer)));
ENSURE(SetConnectionReserved(pSocketObj, TBufferPackInfo::Construct(pBuffer)));
}
return result;
}
virtual EnHandleResult DoFireHandShake(TAgentSocketObj* pSocketObj)
{
EnHandleResult result = __super::DoFireHandShake(pSocketObj);
if(result == HR_ERROR)
ReleaseConnectionExtra(pSocketObj);
return result;
}
virtual EnHandleResult DoFireReceive(TAgentSocketObj* pSocketObj, const BYTE* pData, int iLength)
{
TBufferPackInfo* pInfo = nullptr;
@ -88,14 +98,7 @@ protected:
{
EnHandleResult result = __super::DoFireClose(pSocketObj, enOperation, iErrorCode);
TBufferPackInfo* pInfo = nullptr;
GetConnectionReserved(pSocketObj, (PVOID*)&pInfo);
if(pInfo != nullptr)
{
m_bfPool.PutFreeBuffer(pInfo->pBuffer);
TBufferPackInfo::Destruct(pInfo);
}
ReleaseConnectionExtra(pSocketObj);
return result;
}
@ -161,11 +164,24 @@ public:
virtual USHORT GetPackHeaderFlag() {return m_usHeaderFlag;}
private:
void ReleaseConnectionExtra(TAgentSocketObj* pSocketObj)
{
TBufferPackInfo* pInfo = nullptr;
GetConnectionReserved(pSocketObj, (PVOID*)&pInfo);
if(pInfo != nullptr)
{
m_bfPool.PutFreeBuffer(pInfo->pBuffer);
TBufferPackInfo::Destruct(pInfo);
ENSURE(SetConnectionReserved(pSocketObj, nullptr));
}
}
EnHandleResult DoFireSuperReceive(TAgentSocketObj* pSocketObj, const BYTE* pData, int iLength)
{return __super::DoFireReceive(pSocketObj, pData, iLength);}
friend EnHandleResult ParsePack<> (CTcpPackAgentT* pThis, TBufferPackInfo* pInfo, TBuffer* pBuffer, TAgentSocketObj* pSocket,
DWORD dwMaxPackSize, USHORT usPackHeaderFlag);
friend EnHandleResult ParsePack<>(CTcpPackAgentT* pThis, TBufferPackInfo* pInfo, TBuffer* pBuffer, TAgentSocketObj* pSocket, DWORD dwMaxPackSize, USHORT usPackHeaderFlag);
public:
CTcpPackAgentT(ITcpAgentListener* pListener)

View File

@ -59,19 +59,29 @@ public:
}
protected:
virtual EnHandleResult DoFireHandShake(TSocketObj* pSocketObj)
virtual EnHandleResult DoFireAccept(TSocketObj* pSocketObj)
{
EnHandleResult result = __super::DoFireHandShake(pSocketObj);
EnHandleResult result = __super::DoFireAccept(pSocketObj);
if(result != HR_ERROR)
{
TBuffer* pBuffer = m_bfPool.PickFreeBuffer(pSocketObj->connID);
VERIFY(SetConnectionReserved(pSocketObj, TBufferPackInfo::Construct(pBuffer)));
ENSURE(SetConnectionReserved(pSocketObj, TBufferPackInfo::Construct(pBuffer)));
}
return result;
}
virtual EnHandleResult DoFireHandShake(TSocketObj* pSocketObj)
{
EnHandleResult result = __super::DoFireHandShake(pSocketObj);
if(result == HR_ERROR)
ReleaseConnectionExtra(pSocketObj);
return result;
}
virtual EnHandleResult DoFireReceive(TSocketObj* pSocketObj, const BYTE* pData, int iLength)
{
TBufferPackInfo* pInfo = nullptr;
@ -88,14 +98,7 @@ protected:
{
EnHandleResult result = __super::DoFireClose(pSocketObj, enOperation, iErrorCode);
TBufferPackInfo* pInfo = nullptr;
GetConnectionReserved(pSocketObj, (PVOID*)&pInfo);
if(pInfo != nullptr)
{
m_bfPool.PutFreeBuffer(pInfo->pBuffer);
TBufferPackInfo::Destruct(pInfo);
}
ReleaseConnectionExtra(pSocketObj);
return result;
}
@ -161,11 +164,24 @@ public:
virtual USHORT GetPackHeaderFlag() {return m_usHeaderFlag;}
private:
void ReleaseConnectionExtra(TSocketObj* pSocketObj)
{
TBufferPackInfo* pInfo = nullptr;
GetConnectionReserved(pSocketObj, (PVOID*)&pInfo);
if(pInfo != nullptr)
{
m_bfPool.PutFreeBuffer(pInfo->pBuffer);
TBufferPackInfo::Destruct(pInfo);
ENSURE(SetConnectionReserved(pSocketObj, nullptr));
}
}
EnHandleResult DoFireSuperReceive(TSocketObj* pSocketObj, const BYTE* pData, int iLength)
{return __super::DoFireReceive(pSocketObj, pData, iLength);}
friend EnHandleResult ParsePack<> (CTcpPackServerT* pThis, TBufferPackInfo* pInfo, TBuffer* pBuffer, TSocketObj* pSocket,
DWORD dwMaxPackSize, USHORT usPackHeaderFlag);
friend EnHandleResult ParsePack<>(CTcpPackServerT* pThis, TBufferPackInfo* pInfo, TBuffer* pBuffer, TSocketObj* pSocket, DWORD dwMaxPackSize, USHORT usPackHeaderFlag);
public:
CTcpPackServerT(ITcpServerListener* pListener)

View File

@ -58,19 +58,29 @@ public:
}
protected:
virtual EnHandleResult DoFireHandShake(TAgentSocketObj* pSocketObj)
virtual EnHandleResult DoFireConnect(TAgentSocketObj* pSocketObj)
{
EnHandleResult result = __super::DoFireHandShake(pSocketObj);
EnHandleResult result = __super::DoFireConnect(pSocketObj);
if(result != HR_ERROR)
{
TBuffer* pBuffer = m_bfPool.PutCacheBuffer(pSocketObj->connID);
VERIFY(SetConnectionReserved(pSocketObj, pBuffer));
ENSURE(SetConnectionReserved(pSocketObj, pBuffer));
}
return result;
}
virtual EnHandleResult DoFireHandShake(TAgentSocketObj* pSocketObj)
{
EnHandleResult result = __super::DoFireHandShake(pSocketObj);
if(result == HR_ERROR)
ReleaseConnectionExtra(pSocketObj);
return result;
}
virtual EnHandleResult DoFireReceive(TAgentSocketObj* pSocketObj, const BYTE* pData, int iLength)
{
TBuffer* pBuffer = nullptr;
@ -86,11 +96,7 @@ protected:
{
EnHandleResult result = __super::DoFireClose(pSocketObj, enOperation, iErrorCode);
TBuffer* pBuffer = nullptr;
GetConnectionReserved(pSocketObj, (PVOID*)&pBuffer);
if(pBuffer != nullptr)
m_bfPool.PutFreeBuffer(pBuffer);
ReleaseConnectionExtra(pSocketObj);
return result;
}
@ -119,6 +125,19 @@ protected:
m_bfPool.Prepare();
}
private:
void ReleaseConnectionExtra(TAgentSocketObj* pSocketObj)
{
TBuffer* pBuffer = nullptr;
GetConnectionReserved(pSocketObj, (PVOID*)&pBuffer);
if(pBuffer != nullptr)
{
m_bfPool.PutFreeBuffer(pBuffer);
ENSURE(SetConnectionReserved(pSocketObj, nullptr));
}
}
public:
CTcpPullAgentT(ITcpAgentListener* pListener)
: T(pListener)

View File

@ -58,19 +58,29 @@ public:
}
protected:
virtual EnHandleResult DoFireHandShake(TSocketObj* pSocketObj)
virtual EnHandleResult DoFireAccept(TSocketObj* pSocketObj)
{
EnHandleResult result = __super::DoFireHandShake(pSocketObj);
EnHandleResult result = __super::DoFireAccept(pSocketObj);
if(result != HR_ERROR)
{
TBuffer* pBuffer = m_bfPool.PutCacheBuffer(pSocketObj->connID);
VERIFY(SetConnectionReserved(pSocketObj, pBuffer));
ENSURE(SetConnectionReserved(pSocketObj, pBuffer));
}
return result;
}
virtual EnHandleResult DoFireHandShake(TSocketObj* pSocketObj)
{
EnHandleResult result = __super::DoFireHandShake(pSocketObj);
if(result == HR_ERROR)
ReleaseConnectionExtra(pSocketObj);
return result;
}
virtual EnHandleResult DoFireReceive(TSocketObj* pSocketObj, const BYTE* pData, int iLength)
{
TBuffer* pBuffer = nullptr;
@ -86,11 +96,7 @@ protected:
{
EnHandleResult result = __super::DoFireClose(pSocketObj, enOperation, iErrorCode);
TBuffer* pBuffer = nullptr;
GetConnectionReserved(pSocketObj, (PVOID*)&pBuffer);
if(pBuffer != nullptr)
m_bfPool.PutFreeBuffer(pBuffer);
ReleaseConnectionExtra(pSocketObj);
return result;
}
@ -119,6 +125,19 @@ protected:
m_bfPool.Prepare();
}
private:
void ReleaseConnectionExtra(TSocketObj* pSocketObj)
{
TBuffer* pBuffer = nullptr;
GetConnectionReserved(pSocketObj, (PVOID*)&pBuffer);
if(pBuffer != nullptr)
{
m_bfPool.PutFreeBuffer(pBuffer);
ENSURE(SetConnectionReserved(pSocketObj, nullptr));
}
}
public:
CTcpPullServerT(ITcpServerListener* pListener)
: T(pListener)

View File

@ -132,10 +132,13 @@ BOOL CUdpCast::CheckStoping()
BOOL CUdpCast::CreateClientSocket(LPCTSTR lpszRemoteAddress, USHORT usPort, LPCTSTR lpszBindAddress, HP_SOCKADDR& bindAddr)
{
if(m_enCastMode == CM_BROADCAST && ::IsStrEmpty(lpszRemoteAddress))
lpszRemoteAddress = DEFAULT_IPV4_BROAD_CAST_ADDRESS;
HP_SCOPE_HOST host(lpszRemoteAddress);
LPCTSTR lpszRealAddress = host.addr;
if(!::GetSockAddrByHostName(lpszRemoteAddress, usPort, m_castAddr))
if(m_enCastMode == CM_BROADCAST && ::IsStrEmpty(lpszRealAddress))
lpszRealAddress = DEFAULT_IPV4_BROAD_CAST_ADDRESS;
if(!::GetSockAddrByHostName(lpszRealAddress, usPort, m_castAddr))
return FALSE;
if(::IsStrEmpty(lpszBindAddress))
@ -169,7 +172,7 @@ BOOL CUdpCast::CreateClientSocket(LPCTSTR lpszRemoteAddress, USHORT usPort, LPCT
VERIFY(::fcntl_SETFL(m_soClient, O_NOATIME | O_NONBLOCK | O_CLOEXEC));
VERIFY(::SSO_ReuseAddress(m_soClient, m_enReusePolicy) == NO_ERROR);
SetRemoteHost(lpszRemoteAddress, usPort);
SetRemoteHost(host.name, usPort);
return TRUE;
}

View File

@ -127,7 +127,9 @@ BOOL CUdpClient::CheckStoping()
BOOL CUdpClient::CreateClientSocket(LPCTSTR lpszRemoteAddress, HP_SOCKADDR& addrRemote, USHORT usPort, LPCTSTR lpszBindAddress, HP_SOCKADDR& addrBind)
{
if(!::GetSockAddrByHostName(lpszRemoteAddress, usPort, addrRemote))
HP_SCOPE_HOST host(lpszRemoteAddress);
if(!::GetSockAddrByHostName(host.addr, usPort, addrRemote))
return FALSE;
if(::IsStrNotEmpty(lpszBindAddress))
@ -149,7 +151,7 @@ BOOL CUdpClient::CreateClientSocket(LPCTSTR lpszRemoteAddress, HP_SOCKADDR& addr
VERIFY(::SSO_ReuseAddress(m_soClient, m_enReusePolicy) == NO_ERROR);
SetRemoteHost(lpszRemoteAddress, usPort);
SetRemoteHost(host.name, usPort);
return TRUE;
}

View File

@ -366,7 +366,7 @@ BOOL CUdpNode::DoSendPackets(HP_SOCKADDR& addrRemote, const WSABUF pBuffers[], i
ASSERT(pBuffers && iCount > 0);
if(!pBuffers || iCount <= 0)
return ERROR_INVALID_PARAMETER;;
return ERROR_INVALID_PARAMETER;
if(!IsValid())
{

View File

@ -1126,7 +1126,7 @@ BOOL CUdpServer::SendPackets(CONNID dwConnID, const WSABUF pBuffers[], int iCoun
ASSERT(pBuffers && iCount > 0);
if(!pBuffers || iCount <= 0)
return ERROR_INVALID_PARAMETER;;
return ERROR_INVALID_PARAMETER;
TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);

View File

@ -53,10 +53,6 @@ using namespace std;
#else
typedef atomic_long atomic_tid;
#if !defined(EFD_SEMAPHORE)
#define EFD_SEMAPHORE 00000001
#endif
#if defined(stdout)
#undef stdout
#endif

View File

@ -164,6 +164,10 @@ DWORD GetDefaultWorkerThreadCount();
#include<android/api-level.h>
#if !defined(EFD_SEMAPHORE)
#define EFD_SEMAPHORE 00000001
#endif
#define pthread_cancel(t)
#if defined(__ANDROID_API__)

View File

@ -54,10 +54,10 @@ Note the dependency header files and library paths in the example.
> CMakeLists.txt
```
include_directories(/opt/local/include)
link_directories(/opt/local/lib)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(unofficial-iconv CONFIG REQUIRED)
link_libraries(ssl iconv z crypto)
add_definitions(-D_NEED_HTTP -D_SSL_SUPPORT -D_NEED_SSL)
```
@ -82,8 +82,8 @@ Full support for official usage examples
### How to install related dependencies?
By using `Brew` or `MacPort`; `MacPort` is used in the example.
By using `vcpkg`, `Brew` or `MacPort`; `vcpkg` is used in the example.
The following dependencies are installed:
`openssl`, `zlib`
`openssl`, `iconv`, `zlib`

View File

@ -53,10 +53,10 @@ HP-Socket for MacOS版本只是提供与其他平台上相同的回调接口
> CMakeLists.txt
```
include_directories(/opt/local/include)
link_directories(/opt/local/lib)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(unofficial-iconv CONFIG REQUIRED)
link_libraries(ssl iconv z crypto)
add_definitions(-D_NEED_HTTP -D_SSL_SUPPORT -D_NEED_SSL)
```
@ -81,8 +81,8 @@ HPSocket-SSL.h
#### 相关依赖如何安装?
通过使用brew或MacPort例子中使用的是MacPort
通过使用vcpkg、brew或MacPort例子中使用的是vcpkg管理toolchain
具体安装了以下依赖:
`openssl`, `zlib`
`openssl`, `iconv`, `zlib`

View File

@ -1,3 +1,18 @@
# ======================================== #
HP-Socket v5.8.8 API 更新列表:
# ======================================== #
--------------------
1、Global:
--------------------
SYS_CodePageToUnicodeEx (增加)
SYS_UnicodeToCodePageEx (增加)
SYS_GbkToUnicodeEx (增加)
SYS_UnicodeToGbkEx (增加)
SYS_Utf8ToUnicodeEx (增加)
SYS_UnicodeToUtf8Ex (增加)
SYS_GbkToUtf8Ex (增加)
SYS_Utf8ToGbkEx (增加)
# ======================================== #
HP-Socket v5.8.6 API 更新列表:
# ======================================== #

View File

@ -1,3 +1,22 @@
==========================================================================================
v5.8.8 更新:
==========================================================================================
> 主要更新:
-----------------
1、Client/Agent 连接服务端时支持指定主机名称,格式:<hostaddress>[^<hostname>],其中 ^<hostname> 可选。应用场景之一:通过代理服务器向目标服务器传递 SSL SNI hostname
2、增加字符编码转换系列函数参考Chang-Log.txt支持指定源字符串长度
3、修复 SSL Pull/Pack Server/Agent 组件在手工启动SSLSetSSLAutoStart(FALSE))场景下的异常问题
> 第三方库更新:
-----------------
1、zlib 升级到 1.2.12 版本
2、openssl 升级到 1.1.1n 版本
> 升级说明:
-----------------
1、HP-Socket v5.8.8 完全兼容 HP-Socket v5.8.7 版本,可以直接替换升级
==========================================================================================
v5.8.7 更新:
==========================================================================================

Some files were not shown because too many files have changed in this diff Show More