1 #include <unix.h>
2 #include <pkcs11.h>
3 #include <testlib.h>
4 #include <eid-viewer/oslayer.h>
5 #include <stdlib.h>
6
7 enum eid_vwr_source cursrc;
8
newsrc(enum eid_vwr_source src)9 static void newsrc(enum eid_vwr_source src) {
10 cursrc = src;
11 switch(src) {
12 case EID_VWR_SRC_NONE:
13 printf("card removed\n");
14 break;
15 case EID_VWR_SRC_FILE:
16 printf("file source\n");
17 break;
18 case EID_VWR_SRC_CARD:
19 printf("card found\n");
20 break;
21 default:
22 printf("unknown source; error?\n");
23 exit(TEST_RV_FAIL);
24 }
25 }
26
newstringdata(const EID_CHAR * label,const EID_CHAR * data)27 static void newstringdata(const EID_CHAR* label, const EID_CHAR* data) {
28 printf("Found string data\nLabel:\t%s\nData:\t%s\n", label, data);
29 }
30
newbindata(const EID_CHAR * label,const unsigned char * data EIDT_UNUSED,int datalen)31 static void newbindata(const EID_CHAR* label, const unsigned char* data EIDT_UNUSED, int datalen) {
32 printf("Found binary data\nLabel:\t%s\nLength:\t%d\n", label, datalen);
33 }
34
dolog(enum eid_vwr_loglevel lvl,const EID_CHAR * line)35 static void dolog(enum eid_vwr_loglevel lvl, const EID_CHAR* line) {
36 printf("Log message; level: ");
37 switch(lvl) {
38 case EID_VWR_LOG_DETAIL:
39 printf("detail");
40 break;
41 case EID_VWR_LOG_NORMAL:
42 printf("normal");
43 break;
44 case EID_VWR_LOG_COARSE:
45 printf("coarse");
46 break;
47 case EID_VWR_LOG_ERROR:
48 printf("error");
49 break;
50 }
51 printf("; line: %s\n", line);
52 }
53
createcbs()54 struct eid_vwr_ui_callbacks* createcbs() {
55 struct eid_vwr_ui_callbacks* cb = eid_vwr_cbstruct();
56 if(cb == NULL) {
57 return cb;
58 }
59 cb->newsrc = newsrc;
60 cb->newstringdata = newstringdata;
61 cb->newbindata = newbindata;
62 cb->log = dolog;
63 return cb;
64 }
65