Annotation of embedaddon/quagga/tests/test-stream.c, revision 1.1.1.1

1.1       misho       1: #include <zebra.h>
                      2: #include <stream.h>
                      3: #include <thread.h>
                      4: 
                      5: static long int ham = 0xdeadbeefdeadbeef;
                      6: struct thread_master *master;
                      7: 
                      8: static void
                      9: print_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: 
                     30: int
                     31: main (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: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>