pdcomm_gem_configure_programs
Function
Attaches a process program store to a GEM endpoint.
PdcommStatus pdcomm_gem_configure_programs(PdcommTcpEndpoint *endpoint, const PdcommGemProgramOptions *options, const char *path, size_t path_length)Call once while the endpoint is stopped, after configuring the GEM Host or Equipment role. With NULL and a zero path_length, the store lives in RAM. With a path, the store opens and validates a bounded snapshot file under an exclusive lock on <path>.lock; the parent directory must already exist. A missing file starts an empty store, which is written on the first mutation. If opening or loading fails, no store is attached and a corrupt file is never replaced with an empty catalog.
Parameters
| Name | Description |
|---|---|
endpoint | Stopped endpoint configured as GEM Host or Equipment. |
options | Limits and policy; version must be #PDCOMM_GEM_PROGRAM_OPTIONS_VERSION and reserved 0. |
path | UTF-8 snapshot path without a terminating NUL, or NULL for RAM. Embedded NUL bytes are rejected. |
path_length | Length of path in bytes; 0 selects RAM. |
Returns
#PDCOMM_OK on success; #PDCOMM_INVALID_ARGUMENT when endpoint or options is NULL, struct_size is too small, version or reserved is wrong, the grant policy is unknown, path is NULL with a nonzero length, or the path is not valid UTF-8, contains NUL, or has no file name; #PDCOMM_INVALID_STATE when the endpoint is not stopped, GEM is not configured, or a program store is already attached; #PDCOMM_BACKPRESSURE when a staged TCP event is pending or the snapshot lock is held by another owner; #PDCOMM_LIMIT_EXCEEDED when the file exceeds max_serialized_bytes or its content exceeds the store limits; #PDCOMM_INVALID_DATA when the snapshot is corrupt; #PDCOMM_IO_ERROR for file system errors; #PDCOMM_ALLOCATION_FAILED or #PDCOMM_POISONED.
Notes
- The snapshot lock is held until the endpoint is destroyed.