56 lines
1.4 KiB
C
56 lines
1.4 KiB
C
// Minimal C header for medicallib_rust FFI
|
|
// Build with: cargo build --features ffi --release
|
|
// Link your C app against the produced cdylib and ensure the header codes
|
|
// match the Rust definitions.
|
|
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
|
|
// Return codes
|
|
#define ML_OK 0
|
|
#define ML_ERR 1
|
|
#define ML_EINVAL 2
|
|
|
|
typedef struct MLPatient MLPatient; // opaque
|
|
|
|
// Organ codes (keep in sync with Rust)
|
|
#define ML_ORGAN_HEART 0
|
|
#define ML_ORGAN_LUNGS 1
|
|
#define ML_ORGAN_BRAIN 2
|
|
#define ML_ORGAN_SPINAL_CORD 3
|
|
#define ML_ORGAN_STOMACH 4
|
|
#define ML_ORGAN_LIVER 5
|
|
#define ML_ORGAN_GALLBLADDER 6
|
|
#define ML_ORGAN_PANCREAS 7
|
|
#define ML_ORGAN_INTESTINES 8
|
|
#define ML_ORGAN_ESOPHAGUS 9
|
|
#define ML_ORGAN_KIDNEYS 10
|
|
#define ML_ORGAN_BLADDER 11
|
|
#define ML_ORGAN_SPLEEN 12
|
|
|
|
// BMI computation. Returns 0 on success, writes to out_bmi.
|
|
int32_t medicallib_bmi(float weight_kg, float height_m, float* out_bmi);
|
|
|
|
// Patient lifecycle
|
|
MLPatient* ml_patient_new(const char* id);
|
|
void ml_patient_free(MLPatient* p);
|
|
|
|
// Returns a newly-allocated C string. Free with ml_string_free.
|
|
char* ml_patient_summary(const MLPatient* p);
|
|
void ml_string_free(char* s);
|
|
|
|
// Advance simulation by dt seconds.
|
|
int32_t ml_patient_update(MLPatient* p, float dt_seconds);
|
|
|
|
// Get summary for a specific organ type code.
|
|
char* ml_patient_organ_summary(const MLPatient* p, uint32_t organ_code);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|