fdpass.c revision d965dc8785aeb06eb504e88796d532e5084d23cd
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen Copyright (c) 2002 Timo Sirainen
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen Permission is hereby granted, free of charge, to any person obtaining
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen a copy of this software and associated documentation files (the
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen "Software"), to deal in the Software without restriction, including
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen without limitation the rights to use, copy, modify, merge, publish,
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen distribute, sublicense, and/or sell copies of the Software, and to
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen permit persons to whom the Software is furnished to do so, subject to
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen the following conditions:
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen The above copyright notice and this permission notice shall be
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen included in all copies or substantial portions of the Software.
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen (((len) + sizeof(size_t) - 1) & ~(sizeof(size_t) - 1))
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen (CMSG_ALIGN(len) + CMSG_ALIGN(sizeof(struct cmsghdr)))
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainenssize_t fd_send(int handle, int send_fd, const void *data, size_t size)
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen /* at least one byte is required to be sent with fd passing */
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen /* set the control and controllen before CMSG_FIRSTHDR() */
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen /* set the real length we want to use. it's different than
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen sizeof(buf) in 64bit systems. */
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainenssize_t fd_read(int handle, void *data, size_t size, int *fd)
8aeae03f9f447c8a792b215c9fb954468053c556Timo Sirainen /* at least one byte transferred - we should have the fd now */