+ sayonara old_pid!
[jleu-quagga.git] / tests / test-stream.c
blob785ce5882779380b42c5296d8b94a2f1e36be570
1 #include <zebra.h>
2 #include <stream.h>
3 #include <thread.h>
5 static long int ham = 0xdeadbeefdeadbeef;
6 struct thread_master *master;
8 static void
9 print_stream (struct stream *s)
11 size_t getp = stream_get_getp (s);
13 printf ("endp: %ld, readable: %ld, writeable: %ld\n",
14 stream_get_endp (s),
15 STREAM_READABLE (s),
16 STREAM_WRITEABLE (s));
18 while (STREAM_READABLE (s))
20 printf ("0x%x ", *stream_pnt (s));
21 stream_forward_getp (s, 1);
24 printf ("\n");
26 /* put getp back to where it was */
27 stream_set_getp (s, getp);
30 int
31 main (void)
33 struct stream *s;
35 s = stream_new (1024);
37 stream_putc (s, ham);
38 stream_putw (s, ham);
39 stream_putl (s, ham);
40 stream_putq (s, ham);
42 print_stream (s);
44 stream_resize (s, stream_get_endp (s));
46 print_stream (s);
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));
53 return 0;