Add pwmd_cancel().
[libpwmd.git] / src / types.h
blob3c61e6011b232a6cd37d51cd2ca7f319badb4e45
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 <assuan.h>
30 #ifdef WITH_SSH
31 #include "ssh.h"
32 #endif
34 #ifdef WITH_GNUTLS
35 #include "tls.h"
36 #endif
38 #ifdef ENABLE_NLS
39 #ifdef HAVE_SETLOCALE
40 #include <locale.h>
41 #endif
42 #include "gettext.h"
43 #define N_(msgid) dgettext("libpwmd", msgid)
44 #else
45 #define N_(msgid) (msgid)
46 #endif
48 #define N_ARRAY(a) (sizeof(a)/sizeof(a[0]))
50 typedef enum
52 PWMD_IPV6, PWMD_IPV4, PWMD_IP_ANY
53 } pwmd_ip_version_t;
55 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
56 struct tcp_s
58 char *host;
59 unsigned port;
60 int *fd;
61 gpg_error_t rc;
62 struct addrinfo *addrs;
63 struct addrinfo *addr;
64 #ifdef WITH_SSH
65 struct ssh_s *ssh;
66 #endif
67 #ifdef WITH_GNUTLS
68 struct tls_s *tls;
69 #endif
71 #endif
73 #define OPT_LOCK_ON_OPEN 0x0001
74 #define OPT_SIGPIPE 0x0002
76 struct pwm_s
78 assuan_context_t ctx;
79 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
80 struct tcp_s *tcp;
81 #ifdef WITH_GNUTLS
82 int tls_error;
83 #endif
84 #endif
85 /* Options set with pwmd_setopt(). */
86 pwmd_ip_version_t prot;
87 pwmd_knownhost_cb_t kh_cb;
88 void *kh_data;
89 int use_agent;
90 int tls_verify;
91 int socket_timeout;
92 int fd;
93 int cancel;
94 #ifdef WITH_PINENTRY
95 pid_t pinentry_pid; // for local pinentry timeouts
96 assuan_context_t pctx;
97 #endif
98 char *pinentry_path;
99 char *pinentry_tty;
100 char *pinentry_term;
101 char *pinentry_display;
102 char *pinentry_lcctype;
103 char *pinentry_lcmessages;
104 char *pinentry_error;
105 char *pinentry_prompt;
106 char *pinentry_desc;
107 int pinentry_tries; // local pinentry
108 int pinentry_try; // local pinentry
109 char *passphrase_hint;
110 char *passphrase_info;
111 char *filename;
112 int pinentry_timeout;
113 int current_pinentry_timeout;
114 int disable_pinentry;
115 int local_pinentry;
116 int pinentry_disabled; // for sending the disable command
117 pwmd_status_cb_t status_func;
118 void *status_data;
119 pwmd_inquire_cb_t inquire_func;
120 void *inquire_data;
121 size_t inquire_total;
122 size_t inquire_sent;
123 size_t inquire_maxlen;
124 #ifdef WITH_QUALITY
125 gpg_error_t (*_inquire_func) (void *, const char *);
126 void *_inquire_data;
127 #endif
128 char *name;
129 unsigned opts;
130 int override_inquire;
131 void *user_data;
132 unsigned version; // of pwmd
135 gpg_error_t _assuan_command (pwm_t * pwm, assuan_context_t ctx,
136 char **result, size_t * len, const char *cmd);
137 gpg_error_t _connect_finalize (pwm_t * pwm);
138 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
139 void free_tcp (pwm_t *);
140 gpg_error_t tcp_connect_common (pwm_t * pwm);
141 #endif
143 #endif