Added pwmd_getpin(). This won't send any commands to the server. May be
[libpwmd.git] / src / types.h
blob97ddb1bc72ae6ffa4b0834d8bc4ddbef74e826eb
1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
2 /*
3 Copyright (C) 2006-2009 Ben Kibbey <bjk@luxsci.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02110-1301 USA
19 #ifndef TYPES_H
20 #define TYPES_H
22 #include <assuan.h>
23 #include <libpwmd.h>
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
29 #ifdef WITH_TCP
30 #include <libssh2.h>
31 #ifndef DNS_USE_GETTIMEOFDAY_FOR_ID
32 #define DNS_USE_GETTIMEOFDAY_FOR_ID 1
33 #endif
34 #include <ares.h>
35 #include <arpa/nameser.h>
36 #endif
38 #ifdef WITH_LIBPTH
39 #include <pth.h>
40 #endif
42 #ifdef ENABLE_NLS
43 #ifdef HAVE_SETLOCALE
44 #include <locale.h>
45 #endif
46 #include "gettext.h"
47 #define N_(msgid) dgettext("libpwmd", msgid)
48 #endif
50 #define N_ARRAY(a) (sizeof(a)/sizeof(a[0]))
52 typedef enum {
53 ASYNC_CMD_NONE,
54 #ifdef WITH_TCP
55 ASYNC_CMD_DNS,
56 ASYNC_CMD_CONNECT,
57 ASYNC_CMD_HOSTKEY,
58 #endif
59 ASYNC_CMD_OPEN,
60 ASYNC_CMD_OPEN2,
61 ASYNC_CMD_SAVE,
62 ASYNC_CMD_SAVE2,
63 } pwmd_async_cmd_t;
65 #ifdef WITH_TCP
66 typedef struct {
67 char *host;
68 unsigned port;
69 char *username;
70 char *known_hosts;
71 char *identity;
72 char *identity_pub;
73 int fd;
74 gpg_error_t rc;
75 ares_channel chan;
76 int async;
77 struct hostent *he;
78 LIBSSH2_SESSION *session;
79 LIBSSH2_CHANNEL *channel;
80 char *hostkey;
81 pwmd_async_cmd_t cmd;
82 } pwmd_tcp_conn_t;
83 #endif
85 enum {
86 PWMD_V1,
87 PWMD_V2
90 struct pwm_s {
91 assuan_context_t ctx;
92 int version;
93 #ifdef WITH_TCP
94 pwmd_tcp_conn_t *tcp_conn;
95 pwmd_ip_version_t prot;
96 #endif
97 int fd;
98 pwmd_async_t state;
99 pwmd_async_cmd_t cmd;
100 pwmd_async_cmd_t lastcmd;
101 char *result; // not related to anything the client can see.
102 #ifdef WITH_PINENTRY
103 pid_t pid; // for pinentry timeouts when used with ..async2().
104 assuan_context_t pctx;
105 int nb_fd; // for pwmd_open/save_async2().
106 pid_t nb_pid;
107 char *_password;
108 #endif
109 int pinentry_tries;
110 int pin_try;
111 char *pinentry_path;
112 char *pinentry_tty;
113 char *pinentry_term;
114 char *pinentry_display;
115 char *lcctype;
116 char *lcmessages;
117 char *title;
118 char *prompt;
119 char *desc;
120 char *password;
121 char *filename;
122 int pinentry_timeout;
123 pwmd_passphrase_cb_t passfunc;
124 void *passdata;
125 pwmd_status_cb_t status_func;
126 void *status_data;
127 pwmd_inquire_cb_t inquire_func;
128 void *inquire_data;
129 #ifdef WITH_QUALITY
130 int (*_inquire_func)(void *, const char *);
131 void *_inquire_data;
132 #endif
133 char *name;
136 typedef struct {
137 size_t len;
138 void *buf;
139 } membuf_t;
141 typedef struct {
142 int fd;
143 gpg_error_t error;
144 char password[ASSUAN_LINELENGTH+1];
145 } pwmd_nb_status_t;
147 gpg_error_t _assuan_command(pwm_t *pwm, assuan_context_t ctx,
148 char **result, const char *cmd)
149 __attribute__ ((visibility ("hidden")));
151 gpg_error_t _connect_finalize(pwm_t *pwm)
152 __attribute__ ((visibility ("hidden")));
154 #endif