Imported Upstream version 0.7.0
[platform/upstream/libsolv.git] / tools / deltainfoxml2solv.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 #include <sys/types.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <unistd.h>
13
14 #include "pool.h"
15 #include "repo.h"
16 #include "repo_deltainfoxml.h"
17 #include "common_write.h"
18
19 static void
20 usage(int status)
21 {
22   fprintf(stderr, "\nUsage:\n"
23           "deltainfoxml2solv [-h]\n"
24           "  reads a 'deltainfo.xml' file from <stdin> and writes a .solv file to <stdout>\n"
25           "  -h : print help & exit\n"
26          );
27   exit(status);
28 }
29
30 int
31 main(int argc, char **argv)
32 {
33   int c, flags = 0;
34   
35   Pool *pool = pool_create();
36   Repo *repo = repo_create(pool, "<stdin>");
37
38   while ((c = getopt(argc, argv, "h")) >= 0)
39     {   
40       switch(c)
41         {
42         case 'h':
43           usage(0);
44           break;
45         default:
46           usage(1);
47           break;
48         }
49     }
50   if (repo_add_deltainfoxml(repo, stdin, flags))
51     {
52       fprintf(stderr, "deltainfoxml2solv: %s\n", pool_errstr(pool));
53       exit(1);
54     }
55   tool_write(repo, stdout);
56   pool_free(pool);
57   exit(0);
58 }