tools/mkset.c, tools/setcmp.c: command-line helpers
This commit is contained in:
parent
9fabff6e7a
commit
5e8118e213
@ -445,6 +445,9 @@ fi
|
||||
%rpmattr %_rpmlibdir/symlinks.*
|
||||
%rpmattr %_rpmlibdir/verify-elf
|
||||
%rpmattr %_rpmlibdir/*.awk
|
||||
# set-version helpers
|
||||
%rpmattr %_rpmlibdir/mkset
|
||||
%rpmattr %_rpmlibdir/setcmp
|
||||
|
||||
%_mandir/man?/gendiff.*
|
||||
%_man8dir/rpmbuild.*
|
||||
|
@ -28,7 +28,7 @@ noinst_PROGRAMS = \
|
||||
dump dumpdb rpmarchive rpmheader rpmlead rpmsignature
|
||||
|
||||
pkgbindir = @RPMCONFIGDIR@
|
||||
pkgbin_PROGRAMS = javadeps filesize dump_ld_config relative pdeath_execute
|
||||
pkgbin_PROGRAMS = javadeps filesize dump_ld_config relative pdeath_execute mkset setcmp
|
||||
bin_PROGRAMS = rpmvercmp rpmevrcmp
|
||||
|
||||
javadeps_SOURCES = javadeps.c
|
||||
@ -45,6 +45,9 @@ dump_ld_config_LDADD =
|
||||
pdeath_execute_SOURCES = pdeath_execute.c
|
||||
pdeath_execute_LDADD =
|
||||
|
||||
mkset_SOURCES = mkset.c
|
||||
setcmp_SOURCES = setcmp.c
|
||||
|
||||
rpmvercmp_SOURCES = rpmvercmp.c
|
||||
|
||||
rpmevrcmp_SOURCES = rpmevrcmp.c
|
||||
|
30
tools/mkset.c
Normal file
30
tools/mkset.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "set.h"
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
assert(argc == 2);
|
||||
int bpp = atoi(argv[1]);
|
||||
assert(bpp >= 10);
|
||||
assert(bpp <= 32);
|
||||
struct set *set = set_new();
|
||||
char *line = NULL;
|
||||
size_t alloc_size = 0;
|
||||
ssize_t len;
|
||||
int added = 0;
|
||||
while ((len = getline(&line, &alloc_size, stdin)) >= 0) {
|
||||
if (len > 0 && line[len-1] == '\n')
|
||||
line[--len] = '\0';
|
||||
if (len == 0)
|
||||
continue;
|
||||
set_add(set, line);
|
||||
added++;
|
||||
}
|
||||
assert(added > 0);
|
||||
const char *str = set_fini(set, bpp);
|
||||
assert(str);
|
||||
printf("set:%s\n", str);
|
||||
return 0;
|
||||
}
|
27
tools/setcmp.c
Normal file
27
tools/setcmp.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "set.h"
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
assert(argc == 3);
|
||||
int cmp = rpmsetcmp(argv[1], argv[2]);
|
||||
switch (cmp) {
|
||||
case 1:
|
||||
case 0:
|
||||
case -1:
|
||||
case -2:
|
||||
printf("%d\n", cmp);
|
||||
return 0;
|
||||
case -3:
|
||||
fprintf(stderr, "%s: set1 error\n", __FILE__);
|
||||
break;
|
||||
case -4:
|
||||
fprintf(stderr, "%s: set2 error\n", __FILE__);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: unknown error\n", __FILE__);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user