gwenhywfar  5.10.1
tm_inline.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Thu Jul 02 2009
3  copyright : (C) 2009 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 #ifdef HAVE_CONFIG_H
11 # include <config.h>
12 #endif
13 
14 
15 #include "tm_inline_p.h"
16 #include "tm_util.h"
17 
18 
19 #include <gwenhywfar/debug.h>
20 #include <gwenhywfar/misc.h>
21 
22 #include <assert.h>
23 
24 
25 
26 GWEN_LIST_FUNCTIONS(TYPEMAKER2_INLINE, Typemaker2_Inline)
27 
28 
29 
31 {
33 
35  th->refCount=1;
37 
38  return th;
39 }
40 
41 
42 
44 {
45  if (th) {
46  assert(th->refCount);
47  if (th->refCount==1) {
49  free(th->content);
50  th->refCount=0;
51  GWEN_FREE_OBJECT(th);
52  }
53  else
54  th->refCount++;
55  }
56 }
57 
58 
59 
61 {
62  assert(th);
63  assert(th->refCount);
64  th->refCount++;
65 }
66 
67 
68 
70 {
71  assert(th);
72  assert(th->refCount);
73  return th->content;
74 }
75 
76 
77 
79 {
80  assert(th);
81  assert(th->refCount);
82  free(th->content);
83  if (s)
84  th->content=strdup(s);
85  else
86  th->content=NULL;
87 }
88 
89 
90 
92 {
93  assert(th);
94  assert(th->refCount);
95  return th->location;
96 }
97 
98 
99 
101 {
102  assert(th);
103  assert(th->refCount);
104  th->location=i;
105 }
106 
107 
108 
110 {
111  assert(th);
112  assert(th->refCount);
113  return th->acc;
114 }
115 
116 
117 
119 {
120  assert(th);
121  assert(th->refCount);
122  th->acc=i;
123 }
124 
125 
126 
128 {
129  assert(th);
130  assert(th->refCount);
131  return th->typeFlagsMask;
132 }
133 
134 
135 
137 {
138  assert(th);
139  assert(th->refCount);
140  return th->typeFlagsValue;
141 }
142 
143 
144 
146 {
147  TYPEMAKER2_INLINE *th;
148  const char *s;
149 
151 
152  s=GWEN_XMLNode_GetCharValue(node, "content", NULL);
154 
155  s=GWEN_XMLNode_GetCharValue(node, "typeFlagsMask", NULL);
156  if (s && *s)
157  th->typeFlagsMask=Typemaker2_TypeFlagsFromString(s);
158 
159  s=GWEN_XMLNode_GetCharValue(node, "typeFlagsValue", NULL);
160  if (s && *s)
161  th->typeFlagsValue=Typemaker2_TypeFlagsFromString(s);
162 
163  /* read header location */
164  s=GWEN_XMLNode_GetProperty(node, "loc", "post");
165  if (strcasecmp(s, "header")==0)
167  else if (strcasecmp(s, "code")==0)
169 
170  /* read access */
171  s=GWEN_XMLNode_GetProperty(node, "access", "public");
173 
174  return th;
175 }
176 
177 
178 
179 
180 
181 
182 
void Typemaker2_Inline_SetAccess(TYPEMAKER2_INLINE *th, int i)
Definition: tm_inline.c:118
int Typemaker2_Inline_GetTypeFlagsValue(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:136
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:239
const char * Typemaker2_Inline_GetContent(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:69
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:61
#define NULL
Definition: binreloc.c:300
void Typemaker2_Inline_free(TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:43
TYPEMAKER2_INLINE * Typemaker2_Inline_new()
Definition: tm_inline.c:30
struct TYPEMAKER2_INLINE TYPEMAKER2_INLINE
Definition: tm_inline.h:19
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55
const char * GWEN_XMLNode_GetCharValue(const GWEN_XMLNODE *n, const char *name, const char *defValue)
Definition: xml.c:812
int Typemaker2_Inline_GetTypeFlagsMask(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:127
int Typemaker2_AccessFromString(const char *s)
Definition: tm_util.c:163
void Typemaker2_Inline_SetContent(TYPEMAKER2_INLINE *th, const char *s)
Definition: tm_inline.c:78
TYPEMAKER2_INLINE * Typemaker2_Inline_fromXml(GWEN_XMLNODE *node)
Definition: tm_inline.c:145
void Typemaker2_Inline_SetLocation(TYPEMAKER2_INLINE *th, int i)
Definition: tm_inline.c:100
uint32_t Typemaker2_TypeFlagsFromString(const char *t)
Definition: tm_util.c:95
int Typemaker2_Inline_GetLocation(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:91
int Typemaker2_Inline_GetAccess(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:109
#define GWEN_LIST_INIT(t, element)
Definition: list1.h:465
void Typemaker2_Inline_Attach(TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:60
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition: list1.h:366
#define GWEN_LIST_FINI(t, element)
Definition: list1.h:474
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:156