aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-08-26 13:03:32 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-08-26 13:03:32 +0000
commitb89ece30bebb5b9dd06e4e061537b6bf068566f2 (patch)
treec7f65b64fccfac2f0e7e134e5f7666a4fb1907d1 /src/wydawca.c
parent338c0d9c35c56f35c636df1c1da0852a466e731f (diff)
downloadwydawca-b89ece30bebb5b9dd06e4e061537b6bf068566f2.tar.gz
wydawca-b89ece30bebb5b9dd06e4e061537b6bf068566f2.tar.bz2
Implement project owner notifications.
* wydawca/wydawca.c (syslog_printer): Reduce the number of memory reallocations (make_stat_expansion): Update * wydawca/method.c: Implement a new framework: methods may return 2-dimensional arrays of strings. * wydawca/sql.c, wydawca/sql.h: Implement the new method framework. * wydawca/verify.c (expand_param): kw_expansion may provide expansion functions. An additional argument supplies user-defined data for expansions. (escape_kwexp): Extern (free_kwexp): Improve (get_project_name): New function (make_default_kwexp): New function (check_access_rights): Call get_project_name. Use make_default_kwexp to initialize expansions (verify_directive_file): Use make_default_kwexp to initialize expansions * wydawca/wydawca.h (NITEMS): New macro (enum access_method_type): New members: ncol, nrow (struct directory_pair): New members url,project_owner_method, user_data_method (struct file_info): Replace mtime, uid with struct stat sb (struct file_triplet): New members project, dpair, user_data (TRIPLET_UID): Take into account the changes to struct file_info (enum notification_event): New data type (notify_project_owner, notify_admin, notify): New functions (struct kw_expansion): New members static_p, expand and data. (escape_kwexp,make_default_kwexp): New proto (expand_param): Change signature (triplet_expand_param): New function (method_result): Change prototype (method_num_rows,method_num_cols): New functions * wydawca/config.c: New statements project-owner, user-data, admin-address, mail-user, user-message directory can take an optional argument specifying base URL for notification messages * wydawca/gpg.c (verify_directive_signature): Expand directives even if the signature does not match. Useful for notifications. Add notifications. * wydawca/process.c: Add notifications. * wydawca/directive.c: Add notifications * wydawca/wydawca.rc: Update * wydawca/mail.c, wydawca/mail.h: Implement project owner notifications * wydawca/triplet.c (triplet_expand_param): New function * lib/cfg.c (read_cont_line): Fix counting of input lines. git-svn-id: file:///svnroot/wydawca/trunk@297 6bb4bd81-ecc2-4fd4-a2d4-9571d19c0d33
Diffstat (limited to 'src/wydawca.c')
-rw-r--r--src/wydawca.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/wydawca.c b/src/wydawca.c
index 559970a..a51584b 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -63,21 +63,20 @@ usage ()
void
syslog_printer (int prio, const char *fmt, va_list ap)
{
- char *tmp = NULL;
-
if (syslog_include_prio)
{
+ static char *fmtbuf;
+ static size_t fmtsize;
const char *p = gsc_syslog_priority_to_str (prio);
- tmp = malloc (strlen (p) + 3 + strlen (fmt) + 1);
- if (!tmp)
- /* report memory shortage and continue anyway */
- syslog (LOG_ERR, "[%s] not enough memory for error reporting",
- gsc_syslog_priority_to_str (LOG_ERR));
- else
+ size_t size = strlen (p) + 3 + strlen (fmt) + 1;
+
+ if (size > fmtsize)
{
- sprintf (tmp, "[%s] %s", p, fmt);
- fmt = tmp;
+ fmtsize = size;
+ fmtbuf = x2realloc (fmtbuf, &fmtsize);
}
+ sprintf (fmtbuf, "[%s] %s", p, fmt);
+ fmt = fmtbuf;
}
#if HAVE_VSYSLOG
@@ -87,7 +86,6 @@ syslog_printer (int prio, const char *fmt, va_list ap)
vsnprintf (buf, sizeof buf, fmt, ap);
syslog (prio, "%s", buf);
#endif
- free (tmp);
}
void
@@ -193,15 +191,25 @@ stat_mask_p (unsigned long mask)
return 0;
}
+static char *
+stat_expand (struct kw_expansion *exp, void *data)
+{
+ char sbuf[INT_BUFSIZE_BOUND (wydawca_stat[0])];
+ exp->value = xstrdup (uinttostr (wydawca_stat[(int) exp->data], sbuf));
+ return exp->value;
+}
+
void
make_stat_expansion (struct kw_expansion *exp)
{
int i;
- char sbuf[INT_BUFSIZE_BOUND (wydawca_stat[0])];
for (i = 0; i < MAX_STAT; i++)
{
exp[i].kw = stat_kwname[i];
- exp[i].value = xstrdup (uinttostr (wydawca_stat[i], sbuf));
+ exp[i].value = NULL;
+ exp[i].static_p = 0;
+ exp[i].expand = stat_expand;
+ exp[i].data = (void*) i;
}
}

Return to:

Send suggestions and report system problems to the System administrator.