Skip to main content

hxcfe_sys/
lib.rs

1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![deny(clippy::as_conversions)]
5
6include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
7
8// Include generated ImageFormat enum
9include!(concat!(env!("OUT_DIR"), "/image_format.rs"));
10
11// Include generated InterfaceMode enum
12include!(concat!(env!("OUT_DIR"), "/interface_mode.rs"));
13
14// Include generated TrackEncoding enum
15include!(concat!(env!("OUT_DIR"), "/track_encoding.rs"));
16
17// Include generated DiskLayout enum
18include!(concat!(env!("OUT_DIR"), "/disk_layout.rs"));
19
20/// Core HxCFloppyEmulator library functions
21///
22/// This module contains functions for floppy disk image manipulation,
23/// including loading, saving, track/sector access, filesystem operations,
24/// and format conversion.
25pub mod hxcfe {
26    pub use crate::{
27        hxcfe_FDC_FORMAT, hxcfe_FDC_READSECTOR, hxcfe_FDC_SCANSECTOR, hxcfe_FDC_WRITESECTOR,
28        hxcfe_FxStream_AddIndex, hxcfe_FxStream_AnalyzeAndGetTrack, hxcfe_FxStream_ChangeSpeed,
29        hxcfe_FxStream_ExportToBmp, hxcfe_FxStream_FreeStream,
30        hxcfe_FxStream_GetMeanRevolutionPeriod, hxcfe_FxStream_GetNumberOfRevolution,
31        hxcfe_FxStream_GetRevolutionIndex, hxcfe_FxStream_GetRevolutionPeriod,
32        hxcfe_FxStream_ImportHxCStreamBuffer, hxcfe_FxStream_ImportStream,
33        hxcfe_FxStream_SetIndexLength, hxcfe_FxStream_setBitrate,
34        hxcfe_FxStream_setFilterParameters, hxcfe_FxStream_setPhaseCorrectionFactor,
35        hxcfe_FxStream_setResolution, hxcfe_addSector, hxcfe_addSectors, hxcfe_addTrack,
36        hxcfe_allocSide1, hxcfe_clearTrackCache, hxcfe_closeDir, hxcfe_closeFile, hxcfe_createDir,
37        hxcfe_createFile, hxcfe_deinit, hxcfe_deinitFDC, hxcfe_deinitFsManager,
38        hxcfe_deinitFxStream, hxcfe_deinitScript, hxcfe_deinitSectorAccess, hxcfe_deinitXmlFloppy,
39        hxcfe_deleteFile, hxcfe_deleteSide1, hxcfe_duplicateSide, hxcfe_execScriptFile,
40        hxcfe_execScriptLine, hxcfe_execScriptRam, hxcfe_floppyDuplicate,
41        hxcfe_floppyGetDoubleStep, hxcfe_floppyGetFlags, hxcfe_floppyGetInterfaceMode,
42        hxcfe_floppyGetSetParams, hxcfe_floppySectorBySectorCopy, hxcfe_floppySetDoubleStep,
43        hxcfe_floppySetFlags, hxcfe_floppySetInterfaceMode, hxcfe_floppyUnload,
44        hxcfe_foundMatchingXmlFileFloppy, hxcfe_freeFloppy, hxcfe_freeSectorConfig,
45        hxcfe_freeSectorConfigData, hxcfe_freeSide, hxcfe_fseek, hxcfe_ftell, hxcfe_generateDisk,
46        hxcfe_generateFloppy, hxcfe_generateXmlFileFloppy, hxcfe_generateXmlFloppy,
47        hxcfe_getAllTrackISOSectors, hxcfe_getAllTrackSectors, hxcfe_getCellBitrate,
48        hxcfe_getCellFlakeyState, hxcfe_getCellIndexState, hxcfe_getCellState,
49        hxcfe_getCurrentNumberOfSector, hxcfe_getCurrentNumberOfSide,
50        hxcfe_getCurrentNumberOfTrack, hxcfe_getCurrentRPM, hxcfe_getCurrentSectorSize,
51        hxcfe_getCurrentSkew, hxcfe_getCurrentTrackType, hxcfe_getEnvVar, hxcfe_getEnvVarIndex,
52        hxcfe_getEnvVarValue, hxcfe_getFSDesc, hxcfe_getFSID, hxcfe_getFSName, hxcfe_getFirstFile,
53        hxcfe_getFloppy, hxcfe_getFloppyInterfaceModeDesc, hxcfe_getFloppyInterfaceModeID,
54        hxcfe_getFloppyInterfaceModeName, hxcfe_getFloppySize, hxcfe_getFreeFsSpace, hxcfe_getHash,
55        hxcfe_getLicense, hxcfe_getNextFile, hxcfe_getNextSector, hxcfe_getNumberOfSide,
56        hxcfe_getNumberOfTrack, hxcfe_getSectorConfigDCRC, hxcfe_getSectorConfigDCRCStatus,
57        hxcfe_getSectorConfigDataMark, hxcfe_getSectorConfigEncoding,
58        hxcfe_getSectorConfigEndSectorIndex, hxcfe_getSectorConfigHCRC,
59        hxcfe_getSectorConfigHCRCStatus, hxcfe_getSectorConfigInputData,
60        hxcfe_getSectorConfigSectorID, hxcfe_getSectorConfigSectorSize,
61        hxcfe_getSectorConfigSideID, hxcfe_getSectorConfigSizeID,
62        hxcfe_getSectorConfigStartDataIndex, hxcfe_getSectorConfigStartSectorIndex,
63        hxcfe_getSectorConfigTrackID, hxcfe_getSectorData, hxcfe_getSectorSize, hxcfe_getSide,
64        hxcfe_getTotalFsSpace, hxcfe_getTrackBitrate, hxcfe_getTrackEncoding,
65        hxcfe_getTrackEncodingName, hxcfe_getTrackLength, hxcfe_getTrackNumberOfSide,
66        hxcfe_getTrackRPM, hxcfe_getVersion, hxcfe_getXmlLayoutDesc, hxcfe_getXmlLayoutID,
67        hxcfe_getXmlLayoutName, hxcfe_imgAutoSetectLoader, hxcfe_imgCallProgressCallback,
68        hxcfe_imgCheckFileCompatibility, hxcfe_imgDeInitLoader, hxcfe_imgExport,
69        hxcfe_imgGetLoaderAccess, hxcfe_imgGetLoaderDesc, hxcfe_imgGetLoaderExt,
70        hxcfe_imgGetLoaderID, hxcfe_imgGetLoaderName, hxcfe_imgGetNumberOfLoader,
71        hxcfe_imgInitLoader, hxcfe_imgLoad, hxcfe_imgLoadEx, hxcfe_imgSetProgressCallback,
72        hxcfe_imgUnload, hxcfe_init, hxcfe_initFDC, hxcfe_initFloppy, hxcfe_initFsManager,
73        hxcfe_initFxStream, hxcfe_initScript, hxcfe_initSectorAccess, hxcfe_initXmlFloppy,
74        hxcfe_insertCell, hxcfe_insertDiskFDC, hxcfe_insertTrack, hxcfe_localRepair,
75        hxcfe_mountImage, hxcfe_numberOfFS, hxcfe_numberOfXmlLayout, hxcfe_openDir, hxcfe_openFile,
76        hxcfe_popSector, hxcfe_popTrack, hxcfe_preloadImgInfos, hxcfe_pushSector, hxcfe_pushTrack,
77        hxcfe_pushTrackPFS, hxcfe_readDir, hxcfe_readFile, hxcfe_readSectorData,
78        hxcfe_readSectorFDC, hxcfe_removeCell, hxcfe_removeDir, hxcfe_removeLastTrack,
79        hxcfe_removeOddTracks, hxcfe_removeTrack, hxcfe_replaceSide,
80        hxcfe_resetSearchTrackPosition, hxcfe_reverseFloppy, hxcfe_reverseTrackData,
81        hxcfe_rotateFloppy, hxcfe_searchSector, hxcfe_sectorRepair, hxcfe_selectFS,
82        hxcfe_selectXmlFloppyLayout, hxcfe_setCellBitrate, hxcfe_setCellFlakeyState,
83        hxcfe_setCellIndexState, hxcfe_setCellState, hxcfe_setDiskFlags,
84        hxcfe_setDiskSectorsHeadID, hxcfe_setEnvVar, hxcfe_setEnvVarValue, hxcfe_setIndexLength,
85        hxcfe_setIndexPosition, hxcfe_setInterfaceMode, hxcfe_setNumberOfSector,
86        hxcfe_setNumberOfSide, hxcfe_setNumberOfTrack, hxcfe_setOutputFunc, hxcfe_setRPM,
87        hxcfe_setScriptOutputFunc, hxcfe_setSectorAccessFlags, hxcfe_setSectorBitrate,
88        hxcfe_setSectorData, hxcfe_setSectorDataCRC, hxcfe_setSectorDataMark,
89        hxcfe_setSectorEncoding, hxcfe_setSectorFill, hxcfe_setSectorGap3, hxcfe_setSectorHeadID,
90        hxcfe_setSectorHeaderCRC, hxcfe_setSectorID, hxcfe_setSectorSize, hxcfe_setSectorSizeID,
91        hxcfe_setSectorTrackID, hxcfe_setSideSkew, hxcfe_setStartSectorID, hxcfe_setTrackBitrate,
92        hxcfe_setTrackInterleave, hxcfe_setTrackPreGap, hxcfe_setTrackRPM, hxcfe_setTrackSkew,
93        hxcfe_setTrackType, hxcfe_setXmlFloppyLayoutFile, hxcfe_shiftTrackData,
94        hxcfe_td_activate_analyzer, hxcfe_td_deinit, hxcfe_td_draw_disk,
95        hxcfe_td_draw_stream_track, hxcfe_td_draw_track, hxcfe_td_draw_trkstream,
96        hxcfe_td_exportToBMP, hxcfe_td_get_view_mode_name, hxcfe_td_getframebuffer,
97        hxcfe_td_getframebuffer_xres, hxcfe_td_getframebuffer_yres, hxcfe_td_getlastpulselist,
98        hxcfe_td_getlastsectorlist, hxcfe_td_init, hxcfe_td_select_view_type, hxcfe_td_set_marker,
99        hxcfe_td_setName, hxcfe_td_setProgressCallback, hxcfe_td_setparams,
100        hxcfe_td_stream_to_sound, hxcfe_td_virt_xres, hxcfe_td_virt_yres, hxcfe_td_window_xpos,
101        hxcfe_td_window_ypos, hxcfe_td_zoom_area, hxcfe_umountImage, hxcfe_writeFile,
102        hxcfe_writeSectorData, hxcfe_writeSectorFDC,
103    };
104}
105
106/// Platform abstraction layer functions
107///
108/// This module provides cross-platform file I/O, threading, synchronization,
109/// and string manipulation functions used by the HxC library.
110pub mod hxcadaptor {
111    pub use crate::{
112        hxc_checkfileext, hxc_createcriticalsection, hxc_createevent, hxc_createthread,
113        hxc_destroycriticalsection, hxc_dyn_sprintfcat, hxc_dyn_strcat, hxc_entercriticalsection,
114        hxc_fclose, hxc_fgets, hxc_fgetsize, hxc_find_close, hxc_find_first_file,
115        hxc_find_next_file, hxc_fopen, hxc_fread, hxc_getcurrentdirectory, hxc_getfilenamebase,
116        hxc_getfilenameext, hxc_getfilenamewext, hxc_getfilesize, hxc_getpathfolder,
117        hxc_leavecriticalsection, hxc_mkdir, hxc_open, hxc_pause, hxc_ram_fclose, hxc_ram_fopen,
118        hxc_ram_fwrite, hxc_setevent, hxc_stat, hxc_strlower, hxc_strupper, hxc_waitevent,
119    };
120}
121
122/// USB hardware interface functions (requires 'usb' feature)
123///
124/// This module provides functions to interface with physical USB floppy emulator hardware.
125/// Only available when the `usb` feature is enabled.
126///
127/// To use this module, add to your `Cargo.toml`:
128/// ```toml
129/// [dependencies]
130/// hxcfe-sys = { version = "*", features = ["usb"] }
131/// ```
132#[cfg(feature = "usb")]
133pub mod usbhxcfe {
134    pub use crate::{
135        libusbhxcfe_deInit, libusbhxcfe_ejectFloppy, libusbhxcfe_getCurTrack,
136        libusbhxcfe_getDoubleStep, libusbhxcfe_getDrive, libusbhxcfe_getInterfaceMode,
137        libusbhxcfe_getStats, libusbhxcfe_init, libusbhxcfe_loadFloppy,
138        libusbhxcfe_setInterfaceMode, libusbhxcfe_setUSBBufferSize,
139    };
140}
141
142#[cfg(test)]
143mod test {
144    use crate::{hxcfe_deinit, hxcfe_init};
145
146    #[test]
147    fn nothing() {
148        unsafe {
149            let res = hxcfe_init();
150            hxcfe_deinit(res);
151        }
152    }
153
154    #[test]
155    fn module_hxcfe() {
156        // Test that hxcfe module exports work
157        unsafe {
158            let res = crate::hxcfe::hxcfe_init();
159            crate::hxcfe::hxcfe_deinit(res);
160        }
161    }
162
163    #[test]
164    fn module_hxcadaptor() {
165        // Test that hxcadaptor module exports work
166        use crate::hxcadaptor::hxc_strupper;
167        let _ = hxc_strupper; // Just verify it exists
168    }
169}