gwenhywfar 5.14.1
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
25GWEN_LIST_FUNCTIONS(TYPEMAKER2_HEADER, Typemaker2_Header)
26
27
28
30{
32
34 th->refCount=1;
36
37 return th;
38}
39
40
41
43{
44 if (th) {
45 assert(th->refCount);
46 if (th->refCount==1) {
48 free(th->fileName);
49 th->refCount=0;
51 }
52 else
53 th->refCount++;
54 }
55}
56
57
58
60{
61 assert(th);
62 assert(th->refCount);
63 th->refCount++;
64}
65
66
67
69{
70 assert(th);
71 assert(th->refCount);
72 return th->fileName;
73}
74
75
76
78{
79 assert(th);
80 assert(th->refCount);
81 free(th->fileName);
82 if (s)
83 th->fileName=strdup(s);
84 else
85 th->fileName=NULL;
86}
87
88
89
91{
92 assert(th);
93 assert(th->refCount);
94 return th->type;
95}
96
97
98
100{
101 assert(th);
102 assert(th->refCount);
103 th->type=i;
104}
105
106
107
109{
110 assert(th);
111 assert(th->refCount);
112 return th->location;
113}
114
115
116
118{
119 assert(th);
120 assert(th->refCount);
121 th->location=i;
122}
123
124
125
127{
128 const char *s;
129 GWEN_XMLNODE *n;
130
131 assert(th);
132 assert(th->refCount);
133
135 if (n) {
138 }
139
140 /* read header type */
141 s=GWEN_XMLNode_GetProperty(node, "type", "sys");
142 if (strcasecmp(s, "sys")==0 ||
143 strcasecmp(s, "system")==0)
145 else if (strcasecmp(s, "local")==0)
147
148 /* read header location */
149 s=GWEN_XMLNode_GetProperty(node, "loc", "post");
150 if (strcasecmp(s, "pre")==0)
152 else if (strcasecmp(s, "post")==0)
154 else if (strcasecmp(s, "code")==0)
156 else if (strcasecmp(s, "codeEnd")==0)
158 else if (strcasecmp(s, "headerEnd")==0)
160
161 return 0;
162}
163
164
165
166
167
168
169
#define NULL
Definition binreloc.c:300
#define GWEN_LIST_FINI(t, element)
Definition list1.h:475
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition list1.h:367
#define GWEN_LIST_INIT(t, element)
Definition list1.h:466
#define GWEN_FREE_OBJECT(varname)
Definition memory.h:61
#define GWEN_NEW_OBJECT(typ, varname)
Definition memory.h:55
int Typemaker2_Header_GetType(const TYPEMAKER2_HEADER *th)
Definition tm_header.c:90
int Typemaker2_Header_readXml(TYPEMAKER2_HEADER *th, GWEN_XMLNODE *node)
Definition tm_header.c:126
void Typemaker2_Header_free(TYPEMAKER2_HEADER *th)
Definition tm_header.c:42
void Typemaker2_Header_SetLocation(TYPEMAKER2_HEADER *th, int i)
Definition tm_header.c:117
void Typemaker2_Header_Attach(TYPEMAKER2_HEADER *th)
Definition tm_header.c:59
int Typemaker2_Header_GetLocation(const TYPEMAKER2_HEADER *th)
Definition tm_header.c:108
void Typemaker2_Header_SetFileName(TYPEMAKER2_HEADER *th, const char *s)
Definition tm_header.c:77
void Typemaker2_Header_SetType(TYPEMAKER2_HEADER *th, int i)
Definition tm_header.c:99
TYPEMAKER2_HEADER * Typemaker2_Header_new()
Definition tm_header.c:29
const char * Typemaker2_Header_GetFileName(const TYPEMAKER2_HEADER *th)
Definition tm_header.c:68
@ Typemaker2_HeaderType_System
Definition tm_header.h:25
@ Typemaker2_HeaderType_Local
Definition tm_header.h:26
@ Typemaker2_HeaderLocation_Code
Definition tm_header.h:33
@ Typemaker2_HeaderLocation_Post
Definition tm_header.h:32
@ Typemaker2_HeaderLocation_CodeEnd
Definition tm_header.h:34
@ Typemaker2_HeaderLocation_HeaderEnd
Definition tm_header.h:35
@ Typemaker2_HeaderLocation_Pre
Definition tm_header.h:31
struct TYPEMAKER2_HEADER TYPEMAKER2_HEADER
Definition tm_header.h:19
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition xml.c:239
GWEN_XMLNODE * GWEN_XMLNode_GetFirstData(const GWEN_XMLNODE *n)
Definition xml.c:724
const char * GWEN_XMLNode_GetData(const GWEN_XMLNODE *n)
Definition xml.c:370
struct GWEN__XMLNODE GWEN_XMLNODE
Definition xml.h:156