comparison cinst/windowsstore.c @ 626:f595fcbe3e76

Replace "normal printfs" with DEBUG / ERROR printf macros
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 20 Jun 2014 14:29:05 +0200
parents 736e95c63b86
children 698b6a9bd75e
comparison
equal deleted inserted replaced
625:2303caf56dbb 626:f595fcbe3e76
26 26
27 ret = str_base64_decode (&buf, &buf_size, b64_data, b64_size); 27 ret = str_base64_decode (&buf, &buf_size, b64_data, b64_size);
28 28
29 if (ret != 0) 29 if (ret != 0)
30 { 30 {
31 printf ("decoding certificate failed\n"); 31 ERRORPRINTF ("decoding certificate failed\n");
32 return NULL; 32 return NULL;
33 } 33 }
34 34
35 pCert = CertCreateContext (CERT_STORE_CERTIFICATE_CONTEXT, 35 pCert = CertCreateContext (CERT_STORE_CERTIFICATE_CONTEXT,
36 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 36 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
43 if (pCert == NULL) 43 if (pCert == NULL)
44 { 44 {
45 char *error = getLastErrorMsg(); 45 char *error = getLastErrorMsg();
46 if (error) 46 if (error)
47 { 47 {
48 printf ("Failed to create cert context: %s \n", error); 48 ERRORPRINTF ("Failed to create cert context: %s \n", error);
49 free (error); 49 free (error);
50 } 50 }
51 return NULL; 51 return NULL;
52 } 52 }
53 return pCert; 53 return pCert;
75 if (pc_to_remove == NULL) 75 if (pc_to_remove == NULL)
76 { 76 {
77 char *error = getLastErrorMsg(); 77 char *error = getLastErrorMsg();
78 if (error) 78 if (error)
79 { 79 {
80 printf ("Failed to create cert context: %s \n", error); 80 ERRORPRINTF ("Failed to create cert context: %s \n", error);
81 free (error); 81 free (error);
82 } 82 }
83 continue; 83 continue;
84 } 84 }
85 85
92 92
93 CertFreeCertificateContext (pc_to_remove); 93 CertFreeCertificateContext (pc_to_remove);
94 94
95 if (pCert == NULL) 95 if (pCert == NULL)
96 { 96 {
97 printf ("Did not find certificate\n"); 97 ERRORPRINTF ("Did not find certificate\n");
98 continue; 98 continue;
99 } 99 }
100 100
101 if (!CertDeleteCertificateFromStore (pCert)) 101 if (!CertDeleteCertificateFromStore (pCert))
102 { 102 {
103 /* From MSDN: 103 /* From MSDN:
104 The CertDeleteCertificateFromStore function always frees 104 The CertDeleteCertificateFromStore function always frees
105 pCertContext by calling the CertFreeCertificateContext 105 pCertContext by calling the CertFreeCertificateContext
106 function, even if an error is encountered. */ 106 function, even if an error is encountered. */
107 char *error = getLastErrorMsg(); 107 char *error = getLastErrorMsg();
108 printf ("Error deleting certificate. %s", error); 108 ERRORPRINTF ("Error deleting certificate. %s", error);
109 free (error); 109 free (error);
110 continue; 110 continue;
111 } 111 }
112 log_certificate (elevated ? "Local Machine" : "Current User", 112 log_certificate (elevated ? "Local Machine" : "Current User",
113 to_remove[i], false); 113 to_remove[i], false);
146 CERT_FIND_EXISTING, 146 CERT_FIND_EXISTING,
147 pc_to_add, 147 pc_to_add,
148 NULL); 148 NULL);
149 if (found_cert != NULL) 149 if (found_cert != NULL)
150 { 150 {
151 printf ("Certificate already in store\n"); 151 DEBUGPRINTF ("Certificate already in store\n");
152 CertFreeCertificateContext (found_cert); 152 CertFreeCertificateContext (found_cert);
153 CertFreeCertificateContext (pc_to_add); 153 CertFreeCertificateContext (pc_to_add);
154 continue; 154 continue;
155 } 155 }
156 156
162 if (!ret) 162 if (!ret)
163 { 163 {
164 char *error = getLastErrorMsg(); 164 char *error = getLastErrorMsg();
165 if (error) 165 if (error)
166 { 166 {
167 printf ("Failed to add certificate: %s \n", error); 167 ERRORPRINTF ("Failed to add certificate: %s \n", error);
168 free (error); 168 free (error);
169 } 169 }
170 } 170 }
171 log_certificate (elevated ? "Local Machine" : "Current User", 171 log_certificate (elevated ? "Local Machine" : "Current User",
172 to_install[i], true); 172 to_install[i], true);

http://wald.intevation.org/projects/trustbridge/