2 Copyright (C) 2006-2022 Ben Kibbey <bjk@luxsci.net>
4 This file is part of pwmd.
6 Pwmd is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 Pwmd 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 Pwmd. If not, see <http://www.gnu.org/licenses/>.
25 #include <sys/types.h>
28 #include "pwmd-error.h"
30 #include <libxml/xmlerror.h>
46 #ifdef _POSIX2_LINE_MAX
47 #define LINE_MAX _POSIX2_LINE_MAX
56 #define _(msgid) gettext(msgid)
65 #define CLIENT_STATE_UNKNOWN 0
66 #define CLIENT_STATE_INIT 1
67 #define CLIENT_STATE_IDLE 2
68 #define CLIENT_STATE_COMMAND 3
69 #define CLIENT_STATE_DISCON 4
71 struct client_thread_s
75 pthread_mutex_t status_mutex
;
76 struct status_msg_s
*msg_queue
;
77 int status_msg_pipe
[2];
80 assuan_peercred_t peer
;
85 int send_state
; /* OPTION to receive client state msgs. */
101 xmlErrorPtr xml_error
;
103 struct client_thread_s
*thd
;
104 struct crypto_s
*crypto
;
108 long lock_timeout
; /* In tenths of a second. */
110 char *last_error
; /* ELOOP element path. */
111 unsigned char *crc
; /* Of the data file. */
112 int did_cow
; /* Have already done a CoW operation. */
113 struct bulk_cmd_s
*bulk_p
; /* For the command result set in xfer_data(). */
115 int disco
; /* Rather than thread->state to avoid lock. */
119 extern pthread_key_t thread_name_key
;
120 extern pthread_mutex_t cn_mutex
;
121 extern struct slist_s
*cn_thread_list
;
123 void log_write (const char *fmt
, ...);
124 int assuan_log_cb (assuan_context_t ctx
, void *data
, unsigned cat
,
126 gpg_error_t
send_error (assuan_context_t ctx
, gpg_error_t e
);
127 void update_client_state (struct client_s
*client
, unsigned s
);
128 gpg_error_t
lock_flock (assuan_context_t ctx
, const char *filename
, int type
,
130 void unlock_flock (int *fd
);