gwenhywfar  4.99.8beta
tm_header.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_header_p.h"
16 
17 
18 #include <gwenhywfar/debug.h>
19 #include <gwenhywfar/misc.h>
20 
21 #include <assert.h>
22 
23 
24 
25 GWEN_LIST_FUNCTIONS(TYPEMAKER2_HEADER, Typemaker2_Header)
26 
27 
28 
31 
33  th->refCount=1;
35 
36  return th;
37 }
38 
39 
40 
42  if (th) {
43  assert(th->refCount);
44  if (th->refCount==1) {
46  free(th->fileName);
47  th->refCount=0;
48  GWEN_FREE_OBJECT(th);
49  }
50  else
51  th->refCount++;
52  }
53 }
54 
55 
56 
58  assert(th);
59  assert(th->refCount);
60  th->refCount++;
61 }
62 
63 
64 
66  assert(th);
67  assert(th->refCount);
68  return th->fileName;
69 }
70 
71 
72 
74  assert(th);
75  assert(th->refCount);
76  free(th->fileName);
77  if (s) th->fileName=strdup(s);
78  else th->fileName=NULL;
79 }
80 
81 
82 
84  assert(th);
85  assert(th->refCount);
86  return th->type;
87 }
88 
89 
90 
92  assert(th);
93  assert(th->refCount);
94  th->type=i;
95 }
96 
97 
98 
100  assert(th);
101  assert(th->refCount);
102  return th->location;
103 }
104 
105 
106 
108  assert(th);
109  assert(th->refCount);
110  th->location=i;
111 }
112 
113 
114 
116  const char *s;
117  GWEN_XMLNODE *n;
118 
119  assert(th);
120  assert(th->refCount);
121 
123  if (n) {
126  }
127 
128  /* read header type */
129  s=GWEN_XMLNode_GetProperty(node, "type", "sys");
130  if (strcasecmp(s, "sys")==0 ||
131  strcasecmp(s, "system")==0)
133  else if (strcasecmp(s, "local")==0)
135 
136  /* read header location */
137  s=GWEN_XMLNode_GetProperty(node, "loc", "post");
138  if (strcasecmp(s, "pre")==0)
140  else if (strcasecmp(s, "post")==0)
142  else if (strcasecmp(s, "code")==0)
144  else if (strcasecmp(s, "codeEnd")==0)
146  else if (strcasecmp(s, "headerEnd")==0)
148 
149  return 0;
150 }
151 
152 
153 
154 
155 
156 
157 
int Typemaker2_Header_GetType(const TYPEMAKER2_HEADER *th)
Definition: tm_header.c:83
void Typemaker2_Header_SetLocation(TYPEMAKER2_HEADER *th, int i)
Definition: tm_header.c:107
const char * Typemaker2_Header_GetFileName(const TYPEMAKER2_HEADER *th)
Definition: tm_header.c:65
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:228
GWEN_XMLNODE * GWEN_XMLNode_GetFirstData(const GWEN_XMLNODE *n)
Definition: xml.c:646
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:92
#define NULL
Definition: binreloc.c:290
int Typemaker2_Header_GetLocation(const TYPEMAKER2_HEADER *th)
Definition: tm_header.c:99
struct TYPEMAKER2_HEADER TYPEMAKER2_HEADER
Definition: tm_header.h:19
void Typemaker2_Header_SetFileName(TYPEMAKER2_HEADER *th, const char *s)
Definition: tm_header.c:73
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:86
TYPEMAKER2_HEADER * Typemaker2_Header_new()
Definition: tm_header.c:29
void Typemaker2_Header_SetType(TYPEMAKER2_HEADER *th, int i)
Definition: tm_header.c:91
void Typemaker2_Header_Attach(TYPEMAKER2_HEADER *th)
Definition: tm_header.c:57
const char * GWEN_XMLNode_GetData(const GWEN_XMLNODE *n)
Definition: xml.c:351
int Typemaker2_Header_readXml(TYPEMAKER2_HEADER *th, GWEN_XMLNODE *node)
Definition: tm_header.c:115
#define GWEN_LIST_INIT(t, element)
Definition: list1.h:465
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition: list1.h:366
void Typemaker2_Header_free(TYPEMAKER2_HEADER *th)
Definition: tm_header.c:41
#define GWEN_LIST_FINI(t, element)
Definition: list1.h:474
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:148