1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 use core::ffi::{c_uchar, c_int, c_char, c_ulong, CStr, c_void};
17
18 #[allow(unused)]
err_print_cb(err_str: *const c_char, _len: c_ulong, _u: *mut c_void) -> c_int19 pub extern fn err_print_cb (err_str: *const c_char, _len: c_ulong, _u: *mut c_void) -> c_int
20 {
21 println!("openssl err: {}", unsafe { CStr::from_ptr(err_str) }.to_string_lossy());
22 1 // don't abort program
23 }
24
25 #[link(name = "crypto_static")]
26 #[allow(unused)]
27 extern "C" {
28 /// evp bindings
EVP_DecodeBlock(t: *mut c_uchar, f: *const c_uchar, n: c_int) -> c_int29 pub fn EVP_DecodeBlock(t: *mut c_uchar, f: *const c_uchar, n: c_int) -> c_int;
30
ERR_print_errors_cb( cb: extern fn( err_str: *const c_char, len: c_ulong, u: *mut c_void ) -> c_int, u: *mut c_void ) -> c_void31 pub fn ERR_print_errors_cb(
32 cb: extern fn(
33 err_str: *const c_char,
34 len: c_ulong,
35 u: *mut c_void
36 ) -> c_int,
37 u: *mut c_void
38 ) -> c_void;
39 }
40
41 /// this should be consistent with enum in log/log.h
42 #[allow(unused)]
43 pub enum LogLevel {
44 DEBUG = 3,
45 INFO = 4,
46 WARNING = 5,
47 ERROR = 6,
48 FATAL = 7,
49 }
50
51 #[link(name = "updaterlog")]
52 extern "C" {
Logger(level: c_int, file_name: *const c_char, line: i32, format: *const c_char, ...) -> c_void53 pub fn Logger(level: c_int, file_name: *const c_char, line: i32, format: *const c_char, ...) -> c_void;
54 }