gwenhywfar  4.99.8beta
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 
32 
34  th->refCount=1;
36 
37  return th;
38 }
39 
40 
41 
43  if (th) {
44  assert(th->refCount);
45  if (th->refCount==1) {
47  free(th->content);
48  th->refCount=0;
49  GWEN_FREE_OBJECT(th);
50  }
51  else
52  th->refCount++;
53  }
54 }
55 
56 
57 
59  assert(th);
60  assert(th->refCount);
61  th->refCount++;
62 }
63 
64 
65 
67  assert(th);
68  assert(th->refCount);
69  return th->content;
70 }
71 
72 
73 
75  assert(th);
76  assert(th->refCount);
77  free(th->content);
78  if (s) th->content=strdup(s);
79  else th->content=NULL;
80 }
81 
82 
83 
85  assert(th);
86  assert(th->refCount);
87  return th->location;
88 }
89 
90 
91 
93  assert(th);
94  assert(th->refCount);
95  th->location=i;
96 }
97 
98 
99 
101  assert(th);
102  assert(th->refCount);
103  return th->acc;
104 }
105 
106 
107 
109  assert(th);
110  assert(th->refCount);
111  th->acc=i;
112 }
113 
114 
115 
117  assert(th);
118  assert(th->refCount);
119  return th->typeFlagsMask;
120 }
121 
122 
123 
125  assert(th);
126  assert(th->refCount);
127  return th->typeFlagsValue;
128 }
129 
130 
131 
133  TYPEMAKER2_INLINE *th;
134  const char *s;
135 
137 
138  s=GWEN_XMLNode_GetCharValue(node, "content", NULL);
140 
141  s=GWEN_XMLNode_GetCharValue(node, "typeFlagsMask", NULL);
142  if (s && *s)
143  th->typeFlagsMask=Typemaker2_TypeFlagsFromString(s);
144 
145  s=GWEN_XMLNode_GetCharValue(node, "typeFlagsValue", NULL);
146  if (s && *s)
147  th->typeFlagsValue=Typemaker2_TypeFlagsFromString(s);
148 
149  /* read header location */
150  s=GWEN_XMLNode_GetProperty(node, "loc", "post");
151  if (strcasecmp(s, "header")==0)
153  else if (strcasecmp(s, "code")==0)
155 
156  /* read access */
157  s=GWEN_XMLNode_GetProperty(node, "access", "public");
159 
160  return th;
161 }
162 
163 
164 
165 
166 
167 
168 
void Typemaker2_Inline_SetAccess(TYPEMAKER2_INLINE *th, int i)
Definition: tm_inline.c:108
int Typemaker2_Inline_GetTypeFlagsValue(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:124
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:228
const char * Typemaker2_Inline_GetContent(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:66
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:92
#define NULL
Definition: binreloc.c:290
void Typemaker2_Inline_free(TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:42
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:86
const char * GWEN_XMLNode_GetCharValue(const GWEN_XMLNODE *n, const char *name, const char *defValue)
Definition: xml.c:729
int Typemaker2_Inline_GetTypeFlagsMask(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:116
int Typemaker2_AccessFromString(const char *s)
Definition: tm_util.c:157
void Typemaker2_Inline_SetContent(TYPEMAKER2_INLINE *th, const char *s)
Definition: tm_inline.c:74
TYPEMAKER2_INLINE * Typemaker2_Inline_fromXml(GWEN_XMLNODE *node)
Definition: tm_inline.c:132
void Typemaker2_Inline_SetLocation(TYPEMAKER2_INLINE *th, int i)
Definition: tm_inline.c:92
uint32_t Typemaker2_TypeFlagsFromString(const char *t)
Definition: tm_util.c:92
int Typemaker2_Inline_GetLocation(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:84
int Typemaker2_Inline_GetAccess(const TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:100
#define GWEN_LIST_INIT(t, element)
Definition: list1.h:465
void Typemaker2_Inline_Attach(TYPEMAKER2_INLINE *th)
Definition: tm_inline.c:58
#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:148