gwenhywfar  4.99.8beta
ct_context.c
Go to the documentation of this file.
1 /**********************************************************
2  * This file has been automatically created by "typemaker2"
3  * from the file "ct_context.xml".
4  * Please do not edit this file, all changes will be lost.
5  * Better edit the mentioned source file instead.
6  **********************************************************/
7 
8 #ifdef HAVE_CONFIG_H
9 # include <config.h>
10 #endif
11 
12 #include "ct_context_p.h"
13 
14 #include <gwenhywfar/misc.h>
15 #include <gwenhywfar/debug.h>
16 
17 /* code headers */
18 
19 /* macro functions */
20 GWEN_LIST_FUNCTIONS(GWEN_CRYPT_TOKEN_CONTEXT, GWEN_Crypt_Token_Context)
21 GWEN_LIST2_FUNCTIONS(GWEN_CRYPT_TOKEN_CONTEXT, GWEN_Crypt_Token_Context)
22 GWEN_INHERIT_FUNCTIONS(GWEN_CRYPT_TOKEN_CONTEXT)
23 
24 
25 GWEN_CRYPT_TOKEN_CONTEXT *GWEN_Crypt_Token_Context_new(void)
26 {
27  GWEN_CRYPT_TOKEN_CONTEXT *p_struct;
28 
29  GWEN_NEW_OBJECT(GWEN_CRYPT_TOKEN_CONTEXT, p_struct)
30  p_struct->_refCount = 1;
31  GWEN_INHERIT_INIT(GWEN_CRYPT_TOKEN_CONTEXT, p_struct)
32  GWEN_LIST_INIT(GWEN_CRYPT_TOKEN_CONTEXT, p_struct)
33  /* members */
34  p_struct->id = 0;
35  p_struct->signKeyId = 0;
36  p_struct->verifyKeyId = 0;
37  p_struct->encipherKeyId = 0;
38  p_struct->decipherKeyId = 0;
39  p_struct->authSignKeyId = 0;
40  p_struct->authVerifyKeyId = 0;
41  p_struct->tempSignKeyId = 0;
42  p_struct->keyHashNum = 0;
43  p_struct->keyHashVer = 0;
44  p_struct->keyHashAlgo = 0;
45  p_struct->keyHash.pointer = NULL;
46  p_struct->keyHash.length = 0;
47  p_struct->keyStatus = 0;
48  p_struct->protocolVersion = 0;
49  p_struct->cid = NULL;
50  p_struct->serviceId = NULL;
51  p_struct->userId = NULL;
52  p_struct->customerId = NULL;
53  p_struct->userName = NULL;
54  p_struct->peerId = NULL;
55  p_struct->peerName = NULL;
56  p_struct->address = NULL;
57  p_struct->port = 0;
58  p_struct->systemId = NULL;
59  /* virtual functions */
60 
61  return p_struct;
62 }
63 
65 {
66  if (p_struct) {
67  assert(p_struct->_refCount);
68  if (p_struct->_refCount == 1) {
71  /* members */
72  if (p_struct->keyHash.length && p_struct->keyHash.pointer) {
73  free(p_struct->keyHash.pointer);
74  }
75  p_struct->keyHash.pointer = NULL;
76  p_struct->keyHash.length = 0;
77  free(p_struct->cid);
78  p_struct->cid = NULL;
79  free(p_struct->serviceId);
80  p_struct->serviceId = NULL;
81  free(p_struct->userId);
82  p_struct->userId = NULL;
83  free(p_struct->customerId);
84  p_struct->customerId = NULL;
85  free(p_struct->userName);
86  p_struct->userName = NULL;
87  free(p_struct->peerId);
88  p_struct->peerId = NULL;
89  free(p_struct->peerName);
90  p_struct->peerName = NULL;
91  free(p_struct->address);
92  p_struct->address = NULL;
93  free(p_struct->systemId);
94  p_struct->systemId = NULL;
95  p_struct->_refCount = 0;
96  GWEN_FREE_OBJECT(p_struct);
97  } else
98  p_struct->_refCount--;
99  }
100 }
101 
103 {
104  assert(p_struct);
105  assert(p_struct->_refCount);
106  p_struct->_refCount++;
107 }
108 
110 {
111  GWEN_CRYPT_TOKEN_CONTEXT *p_struct;
112 
113  assert(p_src);
114  p_struct = GWEN_Crypt_Token_Context_new();
115  /* member "id" */
116  p_struct->id = p_src->id;
117 
118  /* member "signKeyId" */
119  p_struct->signKeyId = p_src->signKeyId;
120 
121  /* member "verifyKeyId" */
122  p_struct->verifyKeyId = p_src->verifyKeyId;
123 
124  /* member "encipherKeyId" */
125  p_struct->encipherKeyId = p_src->encipherKeyId;
126 
127  /* member "decipherKeyId" */
128  p_struct->decipherKeyId = p_src->decipherKeyId;
129 
130  /* member "authSignKeyId" */
131  p_struct->authSignKeyId = p_src->authSignKeyId;
132 
133  /* member "authVerifyKeyId" */
134  p_struct->authVerifyKeyId = p_src->authVerifyKeyId;
135 
136  /* member "tempSignKeyId" */
137  p_struct->tempSignKeyId = p_src->tempSignKeyId;
138 
139  /* member "keyHashNum" */
140  p_struct->keyHashNum = p_src->keyHashNum;
141 
142  /* member "keyHashVer" */
143  p_struct->keyHashVer = p_src->keyHashVer;
144 
145  /* member "keyHashAlgo" */
146  p_struct->keyHashAlgo = p_src->keyHashAlgo;
147 
148  /* member "keyHash" */
149  if (p_src->keyHash.length && p_src->keyHash.pointer) {
150  p_struct->keyHash.pointer = (uint8_t*) malloc(p_src->keyHash.length);
151  if (p_struct->keyHash.pointer) {
152  p_struct->keyHash.length = p_src->keyHash.length;
153  memmove(p_struct->keyHash.pointer, p_src->keyHash.pointer, p_src->keyHash.length);
154  } else {
155  p_struct->keyHash.pointer = NULL;
156  p_struct->keyHash.length = 0;
157  }
158  } else {
159  p_struct->keyHash.pointer = NULL;
160  p_struct->keyHash.length = 0;
161  }
162 
163  /* member "keyStatus" */
164  p_struct->keyStatus = p_src->keyStatus;
165 
166  /* member "protocolVersion" */
167  p_struct->protocolVersion = p_src->protocolVersion;
168 
169  /* member "cid" */
170  if (p_struct->cid) {
171  free(p_struct->cid);
172  p_struct->cid = NULL;
173  p_struct->cid = NULL;
174  }
175  if (p_src->cid) {
176  p_struct->cid = strdup(p_src->cid);
177  }
178 
179  /* member "serviceId" */
180  if (p_struct->serviceId) {
181  free(p_struct->serviceId);
182  p_struct->serviceId = NULL;
183  p_struct->serviceId = NULL;
184  }
185  if (p_src->serviceId) {
186  p_struct->serviceId = strdup(p_src->serviceId);
187  }
188 
189  /* member "userId" */
190  if (p_struct->userId) {
191  free(p_struct->userId);
192  p_struct->userId = NULL;
193  p_struct->userId = NULL;
194  }
195  if (p_src->userId) {
196  p_struct->userId = strdup(p_src->userId);
197  }
198 
199  /* member "customerId" */
200  if (p_struct->customerId) {
201  free(p_struct->customerId);
202  p_struct->customerId = NULL;
203  p_struct->customerId = NULL;
204  }
205  if (p_src->customerId) {
206  p_struct->customerId = strdup(p_src->customerId);
207  }
208 
209  /* member "userName" */
210  if (p_struct->userName) {
211  free(p_struct->userName);
212  p_struct->userName = NULL;
213  p_struct->userName = NULL;
214  }
215  if (p_src->userName) {
216  p_struct->userName = strdup(p_src->userName);
217  }
218 
219  /* member "peerId" */
220  if (p_struct->peerId) {
221  free(p_struct->peerId);
222  p_struct->peerId = NULL;
223  p_struct->peerId = NULL;
224  }
225  if (p_src->peerId) {
226  p_struct->peerId = strdup(p_src->peerId);
227  }
228 
229  /* member "peerName" */
230  if (p_struct->peerName) {
231  free(p_struct->peerName);
232  p_struct->peerName = NULL;
233  p_struct->peerName = NULL;
234  }
235  if (p_src->peerName) {
236  p_struct->peerName = strdup(p_src->peerName);
237  }
238 
239  /* member "address" */
240  if (p_struct->address) {
241  free(p_struct->address);
242  p_struct->address = NULL;
243  p_struct->address = NULL;
244  }
245  if (p_src->address) {
246  p_struct->address = strdup(p_src->address);
247  }
248 
249  /* member "port" */
250  p_struct->port = p_src->port;
251 
252  /* member "systemId" */
253  if (p_struct->systemId) {
254  free(p_struct->systemId);
255  p_struct->systemId = NULL;
256  p_struct->systemId = NULL;
257  }
258  if (p_src->systemId) {
259  p_struct->systemId = strdup(p_src->systemId);
260  }
261 
262  return p_struct;
263 }
264 
266 {
267  assert(p_struct);
268  assert(p_src);
269  /* member "id" */
270  p_struct->id = p_src->id;
271 
272  /* member "signKeyId" */
273  p_struct->signKeyId = p_src->signKeyId;
274 
275  /* member "verifyKeyId" */
276  p_struct->verifyKeyId = p_src->verifyKeyId;
277 
278  /* member "encipherKeyId" */
279  p_struct->encipherKeyId = p_src->encipherKeyId;
280 
281  /* member "decipherKeyId" */
282  p_struct->decipherKeyId = p_src->decipherKeyId;
283 
284  /* member "authSignKeyId" */
285  p_struct->authSignKeyId = p_src->authSignKeyId;
286 
287  /* member "authVerifyKeyId" */
288  p_struct->authVerifyKeyId = p_src->authVerifyKeyId;
289 
290  /* member "tempSignKeyId" */
291  p_struct->tempSignKeyId = p_src->tempSignKeyId;
292 
293  /* member "keyHashNum" */
294  p_struct->keyHashNum = p_src->keyHashNum;
295 
296  /* member "keyHashVer" */
297  p_struct->keyHashVer = p_src->keyHashVer;
298 
299  /* member "keyHashAlgo" */
300  p_struct->keyHashAlgo = p_src->keyHashAlgo;
301 
302  /* member "keyHash" */
303  if (p_src->keyHash.length && p_src->keyHash.pointer) {
304  p_struct->keyHash.pointer = (uint8_t*) malloc(p_src->keyHash.length);
305  if (p_struct->keyHash.pointer) {
306  p_struct->keyHash.length = p_src->keyHash.length;
307  memmove(p_struct->keyHash.pointer, p_src->keyHash.pointer, p_src->keyHash.length);
308  } else {
309  p_struct->keyHash.pointer = NULL;
310  p_struct->keyHash.length = 0;
311  }
312  } else {
313  p_struct->keyHash.pointer = NULL;
314  p_struct->keyHash.length = 0;
315  }
316 
317  /* member "keyStatus" */
318  p_struct->keyStatus = p_src->keyStatus;
319 
320  /* member "protocolVersion" */
321  p_struct->protocolVersion = p_src->protocolVersion;
322 
323  /* member "cid" */
324  if (p_struct->cid) {
325  free(p_struct->cid);
326  p_struct->cid = NULL;
327  p_struct->cid = NULL;
328  }
329  if (p_src->cid) {
330  p_struct->cid = strdup(p_src->cid);
331  }
332 
333  /* member "serviceId" */
334  if (p_struct->serviceId) {
335  free(p_struct->serviceId);
336  p_struct->serviceId = NULL;
337  p_struct->serviceId = NULL;
338  }
339  if (p_src->serviceId) {
340  p_struct->serviceId = strdup(p_src->serviceId);
341  }
342 
343  /* member "userId" */
344  if (p_struct->userId) {
345  free(p_struct->userId);
346  p_struct->userId = NULL;
347  p_struct->userId = NULL;
348  }
349  if (p_src->userId) {
350  p_struct->userId = strdup(p_src->userId);
351  }
352 
353  /* member "customerId" */
354  if (p_struct->customerId) {
355  free(p_struct->customerId);
356  p_struct->customerId = NULL;
357  p_struct->customerId = NULL;
358  }
359  if (p_src->customerId) {
360  p_struct->customerId = strdup(p_src->customerId);
361  }
362 
363  /* member "userName" */
364  if (p_struct->userName) {
365  free(p_struct->userName);
366  p_struct->userName = NULL;
367  p_struct->userName = NULL;
368  }
369  if (p_src->userName) {
370  p_struct->userName = strdup(p_src->userName);
371  }
372 
373  /* member "peerId" */
374  if (p_struct->peerId) {
375  free(p_struct->peerId);
376  p_struct->peerId = NULL;
377  p_struct->peerId = NULL;
378  }
379  if (p_src->peerId) {
380  p_struct->peerId = strdup(p_src->peerId);
381  }
382 
383  /* member "peerName" */
384  if (p_struct->peerName) {
385  free(p_struct->peerName);
386  p_struct->peerName = NULL;
387  p_struct->peerName = NULL;
388  }
389  if (p_src->peerName) {
390  p_struct->peerName = strdup(p_src->peerName);
391  }
392 
393  /* member "address" */
394  if (p_struct->address) {
395  free(p_struct->address);
396  p_struct->address = NULL;
397  p_struct->address = NULL;
398  }
399  if (p_src->address) {
400  p_struct->address = strdup(p_src->address);
401  }
402 
403  /* member "port" */
404  p_struct->port = p_src->port;
405 
406  /* member "systemId" */
407  if (p_struct->systemId) {
408  free(p_struct->systemId);
409  p_struct->systemId = NULL;
410  p_struct->systemId = NULL;
411  }
412  if (p_src->systemId) {
413  p_struct->systemId = strdup(p_src->systemId);
414  }
415 
416  return p_struct;
417 }
418 
420 {
421  assert(p_struct);
422  return p_struct->id;
423 }
424 
426 {
427  assert(p_struct);
428  return p_struct->signKeyId;
429 }
430 
432 {
433  assert(p_struct);
434  return p_struct->verifyKeyId;
435 }
436 
438 {
439  assert(p_struct);
440  return p_struct->encipherKeyId;
441 }
442 
444 {
445  assert(p_struct);
446  return p_struct->decipherKeyId;
447 }
448 
450 {
451  assert(p_struct);
452  return p_struct->authSignKeyId;
453 }
454 
456 {
457  assert(p_struct);
458  return p_struct->authVerifyKeyId;
459 }
460 
462 {
463  assert(p_struct);
464  return p_struct->tempSignKeyId;
465 }
466 
468 {
469  assert(p_struct);
470  return p_struct->keyHashNum;
471 }
472 
474 {
475  assert(p_struct);
476  return p_struct->keyHashVer;
477 }
478 
480 {
481  assert(p_struct);
482  return p_struct->keyHashAlgo;
483 }
484 
486 {
487  assert(p_struct);
488  return p_struct->keyStatus;
489 }
490 
492 {
493  assert(p_struct);
494  return p_struct->protocolVersion;
495 }
496 
498 {
499  assert(p_struct);
500  return p_struct->cid;
501 }
502 
504 {
505  assert(p_struct);
506  return p_struct->serviceId;
507 }
508 
510 {
511  assert(p_struct);
512  return p_struct->userId;
513 }
514 
516 {
517  assert(p_struct);
518  return p_struct->customerId;
519 }
520 
522 {
523  assert(p_struct);
524  return p_struct->userName;
525 }
526 
528 {
529  assert(p_struct);
530  return p_struct->peerId;
531 }
532 
534 {
535  assert(p_struct);
536  return p_struct->peerName;
537 }
538 
540 {
541  assert(p_struct);
542  return p_struct->address;
543 }
544 
546 {
547  assert(p_struct);
548  return p_struct->port;
549 }
550 
552 {
553  assert(p_struct);
554  return p_struct->systemId;
555 }
556 
558 {
559  assert(p_struct);
560  p_struct->id = p_src;
561 }
562 
564 {
565  assert(p_struct);
566  p_struct->signKeyId = p_src;
567 }
568 
570 {
571  assert(p_struct);
572  p_struct->verifyKeyId = p_src;
573 }
574 
576 {
577  assert(p_struct);
578  p_struct->encipherKeyId = p_src;
579 }
580 
582 {
583  assert(p_struct);
584  p_struct->decipherKeyId = p_src;
585 }
586 
588 {
589  assert(p_struct);
590  p_struct->authSignKeyId = p_src;
591 }
592 
594 {
595  assert(p_struct);
596  p_struct->authVerifyKeyId = p_src;
597 }
598 
600 {
601  assert(p_struct);
602  p_struct->tempSignKeyId = p_src;
603 }
604 
606 {
607  assert(p_struct);
608  p_struct->keyHashNum = p_src;
609 }
610 
612 {
613  assert(p_struct);
614  p_struct->keyHashVer = p_src;
615 }
616 
618 {
619  assert(p_struct);
620  p_struct->keyHashAlgo = p_src;
621 }
622 
624 {
625  assert(p_struct);
626  p_struct->keyStatus = p_src;
627 }
628 
630 {
631  assert(p_struct);
632  p_struct->protocolVersion = p_src;
633 }
634 
636 {
637  assert(p_struct);
638  if (p_struct->cid) {
639  free(p_struct->cid);
640  p_struct->cid = NULL;
641  }
642  if (p_src) {
643  p_struct->cid = strdup(p_src);
644  } else {
645  p_struct->cid = NULL;
646  }
647 }
648 
650 {
651  assert(p_struct);
652  if (p_struct->serviceId) {
653  free(p_struct->serviceId);
654  p_struct->serviceId = NULL;
655  }
656  if (p_src) {
657  p_struct->serviceId = strdup(p_src);
658  } else {
659  p_struct->serviceId = NULL;
660  }
661 }
662 
664 {
665  assert(p_struct);
666  if (p_struct->userId) {
667  free(p_struct->userId);
668  p_struct->userId = NULL;
669  }
670  if (p_src) {
671  p_struct->userId = strdup(p_src);
672  } else {
673  p_struct->userId = NULL;
674  }
675 }
676 
678 {
679  assert(p_struct);
680  if (p_struct->customerId) {
681  free(p_struct->customerId);
682  p_struct->customerId = NULL;
683  }
684  if (p_src) {
685  p_struct->customerId = strdup(p_src);
686  } else {
687  p_struct->customerId = NULL;
688  }
689 }
690 
692 {
693  assert(p_struct);
694  if (p_struct->userName) {
695  free(p_struct->userName);
696  p_struct->userName = NULL;
697  }
698  if (p_src) {
699  p_struct->userName = strdup(p_src);
700  } else {
701  p_struct->userName = NULL;
702  }
703 }
704 
706 {
707  assert(p_struct);
708  if (p_struct->peerId) {
709  free(p_struct->peerId);
710  p_struct->peerId = NULL;
711  }
712  if (p_src) {
713  p_struct->peerId = strdup(p_src);
714  } else {
715  p_struct->peerId = NULL;
716  }
717 }
718 
720 {
721  assert(p_struct);
722  if (p_struct->peerName) {
723  free(p_struct->peerName);
724  p_struct->peerName = NULL;
725  }
726  if (p_src) {
727  p_struct->peerName = strdup(p_src);
728  } else {
729  p_struct->peerName = NULL;
730  }
731 }
732 
734 {
735  assert(p_struct);
736  if (p_struct->address) {
737  free(p_struct->address);
738  p_struct->address = NULL;
739  }
740  if (p_src) {
741  p_struct->address = strdup(p_src);
742  } else {
743  p_struct->address = NULL;
744  }
745 }
746 
748 {
749  assert(p_struct);
750  p_struct->port = p_src;
751 }
752 
754 {
755  assert(p_struct);
756  if (p_struct->systemId) {
757  free(p_struct->systemId);
758  p_struct->systemId = NULL;
759  }
760  if (p_src) {
761  p_struct->systemId = strdup(p_src);
762  } else {
763  p_struct->systemId = NULL;
764  }
765 }
766 
767 /* list1 functions */
769 {
771  GWEN_CRYPT_TOKEN_CONTEXT *p_elem;
772 
773  assert(p_src);
775  p_elem = GWEN_Crypt_Token_Context_List_First(p_src);
776  while(p_elem) {
778 
779  p_cpy = GWEN_Crypt_Token_Context_dup(p_elem);
780  GWEN_Crypt_Token_Context_List_Add(p_cpy, p_dest);
781  p_elem = GWEN_Crypt_Token_Context_List_Next(p_elem);
782  }
783 
784  return p_dest;
785 }
786 
788 {
789  assert(p_struct);
790  /* member "id" */
791  p_struct->id = GWEN_DB_GetIntValue(p_db, "id", 0, 0);
792 
793  /* member "signKeyId" */
794  p_struct->signKeyId = GWEN_DB_GetIntValue(p_db, "signKeyId", 0, 0);
795 
796  /* member "verifyKeyId" */
797  p_struct->verifyKeyId = GWEN_DB_GetIntValue(p_db, "verifyKeyId", 0, 0);
798 
799  /* member "encipherKeyId" */
800  p_struct->encipherKeyId = GWEN_DB_GetIntValue(p_db, "encipherKeyId", 0, 0);
801 
802  /* member "decipherKeyId" */
803  p_struct->decipherKeyId = GWEN_DB_GetIntValue(p_db, "decipherKeyId", 0, 0);
804 
805  /* member "authSignKeyId" */
806  p_struct->authSignKeyId = GWEN_DB_GetIntValue(p_db, "authSignKeyId", 0, 0);
807 
808  /* member "authVerifyKeyId" */
809  p_struct->authVerifyKeyId = GWEN_DB_GetIntValue(p_db, "authVerifyKeyId", 0, 0);
810 
811  /* member "tempSignKeyId" */
812  p_struct->tempSignKeyId = GWEN_DB_GetIntValue(p_db, "tempSignKeyId", 0, 0);
813 
814  /* member "keyHashNum" */
815  p_struct->keyHashNum = GWEN_DB_GetIntValue(p_db, "keyHashNum", 0, 0);
816 
817  /* member "keyHashVer" */
818  p_struct->keyHashVer = GWEN_DB_GetIntValue(p_db, "keyHashVer", 0, 0);
819 
820  /* member "keyHashAlgo" */
821  p_struct->keyHashAlgo = GWEN_DB_GetIntValue(p_db, "keyHashAlgo", 0, 0);
822 
823  /* member "keyHash" */
824  {
825  const void *v;
826  unsigned int vlen;
827  v = GWEN_DB_GetBinValue(p_db, "keyHash", 0, NULL, 0, &vlen);
828  if (v && vlen) {
829  uint8_t *dest;
830  dest = (uint8_t*) malloc(vlen);
831  memmove(dest, v, vlen);
832  p_struct->keyHash.pointer = dest;
833  p_struct->keyHash.length = vlen;
834  }
835  }
836 
837  /* member "keyStatus" */
838  p_struct->keyStatus = GWEN_DB_GetIntValue(p_db, "keyStatus", 0, 0);
839 
840  /* member "protocolVersion" */
841  p_struct->protocolVersion = GWEN_DB_GetIntValue(p_db, "protocolVersion", 0, 0);
842 
843  /* member "cid" */
844  if (p_struct->cid) {
845  free(p_struct->cid);
846  p_struct->cid = NULL;
847  }
848  {
849  const char *s;
850  s = GWEN_DB_GetCharValue(p_db, "cid", 0, NULL);
851  if (s) p_struct->cid = strdup(s);
852  }
853  if (p_struct->cid == NULL) {
854  p_struct->cid = NULL;
855  }
856 
857  /* member "serviceId" */
858  if (p_struct->serviceId) {
859  free(p_struct->serviceId);
860  p_struct->serviceId = NULL;
861  }
862  {
863  const char *s;
864  s = GWEN_DB_GetCharValue(p_db, "serviceId", 0, NULL);
865  if (s) p_struct->serviceId = strdup(s);
866  }
867  if (p_struct->serviceId == NULL) {
868  p_struct->serviceId = NULL;
869  }
870 
871  /* member "userId" */
872  if (p_struct->userId) {
873  free(p_struct->userId);
874  p_struct->userId = NULL;
875  }
876  {
877  const char *s;
878  s = GWEN_DB_GetCharValue(p_db, "userId", 0, NULL);
879  if (s) p_struct->userId = strdup(s);
880  }
881  if (p_struct->userId == NULL) {
882  p_struct->userId = NULL;
883  }
884 
885  /* member "customerId" */
886  if (p_struct->customerId) {
887  free(p_struct->customerId);
888  p_struct->customerId = NULL;
889  }
890  {
891  const char *s;
892  s = GWEN_DB_GetCharValue(p_db, "customerId", 0, NULL);
893  if (s) p_struct->customerId = strdup(s);
894  }
895  if (p_struct->customerId == NULL) {
896  p_struct->customerId = NULL;
897  }
898 
899  /* member "userName" */
900  if (p_struct->userName) {
901  free(p_struct->userName);
902  p_struct->userName = NULL;
903  }
904  {
905  const char *s;
906  s = GWEN_DB_GetCharValue(p_db, "userName", 0, NULL);
907  if (s) p_struct->userName = strdup(s);
908  }
909  if (p_struct->userName == NULL) {
910  p_struct->userName = NULL;
911  }
912 
913  /* member "peerId" */
914  if (p_struct->peerId) {
915  free(p_struct->peerId);
916  p_struct->peerId = NULL;
917  }
918  {
919  const char *s;
920  s = GWEN_DB_GetCharValue(p_db, "peerId", 0, NULL);
921  if (s) p_struct->peerId = strdup(s);
922  }
923  if (p_struct->peerId == NULL) {
924  p_struct->peerId = NULL;
925  }
926 
927  /* member "peerName" */
928  if (p_struct->peerName) {
929  free(p_struct->peerName);
930  p_struct->peerName = NULL;
931  }
932  {
933  const char *s;
934  s = GWEN_DB_GetCharValue(p_db, "peerName", 0, NULL);
935  if (s) p_struct->peerName = strdup(s);
936  }
937  if (p_struct->peerName == NULL) {
938  p_struct->peerName = NULL;
939  }
940 
941  /* member "address" */
942  if (p_struct->address) {
943  free(p_struct->address);
944  p_struct->address = NULL;
945  }
946  {
947  const char *s;
948  s = GWEN_DB_GetCharValue(p_db, "address", 0, NULL);
949  if (s) p_struct->address = strdup(s);
950  }
951  if (p_struct->address == NULL) {
952  p_struct->address = NULL;
953  }
954 
955  /* member "port" */
956  p_struct->port = GWEN_DB_GetIntValue(p_db, "port", 0, 0);
957 
958  /* member "systemId" */
959  if (p_struct->systemId) {
960  free(p_struct->systemId);
961  p_struct->systemId = NULL;
962  }
963  {
964  const char *s;
965  s = GWEN_DB_GetCharValue(p_db, "systemId", 0, NULL);
966  if (s) p_struct->systemId = strdup(s);
967  }
968  if (p_struct->systemId == NULL) {
969  p_struct->systemId = NULL;
970  }
971 
972 }
973 
975 {
976  int p_rv;
977 
978  assert(p_struct);
979  /* member "id" */
980  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "id", p_struct->id);
981  if (p_rv < 0) {
982  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
983  return p_rv;
984  }
985 
986  /* member "signKeyId" */
987  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "signKeyId", p_struct->signKeyId);
988  if (p_rv < 0) {
989  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
990  return p_rv;
991  }
992 
993  /* member "verifyKeyId" */
994  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "verifyKeyId", p_struct->verifyKeyId);
995  if (p_rv < 0) {
996  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
997  return p_rv;
998  }
999 
1000  /* member "encipherKeyId" */
1001  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "encipherKeyId", p_struct->encipherKeyId);
1002  if (p_rv < 0) {
1003  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1004  return p_rv;
1005  }
1006 
1007  /* member "decipherKeyId" */
1008  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "decipherKeyId", p_struct->decipherKeyId);
1009  if (p_rv < 0) {
1010  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1011  return p_rv;
1012  }
1013 
1014  /* member "authSignKeyId" */
1015  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "authSignKeyId", p_struct->authSignKeyId);
1016  if (p_rv < 0) {
1017  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1018  return p_rv;
1019  }
1020 
1021  /* member "authVerifyKeyId" */
1022  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "authVerifyKeyId", p_struct->authVerifyKeyId);
1023  if (p_rv < 0) {
1024  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1025  return p_rv;
1026  }
1027 
1028  /* member "tempSignKeyId" */
1029  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "tempSignKeyId", p_struct->tempSignKeyId);
1030  if (p_rv < 0) {
1031  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1032  return p_rv;
1033  }
1034 
1035  /* member "keyHashNum" */
1036  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "keyHashNum", p_struct->keyHashNum);
1037  if (p_rv < 0) {
1038  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1039  return p_rv;
1040  }
1041 
1042  /* member "keyHashVer" */
1043  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "keyHashVer", p_struct->keyHashVer);
1044  if (p_rv < 0) {
1045  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1046  return p_rv;
1047  }
1048 
1049  /* member "keyHashAlgo" */
1050  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "keyHashAlgo", p_struct->keyHashAlgo);
1051  if (p_rv < 0) {
1052  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1053  return p_rv;
1054  }
1055 
1056  /* member "keyHash" */
1057  {
1058  if (p_struct->keyHash.length && p_struct->keyHash.pointer) {
1059  GWEN_DB_SetBinValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "keyHash", p_struct->keyHash.pointer, p_struct->keyHash.length);
1060  } else {
1061  GWEN_DB_DeleteVar(p_db, "keyHash");
1062  p_rv = 0;
1063  }
1064  }
1065  if (p_rv < 0) {
1066  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1067  return p_rv;
1068  }
1069 
1070  /* member "keyStatus" */
1071  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "keyStatus", p_struct->keyStatus);
1072  if (p_rv < 0) {
1073  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1074  return p_rv;
1075  }
1076 
1077  /* member "protocolVersion" */
1078  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "protocolVersion", p_struct->protocolVersion);
1079  if (p_rv < 0) {
1080  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1081  return p_rv;
1082  }
1083 
1084  /* member "cid" */
1085  if (p_struct->cid) p_rv = GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "cid", p_struct->cid);
1086  else {
1087  GWEN_DB_DeleteVar(p_db, "cid");
1088  p_rv = 0;
1089  }
1090  if (p_rv < 0) {
1091  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1092  return p_rv;
1093  }
1094 
1095  /* member "serviceId" */
1096  if (p_struct->serviceId) p_rv = GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "serviceId", p_struct->serviceId);
1097  else {
1098  GWEN_DB_DeleteVar(p_db, "serviceId");
1099  p_rv = 0;
1100  }
1101  if (p_rv < 0) {
1102  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1103  return p_rv;
1104  }
1105 
1106  /* member "userId" */
1107  if (p_struct->userId) p_rv = GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "userId", p_struct->userId);
1108  else {
1109  GWEN_DB_DeleteVar(p_db, "userId");
1110  p_rv = 0;
1111  }
1112  if (p_rv < 0) {
1113  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1114  return p_rv;
1115  }
1116 
1117  /* member "customerId" */
1118  if (p_struct->customerId) p_rv = GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "customerId", p_struct->customerId);
1119  else {
1120  GWEN_DB_DeleteVar(p_db, "customerId");
1121  p_rv = 0;
1122  }
1123  if (p_rv < 0) {
1124  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1125  return p_rv;
1126  }
1127 
1128  /* member "userName" */
1129  if (p_struct->userName) p_rv = GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "userName", p_struct->userName);
1130  else {
1131  GWEN_DB_DeleteVar(p_db, "userName");
1132  p_rv = 0;
1133  }
1134  if (p_rv < 0) {
1135  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1136  return p_rv;
1137  }
1138 
1139  /* member "peerId" */
1140  if (p_struct->peerId) p_rv = GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "peerId", p_struct->peerId);
1141  else {
1142  GWEN_DB_DeleteVar(p_db, "peerId");
1143  p_rv = 0;
1144  }
1145  if (p_rv < 0) {
1146  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1147  return p_rv;
1148  }
1149 
1150  /* member "peerName" */
1151  if (p_struct->peerName) p_rv = GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "peerName", p_struct->peerName);
1152  else {
1153  GWEN_DB_DeleteVar(p_db, "peerName");
1154  p_rv = 0;
1155  }
1156  if (p_rv < 0) {
1157  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1158  return p_rv;
1159  }
1160 
1161  /* member "address" */
1162  if (p_struct->address) p_rv = GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "address", p_struct->address);
1163  else {
1164  GWEN_DB_DeleteVar(p_db, "address");
1165  p_rv = 0;
1166  }
1167  if (p_rv < 0) {
1168  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1169  return p_rv;
1170  }
1171 
1172  /* member "port" */
1173  p_rv = GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "port", p_struct->port);
1174  if (p_rv < 0) {
1175  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1176  return p_rv;
1177  }
1178 
1179  /* member "systemId" */
1180  if (p_struct->systemId) p_rv = GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "systemId", p_struct->systemId);
1181  else {
1182  GWEN_DB_DeleteVar(p_db, "systemId");
1183  p_rv = 0;
1184  }
1185  if (p_rv < 0) {
1186  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
1187  return p_rv;
1188  }
1189 
1190  return 0;
1191 }
1192 
1194 {
1195  GWEN_CRYPT_TOKEN_CONTEXT *p_struct;
1196  p_struct = GWEN_Crypt_Token_Context_new();
1197  GWEN_Crypt_Token_Context_ReadDb(p_struct, p_db);
1198  return p_struct;
1199 }
1200 
1202 {
1203  return GWEN_Crypt_Token_Context_WriteDb(p_struct, p_db);
1204 }
1205 
1207 {
1208  assert(p_struct);
1209  /* member "id" */
1210  p_struct->id = GWEN_XMLNode_GetIntValue(p_db, "id", 0);
1211 
1212  /* member "signKeyId" */
1213  p_struct->signKeyId = GWEN_XMLNode_GetIntValue(p_db, "signKeyId", 0);
1214 
1215  /* member "verifyKeyId" */
1216  p_struct->verifyKeyId = GWEN_XMLNode_GetIntValue(p_db, "verifyKeyId", 0);
1217 
1218  /* member "encipherKeyId" */
1219  p_struct->encipherKeyId = GWEN_XMLNode_GetIntValue(p_db, "encipherKeyId", 0);
1220 
1221  /* member "decipherKeyId" */
1222  p_struct->decipherKeyId = GWEN_XMLNode_GetIntValue(p_db, "decipherKeyId", 0);
1223 
1224  /* member "authSignKeyId" */
1225  p_struct->authSignKeyId = GWEN_XMLNode_GetIntValue(p_db, "authSignKeyId", 0);
1226 
1227  /* member "authVerifyKeyId" */
1228  p_struct->authVerifyKeyId = GWEN_XMLNode_GetIntValue(p_db, "authVerifyKeyId", 0);
1229 
1230  /* member "tempSignKeyId" */
1231  p_struct->tempSignKeyId = GWEN_XMLNode_GetIntValue(p_db, "tempSignKeyId", 0);
1232 
1233  /* member "keyHashNum" */
1234  p_struct->keyHashNum = GWEN_XMLNode_GetIntValue(p_db, "keyHashNum", 0);
1235 
1236  /* member "keyHashVer" */
1237  p_struct->keyHashVer = GWEN_XMLNode_GetIntValue(p_db, "keyHashVer", 0);
1238 
1239  /* member "keyHashAlgo" */
1240  p_struct->keyHashAlgo = GWEN_XMLNode_GetIntValue(p_db, "keyHashAlgo", 0);
1241 
1242  /* member "keyHash" */
1243  {
1244  const char *s;
1245  s = GWEN_XMLNode_GetCharValue(p_db, "keyHash", NULL);
1246  if (s) {
1247  GWEN_BUFFER *tbuf;
1248  int rv;
1249  tbuf = GWEN_Buffer_new(0, 1024, 0, 1);
1250  rv = GWEN_Base64_Decode((const unsigned char*)s, strlen(s), tbuf);
1251  if (rv < 0) {
1252  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1253  } else {
1254  char *t;
1255  uint32_t len;
1256  len = GWEN_Buffer_GetUsedBytes(tbuf);
1257  t = GWEN_Buffer_GetStart(tbuf);
1258  if (GWEN_Buffer_Relinquish(tbuf) < 0) {
1259  uint8_t *dest;
1260  dest = (uint8_t*) malloc(len);
1261  memmove(dest, t, len);
1262  p_struct->keyHash.pointer = dest;
1263  p_struct->keyHash.length = len;
1264  } else {
1265  p_struct->keyHash.pointer = (uint8_t*) t;
1266  p_struct->keyHash.length = len;
1267  }
1268  }
1269  GWEN_Buffer_free(tbuf);
1270  }
1271  }
1272 
1273  /* member "keyStatus" */
1274  p_struct->keyStatus = GWEN_XMLNode_GetIntValue(p_db, "keyStatus", 0);
1275 
1276  /* member "protocolVersion" */
1277  p_struct->protocolVersion = GWEN_XMLNode_GetIntValue(p_db, "protocolVersion", 0);
1278 
1279  /* member "cid" */
1280  if (p_struct->cid) {
1281  free(p_struct->cid);
1282  p_struct->cid = NULL;
1283  }
1284  {
1285  const char *s;
1286  s = GWEN_XMLNode_GetCharValue(p_db, "cid", NULL);
1287  if (s) p_struct->cid = strdup(s);
1288  }
1289  if (p_struct->cid == NULL) { /* preset member "cid" if empty */
1290  p_struct->cid = NULL;
1291  }
1292 
1293  /* member "serviceId" */
1294  if (p_struct->serviceId) {
1295  free(p_struct->serviceId);
1296  p_struct->serviceId = NULL;
1297  }
1298  {
1299  const char *s;
1300  s = GWEN_XMLNode_GetCharValue(p_db, "serviceId", NULL);
1301  if (s) p_struct->serviceId = strdup(s);
1302  }
1303  if (p_struct->serviceId == NULL) { /* preset member "serviceId" if empty */
1304  p_struct->serviceId = NULL;
1305  }
1306 
1307  /* member "userId" */
1308  if (p_struct->userId) {
1309  free(p_struct->userId);
1310  p_struct->userId = NULL;
1311  }
1312  {
1313  const char *s;
1314  s = GWEN_XMLNode_GetCharValue(p_db, "userId", NULL);
1315  if (s) p_struct->userId = strdup(s);
1316  }
1317  if (p_struct->userId == NULL) { /* preset member "userId" if empty */
1318  p_struct->userId = NULL;
1319  }
1320 
1321  /* member "customerId" */
1322  if (p_struct->customerId) {
1323  free(p_struct->customerId);
1324  p_struct->customerId = NULL;
1325  }
1326  {
1327  const char *s;
1328  s = GWEN_XMLNode_GetCharValue(p_db, "customerId", NULL);
1329  if (s) p_struct->customerId = strdup(s);
1330  }
1331  if (p_struct->customerId == NULL) { /* preset member "customerId" if empty */
1332  p_struct->customerId = NULL;
1333  }
1334 
1335  /* member "userName" */
1336  if (p_struct->userName) {
1337  free(p_struct->userName);
1338  p_struct->userName = NULL;
1339  }
1340  {
1341  const char *s;
1342  s = GWEN_XMLNode_GetCharValue(p_db, "userName", NULL);
1343  if (s) p_struct->userName = strdup(s);
1344  }
1345  if (p_struct->userName == NULL) { /* preset member "userName" if empty */
1346  p_struct->userName = NULL;
1347  }
1348 
1349  /* member "peerId" */
1350  if (p_struct->peerId) {
1351  free(p_struct->peerId);
1352  p_struct->peerId = NULL;
1353  }
1354  {
1355  const char *s;
1356  s = GWEN_XMLNode_GetCharValue(p_db, "peerId", NULL);
1357  if (s) p_struct->peerId = strdup(s);
1358  }
1359  if (p_struct->peerId == NULL) { /* preset member "peerId" if empty */
1360  p_struct->peerId = NULL;
1361  }
1362 
1363  /* member "peerName" */
1364  if (p_struct->peerName) {
1365  free(p_struct->peerName);
1366  p_struct->peerName = NULL;
1367  }
1368  {
1369  const char *s;
1370  s = GWEN_XMLNode_GetCharValue(p_db, "peerName", NULL);
1371  if (s) p_struct->peerName = strdup(s);
1372  }
1373  if (p_struct->peerName == NULL) { /* preset member "peerName" if empty */
1374  p_struct->peerName = NULL;
1375  }
1376 
1377  /* member "address" */
1378  if (p_struct->address) {
1379  free(p_struct->address);
1380  p_struct->address = NULL;
1381  }
1382  {
1383  const char *s;
1384  s = GWEN_XMLNode_GetCharValue(p_db, "address", NULL);
1385  if (s) p_struct->address = strdup(s);
1386  }
1387  if (p_struct->address == NULL) { /* preset member "address" if empty */
1388  p_struct->address = NULL;
1389  }
1390 
1391  /* member "port" */
1392  p_struct->port = GWEN_XMLNode_GetIntValue(p_db, "port", 0);
1393 
1394  /* member "systemId" */
1395  if (p_struct->systemId) {
1396  free(p_struct->systemId);
1397  p_struct->systemId = NULL;
1398  }
1399  {
1400  const char *s;
1401  s = GWEN_XMLNode_GetCharValue(p_db, "systemId", NULL);
1402  if (s) p_struct->systemId = strdup(s);
1403  }
1404  if (p_struct->systemId == NULL) { /* preset member "systemId" if empty */
1405  p_struct->systemId = NULL;
1406  }
1407 
1408 }
1409 
1411 {
1412  assert(p_struct);
1413  /* member "id" */
1414  GWEN_XMLNode_SetIntValue(p_db, "id", p_struct->id);
1415 
1416  /* member "signKeyId" */
1417  GWEN_XMLNode_SetIntValue(p_db, "signKeyId", p_struct->signKeyId);
1418 
1419  /* member "verifyKeyId" */
1420  GWEN_XMLNode_SetIntValue(p_db, "verifyKeyId", p_struct->verifyKeyId);
1421 
1422  /* member "encipherKeyId" */
1423  GWEN_XMLNode_SetIntValue(p_db, "encipherKeyId", p_struct->encipherKeyId);
1424 
1425  /* member "decipherKeyId" */
1426  GWEN_XMLNode_SetIntValue(p_db, "decipherKeyId", p_struct->decipherKeyId);
1427 
1428  /* member "authSignKeyId" */
1429  GWEN_XMLNode_SetIntValue(p_db, "authSignKeyId", p_struct->authSignKeyId);
1430 
1431  /* member "authVerifyKeyId" */
1432  GWEN_XMLNode_SetIntValue(p_db, "authVerifyKeyId", p_struct->authVerifyKeyId);
1433 
1434  /* member "tempSignKeyId" */
1435  GWEN_XMLNode_SetIntValue(p_db, "tempSignKeyId", p_struct->tempSignKeyId);
1436 
1437  /* member "keyHashNum" */
1438  GWEN_XMLNode_SetIntValue(p_db, "keyHashNum", p_struct->keyHashNum);
1439 
1440  /* member "keyHashVer" */
1441  GWEN_XMLNode_SetIntValue(p_db, "keyHashVer", p_struct->keyHashVer);
1442 
1443  /* member "keyHashAlgo" */
1444  GWEN_XMLNode_SetIntValue(p_db, "keyHashAlgo", p_struct->keyHashAlgo);
1445 
1446  /* member "keyHash" */
1447  {
1448  if (p_struct->keyHash.length && p_struct->keyHash.pointer) {
1449  GWEN_BUFFER *tbuf;
1450  int rv;
1451  tbuf = GWEN_Buffer_new(0, 1024, 0, 1);
1452  rv = GWEN_Base64_Encode((const unsigned char*) p_struct->keyHash.pointer, p_struct->keyHash.length, tbuf, 80);
1453  if (rv < 0) {
1454  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1455  } else {
1456  GWEN_XMLNode_SetCharValue(p_db, "keyHash", GWEN_Buffer_GetStart(tbuf));
1457  GWEN_Buffer_free(tbuf);
1458  }
1459  }
1460  }
1461 
1462  /* member "keyStatus" */
1463  GWEN_XMLNode_SetIntValue(p_db, "keyStatus", p_struct->keyStatus);
1464 
1465  /* member "protocolVersion" */
1466  GWEN_XMLNode_SetIntValue(p_db, "protocolVersion", p_struct->protocolVersion);
1467 
1468  /* member "cid" */
1469  GWEN_XMLNode_SetCharValue(p_db, "cid", p_struct->cid);
1470 
1471  /* member "serviceId" */
1472  GWEN_XMLNode_SetCharValue(p_db, "serviceId", p_struct->serviceId);
1473 
1474  /* member "userId" */
1475  GWEN_XMLNode_SetCharValue(p_db, "userId", p_struct->userId);
1476 
1477  /* member "customerId" */
1478  GWEN_XMLNode_SetCharValue(p_db, "customerId", p_struct->customerId);
1479 
1480  /* member "userName" */
1481  GWEN_XMLNode_SetCharValue(p_db, "userName", p_struct->userName);
1482 
1483  /* member "peerId" */
1484  GWEN_XMLNode_SetCharValue(p_db, "peerId", p_struct->peerId);
1485 
1486  /* member "peerName" */
1487  GWEN_XMLNode_SetCharValue(p_db, "peerName", p_struct->peerName);
1488 
1489  /* member "address" */
1490  GWEN_XMLNode_SetCharValue(p_db, "address", p_struct->address);
1491 
1492  /* member "port" */
1493  GWEN_XMLNode_SetIntValue(p_db, "port", p_struct->port);
1494 
1495  /* member "systemId" */
1496  GWEN_XMLNode_SetCharValue(p_db, "systemId", p_struct->systemId);
1497 
1498 }
1499 
1501 {
1502  GWEN_Crypt_Token_Context_WriteXml(p_struct, p_db);
1503 }
1504 
1506 {
1507  GWEN_CRYPT_TOKEN_CONTEXT *p_struct;
1508  p_struct = GWEN_Crypt_Token_Context_new();
1509  GWEN_Crypt_Token_Context_ReadXml(p_struct, p_db);
1510  return p_struct;
1511 }
1512 
1514 {
1515  GWEN_CRYPT_TOKEN_CONTEXT *p_struct;
1516 
1517  assert(p_list);
1518  p_struct = GWEN_Crypt_Token_Context_List_First(p_list);
1519  while(p_struct) {
1520  int p_rv;
1521 
1522  if (p_struct->id == p_cmp) p_rv = 0;
1523  else if (p_cmp < p_struct->id) p_rv = -1;
1524  else p_rv = 1;
1525  if (p_rv == 0)
1526  return p_struct;
1527  p_struct = GWEN_Crypt_Token_Context_List_Next(p_struct);
1528  }
1529  return NULL;
1530 }
1531 
1532 void GWEN_Crypt_Token_Context_SetKeyHash(GWEN_CRYPT_TOKEN_CONTEXT *st, const uint8_t *p, uint32_t len)
1533 {
1534  assert(st);
1535  if (st->keyHash.length && st->keyHash.pointer) free(st->keyHash.pointer);
1536  if (p && len) {
1537  st->keyHash.pointer = (uint8_t*) malloc(len);
1538  if (st->keyHash.pointer) {
1539  st->keyHash.length = len;
1540  memmove(st->keyHash.pointer, p, len);
1541  } else {
1542  st->keyHash.pointer = NULL;
1543  st->keyHash.length = 0;
1544  }
1545  } else {
1546  st->keyHash.length = 0;
1547  st->keyHash.pointer = NULL;
1548  }
1549 }
1551 {
1552  assert(st);
1553  return st->keyHash.pointer;
1554 }
1556 {
1557  assert(st);
1558  return st->keyHash.length;
1559 }
1560 
1561 /* code headers */
1562 
void GWEN_Crypt_Token_Context_SetVerifyKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:569
const char * GWEN_Crypt_Token_Context_GetServiceId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:503
void GWEN_Crypt_Token_Context_SetServiceId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
Definition: ct_context.c:649
void GWEN_Crypt_Token_Context_List_Add(GWEN_CRYPT_TOKEN_CONTEXT *element, GWEN_CRYPT_TOKEN_CONTEXT_LIST *list)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:223
#define GWEN_DB_FLAGS_OVERWRITE_VARS
Definition: db.h:121
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_Token_Context_copy(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const GWEN_CRYPT_TOKEN_CONTEXT *p_src)
Definition: ct_context.c:265
void GWEN_Crypt_Token_Context_SetProtocolVersion(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:629
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
#define GWEN_INHERIT_FINI(t, element)
Definition: inherit.h:238
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_Token_Context_fromDb(GWEN_DB_NODE *p_db)
Definition: ct_context.c:1193
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
Definition: buffer.c:266
uint32_t GWEN_Crypt_Token_Context_GetSignKeyId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:425
void GWEN_Crypt_Token_Context_SetKeyStatus(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:623
const char * GWEN_Crypt_Token_Context_GetUserId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:509
const char * GWEN_Crypt_Token_Context_GetUserName(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:521
const uint8_t * GWEN_Crypt_Token_Context_GetKeyHashPtr(const GWEN_CRYPT_TOKEN_CONTEXT *st)
Definition: ct_context.c:1550
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_Token_Context_new(void)
Definition: ct_context.c:25
uint32_t GWEN_Crypt_Token_Context_GetTempSignKeyId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:461
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_Token_Context_List_GetById(const GWEN_CRYPT_TOKEN_CONTEXT_LIST *p_list, uint32_t p_cmp)
Definition: ct_context.c:1513
void GWEN_Crypt_Token_Context_ReadDb(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, GWEN_DB_NODE *p_db)
Definition: ct_context.c:787
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:92
#define NULL
Definition: binreloc.c:290
const char * GWEN_Crypt_Token_Context_GetAddress(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:539
uint32_t GWEN_Crypt_Token_Context_GetEncipherKeyId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:437
void GWEN_Crypt_Token_Context_SetEncipherKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:575
void GWEN_Crypt_Token_Context_SetSystemId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
Definition: ct_context.c:753
uint32_t GWEN_Crypt_Token_Context_GetVerifyKeyId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:431
int GWEN_Crypt_Token_Context_GetPort(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:545
void GWEN_Crypt_Token_Context_SetCid(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
Definition: ct_context.c:635
int GWEN_Base64_Decode(const unsigned char *src, unsigned int size, GWEN_BUFFER *dst)
Definition: base64.c:132
void GWEN_Crypt_Token_Context_SetAuthSignKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:587
const char * GWEN_Crypt_Token_Context_GetSystemId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:551
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_Token_Context_dup(const GWEN_CRYPT_TOKEN_CONTEXT *p_src)
Definition: ct_context.c:109
void GWEN_Crypt_Token_Context_SetUserName(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
Definition: ct_context.c:691
void GWEN_XMLNode_SetCharValue(GWEN_XMLNODE *n, const char *name, const char *value)
Definition: xml.c:812
#define GWEN_LOGDOMAIN
Definition: logger.h:35
int GWEN_Base64_Encode(const unsigned char *src, unsigned int size, GWEN_BUFFER *dst, unsigned int maxLineLength)
Definition: base64.c:44
void GWEN_Crypt_Token_Context_SetPeerName(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
Definition: ct_context.c:719
void GWEN_Crypt_Token_Context_free(GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:64
uint32_t GWEN_Crypt_Token_Context_GetId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:419
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition: buffer.c:38
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_Token_Context_List_Next(const GWEN_CRYPT_TOKEN_CONTEXT *element)
int GWEN_XMLNode_GetIntValue(const GWEN_XMLNODE *n, const char *name, int defValue)
Definition: xml.c:837
void GWEN_Crypt_Token_Context_ReadXml(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, GWEN_XMLNODE *p_db)
Definition: ct_context.c:1206
uint32_t GWEN_Crypt_Token_Context_GetKeyHashLen(const GWEN_CRYPT_TOKEN_CONTEXT *st)
Definition: ct_context.c:1555
const char * GWEN_Crypt_Token_Context_GetCid(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:497
void GWEN_Crypt_Token_Context_SetSignKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:563
uint32_t GWEN_Crypt_Token_Context_GetKeyHashNum(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:467
int GWEN_DB_SetBinValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const void *val, unsigned int valSize)
Definition: db.c:1151
#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
uint32_t GWEN_Crypt_Token_Context_GetKeyStatus(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:485
void GWEN_Crypt_Token_Context_SetKeyHashNum(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:605
void GWEN_Crypt_Token_Context_SetKeyHashVer(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:611
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_Token_Context_fromXml(GWEN_XMLNODE *p_db)
Definition: ct_context.c:1505
void GWEN_Crypt_Token_Context_SetCustomerId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
Definition: ct_context.c:677
const void * GWEN_DB_GetBinValue(GWEN_DB_NODE *n, const char *path, int idx, const void *defVal, unsigned int defValSize, unsigned int *returnValueSize)
Definition: db.c:1120
int GWEN_Crypt_Token_Context_WriteDb(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct, GWEN_DB_NODE *p_db)
Definition: ct_context.c:974
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
Definition: db.c:897
#define GWEN_INHERIT_INIT(t, element)
Definition: inherit.h:223
int GWEN_Buffer_Relinquish(GWEN_BUFFER *bf)
Definition: buffer.c:139
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition: buffer.c:83
int GWEN_DB_DeleteVar(GWEN_DB_NODE *n, const char *path)
Definition: db.c:828
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:41
const char * GWEN_Crypt_Token_Context_GetPeerId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:527
uint32_t GWEN_Crypt_Token_Context_GetAuthVerifyKeyId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:455
GWEN_LIST2_FUNCTIONS(TYPEMAKER2_TYPE, Typemaker2_Type)
uint32_t GWEN_Crypt_Token_Context_GetKeyHashAlgo(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:479
void GWEN_Crypt_Token_Context_SetKeyHashAlgo(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:617
void GWEN_Crypt_Token_Context_WriteXml(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct, GWEN_XMLNODE *p_db)
Definition: ct_context.c:1410
uint32_t GWEN_Crypt_Token_Context_GetAuthSignKeyId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:449
struct GWEN_CRYPT_TOKEN_CONTEXT GWEN_CRYPT_TOKEN_CONTEXT
Definition: ct_context.h:185
void GWEN_Crypt_Token_Context_SetKeyHash(GWEN_CRYPT_TOKEN_CONTEXT *st, const uint8_t *p, uint32_t len)
Definition: ct_context.c:1532
uint32_t GWEN_Crypt_Token_Context_GetDecipherKeyId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:443
GWEN_CRYPT_TOKEN_CONTEXT_LIST * GWEN_Crypt_Token_Context_List_dup(const GWEN_CRYPT_TOKEN_CONTEXT_LIST *p_src)
Definition: ct_context.c:768
void GWEN_Crypt_Token_Context_SetAddress(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
Definition: ct_context.c:733
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
Definition: db.c:922
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_Token_Context_List_First(const GWEN_CRYPT_TOKEN_CONTEXT_LIST *l)
void GWEN_Crypt_Token_Context_SetUserId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
Definition: ct_context.c:663
void GWEN_Crypt_Token_Context_SetTempSignKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:599
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:164
const char * GWEN_Crypt_Token_Context_GetPeerName(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:533
int GWEN_Crypt_Token_Context_toDb(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct, GWEN_DB_NODE *p_db)
Definition: ct_context.c:1201
#define GWEN_LIST_INIT(t, element)
Definition: list1.h:465
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
Definition: db.c:1048
uint32_t GWEN_Crypt_Token_Context_GetKeyHashVer(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:473
uint32_t GWEN_Crypt_Token_Context_GetProtocolVersion(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:491
void GWEN_Crypt_Token_Context_SetDecipherKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:581
const char * GWEN_Crypt_Token_Context_GetCustomerId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:515
int GWEN_DB_SetIntValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
Definition: db.c:1086
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition: list1.h:366
void GWEN_Crypt_Token_Context_SetId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:557
GWEN_CRYPT_TOKEN_CONTEXT_LIST * GWEN_Crypt_Token_Context_List_new()
void GWEN_Crypt_Token_Context_toXml(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct, GWEN_XMLNODE *p_db)
Definition: ct_context.c:1500
void GWEN_Crypt_Token_Context_SetPeerId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
Definition: ct_context.c:705
#define GWEN_LIST_FINI(t, element)
Definition: list1.h:474
#define GWEN_INHERIT_FUNCTIONS(t)
Definition: inherit.h:163
void GWEN_Crypt_Token_Context_Attach(GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
Definition: ct_context.c:102
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:148
void GWEN_Crypt_Token_Context_SetAuthVerifyKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
Definition: ct_context.c:593
void GWEN_Crypt_Token_Context_SetPort(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, int p_src)
Definition: ct_context.c:747
void GWEN_XMLNode_SetIntValue(GWEN_XMLNODE *n, const char *name, int value)
Definition: xml.c:853