2 This file is part of the NoBug debugging library.
5 2008, Simeon Voelkel <simeon_voelkel@arcor.de>
6 2008, 2009 Christian Thaeter <ct@pipapo.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, contact Christian Thaeter <ct@pipapo.org>.
24 #include <sys/types.h>
29 #define NOBUG_LIBNOBUG_C
33 //rbdump HEAD- Dumping Persistent Ringbuffers; rbdump; dumping persistent ringbuffers
35 //rbdump NoBug installs the `nobug_rbdump` tool for dumping the content of a persistent
36 //rbdump ringbuffer. It is invoked with the filename of the ringbuffer, the content is then
37 //rbdump printed to stdout.
41 main(int argc
, char* argv
[])
47 printf( "usage: %s file\n\n"
48 " nobug ringbuffer dump\n\n"
50 " 2008, Simeon Voelkel <simeon_voelkel@arcor.de>\n\n"
51 " This is free software. You may redistribute copies of it under the terms of\n"
52 " the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.\n"
53 " There is NO WARRANTY, to the extent permitted by law.\n\n",
60 if (stat(argv
[1], &filestat
))
62 fprintf (stderr
, "Can't stat file %s\n", argv
[1]);
66 struct nobug_ringbuffer rb
;
68 /* using the file size for the guard too is quite excessive but the only way to be 100% sure any ringbuffer can be read */
69 if (!nobug_ringbuffer_init (&rb
, filestat
.st_size
, filestat
.st_size
, argv
[1], NOBUG_RINGBUFFER_KEEP
|NOBUG_RINGBUFFER_APPEND
))
71 fprintf (stderr
, "Error opening ringbuffer %s\n", argv
[1]);
75 nobug_ringbuffer_save (&rb
, stdout
);