mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-12-16 07:01:32 +03:00
Implementation of the JSON-RPC API and the Web Admin interface. (dnobori's internal note: 7579 - 7682)
This commit is contained in:
@ -1413,6 +1413,48 @@ bool ReplaceListPointer(LIST *o, void *oldptr, void *newptr)
|
||||
return false;
|
||||
}
|
||||
|
||||
// New string list
|
||||
LIST *NewStrList()
|
||||
{
|
||||
return NewListFast(CompareStr);
|
||||
}
|
||||
|
||||
// Release string list
|
||||
void ReleaseStrList(LIST *o)
|
||||
{
|
||||
UINT i;
|
||||
if (o == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0;i < LIST_NUM(o);i++)
|
||||
{
|
||||
char *s = LIST_DATA(o, i);
|
||||
Free(s);
|
||||
}
|
||||
|
||||
ReleaseList(o);
|
||||
}
|
||||
|
||||
// Add a string distinct to the string list
|
||||
bool AddStrToStrListDistinct(LIST *o, char *str)
|
||||
{
|
||||
if (o == NULL || str == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsInListStr(o, str) == false)
|
||||
{
|
||||
Add(o, CopyStr(str));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Examine whether a string items are present in the list
|
||||
bool IsInListStr(LIST *o, char *str)
|
||||
{
|
||||
@ -2948,6 +2990,43 @@ void WriteBufBuf(BUF *b, BUF *bb)
|
||||
WriteBuf(b, bb->Buf, bb->Size);
|
||||
}
|
||||
|
||||
// Write the buffer (from the offset) to a buffer
|
||||
void WriteBufBufWithOffset(BUF *b, BUF *bb)
|
||||
{
|
||||
// Validate arguments
|
||||
if (b == NULL || bb == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WriteBuf(b, ((UCHAR *)bb->Buf) + bb->Current, bb->Size - bb->Current);
|
||||
}
|
||||
|
||||
// Skip UTF-8 BOM
|
||||
bool BufSkipUtf8Bom(BUF *b)
|
||||
{
|
||||
if (b == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SeekBufToBegin(b);
|
||||
|
||||
if (b->Size >= 3)
|
||||
{
|
||||
UCHAR *data = b->Buf;
|
||||
|
||||
if (data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF)
|
||||
{
|
||||
SeekBuf(b, 3, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read into a buffer from the buffer
|
||||
BUF *ReadBufFromBuf(BUF *b, UINT size)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user