// quicprochat_ffi.h — C header for libquicprochat_ffi. // // Mirrors the extern "C" functions from crates/quicprochat-ffi/src/lib.rs. #ifndef QUICPROCHAT_FFI_H #define QUICPROCHAT_FFI_H #include #include #ifdef __cplusplus extern "C" { #endif // Status codes. #define QPQ_OK 0 #define QPQ_ERROR 1 #define QPQ_AUTH_FAILED 2 #define QPQ_TIMEOUT 3 #define QPQ_NOT_CONNECTED 4 // Opaque handle type. typedef struct QpqHandle QpqHandle; // Connect to a quicprochat server. Returns NULL on failure. QpqHandle* qpq_connect(const char* server, const char* ca_cert, const char* server_name); // Authenticate with OPAQUE credentials. int qpq_login(QpqHandle* handle, const char* username, const char* password); // Send a message to a recipient (by username). int qpq_send(QpqHandle* handle, const char* recipient, const uint8_t* message, size_t message_len); // Receive pending messages (blocking). On success, *out_json is a // heap-allocated JSON string that must be freed with qpq_free_string. int qpq_receive(QpqHandle* handle, uint32_t timeout_ms, char** out_json); // Disconnect and free the handle. void qpq_disconnect(QpqHandle* handle); // Return the last error message, or NULL. Do NOT free the result. const char* qpq_last_error(const QpqHandle* handle); // Free a string returned by qpq_receive. void qpq_free_string(char* ptr); #ifdef __cplusplus } #endif #endif // QUICPROCHAT_FFI_H