blob: 785ce5882779380b42c5296d8b94a2f1e36be570 [file] [log] [blame]
paul067fca82006-01-10 14:49:04 +00001#include <zebra.h>
2#include <stream.h>
3#include <thread.h>
4
5static long int ham = 0xdeadbeefdeadbeef;
6struct thread_master *master;
7
8static void
9print_stream (struct stream *s)
10{
11 size_t getp = stream_get_getp (s);
12
13 printf ("endp: %ld, readable: %ld, writeable: %ld\n",
14 stream_get_endp (s),
15 STREAM_READABLE (s),
16 STREAM_WRITEABLE (s));
17
18 while (STREAM_READABLE (s))
19 {
20 printf ("0x%x ", *stream_pnt (s));
21 stream_forward_getp (s, 1);
22 }
23
24 printf ("\n");
25
26 /* put getp back to where it was */
27 stream_set_getp (s, getp);
28}
29
30int
31main (void)
32{
33 struct stream *s;
34
35 s = stream_new (1024);
36
37 stream_putc (s, ham);
38 stream_putw (s, ham);
39 stream_putl (s, ham);
40 stream_putq (s, ham);
41
42 print_stream (s);
43
44 stream_resize (s, stream_get_endp (s));
45
46 print_stream (s);
47
48 printf ("c: 0x%hhx\n", stream_getc (s));
49 printf ("w: 0x%hx\n", stream_getw (s));
50 printf ("l: 0x%x\n", stream_getl (s));
51 printf ("q: 0x%lx\n", stream_getq (s));
52
53 return 0;
54}