aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-23 23:15:18 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-23 23:15:50 +0300
commit662f6eddf08edc3f2ba30ac58853cb0de86b30a3 (patch)
treee7a0369e84690d3dd5ec8c5877c68d8dd730173e /src
parent8234484dba123ad8001657def8fb57133f9610bf (diff)
downloadwydawca-662f6eddf08edc3f2ba30ac58853cb0de86b30a3.tar.gz
wydawca-662f6eddf08edc3f2ba30ac58853cb0de86b30a3.tar.bz2
Remove a left-over global variable
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/directive.c3
-rw-r--r--src/report.c53
-rw-r--r--src/triplet.c30
-rw-r--r--src/vtab.c19
-rw-r--r--src/wydawca.h11
6 files changed, 46 insertions, 71 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index f7a2201..73e3c1c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,7 +48,6 @@ wydawca_SOURCES=\
vtab.c\
null.c\
timer.c\
- report.c\
$(WATCHER_C)
BUILT_SOURCES=cmdline.h
diff --git a/src/directive.c b/src/directive.c
index 5067f00..68450df 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -598,7 +598,6 @@ process_directives(struct wy_triplet *trp)
increase_stat_counter(WY_STAT_COMPLETE_TRIPLETS);
timer_start(WY_TIMER_TRIPLET);
- report_init();
for (n = directive_first(trp, &key, &val); n;
n = directive_next(trp, n, &key, &val)) {
enum directive d = find_directive(key);
@@ -669,7 +668,7 @@ process_directives(struct wy_triplet *trp)
}
increase_stat_counter(WY_STAT_TRIPLET_SUCCESS);
- report_finish();
+ triplet_report_finish(trp);
timer_stop(WY_TIMER_TRIPLET);
notify(spool->notification, trp, wy_ev_success);
return 0;
diff --git a/src/report.c b/src/report.c
deleted file mode 100644
index 5cf8e46..0000000
--- a/src/report.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* wydawca - automatic release submission daemon
- Copyright (C) 2009-2013, 2017, 2019-2020 Sergey Poznyakoff
-
- Wydawca is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 3 of the License, or (at your
- option) any later version.
-
- Wydawca is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with wydawca. If not, see <http://www.gnu.org/licenses/>. */
-
-#include "wydawca.h"
-
-static struct grecs_txtacc *report_acc;
-char *report_string;
-
-void
-report_init()
-{
- if (!report_acc)
- report_acc = grecs_txtacc_create();
- else
- grecs_txtacc_free_string(report_acc, report_string);
-}
-
-void
-report_add(const char *fmt, ...)
-{
- va_list ap;
- char *str = NULL;
- size_t size = 0;
-
- va_start(ap, fmt);
- grecs_vasprintf(&str, &size, fmt, ap);
- va_end(ap);
- if (str) {
- grecs_txtacc_grow_string(report_acc, str);
- grecs_txtacc_grow_char(report_acc, '\n');
- }
- free(str);
-}
-
-void
-report_finish()
-{
- grecs_txtacc_grow_char(report_acc, 0);
- report_string = grecs_txtacc_finish(report_acc, 0);
-}
diff --git a/src/triplet.c b/src/triplet.c
index 980c906..cf6ba36 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -227,6 +227,7 @@ hash_triplet_free(void *data)
free(tp->blurb);
free(tp->tmp);
grecs_txtacc_free(tp->acc);
+ grecs_txtacc_free(tp->report_acc);
/* Free uploader and admin lists */
wy_userlist_free(tp->uploader_list);
@@ -279,6 +280,7 @@ register_file(struct file_info *finfo, struct spool *spool)
ret->directive_verified = DIRECTIVE_UNCHECKED;
ret->spool = spool;
ret->acc = grecs_txtacc_create();
+ ret->report_acc = grecs_txtacc_create();
} else if (ret->list)
triplet_list_unlink(ret->list, ret);
triplet_list_ordered_insert(&triplet_pending_list, ret);
@@ -1000,7 +1002,7 @@ expand_email_user(char **ret, struct wy_triplet *trp)
static int
expand_report(char **ret, struct wy_triplet *trp)
{
- return wy_expand_copy(ret, report_string);
+ return wy_expand_copy(ret, trp->report_str);
}
DECL_TRIPLET_EXP(check_diagn, check_diag);
@@ -1302,3 +1304,29 @@ wy_triplet_project(struct wy_triplet *trp)
{
return trp->project;
}
+
+void
+triplet_report_add(struct wy_triplet *trp, const char *fmt, ...)
+{
+ va_list ap;
+ char *str = NULL;
+ size_t size = 0;
+
+ va_start(ap, fmt);
+ grecs_vasprintf(&str, &size, fmt, ap);
+ va_end(ap);
+ if (str) {
+ grecs_txtacc_grow_string(trp->report_acc, str);
+ grecs_txtacc_grow_char(trp->report_acc, '\n');
+ }
+ free(str);
+}
+
+void
+triplet_report_finish(struct wy_triplet *trp)
+{
+ if (!trp->report_str) {
+ grecs_txtacc_grow_char(trp->report_acc, 0);
+ trp->report_str = grecs_txtacc_finish(trp->report_acc, 0);
+ }
+}
diff --git a/src/vtab.c b/src/vtab.c
index d008f78..447ab21 100644
--- a/src/vtab.c
+++ b/src/vtab.c
@@ -127,8 +127,8 @@ int
move_file(struct wy_triplet *trp, enum file_type file_id)
{
int rc = trp->spool->vtab.move_file(trp, file_id);
- report_add("Move %s to %s: %s", trp->file[file_id].name,
- trp->relative_dir, rc == 0 ? "OK" : "FAILED");
+ triplet_report_add(trp, "Move %s to %s: %s", trp->file[file_id].name,
+ trp->relative_dir, rc == 0 ? "OK" : "FAILED");
return rc;
}
@@ -136,8 +136,9 @@ int
archive_file(struct wy_triplet *trp, const char *file_name)
{
int rc = trp->spool->vtab.archive_file(trp, file_name);
- report_add("Archive and remove %s/%s: %s",
- trp->relative_dir, file_name, rc == 0 ? "OK" : "FAILED");
+ triplet_report_add(trp, "Archive and remove %s/%s: %s",
+ trp->relative_dir, file_name,
+ rc == 0 ? "OK" : "FAILED");
return rc;
}
@@ -146,8 +147,9 @@ symlink_file(struct wy_triplet *trp,
const char *wanted_src, const char *wanted_dst)
{
int rc = trp->spool->vtab.symlink_file(trp, wanted_src, wanted_dst);
- report_add("Symlink %s to %s in %s/: %s", wanted_src, wanted_dst,
- trp->relative_dir, rc == 0 ? "OK" : "FAILED");
+ triplet_report_add(trp, "Symlink %s to %s in %s/: %s",
+ wanted_src, wanted_dst,
+ trp->relative_dir, rc == 0 ? "OK" : "FAILED");
return rc;
}
@@ -155,7 +157,8 @@ int
rmsymlink_file(struct wy_triplet *trp, const char *file_name)
{
int rc = trp->spool->vtab.rmsymlink_file(trp, file_name);
- report_add("Remove symlink %s/%s: %s", trp->relative_dir, file_name,
- rc == 0 ? "OK" : "FAILED");
+ triplet_report_add(trp, "Remove symlink %s/%s: %s",
+ trp->relative_dir, file_name,
+ rc == 0 ? "OK" : "FAILED");
return rc;
}
diff --git a/src/wydawca.h b/src/wydawca.h
index b3ece49..42329b8 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -192,6 +192,8 @@ struct wy_triplet {
char *tmp; /* Temporary storage */
size_t tmpsize; /* Size of memory allocated in tmp */
struct grecs_txtacc *acc; /* Text accumulator for string allocation */
+ struct grecs_txtacc *report_acc;/* Text accumulator for reports */
+ char *report_str; /* Final report string */
/* Triplets are joined in a doubly-linked list in chronological order.
The prev member points to a triplet older than this one, and next
points to a triplet newer than it: */
@@ -421,6 +423,9 @@ void triplet_enqueue(struct wy_triplet *trp);
void triplet_commit(struct wy_triplet *trp);
void triplet_gpgme_ctx_release(struct wy_triplet *trp);
+void triplet_report_add(struct wy_triplet *trp, const char *fmt, ...);
+void triplet_report_finish(struct wy_triplet *trp);
+
/* General-purpose dictionary support */
struct dictionary *dictionary_new(enum dictionary_id id,
enum dictionary_type type);
@@ -538,12 +543,6 @@ double timer_get_user(wydawca_timer_t t);
double timer_get_system(wydawca_timer_t t);
char *timer_format_time(double t);
int spool_timer_id(char *name);
-
-
-void report_init(void);
-void report_add(const char *fmt, ...);
-void report_finish(void);
-extern char *report_string;
/* profile.c */
void pidfile_check(void);

Return to:

Send suggestions and report system problems to the System administrator.