Line data Source code
1 : /* t-engine-info.c - Regression test for gpgme_get_engine_info.
2 : Copyright (C) 2003, 2004, 2007 g10 Code GmbH
3 :
4 : This file is part of GPGME.
5 :
6 : GPGME is free software; you can redistribute it and/or modify it
7 : under the terms of the GNU Lesser General Public License as
8 : published by the Free Software Foundation; either version 2.1 of
9 : the License, or (at your option) any later version.
10 :
11 : GPGME is distributed in the hope that it will be useful, but
12 : WITHOUT ANY WARRANTY; without even the implied warranty of
13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : Lesser General Public License for more details.
15 :
16 : You should have received a copy of the GNU Lesser General Public
17 : License along with this program; if not, write to the Free Software
18 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 : 02111-1307, USA. */
20 :
21 : #ifdef HAVE_CONFIG_H
22 : #include <config.h>
23 : #endif
24 :
25 : #include <stdlib.h>
26 : #include <stdio.h>
27 : #include <string.h>
28 :
29 : #include <gpgme.h>
30 :
31 : #define PGM "t-engine-info"
32 :
33 : static int verbose;
34 :
35 :
36 :
37 :
38 : #define fail_if_err(err) \
39 : do \
40 : { \
41 : if (err) \
42 : { \
43 : fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
44 : __FILE__, __LINE__, gpgme_strerror (err)); \
45 : exit (1); \
46 : } \
47 : } \
48 : while (0)
49 :
50 :
51 : int
52 1 : main (int argc, char **argv )
53 : {
54 1 : int last_argc = -1;
55 : gpgme_engine_info_t info;
56 : gpgme_error_t err;
57 :
58 1 : if (argc)
59 1 : { argc--; argv++; }
60 :
61 2 : while (argc && last_argc != argc )
62 : {
63 0 : last_argc = argc;
64 0 : if (!strcmp (*argv, "--"))
65 : {
66 0 : argc--; argv++;
67 0 : break;
68 : }
69 0 : else if (!strcmp (*argv, "--help"))
70 : {
71 0 : fputs ("usage: " PGM " [options]\n"
72 : "Options:\n"
73 : " --set-global-flag KEY VALUE\n",
74 : stdout);
75 0 : exit (0);
76 : }
77 0 : else if (!strcmp (*argv, "--verbose"))
78 : {
79 0 : verbose++;
80 0 : argc--; argv++;
81 : }
82 0 : else if (!strcmp (*argv, "--set-global-flag"))
83 : {
84 0 : argc--; argv++;
85 0 : if (argc < 2)
86 : {
87 0 : fprintf (stderr, PGM ": not enough arguments for option\n");
88 0 : exit (1);
89 : }
90 0 : if (gpgme_set_global_flag (argv[0], argv[1]))
91 : {
92 0 : fprintf (stderr, PGM ": gpgme_set_global_flag failed\n");
93 0 : exit (1);
94 : }
95 0 : argc--; argv++;
96 0 : argc--; argv++;
97 : }
98 0 : else if (!strncmp (*argv, "--", 2))
99 : {
100 0 : fprintf (stderr, PGM ": unknown option '%s'\n", *argv);
101 0 : exit (1);
102 : }
103 : }
104 :
105 1 : if (argc)
106 : {
107 0 : fprintf (stderr, PGM ": unexpected arguments\n");
108 0 : exit (1);
109 : }
110 :
111 1 : gpgme_check_version (NULL);
112 :
113 : {
114 1 : const char *keys[] = {"homedir",
115 : "sysconfdir",
116 : "bindir",
117 : "libexecdir",
118 : "libdir",
119 : "datadir",
120 : "localedir",
121 : "agent-socket",
122 : "agent-ssh-socket",
123 : "dirmngr-socket",
124 : "uiserver-socket",
125 : "gpgconf-name",
126 : "gpg-name",
127 : "gpgsm-name",
128 : "g13-name",
129 : "gpg-wks-client-name",
130 : NULL };
131 : const char *s;
132 : int i;
133 :
134 17 : for (i=0; keys[i]; i++)
135 16 : if ((s = gpgme_get_dirinfo (keys[i])))
136 15 : fprintf (stderr, "dirinfo: %s='%s'\n", keys[i], s);
137 : }
138 :
139 1 : err = gpgme_get_engine_info (&info);
140 1 : fail_if_err (err);
141 :
142 7 : for (; info; info = info->next)
143 31 : fprintf (stdout, "protocol=%d engine='%s' v='%s' (min='%s') home='%s'\n",
144 24 : info->protocol, info->file_name, info->version, info->req_version,
145 7 : info->home_dir? info->home_dir : "[default]");
146 :
147 1 : return 0;
148 : }
|