Parse UIDPLUS Store response payloads
Debian Trixie package bundle / packages (push) Successful in 22m32s
Debian Trixie package bundle / packages (push) Successful in 22m32s
This commit is contained in:
@@ -34,21 +34,25 @@ main(void)
|
||||
uint32_t descending[] = { 7, 2 };
|
||||
char buffer[64];
|
||||
|
||||
assert(IMAPUidplusParseCreated("1000 abcdef 4 27\r\n", &guid,
|
||||
assert(IMAPUidplusParseCreated("abcdef 4 27", &guid,
|
||||
&target_uid));
|
||||
assert(guid == UINT64_C(0xabcdef));
|
||||
assert(target_uid == 27);
|
||||
assert(!IMAPUidplusParseCreated("1000 abcdef 4\r\n", &guid,
|
||||
assert(!IMAPUidplusParseCreated("abcdef 4", &guid,
|
||||
&target_uid));
|
||||
assert(!IMAPUidplusParseCreated("1000 abcdef 4 0 extra\r\n", &guid,
|
||||
assert(!IMAPUidplusParseCreated("abcdef 4 0 extra", &guid,
|
||||
&target_uid));
|
||||
assert(!IMAPUidplusParseCreated("1000 abcdef 4 27", &guid,
|
||||
&target_uid));
|
||||
|
||||
assert(IMAPUidplusParseMoved("1000 OK abcdef 5 12 33\r\n", &guid,
|
||||
assert(IMAPUidplusParseMoved("OK abcdef 5 12 33", &guid,
|
||||
&source_uid, &target_uid));
|
||||
assert(guid == UINT64_C(0xabcdef));
|
||||
assert(source_uid == 12);
|
||||
assert(target_uid == 33);
|
||||
assert(!IMAPUidplusParseMoved("1000 abcdef 5 12 33\r\n", &guid,
|
||||
assert(!IMAPUidplusParseMoved("abcdef 5 12 33", &guid,
|
||||
&source_uid, &target_uid));
|
||||
assert(!IMAPUidplusParseMoved("1000 OK abcdef 5 12 33", &guid,
|
||||
&source_uid, &target_uid));
|
||||
|
||||
assert(IMAPUidplusFormatSet(uids, 6, buffer, sizeof(buffer)));
|
||||
|
||||
@@ -48,12 +48,11 @@ int
|
||||
IMAPUidplusParseCreated(const char *response, uint64_t *guid, uint32_t *uid)
|
||||
{
|
||||
const char *cursor;
|
||||
uint64_t code, version, parsed_guid, parsed_uid;
|
||||
uint64_t version, parsed_guid, parsed_uid;
|
||||
|
||||
if (!response || !guid || !uid) return 0;
|
||||
cursor = response;
|
||||
if (!ParseUnsigned(&cursor, 10, UINT_MAX, &code) || code != 1000 ||
|
||||
!ParseUnsigned(&cursor, 16, UINT64_MAX, &parsed_guid) ||
|
||||
if (!ParseUnsigned(&cursor, 16, UINT64_MAX, &parsed_guid) ||
|
||||
!ParseUnsigned(&cursor, 10, UINT_MAX, &version) ||
|
||||
!ParseUnsigned(&cursor, 10, UINT32_MAX, &parsed_uid)) return 0;
|
||||
while (*cursor == ' ') cursor++;
|
||||
@@ -68,11 +67,10 @@ IMAPUidplusParseMoved(const char *response, uint64_t *guid,
|
||||
uint32_t *source_uid, uint32_t *target_uid)
|
||||
{
|
||||
const char *cursor;
|
||||
uint64_t code, version, parsed_guid, parsed_source, parsed_target;
|
||||
uint64_t version, parsed_guid, parsed_source, parsed_target;
|
||||
|
||||
if (!response || !guid || !source_uid || !target_uid) return 0;
|
||||
cursor = response;
|
||||
if (!ParseUnsigned(&cursor, 10, UINT_MAX, &code) || code != 1000) return 0;
|
||||
while (*cursor == ' ') cursor++;
|
||||
if (strncmp(cursor, "OK", 2) || (cursor[2] && cursor[2] != ' ')) return 0;
|
||||
cursor += 2;
|
||||
|
||||
Reference in New Issue
Block a user