function_name
stringlengths 1
80
| function
stringlengths 14
10.6k
| comment
stringlengths 12
8.02k
| normalized_comment
stringlengths 6
6.55k
|
|---|---|---|---|
MsIsAeroColor
|
bool MsIsAeroColor()
{
UINT r;
if (MsIsNt() == false)
{
return false;
}
if (MsIsVista() == false)
{
return false;
}
r = GetSysColor(COLOR_MENU);
if (r == 0xFFFFFF || r == 0xF0F0F0 || r >= 0xF00000)
{
return true;
}
if (MsIsAeroEnabled())
{
return true;
}
return false;
}
|
/* Get whether the screen color is like to Aero of Windows Vista or later*/
|
Get whether the screen color is like to Aero of Windows Vista or later
|
MsIsAeroEnabled
|
bool MsIsAeroEnabled()
{
bool ret;
if (MsIsNt() == false)
{
return false;
}
if (ms->nt->DwmIsCompositionEnabled == NULL)
{
return false;
}
ret = false;
if (ms->nt->DwmIsCompositionEnabled(&ret) != S_OK)
{
return false;
}
return ret;
}
|
/* Get whether Aero is enabled*/
|
Get whether Aero is enabled
|
MsRegAccessMaskFor64BitEx
|
DWORD MsRegAccessMaskFor64BitEx(bool force32bit, bool force64bit)
{
if (MsIs64BitWindows() == false)
{
return 0;
}
if (force32bit)
{
return KEY_WOW64_32KEY;
}
if (force64bit)
{
return KEY_WOW64_64KEY;
}
return 0;
}
|
/* Generate an access mask to force accessing to the 32 bit registry key for 64 bit application*/
|
Generate an access mask to force accessing to the 32 bit registry key for 64 bit application
|
MsRegLoadHive
|
bool MsRegLoadHive(UINT root, wchar_t *keyname, wchar_t *filename)
{
LONG ret;
if (keyname == NULL || filename == NULL)
{
WHERE;
return false;
}
if (ms->nt == NULL || ms->nt->RegLoadKeyW == NULL || ms->nt->RegUnLoadKeyW == NULL)
{
WHERE;
return false;
}
ret = ms->nt->RegLoadKeyW(MsGetRootKeyFromInt(root), keyname, filename);
if (ret != ERROR_SUCCESS)
{
Debug("RegLoadKeyW: %S %S %u\n", keyname, filename, GetLastError());
return false;
}
WHERE;
return true;
}
|
/* Load the hive*/
|
Load the hive
|
MsRegUnloadHive
|
bool MsRegUnloadHive(UINT root, wchar_t *keyname)
{
LONG ret;
if (keyname == NULL)
{
return false;
}
if (ms->nt == NULL || ms->nt->RegLoadKeyW == NULL || ms->nt->RegUnLoadKeyW == NULL)
{
return false;
}
ret = ms->nt->RegUnLoadKeyW(MsGetRootKeyFromInt(root), keyname);
if (ret != ERROR_SUCCESS)
{
Debug("RegUnLoadKeyW: %u\n", GetLastError());
return false;
}
return true;
}
|
/* Unload the hive*/
|
Unload the hive
|
MsRegDeleteValue
|
bool MsRegDeleteValue(UINT root, char *keyname, char *valuename)
{
return MsRegDeleteValueEx(root, keyname, valuename, false);
}
|
/* Delete the value*/
|
Delete the value
|
MsRegDeleteKey
|
bool MsRegDeleteKey(UINT root, char *keyname)
{
return MsRegDeleteKeyEx(root, keyname, false);
}
|
/* Delete the key*/
|
Delete the key
|
MsRegEnumValue
|
TOKEN_LIST *MsRegEnumValue(UINT root, char *keyname)
{
return MsRegEnumValueEx(root, keyname, false);
}
|
/* Enumeration of values*/
|
Enumeration of values
|
MsRegEnumKey
|
TOKEN_LIST *MsRegEnumKey(UINT root, char *keyname)
{
return MsRegEnumKeyEx(root, keyname, false);
}
|
/* Enumeration of the keys*/
|
Enumeration of the keys
|
MsRegWriteBin
|
bool MsRegWriteBin(UINT root, char *keyname, char *valuename, void *data, UINT size)
{
return MsRegWriteBinEx(root, keyname, valuename, data, size, false);
}
|
/* Set the binary data*/
|
Set the binary data
|
MsRegWriteInt
|
bool MsRegWriteInt(UINT root, char *keyname, char *valuename, UINT value)
{
return MsRegWriteIntEx(root, keyname, valuename, value, false);
}
|
/* Set the integer value*/
|
Set the integer value
|
MsRegWriteStrExpand
|
bool MsRegWriteStrExpand(UINT root, char *keyname, char *valuename, char *str)
{
return MsRegWriteStrExpandEx(root, keyname, valuename, str, false);
}
|
/* Set the string*/
|
Set the string
|
MsRegWriteValueEx2
|
bool MsRegWriteValueEx2(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size, bool force32bit, bool force64bit)
{
HKEY h;
// Validate arguments
if (keyname == NULL || (size != 0 && data == NULL))
{
return false;
}
// Create a key
MsRegNewKeyEx2(root, keyname, force32bit, force64bit);
// Open the key
if (RegOpenKeyEx(MsGetRootKeyFromInt(root), keyname, 0, KEY_ALL_ACCESS | MsRegAccessMaskFor64BitEx(force32bit, force64bit), &h) != ERROR_SUCCESS)
{
return false;
}
// Write the value
if (RegSetValueEx(h, valuename, 0, type, data, size) != ERROR_SUCCESS)
{
RegCloseKey(h);
return false;
}
// Close the key
RegCloseKey(h);
return true;
}
|
/* Set the value*/
|
Set the value
|
MsRegReadBin
|
BUF *MsRegReadBin(UINT root, char *keyname, char *valuename)
{
return MsRegReadBinEx(root, keyname, valuename, false);
}
|
/* Get the binary data*/
|
Get the binary data
|
MsRegReadInt
|
UINT MsRegReadInt(UINT root, char *keyname, char *valuename)
{
return MsRegReadIntEx(root, keyname, valuename, false);
}
|
/* Get an integer value*/
|
Get an integer value
|
MsRegReadStrList
|
LIST *MsRegReadStrList(UINT root, char *keyname, char *valuename)
{
return MsRegReadStrListEx(root, keyname, valuename, false);
}
|
/* Get a string list*/
|
Get a string list
|
MsRegReadStr
|
char *MsRegReadStr(UINT root, char *keyname, char *valuename)
{
return MsRegReadStrEx(root, keyname, valuename, false);
}
|
/* Get a string*/
|
Get a string
|
MsRegIsValue
|
bool MsRegIsValue(UINT root, char *keyname, char *valuename)
{
return MsRegIsValueEx(root, keyname, valuename, false);
}
|
/* Confirm that the specified value exists on the registry*/
|
Confirm that the specified value exists on the registry
|
MsRegNewKeyEx2
|
bool MsRegNewKeyEx2(UINT root, char *keyname, bool force32bit, bool force64bit)
{
HKEY h;
// Validate arguments
if (keyname == NULL)
{
return false;
}
// Confirm whether there is the key
if (MsRegIsKeyEx2(root, keyname, force32bit, force64bit))
{
// Already exists
return true;
}
// Create a key
if (RegCreateKeyEx(MsGetRootKeyFromInt(root), keyname, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS | MsRegAccessMaskFor64BitEx(force32bit, force64bit), NULL, &h, NULL) != ERROR_SUCCESS)
{
// Failed
return false;
}
RegCloseKey(h);
return true;
}
|
/* Create a key in the registry*/
|
Create a key in the registry
|
MsRegIsKey
|
bool MsRegIsKey(UINT root, char *name)
{
return MsRegIsKeyEx(root, name, false);
}
|
/* Confirm the specified key exists on the registry*/
|
Confirm the specified key exists on the registry
|
MsGetRootKeyFromInt
|
HKEY MsGetRootKeyFromInt(UINT root)
{
switch (root)
{
case REG_CLASSES_ROOT:
return HKEY_CLASSES_ROOT;
case REG_LOCAL_MACHINE:
return HKEY_LOCAL_MACHINE;
case REG_CURRENT_USER:
return HKEY_CURRENT_USER;
case REG_USERS:
return HKEY_USERS;
}
return NULL;
}
|
/* Getting root key handle*/
|
Getting root key handle
|
MsGetCurrentProcess
|
void *MsGetCurrentProcess()
{
return ms->hCurrentProcess;
}
|
/* Get the Process handle*/
|
Get the Process handle
|
MsGetCurrentProcessId
|
UINT MsGetCurrentProcessId()
{
return ms->CurrentProcessId;
}
|
/* Get the Process ID*/
|
Get the Process ID
|
MsGetExeFileName
|
char *MsGetExeFileName()
{
return ms == NULL ? "Unknown" : ms->ExeFileName;
}
|
/* Get the EXE file name*/
|
Get the EXE file name
|
MsGetExeDirName
|
char *MsGetExeDirName()
{
return ms->ExeFileDir;
}
|
/* Get the name of the directory where the EXE file is in*/
|
Get the name of the directory where the EXE file is in
|
MsGetSpecialDir
|
char *MsGetSpecialDir(int id)
{
LPITEMIDLIST t = NULL;
char tmp[MAX_PATH];
if (SHGetSpecialFolderLocation(NULL, id, &t) != S_OK)
{
return CopyStr(ms->ExeFileDir);
}
if (SHGetPathFromIDList(t, tmp) == false)
{
return CopyStr(ms->ExeFileDir);
}
Win32NukuEn(tmp, sizeof(tmp), tmp);
return CopyStr(tmp);
}
|
/* Get the special directory name*/
|
Get the special directory name
|
MsIsMinidumpEnabled
|
bool MsIsMinidumpEnabled()
{
return ms->MiniDumpEnabled;
}
|
/* Determine whether minidump is enabled*/
|
Determine whether minidump is enabled
|
MsSetEnableMinidump
|
void MsSetEnableMinidump(bool enabled)
{
ms->MiniDumpEnabled = enabled;
}
|
/* Determine whether to create a minidump*/
|
Determine whether to create a minidump
|
MsGetWindowsDir
|
char *MsGetWindowsDir()
{
return ms->WindowsDir;
}
|
/* Directory acquisition related*/
|
Directory acquisition related
|
GetPackElementNames
|
TOKEN_LIST *GetPackElementNames(PACK *p)
{
TOKEN_LIST *ret;
UINT i;
// Validate arguments
if (p == NULL)
{
return NULL;
}
ret = ZeroMalloc(sizeof(TOKEN_LIST));
ret->NumTokens = LIST_NUM(p->elements);
ret->Token = ZeroMalloc(sizeof(char *) * ret->NumTokens);
for (i = 0;i < ret->NumTokens;i++)
{
ELEMENT *e = LIST_DATA(p->elements, i);
ret->Token[i] = CopyStr(e->name);
}
return ret;
}
|
/* Get a list of the element names in the PACK*/
|
Get a list of the element names in the PACK
|
BufToPack
|
PACK *BufToPack(BUF *b)
{
PACK *p;
// Validate arguments
if (b == NULL)
{
return NULL;
}
p = NewPack();
if (ReadPack(b, p) == false)
{
FreePack(p);
return NULL;
}
return p;
}
|
/* Convert the BUF to a PACK*/
|
Convert the BUF to a PACK
|
PackToBuf
|
BUF *PackToBuf(PACK *p)
{
BUF *b;
// Validate arguments
if (p == NULL)
{
return NULL;
}
b = NewBuf();
WritePack(b, p);
return b;
}
|
/* Convert the PACK to the BUF*/
|
Convert the PACK to the BUF
|
ReadPack
|
bool ReadPack(BUF *b, PACK *p)
{
UINT i, num;
// Validate arguments
if (b == NULL || p == NULL)
{
return false;
}
// The number of ELEMENTs
num = ReadBufInt(b);
if (num > MAX_ELEMENT_NUM)
{
// Number exceeds
return false;
}
// Read the ELEMENT
for (i = 0;i < num;i++)
{
ELEMENT *e;
e = ReadElement(b);
if (AddElement(p, e) == false)
{
// Adding error
return false;
}
}
return true;
}
|
/* Read the PACK*/
|
Read the PACK
|
WritePack
|
void WritePack(BUF *b, PACK *p)
{
UINT i;
// Validate arguments
if (b == NULL || p == NULL)
{
return;
}
// The number of ELEMENTs
WriteBufInt(b, LIST_NUM(p->elements));
// Write the ELEMENT
for (i = 0;i < LIST_NUM(p->elements);i++)
{
ELEMENT *e = LIST_DATA(p->elements, i);
WriteElement(b, e);
}
}
|
/* Write down the PACK*/
|
Write down the PACK
|
WriteElement
|
void WriteElement(BUF *b, ELEMENT *e)
{
UINT i;
// Validate arguments
if (b == NULL || e == NULL)
{
return;
}
// Name
WriteBufStr(b, e->name);
// Type of item
WriteBufInt(b, e->type);
// Number of items
WriteBufInt(b, e->num_value);
// VALUE
for (i = 0;i < e->num_value;i++)
{
VALUE *v = e->values[i];
WriteValue(b, v, e->type);
}
}
|
/* Write the ELEMENT*/
|
Write the ELEMENT
|
GetDataValueSize
|
UINT GetDataValueSize(ELEMENT *e, UINT index)
{
// Validate arguments
if (e == NULL)
{
return 0;
}
if (e->values == NULL)
{
return 0;
}
if (index >= e->num_value)
{
return 0;
}
if (e->values[index] == NULL)
{
return 0;
}
return e->values[index]->Size;
}
|
/* Get data size*/
|
Get data size
|
GetDataValue
|
void *GetDataValue(ELEMENT *e, UINT index)
{
// Validate arguments
if (e == NULL)
{
return NULL;
}
if (e->values == NULL)
{
return NULL;
}
if (index >= e->num_value)
{
return NULL;
}
if (e->values[index] == NULL)
{
return NULL;
}
return e->values[index]->Data;
}
|
/* Get the data*/
|
Get the data
|
GetUniStrValue
|
wchar_t *GetUniStrValue(ELEMENT *e, UINT index)
{
// Validate arguments
if (e == NULL)
{
return 0;
}
if (index >= e->num_value)
{
return 0;
}
if (e->values[index] == NULL)
{
return NULL;
}
return e->values[index]->UniStr;
}
|
/* Get the Unicode string type*/
|
Get the Unicode string type
|
GetStrValue
|
char *GetStrValue(ELEMENT *e, UINT index)
{
// Validate arguments
if (e == NULL)
{
return 0;
}
if (index >= e->num_value)
{
return 0;
}
if (e->values[index] == NULL)
{
return NULL;
}
return e->values[index]->Str;
}
|
/* Get the ANSI string type*/
|
Get the ANSI string type
|
GetInt64Value
|
UINT64 GetInt64Value(ELEMENT *e, UINT index)
{
// Validate arguments
if (e == NULL)
{
return 0;
}
if (index >= e->num_value)
{
return 0;
}
if (e->values[index] == NULL)
{
return 0;
}
return e->values[index]->Int64Value;
}
|
/* Get the 64 bit integer value*/
|
Get the 64 bit integer value
|
GetIntValue
|
UINT GetIntValue(ELEMENT *e, UINT index)
{
// Validate arguments
if (e == NULL)
{
return 0;
}
if (index >= e->num_value)
{
return 0;
}
if (e->values[index] == NULL)
{
return 0;
}
return e->values[index]->IntValue;
}
|
/* Get the integer value*/
|
Get the integer value
|
ComparePackName
|
int ComparePackName(void *p1, void *p2)
{
ELEMENT *o1, *o2;
if (p1 == NULL || p2 == NULL)
{
return 0;
}
o1 = *(ELEMENT **)p1;
o2 = *(ELEMENT **)p2;
if (o1 == NULL || o2 == NULL)
{
return 0;
}
return StrCmpi(o1->name, o2->name);
}
|
/* Function of sort for PACK*/
|
Function of sort for PACK
|
FreeValue
|
void FreeValue(VALUE *v, UINT type)
{
// Validate arguments
if (v == NULL)
{
return;
}
switch (type)
{
case VALUE_INT:
case VALUE_INT64:
break;
case VALUE_DATA:
Free(v->Data);
break;
case VALUE_STR:
Free(v->Str);
break;
case VALUE_UNISTR:
Free(v->UniStr);
break;
}
// Memory release
Free(v);
}
|
/* Delete the VALUE*/
|
Delete the VALUE
|
NewUniStrValue
|
VALUE *NewUniStrValue(wchar_t *str)
{
VALUE *v;
// Validate arguments
if (str == NULL)
{
return NULL;
}
// Memory allocation
v = Malloc(sizeof(VALUE));
// String copy
v->Size = UniStrSize(str);
v->UniStr = Malloc(v->Size);
UniStrCpy(v->UniStr, v->Size, str);
UniTrim(v->UniStr);
return v;
}
|
/* Create a VALUE of Unicode String type*/
|
Create a VALUE of Unicode String type
|
NewStrValue
|
VALUE *NewStrValue(char *str)
{
VALUE *v;
// Validate arguments
if (str == NULL)
{
return NULL;
}
// Memory allocation
v = Malloc(sizeof(VALUE));
// String copy
v->Size = StrLen(str) + 1;
v->Str = Malloc(v->Size);
StrCpy(v->Str, v->Size, str);
Trim(v->Str);
return v;
}
|
/* Creation of the VALUE of ANSI string type*/
|
Creation of the VALUE of ANSI string type
|
NewDataValue
|
VALUE *NewDataValue(void *data, UINT size)
{
VALUE *v;
// Validate arguments
if (data == NULL)
{
return NULL;
}
// Memory allocation
v = Malloc(sizeof(VALUE));
// Data copy
v->Size = size;
v->Data = Malloc(v->Size);
Copy(v->Data, data, size);
return v;
}
|
/* Create the VALUE of the data type*/
|
Create the VALUE of the data type
|
NewInt64Value
|
VALUE *NewInt64Value(UINT64 i)
{
VALUE *v;
v = Malloc(sizeof(VALUE));
v->Int64Value = i;
v->Size = sizeof(UINT64);
return v;
}
|
/* Create the VALUE of 64 bit integer type*/
|
Create the VALUE of 64 bit integer type
|
NewIntValue
|
VALUE *NewIntValue(UINT i)
{
VALUE *v;
// Memory allocation
v = Malloc(sizeof(VALUE));
v->IntValue = i;
v->Size = sizeof(UINT);
return v;
}
|
/* Create the VALUE of integer type*/
|
Create the VALUE of integer type
|
FreeElement
|
void FreeElement(ELEMENT *e)
{
UINT i;
// Validate arguments
if (e == NULL)
{
return;
}
for (i = 0;i < e->num_value;i++)
{
FreeValue(e->values[i], e->type);
}
Free(e->values);
Free(e);
}
|
/* Delete the ELEMENT*/
|
Delete the ELEMENT
|
GetElement
|
ELEMENT *GetElement(PACK *p, char *name, UINT type)
{
ELEMENT t;
ELEMENT *e;
// Validate arguments
if (p == NULL || name == NULL)
{
return NULL;
}
// Search
StrCpy(t.name, sizeof(t.name), name);
e = Search(p->elements, &t);
if (e == NULL)
{
return NULL;
}
// Type checking
if (type != INFINITE)
{
if (e->type != type)
{
return NULL;
}
}
return e;
}
|
/* Search and retrieve a ELEMENT from the PACK*/
|
Search and retrieve a ELEMENT from the PACK
|
IsElement
|
bool IsElement(PACK *p, char *name)
{
ELEMENT t;
ELEMENT *e;
// Validate arguments
if (p == NULL || name == NULL)
{
return false;
}
// Search
StrCpy(t.name, sizeof(t.name), name);
e = Search(p->elements, &t);
if (e == NULL)
{
return false;
}
return true;
}
|
/* Check whether the specified element exists*/
|
Check whether the specified element exists
|
DelElement
|
void DelElement(PACK *p, char *name)
{
ELEMENT *e;
// Validate arguments
if (p == NULL || name == NULL)
{
return;
}
e = GetElement(p, name, INFINITE);
if (e != NULL)
{
Delete(p->elements, e);
FreeElement(e);
}
}
|
/* Remove the ELEMENT from the PACK*/
|
Remove the ELEMENT from the PACK
|
AddElement
|
bool AddElement(PACK *p, ELEMENT *e)
{
// Validate arguments
if (p == NULL || e == NULL)
{
return false;
}
// Size Check
if (LIST_NUM(p->elements) >= MAX_ELEMENT_NUM)
{
// Can not add any more
FreeElement(e);
return false;
}
// Check whether there is another item which have same name
if (GetElement(p, e->name, INFINITE))
{
// Exists
FreeElement(e);
return false;
}
if (e->num_value == 0)
{
// VALUE without any items can not be added
FreeElement(e);
return false;
}
// Set JsonHint_GroupName
StrCpy(e->JsonHint_GroupName, sizeof(e->JsonHint_GroupName), p->CurrentJsonHint_GroupName);
// Adding
Add(p->elements, e);
return true;
}
|
/* Add an ELEMENT to the PACK*/
|
Add an ELEMENT to the PACK
|
FreePack
|
void FreePack(PACK *p)
{
UINT i;
ELEMENT **elements;
// Validate arguments
if (p == NULL)
{
return;
}
elements = ToArray(p->elements);
for (i = 0;i < LIST_NUM(p->elements);i++)
{
FreeElement(elements[i]);
}
Free(elements);
if (p->json_subitem_names != NULL)
{
FreeStrList(p->json_subitem_names);
}
ReleaseList(p->elements);
Free(p);
}
|
/* Release of the PACK object*/
|
Release of the PACK object
|
NewPack
|
PACK *NewPack()
{
PACK *p;
// Memory allocation
p = ZeroMallocEx(sizeof(PACK), true);
// Creating a List
p->elements = NewListFast(ComparePackName);
return p;
}
|
/* Create a PACK object*/
|
Create a PACK object
|
PackGetK
|
K *PackGetK(PACK *p, char *name)
{
K *k;
BUF *b;
// Validate arguments
if (p == NULL || name == NULL)
{
return NULL;
}
b = PackGetBuf(p, name);
if (b == NULL)
{
return NULL;
}
k = BufToK(b, true, false, NULL);
if (k == NULL)
{
k = BufToK(b, true, true, NULL);
}
FreeBuf(b);
return k;
}
|
/* Get the K from the PACK*/
|
Get the K from the PACK
|
PackGetX
|
X *PackGetX(PACK *p, char *name)
{
X *x;
BUF *b;
// Validate arguments
if (p == NULL || name == NULL)
{
return NULL;
}
b = PackGetBuf(p, name);
if (b == NULL)
{
return NULL;
}
x = BufToX(b, false);
if (x == NULL)
{
x = BufToX(b, true);
}
FreeBuf(b);
return x;
}
|
/* Get the X from the PACK*/
|
Get the X from the PACK
|
PackAddK
|
ELEMENT *PackAddK(PACK *p, char *name, K *k)
{
BUF *b;
ELEMENT *e = NULL;
// Validate arguments
if (p == NULL || name == NULL || k == NULL)
{
return NULL;
}
b = KToBuf(k, false, NULL);
if (b == NULL)
{
return NULL;
}
e = PackAddBuf(p, name, b);
FreeBuf(b);
return e;
}
|
/* Add the K to the PACK*/
|
Add the K to the PACK
|
PackAddX
|
ELEMENT *PackAddX(PACK *p, char *name, X *x)
{
BUF *b;
ELEMENT *e = NULL;
// Validate arguments
if (p == NULL || name == NULL || x == NULL)
{
return NULL;
}
b = XToBuf(x, false);
if (b == NULL)
{
return NULL;
}
e = PackAddBuf(p, name, b);
FreeBuf(b);
return e;
}
|
/* Add an X into the PACK*/
|
Add an X into the PACK
|
PackGetBuf
|
BUF *PackGetBuf(PACK *p, char *name)
{
return PackGetBufEx(p, name, 0);
}
|
/* Get a buffer from the PACK*/
|
Get a buffer from the PACK
|
PackGetData
|
bool PackGetData(PACK *p, char *name, void *data)
{
return PackGetDataEx(p, name, data, 0);
}
|
/* Get the data from the PACK*/
|
Get the data from the PACK
|
PackGetDataSize
|
UINT PackGetDataSize(PACK *p, char *name)
{
return PackGetDataSizeEx(p, name, 0);
}
|
/* Get the data size from the PACK*/
|
Get the data size from the PACK
|
PackGetInt64
|
UINT64 PackGetInt64(PACK *p, char *name)
{
return PackGetInt64Ex(p, name, 0);
}
|
/* Get an integer from the PACK*/
|
Get an integer from the PACK
|
PackGetIndexCount
|
UINT PackGetIndexCount(PACK *p, char *name)
{
ELEMENT *e;
// Validate arguments
if (p == NULL || name == NULL)
{
return 0;
}
e = GetElement(p, name, INFINITE);
if (e == NULL)
{
return 0;
}
return e->num_value;
}
|
/* Get the index number from the PACK*/
|
Get the index number from the PACK
|
PackGetNum
|
UINT PackGetNum(PACK *p, char *name)
{
return MIN(PackGetInt(p, name), 65536);
}
|
/* Get the number from the PACK*/
|
Get the number from the PACK
|
PackGetBool
|
bool PackGetBool(PACK *p, char *name)
{
return PackGetInt(p, name) == 0 ? false : true;
}
|
/* Get a bool type from the PACK*/
|
Get a bool type from the PACK
|
PackSetCurrentJsonGroupName
|
void PackSetCurrentJsonGroupName(PACK *p, char *json_group_name)
{
if (p == NULL)
{
return;
}
if (json_group_name == NULL)
{
ClearStr(p->CurrentJsonHint_GroupName, sizeof(p->CurrentJsonHint_GroupName));
}
else
{
StrCpy(p->CurrentJsonHint_GroupName, sizeof(p->CurrentJsonHint_GroupName), json_group_name);
if (p->json_subitem_names == NULL)
{
p->json_subitem_names = NewStrList();
}
AddStrToStrListDistinct(p->json_subitem_names, json_group_name);
}
}
|
/* Set CurrentJsonHint_GroupName to PACK*/
|
Set CurrentJsonHint_GroupName to PACK
|
PackAddBool
|
ELEMENT *PackAddBool(PACK *p, char *name, bool b)
{
ELEMENT *e = PackAddInt(p, name, b ? 1 : 0);
if (e != NULL)
{
e->JsonHint_IsBool = true;
}
return e;
}
|
/* Add a bool type into the PACK*/
|
Add a bool type into the PACK
|
PackAddIp6AddrEx
|
ELEMENT *PackAddIp6AddrEx(PACK *p, char *name, IPV6_ADDR *addr, UINT index, UINT total)
{
// Validate arguments
if (p == NULL || name == NULL || addr == NULL)
{
return NULL;
}
return PackAddDataEx(p, name, addr, sizeof(IPV6_ADDR), index, total);
}
|
/* Add the IPV6_ADDR to the PACK*/
|
Add the IPV6_ADDR to the PACK
|
PackGetIp6AddrEx
|
bool PackGetIp6AddrEx(PACK *p, char *name, IPV6_ADDR *addr, UINT index)
{
// Validate arguments
if (p == NULL || name == NULL || addr == NULL)
{
Zero(addr, sizeof(IPV6_ADDR));
return false;
}
return PackGetDataEx2(p, name, addr, sizeof(IPV6_ADDR), index);
}
|
/* Get an IPV6_ADDR from the PACK*/
|
Get an IPV6_ADDR from the PACK
|
PackAddIp32Ex
|
void PackAddIp32Ex(PACK *p, char *name, UINT ip32, UINT index, UINT total)
{
PackAddIp32Ex2(p, name, ip32, index, total, false);
}
|
/* Add the IP to the PACK*/
|
Add the IP to the PACK
|
PackGetIp32Ex
|
UINT PackGetIp32Ex(PACK *p, char *name, UINT index)
{
IP ip;
// Validate arguments
if (p == NULL || name == NULL)
{
return 0;
}
if (PackGetIpEx(p, name, &ip, index) == false)
{
return 0;
}
return IPToUINT(&ip);
}
|
/* Get an IP from the PACK*/
|
Get an IP from the PACK
|
PackIsValueExists
|
bool PackIsValueExists(PACK *p, char *name)
{
// Validate arguments
if (p == NULL || name == NULL)
{
return false;
}
return IsElement(p, name);
}
|
/* Check whether the specified value is existing on the Pack*/
|
Check whether the specified value is existing on the Pack
|
PackGetInt
|
UINT PackGetInt(PACK *p, char *name)
{
return PackGetIntEx(p, name, 0);
}
|
/* Get an integer from the PACK*/
|
Get an integer from the PACK
|
PackGetUniStr
|
bool PackGetUniStr(PACK *p, char *name, wchar_t *unistr, UINT size)
{
return PackGetUniStrEx(p, name, unistr, size, 0);
}
|
/* Get an Unicode string from the PACK*/
|
Get an Unicode string from the PACK
|
PackCmpStr
|
bool PackCmpStr(PACK *p, char *name, char *str)
{
char tmp[MAX_SIZE];
if (PackGetStr(p, name, tmp, sizeof(tmp)) == false)
{
return false;
}
if (StrCmpi(tmp, str) == 0)
{
return true;
}
return false;
}
|
/* Compare strings in the PACK*/
|
Compare strings in the PACK
|
PackGetStr
|
bool PackGetStr(PACK *p, char *name, char *str, UINT size)
{
return PackGetStrEx(p, name, str, size, 0);
}
|
/* Get a string from the PACK*/
|
Get a string from the PACK
|
PackAddBufEx
|
ELEMENT *PackAddBufEx(PACK *p, char *name, BUF *b, UINT index, UINT total)
{
// Validate arguments
if (p == NULL || name == NULL || b == NULL || total == 0)
{
return NULL;
}
return PackAddDataEx(p, name, b->Buf, b->Size, index, total);
}
|
/* Add the buffer to the PACK (array)*/
|
Add the buffer to the PACK (array)
|
PackAddBuf
|
ELEMENT *PackAddBuf(PACK *p, char *name, BUF *b)
{
// Validate arguments
if (p == NULL || name == NULL || b == NULL)
{
return NULL;
}
return PackAddData(p, name, b->Buf, b->Size);
}
|
/* Add the buffer to the PACK*/
|
Add the buffer to the PACK
|
PackAddData
|
ELEMENT *PackAddData(PACK *p, char *name, void *data, UINT size)
{
VALUE *v;
ELEMENT *e;
// Validate arguments
if (p == NULL || data == NULL || name == NULL)
{
return NULL;
}
v = NewDataValue(data, size);
e = NewElement(name, VALUE_DATA, 1, &v);
if (AddElement(p, e) == false)
{
return NULL;
}
return e;
}
|
/* Add the data to the PACK*/
|
Add the data to the PACK
|
PackAddTime64
|
ELEMENT *PackAddTime64(PACK *p, char *name, UINT64 i)
{
ELEMENT *e = PackAddInt64(p, name, i);
if (e != NULL)
{
e->JsonHint_IsDateTime = true;
}
return e;
}
|
/* Add 64 bit integer time value to the PACK*/
|
Add 64 bit integer time value to the PACK
|
PackAddInt64
|
ELEMENT *PackAddInt64(PACK *p, char *name, UINT64 i)
{
VALUE *v;
ELEMENT *e;
// Validate arguments
if (p == NULL || name == NULL)
{
return NULL;
}
v = NewInt64Value(i);
e = NewElement(name, VALUE_INT64, 1, &v);
if (AddElement(p, e) == false)
{
return NULL;
}
return e;
}
|
/* Add a 64 bit integer to the PACK*/
|
Add a 64 bit integer to the PACK
|
PackAddNum
|
ELEMENT *PackAddNum(PACK *p, char *name, UINT num)
{
return PackAddInt(p, name, num);
}
|
/* Add the number of items to the PACK*/
|
Add the number of items to the PACK
|
PackAddInt
|
ELEMENT *PackAddInt(PACK *p, char *name, UINT i)
{
VALUE *v;
ELEMENT *e = NULL;
// Validate arguments
if (p == NULL || name == NULL)
{
return NULL;
}
v = NewIntValue(i);
e = NewElement(name, VALUE_INT, 1, &v);
if (AddElement(p, e) == false)
{
return NULL;
}
return e;
}
|
/* Add an integer to the PACK*/
|
Add an integer to the PACK
|
PackAddUniStr
|
ELEMENT *PackAddUniStr(PACK *p, char *name, wchar_t *unistr)
{
VALUE *v;
ELEMENT *e = NULL;
// Validate arguments
if (p == NULL || name == NULL || unistr == NULL)
{
return NULL;
}
v = NewUniStrValue(unistr);
e = NewElement(name, VALUE_UNISTR, 1, &v);
if (AddElement(p, e) == false)
{
return NULL;
}
return e;
}
|
/* Add a Unicode string to the PACK*/
|
Add a Unicode string to the PACK
|
PackAddStr
|
ELEMENT *PackAddStr(PACK *p, char *name, char *str)
{
VALUE *v;
ELEMENT *e = NULL;
// Validate arguments
if (p == NULL || name == NULL || str == NULL)
{
return NULL;
}
v = NewStrValue(str);
e = NewElement(name, VALUE_STR, 1, &v);
if (AddElement(p, e) == false)
{
return NULL;
}
return e;
}
|
/* Add a string to the PACK*/
|
Add a string to the PACK
|
JsonStrToPack
|
PACK *JsonStrToPack(char *str)
{
JSON_VALUE *v = StrToJson(str);
PACK *ret;
if (v == NULL)
{
return NULL;
}
ret = JsonToPack(v);
JsonFree(v);
return ret;
}
|
/* Convert JSON string to PACK*/
|
Convert JSON string to PACK
|
PackToJsonStr
|
char *PackToJsonStr(PACK *p)
{
char *ret;
JSON_VALUE *json = PackToJson(p);
ret = JsonToStr(json);
JsonFree(json);
return ret;
}
|
/* Convert PACK to JSON string*/
|
Convert PACK to JSON string
|
GetCurrentOsLang
|
void GetCurrentOsLang(LANGLIST *e)
{
// Validate arguments
if (e == NULL)
{
return;
}
Copy(e, ¤t_os_lang, sizeof(LANGLIST));
}
|
/* Get the language of the current OS*/
|
Get the language of the current OS
|
GetCurrentOsLangId
|
UINT GetCurrentOsLangId()
{
LANGLIST e;
Zero(&e, sizeof(e));
GetCurrentOsLang(&e);
return e.Id;
}
|
/* Get the language ID of the current OS*/
|
Get the language ID of the current OS
|
GetCurrentLang
|
void GetCurrentLang(LANGLIST *e)
{
// Validate arguments
if (e == NULL)
{
return;
}
Copy(e, ¤t_lang, sizeof(LANGLIST));
}
|
/* Get the current language*/
|
Get the current language
|
GetCurrentLangId
|
UINT GetCurrentLangId()
{
LANGLIST e;
Zero(&e, sizeof(e));
GetCurrentLang(&e);
return e.Id;
}
|
/* Get the current language ID*/
|
Get the current language ID
|
SaveLangConfigCurrentDir
|
bool SaveLangConfigCurrentDir(char *str)
{
// Validate arguments
if (str == NULL)
{
return false;
}
return SaveLangConfig(LANG_CONFIG_FILENAME, str);
}
|
/* Write to the lang.config file in the current directory*/
|
Write to the lang.config file in the current directory
|
LoadLangConfigCurrentDir
|
bool LoadLangConfigCurrentDir(char *str, UINT str_size)
{
// Validate arguments
if (str == NULL)
{
return false;
}
return LoadLangConfig(LANG_CONFIG_FILENAME, str, str_size);
}
|
/* Read the lang.config file in the current directory*/
|
Read the lang.config file in the current directory
|
GetLangById
|
LANGLIST *GetLangById(LIST *o, UINT id)
{
UINT i;
// Validate arguments
if (o == NULL)
{
return NULL;
}
for (i = 0;i < LIST_NUM(o);i++)
{
LANGLIST *e = LIST_DATA(o, i);
if (e->Id == id)
{
return e;
}
}
return NULL;
}
|
/* Choose the language from the ID*/
|
Choose the language from the ID
|
GetBestLangForCurrentEnvironment
|
LANGLIST *GetBestLangForCurrentEnvironment(LIST *o)
{
LANGLIST *ret = NULL;
// Validate arguments
if (o == NULL)
{
return NULL;
}
#ifdef OS_WIN32
ret = GetBestLangByLcid(o, MsGetUserLocaleId());
#else // OS_WIN32
if (true)
{
char lang[MAX_SIZE];
if (GetEnv("LANG", lang, sizeof(lang)))
{
ret = GetBestLangByLangStr(o, lang);
}
else
{
ret = GetBestLangByLangStr(o, "C");
}
}
#endif // OS_WIN32
return ret;
}
|
/* Choice the best language for the current environment*/
|
Choice the best language for the current environment
|
GetBestLangByLcid
|
LANGLIST *GetBestLangByLcid(LIST *o, UINT lcid)
{
LANGLIST *ret;
UINT i;
// Validate arguments
if (o == NULL)
{
return NULL;
}
for (i = 0;i < LIST_NUM(o);i++)
{
LANGLIST *e = LIST_DATA(o, i);
if (IsIntInList(e->LcidList, lcid))
{
return e;
}
}
ret = GetBestLangByName(o, "en");
return ret;
}
|
/* Search for the best language from LCID*/
|
Search for the best language from LCID
|
FreeLangList
|
void FreeLangList(LIST *o)
{
UINT i;
// Validate arguments
if (o == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(o);i++)
{
LANGLIST *e = LIST_DATA(o, i);
FreeStrList(e->LangList);
ReleaseIntList(e->LcidList);
Free(e);
}
ReleaseList(o);
}
|
/* Release the language list*/
|
Release the language list
|
GetUniErrorStr
|
wchar_t *GetUniErrorStr(UINT err)
{
wchar_t *ret;
char name[MAX_SIZE];
Format(name, sizeof(name), "ERR_%u", err);
ret = GetTableUniStr(name);
if (UniStrLen(ret) != 0)
{
return ret;
}
else
{
return _UU("ERR_UNKNOWN");
}
}
|
/* Get an error string in Unicode*/
|
Get an error string in Unicode
|
GetErrorStr
|
char *GetErrorStr(UINT err)
{
char *ret;
char name[MAX_SIZE];
Format(name, sizeof(name), "ERR_%u", err);
ret = GetTableStr(name);
if (StrLen(ret) != 0)
{
return ret;
}
else
{
return _SS("ERR_UNKNOWN");
}
}
|
/* Get an error string*/
|
Get an error string
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.