1
0
forked from aniani/vim

Change 'cryptmethod' from a number to a string option. Make it global-local.

This commit is contained in:
Bram Moolenaar
2010-07-20 17:32:38 +02:00
parent c7040a5615
commit 49771f4fb0
14 changed files with 176 additions and 82 deletions

View File

@@ -3750,6 +3750,41 @@ static int crypt_busy = 0;
static ulg saved_keys[3];
static int saved_crypt_method;
/*
* Return int value for crypt method string:
* 0 for "zip", the old method. Also for any non-valid value.
* 1 for "blowfish".
*/
int
crypt_method_from_string(s)
char_u *s;
{
return *s == 'b' ? 1 : 0;
}
/*
* Get the crypt method for buffer "buf" as a number.
*/
int
get_crypt_method(buf)
buf_T *buf;
{
return crypt_method_from_string(*buf->b_p_cm == NUL ? p_cm : buf->b_p_cm);
}
/*
* Set the crypt method for buffer "buf" to "method" using the int value as
* returned by crypt_method_from_string().
*/
void
set_crypt_method(buf, method)
buf_T *buf;
int method;
{
free_string_option(buf->b_p_cm);
buf->b_p_cm = vim_strsave((char_u *)(method == 0 ? "zip" : "blowfish"));
}
/*
* Prepare for initializing encryption. If already doing encryption then save
* the state.