2 * Unix PuTTY main program.
16 * Stubs to avoid uxpty.c needing to be linked in.
18 const int use_pty_argv = FALSE;
19 char **pty_argv; /* never used */
24 void cleanup_exit(int code)
34 Backend *select_backend(Config *cfg)
38 for (i = 0; backends[i].backend != NULL; i++)
39 if (backends[i].protocol == cfg->protocol) {
40 back = backends[i].backend;
47 int cfgbox(Config *cfg)
49 return do_config_box("PuTTY Configuration", cfg, 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(char *arg, Config *cfg, int *allow_launch)
62 * If we already have a host name, treat this argument as a
63 * port number. NB we have to treat this as a saved -P
64 * argument, so that it will be deferred until it's a good
67 int ret = cmdline_process_param("-P", arg, 1, cfg);
69 } else if (!strncmp(q, "telnet:", 7)) {
71 * If the hostname starts with "telnet:",
72 * set the protocol to Telnet and process
73 * the string as a Telnet URL.
78 if (q[0] == '/' && q[1] == '/')
80 cfg->protocol = PROT_TELNET;
82 while (*p && *p != ':' && *p != '/')
91 strncpy(cfg->host, q, sizeof(cfg->host) - 1);
92 cfg->host[sizeof(cfg->host) - 1] = '\0';
96 * Otherwise, treat this argument as a host name.
99 while (*p && !isspace((unsigned char)*p))
103 strncpy(cfg->host, q, sizeof(cfg->host) - 1);
104 cfg->host[sizeof(cfg->host) - 1] = '\0';
108 *allow_launch = TRUE;
112 char *make_default_wintitle(char *hostname)
114 return dupcat(hostname, " - PuTTY", NULL);
118 * X11-forwarding-related things suitable for Gtk app.
121 const char platform_x11_best_transport[] = "unix";
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 int main(int argc, char **argv)
134 extern int pt_main(int argc, char **argv);
136 flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
137 default_protocol = be_default_protocol;
138 /* Find the appropriate default port. */
141 default_port = 0; /* illegal */
142 for (i = 0; backends[i].backend != NULL; i++)
143 if (backends[i].protocol == default_protocol) {
144 default_port = backends[i].backend->default_port;
148 return pt_main(argc, argv);