MHEG5
15.3.0
|
00001 /******************************************************************************* 00002 * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org) 00003 * Copyright © 2010 Ocean Blue Software Ltd 00004 * 00005 * This file is part of a DTVKit Software Component 00006 * You are permitted to copy, modify or distribute this file subject to the terms 00007 * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org 00008 * 00009 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 00010 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 00011 * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 00012 * 00013 * If you or your organisation is not a member of DTVKit then you have access 00014 * to this source code outside of the terms of the licence agreement 00015 * and you are expected to delete this and any associated files immediately. 00016 * Further information on DTVKit, membership and terms can be found at www.dtvkit.org 00017 *******************************************************************************/ 00025 #ifndef _MH5JSON_H 00026 #define _MH5JSON_H 00027 00028 /*---includes for this file--------------------------------------------------*/ 00029 #include "techtype.h" 00030 #include "dtvstring.h" 00031 00032 /*---Constant and macro definitions for public use---------------------------*/ 00033 /* values given to callback when JST_CBF_ARRAY_OBJ */ 00034 #define JSON_VALUE_FINISH 0x80000000 00035 #define JSON_VALUE_ERROR 0xffffffff 00036 #define NULL_TOKEN "" 00037 00038 /* helpful macro's for creating const token elements of S_JSON_MEMBERS */ 00039 #define DECLARE_MEMBER( token_str, type, ptr, child_object ) \ 00040 { sizeof(token_str) - 1, token_str, type, {ptr}, child_object } 00041 #define DECLARE_OBJECT( cb_func ) \ 00042 { 0, NULL_TOKEN, JST_CBF_OBJECT, {cb_func}, NULL } 00043 #define DECLARE_OBJEND() \ 00044 { 0, NULL_TOKEN, JST_NOTHING, {NULL}, NULL } 00045 00046 /*---Enumerations for public use---------------------------------------------*/ 00047 00048 /*---Global type defs for public use-----------------------------------------*/ 00049 00050 typedef enum 00051 { 00052 JST_NOTHING, 00053 JST_PTR_INTEGER, 00054 JST_PTR_STRING, 00055 JST_PTR_ASTRING, 00056 JST_CBF_OBJECT, 00057 JST_CBF_INTEGER, 00058 JST_CBF_STRING, 00059 JST_CBF_ASTRING, 00060 JST_CBF_ARRAY_OBJ, 00061 /*below are not yet supported*/ 00062 JST_CBF_ARRAY_INT, 00063 JST_CBF_ARRAY_STR 00064 } E_JSON_TYPE; 00065 00066 typedef enum 00067 { 00068 JSON_ERROR, 00069 JSON_OKAY, 00070 JSON_MAIN, 00071 JSON_NEXT, 00072 } E_JSON_STATE; 00073 00074 00101 typedef void * (*JsonCallback)( unsigned int val, void *array, void *usr ); 00102 00103 00104 typedef struct s_json_members 00105 { 00106 unsigned int tk_len; 00107 const char *tk_str; 00108 E_JSON_TYPE type; 00109 union 00110 { 00111 void *ptr; 00112 JsonCallback cb_func; 00113 U32BIT *p_uint; 00114 S_STRING *p_str; 00115 } u; 00116 const struct s_json_members *pChildren; 00117 } S_JSON_MEMBERS; 00118 00119 00120 /*---Global variable declarations for public use-----------------------------*/ 00121 00122 /*---Global Function prototypes for public use-------------------------------*/ 00123 00132 E_JSON_STATE JSON_Parse( U8BIT *data, U32BIT size, 00133 const S_JSON_MEMBERS *members, void *usr ); 00134 00139 void JSON_FreeAstring( S_STRING *p_str ); 00140 00145 void JSON_FreeUintArray( U32BIT *p_uint ); 00146 00153 void JSON_FreeStrArray( S_STRING **pp_str ); 00154 00155 #endif /*_MH5JSON_H*/