1 #define _POSIX_C_SOURCE 200809L
12 fprintf(stderr, "zpm-note [-I] [-s <status> ...] [-S <status>] [package]\n");
15 void print_note(struct zpm_note *n) {
16 printf("%" PRId64 " %s %s\n", n->id, n->pkgid ? n->pkgid : "-", n->note);
19 int main(int ac, char **av){
27 struct zpm_note n = { 0 };
32 dbfile = getenv("ZPMDB");
34 dbfile = "/var/lib/zpm/local.db";
44 * -m note message, otherwise EDITOR/vi to edit a text file
45 * -e echo note after creating
46 * zpm note -p pkgid -P path -H hash -m 'foo'
51 int list = 0, delete = 0, ack = 0;
52 while ((opt = getopt(ac, av, "f:p:P:H:m:n:lDAae")) != -1) {
54 case 'f': dbfile = optarg; break;
55 case 'p': n.pkgid = optarg; break;
56 case 'P': n.path = optarg; break;
57 case 'H': n.hash = optarg; break;
58 case 'm': n.note = optarg; break;
59 case 'n': n.id = strtoll(optarg, NULL, 10); break;
60 case 'l': list = 1; break;
61 case 'e': echo = 1; break;
62 case 'D': delete = 1; break;
63 case 'A': ack = 1; break;
64 case 'a': select = 3; break;
74 fprintf(stderr, "must specify db\n");
78 /* given a package name, get the packages */
79 /* no package name, get all */
81 if (zpm_open(&pkg, dbfile)) {
83 while (zpm_note(&pkg, &n, select)) {
88 n.id = zpm_note_add(&pkg, n.pkgid, n.path, n.hash, "%s", n.note);
93 printf("%" PRId64 "\n", n.id);
96 fprintf(stderr, "unable to create note\n");
100 zpm_note_del(&pkg, n.id);
102 zpm_note_ack(&pkg, n.id);
105 fprintf(stderr, "unable to open %s\n", dbfile);
112 return fail ? EXIT_FAILURE : EXIT_SUCCESS;