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);
44 /* Create a pipe with an inheritable end. */
46 my_pipe (assuan_context_t ctx, assuan_fd_t fds[2], int inherit_idx)
48 return _gpgme_io_pipe (fds, inherit_idx);
52 /* Close the given file descriptor, created with _assuan_pipe or one
53 of the socket functions. */
55 my_close (assuan_context_t ctx, assuan_fd_t fd)
57 return _gpgme_io_close (fd);
62 my_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size)
64 return _gpgme_io_read (fd, buffer, size);
69 my_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size)
71 return _gpgme_io_write (fd, buffer, size);
76 my_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg,
79 #ifdef HAVE_W32_SYSTEM
83 return _gpgme_io_recvmsg (fd, msg, flags);
90 my_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg,
93 #ifdef HAVE_W32_SYSTEM
97 return _gpgme_io_sendmsg (fd, msg, flags);
102 /* If NAME is NULL, don't exec, just fork. FD_CHILD_LIST is modified
103 to reflect the value of the FD in the peer process (on
106 my_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
108 assuan_fd_t fd_in, assuan_fd_t fd_out,
109 assuan_fd_t *fd_child_list,
110 void (*atfork) (void *opaque, int reserved),
111 void *atforkvalue, unsigned int flags)
114 struct spawn_fd_item_s *fd_items;
128 while (fd_child_list[i] != ASSUAN_INVALID_FD)
131 /* fd_in, fd_out, terminator */
133 fd_items = calloc (i, sizeof (struct spawn_fd_item_s));
139 while (fd_child_list[i] != ASSUAN_INVALID_FD)
141 fd_items[i].fd = fd_child_list[i];
142 fd_items[i].dup_to = -1;
146 if (fd_in != ASSUAN_INVALID_FD)
148 fd_items[i].fd = fd_in;
149 fd_items[i].dup_to = 0;
152 if (fd_out != ASSUAN_INVALID_FD)
154 fd_items[i].fd = fd_out;
155 fd_items[i].dup_to = 1;
159 fd_items[i].dup_to = -1;
161 err = _gpgme_io_spawn (name, argv, IOSPAWN_FLAG_NOCLOSE, fd_items,
162 atfork, atforkvalue, r_pid);
169 while (fd_child_list[i] != ASSUAN_INVALID_FD)
171 fd_child_list[i] = fd_items[i].peer_name;
181 /* If action is 0, like waitpid. If action is 1, just release the PID? */
183 my_waitpid (assuan_context_t ctx, pid_t pid,
184 int nowait, int *status, int options)
186 #ifdef HAVE_W32_SYSTEM
187 CloseHandle ((HANDLE) pid);
189 /* We can't just release the PID, a waitpid is mandatory. But
190 NOWAIT in POSIX systems just means the caller already did the
191 waitpid for this child. */
193 return _gpgme_ath_waitpid (pid, status, options);
202 my_socketpair (assuan_context_t ctx, int namespace, int style,
203 int protocol, assuan_fd_t filedes[2])
205 #ifdef HAVE_W32_SYSTEM
209 /* FIXME: Debug output missing. */
210 return __assuan_socketpair (ctx, namespace, style, protocol, filedes);
215 struct assuan_system_hooks _gpgme_assuan_system_hooks =
217 ASSUAN_SYSTEM_HOOKS_VERSION,