1 |
twoaday |
2 |
/* common-status.c |
2 |
|
|
* Copyright (C) 2004 Timo Schulz |
3 |
|
|
* |
4 |
|
|
* This file is part of MyGPGME. |
5 |
|
|
* |
6 |
|
|
* MyGPGME is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* MyGPGME is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include <stdlib.h> |
22 |
|
|
#include <stdio.h> |
23 |
|
|
|
24 |
|
|
#include "types.h" |
25 |
|
|
#include "context.h" |
26 |
|
|
#include "common-status.h" |
27 |
|
|
#include "util.h" |
28 |
|
|
|
29 |
|
|
|
30 |
|
|
gpgme_error_t |
31 |
|
|
_gpgme_nodata_status_handler (gpg_status_code_t code, |
32 |
|
|
const char * args, int * ret) |
33 |
|
|
{ |
34 |
|
|
*ret = 0; |
35 |
|
|
|
36 |
|
|
switch (code) { |
37 |
|
|
case STATUS_NODATA: |
38 |
|
|
if (args) |
39 |
|
|
*ret = atoi (args); |
40 |
|
|
else |
41 |
|
|
*ret = -1; |
42 |
|
|
break; |
43 |
|
|
|
44 |
|
|
case STATUS_UNEXPECTED: |
45 |
|
|
*ret = 1; |
46 |
|
|
break; |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
return 0; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
gpgme_error_t |
54 |
|
|
_gpgme_sigtrust_status_handler (gpg_status_code_t code, |
55 |
|
|
const char * args, |
56 |
|
|
int * retval) |
57 |
|
|
{ |
58 |
|
|
*retval = 0; |
59 |
twoaday |
9 |
|
60 |
twoaday |
2 |
switch (code) { |
61 |
|
|
case STATUS_TRUST_UNDEFINED: |
62 |
|
|
*retval = GPGME_VALIDITY_UNDEFINED; |
63 |
|
|
break; |
64 |
|
|
|
65 |
|
|
case STATUS_TRUST_NEVER: |
66 |
|
|
*retval = GPGME_VALIDITY_NEVER; |
67 |
|
|
break; |
68 |
|
|
|
69 |
|
|
case STATUS_TRUST_MARGINAL: |
70 |
|
|
*retval = GPGME_VALIDITY_MARGINAL; |
71 |
|
|
break; |
72 |
|
|
|
73 |
|
|
case STATUS_TRUST_FULLY: |
74 |
|
|
*retval = GPGME_VALIDITY_FULL; |
75 |
|
|
break; |
76 |
|
|
|
77 |
|
|
case STATUS_TRUST_ULTIMATE: |
78 |
|
|
*retval = GPGME_VALIDITY_ULTIMATE; |
79 |
|
|
break; |
80 |
|
|
} |
81 |
|
|
return 0; |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
|
85 |
|
|
gpgme_error_t |
86 |
|
|
_gpgme_pass_status_handler (gpg_status_code_t code, |
87 |
|
|
const char * args, |
88 |
|
|
int * r_bad_pass, int * r_no_pass, |
89 |
|
|
char ** r_info) |
90 |
|
|
{ |
91 |
|
|
int bad_pass = *r_bad_pass; |
92 |
|
|
int no_pass = *r_no_pass; |
93 |
|
|
char * p; |
94 |
|
|
|
95 |
|
|
switch (code) { |
96 |
|
|
case STATUS_BAD_PASSPHRASE: |
97 |
|
|
bad_pass++; |
98 |
|
|
break; |
99 |
|
|
|
100 |
|
|
case STATUS_GOOD_PASSPHRASE: |
101 |
|
|
bad_pass = 0; |
102 |
|
|
break; |
103 |
|
|
|
104 |
|
|
case STATUS_NEED_PASSPHRASE: |
105 |
|
|
case STATUS_NEED_PASSPHRASE_SYM: |
106 |
|
|
safe_free (*r_info); |
107 |
|
|
p = *r_info = strdup (args); |
108 |
|
|
if (!p) |
109 |
|
|
return GPGME_Out_Of_Core; |
110 |
|
|
break; |
111 |
|
|
|
112 |
|
|
case STATUS_MISSING_PASSPHRASE: |
113 |
|
|
DEBUG0 ("missing passphrase - stop\n"); |
114 |
|
|
no_pass = 1; |
115 |
|
|
break; |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
*r_bad_pass = bad_pass; |
119 |
|
|
*r_no_pass = no_pass; |
120 |
|
|
|
121 |
|
|
return 0; |
122 |
|
|
} |