Mercurial > vim
comparison src/memline.c @ 2360:d8e4b27cef80 vim73
Change 'cryptmethod' from a number to a string option. Make it global-local.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 20 Jul 2010 17:32:38 +0200 |
parents | 7e1bd501306d |
children | a3aca345aafa |
comparison
equal
deleted
inserted
replaced
2359:496feb41b83f | 2360:d8e4b27cef80 |
---|---|
439 { | 439 { |
440 if (*buf->b_p_key == NUL) | 440 if (*buf->b_p_key == NUL) |
441 b0p->b0_id[1] = BLOCK0_ID1; | 441 b0p->b0_id[1] = BLOCK0_ID1; |
442 else | 442 else |
443 { | 443 { |
444 if (buf->b_p_cm == 0) | 444 if (get_crypt_method(buf) == 0) |
445 b0p->b0_id[1] = BLOCK0_ID1_C0; | 445 b0p->b0_id[1] = BLOCK0_ID1_C0; |
446 else | 446 else |
447 { | 447 { |
448 b0p->b0_id[1] = BLOCK0_ID1_C1; | 448 b0p->b0_id[1] = BLOCK0_ID1_C1; |
449 /* Generate a seed and store it in block 0 and in the memfile. */ | 449 /* Generate a seed and store it in block 0 and in the memfile. */ |
456 /* | 456 /* |
457 * Called after the crypt key or 'cryptmethod' was changed for "buf". | 457 * Called after the crypt key or 'cryptmethod' was changed for "buf". |
458 * Will apply this to the swapfile. | 458 * Will apply this to the swapfile. |
459 * "old_key" is the previous key. It is equal to buf->b_p_key when | 459 * "old_key" is the previous key. It is equal to buf->b_p_key when |
460 * 'cryptmethod' is changed. | 460 * 'cryptmethod' is changed. |
461 * "old_cm" is the previous 'cryptmethod'. It is equal to buf->b_p_cm when | 461 * "old_cm" is the previous 'cryptmethod'. It is equal to the current |
462 * 'key' is changed. | 462 * 'cryptmethod' when 'key' is changed. |
463 */ | 463 */ |
464 void | 464 void |
465 ml_set_crypt_key(buf, old_key, old_cm) | 465 ml_set_crypt_key(buf, old_key, old_cm) |
466 buf_T *buf; | 466 buf_T *buf; |
467 char_u *old_key; | 467 char_u *old_key; |
1248 goto theend; | 1248 goto theend; |
1249 } | 1249 } |
1250 | 1250 |
1251 #ifdef FEAT_CRYPT | 1251 #ifdef FEAT_CRYPT |
1252 if (b0p->b0_id[1] == BLOCK0_ID1_C0) | 1252 if (b0p->b0_id[1] == BLOCK0_ID1_C0) |
1253 buf->b_p_cm = b0_cm = 0; | 1253 b0_cm = 0; |
1254 else if (b0p->b0_id[1] == BLOCK0_ID1_C1) | 1254 else if (b0p->b0_id[1] == BLOCK0_ID1_C1) |
1255 { | 1255 { |
1256 buf->b_p_cm = b0_cm = 1; | 1256 b0_cm = 1; |
1257 mch_memmove(mfp->mf_seed, &b0p->b0_seed, MF_SEED_LEN); | 1257 mch_memmove(mfp->mf_seed, &b0p->b0_seed, MF_SEED_LEN); |
1258 } | 1258 } |
1259 set_crypt_method(buf, b0_cm); | |
1259 #else | 1260 #else |
1260 if (b0p->b0_id[1] != BLOCK0_ID1) | 1261 if (b0p->b0_id[1] != BLOCK0_ID1) |
1261 { | 1262 { |
1262 EMSG2(_("E833: %s is encrypted and this version of Vim does not support encryption"), mfp->mf_fname); | 1263 EMSG2(_("E833: %s is encrypted and this version of Vim does not support encryption"), mfp->mf_fname); |
1263 goto theend; | 1264 goto theend; |
4906 key = mfp->mf_old_key; | 4907 key = mfp->mf_old_key; |
4907 seed = mfp->mf_old_seed; | 4908 seed = mfp->mf_old_seed; |
4908 } | 4909 } |
4909 else | 4910 else |
4910 { | 4911 { |
4911 method = buf->b_p_cm; | 4912 method = get_crypt_method(buf); |
4912 key = buf->b_p_key; | 4913 key = buf->b_p_key; |
4913 seed = mfp->mf_seed; | 4914 seed = mfp->mf_seed; |
4914 } | 4915 } |
4915 | 4916 |
4916 use_crypt_method = method; /* select pkzip or blowfish */ | 4917 use_crypt_method = method; /* select pkzip or blowfish */ |