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

Comparing rxvt-unicode/src/rxvtdaemon.C (file contents):
Revision 1.7 by root, Thu Jul 29 15:25:43 2004 UTC vs.
Revision 1.16 by sf-exg, Sun May 1 13:54:27 2011 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvtdaemon.C 2 * File: rxvtdaemon.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2007 Marc Lehmann <schmorp@schmorp.de>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
24#include <cstring> 24#include <cstring>
25#include <cstdio> 25#include <cstdio>
26 26
27#include <inttypes.h> 27#include <inttypes.h>
28#include <unistd.h> 28#include <unistd.h>
29#include <errno.h>
30#include <sys/types.h>
29#include <sys/utsname.h> 31#include <sys/utsname.h>
30#include <limits.h>
31 32
32#include "rxvtdaemon.h" 33#include "rxvtdaemon.h"
33 34
34char *rxvt_connection::unix_sockname () 35char *rxvt_connection::unix_sockname ()
35{ 36{
40 { 41 {
41 struct utsname u; 42 struct utsname u;
42 uname (&u); 43 uname (&u);
43 44
44 path = getenv ("HOME"); 45 path = getenv ("HOME");
45 snprintf (name, PATH_MAX, "%s/.rxvt-%s", 46 snprintf (name, PATH_MAX, "%s/.rxvt-unicode-%s",
46 path ? path : "/tmp", 47 path ? path : "/tmp",
47 u.nodename); 48 u.nodename);
48 49
49 path = name; 50 path = name;
50 } 51 }
53} 54}
54 55
55void rxvt_connection::send (const char *data, int len) 56void rxvt_connection::send (const char *data, int len)
56{ 57{
57 uint8_t s[2]; 58 uint8_t s[2];
59
60 if (len > 65535)
61 len = 65535;
58 62
59 s[0] = len >> 8; s[1] = len; 63 s[0] = len >> 8; s[1] = len;
60 64
61 write (fd, s, 2); 65 write (fd, s, 2);
62 write (fd, data, len); 66 write (fd, data, len);
74 78
75 if (read (fd, s, 2) != 2) 79 if (read (fd, s, 2) != 2)
76 return false; 80 return false;
77 81
78 l = (s[0] << 8) + s[1]; 82 l = (s[0] << 8) + s[1];
79 if (l > 4096) 83 if (l > 65535)
80 return false; 84 return false;
81 85
82 if (len) 86 if (len)
83 *len = l; 87 *len = l;
84 88

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines