exip  Alpha 0.5.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
procTypes.c
Go to the documentation of this file.
1 /*==================================================================*\
2 | EXIP - Embeddable EXI Processor in C |
3 |--------------------------------------------------------------------|
4 | This work is licensed under BSD 3-Clause License |
5 | The full license terms and conditions are located in LICENSE.txt |
6 \===================================================================*/
7 
18 #include "procTypes.h"
19 #include "memManagement.h"
20 
22 {
23  opts->enumOpt = 0;
24  opts->preserve = 0; // all preserve flags are false by default
25  opts->blockSize = 1000000;
26  opts->valueMaxLength = INDEX_MAX;
28  opts->user_defined_data = NULL;
30  opts->schemaID.str = NULL;
31  opts->schemaID.length = 0;
32  opts->drMap = NULL;
33 }
34 
36 {
49  {
50  DEBUG_MSG(ERROR, DEBUG_COMMON, ("\n>EXI Options mismatch: both \"alignment\" and \"compression\" set"));
52  }
53  else if(WITH_STRICT(opts->enumOpt) &&
59  )
60  {
61  DEBUG_MSG(ERROR, DEBUG_COMMON, ("\n>EXI Options mismatch: both \"strict\" and one or more of \"dtd\", \"prefixes\", \"comments\", \"pis\" or \"selfContained\" are set"));
63  }
65  {
66  DEBUG_MSG(ERROR, DEBUG_COMMON, ("\n>EXI Options mismatch: both \"selfContained\" and (\"compression\" or \"pre-compression\") are set"));
68  }
69 
70  if(opts->drMap != NULL && (IS_PRESERVED(opts->preserve, PRESERVE_LEXVALUES)))
71  {
72  DEBUG_MSG(WARNING, DEBUG_COMMON, ("\n>The datatypeRepresentationMap option specified but has no effect"));
73  }
74 
75  return EXIP_OK;
76 }
77 
78 errorCode pushOnStack(GenericStack** stack, void* item)
79 {
80  struct stackNode* node = (struct stackNode*)EXIP_MALLOC(sizeof(struct stackNode));
81  if(node == NULL)
83 
84  node->item = item;
85  node->nextInStack = *stack;
86  *stack = node;
87  return EXIP_OK;
88 }
89 
90 void popFromStack(GenericStack** stack, void** item)
91 {
92  struct stackNode* node;
93  if((*stack) == NULL)
94  {
95  (*item) = NULL;
96  }
97  else
98  {
99  node = *stack;
100  *stack = (*stack)->nextInStack;
101 
102  (*item) = node->item;
103  EXIP_MFREE(node);
104  }
105 }
106 
107 int compareEnumDefs(const void* enum1, const void* enum2)
108 {
109  EnumDefinition* e1 = (EnumDefinition*) enum1;
110  EnumDefinition* e2 = (EnumDefinition*) enum2;
111 
112  if(e1->typeId < e2->typeId)
113  return -1;
114  else if(e1->typeId > e2->typeId)
115  return 1;
116 
117  return 0;
118 }
119 
121 {
122  struct stackNode* node = (struct stackNode*)memManagedAllocate(memList, sizeof(struct stackNode));
123  if(node == NULL)
125 
126  node->item = item;
127  node->nextInStack = *stack;
128  *stack = node;
129  return EXIP_OK;
130 }
131 
133 {
134  struct stackNode* node;
135  if((*stack) == NULL)
136  {
137  (*item) = NULL;
138  }
139  else
140  {
141  node = *stack;
142  *stack = (*stack)->nextInStack;
143 
144  (*item) = node->item;
145  }
146 }
147 
148 #if EXIP_DEBUG == ON
149 // IMPORTANT: remember to keep in sync with "enum errorCode" in errorHandle.h!
150  const char* errorCodeStrings[] =
151  {
152  "EXIP_OK",
153  "EXIP_NOT_IMPLEMENTED_YET",
154  "EXIP_UNEXPECTED_ERROR",
155  "EXIP_HASH_TABLE_ERROR",
156  "EXIP_OUT_OF_BOUND_BUFFER",
157  "EXIP_NULL_POINTER_REF",
158  "EXIP_MEMORY_ALLOCATION_ERROR",
159  "EXIP_INVALID_EXI_HEADER",
160  "EXIP_INCONSISTENT_PROC_STATE",
161  "EXIP_INVALID_EXI_INPUT",
162  "EXIP_BUFFER_END_REACHED",
163  "EXIP_PARSING_COMPLETE",
164  "EXIP_INVALID_EXIP_CONFIGURATION",
165  "EXIP_NO_PREFIXES_PRESERVED_XML_SCHEMA",
166  "EXIP_INVALID_STRING_OPERATION",
167  "EXIP_HEADER_OPTIONS_MISMATCH",
168  "EXIP_HANDLER_STOP"
169  };
170 #endif