summaryrefslogtreecommitdiff
path: root/libstore/storecat.c
blob: 895b44e86ddbd2330262d7d02b83e80625ad8438 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Test program for libstore -- outputs the concatenation of stores  */ 

#include <argp.h>
#include <error.h>
#include <unistd.h>

#include "store.h"

int
main (int argc, char **argv)
{
  error_t err;
  struct store *s;
  char buf[4096], *data = buf;
  size_t data_len = sizeof (buf);
  struct store_parsed *parsed;

  argp_parse (&store_argp, argc, argv, 0, 0, &parsed);
  err = store_parsed_open (parsed, STORE_READONLY, 0, &s);
  if (err)
    error (4, err, "store_parsed_open");

  err = store_read (s, 0, s->size, &data, &data_len);
  if (err)
    error (5, err, s->name ? "%s" : "<store>", s->name);

  if (write (1, data, data_len) < 0)
    error (6, errno, "stdout");

  exit (0);
}