Resend pinentry options during PASSWD and SAVE.
[libpwmd.git] / src / types.h
bloba2862686044b1d174032a1d7109748169e83532b
1 /*
2 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
3 Ben Kibbey <bjk@luxsci.net>
5 This file is part of libpwmd.
7 Libpwmd is free software: you can redistribute it and/or modify
8 it 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.
12 Libpwmd is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Libpwmd. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef TYPES_H
21 #define TYPES_H
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
27 #include <libpwmd.h>
28 #include <pthread.h>
29 #include <assuan.h>
31 #ifdef WITH_SSH
32 #include "ssh.h"
33 #endif
35 #ifdef WITH_GNUTLS
36 #include "tls.h"
37 #endif
39 #ifdef ENABLE_NLS
40 #ifdef HAVE_SETLOCALE
41 #include <locale.h>
42 #endif
43 #include "gettext.h"
44 #define N_(msgid) dgettext("libpwmd", msgid)
45 #else
46 #define N_(msgid) (msgid)
47 #endif
49 #define N_ARRAY(a) (sizeof(a)/sizeof(a[0]))
51 typedef enum
53 PWMD_IPV6, PWMD_IPV4, PWMD_IP_ANY
54 } pwmd_ip_version_t;
56 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
57 struct tcp_s
59 char *host;
60 unsigned port;
61 int *fd;
62 gpg_error_t rc;
63 struct addrinfo *addrs;
64 struct addrinfo *addr;
65 pthread_cond_t dns_cond;
66 pthread_mutex_t dns_mutex;
67 #ifdef WITH_SSH
68 struct ssh_s *ssh;
69 #endif
70 #ifdef WITH_GNUTLS
71 struct tls_s *tls;
72 #endif
74 #endif
76 #define OPT_LOCK_ON_OPEN 0x0001
77 #define OPT_SIGPIPE 0x0002
79 struct pwm_s
81 assuan_context_t ctx;
82 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
83 struct tcp_s *tcp;
84 #ifdef WITH_GNUTLS
85 int tls_error;
86 #endif
87 #endif
88 /* Options set with pwmd_setopt(). */
89 pwmd_ip_version_t prot;
90 pwmd_knownhost_cb_t kh_cb;
91 void *kh_data;
92 int use_agent;
93 int tls_verify;
94 int socket_timeout;
95 int fd;
96 int cancel;
97 int connected;
98 #ifdef WITH_PINENTRY
99 pid_t pinentry_pid; // for local pinentry timeouts
100 assuan_context_t pctx;
101 #endif
102 char *pinentry_path;
103 char *pinentry_tty;
104 char *pinentry_term;
105 char *pinentry_display;
106 char *pinentry_lcctype;
107 char *pinentry_lcmessages;
108 char *pinentry_error;
109 char *pinentry_prompt;
110 char *pinentry_desc;
111 int pinentry_tries; // local pinentry
112 int pinentry_try; // local pinentry
113 char *passphrase_hint;
114 char *passphrase_info;
115 char *filename;
116 int pinentry_timeout;
117 int current_pinentry_timeout;
118 int disable_pinentry;
119 int local_pinentry;
120 int pinentry_disabled; // for sending the disable command
121 pwmd_status_cb_t status_func;
122 void *status_data;
123 pwmd_inquire_cb_t inquire_func;
124 void *inquire_data;
125 size_t inquire_total;
126 size_t inquire_sent;
127 size_t inquire_maxlen;
128 #ifdef WITH_QUALITY
129 gpg_error_t (*_inquire_func) (void *, const char *);
130 void *_inquire_data;
131 #endif
132 char *name;
133 unsigned opts;
134 int override_inquire;
135 void *user_data;
136 unsigned version; // of pwmd
139 gpg_error_t _assuan_command (pwm_t * pwm, assuan_context_t ctx,
140 char **result, size_t * len, const char *cmd);
141 gpg_error_t _connect_finalize (pwm_t * pwm);
142 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
143 void free_tcp (pwm_t *);
144 gpg_error_t tcp_connect_common (pwm_t * pwm);
145 #endif
147 #endif