Doc: Fix broken link
[TortoiseGit.git] / src / TortoisePlink / CMDLINE.C
blobbb1618a56cf72f3f11a51633eb489a98308f71f7
1 /*\r
2  * cmdline.c - command-line parsing shared between many of the\r
3  * PuTTY applications\r
4  */\r
5 \r
6 #include <stdio.h>\r
7 #include <assert.h>\r
8 #include <stdlib.h>\r
9 #include "putty.h"\r
11 /*\r
12  * Some command-line parameters need to be saved up until after\r
13  * we've loaded the saved session which will form the basis of our\r
14  * eventual running configuration. For this we use the macro\r
15  * SAVEABLE, which notices if the `need_save' parameter is set and\r
16  * saves the parameter and value on a list.\r
17  * \r
18  * We also assign priorities to saved parameters, just to slightly\r
19  * ameliorate silly ordering problems. For example, if you specify\r
20  * a saved session to load, it will be loaded _before_ all your\r
21  * local modifications such as -L are evaluated; and if you specify\r
22  * a protocol and a port, the protocol is set up first so that the\r
23  * port can override its choice of port number.\r
24  * \r
25  * (In fact -load is not saved at all, since in at least Plink the\r
26  * processing of further command-line options depends on whether or\r
27  * not the loaded session contained a hostname. So it must be\r
28  * executed immediately.)\r
29  */\r
31 #define NPRIORITIES 2\r
33 struct cmdline_saved_param {\r
34     char *p, *value;\r
35 };\r
36 struct cmdline_saved_param_set {\r
37     struct cmdline_saved_param *params;\r
38     int nsaved, savesize;\r
39 };\r
41 /*\r
42  * C guarantees this structure will be initialised to all zero at\r
43  * program start, which is exactly what we want.\r
44  */\r
45 static struct cmdline_saved_param_set saves[NPRIORITIES];\r
47 static void cmdline_save_param(const char *p, const char *value, int pri)\r
48 {\r
49     if (saves[pri].nsaved >= saves[pri].savesize) {\r
50         saves[pri].savesize = saves[pri].nsaved + 32;\r
51         saves[pri].params = sresize(saves[pri].params, saves[pri].savesize,\r
52                                     struct cmdline_saved_param);\r
53     }\r
54     saves[pri].params[saves[pri].nsaved].p = dupstr(p);\r
55     saves[pri].params[saves[pri].nsaved].value = dupstr(value);\r
56     saves[pri].nsaved++;\r
57 }\r
59 static char *cmdline_password = NULL;\r
61 void cmdline_cleanup(void)\r
62 {\r
63     int pri;\r
65     if (cmdline_password) {\r
66         smemclr(cmdline_password, strlen(cmdline_password));\r
67         sfree(cmdline_password);\r
68         cmdline_password = NULL;\r
69     }\r
70     \r
71     for (pri = 0; pri < NPRIORITIES; pri++) {\r
72         sfree(saves[pri].params);\r
73         saves[pri].params = NULL;\r
74         saves[pri].savesize = 0;\r
75         saves[pri].nsaved = 0;\r
76     }\r
77 }\r
79 #define SAVEABLE(pri) do { \\r
80     if (need_save) { cmdline_save_param(p, value, pri); return ret; } \\r
81 } while (0)\r
83 /*\r
84  * Similar interface to get_userpass_input(), except that here a -1\r
85  * return means that we aren't capable of processing the prompt and\r
86  * someone else should do it.\r
87  */\r
88 int cmdline_get_passwd_input(prompts_t *p, const unsigned char *in, int inlen)\r
89 {\r
90     static int tried_once = 0;\r
92     /*\r
93      * We only handle prompts which don't echo (which we assume to be\r
94      * passwords), and (currently) we only cope with a password prompt\r
95      * that comes in a prompt-set on its own.\r
96      */\r
97     if (!cmdline_password || in || p->n_prompts != 1 || p->prompts[0]->echo) {\r
98         return -1;\r
99     }\r
101     /*\r
102      * If we've tried once, return utter failure (no more passwords left\r
103      * to try).\r
104      */\r
105     if (tried_once)\r
106         return 0;\r
108     prompt_set_result(p->prompts[0], cmdline_password);\r
109     smemclr(cmdline_password, strlen(cmdline_password));\r
110     sfree(cmdline_password);\r
111     cmdline_password = NULL;\r
112     tried_once = 1;\r
113     return 1;\r
116 /*\r
117  * Here we have a flags word which describes the capabilities of\r
118  * the particular tool on whose behalf we're running. We will\r
119  * refuse certain command-line options if a particular tool\r
120  * inherently can't do anything sensible. For example, the file\r
121  * transfer tools (psftp, pscp) can't do a great deal with protocol\r
122  * selections (ever tried running scp over telnet?) or with port\r
123  * forwarding (even if it wasn't a hideously bad idea, they don't\r
124  * have the select() infrastructure to make them work).\r
125  */\r
126 int cmdline_tooltype = 0;\r
128 static int cmdline_check_unavailable(int flag, const char *p)\r
130     if (cmdline_tooltype & flag) {\r
131         cmdline_error("option \"%s\" not available in this tool", p);\r
132         return 1;\r
133     }\r
134     return 0;\r
137 #define UNAVAILABLE_IN(flag) do { \\r
138     if (cmdline_check_unavailable(flag, p)) return ret; \\r
139 } while (0)\r
141 /*\r
142  * Process a standard command-line parameter. `p' is the parameter\r
143  * in question; `value' is the subsequent element of argv, which\r
144  * may or may not be required as an operand to the parameter.\r
145  * If `need_save' is 1, arguments which need to be saved as\r
146  * described at this top of this file are, for later execution;\r
147  * if 0, they are processed normally. (-1 is a special value used\r
148  * by pterm to count arguments for a preliminary pass through the\r
149  * argument list; it causes immediate return with an appropriate\r
150  * value with no action taken.)\r
151  * Return value is 2 if both arguments were used; 1 if only p was\r
152  * used; 0 if the parameter wasn't one we recognised; -2 if it\r
153  * should have been 2 but value was NULL.\r
154  */\r
156 #define RETURN(x) do { \\r
157     if ((x) == 2 && !value) return -2; \\r
158     ret = x; \\r
159     if (need_save < 0) return x; \\r
160 } while (0)\r
162 int cmdline_process_param(const char *p, char *value,\r
163                           int need_save, Conf *conf)\r
165     int ret = 0;\r
167     if (!strcmp(p, "-load")) {\r
168         RETURN(2);\r
169         /* This parameter must be processed immediately rather than being\r
170          * saved. */\r
171         do_defaults(value, conf);\r
172         loaded_session = TRUE;\r
173         cmdline_session_name = dupstr(value);\r
174         return 2;\r
175     }\r
176     if (!strcmp(p, "-ssh")) {\r
177         RETURN(1);\r
178         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
179         SAVEABLE(0);\r
180         default_protocol = PROT_SSH;\r
181         default_port = 22;\r
182         conf_set_int(conf, CONF_protocol, default_protocol);\r
183         conf_set_int(conf, CONF_port, default_port);\r
184         return 1;\r
185     }\r
186     if (!strcmp(p, "-telnet")) {\r
187         RETURN(1);\r
188         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
189         SAVEABLE(0);\r
190         default_protocol = PROT_TELNET;\r
191         default_port = 23;\r
192         conf_set_int(conf, CONF_protocol, default_protocol);\r
193         conf_set_int(conf, CONF_port, default_port);\r
194         return 1;\r
195     }\r
196     if (!strcmp(p, "-rlogin")) {\r
197         RETURN(1);\r
198         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
199         SAVEABLE(0);\r
200         default_protocol = PROT_RLOGIN;\r
201         default_port = 513;\r
202         conf_set_int(conf, CONF_protocol, default_protocol);\r
203         conf_set_int(conf, CONF_port, default_port);\r
204         return 1;\r
205     }\r
206     if (!strcmp(p, "-raw")) {\r
207         RETURN(1);\r
208         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
209         SAVEABLE(0);\r
210         default_protocol = PROT_RAW;\r
211         conf_set_int(conf, CONF_protocol, default_protocol);\r
212     }\r
213     if (!strcmp(p, "-serial")) {\r
214         RETURN(1);\r
215         /* Serial is not NONNETWORK in an odd sense of the word */\r
216         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
217         SAVEABLE(0);\r
218         default_protocol = PROT_SERIAL;\r
219         conf_set_int(conf, CONF_protocol, default_protocol);\r
220         /* The host parameter will already be loaded into CONF_host,\r
221          * so copy it across */\r
222         conf_set_str(conf, CONF_serline, conf_get_str(conf, CONF_host));\r
223     }\r
224     if (!strcmp(p, "-v")) {\r
225         RETURN(1);\r
226         flags |= FLAG_VERBOSE;\r
227     }\r
228     if (!strcmp(p, "-l")) {\r
229         RETURN(2);\r
230         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
231         SAVEABLE(0);\r
232         conf_set_str(conf, CONF_username, value);\r
233     }\r
234     if (!strcmp(p, "-loghost")) {\r
235         RETURN(2);\r
236         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
237         SAVEABLE(0);\r
238         conf_set_str(conf, CONF_loghost, value);\r
239     }\r
240     if (!strcmp(p, "-hostkey")) {\r
241         char *dup;\r
242         RETURN(2);\r
243         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
244         SAVEABLE(0);\r
245         dup = dupstr(value);\r
246         if (!validate_manual_hostkey(dup)) {\r
247             cmdline_error("'%s' is not a valid format for a manual host "\r
248                           "key specification", value);\r
249             sfree(dup);\r
250             return ret;\r
251         }\r
252         conf_set_str_str(conf, CONF_ssh_manual_hostkeys, dup, "");\r
253         sfree(dup);\r
254     }\r
255     if ((!strcmp(p, "-L") || !strcmp(p, "-R") || !strcmp(p, "-D"))) {\r
256         char type, *q, *qq, *key, *val;\r
257         RETURN(2);\r
258         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
259         SAVEABLE(0);\r
260         if (strcmp(p, "-D")) {\r
261             /*\r
262              * For -L or -R forwarding types:\r
263              *\r
264              * We expect _at least_ two colons in this string. The\r
265              * possible formats are `sourceport:desthost:destport',\r
266              * or `sourceip:sourceport:desthost:destport' if you're\r
267              * specifying a particular loopback address. We need to\r
268              * replace the one between source and dest with a \t;\r
269              * this means we must find the second-to-last colon in\r
270              * the string.\r
271              *\r
272              * (This looks like a foolish way of doing it given the\r
273              * existence of strrchr, but it's more efficient than\r
274              * two strrchrs - not to mention that the second strrchr\r
275              * would require us to modify the input string!)\r
276              */\r
278             type = p[1];               /* 'L' or 'R' */\r
280             q = qq = host_strchr(value, ':');\r
281             while (qq) {\r
282                 char *qqq = host_strchr(qq+1, ':');\r
283                 if (qqq)\r
284                     q = qq;\r
285                 qq = qqq;\r
286             }\r
288             if (!q) {\r
289                 cmdline_error("-%c expects at least two colons in its"\r
290                               " argument", type);\r
291                 return ret;\r
292             }\r
294             key = dupprintf("%c%.*s", type, (int)(q - value), value);\r
295             val = dupstr(q+1);\r
296         } else {\r
297             /*\r
298              * Dynamic port forwardings are entered under the same key\r
299              * as if they were local (because they occupy the same\r
300              * port space - a local and a dynamic forwarding on the\r
301              * same local port are mutually exclusive), with the\r
302              * special value "D" (which can be distinguished from\r
303              * anything in the ordinary -L case by containing no\r
304              * colon).\r
305              */\r
306             key = dupprintf("L%s", value);\r
307             val = dupstr("D");\r
308         }\r
309         conf_set_str_str(conf, CONF_portfwd, key, val);\r
310         sfree(key);\r
311         sfree(val);\r
312     }\r
313     if ((!strcmp(p, "-nc"))) {\r
314         char *host, *portp;\r
316         RETURN(2);\r
317         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
318         SAVEABLE(0);\r
320         portp = host_strchr(value, ':');\r
321         if (!portp) {\r
322             cmdline_error("-nc expects argument of form 'host:port'");\r
323             return ret;\r
324         }\r
326         host = dupprintf("%.*s", (int)(portp - value), value);\r
327         conf_set_str(conf, CONF_ssh_nc_host, host);\r
328         conf_set_int(conf, CONF_ssh_nc_port, atoi(portp + 1));\r
329         sfree(host);\r
330     }\r
331     if (!strcmp(p, "-m")) {\r
332         const char *filename;\r
333         char *command;\r
334         int cmdlen, cmdsize;\r
335         FILE *fp;\r
336         int c, d;\r
338         RETURN(2);\r
339         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
340         SAVEABLE(0);\r
342         filename = value;\r
344         cmdlen = cmdsize = 0;\r
345         command = NULL;\r
346         fp = fopen(filename, "r");\r
347         if (!fp) {\r
348             cmdline_error("unable to open command file \"%s\"", filename);\r
349             return ret;\r
350         }\r
351         do {\r
352             c = fgetc(fp);\r
353             d = c;\r
354             if (c == EOF)\r
355                 d = 0;\r
356             if (cmdlen >= cmdsize) {\r
357                 cmdsize = cmdlen + 512;\r
358                 command = sresize(command, cmdsize, char);\r
359             }\r
360             command[cmdlen++] = d;\r
361         } while (c != EOF);\r
362         fclose(fp);\r
363         conf_set_str(conf, CONF_remote_cmd, command);\r
364         conf_set_str(conf, CONF_remote_cmd2, "");\r
365         conf_set_int(conf, CONF_nopty, TRUE);   /* command => no terminal */\r
366         sfree(command);\r
367     }\r
368     if ((!strcmp(p, "-P"))||(!strcmp(p, "-p"))) {\r
369         RETURN(2);\r
370         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
371         SAVEABLE(1);                   /* lower priority than -ssh,-telnet */\r
372         conf_set_int(conf, CONF_port, atoi(value));\r
373     }\r
374     if (!strcmp(p, "-pw")) {\r
375         RETURN(2);\r
376         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
377         SAVEABLE(1);\r
378         /* We delay evaluating this until after the protocol is decided,\r
379          * so that we can warn if it's of no use with the selected protocol */\r
380         if (conf_get_int(conf, CONF_protocol) != PROT_SSH)\r
381             cmdline_error("the -pw option can only be used with the "\r
382                           "SSH protocol");\r
383         else {\r
384             cmdline_password = dupstr(value);\r
385             /* Assuming that `value' is directly from argv, make a good faith\r
386              * attempt to trample it, to stop it showing up in `ps' output\r
387              * on Unix-like systems. Not guaranteed, of course. */\r
388             smemclr(value, strlen(value));\r
389         }\r
390     }\r
392     if (!strcmp(p, "-agent") || !strcmp(p, "-pagent") ||\r
393         !strcmp(p, "-pageant")) {\r
394         RETURN(1);\r
395         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
396         SAVEABLE(0);\r
397         conf_set_int(conf, CONF_tryagent, TRUE);\r
398     }\r
399     if (!strcmp(p, "-noagent") || !strcmp(p, "-nopagent") ||\r
400         !strcmp(p, "-nopageant")) {\r
401         RETURN(1);\r
402         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
403         SAVEABLE(0);\r
404         conf_set_int(conf, CONF_tryagent, FALSE);\r
405     }\r
407     if (!strcmp(p, "-A")) {\r
408         RETURN(1);\r
409         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
410         SAVEABLE(0);\r
411         conf_set_int(conf, CONF_agentfwd, 1);\r
412     }\r
413     if (!strcmp(p, "-a")) {\r
414         RETURN(1);\r
415         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
416         SAVEABLE(0);\r
417         conf_set_int(conf, CONF_agentfwd, 0);\r
418     }\r
420     if (!strcmp(p, "-X")) {\r
421         RETURN(1);\r
422         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
423         SAVEABLE(0);\r
424         conf_set_int(conf, CONF_x11_forward, 1);\r
425     }\r
426     if (!strcmp(p, "-x")) {\r
427         RETURN(1);\r
428         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
429         SAVEABLE(0);\r
430         conf_set_int(conf, CONF_x11_forward, 0);\r
431     }\r
433     if (!strcmp(p, "-t")) {\r
434         RETURN(1);\r
435         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
436         SAVEABLE(1);    /* lower priority than -m */\r
437         conf_set_int(conf, CONF_nopty, 0);\r
438     }\r
439     if (!strcmp(p, "-T")) {\r
440         RETURN(1);\r
441         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
442         SAVEABLE(1);\r
443         conf_set_int(conf, CONF_nopty, 1);\r
444     }\r
446     if (!strcmp(p, "-N")) {\r
447         RETURN(1);\r
448         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
449         SAVEABLE(0);\r
450         conf_set_int(conf, CONF_ssh_no_shell, 1);\r
451     }\r
453     if (!strcmp(p, "-C")) {\r
454         RETURN(1);\r
455         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
456         SAVEABLE(0);\r
457         conf_set_int(conf, CONF_compression, 1);\r
458     }\r
460     if (!strcmp(p, "-1")) {\r
461         RETURN(1);\r
462         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
463         SAVEABLE(0);\r
464         conf_set_int(conf, CONF_sshprot, 0);   /* ssh protocol 1 only */\r
465     }\r
466     if (!strcmp(p, "-2")) {\r
467         RETURN(1);\r
468         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
469         SAVEABLE(0);\r
470         conf_set_int(conf, CONF_sshprot, 3);   /* ssh protocol 2 only */\r
471     }\r
473     if (!strcmp(p, "-i")) {\r
474         Filename *fn;\r
475         RETURN(2);\r
476         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
477         SAVEABLE(0);\r
478         fn = filename_from_str(value);\r
479         conf_set_filename(conf, CONF_keyfile, fn);\r
480         filename_free(fn);\r
481     }\r
483     if (!strcmp(p, "-4") || !strcmp(p, "-ipv4")) {\r
484         RETURN(1);\r
485         SAVEABLE(1);\r
486         conf_set_int(conf, CONF_addressfamily, ADDRTYPE_IPV4);\r
487     }\r
488     if (!strcmp(p, "-6") || !strcmp(p, "-ipv6")) {\r
489         RETURN(1);\r
490         SAVEABLE(1);\r
491         conf_set_int(conf, CONF_addressfamily, ADDRTYPE_IPV6);\r
492     }\r
493     if (!strcmp(p, "-sercfg")) {\r
494         char* nextitem;\r
495         RETURN(2);\r
496         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);\r
497         SAVEABLE(1);\r
498         if (conf_get_int(conf, CONF_protocol) != PROT_SERIAL)\r
499             cmdline_error("the -sercfg option can only be used with the "\r
500                           "serial protocol");\r
501         /* Value[0] contains one or more , separated values, like 19200,8,n,1,X */\r
502         nextitem = value;\r
503         while (nextitem[0] != '\0') {\r
504             int length, skip;\r
505             char *end = strchr(nextitem, ',');\r
506             if (!end) {\r
507                 length = strlen(nextitem);\r
508                 skip = 0;\r
509             } else {\r
510                 length = end - nextitem;\r
511                 nextitem[length] = '\0';\r
512                 skip = 1;\r
513             }\r
514             if (length == 1) {\r
515                 switch (*nextitem) {\r
516                   case '1':\r
517                   case '2':\r
518                     conf_set_int(conf, CONF_serstopbits, 2 * (*nextitem-'0'));\r
519                     break;\r
521                   case '5':\r
522                   case '6':\r
523                   case '7':\r
524                   case '8':\r
525                   case '9':\r
526                     conf_set_int(conf, CONF_serdatabits, *nextitem-'0');\r
527                     break;\r
529                   case 'n':\r
530                     conf_set_int(conf, CONF_serparity, SER_PAR_NONE);\r
531                     break;\r
532                   case 'o':\r
533                     conf_set_int(conf, CONF_serparity, SER_PAR_ODD);\r
534                     break;\r
535                   case 'e':\r
536                     conf_set_int(conf, CONF_serparity, SER_PAR_EVEN);\r
537                     break;\r
538                   case 'm':\r
539                     conf_set_int(conf, CONF_serparity, SER_PAR_MARK);\r
540                     break;\r
541                   case 's':\r
542                     conf_set_int(conf, CONF_serparity, SER_PAR_SPACE);\r
543                     break;\r
545                   case 'N':\r
546                     conf_set_int(conf, CONF_serflow, SER_FLOW_NONE);\r
547                     break;\r
548                   case 'X':\r
549                     conf_set_int(conf, CONF_serflow, SER_FLOW_XONXOFF);\r
550                     break;\r
551                   case 'R':\r
552                     conf_set_int(conf, CONF_serflow, SER_FLOW_RTSCTS);\r
553                     break;\r
554                   case 'D':\r
555                     conf_set_int(conf, CONF_serflow, SER_FLOW_DSRDTR);\r
556                     break;\r
558                   default:\r
559                     cmdline_error("Unrecognised suboption \"-sercfg %c\"",\r
560                                   *nextitem);\r
561                 }\r
562             } else if (length == 3 && !strncmp(nextitem,"1.5",3)) {\r
563                 /* Messy special case */\r
564                 conf_set_int(conf, CONF_serstopbits, 3);\r
565             } else {\r
566                 int serspeed = atoi(nextitem);\r
567                 if (serspeed != 0) {\r
568                     conf_set_int(conf, CONF_serspeed, serspeed);\r
569                 } else {\r
570                     cmdline_error("Unrecognised suboption \"-sercfg %s\"",\r
571                                   nextitem);\r
572                 }\r
573             }\r
574             nextitem += length + skip;\r
575         }\r
576     }\r
578     if (!strcmp(p, "-sessionlog")) {\r
579         Filename *fn;\r
580         RETURN(2);\r
581         UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER);\r
582         /* but available even in TOOLTYPE_NONNETWORK, cf pterm "-log" */\r
583         SAVEABLE(0);\r
584         fn = filename_from_str(value);\r
585         conf_set_filename(conf, CONF_logfilename, fn);\r
586         conf_set_int(conf, CONF_logtype, LGTYP_DEBUG);\r
587         filename_free(fn);\r
588     }\r
590     if (!strcmp(p, "-sshlog") ||\r
591         !strcmp(p, "-sshrawlog")) {\r
592         Filename *fn;\r
593         RETURN(2);\r
594         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
595         SAVEABLE(0);\r
596         fn = filename_from_str(value);\r
597         conf_set_filename(conf, CONF_logfilename, fn);\r
598         conf_set_int(conf, CONF_logtype,\r
599                      !strcmp(p, "-sshlog") ? LGTYP_PACKETS :\r
600                      /* !strcmp(p, "-sshrawlog") ? */ LGTYP_SSHRAW);\r
601         filename_free(fn);\r
602     }\r
604     if (!strcmp(p, "-proxycmd")) {\r
605         RETURN(2);\r
606         UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);\r
607         SAVEABLE(0);\r
608         conf_set_int(conf, CONF_proxy_type, PROXY_CMD);\r
609         conf_set_str(conf, CONF_proxy_telnet_command, value);\r
610     }\r
612 #ifdef _WINDOWS\r
613     /*\r
614      * Cross-tool options only available on Windows.\r
615      */\r
616     if (!strcmp(p, "-restrict-acl") || !strcmp(p, "-restrict_acl") ||\r
617         !strcmp(p, "-restrictacl")) {\r
618         RETURN(1);\r
619         restrict_process_acl();\r
620         restricted_acl = TRUE;\r
621     }\r
622 #endif\r
624     return ret;                        /* unrecognised */\r
627 void cmdline_run_saved(Conf *conf)\r
629     int pri, i;\r
630     for (pri = 0; pri < NPRIORITIES; pri++) {\r
631         for (i = 0; i < saves[pri].nsaved; i++) {\r
632             cmdline_process_param(saves[pri].params[i].p,\r
633                                   saves[pri].params[i].value, 0, conf);\r
634             sfree(saves[pri].params[i].p);\r
635             sfree(saves[pri].params[i].value);\r
636         }\r
637         saves[pri].nsaved = 0;\r
638     }\r