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

Comparing rxvt-unicode/src/rxvtd.C (file contents):
Revision 1.9 by pcg, Fri Feb 13 13:28:17 2004 UTC vs.
Revision 1.10 by pcg, Wed Mar 17 05:15:02 2004 UTC

17#include <cerrno> 17#include <cerrno>
18 18
19extern char **environ; 19extern char **environ;
20 20
21struct server : rxvt_connection { 21struct server : rxvt_connection {
22 log_callback log_cb;
23
22 void read_cb (io_watcher &w, short revents); io_watcher read_ev; 24 void read_cb (io_watcher &w, short revents); io_watcher read_ev;
25 void log_msg (const char *msg);
23 26
24 server (int fd) 27 server (int fd)
25 : read_ev (this, &server::read_cb) 28 : read_ev (this, &server::read_cb),
29 log_cb (this, &server::log_msg)
26 { 30 {
27 this->fd = fd; 31 this->fd = fd;
28 read_ev.start (fd, EVENT_READ); 32 read_ev.start (fd, EVENT_READ);
29 } 33 }
30 34
80 84
81 if (fd2 >= 0) 85 if (fd2 >= 0)
82 new server (fd2); 86 new server (fd2);
83} 87}
84 88
89void server::log_msg (const char *msg)
90{
91 send ("MSG"), send (msg);
92}
93
85void server::err (const char *format, ...) 94void server::err (const char *format, ...)
86{ 95{
87 if (format) 96 if (format)
88 { 97 {
89 char err[1024]; 98 char err[1024];
91 va_list ap; 100 va_list ap;
92 va_start (ap, format); 101 va_start (ap, format);
93 vsnprintf (err, 1024, format, ap); 102 vsnprintf (err, 1024, format, ap);
94 va_end (ap); 103 va_end (ap);
95 104
96 send ("ERR"), send (err); 105 send ("MSG"), send (err);
97 } 106 }
98 107
108 send ("END", 0);
99 close (fd); 109 close (fd);
100 delete this; 110 delete this;
101} 111}
102 112
103void server::read_cb (io_watcher &w, short revents) 113void server::read_cb (io_watcher &w, short revents)
136 146
137 { 147 {
138 char **old_environ = environ; 148 char **old_environ = environ;
139 environ = envv->begin (); 149 environ = envv->begin ();
140 150
141 rxvt_term *term = rxvt_init (argv->size (), argv->begin ()); 151 rxvt_term *term = new rxvt_term;
142 152
153 term->log_hook = &log_cb;
143 term->argv = argv; 154 term->argv = argv;
144 term->envv = envv; 155 term->envv = envv;
145 156
157 bool success;
158
159 try
160 {
161 success = term->init (argv->size (), argv->begin ());
162 }
163 catch (const class rxvt_failure_exception &e)
164 {
165 success = false;
166 }
167
146 environ = old_environ; 168 environ = old_environ;
169
170 if (!success)
171 term->destroy ();
172
173 send ("END"); send (success ? 1 : 0);
147 } 174 }
148 } 175 }
149 else 176 else
150 return err ("protocol error: request '%s' unsupported.", (char *)tok); 177 return err ("protocol error: request '%s' unsupported.", (char *)tok);
151 } 178 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines