pwmc: Reset filename upon .open failure.
[libpwmd.git] / src / types.h
blob37a4508cc344ccbbd5538387ad328a7c0728e635
1 /*
2 Copyright (C) 2006-2016 Ben Kibbey <bjk@luxsci.net>
4 This file is part of libpwmd.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library 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 GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
21 #ifndef TYPES_H
22 #define TYPES_H
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
28 #include <libpwmd.h>
29 #include <pthread.h>
30 #include <assuan.h>
32 #ifdef WITH_SSH
33 #include "ssh.h"
34 #endif
36 #ifdef WITH_GNUTLS
37 #include "tls.h"
38 #endif
40 #ifdef ENABLE_NLS
41 #ifdef HAVE_SETLOCALE
42 #include <locale.h>
43 #endif
44 #include "gettext.h"
45 #define N_(msgid) dgettext("libpwmd", msgid)
46 #else
47 #define N_(msgid) (msgid)
48 #endif
50 #define N_ARRAY(a) (sizeof(a)/sizeof(a[0]))
52 typedef enum
54 PWMD_IPV6, PWMD_IPV4, PWMD_IP_ANY
55 } pwmd_ip_version_t;
57 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
58 struct tcp_s
60 char *host;
61 unsigned port;
62 int *fd;
63 gpg_error_t rc;
64 struct addrinfo *addrs;
65 struct addrinfo *addr;
66 pthread_cond_t dns_cond;
67 pthread_mutex_t dns_mutex;
68 #ifdef WITH_SSH
69 struct ssh_s *ssh;
70 #endif
71 #ifdef WITH_GNUTLS
72 struct tls_s *tls;
73 #endif
75 #endif
77 #define OPT_LOCK_ON_OPEN 0x0001
78 #define OPT_SIGPIPE 0x0002
80 struct pwm_s
82 assuan_context_t ctx;
83 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
84 struct tcp_s *tcp;
85 #ifdef WITH_GNUTLS
86 int tls_error;
87 #endif
88 #endif
89 /* Options set with pwmd_setopt(). */
90 pwmd_ip_version_t prot;
91 pwmd_knownhost_cb_t kh_cb;
92 int needs_passphrase;
93 char *ssh_passphrase;
94 void *kh_data;
95 int use_agent;
96 int tls_verify;
97 char *tls_priority;
98 int socket_timeout;
99 int fd;
100 int cancel;
101 int connected;
102 #ifdef WITH_PINENTRY
103 pid_t pinentry_pid; // for local pinentry timeouts
104 assuan_context_t pctx;
105 #endif
106 char *pinentry_path;
107 char *pinentry_tty;
108 char *pinentry_term;
109 char *pinentry_display;
110 char *pinentry_lcctype;
111 char *pinentry_lcmessages;
112 char *pinentry_error;
113 char *pinentry_prompt;
114 char *pinentry_desc;
115 int pinentry_tries; // local pinentry
116 int pinentry_try; // local pinentry
117 char *passphrase_hint;
118 char *passphrase_info;
119 char *filename;
120 int pinentry_timeout;
121 int current_pinentry_timeout;
122 int disable_pinentry;
123 int local_pinentry;
124 int pinentry_disabled; // for sending the disable command
125 pwmd_status_cb_t status_func;
126 void *status_data;
127 pwmd_inquire_cb_t inquire_func;
128 void *inquire_data;
129 size_t inquire_total;
130 size_t inquire_sent;
131 size_t inquire_maxlen;
132 #ifdef WITH_QUALITY
133 gpg_error_t (*_inquire_func) (void *, const char *);
134 void *_inquire_data;
135 #endif
136 char *name;
137 unsigned opts;
138 int override_inquire;
139 void *user_data;
140 unsigned version; // of pwmd
143 gpg_error_t _assuan_command (pwm_t * pwm, assuan_context_t ctx,
144 char **result, size_t * len, const char *cmd);
145 gpg_error_t _connect_finalize (pwm_t * pwm);
146 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
147 void free_tcp (pwm_t *);
148 gpg_error_t tcp_connect_common (pwm_t * pwm);
149 #endif
151 #endif