diff options
Diffstat (limited to 'lib9p/include/lib9p/9p.h')
-rw-r--r-- | lib9p/include/lib9p/9p.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h index 21c10e0..d4764a2 100644 --- a/lib9p/include/lib9p/9p.h +++ b/lib9p/include/lib9p/9p.h @@ -19,6 +19,17 @@ #error config.h must define CONFIG_9P_MAX_ERR_SIZE #endif +/* strings ********************************************************************/ + +const char *lib9p_version_str(enum lib9p_version); +const char *lib9p_msgtype_str(enum lib9p_version, enum lib9p_msg_type); + +struct lib9p_s lib9p_str(char *s); +struct lib9p_s lib9p_strn(char *s, size_t maxlen); +struct lib9p_s lib9p_str_slice(struct lib9p_s s, uint16_t beg, uint16_t end); +#define lib9p_str_sliceleft(s, beg) lib9p_str_slice(s, beg, (s).len) +bool lib9p_str_eq(struct lib9p_s a, struct lib9p_s b); + /* ctx ************************************************************************/ struct lib9p_ctx { @@ -30,7 +41,7 @@ struct lib9p_ctx { #ifdef CONFIG_9P_ENABLE_9P2000_u uint32_t err_num; #endif - char err_msg[CONFIG_9P_MAX_ERR_SIZE]; + [[gnu::nonstring]] char err_msg[CONFIG_9P_MAX_ERR_SIZE]; }; void lib9p_ctx_clear_error(struct lib9p_ctx *ctx); @@ -42,8 +53,6 @@ int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg); /** Write a printf-style error into ctx, return -1. */ int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, ...); -const char *lib9p_msg_type_str(struct lib9p_ctx *, enum lib9p_msg_type); - /* main T-message functions ***************************************************/ /** @@ -52,7 +61,7 @@ const char *lib9p_msg_type_str(struct lib9p_ctx *, enum lib9p_msg_type); * * Return how much space the message will take when unmarshaled. This * number may be larger than net_bytes due to (1) struct padding, (2) - * nul-terminator bytes for strings. + * array pointers. * * Emits an error (return -1, set ctx->err_num and ctx->err_msg) if * either the message type is unknown, or if net_bytes is too short |