2 * Unix PuTTY main program.
17 * - Better control of the individual config box features.
18 * + SSH packet logging shouldn't be mentioned in pterm, and in
19 * fact not PuTTYtel either.
20 * + Keepalives, and the Connection panel in general, shouldn't
21 * crop up in pterm. (And perhaps also not mid-session in
28 void cleanup_exit(int code
)
38 Backend
*select_backend(Config
*cfg
)
42 for (i
= 0; backends
[i
].backend
!= NULL
; i
++)
43 if (backends
[i
].protocol
== cfg
->protocol
) {
44 back
= backends
[i
].backend
;
51 int cfgbox(Config
*cfg
)
53 return do_config_box("PuTTY Configuration", cfg
, 0);
56 static int got_host
= 0;
58 const int use_event_log
= 1, new_session
= 1, saved_sessions
= 1;
60 int process_nonoption_arg(char *arg
, Config
*cfg
)
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", arg
, 1, cfg
);
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 cfg
->protocol
= PROT_TELNET
;
86 while (*p
&& *p
!= ':' && *p
!= '/')
95 strncpy(cfg
->host
, q
, sizeof(cfg
->host
) - 1);
96 cfg
->host
[sizeof(cfg
->host
) - 1] = '\0';
100 * Otherwise, treat this argument as a host name.
103 while (*p
&& !isspace((unsigned char)*p
))
107 strncpy(cfg
->host
, q
, sizeof(cfg
->host
) - 1);
108 cfg
->host
[sizeof(cfg
->host
) - 1] = '\0';
114 char *make_default_wintitle(char *hostname
)
116 return dupcat(hostname
, " - PuTTY", NULL
);
119 int main(int argc
, char **argv
)
121 extern int pt_main(int argc
, char **argv
);
123 flags
= FLAG_VERBOSE
| FLAG_INTERACTIVE
;
124 default_protocol
= be_default_protocol
;
125 /* Find the appropriate default port. */
128 default_port
= 0; /* illegal */
129 for (i
= 0; backends
[i
].backend
!= NULL
; i
++)
130 if (backends
[i
].protocol
== default_protocol
) {
131 default_port
= backends
[i
].backend
->default_port
;
135 return pt_main(argc
, argv
);