2 * Unix PuTTY main program.
18 void cleanup_exit(int code
)
28 Backend
*select_backend(Config
*cfg
)
32 for (i
= 0; backends
[i
].backend
!= NULL
; i
++)
33 if (backends
[i
].protocol
== cfg
->protocol
) {
34 back
= backends
[i
].backend
;
41 int cfgbox(Config
*cfg
)
43 return do_config_box("PuTTY Configuration", cfg
, 0, 0);
46 static int got_host
= 0;
48 const int use_event_log
= 1, new_session
= 1, saved_sessions
= 1;
50 int process_nonoption_arg(char *arg
, Config
*cfg
)
56 * If we already have a host name, treat this argument as a
57 * port number. NB we have to treat this as a saved -P
58 * argument, so that it will be deferred until it's a good
61 int ret
= cmdline_process_param("-P", arg
, 1, cfg
);
63 } else if (!strncmp(q
, "telnet:", 7)) {
65 * If the hostname starts with "telnet:",
66 * set the protocol to Telnet and process
67 * the string as a Telnet URL.
72 if (q
[0] == '/' && q
[1] == '/')
74 cfg
->protocol
= PROT_TELNET
;
76 while (*p
&& *p
!= ':' && *p
!= '/')
85 strncpy(cfg
->host
, q
, sizeof(cfg
->host
) - 1);
86 cfg
->host
[sizeof(cfg
->host
) - 1] = '\0';
90 * Otherwise, treat this argument as a host name.
93 while (*p
&& !isspace((unsigned char)*p
))
97 strncpy(cfg
->host
, q
, sizeof(cfg
->host
) - 1);
98 cfg
->host
[sizeof(cfg
->host
) - 1] = '\0';
104 char *make_default_wintitle(char *hostname
)
106 return dupcat(hostname
, " - PuTTY", NULL
);
110 * X11-forwarding-related things suitable for Gtk app.
113 const char platform_x11_best_transport
[] = "unix";
115 char *platform_get_x_display(void) {
117 /* Try to take account of --display and what have you. */
118 if (!(display
= gdk_get_display()))
119 /* fall back to traditional method */
120 display
= getenv("DISPLAY");
121 return dupstr(display
);
124 int main(int argc
, char **argv
)
126 extern int pt_main(int argc
, char **argv
);
128 flags
= FLAG_VERBOSE
| FLAG_INTERACTIVE
;
129 default_protocol
= be_default_protocol
;
130 /* Find the appropriate default port. */
133 default_port
= 0; /* illegal */
134 for (i
= 0; backends
[i
].backend
!= NULL
; i
++)
135 if (backends
[i
].protocol
== default_protocol
) {
136 default_port
= backends
[i
].backend
->default_port
;
140 return pt_main(argc
, argv
);