]> mj.ucw.cz Git - libucw.git/blob - charset/unistream.h
dmalloc and efence work again (ported from rel-2.1 branch).
[libucw.git] / charset / unistream.h
1 /*
2  *      The UniCode Library: Reading and writing of UTF-8 on Fastbuf Streams
3  *
4  *      (c) 2001--2002 Martin Mares <mj@ucw.cz>
5  */
6
7 #ifndef _UNISTREAM_H
8 #define _UNISTREAM_H
9
10 #include "charset/unicode.h"
11
12 int bget_utf8_slow(struct fastbuf *b);
13 void bput_utf8_slow(struct fastbuf *b, uns u);
14
15 static inline int
16 bget_utf8(struct fastbuf *b)
17 {
18   uns u;
19
20   if (b->bptr + 5 <= b->bufend)
21     {
22       GET_UTF8(b->bptr, u);
23       return u;
24     }
25   else
26     return bget_utf8_slow(b);
27 }
28
29 static inline void
30 bput_utf8(struct fastbuf *b, uns u)
31 {
32   ASSERT(u < 65536);
33   if (b->bptr + 5 <= b->bufend)
34     PUT_UTF8(b->bptr, u);
35   else
36     bput_utf8_slow(b, u);
37 }
38
39 #endif