MHEG  17.9.0
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
mh5base.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2000 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
26 #ifndef _MH5BASE_H
27 #define _MH5BASE_H
28 
29 /*---includes for this file--------------------------------------------------*/
30 
31 #include <stdio.h>
32 
33 #include "techtype.h"
34 #include "dtvstring.h"
35 #include "glue_debug.h"
36 
37 /*---Constant and macro definitions for public use---------------------------*/
38 
39 /* Rules for version number:
40  Realeases to customers : n.n
41  Minor releases to testers/internal : n.nbn
42  Modified minor releases : n.nbn+
43 
44  Example version sequence: 1.2, 1.3b0+, 1.3b1, 1.3b1+, 1.3b2, 1.3b2+, 1.3, ...
45  */
46 
47 /* Boolean values */
48 #define MHEG5FALSE (0)
49 #define MHEG5TRUE (-1)
50 
51 #ifndef MHG_STRNCMP
52 #define MHEG5strncmp(a, b, n) strncmp((char *)a, (char *)b, n)
53 #endif /* #ifdef MHG_STRNCMP */
54 
55 #ifndef MHG_STRCMP
56 #define MHEG5strcmp(a, b) strcmp((char *)a, (char *)b)
57 #endif /* #ifdef MHG_STRCMP */
58 
59 #define INVALID_GRP_REF 0
60 
61 #define MHEG5colourInit MHEG5genericSet
62 #define MHEG5colourDestruct MHEG5genericDestruct
63 
64 /*---Enumerations for public use---------------------------------------------*/
65 
66 /*---Global type defs for public use-----------------------------------------*/
67 
68 /*
69  Simple Types
70  */
71 typedef short MHEG5Bool;
72 typedef short MHEG5Short;
73 typedef long MHEG5Int;
74 typedef unsigned char MHEG5Byte;
75 
76 typedef struct SMHEG5IntPair
77 {
78  MHEG5Int x;
79  MHEG5Int y;
80 } MHEG5IntPair;
81 
82 typedef struct sMHEG5String
83 {
84  MHEG5Int len;
85  MHEG5Byte *data;
86 } MHEG5String;
87 
88 /* forward declaration of group structure */
89 typedef struct sMHEG5Group sMHEG5Group;
90 
91 /* unique id for each new group created */
92 typedef MHEG5Int MH5GroupId;
93 
94 /* forward declaration of pointer to group structure */
95 typedef struct sMHEG5Group *MH5GroupPtr;
96 
97 typedef struct sMH5GroupRef
98 {
99  MHEG5Int len; /* if (len == 0) 'pgrp' points to group, else len is string length of 'name' */
100  union
101  {
102  MHEG5Byte *name;
103  MH5GroupPtr group;
104  } ptr;
105 } MH5GroupRef;
106 
107 typedef struct sMHEG5ObjectReference
108 {
109  MHEG5Int id;
110  MH5GroupRef gref;
112 
113 
114 typedef enum
115 {
116  MHEG5NONEEVENT,
117  /* Synchronous events */
118  MHEG5ISAVAILABLE, MHEG5ISDELETED, MHEG5ISRUNNING, MHEG5ISSTOPPED,
119  MHEG5TOKENMOVEDFROM, MHEG5TOKENMOVEDTO, MHEG5HIGHLIGHTON, MHEG5HIGHLIGHTOFF,
120  MHEG5ISSELECTED, MHEG5ISDESELECTED, MHEG5TESTEVENT,
121  MHEG5HEADITEMS, MHEG5TAILITEMS, MHEG5FIRSTITEMPRESENTED,
122  MHEG5ITEMSELECTED, MHEG5ITEMDESELECTED, MHEG5LASTITEMPRESENTED,
123  /* Asynchronous events */
124  MHEG5ANCHORFIRED, MHEG5ASYNCHSTOPPED, MHEG5CONTENTAVAILABLE,
125  MHEG5COUNTERTRIGGER, MHEG5CURSORENTER, MHEG5CURSORLEAVE,
126  MHEG5ENGINEEVENT, MHEG5ENTRYFIELDFULL, MHEG5FOCUSMOVED,
127  MHEG5INTERACTIONCOMPLETED, MHEG5SLIDERVALUECHANGED,
128  MHEG5STREAMEVENT, MHEG5STREAMPLAYING, MHEG5STREAMSTOPPED,
129  MHEG5TIMERFIRED, MHEG5USERINPUT,
130  /* dummy last event */
131  MHEG5LASTEVENT
132 } MHEG5EventType;
133 
134 
135 /*
136  special MEGA-Type for holding a lot of MHEG5 types
137  */
138 typedef enum
139 {
140  MHEG5NONE, MHEG5INT, MHEG5BOOL, MHEG5NULL, MHEG5OCTETSTRING,
141  MHEG5BRACKETOPEN, MHEG5BRACKETCLOSE, MHEG5EVENT, MHEG5CONTENTREF,
142  MHEG5INTPAIR, MHEG5OBJECTREF, MHEG5OBJREFEXT, MHEG5CONTENTSIZE, MHEG5CONTENTCCP
143 } E_ParamTypes;
144 
145 typedef MHEG5Bool MHEG5Boolean;
146 
147 typedef struct
148 {
149  U8BIT indirect;
150  U8BIT isfirst;
151  U16BIT type;
152  union
153  {
154  MHEG5Int i;
155  MHEG5Bool b;
156  MHEG5String s;
157  MHEG5EventType e;
158  MHEG5IntPair p;
160  } value;
161 } MHEG5Generic;
162 
163 
164 
165 
166 /*
167  List of Generic Items
168  */
170 {
171  MHEG5Generic generic;
172  struct sMHEG5GList *next;
173 };
174 
175 typedef struct sMHEG5GList MHEG5GList;
176 
177 typedef MHEG5Generic MHEG5Colour;
178 
179 typedef struct sParamList
180 {
181  MHEG5Int total;
182  MHEG5GList *params;
183 } ParamList;
184 
185 
186 
187 /*
188  MHEG5 Finals
189  */
190 typedef enum
191 {
192  MHEG5SCENE, MHEG5APPLICATION, MHEG5LINK, MHEG5PALETTE, MHEG5CURSORSHAPE,
193  MHEG5FONT, MHEG5RESIDENTPROGRAM, MHEG5REMOTEPROGRAM, MHEG5INTERCHANGEDPROGRAM,
194  MHEG5BOOLEANVARIABLE, MHEG5INTEGERVARIABLE,
195  MHEG5OCTETSTRINGVARIABLE, MHEG5OBJECTREFVARIABLE, MHEG5CONTENTREFVARIABLE,
196  MHEG5STREAM, MHEG5AUDIO, MHEG5TOKENGROUP, MHEG5LISTGROUP, MHEG5RTGRAPHICS,
197  MHEG5LINEART, MHEG5BITMAP, MHEG5TEXT, MHEG5VIDEO, MHEG5SLIDER, MHEG5DYNAMICLINEART,
198  MHEG5RECTANGLE, MHEG5ENTRYFIELD, MHEG5HYPERTEXT, MHEG5HOTSPOT, MHEG5PUSHBUTTON,
199  MHEG5SWITCHBUTTON
200 } MHEG5Final;
201 
202 
203 typedef enum
204 {
205  MHEG5LEFT, MHEG5RIGHT, MHEG5UP, MHEG5DOWN
206 } MHEG5Orientation;
207 
208 typedef enum
209 {
210  MHEG5NORMAL, MHEG5THERMOMETER, MHEG5PROPORTIONAL
211 } MHEG5SliderStyle;
212 
213 typedef enum
214 {
215  MHEG5PUSHBUTTONS, MHEG5RADIOBUTTON, MHEG5CHECKBOX
216 } MHEG5PushbuttonStyle;
217 
218 
219 /*
220  Error Codes
221  */
222 typedef enum
223 {
224  MHEG5ERR_NOERROR,
225  MHEG5ERR_NOTYETSUPPORTED,
226  MHEG5ERR_NOTSUPPORTEDBYPROFILE,
227  MHEG5ERR_WRONGNUMBEROFPARAMS,
228  MHEG5ERR_TARGETNOTAVAILABLE,
229  MHEG5ERR_WRONGTARGET,
230  MHEG5ERR_REFERENCEDPARAMNOTAVAILABLE,
231  MHEG5ERR_WRONGPARAM,
232  MHEG5ERR_PARAMNOTACTIVE,
233  MHEG5ERR_NOSCENE,
234  MHEG5ERR_TARGETNOTACTIVE,
235  MHEG5ERR_NOSUCHITEM,
236  MHEG5ERR_NOSUCHSLOT,
237  MHEG5ERR_IGNORE_ACTION /* Used by Launch, Spawn and TransitionTo */
238 } MHEG5ErrorCode;
239 
240 typedef struct sMHEG5FontBody
241 {
242  MHEG5Bool referenced;
243  union
244  {
245  MHEG5String included;
246  struct
247  {
248  MHEG5Int id;
249  MH5GroupRef grp;
250  } referenced;
251  } ref;
252 } MHEG5FontBody;
253 
254 /*---Global variable declarations for public use-----------------------------*/
255 
256 /*---Global Function prototypes for public use-------------------------------*/
257 
263 #ifdef MHG_TRACK_MEM
264 MHEG5String MHEG5stringCopyFunc(MHEG5String source, int line );
265 #define MHEG5stringCopy(s) MHEG5stringCopyFunc(s, __LINE__)
266 #else
268 #endif
269 MHEG5String MHEG5stringCopyChr(const char *source);
271 void MHEG5stringDestruct(MHEG5String *item);
272 MHEG5Int MHEG5strToInt(MHEG5String string);
273 MHEG5Bool MHEG5stringEqual(MHEG5String *s1, MHEG5String *s2);
274 MHEG5String MHEG5intToStr(MHEG5Int i);
275 
276 #ifdef MHEG5LOG
277 
278 char* MHEG5stringGet(MHEG5String source);
279 
280 #endif
281 
282 void MHEG5genericSet(MHEG5Generic *item, MHEG5Int initialValue);
284 MHEG5Bool MHEG5genericEqual(MHEG5Generic *g1, MHEG5Generic *g2);
285 void MHEG5genericCopy(MHEG5Generic *dest, MHEG5Generic *src);
286 
287 void MHEG5gListDestruct(MHEG5GList *item);
289 
290 #ifdef MHG_STRNCMP
291 
292 int MHEG5strncmp(char *a, char *b, int n);
293 
294 #endif /* #ifdef MHG_STRNCMP */
295 
296 #ifdef MHG_STRCMP
297 
298 int MHEG5strcmp(char *a, char *b);
299 
300 #endif /* #ifdef MHG_STRCMP */
301 
306 unsigned long MHEG5random(void);
307 
308 
319 char* MHEG5safeStrcat(char *dest, size_t destLength,
320  const char *source);
321 
322 
323 #ifdef _WIN32_WCE
324 TCHAR* StrToUnicode(char *string);
325 char* StrFromUnicode(TCHAR *string);
326 #endif
327 
328 /*
329  Debug
330  */
331 #ifdef MH5PRINTOUT
332 void MHEG5classPrint(MHEG5Final class, char *out);
333 void MHEG5indent(char *out);
334 int MHEG5setIndent(int i);
335 void MHEG5incIndent(void);
336 void MHEG5decIndent(void);
337 void MHEG5newLine(char *out);
338 
339 #define MHEG_PRINT(out, str) STB_DebugLogPrintf(str)
340 #define MHEG5intPrint(i, out) STB_DebugLogPrintf("%ld", i)
341 #define MHEG5hexPrint(i, out) STB_DebugLogPrintf("%#x", i)
342 #endif /* #ifdef MH5PRINTOUT */
343 
344 #if defined(MHEG5LOG) || defined(MH5PRINTOUT)
345 void MHEG5eventPrint(MHEG5EventType e, char *out);
346 void MHEG5stringPrint(MHEG5String s, char *out);
347 void MHEG5objectrefPrint(MHEG5ObjectReference o, char *out);
348 void MHEG5boolPrint(MHEG5Bool b, char *out);
349 void MHEG5genericPrint(MHEG5Generic g, char *out, U8BIT dotype);
350 void MHEG5colourPrint(MHEG5Colour c, char *out);
351 void MHEG5gListPrint(MHEG5GList *l, char *out, U8BIT noTypeCnt);
352 void MHEG5cListPrint(MHEG5GList *l, char *out);
353 void MHEG5sdListPrint(MHEG5GList *l, char *out);
354 void MHEG5clrListPrint(MHEG5GList *l, char *out);
355 #endif /* #ifdef MHEG5LOG */
356 
357 #ifdef TRACING
358 extern int extra_trace_param;
359 #endif
360 
361 #endif /*_MH5BASE_H*/
unsigned long MHEG5random(void)
Calculate and return a psuedo random number.
Definition: mh5base.c:1071
MHEG5GList * MHEG5gListCopy(MHEG5GList *list)
Copy a list of MHEG5Generic objects.
Definition: mh5base.c:950
Define MHEG5 String type.
MHEG5Bool MHEG5stringEqual(MHEG5String *s1, MHEG5String *s2)
Compare two Strings (case sensitive!)
Definition: mh5base.c:710
Definition: mh5base.h:82
void MHEG5genericSet(MHEG5Generic *item, MHEG5Int initialValue)
Set a MHEG5Generic to the MHEG5Int value.
Definition: mh5base.c:978
Debug tracing.
Definition: mh5group.h:47
void MHEG5genericCopy(MHEG5Generic *dest, MHEG5Generic *src)
Copy a MHEG5Generic.
Definition: mh5base.c:861
MHEG5Int MHEG5strToInt(MHEG5String string)
Convert a MHEG5String to a MHEG5Integer.
Definition: mh5base.c:739
MHEG5Bool MHEG5genericEqual(MHEG5Generic *g1, MHEG5Generic *g2)
Compare two generic Variables.
Definition: mh5base.c:889
MHEG5String MHEG5stringCopy(MHEG5String source)
<Function description>="">
Definition: mh5base.c:574
char * MHEG5safeStrcat(char *dest, size_t destLength, const char *source)
Perform a standard strcat restricted to the length of the destination. The dest string will always be...
Definition: mh5base.c:1103
void MHEG5stringDestruct(MHEG5String *item)
Destruct a MHEG5String.
Definition: mh5base.c:686
Definition: mh5base.h:97
void MHEG5gListDestruct(MHEG5GList *item)
Destruct a list of MHEG5Generic objects.
Definition: mh5base.c:933
Definition: mh5base.h:240
Definition: mh5base.h:107
Definition: mh5base.h:169
Definition: mh5base.h:179
MHEG5String MHEG5stringCat(MHEG5String string1, MHEG5String string2)
Concatenate two MHEG5Strings.
Definition: mh5base.c:648
MHEG5String MHEG5intToStr(MHEG5Int i)
Convert MHEG5Int to MHEG5String.
Definition: mh5base.c:787
Definition: mh5base.h:76
void MHEG5genericDestruct(MHEG5Generic *item)
Destruct a MHEG5Generic.
Definition: mh5base.c:834
Definition: mh5base.h:147
System Wide Global Technical Data Type Definitions.
MHEG5String MHEG5stringCopyChr(const char *source)
Copy the C-String source to a MHEG5String.
Definition: mh5base.c:612