euroscope-sys 0.0.1

Raw FFI bindings and C++ glue shim for the EuroScope plugin SDK
//! Owned-handle selectors, cross-navigation, and misc `CPlugIn` scalars.
//!
//! The `*_select_*` / `*_correlated_*` functions return a heap-owned handle
//! copy (or null); free it with the matching `es_*_free`.

use std::ffi::{c_char, c_int};

use crate::{EsHandle, PluginPtr};

unsafe extern "C" {
    // CFlightPlan
    pub fn es_flightplan_free(fp: EsHandle);
    pub fn es_plugin_flightplan_select_first(plugin: PluginPtr) -> EsHandle;
    pub fn es_plugin_flightplan_select_next(plugin: PluginPtr, current: EsHandle) -> EsHandle;
    pub fn es_plugin_flightplan_select_asel(plugin: PluginPtr) -> EsHandle;
    pub fn es_plugin_flightplan_select(plugin: PluginPtr, callsign: *const c_char) -> EsHandle;
    pub fn es_flightplan_correlated_radar_target(fp: EsHandle) -> EsHandle;

    // CRadarTarget
    pub fn es_radartarget_free(rt: EsHandle);
    pub fn es_plugin_radartarget_select_first(plugin: PluginPtr) -> EsHandle;
    pub fn es_plugin_radartarget_select_next(plugin: PluginPtr, current: EsHandle) -> EsHandle;
    pub fn es_plugin_radartarget_select_asel(plugin: PluginPtr) -> EsHandle;
    pub fn es_plugin_radartarget_select(plugin: PluginPtr, callsign: *const c_char) -> EsHandle;
    pub fn es_radartarget_correlated_flight_plan(rt: EsHandle) -> EsHandle;
    /// Owned latest position snapshot (free with `es_rtposdata_free`).
    pub fn es_radartarget_current_position(rt: EsHandle) -> EsHandle;
    /// Owned previous snapshot before `current` (free with `es_rtposdata_free`).
    pub fn es_radartarget_previous_position(rt: EsHandle, current: EsHandle) -> EsHandle;
    /// Owned FP-track position snapshot (free with `es_rtposdata_free`).
    pub fn es_flightplan_track_position(fp: EsHandle) -> EsHandle;

    // CController
    pub fn es_controller_free(c: EsHandle);
    pub fn es_plugin_controller_select_first(plugin: PluginPtr) -> EsHandle;
    pub fn es_plugin_controller_select_next(plugin: PluginPtr, current: EsHandle) -> EsHandle;
    pub fn es_plugin_controller_select(plugin: PluginPtr, callsign: *const c_char) -> EsHandle;
    pub fn es_plugin_controller_select_by_position_id(
        plugin: PluginPtr,
        position_id: *const c_char,
    ) -> EsHandle;
    pub fn es_plugin_controller_myself(plugin: PluginPtr) -> EsHandle;

    // Misc
    pub fn es_plugin_transition_altitude(plugin: PluginPtr) -> c_int;
    pub fn es_plugin_set_asel_flightplan(plugin: PluginPtr, fp: EsHandle);
    pub fn es_plugin_set_asel_radartarget(plugin: PluginPtr, rt: EsHandle);
    pub fn es_plugin_get_data_from_settings(plugin: PluginPtr, key: *const c_char)
    -> *const c_char;
    pub fn es_plugin_save_data_to_settings(
        plugin: PluginPtr,
        key: *const c_char,
        description: *const c_char,
        value: *const c_char,
    );

    // CFlightPlanList
    pub fn es_fplist_free(list: EsHandle);
    pub fn es_plugin_register_fp_list(plugin: PluginPtr, name: *const c_char) -> EsHandle;

    // CSectorElement (filtered by element type)
    pub fn es_sectorelement_free(el: EsHandle);
    pub fn es_plugin_sectorelement_select_first(plugin: PluginPtr, element_type: c_int)
    -> EsHandle;
    pub fn es_plugin_sectorelement_select_next(
        plugin: PluginPtr,
        current: EsHandle,
        element_type: c_int,
    ) -> EsHandle;

    // CGrountToAirChannel
    pub fn es_gtachannel_free(ch: EsHandle);
    pub fn es_plugin_gtachannel_select_first(plugin: PluginPtr) -> EsHandle;
    pub fn es_plugin_gtachannel_select_next(plugin: PluginPtr, current: EsHandle) -> EsHandle;
}