2 * Unix PuTTY main program.
17 void cleanup_exit(int code
)
27 Backend
*select_backend(Config
*cfg
)
31 for (i
= 0; backends
[i
].backend
!= NULL
; i
++)
32 if (backends
[i
].protocol
== cfg
->protocol
) {
33 back
= backends
[i
].backend
;
40 int cfgbox(Config
*cfg
)
42 return do_config_box("PuTTY Configuration", cfg
, 0);
45 static int got_host
= 0;
47 const int use_event_log
= 1, new_session
= 1, saved_sessions
= 1;
49 int process_nonoption_arg(char *arg
, Config
*cfg
)
55 * If we already have a host name, treat this argument as a
56 * port number. NB we have to treat this as a saved -P
57 * argument, so that it will be deferred until it's a good
60 int ret
= cmdline_process_param("-P", arg
, 1, cfg
);
62 } else if (!strncmp(q
, "telnet:", 7)) {
64 * If the hostname starts with "telnet:",
65 * set the protocol to Telnet and process
66 * the string as a Telnet URL.
71 if (q
[0] == '/' && q
[1] == '/')
73 cfg
->protocol
= PROT_TELNET
;
75 while (*p
&& *p
!= ':' && *p
!= '/')
84 strncpy(cfg
->host
, q
, sizeof(cfg
->host
) - 1);
85 cfg
->host
[sizeof(cfg
->host
) - 1] = '\0';
89 * Otherwise, treat this argument as a host name.
92 while (*p
&& !isspace((unsigned char)*p
))
96 strncpy(cfg
->host
, q
, sizeof(cfg
->host
) - 1);
97 cfg
->host
[sizeof(cfg
->host
) - 1] = '\0';
103 char *make_default_wintitle(char *hostname
)
105 return dupcat(hostname
, " - PuTTY", NULL
);
108 int main(int argc
, char **argv
)
110 extern int pt_main(int argc
, char **argv
);
112 flags
= FLAG_VERBOSE
| FLAG_INTERACTIVE
;
113 default_protocol
= be_default_protocol
;
114 /* Find the appropriate default port. */
117 default_port
= 0; /* illegal */
118 for (i
= 0; backends
[i
].backend
!= NULL
; i
++)
119 if (backends
[i
].protocol
== default_protocol
) {
120 default_port
= backends
[i
].backend
->default_port
;
124 return pt_main(argc
, argv
);