Skip to content

Commit

Permalink
Merge pull request #108 from Starry-OvO/develop
Browse files Browse the repository at this point in the history
Update 3.2.2
  • Loading branch information
lumina37 authored Feb 20, 2023
2 parents b9070e7 + 19d8427 commit 411814c
Show file tree
Hide file tree
Showing 66 changed files with 900 additions and 1,153 deletions.
42 changes: 16 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
.*/
build/
dist/
log/
*.egg-info
*

*.toml
*.exe
*.csv
*.xlsx
*.md
*.cmd
*.jpg
*.pdb
*.bin
*.txt

/*.py
!.gitattributes
!.gitignore
!LICENSE
!mkdocs.yml
!pyproject.toml
!README.md
!setup.py

!.github
!.github/**
!3rdparty
!3rdparty/**
!aiotieba
!aiotieba/**
!docs
!docs/**
!setup.py

!README.md
!ReadMe.md
!requirements.txt
!pyproject.toml
!tests
!tests/**

*.code-workspace
*.pyc
*.pyd
*.py[cd]
__pycache__
58 changes: 28 additions & 30 deletions 3rdparty/base32/base32.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* THE SOFTWARE.
**/

#include <assert.h> // assert()
#include <limits.h> // CHAR_BIT
#include <assert.h> // assert()
#include <limits.h> // CHAR_BIT

#include "base32.h"

Expand All @@ -44,7 +44,7 @@
* systems that don't have exactly 8 bits per (unsigned) char.
**/

static size_t min(size_t x, size_t y)
static inline int min(int x, int y)
{
return x < y ? x : y;
}
Expand All @@ -54,7 +54,7 @@ static const unsigned char PADDING_CHAR = '=';
/**
* Pad the given buffer with len padding characters.
*/
static void pad(unsigned char *buf, int len)
static inline void pad(unsigned char *buf, int len)
{
for (int i = 0; i < len; i++)
buf[i] = PADDING_CHAR;
Expand All @@ -64,10 +64,10 @@ static void pad(unsigned char *buf, int len)
* This convert a 5 bits value into a base32 character.
* Only the 5 least significant bits are used.
*/
static unsigned char encode_char(unsigned char c)
static inline unsigned char encode_char(unsigned char c)
{
static unsigned char base32[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
return base32[c & 0x1F]; // 0001 1111
return base32[c & 0x1F]; // 0001 1111
}

/**
Expand All @@ -80,15 +80,15 @@ static unsigned char encode_char(unsigned char c)
* +--------+--------+
* octet 1 | octet 2
*/
static int get_octet(int block)
static inline int get_octet(int block)
{
assert(block >= 0 && block < 8);
return (block*5) / 8;
return (block * 5) / 8;
}

/**
* Given a block id between 0 and 7 inclusive, this will return how many bits
* we can drop at the end of the octet in which this block starts.
* we can drop at the end of the octet in which this block starts.
* For example, given block 0 it will return 3 because there are 3 bits
* we don't care about at the end:
*
Expand All @@ -103,66 +103,64 @@ static int get_octet(int block)
* |.....< 1|..
* +--------+-
**/
static int get_offset(int block)
static inline int get_offset(int block)
{
assert(block >= 0 && block < 8);
return (8 - 5 - (5*block) % 8);
return (8 - 5 - (5 * block) % 8);
}

/**
* Like "b >> offset" but it will do the right thing with negative offset.
* We need this as bitwise shifting by a negative offset is undefined
* behavior.
*/
static unsigned char shift_right(unsigned char byte, char offset)
static inline unsigned char shift_right(unsigned char byte, char offset)
{
if (offset > 0)
return byte >> offset;
return byte >> offset;
else
return byte << -offset;
}

static unsigned char shift_left(unsigned char byte, char offset)
{
return shift_right(byte, - offset);
}

/**
* Encode a sequence. A sequence is no longer than 5 octets by definition.
* Thus passing a length greater than 5 to this function is an error. Encoding
* sequences shorter than 5 octets is supported and padding will be added to the
* output as per the specification.
*/
static void encode_sequence(const unsigned char *plain, size_t len, unsigned char *coded)
static void encode_sequence(const unsigned char *plain, int len, unsigned char *coded)
{
assert(CHAR_BIT == 8); // not sure this would work otherwise
assert(CHAR_BIT == 8); // not sure this would work otherwise
assert(len >= 0 && len <= 5);

for (int block = 0; block < 8; block++) {
int octet = get_octet(block); // figure out which octet this block starts in
int junk = get_offset(block); // how many bits do we drop from this octet?
for (int block = 0; block < 8; block++)
{
int octet = get_octet(block); // figure out which octet this block starts in
int junk = get_offset(block); // how many bits do we drop from this octet?

if (octet >= len) { // we hit the end of the buffer
if (octet >= len)
{ // we hit the end of the buffer
pad(&coded[block], 8 - block);
return;
}

unsigned char c = shift_right(plain[octet], junk); // first part
unsigned char c = shift_right(plain[octet], junk); // first part

if (junk < 0 // is there a second part?
&& octet < len - 1) // is there still something to read?
if (junk < 0 // is there a second part?
&& octet < len - 1) // is there still something to read?
{
c |= shift_right(plain[octet+1], 8 + junk);
c |= shift_right(plain[octet + 1], 8 + junk);
}
coded[block] = encode_char(c);
}
}

void base32_encode(const unsigned char *plain, size_t len, unsigned char *coded)
void base32_encode(const unsigned char *plain, int len, unsigned char *coded)
{
// All the hard work is done in encode_sequence(),
// here we just need to feed it the data sequence by sequence.
for (size_t i = 0, j = 0; i < len; i += 5, j += 8) {
for (int i = 0, j = 0; i < len; i += 5, j += 8)
{
encode_sequence(&plain[i], min(len - i, 5), &coded[j]);
}
}
2 changes: 1 addition & 1 deletion 3rdparty/base32/base32.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
* contain characters from the [A-Z2-7=] set. The "len" arguments
* define how many bytes will be read from the "plain" buffer.
**/
void base32_encode(const unsigned char* plain, size_t len, unsigned char* coded);
void base32_encode(const unsigned char* plain, int len, unsigned char* coded);

#endif
3 changes: 1 addition & 2 deletions 3rdparty/crc/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ static uint32_t crc32_tab[] =

uint32_t crc32(const char *s, size_t len)
{
int i;
uint32_t crc32val = 0;
crc32val ^= 0xFFFFFFFF;

for (i = 0; i < len; i++)
for (size_t i = 0; i < len; i++)
{
crc32val = crc32_tab[(crc32val ^ s[i]) & 0xFF] ^ ((crc32val >> 8) & 0x00FFFFFF);
}
Expand Down
2 changes: 1 addition & 1 deletion aiotieba/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.2.1"
__version__ = "3.2.2"
27 changes: 11 additions & 16 deletions aiotieba/api/_protobuf/Agree_pb2.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: Agree.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
from google.protobuf.internal import builder as _builder

_sym_db = _symbol_database.Default()


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
b'\n\x0b\x41gree.proto\"0\n\x05\x41gree\x12\x11\n\tagree_num\x18\x01 \x01(\x03\x12\x14\n\x0c\x64isagree_num\x18\x04 \x01(\x03\x62\x06proto3'
)


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0b\x41gree.proto\"0\n\x05\x41gree\x12\x11\n\tagree_num\x18\x01 \x01(\x03\x12\x14\n\x0c\x64isagree_num\x18\x04 \x01(\x03\x62\x06proto3')

_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'Agree_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_AGREE._serialized_start=15
_AGREE._serialized_end=63
# @@protoc_insertion_point(module_scope)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'Agree_pb2', _globals)
if _descriptor._USE_C_DESCRIPTORS is False:
DESCRIPTOR._options = None
_globals['_AGREE']._serialized_start = 15
_globals['_AGREE']._serialized_end = 63
27 changes: 11 additions & 16 deletions aiotieba/api/_protobuf/CommonReq_pb2.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: CommonReq.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
from google.protobuf.internal import builder as _builder

_sym_db = _symbol_database.Default()


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
b'\n\x0f\x43ommonReq.proto\"I\n\tCommonReq\x12\x14\n\x0c_client_type\x18\x01 \x01(\x05\x12\x17\n\x0f_client_version\x18\x02 \x01(\t\x12\r\n\x05\x42\x44USS\x18\n \x01(\tb\x06proto3'
)


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0f\x43ommonReq.proto\"I\n\tCommonReq\x12\x14\n\x0c_client_type\x18\x01 \x01(\x05\x12\x17\n\x0f_client_version\x18\x02 \x01(\t\x12\r\n\x05\x42\x44USS\x18\n \x01(\tb\x06proto3')

_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'CommonReq_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_COMMONREQ._serialized_start=19
_COMMONREQ._serialized_end=92
# @@protoc_insertion_point(module_scope)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'CommonReq_pb2', _globals)
if _descriptor._USE_C_DESCRIPTORS is False:
DESCRIPTOR._options = None
_globals['_COMMONREQ']._serialized_start = 19
_globals['_COMMONREQ']._serialized_end = 92
27 changes: 11 additions & 16 deletions aiotieba/api/_protobuf/Error_pb2.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: Error.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
from google.protobuf.internal import builder as _builder

_sym_db = _symbol_database.Default()


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
b'\n\x0b\x45rror.proto\"(\n\x05\x45rror\x12\x0f\n\x07\x65rrorno\x18\x01 \x01(\x05\x12\x0e\n\x06\x65rrmsg\x18\x02 \x01(\tb\x06proto3'
)


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0b\x45rror.proto\"(\n\x05\x45rror\x12\x0f\n\x07\x65rrorno\x18\x01 \x01(\x05\x12\x0e\n\x06\x65rrmsg\x18\x02 \x01(\tb\x06proto3')

_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'Error_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_ERROR._serialized_start=15
_ERROR._serialized_end=55
# @@protoc_insertion_point(module_scope)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'Error_pb2', _globals)
if _descriptor._USE_C_DESCRIPTORS is False:
DESCRIPTOR._options = None
_globals['_ERROR']._serialized_start = 15
_globals['_ERROR']._serialized_end = 55
27 changes: 11 additions & 16 deletions aiotieba/api/_protobuf/ForumList_pb2.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: ForumList.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
from google.protobuf.internal import builder as _builder

_sym_db = _symbol_database.Default()


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
b'\n\x0f\x46orumList.proto\"m\n\tForumList\x12\x10\n\x08\x66orum_id\x18\x01 \x01(\x03\x12\x12\n\nforum_name\x18\x02 \x01(\t\x12\x14\n\x0cmember_count\x18\x04 \x01(\x05\x12\x10\n\x08post_num\x18\x07 \x01(\x03\x12\x12\n\nthread_num\x18\x08 \x01(\x03\x62\x06proto3'
)


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0f\x46orumList.proto\"m\n\tForumList\x12\x10\n\x08\x66orum_id\x18\x01 \x01(\x03\x12\x12\n\nforum_name\x18\x02 \x01(\t\x12\x14\n\x0cmember_count\x18\x04 \x01(\x05\x12\x10\n\x08post_num\x18\x07 \x01(\x03\x12\x12\n\nthread_num\x18\x08 \x01(\x03\x62\x06proto3')

_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'ForumList_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_FORUMLIST._serialized_start=19
_FORUMLIST._serialized_end=128
# @@protoc_insertion_point(module_scope)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'ForumList_pb2', _globals)
if _descriptor._USE_C_DESCRIPTORS is False:
DESCRIPTOR._options = None
_globals['_FORUMLIST']._serialized_start = 19
_globals['_FORUMLIST']._serialized_end = 128
Loading

0 comments on commit 411814c

Please sign in to comment.