Created src/misc.[ch],ssh.[ch],pinentry.[ch].
[libpwmd.git] / src / types.h
blob0d00b5ec2d8e686ac8c306f9dc38652a1cccb967
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 ENABLE_NLS
39 #ifdef HAVE_SETLOCALE
40 #include <locale.h>
41 #endif
42 #include "gettext.h"
43 #define N_(msgid) dgettext("libpwmd", msgid)
44 #endif
46 #define N_ARRAY(a) (sizeof(a)/sizeof(a[0]))
48 typedef enum {
49 ASYNC_CMD_NONE,
50 #ifdef WITH_TCP
51 ASYNC_CMD_DNS,
52 ASYNC_CMD_CONNECT,
53 ASYNC_CMD_HOSTKEY,
54 #endif
55 ASYNC_CMD_OPEN,
56 ASYNC_CMD_OPEN2,
57 ASYNC_CMD_SAVE,
58 ASYNC_CMD_SAVE2,
59 } pwmd_async_cmd_t;
61 enum {
62 PINENTRY_OPEN,
63 PINENTRY_OPEN_FAILED,
64 PINENTRY_SAVE,
65 PINENTRY_SAVE_CONFIRM
68 #ifdef WITH_TCP
69 typedef struct {
70 char *host;
71 unsigned port;
72 char *username;
73 char *known_hosts;
74 char *identity;
75 char *identity_pub;
76 int fd;
77 gpg_error_t rc;
78 ares_channel chan;
79 int async;
80 struct hostent *he;
81 LIBSSH2_SESSION *session;
82 LIBSSH2_CHANNEL *channel;
83 int get_only;
84 char *hostkey;
85 pwmd_async_cmd_t cmd;
86 } pwmd_tcp_conn_t;
87 #endif
89 enum {
90 PWMD_V1,
91 PWMD_V2
94 struct pwm_s {
95 assuan_context_t ctx;
96 int version;
97 #ifdef WITH_TCP
98 pwmd_tcp_conn_t *tcp_conn;
99 pwmd_ip_version_t prot;
100 #endif
101 int fd;
102 pwmd_async_t state;
103 pwmd_async_cmd_t cmd;
104 char *result; // not related to anything the client can see.
105 #ifdef WITH_PINENTRY
106 pid_t pid; // for pinentry timeouts when used with ..async2().
107 assuan_context_t pctx;
108 int nb_fd; // for pwmd_open/save_async2().
109 pid_t nb_pid;
110 #endif
111 int pinentry_tries;
112 int pin_try;
113 char *pinentry_path;
114 char *pinentry_tty;
115 char *pinentry_term;
116 char *pinentry_display;
117 char *lcctype;
118 char *lcmessages;
119 char *title;
120 char *prompt;
121 char *desc;
122 char *password;
123 char *filename;
124 int pinentry_timeout;
125 pwmd_passphrase_cb_t passfunc;
126 void *passdata;
127 pwmd_status_cb_t status_func;
128 void *status_data;
129 pwmd_inquire_cb_t inquire_func;
130 void *inquire_data;
131 char *name;
134 typedef struct {
135 size_t len;
136 void *buf;
137 } membuf_t;
139 typedef struct {
140 int fd;
141 gpg_error_t error;
142 char password[ASSUAN_LINELENGTH+1];
143 } pwmd_nb_status_t;
145 gpg_error_t _assuan_command(pwm_t *pwm, assuan_context_t ctx,
146 char **result, const char *cmd)
147 __attribute__ ((visibility ("internal")));
149 gpg_error_t _socket_connect_finalize(pwm_t *pwm)
150 __attribute__ ((visibility ("internal")));
152 #endif