diff options
Diffstat (limited to 'assuan/assuan-defs.h')
-rw-r--r-- | assuan/assuan-defs.h | 93 |
1 files changed, 61 insertions, 32 deletions
diff --git a/assuan/assuan-defs.h b/assuan/assuan-defs.h index b1d9f3ef..e2d0f52b 100644 --- a/assuan/assuan-defs.h +++ b/assuan/assuan-defs.h @@ -1,5 +1,5 @@ /* assuan-defs.c - Internal definitions to Assuan - * Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. * * This file is part of Assuan. * @@ -40,17 +40,6 @@ #endif #ifdef HAVE_W32_SYSTEM -#define AF_LOCAL AF_UNIX -/* We need to prefix the structure with a sockaddr_in header so we can - use it later for sendto and recvfrom. */ -struct sockaddr_un -{ - short sun_family; - unsigned short sun_port; - struct in_addr sun_addr; - char sun_path[108-2-4]; /* Path name. */ -}; - /* Not needed anymore because the current mingw32 defines this in sys/types.h */ /* typedef int ssize_t; */ @@ -80,12 +69,16 @@ struct assuan_io /* Routine to write to output_fd. */ ssize_t (*writefnc) (assuan_context_t, const void *, size_t); /* Send a file descriptor. */ - assuan_error_t (*sendfd) (assuan_context_t, int); + assuan_error_t (*sendfd) (assuan_context_t, assuan_fd_t); /* Receive a file descriptor. */ - assuan_error_t (*receivefd) (assuan_context_t, int *); + assuan_error_t (*receivefd) (assuan_context_t, assuan_fd_t *); }; +/* The global variable with the optional hook fucntions. */ +extern struct assuan_io_hooks _assuan_io_hooks; + + /* The context we use with most functions. */ struct assuan_context_s { @@ -103,6 +96,14 @@ struct assuan_context_s int confidential; int is_server; /* Set if this is context belongs to a server */ int in_inquire; + int in_process_next; + int in_command; + + /* The following members are used by assuan_inquire_ext. */ + int (*inquire_cb) (void *cb_data, int rc, unsigned char *buf, size_t len); + void *inquire_cb_data; + void *inquire_membuf; + char *hello_line; char *okay_line; /* See assuan_set_okay_line() */ @@ -111,7 +112,7 @@ struct assuan_context_s FILE *log_fp; struct { - int fd; + assuan_fd_t fd; int eof; char line[LINELENGTH]; int linelen; /* w/o CR, LF - might not be the same as @@ -125,7 +126,7 @@ struct assuan_context_s } inbound; struct { - int fd; + assuan_fd_t fd; struct { FILE *fp; char line[LINELENGTH]; @@ -137,8 +138,10 @@ struct assuan_context_s int pipe_mode; /* We are in pipe mode, i.e. we can handle just one connection and must terminate then. */ pid_t pid; /* The pid of the peer. */ - int listen_fd; /* The fd we are listening on (used by socket servers) */ - int connected_fd; /* helper */ + assuan_fd_t listen_fd; /* The fd we are listening on (used by + socket servers) */ + assuan_sock_nonce_t listen_nonce; /* Used with LISTEN_FD. */ + assuan_fd_t connected_fd; /* helper */ struct { int valid; /* Whether this structure has valid information. */ @@ -162,7 +165,7 @@ struct assuan_context_s int bufferoffset; /* Offset of start of buffer. */ int buffersize; /* Bytes buffered. */ - int pendingfds[5]; /* Array to save received descriptors. */ + assuan_fd_t pendingfds[5]; /* Array to save received descriptors. */ int pendingfdscount; /* Number of received descriptors. */ } uds; @@ -188,15 +191,15 @@ struct assuan_context_s /* If set, this is called right before logging an I/O line. With DIRECTION set to 1 it is called for an output oeration; 0 means an input operation. If bit 0 is set in the return value, the - logging of the will be suppressed. With bit 1 set, the entire - line will be ignored. */ + logging of the line will be suppressed. With bit 1 set, the + entire line will be ignored. */ unsigned int (*io_monitor)(assuan_context_t ctx, int direction, const char *line, size_t linelen); - int input_fd; /* set by INPUT command */ - int output_fd; /* set by OUTPUT command */ + assuan_fd_t input_fd; /* Set by the INPUT command. */ + assuan_fd_t output_fd; /* Set by the OUTPUT command. */ /* io routines. */ struct assuan_io *io; @@ -228,17 +231,22 @@ assuan_error_t _assuan_read_from_server (assuan_context_t ctx, /*-- assuan-error.c --*/ +/*-- assuan-inquire.c --*/ +int _assuan_inquire_ext_cb (assuan_context_t ctx); +void _assuan_inquire_release (assuan_context_t ctx); -/* Map error codes as used in this implementaion to the libgpg-error +/* Map error codes as used in this implementation to the libgpg-error codes. */ assuan_error_t _assuan_error (int oldcode); +/* Check if ERR means EAGAIN. */ +int _assuan_error_is_eagain (assuan_error_t err); -/* Extrac the erro code from A. This works for both the old and the - new style error codes. This needs to be whenever an error code is - compared. */ +/* Extract the error code from A. This works for both the old and the + new style error codes. This needs to be used whenever an error + code is compared. */ #define err_code(a) ((a) & 0x00ffffff) -/* Check whether A is the erro code for EOF. We allow forold and new +/* Check whether A is the erro code for EOF. We allow for old and new style EOF error codes here. */ #define err_is_eof(a) ((a) == (-1) || err_code (a) == 16383) @@ -284,6 +292,8 @@ pid_t _assuan_waitpid (pid_t pid, int *status, int options); ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size); ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size); +ssize_t _assuan_io_read (assuan_fd_t fd, void *buffer, size_t size); +ssize_t _assuan_io_write (assuan_fd_t fd, const void *buffer, size_t size); #ifdef HAVE_W32_SYSTEM int _assuan_simple_sendmsg (assuan_context_t ctx, void *msg); int _assuan_simple_recvmsg (assuan_context_t ctx, void *msg); @@ -292,11 +302,21 @@ ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg); ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg); #endif +void _assuan_usleep (unsigned int usec); + + /*-- assuan-socket.c --*/ -int _assuan_close (int fd); -int _assuan_sock_new (int domain, int type, int proto); -int _assuan_sock_bind (int sockfd, struct sockaddr *addr, int addrlen); -int _assuan_sock_connect (int sockfd, struct sockaddr *addr, int addrlen); +int _assuan_close (assuan_fd_t fd); +assuan_fd_t _assuan_sock_new (int domain, int type, int proto); +int _assuan_sock_connect (assuan_fd_t sockfd, + struct sockaddr *addr, int addrlen); +int _assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen); +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); +#ifdef HAVE_W32_SYSTEM +int _assuan_sock_wsa2errno (int err); +#endif #ifdef HAVE_FOPENCOOKIE /* We have to implement funopen in terms of glibc's fopencookie. */ @@ -329,4 +349,13 @@ int putc_unlocked (int c, FILE *stream); #define DIMof(type,member) DIM(((type *)0)->member) +#if HAVE_W32_SYSTEM +#define SOCKET2HANDLE(s) ((void *)(s)) +#define HANDLE2SOCKET(h) ((unsigned int)(h)) +#else +#define SOCKET2HANDLE(s) (s) +#define HANDLE2SOCKET(h) (h) +#endif + + #endif /*ASSUAN_DEFS_H*/ |