mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 18:36:30 +03:00
Make dc_split_armored_data return bool (#251)
* Make dc_split_armored_data return bool * Remove double negations
This commit is contained in:
committed by
Lars-Magnus Skog
parent
9314a5a8fd
commit
707c8c2830
@@ -462,20 +462,18 @@ pub unsafe fn dc_decrypt_setup_file(
|
||||
|
||||
let mut payload: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
fc_buf = dc_strdup(filecontent);
|
||||
if !(0
|
||||
== dc_split_armored_data(
|
||||
fc_buf,
|
||||
&mut fc_headerline,
|
||||
0 as *mut *const libc::c_char,
|
||||
0 as *mut *const libc::c_char,
|
||||
&mut fc_base64,
|
||||
)
|
||||
|| fc_headerline.is_null()
|
||||
|| strcmp(
|
||||
if dc_split_armored_data(
|
||||
fc_buf,
|
||||
&mut fc_headerline,
|
||||
0 as *mut *const libc::c_char,
|
||||
0 as *mut *const libc::c_char,
|
||||
&mut fc_base64,
|
||||
) && !fc_headerline.is_null()
|
||||
&& strcmp(
|
||||
fc_headerline,
|
||||
b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char,
|
||||
) != 0i32
|
||||
|| fc_base64.is_null())
|
||||
) == 0
|
||||
&& !fc_base64.is_null()
|
||||
{
|
||||
/* convert base64 to binary */
|
||||
/*must be freed using mmap_string_unref()*/
|
||||
@@ -1154,7 +1152,7 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
|
||||
private_key = buf;
|
||||
free(buf2 as *mut libc::c_void);
|
||||
buf2 = dc_strdup(buf);
|
||||
if 0 != dc_split_armored_data(
|
||||
if dc_split_armored_data(
|
||||
buf2,
|
||||
&mut buf2_headerline,
|
||||
0 as *mut *const libc::c_char,
|
||||
|
||||
@@ -1031,19 +1031,17 @@ pub unsafe fn dc_msg_get_setupcodebegin(msg: *const dc_msg_t) -> *mut libc::c_ch
|
||||
|| buf.is_null()
|
||||
|| buf_bytes <= 0)
|
||||
{
|
||||
if !(0
|
||||
== dc_split_armored_data(
|
||||
buf,
|
||||
&mut buf_headerline,
|
||||
&mut buf_setupcodebegin,
|
||||
0 as *mut *const libc::c_char,
|
||||
0 as *mut *const libc::c_char,
|
||||
)
|
||||
|| strcmp(
|
||||
buf_headerline,
|
||||
b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char,
|
||||
) != 0i32
|
||||
|| buf_setupcodebegin.is_null())
|
||||
if dc_split_armored_data(
|
||||
buf,
|
||||
&mut buf_headerline,
|
||||
&mut buf_setupcodebegin,
|
||||
0 as *mut *const libc::c_char,
|
||||
0 as *mut *const libc::c_char,
|
||||
) && strcmp(
|
||||
buf_headerline,
|
||||
b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0
|
||||
&& !buf_setupcodebegin.is_null()
|
||||
{
|
||||
ret = dc_strdup(buf_setupcodebegin)
|
||||
}
|
||||
|
||||
@@ -17,15 +17,14 @@ use crate::keyring::*;
|
||||
use crate::types::*;
|
||||
use crate::x::*;
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_split_armored_data(
|
||||
buf: *mut libc::c_char,
|
||||
ret_headerline: *mut *const libc::c_char,
|
||||
ret_setupcodebegin: *mut *const libc::c_char,
|
||||
ret_preferencrypt: *mut *const libc::c_char,
|
||||
ret_base64: *mut *const libc::c_char,
|
||||
) -> libc::c_int {
|
||||
let mut success: libc::c_int = 0i32;
|
||||
) -> bool {
|
||||
let mut success = false;
|
||||
let mut line_chars: size_t = 0i32 as size_t;
|
||||
let mut line: *mut libc::c_char = buf;
|
||||
let mut p1: *mut libc::c_char = buf;
|
||||
@@ -128,7 +127,7 @@ pub unsafe fn dc_split_armored_data(
|
||||
if !ret_base64.is_null() {
|
||||
*ret_base64 = base64
|
||||
}
|
||||
success = 1i32
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user