Turn 'Filename' into a dynamically allocated type with no arbitrary
[u/mdw/putty] / cmdgen.c
index 9911db1..9cd5b52 100644 (file)
--- a/cmdgen.c
+++ b/cmdgen.c
@@ -257,10 +257,9 @@ static char *blobfp(char *alg, int bits, unsigned char *blob, int bloblen)
 int main(int argc, char **argv)
 {
     char *infile = NULL;
-    Filename infilename;
+    Filename *infilename, *outfilename;
     enum { NOKEYGEN, RSA1, RSA2, DSA } keytype = NOKEYGEN;    
     char *outfile = NULL, *outfiletmp = NULL;
-    Filename outfilename;
     enum { PRIVATE, PUBLIC, PUBLICO, FP, OPENSSH, SSHCOM } outtype = PRIVATE;
     int bits = 1024;
     char *comment = NULL, *origcomment = NULL;
@@ -536,7 +535,7 @@ int main(int argc, char **argv)
     if (infile) {
        infilename = filename_from_str(infile);
 
-       intype = key_type(&infilename);
+       intype = key_type(infilename);
 
        switch (intype) {
            /*
@@ -707,11 +706,11 @@ int main(int argc, char **argv)
         * Find out whether the input key is encrypted.
         */
        if (intype == SSH_KEYTYPE_SSH1)
-           encrypted = rsakey_encrypted(&infilename, &origcomment);
+           encrypted = rsakey_encrypted(infilename, &origcomment);
        else if (intype == SSH_KEYTYPE_SSH2)
-           encrypted = ssh2_userkey_encrypted(&infilename, &origcomment);
+           encrypted = ssh2_userkey_encrypted(infilename, &origcomment);
        else
-           encrypted = import_encrypted(&infilename, intype, &origcomment);
+           encrypted = import_encrypted(infilename, intype, &origcomment);
 
        /*
         * If so, ask for a passphrase.
@@ -746,7 +745,7 @@ int main(int argc, char **argv)
                unsigned char *blob;
                int n, l, bloblen;
 
-               ret = rsakey_pubblob(&infilename, &vblob, &bloblen,
+               ret = rsakey_pubblob(infilename, &vblob, &bloblen,
                                     &origcomment, &error);
                blob = (unsigned char *)vblob;
 
@@ -768,7 +767,7 @@ int main(int argc, char **argv)
                ssh1key->comment = dupstr(origcomment);
                ssh1key->private_exponent = NULL;
            } else {
-               ret = loadrsakey(&infilename, ssh1key, passphrase, &error);
+               ret = loadrsakey(infilename, ssh1key, passphrase, &error);
            }
            if (ret > 0)
                error = NULL;
@@ -778,7 +777,7 @@ int main(int argc, char **argv)
 
          case SSH_KEYTYPE_SSH2:
            if (!load_encrypted) {
-               ssh2blob = ssh2_userkey_loadpub(&infilename, &ssh2alg,
+               ssh2blob = ssh2_userkey_loadpub(infilename, &ssh2alg,
                                                &ssh2bloblen, NULL, &error);
                ssh2algf = find_pubkey_alg(ssh2alg);
                if (ssh2algf)
@@ -786,7 +785,7 @@ int main(int argc, char **argv)
                else
                    bits = -1;
            } else {
-               ssh2key = ssh2_load_userkey(&infilename, passphrase, &error);
+               ssh2key = ssh2_load_userkey(infilename, passphrase, &error);
            }
            if ((ssh2key && ssh2key != SSH2_WRONG_PASSPHRASE) || ssh2blob)
                error = NULL;
@@ -800,7 +799,7 @@ int main(int argc, char **argv)
 
          case SSH_KEYTYPE_OPENSSH:
          case SSH_KEYTYPE_SSHCOM:
-           ssh2key = import_ssh2(&infilename, intype, passphrase, &error);
+           ssh2key = import_ssh2(infilename, intype, passphrase, &error);
            if (ssh2key) {
                if (ssh2key != SSH2_WRONG_PASSPHRASE)
                    error = NULL;
@@ -892,14 +891,14 @@ int main(int argc, char **argv)
       case PRIVATE:
        if (sshver == 1) {
            assert(ssh1key);
-           ret = saversakey(&outfilename, ssh1key, passphrase);
+           ret = saversakey(outfilename, ssh1key, passphrase);
            if (!ret) {
                fprintf(stderr, "puttygen: unable to save SSH-1 private key\n");
                return 1;
            }
        } else {
            assert(ssh2key);
-           ret = ssh2_save_userkey(&outfilename, ssh2key, passphrase);
+           ret = ssh2_save_userkey(outfilename, ssh2key, passphrase);
            if (!ret) {
                fprintf(stderr, "puttygen: unable to save SSH-2 private key\n");
                return 1;
@@ -1023,7 +1022,7 @@ int main(int argc, char **argv)
       case SSHCOM:
        assert(sshver == 2);
        assert(ssh2key);
-       ret = export_ssh2(&outfilename, outtype, ssh2key, passphrase);
+       ret = export_ssh2(outfilename, outtype, ssh2key, passphrase);
        if (!ret) {
            fprintf(stderr, "puttygen: unable to export key\n");
            return 1;