1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 11:31:00 -05:00

Make strbuf a less opaque type.

Now, instead of being a black box that you shovel strings into and
eventually extract a final answer, it exposes enough structure fields
to the world that you can append things to it _and_ look inside its
current contents. For convenience, it exports its internal pointer as
both a char * and an unsigned char *.
This commit is contained in:
Simon Tatham
2018-05-24 14:55:10 +01:00
parent 12b38ad9e1
commit bff128fea9
3 changed files with 55 additions and 22 deletions

7
misc.h
View File

@ -37,9 +37,14 @@ char *dupprintf(const char *fmt, ...)
char *dupvprintf(const char *fmt, va_list ap);
void burnstr(char *string);
struct strbuf {
char *s;
unsigned char *u;
int len;
/* (also there's a surrounding implementation struct in misc.c) */
};
strbuf *strbuf_new(void);
void strbuf_free(strbuf *buf);
char *strbuf_str(strbuf *buf); /* does not free buf */
char *strbuf_to_str(strbuf *buf); /* does free buf, but you must free result */
void strbuf_catf(strbuf *buf, const char *fmt, ...);
void strbuf_catfv(strbuf *buf, const char *fmt, va_list ap);