]>
Commit | Line | Data |
---|---|---|
46f4a4d2 | 1 | /* Simple stream test. |
896014f4 | 2 | * |
46f4a4d2 PJ |
3 | * Copyright (C) 2006 Sun Microsystems, Inc. |
4 | * | |
5 | * This file is part of Quagga. | |
6 | * | |
7 | * Quagga is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * Quagga is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
46f4a4d2 PJ |
20 | */ |
21 | ||
067fca86 | 22 | #include <zebra.h> |
23 | #include <stream.h> | |
24 | #include <thread.h> | |
25 | ||
6a697154 | 26 | static unsigned long long ham = 0xdeadbeefdeadbeef; |
067fca86 | 27 | struct thread_master *master; |
28 | ||
29 | static void | |
30 | print_stream (struct stream *s) | |
31 | { | |
32 | size_t getp = stream_get_getp (s); | |
33 | ||
6a697154 | 34 | printf ("endp: %zu, readable: %zu, writeable: %zu\n", |
067fca86 | 35 | stream_get_endp (s), |
36 | STREAM_READABLE (s), | |
37 | STREAM_WRITEABLE (s)); | |
38 | ||
39 | while (STREAM_READABLE (s)) | |
40 | { | |
41 | printf ("0x%x ", *stream_pnt (s)); | |
42 | stream_forward_getp (s, 1); | |
43 | } | |
44 | ||
45 | printf ("\n"); | |
46 | ||
47 | /* put getp back to where it was */ | |
48 | stream_set_getp (s, getp); | |
49 | } | |
50 | ||
51 | int | |
52 | main (void) | |
53 | { | |
54 | struct stream *s; | |
55 | ||
56 | s = stream_new (1024); | |
57 | ||
58 | stream_putc (s, ham); | |
59 | stream_putw (s, ham); | |
60 | stream_putl (s, ham); | |
61 | stream_putq (s, ham); | |
62 | ||
63 | print_stream (s); | |
64 | ||
65 | stream_resize (s, stream_get_endp (s)); | |
66 | ||
67 | print_stream (s); | |
68 | ||
69 | printf ("c: 0x%hhx\n", stream_getc (s)); | |
70 | printf ("w: 0x%hx\n", stream_getw (s)); | |
71 | printf ("l: 0x%x\n", stream_getl (s)); | |
eed831e0 | 72 | printf ("q: 0x%" PRIx64 "\n", stream_getq (s)); |
067fca86 | 73 | |
74 | return 0; | |
75 | } |