added GPG files
This commit is contained in:
676
gpg/include/assuan.h
Normal file
676
gpg/include/assuan.h
Normal file
@@ -0,0 +1,676 @@
|
||||
/* assuan.h - Definitions for the Assuan IPC library -*- c -*-
|
||||
* Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2001-2017 g10 Code GmbH
|
||||
*
|
||||
* This file is part of Assuan.
|
||||
*
|
||||
* Assuan is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Assuan is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1+
|
||||
*
|
||||
* Do not edit. Generated from assuan.h.in by mkheader for mingw32.
|
||||
*/
|
||||
|
||||
#ifndef ASSUAN_H
|
||||
#define ASSUAN_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifndef _ASSUAN_NO_SOCKET_WRAPPER
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif /*!_ASSUAN_NO_SOCKET_WRAPPER*/
|
||||
|
||||
typedef void *assuan_msghdr_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef long ssize_t;
|
||||
typedef int pid_t;
|
||||
#endif
|
||||
|
||||
|
||||
#include <gpg-error.h>
|
||||
|
||||
/* Compile time configuration:
|
||||
|
||||
#define _ASSUAN_NO_SOCKET_WRAPPER
|
||||
|
||||
Do not include the definitions for the socket wrapper feature. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The version of this header should match the one of the library. Do
|
||||
not use this symbol in your application; use assuan_check_version
|
||||
instead. */
|
||||
#define ASSUAN_VERSION "2.5.1"
|
||||
|
||||
/* The version number of this header. It may be used to handle minor
|
||||
API incompatibilities. */
|
||||
#define ASSUAN_VERSION_NUMBER 0x020501
|
||||
|
||||
|
||||
/* Check for compiler features. */
|
||||
#if __GNUC__
|
||||
#define _ASSUAN_GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if _ASSUAN_GCC_VERSION > 30100
|
||||
#define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef _ASSUAN_DEPRECATED
|
||||
#define _ASSUAN_DEPRECATED
|
||||
#endif
|
||||
|
||||
|
||||
#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
|
||||
|
||||
struct assuan_context_s;
|
||||
typedef struct assuan_context_s *assuan_context_t;
|
||||
|
||||
/* Because we use system handles and not libc low level file
|
||||
descriptors on W32, we need to declare them as HANDLE (which
|
||||
actually is a plain pointer). This is required to eventually
|
||||
support 64 bit Windows systems. */
|
||||
typedef void *assuan_fd_t;
|
||||
#define ASSUAN_INVALID_FD ((void*)(-1))
|
||||
#define ASSUAN_INVALID_PID ((pid_t) -1)
|
||||
static GPG_ERR_INLINE assuan_fd_t
|
||||
assuan_fd_from_posix_fd (int fd)
|
||||
{
|
||||
if (fd < 0)
|
||||
return ASSUAN_INVALID_FD;
|
||||
else
|
||||
return (assuan_fd_t) _get_osfhandle (fd);
|
||||
}
|
||||
|
||||
|
||||
assuan_fd_t assuan_fdopen (int fd);
|
||||
|
||||
|
||||
/* Assuan features an emulation of Unix domain sockets based on local
|
||||
TCP connections. To implement access permissions based on file
|
||||
permissions a nonce is used which is expected by the server as the
|
||||
first bytes received. This structure is used by the server to save
|
||||
the nonce created initially by bind. */
|
||||
struct assuan_sock_nonce_s
|
||||
{
|
||||
size_t length;
|
||||
char nonce[16];
|
||||
};
|
||||
typedef struct assuan_sock_nonce_s assuan_sock_nonce_t;
|
||||
|
||||
/* Define the Unix domain socket structure for Windows. */
|
||||
#ifndef _ASSUAN_NO_SOCKET_WRAPPER
|
||||
# ifndef AF_LOCAL
|
||||
# define AF_LOCAL AF_UNIX
|
||||
# endif
|
||||
# ifndef EADDRINUSE
|
||||
# define EADDRINUSE WSAEADDRINUSE
|
||||
# endif
|
||||
struct sockaddr_un
|
||||
{
|
||||
short sun_family;
|
||||
unsigned short sun_port;
|
||||
struct in_addr sun_addr;
|
||||
char sun_path[108-2-4];
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Global interface. */
|
||||
|
||||
struct assuan_malloc_hooks
|
||||
{
|
||||
void *(*malloc) (size_t cnt);
|
||||
void *(*realloc) (void *ptr, size_t cnt);
|
||||
void (*free) (void *ptr);
|
||||
};
|
||||
typedef struct assuan_malloc_hooks *assuan_malloc_hooks_t;
|
||||
|
||||
/* Categories for log messages. */
|
||||
#define ASSUAN_LOG_INIT 1
|
||||
#define ASSUAN_LOG_CTX 2
|
||||
#define ASSUAN_LOG_ENGINE 3
|
||||
#define ASSUAN_LOG_DATA 4
|
||||
#define ASSUAN_LOG_SYSIO 5
|
||||
#define ASSUAN_LOG_CONTROL 8
|
||||
|
||||
/* If MSG is NULL, return true/false depending on if this category is
|
||||
logged. This is used to probe before expensive log message
|
||||
generation (buffer dumps). */
|
||||
typedef int (*assuan_log_cb_t) (assuan_context_t ctx, void *hook,
|
||||
unsigned int cat, const char *msg);
|
||||
|
||||
/* Return or check the version number. */
|
||||
const char *assuan_check_version (const char *req_version);
|
||||
|
||||
/* Set the default gpg error source. */
|
||||
void assuan_set_gpg_err_source (gpg_err_source_t errsource);
|
||||
|
||||
/* Get the default gpg error source. */
|
||||
gpg_err_source_t assuan_get_gpg_err_source (void);
|
||||
|
||||
|
||||
/* Set the default malloc hooks. */
|
||||
void assuan_set_malloc_hooks (assuan_malloc_hooks_t malloc_hooks);
|
||||
|
||||
/* Get the default malloc hooks. */
|
||||
assuan_malloc_hooks_t assuan_get_malloc_hooks (void);
|
||||
|
||||
|
||||
/* Set the default log callback handler. */
|
||||
void assuan_set_log_cb (assuan_log_cb_t log_cb, void *log_cb_data);
|
||||
|
||||
/* Get the default log callback handler. */
|
||||
void assuan_get_log_cb (assuan_log_cb_t *log_cb, void **log_cb_data);
|
||||
|
||||
|
||||
/* Create a new Assuan context. The initial parameters are all needed
|
||||
in the creation of the context. */
|
||||
gpg_error_t assuan_new_ext (assuan_context_t *ctx, gpg_err_source_t errsource,
|
||||
assuan_malloc_hooks_t malloc_hooks,
|
||||
assuan_log_cb_t log_cb, void *log_cb_data);
|
||||
|
||||
/* Create a new context with default arguments. */
|
||||
gpg_error_t assuan_new (assuan_context_t *ctx);
|
||||
|
||||
/* Release all resources associated with the given context. */
|
||||
void assuan_release (assuan_context_t ctx);
|
||||
|
||||
/* Release the memory at PTR using the allocation handler of the
|
||||
context CTX. This is a convenience function. */
|
||||
void assuan_free (assuan_context_t ctx, void *ptr);
|
||||
|
||||
|
||||
/* Set user-data in a context. */
|
||||
void assuan_set_pointer (assuan_context_t ctx, void *pointer);
|
||||
|
||||
/* Get user-data in a context. */
|
||||
void *assuan_get_pointer (assuan_context_t ctx);
|
||||
|
||||
|
||||
/* Definitions of flags for assuan_set_flag(). */
|
||||
typedef unsigned int assuan_flag_t;
|
||||
|
||||
/* When using a pipe server, by default Assuan will wait for the
|
||||
forked process to die in assuan_release. In certain cases this
|
||||
is not desirable. By setting this flag, the waitpid will be
|
||||
skipped and the caller is responsible to cleanup a forked
|
||||
process. */
|
||||
#define ASSUAN_NO_WAITPID 1
|
||||
/* This flag indicates whether Assuan logging is in confidential mode.
|
||||
You can use assuan_{begin,end}_condidential to change the mode. */
|
||||
#define ASSUAN_CONFIDENTIAL 2
|
||||
/* This flag suppresses fix up of signal handlers for pipes. */
|
||||
#define ASSUAN_NO_FIXSIGNALS 3
|
||||
/* This flag changes assuan_transact to return comment lines via the
|
||||
status callback. The default is to skip comment lines. */
|
||||
#define ASSUAN_CONVEY_COMMENTS 4
|
||||
/* This flag disables logging for one context. */
|
||||
#define ASSUAN_NO_LOGGING 5
|
||||
/* This flag forces a connection close. */
|
||||
#define ASSUAN_FORCE_CLOSE 6
|
||||
|
||||
/* For context CTX, set the flag FLAG to VALUE. Values for flags
|
||||
are usually 1 or 0 but certain flags might allow for other values;
|
||||
see the description of the type assuan_flag_t for details. */
|
||||
void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value);
|
||||
|
||||
/* Return the VALUE of FLAG in context CTX. */
|
||||
int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag);
|
||||
|
||||
|
||||
/* Same as assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 1). */
|
||||
void assuan_begin_confidential (assuan_context_t ctx);
|
||||
|
||||
/* Same as assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 0). */
|
||||
void assuan_end_confidential (assuan_context_t ctx);
|
||||
|
||||
|
||||
/* Direction values for assuan_set_io_monitor. */
|
||||
#define ASSUAN_IO_FROM_PEER 0
|
||||
#define ASSUAN_IO_TO_PEER 1
|
||||
|
||||
/* Return flags of I/O monitor. */
|
||||
#define ASSUAN_IO_MONITOR_NOLOG 1
|
||||
#define ASSUAN_IO_MONITOR_IGNORE 2
|
||||
|
||||
/* The IO monitor gets to see all I/O on the context, and can return
|
||||
ASSUAN_IO_MONITOR_* bits to control actions on it. */
|
||||
typedef unsigned int (*assuan_io_monitor_t) (assuan_context_t ctx, void *hook,
|
||||
int inout, const char *line,
|
||||
size_t linelen);
|
||||
|
||||
/* Set the IO monitor function. */
|
||||
void assuan_set_io_monitor (assuan_context_t ctx,
|
||||
assuan_io_monitor_t io_monitor, void *hook_data);
|
||||
|
||||
|
||||
#define ASSUAN_SYSTEM_HOOKS_VERSION 2
|
||||
#define ASSUAN_SPAWN_DETACHED 128
|
||||
struct assuan_system_hooks
|
||||
{
|
||||
/* Always set to ASSUAN_SYTEM_HOOKS_VERSION. */
|
||||
int version;
|
||||
|
||||
/* Sleep for the given number of microseconds. */
|
||||
void (*usleep) (assuan_context_t ctx, unsigned int usec);
|
||||
|
||||
/* Create a pipe with an inheritable end. */
|
||||
int (*pipe) (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx);
|
||||
|
||||
/* Close the given file descriptor, created with _assuan_pipe or one
|
||||
of the socket functions. */
|
||||
int (*close) (assuan_context_t ctx, assuan_fd_t fd);
|
||||
|
||||
|
||||
ssize_t (*read) (assuan_context_t ctx, assuan_fd_t fd, void *buffer,
|
||||
size_t size);
|
||||
ssize_t (*write) (assuan_context_t ctx, assuan_fd_t fd,
|
||||
const void *buffer, size_t size);
|
||||
|
||||
int (*recvmsg) (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg,
|
||||
int flags);
|
||||
int (*sendmsg) (assuan_context_t ctx, assuan_fd_t fd,
|
||||
const assuan_msghdr_t msg, int flags);
|
||||
|
||||
/* If NAME is NULL, don't exec, just fork. FD_CHILD_LIST is
|
||||
modified to reflect the value of the FD in the peer process (on
|
||||
Windows). */
|
||||
int (*spawn) (assuan_context_t ctx, pid_t *r_pid, const char *name,
|
||||
const char **argv,
|
||||
assuan_fd_t fd_in, assuan_fd_t fd_out,
|
||||
assuan_fd_t *fd_child_list,
|
||||
void (*atfork) (void *opaque, int reserved),
|
||||
void *atforkvalue, unsigned int flags);
|
||||
|
||||
/* If action is 0, like waitpid. If action is 1, just release the PID? */
|
||||
pid_t (*waitpid) (assuan_context_t ctx, pid_t pid,
|
||||
int action, int *status, int options);
|
||||
int (*socketpair) (assuan_context_t ctx, int _namespace, int style,
|
||||
int protocol, assuan_fd_t filedes[2]);
|
||||
int (*socket) (assuan_context_t ctx, int _namespace, int style, int protocol);
|
||||
int (*connect) (assuan_context_t ctx, int sock, struct sockaddr *addr, socklen_t length);
|
||||
};
|
||||
typedef struct assuan_system_hooks *assuan_system_hooks_t;
|
||||
|
||||
|
||||
/* Configuration of the default log handler. */
|
||||
|
||||
/* Set the prefix to be used at the start of a line emitted by assuan
|
||||
on the log stream. The default is the empty string. Note, that
|
||||
this function is not thread-safe and should in general be used
|
||||
right at startup. */
|
||||
void assuan_set_assuan_log_prefix (const char *text);
|
||||
|
||||
/* Return a prefix to be used at the start of a line emitted by assuan
|
||||
on the log stream. The default implementation returns the empty
|
||||
string, i.e. "" */
|
||||
const char *assuan_get_assuan_log_prefix (void);
|
||||
|
||||
/* Global default log stream. */
|
||||
void assuan_set_assuan_log_stream (FILE *fp);
|
||||
|
||||
/* Set the per context log stream for the default log handler. */
|
||||
void assuan_set_log_stream (assuan_context_t ctx, FILE *fp);
|
||||
|
||||
|
||||
typedef gpg_error_t (*assuan_handler_t) (assuan_context_t, char *);
|
||||
|
||||
/*-- assuan-handler.c --*/
|
||||
gpg_error_t assuan_register_command (assuan_context_t ctx,
|
||||
const char *cmd_string,
|
||||
assuan_handler_t handler,
|
||||
const char *help_string);
|
||||
gpg_error_t assuan_register_pre_cmd_notify (assuan_context_t ctx,
|
||||
gpg_error_t (*fnc)(assuan_context_t, const char *cmd));
|
||||
gpg_error_t assuan_register_post_cmd_notify (assuan_context_t ctx,
|
||||
void (*fnc)(assuan_context_t,
|
||||
gpg_error_t));
|
||||
gpg_error_t assuan_register_bye_notify (assuan_context_t ctx,
|
||||
assuan_handler_t handler);
|
||||
gpg_error_t assuan_register_reset_notify (assuan_context_t ctx,
|
||||
assuan_handler_t handler);
|
||||
gpg_error_t assuan_register_cancel_notify (assuan_context_t ctx,
|
||||
assuan_handler_t handler);
|
||||
gpg_error_t assuan_register_input_notify (assuan_context_t ctx,
|
||||
assuan_handler_t handler);
|
||||
gpg_error_t assuan_register_output_notify (assuan_context_t ctx,
|
||||
assuan_handler_t handler);
|
||||
|
||||
gpg_error_t assuan_register_option_handler (assuan_context_t ctx,
|
||||
gpg_error_t (*fnc)(assuan_context_t,
|
||||
const char*,
|
||||
const char*));
|
||||
|
||||
gpg_error_t assuan_process (assuan_context_t ctx);
|
||||
gpg_error_t assuan_process_next (assuan_context_t ctx, int *done);
|
||||
gpg_error_t assuan_process_done (assuan_context_t ctx, gpg_error_t rc);
|
||||
int assuan_get_active_fds (assuan_context_t ctx, int what,
|
||||
assuan_fd_t *fdarray, int fdarraysize);
|
||||
|
||||
const char *assuan_get_command_name (assuan_context_t ctx);
|
||||
|
||||
FILE *assuan_get_data_fp (assuan_context_t ctx);
|
||||
gpg_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line);
|
||||
gpg_error_t assuan_write_status (assuan_context_t ctx,
|
||||
const char *keyword, const char *text);
|
||||
|
||||
/* Negotiate a file descriptor. If LINE contains "FD=N", returns N
|
||||
assuming a local file descriptor. If LINE contains "FD" reads a
|
||||
file descriptor via CTX and stores it in *RDF (the CTX must be
|
||||
capable of passing file descriptors). Under W32 the returned FD is
|
||||
a libc-type one. */
|
||||
gpg_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line,
|
||||
assuan_fd_t *rfd);
|
||||
|
||||
|
||||
/*-- assuan-listen.c --*/
|
||||
gpg_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line);
|
||||
gpg_error_t assuan_accept (assuan_context_t ctx);
|
||||
assuan_fd_t assuan_get_input_fd (assuan_context_t ctx);
|
||||
assuan_fd_t assuan_get_output_fd (assuan_context_t ctx);
|
||||
gpg_error_t assuan_close_input_fd (assuan_context_t ctx);
|
||||
gpg_error_t assuan_close_output_fd (assuan_context_t ctx);
|
||||
|
||||
|
||||
/*-- assuan-pipe-server.c --*/
|
||||
gpg_error_t assuan_init_pipe_server (assuan_context_t ctx,
|
||||
assuan_fd_t filedes[2]);
|
||||
|
||||
/*-- assuan-socket-server.c --*/
|
||||
#define ASSUAN_SOCKET_SERVER_FDPASSING 1
|
||||
#define ASSUAN_SOCKET_SERVER_ACCEPTED 2
|
||||
gpg_error_t assuan_init_socket_server (assuan_context_t ctx,
|
||||
assuan_fd_t listen_fd,
|
||||
unsigned int flags);
|
||||
void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce);
|
||||
|
||||
/*-- assuan-pipe-connect.c --*/
|
||||
#define ASSUAN_PIPE_CONNECT_FDPASSING 1
|
||||
#define ASSUAN_PIPE_CONNECT_DETACHED 128
|
||||
gpg_error_t assuan_pipe_connect (assuan_context_t ctx,
|
||||
const char *name,
|
||||
const char *argv[],
|
||||
assuan_fd_t *fd_child_list,
|
||||
void (*atfork) (void *, int),
|
||||
void *atforkvalue,
|
||||
unsigned int flags);
|
||||
|
||||
/*-- assuan-socket-connect.c --*/
|
||||
#define ASSUAN_SOCKET_CONNECT_FDPASSING 1
|
||||
gpg_error_t assuan_socket_connect (assuan_context_t ctx, const char *name,
|
||||
pid_t server_pid, unsigned int flags);
|
||||
|
||||
/*-- assuan-socket-connect.c --*/
|
||||
gpg_error_t assuan_socket_connect_fd (assuan_context_t ctx, int fd,
|
||||
unsigned int flags);
|
||||
|
||||
/*-- context.c --*/
|
||||
pid_t assuan_get_pid (assuan_context_t ctx);
|
||||
struct _assuan_peercred
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* Empty struct not allowed on some compilers. */
|
||||
unsigned int _dummy;
|
||||
#else
|
||||
pid_t pid;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
#endif
|
||||
};
|
||||
typedef struct _assuan_peercred *assuan_peercred_t;
|
||||
|
||||
gpg_error_t assuan_get_peercred (assuan_context_t ctx,
|
||||
assuan_peercred_t *peercred);
|
||||
|
||||
|
||||
|
||||
/* Client interface. */
|
||||
#define ASSUAN_RESPONSE_ERROR 0
|
||||
#define ASSUAN_RESPONSE_OK 1
|
||||
#define ASSUAN_RESPONSE_DATA 2
|
||||
#define ASSUAN_RESPONSE_INQUIRE 3
|
||||
#define ASSUAN_RESPONSE_STATUS 4
|
||||
#define ASSUAN_RESPONSE_END 5
|
||||
#define ASSUAN_RESPONSE_COMMENT 6
|
||||
typedef int assuan_response_t;
|
||||
|
||||
/* This already de-escapes data lines. */
|
||||
gpg_error_t assuan_client_read_response (assuan_context_t ctx,
|
||||
char **line, int *linelen);
|
||||
|
||||
gpg_error_t assuan_client_parse_response (assuan_context_t ctx,
|
||||
char *line, int linelen,
|
||||
assuan_response_t *response,
|
||||
int *off);
|
||||
|
||||
/*-- assuan-client.c --*/
|
||||
gpg_error_t
|
||||
assuan_transact (assuan_context_t ctx,
|
||||
const char *command,
|
||||
gpg_error_t (*data_cb)(void *, const void *, size_t),
|
||||
void *data_cb_arg,
|
||||
gpg_error_t (*inquire_cb)(void*, const char *),
|
||||
void *inquire_cb_arg,
|
||||
gpg_error_t (*status_cb)(void*, const char *),
|
||||
void *status_cb_arg);
|
||||
|
||||
|
||||
/*-- assuan-inquire.c --*/
|
||||
gpg_error_t assuan_inquire (assuan_context_t ctx, const char *keyword,
|
||||
unsigned char **r_buffer, size_t *r_length,
|
||||
size_t maxlen);
|
||||
gpg_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword,
|
||||
size_t maxlen,
|
||||
gpg_error_t (*cb) (void *cb_data,
|
||||
gpg_error_t rc,
|
||||
unsigned char *buf,
|
||||
size_t buf_len),
|
||||
void *cb_data);
|
||||
/*-- assuan-buffer.c --*/
|
||||
gpg_error_t assuan_read_line (assuan_context_t ctx,
|
||||
char **line, size_t *linelen);
|
||||
int assuan_pending_line (assuan_context_t ctx);
|
||||
gpg_error_t assuan_write_line (assuan_context_t ctx, const char *line);
|
||||
gpg_error_t assuan_send_data (assuan_context_t ctx,
|
||||
const void *buffer, size_t length);
|
||||
|
||||
/* The file descriptor must be pending before assuan_receivefd is
|
||||
called. This means that assuan_sendfd should be called *before* the
|
||||
trigger is sent (normally via assuan_write_line ("INPUT FD")). */
|
||||
gpg_error_t assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd);
|
||||
gpg_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd);
|
||||
|
||||
|
||||
/*-- assuan-util.c --*/
|
||||
gpg_error_t assuan_set_error (assuan_context_t ctx, gpg_error_t err,
|
||||
const char *text);
|
||||
|
||||
|
||||
|
||||
/*-- assuan-socket.c --*/
|
||||
|
||||
/* This flag is used with assuan_sock_connect_byname to
|
||||
connect via SOCKS. */
|
||||
#define ASSUAN_SOCK_SOCKS 1
|
||||
/* This flag is used with assuan_sock_connect_byname to force a
|
||||
connection via Tor even if the socket subsystem has not been
|
||||
swicthed into Tor mode. This flags overrides ASSUAN_SOCK_SOCKS. */
|
||||
#define ASSUAN_SOCK_TOR 2
|
||||
|
||||
/* These are socket wrapper functions to support an emulation of Unix
|
||||
domain sockets on Windows W32. */
|
||||
gpg_error_t assuan_sock_init (void);
|
||||
void assuan_sock_deinit (void);
|
||||
int assuan_sock_close (assuan_fd_t fd);
|
||||
assuan_fd_t assuan_sock_new (int domain, int type, int proto);
|
||||
int assuan_sock_set_flag (assuan_fd_t sockfd, const char *name, int value);
|
||||
int assuan_sock_get_flag (assuan_fd_t sockfd, const char *name, int *r_value);
|
||||
int assuan_sock_connect (assuan_fd_t sockfd,
|
||||
struct sockaddr *addr, int addrlen);
|
||||
assuan_fd_t assuan_sock_connect_byname (const char *host, unsigned short port,
|
||||
int reserved,
|
||||
const char *credentials,
|
||||
unsigned int flags);
|
||||
int assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen);
|
||||
int assuan_sock_set_sockaddr_un (const char *fname, struct sockaddr *addr,
|
||||
int *r_redirected);
|
||||
int assuan_sock_get_nonce (struct sockaddr *addr, int addrlen,
|
||||
assuan_sock_nonce_t *nonce);
|
||||
int assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce);
|
||||
void assuan_sock_set_system_hooks (assuan_system_hooks_t system_hooks);
|
||||
|
||||
|
||||
/* Set the default system callbacks. This is irreversible. */
|
||||
void assuan_set_system_hooks (assuan_system_hooks_t system_hooks);
|
||||
|
||||
/* Set the per context system callbacks. This is irreversible. */
|
||||
void assuan_ctx_set_system_hooks (assuan_context_t ctx,
|
||||
assuan_system_hooks_t system_hooks);
|
||||
|
||||
/* Change the system hooks for the socket interface.
|
||||
* This is not thread-safe. */
|
||||
void assuan_sock_set_system_hooks (assuan_system_hooks_t system_hooks);
|
||||
|
||||
void __assuan_usleep (assuan_context_t ctx, unsigned int usec);
|
||||
int __assuan_pipe (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx);
|
||||
int __assuan_close (assuan_context_t ctx, assuan_fd_t fd);
|
||||
int __assuan_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
|
||||
const char **argv, assuan_fd_t fd_in, assuan_fd_t fd_out,
|
||||
assuan_fd_t *fd_child_list,
|
||||
void (*atfork) (void *opaque, int reserved),
|
||||
void *atforkvalue, unsigned int flags);
|
||||
int __assuan_socketpair (assuan_context_t ctx, int _namespace, int style,
|
||||
int protocol, assuan_fd_t filedes[2]);
|
||||
int __assuan_socket (assuan_context_t ctx, int _namespace, int style, int protocol);
|
||||
int __assuan_connect (assuan_context_t ctx, int sock, struct sockaddr *addr, socklen_t length);
|
||||
ssize_t __assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size);
|
||||
ssize_t __assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size);
|
||||
int __assuan_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, int flags);
|
||||
int __assuan_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg, int flags);
|
||||
pid_t __assuan_waitpid (assuan_context_t ctx, pid_t pid, int nowait, int *status, int options);
|
||||
|
||||
|
||||
#define ASSUAN_SYSTEM_PTH_IMPL \
|
||||
static void _assuan_pth_usleep (assuan_context_t ctx, unsigned int usec) \
|
||||
{ (void) ctx; pth_usleep (usec); } \
|
||||
static ssize_t _assuan_pth_read (assuan_context_t ctx, assuan_fd_t fd, \
|
||||
void *buffer, size_t size) \
|
||||
{ (void) ctx; return pth_read (fd, buffer, size); } \
|
||||
static ssize_t _assuan_pth_write (assuan_context_t ctx, assuan_fd_t fd, \
|
||||
const void *buffer, size_t size) \
|
||||
{ (void) ctx; return pth_write (fd, buffer, size); } \
|
||||
static int _assuan_pth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \
|
||||
assuan_msghdr_t msg, int flags) \
|
||||
{ \
|
||||
(void) ctx; \
|
||||
gpg_err_set_errno (ENOSYS); \
|
||||
return -1; \
|
||||
} \
|
||||
static int _assuan_pth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \
|
||||
const assuan_msghdr_t msg, int flags) \
|
||||
{ \
|
||||
(void) ctx; \
|
||||
gpg_err_set_errno (ENOSYS); \
|
||||
return -1; \
|
||||
} \
|
||||
static pid_t _assuan_pth_waitpid (assuan_context_t ctx, pid_t pid, \
|
||||
int nowait, int *status, int options) \
|
||||
{ (void) ctx; \
|
||||
if (!nowait) return pth_waitpid (pid, status, options); \
|
||||
else return 0; } \
|
||||
\
|
||||
struct assuan_system_hooks _assuan_system_pth = \
|
||||
{ ASSUAN_SYSTEM_HOOKS_VERSION, _assuan_pth_usleep, __assuan_pipe, \
|
||||
__assuan_close, _assuan_pth_read, _assuan_pth_write, \
|
||||
_assuan_pth_recvmsg, _assuan_pth_sendmsg, \
|
||||
__assuan_spawn, _assuan_pth_waitpid, __assuan_socketpair, \
|
||||
__assuan_socket, __assuan_connect }
|
||||
|
||||
extern struct assuan_system_hooks _assuan_system_pth;
|
||||
#define ASSUAN_SYSTEM_PTH &_assuan_system_pth
|
||||
|
||||
#define ASSUAN_SYSTEM_NPTH_IMPL \
|
||||
static void _assuan_npth_usleep (assuan_context_t ctx, unsigned int usec) \
|
||||
{ npth_unprotect(); \
|
||||
__assuan_usleep (ctx, usec); \
|
||||
npth_protect(); } \
|
||||
static ssize_t _assuan_npth_read (assuan_context_t ctx, assuan_fd_t fd, \
|
||||
void *buffer, size_t size) \
|
||||
{ ssize_t res; (void) ctx; npth_unprotect(); \
|
||||
res = __assuan_read (ctx, fd, buffer, size); \
|
||||
npth_protect(); return res; } \
|
||||
static ssize_t _assuan_npth_write (assuan_context_t ctx, assuan_fd_t fd, \
|
||||
const void *buffer, size_t size) \
|
||||
{ ssize_t res; (void) ctx; npth_unprotect(); \
|
||||
res = __assuan_write (ctx, fd, buffer, size); \
|
||||
npth_protect(); return res; } \
|
||||
static int _assuan_npth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \
|
||||
assuan_msghdr_t msg, int flags) \
|
||||
{ int res; (void) ctx; npth_unprotect(); \
|
||||
res = __assuan_recvmsg (ctx, fd, msg, flags); \
|
||||
npth_protect(); return res; } \
|
||||
static int _assuan_npth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \
|
||||
const assuan_msghdr_t msg, int flags) \
|
||||
{ int res; (void) ctx; npth_unprotect(); \
|
||||
res = __assuan_sendmsg (ctx, fd, msg, flags); \
|
||||
npth_protect(); return res; } \
|
||||
static pid_t _assuan_npth_waitpid (assuan_context_t ctx, pid_t pid, \
|
||||
int nowait, int *status, int options) \
|
||||
{ pid_t res; (void) ctx; npth_unprotect(); \
|
||||
res = __assuan_waitpid (ctx, pid, nowait, status, options); \
|
||||
npth_protect(); return res; } \
|
||||
static int _assuan_npth_connect (assuan_context_t ctx, int sock, \
|
||||
struct sockaddr *addr, socklen_t len)\
|
||||
{ int res; npth_unprotect(); \
|
||||
res = __assuan_connect (ctx, sock, addr, len); \
|
||||
npth_protect(); return res; } \
|
||||
static int _assuan_npth_close (assuan_context_t ctx, assuan_fd_t fd) \
|
||||
{ int res; npth_unprotect(); \
|
||||
res = __assuan_close (ctx, fd); \
|
||||
npth_protect(); return res; } \
|
||||
\
|
||||
struct assuan_system_hooks _assuan_system_npth = \
|
||||
{ ASSUAN_SYSTEM_HOOKS_VERSION, _assuan_npth_usleep, __assuan_pipe, \
|
||||
_assuan_npth_close, _assuan_npth_read, _assuan_npth_write, \
|
||||
_assuan_npth_recvmsg, _assuan_npth_sendmsg, \
|
||||
__assuan_spawn, _assuan_npth_waitpid, __assuan_socketpair, \
|
||||
__assuan_socket, _assuan_npth_connect }
|
||||
|
||||
extern struct assuan_system_hooks _assuan_system_npth;
|
||||
#define ASSUAN_SYSTEM_NPTH &_assuan_system_npth
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ASSUAN_H */
|
||||
/*
|
||||
Local Variables:
|
||||
buffer-read-only: t
|
||||
End:
|
||||
*/
|
||||
1798
gpg/include/gcrypt.h
Normal file
1798
gpg/include/gcrypt.h
Normal file
File diff suppressed because it is too large
Load Diff
1942
gpg/include/gpg-error.h
Normal file
1942
gpg/include/gpg-error.h
Normal file
File diff suppressed because it is too large
Load Diff
2842
gpg/include/gpgme.h
Normal file
2842
gpg/include/gpgme.h
Normal file
File diff suppressed because it is too large
Load Diff
553
gpg/include/ksba.h
Normal file
553
gpg/include/ksba.h
Normal file
@@ -0,0 +1,553 @@
|
||||
/* ksba.h - X.509 library used by GnuPG
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011
|
||||
* 2012, 2013, 2104, 2015 g10 Code GmbH
|
||||
*
|
||||
* This file is part of KSBA.
|
||||
*
|
||||
* KSBA is free software; you can redistribute it and/or modify
|
||||
* it under the terms of either
|
||||
*
|
||||
* - the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* or
|
||||
*
|
||||
* - the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* or both in parallel, as here.
|
||||
*
|
||||
* KSBA is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copies of the GNU General Public License
|
||||
* and the GNU Lesser General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KSBA_H
|
||||
#define KSBA_H 1
|
||||
|
||||
#include <gpg-error.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Check for compiler features. */
|
||||
#ifdef __GNUC__
|
||||
#define _KSBA_GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
#if _KSBA_GCC_VERSION > 30100
|
||||
#define _KSBA_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
#endif /*__GNUC__*/
|
||||
|
||||
#ifndef _KSBA_DEPRECATED
|
||||
#define _KSBA_DEPRECATED
|
||||
#endif
|
||||
|
||||
|
||||
typedef gpg_error_t KsbaError _KSBA_DEPRECATED;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
KSBA_CT_NONE = 0,
|
||||
KSBA_CT_DATA = 1,
|
||||
KSBA_CT_SIGNED_DATA = 2,
|
||||
KSBA_CT_ENVELOPED_DATA = 3,
|
||||
KSBA_CT_DIGESTED_DATA = 4,
|
||||
KSBA_CT_ENCRYPTED_DATA = 5,
|
||||
KSBA_CT_AUTH_DATA = 6,
|
||||
KSBA_CT_PKCS12 = 7
|
||||
}
|
||||
ksba_content_type_t;
|
||||
typedef ksba_content_type_t KsbaContentType _KSBA_DEPRECATED;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
KSBA_SR_NONE = 0, /* Never seen by libksba user. */
|
||||
KSBA_SR_RUNNING = 1, /* Never seen by libksba user. */
|
||||
KSBA_SR_GOT_CONTENT = 2,
|
||||
KSBA_SR_NEED_HASH = 3,
|
||||
KSBA_SR_BEGIN_DATA = 4,
|
||||
KSBA_SR_END_DATA = 5,
|
||||
KSBA_SR_READY = 6,
|
||||
KSBA_SR_NEED_SIG = 7,
|
||||
KSBA_SR_DETACHED_DATA = 8,
|
||||
KSBA_SR_BEGIN_ITEMS = 9,
|
||||
KSBA_SR_GOT_ITEM = 10,
|
||||
KSBA_SR_END_ITEMS = 11
|
||||
}
|
||||
ksba_stop_reason_t;
|
||||
typedef ksba_stop_reason_t KsbaStopReason _KSBA_DEPRECATED;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
KSBA_CRLREASON_UNSPECIFIED = 1,
|
||||
KSBA_CRLREASON_KEY_COMPROMISE = 2,
|
||||
KSBA_CRLREASON_CA_COMPROMISE = 4,
|
||||
KSBA_CRLREASON_AFFILIATION_CHANGED = 8,
|
||||
KSBA_CRLREASON_SUPERSEDED = 16,
|
||||
KSBA_CRLREASON_CESSATION_OF_OPERATION = 32,
|
||||
KSBA_CRLREASON_CERTIFICATE_HOLD = 64,
|
||||
KSBA_CRLREASON_REMOVE_FROM_CRL = 256,
|
||||
KSBA_CRLREASON_PRIVILEGE_WITHDRAWN = 512,
|
||||
KSBA_CRLREASON_AA_COMPROMISE = 1024,
|
||||
KSBA_CRLREASON_OTHER = 32768
|
||||
}
|
||||
ksba_crl_reason_t;
|
||||
typedef ksba_crl_reason_t KsbaCRLReason _KSBA_DEPRECATED;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
KSBA_OCSP_RSPSTATUS_SUCCESS = 0,
|
||||
KSBA_OCSP_RSPSTATUS_MALFORMED = 1,
|
||||
KSBA_OCSP_RSPSTATUS_INTERNAL = 2,
|
||||
KSBA_OCSP_RSPSTATUS_TRYLATER = 3,
|
||||
KSBA_OCSP_RSPSTATUS_SIGREQUIRED = 5,
|
||||
KSBA_OCSP_RSPSTATUS_UNAUTHORIZED = 6,
|
||||
KSBA_OCSP_RSPSTATUS_REPLAYED = 253,
|
||||
KSBA_OCSP_RSPSTATUS_OTHER = 254,
|
||||
KSBA_OCSP_RSPSTATUS_NONE = 255
|
||||
}
|
||||
ksba_ocsp_response_status_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
KSBA_STATUS_NONE = 0,
|
||||
KSBA_STATUS_UNKNOWN = 1,
|
||||
KSBA_STATUS_GOOD = 2,
|
||||
KSBA_STATUS_REVOKED = 4
|
||||
}
|
||||
ksba_status_t;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
KSBA_KEYUSAGE_DIGITAL_SIGNATURE = 1,
|
||||
KSBA_KEYUSAGE_NON_REPUDIATION = 2,
|
||||
KSBA_KEYUSAGE_KEY_ENCIPHERMENT = 4,
|
||||
KSBA_KEYUSAGE_DATA_ENCIPHERMENT = 8,
|
||||
KSBA_KEYUSAGE_KEY_AGREEMENT = 16,
|
||||
KSBA_KEYUSAGE_KEY_CERT_SIGN = 32,
|
||||
KSBA_KEYUSAGE_CRL_SIGN = 64,
|
||||
KSBA_KEYUSAGE_ENCIPHER_ONLY = 128,
|
||||
KSBA_KEYUSAGE_DECIPHER_ONLY = 256
|
||||
}
|
||||
ksba_key_usage_t;
|
||||
typedef ksba_key_usage_t KsbaKeyUsage _KSBA_DEPRECATED;
|
||||
|
||||
/* ISO format, e.g. "19610711T172059", assumed to be UTC. */
|
||||
typedef char ksba_isotime_t[16];
|
||||
|
||||
|
||||
/* X.509 certificates are represented by this object.
|
||||
ksba_cert_new() creates such an object */
|
||||
struct ksba_cert_s;
|
||||
typedef struct ksba_cert_s *ksba_cert_t;
|
||||
typedef struct ksba_cert_s *KsbaCert _KSBA_DEPRECATED;
|
||||
|
||||
/* CMS objects are controlled by this object.
|
||||
ksba_cms_new() creates it */
|
||||
struct ksba_cms_s;
|
||||
typedef struct ksba_cms_s *ksba_cms_t;
|
||||
typedef struct ksba_cms_s *KsbaCMS _KSBA_DEPRECATED;
|
||||
|
||||
/* CRL objects are controlled by this object.
|
||||
ksba_crl_new() creates it */
|
||||
struct ksba_crl_s;
|
||||
typedef struct ksba_crl_s *ksba_crl_t;
|
||||
typedef struct ksba_crl_s *KsbaCRL _KSBA_DEPRECATED;
|
||||
|
||||
/* OCSP objects are controlled by this object.
|
||||
ksba_ocsp_new() creates it. */
|
||||
struct ksba_ocsp_s;
|
||||
typedef struct ksba_ocsp_s *ksba_ocsp_t;
|
||||
|
||||
/* PKCS-10 creation is controlled by this object.
|
||||
ksba_certreq_new() creates it */
|
||||
struct ksba_certreq_s;
|
||||
typedef struct ksba_certreq_s *ksba_certreq_t;
|
||||
typedef struct ksba_certreq_s *KsbaCertreq _KSBA_DEPRECATED;
|
||||
|
||||
/* This is a reader object for various purposes
|
||||
see ksba_reader_new et al. */
|
||||
struct ksba_reader_s;
|
||||
typedef struct ksba_reader_s *ksba_reader_t;
|
||||
typedef struct ksba_reader_s *KsbaReader _KSBA_DEPRECATED;
|
||||
|
||||
/* This is a writer object for various purposes
|
||||
see ksba_writer_new et al. */
|
||||
struct ksba_writer_s;
|
||||
typedef struct ksba_writer_s *ksba_writer_t;
|
||||
typedef struct ksba_writer_s *KsbaWriter _KSBA_DEPRECATED;
|
||||
|
||||
/* This is an object to store an ASN.1 parse tree as
|
||||
create by ksba_asn_parse_file() */
|
||||
struct ksba_asn_tree_s;
|
||||
typedef struct ksba_asn_tree_s *ksba_asn_tree_t;
|
||||
typedef struct ksba_asn_tree_s *KsbaAsnTree _KSBA_DEPRECATED;
|
||||
|
||||
/* This is an object to reference a General Name. Such an object is
|
||||
returned by several functions. */
|
||||
struct ksba_name_s;
|
||||
typedef struct ksba_name_s *ksba_name_t;
|
||||
typedef struct ksba_name_s *KsbaName _KSBA_DEPRECATED;
|
||||
|
||||
/* KsbaSexp is just an unsigned char * which should be used for
|
||||
documentation purpose. The S-expressions returned by libksba are
|
||||
always in canonical representation with an extra 0 byte at the end,
|
||||
so that one can print the values in the debugger and at least see
|
||||
the first bytes */
|
||||
typedef unsigned char *ksba_sexp_t;
|
||||
typedef unsigned char *KsbaSexp _KSBA_DEPRECATED;
|
||||
typedef const unsigned char *ksba_const_sexp_t;
|
||||
typedef const unsigned char *KsbaConstSexp _KSBA_DEPRECATED;
|
||||
|
||||
|
||||
/*-- cert.c --*/
|
||||
gpg_error_t ksba_cert_new (ksba_cert_t *acert);
|
||||
void ksba_cert_ref (ksba_cert_t cert);
|
||||
void ksba_cert_release (ksba_cert_t cert);
|
||||
gpg_error_t ksba_cert_set_user_data (ksba_cert_t cert, const char *key,
|
||||
const void *data, size_t datalen);
|
||||
gpg_error_t ksba_cert_get_user_data (ksba_cert_t cert, const char *key,
|
||||
void *buffer, size_t bufferlen,
|
||||
size_t *datalen);
|
||||
|
||||
gpg_error_t ksba_cert_read_der (ksba_cert_t cert, ksba_reader_t reader);
|
||||
gpg_error_t ksba_cert_init_from_mem (ksba_cert_t cert,
|
||||
const void *buffer, size_t length);
|
||||
const unsigned char *ksba_cert_get_image (ksba_cert_t cert, size_t *r_length);
|
||||
gpg_error_t ksba_cert_hash (ksba_cert_t cert,
|
||||
int what,
|
||||
void (*hasher)(void *,
|
||||
const void *,
|
||||
size_t length),
|
||||
void *hasher_arg);
|
||||
const char *ksba_cert_get_digest_algo (ksba_cert_t cert);
|
||||
ksba_sexp_t ksba_cert_get_serial (ksba_cert_t cert);
|
||||
char *ksba_cert_get_issuer (ksba_cert_t cert, int idx);
|
||||
gpg_error_t ksba_cert_get_validity (ksba_cert_t cert, int what,
|
||||
ksba_isotime_t r_time);
|
||||
char *ksba_cert_get_subject (ksba_cert_t cert, int idx);
|
||||
ksba_sexp_t ksba_cert_get_public_key (ksba_cert_t cert);
|
||||
ksba_sexp_t ksba_cert_get_sig_val (ksba_cert_t cert);
|
||||
|
||||
gpg_error_t ksba_cert_get_extension (ksba_cert_t cert, int idx,
|
||||
char const **r_oid, int *r_crit,
|
||||
size_t *r_deroff, size_t *r_derlen);
|
||||
|
||||
gpg_error_t ksba_cert_is_ca (ksba_cert_t cert, int *r_ca, int *r_pathlen);
|
||||
gpg_error_t ksba_cert_get_key_usage (ksba_cert_t cert, unsigned int *r_flags);
|
||||
gpg_error_t ksba_cert_get_cert_policies (ksba_cert_t cert, char **r_policies);
|
||||
gpg_error_t ksba_cert_get_ext_key_usages (ksba_cert_t cert, char **result);
|
||||
gpg_error_t ksba_cert_get_crl_dist_point (ksba_cert_t cert, int idx,
|
||||
ksba_name_t *r_distpoint,
|
||||
ksba_name_t *r_issuer,
|
||||
ksba_crl_reason_t *r_reason);
|
||||
gpg_error_t ksba_cert_get_auth_key_id (ksba_cert_t cert,
|
||||
ksba_sexp_t *r_keyid,
|
||||
ksba_name_t *r_name,
|
||||
ksba_sexp_t *r_serial);
|
||||
gpg_error_t ksba_cert_get_subj_key_id (ksba_cert_t cert,
|
||||
int *r_crit,
|
||||
ksba_sexp_t *r_keyid);
|
||||
gpg_error_t ksba_cert_get_authority_info_access (ksba_cert_t cert, int idx,
|
||||
char **r_method,
|
||||
ksba_name_t *r_location);
|
||||
gpg_error_t ksba_cert_get_subject_info_access (ksba_cert_t cert, int idx,
|
||||
char **r_method,
|
||||
ksba_name_t *r_location);
|
||||
|
||||
|
||||
/*-- cms.c --*/
|
||||
ksba_content_type_t ksba_cms_identify (ksba_reader_t reader);
|
||||
|
||||
gpg_error_t ksba_cms_new (ksba_cms_t *r_cms);
|
||||
void ksba_cms_release (ksba_cms_t cms);
|
||||
gpg_error_t ksba_cms_set_reader_writer (ksba_cms_t cms,
|
||||
ksba_reader_t r, ksba_writer_t w);
|
||||
|
||||
gpg_error_t ksba_cms_parse (ksba_cms_t cms, ksba_stop_reason_t *r_stopreason);
|
||||
gpg_error_t ksba_cms_build (ksba_cms_t cms, ksba_stop_reason_t *r_stopreason);
|
||||
|
||||
ksba_content_type_t ksba_cms_get_content_type (ksba_cms_t cms, int what);
|
||||
const char *ksba_cms_get_content_oid (ksba_cms_t cms, int what);
|
||||
gpg_error_t ksba_cms_get_content_enc_iv (ksba_cms_t cms, void *iv,
|
||||
size_t maxivlen, size_t *ivlen);
|
||||
const char *ksba_cms_get_digest_algo_list (ksba_cms_t cms, int idx);
|
||||
gpg_error_t ksba_cms_get_issuer_serial (ksba_cms_t cms, int idx,
|
||||
char **r_issuer,
|
||||
ksba_sexp_t *r_serial);
|
||||
const char *ksba_cms_get_digest_algo (ksba_cms_t cms, int idx);
|
||||
ksba_cert_t ksba_cms_get_cert (ksba_cms_t cms, int idx);
|
||||
gpg_error_t ksba_cms_get_message_digest (ksba_cms_t cms, int idx,
|
||||
char **r_digest, size_t *r_digest_len);
|
||||
gpg_error_t ksba_cms_get_signing_time (ksba_cms_t cms, int idx,
|
||||
ksba_isotime_t r_sigtime);
|
||||
gpg_error_t ksba_cms_get_sigattr_oids (ksba_cms_t cms, int idx,
|
||||
const char *reqoid, char **r_value);
|
||||
ksba_sexp_t ksba_cms_get_sig_val (ksba_cms_t cms, int idx);
|
||||
ksba_sexp_t ksba_cms_get_enc_val (ksba_cms_t cms, int idx);
|
||||
|
||||
void ksba_cms_set_hash_function (ksba_cms_t cms,
|
||||
void (*hash_fnc)(void *, const void *, size_t),
|
||||
void *hash_fnc_arg);
|
||||
|
||||
gpg_error_t ksba_cms_hash_signed_attrs (ksba_cms_t cms, int idx);
|
||||
|
||||
|
||||
gpg_error_t ksba_cms_set_content_type (ksba_cms_t cms, int what,
|
||||
ksba_content_type_t type);
|
||||
gpg_error_t ksba_cms_add_digest_algo (ksba_cms_t cms, const char *oid);
|
||||
gpg_error_t ksba_cms_add_signer (ksba_cms_t cms, ksba_cert_t cert);
|
||||
gpg_error_t ksba_cms_add_cert (ksba_cms_t cms, ksba_cert_t cert);
|
||||
gpg_error_t ksba_cms_add_smime_capability (ksba_cms_t cms, const char *oid,
|
||||
const unsigned char *der,
|
||||
size_t derlen);
|
||||
gpg_error_t ksba_cms_set_message_digest (ksba_cms_t cms, int idx,
|
||||
const unsigned char *digest,
|
||||
size_t digest_len);
|
||||
gpg_error_t ksba_cms_set_signing_time (ksba_cms_t cms, int idx,
|
||||
const ksba_isotime_t sigtime);
|
||||
gpg_error_t ksba_cms_set_sig_val (ksba_cms_t cms,
|
||||
int idx, ksba_const_sexp_t sigval);
|
||||
|
||||
gpg_error_t ksba_cms_set_content_enc_algo (ksba_cms_t cms,
|
||||
const char *oid,
|
||||
const void *iv,
|
||||
size_t ivlen);
|
||||
gpg_error_t ksba_cms_add_recipient (ksba_cms_t cms, ksba_cert_t cert);
|
||||
gpg_error_t ksba_cms_set_enc_val (ksba_cms_t cms,
|
||||
int idx, ksba_const_sexp_t encval);
|
||||
|
||||
|
||||
/*-- crl.c --*/
|
||||
gpg_error_t ksba_crl_new (ksba_crl_t *r_crl);
|
||||
void ksba_crl_release (ksba_crl_t crl);
|
||||
gpg_error_t ksba_crl_set_reader (ksba_crl_t crl, ksba_reader_t r);
|
||||
void ksba_crl_set_hash_function (ksba_crl_t crl,
|
||||
void (*hash_fnc)(void *,
|
||||
const void *, size_t),
|
||||
void *hash_fnc_arg);
|
||||
const char *ksba_crl_get_digest_algo (ksba_crl_t crl);
|
||||
gpg_error_t ksba_crl_get_issuer (ksba_crl_t crl, char **r_issuer);
|
||||
gpg_error_t ksba_crl_get_extension (ksba_crl_t crl, int idx,
|
||||
char const **oid, int *critical,
|
||||
unsigned char const **der, size_t *derlen);
|
||||
gpg_error_t ksba_crl_get_auth_key_id (ksba_crl_t crl,
|
||||
ksba_sexp_t *r_keyid,
|
||||
ksba_name_t *r_name,
|
||||
ksba_sexp_t *r_serial);
|
||||
gpg_error_t ksba_crl_get_crl_number (ksba_crl_t crl, ksba_sexp_t *number);
|
||||
gpg_error_t ksba_crl_get_update_times (ksba_crl_t crl,
|
||||
ksba_isotime_t this_update,
|
||||
ksba_isotime_t next_update);
|
||||
gpg_error_t ksba_crl_get_item (ksba_crl_t crl,
|
||||
ksba_sexp_t *r_serial,
|
||||
ksba_isotime_t r_revocation_date,
|
||||
ksba_crl_reason_t *r_reason);
|
||||
ksba_sexp_t ksba_crl_get_sig_val (ksba_crl_t crl);
|
||||
gpg_error_t ksba_crl_parse (ksba_crl_t crl, ksba_stop_reason_t *r_stopreason);
|
||||
|
||||
|
||||
|
||||
/*-- ocsp.c --*/
|
||||
gpg_error_t ksba_ocsp_new (ksba_ocsp_t *r_oscp);
|
||||
void ksba_ocsp_release (ksba_ocsp_t ocsp);
|
||||
gpg_error_t ksba_ocsp_set_digest_algo (ksba_ocsp_t ocsp, const char *oid);
|
||||
gpg_error_t ksba_ocsp_set_requestor (ksba_ocsp_t ocsp, ksba_cert_t cert);
|
||||
gpg_error_t ksba_ocsp_add_target (ksba_ocsp_t ocsp,
|
||||
ksba_cert_t cert, ksba_cert_t issuer_cert);
|
||||
size_t ksba_ocsp_set_nonce (ksba_ocsp_t ocsp,
|
||||
unsigned char *nonce, size_t noncelen);
|
||||
|
||||
gpg_error_t ksba_ocsp_prepare_request (ksba_ocsp_t ocsp);
|
||||
gpg_error_t ksba_ocsp_hash_request (ksba_ocsp_t ocsp,
|
||||
void (*hasher)(void *, const void *,
|
||||
size_t length),
|
||||
void *hasher_arg);
|
||||
gpg_error_t ksba_ocsp_set_sig_val (ksba_ocsp_t ocsp,
|
||||
ksba_const_sexp_t sigval);
|
||||
gpg_error_t ksba_ocsp_add_cert (ksba_ocsp_t ocsp, ksba_cert_t cert);
|
||||
gpg_error_t ksba_ocsp_build_request (ksba_ocsp_t ocsp,
|
||||
unsigned char **r_buffer,
|
||||
size_t *r_buflen);
|
||||
|
||||
gpg_error_t ksba_ocsp_parse_response (ksba_ocsp_t ocsp,
|
||||
const unsigned char *msg, size_t msglen,
|
||||
ksba_ocsp_response_status_t *resp_status);
|
||||
|
||||
const char *ksba_ocsp_get_digest_algo (ksba_ocsp_t ocsp);
|
||||
gpg_error_t ksba_ocsp_hash_response (ksba_ocsp_t ocsp,
|
||||
const unsigned char *msg, size_t msglen,
|
||||
void (*hasher)(void *, const void *,
|
||||
size_t length),
|
||||
void *hasher_arg);
|
||||
ksba_sexp_t ksba_ocsp_get_sig_val (ksba_ocsp_t ocsp,
|
||||
ksba_isotime_t produced_at);
|
||||
gpg_error_t ksba_ocsp_get_responder_id (ksba_ocsp_t ocsp,
|
||||
char **r_name,
|
||||
ksba_sexp_t *r_keyid);
|
||||
ksba_cert_t ksba_ocsp_get_cert (ksba_ocsp_t ocsp, int idx);
|
||||
gpg_error_t ksba_ocsp_get_status (ksba_ocsp_t ocsp, ksba_cert_t cert,
|
||||
ksba_status_t *r_status,
|
||||
ksba_isotime_t r_this_update,
|
||||
ksba_isotime_t r_next_update,
|
||||
ksba_isotime_t r_revocation_time,
|
||||
ksba_crl_reason_t *r_reason);
|
||||
gpg_error_t ksba_ocsp_get_extension (ksba_ocsp_t ocsp, ksba_cert_t cert,
|
||||
int idx,
|
||||
char const **r_oid, int *r_crit,
|
||||
unsigned char const **r_der,
|
||||
size_t *r_derlen);
|
||||
|
||||
|
||||
/*-- certreq.c --*/
|
||||
gpg_error_t ksba_certreq_new (ksba_certreq_t *r_cr);
|
||||
void ksba_certreq_release (ksba_certreq_t cr);
|
||||
gpg_error_t ksba_certreq_set_writer (ksba_certreq_t cr, ksba_writer_t w);
|
||||
void ksba_certreq_set_hash_function (
|
||||
ksba_certreq_t cr,
|
||||
void (*hash_fnc)(void *, const void *, size_t),
|
||||
void *hash_fnc_arg);
|
||||
gpg_error_t ksba_certreq_add_subject (ksba_certreq_t cr, const char *name);
|
||||
gpg_error_t ksba_certreq_set_public_key (ksba_certreq_t cr,
|
||||
ksba_const_sexp_t key);
|
||||
gpg_error_t ksba_certreq_add_extension (ksba_certreq_t cr,
|
||||
const char *oid, int is_crit,
|
||||
const void *der,
|
||||
size_t derlen);
|
||||
gpg_error_t ksba_certreq_set_sig_val (ksba_certreq_t cr,
|
||||
ksba_const_sexp_t sigval);
|
||||
gpg_error_t ksba_certreq_build (ksba_certreq_t cr,
|
||||
ksba_stop_reason_t *r_stopreason);
|
||||
|
||||
/* The functions below are used to switch to X.509 certificate creation. */
|
||||
gpg_error_t ksba_certreq_set_serial (ksba_certreq_t cr, ksba_const_sexp_t sn);
|
||||
gpg_error_t ksba_certreq_set_issuer (ksba_certreq_t cr, const char *name);
|
||||
gpg_error_t ksba_certreq_set_validity (ksba_certreq_t cr, int what,
|
||||
const ksba_isotime_t timebuf);
|
||||
gpg_error_t ksba_certreq_set_siginfo (ksba_certreq_t cr,
|
||||
ksba_const_sexp_t siginfo);
|
||||
|
||||
|
||||
|
||||
/*-- reader.c --*/
|
||||
gpg_error_t ksba_reader_new (ksba_reader_t *r_r);
|
||||
void ksba_reader_release (ksba_reader_t r);
|
||||
gpg_error_t ksba_reader_set_release_notify (ksba_reader_t r,
|
||||
void (*notify)(void*,ksba_reader_t),
|
||||
void *notify_value);
|
||||
gpg_error_t ksba_reader_clear (ksba_reader_t r,
|
||||
unsigned char **buffer, size_t *buflen);
|
||||
gpg_error_t ksba_reader_error (ksba_reader_t r);
|
||||
|
||||
gpg_error_t ksba_reader_set_mem (ksba_reader_t r,
|
||||
const void *buffer, size_t length);
|
||||
gpg_error_t ksba_reader_set_fd (ksba_reader_t r, int fd);
|
||||
gpg_error_t ksba_reader_set_file (ksba_reader_t r, FILE *fp);
|
||||
gpg_error_t ksba_reader_set_cb (ksba_reader_t r,
|
||||
int (*cb)(void*,char *,size_t,size_t*),
|
||||
void *cb_value );
|
||||
|
||||
gpg_error_t ksba_reader_read (ksba_reader_t r,
|
||||
char *buffer, size_t length, size_t *nread);
|
||||
gpg_error_t ksba_reader_unread (ksba_reader_t r, const void *buffer, size_t count);
|
||||
unsigned long ksba_reader_tell (ksba_reader_t r);
|
||||
|
||||
/*-- writer.c --*/
|
||||
gpg_error_t ksba_writer_new (ksba_writer_t *r_w);
|
||||
void ksba_writer_release (ksba_writer_t w);
|
||||
gpg_error_t ksba_writer_set_release_notify (ksba_writer_t w,
|
||||
void (*notify)(void*,ksba_writer_t),
|
||||
void *notify_value);
|
||||
int ksba_writer_error (ksba_writer_t w);
|
||||
unsigned long ksba_writer_tell (ksba_writer_t w);
|
||||
gpg_error_t ksba_writer_set_fd (ksba_writer_t w, int fd);
|
||||
gpg_error_t ksba_writer_set_file (ksba_writer_t w, FILE *fp);
|
||||
gpg_error_t ksba_writer_set_cb (ksba_writer_t w,
|
||||
int (*cb)(void*,const void *,size_t),
|
||||
void *cb_value);
|
||||
gpg_error_t ksba_writer_set_mem (ksba_writer_t w, size_t initial_size);
|
||||
const void *ksba_writer_get_mem (ksba_writer_t w, size_t *nbytes);
|
||||
void * ksba_writer_snatch_mem (ksba_writer_t w, size_t *nbytes);
|
||||
gpg_error_t ksba_writer_set_filter (ksba_writer_t w,
|
||||
gpg_error_t (*filter)(void*,
|
||||
const void *,size_t, size_t *,
|
||||
void *, size_t, size_t *),
|
||||
void *filter_arg);
|
||||
|
||||
gpg_error_t ksba_writer_write (ksba_writer_t w, const void *buffer, size_t length);
|
||||
gpg_error_t ksba_writer_write_octet_string (ksba_writer_t w,
|
||||
const void *buffer, size_t length,
|
||||
int flush);
|
||||
|
||||
/*-- asn1-parse.y --*/
|
||||
int ksba_asn_parse_file (const char *filename, ksba_asn_tree_t *result,
|
||||
int debug);
|
||||
void ksba_asn_tree_release (ksba_asn_tree_t tree);
|
||||
|
||||
/*-- asn1-func.c --*/
|
||||
void ksba_asn_tree_dump (ksba_asn_tree_t tree, const char *name, FILE *fp);
|
||||
gpg_error_t ksba_asn_create_tree (const char *mod_name, ksba_asn_tree_t *result);
|
||||
|
||||
/*-- oid.c --*/
|
||||
char *ksba_oid_to_str (const char *buffer, size_t length);
|
||||
gpg_error_t ksba_oid_from_str (const char *string,
|
||||
unsigned char **rbuf, size_t *rlength);
|
||||
|
||||
/*-- dn.c --*/
|
||||
gpg_error_t ksba_dn_der2str (const void *der, size_t derlen, char **r_string);
|
||||
gpg_error_t ksba_dn_str2der (const char *string,
|
||||
unsigned char **rder, size_t *rderlen);
|
||||
gpg_error_t ksba_dn_teststr (const char *string, int seq,
|
||||
size_t *rerroff, size_t *rerrlen);
|
||||
|
||||
|
||||
/*-- name.c --*/
|
||||
gpg_error_t ksba_name_new (ksba_name_t *r_name);
|
||||
void ksba_name_ref (ksba_name_t name);
|
||||
void ksba_name_release (ksba_name_t name);
|
||||
const char *ksba_name_enum (ksba_name_t name, int idx);
|
||||
char *ksba_name_get_uri (ksba_name_t name, int idx);
|
||||
|
||||
|
||||
/*-- util.c --*/
|
||||
void ksba_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
|
||||
void *(*new_realloc_func)(void *p, size_t n),
|
||||
void (*new_free_func)(void*) );
|
||||
void ksba_set_hash_buffer_function ( gpg_error_t (*fnc)
|
||||
(void *arg, const char *oid,
|
||||
const void *buffer, size_t length,
|
||||
size_t resultsize,
|
||||
unsigned char *result,
|
||||
size_t *resultlen),
|
||||
void *fnc_arg);
|
||||
void *ksba_malloc (size_t n );
|
||||
void *ksba_calloc (size_t n, size_t m );
|
||||
void *ksba_realloc (void *p, size_t n);
|
||||
char *ksba_strdup (const char *p);
|
||||
void ksba_free ( void *a );
|
||||
|
||||
/*--version.c --*/
|
||||
const char *ksba_check_version (const char *req_version);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*KSBA_H*/
|
||||
238
gpg/include/npth.h
Normal file
238
gpg/include/npth.h
Normal file
@@ -0,0 +1,238 @@
|
||||
/* npth.h - a lightweight implementation of pth over native threads
|
||||
* Copyright (C) 2011, 2015 g10 Code GmbH
|
||||
*
|
||||
* This file is part of nPth.
|
||||
*
|
||||
* nPth is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* nPth is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
* the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _NPTH_H
|
||||
#define _NPTH_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#if 0 /* (Keep Emacsens' auto-indent happy.) */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct msghdr;
|
||||
|
||||
/* The mingw-w64 headers define timespec. For older compilers we keep
|
||||
our replacement. */
|
||||
#ifndef __MINGW64_VERSION_MAJOR
|
||||
struct timespec {
|
||||
long tv_sec; /* seconds */
|
||||
long tv_nsec; /* nanoseconds */
|
||||
};
|
||||
#endif /*__MINGW64_VERSION_MAJOR */
|
||||
|
||||
|
||||
#ifndef ETIMEDOUT
|
||||
#define ETIMEDOUT 10060 /* This is WSAETIMEDOUT. */
|
||||
#endif
|
||||
#ifndef EOPNOTSUPP
|
||||
#define EOPNOTSUPP 10045 /* This is WSAEOPNOTSUPP. */
|
||||
#endif
|
||||
|
||||
|
||||
int npth_init (void);
|
||||
|
||||
typedef struct npth_attr_s *npth_attr_t;
|
||||
typedef unsigned long int npth_t;
|
||||
typedef struct npth_mutexattr_s *npth_mutexattr_t;
|
||||
typedef struct npth_mutex_s *npth_mutex_t;
|
||||
typedef struct npth_rwlockattr_s *npth_rwlockattr_t;
|
||||
typedef struct npth_rwlock_s *npth_rwlock_t;
|
||||
typedef struct npth_condattr_s *npth_condattr_t;
|
||||
typedef struct npth_cond_s *npth_cond_t;
|
||||
|
||||
int npth_attr_init (npth_attr_t *attr);
|
||||
int npth_attr_destroy (npth_attr_t *attr);
|
||||
#define NPTH_CREATE_JOINABLE 0
|
||||
#define NPTH_CREATE_DETACHED 1
|
||||
int npth_attr_getdetachstate(npth_attr_t *attr, int *detachstate);
|
||||
int npth_attr_setdetachstate(npth_attr_t *attr, int detachstate);
|
||||
int npth_getname_np (npth_t target_thread, char *buf, size_t buflen);
|
||||
int npth_setname_np (npth_t target_thread, const char *name);
|
||||
|
||||
int npth_create (npth_t *newthread, const npth_attr_t *attr,
|
||||
void *(*start_routine) (void *), void *arg);
|
||||
|
||||
npth_t npth_self (void);
|
||||
|
||||
int npth_join (npth_t th, void **thread_return);
|
||||
int npth_detach (npth_t th);
|
||||
void npth_exit (void *retval);
|
||||
|
||||
typedef DWORD npth_key_t;
|
||||
int npth_key_create (npth_key_t *key,
|
||||
void (*destr_function) (void *));
|
||||
int npth_key_delete (npth_key_t key);
|
||||
void *npth_getspecific (npth_key_t key);
|
||||
int npth_setspecific (npth_key_t key, const void *pointer);
|
||||
|
||||
int npth_mutexattr_init (npth_mutexattr_t *attr);
|
||||
int npth_mutexattr_destroy (npth_mutexattr_t *attr);
|
||||
int npth_mutexattr_gettype (const npth_mutexattr_t *attr,
|
||||
int *kind);
|
||||
int npth_mutexattr_settype (npth_mutexattr_t *attr, int kind);
|
||||
#define NPTH_MUTEX_NORMAL 0
|
||||
#define NPTH_MUTEX_RECURSIVE 1
|
||||
#define NPTH_MUTEX_ERRORCHECK 2
|
||||
#define NPTH_MUTEX_DEFAULT NPTH_MUTEX_NORMAL
|
||||
|
||||
#define NPTH_MUTEX_INITIALIZER ((npth_mutex_t) -1)
|
||||
#define NPTH_RECURSIVE_MUTEX_INITIALIZER_NP ((npth_mutex_t) -2)
|
||||
#define NPTH_ERRORCHECK_MUTEX_INITIALIZER_NP ((npth_mutex_t) -3)
|
||||
int npth_mutex_init (npth_mutex_t *mutex, const npth_mutexattr_t *mutexattr);
|
||||
int npth_mutex_destroy (npth_mutex_t *mutex);
|
||||
int npth_mutex_trylock(npth_mutex_t *mutex);
|
||||
int npth_mutex_lock(npth_mutex_t *mutex);
|
||||
int npth_mutex_timedlock(npth_mutex_t *mutex, const struct timespec *abstime);
|
||||
int npth_mutex_unlock(npth_mutex_t *mutex);
|
||||
|
||||
int npth_rwlockattr_init (npth_rwlockattr_t *attr);
|
||||
int npth_rwlockattr_destroy (npth_rwlockattr_t *attr);
|
||||
int npth_rwlockattr_gettype_np (const npth_rwlockattr_t *attr,
|
||||
int *kind);
|
||||
int npth_rwlockattr_settype_np (npth_rwlockattr_t *attr, int kind);
|
||||
#define NPTH_RWLOCK_PREFER_READER_NP 0
|
||||
#define NPTH_RWLOCK_PREFER_WRITER_NP 1
|
||||
#define NPTH_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP 2
|
||||
#define NPTH_RWLOCK_DEFAULT_NP NPTH_RWLOCK_PREFER_READER_NP
|
||||
#define NPTH_RWLOCK_INITIALIZER ((npth_rwlock_t) -1)
|
||||
#define NPTH_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP ((npth_rwlock_t) -2)
|
||||
|
||||
/* For now, we don't support any rwlock attributes. */
|
||||
int npth_rwlock_init (npth_rwlock_t *rwlock,
|
||||
const npth_rwlockattr_t *attr);
|
||||
int npth_rwlock_destroy (npth_rwlock_t *rwlock);
|
||||
int npth_rwlock_tryrdlock (npth_rwlock_t *rwlock);
|
||||
int npth_rwlock_rdlock (npth_rwlock_t *rwlock);
|
||||
int npth_rwlock_timedrdlock (npth_rwlock_t *rwlock,
|
||||
const struct timespec *abstime);
|
||||
int npth_rwlock_trywrlock (npth_rwlock_t *rwlock);
|
||||
|
||||
int npth_rwlock_wrlock (npth_rwlock_t *rwlock);
|
||||
int npth_rwlock_timedwrlock (npth_rwlock_t *rwlock,
|
||||
const struct timespec *abstime);
|
||||
int npth_rwlock_unlock (npth_rwlock_t *rwlock);
|
||||
|
||||
#define NPTH_COND_INITIALIZER ((npth_cond_t) -1)
|
||||
/* For now, we don't support any cond attributes. */
|
||||
int npth_cond_init (npth_cond_t *cond,
|
||||
const npth_condattr_t *cond_attr);
|
||||
int npth_cond_broadcast (npth_cond_t *cond);
|
||||
int npth_cond_signal (npth_cond_t *cond);
|
||||
int npth_cond_destroy (npth_cond_t *cond);
|
||||
int npth_cond_wait (npth_cond_t *cond, npth_mutex_t *mutex);
|
||||
int npth_cond_timedwait (npth_cond_t *cond, npth_mutex_t *mutex,
|
||||
const struct timespec *abstime);
|
||||
|
||||
int npth_usleep(unsigned int usec);
|
||||
unsigned int npth_sleep(unsigned int sec);
|
||||
|
||||
pid_t npth_waitpid(pid_t pid, int *status, int options);
|
||||
int npth_system(const char *cmd);
|
||||
|
||||
#if 0
|
||||
/* We do not support this on windows. */
|
||||
int npth_sigmask(int how, const sigset_t *set, sigset_t *oldset);
|
||||
int npth_sigwait(const sigset_t *set, int *sig);
|
||||
#endif
|
||||
|
||||
int npth_connect(int s, const struct sockaddr *addr, socklen_t addrlen);
|
||||
int npth_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
|
||||
/* Only good for sockets! */
|
||||
int npth_select(int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds,
|
||||
struct timeval *timeout);
|
||||
#if 0
|
||||
/* We do not support this on windows. */
|
||||
int npth_pselect(int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds,
|
||||
const struct timespec *timeout, const sigset_t *sigmask);
|
||||
#endif
|
||||
/* Wait on the FDs (only good for sockets!) and the
|
||||
INVALID_HANDLE_VALUE terminated list of extra events. On return
|
||||
(even on error), the bits in EVENTS_SET will contain the extra
|
||||
events that occured (which means that there can only be up to 31
|
||||
extra events). */
|
||||
int npth_eselect(int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds,
|
||||
const struct timespec *timeout,
|
||||
HANDLE *events, unsigned int *events_set);
|
||||
|
||||
ssize_t npth_read(int fd, void *buf, size_t nbytes);
|
||||
ssize_t npth_write(int fd, const void *buf, size_t nbytes);
|
||||
int npth_recvmsg (int fd, struct msghdr *msg, int flags);
|
||||
int npth_sendmsg (int fd, const struct msghdr *msg, int flags);
|
||||
|
||||
void npth_unprotect (void);
|
||||
void npth_protect (void);
|
||||
|
||||
/* Return true when we hold the sceptre. This is used to debug
|
||||
* problems with npth_unprotect and npth_protect. */
|
||||
int npth_is_protected (void);
|
||||
|
||||
int npth_clock_gettime(struct timespec *tp);
|
||||
|
||||
/* CMP may be ==, < or >. Do not use <= or >=. */
|
||||
#define npth_timercmp(t1, t2, cmp) \
|
||||
(((t1)->tv_sec == (t2)->tv_sec) ? \
|
||||
((t1)->tv_nsec cmp (t2)->tv_nsec) : \
|
||||
((t1)->tv_sec cmp (t2)->tv_sec))
|
||||
#define npth_timeradd(t1, t2, result) \
|
||||
do { \
|
||||
(result)->tv_sec = (t1)->tv_sec + (t2)->tv_sec; \
|
||||
(result)->tv_nsec = (t1)->tv_nsec + (t2)->tv_nsec; \
|
||||
if ((result)->tv_nsec >= 1000000000) \
|
||||
{ \
|
||||
++(result)->tv_sec; \
|
||||
(result)->tv_nsec -= 1000000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#define npth_timersub(t1, t2, result) \
|
||||
do { \
|
||||
(result)->tv_sec = (t1)->tv_sec - (t2)->tv_sec; \
|
||||
(result)->tv_nsec = (t1)->tv_nsec - (t2)->tv_nsec; \
|
||||
if ((result)->tv_nsec < 0) { \
|
||||
--(result)->tv_sec; \
|
||||
(result)->tv_nsec += 1000000000; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#if 0
|
||||
/* We do not support this on windows. */
|
||||
void npth_sigev_init (void);
|
||||
void npth_sigev_add (int signum);
|
||||
void npth_sigev_fini (void);
|
||||
sigset_t *npth_sigev_sigmask (void);
|
||||
int npth_sigev_get_pending (int *r_signum);
|
||||
#endif
|
||||
|
||||
#if 0 /* (Keep Emacsens' auto-indent happy.) */
|
||||
{
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*_NPTH_H*/
|
||||
Reference in New Issue
Block a user