to follow SUSE tools conventions
[platform/upstream/libsolv.git] / tools / rpmdb2solv.c
1 /*
2  * rpmdb2solv
3  * 
4  */
5
6 #include <sys/types.h>
7 #include <limits.h>
8 #include <fcntl.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12
13 #include "pool.h"
14 #include "repo_rpmdb.h"
15 #include "repo_solv.h"
16 #include "repo_write.h"
17
18 int
19 main(int argc, char **argv)
20 {
21   Pool *pool = pool_create();
22   Repo *ref = NULL;
23   FILE *fp;
24
25   if (argc != 1)
26     {
27       Pool *refpool = pool;
28       if ((fp = fopen(argv[1], "r")) == NULL)
29         {
30           perror(argv[1]);
31           exit(0);
32         }
33       ref = pool_addrepo_solv(refpool, fp, "rpmdb");
34       fclose(fp);
35     }
36
37   Repo *repo = pool_addrepo_rpmdb(pool, ref);
38   if (ref)
39     {
40       if (ref->pool != pool)
41         pool_free(ref->pool);
42       else
43         pool_freerepo(pool, ref);
44       ref = NULL;
45     }
46
47   pool_writerepo(pool, repo, stdout);
48   pool_free(pool);
49
50   exit(0);
51 }