- console_batch_mode = TRUE;
- } else if (!strcmp(p, "-v")) {
- flags |= FLAG_VERBOSE;
- } else if (!strcmp(p, "-log")) {
- logfile = "putty.log";
- } else if (!strcmp(p, "-pw") && argc > 1) {
- --argc, console_password = *++argv;
- } else if (!strcmp(p, "-l") && argc > 1) {
- char *username;
- --argc, username = *++argv;
- strncpy(cfg.username, username, sizeof(cfg.username));
- cfg.username[sizeof(cfg.username) - 1] = '\0';
- } else if ((!strcmp(p, "-L") || !strcmp(p, "-R")) && argc > 1) {
- char *fwd, *ptr, *q;
- int i=0;
- --argc, fwd = *++argv;
- ptr = extra_portfwd;
- /* if multiple forwards, find end of list */
- if (ptr[0]=='R' || ptr[0]=='L') {
- for (i = 0; i < sizeof(extra_portfwd) - 2; i++)
- if (ptr[i]=='\000' && ptr[i+1]=='\000')
- break;
- ptr = ptr + i + 1; /* point to next forward slot */
- }
- ptr[0] = p[1]; /* insert a 'L' or 'R' at the start */
- strncpy(ptr+1, fwd, sizeof(extra_portfwd) - i);
- q = strchr(ptr, ':');
- if (q) *q = '\t'; /* replace first : with \t */
- ptr[strlen(ptr)+1] = '\000'; /* append two '\000' */
- extra_portfwd[sizeof(extra_portfwd) - 1] = '\0';
- } else if (!strcmp(p, "-m") && argc > 1) {
- char *filename, *command;
- int cmdlen, cmdsize;
- FILE *fp;
- int c, d;
-
- --argc, filename = *++argv;
-
- cmdlen = cmdsize = 0;
- command = NULL;
- fp = fopen(filename, "r");
- if (!fp) {
- fprintf(stderr, "plink: unable to open command "
- "file \"%s\"\n", filename);
- return 1;
- }
- do {
- c = fgetc(fp);
- d = c;
- if (c == EOF)
- d = 0;
- if (cmdlen >= cmdsize) {
- cmdsize = cmdlen + 512;
- command = srealloc(command, cmdsize);
- }
- command[cmdlen++] = d;
- } while (c != EOF);
- cfg.remote_cmd_ptr = command;
- cfg.remote_cmd_ptr2 = NULL;
- cfg.nopty = TRUE; /* command => no terminal */
- } else if (!strcmp(p, "-P") && argc > 1) {
- --argc, portnumber = atoi(*++argv);