ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/fdpass.C
(Generate patch)

Comparing rxvt-unicode/src/fdpass.C (file contents):
Revision 1.6 by root, Sun Jan 22 00:48:13 2006 UTC vs.
Revision 1.13 by ayin, Mon Sep 11 08:48:37 2006 UTC

1// This file is part of libptytty. Do not make local modifications.
2// http://software.schmorp.de/pkg/libptytty
3
1/*--------------------------------*-C-*---------------------------------* 4/*----------------------------------------------------------------------*
2 * File: fdpass.C 5 * File: fdpass.C
3 *----------------------------------------------------------------------* 6 *----------------------------------------------------------------------*
4 * 7 *
5 * All portions of code are copyright by their respective author/s. 8 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> 9 * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com>
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *----------------------------------------------------------------------*/ 24 *----------------------------------------------------------------------*/
22 25
23#include "../config.h" 26#include "../config.h"
24 27
28#include <cstddef> // needed by broken bsds for NULL used in sys/uio.h
29
30#include <sys/types.h>
25#include <sys/uio.h> 31#include <sys/uio.h>
26#include <sys/types.h>
27#include <sys/socket.h> 32#include <sys/socket.h>
28 33
29#include "fdpass.h" 34#include "libptytty.h"
30 35
31#ifndef CMSG_LEN // CMSG_SPACe && CMSG_LEN are rfc2292 extensions to unix 36#ifndef CMSG_LEN // CMSG_SPACE && CMSG_LEN are rfc2292 extensions to unix
32# define CMSG_LEN(len) (sizeof (cmsghdr) + len) 37# define CMSG_LEN(len) (sizeof (cmsghdr) + len)
33#endif 38#endif
34 39
35int 40bool
36ptytty_send_fd (int socket, int fd) 41ptytty::send_fd (int socket, int fd)
37{ 42{
38 msghdr msg; 43 msghdr msg;
39 iovec iov; 44 iovec iov;
40 char buf [CMSG_LEN (sizeof (int))]; 45 char buf [CMSG_LEN (sizeof (int))];
41 char data = 0; 46 char data = 0;
57 62
58 *(int *)CMSG_DATA (cmsg) = fd; 63 *(int *)CMSG_DATA (cmsg) = fd;
59 64
60 msg.msg_controllen = cmsg->cmsg_len; 65 msg.msg_controllen = cmsg->cmsg_len;
61 66
62 return sendmsg (socket, &msg, 0); 67 return sendmsg (socket, &msg, 0) >= 0;
63} 68}
64 69
65int 70int
66ptytty_recv_fd (int socket) 71ptytty::recv_fd (int socket)
67{ 72{
68 msghdr msg; 73 msghdr msg;
69 iovec iov; 74 iovec iov;
70 char buf [CMSG_LEN (sizeof (int))]; /* ancillary data buffer */ 75 char buf [CMSG_LEN (sizeof (int))]; /* ancillary data buffer */
71 char data = 1; 76 char data = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines