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

Annotation of /trunk/MyGPGME/implist.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Mon Jan 31 11:02:21 2005 UTC (20 years, 1 month ago) by twoaday
File MIME type: text/plain
File size: 2649 byte(s)
WinPT initial checkin.


1 twoaday 2 /* implist.c - list keys from a file
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     #include <sys/types.h>
25     #include <ctype.h>
26    
27     #include "openpgp.h"
28     #include "util.h"
29     #include "context.h"
30     #include "context.h"
31     #include "key.h"
32     #include "ops.h"
33    
34    
35     void
36     gpgme_implist_create_revcert( gpgme_key_t *r_key, gpgme_revcert_t cert, gpgme_key_t pubk )
37     {
38     size_t size = 1, len = 0;
39     const char *fmt_reason = "Revocation cert; Code %02X; Reason %s";
40     const char *fmt = "Revocation cert; Code %02X";
41     const char * s = "Key revocation certificate";
42     gpgme_key_t key;
43    
44     if( !r_key || !pubk )
45     return;
46    
47     _gpgme_key_new( &key );
48    
49     if( !cert ) {
50     key->keys.key_algo = 0;
51     key->keys.key_len = 0;
52     key->keys.timestamp = 0;
53     memset( key->keys.keyid, '0', sizeof key->keys.keyid );
54     key->uids = calloc (1, sizeof *key->uids + strlen (s) +1);
55     if (!key->uids)
56     return;
57     strcpy (key->uids->name, s);
58     return;
59     }
60    
61     /* fixme: add the public key to the gpgme_revcert_t */
62     key->keys.key_algo = pubk->keys.key_algo;
63     /*key->created = pubk->keys.timestamp;*/
64     key->keys.key_len = pubk->keys.key_len;
65     key->keys.timestamp = cert->timestamp;
66     strcpy( key->keys.keyid, cert->keyid );
67     safe_free( key->uids );
68     if( cert->reason ) {
69     size += strlen( cert->reason );
70     len = strlen( fmt_reason ) + size;
71     key->uids = calloc( 1, sizeof *key->uids + len + 1 );
72     if( key->uids )
73     _snprintf( key->uids->name, len, fmt_reason, cert->code, cert->reason );
74     }
75     else {
76     len = strlen( fmt ) + size;
77     key->uids = calloc( 1, sizeof *key->uids + len + 1 );
78     if( key->uids->name )
79     _snprintf( key->uids->name, len, fmt, cert->code );
80     }
81     *r_key = key;
82     } /* gpgme_implist_create_revcert */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26