2 Copyright (C) 2006-2023 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/>.
26 #include <sys/types.h>
30 #ifdef HAVE_NETINET_IN_H
31 #include <netinet/in.h>
37 #define BACKTRACE_COUNT 64
38 #define BACKTRACE(fn) do { \
41 void *buffer[BACKTRACE_COUNT]; \
42 nptrs = backtrace(buffer, BACKTRACE_COUNT); \
43 snprintf(tmp, sizeof(tmp), "%s/crash-%u.log", homedir, getpid());\
44 int fd = open(tmp,O_WRONLY|O_CREAT|O_TRUNC, 0600); \
46 backtrace_symbols_fd(buffer, nptrs, fd); \
52 #define log_write0 log_write
54 #define log_write1(...) do { \
56 log_write(__VA_ARGS__); \
59 #define log_write2(...) do { \
61 log_write(__VA_ARGS__); \
75 gpg_error_t (*func
) (void *data
, void *value
);
84 extern char *home_directory
;
87 gpg_error_t
parse_options (char **line
, struct argv_s
*args
[], void *data
,
89 int valid_filename (const char *filename
);
90 char *expand_homedir (char *str
);
91 char *bin2hex (const unsigned char *data
, size_t len
);
92 char *gnupg_escape (const char *str
);
93 char *strip_texi_and_wrap (const char *str
, int html
);
94 void free_key (void *data
);
95 gpg_error_t
create_thread (void *(*cb
) (void *), void *data
,
96 pthread_t
* tid
, int detached
);
97 void release_mutex_cb (void *arg
);
98 void close_fd_cb (void *arg
);
99 gpg_error_t
get_checksum (const char *filename
, unsigned char **r_crc
,
101 gpg_error_t
get_checksum_memory (void *data
, size_t size
,
102 unsigned char **r_crc
, size_t *r_crclen
);
103 char *get_username (uid_t
);
104 char *get_home_dir ();
105 struct passwd
*get_pwd_struct (const char *user
, uid_t uid
, struct passwd
*,
106 char **buf
, gpg_error_t
*);
107 wchar_t *str_to_wchar (const char *str
);
108 void *get_in_addr (struct sockaddr
*sa
);
109 gpg_error_t
open_check_file (const char *, int *, struct stat
*, int);