use core::{
    ffi::{c_char, c_int},
    ptr::null_mut,
};

use alloc::boxed::Box;

#[derive(Clone, Copy)]
#[repr(C)]
pub struct lconv {
    pub currency_symbol: *mut c_char,
    pub decimal_point: *mut c_char,
    pub frac_digits: c_char,
    pub grouping: *mut c_char,
    pub int_curr_symbol: *mut c_char,
    pub int_frac_digits: c_char,
    pub int_n_cs_precedes: c_char,
    pub int_n_sep_by_space: c_char,
    pub int_n_sign_posn: c_char,
    pub int_p_cs_precedes: c_char,
    pub int_p_sep_by_space: c_char,
    pub int_p_sign_posn: c_char,
    pub mon_decimal_point: *mut c_char,
    pub mon_grouping: *mut c_char,
    pub mon_thousands_sep: *mut c_char,
    pub negative_sign: *mut c_char,
    pub n_cs_precedes: c_char,
    pub n_sep_by_space: c_char,
    pub n_sign_posn: c_char,
    pub positive_sign: *mut c_char,
    pub p_cs_precedes: c_char,
    pub p_sep_by_space: c_char,
    pub p_sign_posn: c_char,
    pub thousands_sep: *mut c_char,
}

pub struct __locale_data {}

#[derive(Clone, Copy)]
#[repr(C)]
pub struct __locale_struct {
    pub __locales: [*mut __locale_data; __LC_LAST],
}

pub type locale_t = *mut __locale_struct;

pub const LC_COLLATE: c_int = 0;
pub const LC_CTYPE: c_int = 1;
pub const LC_MESSAGES: c_int = 2;
pub const LC_MONETARY: c_int = 3;
pub const LC_NUMERIC: c_int = 4;
pub const LC_TIME: c_int = 5;

pub const LC_COLLATE_MASK: c_int = 0;
pub const LC_CTYPE_MASK: c_int = 0;
pub const LC_MESSAGES_MASK: c_int = 0;
pub const LC_MONETARY_MASK: c_int = 0;
pub const LC_NUMERIC_MASK: c_int = 0;
pub const LC_TIME_MASK: c_int = 0;

pub const LC_ALL_MASK: c_int = 0;

pub const LC_ALL: c_int = 6;
pub const __LC_LAST: usize = 6;

#[no_mangle]
unsafe extern "C" fn duplocale(_locobj: locale_t) -> locale_t {
    todo!()
}

#[no_mangle]
unsafe extern "C" fn freelocale(_locobj: locale_t) {
    todo!()
}

#[no_mangle]
unsafe extern "C" fn localeconv() -> *mut lconv {
    todo!()
}

#[no_mangle]
unsafe extern "C" fn newlocale(
    _category_mask: c_int,
    _locale: *const c_char,
    _base: locale_t,
) -> locale_t {
    let locale = Box::new(__locale_struct {
        __locales: [null_mut(); __LC_LAST],
    });

    Box::into_raw(locale)
}

#[no_mangle]
unsafe extern "C" fn setlocale(_category: c_int, _locale: *const c_char) -> *mut c_char {
    // TODO
    c"C".as_ptr().cast_mut()
}

#[no_mangle]
unsafe extern "C" fn uselocale(_locobj: locale_t) -> locale_t {
    null_mut()
}
