MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / Nbt_ReadString

Function Nbt_ReadString

src/Formats.c:405–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403}
404
405static cc_result Nbt_ReadString(struct Stream* stream, cc_string* str) {
406 cc_uint8 buffer[NBT_STRING_SIZE * 4];
407 int len;
408 cc_result res;
409
410 if ((res = Stream_Read(stream, buffer, 2))) return res;
411 len = Stream_GetU16_BE(buffer);
412
413 if (len > Array_Elems(buffer)) return CW_ERR_STRING_LEN;
414 if ((res = Stream_Read(stream, buffer, len))) return res;
415
416 String_AppendUtf8(str, buffer, len);
417 return 0;
418}
419
420typedef void (*Nbt_Callback)(struct NbtTag* tag);
421static cc_result Nbt_ReadTag(cc_uint8 typeId, cc_bool readTagName, struct Stream* stream,

Callers 1

Nbt_ReadTagFunction · 0.85

Calls 3

Stream_ReadFunction · 0.85
Stream_GetU16_BEFunction · 0.85
String_AppendUtf8Function · 0.85

Tested by

no test coverage detected