… | |
… | |
166 | return err (); |
166 | return err (); |
167 | |
167 | |
168 | if (!strcmp (tok, "END")) |
168 | if (!strcmp (tok, "END")) |
169 | break; |
169 | break; |
170 | else if (!strcmp (tok, "ENV") && recv (tok)) |
170 | else if (!strcmp (tok, "ENV") && recv (tok)) |
171 | envv->push_back (tok.get ()); |
171 | envv->push_back (strdup (tok)); |
172 | else if (!strcmp (tok, "CWD") && recv (tok)) |
172 | else if (!strcmp (tok, "CWD") && recv (tok)) |
173 | { |
173 | { |
174 | if (chdir (tok)) |
174 | if (chdir (tok)) |
175 | err ("unable to change to working directory to '%s': %s", |
175 | err ("unable to change to working directory to '%s': %s", |
176 | (char *)tok, strerror (errno)); |
176 | (char *)tok, strerror (errno)); |
177 | } |
177 | } |
178 | else if (!strcmp (tok, "ARG") && recv (tok)) |
178 | else if (!strcmp (tok, "ARG") && recv (tok)) |
179 | argv->push_back (tok.get ()); |
179 | argv->push_back (strdup (tok)); |
180 | else |
180 | else |
181 | return err ("protocol error: unexpected NEW token"); |
181 | return err ("protocol error: unexpected NEW token"); |
182 | } |
182 | } |
183 | |
183 | |
184 | envv->push_back (0); |
184 | envv->push_back (0); |
… | |
… | |
186 | { |
186 | { |
187 | rxvt_term *term = new rxvt_term; |
187 | rxvt_term *term = new rxvt_term; |
188 | |
188 | |
189 | term->log_hook = &log_cb; |
189 | term->log_hook = &log_cb; |
190 | term->getfd_hook = &getfd_cb; |
190 | term->getfd_hook = &getfd_cb; |
191 | term->argv = argv; |
|
|
192 | term->envv = envv; |
|
|
193 | |
191 | |
194 | bool success; |
192 | bool success; |
195 | |
193 | |
196 | try |
194 | try |
197 | { |
195 | { |
198 | success = term->init (argv->size (), argv->begin ()); |
196 | success = term->init (argv, envv); |
199 | } |
197 | } |
200 | catch (const class rxvt_failure_exception &e) |
198 | catch (const class rxvt_failure_exception &e) |
201 | { |
199 | { |
202 | success = false; |
200 | success = false; |
203 | } |
201 | } |
… | |
… | |
222 | int opt_fork, opt_opendisplay, opt_quiet; |
220 | int opt_fork, opt_opendisplay, opt_quiet; |
223 | |
221 | |
224 | int |
222 | int |
225 | main (int argc, const char *const *argv) |
223 | main (int argc, const char *const *argv) |
226 | { |
224 | { |
|
|
225 | rxvt_init (); |
|
|
226 | |
227 | for (int i = 1; i < argc; i++) |
227 | for (int i = 1; i < argc; i++) |
228 | { |
228 | { |
229 | if (!strcmp (argv [i], "-f") || !strcmp (argv [i], "--fork")) |
229 | if (!strcmp (argv [i], "-f") || !strcmp (argv [i], "--fork")) |
230 | opt_fork = 1; |
230 | opt_fork = 1; |
231 | else if (!strcmp (argv [i], "-o") || !strcmp (argv [i], "--opendisplay")) |
231 | else if (!strcmp (argv [i], "-o") || !strcmp (argv [i], "--opendisplay")) |
… | |
… | |
237 | rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]); |
237 | rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]); |
238 | return EXIT_FAILURE; |
238 | return EXIT_FAILURE; |
239 | } |
239 | } |
240 | } |
240 | } |
241 | |
241 | |
242 | rxvt_init (); |
|
|
243 | |
|
|
244 | chdir ("/"); |
242 | chdir ("/"); |
245 | |
243 | |
246 | if (opt_opendisplay) |
244 | if (opt_opendisplay) |
247 | displays.get (getenv ("DISPLAY")); // open display and never release it |
245 | displays.get (getenv ("DISPLAY")); // open display and never release it |
248 | |
246 | |