+++ /dev/null
-/*\r
- * Unix PuTTY main program.\r
- */\r
-\r
-#include <stdio.h>\r
-#include <ctype.h>\r
-#include <stdlib.h>\r
-#include <assert.h>\r
-#include <unistd.h>\r
-#include <gdk/gdk.h>\r
-\r
-#include "putty.h"\r
-#include "storage.h"\r
-\r
-/*\r
- * Stubs to avoid uxpty.c needing to be linked in.\r
- */\r
-const int use_pty_argv = FALSE;\r
-char **pty_argv; /* never used */\r
-\r
-/*\r
- * Clean up and exit.\r
- */\r
-void cleanup_exit(int code)\r
-{\r
- /*\r
- * Clean up.\r
- */\r
- sk_cleanup();\r
- random_save_seed();\r
- exit(code);\r
-}\r
-\r
-Backend *select_backend(Config *cfg)\r
-{\r
- Backend *back = backend_from_proto(cfg->protocol);\r
- assert(back != NULL);\r
- return back;\r
-}\r
-\r
-int cfgbox(Config *cfg)\r
-{\r
- char *title = dupcat(appname, " Configuration", NULL);\r
- int ret = do_config_box(title, cfg, 0, 0);\r
- sfree(title);\r
- return ret;\r
-}\r
-\r
-static int got_host = 0;\r
-\r
-const int use_event_log = 1, new_session = 1, saved_sessions = 1;\r
-\r
-int process_nonoption_arg(char *arg, Config *cfg, int *allow_launch)\r
-{\r
- char *p, *q = arg;\r
-\r
- if (got_host) {\r
- /*\r
- * If we already have a host name, treat this argument as a\r
- * port number. NB we have to treat this as a saved -P\r
- * argument, so that it will be deferred until it's a good\r
- * moment to run it.\r
- */\r
- int ret = cmdline_process_param("-P", arg, 1, cfg);\r
- assert(ret == 2);\r
- } else if (!strncmp(q, "telnet:", 7)) {\r
- /*\r
- * If the hostname starts with "telnet:",\r
- * set the protocol to Telnet and process\r
- * the string as a Telnet URL.\r
- */\r
- char c;\r
-\r
- q += 7;\r
- if (q[0] == '/' && q[1] == '/')\r
- q += 2;\r
- cfg->protocol = PROT_TELNET;\r
- p = q;\r
- while (*p && *p != ':' && *p != '/')\r
- p++;\r
- c = *p;\r
- if (*p)\r
- *p++ = '\0';\r
- if (c == ':')\r
- cfg->port = atoi(p);\r
- else\r
- cfg->port = -1;\r
- strncpy(cfg->host, q, sizeof(cfg->host) - 1);\r
- cfg->host[sizeof(cfg->host) - 1] = '\0';\r
- got_host = 1;\r
- } else {\r
- /*\r
- * Otherwise, treat this argument as a host name.\r
- */\r
- p = arg;\r
- while (*p && !isspace((unsigned char)*p))\r
- p++;\r
- if (*p)\r
- *p++ = '\0';\r
- strncpy(cfg->host, q, sizeof(cfg->host) - 1);\r
- cfg->host[sizeof(cfg->host) - 1] = '\0';\r
- got_host = 1;\r
- }\r
- if (got_host)\r
- *allow_launch = TRUE;\r
- return 1;\r
-}\r
-\r
-char *make_default_wintitle(char *hostname)\r
-{\r
- return dupcat(hostname, " - ", appname, NULL);\r
-}\r
-\r
-/*\r
- * X11-forwarding-related things suitable for Gtk app.\r
- */\r
-\r
-char *platform_get_x_display(void) {\r
- const char *display;\r
- /* Try to take account of --display and what have you. */\r
- if (!(display = gdk_get_display()))\r
- /* fall back to traditional method */\r
- display = getenv("DISPLAY");\r
- return dupstr(display);\r
-}\r
-\r
-int main(int argc, char **argv)\r
-{\r
- extern int pt_main(int argc, char **argv);\r
- sk_init();\r
- flags = FLAG_VERBOSE | FLAG_INTERACTIVE;\r
- default_protocol = be_default_protocol;\r
- /* Find the appropriate default port. */\r
- {\r
- Backend *b = backend_from_proto(default_protocol);\r
- default_port = 0; /* illegal */\r
- if (b)\r
- default_port = b->default_port;\r
- }\r
- return pt_main(argc, argv);\r
-}\r