/[winpt]/trunk/MyGPGME/sig.c
ViewVC logotype

Annotation of /trunk/MyGPGME/sig.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (hide annotations)
Fri May 20 08:38:32 2005 UTC (19 years, 9 months ago) by twoaday
File MIME type: text/plain
File size: 3472 byte(s)
2005-05-20      Timo Schulz  <twoaday@freakmail.de>
 
        * gpgme.h: s/cliptype/pgptype. Suggested by Kurt Fitzner.
        s/CLIP/PGP. Likewise.
        * w32-io.c (_gpgme_io_select): Increment the right loop variable.
        Kudos to Kurt.
        * keylist.c (gpgme_op_keylist_getkey): New. Handy function to
        retrieve a single key.
        * verify.c (gpgme_get_sig_key): Use it here.
        * keycache.c (gpgme_keycache_update_key): Update a single key.
 


1 twoaday 2 /* sig.c - General signature API
2     * Copyright (C) 2001, 2002, 2003 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 <stdio.h>
22     #include <string.h>
23     #include <stdlib.h>
24    
25     #include "gpgme.h"
26     #include "context.h"
27     #include "util.h"
28    
29    
30     gpgme_error_t
31     gpgme_sig_new( gpgme_sig_t *r_sig )
32     {
33     gpgme_sig_t sig;
34    
35     sig = calloc( 1, sizeof *sig );
36     if( !sig )
37     return mk_error( Out_Of_Core );
38     *r_sig = sig;
39     return 0;
40     } /* gpgme_sig_new */
41    
42    
43     void
44 twoaday 9 gpgme_sig_release (gpgme_sig_t sig)
45 twoaday 2 {
46     if( !sig )
47     return;
48     if( sig->ref_count > 0 ) {
49     sig->ref_count--;
50     return;
51     }
52     safe_free( sig->notation );
53     safe_free( sig->policy_url );
54     safe_free( sig->user_id );
55     safe_free( sig->file_name );
56     safe_free (sig->key_server);
57     safe_free( sig );
58     } /* gpgme_sig_release */
59    
60    
61     void
62     _gpgme_sig_ref( gpgme_sig_t sig )
63     {
64     if( sig )
65     sig->ref_count++;
66     } /* _gpgme_sig_ref */
67    
68    
69     void
70 twoaday 17 gpgme_sig_set_key_ctx (gpgme_sig_t sig, gpgme_keycache_t cache)
71 twoaday 2 {
72 twoaday 17 if (sig && cache)
73     gpgme_keycache_find_key (cache, sig->id, 0, &sig->key);
74 twoaday 2 } /* gpgme_sig_set_key_ctx */
75    
76    
77     ulong
78 twoaday 9 gpgme_sig_get_ulong_attr (gpgme_sig_t sig, int idx, int what)
79 twoaday 2 {
80     gpgme_sig_t s;
81     int pos = 0;
82    
83 twoaday 9 if (!sig)
84 twoaday 2 return 0;
85    
86     switch( what ) {
87     case GPGME_ATTR_EXPIRES: return sig->expired;
88     case GPGME_ATTR_EXPIRE: return sig->flags.expired;;
89     case GPGME_ATTR_VALIDITY: return sig->sigstat;
90     case GPGME_ATTR_OTRUST: return sig->trust;
91     case GPGME_ATTR_CREATED: return sig->created;
92     case GPGME_ATTR_TYPE: return (ulong)sig->key;
93     case GPGME_ATTR_ALGO: return sig->key_algo;
94     case GPGME_ATTR_OPAQUE:
95     for( s = sig; s && idx > 0; s=s->next, idx-- )
96     ;
97     return (ulong)s;
98    
99     case GPGME_ATTR_LEVEL:
100 twoaday 9 for (s = sig; s; s = s->next)
101 twoaday 2 pos++;
102     return pos;
103     case GPGME_ATTR_KEYID:
104 twoaday 17 if (strlen (sig->id) == 40)
105     pos = 32;
106     else if (strlen (sig->id) == 16)
107     pos = 8;
108     /* XXX: else?? */
109     return strtoul (sig->id + pos, NULL, 16);
110 twoaday 2 }
111     return 0;
112     } /* gpgme_sig_get_ulong_attr */
113    
114    
115     const char*
116 twoaday 17 gpgme_sig_get_string_attr (gpgme_sig_t sig, int what)
117 twoaday 2 {
118     if( !sig )
119     return NULL;
120    
121     switch( what ) {
122     case GPGME_ATTR_NOTATION:
123     return sig->notation;
124     case GPGME_ATTR_NAME:
125     return sig->file_name;
126     case GPGME_ATTR_USERID:
127     return sig->user_id;
128     case GPGME_ATTR_POLICY_URL:
129     return sig->policy_url;
130     case GPGME_ATTR_KEYSERVER:
131     return sig->key_server;
132     case GPGME_ATTR_KEYID:
133     if( strlen( sig->id ) == 40 )
134     return sig->id + 24;
135     return sig->id;
136     }
137     return NULL;
138     } /* gpgme_sig_get_string_attr */
139    

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26