pterm : [X] pterm terminal wcwidth uxucs uxmisc tree234 misc ldisc ldiscucs
+ logging uxprint settings pty uxsel be_none uxstore signal CHARSET
- + ptermm
+ + cmdline ptermm
putty : [X] pterm terminal wcwidth uxucs uxmisc tree234 misc ldisc ldiscucs
+ logging uxprint settings pty uxsel be_all uxstore signal CHARSET
+ uxputty NONSSH UXSSH UXMISC logging ux_x11 UXCFG
#define RETURN(x) do { \
if ((x) == 2 && !value) return -2; \
ret = x; \
+ if (need_save < 0) return x; \
} while (0)
int cmdline_process_param(char *p, char *value, int need_save, Config *cfg)
}
if (!strcmp(p, "-ssh")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
default_protocol = cfg->protocol = PROT_SSH;
default_port = cfg->port = 22;
}
if (!strcmp(p, "-telnet")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
default_protocol = cfg->protocol = PROT_TELNET;
default_port = cfg->port = 23;
}
if (!strcmp(p, "-rlogin")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
default_protocol = cfg->protocol = PROT_RLOGIN;
default_port = cfg->port = 513;
}
if (!strcmp(p, "-raw")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
default_protocol = cfg->protocol = PROT_RAW;
}
}
if (!strcmp(p, "-l")) {
RETURN(2);
+ UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
SAVEABLE(0);
strncpy(cfg->username, value, sizeof(cfg->username));
cfg->username[sizeof(cfg->username) - 1] = '\0';
char *fwd, *ptr, *q, *qq;
int i=0;
RETURN(2);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
fwd = value;
ptr = cfg->portfwd;
int c, d;
RETURN(2);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
filename = value;
}
if (!strcmp(p, "-P")) {
RETURN(2);
+ UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
SAVEABLE(1); /* lower priority than -ssh,-telnet */
cfg->port = atoi(value);
}
if (!strcmp(p, "-pw")) {
RETURN(2);
+ UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
cmdline_password = value;
ssh_get_line = cmdline_get_line;
ssh_getline_pw_only = TRUE;
if (!strcmp(p, "-A")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->agentfwd = 1;
}
if (!strcmp(p, "-a")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->agentfwd = 0;
}
if (!strcmp(p, "-X")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->x11_forward = 1;
}
if (!strcmp(p, "-x")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->x11_forward = 0;
}
if (!strcmp(p, "-t")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->nopty = 0;
}
if (!strcmp(p, "-T")) {
RETURN(1);
- UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);
+ UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->nopty = 1;
}
if (!strcmp(p, "-C")) {
RETURN(1);
+ UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->compression = 1;
}
if (!strcmp(p, "-1")) {
RETURN(1);
+ UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->sshprot = 0; /* ssh protocol 1 only */
}
if (!strcmp(p, "-2")) {
RETURN(1);
+ UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->sshprot = 3; /* ssh protocol 2 only */
}
if (!strcmp(p, "-i")) {
RETURN(2);
+ UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
SAVEABLE(0);
cfg->keyfile = filename_from_str(value);
}
void cmdline_run_saved(Config *);
extern char *cmdline_password;
#define TOOLTYPE_FILETRANSFER 1
+#define TOOLTYPE_NONNETWORK 2
extern int cmdline_tooltype;
void cmdline_error(char *, ...);
struct selparam *selparams = NULL;
int nselparams = 0, selparamsize = 0;
- do_defaults(NULL, cfg);
-
dlg_init(&dp);
{
exit(1);
}
+void cmdline_error(char *p, ...)
+{
+ va_list ap;
+ fprintf(stderr, "plink: ");
+ va_start(ap, p);
+ vfprintf(stderr, p, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+ exit(1);
+}
+
char *get_x_display(void *frontend)
{
return gdk_get_display();
char *val;
while (--argc > 0) {
char *p = *++argv;
+ int ret;
+
+ ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL),
+ do_everything ? 1 : -1, cfg);
+
+ if (ret == -2) {
+ cmdline_error("option \"%s\" requires an argument", p);
+ } else if (ret == 2) {
+ --argc, ++argv; /* skip next argument */
+ continue;
+ } else if (ret == 1) {
+ continue;
+ }
+
if (!strcmp(p, "-fn") || !strcmp(p, "-font")) {
EXPECTS_ARG;
SECOND_PASS_ONLY;
help(stdout);
exit(0);
+ } else if(p[0] != '-' && (!do_everything ||
+ process_nonoption_arg(p, cfg))) {
+ /* do nothing */
+
} else {
err = 1;
fprintf(stderr, "pterm: unrecognized option '%s'\n", p);
if (do_cmdline(argc, argv, 1, &inst->cfg))
exit(1); /* post-defaults, do everything */
- if (!cfgbox(&inst->cfg))
+ cmdline_run_saved(&inst->cfg);
+
+ if (!*inst->cfg.host && !cfgbox(&inst->cfg))
exit(0); /* config box hit Cancel */
inst->fonts[0] = gdk_font_load(inst->cfg.font.name);
return 1; /* no-op in pterm */
}
+int process_nonoption_arg(char *arg, Config *cfg)
+{
+ return 0; /* pterm doesn't have any. */
+}
+
char *make_default_wintitle(char *hostname)
{
return dupstr("pterm");
extern int pt_main(int argc, char **argv);
extern void pty_pre_init(void); /* declared in pty.c */
+ cmdline_tooltype = TOOLTYPE_NONNETWORK;
+
pty_pre_init();
return pt_main(argc, argv);
/* Things pterm.c needs from {ptermm,uxputty}.c */
char *make_default_wintitle(char *hostname);
+int process_nonoption_arg(char *arg, Config *cfg);
/* Things uxstore.c needs from pterm.c */
char *x_get_default(const char *key);
*/
#include <stdio.h>
+#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
* - About (and uxcfg.c must also supply the about box)
*/
-void cmdline_error(char *p, ...)
-{
- va_list ap;
- fprintf(stderr, "plink: ");
- va_start(ap, p);
- vfprintf(stderr, p, ap);
- va_end(ap);
- fputc('\n', stderr);
- exit(1);
-}
-
/*
* Clean up and exit.
*/
return do_config_box("PuTTY Configuration", cfg);
}
+static int got_host = 0;
+
+int process_nonoption_arg(char *arg, Config *cfg)
+{
+ char *p, *q = arg;
+
+ if (got_host) {
+ /*
+ * If we already have a host name, treat this argument as a
+ * port number. NB we have to treat this as a saved -P
+ * argument, so that it will be deferred until it's a good
+ * moment to run it.
+ */
+ int ret = cmdline_process_param("-P", arg, 1, cfg);
+ assert(ret == 2);
+ } else if (!strncmp(q, "telnet:", 7)) {
+ /*
+ * If the hostname starts with "telnet:",
+ * set the protocol to Telnet and process
+ * the string as a Telnet URL.
+ */
+ char c;
+
+ q += 7;
+ if (q[0] == '/' && q[1] == '/')
+ q += 2;
+ cfg->protocol = PROT_TELNET;
+ p = q;
+ while (*p && *p != ':' && *p != '/')
+ p++;
+ c = *p;
+ if (*p)
+ *p++ = '\0';
+ if (c == ':')
+ cfg->port = atoi(p);
+ else
+ cfg->port = -1;
+ strncpy(cfg->host, q, sizeof(cfg->host) - 1);
+ cfg->host[sizeof(cfg->host) - 1] = '\0';
+ got_host = 1;
+ } else {
+ /*
+ * Otherwise, treat this argument as a host name.
+ */
+ while (*p && !isspace((unsigned char)*p))
+ p++;
+ if (*p)
+ *p++ = '\0';
+ strncpy(cfg->host, q, sizeof(cfg->host) - 1);
+ cfg->host[sizeof(cfg->host) - 1] = '\0';
+ got_host = 1;
+ }
+ return 1;
+}
+
char *make_default_wintitle(char *hostname)
{
return dupcat(hostname, " - PuTTY", NULL);