Files
marqdo-cli/crates/marqdo-host/include/marqdo_resource_provider.h
cflmy b22a89e7b4 feat(host): add trusted C ABI ResourceProvider v1
- Add the frozen marqdo_resource_provider.h ABI (version + open/read/write/
  close/last_error) and a libloading-based host adapter with version/symbol
  checks and callsite-attached host errors (ADR-0036).
- Add StdHost::register_c_resource_provider using the same kind/name validation
  and project-mode name grant as the in-process/worker providers.
- Compile a C shared-library test provider; cover round-trip and fail-closed
  missing-library behavior. Trusted native code, not a sandbox; plugin-Worker
  binding remains open.
- Update ADRs/spec/status/README/changelog and evidence.

Gate: fmt, clippy -D warnings, 435 tests passed.
2026-11-20 23:26:25 +08:00

38 lines
1.4 KiB
C

/* Marqdo ResourceProvider C ABI v1 (ADR-0036).
*
* This ABI is for trusted native adapters, not a sandbox. The host loads the
* shared library, checks marqdo_resource_provider_abi_version() == 1 and calls
* these symbols for language-level resource.* operations.
*
* Conventions:
* - return 0 on success, nonzero on failure;
* - failure text is available from marqdo_resource_last_error();
* - rights is a comma-separated list (e.g. "read,write");
* - provider tokens are private to the adapter and must not be exposed to
* language Values, wire frames or trace output.
*/
#ifndef MARQDO_RESOURCE_PROVIDER_H
#define MARQDO_RESOURCE_PROVIDER_H
#include <stdint.h>
#define MARQDO_RESOURCE_PROVIDER_ABI_VERSION 1u
uint32_t marqdo_resource_provider_abi_version(void);
int32_t marqdo_resource_open(const char *kind, const char *descriptor,
const char *rights_csv, uint64_t *out_token);
int32_t marqdo_resource_read(uint64_t token, uint8_t *buffer,
uint32_t capacity, uint32_t *out_read,
int32_t *out_eof);
int32_t marqdo_resource_write(uint64_t token, const uint8_t *bytes,
uint32_t length, uint32_t *out_written);
int32_t marqdo_resource_close(uint64_t token);
int32_t marqdo_resource_last_error(char *buffer, uint32_t capacity);
#endif /* MARQDO_RESOURCE_PROVIDER_H */