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;
57 int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch)
65 * If we already have a host name, treat this argument as a
66 * port number. NB we have to treat this as a saved -P
67 * argument, so that it will be deferred until it's a good
70 int ret = cmdline_process_param("-P", argdup, 1, conf);
72 } else if (!strncmp(q, "telnet:", 7)) {
74 * If the hostname starts with "telnet:",
75 * set the protocol to Telnet and process
76 * the string as a Telnet URL.
81 if (q[0] == '/' && q[1] == '/')
83 conf_set_int(conf, CONF_protocol, PROT_TELNET);
85 p += host_strcspn(p, ":/");
90 conf_set_int(conf, CONF_port, atoi(p));
92 conf_set_int(conf, CONF_port, -1);
93 conf_set_str(conf, CONF_host, q);
97 * Otherwise, treat this argument as a host name.
100 while (*p && !isspace((unsigned char)*p))
104 conf_set_str(conf, CONF_host, q);
108 *allow_launch = TRUE;
115 char *make_default_wintitle(char *hostname)
117 return dupcat(hostname, " - ", appname, NULL);
121 * X11-forwarding-related things suitable for Gtk app.
124 char *platform_get_x_display(void) {
126 /* Try to take account of --display and what have you. */
127 if (!(display = gdk_get_display()))
128 /* fall back to traditional method */
129 display = getenv("DISPLAY");
130 return dupstr(display);
133 const int share_can_be_downstream = TRUE;
134 const int share_can_be_upstream = TRUE;
136 void setup(int single)
139 flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
140 default_protocol = be_default_protocol;
141 /* Find the appropriate default port. */
143 Backend *b = backend_from_proto(default_protocol);
144 default_port = 0; /* illegal */
146 default_port = b->default_port;