Coverage Report

Created: 2026-09-28 07:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/suricata/rust/htp/src/c_api/uri.rs
Line
Count
Source
1
use crate::{bstr::Bstr, uri::Uri};
2
3
/// Get the hostname of a uri.
4
///
5
/// Returns the hostname for uri or NULL on error.
6
/// # Safety
7
/// When calling this method, you have to ensure that uri is either properly initialized or NULL
8
#[no_mangle]
9
4.82k
pub unsafe extern "C" fn htp_uri_hostname(uri: *const Uri) -> *const Bstr {
10
4.82k
    uri.as_ref()
11
4.82k
        .and_then(|uri| uri.hostname.as_ref())
12
4.82k
        .map(|hostname| hostname as *const Bstr)
13
4.82k
        .unwrap_or(std::ptr::null())
14
4.82k
}
15
16
/// Get the path of a uri.
17
///
18
/// Returns the path for uri or NULL on error.
19
/// # Safety
20
/// When calling this method, you have to ensure that uri is either properly initialized or NULL
21
#[no_mangle]
22
1.73M
pub unsafe extern "C" fn htp_uri_path(uri: *const Uri) -> *const Bstr {
23
1.73M
    uri.as_ref()
24
1.73M
        .and_then(|uri| uri.path.as_ref())
25
1.73M
        .map(|path| path as *const Bstr)
26
1.73M
        .unwrap_or(std::ptr::null())
27
1.73M
}