d7c6bc8c569111740b17ab4eff0363f3cfe28228
[gpgme.git] / tests / gpg / t-trustlist.c
1 /* t-trustlist.c - Regression test.
2    Copyright (C) 2000 Werner Koch (dd9jn)
3    Copyright (C) 2001, 2003 g10 Code GmbH
4
5    This file is part of GPGME.
6  
7    GPGME is free software; you can redistribute it and/or modify it
8    under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11  
12    GPGME is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16  
17    You should have received a copy of the GNU General Public License
18    along with GPGME; if not, write to the Free Software Foundation,
19    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24
25 #include <gpgme.h>
26
27 \f
28 #define fail_if_err(err)                                        \
29   do                                                            \
30     {                                                           \
31       if (err)                                                  \
32         {                                                       \
33           fprintf (stderr, "%s:%d: gpgme_error_t %s\n",         \
34                    __FILE__, __LINE__, gpgme_strerror (err));   \
35           exit (1);                                             \
36         }                                                       \
37     }                                                           \
38   while (0)
39
40
41 int 
42 main (int argc, char *argv[])
43 {
44   gpgme_ctx_t ctx;
45   gpgme_error_t err;
46   gpgme_trust_item_t item;
47
48   err = gpgme_new (&ctx);
49   fail_if_err (err);
50
51   err = gpgme_op_trustlist_start (ctx, "alice", 0);
52   fail_if_err (err);
53   
54   while (!(err = gpgme_op_trustlist_next (ctx, &item)))
55     {
56       printf ("l=%d k=%s t=%d o=%s v=%s u=%s\n",
57               item->level, item->keyid, item->type, item->owner_trust,
58               item->validity, item->name);
59       gpgme_trust_item_unref (item);
60     }
61   if (err != GPGME_EOF)
62     fail_if_err (err);
63
64   gpgme_release (ctx);
65   return 0;
66 }