Blame src/priv-io.h

Packit d7e8d0
/* priv-io.h - Interface to the private I/O functions.
Packit d7e8d0
   Copyright (C) 2000 Werner Koch (dd9jn)
Packit d7e8d0
   Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH
Packit d7e8d0
Packit d7e8d0
   This file is part of GPGME.
Packit d7e8d0
Packit d7e8d0
   GPGME is free software; you can redistribute it and/or modify it
Packit d7e8d0
   under the terms of the GNU Lesser General Public License as
Packit d7e8d0
   published by the Free Software Foundation; either version 2.1 of
Packit d7e8d0
   the License, or (at your option) any later version.
Packit d7e8d0
Packit d7e8d0
   GPGME is distributed in the hope that it will be useful, but
Packit d7e8d0
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit d7e8d0
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit d7e8d0
   Lesser General Public License for more details.
Packit d7e8d0
Packit d7e8d0
   You should have received a copy of the GNU Lesser General Public
Packit d7e8d0
   License along with this program; if not, write to the Free Software
Packit d7e8d0
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
Packit d7e8d0
   02111-1307, USA.  */
Packit d7e8d0
Packit d7e8d0
#ifndef IO_H
Packit d7e8d0
#define IO_H
Packit d7e8d0
Packit d7e8d0
#ifdef HAVE_W32_SYSTEM
Packit d7e8d0
# include <winsock2.h>
Packit d7e8d0
# include <windows.h>
Packit d7e8d0
#else
Packit d7e8d0
# include <sys/socket.h>
Packit d7e8d0
#endif
Packit d7e8d0
Packit d7e8d0
/* For pid_t.  */
Packit d7e8d0
#ifdef HAVE_SYS_TYPES_H
Packit d7e8d0
# include <sys/types.h>
Packit d7e8d0
#endif
Packit d7e8d0
Packit d7e8d0
Packit d7e8d0
/* A single file descriptor passed to spawn.  For child fds, dup_to
Packit d7e8d0
   specifies the fd it should become in the child, but only 0, 1 and 2
Packit d7e8d0
   are valid values (due to a limitation in the W32 code).  As return
Packit d7e8d0
   value, the PEER_NAME fields specify the name of the file
Packit d7e8d0
   descriptor in the spawned process, or -1 if no change.  If ARG_LOC
Packit d7e8d0
   is not 0, it specifies the index in the argument vector of the
Packit d7e8d0
   program which contains a numerical representation of the file
Packit d7e8d0
   descriptor for translation purposes.  */
Packit d7e8d0
struct spawn_fd_item_s
Packit d7e8d0
{
Packit d7e8d0
  int fd;
Packit d7e8d0
  int dup_to;
Packit d7e8d0
  int peer_name;
Packit d7e8d0
  int arg_loc;
Packit d7e8d0
};
Packit d7e8d0
Packit d7e8d0
struct io_select_fd_s
Packit d7e8d0
{
Packit d7e8d0
  int fd;
Packit d7e8d0
  int for_read;
Packit d7e8d0
  int for_write;
Packit d7e8d0
  int signaled;
Packit d7e8d0
  void *opaque;
Packit d7e8d0
};
Packit d7e8d0
Packit d7e8d0
/* These function are either defined in posix-io.c or w32-io.c.  */
Packit d7e8d0
void _gpgme_io_subsystem_init (void);
Packit d7e8d0
int _gpgme_io_socket (int namespace, int style, int protocol);
Packit d7e8d0
int _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen);
Packit d7e8d0
int _gpgme_io_read (int fd, void *buffer, size_t count);
Packit d7e8d0
int _gpgme_io_write (int fd, const void *buffer, size_t count);
Packit d7e8d0
int _gpgme_io_pipe (int filedes[2], int inherit_idx);
Packit d7e8d0
int _gpgme_io_close (int fd);
Packit d7e8d0
typedef void (*_gpgme_close_notify_handler_t) (int,void*);
Packit d7e8d0
int _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler,
Packit d7e8d0
				void *value);
Packit d7e8d0
int _gpgme_io_set_nonblocking (int fd);
Packit d7e8d0
Packit d7e8d0
/* Under Windows do not allocate a console.  */
Packit d7e8d0
#define IOSPAWN_FLAG_DETACHED 1
Packit d7e8d0
/* A flag to tell the spawn function to allow the child process to set
Packit d7e8d0
   the foreground window. */
Packit d7e8d0
#define IOSPAWN_FLAG_ALLOW_SET_FG 2
Packit d7e8d0
/* Don't close any child FDs.  */
Packit d7e8d0
#define IOSPAWN_FLAG_NOCLOSE 4
Packit Service 30b792
/* Set show window to true for windows */
Packit Service 30b792
#define IOSPAWN_FLAG_SHOW_WINDOW 8
Packit d7e8d0
Packit d7e8d0
/* Spawn the executable PATH with ARGV as arguments.  After forking
Packit d7e8d0
   close all fds except for those in FD_LIST in the child, then
Packit d7e8d0
   optionally dup() the child fds.  Finally, all fds in the list are
Packit d7e8d0
   closed in the parent.  */
Packit d7e8d0
int _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
Packit d7e8d0
		     struct spawn_fd_item_s *fd_list,
Packit d7e8d0
		     void (*atfork) (void *opaque, int reserved),
Packit d7e8d0
		     void *atforkvalue, pid_t *r_pid);
Packit d7e8d0
Packit d7e8d0
int _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock);
Packit d7e8d0
Packit d7e8d0
/* Write the printable version of FD to the buffer BUF of length
Packit d7e8d0
   BUFLEN.  The printable version is the representation on the command
Packit d7e8d0
   line that the child process expects.  */
Packit d7e8d0
int _gpgme_io_fd2str (char *buf, int buflen, int fd);
Packit d7e8d0
Packit d7e8d0
/* Duplicate a file descriptor.  This is more restrictive than dup():
Packit d7e8d0
   it assumes that the resulting file descriptors are essentially
Packit d7e8d0
   co-equal (for example, no private offset), which is true for pipes
Packit d7e8d0
   and sockets (but not files) under Unix with the standard dup()
Packit d7e8d0
   function.  Basically, this function is used to reference count the
Packit d7e8d0
   status output file descriptor shared between GPGME and libassuan
Packit d7e8d0
   (in engine-gpgsm.c).  */
Packit d7e8d0
int _gpgme_io_dup (int fd);
Packit d7e8d0
Packit d7e8d0
#ifndef HAVE_W32_SYSTEM
Packit d7e8d0
int _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags);
Packit d7e8d0
int _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags);
Packit d7e8d0
int _gpgme_io_waitpid (int pid, int hang, int *r_status, int *r_signal);
Packit d7e8d0
#endif
Packit d7e8d0
Packit d7e8d0
#endif /* IO_H */