mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-30 01:06:55 +08:00
commit
a3e16c18b1
@ -339,6 +339,7 @@ set(cxx-sources
|
|||||||
session_base.cpp
|
session_base.cpp
|
||||||
signaler.cpp
|
signaler.cpp
|
||||||
socket_base.cpp
|
socket_base.cpp
|
||||||
|
stream.cpp
|
||||||
stream_engine.cpp
|
stream_engine.cpp
|
||||||
sub.cpp
|
sub.cpp
|
||||||
tcp.cpp
|
tcp.cpp
|
||||||
|
@ -54,15 +54,15 @@ char *
|
|||||||
Z85_encode (char *dest, uint8_t *data, size_t size)
|
Z85_encode (char *dest, uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
assert (size % 4 == 0);
|
assert (size % 4 == 0);
|
||||||
uint char_nbr = 0;
|
unsigned int char_nbr = 0;
|
||||||
uint byte_nbr = 0;
|
unsigned int byte_nbr = 0;
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
while (byte_nbr < size) {
|
while (byte_nbr < size) {
|
||||||
// Accumulate value in base 256 (binary)
|
// Accumulate value in base 256 (binary)
|
||||||
value = value * 256 + data [byte_nbr++];
|
value = value * 256 + data [byte_nbr++];
|
||||||
if (byte_nbr % 4 == 0) {
|
if (byte_nbr % 4 == 0) {
|
||||||
// Output value in base 85
|
// Output value in base 85
|
||||||
uint divisor = 85 * 85 * 85 * 85;
|
unsigned int divisor = 85 * 85 * 85 * 85;
|
||||||
while (divisor) {
|
while (divisor) {
|
||||||
dest [char_nbr++] = encoder [value / divisor % 85];
|
dest [char_nbr++] = encoder [value / divisor % 85];
|
||||||
divisor /= 85;
|
divisor /= 85;
|
||||||
@ -85,15 +85,15 @@ uint8_t *
|
|||||||
Z85_decode (uint8_t *dest, char *string)
|
Z85_decode (uint8_t *dest, char *string)
|
||||||
{
|
{
|
||||||
assert (strlen (string) % 5 == 0);
|
assert (strlen (string) % 5 == 0);
|
||||||
uint byte_nbr = 0;
|
unsigned int byte_nbr = 0;
|
||||||
uint char_nbr = 0;
|
unsigned int char_nbr = 0;
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
while (char_nbr < strlen (string)) {
|
while (char_nbr < strlen (string)) {
|
||||||
// Accumulate value in base 85
|
// Accumulate value in base 85
|
||||||
value = value * 85 + decoder [(uint8_t) string [char_nbr++] - 32];
|
value = value * 85 + decoder [(uint8_t) string [char_nbr++] - 32];
|
||||||
if (char_nbr % 5 == 0) {
|
if (char_nbr % 5 == 0) {
|
||||||
// Output value in base 256
|
// Output value in base 256
|
||||||
uint divisor = 256 * 256 * 256;
|
unsigned int divisor = 256 * 256 * 256;
|
||||||
while (divisor) {
|
while (divisor) {
|
||||||
dest [byte_nbr++] = value / divisor % 256;
|
dest [byte_nbr++] = value / divisor % 256;
|
||||||
divisor /= 256;
|
divisor /= 256;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user