16 struct assuan_malloc_hooks _gpgme_assuan_malloc_hooks =
25 _gpgme_assuan_log_cb (assuan_context_t ctx, void *hook,
26 unsigned int cat, const char *msg)
31 _gpgme_debug (DEBUG_ASSUAN, "%s", msg);
37 my_usleep (assuan_context_t ctx, unsigned int usec)
39 /* FIXME: Add to ath. */
40 __assuan_usleep (ctx, usec);
43 /* Create a pipe with an inheritable end. */
45 my_pipe (assuan_context_t ctx, assuan_fd_t fds[2], int inherit_idx)
47 return _gpgme_io_pipe (fds, inherit_idx);
51 /* Close the given file descriptor, created with _assuan_pipe or one
52 of the socket functions. */
54 my_close (assuan_context_t ctx, assuan_fd_t fd)
56 return _gpgme_io_close (fd);
61 my_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size)
63 return _gpgme_io_read (fd, buffer, size);
68 my_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size)
70 return _gpgme_io_write (fd, buffer, size);
75 my_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg,
78 #ifdef HAVE_W32_SYSTEM
79 return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
81 return _gpgme_io_recvmsg (fd, msg, flags);
88 my_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg,
91 #ifdef HAVE_W32_SYSTEM
92 return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
94 return _gpgme_io_sendmsg (fd, msg, flags);
99 /* If NAME is NULL, don't exec, just fork. FD_CHILD_LIST is modified
100 to reflect the value of the FD in the peer process (on
103 my_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
105 assuan_fd_t fd_in, assuan_fd_t fd_out,
106 assuan_fd_t *fd_child_list,
107 void (*atfork) (void *opaque, int reserved),
108 void *atforkvalue, unsigned int flags)
111 struct spawn_fd_item_s *fd_items;
117 return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
120 while (fd_child_list[i] != ASSUAN_INVALID_FD)
122 /* fd_in, fd_out, terminator */
124 fd_items = malloc (sizeof (struct spawn_fd_item_s) * i);
126 return gpg_error_from_syserror ();
128 while (fd_child_list[i] != ASSUAN_INVALID_FD)
130 fd_items[i].fd = fd_child_list[i];
131 fd_items[i].dup_to = -1;
134 if (fd_in != ASSUAN_INVALID_FD)
136 fd_items[i].fd = fd_in;
137 fd_items[i].dup_to = 0;
140 if (fd_out != ASSUAN_INVALID_FD)
142 fd_items[i].fd = fd_out;
143 fd_items[i].dup_to = 1;
147 fd_items[i].dup_to = -1;
149 err = _gpgme_io_spawn (name, argv, 0, fd_items, r_pid);
154 while (fd_child_list[i] != ASSUAN_INVALID_FD)
156 fd_child_list[i] = fd_items[i].peer_name;
165 /* If action is 0, like waitpid. If action is 1, just release the PID? */
167 my_waitpid (assuan_context_t ctx, pid_t pid,
168 int nowait, int *status, int options)
170 #ifdef HAVE_W32_SYSTEM
171 CloseHandle ((HANDLE) pid);
173 /* We can't just release the PID, a waitpid is mandatory. But
174 NOWAIT in POSIX systems just means the caller already did the
175 waitpid for this child. */
177 return _gpgme_ath_waitpid (pid, status, options);
186 my_socketpair (assuan_context_t ctx, int namespace, int style,
187 int protocol, assuan_fd_t filedes[2])
189 assert ("Should never happen.");
190 return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
194 struct assuan_system_hooks _gpgme_assuan_system_hooks =
196 ASSUAN_SYSTEM_HOOKS_VERSION,