diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-07-14 23:35:28 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-07-14 23:35:28 +0000 |
commit | 20e08ebe561d4ac2d1e9e26fcf74162b93f8555e (patch) | |
tree | cbdf8096c494647b69aa207e35a8809743625ded | |
parent | 4a3ee4cee740ac1cda420bef0bb33662688e2f74 (diff) | |
download | wydawca-20e08ebe561d4ac2d1e9e26fcf74162b93f8555e.tar.gz wydawca-20e08ebe561d4ac2d1e9e26fcf74162b93f8555e.tar.bz2 |
* src/wydawca.h (register_message_template): New prototype.
* src/verify.c (fill_project_name): Fix return value.
* src/config.c (_cfg_raw_read): Remove unused variables.
* src/directive.c (directive_version_in_range_p): Version is unsigned.
* src/mail.c (do_notify): Remove unused variable.
* src/diskio.c (copy_file): Fall back to user-space copying if sendile
fails with EINVAL. Always remove destination file on failure.
* src/triplet.c (expand_triplet_upload): Initialize exp->value.
git-svn-id: file:///svnroot/wydawca/trunk@323 6bb4bd81-ecc2-4fd4-a2d4-9571d19c0d33
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | src/config.c | 4 | ||||
-rw-r--r-- | src/directive.c | 4 | ||||
-rw-r--r-- | src/diskio.c | 135 | ||||
-rw-r--r-- | src/mail.c | 4 | ||||
-rw-r--r-- | src/triplet.c | 3 | ||||
-rw-r--r-- | src/verify.c | 4 | ||||
-rw-r--r-- | src/wydawca.h | 5 |
8 files changed, 89 insertions, 81 deletions
@@ -1,3 +1,14 @@ +2008-07-15 Sergey Poznyakoff <gray@gnu.org.ua> + + * src/wydawca.h (register_message_template): New prototype. + * src/verify.c (fill_project_name): Fix return value. + * src/config.c (_cfg_raw_read): Remove unused variables. + * src/directive.c (directive_version_in_range_p): Version is unsigned. + * src/mail.c (do_notify): Remove unused variable. + * src/diskio.c (copy_file): Fall back to user-space copying if sendile + fails with EINVAL. Always remove destination file on failure. + * src/triplet.c (expand_triplet_upload): Initialize exp->value. + 2007-11-19 Sergey Poznyakoff <gray@gnu.org.ua> * configure.ac: Use AM_GNU_MAILUTILS diff --git a/src/config.c b/src/config.c index c21c14b..4203bbb 100644 --- a/src/config.c +++ b/src/config.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2008 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 @@ -916,8 +916,6 @@ _cfg_recursive_raw_read (gsc_config_file_t *file, struct obstack *stk, static int _cfg_raw_read (gsc_config_file_t *file, char *val, struct obstack *stk) { - size_t size = 0; - char *buf = NULL; char *word = val ? get_word (&val) : ""; size_t wlen; size_t start_line = file->line; diff --git a/src/directive.c b/src/directive.c index 924582c..eeb82c1 100644 --- a/src/directive.c +++ b/src/directive.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2008 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 @@ -169,7 +169,7 @@ directive_version_in_range_p (struct file_triplet *trp, unsigned from, unsigned to) { const char *val; - int version; + unsigned version; if (directive_get_value (trp, "version", &val)) { diff --git a/src/diskio.c b/src/diskio.c index bc12971..832b329 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2008 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 @@ -173,77 +173,76 @@ copy_file (const char *file, const char *dst_file, uid_t uid, gid_t gid) } #ifdef USE_SENDFILE - { - off_t offset = 0; - ssize_t count; + { + off_t offset = 0; + ssize_t count; - count = sendfile (out_fd, in_fd, &offset, st.st_size); - if (count == -1) - { - rc = 1; - logmsg (LOG_ERR, "copying %s to %s failed: %s", - file, dst_file, strerror (errno)); - } - else if (count < st.st_size) - { - rc = 1; - logmsg (LOG_ERR, "copying %s to %s failed: short write", - file, dst_file); - unlink (dst_file); - } - else - rc = 0; - } -#else - { - char *buf = NULL; - size_t bufsize; - size_t fsize = st.st_size; - - for (bufsize = fsize; bufsize > 0 && (buf = malloc (bufsize)) == NULL; - bufsize /= 2) - ; - if (bufsize == 0) - xalloc_die (); - - rc = 0; - while (fsize > 0) - { - size_t rest; - size_t rdbytes; - - rest = fsize > bufsize ? bufsize : fsize; - rdbytes = read (in_fd, buf, rest); - if (rdbytes == -1) - { - logmsg (LOG_ERR, "unexpected error reading %s: %s", - file, strerror (errno)); - unlink (dst_file); - rc = 1; - break; - } - rest = write (out_fd, buf, rdbytes); - if (rest == -1) - { - logmsg (LOG_ERR, "unexpected error writing to %s: %s", - dst_file, strerror (errno)); - unlink (dst_file); - rc = 1; - break; - } - else if (rest != rdbytes) - { - logmsg (LOG_ERR, "short write on %s", dst_file); - unlink (dst_file); - rc = 1; - } - fsize -= rdbytes; - } - free (buf); - } + count = sendfile (out_fd, in_fd, &offset, st.st_size); + if (count == -1) + { + rc = 1; + logmsg (LOG_ERR, "copying %s to %s failed: %s", + file, dst_file, strerror (errno)); + } + else if (count < st.st_size) + { + rc = 1; + logmsg (LOG_ERR, "copying %s to %s failed: short write", + file, dst_file); + } + else + rc = 0; + } + if (rc && errno == EINVAL) #endif + { + char *buf = NULL; + size_t bufsize; + size_t fsize = st.st_size; + + for (bufsize = fsize; bufsize > 0 && (buf = malloc (bufsize)) == NULL; + bufsize /= 2) + ; + if (bufsize == 0) + xalloc_die (); + + rc = 0; + while (fsize > 0) + { + size_t rest; + size_t rdbytes; + + rest = fsize > bufsize ? bufsize : fsize; + rdbytes = read (in_fd, buf, rest); + if (rdbytes == -1) + { + logmsg (LOG_ERR, "unexpected error reading %s: %s", + file, strerror (errno)); + rc = 1; + break; + } + rest = write (out_fd, buf, rdbytes); + if (rest == -1) + { + logmsg (LOG_ERR, "unexpected error writing to %s: %s", + dst_file, strerror (errno)); + rc = 1; + break; + } + else if (rest != rdbytes) + { + logmsg (LOG_ERR, "short write on %s", dst_file); + rc = 1; + } + fsize -= rdbytes; + } + free (buf); + } + close (in_fd); close (out_fd); + if (rc) + unlink (dst_file); return rc; } @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2008 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 @@ -268,10 +268,8 @@ void do_notify (struct file_triplet *trp, enum notification_event ev, struct notification *ntf) { - int rc; mu_address_t rcpt = NULL; char *errp; - switch (ntf->tgt) { case notify_admin: diff --git a/src/triplet.c b/src/triplet.c index e7bab3e..de8c8d6 100644 --- a/src/triplet.c +++ b/src/triplet.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2008 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 @@ -423,6 +423,7 @@ expand_triplet_upload (struct kw_expansion *exp, void *data) size += strlen (buf[file_signature]) + 1; exp->value = xmalloc (size + 1); + exp->value[0] = 0; if (buf[file_dist]) { strcat(exp->value, buf[file_dist]); diff --git a/src/verify.c b/src/verify.c index 2290fce..a97fbea 100644 --- a/src/verify.c +++ b/src/verify.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2008 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 @@ -250,7 +250,7 @@ fill_project_name (struct file_triplet *trp) char *p; if (trp->project) - return; + return 1; if (directive_get_value (trp, "directory", &directory)) { logmsg (LOG_ERR, "%s: missing `directory' directive", diff --git a/src/wydawca.h b/src/wydawca.h index 39d1073..d623e53 100644 --- a/src/wydawca.h +++ b/src/wydawca.h @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2008 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -209,7 +209,8 @@ struct message_template *find_message_template (char *name); void register_notification (enum notification_event ev, enum notification_target tgt, struct message_template *msg); - +void register_message_template (char *name, char *text); + void notify (struct file_triplet *, enum notification_event); const char *notification_event_str (enum notification_event evt); |