32 #define BKG_TITLE_TOKEN "t" 33 #define BKG_BOOKING_TOKEN "b" 34 #define BKG_CRIDTYPE_TOKEN "ct" 35 #define BKG_SYNOPSIS_TOKEN "s" 36 #define BKG_LOCATION_TOKEN "l" 37 #define BKG_DVB_TOKEN "dvb://" 39 #define BKG_CRID_TTL_STRING "{\"ct\":\"49\",\"t\":\"" 40 #define BKG_SYNOPSIS_STRING "\",\"s\":\"" 41 #define BKG_BOOKING_PREFIX "\",\"b\":[" 42 #define BKG_LOCATION_PREFIX "\"l\":\"dvb://" 43 #define BKG_DURATION_PREFIX "--PT" 44 #define BKG_BOOKING_ENDFIX "]}" 46 #define MAX_INT_LENGTH 32 47 #define MIN_DATA_BLOCK 32 75 static void* NewLocation(
unsigned int val,
void *array,
void *cptr );
76 static void* BookingArray(
unsigned int val,
void *array,
void *cptr );
77 static void* DoneLocation(
unsigned int val,
void *array,
void *cptr );
112 if (ch >=
'0' && ch <=
'9')
120 else if (ch >=
'a' && ch <=
'z')
122 if (base > 10 && ch -
'a' < base - 10)
124 *value = ch -
'a' + 10;
128 else if (ch >=
'A' && ch <=
'Z')
130 if (base > 10 && ch -
'A' < base - 10)
132 *value = ch -
'A' + 10;
155 U32BIT originalNetworkId = 0;
156 U32BIT transportStreamId = 0;
160 enum {ST_FIRST_DIGIT, ST_FIRST_NUMBER, ST_FIRST_DOT,
161 ST_SECOND_NUMBER, ST_SECOND_DOT,
162 ST_THIRD_NUMBER, ST_END, ST_ERROR} state = ST_FIRST_DIGIT;
166 while (ndx != length && state != ST_ERROR)
171 if (!MHEG5IsDigit(buffer[ndx], 16, &value))
177 originalNetworkId = value;
178 state = ST_FIRST_NUMBER;
181 case ST_FIRST_NUMBER:
182 if (buffer[ndx] ==
'.')
184 state = ST_FIRST_DOT;
186 else if (!MHEG5IsDigit(buffer[ndx], 16, &value))
192 originalNetworkId *= 16;
193 originalNetworkId += value;
197 if (buffer[ndx] ==
'.')
199 state = ST_SECOND_DOT;
201 else if (!MHEG5IsDigit(buffer[ndx], 16, &value))
207 transportStreamId = value;
208 state = ST_SECOND_NUMBER;
211 case ST_SECOND_NUMBER:
212 if (buffer[ndx] ==
'.')
214 state = ST_SECOND_DOT;
216 else if (!MHEG5IsDigit(buffer[ndx], 16, &value))
222 transportStreamId *= 16;
223 transportStreamId += value;
227 if (!MHEG5IsDigit(buffer[ndx], 16, &value))
234 state = ST_THIRD_NUMBER;
237 case ST_THIRD_NUMBER:
238 if (!MHEG5IsDigit(buffer[ndx], 16, &value))
254 if (state == ST_THIRD_NUMBER)
273 for (p = buf; p != end; p++)
275 if (MHEG5IsDigit(*p, 10, &value))
277 lcn = (lcn * 10) + value;
291 #ifdef INCLUDE_PVR_AU 293 static int ParseLocation(
char *in_data,
int chrs_left,
S_LOCATION *p_loc )
297 while (posn != chrs_left && in_data[posn] !=
'@')
300 if (posn == chrs_left ||
301 strncmp((
char *)in_data, (
char *)
"dvb://", 6) != 0 ||
311 while (posn < chrs_left && in_data[posn] !=
'\"')
313 if (in_data[posn] >=
'0' && in_data[posn] <=
'9')
318 case 0: value = (int)(in_data[posn] -
'0');
break;
320 value = (value * 10) + (
int)(in_data[posn] -
'0');
323 p_loc->
date.
year = (value * 10) + (
int)(in_data[posn] -
'0');
326 case 4: value = (int)(in_data[posn] -
'0');
break;
328 p_loc->
date.
month = (value * 10) + (
int)(in_data[posn] -
'0');
331 case 6: value = (int)(in_data[posn] -
'0');
break;
333 p_loc->
date.
day = (value * 10) + (
int)(in_data[posn] -
'0');
336 case 9: value = (int)(in_data[posn] -
'0');
break;
338 p_loc->
time.
hour = (value * 10) + (
int)(in_data[posn] -
'0');
341 case 12: value = (int)(in_data[posn] -
'0');
break;
343 p_loc->
time.
minute = (value * 10) + (
int)(in_data[posn] -
'0');
346 case 17: value = (int)(in_data[posn] -
'0');
break;
348 p_loc->
duration.
hour = (value * 10) + (
int)(in_data[posn] -
'0');
351 case 20: value = (int)(in_data[posn] -
'0');
break;
353 p_loc->
duration.
minute = (value * 10) + (
int)(in_data[posn] -
'0');
356 TRACE(TERROR, (
"%c count=%d", in_data[posn], count))
366 if (in_data[posn] !=
'T')
368 TRACE(TERROR, (
"%c %d", in_data[posn], in_data[posn]))
374 if (in_data[posn] !=
':')
376 TRACE(TERROR, (
"%c %d", in_data[posn], in_data[posn]))
381 if (in_data[posn] !=
'-')
383 TRACE(TERROR, (
"%c %d", in_data[posn], in_data[posn]))
388 if (in_data[posn] !=
'P')
390 TRACE(TERROR, (
"%c %d", in_data[posn], in_data[posn]))
395 if (in_data[posn] !=
'T')
397 TRACE(TERROR, (
"%c %d", in_data[posn], in_data[posn]))
402 if (in_data[posn] !=
'H')
404 TRACE(TERROR, (
"%c %d", in_data[posn], in_data[posn]))
409 if (in_data[posn] !=
'M')
411 TRACE(TERROR, (
"%c %d", in_data[posn], in_data[posn]))
416 TRACE(TERROR, (
"%c count=%d", in_data[posn], count))
433 static void* NewLocation(
unsigned int val,
void *array,
void *cptr )
438 if (ParseLocation((
char *)array, val, pLoc ) == -1)
445 static void* DoneLocation(
unsigned int val,
void *array,
void *cptr )
448 return (
void *)(pLoc + 1);
451 static void* BookingArray(
unsigned int val,
void *array,
void *cptr )
462 *p_booking_ptr = pBook;
463 p_booking_ptr = &(pBook->
next);
471 TRACE(TERROR, (
"Array FINISH"))
475 TRACE(TERROR, (
"Array ERROR"))
486 p_booking_ptr = &(pDetails->
bookings);
490 if (ctype_str.
zlen == 2 && ctype_str.
zptr != NULL &&
491 title_str.
zptr != NULL && synop_str.
zptr != NULL)
493 if (ctype_str.
zptr[0] ==
'4' && ctype_str.
zptr[1] ==
'9')
498 else if (ctype_str.
zptr[0] ==
'5' && ctype_str.
zptr[1] ==
'0')
505 ctype_str.
zptr = NULL;
507 pDetails->
title = title_str;
508 title_str.
zptr = NULL;
511 synop_str.
zptr = NULL;
515 MHEG5freeDecodeBookings( pDetails );
539 while (pBook != NULL);
543 char* ParseCatHexNum(
char *p_os,
U16BIT num )
545 const char ch[16] =
"0123456789abcdef";
554 *p_os = ch[(num >> 12) & 0xf];
557 *p_os = ch[(num >> 8) & 0xf];
560 *p_os = ch[(num >> 4) & 0xf];
563 *p_os = ch[(num >> 0) & 0xf];
569 char* ParseCatDecNum(
char *p_os,
U16BIT num )
575 ch[c++] = (char)(n % 10) +
'0';
600 if (n_locs != 0 && n_locs < 16)
615 if (out_str.
data != NULL)
618 char *os_data = (
char *)out_str.
data;
622 if (pDetails->
type == 50)
624 while (*os_data !=
'4')
629 os_data = (
char *)&out_str.
data[len];
664 os_data = ParseCatDecNum( os_data, p_loc->
date.
year );
665 os_data = ParseCatDecNum( os_data, p_loc->
date.
month );
666 os_data = ParseCatDecNum( os_data, p_loc->
date.
day );
669 os_data = ParseCatDecNum( os_data, p_loc->
time.
hour );
672 os_data = ParseCatDecNum( os_data, p_loc->
time.
minute );
675 os_data = ParseCatDecNum( os_data, p_loc->
offset.
hour );
678 os_data = ParseCatDecNum( os_data, p_loc->
offset.
minute );
683 os_data = ParseCatDecNum( os_data, p_loc->
duration.
hour );
704 out_str.
len = (int)os_data - (
int)out_str.
data;
709 TRACE(TERROR, (
"Invalid number of locations %d", n_locs))
739 success = AppendInteger(buffer, used, allocated, value->
value.
i);
745 success = AppendString(buffer, used, allocated,
750 success = AppendString(buffer, used, allocated,
756 success = EncodeOctetString(buffer, used, allocated,
762 success = EncodeOctetString(buffer, used, allocated,
778 success = AppendChar(buffer, used, allocated,
'(');
781 success = EncodeOctetString(buffer, used, allocated, data, len);
785 success = AppendChar(buffer, used, allocated,
' ');
789 success = AppendInteger(buffer, used, allocated, value->
value.
o.
id);
793 success = AppendChar(buffer, used, allocated,
')');
822 for (i = 0; success && i <
len; ++i)
824 success = EncodeChar(buffer, used, allocated, data[i]);
848 success = AppendChar(buffer, used, allocated,
'\n');
853 success = AppendChar(buffer, used, allocated,
'\t');
855 else if (ch >= 0x20 && ch < 0x7f && ch !=
'=' && ch !=
'\'')
858 success = AppendChar(buffer, used, allocated, ch);
863 success = AppendChar(buffer, used, allocated,
'=');
873 digit =
'A' + digit - 10;
875 success = AppendChar(buffer, used, allocated, digit);
886 digit =
'A' + digit - 10;
888 success = AppendChar(buffer, used, allocated, digit);
912 for (i = 0; success && i <
len; ++i)
914 success = AppendChar(buffer, used, allocated, data[i]);
935 nbytes = sprintf(decimal,
"%ld", value);
937 for (i = 0; success && i < nbytes; ++i)
939 success = AppendChar(buffer, used, allocated, decimal[i]);
962 if (*buffer != NULL && *used + 1 < *allocated)
964 (*buffer)[*used] = ch;
966 (*buffer)[*used] =
'\0';
969 else if (*buffer == NULL)
983 new_size = *allocated * 2;
985 if (new_block != NULL)
987 memcpy(new_block, *buffer, *used);
990 *allocated = new_size;
991 (*buffer)[*used] = ch;
993 (*buffer)[*used] =
'\0';
1029 if (*buffer != NULL && *used > 0)
1031 success = AppendChar(buffer, used, allocated,
'&');
1035 success = AddOctetString(buffer, used, allocated,
1040 success = AppendChar(buffer, used, allocated,
'=');
1044 switch (value->
type)
1047 success = AppendInteger(buffer, used, allocated, value->
value.
i);
1052 success = AddOctetString(buffer, used, allocated,
1057 success = AddOctetString(buffer, used, allocated,
1062 success = AddOctetString(buffer, used, allocated,
1067 success = AddOctetString(buffer, used, allocated,
1082 success = AddOctetString(buffer, used, allocated, data, len);
1085 success = AddEncodedChar(buffer, used, allocated,
',');
1089 success = AppendInteger(buffer, used, allocated,
1118 for (i = 0; success && i <
len; ++i)
1120 success = AddEncodedChar(buffer, used, allocated, data[i]);
1138 static MHEG5Byte hex[] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
1139 '8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' };
1141 if ((ch >=
'0' && ch <=
'9') ||
1142 (ch >=
'A' && ch <=
'Z') ||
1143 (ch >=
'a' && ch <=
'z') ||
1144 (ch ==
'-' || ch ==
'.' || ch ==
'_' || ch ==
'~'))
1146 success = AppendChar(buffer, used, allocated, ch);
1151 success = AppendChar(buffer, used, allocated,
'+');
1156 success = AppendChar(buffer, used, allocated,
'%');
1159 success = AppendChar(buffer, used, allocated, hex[ch >> 4]);
1163 success = AppendChar(buffer, used, allocated, hex[ch & 0xf]);
#define BKG_CRID_TTL_STRING
#define JSON_VALUE_FINISH
E_JSON_STATE JSON_Parse(U8BIT *data, U32BIT size, const S_JSON_MEMBERS *members, void *usr)
#define DECLARE_MEMBER(token_str, type, ptr, child_object)
union sMH5GroupRef::@5 ptr
Implementation of the Group class Description Defines the structure and behaviour of objects used as ...
#define BKG_CRIDTYPE_TOKEN
union MHEG5Generic::@6 value
U16BIT transport_stream_id
U16BIT original_network_id
#define BKG_BOOKING_TOKEN
string parsing utility functions for MHEG5
#define BKG_LOCATION_PREFIX
#define BKG_SYNOPSIS_STRING
MHEG5Bool MHEG5parseEncodeQPrintable(MHEG5Byte **buffer, MHEG5Int *used, MHEG5Int *allocated, MHEG5Generic *value)
Add a value to the buffer. The value is QPrintable-encoded, which means that printable characters are...
#define BKG_BOOKING_ENDFIX
#define BKG_DURATION_PREFIX
MHEG5Bool MHEG5parseDvbUrl(U8BIT *buffer, U32BIT length, S_DVB_LOCATOR *dvb_loc)
Parse a DAVIC style multiplex reference or UK-DTT inherritance format URL. This can be one of the fol...
string parsing utility functions described by the [JSON] schema
#define BKG_LOCATION_TOKEN
#define BKG_SYNOPSIS_TOKEN
#define BKG_BOOKING_PREFIX
int MHEG5parseLcn(U8BIT *buf, U8BIT *end)
U8BIT name[MAX_NAME_LENGTH+1]
#define DECLARE_OBJECT(cb_func)
void JSON_FreeAstring(S_STRING *p_str)