libmp/examples/client/list.c

29 lines
570 B
C
Raw Normal View History

#include "../../include/all.h"
#include "./common.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
lm_ctx_t ctx;
lm_pkg_t pkg;
int ret = EXIT_FAILURE;
lm_ctx_init(&ctx);
if (!lm_ctx_set_data(&ctx, DATA_DIR)) {
printf("failed to set data dir: %s (%d)\n", lm_strerror(), lm_error());
goto end;
}
printf("listing installed packages:\n");
while (lm_ctx_database_next(&ctx, &pkg))
printf("%s (%s)\n", pkg.name, pkg.version);
end:
lm_ctx_database_next_free(&ctx, &pkg);
return ret;
}