1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-09 19:20:41 +03:00

Mayaqua/Pack: add PackGetStrSize(), for strings with non-constant length

This commit is contained in:
Davide Beatrici 2020-07-18 18:16:54 +02:00
parent b352aa4cc3
commit aa65327e73
2 changed files with 24 additions and 0 deletions

View File

@ -1429,6 +1429,28 @@ bool PackGetStrEx(PACK *p, char *name, char *str, UINT size, UINT index)
return true; return true;
} }
// Get the string size from the PACK
bool PackGetStrSize(PACK *p, char *name)
{
return PackGetStrSizeEx(p, name, 0);
}
bool PackGetStrSizeEx(PACK *p, char *name, UINT index)
{
ELEMENT *e;
// Validate arguments
if (p == NULL || name == NULL)
{
return 0;
}
e = GetElement(p, name, VALUE_STR);
if (e == NULL)
{
return 0;
}
return GetDataValueSize(e, index);
}
// Add the buffer to the PACK (array) // Add the buffer to the PACK (array)
ELEMENT *PackAddBufEx(PACK *p, char *name, BUF *b, UINT index, UINT total) ELEMENT *PackAddBufEx(PACK *p, char *name, BUF *b, UINT index, UINT total)
{ {

View File

@ -143,6 +143,8 @@ ELEMENT *PackAddData(PACK *p, char *name, void *data, UINT size);
ELEMENT *PackAddDataEx(PACK *p, char *name, void *data, UINT size, UINT index, UINT total); ELEMENT *PackAddDataEx(PACK *p, char *name, void *data, UINT size, UINT index, UINT total);
ELEMENT *PackAddBuf(PACK *p, char *name, BUF *b); ELEMENT *PackAddBuf(PACK *p, char *name, BUF *b);
ELEMENT *PackAddBufEx(PACK *p, char *name, BUF *b, UINT index, UINT total); ELEMENT *PackAddBufEx(PACK *p, char *name, BUF *b, UINT index, UINT total);
bool PackGetStrSize(PACK *p, char *name);
bool PackGetStrSizeEx(PACK *p, char *name, UINT index);
bool PackGetStr(PACK *p, char *name, char *str, UINT size); bool PackGetStr(PACK *p, char *name, char *str, UINT size);
bool PackGetStrEx(PACK *p, char *name, char *str, UINT size, UINT index); bool PackGetStrEx(PACK *p, char *name, char *str, UINT size, UINT index);
bool PackGetUniStr(PACK *p, char *name, wchar_t *unistr, UINT size); bool PackGetUniStr(PACK *p, char *name, wchar_t *unistr, UINT size);