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 */
23 char *pty_osx_envrestore_prefix;
28 void cleanup_exit(int code)
38 Backend *select_backend(Conf *conf)
40 Backend *back = backend_from_proto(conf_get_int(conf, CONF_protocol));
45 int cfgbox(Conf *conf)
47 char *title = dupcat(appname, " Configuration", NULL);
48 int ret = do_config_box(title, conf, 0, 0);
53 static int got_host = 0;
55 const int use_event_log = 1, new_session = 1, saved_sessions = 1;
56 const int dup_check_launchable = 1;
58 int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch)
66 * If we already have a host name, treat this argument as a
67 * port number. NB we have to treat this as a saved -P
68 * argument, so that it will be deferred until it's a good
71 int ret = cmdline_process_param("-P", argdup, 1, conf);
73 } else if (!strncmp(q, "telnet:", 7)) {
75 * If the hostname starts with "telnet:",
76 * set the protocol to Telnet and process
77 * the string as a Telnet URL.
82 if (q[0] == '/' && q[1] == '/')
84 conf_set_int(conf, CONF_protocol, PROT_TELNET);
86 p += host_strcspn(p, ":/");
91 conf_set_int(conf, CONF_port, atoi(p));
93 conf_set_int(conf, CONF_port, -1);
94 conf_set_str(conf, CONF_host, q);
98 * Otherwise, treat this argument as a host name.
101 while (*p && !isspace((unsigned char)*p))
105 conf_set_str(conf, CONF_host, q);
109 *allow_launch = TRUE;
116 char *make_default_wintitle(char *hostname)
118 return dupcat(hostname, " - ", appname, NULL);
122 * X11-forwarding-related things suitable for Gtk app.
125 char *platform_get_x_display(void) {
127 /* Try to take account of --display and what have you. */
128 if (!(display = gdk_get_display()))
129 /* fall back to traditional method */
130 display = getenv("DISPLAY");
131 return dupstr(display);
134 const int share_can_be_downstream = TRUE;
135 const int share_can_be_upstream = TRUE;
137 void setup(int single)
140 flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
141 default_protocol = be_default_protocol;
142 /* Find the appropriate default port. */
144 Backend *b = backend_from_proto(default_protocol);
145 default_port = 0; /* illegal */
147 default_port = b->default_port;