/ [paxutils] / paxutils / paxtest / paxtest.c
To checkout: cvs -d:pserver:anonymous@cvs.gnu.org.ua:/cvsmirror/paxutils co paxutils/paxtest/paxtest.c
Puszcza

Annotation of /paxutils/paxtest/paxtest.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Wed Jun 27 13:49:34 2007 UTC (14 years, 7 months ago) by gray
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +2 -2 lines
File MIME type: text/plain
Relicense under GPLv3

1 gray 1.1 /* This file is part of GNU paxutils
2    
3 gray 1.3 Copyright (C) 2005, 2007 Free Software Foundation, Inc.
4 gray 1.1
5     Written by Sergey Poznyakoff
6    
7     GNU paxutils 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 gray 1.3 Free Software Foundation; either version 3, or (at your option) any later
10 gray 1.1 version.
11    
12     GNU paxutils program 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 General
15     Public License for more details.
16    
17     You should have received a copy of the GNU General Public License along
18     with GNU paxutils; if not, write to the Free Software Foundation, Inc.,
19 eggert 1.2 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 gray 1.1
21     #ifdef HAVE_CONFIG_H
22     # include <config.h>
23     #endif
24    
25     #include <paxtest.h>
26    
27     #ifndef DEFAULT_BLOCKING_FACTOR
28     # define DEFAULT_BLOCKING_FACTOR 20
29     #endif
30    
31     void
32     xalloc_die (void)
33     {
34     error(1, ENOMEM, "Exiting");
35     }
36    
37     void
38     dump (unsigned char *buf, size_t size)
39     {
40     while (size)
41     {
42     int i;
43     for (i = 0; i < 16 && size; i++, size--, buf++)
44     printf ("%02X ", *buf);
45     printf ("\n");
46     }
47     }
48    
49    
50     void
51     read_and_dump (paxbuf_t pbuf)
52     {
53     union block block;
54     size_t size;
55     pax_io_status_t rc;
56    
57     while ((rc = paxbuf_read (pbuf, block.buffer, sizeof block, &size))
58     == pax_io_success)
59     {
60     dump (block.buffer, size);
61     }
62     if (rc == pax_io_failure)
63     error (1, 0, "Read error");
64     }
65    
66     int
67     main (int argc, char **argv)
68     {
69     paxbuf_t pbuf;
70     int rc;
71    
72     if (argc == 1)
73     error (1, 0, "Not enough arguments");
74    
75     tar_archive_create (&pbuf, argv[1], 0, PAXBUF_READ, DEFAULT_BLOCKING_FACTOR);
76    
77     rc = paxbuf_open (pbuf);
78     printf ("Open: %d\n", rc);
79     if (rc)
80     abort ();
81     read_and_dump (pbuf);
82     paxbuf_close (pbuf);
83     paxbuf_destroy (&pbuf);
84     return 0;
85     }

Send suggestions and bug reports to Sergey Poznyakoff
ViewVC Help
Powered by ViewVC 1.1.20