Files
praxisandClaude Fable 5.2 8e02dccb86 In-client stack: transport, session lifecycle and engine bridge
175 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

88 lines
4.0 KiB
C

#include <windows.h>
#include "pipe_live_input.h"
#include <stddef.h>
#include <string.h>
_Static_assert(sizeof(struct gw_session_pipe_tables) ==
sizeof(struct gw_private_pipe_tables),
"native epoch tables differ from atomic publisher");
_Static_assert(offsetof(struct gw_session_pipe_tables, methods) ==
offsetof(struct gw_private_pipe_tables, methods),
"native epoch method offset differs");
int gw_pipe_live_prepare_input(void *opaque, uintptr_t owner,
uint32_t current_thread,
struct gw_pipe_admission_input *out) {
const struct gw_pipe_live_input_context *context = opaque;
const struct gw_wire_auth_control *auth;
const struct gw_wire_auth_credentials *credentials;
const struct gw_session_pipe_callbacks *callbacks;
const struct gw_session_pipe_receivers *receivers;
const struct gw_session_pipe_tables *tables;
uint32_t generation;
struct gw_pipe_admission_input candidate;
if (!context || !out || context->abi != 1 ||
context->size != sizeof(*context) ||
!owner || owner != context->owner ||
!current_thread || current_thread != context->primary_thread ||
!context->bound_owner_vtable || !context->auth ||
!context->credentials || !context->pipe_generation ||
!context->control || !context->tables || !context->callbacks ||
!context->receivers || !context->read || !context->executable ||
!context->writable ||
context->callback_module_begin >= context->callback_module_end)
return -1;
auth = context->auth;
credentials = context->credentials;
callbacks = context->callbacks;
receivers = context->receivers;
tables = context->tables;
if (auth->abi != 1 || auth->size != sizeof(*auth) ||
auth->state != 2 || auth->error || auth->cancel ||
auth->server_proof_verified != 1 ||
auth->transport_prepared != 1 ||
credentials->abi != 1 ||
credentials->size != sizeof(*credentials) ||
credentials->state != 3 || !credentials->generation ||
credentials->generation > 64 ||
credentials->consumed_generation != credentials->generation ||
credentials->username_bytes || credentials->password_bytes ||
credentials->reserved)
return -2;
generation = context->pipe_generation();
if (generation != credentials->generation) return -3;
memset(&candidate, 0, sizeof(candidate));
candidate.read_context = context->probe_context;
candidate.read = context->read;
candidate.executable = context->executable;
candidate.writable = context->writable;
candidate.expected_owner = owner;
candidate.expected_bound_owner_vtable =
context->bound_owner_vtable;
candidate.current_thread = current_thread;
candidate.primary_thread = context->primary_thread;
candidate.auth_state = (uint32_t)auth->state;
candidate.server_proof_verified =
(uint32_t)auth->server_proof_verified;
candidate.transport_prepared = (uint32_t)auth->transport_prepared;
candidate.credentials_generation = credentials->generation;
candidate.pipe_generation = generation;
candidate.callback_module_begin = context->callback_module_begin;
candidate.callback_module_end = context->callback_module_end;
candidate.current_control = context->control;
candidate.current_tables =
(const struct gw_private_pipe_tables *)tables;
candidate.epoch_callbacks = callbacks->callbacks;
candidate.epoch_callbacks_abi = callbacks->abi;
candidate.epoch_callbacks_size = callbacks->size;
candidate.epoch_callbacks_count = callbacks->count;
candidate.epoch_callbacks_reserved = callbacks->reserved;
candidate.retired_receivers = receivers->objects;
candidate.retired_receivers_abi = receivers->abi;
candidate.retired_receivers_size = receivers->size;
candidate.retired_receivers_count = receivers->count;
candidate.retired_receivers_reserved = receivers->reserved;
*out = candidate;
return 0;
}