1 /* This file is auto-generated from "pininfo.xml" by the typemaker
2    tool of Gwenhywfar.
3    Do not edit this file -- all changes will be lost! */
4 #ifdef HAVE_CONFIG_H
5 # include "config.h"
6 #endif
7 
8 #include "pininfo_p.h"
9 #include <gwenhywfar/misc.h>
10 #include <gwenhywfar/db.h>
11 #include <gwenhywfar/debug.h>
12 #include <assert.h>
13 #include <stdlib.h>
14 #include <strings.h>
15 
16 #include <gwenhywfar/types.h>
17 #include <gwenhywfar/cryptdefs.h>
18 #include <chipcard/chipcard.h>
19 
20 
21 GWEN_INHERIT_FUNCTIONS(LC_PININFO)
GWEN_LIST_FUNCTIONS(LC_PININFO,LC_PinInfo)22 GWEN_LIST_FUNCTIONS(LC_PININFO, LC_PinInfo)
23 GWEN_LIST2_FUNCTIONS(LC_PININFO, LC_PinInfo)
24 
25 
26 
27 
28 LC_PININFO *LC_PinInfo_new(void) {
29   LC_PININFO *st;
30 
31   GWEN_NEW_OBJECT(LC_PININFO, st)
32   st->_usage=1;
33   GWEN_INHERIT_INIT(LC_PININFO, st)
34   GWEN_LIST_INIT(LC_PININFO, st)
35   return st;
36 }
37 
38 
LC_PinInfo_free(LC_PININFO * st)39 void LC_PinInfo_free(LC_PININFO *st) {
40   if (st) {
41     assert(st->_usage);
42     if (--(st->_usage)==0) {
43   GWEN_INHERIT_FINI(LC_PININFO, st)
44   if (st->name)
45     free(st->name);
46   GWEN_LIST_FINI(LC_PININFO, st)
47   GWEN_FREE_OBJECT(st);
48     }
49   }
50 
51 }
52 
53 
LC_PinInfo_dup(const LC_PININFO * d)54 LC_PININFO *LC_PinInfo_dup(const LC_PININFO *d) {
55   LC_PININFO *st;
56 
57   assert(d);
58   st=LC_PinInfo_new();
59   if (d->name)
60     st->name=strdup(d->name);
61   st->id=d->id;
62   st->encoding=d->encoding;
63   st->minLength=d->minLength;
64   st->maxLength=d->maxLength;
65   st->allowChange=d->allowChange;
66   st->filler=d->filler;
67   st->recordNum=d->recordNum;
68   return st;
69 }
70 
71 
LC_PinInfo_toDb(const LC_PININFO * st,GWEN_DB_NODE * db)72 int LC_PinInfo_toDb(const LC_PININFO *st, GWEN_DB_NODE *db) {
73   assert(st);
74   assert(db);
75   if (st->name)
76     if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "name", st->name))
77       return -1;
78   if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "id", st->id))
79     return -1;
80   if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "encoding", st->encoding))
81     return -1;
82   if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLength", st->minLength))
83     return -1;
84   if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLength", st->maxLength))
85     return -1;
86   if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChange", st->allowChange))
87     return -1;
88   if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "filler", st->filler))
89     return -1;
90   if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "recordNum", st->recordNum))
91     return -1;
92   return 0;
93 }
94 
95 
LC_PinInfo_ReadDb(LC_PININFO * st,GWEN_DB_NODE * db)96 int LC_PinInfo_ReadDb(LC_PININFO *st, GWEN_DB_NODE *db) {
97   assert(st);
98   assert(db);
99   LC_PinInfo_SetName(st, GWEN_DB_GetCharValue(db, "name", 0, 0));
100   LC_PinInfo_SetId(st, GWEN_DB_GetIntValue(db, "id", 0, 0));
101   LC_PinInfo_SetEncoding(st, GWEN_DB_GetIntValue(db, "encoding", 0, 0));
102   LC_PinInfo_SetMinLength(st, GWEN_DB_GetIntValue(db, "minLength", 0, 0));
103   LC_PinInfo_SetMaxLength(st, GWEN_DB_GetIntValue(db, "maxLength", 0, 0));
104   LC_PinInfo_SetAllowChange(st, GWEN_DB_GetIntValue(db, "allowChange", 0, 0));
105   LC_PinInfo_SetFiller(st, GWEN_DB_GetIntValue(db, "filler", 0, 0));
106   LC_PinInfo_SetRecordNum(st, GWEN_DB_GetIntValue(db, "recordNum", 0, 0));
107   return 0;
108 }
109 
110 
LC_PinInfo_fromDb(GWEN_DB_NODE * db)111 LC_PININFO *LC_PinInfo_fromDb(GWEN_DB_NODE *db) {
112   LC_PININFO *st;
113 
114   assert(db);
115   st=LC_PinInfo_new();
116   LC_PinInfo_ReadDb(st, db);
117   st->_modified=0;
118   return st;
119 }
120 
121 
122 
123 
LC_PinInfo_GetName(const LC_PININFO * st)124 const char *LC_PinInfo_GetName(const LC_PININFO *st) {
125   assert(st);
126   return st->name;
127 }
128 
129 
LC_PinInfo_SetName(LC_PININFO * st,const char * d)130 void LC_PinInfo_SetName(LC_PININFO *st, const char *d) {
131   assert(st);
132   if (st->name)
133     free(st->name);
134   if (d && *d)
135     st->name=strdup(d);
136   else
137     st->name=0;
138   st->_modified=1;
139 }
140 
141 
142 
143 
LC_PinInfo_GetId(const LC_PININFO * st)144 uint32_t LC_PinInfo_GetId(const LC_PININFO *st) {
145   assert(st);
146   return st->id;
147 }
148 
149 
LC_PinInfo_SetId(LC_PININFO * st,uint32_t d)150 void LC_PinInfo_SetId(LC_PININFO *st, uint32_t d) {
151   assert(st);
152   st->id=d;
153   st->_modified=1;
154 }
155 
156 
157 
158 
LC_PinInfo_GetEncoding(const LC_PININFO * st)159 int LC_PinInfo_GetEncoding(const LC_PININFO *st) {
160   assert(st);
161   return st->encoding;
162 }
163 
164 
LC_PinInfo_SetEncoding(LC_PININFO * st,int d)165 void LC_PinInfo_SetEncoding(LC_PININFO *st, int d) {
166   assert(st);
167   st->encoding=d;
168   st->_modified=1;
169 }
170 
171 
172 
173 
LC_PinInfo_GetMinLength(const LC_PININFO * st)174 int LC_PinInfo_GetMinLength(const LC_PININFO *st) {
175   assert(st);
176   return st->minLength;
177 }
178 
179 
LC_PinInfo_SetMinLength(LC_PININFO * st,int d)180 void LC_PinInfo_SetMinLength(LC_PININFO *st, int d) {
181   assert(st);
182   st->minLength=d;
183   st->_modified=1;
184 }
185 
186 
187 
188 
LC_PinInfo_GetMaxLength(const LC_PININFO * st)189 int LC_PinInfo_GetMaxLength(const LC_PININFO *st) {
190   assert(st);
191   return st->maxLength;
192 }
193 
194 
LC_PinInfo_SetMaxLength(LC_PININFO * st,int d)195 void LC_PinInfo_SetMaxLength(LC_PININFO *st, int d) {
196   assert(st);
197   st->maxLength=d;
198   st->_modified=1;
199 }
200 
201 
202 
203 
LC_PinInfo_GetAllowChange(const LC_PININFO * st)204 int LC_PinInfo_GetAllowChange(const LC_PININFO *st) {
205   assert(st);
206   return st->allowChange;
207 }
208 
209 
LC_PinInfo_SetAllowChange(LC_PININFO * st,int d)210 void LC_PinInfo_SetAllowChange(LC_PININFO *st, int d) {
211   assert(st);
212   st->allowChange=d;
213   st->_modified=1;
214 }
215 
216 
217 
218 
LC_PinInfo_GetFiller(const LC_PININFO * st)219 int LC_PinInfo_GetFiller(const LC_PININFO *st) {
220   assert(st);
221   return st->filler;
222 }
223 
224 
LC_PinInfo_SetFiller(LC_PININFO * st,int d)225 void LC_PinInfo_SetFiller(LC_PININFO *st, int d) {
226   assert(st);
227   st->filler=d;
228   st->_modified=1;
229 }
230 
231 
232 
233 
LC_PinInfo_GetRecordNum(const LC_PININFO * st)234 int LC_PinInfo_GetRecordNum(const LC_PININFO *st) {
235   assert(st);
236   return st->recordNum;
237 }
238 
239 
LC_PinInfo_SetRecordNum(LC_PININFO * st,int d)240 void LC_PinInfo_SetRecordNum(LC_PININFO *st, int d) {
241   assert(st);
242   st->recordNum=d;
243   st->_modified=1;
244 }
245 
246 
247 
248 
LC_PinInfo_IsModified(const LC_PININFO * st)249 int LC_PinInfo_IsModified(const LC_PININFO *st) {
250   assert(st);
251   return st->_modified;
252 }
253 
254 
LC_PinInfo_SetModified(LC_PININFO * st,int i)255 void LC_PinInfo_SetModified(LC_PININFO *st, int i) {
256   assert(st);
257   st->_modified=i;
258 }
259 
260 
LC_PinInfo_Attach(LC_PININFO * st)261 void LC_PinInfo_Attach(LC_PININFO *st) {
262   assert(st);
263   st->_usage++;
264 }
LC_PinInfo_List2__freeAll_cb(LC_PININFO * st,void * user_data)265 LC_PININFO *LC_PinInfo_List2__freeAll_cb(LC_PININFO *st, void *user_data) {
266   LC_PinInfo_free(st);
267 return 0;
268 }
269 
270 
LC_PinInfo_List2_freeAll(LC_PININFO_LIST2 * stl)271 void LC_PinInfo_List2_freeAll(LC_PININFO_LIST2 *stl) {
272   if (stl) {
273     LC_PinInfo_List2_ForEach(stl, LC_PinInfo_List2__freeAll_cb, 0);
274     LC_PinInfo_List2_free(stl);
275   }
276 }
277 
278 
LC_PinInfo_List_dup(const LC_PININFO_LIST * stl)279 LC_PININFO_LIST *LC_PinInfo_List_dup(const LC_PININFO_LIST *stl) {
280   if (stl) {
281     LC_PININFO_LIST *nl;
282     LC_PININFO *e;
283 
284     nl=LC_PinInfo_List_new();
285     e=LC_PinInfo_List_First(stl);
286     while(e) {
287       LC_PININFO *ne;
288 
289       ne=LC_PinInfo_dup(e);
290       assert(ne);
291       LC_PinInfo_List_Add(ne, nl);
292       e=LC_PinInfo_List_Next(e);
293     } /* while (e) */
294     return nl;
295   }
296   else
297     return 0;
298 }
299 
300 
301 
302 
303