56 |
int alloc_failed; |
int alloc_failed; |
57 |
} STRBUF; |
} STRBUF; |
58 |
|
|
59 |
|
/* |
60 |
|
* STATIC_STRBUF(sb): |
61 |
|
* |
62 |
|
* This macro is used for static string buffer which is suitable for |
63 |
|
* work area and(or) return value of function. The area allocated once |
64 |
|
* is repeatedly used though the area is never released. |
65 |
|
* You must call strbuf_init(sb) every time before using. |
66 |
|
* You must not call strbuf_close(sb) for it. |
67 |
|
* |
68 |
|
* Usage: |
69 |
|
* function(...) { |
70 |
|
* STATIC_STRBUF(sb); |
71 |
|
* |
72 |
|
* strbuf_init(sb); |
73 |
|
* ... |
74 |
|
* strbuf_puts(sb, "xxxxx"); |
75 |
|
* ... |
76 |
|
* return strbuf_value(sb); |
77 |
|
* } |
78 |
|
*/ |
79 |
|
#define STATIC_STRBUF(sb) static STRBUF __##sb, *sb = &__##sb |
80 |
|
|
81 |
#define strbuf_putc(sb, c) do {\ |
#define strbuf_putc(sb, c) do {\ |
82 |
if (!sb->alloc_failed) {\ |
if (!sb->alloc_failed) {\ |
83 |
if (sb->curp >= sb->endp)\ |
if (sb->curp >= sb->endp)\ |
119 |
#endif |
#endif |
120 |
void __strbuf_expandbuf(STRBUF *, int); |
void __strbuf_expandbuf(STRBUF *, int); |
121 |
STRBUF *strbuf_open(int); |
STRBUF *strbuf_open(int); |
122 |
|
void strbuf_init(STRBUF *); |
123 |
void strbuf_putn(STRBUF *, int); |
void strbuf_putn(STRBUF *, int); |
124 |
int strbuf_unputc(STRBUF *, int); |
int strbuf_unputc(STRBUF *, int); |
125 |
char *strbuf_value(STRBUF *); |
char *strbuf_value(STRBUF *); |