projects
/
platform
/
upstream
/
libsolv.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
make repodata_stringify return the result string
[platform/upstream/libsolv.git]
/
tools
/
updateinfoxml2solv.c
diff --git
a/tools/updateinfoxml2solv.c
b/tools/updateinfoxml2solv.c
index
6d88995
..
5432150
100644
(file)
--- a/
tools/updateinfoxml2solv.c
+++ b/
tools/updateinfoxml2solv.c
@@
-11,6
+11,7
@@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pool.h"
#include "repo.h"
#include "pool.h"
#include "repo.h"
@@
-18,59
+19,47
@@
#include "common_write.h"
static void
#include "common_write.h"
static void
-usage(
const char *err
)
+usage(
int status
)
{
{
- if (err)
- fprintf(stderr, "\n** Error:\n %s\n", err);
fprintf(stderr, "\nUsage:\n"
fprintf(stderr, "\nUsage:\n"
- "updateinfoxml2solv [-
a][-h][-k
][-n <attrname>]\n"
+ "updateinfoxml2solv [-
h
][-n <attrname>]\n"
" reads a 'updateinfo.xml' file from <stdin> and writes a .solv file to <stdout>\n"
" -h : print help & exit\n"
" reads a 'updateinfo.xml' file from <stdin> and writes a .solv file to <stdout>\n"
" -h : print help & exit\n"
- " -k : don't mix kinds (experimental!)\n"
" -n <name>: save attributes as <name>.attr\n"
);
" -n <name>: save attributes as <name>.attr\n"
);
-
exit(0
);
+
exit(status
);
}
int
main(int argc, char **argv)
{
}
int
main(int argc, char **argv)
{
- int flags = 0;
+ int
c,
flags = 0;
char *attrname = 0;
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
char *attrname = 0;
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
- argv++;
- argc--;
- while (argc--)
+ while ((c = getopt(argc, argv, "hn:")) >= 0)
{
{
- const char *s = argv[0];
- if (*s++ == '-')
- while (*s)
- switch (*s++)
- {
- case 'h': usage(NULL); break;
- case 'n':
- if (argc)
- {
- attrname = argv[1];
- argv++;
- argc--;
- }
- else
- usage("argument required for '-n'");
- break;
- case 'k':
- flags |= UPDATEINFOXML_KINDS_SEPARATELY;
- break;
- default : break;
- }
- argv++;
+ switch(c)
+ {
+ case 'h':
+ usage(0);
+ break;
+ case 'n':
+ attrname = optarg;
+ break;
+ default:
+ usage(1);
+ break;
+ }
}
}
-
- repo_add_updateinfoxml(repo, stdin, flags);
- tool_write(repo, 0, 0);
+ if (repo_add_updateinfoxml(repo, stdin, flags))
+ {
+ fprintf(stderr, "updateinfoxml2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
+ tool_write(repo, 0, attrname);
pool_free(pool);
exit(0);
}
pool_free(pool);
exit(0);
}