From b120452a12d0ffef68822f8a83f67ab89c606a08 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Tue, 26 Feb 2019 05:50:33 +0000 Subject: [PATCH] preliminary buffer note --- src/syncfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/syncfs.c b/src/syncfs.c index 9015fc1..ebd0672 100644 --- a/src/syncfs.c +++ b/src/syncfs.c @@ -22,6 +22,7 @@ #include "sqlite3.h" #include "zpm.h" +#include "lib/buffer.h" struct config { struct zpm *log; /* logging db will be attached as "log" */ @@ -37,6 +38,7 @@ struct config { unsigned long ops_update, ops_update_completed; unsigned long ops_install, ops_install_completed; int progress; /* type of progress meter */ + struct zpm_buffer note; }; struct nitem { @@ -58,7 +60,7 @@ struct nitem { }; static void usage() { - printf("usage: zpm $scriptname [-fncC] args ...\n"); + printf("usage: zpm syncfs ...\n"); } static void warn(char *fmt, ...) { @@ -70,6 +72,14 @@ static void warn(char *fmt, ...) { fprintf(stderr, "\n"); } +static void add_to_note(struct config *cf, char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + zpm_buffer_appendvf(&cf->note, fmt, ap); + va_end(ap); +} + static void pdots(int len, int ch, int was, int now, int total) { was = len * was / total; if (now > total) { @@ -1248,6 +1258,7 @@ static int install_files(void *f, int ncols, char **vals, char **cols) { if (update) { if (!exist) { /* warn, it should exist */ + add_to_note(conf, "%s missing, installing\n", nitem.dest); fprintf(stderr, "%s missing, installing\n", nitem.dest); return install(conf, &nitem, 3); } @@ -1586,6 +1597,7 @@ int main(int ac, char **av) { conf.overwrite = 0; conf.accept = 0; conf.acceptdir = 1; + zpm_buffer_init(&conf.note); if (geteuid() != 0) { conf.setuser = 0; @@ -1740,5 +1752,7 @@ int main(int ac, char **av) { zpm_close(&localdb); zpm_close(conf.src); + /* TODO add the note */ + zpm_buffer_free(&conf.note); return conf.errors ? 1 : 0; } -- 2.40.0