Merge branch 'master' of git@git.opensuse.org:projects/zypp/sat-solver
[platform/upstream/libsolv.git] / tools / repomdxml2solv.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 <limits.h>
10 #include <fcntl.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14
15 #include "pool.h"
16 #include "repo.h"
17 #include "repo_repomdxml.h"
18 #include "common_write.h"
19
20 static void
21 usage(const char *err)
22 {
23   if (err)
24     fprintf(stderr, "\n** Error:\n  %s\n", err);
25   fprintf(stderr, "\nUsage:\n"
26           "repomdxml2solv [-a][-h][-k][-n <attrname>]\n"
27           "  reads a 'repomd.xml' file from <stdin> and writes a .solv file to <stdout>\n"
28           "  -h : print help & exit\n"
29          );
30    exit(0);
31 }
32
33 int
34 main(int argc, char **argv)
35 {
36   int flags = 0;
37   
38   Pool *pool = pool_create();
39   Repo *repo = repo_create(pool, "<stdin>");
40
41   argv++;
42   argc--;
43   while (argc--)
44     {
45       const char *s = argv[0];
46       if (*s++ == '-')
47         while (*s)
48           switch (*s++)
49             {
50               case 'h': usage(NULL); break;
51               default : break;
52             }
53       argv++;
54     }
55
56   repo_add_repomdxml(repo, stdin, flags);
57   tool_write(repo, 0, 0);
58   pool_free(pool);
59   exit(0);
60 }