gwenhywfar  4.8.0beta
ssl_cert_descr.c
Go to the documentation of this file.
1 /* This file is auto-generated from "ssl_cert_descr.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 "ssl_cert_descr_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/gwentime.h>
17 #include <gwenhywfar/ssl_cert_flags.h>
18 
19 
20 GWEN_LIST_FUNCTIONS(GWEN_SSLCERTDESCR, GWEN_SslCertDescr)
21 GWEN_LIST2_FUNCTIONS(GWEN_SSLCERTDESCR, GWEN_SslCertDescr)
22 
23 
24 
25 
26 GWEN_SSLCERTDESCR *GWEN_SslCertDescr_new(void) {
27  GWEN_SSLCERTDESCR *st;
28 
29  GWEN_NEW_OBJECT(GWEN_SSLCERTDESCR, st)
30  st->_usage=1;
31  GWEN_LIST_INIT(GWEN_SSLCERTDESCR, st)
32  return st;
33 }
34 
35 
37  if (st) {
38  assert(st->_usage);
39  if (--(st->_usage)==0) {
40  if (st->countryName)
41  free(st->countryName);
42  if (st->commonName)
43  free(st->commonName);
44  if (st->organizationName)
45  free(st->organizationName);
46  if (st->organizationalUnitName)
47  free(st->organizationalUnitName);
48  if (st->localityName)
49  free(st->localityName);
50  if (st->stateOrProvinceName)
51  free(st->stateOrProvinceName);
52  if (st->notBefore)
53  GWEN_Time_free(st->notBefore);
54  if (st->notAfter)
55  GWEN_Time_free(st->notAfter);
56  if (st->ipAddress)
57  free(st->ipAddress);
58  if (st->fingerPrint)
59  free(st->fingerPrint);
60  if (st->pubKeyModulus)
61  free(st->pubKeyModulus);
62  if (st->pubKeyExponent)
63  free(st->pubKeyExponent);
64  if (st->statusText)
65  free(st->statusText);
67  GWEN_FREE_OBJECT(st);
68  }
69  }
70 
71 }
72 
73 
76 
77  assert(d);
79  if (d->countryName)
80  st->countryName=strdup(d->countryName);
81  if (d->commonName)
82  st->commonName=strdup(d->commonName);
83  if (d->organizationName)
84  st->organizationName=strdup(d->organizationName);
85  if (d->organizationalUnitName)
86  st->organizationalUnitName=strdup(d->organizationalUnitName);
87  if (d->localityName)
88  st->localityName=strdup(d->localityName);
89  if (d->stateOrProvinceName)
90  st->stateOrProvinceName=strdup(d->stateOrProvinceName);
91  if (d->notBefore)
92  st->notBefore=GWEN_Time_dup(d->notBefore);
93  if (d->notAfter)
94  st->notAfter=GWEN_Time_dup(d->notAfter);
95  if (d->ipAddress)
96  st->ipAddress=strdup(d->ipAddress);
97  if (d->fingerPrint)
98  st->fingerPrint=strdup(d->fingerPrint);
99  if (d->pubKeyModulus)
100  st->pubKeyModulus=strdup(d->pubKeyModulus);
101  if (d->pubKeyExponent)
102  st->pubKeyExponent=strdup(d->pubKeyExponent);
103  if (d->statusText)
104  st->statusText=strdup(d->statusText);
105  st->isError=d->isError;
106  st->statusFlags=d->statusFlags;
107  return st;
108 }
109 
110 
112  assert(st);
113  assert(db);
114  if (st->countryName)
115  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "countryName", st->countryName))
116  return -1;
117  if (st->commonName)
118  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "commonName", st->commonName))
119  return -1;
120  if (st->organizationName)
121  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "organizationName", st->organizationName))
122  return -1;
123  if (st->organizationalUnitName)
124  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "organizationalUnitName", st->organizationalUnitName))
125  return -1;
126  if (st->localityName)
127  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "localityName", st->localityName))
128  return -1;
129  if (st->stateOrProvinceName)
130  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "stateOrProvinceName", st->stateOrProvinceName))
131  return -1;
132  if (st->notBefore)
133  if (GWEN_Time_toDb(st->notBefore, GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT, "notBefore")))
134  return -1;
135  if (st->notAfter)
136  if (GWEN_Time_toDb(st->notAfter, GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT, "notAfter")))
137  return -1;
138  if (st->ipAddress)
139  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "ipAddress", st->ipAddress))
140  return -1;
141  if (st->fingerPrint)
142  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "fingerPrint", st->fingerPrint))
143  return -1;
144  if (st->pubKeyModulus)
145  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "pubKeyModulus", st->pubKeyModulus))
146  return -1;
147  if (st->pubKeyExponent)
148  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "pubKeyExponent", st->pubKeyExponent))
149  return -1;
150  if (st->statusText)
151  if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "statusText", st->statusText))
152  return -1;
153  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "isError", st->isError))
154  return -1;
155  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "statusFlags", st->statusFlags))
156  return -1;
157  return 0;
158 }
159 
160 
162  assert(st);
163  assert(db);
164  GWEN_SslCertDescr_SetCountryName(st, GWEN_DB_GetCharValue(db, "countryName", 0, 0));
165  GWEN_SslCertDescr_SetCommonName(st, GWEN_DB_GetCharValue(db, "commonName", 0, 0));
166  GWEN_SslCertDescr_SetOrganizationName(st, GWEN_DB_GetCharValue(db, "organizationName", 0, 0));
167  GWEN_SslCertDescr_SetOrganizationalUnitName(st, GWEN_DB_GetCharValue(db, "organizationalUnitName", 0, 0));
168  GWEN_SslCertDescr_SetLocalityName(st, GWEN_DB_GetCharValue(db, "localityName", 0, 0));
169  GWEN_SslCertDescr_SetStateOrProvinceName(st, GWEN_DB_GetCharValue(db, "stateOrProvinceName", 0, 0));
170  if (1) { /* for local vars */
171  GWEN_DB_NODE *dbT;
172 
173  dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "notBefore");
174  if (dbT) {
175  if (st->notBefore)
176  GWEN_Time_free(st->notBefore);
177  st->notBefore=GWEN_Time_fromDb(dbT);
178 }
179  }
180  if (1) { /* for local vars */
181  GWEN_DB_NODE *dbT;
182 
183  dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "notAfter");
184  if (dbT) {
185  if (st->notAfter)
186  GWEN_Time_free(st->notAfter);
187  st->notAfter=GWEN_Time_fromDb(dbT);
188 }
189  }
190  GWEN_SslCertDescr_SetIpAddress(st, GWEN_DB_GetCharValue(db, "ipAddress", 0, 0));
191  GWEN_SslCertDescr_SetFingerPrint(st, GWEN_DB_GetCharValue(db, "fingerPrint", 0, 0));
192  GWEN_SslCertDescr_SetPubKeyModulus(st, GWEN_DB_GetCharValue(db, "pubKeyModulus", 0, 0));
193  GWEN_SslCertDescr_SetPubKeyExponent(st, GWEN_DB_GetCharValue(db, "pubKeyExponent", 0, 0));
194  GWEN_SslCertDescr_SetStatusText(st, GWEN_DB_GetCharValue(db, "statusText", 0, 0));
195  GWEN_SslCertDescr_SetIsError(st, GWEN_DB_GetIntValue(db, "isError", 0, 0));
196  GWEN_SslCertDescr_SetStatusFlags(st, GWEN_DB_GetIntValue(db, "statusFlags", 0, 0));
197  return 0;
198 }
199 
200 
202  GWEN_SSLCERTDESCR *st;
203 
204  assert(db);
206  GWEN_SslCertDescr_ReadDb(st, db);
207  st->_modified=0;
208  return st;
209 }
210 
211 
212 
213 
215  assert(st);
216  return st->countryName;
217 }
218 
219 
221  assert(st);
222  if (st->countryName)
223  free(st->countryName);
224  if (d && *d)
225  st->countryName=strdup(d);
226  else
227  st->countryName=0;
228  st->_modified=1;
229 }
230 
231 
232 
233 
235  assert(st);
236  return st->commonName;
237 }
238 
239 
241  assert(st);
242  if (st->commonName)
243  free(st->commonName);
244  if (d && *d)
245  st->commonName=strdup(d);
246  else
247  st->commonName=0;
248  st->_modified=1;
249 }
250 
251 
252 
253 
255  assert(st);
256  return st->organizationName;
257 }
258 
259 
261  assert(st);
262  if (st->organizationName)
263  free(st->organizationName);
264  if (d && *d)
265  st->organizationName=strdup(d);
266  else
267  st->organizationName=0;
268  st->_modified=1;
269 }
270 
271 
272 
273 
275  assert(st);
276  return st->organizationalUnitName;
277 }
278 
279 
281  assert(st);
282  if (st->organizationalUnitName)
283  free(st->organizationalUnitName);
284  if (d && *d)
285  st->organizationalUnitName=strdup(d);
286  else
287  st->organizationalUnitName=0;
288  st->_modified=1;
289 }
290 
291 
292 
293 
295  assert(st);
296  return st->localityName;
297 }
298 
299 
301  assert(st);
302  if (st->localityName)
303  free(st->localityName);
304  if (d && *d)
305  st->localityName=strdup(d);
306  else
307  st->localityName=0;
308  st->_modified=1;
309 }
310 
311 
312 
313 
315  assert(st);
316  return st->stateOrProvinceName;
317 }
318 
319 
321  assert(st);
322  if (st->stateOrProvinceName)
323  free(st->stateOrProvinceName);
324  if (d && *d)
325  st->stateOrProvinceName=strdup(d);
326  else
327  st->stateOrProvinceName=0;
328  st->_modified=1;
329 }
330 
331 
332 
333 
335  assert(st);
336  return st->notBefore;
337 }
338 
339 
341  assert(st);
342  if (st->notBefore)
343  GWEN_Time_free(st->notBefore);
344  if (d)
345  st->notBefore=GWEN_Time_dup(d);
346  else
347  st->notBefore=0;
348  st->_modified=1;
349 }
350 
351 
352 
353 
355  assert(st);
356  return st->notAfter;
357 }
358 
359 
361  assert(st);
362  if (st->notAfter)
363  GWEN_Time_free(st->notAfter);
364  if (d)
365  st->notAfter=GWEN_Time_dup(d);
366  else
367  st->notAfter=0;
368  st->_modified=1;
369 }
370 
371 
372 
373 
375  assert(st);
376  return st->ipAddress;
377 }
378 
379 
381  assert(st);
382  if (st->ipAddress)
383  free(st->ipAddress);
384  if (d && *d)
385  st->ipAddress=strdup(d);
386  else
387  st->ipAddress=0;
388  st->_modified=1;
389 }
390 
391 
392 
393 
395  assert(st);
396  return st->fingerPrint;
397 }
398 
399 
401  assert(st);
402  if (st->fingerPrint)
403  free(st->fingerPrint);
404  if (d && *d)
405  st->fingerPrint=strdup(d);
406  else
407  st->fingerPrint=0;
408  st->_modified=1;
409 }
410 
411 
412 
413 
415  assert(st);
416  return st->pubKeyModulus;
417 }
418 
419 
421  assert(st);
422  if (st->pubKeyModulus)
423  free(st->pubKeyModulus);
424  if (d && *d)
425  st->pubKeyModulus=strdup(d);
426  else
427  st->pubKeyModulus=0;
428  st->_modified=1;
429 }
430 
431 
432 
433 
435  assert(st);
436  return st->pubKeyExponent;
437 }
438 
439 
441  assert(st);
442  if (st->pubKeyExponent)
443  free(st->pubKeyExponent);
444  if (d && *d)
445  st->pubKeyExponent=strdup(d);
446  else
447  st->pubKeyExponent=0;
448  st->_modified=1;
449 }
450 
451 
452 
453 
455  assert(st);
456  return st->statusText;
457 }
458 
459 
461  assert(st);
462  if (st->statusText)
463  free(st->statusText);
464  if (d && *d)
465  st->statusText=strdup(d);
466  else
467  st->statusText=0;
468  st->_modified=1;
469 }
470 
471 
472 
473 
475  assert(st);
476  return st->isError;
477 }
478 
479 
481  assert(st);
482  st->isError=d;
483  st->_modified=1;
484 }
485 
486 
487 
488 
490  assert(st);
491  return st->statusFlags;
492 }
493 
494 
496  assert(st);
497  st->statusFlags=d;
498  st->_modified=1;
499 }
500 
501 
502 
503 
505  assert(st);
506  return st->_modified;
507 }
508 
509 
511  assert(st);
512  st->_modified=i;
513 }
514 
515 
517  assert(st);
518  st->_usage++;
519 }
522 return 0;
523 }
524 
525 
526 void GWEN_SslCertDescr_List2_freeAll(GWEN_SSLCERTDESCR_LIST2 *stl) {
527  if (stl) {
528  GWEN_SslCertDescr_List2_ForEach(stl, GWEN_SslCertDescr_List2__freeAll_cb, 0);
529  GWEN_SslCertDescr_List2_free(stl);
530  }
531 }
532 
533 
534 GWEN_SSLCERTDESCR_LIST *GWEN_SslCertDescr_List_dup(const GWEN_SSLCERTDESCR_LIST *stl) {
535  if (stl) {
536  GWEN_SSLCERTDESCR_LIST *nl;
538 
539  nl=GWEN_SslCertDescr_List_new();
540  e=GWEN_SslCertDescr_List_First(stl);
541  while(e) {
542  GWEN_SSLCERTDESCR *ne;
543 
544  ne=GWEN_SslCertDescr_dup(e);
545  assert(ne);
546  GWEN_SslCertDescr_List_Add(ne, nl);
547  e=GWEN_SslCertDescr_List_Next(e);
548  } /* while (e) */
549  return nl;
550  }
551  else
552  return 0;
553 }
554 
555 
556 
557