From 449e27bf754f903f856a741e163a9e4a0c8037b0 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 12 May 2016 02:52:50 +0200 Subject: Add plist_is_binary() It can be useful if one needs to know what type of plist a memory buffer contains. --- include/plist/plist.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/plist/plist.h b/include/plist/plist.h index acd1c4d..2b7e1a1 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h @@ -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); /******************************************** * * -- cgit v1.1-32-gdbae