X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/1eeed1150149b63d6e49e033697454bc12b533b9..bdc143a7aa3f51a46eceec62b0b364599533fa21:/lunaix-os/includes/lunaix/ds/rbuffer.h diff --git a/lunaix-os/includes/lunaix/ds/rbuffer.h b/lunaix-os/includes/lunaix/ds/rbuffer.h index d45c9fd..ffbb99b 100644 --- a/lunaix-os/includes/lunaix/ds/rbuffer.h +++ b/lunaix-os/includes/lunaix/ds/rbuffer.h @@ -30,11 +30,22 @@ int rbuffer_puts(struct rbuffer* rb, char* c, size_t len); int -rbuffer_gets(struct rbuffer* rb, char* buf, size_t len); +rbuffer_gets_opt(struct rbuffer* rb, char* buf, size_t len, bool consumed); int rbuffer_get(struct rbuffer* rb, char* c); +static inline int +rbuffer_gets(struct rbuffer* rb, char* buf, size_t len) +{ + return rbuffer_gets_opt(rb, buf, len, true); +} + +static inline int +rbuffer_gets_no_consume(struct rbuffer* rb, char* buf, size_t len) +{ + return rbuffer_gets_opt(rb, buf, len, false); +} static inline void rbuffer_clear(struct rbuffer* rb) @@ -48,6 +59,19 @@ rbuffer_empty(struct rbuffer* rb) return rb->len == 0; } +static inline unsigned int +rbuffer_len(struct rbuffer* rb) +{ + return rb->len; +} + +static inline void +rbuffer_setcontent(struct rbuffer* rb, size_t content_len) +{ + rb->ptr = content_len; + rb->len = content_len; +} + static inline bool rbuffer_full(struct rbuffer* rb) {