From e0fa36e9427424a1e68d4c196dd5249b1cef7e2c Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Mon, 13 Jan 2025 18:57:16 -0700 Subject: wip container types --- lib9p/9p.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'lib9p/9p.c') diff --git a/lib9p/9p.c b/lib9p/9p.c index ecb75fd..06f4023 100644 --- a/lib9p/9p.c +++ b/lib9p/9p.c @@ -146,15 +146,17 @@ void _lib9p_unmarshal(const struct _lib9p_recv_tentry xxx_table[LIB9P_VER_NUM][0 } void lib9p_Tmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, - enum lib9p_msg_type *ret_typ, void *ret_body) { + struct lib9p_Tmsg *ret) { + assert(ret); _lib9p_unmarshal(_lib9p_table_Tmsg_recv, - ctx, net_bytes, ret_typ, ret_body); + ctx, net_bytes, &ret->typ, &ret->body); } void lib9p_Rmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, - enum lib9p_msg_type *ret_typ, void *ret_body) { + struct lib9p_Rmsg *ret) { + assert(ret); _lib9p_unmarshal(_lib9p_table_Rmsg_recv, - ctx, net_bytes, ret_typ, ret_body); + ctx, net_bytes, &ret->typ, &ret->body); } static @@ -171,16 +173,20 @@ bool _lib9p_marshal(const struct _lib9p_send_tentry xxx_table[LIB9P_VER_NUM][0x8 return tentry.marshal(&subctx, body); } -bool lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, +bool lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, struct lib9p_Tmsg *msg, uint8_t *ret_bytes) { - assert(typ % 2 == 0); - return _lib9p_marshal(_lib9p_table_Tmsg_send, ctx, typ, body, ret_bytes); + assert(msg); + assert(msg->typ % 2 == 0); + return _lib9p_marshal(_lib9p_table_Tmsg_send, ctx, msg->typ, &msg->body, + ret_bytes); } -bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, +bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, struct lib9p_Rmsg *msg, uint8_t *ret_bytes) { - assert(typ % 2 == 1); - return _lib9p_marshal(_lib9p_table_Rmsg_send, ctx, typ, body, ret_bytes); + assert(msg); + assert(msg->typ % 2 == 1); + return _lib9p_marshal(_lib9p_table_Rmsg_send, ctx, msg->typ, &msg->body, + ret_bytes); } /* `struct lib9p_stat` helpers ************************************************/ -- cgit v1.2.3-2-g168b