MHEG5  18.9.0
MHEG5 Documentation
asn1_createEntryField.c
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  *******************************************************************************/
27 /*---includes for this file--------------------------------------------------*/
28 #include <stdio.h>
29 #include "vpa1_sys.h"
30 #include "vpa1_tgs.h"
31 #include "fpa1_syn.h"
32 #include "asn1_sys.h"
33 
34 #include "mh5base.h"
35 #include "mh5entryfield.h"
36 #include "asn1_createExtras.h"
38 #include "asn1_createText.h"
39 #include "asn1_createEntryField.h"
40 
41 /*---constant definitions for this file--------------------------------------*/
42 
43 
44 /*---local typedef structs for this file-------------------------------------*/
45 
46 /*---local (static) variable declarations for this file----------------------*/
47 
48 /*---local function definitions----------------------------------------------*/
49 
50 /*---global function definitions---------------------------------------------*/
51 
61 {
62  MHEG5Entryfield *entryField;
63  asnErr errVal = 0;
64  fpa1_syntaxList *currItem;
65  MHEG5Int inputTypeInt;
66 
67  DPL5((">> asn1_createEntryField(%X)\n", listPtr));
68  assert(listPtr);
69 
70  entryField = (MHEG5Entryfield *)MHEG5getMem( sizeof(MHEG5Entryfield));
71  if (entryField != NULL)
72  {
73  memset(entryField, 0, sizeof(MHEG5Entryfield));
75 
76  /* defaults */
77  entryField->inputType = mh5any;
78  /*
79  entryField->obscuredInput = MHEG5FALSE;
80  entryField->maxlength = 0;
81  */
82 
83  /* searches current set of tags for local tags */
84  currItem = listPtr->children;
85  while (currItem != NULL)
86  {
87  /* most objects will have more than one local tag */
88  switch (currItem->tag)
89  {
90  case INPUTTYPE:
91  /* this is a bit nasty because the enum inputType is defined inside
92  the MHEG5Entryfield struct. */
93  inputTypeInt = currItem->data.intData;
94  switch (inputTypeInt)
95  {
96  #ifdef INCLUDE_IC
97  case 1:
98  entryField->inputType = mh5alpha;
99  break;
100  #endif /* INCLUDE_IC */
101  case 2:
102  entryField->inputType = mh5numeric;
103  break;
104  #ifdef INCLUDE_IC
105  case 3:
106  entryField->inputType = mh5any;
107  break;
108  case 4:
109  entryField->inputType = mh5listed;
110  break;
111  #endif /* INCLUDE_IC */
112  default:
113  DPL2(("WARNING:[ASN.1] Unknown entryfield inputType, default to mh5any\n"));
114  }
115  break;
116  #ifdef INCLUDE_IC
117  case CHARLIST:
118  errVal |= asn1_decodeOctetString(currItem, &entryField->charList);
119  break;
120  #endif /* INCLUDE_IC */
121  case OBSCURED:
122  entryField->obscuredInput = (currItem->data.boolData == 0) ? MHEG5FALSE : MHEG5TRUE;
123  break;
124  case MAXLEN:
125  entryField->maxlength = currItem->data.intData;
126  break;
127  default:
128  break;
129  }
130  currItem = currItem->next;
131  }
132  /* decode inherited tags */
133  errVal |= asn1_decodeText(listPtr, &(entryField->text));
134  errVal |= asn1_decodeInteractible(listPtr, &(entryField->interactible));
135  if (errVal != ASN_NO_ERROR)
136  {
137  #if (DPLEVEL >= 2)
138  DPL2(("WARNING:[ASN.1] asn1_createEntryField() errVal = %d\n", errVal));
139  #endif /* DPLEVEL >= 2 */
140  MHEG5freeMem( entryField );
141  entryField = NULL;
142  }
143  }
144 
145  DPL5(("<< asn1_createEntryField() %X\n", entryField));
146  return (MHEG5Ingredient *)entryField;
147 }
148 
MHEG5Visible visible
Definition: mh5text.h:62
Basis MHEG5 data types.
Functions to create a MHEG5EntryField from a MHEG5 script (in the form of a list of fpa1_syntaxList s...
#define CHARLIST
Definition: vpa1_tgs.h:159
asnErr asn1_decodeOctetString(fpa1_syntaxList *listPtr, MHEG5String *decodedString)
decodes String type
Miscellaneous functions for decoding ASN.1 types.
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
#define MHEG5getMem
Definition: glue_memory.h:93
MHEG5Final clazz
Definition: mh5root.h:55
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
struct fpa1_syntaxItem * children
Definition: fpa1_syn.h:53
#define ASN_NO_ERROR
Definition: asn1_sys.h:36
syntaxItemData data
Definition: fpa1_syn.h:57
asnErr asn1_decodeInteractible(fpa1_syntaxList *listPtr, MHEG5Interactible *interactible)
Decodes interactible class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
#define DPL5(x)
Definition: glue_debug.h:167
Functions to create a MHEG5Text from a MHEG5 script (in the form of a list of fpa1_syntaxList structu...
MHEG5String charList
Definition: mh5entryfield.h:52
MHEG5Bool obscuredInput
Definition: mh5entryfield.h:53
#define INPUTTYPE
Definition: vpa1_tgs.h:158
typedefs etc for the whole object creation section.
long MHEG5Int
Definition: mh5base.h:73
Contains macros for MHEG-5 ASN.1 tags and structures.
Functions to create a MHEG5Interactible from a MHEG5 script (in the form of a list of fpa1_syntaxList...
#define MHEG5freeMem
Definition: glue_memory.h:94
MHEG5Bool boolData
Definition: fpa1_syn.h:44
MHEG5Int maxlength
Definition: mh5entryfield.h:54
#define OBSCURED
Definition: vpa1_tgs.h:160
#define DPL2(x)
Definition: glue_debug.h:185
#define MHEG5TRUE
Definition: mh5base.h:49
MHEG5Text text
Definition: mh5entryfield.h:47
MHEG5Ingredient ingredient
Definition: mh5visible.h:49
int asnErr
Definition: asn1_sys.h:41
asnErr asn1_decodeText(fpa1_syntaxList *listPtr, MHEG5Text *text)
Decodes Text class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
struct fpa1_syntaxItem * next
Definition: fpa1_syn.h:52
enum MHEG5Entryfield::@1 inputType
#define MAXLEN
Definition: vpa1_tgs.h:161
MHEG5Int intData
Definition: fpa1_syn.h:45
MHEG5Interactible interactible
Definition: mh5entryfield.h:48
#define MHEG5FALSE
Definition: mh5base.h:48
MHEG5Ingredient * asn1_createEntryField(fpa1_syntaxList *listPtr)
Decodes EntryField class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Implement the MHEG5 EntryField Class. Defines an interaction widget used by the final user to edit an...