Commit 449e27bf authored by Christophe Fergeau's avatar Christophe Fergeau Committed by Nikias Bassen

Add plist_is_binary()

It can be useful if one needs to know what type of plist a memory buffer
contains.
parent 19735fbd
......@@ -616,6 +616,19 @@ extern "C"
*/
void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist);
/**
* Test if in-memory plist data is binary or XML
* This method will look at the first bytes of plist_data
* to determine if plist_data contains a binary or XML plist.
* This method is not validating the whole memory buffer to check if the
* content is truly a plist, it's only using some heuristic on the first few
* bytes of plist_data.
*
* @param plist_data a pointer to the memory buffer containing plist data.
* @param length length of the buffer to read.
* @return 1 if the buffer is a binary plist, 0 otherwise.
*/
int plist_is_binary(const char *plist_data, uint32_t length);
/********************************************
* *
......
......@@ -49,6 +49,15 @@ void plist_cleanup(void)
xmlCleanupMemory();
}
PLIST_API int plist_is_binary(const char *plist_data, uint32_t length)
{
if (length < 8) {
return 0;
}
return (memcmp(plist_data, "bplist00", 8) == 0);
}
plist_t plist_new_node(plist_data_t data)
{
return (plist_t) node_create(NULL, data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment