17 struct assuan_malloc_hooks _gpgme_assuan_malloc_hooks =
26 _gpgme_assuan_log_cb (assuan_context_t ctx, void *hook,
27 unsigned int cat, const char *msg)
32 _gpgme_debug (DEBUG_ASSUAN, "%s", msg);
38 my_usleep (assuan_context_t ctx, unsigned int usec)
40 /* FIXME: Add to ath. */
41 __assuan_usleep (ctx, usec);
45 /* Create a pipe with an inheritable end. */
47 my_pipe (assuan_context_t ctx, assuan_fd_t fds[2], int inherit_idx)
52 res = _gpgme_io_pipe (gfds, inherit_idx);
55 fds[0] = (assuan_fd_t) gfds[0];
56 fds[1] = (assuan_fd_t) gfds[1];
62 /* Close the given file descriptor, created with _assuan_pipe or one
63 of the socket functions. */
65 my_close (assuan_context_t ctx, assuan_fd_t fd)
67 return _gpgme_io_close ((int) fd);
72 my_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size)
74 return _gpgme_io_read ((int) fd, buffer, size);
79 my_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size)
81 return _gpgme_io_write ((int) fd, buffer, size);
86 my_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg,
89 #ifdef HAVE_W32_SYSTEM
90 gpg_err_set_errno (ENOSYS);
93 return _gpgme_io_recvmsg ((int) fd, msg, flags);
100 my_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg,
103 #ifdef HAVE_W32_SYSTEM
104 gpg_err_set_errno (ENOSYS);
107 return _gpgme_io_sendmsg ((int) fd, msg, flags);
112 /* If NAME is NULL, don't exec, just fork. FD_CHILD_LIST is modified
113 to reflect the value of the FD in the peer process (on
116 my_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
118 assuan_fd_t fd_in, assuan_fd_t fd_out,
119 assuan_fd_t *fd_child_list,
120 void (*atfork) (void *opaque, int reserved),
121 void *atforkvalue, unsigned int flags)
124 struct spawn_fd_item_s *fd_items;
131 gpg_err_set_errno (ENOSYS);
138 while (fd_child_list[i] != ASSUAN_INVALID_FD)
141 /* fd_in, fd_out, terminator */
143 fd_items = calloc (i, sizeof (struct spawn_fd_item_s));
149 while (fd_child_list[i] != ASSUAN_INVALID_FD)
151 fd_items[i].fd = (int) fd_child_list[i];
152 fd_items[i].dup_to = -1;
156 if (fd_in != ASSUAN_INVALID_FD)
158 fd_items[i].fd = (int) fd_in;
159 fd_items[i].dup_to = 0;
162 if (fd_out != ASSUAN_INVALID_FD)
164 fd_items[i].fd = (int) fd_out;
165 fd_items[i].dup_to = 1;
169 fd_items[i].dup_to = -1;
171 err = _gpgme_io_spawn (name, (char*const*)argv, IOSPAWN_FLAG_NOCLOSE,
172 fd_items, atfork, atforkvalue, r_pid);
179 while (fd_child_list[i] != ASSUAN_INVALID_FD)
181 fd_child_list[i] = (assuan_fd_t) fd_items[i].peer_name;
191 /* If action is 0, like waitpid. If action is 1, just release the PID? */
193 my_waitpid (assuan_context_t ctx, pid_t pid,
194 int nowait, int *status, int options)
196 #ifdef HAVE_W32_SYSTEM
197 CloseHandle ((HANDLE) pid);
199 /* We can't just release the PID, a waitpid is mandatory. But
200 NOWAIT in POSIX systems just means the caller already did the
201 waitpid for this child. */
203 return _gpgme_ath_waitpid (pid, status, options);
212 my_socketpair (assuan_context_t ctx, int namespace, int style,
213 int protocol, assuan_fd_t filedes[2])
215 #ifdef HAVE_W32_SYSTEM
216 gpg_err_set_errno (ENOSYS);
219 /* FIXME: Debug output missing. */
220 return __assuan_socketpair (ctx, namespace, style, protocol, filedes);
226 my_socket (assuan_context_t ctx, int namespace, int style, int protocol)
228 return _gpgme_io_socket (namespace, style, protocol);
233 my_connect (assuan_context_t ctx, int sock, struct sockaddr *addr,
236 return _gpgme_io_connect (sock, addr, length);
240 struct assuan_system_hooks _gpgme_assuan_system_hooks =
242 ASSUAN_SYSTEM_HOOKS_VERSION,