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
)
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';
110 char *make_default_wintitle(char *hostname
)
112 return dupcat(hostname
, " - PuTTY", NULL
);
116 * X11-forwarding-related things suitable for Gtk app.
119 const char platform_x11_best_transport
[] = "unix";
121 char *platform_get_x_display(void) {
123 /* Try to take account of --display and what have you. */
124 if (!(display
= gdk_get_display()))
125 /* fall back to traditional method */
126 display
= getenv("DISPLAY");
127 return dupstr(display
);
130 int main(int argc
, char **argv
)
132 extern int pt_main(int argc
, char **argv
);
134 flags
= FLAG_VERBOSE
| FLAG_INTERACTIVE
;
135 default_protocol
= be_default_protocol
;
136 /* Find the appropriate default port. */
139 default_port
= 0; /* illegal */
140 for (i
= 0; backends
[i
].backend
!= NULL
; i
++)
141 if (backends
[i
].protocol
== default_protocol
) {
142 default_port
= backends
[i
].backend
->default_port
;
146 return pt_main(argc
, argv
);