add "-h" for help
[platform/upstream/libsolv.git] / tools / mergesolv.c
1 /*
2  * Copyright (c) 2007, Novell Inc.
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 /*
9  * mergesolv
10  * 
11  */
12
13 #include <sys/types.h>
14 #include <limits.h>
15 #include <fcntl.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <assert.h>
20
21 #include "pool.h"
22 #include "repo_solv.h"
23 #include "common_write.h"
24
25 static void
26 usage()
27 {
28   fprintf(stderr, "\nUsage:\n"
29           "mergesolv [file] [file] [...]\n"
30           "  merges multiple solv files into one and writes it to stdout\n"
31           );
32   exit(0);
33 }
34
35
36 int
37 main(int argc, char **argv)
38 {
39   Pool *pool = pool_create();
40   Repo *repo;
41
42   repo = repo_create(pool, "");
43   while (argc-- > 1)
44     {
45       FILE *fp;
46       argv++;
47       if (!strcmp(*argv,"-h"))
48         usage();
49       if ((fp = fopen(*argv, "r")) == NULL)
50         {
51           perror(argv[1]);
52           exit(0);
53         }
54       repo_add_solv(repo, fp);
55       fclose(fp);
56     }
57
58   tool_write(repo, 0, 0);
59   pool_free(pool);
60
61   return 0;
62 }