2 * Unix PuTTY main program.
16 #include "gtkcompat.h"
19 * Stubs to avoid uxpty.c needing to be linked in.
21 const int use_pty_argv = FALSE;
22 char **pty_argv; /* never used */
27 void cleanup_exit(int code)
37 Backend *select_backend(Conf *conf)
39 Backend *back = backend_from_proto(conf_get_int(conf, CONF_protocol));
44 int cfgbox(Conf *conf)
46 char *title = dupcat(appname, " Configuration", NULL);
47 int ret = do_config_box(title, conf, 0, 0);
52 static int got_host = 0;
54 const int use_event_log = 1, new_session = 1, saved_sessions = 1;
56 int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch)
64 * If we already have a host name, treat this argument as a
65 * port number. NB we have to treat this as a saved -P
66 * argument, so that it will be deferred until it's a good
69 int ret = cmdline_process_param("-P", argdup, 1, conf);
71 } else if (!strncmp(q, "telnet:", 7)) {
73 * If the hostname starts with "telnet:",
74 * set the protocol to Telnet and process
75 * the string as a Telnet URL.
80 if (q[0] == '/' && q[1] == '/')
82 conf_set_int(conf, CONF_protocol, PROT_TELNET);
84 p += host_strcspn(p, ":/");
89 conf_set_int(conf, CONF_port, atoi(p));
91 conf_set_int(conf, CONF_port, -1);
92 conf_set_str(conf, CONF_host, q);
96 * Otherwise, treat this argument as a host name.
99 while (*p && !isspace((unsigned char)*p))
103 conf_set_str(conf, CONF_host, q);
107 *allow_launch = TRUE;
114 char *make_default_wintitle(char *hostname)
116 return dupcat(hostname, " - ", appname, NULL);
120 * X11-forwarding-related things suitable for Gtk app.
123 char *platform_get_x_display(void) {
125 /* Try to take account of --display and what have you. */
126 if (!(display = gdk_get_display()))
127 /* fall back to traditional method */
128 display = getenv("DISPLAY");
129 return dupstr(display);
132 const int share_can_be_downstream = TRUE;
133 const int share_can_be_upstream = TRUE;
135 int main(int argc, char **argv)
137 extern int pt_main(int argc, char **argv);
141 flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
142 default_protocol = be_default_protocol;
143 /* Find the appropriate default port. */
145 Backend *b = backend_from_proto(default_protocol);
146 default_port = 0; /* illegal */
148 default_port = b->default_port;
150 ret = pt_main(argc, argv);
152 return ret; /* not reached, but placates optimisers */