Skip to content

Commit

Permalink
TgBot++: socket: Unify length_t to size_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Royna2544 committed Jun 12, 2024
1 parent 275f65d commit bc327bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/socket/include/TgBotSocket_Export.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <zlib.h>

#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
Expand Down Expand Up @@ -54,14 +55,15 @@ enum class Command : std::int32_t {
*/

struct TGSOCKET_ATTR_PACKED PacketHeader {
using length_type = uint64_t;
using length_type = size_t;
constexpr static int64_t MAGIC_VALUE_BASE = 0xDEADFACE;
// Version number, to be increased on breaking changes
// 1: Initial version
// 2: Added crc32 checks to packet data
// 3: Uploadfile has a sha256sum check, std::array conversions
// 4: Move CMD_UPLOAD_FILE_DRY to internal namespace
// 5: Use the packed attribute for structs
// 6: Use size_t for length_type
constexpr static int DATA_VERSION = 5;
constexpr static int64_t MAGIC_VALUE = MAGIC_VALUE_BASE + DATA_VERSION;

Expand Down
3 changes: 2 additions & 1 deletion src/socket/interface/SocketBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <TgBotSocket_Export.hpp>

#include <SocketDescriptor_defs.hpp>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <functional>
Expand Down Expand Up @@ -30,7 +31,7 @@ struct SocketInterfaceBase {
// addr is used as void pointer to maintain platform independence.
using listener_callback_t = std::function<bool(SocketConnContext ctx)>;
using dummy_listen_buf_t = char;
using buffer_len_t = uint64_t;
using buffer_len_t = TgBotSocket::PacketHeader::length_type;

constexpr static int kTgBotHostPort = 50000;

Expand Down

0 comments on commit bc327bd

Please sign in to comment.